]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | Report Status Code Library template for Base modules.\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation<BR>\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | /**\r | |
16 | Converts a status code to an 8-bit POST code value.\r | |
17 | \r | |
18 | Converts the status code specified by CodeType and Value to an 8-bit POST code \r | |
19 | and returns the 8-bit POST code in PostCode. If CodeType is an \r | |
20 | EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode \r | |
21 | are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits \r | |
22 | 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned. \r | |
23 | \r | |
24 | If PostCode is NULL, then ASSERT().\r | |
25 | \r | |
26 | @param CodeType The type of status code being converted.\r | |
27 | @param Value The status code value being converted.\r | |
28 | @param PostCode A pointer to the 8-bit POST code value to return. \r | |
29 | \r | |
30 | @retval TRUE The status code specified by CodeType and Value was converted \r | |
31 | to an 8-bit POST code and returned in PostCode.\r | |
32 | @retval FALSE The status code specified by CodeType and Value could not be \r | |
33 | converted to an 8-bit POST code value.\r | |
34 | \r | |
35 | **/\r | |
36 | BOOLEAN\r | |
37 | EFIAPI\r | |
38 | CodeTypeToPostCode (\r | |
39 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
40 | IN EFI_STATUS_CODE_VALUE Value,\r | |
41 | OUT UINT8 *PostCode\r | |
42 | )\r | |
43 | {\r | |
44 | //\r | |
45 | // If PostCode is NULL, then ASSERT()\r | |
46 | //\r | |
47 | ASSERT (PostCode != NULL);\r | |
48 | \r | |
49 | //\r | |
50 | // Convert Value to an 8 bit post code\r | |
51 | //\r | |
52 | if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r | |
53 | ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) {\r | |
54 | *PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5);\r | |
55 | *PostCode |= (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f);\r | |
56 | return TRUE;\r | |
57 | }\r | |
58 | return FALSE;\r | |
59 | }\r | |
60 | \r | |
61 | \r | |
62 | /**\r | |
63 | Extracts ASSERT() information from a status code structure.\r | |
64 | \r | |
65 | Converts the status code specified by CodeType, Value, and Data to the ASSERT()\r | |
66 | arguments specified by Filename, Description, and LineNumber. If CodeType is \r | |
67 | an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and \r | |
68 | Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract \r | |
69 | Filename, Description, and LineNumber from the optional data area of the \r | |
70 | status code buffer specified by Data. The optional data area of Data contains \r | |
71 | a Null-terminated ASCII string for the FileName, followed by a Null-terminated \r | |
72 | ASCII string for the Description, followed by a 32-bit LineNumber. If the \r | |
73 | ASSERT() information could be extracted from Data, then return TRUE. \r | |
74 | Otherwise, FALSE is returned. \r | |
75 | \r | |
76 | If Data is NULL, then ASSERT().\r | |
77 | If Filename is NULL, then ASSERT().\r | |
78 | If Description is NULL, then ASSERT().\r | |
79 | If LineNumber is NULL, then ASSERT().\r | |
80 | \r | |
81 | @param CodeType The type of status code being converted.\r | |
82 | @param Value The status code value being converted.\r | |
83 | @param Data Pointer to status code data buffer. \r | |
84 | @param Filename Pointer to the source file name that generated the ASSERT().\r | |
85 | @param Description Pointer to the description of the ASSERT().\r | |
86 | @param LineNumber Pointer to source line number that generated the ASSERT().\r | |
87 | \r | |
88 | @retval TRUE The status code specified by CodeType, Value, and Data was \r | |
89 | converted ASSERT() arguments specified by Filename, Description, \r | |
90 | and LineNumber.\r | |
91 | @retval FALSE The status code specified by CodeType, Value, and Data could \r | |
92 | not be converted to ASSERT() arguments.\r | |
93 | \r | |
94 | **/\r | |
95 | BOOLEAN\r | |
96 | EFIAPI\r | |
97 | ReportStatusCodeExtractAssertInfo (\r | |
8960cdeb | 98 | IN EFI_STATUS_CODE_TYPE CodeType,\r |
99 | IN EFI_STATUS_CODE_VALUE Value, \r | |
100 | IN CONST EFI_STATUS_CODE_DATA *Data, \r | |
101 | OUT CHAR8 **Filename,\r | |
102 | OUT CHAR8 **Description,\r | |
103 | OUT UINT32 *LineNumber\r | |
878ddf1f | 104 | )\r |
105 | {\r | |
106 | EFI_DEBUG_ASSERT_DATA *AssertData;\r | |
107 | \r | |
108 | ASSERT (Data != NULL);\r | |
109 | ASSERT (Filename != NULL);\r | |
110 | ASSERT (Description != NULL);\r | |
111 | ASSERT (LineNumber != NULL);\r | |
112 | \r | |
113 | if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) && \r | |
114 | ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&\r | |
115 | ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {\r | |
116 | AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);\r | |
117 | *Filename = (CHAR8 *)(AssertData + 1);\r | |
118 | *Description = *Filename + AsciiStrLen (*Filename) + 1;\r | |
119 | *LineNumber = AssertData->LineNumber;\r | |
120 | return TRUE;\r | |
121 | }\r | |
122 | return FALSE;\r | |
123 | }\r | |
124 | \r | |
125 | \r | |
126 | /**\r | |
127 | Extracts DEBUG() information from a status code structure.\r | |
128 | \r | |
129 | Converts the status code specified by Data to the DEBUG() arguments specified \r | |
130 | by ErrorLevel, Marker, and Format. If type GUID in Data is \r | |
131 | EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and \r | |
132 | Format from the optional data area of the status code buffer specified by Data. \r | |
133 | The optional data area of Data contains a 32-bit ErrorLevel followed by Marker \r | |
134 | which is 12 UINTN parameters, followed by a Null-terminated ASCII string for \r | |
135 | the Format. If the DEBUG() information could be extracted from Data, then \r | |
136 | return TRUE. Otherwise, FALSE is returned.\r | |
137 | \r | |
138 | If Data is NULL, then ASSERT().\r | |
139 | If ErrorLevel is NULL, then ASSERT().\r | |
140 | If Marker is NULL, then ASSERT().\r | |
141 | If Format is NULL, then ASSERT().\r | |
142 | \r | |
143 | @param Data Pointer to status code data buffer. \r | |
144 | @param ErrorLevel Pointer to error level mask for a debug message.\r | |
145 | @param Marker Pointer to the variable argument list associated with Format.\r | |
146 | @param Format Pointer to a Null-terminated ASCII format string of a \r | |
147 | debug message.\r | |
148 | \r | |
149 | @retval TRUE The status code specified by Data was converted DEBUG() arguments \r | |
150 | specified by ErrorLevel, Marker, and Format.\r | |
151 | @retval FALSE The status code specified by Data could not be converted to \r | |
152 | DEBUG() arguments.\r | |
153 | \r | |
154 | **/\r | |
155 | BOOLEAN\r | |
156 | EFIAPI\r | |
157 | ReportStatusCodeExtractDebugInfo (\r | |
8960cdeb | 158 | IN CONST EFI_STATUS_CODE_DATA *Data, \r |
159 | OUT UINT32 *ErrorLevel,\r | |
160 | OUT VA_LIST *Marker,\r | |
161 | OUT CHAR8 **Format\r | |
878ddf1f | 162 | )\r |
163 | {\r | |
164 | EFI_DEBUG_INFO *DebugInfo;\r | |
165 | \r | |
166 | ASSERT (Data != NULL);\r | |
167 | ASSERT (ErrorLevel != NULL);\r | |
168 | ASSERT (Marker != NULL);\r | |
169 | ASSERT (Format != NULL);\r | |
170 | \r | |
171 | //\r | |
172 | // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE\r | |
173 | //\r | |
174 | if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {\r | |
175 | return FALSE;\r | |
176 | }\r | |
177 | \r | |
178 | //\r | |
179 | // Retrieve the debug information from the status code record\r | |
180 | //\r | |
181 | DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);\r | |
182 | \r | |
183 | *ErrorLevel = DebugInfo->ErrorLevel;\r | |
184 | \r | |
185 | //\r | |
186 | // The first 12 * UINTN bytes of the string are really an \r | |
187 | // argument stack to support varargs on the Format string.\r | |
188 | //\r | |
189 | *Marker = (VA_LIST) (DebugInfo + 1);\r | |
190 | *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);\r | |
191 | \r | |
192 | return TRUE;\r | |
193 | }\r | |
194 | \r | |
195 | \r | |
196 | /**\r | |
197 | Reports a status code.\r | |
198 | \r | |
199 | Reports the status code specified by the parameters Type and Value. Status \r | |
200 | code also require an instance, caller ID, and extended data. This function \r | |
201 | passed in a zero instance, NULL extended data, and a caller ID of \r | |
202 | gEfiCallerIdGuid, which is the GUID for the module. \r | |
203 | \r | |
204 | ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode() \r | |
205 | is called while processing another any other Report Status Code Library function,\r | |
206 | then ReportStatusCode() must return immediately.\r | |
207 | \r | |
208 | @param Type Status code type. \r | |
209 | @param Value Status code value.\r | |
210 | \r | |
211 | @retval EFI_SUCCESS The status code was reported.\r | |
212 | @retval EFI_DEVICE_ERROR There status code could not be reported due to a \r | |
213 | device error.\r | |
214 | @retval EFI_UNSUPPORTED Report status code is not supported\r | |
215 | \r | |
216 | **/\r | |
217 | EFI_STATUS\r | |
218 | EFIAPI\r | |
219 | ReportStatusCode (\r | |
220 | IN EFI_STATUS_CODE_TYPE Type,\r | |
221 | IN EFI_STATUS_CODE_VALUE Value\r | |
222 | )\r | |
223 | {\r | |
224 | return EFI_UNSUPPORTED;\r | |
225 | }\r | |
226 | \r | |
227 | \r | |
228 | /**\r | |
229 | Reports a status code with a Device Path Protocol as the extended data.\r | |
230 | \r | |
231 | Allocates and fills in the extended data section of a status code with the \r | |
232 | Device Path Protocol specified by DevicePath. This function is responsible \r | |
233 | for allocating a buffer large enough for the standard header and the device \r | |
234 | path. The standard header is filled in with a GUID of \r | |
235 | gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero \r | |
236 | instance and a caller ID of gEfiCallerIdGuid.\r | |
237 | \r | |
238 | ReportStatusCodeWithDevicePath()must actively prevent recursion. If \r | |
239 | ReportStatusCodeWithDevicePath() is called while processing another any other \r | |
240 | Report Status Code Library function, then ReportStatusCodeWithDevicePath() \r | |
241 | must return EFI_DEVICE_ERROR immediately.\r | |
242 | \r | |
243 | If DevicePath is NULL, then ASSERT().\r | |
244 | \r | |
245 | @param Type Status code type. \r | |
246 | @param Value Status code value.\r | |
247 | @param DevicePath Pointer to the Device Path Protocol to be reported.\r | |
248 | \r | |
249 | @retval EFI_SUCCESS The status code was reported with the extended \r | |
250 | data specified by DevicePath.\r | |
251 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the \r | |
252 | extended data section.\r | |
253 | @retval EFI_UNSUPPORTED Report status code is not supported\r | |
254 | \r | |
255 | **/\r | |
256 | EFI_STATUS\r | |
257 | EFIAPI\r | |
258 | ReportStatusCodeWithDevicePath (\r | |
8960cdeb | 259 | IN EFI_STATUS_CODE_TYPE Type,\r |
260 | IN EFI_STATUS_CODE_VALUE Value,\r | |
261 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
878ddf1f | 262 | )\r |
263 | {\r | |
264 | ASSERT (DevicePath != NULL);\r | |
265 | return EFI_UNSUPPORTED;\r | |
266 | }\r | |
267 | \r | |
268 | \r | |
269 | /**\r | |
270 | Reports a status code with an extended data buffer.\r | |
271 | \r | |
272 | Allocates and fills in the extended data section of a status code with the \r | |
273 | extended data specified by ExtendedData and ExtendedDataSize. ExtendedData \r | |
274 | is assumed to be one of the data structures specified in Related Definitions. \r | |
275 | These data structure do not have the standard header, so this function is \r | |
276 | responsible for allocating a buffer large enough for the standard header and \r | |
277 | the extended data passed into this function. The standard header is filled \r | |
278 | in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported \r | |
279 | with a zero instance and a caller ID of gEfiCallerIdGuid.\r | |
280 | \r | |
281 | ReportStatusCodeWithExtendedData()must actively prevent recursion. If \r | |
282 | ReportStatusCodeWithExtendedData() is called while processing another any other \r | |
283 | Report Status Code Library function, then ReportStatusCodeWithExtendedData() \r | |
284 | must return EFI_DEVICE_ERROR immediately.\r | |
285 | \r | |
286 | If ExtendedData is NULL, then ASSERT().\r | |
287 | If ExtendedDataSize is 0, then ASSERT().\r | |
288 | \r | |
289 | @param Type Status code type. \r | |
290 | @param Value Status code value.\r | |
291 | @param ExtendedData Pointer to the extended data buffer to be reported.\r | |
292 | @param ExtendedDataSize The size, in bytes, of the extended data buffer to \r | |
293 | be reported.\r | |
294 | \r | |
295 | @retval EFI_SUCCESS The status code was reported with the extended \r | |
296 | data specified by ExtendedData and ExtendedDataSize.\r | |
297 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the \r | |
298 | extended data section.\r | |
299 | @retval EFI_UNSUPPORTED Report status code is not supported\r | |
300 | \r | |
301 | **/\r | |
302 | EFI_STATUS\r | |
303 | EFIAPI\r | |
304 | ReportStatusCodeWithExtendedData (\r | |
305 | IN EFI_STATUS_CODE_TYPE Type,\r | |
306 | IN EFI_STATUS_CODE_VALUE Value,\r | |
8960cdeb | 307 | IN CONST VOID *ExtendedData,\r |
878ddf1f | 308 | IN UINTN ExtendedDataSize\r |
309 | )\r | |
310 | {\r | |
311 | ASSERT (ExtendedData != NULL);\r | |
312 | ASSERT (ExtendedDataSize != 0);\r | |
313 | return EFI_UNSUPPORTED;\r | |
314 | }\r | |
315 | \r | |
316 | \r | |
317 | /**\r | |
318 | Reports a status code with full parameters.\r | |
319 | \r | |
320 | The function reports a status code. If ExtendedData is NULL and ExtendedDataSize \r | |
321 | is 0, then an extended data buffer is not reported. If ExtendedData is not \r | |
322 | NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated. \r | |
323 | ExtendedData is assumed not have the standard status code header, so this function \r | |
324 | is responsible for allocating a buffer large enough for the standard header and \r | |
325 | the extended data passed into this function. The standard header is filled in \r | |
326 | with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a \r | |
327 | GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with \r | |
328 | an instance specified by Instance and a caller ID specified by CallerId. If \r | |
329 | CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r | |
330 | \r | |
331 | ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx() \r | |
332 | is called while processing another any other Report Status Code Library function, \r | |
333 | then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r | |
334 | \r | |
335 | If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r | |
336 | If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r | |
337 | \r | |
338 | @param Type Status code type. \r | |
339 | @param Value Status code value.\r | |
340 | @param Instance Status code instance number.\r | |
341 | @param CallerId Pointer to a GUID that identifies the caller of this \r | |
342 | function. If this parameter is NULL, then a caller \r | |
343 | ID of gEfiCallerIdGuid is used.\r | |
344 | @param ExtendedDataGuid Pointer to the GUID for the extended data buffer. \r | |
345 | If this parameter is NULL, then a the status code \r | |
346 | standard header is filled in with \r | |
347 | gEfiStatusCodeSpecificDataGuid.\r | |
348 | @param ExtendedData Pointer to the extended data buffer. This is an \r | |
349 | optional parameter that may be NULL.\r | |
350 | @param ExtendedDataSize The size, in bytes, of the extended data buffer.\r | |
351 | \r | |
352 | @retval EFI_SUCCESS The status code was reported.\r | |
353 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate \r | |
354 | the extended data section if it was specified.\r | |
355 | @retval EFI_UNSUPPORTED Report status code is not supported\r | |
356 | \r | |
357 | **/\r | |
358 | EFI_STATUS\r | |
359 | EFIAPI\r | |
360 | ReportStatusCodeEx (\r | |
361 | IN EFI_STATUS_CODE_TYPE Type,\r | |
362 | IN EFI_STATUS_CODE_VALUE Value,\r | |
363 | IN UINT32 Instance,\r | |
8960cdeb | 364 | IN CONST EFI_GUID *CallerId OPTIONAL,\r |
365 | IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,\r | |
366 | IN CONST VOID *ExtendedData OPTIONAL,\r | |
878ddf1f | 367 | IN UINTN ExtendedDataSize\r |
368 | )\r | |
369 | {\r | |
370 | ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r | |
371 | ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r | |
372 | return EFI_UNSUPPORTED;\r | |
373 | }\r | |
374 | \r | |
375 | \r | |
376 | /**\r | |
377 | Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled\r | |
378 | \r | |
379 | This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED \r | |
380 | bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.\r | |
381 | \r | |
382 | @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of \r | |
383 | PcdReportStatusCodeProperyMask is set.\r | |
384 | @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of \r | |
385 | PcdReportStatusCodeProperyMask is clear.\r | |
386 | \r | |
387 | **/\r | |
388 | BOOLEAN\r | |
389 | EFIAPI\r | |
390 | ReportProgressCodeEnabled (\r | |
391 | VOID\r | |
392 | )\r | |
393 | {\r | |
394 | return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);\r | |
395 | }\r | |
396 | \r | |
397 | \r | |
398 | /**\r | |
399 | Returns TRUE if status codes of type EFI_ERROR_CODE are enabled\r | |
400 | \r | |
401 | This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED \r | |
402 | bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.\r | |
403 | \r | |
404 | @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of \r | |
405 | PcdReportStatusCodeProperyMask is set.\r | |
406 | @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of \r | |
407 | PcdReportStatusCodeProperyMask is clear.\r | |
408 | \r | |
409 | **/\r | |
410 | BOOLEAN\r | |
411 | EFIAPI\r | |
412 | ReportErrorCodeEnabled (\r | |
413 | VOID\r | |
414 | )\r | |
415 | {\r | |
416 | return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);\r | |
417 | }\r | |
418 | \r | |
419 | \r | |
420 | /**\r | |
421 | Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled\r | |
422 | \r | |
423 | This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED \r | |
424 | bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.\r | |
425 | \r | |
426 | @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of \r | |
427 | PcdReportStatusCodeProperyMask is set.\r | |
428 | @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of \r | |
429 | PcdReportStatusCodeProperyMask is clear.\r | |
430 | \r | |
431 | **/\r | |
432 | BOOLEAN\r | |
433 | EFIAPI\r | |
434 | ReportDebugCodeEnabled (\r | |
435 | VOID\r | |
436 | )\r | |
437 | {\r | |
438 | return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r | |
439 | }\r |