Beispiel #1
0
        /// <summary>
        /// Sets an interrupt handler for a PCI device
        /// </summary>
        /// <param name="dev">The device</param>
        public static void SetInterruptHandler(PciDevice dev, IRQ.IRQHandler handler)
        {
            // Get IRQ routing data from table
            PciIRQEntry irq    = m_irqTable[(dev.Slot * PCI_PINS) + (dev.IRQPin - 1)];
            uint        irqNum = irq.Irq;

            // If no routing exists, use the interrupt line
            if (irqNum == 0)
            {
                irqNum = dev.IRQLine;
            }

            // First set the IRQ handler to avoid race conditions
            IRQ.SetHandler(irqNum, handler);
            IOApicManager.CreateEntry(irqNum, irqNum, irq.Flags);

            // Info
            Console.Write("[PCI] Set device to use IRQ ");
            Console.WriteNum((int)irqNum);
            Console.Write('\n');
        }
Beispiel #2
0
        /// <summary>
        /// Checks a device
        /// </summary>
        /// <param name="bus">The bus</param>
        /// <param name="device">The device</param>
        /// <param name="function">The function</param>
        private static void checkDevice(byte bus, byte device, byte function)
        {
            ushort vendorID = GetVendorID(bus, device, function);

            if (vendorID == 0xFFFF)
            {
                return;
            }

            ushort deviceID = GetDeviceID(bus, device, function);

            if (deviceID == 0xFFFF)
            {
                return;
            }

            PciDevice dev = new PciDevice();

            dev.Device   = deviceID;
            dev.Function = function;
            dev.Bus      = bus;
            dev.Slot     = device;

            dev.Vendor        = vendorID;
            dev.BAR0          = GetBar(bus, device, function, BAR0);
            dev.BAR1          = GetBar(bus, device, function, BAR1);
            dev.BAR2          = GetBar(bus, device, function, BAR2);
            dev.BAR3          = GetBar(bus, device, function, BAR3);
            dev.BAR4          = GetBar(bus, device, function, BAR4);
            dev.BAR5          = GetBar(bus, device, function, BAR5);
            dev.Type          = (byte)Read(bus, device, function, CONFIG_HEADER_TYPE, 1);
            dev.ClassCode     = (byte)Read(bus, device, function, CONFIG_CLASS_CODE, 1);
            dev.SubClass      = (byte)Read(bus, device, function, CONFIG_SUB_CLASS, 1);
            dev.ProgIntf      = (byte)Read(bus, device, function, CONFIG_PROG_INTF, 1);
            dev.CombinedClass = dev.ClassCode << 8 | dev.SubClass;
            dev.IRQPin        = (byte)Read(bus, device, function, IRQPIN, 1);
            dev.IRQLine       = (byte)Read(bus, device, function, IRQLINE, 1);

            Devices[m_currentdevice++] = dev;
        }
Beispiel #3
0
 /// <summary>
 /// Write data to PCI
 /// </summary>
 /// <param name="dev">The PCI device</param>
 /// <param name="offset">Offset</param>
 /// <param name="value">The value to write</param>
 /// <param name="size">The size of the data to write</param>
 public static void Write(PciDevice dev, ushort offset, uint value, uint size)
 {
     Write(dev.Bus, dev.Slot, dev.Function, offset, value, size);
 }
Beispiel #4
0
 /// <summary>
 /// Read data from PCI
 /// </summary>
 /// <param name="dev">The device</param>
 /// <param name="offset">Offset</param>
 /// <param name="size">The size of the data to read</param>
 /// <returns>The read data</returns>
 public static uint Read(PciDevice dev, ushort offset, uint size)
 {
     return(Read(dev.Bus, dev.Slot, dev.Function, offset, size));
 }