TianoCore EDK2 master
Loading...
Searching...
No Matches
FspMultiPhaseLib.c
Go to the documentation of this file.
1
9#include <PiPei.h>
13#include <Library/DebugLib.h>
14#include <Library/PcdLib.h>
15#include <FspEas/FspApi.h>
16#include <FspGlobalData.h>
17
19EFIAPI
20FspMultiPhaseSwitchStack (
21 )
22{
25
26 return EFI_SUCCESS;
27}
28
30EFIAPI
31FspVariableRequestSwitchStack (
32 IN FSP_MULTI_PHASE_VARIABLE_REQUEST_INFO_PARAMS *FspVariableRequestParams
33 )
34{
35 FSP_GLOBAL_DATA *FspData;
36
37 FspData = GetFspGlobalDataPointer ();
38 if (((UINTN)FspData == 0) || ((UINTN)FspData == 0xFFFFFFFF)) {
39 return EFI_UNSUPPORTED;
40 }
41
42 FspData->VariableRequestParameterPtr = (VOID *)FspVariableRequestParams;
43 SetFspApiReturnStatus (FSP_STATUS_VARIABLE_REQUEST);
45
46 return EFI_SUCCESS;
47}
48
61EFIAPI
63 IN UINT32 ApiIdx,
64 IN VOID *ApiParam
65 )
66{
67 FSP_MULTI_PHASE_PARAMS *FspMultiPhaseParams;
68 FSP_GLOBAL_DATA *FspData;
69 FSP_MULTI_PHASE_GET_NUMBER_OF_PHASES_PARAMS *FspMultiPhaseGetNumber;
70 BOOLEAN FspDataValid;
71 UINT32 NumberOfPhasesSupported;
72
73 FspDataValid = TRUE;
74 FspData = GetFspGlobalDataPointer ();
75 if (((UINTN)FspData == 0) || ((UINTN)FspData == 0xFFFFFFFF)) {
76 FspDataValid = FALSE;
77 }
78
79 //
80 // It is required that FspData->NumberOfPhases to be reset to 0 after
81 // current FSP component finished.
82 // The next component FspData->NumberOfPhases will only be re-initialized when FspData->NumberOfPhases = 0
83 //
84 if ((FspDataValid == TRUE) && (FspData->NumberOfPhases == 0)) {
85 FspData->NumberOfPhases = PcdGet32 (PcdMultiPhaseNumberOfPhases);
86 FspData->PhasesExecuted = 0;
87 if (FspMultiPhasePlatformGetNumberOfPhases (ApiIdx, &NumberOfPhasesSupported) == TRUE) {
88 //
89 // Platform has implemented runtime controlling for NumberOfPhasesSupported
90 //
91 FspData->NumberOfPhases = NumberOfPhasesSupported;
92 }
93 }
94
95 FspMultiPhaseParams = (FSP_MULTI_PHASE_PARAMS *)ApiParam;
96
97 if (FspDataValid == FALSE) {
98 return EFI_DEVICE_ERROR;
99 } else {
100 switch (FspMultiPhaseParams->MultiPhaseAction) {
101 case EnumMultiPhaseGetNumberOfPhases:
102 if ((FspMultiPhaseParams->MultiPhaseParamPtr == NULL) || (FspMultiPhaseParams->PhaseIndex != 0)) {
103 return EFI_INVALID_PARAMETER;
104 }
105
106 FspMultiPhaseGetNumber = (FSP_MULTI_PHASE_GET_NUMBER_OF_PHASES_PARAMS *)FspMultiPhaseParams->MultiPhaseParamPtr;
107 FspMultiPhaseGetNumber->NumberOfPhases = FspData->NumberOfPhases;
108 FspMultiPhaseGetNumber->PhasesExecuted = FspData->PhasesExecuted;
109 break;
110
111 case EnumMultiPhaseExecutePhase:
112 if ((FspMultiPhaseParams->PhaseIndex > FspData->PhasesExecuted) && (FspMultiPhaseParams->PhaseIndex <= FspData->NumberOfPhases)) {
113 FspData->PhasesExecuted = FspMultiPhaseParams->PhaseIndex;
114 return Loader2PeiSwitchStack ();
115 } else {
116 return EFI_INVALID_PARAMETER;
117 }
118
119 break;
120
121 case EnumMultiPhaseGetVariableRequestInfo:
122 //
123 // return variable request info
124 //
125 FspMultiPhaseParams->MultiPhaseParamPtr = FspData->VariableRequestParameterPtr;
126 break;
127
128 case EnumMultiPhaseCompleteVariableRequest:
129 //
130 // retrieve complete variable request params
131 //
132 FspData->VariableRequestParameterPtr = FspMultiPhaseParams->MultiPhaseParamPtr;
133 return Loader2PeiSwitchStack ();
134 break;
135
136 default:
137 return EFI_UNSUPPORTED;
138 }
139 }
140
141 return EFI_SUCCESS;
142}
143
156EFIAPI
158 IN UINT32 ApiIdx,
159 IN VOID *ApiParam
160 )
161{
162 return FspMultiPhaseWorker (ApiIdx, ApiParam);
163}
164
177EFIAPI
179 IN UINT32 ApiIdx,
180 IN VOID *ApiParam
181 )
182{
183 return FspMultiPhaseWorker (ApiIdx, ApiParam);
184}
UINT64 UINTN
VOID EFIAPI SetFspApiReturnStatus(IN UINTN ReturnStatus)
Definition: FspCommonLib.c:160
FSP_GLOBAL_DATA *EFIAPI GetFspGlobalDataPointer(VOID)
Definition: FspCommonLib.c:73
EFI_STATUS EFIAPI FspMultiPhaseMemInitApiHandler(IN UINT32 ApiIdx, IN VOID *ApiParam)
EFI_STATUS EFIAPI FspMultiPhaseSiInitApiHandlerV2(IN UINT32 ApiIdx, IN VOID *ApiParam)
EFI_STATUS EFIAPI FspMultiPhaseWorker(IN UINT32 ApiIdx, IN VOID *ApiParam)
BOOLEAN EFIAPI FspMultiPhasePlatformGetNumberOfPhases(IN UINTN ApiIdx, IN OUT UINT32 *NumberOfPhasesSupported)
EFI_STATUS EFIAPI Loader2PeiSwitchStack(VOID)
EFI_STATUS EFIAPI Pei2LoaderSwitchStack(VOID)
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112