]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
ArmPkg/ArmCpuLib: switch to ASM_FUNC() asm macro
[mirror_edk2.git] / IntelFsp2Pkg / FspSecCore / SecFspApiChk.c
CommitLineData
cf1d4549
JY
1/** @file\r
2\r
3 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
4 This program and the accompanying materials\r
5 are licensed and made available under the terms and conditions of the BSD License\r
6 which accompanies this distribution. The full text of the license may be found at\r
7 http://opensource.org/licenses/bsd-license.php.\r
8\r
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12**/\r
13\r
14#include "SecFsp.h"\r
15\r
16\r
17/**\r
18 This function check the FSP API calling condition.\r
19\r
20 @param[in] ApiIdx Internal index of the FSP API.\r
21 @param[in] ApiParam Parameter of the FSP API.\r
22\r
23**/\r
24EFI_STATUS\r
25EFIAPI\r
26FspApiCallingCheck (\r
27 IN UINT8 ApiIdx,\r
28 IN VOID *ApiParam\r
29 )\r
30{\r
31 EFI_STATUS Status;\r
32 FSP_GLOBAL_DATA *FspData;\r
33\r
34 Status = EFI_SUCCESS;\r
35 FspData = GetFspGlobalDataPointer ();\r
36 \r
37 if (ApiIdx == NotifyPhaseApiIndex) {\r
38 //\r
39 // NotifyPhase check\r
40 //\r
41 if ((FspData == NULL) || ((UINT32)FspData == 0xFFFFFFFF)) {\r
42 Status = EFI_UNSUPPORTED;\r
43 } else {\r
44 if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {\r
45 Status = EFI_UNSUPPORTED;\r
46 }\r
47 }\r
48 } else if (ApiIdx == FspMemoryInitApiIndex) {\r
49 //\r
50 // FspMemoryInit check\r
51 //\r
52 if ((UINT32)FspData != 0xFFFFFFFF) {\r
53 Status = EFI_UNSUPPORTED;\r
54 } else if (EFI_ERROR (FspUpdSignatureCheck (ApiIdx, ApiParam))) {\r
55 Status = EFI_INVALID_PARAMETER;\r
56 }\r
57 } else if (ApiIdx == TempRamExitApiIndex) {\r
58 //\r
59 // TempRamExit check\r
60 //\r
61 if ((FspData == NULL) || ((UINT32)FspData == 0xFFFFFFFF)) {\r
62 Status = EFI_UNSUPPORTED;\r
63 } else {\r
64 if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {\r
65 Status = EFI_UNSUPPORTED;\r
66 }\r
67 }\r
68 } else if (ApiIdx == FspSiliconInitApiIndex) {\r
69 //\r
70 // FspSiliconInit check\r
71 //\r
72 if ((FspData == NULL) || ((UINT32)FspData == 0xFFFFFFFF)) {\r
73 Status = EFI_UNSUPPORTED;\r
74 } else {\r
75 if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {\r
76 Status = EFI_UNSUPPORTED;\r
77 } else if (EFI_ERROR (FspUpdSignatureCheck (ApiIdx, ApiParam))) {\r
78 Status = EFI_INVALID_PARAMETER;\r
79 }\r
80 }\r
81 } else {\r
82 Status = EFI_UNSUPPORTED;\r
83 }\r
84\r
85 if (!EFI_ERROR (Status)) {\r
86 if ((ApiIdx != FspMemoryInitApiIndex)) {\r
87 //\r
88 // For FspMemoryInit, the global data is not valid yet\r
89 // The API index will be updated by SecCore after the global data\r
90 // is initialized\r
91 //\r
92 SetFspApiCallingIndex (ApiIdx);\r
93 }\r
94 }\r
95 \r
96 return Status;\r
97}\r