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