TianoCore EDK2 master
Loading...
Searching...
No Matches
SecPlatformInformation.c
Go to the documentation of this file.
1
9#include <PiPei.h>
10
13
15#include <Library/DebugLib.h>
16
29EFIAPI
31 IN CONST EFI_PEI_SERVICES **PeiServices,
32 IN OUT UINT64 *StructureSize,
33 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord
34 )
35{
36 UINT32 *Bist;
37 UINT32 Size;
38 UINT32 Count;
39 UINT32 TopOfTemporaryRam;
40 VOID *TopOfTemporaryRamPpi;
41 EFI_STATUS Status;
42
43 DEBUG ((DEBUG_INFO, "SecPlatformInformation\n"));
44
45 Status = (*PeiServices)->LocatePpi (
46 PeiServices,
47 &gTopOfTemporaryRamPpiGuid,
48 0,
49 NULL,
50 (VOID **)&TopOfTemporaryRamPpi
51 );
52 if (EFI_ERROR (Status)) {
53 return EFI_NOT_FOUND;
54 }
55
56 //
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.
61 //
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);
66
67 if ((*StructureSize) < (UINT64)Size) {
68 *StructureSize = Size;
69 return EFI_BUFFER_TOO_SMALL;
70 }
71
72 *StructureSize = Size;
73 Bist = (UINT32 *)(TopOfTemporaryRam - sizeof (UINT32) - Size);
74
75 CopyMem (PlatformInformationRecord, Bist, Size);
76
77 return EFI_SUCCESS;
78}
UINT64 UINTN
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define DEBUG(Expression)
Definition: DebugLib.h:422
EFI_STATUS EFIAPI SecPlatformInformation(IN CONST EFI_PEI_SERVICES **PeiServices, IN OUT UINT64 *StructureSize, OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112