2 Report Status Code Library public .h file
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __REPORT_STATUS_CODE_LIB_H__
16 #define __REPORT_STATUS_CODE_LIB_H__
18 #include <Protocol/DevicePath.h>
21 // Declare bits for PcdReportStatusCodePropertyMask
23 #define REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED 0x00000001
24 #define REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED 0x00000002
25 #define REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED 0x00000004
28 // Extended Data structure definitions with EFI_STATUS_CODE_DATA headers removed
32 // Extern for the modules Caller ID GUID
34 extern EFI_GUID gEfiCallerIdGuid
;
37 Converts a status code to an 8-bit POST code value.
39 Converts the status code specified by CodeType and Value to an 8-bit POST code
40 and returns the 8-bit POST code in PostCode. If CodeType is an
41 EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode
42 are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits
43 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned.
45 If PostCode is NULL, then ASSERT().
47 @param CodeType The type of status code being converted.
48 @param Value The status code value being converted.
49 @param PostCode A pointer to the 8-bit POST code value to return.
51 @retval TRUE The status code specified by CodeType and Value was converted
52 to an 8-bit POST code and returned in PostCode.
53 @retval FALSE The status code specified by CodeType and Value could not be
54 converted to an 8-bit POST code value.
60 IN EFI_STATUS_CODE_TYPE CodeType
,
61 IN EFI_STATUS_CODE_VALUE Value
,
67 Extracts ASSERT() information from a status code structure.
69 Converts the status code specified by CodeType, Value, and Data to the ASSERT()
70 arguments specified by Filename, Description, and LineNumber. If CodeType is
71 an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
72 Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
73 Filename, Description, and LineNumber from the optional data area of the
74 status code buffer specified by Data. The optional data area of Data contains
75 a Null-terminated ASCII string for the FileName, followed by a Null-terminated
76 ASCII string for the Description, followed by a 32-bit LineNumber. If the
77 ASSERT() information could be extracted from Data, then return TRUE.
78 Otherwise, FALSE is returned.
80 If Data is NULL, then ASSERT().
81 If Filename is NULL, then ASSERT().
82 If Description is NULL, then ASSERT().
83 If LineNumber is NULL, then ASSERT().
85 @param CodeType The type of status code being converted.
86 @param Value The status code value being converted.
87 @param Data Pointer to status code data buffer.
88 @param Filename Pointer to the source file name that generated the ASSERT().
89 @param Description Pointer to the description of the ASSERT().
90 @param LineNumber Pointer to source line number that generated the ASSERT().
92 @retval TRUE The status code specified by CodeType, Value, and Data was
93 converted ASSERT() arguments specified by Filename, Description,
95 @retval FALSE The status code specified by CodeType, Value, and Data could
96 not be converted to ASSERT() arguments.
101 ReportStatusCodeExtractAssertInfo (
102 IN EFI_STATUS_CODE_TYPE CodeType
,
103 IN EFI_STATUS_CODE_VALUE Value
,
104 IN CONST EFI_STATUS_CODE_DATA
*Data
,
105 OUT CHAR8
**Filename
,
106 OUT CHAR8
**Description
,
107 OUT UINT32
*LineNumber
112 Extracts DEBUG() information from a status code structure.
114 Converts the status code specified by Data to the DEBUG() arguments specified
115 by ErrorLevel, Marker, and Format. If type GUID in Data is
116 EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and
117 Format from the optional data area of the status code buffer specified by Data.
118 The optional data area of Data contains a 32-bit ErrorLevel followed by Marker
119 which is 12 UINTN parameters, followed by a Null-terminated ASCII string for
120 the Format. If the DEBUG() information could be extracted from Data, then
121 return TRUE. Otherwise, FALSE is returned.
123 If Data is NULL, then ASSERT().
124 If ErrorLevel is NULL, then ASSERT().
125 If Marker is NULL, then ASSERT().
126 If Format is NULL, then ASSERT().
128 @param Data Pointer to status code data buffer.
129 @param ErrorLevel Pointer to error level mask for a debug message.
130 @param Marker Pointer to the variable argument list associated with Format.
131 @param Format Pointer to a Null-terminated ASCII format string of a
134 @retval TRUE The status code specified by Data was converted DEBUG() arguments
135 specified by ErrorLevel, Marker, and Format.
136 @retval FALSE The status code specified by Data could not be converted to
142 ReportStatusCodeExtractDebugInfo (
143 IN CONST EFI_STATUS_CODE_DATA
*Data
,
144 OUT UINT32
*ErrorLevel
,
151 Reports a status code.
153 Reports the status code specified by the parameters Type and Value. Status
154 code also require an instance, caller ID, and extended data. This function
155 passed in a zero instance, NULL extended data, and a caller ID of
156 gEfiCallerIdGuid, which is the GUID for the module.
158 ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode()
159 is called while processing another any other Report Status Code Library function,
160 then ReportStatusCode() must return immediately.
162 @param Type Status code type.
163 @param Value Status code value.
165 @retval EFI_SUCCESS The status code was reported.
166 @retval EFI_DEVICE_ERROR There status code could not be reported due to a
168 @retval EFI_UNSUPPORTED Report status code is not supported
174 IN EFI_STATUS_CODE_TYPE Type
,
175 IN EFI_STATUS_CODE_VALUE Value
180 Reports a status code with a Device Path Protocol as the extended data.
182 Allocates and fills in the extended data section of a status code with the
183 Device Path Protocol specified by DevicePath. This function is responsible
184 for allocating a buffer large enough for the standard header and the device
185 path. The standard header is filled in with a GUID of
186 gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero
187 instance and a caller ID of gEfiCallerIdGuid.
189 ReportStatusCodeWithDevicePath()must actively prevent recursion. If
190 ReportStatusCodeWithDevicePath() is called while processing another any other
191 Report Status Code Library function, then ReportStatusCodeWithDevicePath()
192 must return EFI_DEVICE_ERROR immediately.
194 If DevicePath is NULL, then ASSERT().
196 @param Type Status code type.
197 @param Value Status code value.
198 @param DevicePath Pointer to the Device Path Protocol to be reported.
200 @retval EFI_SUCCESS The status code was reported with the extended
201 data specified by DevicePath.
202 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
203 extended data section.
204 @retval EFI_UNSUPPORTED Report status code is not supported
209 ReportStatusCodeWithDevicePath (
210 IN EFI_STATUS_CODE_TYPE Type
,
211 IN EFI_STATUS_CODE_VALUE Value
,
212 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
217 Reports a status code with an extended data buffer.
219 Allocates and fills in the extended data section of a status code with the
220 extended data specified by ExtendedData and ExtendedDataSize. ExtendedData
221 is assumed to be one of the data structures specified in Related Definitions.
222 These data structure do not have the standard header, so this function is
223 responsible for allocating a buffer large enough for the standard header and
224 the extended data passed into this function. The standard header is filled
225 in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported
226 with a zero instance and a caller ID of gEfiCallerIdGuid.
228 ReportStatusCodeWithExtendedData()must actively prevent recursion. If
229 ReportStatusCodeWithExtendedData() is called while processing another any other
230 Report Status Code Library function, then ReportStatusCodeWithExtendedData()
231 must return EFI_DEVICE_ERROR immediately.
233 If ExtendedData is NULL, then ASSERT().
234 If ExtendedDataSize is 0, then ASSERT().
236 @param Type Status code type.
237 @param Value Status code value.
238 @param ExtendedData Pointer to the extended data buffer to be reported.
239 @param ExtendedDataSize The size, in bytes, of the extended data buffer to
242 @retval EFI_SUCCESS The status code was reported with the extended
243 data specified by ExtendedData and ExtendedDataSize.
244 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
245 extended data section.
246 @retval EFI_UNSUPPORTED Report status code is not supported
251 ReportStatusCodeWithExtendedData (
252 IN EFI_STATUS_CODE_TYPE Type
,
253 IN EFI_STATUS_CODE_VALUE Value
,
254 IN CONST VOID
*ExtendedData
,
255 IN UINTN ExtendedDataSize
260 Reports a status code with full parameters.
262 The function reports a status code. If ExtendedData is NULL and ExtendedDataSize
263 is 0, then an extended data buffer is not reported. If ExtendedData is not
264 NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.
265 ExtendedData is assumed not have the standard status code header, so this function
266 is responsible for allocating a buffer large enough for the standard header and
267 the extended data passed into this function. The standard header is filled in
268 with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a
269 GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with
270 an instance specified by Instance and a caller ID specified by CallerId. If
271 CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.
273 ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()
274 is called while processing another any other Report Status Code Library function,
275 then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.
277 If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
278 If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
280 @param Type Status code type.
281 @param Value Status code value.
282 @param Instance Status code instance number.
283 @param CallerId Pointer to a GUID that identifies the caller of this
284 function. If this parameter is NULL, then a caller
285 ID of gEfiCallerIdGuid is used.
286 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
287 If this parameter is NULL, then a the status code
288 standard header is filled in with
289 gEfiStatusCodeSpecificDataGuid.
290 @param ExtendedData Pointer to the extended data buffer. This is an
291 optional parameter that may be NULL.
292 @param ExtendedDataSize The size, in bytes, of the extended data buffer.
294 @retval EFI_SUCCESS The status code was reported.
295 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate
296 the extended data section if it was specified.
297 @retval EFI_UNSUPPORTED Report status code is not supported
303 IN EFI_STATUS_CODE_TYPE Type
,
304 IN EFI_STATUS_CODE_VALUE Value
,
306 IN CONST EFI_GUID
*CallerId OPTIONAL
,
307 IN CONST EFI_GUID
*ExtendedDataGuid OPTIONAL
,
308 IN CONST VOID
*ExtendedData OPTIONAL
,
309 IN UINTN ExtendedDataSize
314 Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
316 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED
317 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
319 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
320 PcdReportStatusCodeProperyMask is set.
321 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
322 PcdReportStatusCodeProperyMask is clear.
327 ReportProgressCodeEnabled (
333 Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
335 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED
336 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
338 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
339 PcdReportStatusCodeProperyMask is set.
340 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
341 PcdReportStatusCodeProperyMask is clear.
346 ReportErrorCodeEnabled (
352 Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
354 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED
355 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
357 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
358 PcdReportStatusCodeProperyMask is set.
359 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
360 PcdReportStatusCodeProperyMask is clear.
365 ReportDebugCodeEnabled (
371 Reports a status code with minimal parameters if the status code type is enabled.
373 If the status code type specified by Type is enabled in
374 PcdReportStatusCodeProperyMask, then call ReportStatusCode() passing in Type
377 @param Type Status code type.
378 @param Value Status code value.
380 @retval EFI_SUCCESS The status code was reported.
381 @retval EFI_DEVICE_ERROR There status code could not be reported due to a device error.
382 @retval EFI_UNSUPPORTED Report status code is not supported
385 #define REPORT_STATUS_CODE(Type,Value) \
386 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
387 ReportStatusCode(Type,Value) : \
388 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
389 ReportStatusCode(Type,Value) : \
390 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
391 ReportStatusCode(Type,Value) : \
396 Reports a status code with a Device Path Protocol as the extended data if the
397 status code type is enabled.
399 If the status code type specified by Type is enabled in
400 PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithDevicePath()
401 passing in Type, Value, and DevicePath.
403 @param Type Status code type.
404 @param Value Status code value.
405 @param DevicePath Pointer to the Device Path Protocol to be reported.
407 @retval EFI_SUCCESS The status code was reported with the extended
408 data specified by DevicePath.
409 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
410 extended data section.
411 @retval EFI_UNSUPPORTED Report status code is not supported
414 #define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type,Value,DevicePathParameter) \
415 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
416 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
417 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
418 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
419 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
420 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
425 Reports a status code with an extended data buffer if the status code type
428 If the status code type specified by Type is enabled in
429 PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithExtendedData()
430 passing in Type, Value, ExtendedData, and ExtendedDataSize.
432 @param Type Status code type.
433 @param Value Status code value.
434 @param ExtendedData Pointer to the extended data buffer to be reported.
435 @param ExtendedDataSize The size, in bytes, of the extended data buffer to
438 @retval EFI_SUCCESS The status code was reported with the extended
439 data specified by ExtendedData and ExtendedDataSize.
440 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
441 extended data section.
442 @retval EFI_UNSUPPORTED Report status code is not supported
445 #define REPORT_STATUS_CODE_WITH_EXTENDED_DATA(Type,Value,ExtendedData,ExtendedDataSize) \
446 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
447 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
448 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
449 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
450 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
451 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
455 Reports a status code specifying all parameters if the status code type is enabled.
457 If the status code type specified by Type is enabled in
458 PcdReportStatusCodeProperyMask, then call ReportStatusCodeEx() passing in Type,
459 Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, and ExtendedDataSize.
461 @param Type Status code type.
462 @param Value Status code value.
463 @param Instance Status code instance number.
464 @param CallerId Pointer to a GUID that identifies the caller of this
465 function. If this parameter is NULL, then a caller
466 ID of gEfiCallerIdGuid is used.
467 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
468 If this parameter is NULL, then a the status code
469 standard header is filled in with
470 gEfiStatusCodeSpecificDataGuid.
471 @param ExtendedData Pointer to the extended data buffer. This is an
472 optional parameter that may be NULL.
473 @param ExtendedDataSize The size, in bytes, of the extended data buffer.
475 @retval EFI_SUCCESS The status code was reported.
476 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
477 extended data section if it was specified.
478 @retval EFI_UNSUPPORTED Report status code is not supported
481 #define REPORT_STATUS_CODE_EX(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) \
482 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
483 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
484 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
485 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
486 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
487 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \