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