2 Sample to provide FSP wrapper platform sec related function.
4 Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Ppi/SecPlatformInformation.h>
12 #include <Ppi/SecPerformance.h>
14 #include <Library/LocalApicLib.h>
15 #include <Library/DebugLib.h>
16 #include <Library/BaseMemoryLib.h>
19 This interface conveys state information out of the Security (SEC) phase into PEI.
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.
25 @retval EFI_SUCCESS The data was successfully returned.
26 @retval EFI_BUFFER_TOO_SMALL The buffer was too small.
31 SecPlatformInformation (
32 IN CONST EFI_PEI_SERVICES
**PeiServices
,
33 IN OUT UINT64
*StructureSize
,
34 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD
*PlatformInformationRecord
38 This interface conveys performance information out of the Security (SEC) phase into PEI.
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.
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.
50 @retval EFI_SUCCESS The data was successfully returned.
56 IN CONST EFI_PEI_SERVICES
**PeiServices
,
57 IN PEI_SEC_PERFORMANCE_PPI
*This
,
58 OUT FIRMWARE_SEC_PERFORMANCE
*Performance
61 PEI_SEC_PERFORMANCE_PPI mSecPerformancePpi
= {
65 EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformPpi
[] = {
67 EFI_PEI_PPI_DESCRIPTOR_PPI
,
68 &gTopOfTemporaryRamPpiGuid
,
69 NULL
// To be patched later.
72 EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
,
73 &gPeiSecPerformancePpiGuid
,
79 A developer supplied function to perform platform specific operations.
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
88 @param[in,out] SecCoreData The same parameter as passing to PEI core. It
89 could be overridden by this function.
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.
95 EFI_PEI_PPI_DESCRIPTOR
*
98 IN OUT EFI_SEC_PEI_HAND_OFF
*SecCoreData
101 EFI_PEI_PPI_DESCRIPTOR
*PpiList
;
103 DEBUG((DEBUG_INFO
, "SecPlatformMain\n"));
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
));
114 InitializeApicTimer (0, (UINT32
) -1, TRUE
, 5);
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
120 PpiList
= (VOID
*)((UINTN
)SecCoreData
->PeiTemporaryRamBase
+ (UINTN
)SecCoreData
->PeiTemporaryRamSize
/2);
121 CopyMem (PpiList
, mPeiSecPlatformPpi
, sizeof(mPeiSecPlatformPpi
));
124 // Patch TopOfTemporaryRamPpi
126 PpiList
[0].Ppi
= (VOID
*)((UINTN
)SecCoreData
->TemporaryRamBase
+ SecCoreData
->TemporaryRamSize
);