]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/ReportStatusCodeLib.h
Checked in part of MDE library instances following PI and UEFI. It includes:
[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 // Extern for the modules Caller ID GUID
33 //
34 extern EFI_GUID gEfiCallerIdGuid;
35
36 /**
37 Converts a status code to an 8-bit POST code value.
38
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.
44
45 If PostCode is NULL, then ASSERT().
46
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.
50
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.
55
56 **/
57 BOOLEAN
58 EFIAPI
59 CodeTypeToPostCode (
60 IN EFI_STATUS_CODE_TYPE CodeType,
61 IN EFI_STATUS_CODE_VALUE Value,
62 OUT UINT8 *PostCode
63 );
64
65
66 /**
67 Extracts ASSERT() information from a status code structure.
68
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.
79
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().
84
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().
91
92 @retval TRUE The status code specified by CodeType, Value, and Data was
93 converted ASSERT() arguments specified by Filename, Description,
94 and LineNumber.
95 @retval FALSE The status code specified by CodeType, Value, and Data could
96 not be converted to ASSERT() arguments.
97
98 **/
99 BOOLEAN
100 EFIAPI
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
108 );
109
110
111 /**
112 Extracts DEBUG() information from a status code structure.
113
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.
122
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().
127
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
132 debug message.
133
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
137 DEBUG() arguments.
138
139 **/
140 BOOLEAN
141 EFIAPI
142 ReportStatusCodeExtractDebugInfo (
143 IN CONST EFI_STATUS_CODE_DATA *Data,
144 OUT UINT32 *ErrorLevel,
145 OUT VA_LIST *Marker,
146 OUT CHAR8 **Format
147 );
148
149
150 /**
151 Reports a status code.
152
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.
157
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.
161
162 @param Type Status code type.
163 @param Value Status code value.
164
165 @retval EFI_SUCCESS The status code was reported.
166 @retval EFI_DEVICE_ERROR There status code could not be reported due to a
167 device error.
168 @retval EFI_UNSUPPORTED Report status code is not supported
169
170 **/
171 EFI_STATUS
172 EFIAPI
173 ReportStatusCode (
174 IN EFI_STATUS_CODE_TYPE Type,
175 IN EFI_STATUS_CODE_VALUE Value
176 );
177
178
179 /**
180 Reports a status code with a Device Path Protocol as the extended data.
181
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.
188
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.
193
194 If DevicePath is NULL, then ASSERT().
195
196 @param Type Status code type.
197 @param Value Status code value.
198 @param DevicePath Pointer to the Device Path Protocol to be reported.
199
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
205
206 **/
207 EFI_STATUS
208 EFIAPI
209 ReportStatusCodeWithDevicePath (
210 IN EFI_STATUS_CODE_TYPE Type,
211 IN EFI_STATUS_CODE_VALUE Value,
212 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
213 );
214
215
216 /**
217 Reports a status code with an extended data buffer.
218
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.
227
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.
232
233 If ExtendedData is NULL, then ASSERT().
234 If ExtendedDataSize is 0, then ASSERT().
235
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
240 be reported.
241
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
247
248 **/
249 EFI_STATUS
250 EFIAPI
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
256 );
257
258
259 /**
260 Reports a status code with full parameters.
261
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.
272
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.
276
277 If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
278 If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
279
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.
293
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
298
299 **/
300 EFI_STATUS
301 EFIAPI
302 ReportStatusCodeEx (
303 IN EFI_STATUS_CODE_TYPE Type,
304 IN EFI_STATUS_CODE_VALUE Value,
305 IN UINT32 Instance,
306 IN CONST EFI_GUID *CallerId OPTIONAL,
307 IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,
308 IN CONST VOID *ExtendedData OPTIONAL,
309 IN UINTN ExtendedDataSize
310 );
311
312
313 /**
314 Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
315
316 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED
317 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
318
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.
323
324 **/
325 BOOLEAN
326 EFIAPI
327 ReportProgressCodeEnabled (
328 VOID
329 );
330
331
332 /**
333 Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
334
335 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED
336 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
337
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.
342
343 **/
344 BOOLEAN
345 EFIAPI
346 ReportErrorCodeEnabled (
347 VOID
348 );
349
350
351 /**
352 Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
353
354 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED
355 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
356
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.
361
362 **/
363 BOOLEAN
364 EFIAPI
365 ReportDebugCodeEnabled (
366 VOID
367 );
368
369
370 /**
371 Reports a status code with minimal parameters if the status code type is enabled.
372
373 If the status code type specified by Type is enabled in
374 PcdReportStatusCodeProperyMask, then call ReportStatusCode() passing in Type
375 and Value.
376
377 @param Type Status code type.
378 @param Value Status code value.
379
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
383
384 **/
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) : \
392 EFI_UNSUPPORTED
393
394
395 /**
396 Reports a status code with a Device Path Protocol as the extended data if the
397 status code type is enabled.
398
399 If the status code type specified by Type is enabled in
400 PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithDevicePath()
401 passing in Type, Value, and DevicePath.
402
403 @param Type Status code type.
404 @param Value Status code value.
405 @param DevicePath Pointer to the Device Path Protocol to be reported.
406
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
413 **/
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) : \
421 EFI_UNSUPPORTED
422
423
424 /**
425 Reports a status code with an extended data buffer if the status code type
426 is enabled.
427
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.
431
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
436 be reported.
437
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
443
444 **/
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) : \
452 EFI_UNSUPPORTED
453
454 /**
455 Reports a status code specifying all parameters if the status code type is enabled.
456
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.
460
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.
474
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
479
480 **/
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) : \
488 EFI_UNSUPPORTED
489
490 #endif