TianoCore EDK2 master
Loading...
Searching...
No Matches
FspWrapperApiLib.c
Go to the documentation of this file.
1
9#include <PiPei.h>
10
12#include <Library/BaseLib.h>
14
27 IN UINT64 Function,
28 IN UINT64 Param1,
29 IN UINT64 Param2
30 );
31
43 IN UINT64 Function,
44 IN UINT64 Param1,
45 IN UINT64 Param2
46 );
47
56EFIAPI
58 IN EFI_PHYSICAL_ADDRESS FlashFvFspBase
59 )
60{
61 UINT8 *CheckPointer;
62
63 CheckPointer = (UINT8 *)(UINTN)FlashFvFspBase;
64
65 if (((EFI_FIRMWARE_VOLUME_HEADER *)CheckPointer)->Signature != EFI_FVH_SIGNATURE) {
66 return NULL;
67 }
68
69 if (((EFI_FIRMWARE_VOLUME_HEADER *)CheckPointer)->ExtHeaderOffset != 0) {
70 CheckPointer = CheckPointer + ((EFI_FIRMWARE_VOLUME_HEADER *)CheckPointer)->ExtHeaderOffset;
71 CheckPointer = CheckPointer + ((EFI_FIRMWARE_VOLUME_EXT_HEADER *)CheckPointer)->ExtHeaderSize;
72 CheckPointer = (UINT8 *)ALIGN_POINTER (CheckPointer, 8);
73 } else {
74 CheckPointer = CheckPointer + ((EFI_FIRMWARE_VOLUME_HEADER *)CheckPointer)->HeaderLength;
75 }
76
77 CheckPointer = CheckPointer + sizeof (EFI_FFS_FILE_HEADER);
78
79 if (((EFI_RAW_SECTION *)CheckPointer)->Type != EFI_SECTION_RAW) {
80 return NULL;
81 }
82
83 CheckPointer = CheckPointer + sizeof (EFI_RAW_SECTION);
84
85 return (FSP_INFO_HEADER *)CheckPointer;
86}
87
96EFIAPI
98 IN NOTIFY_PHASE_PARAMS *NotifyPhaseParams
99 )
100{
101 FSP_INFO_HEADER *FspHeader;
102 FSP_NOTIFY_PHASE NotifyPhaseApi;
103 EFI_STATUS Status;
104 BOOLEAN InterruptState;
105
106 FspHeader = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspsBaseAddress));
107 if (FspHeader == NULL) {
108 return EFI_DEVICE_ERROR;
109 }
110
111 NotifyPhaseApi = (FSP_NOTIFY_PHASE)((UINTN)FspHeader->ImageBase + FspHeader->NotifyPhaseEntryOffset);
112 InterruptState = SaveAndDisableInterrupts ();
113 if ((FspHeader->ImageAttribute & IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT) == FSP_IA32) {
114 Status = Execute32BitCode ((UINTN)NotifyPhaseApi, (UINTN)NotifyPhaseParams, (UINTN)NULL);
115 } else {
116 Status = Execute64BitCode ((UINTN)NotifyPhaseApi, (UINTN)NotifyPhaseParams, (UINTN)NULL);
117 }
118
119 SetInterruptState (InterruptState);
120
121 return Status;
122}
123
133EFIAPI
135 IN VOID *FspmUpdDataPtr,
136 OUT VOID **HobListPtr
137 )
138{
139 FSP_INFO_HEADER *FspHeader;
140 FSP_MEMORY_INIT FspMemoryInitApi;
141 EFI_STATUS Status;
142 BOOLEAN InterruptState;
143
144 FspHeader = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspmBaseAddress));
145 if (FspHeader == NULL) {
146 return EFI_DEVICE_ERROR;
147 }
148
149 FspMemoryInitApi = (FSP_MEMORY_INIT)((UINTN)FspHeader->ImageBase + FspHeader->FspMemoryInitEntryOffset);
150 InterruptState = SaveAndDisableInterrupts ();
151 if ((FspHeader->ImageAttribute & IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT) == FSP_IA32) {
152 Status = Execute32BitCode ((UINTN)FspMemoryInitApi, (UINTN)FspmUpdDataPtr, (UINTN)HobListPtr);
153 } else {
154 Status = Execute64BitCode ((UINTN)FspMemoryInitApi, (UINTN)FspmUpdDataPtr, (UINTN)HobListPtr);
155 }
156
157 SetInterruptState (InterruptState);
158
159 return Status;
160}
161
170EFIAPI
172 IN VOID *TempRamExitParam
173 )
174{
175 FSP_INFO_HEADER *FspHeader;
176 FSP_TEMP_RAM_EXIT TempRamExitApi;
177 EFI_STATUS Status;
178 BOOLEAN InterruptState;
179
180 FspHeader = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspmBaseAddress));
181 if (FspHeader == NULL) {
182 return EFI_DEVICE_ERROR;
183 }
184
185 TempRamExitApi = (FSP_TEMP_RAM_EXIT)((UINTN)FspHeader->ImageBase + FspHeader->TempRamExitEntryOffset);
186 InterruptState = SaveAndDisableInterrupts ();
187 if ((FspHeader->ImageAttribute & IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT) == FSP_IA32) {
188 Status = Execute32BitCode ((UINTN)TempRamExitApi, (UINTN)TempRamExitParam, (UINTN)NULL);
189 } else {
190 Status = Execute64BitCode ((UINTN)TempRamExitApi, (UINTN)TempRamExitParam, (UINTN)NULL);
191 }
192
193 SetInterruptState (InterruptState);
194
195 return Status;
196}
197
206EFIAPI
208 IN VOID *FspsUpdDataPtr
209 )
210{
211 FSP_INFO_HEADER *FspHeader;
212 FSP_SILICON_INIT FspSiliconInitApi;
213 EFI_STATUS Status;
214 BOOLEAN InterruptState;
215
216 FspHeader = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspsBaseAddress));
217 if (FspHeader == NULL) {
218 return EFI_DEVICE_ERROR;
219 }
220
221 FspSiliconInitApi = (FSP_SILICON_INIT)((UINTN)FspHeader->ImageBase + FspHeader->FspSiliconInitEntryOffset);
222 InterruptState = SaveAndDisableInterrupts ();
223 if ((FspHeader->ImageAttribute & IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT) == FSP_IA32) {
224 Status = Execute32BitCode ((UINTN)FspSiliconInitApi, (UINTN)FspsUpdDataPtr, (UINTN)NULL);
225 } else {
226 Status = Execute64BitCode ((UINTN)FspSiliconInitApi, (UINTN)FspsUpdDataPtr, (UINTN)NULL);
227 }
228
229 SetInterruptState (InterruptState);
230
231 return Status;
232}
UINT64 UINTN
BOOLEAN EFIAPI SetInterruptState(IN BOOLEAN InterruptState)
Definition: Cpu.c:48
BOOLEAN EFIAPI SaveAndDisableInterrupts(VOID)
Definition: Cpu.c:21
EFI_STATUS(EFIAPI * FSP_NOTIFY_PHASE)(IN NOTIFY_PHASE_PARAMS *NotifyPhaseParamPtr)
Definition: FspApi.h:609
EFI_STATUS(EFIAPI * FSP_MEMORY_INIT)(IN VOID *FspmUpdDataPtr, OUT VOID **HobListPtr)
Definition: FspApi.h:637
EFI_STATUS(EFIAPI * FSP_TEMP_RAM_EXIT)(IN VOID *TempRamExitParamPtr)
Definition: FspApi.h:662
EFI_STATUS(EFIAPI * FSP_SILICON_INIT)(IN VOID *FspsUpdDataPtr)
Definition: FspApi.h:682
EFI_STATUS Execute32BitCode(IN UINT64 Function, IN UINT64 Param1, IN UINT64 Param2)
EFI_STATUS EFIAPI CallFspMemoryInit(IN VOID *FspmUpdDataPtr, OUT VOID **HobListPtr)
EFI_STATUS EFIAPI CallFspSiliconInit(IN VOID *FspsUpdDataPtr)
EFI_STATUS EFIAPI CallFspNotifyPhase(IN NOTIFY_PHASE_PARAMS *NotifyPhaseParams)
EFI_STATUS Execute64BitCode(IN UINT64 Function, IN UINT64 Param1, IN UINT64 Param2)
FSP_INFO_HEADER *EFIAPI FspFindFspHeader(IN EFI_PHYSICAL_ADDRESS FlashFvFspBase)
EFI_STATUS EFIAPI CallTempRamExit(IN VOID *TempRamExitParam)
#define NULL
Definition: Base.h:319
#define ALIGN_POINTER(Pointer, Alignment)
Definition: Base.h:963
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
UINT32 FspSiliconInitEntryOffset
UINT32 NotifyPhaseEntryOffset
UINT32 FspMemoryInitEntryOffset
UINT32 TempRamExitEntryOffset
UINT16 ImageAttribute
Definition: FspHeaderFile.h:99