]>
Commit | Line | Data |
---|---|---|
79964ac8 | 1 | /** @file\r |
2 | Report Status Code Library for DXE Phase.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2007, Intel Corporation<BR>\r | |
5 | All rights reserved. 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 | |
ed7748fe | 15 | \r |
53f93f7e | 16 | #include <FrameworkDxe.h>\r |
ed7748fe | 17 | \r |
53f93f7e | 18 | #include <Guid/StatusCodeDataTypeId.h>\r |
19 | #include <Protocol/StatusCode.h>\r | |
ed7748fe | 20 | \r |
53f93f7e | 21 | #include <Library/ReportStatusCodeLib.h>\r |
79964ac8 | 22 | #include <Library/DebugLib.h>\r |
23 | #include <Library/UefiBootServicesTableLib.h>\r | |
79964ac8 | 24 | #include <Library/BaseLib.h>\r |
25 | #include <Library/BaseMemoryLib.h>\r | |
26 | #include <Library/PcdLib.h>\r | |
53f93f7e | 27 | #include <Library/UefiRuntimeServicesTableLib.h>\r |
79964ac8 | 28 | \r |
79964ac8 | 29 | \r |
30 | /**\r | |
31 | Internal worker function that reports a status code through the Status Code Protocol\r | |
32 | \r | |
33 | This function checks to see if a Status Code Protocol is present in the handle\r | |
34 | database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is\r | |
35 | returned. If a Status Code Protocol is present, then it is cached in gStatusCode,\r | |
36 | and the ReportStatusCode() service of the Status Code Protocol is called passing in\r | |
37 | Type, Value, Instance, CallerId, and Data. The result of this call is returned.\r | |
38 | \r | |
39 | @param Type Status code type.\r | |
40 | @param Value Status code value.\r | |
41 | @param Instance Status code instance number.\r | |
42 | @param CallerId Pointer to a GUID that identifies the caller of this\r | |
43 | function. This is an optional parameter that may be\r | |
44 | NULL.\r | |
45 | @param Data Pointer to the extended data buffer. This is an\r | |
46 | optional parameter that may be NULL.\r | |
47 | \r | |
48 | @retval EFI_SUCCESS The status code was reported.\r | |
49 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to report the status code.\r | |
50 | @retval EFI_UNSUPPORTED Status Code Protocol is not available.\r | |
51 | \r | |
52 | **/\r | |
53 | STATIC\r | |
54 | EFI_STATUS\r | |
55 | InternalReportStatusCode (\r | |
56 | IN EFI_STATUS_CODE_TYPE Type,\r | |
57 | IN EFI_STATUS_CODE_VALUE Value,\r | |
58 | IN UINT32 Instance,\r | |
59 | IN CONST EFI_GUID *CallerId OPTIONAL,\r | |
60 | IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r | |
61 | )\r | |
62 | {\r | |
63 | EFI_STATUS Status;\r | |
64 | EFI_STATUS_CODE_PROTOCOL *StatusCode;\r | |
65 | STATIC EFI_REPORT_STATUS_CODE ReportStatusCode = NULL;\r | |
66 | \r | |
67 | //\r | |
68 | // If gStatusCode is NULL, then see if a Status Code Protocol instance is present\r | |
69 | // in the handle database.\r | |
70 | //\r | |
71 | if (ReportStatusCode == NULL) {\r | |
72 | if (gBS == NULL) {\r | |
73 | return EFI_UNSUPPORTED;\r | |
74 | }\r | |
898d4ac2 | 75 | Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCode);\r |
79964ac8 | 76 | if (!EFI_ERROR (Status) && StatusCode != NULL) {\r |
77 | ReportStatusCode = StatusCode->ReportStatusCode;\r | |
78 | } else if (gRT->Hdr.Revision < 0x20000) {\r | |
79 | ReportStatusCode = ((FRAMEWORK_EFI_RUNTIME_SERVICES*)gRT)->ReportStatusCode;\r | |
80 | } else {\r | |
81 | return EFI_UNSUPPORTED;\r | |
82 | }\r | |
83 | }\r | |
84 | \r | |
85 | //\r | |
86 | // A Status Code Protocol is present in the handle database, so pass in all the\r | |
87 | // parameters to the ReportStatusCode() service of the Status Code Protocol\r | |
88 | //\r | |
89 | return (*ReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data);\r | |
90 | }\r | |
91 | \r | |
92 | \r | |
93 | /**\r | |
94 | Computes and returns the size, in bytes, of a device path.\r | |
95 | \r | |
96 | @param DevicePath A pointer to a device path.\r | |
97 | \r | |
98 | @return The size, in bytes, of DevicePath.\r | |
99 | \r | |
100 | **/\r | |
101 | STATIC\r | |
102 | UINTN\r | |
103 | InternalReportStatusCodeDevicePathSize (\r | |
104 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
105 | )\r | |
106 | {\r | |
107 | CONST EFI_DEVICE_PATH_PROTOCOL *Start;\r | |
108 | \r | |
109 | //\r | |
110 | // Search for the end of the device path structure\r | |
111 | //\r | |
112 | Start = DevicePath;\r | |
113 | while (!EfiIsDevicePathEnd (DevicePath)) {\r | |
114 | DevicePath = EfiNextDevicePathNode (DevicePath);\r | |
115 | }\r | |
116 | \r | |
117 | //\r | |
118 | // Subtract the start node from the end node and add in the size of the end node\r | |
119 | //\r | |
120 | return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath);\r | |
121 | }\r | |
122 | \r | |
123 | \r | |
124 | /**\r | |
125 | Converts a status code to an 8-bit POST code value.\r | |
126 | \r | |
127 | Converts the status code specified by CodeType and Value to an 8-bit POST code\r | |
128 | and returns the 8-bit POST code in PostCode. If CodeType is an\r | |
129 | EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode\r | |
130 | are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits\r | |
131 | 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned.\r | |
132 | \r | |
133 | If PostCode is NULL, then ASSERT().\r | |
134 | \r | |
135 | @param CodeType The type of status code being converted.\r | |
136 | @param Value The status code value being converted.\r | |
137 | @param PostCode A pointer to the 8-bit POST code value to return.\r | |
138 | \r | |
139 | @retval TRUE The status code specified by CodeType and Value was converted\r | |
140 | to an 8-bit POST code and returned in PostCode.\r | |
141 | @retval FALSE The status code specified by CodeType and Value could not be\r | |
142 | converted to an 8-bit POST code value.\r | |
143 | \r | |
144 | **/\r | |
145 | BOOLEAN\r | |
146 | EFIAPI\r | |
147 | CodeTypeToPostCode (\r | |
148 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
149 | IN EFI_STATUS_CODE_VALUE Value,\r | |
150 | OUT UINT8 *PostCode\r | |
151 | )\r | |
152 | {\r | |
153 | //\r | |
154 | // If PostCode is NULL, then ASSERT()\r | |
155 | //\r | |
156 | ASSERT (PostCode != NULL);\r | |
157 | \r | |
158 | //\r | |
159 | // Convert Value to an 8 bit post code\r | |
160 | //\r | |
161 | if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r | |
162 | ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) {\r | |
163 | *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |\r | |
164 | (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));\r | |
165 | return TRUE;\r | |
166 | }\r | |
167 | return FALSE;\r | |
168 | }\r | |
169 | \r | |
170 | \r | |
171 | /**\r | |
172 | Extracts ASSERT() information from a status code structure.\r | |
173 | \r | |
174 | Converts the status code specified by CodeType, Value, and Data to the ASSERT()\r | |
175 | arguments specified by Filename, Description, and LineNumber. If CodeType is\r | |
176 | an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and\r | |
177 | Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract\r | |
178 | Filename, Description, and LineNumber from the optional data area of the\r | |
179 | status code buffer specified by Data. The optional data area of Data contains\r | |
180 | a Null-terminated ASCII string for the FileName, followed by a Null-terminated\r | |
181 | ASCII string for the Description, followed by a 32-bit LineNumber. If the\r | |
182 | ASSERT() information could be extracted from Data, then return TRUE.\r | |
183 | Otherwise, FALSE is returned.\r | |
184 | \r | |
185 | If Data is NULL, then ASSERT().\r | |
186 | If Filename is NULL, then ASSERT().\r | |
187 | If Description is NULL, then ASSERT().\r | |
188 | If LineNumber is NULL, then ASSERT().\r | |
189 | \r | |
190 | @param CodeType The type of status code being converted.\r | |
191 | @param Value The status code value being converted.\r | |
192 | @param Data Pointer to status code data buffer.\r | |
193 | @param Filename Pointer to the source file name that generated the ASSERT().\r | |
194 | @param Description Pointer to the description of the ASSERT().\r | |
195 | @param LineNumber Pointer to source line number that generated the ASSERT().\r | |
196 | \r | |
197 | @retval TRUE The status code specified by CodeType, Value, and Data was\r | |
198 | converted ASSERT() arguments specified by Filename, Description,\r | |
199 | and LineNumber.\r | |
200 | @retval FALSE The status code specified by CodeType, Value, and Data could\r | |
201 | not be converted to ASSERT() arguments.\r | |
202 | \r | |
203 | **/\r | |
204 | BOOLEAN\r | |
205 | EFIAPI\r | |
206 | ReportStatusCodeExtractAssertInfo (\r | |
207 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
208 | IN EFI_STATUS_CODE_VALUE Value,\r | |
209 | IN CONST EFI_STATUS_CODE_DATA *Data,\r | |
210 | OUT CHAR8 **Filename,\r | |
211 | OUT CHAR8 **Description,\r | |
212 | OUT UINT32 *LineNumber\r | |
213 | )\r | |
214 | {\r | |
215 | EFI_DEBUG_ASSERT_DATA *AssertData;\r | |
216 | \r | |
217 | ASSERT (Data != NULL);\r | |
218 | ASSERT (Filename != NULL);\r | |
219 | ASSERT (Description != NULL);\r | |
220 | ASSERT (LineNumber != NULL);\r | |
221 | \r | |
222 | if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&\r | |
223 | ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&\r | |
224 | ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {\r | |
225 | AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);\r | |
226 | *Filename = (CHAR8 *)(AssertData + 1);\r | |
227 | *Description = *Filename + AsciiStrLen (*Filename) + 1;\r | |
228 | *LineNumber = AssertData->LineNumber;\r | |
229 | return TRUE;\r | |
230 | }\r | |
231 | return FALSE;\r | |
232 | }\r | |
233 | \r | |
234 | \r | |
235 | /**\r | |
236 | Extracts DEBUG() information from a status code structure.\r | |
237 | \r | |
238 | Converts the status code specified by Data to the DEBUG() arguments specified\r | |
239 | by ErrorLevel, Marker, and Format. If type GUID in Data is\r | |
240 | EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and\r | |
241 | Format from the optional data area of the status code buffer specified by Data.\r | |
242 | The optional data area of Data contains a 32-bit ErrorLevel followed by Marker\r | |
243 | which is 12 UINTN parameters, followed by a Null-terminated ASCII string for\r | |
244 | the Format. If the DEBUG() information could be extracted from Data, then\r | |
245 | return TRUE. Otherwise, FALSE is returned.\r | |
246 | \r | |
247 | If Data is NULL, then ASSERT().\r | |
248 | If ErrorLevel is NULL, then ASSERT().\r | |
249 | If Marker is NULL, then ASSERT().\r | |
250 | If Format is NULL, then ASSERT().\r | |
251 | \r | |
252 | @param Data Pointer to status code data buffer.\r | |
253 | @param ErrorLevel Pointer to error level mask for a debug message.\r | |
254 | @param Marker Pointer to the variable argument list associated with Format.\r | |
255 | @param Format Pointer to a Null-terminated ASCII format string of a\r | |
256 | debug message.\r | |
257 | \r | |
258 | @retval TRUE The status code specified by Data was converted DEBUG() arguments\r | |
259 | specified by ErrorLevel, Marker, and Format.\r | |
260 | @retval FALSE The status code specified by Data could not be converted to\r | |
261 | DEBUG() arguments.\r | |
262 | \r | |
263 | **/\r | |
264 | BOOLEAN\r | |
265 | EFIAPI\r | |
266 | ReportStatusCodeExtractDebugInfo (\r | |
267 | IN CONST EFI_STATUS_CODE_DATA *Data,\r | |
268 | OUT UINT32 *ErrorLevel,\r | |
269 | OUT VA_LIST *Marker,\r | |
270 | OUT CHAR8 **Format\r | |
271 | )\r | |
272 | {\r | |
273 | EFI_DEBUG_INFO *DebugInfo;\r | |
274 | \r | |
275 | ASSERT (Data != NULL);\r | |
276 | ASSERT (ErrorLevel != NULL);\r | |
277 | ASSERT (Marker != NULL);\r | |
278 | ASSERT (Format != NULL);\r | |
279 | \r | |
280 | //\r | |
281 | // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE\r | |
282 | //\r | |
283 | if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {\r | |
284 | return FALSE;\r | |
285 | }\r | |
286 | \r | |
287 | //\r | |
288 | // Retrieve the debug information from the status code record\r | |
289 | //\r | |
290 | DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);\r | |
291 | \r | |
292 | *ErrorLevel = DebugInfo->ErrorLevel;\r | |
293 | \r | |
294 | //\r | |
295 | // The first 12 * UINTN bytes of the string are really an\r | |
296 | // argument stack to support varargs on the Format string.\r | |
297 | //\r | |
298 | *Marker = (VA_LIST) (DebugInfo + 1);\r | |
299 | *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);\r | |
300 | \r | |
301 | return TRUE;\r | |
302 | }\r | |
303 | \r | |
304 | \r | |
305 | /**\r | |
306 | Reports a status code.\r | |
307 | \r | |
308 | Reports the status code specified by the parameters Type and Value. Status\r | |
309 | code also require an instance, caller ID, and extended data. This function\r | |
310 | passed in a zero instance, NULL extended data, and a caller ID of\r | |
311 | gEfiCallerIdGuid, which is the GUID for the module.\r | |
312 | \r | |
313 | ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode()\r | |
314 | is called while processing another any other Report Status Code Library function,\r | |
315 | then ReportStatusCode() must return immediately.\r | |
316 | \r | |
317 | @param Type Status code type.\r | |
318 | @param Value Status code value.\r | |
319 | \r | |
320 | @retval EFI_SUCCESS The status code was reported.\r | |
321 | @retval EFI_DEVICE_ERROR There status code could not be reported due to a\r | |
322 | device error.\r | |
323 | @retval EFI_UNSUPPORTED Report status code is not supported\r | |
324 | \r | |
325 | **/\r | |
326 | EFI_STATUS\r | |
327 | EFIAPI\r | |
328 | ReportStatusCode (\r | |
329 | IN EFI_STATUS_CODE_TYPE Type,\r | |
330 | IN EFI_STATUS_CODE_VALUE Value\r | |
331 | )\r | |
332 | {\r | |
333 | return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);\r | |
334 | }\r | |
335 | \r | |
336 | \r | |
337 | /**\r | |
338 | Reports a status code with a Device Path Protocol as the extended data.\r | |
339 | \r | |
340 | Allocates and fills in the extended data section of a status code with the\r | |
341 | Device Path Protocol specified by DevicePath. This function is responsible\r | |
342 | for allocating a buffer large enough for the standard header and the device\r | |
343 | path. The standard header is filled in with a GUID of\r | |
344 | gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero\r | |
345 | instance and a caller ID of gEfiCallerIdGuid.\r | |
346 | \r | |
347 | ReportStatusCodeWithDevicePath()must actively prevent recursion. If\r | |
348 | ReportStatusCodeWithDevicePath() is called while processing another any other\r | |
349 | Report Status Code Library function, then ReportStatusCodeWithDevicePath()\r | |
350 | must return EFI_DEVICE_ERROR immediately.\r | |
351 | \r | |
352 | If DevicePath is NULL, then ASSERT().\r | |
353 | \r | |
354 | @param Type Status code type.\r | |
355 | @param Value Status code value.\r | |
356 | @param DevicePath Pointer to the Device Path Protocol to be reported.\r | |
357 | \r | |
358 | @retval EFI_SUCCESS The status code was reported with the extended\r | |
359 | data specified by DevicePath.\r | |
360 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the\r | |
361 | extended data section.\r | |
362 | @retval EFI_UNSUPPORTED Report status code is not supported\r | |
363 | \r | |
364 | **/\r | |
365 | EFI_STATUS\r | |
366 | EFIAPI\r | |
367 | ReportStatusCodeWithDevicePath (\r | |
368 | IN EFI_STATUS_CODE_TYPE Type,\r | |
369 | IN EFI_STATUS_CODE_VALUE Value,\r | |
370 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
371 | )\r | |
372 | {\r | |
373 | ASSERT (DevicePath != NULL);\r | |
374 | return ReportStatusCodeWithExtendedData (\r | |
375 | Type,\r | |
376 | Value,\r | |
377 | (VOID *)DevicePath,\r | |
378 | InternalReportStatusCodeDevicePathSize (DevicePath)\r | |
379 | );\r | |
380 | }\r | |
381 | \r | |
382 | \r | |
383 | /**\r | |
384 | Reports a status code with an extended data buffer.\r | |
385 | \r | |
386 | Allocates and fills in the extended data section of a status code with the\r | |
387 | extended data specified by ExtendedData and ExtendedDataSize. ExtendedData\r | |
388 | is assumed to be one of the data structures specified in Related Definitions.\r | |
389 | These data structure do not have the standard header, so this function is\r | |
390 | responsible for allocating a buffer large enough for the standard header and\r | |
391 | the extended data passed into this function. The standard header is filled\r | |
392 | in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported\r | |
393 | with a zero instance and a caller ID of gEfiCallerIdGuid.\r | |
394 | \r | |
395 | ReportStatusCodeWithExtendedData()must actively prevent recursion. If\r | |
396 | ReportStatusCodeWithExtendedData() is called while processing another any other\r | |
397 | Report Status Code Library function, then ReportStatusCodeWithExtendedData()\r | |
398 | must return EFI_DEVICE_ERROR immediately.\r | |
399 | \r | |
400 | If ExtendedData is NULL, then ASSERT().\r | |
401 | If ExtendedDataSize is 0, then ASSERT().\r | |
402 | \r | |
403 | @param Type Status code type.\r | |
404 | @param Value Status code value.\r | |
405 | @param ExtendedData Pointer to the extended data buffer to be reported.\r | |
406 | @param ExtendedDataSize The size, in bytes, of the extended data buffer to\r | |
407 | be reported.\r | |
408 | \r | |
409 | @retval EFI_SUCCESS The status code was reported with the extended\r | |
410 | data specified by ExtendedData and ExtendedDataSize.\r | |
411 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the\r | |
412 | extended data section.\r | |
413 | @retval EFI_UNSUPPORTED Report status code is not supported\r | |
414 | \r | |
415 | **/\r | |
416 | EFI_STATUS\r | |
417 | EFIAPI\r | |
418 | ReportStatusCodeWithExtendedData (\r | |
419 | IN EFI_STATUS_CODE_TYPE Type,\r | |
420 | IN EFI_STATUS_CODE_VALUE Value,\r | |
421 | IN CONST VOID *ExtendedData,\r | |
422 | IN UINTN ExtendedDataSize\r | |
423 | )\r | |
424 | {\r | |
425 | ASSERT (ExtendedData != NULL);\r | |
426 | ASSERT (ExtendedDataSize != 0);\r | |
427 | return ReportStatusCodeEx (\r | |
428 | Type,\r | |
429 | Value,\r | |
430 | 0,\r | |
431 | NULL,\r | |
432 | NULL,\r | |
433 | ExtendedData,\r | |
434 | ExtendedDataSize\r | |
435 | );\r | |
436 | }\r | |
437 | \r | |
438 | \r | |
439 | /**\r | |
440 | Reports a status code with full parameters.\r | |
441 | \r | |
442 | The function reports a status code. If ExtendedData is NULL and ExtendedDataSize\r | |
443 | is 0, then an extended data buffer is not reported. If ExtendedData is not\r | |
444 | NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.\r | |
445 | ExtendedData is assumed not have the standard status code header, so this function\r | |
446 | is responsible for allocating a buffer large enough for the standard header and\r | |
447 | the extended data passed into this function. The standard header is filled in\r | |
448 | with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a\r | |
449 | GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with\r | |
450 | an instance specified by Instance and a caller ID specified by CallerId. If\r | |
451 | CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r | |
452 | \r | |
453 | ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()\r | |
454 | is called while processing another any other Report Status Code Library function,\r | |
455 | then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r | |
456 | \r | |
457 | If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r | |
458 | If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r | |
459 | \r | |
460 | @param Type Status code type.\r | |
461 | @param Value Status code value.\r | |
462 | @param Instance Status code instance number.\r | |
463 | @param CallerId Pointer to a GUID that identifies the caller of this\r | |
464 | function. If this parameter is NULL, then a caller\r | |
465 | ID of gEfiCallerIdGuid is used.\r | |
466 | @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.\r | |
467 | If this parameter is NULL, then a the status code\r | |
468 | standard header is filled in with\r | |
469 | gEfiStatusCodeSpecificDataGuid.\r | |
470 | @param ExtendedData Pointer to the extended data buffer. This is an\r | |
471 | optional parameter that may be NULL.\r | |
472 | @param ExtendedDataSize The size, in bytes, of the extended data buffer.\r | |
473 | \r | |
474 | @retval EFI_SUCCESS The status code was reported.\r | |
475 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate\r | |
476 | the extended data section if it was specified.\r | |
477 | @retval EFI_UNSUPPORTED Report status code is not supported\r | |
478 | \r | |
479 | **/\r | |
480 | EFI_STATUS\r | |
481 | EFIAPI\r | |
482 | ReportStatusCodeEx (\r | |
483 | IN EFI_STATUS_CODE_TYPE Type,\r | |
484 | IN EFI_STATUS_CODE_VALUE Value,\r | |
485 | IN UINT32 Instance,\r | |
486 | IN CONST EFI_GUID *CallerId OPTIONAL,\r | |
487 | IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,\r | |
488 | IN CONST VOID *ExtendedData OPTIONAL,\r | |
489 | IN UINTN ExtendedDataSize\r | |
490 | )\r | |
491 | {\r | |
492 | EFI_STATUS Status;\r | |
493 | EFI_STATUS_CODE_DATA *StatusCodeData;\r | |
494 | \r | |
495 | ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r | |
496 | ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r | |
497 | \r | |
498 | if (gBS == NULL) {\r | |
499 | return EFI_UNSUPPORTED;\r | |
500 | }\r | |
501 | \r | |
502 | //\r | |
503 | // Allocate space for the Status Code Header and its buffer\r | |
504 | //\r | |
505 | StatusCodeData = NULL;\r | |
506 | gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);\r | |
507 | if (StatusCodeData == NULL) {\r | |
508 | return EFI_OUT_OF_RESOURCES;\r | |
509 | }\r | |
510 | \r | |
511 | //\r | |
512 | // Fill in the extended data header\r | |
513 | //\r | |
514 | StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);\r | |
515 | StatusCodeData->Size = (UINT16)ExtendedDataSize;\r | |
516 | if (ExtendedDataGuid == NULL) {\r | |
517 | ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;\r | |
518 | }\r | |
519 | CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);\r | |
520 | \r | |
521 | //\r | |
522 | // Fill in the extended data buffer\r | |
523 | //\r | |
524 | CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);\r | |
525 | \r | |
526 | //\r | |
527 | // Report the status code\r | |
528 | //\r | |
529 | if (CallerId == NULL) {\r | |
530 | CallerId = &gEfiCallerIdGuid;\r | |
531 | }\r | |
532 | Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);\r | |
533 | \r | |
534 | //\r | |
535 | // Free the allocated buffer\r | |
536 | //\r | |
537 | gBS->FreePool (StatusCodeData);\r | |
538 | \r | |
539 | return Status;\r | |
540 | }\r | |
541 | \r | |
542 | \r | |
543 | /**\r | |
544 | Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled\r | |
545 | \r | |
546 | This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED\r | |
547 | bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.\r | |
548 | \r | |
549 | @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of\r | |
550 | PcdReportStatusCodeProperyMask is set.\r | |
551 | @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of\r | |
552 | PcdReportStatusCodeProperyMask is clear.\r | |
553 | \r | |
554 | **/\r | |
555 | BOOLEAN\r | |
556 | EFIAPI\r | |
557 | ReportProgressCodeEnabled (\r | |
558 | VOID\r | |
559 | )\r | |
560 | {\r | |
561 | return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);\r | |
562 | }\r | |
563 | \r | |
564 | \r | |
565 | /**\r | |
566 | Returns TRUE if status codes of type EFI_ERROR_CODE are enabled\r | |
567 | \r | |
568 | This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED\r | |
569 | bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.\r | |
570 | \r | |
571 | @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of\r | |
572 | PcdReportStatusCodeProperyMask is set.\r | |
573 | @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of\r | |
574 | PcdReportStatusCodeProperyMask is clear.\r | |
575 | \r | |
576 | **/\r | |
577 | BOOLEAN\r | |
578 | EFIAPI\r | |
579 | ReportErrorCodeEnabled (\r | |
580 | VOID\r | |
581 | )\r | |
582 | {\r | |
583 | return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);\r | |
584 | }\r | |
585 | \r | |
586 | \r | |
587 | /**\r | |
588 | Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled\r | |
589 | \r | |
590 | This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED\r | |
591 | bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.\r | |
592 | \r | |
593 | @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of\r | |
594 | PcdReportStatusCodeProperyMask is set.\r | |
595 | @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of\r | |
596 | PcdReportStatusCodeProperyMask is clear.\r | |
597 | \r | |
598 | **/\r | |
599 | BOOLEAN\r | |
600 | EFIAPI\r | |
601 | ReportDebugCodeEnabled (\r | |
602 | VOID\r | |
603 | )\r | |
604 | {\r | |
605 | return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r | |
606 | }\r |