From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F127F81F15 for ; Wed, 30 Nov 2016 22:50:03 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 30 Nov 2016 22:50:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,723,1477983600"; d="scan'208";a="907481845" Received: from shwde7172.ccr.corp.intel.com ([10.239.9.23]) by orsmga003.jf.intel.com with ESMTP; 30 Nov 2016 22:50:02 -0800 From: Liming Gao To: edk2-devel@lists.01.org Cc: Star Zeng , Jiewen Yao Date: Thu, 1 Dec 2016 14:49:34 +0800 Message-Id: <1480574974-22276-3-git-send-email-liming.gao@intel.com> X-Mailer: git-send-email 2.8.0.windows.1 In-Reply-To: <1480574974-22276-1-git-send-email-liming.gao@intel.com> References: <1480574974-22276-1-git-send-email-liming.gao@intel.com> Subject: [Patch 2/2] MdeModulePkg PiSmmCore: Retrieve Smram base address from system table X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Dec 2016 06:50:04 -0000 PiSmmIpl records LoadModuleAtFixAddressSmramBase in LMFAConfigurationTable. Update PiSmmCore to directly get the address from this system table. Cc: Star Zeng Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao --- MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 1 + MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 2 ++ 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 9b72ded..168fbe9 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h @@ -37,6 +37,7 @@ #include #include #include +#include #include #include diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf index c256e90..f380fc5 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 b638aad..0006588 100644 --- a/MdeModulePkg/Core/PiSmmCore/Pool.c +++ b/MdeModulePkg/Core/PiSmmCore/Pool.c @@ -35,9 +35,8 @@ SmmInitializeMemoryServices ( ) { UINTN Index; - UINT64 SmmCodeSize; - UINTN CurrentSmramRangesIndex; - UINT64 MaxSize; + EFI_STATUS Status; + EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE *LMFAConfigurationTable; // // Initialize Pool list @@ -45,45 +44,15 @@ SmmInitializeMemoryServices ( for (Index = ARRAY_SIZE (mSmmPoolLists); Index > 0;) { InitializeListHead (&mSmmPoolLists[--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 // -- 2.8.0.windows.1