]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/FspSupport/Library/SecFspPlatformSecLibVlv2/SecPlatformInformation.c
50e5cb2670f4c0302144975a13efc2151c929563
[mirror_edk2.git] / Vlv2TbltDevicePkg / FspSupport / Library / SecFspPlatformSecLibVlv2 / SecPlatformInformation.c
1 /** @file
2
3 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials are licensed and
5 made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php.
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 **/
13
14 #include <PiPei.h>
15
16 #include <Ppi/SecPlatformInformation.h>
17 #include <Ppi/TopOfTemporaryRam.h>
18
19 #include <Library/BaseMemoryLib.h>
20 #include <Library/DebugLib.h>
21
22 /**
23 This interface conveys state information out of the Security (SEC) phase into PEI.
24
25 @param PeiServices Pointer to the PEI Services Table.
26 @param StructureSize Pointer to the variable describing size of the input buffer.
27 @param PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.
28
29 @retval EFI_SUCCESS The data was successfully returned.
30 @retval EFI_BUFFER_TOO_SMALL The buffer was too small.
31
32 **/
33 EFI_STATUS
34 EFIAPI
35 SecPlatformInformation (
36 IN CONST EFI_PEI_SERVICES **PeiServices,
37 IN OUT UINT64 *StructureSize,
38 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord
39 )
40 {
41 UINT32 *Bist;
42 UINT32 Size;
43 UINT32 Count;
44 UINT32 TopOfTemporaryRam;
45 VOID *TopOfTemporaryRamPpi;
46 EFI_STATUS Status;
47
48 DEBUG ((DEBUG_INFO, "SecPlatformInformation\n"));
49
50 Status = (*PeiServices)->LocatePpi (
51 PeiServices,
52 &gTopOfTemporaryRamPpiGuid,
53 0,
54 NULL,
55 (VOID **) &TopOfTemporaryRamPpi
56 );
57 if (EFI_ERROR (Status)) {
58 return EFI_NOT_FOUND;
59 }
60
61 //
62 // The entries of BIST information, together with the number of them,
63 // reside in the bottom of stack, left untouched by normal stack operation.
64 // This routine copies the BIST information to the buffer pointed by
65 // PlatformInformationRecord for output.
66 //
67 TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof (UINT32);
68 TopOfTemporaryRam -= sizeof(UINT32) * 2;
69 Count = *((UINT32 *)(UINTN) (TopOfTemporaryRam - sizeof (UINT32)));
70 Size = Count * sizeof (IA32_HANDOFF_STATUS);
71
72 if ((*StructureSize) < (UINT64) Size) {
73 *StructureSize = Size;
74 return EFI_BUFFER_TOO_SMALL;
75 }
76
77 *StructureSize = Size;
78 Bist = (UINT32 *) (TopOfTemporaryRam - sizeof (UINT32) - Size);
79
80 CopyMem (PlatformInformationRecord, Bist, Size);
81
82 return EFI_SUCCESS;
83 }