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 an implementation dependent GUID.
182 The status code is reported with a zero instance and a caller ID of gEfiCallerIdGuid.
184 ReportStatusCodeWithDevicePath()must actively prevent recursion. If
185 ReportStatusCodeWithDevicePath() is called while processing another any other
186 Report Status Code Library function, then ReportStatusCodeWithDevicePath()
187 must return EFI_DEVICE_ERROR immediately.
189 If DevicePath is NULL, then ASSERT().
191 @param Type Status code type.
192 @param Value Status code value.
193 @param DevicePath Pointer to the Device Path Protocol to be reported.
195 @retval EFI_SUCCESS The status code was reported with the extended
196 data specified by DevicePath.
197 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
198 extended data section.
199 @retval EFI_UNSUPPORTED Report status code is not supported
200 @retval EFI_DEVICE_ERROR A call to a Report Status Code Library function
201 is already in progress.
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 an implementation dependent GUID. 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
244 @retval EFI_DEVICE_ERROR A call to a Report Status Code Library function
245 is already in progress.
250 ReportStatusCodeWithExtendedData (
251 IN EFI_STATUS_CODE_TYPE Type
,
252 IN EFI_STATUS_CODE_VALUE Value
,
253 IN CONST VOID
*ExtendedData
,
254 IN UINTN ExtendedDataSize
259 Reports a status code with full parameters.
261 The function reports a status code. If ExtendedData is NULL and ExtendedDataSize
262 is 0, then an extended data buffer is not reported. If ExtendedData is not
263 NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.
264 ExtendedData is assumed not have the standard status code header, so this function
265 is responsible for allocating a buffer large enough for the standard header and
266 the extended data passed into this function. The standard header is filled in
267 with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a
268 GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with
269 an instance specified by Instance and a caller ID specified by CallerId. If
270 CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.
272 ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()
273 is called while processing another any other Report Status Code Library function,
274 then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.
276 If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
277 If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
279 @param Type Status code type.
280 @param Value Status code value.
281 @param Instance Status code instance number.
282 @param CallerId Pointer to a GUID that identifies the caller of this
283 function. If this parameter is NULL, then a caller
284 ID of gEfiCallerIdGuid is used.
285 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
286 If this parameter is NULL, then a the status code
287 standard header is filled in with an implementation dependent GUID.
288 @param ExtendedData Pointer to the extended data buffer. This is an
289 optional parameter that may be NULL.
290 @param ExtendedDataSize The size, in bytes, of the extended data buffer.
292 @retval EFI_SUCCESS The status code was reported.
293 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate
294 the extended data section if it was specified.
295 @retval EFI_UNSUPPORTED Report status code is not supported.
296 @retval EFI_DEVICE_ERROR A call to a Report Status Code Library function
297 is already in progress.
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
412 @retval EFI_DEVICE_ERROR A call to a Report Status Code Library function
413 is already in progress.
416 #define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type,Value,DevicePathParameter) \
417 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
418 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
419 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
420 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
421 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
422 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
427 Reports a status code with an extended data buffer if the status code type
430 If the status code type specified by Type is enabled in
431 PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithExtendedData()
432 passing in Type, Value, ExtendedData, and ExtendedDataSize.
434 @param Type Status code type.
435 @param Value Status code value.
436 @param ExtendedData Pointer to the extended data buffer to be reported.
437 @param ExtendedDataSize The size, in bytes, of the extended data buffer to
440 @retval EFI_SUCCESS The status code was reported with the extended
441 data specified by ExtendedData and ExtendedDataSize.
442 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
443 extended data section.
444 @retval EFI_UNSUPPORTED Report status code is not supported
445 @retval EFI_DEVICE_ERROR A call to a Report Status Code Library function
446 is already in progress.
449 #define REPORT_STATUS_CODE_WITH_EXTENDED_DATA(Type,Value,ExtendedData,ExtendedDataSize) \
450 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
451 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
452 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
453 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
454 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
455 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
459 Reports a status code specifying all parameters if the status code type is enabled.
461 If the status code type specified by Type is enabled in
462 PcdReportStatusCodeProperyMask, then call ReportStatusCodeEx() passing in Type,
463 Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, and ExtendedDataSize.
465 @param Type Status code type.
466 @param Value Status code value.
467 @param Instance Status code instance number.
468 @param CallerId Pointer to a GUID that identifies the caller of this
469 function. If this parameter is NULL, then a caller
470 ID of gEfiCallerIdGuid is used.
471 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
472 If this parameter is NULL, then a the status code
473 standard header is filled in with an implementation dependent GUID.
474 @param ExtendedData Pointer to the extended data buffer. This is an
475 optional parameter that may be NULL.
476 @param ExtendedDataSize The size, in bytes, of the extended data buffer.
478 @retval EFI_SUCCESS The status code was reported.
479 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
480 extended data section if it was specified.
481 @retval EFI_UNSUPPORTED Report status code is not supported
482 @retval EFI_DEVICE_ERROR A call to a Report Status Code Library function
483 is already in progress.
486 #define REPORT_STATUS_CODE_EX(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) \
487 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
488 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
489 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
490 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
491 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
492 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \