2 Provides services to log status code records.
4 Copyright (c) 2006 - 2008, 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 <Pi/PiMultiPhase.h>
19 #include <Protocol/DevicePath.h>
22 // Declare bits for PcdReportStatusCodePropertyMask
24 #define REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED 0x00000001
25 #define REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED 0x00000002
26 #define REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED 0x00000004
29 // Extended Data structure definitions with EFI_STATUS_CODE_DATA headers removed
33 Converts a status code to an 8-bit POST code value.
35 Converts the status code specified by CodeType and Value to an 8-bit POST code
36 and returns the 8-bit POST code in PostCode. If CodeType is an
37 EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode
38 are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits
39 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned.
41 If PostCode is NULL, then ASSERT().
43 @param CodeType The type of status code being converted.
44 @param Value The status code value being converted.
45 @param PostCode A pointer to the 8-bit POST code value to return.
47 @retval TRUE The status code specified by CodeType and Value was converted
48 to an 8-bit POST code and returned in PostCode.
49 @retval FALSE The status code specified by CodeType and Value could not be
50 converted to an 8-bit POST code value.
56 IN EFI_STATUS_CODE_TYPE CodeType
,
57 IN EFI_STATUS_CODE_VALUE Value
,
63 Extracts ASSERT() information from a status code structure.
65 Converts the status code specified by CodeType, Value, and Data to the ASSERT()
66 arguments specified by Filename, Description, and LineNumber. If CodeType is
67 an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
68 Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
69 Filename, Description, and LineNumber from the optional data area of the
70 status code buffer specified by Data. The optional data area of Data contains
71 a Null-terminated ASCII string for the FileName, followed by a Null-terminated
72 ASCII string for the Description, followed by a 32-bit LineNumber. If the
73 ASSERT() information could be extracted from Data, then return TRUE.
74 Otherwise, FALSE is returned.
76 If Data is NULL, then ASSERT().
77 If Filename is NULL, then ASSERT().
78 If Description is NULL, then ASSERT().
79 If LineNumber is NULL, then ASSERT().
81 @param CodeType The type of status code being converted.
82 @param Value The status code value being converted.
83 @param Data Pointer to status code data buffer.
84 @param Filename Pointer to the source file name that generated the ASSERT().
85 @param Description Pointer to the description of the ASSERT().
86 @param LineNumber Pointer to source line number that generated the ASSERT().
88 @retval TRUE The status code specified by CodeType, Value, and Data was
89 converted ASSERT() arguments specified by Filename, Description,
91 @retval FALSE The status code specified by CodeType, Value, and Data could
92 not be converted to ASSERT() arguments.
97 ReportStatusCodeExtractAssertInfo (
98 IN EFI_STATUS_CODE_TYPE CodeType
,
99 IN EFI_STATUS_CODE_VALUE Value
,
100 IN CONST EFI_STATUS_CODE_DATA
*Data
,
101 OUT CHAR8
**Filename
,
102 OUT CHAR8
**Description
,
103 OUT UINT32
*LineNumber
108 Extracts DEBUG() information from a status code structure.
110 Converts the status code specified by Data to the DEBUG() arguments specified
111 by ErrorLevel, Marker, and Format. If type GUID in Data is
112 EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and
113 Format from the optional data area of the status code buffer specified by Data.
114 The optional data area of Data contains a 32-bit ErrorLevel followed by Marker
115 which is 12 UINTN parameters, followed by a Null-terminated ASCII string for
116 the Format. If the DEBUG() information could be extracted from Data, then
117 return TRUE. Otherwise, FALSE is returned.
119 If Data is NULL, then ASSERT().
120 If ErrorLevel is NULL, then ASSERT().
121 If Marker is NULL, then ASSERT().
122 If Format is NULL, then ASSERT().
124 @param Data Pointer to status code data buffer.
125 @param ErrorLevel Pointer to error level mask for a debug message.
126 @param Marker Pointer to the variable argument list associated with Format.
127 @param Format Pointer to a Null-terminated ASCII format string of a
130 @retval TRUE The status code specified by Data was converted DEBUG() arguments
131 specified by ErrorLevel, Marker, and Format.
132 @retval FALSE The status code specified by Data could not be converted to
138 ReportStatusCodeExtractDebugInfo (
139 IN CONST EFI_STATUS_CODE_DATA
*Data
,
140 OUT UINT32
*ErrorLevel
,
147 Reports a status code.
149 Reports the status code specified by the parameters Type and Value. Status
150 code also require an instance, caller ID, and extended data. This function
151 passed in a zero instance, NULL extended data, and a caller ID of
152 gEfiCallerIdGuid, which is the GUID for the module.
154 ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode()
155 is called while processing another any other Report Status Code Library function,
156 then ReportStatusCode() must return immediately.
158 @param Type Status code type.
159 @param Value Status code value.
161 @retval EFI_SUCCESS The status code was reported.
162 @retval EFI_DEVICE_ERROR There status code could not be reported due to a
164 @retval EFI_UNSUPPORTED Report status code is not supported
170 IN EFI_STATUS_CODE_TYPE Type
,
171 IN EFI_STATUS_CODE_VALUE Value
176 Reports a status code with a Device Path Protocol as the extended data.
178 Allocates and fills in the extended data section of a status code with the
179 Device Path Protocol specified by DevicePath. This function is responsible
180 for allocating a buffer large enough for the standard header and the device
181 path. The standard header is filled in with a GUID of
182 gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero
183 instance and a caller ID of gEfiCallerIdGuid.
185 ReportStatusCodeWithDevicePath()must actively prevent recursion. If
186 ReportStatusCodeWithDevicePath() is called while processing another any other
187 Report Status Code Library function, then ReportStatusCodeWithDevicePath()
188 must return EFI_DEVICE_ERROR immediately.
190 If DevicePath is NULL, then ASSERT().
192 @param Type Status code type.
193 @param Value Status code value.
194 @param DevicePath Pointer to the Device Path Protocol to be reported.
196 @retval EFI_SUCCESS The status code was reported with the extended
197 data specified by DevicePath.
198 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
199 extended data section.
200 @retval EFI_UNSUPPORTED Report status code is not supported
205 ReportStatusCodeWithDevicePath (
206 IN EFI_STATUS_CODE_TYPE Type
,
207 IN EFI_STATUS_CODE_VALUE Value
,
208 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
213 Reports a status code with an extended data buffer.
215 Allocates and fills in the extended data section of a status code with the
216 extended data specified by ExtendedData and ExtendedDataSize. ExtendedData
217 is assumed to be one of the data structures specified in Related Definitions.
218 These data structure do not have the standard header, so this function is
219 responsible for allocating a buffer large enough for the standard header and
220 the extended data passed into this function. The standard header is filled
221 in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported
222 with a zero instance and a caller ID of gEfiCallerIdGuid.
224 ReportStatusCodeWithExtendedData()must actively prevent recursion. If
225 ReportStatusCodeWithExtendedData() is called while processing another any other
226 Report Status Code Library function, then ReportStatusCodeWithExtendedData()
227 must return EFI_DEVICE_ERROR immediately.
229 If ExtendedData is NULL, then ASSERT().
230 If ExtendedDataSize is 0, then ASSERT().
232 @param Type Status code type.
233 @param Value Status code value.
234 @param ExtendedData Pointer to the extended data buffer to be reported.
235 @param ExtendedDataSize The size, in bytes, of the extended data buffer to
238 @retval EFI_SUCCESS The status code was reported with the extended
239 data specified by ExtendedData and ExtendedDataSize.
240 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
241 extended data section.
242 @retval EFI_UNSUPPORTED Report status code is not supported
247 ReportStatusCodeWithExtendedData (
248 IN EFI_STATUS_CODE_TYPE Type
,
249 IN EFI_STATUS_CODE_VALUE Value
,
250 IN CONST VOID
*ExtendedData
,
251 IN UINTN ExtendedDataSize
256 Reports a status code with full parameters.
258 The function reports a status code. If ExtendedData is NULL and ExtendedDataSize
259 is 0, then an extended data buffer is not reported. If ExtendedData is not
260 NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.
261 ExtendedData is assumed not have the standard status code header, so this function
262 is responsible for allocating a buffer large enough for the standard header and
263 the extended data passed into this function. The standard header is filled in
264 with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a
265 GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with
266 an instance specified by Instance and a caller ID specified by CallerId. If
267 CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.
269 ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()
270 is called while processing another any other Report Status Code Library function,
271 then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.
273 If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
274 If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
276 @param Type Status code type.
277 @param Value Status code value.
278 @param Instance Status code instance number.
279 @param CallerId Pointer to a GUID that identifies the caller of this
280 function. If this parameter is NULL, then a caller
281 ID of gEfiCallerIdGuid is used.
282 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
283 If this parameter is NULL, then a the status code
284 standard header is filled in with
285 gEfiStatusCodeSpecificDataGuid.
286 @param ExtendedData Pointer to the extended data buffer. This is an
287 optional parameter that may be NULL.
288 @param ExtendedDataSize The size, in bytes, of the extended data buffer.
290 @retval EFI_SUCCESS The status code was reported.
291 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate
292 the extended data section if it was specified.
293 @retval EFI_UNSUPPORTED Report status code is not supported
299 IN EFI_STATUS_CODE_TYPE Type
,
300 IN EFI_STATUS_CODE_VALUE Value
,
302 IN CONST EFI_GUID
*CallerId OPTIONAL
,
303 IN CONST EFI_GUID
*ExtendedDataGuid OPTIONAL
,
304 IN CONST VOID
*ExtendedData OPTIONAL
,
305 IN UINTN ExtendedDataSize
310 Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
312 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED
313 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
315 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
316 PcdReportStatusCodeProperyMask is set.
317 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
318 PcdReportStatusCodeProperyMask is clear.
323 ReportProgressCodeEnabled (
329 Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
331 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED
332 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
334 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
335 PcdReportStatusCodeProperyMask is set.
336 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
337 PcdReportStatusCodeProperyMask is clear.
342 ReportErrorCodeEnabled (
348 Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
350 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED
351 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
353 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
354 PcdReportStatusCodeProperyMask is set.
355 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
356 PcdReportStatusCodeProperyMask is clear.
361 ReportDebugCodeEnabled (
367 Reports a status code with minimal parameters if the status code type is enabled.
369 If the status code type specified by Type is enabled in
370 PcdReportStatusCodeProperyMask, then call ReportStatusCode() passing in Type
373 @param Type Status code type.
374 @param Value Status code value.
376 @retval EFI_SUCCESS The status code was reported.
377 @retval EFI_DEVICE_ERROR There status code could not be reported due to a device error.
378 @retval EFI_UNSUPPORTED Report status code is not supported
381 #define REPORT_STATUS_CODE(Type,Value) \
382 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
383 ReportStatusCode(Type,Value) : \
384 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
385 ReportStatusCode(Type,Value) : \
386 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
387 ReportStatusCode(Type,Value) : \
392 Reports a status code with a Device Path Protocol as the extended data if the
393 status code type is enabled.
395 If the status code type specified by Type is enabled in
396 PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithDevicePath()
397 passing in Type, Value, and DevicePath.
399 @param Type Status code type.
400 @param Value Status code value.
401 @param DevicePath Pointer to the Device Path Protocol to be reported.
403 @retval EFI_SUCCESS The status code was reported with the extended
404 data specified by DevicePath.
405 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
406 extended data section.
407 @retval EFI_UNSUPPORTED Report status code is not supported
410 #define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type,Value,DevicePathParameter) \
411 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
412 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
413 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
414 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
415 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
416 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
421 Reports a status code with an extended data buffer if the status code type
424 If the status code type specified by Type is enabled in
425 PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithExtendedData()
426 passing in Type, Value, ExtendedData, and ExtendedDataSize.
428 @param Type Status code type.
429 @param Value Status code value.
430 @param ExtendedData Pointer to the extended data buffer to be reported.
431 @param ExtendedDataSize The size, in bytes, of the extended data buffer to
434 @retval EFI_SUCCESS The status code was reported with the extended
435 data specified by ExtendedData and ExtendedDataSize.
436 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
437 extended data section.
438 @retval EFI_UNSUPPORTED Report status code is not supported
441 #define REPORT_STATUS_CODE_WITH_EXTENDED_DATA(Type,Value,ExtendedData,ExtendedDataSize) \
442 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
443 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
444 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
445 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
446 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
447 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
451 Reports a status code specifying all parameters if the status code type is enabled.
453 If the status code type specified by Type is enabled in
454 PcdReportStatusCodeProperyMask, then call ReportStatusCodeEx() passing in Type,
455 Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, and ExtendedDataSize.
457 @param Type Status code type.
458 @param Value Status code value.
459 @param Instance Status code instance number.
460 @param CallerId Pointer to a GUID that identifies the caller of this
461 function. If this parameter is NULL, then a caller
462 ID of gEfiCallerIdGuid is used.
463 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
464 If this parameter is NULL, then a the status code
465 standard header is filled in with
466 gEfiStatusCodeSpecificDataGuid.
467 @param ExtendedData Pointer to the extended data buffer. This is an
468 optional parameter that may be NULL.
469 @param ExtendedDataSize The size, in bytes, of the extended data buffer.
471 @retval EFI_SUCCESS The status code was reported.
472 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
473 extended data section if it was specified.
474 @retval EFI_UNSUPPORTED Report status code is not supported
477 #define REPORT_STATUS_CODE_EX(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) \
478 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
479 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
480 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
481 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
482 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
483 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \