]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Bus/Pci/PciBus/Dxe/PciOptionRomSupport.c
The reasons for the changes made are:
[mirror_edk2.git] / EdkModulePkg / Bus / Pci / PciBus / Dxe / PciOptionRomSupport.c
index 5819fd6e373bd9a10479fbb82260bdbaa9375e9b..3ec76989a5c69983859ced1a76aedf1260bac756 100644 (file)
@@ -24,6 +24,13 @@ Revision History
 #include "pcibus.h"\r
 #include "PciResourceSupport.h"\r
 \r
+//\r
+// Min Max\r
+//\r
+#define EFI_MIN(a, b) (((a) < (b)) ? (a) : (b))\r
+#define EFI_MAX(a, b) (((a) > (b)) ? (a) : (b))\r
+\r
+\r
 EFI_STATUS\r
 GetOpRomInfo (\r
   IN PCI_IO_DEVICE    *PciIoDevice\r
@@ -152,6 +159,7 @@ Returns:
   UINT64                    RomSize;\r
   UINT64                    RomImageSize;\r
   UINT8                     *RomInMemory;\r
+  UINT8                     CodeType;\r
 \r
   RomSize       = PciDevice->RomSize;\r
 \r
@@ -159,6 +167,7 @@ Returns:
   RomImageSize  = 0;\r
   RomInMemory   = NULL;\r
   Temp          = 0;\r
+  CodeType      = 0xFF;\r
 \r
   //\r
   // Get the RomBarIndex\r
@@ -231,11 +240,22 @@ Returns:
                                       sizeof (PCI_DATA_STRUCTURE),\r
                                       (UINT8 *) RomPcir\r
                                       );\r
+    if (RomPcir->CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {\r
+      CodeType = PCI_CODE_TYPE_PCAT_IMAGE;\r
+    }\r
     Indicator     = RomPcir->Indicator;\r
     RomImageSize  = RomImageSize + RomPcir->ImageLength * 512;\r
     RomBarOffset  = RomBarOffset + RomPcir->ImageLength * 512;\r
   } while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) < RomSize));\r
 \r
+  //\r
+  // Some Legacy Cards do not report the correct ImageLength so used the maximum\r
+  // of the legacy length and the PCIR Image Length\r
+  //\r
+  if (CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {\r
+    RomImageSize = EFI_MAX(RomImageSize, (((EFI_LEGACY_EXPANSION_ROM_HEADER *)RomHeader)->Size512 * 512));\r
+  }\r
+\r
   if (RomImageSize > 0) {\r
     retStatus = EFI_SUCCESS;\r
     Image     = AllocatePool ((UINT32) RomImageSize);\r