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