]>
Commit | Line | Data |
---|---|---|
863c738c JF |
1 | /** @file\r |
2 | Get SEC platform information(2) PPI and reinstall it.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2016, 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 "SecMain.h"\r | |
16 | \r | |
17 | /**\r | |
18 | Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.\r | |
19 | \r | |
20 | @param PeiServices The pointer to the PEI Services Table.\r | |
21 | @param StructureSize The pointer to the variable describing size of the input buffer.\r | |
22 | @param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2.\r | |
23 | \r | |
24 | @retval EFI_SUCCESS The data was successfully returned.\r | |
25 | @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to\r | |
26 | hold the record is returned in StructureSize.\r | |
27 | \r | |
28 | **/\r | |
29 | EFI_STATUS\r | |
30 | EFIAPI\r | |
31 | SecPlatformInformation2 (\r | |
32 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
33 | IN OUT UINT64 *StructureSize,\r | |
34 | OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2\r | |
35 | )\r | |
36 | {\r | |
37 | EFI_HOB_GUID_TYPE *GuidHob;\r | |
38 | VOID *DataInHob;\r | |
39 | UINTN DataSize;\r | |
40 | \r | |
41 | GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid);\r | |
42 | if (GuidHob == NULL) {\r | |
43 | *StructureSize = 0;\r | |
44 | return EFI_SUCCESS;\r | |
45 | }\r | |
46 | \r | |
47 | DataInHob = GET_GUID_HOB_DATA (GuidHob);\r | |
48 | DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob);\r | |
49 | \r | |
50 | //\r | |
51 | // return the information from BistHob\r | |
52 | //\r | |
53 | if ((*StructureSize) < (UINT64) DataSize) {\r | |
54 | *StructureSize = (UINT64) DataSize;\r | |
55 | return EFI_BUFFER_TOO_SMALL;\r | |
56 | }\r | |
57 | \r | |
58 | *StructureSize = (UINT64) DataSize;\r | |
59 | CopyMem (PlatformInformationRecord2, DataInHob, DataSize);\r | |
60 | return EFI_SUCCESS;\r | |
61 | }\r | |
62 | \r | |
63 | /**\r | |
64 | Worker function to get CPUs' BIST by calling SecPlatformInformationPpi\r | |
65 | or SecPlatformInformation2Ppi.\r | |
66 | \r | |
67 | @param PeiServices Pointer to PEI Services Table\r | |
68 | @param Guid PPI Guid\r | |
69 | @param PpiDescriptor Return a pointer to instance of the\r | |
70 | EFI_PEI_PPI_DESCRIPTOR\r | |
71 | @param BistInformationData Pointer to BIST information data\r | |
72 | @param BistInformationSize Return the size in bytes of BIST information\r | |
73 | \r | |
74 | @retval EFI_SUCCESS Retrieve of the BIST data successfully\r | |
75 | @retval EFI_NOT_FOUND No sec platform information(2) ppi export\r | |
76 | @retval EFI_DEVICE_ERROR Failed to get CPU Information\r | |
77 | \r | |
78 | **/\r | |
79 | EFI_STATUS\r | |
80 | GetBistInfoFromPpi (\r | |
81 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
82 | IN CONST EFI_GUID *Guid,\r | |
83 | OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r | |
84 | OUT VOID **BistInformationData,\r | |
85 | OUT UINT64 *BistInformationSize OPTIONAL\r | |
86 | )\r | |
87 | {\r | |
88 | EFI_STATUS Status;\r | |
89 | EFI_SEC_PLATFORM_INFORMATION2_PPI *SecPlatformInformation2Ppi;\r | |
90 | EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2;\r | |
91 | UINT64 InformationSize;\r | |
92 | \r | |
93 | Status = PeiServicesLocatePpi (\r | |
94 | Guid, // GUID\r | |
95 | 0, // INSTANCE\r | |
96 | PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r | |
97 | (VOID **)&SecPlatformInformation2Ppi // PPI\r | |
98 | );\r | |
99 | if (Status == EFI_NOT_FOUND) {\r | |
100 | return EFI_NOT_FOUND;\r | |
101 | }\r | |
102 | \r | |
103 | if (Status == EFI_SUCCESS) {\r | |
104 | //\r | |
105 | // Get the size of the sec platform information2(BSP/APs' BIST data)\r | |
106 | //\r | |
107 | InformationSize = 0;\r | |
108 | SecPlatformInformation2 = NULL;\r | |
109 | Status = SecPlatformInformation2Ppi->PlatformInformation2 (\r | |
110 | PeiServices,\r | |
111 | &InformationSize,\r | |
112 | SecPlatformInformation2\r | |
113 | );\r | |
114 | if (Status == EFI_BUFFER_TOO_SMALL) {\r | |
115 | Status = PeiServicesAllocatePool (\r | |
116 | (UINTN) InformationSize,\r | |
117 | (VOID **) &SecPlatformInformation2\r | |
118 | );\r | |
119 | if (Status == EFI_SUCCESS) {\r | |
120 | //\r | |
121 | // Retrieve BIST data\r | |
122 | //\r | |
123 | Status = SecPlatformInformation2Ppi->PlatformInformation2 (\r | |
124 | PeiServices,\r | |
125 | &InformationSize,\r | |
126 | SecPlatformInformation2\r | |
127 | );\r | |
128 | if (Status == EFI_SUCCESS) {\r | |
129 | *BistInformationData = SecPlatformInformation2;\r | |
130 | if (BistInformationSize != NULL) {\r | |
131 | *BistInformationSize = InformationSize;\r | |
132 | }\r | |
133 | return EFI_SUCCESS;\r | |
134 | }\r | |
135 | }\r | |
136 | }\r | |
137 | }\r | |
138 | \r | |
139 | return EFI_DEVICE_ERROR;\r | |
140 | }\r |