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