2 Sample to provide SaveSecContext function.
4 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Library/DebugLib.h>
19 #include <Ppi/TopOfTemporaryRam.h>
20 #include <Ppi/SecPlatformInformation.h>
23 Save BIST value before call FspInit.
25 @param[in] Bist BIST value.
33 Save Ticker value before call FspInit.
35 @param[in] Ticker Ticker value.
43 Save SEC context before call FspInit.
45 @param[in] PeiServices Pointer to PEI Services Table.
50 IN CONST EFI_PEI_SERVICES
**PeiServices
57 UINT32 TopOfTemporaryRam
;
58 VOID
*TopOfTemporaryRamPpi
;
61 DEBUG ((DEBUG_INFO
, "SaveSecContext - 0x%x\n", PeiServices
));
63 Status
= (*PeiServices
)->LocatePpi (
65 &gTopOfTemporaryRamPpiGuid
,
68 (VOID
**) &TopOfTemporaryRamPpi
70 if (EFI_ERROR (Status
)) {
74 DEBUG ((DEBUG_INFO
, "TopOfTemporaryRamPpi - 0x%x\n", TopOfTemporaryRamPpi
));
77 // The entries of BIST information, together with the number of them,
78 // reside in the bottom of stack, left untouched by normal stack operation.
79 // This routine copies the BIST information to the buffer pointed by
80 // PlatformInformationRecord for output.
82 // |--------------| <- TopOfTemporaryRam
95 TopOfTemporaryRam
= (UINT32
)(UINTN
)TopOfTemporaryRamPpi
- sizeof(UINT32
);
96 TopOfTemporaryRam
-= sizeof(UINT32
) * 2;
97 DEBUG ((DEBUG_INFO
, "TopOfTemporaryRam - 0x%x\n", TopOfTemporaryRam
));
98 Count
= *(UINT32
*)(UINTN
)(TopOfTemporaryRam
- sizeof(UINT32
));
99 DEBUG ((DEBUG_INFO
, "Count - 0x%x\n", Count
));
100 Size
= Count
* sizeof (IA32_HANDOFF_STATUS
);
101 DEBUG ((DEBUG_INFO
, "Size - 0x%x\n", Size
));
103 Bist
= (UINT32
*)(UINTN
)(TopOfTemporaryRam
- sizeof(UINT32
) - Size
);
104 DEBUG ((DEBUG_INFO
, "Bist - 0x%x\n", *Bist
));
105 Ticker
= (UINT64
*)(UINTN
)(TopOfTemporaryRam
- sizeof(UINT32
) - Size
- sizeof(UINT64
));
106 DEBUG ((DEBUG_INFO
, "Ticker - 0x%lx\n", *Ticker
));
108 // Just need record BSP
109 AsmSaveBistValue (*Bist
);
110 AsmSaveTickerValue (*Ticker
);