]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/ReportStatusCodeLib.h
Remove unnecessary header file including for library class in MdePkg.
[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 <Pi/PiMultiPhase.h>
19 #include <Protocol/DevicePath.h>
20
21 //
22 // Declare bits for PcdReportStatusCodePropertyMask
23 //
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
27
28 //
29 // Extended Data structure definitions with EFI_STATUS_CODE_DATA headers removed
30 //
31
32 /**
33 Converts a status code to an 8-bit POST code value.
34
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.
40
41 If PostCode is NULL, then ASSERT().
42
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.
46
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.
51
52 **/
53 BOOLEAN
54 EFIAPI
55 CodeTypeToPostCode (
56 IN EFI_STATUS_CODE_TYPE CodeType,
57 IN EFI_STATUS_CODE_VALUE Value,
58 OUT UINT8 *PostCode
59 );
60
61
62 /**
63 Extracts ASSERT() information from a status code structure.
64
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.
75
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().
80
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().
87
88 @retval TRUE The status code specified by CodeType, Value, and Data was
89 converted ASSERT() arguments specified by Filename, Description,
90 and LineNumber.
91 @retval FALSE The status code specified by CodeType, Value, and Data could
92 not be converted to ASSERT() arguments.
93
94 **/
95 BOOLEAN
96 EFIAPI
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
104 );
105
106
107 /**
108 Extracts DEBUG() information from a status code structure.
109
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.
118
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().
123
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
128 debug message.
129
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
133 DEBUG() arguments.
134
135 **/
136 BOOLEAN
137 EFIAPI
138 ReportStatusCodeExtractDebugInfo (
139 IN CONST EFI_STATUS_CODE_DATA *Data,
140 OUT UINT32 *ErrorLevel,
141 OUT VA_LIST *Marker,
142 OUT CHAR8 **Format
143 );
144
145
146 /**
147 Reports a status code.
148
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.
153
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.
157
158 @param Type Status code type.
159 @param Value Status code value.
160
161 @retval EFI_SUCCESS The status code was reported.
162 @retval EFI_DEVICE_ERROR There status code could not be reported due to a
163 device error.
164 @retval EFI_UNSUPPORTED Report status code is not supported
165
166 **/
167 EFI_STATUS
168 EFIAPI
169 ReportStatusCode (
170 IN EFI_STATUS_CODE_TYPE Type,
171 IN EFI_STATUS_CODE_VALUE Value
172 );
173
174
175 /**
176 Reports a status code with a Device Path Protocol as the extended data.
177
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.
184
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.
189
190 If DevicePath is NULL, then ASSERT().
191
192 @param Type Status code type.
193 @param Value Status code value.
194 @param DevicePath Pointer to the Device Path Protocol to be reported.
195
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
201
202 **/
203 EFI_STATUS
204 EFIAPI
205 ReportStatusCodeWithDevicePath (
206 IN EFI_STATUS_CODE_TYPE Type,
207 IN EFI_STATUS_CODE_VALUE Value,
208 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
209 );
210
211
212 /**
213 Reports a status code with an extended data buffer.
214
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.
223
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.
228
229 If ExtendedData is NULL, then ASSERT().
230 If ExtendedDataSize is 0, then ASSERT().
231
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
236 be reported.
237
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
243
244 **/
245 EFI_STATUS
246 EFIAPI
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
252 );
253
254
255 /**
256 Reports a status code with full parameters.
257
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.
268
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.
272
273 If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
274 If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
275
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.
289
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
294
295 **/
296 EFI_STATUS
297 EFIAPI
298 ReportStatusCodeEx (
299 IN EFI_STATUS_CODE_TYPE Type,
300 IN EFI_STATUS_CODE_VALUE Value,
301 IN UINT32 Instance,
302 IN CONST EFI_GUID *CallerId OPTIONAL,
303 IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,
304 IN CONST VOID *ExtendedData OPTIONAL,
305 IN UINTN ExtendedDataSize
306 );
307
308
309 /**
310 Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
311
312 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED
313 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
314
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.
319
320 **/
321 BOOLEAN
322 EFIAPI
323 ReportProgressCodeEnabled (
324 VOID
325 );
326
327
328 /**
329 Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
330
331 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED
332 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
333
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.
338
339 **/
340 BOOLEAN
341 EFIAPI
342 ReportErrorCodeEnabled (
343 VOID
344 );
345
346
347 /**
348 Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
349
350 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED
351 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
352
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.
357
358 **/
359 BOOLEAN
360 EFIAPI
361 ReportDebugCodeEnabled (
362 VOID
363 );
364
365
366 /**
367 Reports a status code with minimal parameters if the status code type is enabled.
368
369 If the status code type specified by Type is enabled in
370 PcdReportStatusCodeProperyMask, then call ReportStatusCode() passing in Type
371 and Value.
372
373 @param Type Status code type.
374 @param Value Status code value.
375
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
379
380 **/
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) : \
388 EFI_UNSUPPORTED
389
390
391 /**
392 Reports a status code with a Device Path Protocol as the extended data if the
393 status code type is enabled.
394
395 If the status code type specified by Type is enabled in
396 PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithDevicePath()
397 passing in Type, Value, and DevicePath.
398
399 @param Type Status code type.
400 @param Value Status code value.
401 @param DevicePath Pointer to the Device Path Protocol to be reported.
402
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
408
409 **/
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) : \
417 EFI_UNSUPPORTED
418
419
420 /**
421 Reports a status code with an extended data buffer if the status code type
422 is enabled.
423
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.
427
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
432 be reported.
433
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
439
440 **/
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) : \
448 EFI_UNSUPPORTED
449
450 /**
451 Reports a status code specifying all parameters if the status code type is enabled.
452
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.
456
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.
470
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
475
476 **/
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) : \
484 EFI_UNSUPPORTED
485
486 #endif