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