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