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