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