]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFspWrapperPkg/Library/SecPeiFspPlatformSecLibSample/SecGetPerformance.c
IntelFspWrapperPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFspWrapperPkg / Library / SecPeiFspPlatformSecLibSample / SecGetPerformance.c
CommitLineData
a33a2f62
JY
1/** @file\r
2 Sample to provide SecGetPerformance function.\r
3\r
4 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
19486360 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
a33a2f62
JY
6\r
7**/\r
8\r
9#include <PiPei.h>\r
10\r
11#include <Ppi/SecPerformance.h>\r
12#include <Ppi/TopOfTemporaryRam.h>\r
13\r
14#include <Library/BaseMemoryLib.h>\r
15#include <Library/TimerLib.h>\r
16#include <Library/DebugLib.h>\r
17\r
18/**\r
19 This interface conveys performance information out of the Security (SEC) phase into PEI.\r
20\r
21 This service is published by the SEC phase. The SEC phase handoff has an optional\r
22 EFI_PEI_PPI_DESCRIPTOR list as its final argument when control is passed from SEC into the\r
23 PEI Foundation. As such, if the platform supports collecting performance data in SEC,\r
24 this information is encapsulated into the data structure abstracted by this service.\r
25 This information is collected for the boot-strap processor (BSP) on IA-32.\r
26\r
27 @param[in] PeiServices The pointer to the PEI Services Table.\r
28 @param[in] This The pointer to this instance of the PEI_SEC_PERFORMANCE_PPI.\r
29 @param[out] Performance The pointer to performance data collected in SEC phase.\r
30\r
31 @retval EFI_SUCCESS The data was successfully returned.\r
32\r
33**/\r
34EFI_STATUS\r
35EFIAPI\r
36SecGetPerformance (\r
37 IN CONST EFI_PEI_SERVICES **PeiServices,\r
38 IN PEI_SEC_PERFORMANCE_PPI *This,\r
39 OUT FIRMWARE_SEC_PERFORMANCE *Performance\r
40 )\r
41{\r
42 UINT32 Size;\r
43 UINT32 Count;\r
44 UINT32 TopOfTemporaryRam;\r
45 UINT64 Ticker;\r
46 VOID *TopOfTemporaryRamPpi;\r
47 EFI_STATUS Status;\r
48\r
49 DEBUG ((DEBUG_INFO, "SecGetPerformance\n"));\r
50\r
51 Status = (*PeiServices)->LocatePpi (\r
52 PeiServices,\r
53 &gTopOfTemporaryRamPpiGuid,\r
54 0,\r
55 NULL,\r
56 (VOID **) &TopOfTemporaryRamPpi\r
57 );\r
58 if (EFI_ERROR (Status)) {\r
59 return EFI_NOT_FOUND;\r
60 }\r
61\r
62 //\r
63 // |--------------| <- TopOfTemporaryRam\r
64 // |Number of BSPs|\r
65 // |--------------|\r
66 // | BIST |\r
67 // |--------------|\r
68 // | .... |\r
69 // |--------------|\r
70 // | TSC[63:32] |\r
71 // |--------------|\r
72 // | TSC[31:00] |\r
73 // |--------------|\r
74 //\r
75 TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof(UINT32);\r
76 TopOfTemporaryRam -= sizeof(UINT32) * 2;\r
77 Count = *(UINT32 *) (UINTN) (TopOfTemporaryRam - sizeof (UINT32));\r
78 Size = Count * sizeof (UINT64);\r
79\r
80 Ticker = *(UINT64 *) (UINTN) (TopOfTemporaryRam - sizeof (UINT32) - Size - sizeof (UINT32) * 2);\r
81 Performance->ResetEnd = GetTimeInNanoSecond (Ticker);\r
82\r
83 return EFI_SUCCESS;\r
84}\r