]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyPci.c
IntelSiliconPkg: Fix VS2015 NOOPT IA32 build failure in IntelVTdDxe
[mirror_edk2.git] / IntelFrameworkModulePkg / Csm / LegacyBiosDxe / LegacyPci.c
index 7299fc0e6be45c0cfe5f0fa7906c5e8aa1e12919..c4c77ec344a0399b957b559bc5d43035f6c1c052 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -318,7 +318,7 @@ GetPciLegacyRom (
       break;\r
     }\r
 \r
-    if ((UINTN)(RomHeader.Raw - (UINT8 *) *Rom) + Pcir->ImageLength * 512 > *ImageSize) {\r
+    if (((UINTN)RomHeader.Raw - (UINTN)*Rom) + Pcir->ImageLength * 512 > *ImageSize) {\r
       break;\r
     }\r
     \r
@@ -1812,7 +1812,7 @@ PciShadowRoms (
   @param  RomSize                Size of ROM Image\r
   @param  Flags                  Indicates if ROM found and if PC-AT.\r
 \r
-  @retval EFI_SUCCESS            Legacy Option ROM availible for this device\r
+  @retval EFI_SUCCESS            Legacy Option ROM available for this device\r
   @retval EFI_UNSUPPORTED        Legacy Option ROM not supported.\r
 \r
 **/\r
@@ -1854,7 +1854,7 @@ LegacyBiosCheckPciRom (
     @param[out] OpromRevision          Revision of the PCI Rom\r
     @param[out] ConfigUtilityCodeHeaderPointer of Configuration Utility Code Header\r
 \r
-    @return EFI_SUCCESS            Legacy Option ROM availible for this device\r
+    @return EFI_SUCCESS            Legacy Option ROM available for this device\r
     @return EFI_ALREADY_STARTED    This device is already managed by its Oprom\r
     @return EFI_UNSUPPORTED        Legacy Option ROM not supported.\r
 \r
@@ -2284,6 +2284,7 @@ LegacyBiosInstallRom (
   UINT32                LocalTime;\r
   UINT32                StartBbsIndex;\r
   UINT32                EndBbsIndex;\r
+  UINT32                MaxRomAddr;\r
   UINTN                 TempData;\r
   UINTN                 InitAddress;\r
   UINTN                 RuntimeAddress;\r
@@ -2299,6 +2300,15 @@ LegacyBiosInstallRom (
   Function        = 0;\r
   VideoMode       = 0;\r
   PhysicalAddress = 0;\r
+  MaxRomAddr      = PcdGet32 (PcdEndOpromShadowAddress);\r
+\r
+  if ((Private->Legacy16Table->TableLength >= OFFSET_OF(EFI_COMPATIBILITY16_TABLE, HiPermanentMemoryAddress)) &&\r
+      (Private->Legacy16Table->UmaAddress != 0) && \r
+      (Private->Legacy16Table->UmaSize != 0) &&\r
+      (MaxRomAddr > (Private->Legacy16Table->UmaAddress))) {\r
+    MaxRomAddr = Private->Legacy16Table->UmaAddress;\r
+  }\r
+\r
 \r
   PciProgramAllInterruptLineRegisters (Private);\r
 \r
@@ -2331,7 +2341,7 @@ LegacyBiosInstallRom (
     //   then test if there is enough space for its RT code\r
     //\r
     RuntimeAddress = Private->OptionRom;\r
-    if (RuntimeAddress + *RuntimeImageLength > PcdGet32 (PcdEndOpromShadowAddress)) {\r
+    if (RuntimeAddress + *RuntimeImageLength > MaxRomAddr) {\r
       DEBUG ((EFI_D_ERROR, "return LegacyBiosInstallRom(%d): EFI_OUT_OF_RESOURCES (no more space for OpROM)\n", __LINE__));\r
       gBS->FreePages (PhysicalAddress, EFI_SIZE_TO_PAGES (ImageSize));\r
       //\r
@@ -2349,7 +2359,7 @@ LegacyBiosInstallRom (
     //   test if there is enough space for its INIT code\r
     //\r
     InitAddress    = PCI_START_ADDRESS (Private->OptionRom);\r
-    if (InitAddress + ImageSize > PcdGet32 (PcdEndOpromShadowAddress)) {\r
+    if (InitAddress + ImageSize > MaxRomAddr) {\r
       DEBUG ((EFI_D_ERROR, "return LegacyBiosInstallRom(%d): EFI_OUT_OF_RESOURCES (no more space for OpROM)\n", __LINE__));\r
       //\r
       // Report Status Code to indicate that there is no enough space for OpROM\r