/* * This is the main file of the PCI driver core. It contains the PCI Device * database and controls device initialisation. */ #include #include #include #include /* Structure for a Device */ struct Device { uint16_t vendor, device; char *name; void (*init)(uint8_t, uint8_t, uint8_t); }; void pci_init_ide(uint8_t bus, uint8_t dev, uint8_t func); void pci_init_bga(uint8_t bus, uint8_t dev, uint8_t func); /* Device database */ struct Device devices[] = { /* Intel system devices */ {0x8086, 0x1237, "Intel i440FX Chipset", NULL}, {0x8086, 0x7000, "Intel PIIX3 PCI-to-ISA Bridge (Triton II)", NULL}, {0x8086, 0x7010, "Intel PIIX3 IDE Interface (Triton II)", pci_init_ide}, {0x8086, 0x7020, "Intel PIIX3 USB (Natoma/Triton II)", NULL}, {0x8086, 0x7113, "Intel PIIX4/4E/4M Power Management Controller", NULL}, /* Network devices */ {0x10EC, 0x8139, "Realtek RTL8139 10/100 NIC", NULL}, {0x8086, 0x100E, "Intel Pro 1000/MT NIC", NULL}, /* Virtual devices */ {0x1B36, 0x000D, "QEMU XHCI Host Adapter", NULL}, {0x1234, 0x1111, "QEMU/Bochs VBE Framebuffer", pci_init_bga}, }; /* Initialise a PCI device */ void init_pci_device(int bus, int dev, int func) { uint32_t d; uint16_t vendor, device; vendor = pci_read_word(bus, dev, func, 0); device = pci_read_word(bus, dev, func, 2); /* Lookup device details */ for (d = 0; d < sizeof(devices) / sizeof(struct Device); d++) { if (devices[d].vendor != vendor || devices[d].device != device) continue; if (devices[d].init) devices[d].init(bus, dev, func); return; } }