2 Sample to provide SecPlatformInformation 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 <Ppi/SecPlatformInformation.h>
18 #include <Ppi/TopOfTemporaryRam.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/DebugLib.h>
24 This interface conveys state information out of the Security (SEC) phase into PEI.
26 @param[in] PeiServices Pointer to the PEI Services Table.
27 @param[in,out] StructureSize Pointer to the variable describing size of the input buffer.
28 @param[out] PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.
30 @retval EFI_SUCCESS The data was successfully returned.
31 @retval EFI_BUFFER_TOO_SMALL The buffer was too small.
36 SecPlatformInformation (
37 IN CONST EFI_PEI_SERVICES
**PeiServices
,
38 IN OUT UINT64
*StructureSize
,
39 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD
*PlatformInformationRecord
45 UINT32 TopOfTemporaryRam
;
46 VOID
*TopOfTemporaryRamPpi
;
49 DEBUG ((DEBUG_INFO
, "SecPlatformInformation\n"));
51 Status
= (*PeiServices
)->LocatePpi (
53 &gTopOfTemporaryRamPpiGuid
,
56 (VOID
**) &TopOfTemporaryRamPpi
58 if (EFI_ERROR (Status
)) {
63 // The entries of BIST information, together with the number of them,
64 // reside in the bottom of stack, left untouched by normal stack operation.
65 // This routine copies the BIST information to the buffer pointed by
66 // PlatformInformationRecord for output.
68 TopOfTemporaryRam
= (UINT32
)(UINTN
)TopOfTemporaryRamPpi
- sizeof (UINT32
);
69 TopOfTemporaryRam
-= sizeof(UINT32
) * 2;
70 Count
= *((UINT32
*)(UINTN
) (TopOfTemporaryRam
- sizeof (UINT32
)));
71 Size
= Count
* sizeof (IA32_HANDOFF_STATUS
);
73 if ((*StructureSize
) < (UINT64
) Size
) {
74 *StructureSize
= Size
;
75 return EFI_BUFFER_TOO_SMALL
;
78 *StructureSize
= Size
;
79 Bist
= (UINT32
*) (TopOfTemporaryRam
- sizeof (UINT32
) - Size
);
81 CopyMem (PlatformInformationRecord
, Bist
, Size
);