]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / IntelFsp2Pkg / FspSecCore / SecFspApiChk.c
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 (EFI_ERROR (FspUpdSignatureCheck (ApiIdx, ApiParam))) {
48 Status = EFI_INVALID_PARAMETER;
49 }
50 } else if (ApiIdx == TempRamExitApiIndex) {
51 //
52 // TempRamExit check
53 //
54 if ((FspData == NULL) || ((UINTN)FspData == MAX_ADDRESS) || ((UINTN)FspData == MAX_UINT32)) {
55 Status = EFI_UNSUPPORTED;
56 } else {
57 if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {
58 Status = EFI_UNSUPPORTED;
59 }
60 }
61 } else if ((ApiIdx == FspSiliconInitApiIndex) || (ApiIdx == FspMultiPhaseSiInitApiIndex)) {
62 //
63 // FspSiliconInit check
64 //
65 if ((FspData == NULL) || ((UINTN)FspData == MAX_ADDRESS) || ((UINTN)FspData == MAX_UINT32)) {
66 Status = EFI_UNSUPPORTED;
67 } else {
68 if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {
69 Status = EFI_UNSUPPORTED;
70 } else if (EFI_ERROR (FspUpdSignatureCheck (FspSiliconInitApiIndex, ApiParam))) {
71 Status = EFI_INVALID_PARAMETER;
72 }
73 }
74 } else {
75 Status = EFI_UNSUPPORTED;
76 }
77
78 if (!EFI_ERROR (Status)) {
79 if ((ApiIdx != FspMemoryInitApiIndex)) {
80 //
81 // For FspMemoryInit, the global data is not valid yet
82 // The API index will be updated by SecCore after the global data
83 // is initialized
84 //
85 SetFspApiCallingIndex (ApiIdx);
86 }
87 }
88
89 return Status;
90 }