]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecPlatformInformation.c
IntelFsp2WrapperPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFsp2WrapperPkg / Library / SecFspWrapperPlatformSecLibSample / SecPlatformInformation.c
1 /** @file
2 Sample to provide SecPlatformInformation function.
3
4 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include <PiPei.h>
10
11 #include <Ppi/SecPlatformInformation.h>
12 #include <Ppi/TopOfTemporaryRam.h>
13
14 #include <Library/BaseMemoryLib.h>
15 #include <Library/DebugLib.h>
16
17 /**
18 This interface conveys state information out of the Security (SEC) phase into PEI.
19
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.
23
24 @retval EFI_SUCCESS The data was successfully returned.
25 @retval EFI_BUFFER_TOO_SMALL The buffer was too small.
26
27 **/
28 EFI_STATUS
29 EFIAPI
30 SecPlatformInformation (
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 }