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