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