2 Sample to provide SaveSecContext function.
4 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/DebugLib.h>
13 #include <Ppi/TopOfTemporaryRam.h>
14 #include <Ppi/SecPlatformInformation.h>
17 Save BIST value before call FspInit.
19 @param[in] Bist BIST value.
27 Save Ticker value before call FspInit.
29 @param[in] Ticker Ticker value.
37 Save SEC context before call FspInit.
39 @param[in] PeiServices Pointer to PEI Services Table.
44 IN CONST EFI_PEI_SERVICES
**PeiServices
51 UINT32 TopOfTemporaryRam
;
52 VOID
*TopOfTemporaryRamPpi
;
55 DEBUG ((DEBUG_INFO
, "SaveSecContext - 0x%x\n", PeiServices
));
57 Status
= (*PeiServices
)->LocatePpi (
59 &gTopOfTemporaryRamPpiGuid
,
62 (VOID
**) &TopOfTemporaryRamPpi
64 if (EFI_ERROR (Status
)) {
68 DEBUG ((DEBUG_INFO
, "TopOfTemporaryRamPpi - 0x%x\n", TopOfTemporaryRamPpi
));
71 // The entries of BIST information, together with the number of them,
72 // reside in the bottom of stack, left untouched by normal stack operation.
73 // This routine copies the BIST information to the buffer pointed by
74 // PlatformInformationRecord for output.
76 // |--------------| <- TopOfTemporaryRam
89 TopOfTemporaryRam
= (UINT32
)(UINTN
)TopOfTemporaryRamPpi
- sizeof(UINT32
);
90 TopOfTemporaryRam
-= sizeof(UINT32
) * 2;
91 DEBUG ((DEBUG_INFO
, "TopOfTemporaryRam - 0x%x\n", TopOfTemporaryRam
));
92 Count
= *(UINT32
*)(UINTN
)(TopOfTemporaryRam
- sizeof(UINT32
));
93 DEBUG ((DEBUG_INFO
, "Count - 0x%x\n", Count
));
94 Size
= Count
* sizeof (IA32_HANDOFF_STATUS
);
95 DEBUG ((DEBUG_INFO
, "Size - 0x%x\n", Size
));
97 Bist
= (UINT32
*)(UINTN
)(TopOfTemporaryRam
- sizeof(UINT32
) - Size
);
98 DEBUG ((DEBUG_INFO
, "Bist - 0x%x\n", *Bist
));
99 Ticker
= (UINT64
*)(UINTN
)(TopOfTemporaryRam
- sizeof(UINT32
) - Size
- sizeof(UINT64
));
100 DEBUG ((DEBUG_INFO
, "Ticker - 0x%lx\n", *Ticker
));
102 // Just need record BSP
103 AsmSaveBistValue (*Bist
);
104 AsmSaveTickerValue (*Ticker
);