]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
MdeModulePkg: Apply uncrustify changes
[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
1436aea4
MK
50 if ((gBS != NULL) && (gBS->LocateProtocol != NULL)) {\r
51 Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&mReportStatusCodeLibStatusCodeProtocol);\r
5db9d35f
RN
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
1436aea4
MK
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
75dea6bd 88 )\r
89{\r
1436aea4
MK
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
75dea6bd 94 //\r
4adf0008 95 // If mReportStatusCodeLibStatusCodeProtocol is NULL, then check if Report Status Code Protocol is available in system.\r
75dea6bd 96 //\r
4adf0008 97 InternalGetReportStatusCode ();\r
98 if (mReportStatusCodeLibStatusCodeProtocol == NULL) {\r
99 return EFI_UNSUPPORTED;\r
75dea6bd 100 }\r
4adf0008 101\r
75dea6bd 102 //\r
4adf0008 103 // A Report Status Code Protocol is present in system, so pass in all the parameters to the service.\r
75dea6bd 104 //\r
4adf0008 105 return mReportStatusCodeLibStatusCodeProtocol->ReportStatusCode (Type, Value, Instance, (EFI_GUID *)CallerId, Data);\r
75dea6bd 106 }\r
d1102dba 107\r
75dea6bd 108 return EFI_UNSUPPORTED;\r
109}\r
110\r
75dea6bd 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
1436aea4
MK
149 ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE))\r
150 {\r
151 *PostCode = (UINT8)((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |\r
152 (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));\r
75dea6bd 153 return TRUE;\r
154 }\r
1436aea4 155\r
75dea6bd 156 return FALSE;\r
157}\r
158\r
75dea6bd 159/**\r
160 Extracts ASSERT() information from a status code structure.\r
161\r
162 Converts the status code specified by CodeType, Value, and Data to the ASSERT()\r
163 arguments specified by Filename, Description, and LineNumber. If CodeType is\r
164 an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and\r
165 Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract\r
166 Filename, Description, and LineNumber from the optional data area of the\r
167 status code buffer specified by Data. The optional data area of Data contains\r
168 a Null-terminated ASCII string for the FileName, followed by a Null-terminated\r
169 ASCII string for the Description, followed by a 32-bit LineNumber. If the\r
170 ASSERT() information could be extracted from Data, then return TRUE.\r
171 Otherwise, FALSE is returned.\r
172\r
173 If Data is NULL, then ASSERT().\r
174 If Filename is NULL, then ASSERT().\r
175 If Description is NULL, then ASSERT().\r
176 If LineNumber is NULL, then ASSERT().\r
177\r
178 @param CodeType The type of status code being converted.\r
179 @param Value The status code value being converted.\r
180 @param Data Pointer to status code data buffer.\r
181 @param Filename Pointer to the source file name that generated the ASSERT().\r
182 @param Description Pointer to the description of the ASSERT().\r
183 @param LineNumber Pointer to source line number that generated the ASSERT().\r
184\r
185 @retval TRUE The status code specified by CodeType, Value, and Data was\r
186 converted ASSERT() arguments specified by Filename, Description,\r
187 and LineNumber.\r
188 @retval FALSE The status code specified by CodeType, Value, and Data could\r
189 not be converted to ASSERT() arguments.\r
190\r
191**/\r
192BOOLEAN\r
193EFIAPI\r
194ReportStatusCodeExtractAssertInfo (\r
195 IN EFI_STATUS_CODE_TYPE CodeType,\r
196 IN EFI_STATUS_CODE_VALUE Value,\r
197 IN CONST EFI_STATUS_CODE_DATA *Data,\r
198 OUT CHAR8 **Filename,\r
199 OUT CHAR8 **Description,\r
200 OUT UINT32 *LineNumber\r
201 )\r
202{\r
203 EFI_DEBUG_ASSERT_DATA *AssertData;\r
204\r
205 ASSERT (Data != NULL);\r
206 ASSERT (Filename != NULL);\r
207 ASSERT (Description != NULL);\r
208 ASSERT (LineNumber != NULL);\r
209\r
210 if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&\r
211 ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&\r
1436aea4
MK
212 ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE))\r
213 {\r
75dea6bd 214 AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);\r
215 *Filename = (CHAR8 *)(AssertData + 1);\r
216 *Description = *Filename + AsciiStrLen (*Filename) + 1;\r
217 *LineNumber = AssertData->LineNumber;\r
218 return TRUE;\r
219 }\r
1436aea4 220\r
75dea6bd 221 return FALSE;\r
222}\r
223\r
75dea6bd 224/**\r
225 Extracts DEBUG() information from a status code structure.\r
226\r
227 Converts the status code specified by Data to the DEBUG() arguments specified\r
228 by ErrorLevel, Marker, and Format. If type GUID in Data is\r
229 EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and\r
230 Format from the optional data area of the status code buffer specified by Data.\r
231 The optional data area of Data contains a 32-bit ErrorLevel followed by Marker\r
232 which is 12 UINTN parameters, followed by a Null-terminated ASCII string for\r
233 the Format. If the DEBUG() information could be extracted from Data, then\r
234 return TRUE. Otherwise, FALSE is returned.\r
235\r
236 If Data is NULL, then ASSERT().\r
237 If ErrorLevel is NULL, then ASSERT().\r
238 If Marker is NULL, then ASSERT().\r
239 If Format is NULL, then ASSERT().\r
240\r
241 @param Data Pointer to status code data buffer.\r
242 @param ErrorLevel Pointer to error level mask for a debug message.\r
243 @param Marker Pointer to the variable argument list associated with Format.\r
244 @param Format Pointer to a Null-terminated ASCII format string of a\r
245 debug message.\r
246\r
247 @retval TRUE The status code specified by Data was converted DEBUG() arguments\r
248 specified by ErrorLevel, Marker, and Format.\r
249 @retval FALSE The status code specified by Data could not be converted to\r
250 DEBUG() arguments.\r
251\r
252**/\r
253BOOLEAN\r
254EFIAPI\r
255ReportStatusCodeExtractDebugInfo (\r
256 IN CONST EFI_STATUS_CODE_DATA *Data,\r
257 OUT UINT32 *ErrorLevel,\r
258 OUT BASE_LIST *Marker,\r
259 OUT CHAR8 **Format\r
260 )\r
261{\r
262 EFI_DEBUG_INFO *DebugInfo;\r
263\r
264 ASSERT (Data != NULL);\r
265 ASSERT (ErrorLevel != NULL);\r
266 ASSERT (Marker != NULL);\r
267 ASSERT (Format != NULL);\r
268\r
269 //\r
270 // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE\r
271 //\r
272 if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {\r
273 return FALSE;\r
274 }\r
275\r
276 //\r
277 // Retrieve the debug information from the status code record\r
278 //\r
279 DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);\r
280\r
281 *ErrorLevel = DebugInfo->ErrorLevel;\r
282\r
283 //\r
284 // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments\r
285 // of format in DEBUG string. Its address is returned in Marker and has to be 64-bit aligned.\r
286 // It must be noticed that EFI_DEBUG_INFO follows EFI_STATUS_CODE_DATA, whose size is\r
287 // 20 bytes. The size of EFI_DEBUG_INFO is 4 bytes, so we can ensure that Marker\r
288 // returned is 64-bit aligned.\r
289 // 64-bit aligned is a must, otherwise retrieving 64-bit parameter from BASE_LIST will\r
290 // cause unalignment exception.\r
291 //\r
1436aea4 292 *Marker = (BASE_LIST)(DebugInfo + 1);\r
75dea6bd 293 *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);\r
294\r
295 return TRUE;\r
296}\r
297\r
75dea6bd 298/**\r
299 Reports a status code.\r
300\r
301 Reports the status code specified by the parameters Type and Value. Status\r
302 code also require an instance, caller ID, and extended data. This function\r
303 passed in a zero instance, NULL extended data, and a caller ID of\r
304 gEfiCallerIdGuid, which is the GUID for the module.\r
305\r
306 ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode()\r
307 is called while processing another any other Report Status Code Library function,\r
308 then ReportStatusCode() must return immediately.\r
309\r
310 @param Type Status code type.\r
311 @param Value Status code value.\r
312\r
313 @retval EFI_SUCCESS The status code was reported.\r
314 @retval EFI_DEVICE_ERROR There status code could not be reported due to a\r
315 device error.\r
316 @retval EFI_UNSUPPORTED Report status code is not supported\r
317\r
318**/\r
319EFI_STATUS\r
320EFIAPI\r
321ReportStatusCode (\r
322 IN EFI_STATUS_CODE_TYPE Type,\r
323 IN EFI_STATUS_CODE_VALUE Value\r
324 )\r
325{\r
326 return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);\r
327}\r
328\r
75dea6bd 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
75dea6bd 374/**\r
375 Reports a status code with an extended data buffer.\r
376\r
377 Allocates and fills in the extended data section of a status code with the\r
378 extended data specified by ExtendedData and ExtendedDataSize. ExtendedData\r
379 is assumed to be one of the data structures specified in Related Definitions.\r
380 These data structure do not have the standard header, so this function is\r
381 responsible for allocating a buffer large enough for the standard header and\r
382 the extended data passed into this function. The standard header is filled\r
383 in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported\r
384 with a zero instance and a caller ID of gEfiCallerIdGuid.\r
385\r
386 ReportStatusCodeWithExtendedData()must actively prevent recursion. If\r
387 ReportStatusCodeWithExtendedData() is called while processing another any other\r
388 Report Status Code Library function, then ReportStatusCodeWithExtendedData()\r
389 must return EFI_DEVICE_ERROR immediately.\r
390\r
391 If ExtendedData is NULL, then ASSERT().\r
392 If ExtendedDataSize is 0, then ASSERT().\r
393\r
394 @param Type Status code type.\r
395 @param Value Status code value.\r
396 @param ExtendedData Pointer to the extended data buffer to be reported.\r
397 @param ExtendedDataSize The size, in bytes, of the extended data buffer to\r
398 be reported.\r
399\r
400 @retval EFI_SUCCESS The status code was reported with the extended\r
401 data specified by ExtendedData and ExtendedDataSize.\r
402 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the\r
403 extended data section.\r
404 @retval EFI_UNSUPPORTED Report status code is not supported\r
405\r
406**/\r
407EFI_STATUS\r
408EFIAPI\r
409ReportStatusCodeWithExtendedData (\r
410 IN EFI_STATUS_CODE_TYPE Type,\r
411 IN EFI_STATUS_CODE_VALUE Value,\r
412 IN CONST VOID *ExtendedData,\r
413 IN UINTN ExtendedDataSize\r
414 )\r
415{\r
416 ASSERT (ExtendedData != NULL);\r
417 ASSERT (ExtendedDataSize != 0);\r
418 return ReportStatusCodeEx (\r
419 Type,\r
420 Value,\r
421 0,\r
422 NULL,\r
423 NULL,\r
424 ExtendedData,\r
425 ExtendedDataSize\r
426 );\r
427}\r
428\r
75dea6bd 429/**\r
430 Reports a status code with full parameters.\r
431\r
432 The function reports a status code. If ExtendedData is NULL and ExtendedDataSize\r
433 is 0, then an extended data buffer is not reported. If ExtendedData is not\r
434 NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.\r
435 ExtendedData is assumed not have the standard status code header, so this function\r
436 is responsible for allocating a buffer large enough for the standard header and\r
437 the extended data passed into this function. The standard header is filled in\r
438 with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a\r
439 GUID of gEfiStatusCodeSpecificDataGuid is used. The status code is reported with\r
440 an instance specified by Instance and a caller ID specified by CallerId. If\r
441 CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r
442\r
443 ReportStatusCodeEx()must actively prevent recursion. If\r
444 ReportStatusCodeEx() is called while processing another any\r
445 other Report Status Code Library function, then\r
446 ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r
447\r
448 If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r
449 If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r
450\r
451 @param Type Status code type.\r
452 @param Value Status code value.\r
453 @param Instance Status code instance number.\r
454 @param CallerId Pointer to a GUID that identifies the caller of this\r
455 function. If this parameter is NULL, then a caller\r
456 ID of gEfiCallerIdGuid is used.\r
457 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.\r
458 If this parameter is NULL, then a the status code\r
459 standard header is filled in with\r
460 gEfiStatusCodeSpecificDataGuid.\r
461 @param ExtendedData Pointer to the extended data buffer. This is an\r
462 optional parameter that may be NULL.\r
463 @param ExtendedDataSize The size, in bytes, of the extended data buffer.\r
464\r
465 @retval EFI_SUCCESS The status code was reported.\r
466 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate\r
467 the extended data section if it was specified.\r
468 @retval EFI_UNSUPPORTED Report status code is not supported\r
469\r
470**/\r
471EFI_STATUS\r
472EFIAPI\r
473ReportStatusCodeEx (\r
474 IN EFI_STATUS_CODE_TYPE Type,\r
475 IN EFI_STATUS_CODE_VALUE Value,\r
476 IN UINT32 Instance,\r
477 IN CONST EFI_GUID *CallerId OPTIONAL,\r
478 IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,\r
479 IN CONST VOID *ExtendedData OPTIONAL,\r
480 IN UINTN ExtendedDataSize\r
481 )\r
482{\r
483 EFI_STATUS Status;\r
484 EFI_STATUS_CODE_DATA *StatusCodeData;\r
c5e0de87 485 EFI_TPL Tpl;\r
7b788539 486 UINT64 Buffer[(MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)) + 1];\r
75dea6bd 487\r
488 ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r
489 ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r
490\r
c22f52c5
MK
491 if (ExtendedDataSize <= (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) {\r
492 //\r
493 // Use Buffer instead of allocating if possible.\r
494 //\r
495 StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;\r
496 } else {\r
1436aea4 497 if ((gBS == NULL) || (gBS->AllocatePool == NULL) || (gBS->FreePool == NULL)) {\r
c22f52c5
MK
498 return EFI_UNSUPPORTED;\r
499 }\r
d1102dba 500\r
c5e0de87 501 //\r
c22f52c5 502 // Retrieve the current TPL\r
c5e0de87 503 //\r
c22f52c5
MK
504 Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
505 gBS->RestoreTPL (Tpl);\r
506\r
507 if (Tpl > TPL_NOTIFY) {\r
508 return EFI_OUT_OF_RESOURCES;\r
509 }\r
c5e0de87 510\r
c5e0de87 511 //\r
c22f52c5 512 // Allocate space for the Status Code Header and its buffer\r
c5e0de87 513 //\r
c22f52c5
MK
514 StatusCodeData = NULL;\r
515 gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);\r
516 if (StatusCodeData == NULL) {\r
c5e0de87 517 return EFI_OUT_OF_RESOURCES;\r
518 }\r
75dea6bd 519 }\r
520\r
521 //\r
522 // Fill in the extended data header\r
523 //\r
1436aea4
MK
524 StatusCodeData->HeaderSize = (UINT16)sizeof (EFI_STATUS_CODE_DATA);\r
525 StatusCodeData->Size = (UINT16)ExtendedDataSize;\r
75dea6bd 526 if (ExtendedDataGuid == NULL) {\r
527 ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;\r
528 }\r
1436aea4 529\r
75dea6bd 530 CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);\r
531\r
532 //\r
533 // Fill in the extended data buffer\r
534 //\r
535 if (ExtendedData != NULL) {\r
536 CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);\r
537 }\r
538\r
539 //\r
540 // Report the status code\r
541 //\r
542 if (CallerId == NULL) {\r
543 CallerId = &gEfiCallerIdGuid;\r
544 }\r
1436aea4 545\r
75dea6bd 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
75dea6bd 558/**\r
559 Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled\r
560\r
561 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED\r
562 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.\r
563\r
564 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of\r
565 PcdReportStatusCodeProperyMask is set.\r
566 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of\r
567 PcdReportStatusCodeProperyMask is clear.\r
568\r
569**/\r
570BOOLEAN\r
571EFIAPI\r
572ReportProgressCodeEnabled (\r
573 VOID\r
574 )\r
575{\r
1436aea4 576 return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);\r
75dea6bd 577}\r
578\r
75dea6bd 579/**\r
580 Returns TRUE if status codes of type EFI_ERROR_CODE are enabled\r
581\r
582 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED\r
583 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.\r
584\r
585 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of\r
586 PcdReportStatusCodeProperyMask is set.\r
587 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of\r
588 PcdReportStatusCodeProperyMask is clear.\r
589\r
590**/\r
591BOOLEAN\r
592EFIAPI\r
593ReportErrorCodeEnabled (\r
594 VOID\r
595 )\r
596{\r
1436aea4 597 return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);\r
75dea6bd 598}\r
599\r
75dea6bd 600/**\r
601 Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled\r
602\r
603 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED\r
604 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.\r
605\r
606 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of\r
607 PcdReportStatusCodeProperyMask is set.\r
608 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of\r
609 PcdReportStatusCodeProperyMask is clear.\r
610\r
611**/\r
612BOOLEAN\r
613EFIAPI\r
614ReportDebugCodeEnabled (\r
615 VOID\r
616 )\r
617{\r
1436aea4 618 return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
75dea6bd 619}\r