]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/ReportStatusCodeLib.h
Code have been checked with spec
[mirror_edk2.git] / MdePkg / Include / Library / ReportStatusCodeLib.h
1 /** @file
2 Provides services to log status code records.
3
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
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 @retval EFI_DEVICE_ERROR A call to a Report Status Code Library function
202 is already in progress.
203
204 **/
205 EFI_STATUS
206 EFIAPI
207 ReportStatusCodeWithDevicePath (
208 IN EFI_STATUS_CODE_TYPE Type,
209 IN EFI_STATUS_CODE_VALUE Value,
210 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
211 );
212
213
214 /**
215 Reports a status code with an extended data buffer.
216
217 Allocates and fills in the extended data section of a status code with the
218 extended data specified by ExtendedData and ExtendedDataSize. ExtendedData
219 is assumed to be one of the data structures specified in Related Definitions.
220 These data structure do not have the standard header, so this function is
221 responsible for allocating a buffer large enough for the standard header and
222 the extended data passed into this function. The standard header is filled
223 in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported
224 with a zero instance and a caller ID of gEfiCallerIdGuid.
225
226 ReportStatusCodeWithExtendedData()must actively prevent recursion. If
227 ReportStatusCodeWithExtendedData() is called while processing another any other
228 Report Status Code Library function, then ReportStatusCodeWithExtendedData()
229 must return EFI_DEVICE_ERROR immediately.
230
231 If ExtendedData is NULL, then ASSERT().
232 If ExtendedDataSize is 0, then ASSERT().
233
234 @param Type Status code type.
235 @param Value Status code value.
236 @param ExtendedData Pointer to the extended data buffer to be reported.
237 @param ExtendedDataSize The size, in bytes, of the extended data buffer to
238 be reported.
239
240 @retval EFI_SUCCESS The status code was reported with the extended
241 data specified by ExtendedData and ExtendedDataSize.
242 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
243 extended data section.
244 @retval EFI_UNSUPPORTED Report status code is not supported
245 @retval EFI_DEVICE_ERROR A call to a Report Status Code Library function
246 is already in progress.
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 @retval EFI_DEVICE_ERROR A call to a Report Status Code Library function
299 is already in progress.
300
301 **/
302 EFI_STATUS
303 EFIAPI
304 ReportStatusCodeEx (
305 IN EFI_STATUS_CODE_TYPE Type,
306 IN EFI_STATUS_CODE_VALUE Value,
307 IN UINT32 Instance,
308 IN CONST EFI_GUID *CallerId OPTIONAL,
309 IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,
310 IN CONST VOID *ExtendedData OPTIONAL,
311 IN UINTN ExtendedDataSize
312 );
313
314
315 /**
316 Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
317
318 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED
319 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
320
321 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
322 PcdReportStatusCodeProperyMask is set.
323 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
324 PcdReportStatusCodeProperyMask is clear.
325
326 **/
327 BOOLEAN
328 EFIAPI
329 ReportProgressCodeEnabled (
330 VOID
331 );
332
333
334 /**
335 Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
336
337 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED
338 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
339
340 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
341 PcdReportStatusCodeProperyMask is set.
342 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
343 PcdReportStatusCodeProperyMask is clear.
344
345 **/
346 BOOLEAN
347 EFIAPI
348 ReportErrorCodeEnabled (
349 VOID
350 );
351
352
353 /**
354 Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
355
356 This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED
357 bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
358
359 @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
360 PcdReportStatusCodeProperyMask is set.
361 @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
362 PcdReportStatusCodeProperyMask is clear.
363
364 **/
365 BOOLEAN
366 EFIAPI
367 ReportDebugCodeEnabled (
368 VOID
369 );
370
371
372 /**
373 Reports a status code with minimal parameters if the status code type is enabled.
374
375 If the status code type specified by Type is enabled in
376 PcdReportStatusCodeProperyMask, then call ReportStatusCode() passing in Type
377 and Value.
378
379 @param Type Status code type.
380 @param Value Status code value.
381
382 @retval EFI_SUCCESS The status code was reported.
383 @retval EFI_DEVICE_ERROR There status code could not be reported due to a device error.
384 @retval EFI_UNSUPPORTED Report status code is not supported
385
386 **/
387 #define REPORT_STATUS_CODE(Type,Value) \
388 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
389 ReportStatusCode(Type,Value) : \
390 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
391 ReportStatusCode(Type,Value) : \
392 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
393 ReportStatusCode(Type,Value) : \
394 EFI_UNSUPPORTED
395
396
397 /**
398 Reports a status code with a Device Path Protocol as the extended data if the
399 status code type is enabled.
400
401 If the status code type specified by Type is enabled in
402 PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithDevicePath()
403 passing in Type, Value, and DevicePath.
404
405 @param Type Status code type.
406 @param Value Status code value.
407 @param DevicePath Pointer to the Device Path Protocol to be reported.
408
409 @retval EFI_SUCCESS The status code was reported with the extended
410 data specified by DevicePath.
411 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
412 extended data section.
413 @retval EFI_UNSUPPORTED Report status code is not supported
414 @retval EFI_DEVICE_ERROR A call to a Report Status Code Library function
415 is already in progress.
416
417 **/
418 #define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type,Value,DevicePathParameter) \
419 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
420 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
421 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
422 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
423 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
424 ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
425 EFI_UNSUPPORTED
426
427
428 /**
429 Reports a status code with an extended data buffer if the status code type
430 is enabled.
431
432 If the status code type specified by Type is enabled in
433 PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithExtendedData()
434 passing in Type, Value, ExtendedData, and ExtendedDataSize.
435
436 @param Type Status code type.
437 @param Value Status code value.
438 @param ExtendedData Pointer to the extended data buffer to be reported.
439 @param ExtendedDataSize The size, in bytes, of the extended data buffer to
440 be reported.
441
442 @retval EFI_SUCCESS The status code was reported with the extended
443 data specified by ExtendedData and ExtendedDataSize.
444 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
445 extended data section.
446 @retval EFI_UNSUPPORTED Report status code is not supported
447 @retval EFI_DEVICE_ERROR A call to a Report Status Code Library function
448 is already in progress.
449
450 **/
451 #define REPORT_STATUS_CODE_WITH_EXTENDED_DATA(Type,Value,ExtendedData,ExtendedDataSize) \
452 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
453 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
454 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
455 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
456 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
457 ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
458 EFI_UNSUPPORTED
459
460 /**
461 Reports a status code specifying all parameters if the status code type is enabled.
462
463 If the status code type specified by Type is enabled in
464 PcdReportStatusCodeProperyMask, then call ReportStatusCodeEx() passing in Type,
465 Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, and ExtendedDataSize.
466
467 @param Type Status code type.
468 @param Value Status code value.
469 @param Instance Status code instance number.
470 @param CallerId Pointer to a GUID that identifies the caller of this
471 function. If this parameter is NULL, then a caller
472 ID of gEfiCallerIdGuid is used.
473 @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
474 If this parameter is NULL, then a the status code
475 standard header is filled in with
476 gEfiStatusCodeSpecificDataGuid.
477 @param ExtendedData Pointer to the extended data buffer. This is an
478 optional parameter that may be NULL.
479 @param ExtendedDataSize The size, in bytes, of the extended data buffer.
480
481 @retval EFI_SUCCESS The status code was reported.
482 @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
483 extended data section if it was specified.
484 @retval EFI_UNSUPPORTED Report status code is not supported
485 @retval EFI_DEVICE_ERROR A call to a Report Status Code Library function
486 is already in progress.
487
488 **/
489 #define REPORT_STATUS_CODE_EX(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) \
490 (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
491 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
492 (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
493 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
494 (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
495 ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
496 EFI_UNSUPPORTED
497
498 #endif