Update the way to allocate high PMM, firstly try to allocate high PMM below 16MB, if it fails, allocate high PMM below 4GB.

Signed-off-by: li-elvin <elvin.li@intel.com>
Reviewed-by: jyao1 <jiewen.yao@intel.com>


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13352 6f19259b-4bc3-4df7-8a09-765794883524
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
index 194fee6..c90231a 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
@@ -1,6 +1,6 @@
 /** @file

 

-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>

+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>

 

 This program and the accompanying materials

 are licensed and made available under the terms and conditions

@@ -922,21 +922,32 @@
   EfiToLegacy16InitTable->LowPmmMemory            = (UINT32) MemoryAddressUnder1MB;

   EfiToLegacy16InitTable->LowPmmMemorySizeInBytes = MemorySize;

 

+  MemorySize = PcdGet32 (PcdHighPmmMemorySize);

+  ASSERT ((MemorySize & 0xFFF) == 0);

   //

   // Allocate high PMM Memory under 16 MB

-  //

-  MemorySize = PcdGet32 (PcdHighPmmMemorySize);

-  ASSERT ((MemorySize & 0xFFF) == 0);    

+  //   

   Status = AllocateLegacyMemory (

              AllocateMaxAddress,

              0x1000000,

              EFI_SIZE_TO_PAGES (MemorySize),

              &MemoryAddress

              );

+  if (EFI_ERROR (Status)) {

+    //

+    // If it fails, allocate high PMM Memory under 4GB

+    //   

+    Status = AllocateLegacyMemory (

+               AllocateMaxAddress,

+               0xFFFFFFFF,

+               EFI_SIZE_TO_PAGES (MemorySize),

+               &MemoryAddress

+               );    

+  }

   if (!EFI_ERROR (Status)) {

     EfiToLegacy16InitTable->HiPmmMemory            = (UINT32) (EFI_PHYSICAL_ADDRESS) (UINTN) MemoryAddress;

     EfiToLegacy16InitTable->HiPmmMemorySizeInBytes = MemorySize;

-  }

+  } 

 

   //

   //  ShutdownAPs();