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