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 <ProcessorBind.h>
19 #include <Pi/PiMultiPhase.h>
20 #include <Protocol/DevicePath.h>
23 // Declare bits for PcdReportStatusCodePropertyMask
25 #define REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED 0x00000001
26 #define REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED 0x00000002
27 #define REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED 0x00000004
30 // Extended Data structure definitions with EFI_STATUS_CODE_DATA headers removed
34 Converts a status code to an 8-bit POST code value.
36 Converts the status code specified by CodeType and Value to an 8-bit POST code
37 and returns the 8-bit POST code in PostCode. If CodeType is an
38 EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode
39 are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits
40 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned.
42 If PostCode is NULL, then ASSERT().
44 @param CodeType The type of status code being converted.
45 @param Value The status code value being converted.
46 @param PostCode A pointer to the 8-bit POST code value to return.
48 @retval TRUE The status code specified by CodeType and Value was converted
49 to an 8-bit POST code and returned in PostCode.
50 @retval FALSE The status code specified by CodeType and Value could not be
51 converted to an 8-bit POST code value.
57 IN EFI_STATUS_CODE_TYPE CodeType
,
58 IN EFI_STATUS_CODE_VALUE Value
,
64 Extracts ASSERT() information from a status code structure.
66 Converts the status code specified by CodeType, Value, and Data to the ASSERT()
67 arguments specified by Filename, Description, and LineNumber. If CodeType is
68 an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
69 Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
70 Filename, Description, and LineNumber from the optional data area of the
71 status code buffer specified by Data. The optional data area of Data contains
72 a Null-terminated ASCII string for the FileName, followed by a Null-terminated
73 ASCII string for the Description, followed by a 32-bit LineNumber. If the
74 ASSERT() information could be extracted from Data, then return TRUE.
75 Otherwise, FALSE is returned.
77 If Data is NULL, then ASSERT().
78 If Filename is NULL, then ASSERT().
79 If Description is NULL, then ASSERT().
80 If LineNumber is NULL, then ASSERT().
82 @param CodeType The type of status code being converted.
83 @param Value The status code value being converted.
84 @param Data Pointer to status code data buffer.
85 @param Filename Pointer to the source file name that generated the ASSERT().
86 @param Description Pointer to the description of the ASSERT().
87 @param LineNumber Pointer to source line number that generated the ASSERT().
89 @retval TRUE The status code specified by CodeType, Value, and Data was
90 converted ASSERT() arguments specified by Filename, Description,
92 @retval FALSE The status code specified by CodeType, Value, and Data could
93 not be converted to ASSERT() arguments.
98 ReportStatusCodeExtractAssertInfo (
99 IN EFI_STATUS_CODE_TYPE CodeType
,
100 IN EFI_STATUS_CODE_VALUE Value
,
101 IN CONST EFI_STATUS_CODE_DATA
*Data
,
102 OUT CHAR8
**Filename
,
103 OUT CHAR8
**Description
,
104 OUT UINT32
*LineNumber
109 Extracts DEBUG() information from a status code structure.
111 Converts the status code specified by Data to the DEBUG() arguments specified
112 by ErrorLevel, Marker, and Format. If type GUID in Data is
113 EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and
114 Format from the optional data area of the status code buffer specified by Data.
115 The optional data area of Data contains a 32-bit ErrorLevel followed by Marker
116 which is 12 UINTN parameters, followed by a Null-terminated ASCII string for
117 the Format. If the DEBUG() information could be extracted from Data, then
118 return TRUE. Otherwise, FALSE is returned.
120 If Data is NULL, then ASSERT().
121 If ErrorLevel is NULL, then ASSERT().
122 If Marker is NULL, then ASSERT().
123 If Format is NULL, then ASSERT().
125 @param Data Pointer to status code data buffer.
126 @param ErrorLevel Pointer to error level mask for a debug message.
127 @param Marker Pointer to the variable argument list associated with Format.
128 @param Format Pointer to a Null-terminated ASCII format string of a
131 @retval TRUE The status code specified by Data was converted DEBUG() arguments
132 specified by ErrorLevel, Marker, and Format.
133 @retval FALSE The status code specified by Data could not be converted to
139 ReportStatusCodeExtractDebugInfo (
140 IN CONST EFI_STATUS_CODE_DATA
*Data
,
141 OUT UINT32
*ErrorLevel
,
148 Reports a status code.
150 Reports the status code specified by the parameters Type and Value. Status
151 code also require an instance, caller ID, and extended data. This function
152 passed in a zero instance, NULL extended data, and a caller ID of
153 gEfiCallerIdGuid, which is the GUID for the module.
155 ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode()
156 is called while processing another any other Report Status Code Library function,
157 then ReportStatusCode() must return immediately.
159 @param Type Status code type.
160 @param Value Status code value.
162 @retval EFI_SUCCESS The status code was reported.
163 @retval EFI_DEVICE_ERROR There status code could not be reported due to a
165 @retval EFI_UNSUPPORTED Report status code is not supported
171 IN EFI_STATUS_CODE_TYPE Type
,
172 IN EFI_STATUS_CODE_VALUE Value
177 Reports a status code with a Device Path Protocol as the extended data.
179 Allocates and fills in the extended data section of a status code with the
180 Device Path Protocol specified by DevicePath. This function is responsible
181 for allocating a buffer large enough for the standard header and the device
182 path. The standard header is filled in with a GUID of
183 gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero
184 instance and a caller ID of gEfiCallerIdGuid.
186 ReportStatusCodeWithDevicePath()must actively prevent recursion. If
187 ReportStatusCodeWithDevicePath() is called while processing another any other
188 Report Status Code Library function, then ReportStatusCodeWithDevicePath()
189 must return EFI_DEVICE_ERROR immediately.
191 If DevicePath is NULL, then ASSERT().
193 @param Type Status code type.
194 @param Value Status code value.
195 @param DevicePath Pointer to the Device Path Protocol to be reported.
197 @retval EFI_SUCCESS The status code was reported with the extended
198 data specified by DevicePath.
199 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
200 extended data section.
201 @retval EFI_UNSUPPORTED Report status code is not supported
206 ReportStatusCodeWithDevicePath (
207 IN EFI_STATUS_CODE_TYPE Type
,
208 IN EFI_STATUS_CODE_VALUE Value
,
209 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
214 Reports a status code with an extended data buffer.
216 Allocates and fills in the extended data section of a status code with the
217 extended data specified by ExtendedData and ExtendedDataSize. ExtendedData
218 is assumed to be one of the data structures specified in Related Definitions.
219 These data structure do not have the standard header, so this function is
220 responsible for allocating a buffer large enough for the standard header and
221 the extended data passed into this function. The standard header is filled
222 in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported
223 with a zero instance and a caller ID of gEfiCallerIdGuid.
225 ReportStatusCodeWithExtendedData()must actively prevent recursion. If
226 ReportStatusCodeWithExtendedData() is called while processing another any other
227 Report Status Code Library function, then ReportStatusCodeWithExtendedData()
228 must return EFI_DEVICE_ERROR immediately.
230 If ExtendedData is NULL, then ASSERT().
231 If ExtendedDataSize is 0, then ASSERT().
233 @param Type Status code type.
234 @param Value Status code value.
235 @param ExtendedData Pointer to the extended data buffer to be reported.
236 @param ExtendedDataSize The size, in bytes, of the extended data buffer to
239 @retval EFI_SUCCESS The status code was reported with the extended
240 data specified by ExtendedData and ExtendedDataSize.
241 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
242 extended data section.
243 @retval EFI_UNSUPPORTED Report status code is not supported
248 ReportStatusCodeWithExtendedData (
249 IN EFI_STATUS_CODE_TYPE Type
,
250 IN EFI_STATUS_CODE_VALUE Value
,
251 IN CONST VOID
*ExtendedData
,
252 IN UINTN ExtendedDataSize
257 Reports a status code with full parameters.
259 The function reports a status code. If ExtendedData is NULL and ExtendedDataSize
260 is 0, then an extended data buffer is not reported. If ExtendedData is not
261 NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.
262 ExtendedData is assumed not have the standard status code header, so this function
263 is responsible for allocating a buffer large enough for the standard header and
264 the extended data passed into this function. The standard header is filled in
265 with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a
266 GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with
267 an instance specified by Instance and a caller ID specified by CallerId. If
268 CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.
270 ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()
271 is called while processing another any other Report Status Code Library function,
272 then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.
274 If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
275 If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
277 @param Type Status code type.
278 @param Value Status code value.
279 @param Instance Status code instance number.
280 @param CallerId Pointer to a GUID that identifies the caller of this
281 function. If this parameter is NULL, then a caller
282 ID of gEfiCallerIdGuid is used.
283 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
284 If this parameter is NULL, then a the status code
285 standard header is filled in with
286 gEfiStatusCodeSpecificDataGuid.
287 @param ExtendedData Pointer to the extended data buffer. This is an
288 optional parameter that may be NULL.
289 @param ExtendedDataSize The size, in bytes, of the extended data buffer.
291 @retval EFI_SUCCESS The status code was reported.
292 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate
293 the extended data section if it was specified.
294 @retval EFI_UNSUPPORTED Report status code is not supported
300 IN EFI_STATUS_CODE_TYPE Type
,
301 IN EFI_STATUS_CODE_VALUE Value
,
303 IN CONST EFI_GUID
*CallerId OPTIONAL
,
304 IN CONST EFI_GUID
*ExtendedDataGuid OPTIONAL
,
305 IN CONST VOID
*ExtendedData OPTIONAL
,
306 IN UINTN ExtendedDataSize
311 Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
313 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED
314 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
316 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
317 PcdReportStatusCodeProperyMask is set.
318 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
319 PcdReportStatusCodeProperyMask is clear.
324 ReportProgressCodeEnabled (
330 Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
332 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED
333 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
335 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
336 PcdReportStatusCodeProperyMask is set.
337 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
338 PcdReportStatusCodeProperyMask is clear.
343 ReportErrorCodeEnabled (
349 Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
351 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED
352 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
354 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
355 PcdReportStatusCodeProperyMask is set.
356 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
357 PcdReportStatusCodeProperyMask is clear.
362 ReportDebugCodeEnabled (
368 Reports a status code with minimal parameters if the status code type is enabled.
370 If the status code type specified by Type is enabled in
371 PcdReportStatusCodeProperyMask, then call ReportStatusCode() passing in Type
374 @param Type Status code type.
375 @param Value Status code value.
377 @retval EFI_SUCCESS The status code was reported.
378 @retval EFI_DEVICE_ERROR There status code could not be reported due to a device error.
379 @retval EFI_UNSUPPORTED Report status code is not supported
382 #define REPORT_STATUS_CODE(Type,Value) \
383 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
384 ReportStatusCode(Type,Value) : \
385 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
386 ReportStatusCode(Type,Value) : \
387 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
388 ReportStatusCode(Type,Value) : \
393 Reports a status code with a Device Path Protocol as the extended data if the
394 status code type is enabled.
396 If the status code type specified by Type is enabled in
397 PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithDevicePath()
398 passing in Type, Value, and DevicePath.
400 @param Type Status code type.
401 @param Value Status code value.
402 @param DevicePath Pointer to the Device Path Protocol to be reported.
404 @retval EFI_SUCCESS The status code was reported with the extended
405 data specified by DevicePath.
406 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
407 extended data section.
408 @retval EFI_UNSUPPORTED Report status code is not supported
411 #define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type,Value,DevicePathParameter) \
412 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
413 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
414 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
415 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
416 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
417 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
422 Reports a status code with an extended data buffer if the status code type
425 If the status code type specified by Type is enabled in
426 PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithExtendedData()
427 passing in Type, Value, ExtendedData, and ExtendedDataSize.
429 @param Type Status code type.
430 @param Value Status code value.
431 @param ExtendedData Pointer to the extended data buffer to be reported.
432 @param ExtendedDataSize The size, in bytes, of the extended data buffer to
435 @retval EFI_SUCCESS The status code was reported with the extended
436 data specified by ExtendedData and ExtendedDataSize.
437 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
438 extended data section.
439 @retval EFI_UNSUPPORTED Report status code is not supported
442 #define REPORT_STATUS_CODE_WITH_EXTENDED_DATA(Type,Value,ExtendedData,ExtendedDataSize) \
443 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
444 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
445 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
446 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
447 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
448 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
452 Reports a status code specifying all parameters if the status code type is enabled.
454 If the status code type specified by Type is enabled in
455 PcdReportStatusCodeProperyMask, then call ReportStatusCodeEx() passing in Type,
456 Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, and ExtendedDataSize.
458 @param Type Status code type.
459 @param Value Status code value.
460 @param Instance Status code instance number.
461 @param CallerId Pointer to a GUID that identifies the caller of this
462 function. If this parameter is NULL, then a caller
463 ID of gEfiCallerIdGuid is used.
464 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
465 If this parameter is NULL, then a the status code
466 standard header is filled in with
467 gEfiStatusCodeSpecificDataGuid.
468 @param ExtendedData Pointer to the extended data buffer. This is an
469 optional parameter that may be NULL.
470 @param ExtendedDataSize The size, in bytes, of the extended data buffer.
472 @retval EFI_SUCCESS The status code was reported.
473 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
474 extended data section if it was specified.
475 @retval EFI_UNSUPPORTED Report status code is not supported
478 #define REPORT_STATUS_CODE_EX(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) \
479 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
480 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
481 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
482 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
483 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
484 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \