]>
Commit | Line | Data |
---|---|---|
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 | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php.\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include <PiPei.h>\r | |
16 | \r | |
17 | #include <Ppi/SecPerformance.h>\r | |
18 | #include <Ppi/TopOfTemporaryRam.h>\r | |
19 | \r | |
20 | #include <Library/BaseMemoryLib.h>\r | |
21 | #include <Library/TimerLib.h>\r | |
22 | #include <Library/DebugLib.h>\r | |
23 | \r | |
24 | /**\r | |
25 | This interface conveys performance information out of the Security (SEC) phase into PEI.\r | |
26 | \r | |
27 | This service is published by the SEC phase. The SEC phase handoff has an optional\r | |
28 | EFI_PEI_PPI_DESCRIPTOR list as its final argument when control is passed from SEC into the\r | |
29 | PEI Foundation. As such, if the platform supports collecting performance data in SEC,\r | |
30 | this information is encapsulated into the data structure abstracted by this service.\r | |
31 | This information is collected for the boot-strap processor (BSP) on IA-32.\r | |
32 | \r | |
33 | @param[in] PeiServices The pointer to the PEI Services Table.\r | |
34 | @param[in] This The pointer to this instance of the PEI_SEC_PERFORMANCE_PPI.\r | |
35 | @param[out] Performance The pointer to performance data collected in SEC phase.\r | |
36 | \r | |
37 | @retval EFI_SUCCESS The data was successfully returned.\r | |
38 | \r | |
39 | **/\r | |
40 | EFI_STATUS\r | |
41 | EFIAPI\r | |
42 | SecGetPerformance (\r | |
43 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
44 | IN PEI_SEC_PERFORMANCE_PPI *This,\r | |
45 | OUT FIRMWARE_SEC_PERFORMANCE *Performance\r | |
46 | )\r | |
47 | {\r | |
48 | UINT32 Size;\r | |
49 | UINT32 Count;\r | |
50 | UINT32 TopOfTemporaryRam;\r | |
51 | UINT64 Ticker;\r | |
52 | VOID *TopOfTemporaryRamPpi;\r | |
53 | EFI_STATUS Status;\r | |
54 | \r | |
55 | DEBUG ((DEBUG_INFO, "SecGetPerformance\n"));\r | |
56 | \r | |
57 | Status = (*PeiServices)->LocatePpi (\r | |
58 | PeiServices,\r | |
59 | &gTopOfTemporaryRamPpiGuid,\r | |
60 | 0,\r | |
61 | NULL,\r | |
62 | (VOID **) &TopOfTemporaryRamPpi\r | |
63 | );\r | |
64 | if (EFI_ERROR (Status)) {\r | |
65 | return EFI_NOT_FOUND;\r | |
66 | }\r | |
67 | \r | |
68 | //\r | |
69 | // |--------------| <- TopOfTemporaryRam\r | |
70 | // |Number of BSPs|\r | |
71 | // |--------------|\r | |
72 | // | BIST |\r | |
73 | // |--------------|\r | |
74 | // | .... |\r | |
75 | // |--------------|\r | |
76 | // | TSC[63:32] |\r | |
77 | // |--------------|\r | |
78 | // | TSC[31:00] |\r | |
79 | // |--------------|\r | |
80 | //\r | |
81 | TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof(UINT32);\r | |
82 | TopOfTemporaryRam -= sizeof(UINT32) * 2;\r | |
83 | Count = *(UINT32 *) (UINTN) (TopOfTemporaryRam - sizeof (UINT32));\r | |
84 | Size = Count * sizeof (UINT64);\r | |
85 | \r | |
86 | Ticker = *(UINT64 *) (UINTN) (TopOfTemporaryRam - sizeof (UINT32) - Size - sizeof (UINT32) * 2);\r | |
87 | Performance->ResetEnd = GetTimeInNanoSecond (Ticker);\r | |
88 | \r | |
89 | return EFI_SUCCESS;\r | |
90 | }\r |