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