From 8d0a57d65a3163136cb866e8589947a11511d8de Mon Sep 17 00:00:00 2001 From: Ray Ni Date: Tue, 25 Feb 2025 11:47:00 +0800 Subject: [PATCH] IntelFsp2Pkg/FspSecCore: Update FSP global data in FSP-S/I entry Today when FspSiliconInit/FspSmmInit is called, the corresponding FSP-S/I UPD pointer is saved in FSP_GLOBAL_DATA by gen-specific code. Such code might be duplicated between different gens of FSP implementation. The change is to update FspSecCore module to set the UPD pointer in FSP_GLOBAL_DATA for all API calls: * FspMemoryInit * FspSiliconInit * FspSmmInit This can eliminate the gen-specific code. Signed-off-by: Ray Ni Cc: Chasel Chiu Cc: Nate DeSimone Cc: Duggapu Chinni B Cc: Star Zeng Cc: Ted Kuo Cc: Ashraf Ali S --- IntelFsp2Pkg/FspSecCore/SecFspApiChk.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c b/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c index 644c374bd6..94cb42e625 100644 --- a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c +++ b/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2025, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -10,6 +10,9 @@ /** This function check the FSP API calling condition. + It updates the FSP API index and UPD data pointer in FSP global data + when FspSiliconInit and FspSmmInit are called. + @param[in] ApiIdx Internal index of the FSP API. @param[in] ApiParam Parameter of the FSP API. @@ -23,6 +26,7 @@ FspApiCallingCheck ( { EFI_STATUS Status; FSP_GLOBAL_DATA *FspData; + FSP_INFO_HEADER *FspInfoHeader; Status = EFI_SUCCESS; FspData = GetFspGlobalDataPointer (); @@ -108,11 +112,22 @@ FspApiCallingCheck ( if (!EFI_ERROR (Status)) { if ((ApiIdx != FspMemoryInitApiIndex)) { // - // For FspMemoryInit, the global data is not valid yet - // The API index will be updated by SecCore after the global data - // is initialized + // Set "API Index" and "UPD Data Pointer" in FSP Global Data for FspSiliconInit and FspSmmInit + // For FspMemoryInit: The global data is not valid when code runs here. + // The 2 fields will be updated by SecCore after the global data is allocated in stack. // SetFspApiCallingIndex (ApiIdx); + + if (ApiParam == NULL) { + FspInfoHeader = (FSP_INFO_HEADER *)AsmGetFspInfoHeader (); + ApiParam = (VOID *)(UINTN)(FspInfoHeader->ImageBase + FspInfoHeader->CfgRegionOffset); + } + + if (ApiIdx == FspSiliconInitApiIndex) { + SetFspSiliconInitUpdDataPointer (ApiParam); + } else if (ApiIdx == FspSmmInitApiIndex) { + SetFspSmmInitUpdDataPointer (ApiParam); + } } }