]>
Commit | Line | Data |
---|---|---|
a33a2f62 JY |
1 | /** @file\r |
2 | Sample to provide SaveSecContext 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 | \r | |
16 | #include <PiPei.h>\r | |
17 | #include <Library/DebugLib.h>\r | |
18 | \r | |
19 | #include <Ppi/TopOfTemporaryRam.h>\r | |
20 | #include <Ppi/SecPlatformInformation.h>\r | |
21 | \r | |
22 | /**\r | |
23 | Save BIST value before call FspInit.\r | |
24 | \r | |
25 | @param[in] Bist BIST value.\r | |
26 | **/\r | |
27 | VOID\r | |
28 | AsmSaveBistValue (\r | |
29 | IN UINT32 Bist\r | |
30 | );\r | |
31 | \r | |
32 | /**\r | |
33 | Save Ticker value before call FspInit.\r | |
34 | \r | |
35 | @param[in] Ticker Ticker value.\r | |
36 | **/\r | |
37 | VOID\r | |
38 | AsmSaveTickerValue (\r | |
39 | IN UINT64 Ticker\r | |
40 | );\r | |
41 | \r | |
42 | /**\r | |
43 | Save SEC context before call FspInit.\r | |
44 | \r | |
45 | @param[in] PeiServices Pointer to PEI Services Table.\r | |
46 | **/\r | |
47 | VOID\r | |
48 | EFIAPI\r | |
49 | SaveSecContext (\r | |
50 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
51 | )\r | |
52 | {\r | |
53 | UINT32 *Bist;\r | |
54 | UINT64 *Ticker;\r | |
55 | UINT32 Size;\r | |
56 | UINT32 Count;\r | |
57 | UINT32 TopOfTemporaryRam;\r | |
58 | VOID *TopOfTemporaryRamPpi;\r | |
59 | EFI_STATUS Status;\r | |
60 | \r | |
61 | DEBUG ((DEBUG_INFO, "SaveSecContext - 0x%x\n", PeiServices));\r | |
62 | \r | |
63 | Status = (*PeiServices)->LocatePpi (\r | |
64 | PeiServices,\r | |
65 | &gTopOfTemporaryRamPpiGuid,\r | |
66 | 0,\r | |
67 | NULL,\r | |
68 | (VOID **) &TopOfTemporaryRamPpi\r | |
69 | );\r | |
70 | if (EFI_ERROR (Status)) {\r | |
71 | return ;\r | |
72 | }\r | |
73 | \r | |
74 | DEBUG ((DEBUG_INFO, "TopOfTemporaryRamPpi - 0x%x\n", TopOfTemporaryRamPpi));\r | |
75 | \r | |
76 | //\r | |
77 | // The entries of BIST information, together with the number of them,\r | |
78 | // reside in the bottom of stack, left untouched by normal stack operation.\r | |
79 | // This routine copies the BIST information to the buffer pointed by\r | |
80 | // PlatformInformationRecord for output.\r | |
81 | //\r | |
82 | // |--------------| <- TopOfTemporaryRam\r | |
83 | // |Number of BSPs|\r | |
84 | // |--------------|\r | |
85 | // | BIST |\r | |
86 | // |--------------|\r | |
87 | // | .... |\r | |
88 | // |--------------|\r | |
89 | // | TSC[63:32] |\r | |
90 | // |--------------|\r | |
91 | // | TSC[31:00] |\r | |
92 | // |--------------|\r | |
93 | //\r | |
94 | \r | |
95 | TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof(UINT32);\r | |
96 | TopOfTemporaryRam -= sizeof(UINT32) * 2;\r | |
97 | DEBUG ((DEBUG_INFO, "TopOfTemporaryRam - 0x%x\n", TopOfTemporaryRam));\r | |
98 | Count = *(UINT32 *)(UINTN)(TopOfTemporaryRam - sizeof(UINT32));\r | |
99 | DEBUG ((DEBUG_INFO, "Count - 0x%x\n", Count));\r | |
100 | Size = Count * sizeof (IA32_HANDOFF_STATUS);\r | |
101 | DEBUG ((DEBUG_INFO, "Size - 0x%x\n", Size));\r | |
102 | \r | |
103 | Bist = (UINT32 *)(UINTN)(TopOfTemporaryRam - sizeof(UINT32) - Size);\r | |
104 | DEBUG ((DEBUG_INFO, "Bist - 0x%x\n", *Bist));\r | |
105 | Ticker = (UINT64 *)(UINTN)(TopOfTemporaryRam - sizeof(UINT32) - Size - sizeof(UINT64));\r | |
106 | DEBUG ((DEBUG_INFO, "Ticker - 0x%lx\n", *Ticker));\r | |
107 | \r | |
108 | // Just need record BSP\r | |
109 | AsmSaveBistValue (*Bist);\r | |
110 | AsmSaveTickerValue (*Ticker);\r | |
111 | }\r |