]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/FspSupport/Library/SecFspPlatformSecLibVlv2/SecPlatformInformation.c
Vlv2TbltDevicePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Vlv2TbltDevicePkg / FspSupport / Library / SecFspPlatformSecLibVlv2 / SecPlatformInformation.c
1 /** @file
2
3 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
5
6 **/
7
8 #include <PiPei.h>
9
10 #include <Ppi/SecPlatformInformation.h>
11 #include <Ppi/TopOfTemporaryRam.h>
12
13 #include <Library/BaseMemoryLib.h>
14 #include <Library/DebugLib.h>
15
16 /**
17 This interface conveys state information out of the Security (SEC) phase into PEI.
18
19 @param PeiServices Pointer to the PEI Services Table.
20 @param StructureSize Pointer to the variable describing size of the input buffer.
21 @param PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.
22
23 @retval EFI_SUCCESS The data was successfully returned.
24 @retval EFI_BUFFER_TOO_SMALL The buffer was too small.
25
26 **/
27 EFI_STATUS
28 EFIAPI
29 SecPlatformInformation (
30 IN CONST EFI_PEI_SERVICES **PeiServices,
31 IN OUT UINT64 *StructureSize,
32 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord
33 )
34 {
35 UINT32 *Bist;
36 UINT32 Size;
37 UINT32 Count;
38 UINT32 TopOfTemporaryRam;
39 VOID *TopOfTemporaryRamPpi;
40 EFI_STATUS Status;
41
42 DEBUG ((DEBUG_INFO, "SecPlatformInformation\n"));
43
44 Status = (*PeiServices)->LocatePpi (
45 PeiServices,
46 &gTopOfTemporaryRamPpiGuid,
47 0,
48 NULL,
49 (VOID **) &TopOfTemporaryRamPpi
50 );
51 if (EFI_ERROR (Status)) {
52 return EFI_NOT_FOUND;
53 }
54
55 //
56 // The entries of BIST information, together with the number of them,
57 // reside in the bottom of stack, left untouched by normal stack operation.
58 // This routine copies the BIST information to the buffer pointed by
59 // PlatformInformationRecord for output.
60 //
61 TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof (UINT32);
62 TopOfTemporaryRam -= sizeof(UINT32) * 2;
63 Count = *((UINT32 *)(UINTN) (TopOfTemporaryRam - sizeof (UINT32)));
64 Size = Count * sizeof (IA32_HANDOFF_STATUS);
65
66 if ((*StructureSize) < (UINT64) Size) {
67 *StructureSize = Size;
68 return EFI_BUFFER_TOO_SMALL;
69 }
70
71 *StructureSize = Size;
72 Bist = (UINT32 *) (TopOfTemporaryRam - sizeof (UINT32) - Size);
73
74 CopyMem (PlatformInformationRecord, Bist, Size);
75
76 return EFI_SUCCESS;
77 }