X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkModulePkg%2FBus%2FPci%2FPciBus%2FDxe%2FPciOptionRomSupport.c;h=3ec76989a5c69983859ced1a76aedf1260bac756;hp=5819fd6e373bd9a10479fbb82260bdbaa9375e9b;hb=c51cec25606163ee3cc478f5d4598227558195c5;hpb=db0e690675ba50c2463c47e4811227e56c4858d9 diff --git a/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciOptionRomSupport.c b/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciOptionRomSupport.c index 5819fd6e37..3ec76989a5 100644 --- a/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciOptionRomSupport.c +++ b/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciOptionRomSupport.c @@ -24,6 +24,13 @@ Revision History #include "pcibus.h" #include "PciResourceSupport.h" +// +// Min Max +// +#define EFI_MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define EFI_MAX(a, b) (((a) > (b)) ? (a) : (b)) + + EFI_STATUS GetOpRomInfo ( IN PCI_IO_DEVICE *PciIoDevice @@ -152,6 +159,7 @@ Returns: UINT64 RomSize; UINT64 RomImageSize; UINT8 *RomInMemory; + UINT8 CodeType; RomSize = PciDevice->RomSize; @@ -159,6 +167,7 @@ Returns: RomImageSize = 0; RomInMemory = NULL; Temp = 0; + CodeType = 0xFF; // // Get the RomBarIndex @@ -231,11 +240,22 @@ Returns: sizeof (PCI_DATA_STRUCTURE), (UINT8 *) RomPcir ); + if (RomPcir->CodeType == PCI_CODE_TYPE_PCAT_IMAGE) { + CodeType = PCI_CODE_TYPE_PCAT_IMAGE; + } Indicator = RomPcir->Indicator; RomImageSize = RomImageSize + RomPcir->ImageLength * 512; RomBarOffset = RomBarOffset + RomPcir->ImageLength * 512; } while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) < RomSize)); + // + // Some Legacy Cards do not report the correct ImageLength so used the maximum + // of the legacy length and the PCIR Image Length + // + if (CodeType == PCI_CODE_TYPE_PCAT_IMAGE) { + RomImageSize = EFI_MAX(RomImageSize, (((EFI_LEGACY_EXPANSION_ROM_HEADER *)RomHeader)->Size512 * 512)); + } + if (RomImageSize > 0) { retStatus = EFI_SUCCESS; Image = AllocatePool ((UINT32) RomImageSize);