]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c
Remove BaseMemoryTest PPI and related producers and consumers.
[mirror_edk2.git] / UnixPkg / MiscSubClassPlatformDxe / MiscSubclassDriverEntryPoint.c
CommitLineData
804405e7 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 MiscSubclassDriverEntryPoint.c\r
15\r
16Abstract:\r
17\r
18 This driver parses the mMiscSubclassDataTable structure and reports\r
19 any generated data to the DataHub.\r
20\r
21--*/\r
22\r
23#include "MiscSubClassDriver.h"\r
24\r
25\r
26extern UINT8 MiscSubClassStrings[];\r
27\r
28//\r
29//\r
30//\r
31EFI_STATUS\r
32LogRecordDataToDataHub (\r
33 EFI_DATA_HUB_PROTOCOL *DataHub,\r
34 UINT32 RecordType,\r
35 UINT32 RecordLen,\r
36 VOID *RecordData\r
37 )\r
38/*++\r
39Description:\r
40\r
41Parameters:\r
42\r
43 DataHub\r
44 %%TBD\r
45\r
46 RecordType\r
47 %%TBD\r
48\r
49 RecordLen\r
50 %%TBD\r
51\r
52 RecordData\r
53 %%TBD\r
54\r
55Returns:\r
56\r
57 EFI_INVALID_PARAMETER\r
58\r
59 EFI_SUCCESS\r
60\r
61 Other Data Hub errors\r
62\r
63--*/\r
64{\r
65 EFI_MISC_SUBCLASS_DRIVER_DATA MiscSubclass;\r
66 EFI_STATUS EfiStatus;\r
67\r
68 //\r
69 // Do nothing if data parameters are not valid.\r
70 //\r
71 if (RecordLen == 0 || RecordData == NULL) {\r
72 DEBUG (\r
73 (EFI_D_ERROR,\r
74 "RecordLen == %d RecordData == %xh\n",\r
75 RecordLen,\r
76 RecordData)\r
77 );\r
78\r
79 return EFI_INVALID_PARAMETER;\r
80 }\r
81 //\r
82 // Assemble Data Hub record.\r
83 //\r
84 MiscSubclass.Header.Version = EFI_MISC_SUBCLASS_VERSION;\r
85 MiscSubclass.Header.HeaderSize = sizeof (EFI_SUBCLASS_TYPE1_HEADER);\r
86 MiscSubclass.Header.Instance = 1;\r
87 MiscSubclass.Header.SubInstance = 1;\r
88 MiscSubclass.Header.RecordType = RecordType;\r
89\r
90 CopyMem (\r
91 &MiscSubclass.Record,\r
92 RecordData,\r
93 RecordLen\r
94 );\r
95\r
96 //\r
97 // Log Data Hub record.\r
98 //\r
99 EfiStatus = DataHub->LogData (\r
100 DataHub,\r
101 &gEfiMiscSubClassGuid,\r
102 &gEfiMiscSubClassGuid,\r
103 EFI_DATA_RECORD_CLASS_DATA,\r
104 &MiscSubclass,\r
105 sizeof (EFI_SUBCLASS_TYPE1_HEADER) + RecordLen\r
106 );\r
107\r
108 if (EFI_ERROR (EfiStatus)) {\r
109 DEBUG (\r
110 (EFI_D_ERROR,\r
111 "LogData(%d bytes) == %r\n",\r
112 sizeof (EFI_SUBCLASS_TYPE1_HEADER) + RecordLen,\r
113 EfiStatus)\r
114 );\r
115 }\r
116\r
117 return EfiStatus;\r
118}\r
119\r
120\r
121EFI_STATUS\r
122EFIAPI\r
123MiscSubclassDriverEntryPoint (\r
124 IN EFI_HANDLE ImageHandle,\r
125 IN EFI_SYSTEM_TABLE *SystemTable\r
126 )\r
127/*++\r
128Description:\r
129\r
130 Standard EFI driver point. This driver parses the mMiscSubclassDataTable\r
131 structure and reports any generated data to the DataHub.\r
132\r
133Arguments:\r
134\r
135 ImageHandle\r
136 Handle for the image of this driver\r
137\r
138 SystemTable\r
139 Pointer to the EFI System Table\r
140\r
141Returns:\r
142\r
143 EFI_SUCCESS\r
144 The data was successfully reported to the Data Hub.\r
145\r
146--*/\r
147{\r
148 EFI_MISC_SUBCLASS_DRIVER_DATA RecordData;\r
149 EFI_DATA_HUB_PROTOCOL *DataHub;\r
150 EFI_HII_HANDLE HiiHandle;\r
151 EFI_STATUS EfiStatus;\r
152 UINTN Index;\r
153 BOOLEAN LogRecordData;\r
154 EFI_MEMORY_SUBCLASS_DRIVER_DATA MemorySubClassData; \r
155 UINT64 TotalMemorySize;\r
156 CHAR16 *UnixMemString;\r
157\r
158\r
159\r
160 //\r
161 // Initialize constant portion of subclass header.\r
162 //\r
163 RecordData.Header.Version = EFI_MISC_SUBCLASS_VERSION;\r
164 RecordData.Header.HeaderSize = sizeof (EFI_SUBCLASS_TYPE1_HEADER);\r
165 RecordData.Header.Instance = 1;\r
166 RecordData.Header.SubInstance = 1;\r
167\r
168 //\r
169 // Locate data hub protocol.\r
170 //\r
171 EfiStatus = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID**) &DataHub);\r
172\r
173 if (EFI_ERROR (EfiStatus)) {\r
174 DEBUG ((EFI_D_ERROR, "Could not locate DataHub protocol. %r\n", EfiStatus));\r
175 return EfiStatus;\r
176 } else if (DataHub == NULL) {\r
177 DEBUG ((EFI_D_ERROR, "LocateProtocol(DataHub) returned NULL pointer!\n"));\r
178 return EFI_DEVICE_ERROR;\r
179 }\r
180\r
181 //\r
182 // Add our default strings to the HII database. They will be modified later.\r
183 //\r
184 HiiLibAddPackages (1, &gEfiMiscSubClassGuid, NULL, &HiiHandle, MiscSubclassStrings);\r
185\r
186 if (EFI_ERROR (EfiStatus)) {\r
187 DEBUG ((EFI_D_ERROR, "Could not log default strings to Hii. %r\n", EfiStatus));\r
188 return EfiStatus;\r
189 }\r
190 //\r
191 //\r
192 //\r
193 for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {\r
194 //\r
195 // Stupidity check! Do nothing if RecordLen is zero.\r
196 // %%TBD - Should this be an error or a mechanism for ignoring\r
197 // records in the Data Table?\r
198 //\r
199 if (mMiscSubclassDataTable[Index].RecordLen == 0) {\r
200 DEBUG (\r
201 (EFI_D_ERROR,\r
202 "mMiscSubclassDataTable[%d].RecordLen == 0\n",\r
203 Index)\r
204 );\r
205\r
206 continue;\r
207 }\r
208 //\r
209 // Initialize per-record portion of subclass header and\r
210 // copy static data into data portion of subclass record.\r
211 //\r
212 RecordData.Header.RecordType = mMiscSubclassDataTable[Index].RecordType;\r
213\r
214 if (mMiscSubclassDataTable[Index].RecordData == NULL) {\r
215 ZeroMem (\r
216 &RecordData.Record,\r
217 mMiscSubclassDataTable[Index].RecordLen\r
218 );\r
219 } else {\r
220 CopyMem (\r
221 &RecordData.Record,\r
222 mMiscSubclassDataTable[Index].RecordData,\r
223 mMiscSubclassDataTable[Index].RecordLen\r
224 );\r
225 }\r
226 //\r
227 // If the entry does not have a function pointer, just log the data.\r
228 //\r
229 if (mMiscSubclassDataTable[Index].Function == NULL) {\r
230 //\r
231 // Log RecordData to Data Hub.\r
232 //\r
233 EfiStatus = DataHub->LogData (\r
234 DataHub,\r
235 &gEfiMiscSubClassGuid,\r
236 &gEfiMiscSubClassGuid,\r
237 EFI_DATA_RECORD_CLASS_DATA,\r
238 &RecordData,\r
239 sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen\r
240 );\r
241\r
242 if (EFI_ERROR (EfiStatus)) {\r
243 DEBUG (\r
244 (EFI_D_ERROR,\r
245 "LogData(%d bytes) == %r\n",\r
246 sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen,\r
247 EfiStatus)\r
248 );\r
249 }\r
250\r
251 continue;\r
252 }\r
253 //\r
254 // The entry has a valid function pointer.\r
255 // Keep calling the function and logging data until there\r
256 // is no more data to log.\r
257 //\r
258 for (;;) {\r
259 EfiStatus = (*mMiscSubclassDataTable[Index].Function)(mMiscSubclassDataTable[Index].RecordType, &mMiscSubclassDataTable[Index].RecordLen, &RecordData.Record, &LogRecordData);\r
260\r
261 if (EFI_ERROR (EfiStatus)) {\r
262 break;\r
263 }\r
264\r
265 if (!LogRecordData) {\r
266 break;\r
267 }\r
268 //\r
269 //\r
270 //\r
271 EfiStatus = DataHub->LogData (\r
272 DataHub,\r
273 &gEfiMiscSubClassGuid,\r
274 &gEfiMiscSubClassGuid,\r
275 EFI_DATA_RECORD_CLASS_DATA,\r
276 &RecordData,\r
277 sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen\r
278 );\r
279\r
280 if (EFI_ERROR (EfiStatus)) {\r
281 DEBUG (\r
282 (EFI_D_ERROR,\r
283 "LogData(%d bytes) == %r\n",\r
284 sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen,\r
285 EfiStatus)\r
286 );\r
287 }\r
288 }\r
289 }\r
290 \r
291 //\r
292 // Log Memory Size info based on PCD setting.\r
293 //\r
294 MemorySubClassData.Header.Instance = 1;\r
295 MemorySubClassData.Header.SubInstance = EFI_SUBCLASS_INSTANCE_NON_APPLICABLE;\r
296 MemorySubClassData.Header.RecordType = EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER;\r
297\r
298 //\r
299 // Process Memory String in form size!size ...\r
300 // So 64!64 is 128 MB\r
301 //\r
302 UnixMemString = PcdGetPtr (PcdUnixMemorySize);\r
303 for (TotalMemorySize = 0; *UnixMemString != '\0';) {\r
304 TotalMemorySize += StrDecimalToUint64 (UnixMemString);\r
305 while (*UnixMemString != '\0') {\r
306 if (*UnixMemString == '!') {\r
307 UnixMemString++; \r
308 break;\r
309 }\r
310 UnixMemString++;\r
311 }\r
312 }\r
313\r
314 MemorySubClassData.Record.ArrayStartAddress.MemoryArrayStartAddress = 0;\r
315 MemorySubClassData.Record.ArrayStartAddress.MemoryArrayEndAddress = LShiftU64 (TotalMemorySize, 20) - 1;\r
316 MemorySubClassData.Record.ArrayStartAddress.PhysicalMemoryArrayLink.ProducerName = gEfiMemoryProducerGuid;\r
317 MemorySubClassData.Record.ArrayStartAddress.PhysicalMemoryArrayLink.Instance = 1;\r
318 MemorySubClassData.Record.ArrayStartAddress.PhysicalMemoryArrayLink.SubInstance = EFI_SUBCLASS_INSTANCE_NON_APPLICABLE;\r
319 MemorySubClassData.Record.ArrayStartAddress.MemoryArrayPartitionWidth = 0;\r
320\r
321 //\r
322 // Store memory size data record to data hub.\r
323 //\r
324 EfiStatus = DataHub->LogData (\r
325 DataHub,\r
326 &gEfiMemorySubClassGuid,\r
327 &gEfiMemoryProducerGuid,\r
328 EFI_DATA_RECORD_CLASS_DATA,\r
329 &MemorySubClassData,\r
330 sizeof (EFI_SUBCLASS_TYPE1_HEADER) + sizeof (EFI_MEMORY_ARRAY_START_ADDRESS_DATA)\r
331 );\r
332\r
333 return EFI_SUCCESS;\r
334}\r