--- /dev/null
+/** @file\r
+ Sample to provide FSP wrapper platform sec related function.\r
+\r
+ Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php.\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+\r
+#include <Ppi/SecPlatformInformation.h>\r
+#include <Ppi/SecPerformance.h>\r
+\r
+#include <Library/LocalApicLib.h>\r
+\r
+/**\r
+ This interface conveys state information out of the Security (SEC) phase into PEI.\r
+\r
+ @param[in] PeiServices Pointer to the PEI Services Table.\r
+ @param[in,out] StructureSize Pointer to the variable describing size of the input buffer.\r
+ @param[out] PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.\r
+\r
+ @retval EFI_SUCCESS The data was successfully returned.\r
+ @retval EFI_BUFFER_TOO_SMALL The buffer was too small.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SecPlatformInformation (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN OUT UINT64 *StructureSize,\r
+ OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord\r
+ );\r
+\r
+/**\r
+ This interface conveys performance information out of the Security (SEC) phase into PEI.\r
+\r
+ This service is published by the SEC phase. The SEC phase handoff has an optional\r
+ EFI_PEI_PPI_DESCRIPTOR list as its final argument when control is passed from SEC into the\r
+ PEI Foundation. As such, if the platform supports collecting performance data in SEC,\r
+ this information is encapsulated into the data structure abstracted by this service.\r
+ This information is collected for the boot-strap processor (BSP) on IA-32.\r
+\r
+ @param[in] PeiServices The pointer to the PEI Services Table.\r
+ @param[in] This The pointer to this instance of the PEI_SEC_PERFORMANCE_PPI.\r
+ @param[out] Performance The pointer to performance data collected in SEC phase.\r
+\r
+ @retval EFI_SUCCESS The data was successfully returned.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SecGetPerformance (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN PEI_SEC_PERFORMANCE_PPI *This,\r
+ OUT FIRMWARE_SEC_PERFORMANCE *Performance\r
+ );\r
+\r
+PEI_SEC_PERFORMANCE_PPI mSecPerformancePpi = {\r
+ SecGetPerformance\r
+};\r
+\r
+EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformPpi[] = {\r
+ {\r
+ EFI_PEI_PPI_DESCRIPTOR_PPI,\r
+ &gTopOfTemporaryRamPpiGuid,\r
+ NULL // To be patched later.\r
+ },\r
+ {\r
+ EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
+ &gPeiSecPerformancePpiGuid,\r
+ &mSecPerformancePpi\r
+ },\r
+};\r
+\r
+/**\r
+ A developer supplied function to perform platform specific operations.\r
+\r
+ It's a developer supplied function to perform any operations appropriate to a\r
+ given platform. It's invoked just before passing control to PEI core by SEC\r
+ core. Platform developer may modify the SecCoreData passed to PEI Core.\r
+ It returns a platform specific PPI list that platform wishes to pass to PEI core.\r
+ The Generic SEC core module will merge this list to join the final list passed to\r
+ PEI core.\r
+\r
+ @param[in,out] SecCoreData The same parameter as passing to PEI core. It\r
+ could be overridden by this function.\r
+\r
+ @return The platform specific PPI list to be passed to PEI core or\r
+ NULL if there is no need of such platform specific PPI list.\r
+\r
+**/\r
+EFI_PEI_PPI_DESCRIPTOR *\r
+EFIAPI\r
+SecPlatformMain (\r
+ IN OUT EFI_SEC_PEI_HAND_OFF *SecCoreData\r
+ )\r
+{\r
+ EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
+\r
+ DEBUG((DEBUG_INFO, "SecPlatformMain\n"));\r
+\r
+ DEBUG((DEBUG_INFO, "BootFirmwareVolumeBase - 0x%x\n", SecCoreData->BootFirmwareVolumeBase));\r
+ DEBUG((DEBUG_INFO, "BootFirmwareVolumeSize - 0x%x\n", SecCoreData->BootFirmwareVolumeSize));\r
+ DEBUG((DEBUG_INFO, "TemporaryRamBase - 0x%x\n", SecCoreData->TemporaryRamBase));\r
+ DEBUG((DEBUG_INFO, "TemporaryRamSize - 0x%x\n", SecCoreData->TemporaryRamSize));\r
+ DEBUG((DEBUG_INFO, "PeiTemporaryRamBase - 0x%x\n", SecCoreData->PeiTemporaryRamBase));\r
+ DEBUG((DEBUG_INFO, "PeiTemporaryRamSize - 0x%x\n", SecCoreData->PeiTemporaryRamSize));\r
+ DEBUG((DEBUG_INFO, "StackBase - 0x%x\n", SecCoreData->StackBase));\r
+ DEBUG((DEBUG_INFO, "StackSize - 0x%x\n", SecCoreData->StackSize));\r
+\r
+ InitializeApicTimer (0, (UINT32) -1, TRUE, 5);\r
+\r
+ //\r
+ // Use middle of Heap as temp buffer, it will be copied by caller.\r
+ // Do not use Stack, because it will cause wrong calculation on stack by PeiCore\r
+ //\r
+ PpiList = (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + (UINTN)SecCoreData->PeiTemporaryRamSize/2);\r
+ CopyMem (PpiList, mPeiSecPlatformPpi, sizeof(mPeiSecPlatformPpi));\r
+\r
+ //\r
+ // Patch TopOfTemporaryRamPpi\r
+ //\r
+ PpiList[0].Ppi = (VOID *)((UINTN)SecCoreData->TemporaryRamBase + SecCoreData->TemporaryRamSize);\r
+\r
+ return PpiList;\r
+}\r