From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ml01.01.org (Postfix) with ESMTP id ADFDC1A1E63 for ; Tue, 2 Aug 2016 01:59:57 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 02 Aug 2016 01:59:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,459,1464678000"; d="scan'208";a="743018691" Received: from jfan12-desk.ccr.corp.intel.com ([10.239.9.5]) by FMSMGA003.fm.intel.com with ESMTP; 02 Aug 2016 01:59:56 -0700 From: Jeff Fan To: edk2-devel@lists.01.org Cc: Michael Kinney , Feng Tian , Giri P Mudusuru , Laszlo Ersek Date: Tue, 2 Aug 2016 16:59:03 +0800 Message-Id: <1470128388-17960-4-git-send-email-jeff.fan@intel.com> X-Mailer: git-send-email 2.7.4.windows.1 In-Reply-To: <1470128388-17960-1-git-send-email-jeff.fan@intel.com> References: <1470128388-17960-1-git-send-email-jeff.fan@intel.com> Subject: [Patch v5 03/48] UefiCpuPkg/CpuS3DataDxe: Move StartupVector allocation to EndOfDxe() 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: Tue, 02 Aug 2016 08:59:57 -0000 Currently, we will allocate StartupVector buffer under 1MB at entry point function. But some modules may allocate some hard code address under 1MB. For example, LegacyBiosDxe driver tries to manage some legacy range under 640KB. To avoid the conflicts, we move StartupVector buffer allocation to End Of DXE event callback function. v4: Update the Context parameter is used as a pointer to AcpiCpuDataEx, then we needn't to add the global variable. Cc: Michael Kinney Cc: Feng Tian Cc: Giri P Mudusuru Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan Reviewed-by: Giri P Mudusuru --- UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c | 42 +++++++++++++++++--------------- UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf | 2 +- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c index 9fb47dc..7bd928f 100644 --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c +++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c @@ -9,7 +9,7 @@ number of CPUs reported by the MP Services Protocol, so this module does not support hot plug CPUs. This module can be copied into a CPU specific package and customized if these additional features are required. -Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
Copyright (c) 2015, Red Hat, Inc. This program and the accompanying materials @@ -84,20 +84,36 @@ AllocateAcpiNvsMemoryBelow4G ( /** Callback function executed when the EndOfDxe event group is signaled. - We delay saving the MTRR settings until BDS signals EndOfDxe. + We delay allocating StartupVector and saving the MTRR settings until BDS signals EndOfDxe. @param[in] Event Event whose notification function is being invoked. @param[out] Context Pointer to the MTRR_SETTINGS buffer to fill in. **/ VOID EFIAPI -SaveMtrrsOnEndOfDxe ( +CpuS3DataOnEndOfDxe ( IN EFI_EVENT Event, OUT VOID *Context ) { + EFI_STATUS Status; + ACPI_CPU_DATA_EX *AcpiCpuDataEx; + + AcpiCpuDataEx = (ACPI_CPU_DATA_EX *) Context; + // + // Allocate a 4KB reserved page below 1MB + // + AcpiCpuDataEx->AcpiCpuData.StartupVector = BASE_1MB - 1; + Status = gBS->AllocatePages ( + AllocateMaxAddress, + EfiReservedMemoryType, + 1, + &AcpiCpuDataEx->AcpiCpuData.StartupVector + ); + ASSERT_EFI_ERROR (Status); + DEBUG ((EFI_D_VERBOSE, "%a\n", __FUNCTION__)); - MtrrGetAllMtrrs (Context); + MtrrGetAllMtrrs (&AcpiCpuDataEx->MtrrTable); // // Close event, so it will not be invoked again. @@ -162,18 +178,6 @@ CpuS3DataInitialize ( ASSERT_EFI_ERROR (Status); // - // Allocate a 4KB reserved page below 1MB - // - AcpiCpuData->StartupVector = BASE_1MB - 1; - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiReservedMemoryType, - 1, - &AcpiCpuData->StartupVector - ); - ASSERT_EFI_ERROR (Status); - - // // Get the number of CPUs // Status = MpServices->GetNumberOfProcessors ( @@ -255,13 +259,13 @@ CpuS3DataInitialize ( // // Register EFI_END_OF_DXE_EVENT_GROUP_GUID event. - // The notification function saves MTRRs for ACPI_CPU_DATA + // The notification function allocates StartupVector and saves MTRRs for ACPI_CPU_DATA // Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_CALLBACK, - SaveMtrrsOnEndOfDxe, - &AcpiCpuDataEx->MtrrTable, + CpuS3DataOnEndOfDxe, + AcpiCpuData, &gEfiEndOfDxeEventGroupGuid, &Event ); diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf b/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf index 857e12b..608e19f 100644 --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf +++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf @@ -9,7 +9,7 @@ # support hot plug CPUs. This module can be copied into a CPU specific package # and customized if these additional features are required. # -# Copyright (c) 2013-2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2013-2016, Intel Corporation. All rights reserved.
# Copyright (c) 2015, Red Hat, Inc. # # This program and the accompanying materials -- 2.7.4.windows.1