Skip to content

Commit

Permalink
IntelFsp2Pkg: Add FSP 2.4 MultiPhase interface.
Browse files Browse the repository at this point in the history
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3916

Provide FSP 2.4 MultiPhase interface and scripts
support.

Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
  • Loading branch information
ChaselChiu authored and mergify[bot] committed Aug 31, 2022
1 parent 4b7bd4c commit df25a54
Show file tree
Hide file tree
Showing 10 changed files with 450 additions and 29 deletions.
64 changes: 61 additions & 3 deletions IntelFsp2Pkg/Include/FspEas/FspApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,38 @@ typedef struct {
/// Action definition for FspMultiPhaseSiInit API
///
typedef enum {
EnumMultiPhaseGetNumberOfPhases = 0x0,
EnumMultiPhaseExecutePhase = 0x1
EnumMultiPhaseGetNumberOfPhases = 0x0,
EnumMultiPhaseExecutePhase = 0x1,
EnumMultiPhaseGetVariableRequestInfo = 0x2,
EnumMultiPhaseCompleteVariableRequest = 0x3
} FSP_MULTI_PHASE_ACTION;

typedef enum {
EnumFspVariableRequestGetVariable = 0x0,
EnumFspVariableRequestGetNextVariableName = 0x1,
EnumFspVariableRequestSetVariable = 0x2,
EnumFspVariableRequestQueryVariableInfo = 0x3
} FSP_VARIABLE_REQUEST_TYPE;

#pragma pack(16)
typedef struct {
IN FSP_VARIABLE_REQUEST_TYPE VariableRequest;
IN OUT CHAR16 *VariableName;
IN OUT UINT64 *VariableNameSize;
IN OUT EFI_GUID *VariableGuid;
IN OUT UINT32 *Attributes;
IN OUT UINT64 *DataSize;
IN OUT VOID *Data;
OUT UINT64 *MaximumVariableStorageSize;
OUT UINT64 *RemainingVariableStorageSize;
OUT UINT64 *MaximumVariableSize;
} FSP_MULTI_PHASE_VARIABLE_REQUEST_INFO_PARAMS;

typedef struct {
EFI_STATUS VariableRequestStatus;
} FSP_MULTI_PHASE_COMPLETE_VARIABLE_REQUEST_PARAMS;
#pragma pack()

///
/// Data structure returned by FSP when bootloader calling
/// FspMultiPhaseSiInit API with action 0 (EnumMultiPhaseGetNumberOfPhases)
Expand Down Expand Up @@ -594,7 +622,7 @@ EFI_STATUS
@retval EFI_UNSUPPORTED The FSP calling conditions were not met.
@retval EFI_DEVICE_ERROR FSP initialization failed.
@retval EFI_OUT_OF_RESOURCES Stack range requested by FSP is not met.
@retval FSP_STATUS_RESET_REQUIREDx A reset is reuired. These status codes will not be returned during S3.
@retval FSP_STATUS_RESET_REQUIREDx A reset is required. These status codes will not be returned during S3.
**/
typedef
EFI_STATUS
Expand Down Expand Up @@ -690,4 +718,34 @@ EFI_STATUS
IN VOID *FspiUpdDataPtr
);

/**
This FSP API provides multi-phase memory and silicon initialization, which brings greater modularity to the existing
FspMemoryInit() and FspSiliconInit() API. Increased modularity is achieved by adding an extra API to FSP-M and FSP-S.
This allows the bootloader to add board specific initialization steps throughout the MemoryInit and SiliconInit flows as needed.
The FspMemoryInit() API is always called before FspMultiPhaseMemInit(); it is the first phase of memory initialization. Similarly,
the FspSiliconInit() API is always called before FspMultiPhaseSiInit(); it is the first phase of silicon initialization.
After the first phase, subsequent phases are invoked by calling the FspMultiPhaseMem/SiInit() API.
The FspMultiPhaseMemInit() API may only be called after the FspMemoryInit() API and before the FspSiliconInit() API;
or in the case that FSP-T is being used, before the TempRamExit() API. The FspMultiPhaseSiInit() API may only be called after
the FspSiliconInit() API and before NotifyPhase() API; or in the case that FSP-I is being used, before the FspSmmInit() API.
The multi-phase APIs may not be called at any other time.
@param[in,out] FSP_MULTI_PHASE_PARAMS For action - EnumMultiPhaseGetNumberOfPhases:
FSP_MULTI_PHASE_PARAMS->MultiPhaseParamPtr will contain
how many phases supported by FSP.
For action - EnumMultiPhaseExecutePhase:
FSP_MULTI_PHASE_PARAMS->MultiPhaseParamPtr shall be NULL.
@retval EFI_SUCCESS FSP execution environment was initialized successfully.
@retval EFI_INVALID_PARAMETER Input parameters are invalid.
@retval EFI_UNSUPPORTED The FSP calling conditions were not met.
@retval EFI_DEVICE_ERROR FSP initialization failed.
@retval FSP_STATUS_RESET_REQUIRED_* A reset is required. These status codes will not be returned during S3.
@retval FSP_STATUS_VARIABLE_REQUEST A variable request has been made by FSP that needs boot loader handling.
**/
typedef
EFI_STATUS
(EFIAPI *FSP_MULTI_PHASE_INIT)(
IN FSP_MULTI_PHASE_PARAMS *MultiPhaseInitParamPtr
);

#endif
5 changes: 4 additions & 1 deletion IntelFsp2Pkg/Include/FspGlobalData.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#define FSP_IN_API_MODE 0
#define FSP_IN_DISPATCH_MODE 1
#define FSP_GLOBAL_DATA_VERSION 0x2
#define FSP_GLOBAL_DATA_VERSION 0x3

#pragma pack(1)

Expand All @@ -25,6 +25,7 @@ typedef enum {
FspSiliconInitApiIndex,
FspMultiPhaseSiInitApiIndex,
FspSmmInitApiIndex,
FspMultiPhaseMemInitApiIndex,
FspApiIndexMax
} FSP_API_INDEX;

Expand Down Expand Up @@ -82,6 +83,8 @@ typedef struct {
VOID *FunctionParameterPtr;
FSP_INFO_HEADER *FspInfoHeader;
VOID *UpdDataPtr;
VOID *FspHobListPtr;
VOID *VariableRequestParameterPtr;
///
/// End of UINTN and pointer section
/// At this point, next field offset must be either *0h or *8h to
Expand Down
55 changes: 55 additions & 0 deletions IntelFsp2Pkg/Include/Library/FspMultiPhaseLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/** @file
FSP MultiPhase Library.
Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef _FSP_MULTIPHASE_LIB_H_
#define _FSP_MULTIPHASE_LIB_H_

EFI_STATUS
EFIAPI
FspMultiPhaseSwitchStack (
);

EFI_STATUS
EFIAPI
FspVariableRequestSwitchStack (
IN FSP_MULTI_PHASE_VARIABLE_REQUEST_INFO_PARAMS *FspVariableRequestParams
);

/**
This function handles FspMultiPhaseMemInitApi.
@param[in] ApiIdx Internal index of the FSP API.
@param[in] ApiParam Parameter of the FSP API.
@retval EFI_SUCCESS FSP execution was successful.
@retval EFI_INVALID_PARAMETER Input parameters are invalid.
@retval EFI_UNSUPPORTED The FSP calling conditions were not met.
@retval EFI_DEVICE_ERROR FSP initialization failed.
**/
EFI_STATUS
EFIAPI
FspMultiPhaseMemInitApiHandler (
IN UINT32 ApiIdx,
IN VOID *ApiParam
);

/**
This function handles FspMultiPhaseSiInitApi.
@param[in] ApiIdx Internal index of the FSP API.
@param[in] ApiParam Parameter of the FSP API.
**/
EFI_STATUS
EFIAPI
FspMultiPhaseSiInitApiHandlerV2 (
IN UINT32 ApiIdx,
IN VOID *ApiParam
);

#endif
23 changes: 23 additions & 0 deletions IntelFsp2Pkg/Include/Library/FspSecPlatformLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ FspUpdSignatureCheck (

/**
This function handles FspMultiPhaseSiInitApi.
Starting from FSP 2.4 this function is obsolete and FspMultiPhaseSiInitApiHandlerV2 is the replacement.
@param[in] ApiIdx Internal index of the FSP API.
@param[in] ApiParam Parameter of the FSP API.
Expand All @@ -93,4 +94,26 @@ FspMultiPhaseSiInitApiHandler (
IN VOID *ApiParam
);

/**
FSP MultiPhase Platform Get Number Of Phases Function.
Allows an FSP binary to dynamically update the number of phases at runtime.
For example, UPD settings could negate the need to enter the multi-phase flow
in certain scenarios. If this function returns FALSE, the default number of phases
provided by PcdMultiPhaseNumberOfPhases will be returned to the bootloader instead.
@param[in] ApiIdx - Internal index of the FSP API.
@param[in] NumberOfPhasesSupported - How many phases are supported by current FSP Component.
@retval TRUE - NumberOfPhases are modified by Platform during runtime.
@retval FALSE - The Default build time NumberOfPhases should be used.
**/
BOOLEAN
EFIAPI
FspMultiPhasePlatformGetNumberOfPhases (
IN UINTN ApiIdx,
IN OUT UINT32 *NumberOfPhasesSupported
);

#endif
12 changes: 10 additions & 2 deletions IntelFsp2Pkg/IntelFsp2Pkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
## @libraryclass Provides FSP platform sec related actions.
FspSecPlatformLib|Include/Library/FspSecPlatformLib.h

## @libraryclass Provides FSP MultiPhase service functions.
FspMultiPhaseLib|Include/Library/FspMultiPhaseLib.h

[Ppis]
#
# PPI to indicate FSP is ready to enter notify phase
Expand Down Expand Up @@ -112,5 +115,10 @@
gIntelFsp2PkgTokenSpaceGuid.PcdFspPrivateTemporaryRamSize |0x00000000|UINT32|0x10000006

[PcdsFixedAtBuild,PcdsDynamic,PcdsDynamicEx]
gIntelFsp2PkgTokenSpaceGuid.PcdFspReservedMemoryLength |0x00100000|UINT32|0x46530000
gIntelFsp2PkgTokenSpaceGuid.PcdBootLoaderEntry |0xFFFFFFE4|UINT32|0x46530100
gIntelFsp2PkgTokenSpaceGuid.PcdFspReservedMemoryLength |0x00100000|UINT32|0x46530000
gIntelFsp2PkgTokenSpaceGuid.PcdBootLoaderEntry |0xFFFFFFE4|UINT32|0x46530100
#
# Different FSP Components may have different NumberOfPhases which can be defined
# by each FspSecCore module from DSC.
#
gIntelFsp2PkgTokenSpaceGuid.PcdMultiPhaseNumberOfPhases |0x00000000|UINT32|0x46530101
4 changes: 4 additions & 0 deletions IntelFsp2Pkg/IntelFsp2Pkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
FspPlatformLib|IntelFsp2Pkg/Library/BaseFspPlatformLib/BaseFspPlatformLib.inf
FspSwitchStackLib|IntelFsp2Pkg/Library/BaseFspSwitchStackLib/BaseFspSwitchStackLib.inf
FspSecPlatformLib|IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNull.inf
FspMultiPhaseLib|IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/BaseFspMultiPhaseLib.inf

[LibraryClasses.common.PEIM]
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
Expand All @@ -64,12 +65,15 @@
IntelFsp2Pkg/Library/BaseFspSwitchStackLib/BaseFspSwitchStackLib.inf
IntelFsp2Pkg/Library/BaseDebugDeviceLibNull/BaseDebugDeviceLibNull.inf
IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNull.inf
IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/BaseFspMultiPhaseLib.inf

IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf
IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
IntelFsp2Pkg/FspSecCore/Fsp24SecCoreM.inf
IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf
IntelFsp2Pkg/FspSecCore/FspSecCoreI.inf
IntelFsp2Pkg/FspSecCore/Fsp22SecCoreS.inf
IntelFsp2Pkg/FspSecCore/Fsp24SecCoreS.inf
IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.inf

[PcdsFixedAtBuild.common]
Expand Down
50 changes: 50 additions & 0 deletions IntelFsp2Pkg/Library/BaseFspMultiPhaseLib/BaseFspMultiPhaseLib.inf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## @file
# FSP MultiPhase Lib.
#
# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##

################################################################################
#
# Defines Section - statements that will be processed to create a Makefile.
#
################################################################################
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BaseFspMultiPhaseLib
FILE_GUID = C128CADC-623E-4E41-97CB-A7138E627460
MODULE_TYPE = SEC
VERSION_STRING = 1.0
LIBRARY_CLASS = FspMultiPhaseLib

#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64
#

################################################################################
#
# Sources Section - list of files that are required for the build to succeed.
#
################################################################################

[Sources]
FspMultiPhaseLib.c

################################################################################
#
# Package Dependency Section - list of Package files that are required for
# this module.
#
################################################################################

[Packages]
MdePkg/MdePkg.dec
IntelFsp2Pkg/IntelFsp2Pkg.dec

[Pcd]
gIntelFsp2PkgTokenSpaceGuid.PcdMultiPhaseNumberOfPhases # CONSUMES

0 comments on commit df25a54

Please sign in to comment.