\r
\r
VOID\r
-PciInitialization (\r
+PciAcpiInitialization (\r
)\r
{\r
- //\r
- // Bus 0, Device 0, Function 0 - Host to PCI Bridge\r
- //\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 0, 0, 0x3c), 0x00);\r
-\r
- //\r
- // Bus 0, Device 1, Function 0 - PCI to ISA Bridge\r
- //\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x3c), 0x00);\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); // LNKA routing target\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x0b); // LNKB routing target\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0a); // LNKC routing target\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x0a); // LNKD routing target\r
-\r
- //\r
- // Bus 0, Device 1, Function 1 - IDE Controller\r
- //\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 1, 1, 0x3c), 0x00);\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 1, 1, 0x0d), 0x40);\r
+ UINT16 HostBridgeDevId;\r
+ UINTN Pmba;\r
\r
//\r
- // Bus 0, Device 1, Function 3 - Power Managment Controller\r
+ // Query Host Bridge DID to determine platform type\r
//\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3c), 0x09);\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3d), 0x01); // INTA\r
-\r
- //\r
- // Bus 0, Device 2, Function 0 - Video Controller\r
- //\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 2, 0, 0x3c), 0x00);\r
+ HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId);\r
+ switch (HostBridgeDevId) {\r
+ case INTEL_82441_DEVICE_ID:\r
+ Pmba = POWER_MGMT_REGISTER_PIIX4 (0x40);\r
+ //\r
+ // 00:01.0 ISA Bridge (PIIX4) LNK routing targets\r
+ //\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); // A\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x0b); // B\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0a); // C\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x0a); // D\r
+ break;\r
+ case INTEL_Q35_MCH_DEVICE_ID:\r
+ Pmba = POWER_MGMT_REGISTER_Q35 (0x40);\r
+ //\r
+ // 00:1f.0 LPC Bridge (Q35) LNK routing targets\r
+ //\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x60), 0x0a); // A\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x61), 0x0a); // B\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x62), 0x0b); // C\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x63), 0x0b); // D\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x68), 0x0a); // E\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x69), 0x0a); // F\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6a), 0x0b); // G\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6b), 0x0b); // H\r
+ break;\r
+ default:\r
+ DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",\r
+ __FUNCTION__, HostBridgeDevId));\r
+ ASSERT (FALSE);\r
+ return;\r
+ }\r
\r
//\r
- // Bus 0, Device 3, Function 0 - Network Controller\r
+ // Set ACPI SCI_EN bit in PMCNTRL\r
//\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3c), 0x0a);\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3d), 0x01); // INTA (-> LNKC)\r
+ IoOr16 ((PciRead32 (Pmba) & ~BIT0) + 4, BIT0);\r
\r
//\r
- // Bus 0, Device 5, Function 0 - RAM Memory\r
+ // Initialize PCI_INTERRUPT_LINE for commonly encountered devices and slots\r
//\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 5, 0, 0x3c), 0x0b);\r
- PciWrite8 (PCI_LIB_ADDRESS (0, 5, 0, 0x3d), 0x01); // INTA (-> LNKA)\r
-}\r
-\r
-\r
-VOID\r
-AcpiInitialization (\r
- VOID\r
- )\r
-{\r
- //\r
- // Set ACPI SCI_EN bit in PMCNTRL\r
+ // FIXME: This should instead be accomplished programmatically by\r
+ // ennumerating all PCI devices present in the system and\r
+ // computing PCI_INTERRUPT_LINE from PCI_INTERRUPT_PIN, the\r
+ // slot/position of the device, and the available host IRQs\r
+ // (for an example, see SeaBIOS pci_bios_init_devices() in\r
+ // src/fw/pciinit.c)\r
//\r
- IoOr16 ((PciRead32 (PCI_LIB_ADDRESS (0, 1, 3, 0x40)) & ~BIT0) + 4, BIT0);\r
+ switch (HostBridgeDevId) {\r
+ case INTEL_82441_DEVICE_ID:\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 1, 2, 0x3c), 0x0b); // usb (northbr.)\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 1, 3, 0x3c), 0x0a); // acpi (northbr.)\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3c), 0x0b);\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 4, 0, 0x3c), 0x0b);\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 5, 0, 0x3c), 0x0a);\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 6, 0, 0x3c), 0x0a);\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 7, 0, 0x3c), 0x0b);\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 8, 0, 0x3c), 0x0b);\r
+ break;\r
+ case INTEL_Q35_MCH_DEVICE_ID:\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 2, 0, 0x3c), 0x0b);\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 3, 0, 0x3c), 0x0b);\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 4, 0, 0x3c), 0x0a);\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 5, 0, 0x3c), 0x0a);\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 6, 0, 0x3c), 0x0b);\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 7, 0, 0x3c), 0x0b);\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 8, 0, 0x3c), 0x0a);\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1d, 0, 0x3c), 0x0a); // uhci1\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1d, 1, 0x3c), 0x0a); // uhci2\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1d, 2, 0x3c), 0x0b); // uhci3\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1d, 7, 0x3c), 0x0b); // ehci1\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 2, 0x3c), 0x0a); // ahci (northbr.)\r
+ PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 3, 0x3c), 0x0a); // smbus (northbr.)\r
+ break;\r
+ default:\r
+ ASSERT (FALSE); // should never be reached\r
+ }\r
}\r
\r
\r
//\r
BdsLibConnectAll ();\r
\r
- PciInitialization ();\r
- AcpiInitialization ();\r
+ PciAcpiInitialization ();\r
\r
//\r
// Clear the logo after all devices are connected.\r