]>
Commit | Line | Data |
---|---|---|
804405e7 | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | MiscSubclassDriverEntryPoint.c\r | |
15 | \r | |
16 | Abstract:\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 | |
26 | extern UINT8 MiscSubClassStrings[];\r | |
27 | \r | |
28 | //\r | |
29 | //\r | |
30 | //\r | |
31 | EFI_STATUS\r | |
32 | LogRecordDataToDataHub (\r | |
33 | EFI_DATA_HUB_PROTOCOL *DataHub,\r | |
34 | UINT32 RecordType,\r | |
35 | UINT32 RecordLen,\r | |
36 | VOID *RecordData\r | |
37 | )\r | |
38 | /*++\r | |
39 | Description:\r | |
40 | \r | |
41 | Parameters:\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 | |
55 | Returns:\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 | |
121 | EFI_STATUS\r | |
122 | EFIAPI\r | |
123 | MiscSubclassDriverEntryPoint (\r | |
124 | IN EFI_HANDLE ImageHandle,\r | |
125 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
126 | )\r | |
127 | /*++\r | |
128 | Description:\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 | |
133 | Arguments:\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 | |
141 | Returns:\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 | |
cb7d01c0 | 184 | HiiHandle = HiiAddPackages (\r |
185 | &gEfiMiscSubClassGuid,\r | |
186 | NULL,\r | |
187 | MiscSubclassStrings,\r | |
188 | NULL\r | |
189 | );\r | |
190 | if (HiiHandle == NULL) {\r | |
804405e7 | 191 | DEBUG ((EFI_D_ERROR, "Could not log default strings to Hii. %r\n", EfiStatus));\r |
cb7d01c0 | 192 | return EFI_OUT_OF_RESOURCES;\r |
804405e7 | 193 | }\r |
cb7d01c0 | 194 | \r |
804405e7 | 195 | //\r |
196 | //\r | |
197 | //\r | |
198 | for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {\r | |
199 | //\r | |
200 | // Stupidity check! Do nothing if RecordLen is zero.\r | |
201 | // %%TBD - Should this be an error or a mechanism for ignoring\r | |
202 | // records in the Data Table?\r | |
203 | //\r | |
204 | if (mMiscSubclassDataTable[Index].RecordLen == 0) {\r | |
205 | DEBUG (\r | |
206 | (EFI_D_ERROR,\r | |
207 | "mMiscSubclassDataTable[%d].RecordLen == 0\n",\r | |
208 | Index)\r | |
209 | );\r | |
210 | \r | |
211 | continue;\r | |
212 | }\r | |
213 | //\r | |
214 | // Initialize per-record portion of subclass header and\r | |
215 | // copy static data into data portion of subclass record.\r | |
216 | //\r | |
217 | RecordData.Header.RecordType = mMiscSubclassDataTable[Index].RecordType;\r | |
218 | \r | |
219 | if (mMiscSubclassDataTable[Index].RecordData == NULL) {\r | |
220 | ZeroMem (\r | |
221 | &RecordData.Record,\r | |
222 | mMiscSubclassDataTable[Index].RecordLen\r | |
223 | );\r | |
224 | } else {\r | |
225 | CopyMem (\r | |
226 | &RecordData.Record,\r | |
227 | mMiscSubclassDataTable[Index].RecordData,\r | |
228 | mMiscSubclassDataTable[Index].RecordLen\r | |
229 | );\r | |
230 | }\r | |
231 | //\r | |
232 | // If the entry does not have a function pointer, just log the data.\r | |
233 | //\r | |
234 | if (mMiscSubclassDataTable[Index].Function == NULL) {\r | |
235 | //\r | |
236 | // Log RecordData to Data Hub.\r | |
237 | //\r | |
238 | EfiStatus = DataHub->LogData (\r | |
239 | DataHub,\r | |
240 | &gEfiMiscSubClassGuid,\r | |
241 | &gEfiMiscSubClassGuid,\r | |
242 | EFI_DATA_RECORD_CLASS_DATA,\r | |
243 | &RecordData,\r | |
244 | sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen\r | |
245 | );\r | |
246 | \r | |
247 | if (EFI_ERROR (EfiStatus)) {\r | |
248 | DEBUG (\r | |
249 | (EFI_D_ERROR,\r | |
250 | "LogData(%d bytes) == %r\n",\r | |
251 | sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen,\r | |
252 | EfiStatus)\r | |
253 | );\r | |
254 | }\r | |
255 | \r | |
256 | continue;\r | |
257 | }\r | |
258 | //\r | |
259 | // The entry has a valid function pointer.\r | |
260 | // Keep calling the function and logging data until there\r | |
261 | // is no more data to log.\r | |
262 | //\r | |
263 | for (;;) {\r | |
264 | EfiStatus = (*mMiscSubclassDataTable[Index].Function)(mMiscSubclassDataTable[Index].RecordType, &mMiscSubclassDataTable[Index].RecordLen, &RecordData.Record, &LogRecordData);\r | |
265 | \r | |
266 | if (EFI_ERROR (EfiStatus)) {\r | |
267 | break;\r | |
268 | }\r | |
269 | \r | |
270 | if (!LogRecordData) {\r | |
271 | break;\r | |
272 | }\r | |
273 | //\r | |
274 | //\r | |
275 | //\r | |
276 | EfiStatus = DataHub->LogData (\r | |
277 | DataHub,\r | |
278 | &gEfiMiscSubClassGuid,\r | |
279 | &gEfiMiscSubClassGuid,\r | |
280 | EFI_DATA_RECORD_CLASS_DATA,\r | |
281 | &RecordData,\r | |
282 | sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen\r | |
283 | );\r | |
284 | \r | |
285 | if (EFI_ERROR (EfiStatus)) {\r | |
286 | DEBUG (\r | |
287 | (EFI_D_ERROR,\r | |
288 | "LogData(%d bytes) == %r\n",\r | |
289 | sizeof (EFI_SUBCLASS_TYPE1_HEADER) + mMiscSubclassDataTable[Index].RecordLen,\r | |
290 | EfiStatus)\r | |
291 | );\r | |
292 | }\r | |
293 | }\r | |
294 | }\r | |
295 | \r | |
296 | //\r | |
297 | // Log Memory Size info based on PCD setting.\r | |
298 | //\r | |
299 | MemorySubClassData.Header.Instance = 1;\r | |
300 | MemorySubClassData.Header.SubInstance = EFI_SUBCLASS_INSTANCE_NON_APPLICABLE;\r | |
301 | MemorySubClassData.Header.RecordType = EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER;\r | |
302 | \r | |
303 | //\r | |
304 | // Process Memory String in form size!size ...\r | |
305 | // So 64!64 is 128 MB\r | |
306 | //\r | |
307 | UnixMemString = PcdGetPtr (PcdUnixMemorySize);\r | |
308 | for (TotalMemorySize = 0; *UnixMemString != '\0';) {\r | |
309 | TotalMemorySize += StrDecimalToUint64 (UnixMemString);\r | |
310 | while (*UnixMemString != '\0') {\r | |
311 | if (*UnixMemString == '!') {\r | |
312 | UnixMemString++; \r | |
313 | break;\r | |
314 | }\r | |
315 | UnixMemString++;\r | |
316 | }\r | |
317 | }\r | |
318 | \r | |
319 | MemorySubClassData.Record.ArrayStartAddress.MemoryArrayStartAddress = 0;\r | |
b7f76514 A |
320 | MemorySubClassData.Record.ArrayStartAddress.MemoryArrayEndAddress = LShiftU64 (TotalMemorySize, 20) - 1; \r |
321 | CopyGuid (&MemorySubClassData.Record.ArrayStartAddress.PhysicalMemoryArrayLink.ProducerName, &gEfiCallerIdGuid);\r | |
804405e7 | 322 | MemorySubClassData.Record.ArrayStartAddress.PhysicalMemoryArrayLink.Instance = 1;\r |
323 | MemorySubClassData.Record.ArrayStartAddress.PhysicalMemoryArrayLink.SubInstance = EFI_SUBCLASS_INSTANCE_NON_APPLICABLE;\r | |
324 | MemorySubClassData.Record.ArrayStartAddress.MemoryArrayPartitionWidth = 0;\r | |
325 | \r | |
326 | //\r | |
327 | // Store memory size data record to data hub.\r | |
328 | //\r | |
329 | EfiStatus = DataHub->LogData (\r | |
330 | DataHub,\r | |
331 | &gEfiMemorySubClassGuid,\r | |
c2bd20a5 | 332 | &gEfiCallerIdGuid,\r |
804405e7 | 333 | EFI_DATA_RECORD_CLASS_DATA,\r |
334 | &MemorySubClassData,\r | |
335 | sizeof (EFI_SUBCLASS_TYPE1_HEADER) + sizeof (EFI_MEMORY_ARRAY_START_ADDRESS_DATA)\r | |
336 | );\r | |
337 | \r | |
338 | return EFI_SUCCESS;\r | |
339 | }\r |