1 | /** @file
|
---|
2 |
|
---|
3 | Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.<BR>
|
---|
4 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
5 |
|
---|
6 | **/
|
---|
7 |
|
---|
8 | #include "SecFsp.h"
|
---|
9 |
|
---|
10 | /**
|
---|
11 | This function check the FSP API calling condition.
|
---|
12 |
|
---|
13 | @param[in] ApiIdx Internal index of the FSP API.
|
---|
14 | @param[in] ApiParam Parameter of the FSP API.
|
---|
15 |
|
---|
16 | **/
|
---|
17 | EFI_STATUS
|
---|
18 | EFIAPI
|
---|
19 | FspApiCallingCheck (
|
---|
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) || ((UINTN)FspData == MAX_ADDRESS) || ((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 (((UINTN)FspData != MAX_ADDRESS) && ((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) || ((UINTN)FspData == MAX_ADDRESS) || ((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) || ((UINTN)FspData == MAX_ADDRESS) || ((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) || ((UINTN)FspData == MAX_ADDRESS) || ((UINTN)FspData == MAX_UINT32)) {
|
---|
87 | Status = EFI_UNSUPPORTED;
|
---|
88 | }
|
---|
89 | } else if (ApiIdx == FspSmmInitApiIndex) {
|
---|
90 | //
|
---|
91 | // FspSmmInitApiIndex check
|
---|
92 | //
|
---|
93 | if ((FspData == NULL) || ((UINTN)FspData == MAX_ADDRESS) || ((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 | }
|
---|