diff options
author | Liming Gao <liming.gao@intel.com> | 2016-12-12 10:09:51 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2016-12-12 10:52:33 +0800 |
commit | 94a1bc1212edf521b7c96bfb9dc653818c95bec7 (patch) | |
tree | 956f78cc495aaf67591d1370f9f623aaadbc2703 | |
parent | a7d10bb09dda44e25029b4d0da67ac9348a29f31 (diff) | |
download | edk2-94a1bc1212edf521b7c96bfb9dc653818c95bec7.tar.gz edk2-94a1bc1212edf521b7c96bfb9dc653818c95bec7.tar.bz2 edk2-94a1bc1212edf521b7c96bfb9dc653818c95bec7.zip |
MdeModulePkg PiSmmCore: Retrieve Smram base address from system table
PiSmmIpl records LoadModuleAtFixAddressSmramBase in LMFAConfigurationTable.
Update PiSmmCore to directly get the address from this system table.
Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
-rw-r--r-- | MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 1 | ||||
-rw-r--r-- | MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 2 | ||||
-rw-r--r-- | MdeModulePkg/Core/PiSmmCore/Pool.c | 51 |
3 files changed, 13 insertions, 41 deletions
diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h index d1e7791302..58590d5f61 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h @@ -37,6 +37,7 @@ #include <Guid/EventGroup.h>
#include <Guid/EventLegacyBios.h>
#include <Guid/MemoryProfile.h>
+#include <Guid/LoadModuleAtFixedAddress.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf index c256e90a9b..f380fc5f4b 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf @@ -98,6 +98,8 @@ ## SOMETIMES_PRODUCES ## GUID # Install protocol
gEdkiiSmmMemoryProfileGuid
gEdkiiPiSmmMemoryAttributesTableGuid ## SOMETIMES_PRODUCES ## SystemTable
+ ## SOMETIMES_CONSUMES ## SystemTable
+ gLoadFixedAddressConfigurationTableGuid
[UserExtensions.TianoCore."ExtraFiles"]
PiSmmCoreExtra.uni
diff --git a/MdeModulePkg/Core/PiSmmCore/Pool.c b/MdeModulePkg/Core/PiSmmCore/Pool.c index 173650ae1d..f734b3f72d 100644 --- a/MdeModulePkg/Core/PiSmmCore/Pool.c +++ b/MdeModulePkg/Core/PiSmmCore/Pool.c @@ -59,10 +59,9 @@ SmmInitializeMemoryServices ( )
{
UINTN Index;
- UINT64 SmmCodeSize;
- UINTN CurrentSmramRangesIndex;
- UINT64 MaxSize;
+ EFI_STATUS Status;
UINTN SmmPoolTypeIndex;
+ EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE *LMFAConfigurationTable;
//
// Initialize Pool list
@@ -72,45 +71,15 @@ SmmInitializeMemoryServices ( InitializeListHead (&mSmmPoolLists[SmmPoolTypeIndex][Index]);
}
}
- CurrentSmramRangesIndex = 0;
- //
- // If Loading Module At fixed Address feature is enabled, cache the SMRAM base here
- //
- if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {
- //
- // Build tool will calculate the smm code size and then patch the PcdLoadFixAddressSmmCodePageNumber
- //
- SmmCodeSize = LShiftU64 (PcdGet32(PcdLoadFixAddressSmmCodePageNumber), EFI_PAGE_SHIFT);
-
- //
- // Find the largest SMRAM range between 1MB and 4GB that is at least 256KB - 4K in size
- //
- for (Index = 0, MaxSize = SIZE_256KB - EFI_PAGE_SIZE; Index < SmramRangeCount; Index++) {
- //
- // Skip any SMRAM region that is already allocated, needs testing, or needs ECC initialization
- //
- if ((SmramRanges[Index].RegionState & (EFI_ALLOCATED | EFI_NEEDS_TESTING | EFI_NEEDS_ECC_INITIALIZATION)) != 0) {
- continue;
- }
-
- if (SmramRanges[Index].CpuStart >= BASE_1MB) {
- if ((SmramRanges[Index].CpuStart + SmramRanges[Index].PhysicalSize - 1) <= MAX_ADDRESS) {
- if (SmramRanges[Index].PhysicalSize >= MaxSize) {
- MaxSize = SmramRanges[Index].PhysicalSize;
- CurrentSmramRangesIndex = Index;
- }
- }
- }
- }
- gLoadModuleAtFixAddressSmramBase = SmramRanges[CurrentSmramRangesIndex].CpuStart;
-
- //
- // cut out a memory range from this SMRAM range with the size SmmCodeSize to hold SMM driver code
- // A notable thing is that SMM core is already loaded into this range.
- //
- SmramRanges[CurrentSmramRangesIndex].CpuStart = SmramRanges[CurrentSmramRangesIndex].CpuStart + SmmCodeSize;
- SmramRanges[CurrentSmramRangesIndex].PhysicalSize = SmramRanges[CurrentSmramRangesIndex].PhysicalSize - SmmCodeSize;
+
+ Status = EfiGetSystemConfigurationTable (
+ &gLoadFixedAddressConfigurationTableGuid,
+ (VOID **) &LMFAConfigurationTable
+ );
+ if (!EFI_ERROR (Status) && LMFAConfigurationTable != NULL) {
+ gLoadModuleAtFixAddressSmramBase = LMFAConfigurationTable->SmramBase;
}
+
//
// Add Free SMRAM regions
// Need add Free memory at first, to let gSmmMemoryMap record data
|