From e0ee9d9314c7c2816b89908a1fac871c911f1cb0 Mon Sep 17 00:00:00 2001 From: rsun3 Date: Tue, 28 Dec 2010 10:10:10 +0000 Subject: =?UTF-8?q?Clean=20ISA=5FIO/ISA=5FIO=5F16=20and=20VGA=5FIO/VGA=5FI?= =?UTF-8?q?O=5F16=20attribute=20usage=20in=20PCI=20bus=20driver/PCI=20host?= =?UTF-8?q?=20bridge=20drivers/LPC/VGA=20device=20drivers.=201.=20Fix=20th?= =?UTF-8?q?e=20incorrect=20definition=20of=20EFI=5FPCI=5FIO=5FATTRIBUTE=5F?= =?UTF-8?q?VGA=5FIO=5F16=20(does=20not=20conform=20to=20the=20UEFI=20spec)?= =?UTF-8?q?=20in=20PciIo.h.=202.=20Add=20missing=20definitions=20of=20ISA?= =?UTF-8?q?=20and=20VGA=20IO=20attributes=20in=20PCI=20Root=20Bridge=20IO?= =?UTF-8?q?=20protocol.=203.=20Improve=20the=20algorithm=20in=20the=20PCI?= =?UTF-8?q?=20bus=20driver=20to=20get=20PCI=20platform=20policy=20from=20P?= =?UTF-8?q?CI=20Platform=20Protocol=20and=20PCI=20Override=20Protocol.=204?= =?UTF-8?q?.=20Update=20the=20PCI=20bus=20driver=20to=20use=20the=20PCI=20?= =?UTF-8?q?platform=20policy=20to=20determine=20the=20supported=20attribut?= =?UTF-8?q?es=20that=20are=20returned=20by=20the=20EFI=5FPCI=5FIO=5FPROTOC?= =?UTF-8?q?OL.Attributes()=20function.=20This=20is=20required=20by=20the?= =?UTF-8?q?=20PI=20spec.=205.=20Add=20a=20backward=20compatibility=20worka?= =?UTF-8?q?round=20for=20PCI=20VGA=20drivers=20in=20Option=20ROM,=20which?= =?UTF-8?q?=20typically=20sets=20VGA=5FIO=20without=20checking=20supported?= =?UTF-8?q?=20attributes.=206.=20Update=20the=20PCI=20host=20bridge=20driv?= =?UTF-8?q?er=20in=20PcAtChipsetPkg=20to=20report=20VGA=5FIO=5F16=20and=20?= =?UTF-8?q?ISA=5FIO=5F16=20instead=20of=20VGA=5FIO/ISA=5FIO=20attributes.?= =?UTF-8?q?=20Modern=20chipsets=20don=E2=80=99t=20have=20hardware=20capabi?= =?UTF-8?q?lity=20to=20control=2010-bit=20or=2016-bit=20decoding=20for=20I?= =?UTF-8?q?SA/VGA=20aliases.=207.=20Update=20LPC/VGA=20device=20drivers=20?= =?UTF-8?q?to=20check=20supported=20attributes=20of=20VGA=5FIO/VGA=5FIO=5F?= =?UTF-8?q?16=20or=20ISA=5FIO/ISA=5FIO=5F16.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11204 6f19259b-4bc3-4df7-8a09-765794883524 --- PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c | 50 ++++++++- PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c | 118 ++-------------------- PcAtChipsetPkg/PciHostBridgeDxe/PciRootBridgeIo.c | 7 +- 3 files changed, 59 insertions(+), 116 deletions(-) (limited to 'PcAtChipsetPkg') diff --git a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c index 8e6d8b7f8..ea1180f3a 100644 --- a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c +++ b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c @@ -171,7 +171,11 @@ PcatIsaAcpiDriverBindingStart ( EFI_STATUS Status; EFI_PCI_IO_PROTOCOL *PciIo; PCAT_ISA_ACPI_DEV *PcatIsaAcpiDev; - + UINT64 Supports; + BOOLEAN Enabled; + + Enabled = FALSE; + Supports = 0; PcatIsaAcpiDev = NULL; // // Open the PCI I/O Protocol Interface @@ -189,10 +193,30 @@ PcatIsaAcpiDriverBindingStart ( goto Done; } + // + // Get supported PCI attributes + // + Status = PciIo->Attributes ( + PciIo, + EfiPciIoAttributeOperationSupported, + 0, + &Supports + ); + if (EFI_ERROR (Status)) { + goto Done; + } + + Supports &= (EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_IO_16); + if (Supports == 0 || Supports == (EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_IO_16)) { + Status = EFI_UNSUPPORTED; + goto Done; + } + + Enabled = TRUE; Status = PciIo->Attributes ( PciIo, EfiPciIoAttributeOperationEnable, - EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, + EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, NULL ); if (EFI_ERROR (Status)) { @@ -242,11 +266,11 @@ PcatIsaAcpiDriverBindingStart ( Done: if (EFI_ERROR (Status)) { - if (PciIo != NULL) { + if (PciIo != NULL && Enabled) { PciIo->Attributes ( PciIo, EfiPciIoAttributeOperationDisable, - EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, + EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, NULL ); } @@ -292,6 +316,7 @@ PcatIsaAcpiDriverBindingStop ( EFI_STATUS Status; EFI_ISA_ACPI_PROTOCOL *IsaAcpi; PCAT_ISA_ACPI_DEV *PcatIsaAcpiDev; + UINT64 Supports; // // Get the ISA ACPI Protocol Interface @@ -313,10 +338,25 @@ PcatIsaAcpiDriverBindingStop ( // PcatIsaAcpiDev = PCAT_ISA_ACPI_DEV_FROM_THIS (IsaAcpi); + // + // Get supported PCI attributes + // + Status = PcatIsaAcpiDev->PciIo->Attributes ( + PcatIsaAcpiDev->PciIo, + EfiPciIoAttributeOperationSupported, + 0, + &Supports + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Supports &= (EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_IO_16); + PcatIsaAcpiDev->PciIo->Attributes ( PcatIsaAcpiDev->PciIo, EfiPciIoAttributeOperationDisable, - EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, + EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, NULL ); diff --git a/PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c b/PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c index 27a54461c..6403a0723 100644 --- a/PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c +++ b/PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c @@ -1123,109 +1123,6 @@ GetProposedResources( return EFI_INVALID_PARAMETER; } -/** - Update attribute for PCI root bridge for specifc device. - - @param RootBridge Point to PCI root bridge. - @param PciAddress The specific device PCI address -**/ -VOID -UpdateRootBridgeAttributes ( - IN PCI_ROOT_BRIDGE_INSTANCE *RootBridge, - IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress - ) -{ - EFI_STATUS Status; - PCI_TYPE01 PciConfigurationHeader; - UINT64 Attributes; - - // - // Read the PCI Configuration Header for the device - // - Status = RootBridge->Io.Pci.Read ( - &RootBridge->Io, - EfiPciWidthUint16, - EFI_PCI_ADDRESS( - PciAddress.Bus, - PciAddress.Device, - PciAddress.Function, - 0 - ), - sizeof (PciConfigurationHeader) / sizeof (UINT16), - &PciConfigurationHeader - ); - if (EFI_ERROR (Status)) { - return; - } - - Attributes = RootBridge->Attributes; - - // - // Look for devices with the VGA Palette Snoop enabled in the COMMAND register of the PCI Config Header - // - if (PciConfigurationHeader.Hdr.Command & 0x20) { - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO; - } - - // - // If the device is a PCI-PCI Bridge, then look at the Subordinate Bus Number - // - if (IS_PCI_BRIDGE(&PciConfigurationHeader)) { - // - // Look at the PPB Configuration for legacy decoding attributes - // - if (PciConfigurationHeader.Bridge.BridgeControl & 0x04) { - Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO; - Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO; - } - if (PciConfigurationHeader.Bridge.BridgeControl & 0x08) { - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO; - } - } else { - // - // See if the PCI device is an IDE controller - // - if (PciConfigurationHeader.Hdr.ClassCode[2] == 0x01 && - PciConfigurationHeader.Hdr.ClassCode[1] == 0x01 ) { - if (PciConfigurationHeader.Hdr.ClassCode[0] & 0x80) { - Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO; - Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO; - } - if (PciConfigurationHeader.Hdr.ClassCode[0] & 0x01) { - Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO; - } - if (PciConfigurationHeader.Hdr.ClassCode[0] & 0x04) { - Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO; - } - } - - // - // See if the PCI device is a legacy VGA controller - // - if (PciConfigurationHeader.Hdr.ClassCode[2] == 0x00 && - PciConfigurationHeader.Hdr.ClassCode[1] == 0x01 ) { - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO; - } - - // - // See if the PCI device is a standard VGA controller - // - if (PciConfigurationHeader.Hdr.ClassCode[2] == 0x03 && - PciConfigurationHeader.Hdr.ClassCode[1] == 0x00 ) { - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO; - } - } - - RootBridge->Attributes = Attributes; - RootBridge->Supports = Attributes; -} - /** Provides the hooks from the PCI bus driver to every PCI controller (device/function) at various stages of the PCI enumeration process that allow the host bridge driver to preinitialize individual @@ -1275,14 +1172,17 @@ PreprocessController ( while (List != &HostBridgeInstance->Head) { RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List); if (RootBridgeHandle == RootBridgeInstance->Handle) { - UpdateRootBridgeAttributes ( - RootBridgeInstance, - PciAddress - ); - return EFI_SUCCESS; + break; } List = List->ForwardLink; } + if (List == &HostBridgeInstance->Head) { + return EFI_INVALID_PARAMETER; + } - return EFI_INVALID_PARAMETER; + if (Phase < EfiPciBeforeChildBusEnumeration || Phase > EfiMaxPciHostBridgeEnumerationPhase) { + return EFI_INVALID_PARAMETER; + } + + return EFI_SUCCESS; } diff --git a/PcAtChipsetPkg/PciHostBridgeDxe/PciRootBridgeIo.c b/PcAtChipsetPkg/PciHostBridgeDxe/PciRootBridgeIo.c index cd39f2bbf..512a5049c 100644 --- a/PcAtChipsetPkg/PciHostBridgeDxe/PciRootBridgeIo.c +++ b/PcAtChipsetPkg/PciHostBridgeDxe/PciRootBridgeIo.c @@ -674,8 +674,11 @@ RootBridgeConstructor ( PrivateData->RootBridgeAttrib = Attri; - PrivateData->Attributes = 0; - PrivateData->Supports = 0; + PrivateData->Supports = EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO | EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO | \ + EFI_PCI_ATTRIBUTE_ISA_IO_16 | EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO | \ + EFI_PCI_ATTRIBUTE_VGA_MEMORY | \ + EFI_PCI_ATTRIBUTE_VGA_IO_16 | EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16; + PrivateData->Attributes = PrivateData->Supports; Protocol->ParentHandle = HostBridgeHandle; -- cgit v1.2.3