/** @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
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
@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
@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
UINT32 LocalTime;\r
UINT32 StartBbsIndex;\r
UINT32 EndBbsIndex;\r
+ UINT32 MaxRomAddr;\r
UINTN TempData;\r
UINTN InitAddress;\r
UINTN RuntimeAddress;\r
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
// 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
// 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