]> git.proxmox.com Git - mirror_edk2.git/blame - Vlv2TbltDevicePkg/FspSupport/Library/SecFspPlatformSecLibVlv2/SaveSecContext.c
IntelFrameworkModulePkg: Refine casting expression result to bigger size
[mirror_edk2.git] / Vlv2TbltDevicePkg / FspSupport / Library / SecFspPlatformSecLibVlv2 / SaveSecContext.c
CommitLineData
3cbfba02
DW
1/** @file\r
2 This PEIM will parse the hoblist from fsp and report them into pei core.\r
3 This file contains the main entrypoint of the PEIM.\r
4\r
5 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16\r
17#include <PiPei.h>\r
18#include <Library/DebugLib.h>\r
19\r
20#include <Ppi/TopOfTemporaryRam.h>\r
21#include <Ppi/SecPlatformInformation.h>\r
22\r
23/**\r
24 Save BIST value before call FspInit.\r
25\r
26 @param Bist BIST value.\r
27**/\r
28VOID\r
29AsmSaveBistValue (\r
30 IN UINT32 Bist\r
31 );\r
32\r
33/**\r
34 Save Ticker value before call FspInit.\r
35\r
36 @param Ticker Ticker value.\r
37**/\r
38VOID\r
39AsmSaveTickerValue (\r
40 IN UINT64 Ticker\r
41 );\r
42\r
43/**\r
44 Save SEC context before call FspInit.\r
45\r
46 @param PeiServices Pointer to PEI Services Table.\r
47**/\r
48VOID\r
49EFIAPI\r
50SaveSecContext (\r
51 IN CONST EFI_PEI_SERVICES **PeiServices\r
52 )\r
53{\r
54 UINT32 *Bist;\r
55 UINT64 *Ticker;\r
56 UINT32 Size;\r
57 UINT32 Count;\r
58 UINT32 TopOfTemporaryRam;\r
59 VOID *TopOfTemporaryRamPpi;\r
60 EFI_STATUS Status;\r
61\r
62 DEBUG ((DEBUG_INFO, "SaveSecContext - 0x%x\n", PeiServices));\r
63\r
64 Status = (*PeiServices)->LocatePpi (\r
65 PeiServices,\r
66 &gTopOfTemporaryRamPpiGuid,\r
67 0,\r
68 NULL,\r
69 (VOID **) &TopOfTemporaryRamPpi\r
70 );\r
71 if (EFI_ERROR (Status)) {\r
72 return ;\r
73 }\r
74\r
75 DEBUG ((DEBUG_INFO, "TopOfTemporaryRamPpi - 0x%x\n", TopOfTemporaryRamPpi));\r
76\r
77 //\r
78 // The entries of BIST information, together with the number of them,\r
79 // reside in the bottom of stack, left untouched by normal stack operation.\r
80 // This routine copies the BIST information to the buffer pointed by\r
81 // PlatformInformationRecord for output.\r
82 //\r
83 // |--------------| <- TopOfTemporaryRam\r
84 // |Number of BSPs|\r
85 // |--------------|\r
86 // | BIST |\r
87 // |--------------|\r
88 // | .... |\r
89 // |--------------|\r
90 // | TSC[63:32] |\r
91 // |--------------|\r
92 // | TSC[31:00] |\r
93 // |--------------|\r
94 //\r
95\r
96 TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof(UINT32);\r
97 TopOfTemporaryRam -= sizeof(UINT32) * 2;\r
98 DEBUG ((DEBUG_INFO, "TopOfTemporaryRam - 0x%x\n", TopOfTemporaryRam));\r
99 Count = *(UINT32 *)(UINTN)(TopOfTemporaryRam - sizeof(UINT32));\r
100 DEBUG ((DEBUG_INFO, "Count - 0x%x\n", Count));\r
101 Size = Count * sizeof (IA32_HANDOFF_STATUS);\r
102 DEBUG ((DEBUG_INFO, "Size - 0x%x\n", Size));\r
103\r
104 Bist = (UINT32 *)(UINTN)(TopOfTemporaryRam - sizeof(UINT32) - Size);\r
105 DEBUG ((DEBUG_INFO, "Bist - 0x%x\n", *Bist));\r
106 Ticker = (UINT64 *)(UINTN)(TopOfTemporaryRam - sizeof(UINT32) - Size - sizeof(UINT64));\r
107 DEBUG ((DEBUG_INFO, "Ticker - 0x%lx\n", *Ticker));\r
108\r
109 //\r
110 // Just need record BSP\r
111 //\r
112 AsmSaveBistValue (*Bist);\r
113 AsmSaveTickerValue (*Ticker);\r
114}\r