]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/FspWrapperPlatformSecLibSample.c
IntelFsp2WrapperPkg: Add support to handle ResetRequired return Status from FSP.
[mirror_edk2.git] / IntelFsp2WrapperPkg / Library / SecFspWrapperPlatformSecLibSample / FspWrapperPlatformSecLibSample.c
1 /** @file
2 Sample to provide FSP wrapper platform sec related function.
3
4 Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include <PiPei.h>
16
17 #include <Ppi/SecPlatformInformation.h>
18 #include <Ppi/SecPerformance.h>
19
20 #include <Library/LocalApicLib.h>
21
22 /**
23 This interface conveys state information out of the Security (SEC) phase into PEI.
24
25 @param[in] PeiServices Pointer to the PEI Services Table.
26 @param[in,out] StructureSize Pointer to the variable describing size of the input buffer.
27 @param[out] PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.
28
29 @retval EFI_SUCCESS The data was successfully returned.
30 @retval EFI_BUFFER_TOO_SMALL The buffer was too small.
31
32 **/
33 EFI_STATUS
34 EFIAPI
35 SecPlatformInformation (
36 IN CONST EFI_PEI_SERVICES **PeiServices,
37 IN OUT UINT64 *StructureSize,
38 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord
39 );
40
41 /**
42 This interface conveys performance information out of the Security (SEC) phase into PEI.
43
44 This service is published by the SEC phase. The SEC phase handoff has an optional
45 EFI_PEI_PPI_DESCRIPTOR list as its final argument when control is passed from SEC into the
46 PEI Foundation. As such, if the platform supports collecting performance data in SEC,
47 this information is encapsulated into the data structure abstracted by this service.
48 This information is collected for the boot-strap processor (BSP) on IA-32.
49
50 @param[in] PeiServices The pointer to the PEI Services Table.
51 @param[in] This The pointer to this instance of the PEI_SEC_PERFORMANCE_PPI.
52 @param[out] Performance The pointer to performance data collected in SEC phase.
53
54 @retval EFI_SUCCESS The data was successfully returned.
55
56 **/
57 EFI_STATUS
58 EFIAPI
59 SecGetPerformance (
60 IN CONST EFI_PEI_SERVICES **PeiServices,
61 IN PEI_SEC_PERFORMANCE_PPI *This,
62 OUT FIRMWARE_SEC_PERFORMANCE *Performance
63 );
64
65 PEI_SEC_PERFORMANCE_PPI mSecPerformancePpi = {
66 SecGetPerformance
67 };
68
69 EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformPpi[] = {
70 {
71 EFI_PEI_PPI_DESCRIPTOR_PPI,
72 &gTopOfTemporaryRamPpiGuid,
73 NULL // To be patched later.
74 },
75 {
76 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
77 &gPeiSecPerformancePpiGuid,
78 &mSecPerformancePpi
79 },
80 };
81
82 /**
83 A developer supplied function to perform platform specific operations.
84
85 It's a developer supplied function to perform any operations appropriate to a
86 given platform. It's invoked just before passing control to PEI core by SEC
87 core. Platform developer may modify the SecCoreData passed to PEI Core.
88 It returns a platform specific PPI list that platform wishes to pass to PEI core.
89 The Generic SEC core module will merge this list to join the final list passed to
90 PEI core.
91
92 @param[in,out] SecCoreData The same parameter as passing to PEI core. It
93 could be overridden by this function.
94
95 @return The platform specific PPI list to be passed to PEI core or
96 NULL if there is no need of such platform specific PPI list.
97
98 **/
99 EFI_PEI_PPI_DESCRIPTOR *
100 EFIAPI
101 SecPlatformMain (
102 IN OUT EFI_SEC_PEI_HAND_OFF *SecCoreData
103 )
104 {
105 EFI_PEI_PPI_DESCRIPTOR *PpiList;
106
107 DEBUG((DEBUG_INFO, "SecPlatformMain\n"));
108
109 DEBUG((DEBUG_INFO, "BootFirmwareVolumeBase - 0x%x\n", SecCoreData->BootFirmwareVolumeBase));
110 DEBUG((DEBUG_INFO, "BootFirmwareVolumeSize - 0x%x\n", SecCoreData->BootFirmwareVolumeSize));
111 DEBUG((DEBUG_INFO, "TemporaryRamBase - 0x%x\n", SecCoreData->TemporaryRamBase));
112 DEBUG((DEBUG_INFO, "TemporaryRamSize - 0x%x\n", SecCoreData->TemporaryRamSize));
113 DEBUG((DEBUG_INFO, "PeiTemporaryRamBase - 0x%x\n", SecCoreData->PeiTemporaryRamBase));
114 DEBUG((DEBUG_INFO, "PeiTemporaryRamSize - 0x%x\n", SecCoreData->PeiTemporaryRamSize));
115 DEBUG((DEBUG_INFO, "StackBase - 0x%x\n", SecCoreData->StackBase));
116 DEBUG((DEBUG_INFO, "StackSize - 0x%x\n", SecCoreData->StackSize));
117
118 InitializeApicTimer (0, (UINT32) -1, TRUE, 5);
119
120 //
121 // Use middle of Heap as temp buffer, it will be copied by caller.
122 // Do not use Stack, because it will cause wrong calculation on stack by PeiCore
123 //
124 PpiList = (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + (UINTN)SecCoreData->PeiTemporaryRamSize/2);
125 CopyMem (PpiList, mPeiSecPlatformPpi, sizeof(mPeiSecPlatformPpi));
126
127 //
128 // Patch TopOfTemporaryRamPpi
129 //
130 PpiList[0].Ppi = (VOID *)((UINTN)SecCoreData->TemporaryRamBase + SecCoreData->TemporaryRamSize);
131
132 return PpiList;
133 }