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