示例#1
0
        /// <summary>
        /// Initialize serialport
        /// </summary>
        public static unsafe void Init()
        {
            comports = new Comport[4];

            comports[0]      = new Comport();
            comports[0].Name = "COM1";
            comports[1]      = new Comport();
            comports[1].Name = "COM2";
            comports[2]      = new Comport();
            comports[2].Name = "COM3";
            comports[3]      = new Comport();
            comports[3].Name = "COM4";

            readBda();

            initDevice(0);
            initDevice(1);
            initDevice(2);
            initDevice(3);

            IRQ.SetHandler(3, Handler24);
            IRQ.SetHandler(4, Handler13);
            IOApicManager.CreateISARedirection(3, 3);
            IOApicManager.CreateISARedirection(4, 4);
        }
示例#2
0
        /// <summary>
        /// Parses the MADT
        /// </summary>
        /// <param name="madt">The MADT</param>
        private static void parseMADT(MADT *madt)
        {
            m_madt = madt;
            LocalApic.SetLocalControllerAddress(madt->LocalControllerAddress);

            m_intSourceOverrides = new ISAOverride[16];
            for (uint i = 0; i < 16; i++)
            {
                m_intSourceOverrides[i].GSI      = i;
                m_intSourceOverrides[i].Polarity = IOApic.IOAPIC_REDIR_POLARITY_HIGH;
                m_intSourceOverrides[i].Trigger  = IOApic.IOAPIC_REDIR_TRIGGER_EDGE;
            }

            // After the flags field, the rest of the table contains a variable length of records
            uint current = (uint)madt + (uint)sizeof(MADT);
            uint end     = current + madt->Header.Length - (uint)sizeof(MADT);

            while (current < end)
            {
                ApicEntryHeader *   header = (ApicEntryHeader *)current;
                ApicEntryHeaderType type   = (ApicEntryHeaderType)header->Type;

                switch (type)
                {
                case ApicEntryHeaderType.LOCAL_APIC:
                    ApicLocalApic *localAPIC = (ApicLocalApic *)(current + sizeof(ApicEntryHeader));
                    Console.Write("[ACPI] Found CPU ");
                    Console.WriteNum(localAPIC->ProcessorID);
                    Console.Write('\n');
                    break;

                case ApicEntryHeaderType.IO_APIC:
                    ApicIOApic *IOApicStruct = (ApicIOApic *)(current + sizeof(ApicEntryHeader));

                    Console.Write("[ACPI] Found IO APIC at ");
                    Console.WriteHex(IOApicStruct->IOAPICAddress);
                    Console.Write('\n');

                    IOApic IOApic = new IOApic(IOApicStruct->IOAPIC_ID, (void *)IOApicStruct->IOAPICAddress, IOApicStruct->GlobalSystemInterruptBase);
                    IOApicManager.Add(IOApic);

                    break;

                case ApicEntryHeaderType.INTERRUPT_SOURCE_OVERRIDE:
                    ApicInterruptSourceOverride *intSourceOverride = (ApicInterruptSourceOverride *)(current + sizeof(ApicEntryHeader));

                    m_intSourceOverrides[intSourceOverride->IRQSource].GSI      = intSourceOverride->GlobalSystemInterrupt;
                    m_intSourceOverrides[intSourceOverride->IRQSource].Polarity = (uint)(intSourceOverride->Flags & 0x3);
                    m_intSourceOverrides[intSourceOverride->IRQSource].Trigger  = (uint)((intSourceOverride->Flags >> 2) & 0x3);

                    break;
                }

                current += header->Length;
            }
        }
示例#3
0
        /// <summary>
        /// Initialize keyboard
        /// </summary>
        public static unsafe void Init()
        {
            m_fifo = new Fifo(250, true);

            // Install the IRQ handler
            IRQ.SetHandler(1, handler);
            IOApicManager.CreateISARedirection(1, 1);

            Node node = new Node();

            node.Read    = readImpl;
            node.GetSize = getSizeImpl;
            node.Flags   = NodeFlags.DEVICE | NodeFlags.FILE;

            RootPoint dev = new RootPoint("keyboard", node);

            VFS.MountPointDevFS.AddEntry(dev);
        }