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