]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/ReportStatusCodeLib.h
Merge branch of PI tree to main trunk
[mirror_edk2.git] / MdePkg / Include / Library / ReportStatusCodeLib.h
1 /** @file
2 Report Status Code Library public .h file
3
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
9
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.
12
13 **/
14
15 #ifndef __REPORT_STATUS_CODE_LIB_H__
16 #define __REPORT_STATUS_CODE_LIB_H__
17
18 #include <Protocol/DevicePath.h>
19
20 //
21 // Declare bits for PcdReportStatusCodePropertyMask
22 //
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
26
27 //
28 // Extended Data structure definitions with EFI_STATUS_CODE_DATA headers removed
29 //
30
31 /**
32 Converts a status code to an 8-bit POST code value.
33
34 Converts the status code specified by CodeType and Value to an 8-bit POST code
35 and returns the 8-bit POST code in PostCode. If CodeType is an
36 EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode
37 are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits
38 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned.
39
40 If PostCode is NULL, then ASSERT().
41
42 @param CodeType The type of status code being converted.
43 @param Value The status code value being converted.
44 @param PostCode A pointer to the 8-bit POST code value to return.
45
46 @retval TRUE The status code specified by CodeType and Value was converted
47 to an 8-bit POST code and returned in PostCode.
48 @retval FALSE The status code specified by CodeType and Value could not be
49 converted to an 8-bit POST code value.
50
51 **/
52 BOOLEAN
53 EFIAPI
54 CodeTypeToPostCode (
55 IN EFI_STATUS_CODE_TYPE CodeType,
56 IN EFI_STATUS_CODE_VALUE Value,
57 OUT UINT8 *PostCode
58 );
59
60
61 /**
62 Extracts ASSERT() information from a status code structure.
63
64 Converts the status code specified by CodeType, Value, and Data to the ASSERT()
65 arguments specified by Filename, Description, and LineNumber. If CodeType is
66 an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
67 Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
68 Filename, Description, and LineNumber from the optional data area of the
69 status code buffer specified by Data. The optional data area of Data contains
70 a Null-terminated ASCII string for the FileName, followed by a Null-terminated
71 ASCII string for the Description, followed by a 32-bit LineNumber. If the
72 ASSERT() information could be extracted from Data, then return TRUE.
73 Otherwise, FALSE is returned.
74
75 If Data is NULL, then ASSERT().
76 If Filename is NULL, then ASSERT().
77 If Description is NULL, then ASSERT().
78 If LineNumber is NULL, then ASSERT().
79
80 @param CodeType The type of status code being converted.
81 @param Value The status code value being converted.
82 @param Data Pointer to status code data buffer.
83 @param Filename Pointer to the source file name that generated the ASSERT().
84 @param Description Pointer to the description of the ASSERT().
85 @param LineNumber Pointer to source line number that generated the ASSERT().
86
87 @retval TRUE The status code specified by CodeType, Value, and Data was
88 converted ASSERT() arguments specified by Filename, Description,
89 and LineNumber.
90 @retval FALSE The status code specified by CodeType, Value, and Data could
91 not be converted to ASSERT() arguments.
92
93 **/
94 BOOLEAN
95 EFIAPI
96 ReportStatusCodeExtractAssertInfo (
97 IN EFI_STATUS_CODE_TYPE CodeType,
98 IN EFI_STATUS_CODE_VALUE Value,
99 IN CONST EFI_STATUS_CODE_DATA *Data,
100 OUT CHAR8 **Filename,
101 OUT CHAR8 **Description,
102 OUT UINT32 *LineNumber
103 );
104
105
106 /**
107 Extracts DEBUG() information from a status code structure.
108
109 Converts the status code specified by Data to the DEBUG() arguments specified
110 by ErrorLevel, Marker, and Format. If type GUID in Data is
111 EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and
112 Format from the optional data area of the status code buffer specified by Data.
113 The optional data area of Data contains a 32-bit ErrorLevel followed by Marker
114 which is 12 UINTN parameters, followed by a Null-terminated ASCII string for
115 the Format. If the DEBUG() information could be extracted from Data, then
116 return TRUE. Otherwise, FALSE is returned.
117
118 If Data is NULL, then ASSERT().
119 If ErrorLevel is NULL, then ASSERT().
120 If Marker is NULL, then ASSERT().
121 If Format is NULL, then ASSERT().
122
123 @param Data Pointer to status code data buffer.
124 @param ErrorLevel Pointer to error level mask for a debug message.
125 @param Marker Pointer to the variable argument list associated with Format.
126 @param Format Pointer to a Null-terminated ASCII format string of a
127 debug message.
128
129 @retval TRUE The status code specified by Data was converted DEBUG() arguments
130 specified by ErrorLevel, Marker, and Format.
131 @retval FALSE The status code specified by Data could not be converted to
132 DEBUG() arguments.
133
134 **/
135 BOOLEAN
136 EFIAPI
137 ReportStatusCodeExtractDebugInfo (
138 IN CONST EFI_STATUS_CODE_DATA *Data,
139 OUT UINT32 *ErrorLevel,
140 OUT VA_LIST *Marker,
141 OUT CHAR8 **Format
142 );
143
144
145 /**
146 Reports a status code.
147
148 Reports the status code specified by the parameters Type and Value. Status
149 code also require an instance, caller ID, and extended data. This function
150 passed in a zero instance, NULL extended data, and a caller ID of
151 gEfiCallerIdGuid, which is the GUID for the module.
152
153 ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode()
154 is called while processing another any other Report Status Code Library function,
155 then ReportStatusCode() must return immediately.
156
157 @param Type Status code type.
158 @param Value Status code value.
159
160 @retval EFI_SUCCESS The status code was reported.
161 @retval EFI_DEVICE_ERROR There status code could not be reported due to a
162 device error.
163 @retval EFI_UNSUPPORTED Report status code is not supported
164
165 **/
166 EFI_STATUS
167 EFIAPI
168 ReportStatusCode (
169 IN EFI_STATUS_CODE_TYPE Type,
170 IN EFI_STATUS_CODE_VALUE Value
171 );
172
173
174 /**
175 Reports a status code with a Device Path Protocol as the extended data.
176
177 Allocates and fills in the extended data section of a status code with the
178 Device Path Protocol specified by DevicePath. This function is responsible
179 for allocating a buffer large enough for the standard header and the device
180 path. The standard header is filled in with a GUID of
181 gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero
182 instance and a caller ID of gEfiCallerIdGuid.
183
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.
188
189 If DevicePath is NULL, then ASSERT().
190
191 @param Type Status code type.
192 @param Value Status code value.
193 @param DevicePath Pointer to the Device Path Protocol to be reported.
194
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
201 **/
202 EFI_STATUS
203 EFIAPI
204 ReportStatusCodeWithDevicePath (
205 IN EFI_STATUS_CODE_TYPE Type,
206 IN EFI_STATUS_CODE_VALUE Value,
207 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
208 );
209
210
211 /**
212 Reports a status code with an extended data buffer.
213
214 Allocates and fills in the extended data section of a status code with the
215 extended data specified by ExtendedData and ExtendedDataSize. ExtendedData
216 is assumed to be one of the data structures specified in Related Definitions.
217 These data structure do not have the standard header, so this function is
218 responsible for allocating a buffer large enough for the standard header and
219 the extended data passed into this function. The standard header is filled
220 in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported
221 with a zero instance and a caller ID of gEfiCallerIdGuid.
222
223 ReportStatusCodeWithExtendedData()must actively prevent recursion. If
224 ReportStatusCodeWithExtendedData() is called while processing another any other
225 Report Status Code Library function, then ReportStatusCodeWithExtendedData()
226 must return EFI_DEVICE_ERROR immediately.
227
228 If ExtendedData is NULL, then ASSERT().
229 If ExtendedDataSize is 0, then ASSERT().
230
231 @param Type Status code type.
232 @param Value Status code value.
233 @param ExtendedData Pointer to the extended data buffer to be reported.
234 @param ExtendedDataSize The size, in bytes, of the extended data buffer to
235 be reported.
236
237 @retval EFI_SUCCESS The status code was reported with the extended
238 data specified by ExtendedData and ExtendedDataSize.
239 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
240 extended data section.
241 @retval EFI_UNSUPPORTED Report status code is not supported
242
243 **/
244 EFI_STATUS
245 EFIAPI
246 ReportStatusCodeWithExtendedData (
247 IN EFI_STATUS_CODE_TYPE Type,
248 IN EFI_STATUS_CODE_VALUE Value,
249 IN CONST VOID *ExtendedData,
250 IN UINTN ExtendedDataSize
251 );
252
253
254 /**
255 Reports a status code with full parameters.
256
257 The function reports a status code. If ExtendedData is NULL and ExtendedDataSize
258 is 0, then an extended data buffer is not reported. If ExtendedData is not
259 NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.
260 ExtendedData is assumed not have the standard status code header, so this function
261 is responsible for allocating a buffer large enough for the standard header and
262 the extended data passed into this function. The standard header is filled in
263 with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a
264 GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with
265 an instance specified by Instance and a caller ID specified by CallerId. If
266 CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.
267
268 ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()
269 is called while processing another any other Report Status Code Library function,
270 then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.
271
272 If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
273 If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
274
275 @param Type Status code type.
276 @param Value Status code value.
277 @param Instance Status code instance number.
278 @param CallerId Pointer to a GUID that identifies the caller of this
279 function. If this parameter is NULL, then a caller
280 ID of gEfiCallerIdGuid is used.
281 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
282 If this parameter is NULL, then a the status code
283 standard header is filled in with
284 gEfiStatusCodeSpecificDataGuid.
285 @param ExtendedData Pointer to the extended data buffer. This is an
286 optional parameter that may be NULL.
287 @param ExtendedDataSize The size, in bytes, of the extended data buffer.
288
289 @retval EFI_SUCCESS The status code was reported.
290 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate
291 the extended data section if it was specified.
292 @retval EFI_UNSUPPORTED Report status code is not supported
293
294 **/
295 EFI_STATUS
296 EFIAPI
297 ReportStatusCodeEx (
298 IN EFI_STATUS_CODE_TYPE Type,
299 IN EFI_STATUS_CODE_VALUE Value,
300 IN UINT32 Instance,
301 IN CONST EFI_GUID *CallerId OPTIONAL,
302 IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,
303 IN CONST VOID *ExtendedData OPTIONAL,
304 IN UINTN ExtendedDataSize
305 );
306
307
308 /**
309 Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
310
311 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED
312 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
313
314 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
315 PcdReportStatusCodeProperyMask is set.
316 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
317 PcdReportStatusCodeProperyMask is clear.
318
319 **/
320 BOOLEAN
321 EFIAPI
322 ReportProgressCodeEnabled (
323 VOID
324 );
325
326
327 /**
328 Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
329
330 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED
331 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
332
333 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
334 PcdReportStatusCodeProperyMask is set.
335 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
336 PcdReportStatusCodeProperyMask is clear.
337
338 **/
339 BOOLEAN
340 EFIAPI
341 ReportErrorCodeEnabled (
342 VOID
343 );
344
345
346 /**
347 Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
348
349 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED
350 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
351
352 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
353 PcdReportStatusCodeProperyMask is set.
354 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
355 PcdReportStatusCodeProperyMask is clear.
356
357 **/
358 BOOLEAN
359 EFIAPI
360 ReportDebugCodeEnabled (
361 VOID
362 );
363
364
365 /**
366 Reports a status code with minimal parameters if the status code type is enabled.
367
368 If the status code type specified by Type is enabled in
369 PcdReportStatusCodeProperyMask, then call ReportStatusCode() passing in Type
370 and Value.
371
372 @param Type Status code type.
373 @param Value Status code value.
374
375 @retval EFI_SUCCESS The status code was reported.
376 @retval EFI_DEVICE_ERROR There status code could not be reported due to a device error.
377 @retval EFI_UNSUPPORTED Report status code is not supported
378
379 **/
380 #define REPORT_STATUS_CODE(Type,Value) \
381 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
382 ReportStatusCode(Type,Value) : \
383 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
384 ReportStatusCode(Type,Value) : \
385 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
386 ReportStatusCode(Type,Value) : \
387 EFI_UNSUPPORTED
388
389
390 /**
391 Reports a status code with a Device Path Protocol as the extended data if the
392 status code type is enabled.
393
394 If the status code type specified by Type is enabled in
395 PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithDevicePath()
396 passing in Type, Value, and DevicePath.
397
398 @param Type Status code type.
399 @param Value Status code value.
400 @param DevicePath Pointer to the Device Path Protocol to be reported.
401
402 @retval EFI_SUCCESS The status code was reported with the extended
403 data specified by DevicePath.
404 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
405 extended data section.
406 @retval EFI_UNSUPPORTED Report status code is not supported
407
408 **/
409 #define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type,Value,DevicePathParameter) \
410 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
411 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
412 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
413 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
414 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
415 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
416 EFI_UNSUPPORTED
417
418
419 /**
420 Reports a status code with an extended data buffer if the status code type
421 is enabled.
422
423 If the status code type specified by Type is enabled in
424 PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithExtendedData()
425 passing in Type, Value, ExtendedData, and ExtendedDataSize.
426
427 @param Type Status code type.
428 @param Value Status code value.
429 @param ExtendedData Pointer to the extended data buffer to be reported.
430 @param ExtendedDataSize The size, in bytes, of the extended data buffer to
431 be reported.
432
433 @retval EFI_SUCCESS The status code was reported with the extended
434 data specified by ExtendedData and ExtendedDataSize.
435 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
436 extended data section.
437 @retval EFI_UNSUPPORTED Report status code is not supported
438
439 **/
440 #define REPORT_STATUS_CODE_WITH_EXTENDED_DATA(Type,Value,ExtendedData,ExtendedDataSize) \
441 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
442 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
443 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
444 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
445 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
446 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
447 EFI_UNSUPPORTED
448
449 /**
450 Reports a status code specifying all parameters if the status code type is enabled.
451
452 If the status code type specified by Type is enabled in
453 PcdReportStatusCodeProperyMask, then call ReportStatusCodeEx() passing in Type,
454 Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, and ExtendedDataSize.
455
456 @param Type Status code type.
457 @param Value Status code value.
458 @param Instance Status code instance number.
459 @param CallerId Pointer to a GUID that identifies the caller of this
460 function. If this parameter is NULL, then a caller
461 ID of gEfiCallerIdGuid is used.
462 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
463 If this parameter is NULL, then a the status code
464 standard header is filled in with
465 gEfiStatusCodeSpecificDataGuid.
466 @param ExtendedData Pointer to the extended data buffer. This is an
467 optional parameter that may be NULL.
468 @param ExtendedDataSize The size, in bytes, of the extended data buffer.
469
470 @retval EFI_SUCCESS The status code was reported.
471 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
472 extended data section if it was specified.
473 @retval EFI_UNSUPPORTED Report status code is not supported
474
475 **/
476 #define REPORT_STATUS_CODE_EX(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) \
477 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
478 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
479 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
480 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
481 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
482 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
483 EFI_UNSUPPORTED
484
485 #endif