]>
Commit | Line | Data |
---|---|---|
cf1d4549 JY |
1 | /** @file\r |
2 | \r | |
f2cdb268 | 3 | Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>\r |
9672cd30 | 4 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
cf1d4549 JY |
5 | \r |
6 | **/\r | |
7 | \r | |
8 | #include "SecFsp.h"\r | |
9 | \r | |
10 | \r | |
11 | /**\r | |
12 | This function check the FSP API calling condition.\r | |
13 | \r | |
14 | @param[in] ApiIdx Internal index of the FSP API.\r | |
15 | @param[in] ApiParam Parameter of the FSP API.\r | |
16 | \r | |
17 | **/\r | |
18 | EFI_STATUS\r | |
19 | EFIAPI\r | |
20 | FspApiCallingCheck (\r | |
21 | IN UINT8 ApiIdx,\r | |
22 | IN VOID *ApiParam\r | |
23 | )\r | |
24 | {\r | |
25 | EFI_STATUS Status;\r | |
26 | FSP_GLOBAL_DATA *FspData;\r | |
27 | \r | |
28 | Status = EFI_SUCCESS;\r | |
29 | FspData = GetFspGlobalDataPointer ();\r | |
e37bb20c | 30 | \r |
cf1d4549 JY |
31 | if (ApiIdx == NotifyPhaseApiIndex) {\r |
32 | //\r | |
33 | // NotifyPhase check\r | |
34 | //\r | |
35 | if ((FspData == NULL) || ((UINT32)FspData == 0xFFFFFFFF)) {\r | |
36 | Status = EFI_UNSUPPORTED;\r | |
37 | } else {\r | |
38 | if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {\r | |
39 | Status = EFI_UNSUPPORTED;\r | |
40 | }\r | |
41 | }\r | |
42 | } else if (ApiIdx == FspMemoryInitApiIndex) {\r | |
43 | //\r | |
44 | // FspMemoryInit check\r | |
45 | //\r | |
46 | if ((UINT32)FspData != 0xFFFFFFFF) {\r | |
47 | Status = EFI_UNSUPPORTED;\r | |
48 | } else if (EFI_ERROR (FspUpdSignatureCheck (ApiIdx, ApiParam))) {\r | |
49 | Status = EFI_INVALID_PARAMETER;\r | |
50 | }\r | |
51 | } else if (ApiIdx == TempRamExitApiIndex) {\r | |
52 | //\r | |
53 | // TempRamExit check\r | |
54 | //\r | |
55 | if ((FspData == NULL) || ((UINT32)FspData == 0xFFFFFFFF)) {\r | |
56 | Status = EFI_UNSUPPORTED;\r | |
57 | } else {\r | |
58 | if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {\r | |
59 | Status = EFI_UNSUPPORTED;\r | |
60 | }\r | |
61 | }\r | |
f2cdb268 | 62 | } else if ((ApiIdx == FspSiliconInitApiIndex) || (ApiIdx == FspMultiPhaseSiInitApiIndex)) {\r |
cf1d4549 JY |
63 | //\r |
64 | // FspSiliconInit check\r | |
65 | //\r | |
66 | if ((FspData == NULL) || ((UINT32)FspData == 0xFFFFFFFF)) {\r | |
67 | Status = EFI_UNSUPPORTED;\r | |
68 | } else {\r | |
69 | if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {\r | |
70 | Status = EFI_UNSUPPORTED;\r | |
f2cdb268 | 71 | } else if (EFI_ERROR (FspUpdSignatureCheck (FspSiliconInitApiIndex, ApiParam))) {\r |
cf1d4549 JY |
72 | Status = EFI_INVALID_PARAMETER;\r |
73 | }\r | |
74 | }\r | |
75 | } else {\r | |
76 | Status = EFI_UNSUPPORTED;\r | |
77 | }\r | |
78 | \r | |
79 | if (!EFI_ERROR (Status)) {\r | |
80 | if ((ApiIdx != FspMemoryInitApiIndex)) {\r | |
81 | //\r | |
82 | // For FspMemoryInit, the global data is not valid yet\r | |
83 | // The API index will be updated by SecCore after the global data\r | |
84 | // is initialized\r | |
85 | //\r | |
86 | SetFspApiCallingIndex (ApiIdx);\r | |
87 | }\r | |
88 | }\r | |
e37bb20c | 89 | \r |
cf1d4549 JY |
90 | return Status;\r |
91 | }\r |