TianoCore EDK2 master
Loading...
Searching...
No Matches
SecFspApiChk.c
Go to the documentation of this file.
1
8#include "SecFsp.h"
9
18EFIAPI
20 IN UINT8 ApiIdx,
21 IN VOID *ApiParam
22 )
23{
24 EFI_STATUS Status;
25 FSP_GLOBAL_DATA *FspData;
26
27 Status = EFI_SUCCESS;
28 FspData = GetFspGlobalDataPointer ();
29
30 if (ApiIdx == NotifyPhaseApiIndex) {
31 //
32 // NotifyPhase check
33 //
34 if ((FspData == NULL) || ((UINT32)(UINTN)FspData == MAX_UINT32)) {
35 Status = EFI_UNSUPPORTED;
36 } else {
37 if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {
38 Status = EFI_UNSUPPORTED;
39 }
40 }
41 } else if (ApiIdx == FspMemoryInitApiIndex) {
42 //
43 // FspMemoryInit check
44 //
45 if ((UINT32)(UINTN)FspData != MAX_UINT32) {
46 Status = EFI_UNSUPPORTED;
47 } else if (ApiParam == NULL) {
48 Status = EFI_SUCCESS;
49 } else if (EFI_ERROR (FspUpdSignatureCheck (ApiIdx, ApiParam))) {
50 Status = EFI_INVALID_PARAMETER;
51 }
52 } else if (ApiIdx == TempRamExitApiIndex) {
53 //
54 // TempRamExit check
55 //
56 if ((FspData == NULL) || ((UINT32)(UINTN)FspData == MAX_UINT32)) {
57 Status = EFI_UNSUPPORTED;
58 } else {
59 if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {
60 Status = EFI_UNSUPPORTED;
61 }
62 }
63 } else if ((ApiIdx == FspSiliconInitApiIndex) || (ApiIdx == FspMultiPhaseSiInitApiIndex)) {
64 //
65 // FspSiliconInit check
66 //
67 if ((FspData == NULL) || ((UINT32)(UINTN)FspData == MAX_UINT32)) {
68 Status = EFI_UNSUPPORTED;
69 } else {
70 if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {
71 Status = EFI_UNSUPPORTED;
72 } else if (ApiIdx == FspSiliconInitApiIndex) {
73 if (ApiParam == NULL) {
74 Status = EFI_SUCCESS;
75 } else if (EFI_ERROR (FspUpdSignatureCheck (FspSiliconInitApiIndex, ApiParam))) {
76 Status = EFI_INVALID_PARAMETER;
77 }
78
79 //
80 // Reset MultiPhase NumberOfPhases to zero
81 //
82 FspData->NumberOfPhases = 0;
83 }
84 }
85 } else if (ApiIdx == FspMultiPhaseMemInitApiIndex) {
86 if ((FspData == NULL) || ((UINT32)(UINTN)FspData == MAX_UINT32)) {
87 Status = EFI_UNSUPPORTED;
88 }
89 } else if (ApiIdx == FspSmmInitApiIndex) {
90 //
91 // FspSmmInitApiIndex check
92 //
93 if ((FspData == NULL) || ((UINT32)(UINTN)FspData == MAX_UINT32)) {
94 Status = EFI_UNSUPPORTED;
95 } else {
96 if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {
97 Status = EFI_UNSUPPORTED;
98 } else if (ApiParam == NULL) {
99 Status = EFI_SUCCESS;
100 } else if (EFI_ERROR (FspUpdSignatureCheck (FspSmmInitApiIndex, ApiParam))) {
101 Status = EFI_INVALID_PARAMETER;
102 }
103 }
104 } else {
105 Status = EFI_UNSUPPORTED;
106 }
107
108 if (!EFI_ERROR (Status)) {
109 if ((ApiIdx != FspMemoryInitApiIndex)) {
110 //
111 // For FspMemoryInit, the global data is not valid yet
112 // The API index will be updated by SecCore after the global data
113 // is initialized
114 //
115 SetFspApiCallingIndex (ApiIdx);
116 }
117 }
118
119 return Status;
120}
UINT64 UINTN
FSP_GLOBAL_DATA *EFIAPI GetFspGlobalDataPointer(VOID)
Definition: FspCommonLib.c:73
VOID EFIAPI SetFspApiCallingIndex(UINT8 Index)
Definition: FspCommonLib.c:514
EFI_STATUS EFIAPI FspUpdSignatureCheck(IN UINT32 ApiIdx, IN VOID *ApiParam)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
EFI_STATUS EFIAPI FspApiCallingCheck(IN UINT8 ApiIdx, IN VOID *ApiParam)
Definition: SecFspApiChk.c:19
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112