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 --- MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h | 4 +- .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 18 ++++-- MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c | 46 +++++++++++----- .../Bus/Pci/PciBusDxe/PciResourceSupport.c | 64 +++++++++++----------- 4 files changed, 79 insertions(+), 53 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h index e268014d34..d77982c02a 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h @@ -309,8 +309,8 @@ extern UINT64 gAllOne; extern UINT64 gAllZero; extern EFI_PCI_PLATFORM_PROTOCOL *gPciPlatformProtocol; extern EFI_PCI_OVERRIDE_PROTOCOL *gPciOverrideProtocol; - - +extern BOOLEAN mReserveIsaAliases; +extern BOOLEAN mReserveVgaAliases; /** Macro that checks whether device is a GFX device. diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c index c8689c0421..2dd5889afc 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c @@ -910,9 +910,10 @@ PciSetDeviceAttribute ( EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM | EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE; - if ((Attributes & EFI_PCI_IO_ATTRIBUTE_IO) != 0) { - Attributes |= EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO; - Attributes |= EFI_PCI_IO_ATTRIBUTE_ISA_IO; + if (IS_PCI_LPC (&PciIoDevice->Pci)) { + Attributes |= EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO; + Attributes |= (mReserveIsaAliases ? EFI_PCI_IO_ATTRIBUTE_ISA_IO : \ + EFI_PCI_IO_ATTRIBUTE_ISA_IO_16); } if (IS_PCI_BRIDGE (&PciIoDevice->Pci) || IS_CARDBUS_BRIDGE (&PciIoDevice->Pci)) { @@ -921,6 +922,14 @@ PciSetDeviceAttribute ( // Attributes |= EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO; Attributes |= EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO; + + if (mReserveVgaAliases) { + Attributes &= ~(UINT64)(EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 | \ + EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16); + } else { + Attributes &= ~(UINT64)(EFI_PCI_IO_ATTRIBUTE_VGA_IO | \ + EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO); + } } else { if (IS_PCI_IDE (&PciIoDevice->Pci)) { @@ -930,7 +939,8 @@ PciSetDeviceAttribute ( if (IS_PCI_VGA (&PciIoDevice->Pci)) { Attributes |= EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY; - Attributes |= EFI_PCI_IO_ATTRIBUTE_VGA_IO; + Attributes |= (mReserveVgaAliases ? EFI_PCI_IO_ATTRIBUTE_VGA_IO : \ + EFI_PCI_IO_ATTRIBUTE_VGA_IO_16); } } diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c index c39de9dd7e..5f6d3763e9 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c @@ -1529,6 +1529,38 @@ PciIoAttributes ( ); } + // + // Check VGA and VGA16, they can not be set at the same time + // + if (((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO) != 0 && + (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO_16) != 0) || + ((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO) != 0 && + (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16) != 0) || + ((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO) != 0 && + (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO_16) != 0) || + ((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO) != 0 && + (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16) != 0) ) { + return EFI_UNSUPPORTED; + } + + // + // workaround for PCI drivers which always set ISA_IO or VGA_IO attribute without detecting support of + // ISA_IO/ISA_IO_16 or VGA_IO/VGA_IO_16 to maintain backward-compatibility. + // + if (((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO) != 0) && + ((PciIoDevice->Supports & (EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16)) \ + == EFI_PCI_IO_ATTRIBUTE_VGA_IO_16)) { + Attributes &= ~(UINT64)EFI_PCI_IO_ATTRIBUTE_VGA_IO; + Attributes |= EFI_PCI_IO_ATTRIBUTE_VGA_IO_16; + } + + if (((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO) != 0) && + ((PciIoDevice->Supports & (EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO | EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16)) \ + == EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16)) { + Attributes &= ~(UINT64)EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO; + Attributes |= EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16; + } + // // If no attributes can be supported, then return. // Otherwise, set the attributes that it can support. @@ -1549,20 +1581,6 @@ PciIoAttributes ( Command = 0; BridgeControl = 0; - // - // Check VGA and VGA16, they can not be set at the same time - // - if (((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO) != 0 && - (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO_16) != 0) || - ((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO) != 0 && - (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16) != 0) || - ((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO) != 0 && - (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_IO_16) != 0) || - ((Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO) != 0 && - (Attributes & EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16) != 0) ) { - return EFI_UNSUPPORTED; - } - // // For PPB & P2C, set relevant attribute bits // diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c index cca365370f..6fa4001a62 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c @@ -14,6 +14,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "PciBus.h" +// +// The default policy for the PCI bus driver is NOT to reserve I/O ranges for both ISA aliases and VGA aliases. +// +BOOLEAN mReserveIsaAliases = FALSE; +BOOLEAN mReserveVgaAliases = FALSE; +BOOLEAN mPolicyDetermined = FALSE; + /** The function is used to skip VGA range. @@ -188,46 +195,37 @@ CalculateApertureIo16 ( LIST_ENTRY *CurrentLink; PCI_RESOURCE_NODE *Node; UINT64 Offset; - BOOLEAN IsaEnable; - BOOLEAN VGAEnable; EFI_PCI_PLATFORM_POLICY PciPolicy; - // - // Always assume there is ISA device and VGA device on the platform - // will be customized later - // - IsaEnable = FALSE; - VGAEnable = FALSE; + if (!mPolicyDetermined) { + // + // Check PciPlatform policy + // + Status = EFI_NOT_FOUND; + PciPolicy = 0; + if (gPciPlatformProtocol != NULL) { + Status = gPciPlatformProtocol->GetPlatformPolicy ( + gPciPlatformProtocol, + &PciPolicy + ); + } - // - // Check PciPlatform policy - // - if (gPciPlatformProtocol != NULL) { - Status = gPciPlatformProtocol->GetPlatformPolicy ( - gPciPlatformProtocol, - &PciPolicy - ); - if (!EFI_ERROR (Status)) { - if ((PciPolicy & EFI_RESERVE_ISA_IO_ALIAS) != 0) { - IsaEnable = TRUE; - } - if ((PciPolicy & EFI_RESERVE_VGA_IO_ALIAS) != 0) { - VGAEnable = TRUE; - } + if (EFI_ERROR (Status) && gPciOverrideProtocol != NULL) { + Status = gPciOverrideProtocol->GetPlatformPolicy ( + gPciOverrideProtocol, + &PciPolicy + ); } - } else if (gPciOverrideProtocol != NULL) { - Status = gPciOverrideProtocol->GetPlatformPolicy ( - gPciOverrideProtocol, - &PciPolicy - ); + if (!EFI_ERROR (Status)) { if ((PciPolicy & EFI_RESERVE_ISA_IO_ALIAS) != 0) { - IsaEnable = TRUE; + mReserveIsaAliases = TRUE; } if ((PciPolicy & EFI_RESERVE_VGA_IO_ALIAS) != 0) { - VGAEnable = TRUE; + mReserveVgaAliases = TRUE; } } + mPolicyDetermined = TRUE; } Aperture = 0; @@ -261,13 +259,13 @@ CalculateApertureIo16 ( // If both of them are enabled, then the IO resource would // become too limited to meet the requirement of most of devices. // - if (IsaEnable || VGAEnable) { + if (mReserveIsaAliases || mReserveVgaAliases) { if (!IS_PCI_BRIDGE (&(Node->PciDev->Pci)) && !IS_CARDBUS_BRIDGE (&(Node->PciDev->Pci))) { // // Check if there is need to support ISA/VGA decoding // If so, we need to avoid isa/vga aliasing range // - if (IsaEnable) { + if (mReserveIsaAliases) { SkipIsaAliasAperture ( &Aperture, Node->Length @@ -276,7 +274,7 @@ CalculateApertureIo16 ( if (Offset != 0) { Aperture = Aperture + (Node->Alignment + 1) - Offset; } - } else if (VGAEnable) { + } else if (mReserveVgaAliases) { SkipVGAAperture ( &Aperture, Node->Length -- cgit v1.2.3