Beispiel #1
0
            public byte[] ReadBytes(AcpiObject.RegionSpace regionSpace, ulong offset, ulong length)
            {
                byte[] result = new byte[length];

                switch (regionSpace)
                {
                case AcpiObject.RegionSpace.SystemMemory:
                    IoMemory region = IoMemory.MapPhysicalMemory(offset, length, true /*readable*/, false /*writable*/);
                    for (ulong i = 0; i < length; i++)
                    {
                        result[i] = region.Read8((int)i);
                    }
                    break;

                default:
                    throw new Exception("ReadBytes() only supported for SystemMemory regions");
                }

#if DUMP_RAW_READ_WRITES
                DebugStub.Write("ACPI read: space: " + regionSpace + ", offset: " + offset + ", bytes: " + length + ", result: {");
                for (int i = 0; i < result.Length; i++)
                {
                    DebugStub.Write(result[i].ToString("X"));
                    if (i < result.Length - 1)
                    {
                        DebugStub.Write(",");
                    }
                }
                DebugStub.WriteLine("}");
#endif

                return(result);
            }
Beispiel #2
0
        public override void Write(AcpiObject value)
        {
#if SINGULARITY_KERNEL
            DebugStub.Write(value.ToString());
#else
            Console.Write(value.ToString());
#endif
        }
Beispiel #3
0
        public SortedList Enumerate()
        {
            SortedList found = new SortedList();

            int node = 0x100;

            foreach (AcpiDevice !deviceInfo in deviceInfoEntries)
            {
                IoConfig !ioConfig = ResourceDescriptorsToIoConfig(deviceInfo.DeviceId,
                                                                   (!)deviceInfo.ResourceDescriptors);

                DebugStub.Write("Detected ACPI device ");
                DebugStub.WriteLine(ioConfig.Id);
                System.Text.StringBuilder descriptionBuilder = new System.Text.StringBuilder();
                ioConfig.DumpRanges(descriptionBuilder);
                DebugStub.WriteLine(descriptionBuilder.ToString());

                found.Add(String.Format("/{0,3:x3}", node++), ioConfig);
            }

            return(found);
        }
Beispiel #4
0
        internal static IDevice CreateDevice(IoConfig config, string name)
        {
            PnpConfig pnpConfig = config as PnpConfig;

            if (pnpConfig == null)
            {
                return(null);
            }

            IoMemoryRange imr = config.DynamicRanges[0] as IoMemoryRange;

            if (imr == null)
            {
                return(null);
            }

            int imrBytes = (int)imr.Length.ToUInt32();

            if (imrBytes < Hpet.MinRegionBytes)
            {
                DebugStub.Write(
                    "HPET failed as region too small ({0} bytes).\n",
                    __arglist(imrBytes));
                return(null);
            }

            Hpet hpet = new Hpet(pnpConfig);

            if (hpet.MainCounterWorks())
            {
                HalDevicesApic.SwitchToHpetClock(hpet);
            }
            else
            {
                DebugStub.Print("WARNING: HPET main counter does not work!\n");
            }

            return(hpet);
        }
Beispiel #5
0
        public override bool Register()
        {
            // Check assumptions for remainder of method.
            if ((base.Register() == false) || (HostController == null))
            {  // BUGBUG AM: base.Register() should check if HostController is null, not all callers
                DebugStub.WriteLine("TcpSessionEventsSource: Improper Registration Environment.");
                return(false);
            }

            // TcpSessionStateChange event registration
            if (HostController.RegisterEvent("TcpSessionStateChange",
                                             "TCP: Ses{0,3} ({1}) State Change to {2}.",
                                             ref stateChangeTypeHandle))
            { // BUGBUG AM: Aliases possible with different structs.  Should pass in Struct and Reflect to get name of runtime type, field names, ...
                if ((!HostController.RegisterEventField(stateChangeTypeHandle, "SessionId", 0, DataType.__uint16)) ||
                    (!HostController.RegisterEventField(stateChangeTypeHandle, "FromState", 0, DataType.__uint8)) ||
                    (!HostController.RegisterEventField(stateChangeTypeHandle, "ToState", 0, DataType.__uint8)))
                {
                    stateChangeTypeHandle = 0;
                }
            }

            // TcpSessionReceivedPacket event registration
            if (HostController.RegisterEvent("TcpSessionReceivedPacket",
                                             "TCP: Ses{0,3} ({1}) Packet ({2}) Len{3,4} received",
                                             ref receivedPacketTypeHandle))
            {
                if ((!HostController.RegisterEventField(receivedPacketTypeHandle, "SessionId", 0, DataType.__uint16)) ||
                    (!HostController.RegisterEventField(receivedPacketTypeHandle, "SessionState", 0, DataType.__uint8)) ||
                    (!HostController.RegisterEventField(receivedPacketTypeHandle, "PacketFlags", 0, DataType.__uint8)) ||
                    (!HostController.RegisterEventField(receivedPacketTypeHandle, "PacketLength", 0, DataType.__uint16)))
                {
                    receivedPacketTypeHandle = 0;
                }
            }

            // TcpSessionReceivedPacket event registration
            if (HostController.RegisterEvent("TcpSessionSendingPacket",
                                             "TCP: Ses{0,3} ({1}) Packet ({2}) Len{3,4} being sent",
                                             ref sendingPacketTypeHandle))
            {
                if ((!HostController.RegisterEventField(sendingPacketTypeHandle, "SessionId", 0, DataType.__uint16)) ||
                    (!HostController.RegisterEventField(sendingPacketTypeHandle, "SessionState", 0, DataType.__uint8)) ||
                    (!HostController.RegisterEventField(sendingPacketTypeHandle, "PacketFlags", 0, DataType.__uint8)) ||
                    (!HostController.RegisterEventField(sendingPacketTypeHandle, "PacketLength", 0, DataType.__uint16)))
                {
                    sendingPacketTypeHandle = 0;
                }
            }

            // TcpSessionTimeout event registration
            if (HostController.RegisterEvent("TcpSessionTimeout",
                                             "TCP: Ses{0,3} ({1}) Timeout of type '{2}' occurred",
                                             ref timeoutTypeHandle))
            {
                if ((!HostController.RegisterEventField(timeoutTypeHandle, "SessionId", 0, DataType.__uint16)) ||
                    (!HostController.RegisterEventField(timeoutTypeHandle, "SessionState", 0, DataType.__uint8)) ||
                    (!HostController.RegisterEventField(timeoutTypeHandle, "TimeoutType", 0, DataType.__uint8)))
                {
                    timeoutTypeHandle = 0;
                }
            }

            // TcpSessionContractCall event registration
            if (HostController.RegisterEvent("TcpSessionContractCall",
                                             "TCP: Ses{0,3} ({1}) Contract EP '{2}' called.",
                                             ref contractCallTypeHandle))
            {
                if ((!HostController.RegisterEventField(contractCallTypeHandle, "SessionId", 0, DataType.__uint16)) ||
                    (!HostController.RegisterEventField(contractCallTypeHandle, "SessionState", 0, DataType.__uint8)) ||
                    (!HostController.RegisterEventField(contractCallTypeHandle, "ContractCall", 0, DataType.__uint8)))
                {
                    contractCallTypeHandle = 0;
                }
            }

            // Make sure all handles were either there before or were created here.
            if ((stateChangeTypeHandle == 0) || (contractCallTypeHandle == 0) ||
                (sendingPacketTypeHandle == 0) || (sendingPacketTypeHandle == 0))
            {
                // Construct an error message
                StringBuilder errorString = new StringBuilder();
                String        conjunction = "TcpSessionEventsSource: Registration Failed for ";

                // State Change
                if (stateChangeTypeHandle == 0)
                {
                    errorString.Append(conjunction);
                    errorString.Append("StateChangeEventType");
                    conjunction = ", ";
                }

                // Received Packet
                if (receivedPacketTypeHandle == 0)
                {
                    errorString.Append(conjunction);
                    errorString.Append("ReceivedPacketEventType");
                    conjunction = ", ";
                }

                // Sending Packet
                if (sendingPacketTypeHandle == 0)
                {
                    errorString.Append(conjunction);
                    errorString.Append("SendingPacketEventType");
                    conjunction = ", ";
                }

                // Timeout
                if (timeoutTypeHandle == 0)
                {
                    errorString.Append(conjunction);
                    errorString.Append("TimeoutEventType");
                    conjunction = ", ";
                }

                // Contract Call
                if (contractCallTypeHandle == 0)
                {
                    errorString.Append(conjunction);
                    errorString.Append("ContractCallEventType");
                    conjunction = ", ";
                }

                // Complete the error message and write it to the debugger.
                errorString.Append(".");
                errorString.Append(Environment.NewLine);
                DebugStub.Write(errorString.ToString());

                // Report the failure.
                return(false);
            }

            // If this is reached then everything worked so report success.
            return(true);
        }
Beispiel #6
0
 internal static void Write(string message)
 {
     DebugStub.Write(message);
 }
Beispiel #7
0
 internal static void Write(string format, __arglist)
 {
     DebugStub.Write(format, new ArgIterator(__arglist));
 }