2 Sample to provide SecPlatformInformation function.
4 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Ppi/SecPlatformInformation.h>
12 #include <Ppi/TopOfTemporaryRam.h>
14 #include <Library/BaseMemoryLib.h>
15 #include <Library/DebugLib.h>
18 This interface conveys state information out of the Security (SEC) phase into PEI.
20 @param[in] PeiServices Pointer to the PEI Services Table.
21 @param[in,out] StructureSize Pointer to the variable describing size of the input buffer.
22 @param[out] PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.
24 @retval EFI_SUCCESS The data was successfully returned.
25 @retval EFI_BUFFER_TOO_SMALL The buffer was too small.
30 SecPlatformInformation (
31 IN CONST EFI_PEI_SERVICES
**PeiServices
,
32 IN OUT UINT64
*StructureSize
,
33 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD
*PlatformInformationRecord
39 UINT32 TopOfTemporaryRam
;
40 VOID
*TopOfTemporaryRamPpi
;
43 DEBUG ((DEBUG_INFO
, "SecPlatformInformation\n"));
45 Status
= (*PeiServices
)->LocatePpi (
47 &gTopOfTemporaryRamPpiGuid
,
50 (VOID
**) &TopOfTemporaryRamPpi
52 if (EFI_ERROR (Status
)) {
57 // The entries of BIST information, together with the number of them,
58 // reside in the bottom of stack, left untouched by normal stack operation.
59 // This routine copies the BIST information to the buffer pointed by
60 // PlatformInformationRecord for output.
62 TopOfTemporaryRam
= (UINT32
)(UINTN
)TopOfTemporaryRamPpi
- sizeof (UINT32
);
63 TopOfTemporaryRam
-= sizeof(UINT32
) * 2;
64 Count
= *((UINT32
*)(UINTN
) (TopOfTemporaryRam
- sizeof (UINT32
)));
65 Size
= Count
* sizeof (IA32_HANDOFF_STATUS
);
67 if ((*StructureSize
) < (UINT64
) Size
) {
68 *StructureSize
= Size
;
69 return EFI_BUFFER_TOO_SMALL
;
72 *StructureSize
= Size
;
73 Bist
= (UINT32
*) (TopOfTemporaryRam
- sizeof (UINT32
) - Size
);
75 CopyMem (PlatformInformationRecord
, Bist
, Size
);