]>
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 | |
d157de8b | 18 | Worker function to parse CPU BIST information from Guided HOB.\r |
863c738c | 19 | \r |
d157de8b JF |
20 | @param[out] StructureSize Pointer to the variable describing size of the input buffer.\r |
21 | @param[out] StructureBuffer Pointer to the buffer save CPU BIST information.\r | |
863c738c | 22 | \r |
d157de8b JF |
23 | @retval EFI_SUCCESS The data was successfully returned.\r |
24 | @retval EFI_BUFFER_TOO_SMALL The buffer was too small.\r | |
863c738c JF |
25 | \r |
26 | **/\r | |
27 | EFI_STATUS\r | |
d157de8b JF |
28 | GetBistFromHob (\r |
29 | IN OUT UINT64 *StructureSize,\r | |
30 | IN OUT VOID *StructureBuffer\r | |
863c738c JF |
31 | )\r |
32 | {\r | |
33 | EFI_HOB_GUID_TYPE *GuidHob;\r | |
34 | VOID *DataInHob;\r | |
35 | UINTN DataSize;\r | |
36 | \r | |
d157de8b | 37 | GuidHob = GetFirstGuidHob (&gEfiCallerIdGuid);\r |
863c738c JF |
38 | if (GuidHob == NULL) {\r |
39 | *StructureSize = 0;\r | |
40 | return EFI_SUCCESS;\r | |
41 | }\r | |
42 | \r | |
43 | DataInHob = GET_GUID_HOB_DATA (GuidHob);\r | |
44 | DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob);\r | |
45 | \r | |
46 | //\r | |
47 | // return the information from BistHob\r | |
48 | //\r | |
49 | if ((*StructureSize) < (UINT64) DataSize) {\r | |
50 | *StructureSize = (UINT64) DataSize;\r | |
51 | return EFI_BUFFER_TOO_SMALL;\r | |
52 | }\r | |
53 | \r | |
54 | *StructureSize = (UINT64) DataSize;\r | |
d157de8b | 55 | CopyMem (StructureBuffer, DataInHob, DataSize);\r |
863c738c JF |
56 | return EFI_SUCCESS;\r |
57 | }\r | |
58 | \r | |
d157de8b JF |
59 | /**\r |
60 | Implementation of the PlatformInformation service in EFI_SEC_PLATFORM_INFORMATION_PPI.\r | |
61 | \r | |
62 | @param[in] PeiServices Pointer to the PEI Services Table.\r | |
63 | @param[out] StructureSize Pointer to the variable describing size of the input buffer.\r | |
64 | @param[out PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.\r | |
65 | \r | |
66 | @retval EFI_SUCCESS The data was successfully returned.\r | |
67 | @retval EFI_BUFFER_TOO_SMALL The buffer was too small.\r | |
68 | \r | |
69 | **/\r | |
70 | EFI_STATUS\r | |
71 | EFIAPI\r | |
72 | SecPlatformInformationBist (\r | |
73 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
74 | IN OUT UINT64 *StructureSize,\r | |
75 | OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord\r | |
76 | )\r | |
77 | {\r | |
78 | return GetBistFromHob (StructureSize, PlatformInformationRecord);\r | |
79 | }\r | |
80 | \r | |
81 | /**\r | |
82 | Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.\r | |
83 | \r | |
84 | @param[in] PeiServices The pointer to the PEI Services Table.\r | |
85 | @param[out] StructureSize The pointer to the variable describing size of the input buffer.\r | |
86 | @param[out] PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2.\r | |
87 | \r | |
88 | @retval EFI_SUCCESS The data was successfully returned.\r | |
89 | @retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to\r | |
90 | hold the record is returned in StructureSize.\r | |
91 | \r | |
92 | **/\r | |
93 | EFI_STATUS\r | |
94 | EFIAPI\r | |
95 | SecPlatformInformation2Bist (\r | |
96 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
97 | IN OUT UINT64 *StructureSize,\r | |
98 | OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2\r | |
99 | )\r | |
100 | {\r | |
101 | return GetBistFromHob (StructureSize, PlatformInformationRecord2);\r | |
102 | }\r | |
103 | \r | |
863c738c JF |
104 | /**\r |
105 | Worker function to get CPUs' BIST by calling SecPlatformInformationPpi\r | |
106 | or SecPlatformInformation2Ppi.\r | |
107 | \r | |
d157de8b JF |
108 | @param[in] PeiServices Pointer to PEI Services Table\r |
109 | @param[in] Guid PPI Guid\r | |
110 | @param[out] PpiDescriptor Return a pointer to instance of the\r | |
111 | EFI_PEI_PPI_DESCRIPTOR\r | |
112 | @param[out] BistInformationData Pointer to BIST information data\r | |
113 | @param[out] BistInformationSize Return the size in bytes of BIST information\r | |
863c738c JF |
114 | \r |
115 | @retval EFI_SUCCESS Retrieve of the BIST data successfully\r | |
116 | @retval EFI_NOT_FOUND No sec platform information(2) ppi export\r | |
117 | @retval EFI_DEVICE_ERROR Failed to get CPU Information\r | |
118 | \r | |
119 | **/\r | |
120 | EFI_STATUS\r | |
121 | GetBistInfoFromPpi (\r | |
122 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
123 | IN CONST EFI_GUID *Guid,\r | |
124 | OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r | |
125 | OUT VOID **BistInformationData,\r | |
126 | OUT UINT64 *BistInformationSize OPTIONAL\r | |
127 | )\r | |
128 | {\r | |
129 | EFI_STATUS Status;\r | |
130 | EFI_SEC_PLATFORM_INFORMATION2_PPI *SecPlatformInformation2Ppi;\r | |
131 | EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2;\r | |
132 | UINT64 InformationSize;\r | |
133 | \r | |
134 | Status = PeiServicesLocatePpi (\r | |
135 | Guid, // GUID\r | |
136 | 0, // INSTANCE\r | |
137 | PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r | |
138 | (VOID **)&SecPlatformInformation2Ppi // PPI\r | |
139 | );\r | |
140 | if (Status == EFI_NOT_FOUND) {\r | |
141 | return EFI_NOT_FOUND;\r | |
142 | }\r | |
143 | \r | |
144 | if (Status == EFI_SUCCESS) {\r | |
145 | //\r | |
146 | // Get the size of the sec platform information2(BSP/APs' BIST data)\r | |
147 | //\r | |
148 | InformationSize = 0;\r | |
149 | SecPlatformInformation2 = NULL;\r | |
150 | Status = SecPlatformInformation2Ppi->PlatformInformation2 (\r | |
151 | PeiServices,\r | |
152 | &InformationSize,\r | |
153 | SecPlatformInformation2\r | |
154 | );\r | |
155 | if (Status == EFI_BUFFER_TOO_SMALL) {\r | |
156 | Status = PeiServicesAllocatePool (\r | |
157 | (UINTN) InformationSize,\r | |
158 | (VOID **) &SecPlatformInformation2\r | |
159 | );\r | |
160 | if (Status == EFI_SUCCESS) {\r | |
161 | //\r | |
162 | // Retrieve BIST data\r | |
163 | //\r | |
164 | Status = SecPlatformInformation2Ppi->PlatformInformation2 (\r | |
165 | PeiServices,\r | |
166 | &InformationSize,\r | |
167 | SecPlatformInformation2\r | |
168 | );\r | |
169 | if (Status == EFI_SUCCESS) {\r | |
170 | *BistInformationData = SecPlatformInformation2;\r | |
171 | if (BistInformationSize != NULL) {\r | |
172 | *BistInformationSize = InformationSize;\r | |
173 | }\r | |
174 | return EFI_SUCCESS;\r | |
175 | }\r | |
176 | }\r | |
177 | }\r | |
178 | }\r | |
179 | \r | |
180 | return EFI_DEVICE_ERROR;\r | |
181 | }\r |