]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | Report Status Code Library for DXE Phase.\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 | // Global pointer to the Status Code Protocol\r | |
17 | //\r | |
18 | static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;\r | |
19 | \r | |
20 | /**\r | |
21 | Internal worker function that reports a status code through the Status Code Protocol\r | |
22 | \r | |
23 | This function checks to see if a Status Code Protocol is present in the handle \r | |
24 | database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is \r | |
25 | returned. If a Status Code Protocol is present, then it is cached in gStatusCode,\r | |
26 | and the ReportStatusCode() service of the Status Code Protocol is called passing in\r | |
27 | Type, Value, Instance, CallerId, and Data. The result of this call is returned.\r | |
28 | \r | |
29 | @param Type Status code type. \r | |
30 | @param Value Status code value.\r | |
31 | @param Instance Status code instance number.\r | |
32 | @param CallerId Pointer to a GUID that identifies the caller of this \r | |
33 | function. This is an optional parameter that may be \r | |
34 | NULL.\r | |
35 | @param Data Pointer to the extended data buffer. This is an \r | |
36 | optional parameter that may be NULL.\r | |
37 | \r | |
38 | @retval EFI_SUCCESS The status code was reported.\r | |
39 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to report the status code.\r | |
40 | @retval EFI_UNSUPPORTED Status Code Protocol is not available.\r | |
41 | \r | |
42 | **/\r | |
58251024 | 43 | STATIC\r |
878ddf1f | 44 | EFI_STATUS\r |
45 | InternalReportStatusCode (\r | |
46 | IN EFI_STATUS_CODE_TYPE Type,\r | |
47 | IN EFI_STATUS_CODE_VALUE Value,\r | |
48 | IN UINT32 Instance,\r | |
8960cdeb | 49 | IN CONST EFI_GUID *CallerId OPTIONAL,\r |
878ddf1f | 50 | IN EFI_STATUS_CODE_DATA *Data OPTIONAL \r |
51 | )\r | |
52 | {\r | |
53 | EFI_STATUS Status;\r | |
54 | \r | |
55 | //\r | |
56 | // If gStatusCode is NULL, then see if a Status Code Protocol instance is present \r | |
57 | // in the handle database.\r | |
58 | //\r | |
59 | if (gStatusCode == NULL) {\r | |
60 | Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r | |
61 | if (EFI_ERROR (Status) || gStatusCode == NULL) {\r | |
62 | return EFI_UNSUPPORTED;\r | |
63 | }\r | |
64 | }\r | |
65 | \r | |
66 | //\r | |
67 | // A Status Code Protocol is present in the handle database, so pass in all the \r | |
68 | // parameters to the ReportStatusCode() service of the Status Code Protocol\r | |
69 | //\r | |
8960cdeb | 70 | return gStatusCode->ReportStatusCode (Type, Value, Instance, (EFI_GUID *)CallerId, Data);\r |
878ddf1f | 71 | }\r |
72 | \r | |
73 | \r | |
74 | /**\r | |
75 | Computes and returns the size, in bytes, of a device path.\r | |
76 | \r | |
77 | @param DevicePath A pointer to a device path.\r | |
78 | \r | |
79 | @return The size, in bytes, of DevicePath.\r | |
80 | \r | |
81 | **/\r | |
58251024 | 82 | STATIC\r |
878ddf1f | 83 | UINTN\r |
84 | InternalReportStatusCodeDevicePathSize (\r | |
8960cdeb | 85 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r |
878ddf1f | 86 | )\r |
87 | {\r | |
8960cdeb | 88 | CONST EFI_DEVICE_PATH_PROTOCOL *Start;\r |
878ddf1f | 89 | \r |
90 | //\r | |
91 | // Search for the end of the device path structure\r | |
92 | //\r | |
93 | Start = DevicePath;\r | |
94 | while (!EfiIsDevicePathEnd (DevicePath)) {\r | |
95 | DevicePath = EfiNextDevicePathNode (DevicePath);\r | |
96 | }\r | |
97 | \r | |
98 | //\r | |
99 | // Subtract the start node from the end node and add in the size of the end node\r | |
100 | //\r | |
101 | return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath);\r | |
102 | }\r | |
103 | \r | |
104 | \r | |
105 | /**\r | |
106 | Converts a status code to an 8-bit POST code value.\r | |
107 | \r | |
108 | Converts the status code specified by CodeType and Value to an 8-bit POST code \r | |
109 | and returns the 8-bit POST code in PostCode. If CodeType is an \r | |
110 | EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode \r | |
111 | are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits \r | |
112 | 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned. \r | |
113 | \r | |
114 | If PostCode is NULL, then ASSERT().\r | |
115 | \r | |
116 | @param CodeType The type of status code being converted.\r | |
117 | @param Value The status code value being converted.\r | |
118 | @param PostCode A pointer to the 8-bit POST code value to return. \r | |
119 | \r | |
120 | @retval TRUE The status code specified by CodeType and Value was converted \r | |
121 | to an 8-bit POST code and returned in PostCode.\r | |
122 | @retval FALSE The status code specified by CodeType and Value could not be \r | |
123 | converted to an 8-bit POST code value.\r | |
124 | \r | |
125 | **/\r | |
126 | BOOLEAN\r | |
127 | EFIAPI\r | |
128 | CodeTypeToPostCode (\r | |
129 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
130 | IN EFI_STATUS_CODE_VALUE Value,\r | |
131 | OUT UINT8 *PostCode\r | |
132 | )\r | |
133 | {\r | |
134 | //\r | |
135 | // If PostCode is NULL, then ASSERT()\r | |
136 | //\r | |
137 | ASSERT (PostCode != NULL);\r | |
138 | \r | |
139 | //\r | |
140 | // Convert Value to an 8 bit post code\r | |
141 | //\r | |
142 | if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||\r | |
143 | ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) {\r | |
58251024 | 144 | *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |\r |
145 | (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));\r | |
878ddf1f | 146 | return TRUE;\r |
147 | }\r | |
148 | return FALSE;\r | |
149 | }\r | |
150 | \r | |
151 | \r | |
152 | /**\r | |
153 | Extracts ASSERT() information from a status code structure.\r | |
154 | \r | |
155 | Converts the status code specified by CodeType, Value, and Data to the ASSERT()\r | |
156 | arguments specified by Filename, Description, and LineNumber. If CodeType is \r | |
157 | an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and \r | |
158 | Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract \r | |
159 | Filename, Description, and LineNumber from the optional data area of the \r | |
160 | status code buffer specified by Data. The optional data area of Data contains \r | |
161 | a Null-terminated ASCII string for the FileName, followed by a Null-terminated \r | |
162 | ASCII string for the Description, followed by a 32-bit LineNumber. If the \r | |
163 | ASSERT() information could be extracted from Data, then return TRUE. \r | |
164 | Otherwise, FALSE is returned. \r | |
165 | \r | |
166 | If Data is NULL, then ASSERT().\r | |
167 | If Filename is NULL, then ASSERT().\r | |
168 | If Description is NULL, then ASSERT().\r | |
169 | If LineNumber is NULL, then ASSERT().\r | |
170 | \r | |
171 | @param CodeType The type of status code being converted.\r | |
172 | @param Value The status code value being converted.\r | |
173 | @param Data Pointer to status code data buffer. \r | |
174 | @param Filename Pointer to the source file name that generated the ASSERT().\r | |
175 | @param Description Pointer to the description of the ASSERT().\r | |
176 | @param LineNumber Pointer to source line number that generated the ASSERT().\r | |
177 | \r | |
178 | @retval TRUE The status code specified by CodeType, Value, and Data was \r | |
179 | converted ASSERT() arguments specified by Filename, Description, \r | |
180 | and LineNumber.\r | |
181 | @retval FALSE The status code specified by CodeType, Value, and Data could \r | |
182 | not be converted to ASSERT() arguments.\r | |
183 | \r | |
184 | **/\r | |
185 | BOOLEAN\r | |
186 | EFIAPI\r | |
187 | ReportStatusCodeExtractAssertInfo (\r | |
8960cdeb | 188 | IN EFI_STATUS_CODE_TYPE CodeType,\r |
189 | IN EFI_STATUS_CODE_VALUE Value, \r | |
190 | IN CONST EFI_STATUS_CODE_DATA *Data, \r | |
191 | OUT CHAR8 **Filename,\r | |
192 | OUT CHAR8 **Description,\r | |
193 | OUT UINT32 *LineNumber\r | |
878ddf1f | 194 | )\r |
195 | {\r | |
196 | EFI_DEBUG_ASSERT_DATA *AssertData;\r | |
197 | \r | |
198 | ASSERT (Data != NULL);\r | |
199 | ASSERT (Filename != NULL);\r | |
200 | ASSERT (Description != NULL);\r | |
201 | ASSERT (LineNumber != NULL);\r | |
202 | \r | |
203 | if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) && \r | |
204 | ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&\r | |
205 | ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {\r | |
206 | AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);\r | |
207 | *Filename = (CHAR8 *)(AssertData + 1);\r | |
208 | *Description = *Filename + AsciiStrLen (*Filename) + 1;\r | |
209 | *LineNumber = AssertData->LineNumber;\r | |
210 | return TRUE;\r | |
211 | }\r | |
212 | return FALSE;\r | |
213 | }\r | |
214 | \r | |
215 | \r | |
216 | /**\r | |
217 | Extracts DEBUG() information from a status code structure.\r | |
218 | \r | |
219 | Converts the status code specified by Data to the DEBUG() arguments specified \r | |
220 | by ErrorLevel, Marker, and Format. If type GUID in Data is \r | |
221 | EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and \r | |
222 | Format from the optional data area of the status code buffer specified by Data. \r | |
223 | The optional data area of Data contains a 32-bit ErrorLevel followed by Marker \r | |
224 | which is 12 UINTN parameters, followed by a Null-terminated ASCII string for \r | |
225 | the Format. If the DEBUG() information could be extracted from Data, then \r | |
226 | return TRUE. Otherwise, FALSE is returned.\r | |
227 | \r | |
228 | If Data is NULL, then ASSERT().\r | |
229 | If ErrorLevel is NULL, then ASSERT().\r | |
230 | If Marker is NULL, then ASSERT().\r | |
231 | If Format is NULL, then ASSERT().\r | |
232 | \r | |
233 | @param Data Pointer to status code data buffer. \r | |
234 | @param ErrorLevel Pointer to error level mask for a debug message.\r | |
235 | @param Marker Pointer to the variable argument list associated with Format.\r | |
236 | @param Format Pointer to a Null-terminated ASCII format string of a \r | |
237 | debug message.\r | |
238 | \r | |
239 | @retval TRUE The status code specified by Data was converted DEBUG() arguments \r | |
240 | specified by ErrorLevel, Marker, and Format.\r | |
241 | @retval FALSE The status code specified by Data could not be converted to \r | |
242 | DEBUG() arguments.\r | |
243 | \r | |
244 | **/\r | |
245 | BOOLEAN\r | |
246 | EFIAPI\r | |
247 | ReportStatusCodeExtractDebugInfo (\r | |
8960cdeb | 248 | IN CONST EFI_STATUS_CODE_DATA *Data, \r |
249 | OUT UINT32 *ErrorLevel,\r | |
250 | OUT VA_LIST *Marker,\r | |
251 | OUT CHAR8 **Format\r | |
878ddf1f | 252 | )\r |
253 | {\r | |
254 | EFI_DEBUG_INFO *DebugInfo;\r | |
255 | \r | |
256 | ASSERT (Data != NULL);\r | |
257 | ASSERT (ErrorLevel != NULL);\r | |
258 | ASSERT (Marker != NULL);\r | |
259 | ASSERT (Format != NULL);\r | |
260 | \r | |
261 | //\r | |
262 | // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE\r | |
263 | //\r | |
264 | if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {\r | |
265 | return FALSE;\r | |
266 | }\r | |
267 | \r | |
268 | //\r | |
269 | // Retrieve the debug information from the status code record\r | |
270 | //\r | |
271 | DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);\r | |
272 | \r | |
273 | *ErrorLevel = DebugInfo->ErrorLevel;\r | |
274 | \r | |
275 | //\r | |
276 | // The first 12 * UINTN bytes of the string are really an \r | |
277 | // argument stack to support varargs on the Format string.\r | |
278 | //\r | |
279 | *Marker = (VA_LIST) (DebugInfo + 1);\r | |
280 | *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);\r | |
281 | \r | |
282 | return TRUE;\r | |
283 | }\r | |
284 | \r | |
285 | \r | |
286 | /**\r | |
287 | Reports a status code.\r | |
288 | \r | |
289 | Reports the status code specified by the parameters Type and Value. Status \r | |
290 | code also require an instance, caller ID, and extended data. This function \r | |
291 | passed in a zero instance, NULL extended data, and a caller ID of \r | |
292 | gEfiCallerIdGuid, which is the GUID for the module. \r | |
293 | \r | |
294 | ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode() \r | |
295 | is called while processing another any other Report Status Code Library function,\r | |
296 | then ReportStatusCode() must return immediately.\r | |
297 | \r | |
298 | @param Type Status code type. \r | |
299 | @param Value Status code value.\r | |
300 | \r | |
301 | @retval EFI_SUCCESS The status code was reported.\r | |
302 | @retval EFI_DEVICE_ERROR There status code could not be reported due to a \r | |
303 | device error.\r | |
304 | @retval EFI_UNSUPPORTED Report status code is not supported\r | |
305 | \r | |
306 | **/\r | |
307 | EFI_STATUS\r | |
308 | EFIAPI\r | |
309 | ReportStatusCode (\r | |
310 | IN EFI_STATUS_CODE_TYPE Type,\r | |
311 | IN EFI_STATUS_CODE_VALUE Value\r | |
312 | )\r | |
313 | {\r | |
314 | return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);\r | |
315 | }\r | |
316 | \r | |
317 | \r | |
318 | /**\r | |
319 | Reports a status code with a Device Path Protocol as the extended data.\r | |
320 | \r | |
321 | Allocates and fills in the extended data section of a status code with the \r | |
322 | Device Path Protocol specified by DevicePath. This function is responsible \r | |
323 | for allocating a buffer large enough for the standard header and the device \r | |
324 | path. The standard header is filled in with a GUID of \r | |
325 | gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero \r | |
326 | instance and a caller ID of gEfiCallerIdGuid.\r | |
327 | \r | |
328 | ReportStatusCodeWithDevicePath()must actively prevent recursion. If \r | |
329 | ReportStatusCodeWithDevicePath() is called while processing another any other \r | |
330 | Report Status Code Library function, then ReportStatusCodeWithDevicePath() \r | |
331 | must return EFI_DEVICE_ERROR immediately.\r | |
332 | \r | |
333 | If DevicePath is NULL, then ASSERT().\r | |
334 | \r | |
335 | @param Type Status code type. \r | |
336 | @param Value Status code value.\r | |
337 | @param DevicePath Pointer to the Device Path Protocol to be reported.\r | |
338 | \r | |
339 | @retval EFI_SUCCESS The status code was reported with the extended \r | |
340 | data specified by DevicePath.\r | |
341 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the \r | |
342 | extended data section.\r | |
343 | @retval EFI_UNSUPPORTED Report status code is not supported\r | |
344 | \r | |
345 | **/\r | |
346 | EFI_STATUS\r | |
347 | EFIAPI\r | |
348 | ReportStatusCodeWithDevicePath (\r | |
8960cdeb | 349 | IN EFI_STATUS_CODE_TYPE Type,\r |
350 | IN EFI_STATUS_CODE_VALUE Value,\r | |
351 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
878ddf1f | 352 | )\r |
353 | {\r | |
354 | ASSERT (DevicePath != NULL);\r | |
355 | return ReportStatusCodeWithExtendedData (\r | |
356 | Type, \r | |
357 | Value, \r | |
358 | (VOID *)DevicePath, \r | |
359 | InternalReportStatusCodeDevicePathSize (DevicePath)\r | |
360 | );\r | |
361 | }\r | |
362 | \r | |
363 | \r | |
364 | /**\r | |
365 | Reports a status code with an extended data buffer.\r | |
366 | \r | |
367 | Allocates and fills in the extended data section of a status code with the \r | |
368 | extended data specified by ExtendedData and ExtendedDataSize. ExtendedData \r | |
369 | is assumed to be one of the data structures specified in Related Definitions. \r | |
370 | These data structure do not have the standard header, so this function is \r | |
371 | responsible for allocating a buffer large enough for the standard header and \r | |
372 | the extended data passed into this function. The standard header is filled \r | |
373 | in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported \r | |
374 | with a zero instance and a caller ID of gEfiCallerIdGuid.\r | |
375 | \r | |
376 | ReportStatusCodeWithExtendedData()must actively prevent recursion. If \r | |
377 | ReportStatusCodeWithExtendedData() is called while processing another any other \r | |
378 | Report Status Code Library function, then ReportStatusCodeWithExtendedData() \r | |
379 | must return EFI_DEVICE_ERROR immediately.\r | |
380 | \r | |
381 | If ExtendedData is NULL, then ASSERT().\r | |
382 | If ExtendedDataSize is 0, then ASSERT().\r | |
383 | \r | |
384 | @param Type Status code type. \r | |
385 | @param Value Status code value.\r | |
386 | @param ExtendedData Pointer to the extended data buffer to be reported.\r | |
387 | @param ExtendedDataSize The size, in bytes, of the extended data buffer to \r | |
388 | be reported.\r | |
389 | \r | |
390 | @retval EFI_SUCCESS The status code was reported with the extended \r | |
391 | data specified by ExtendedData and ExtendedDataSize.\r | |
392 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the \r | |
393 | extended data section.\r | |
394 | @retval EFI_UNSUPPORTED Report status code is not supported\r | |
395 | \r | |
396 | **/\r | |
397 | EFI_STATUS\r | |
398 | EFIAPI\r | |
399 | ReportStatusCodeWithExtendedData (\r | |
400 | IN EFI_STATUS_CODE_TYPE Type,\r | |
401 | IN EFI_STATUS_CODE_VALUE Value,\r | |
8960cdeb | 402 | IN CONST VOID *ExtendedData,\r |
878ddf1f | 403 | IN UINTN ExtendedDataSize\r |
404 | )\r | |
405 | {\r | |
406 | ASSERT (ExtendedData != NULL);\r | |
407 | ASSERT (ExtendedDataSize != 0);\r | |
408 | return ReportStatusCodeEx (\r | |
409 | Type,\r | |
410 | Value,\r | |
411 | 0,\r | |
412 | NULL,\r | |
413 | NULL,\r | |
414 | ExtendedData,\r | |
415 | ExtendedDataSize\r | |
416 | );\r | |
417 | }\r | |
418 | \r | |
419 | \r | |
420 | /**\r | |
421 | Reports a status code with full parameters.\r | |
422 | \r | |
423 | The function reports a status code. If ExtendedData is NULL and ExtendedDataSize \r | |
424 | is 0, then an extended data buffer is not reported. If ExtendedData is not \r | |
425 | NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated. \r | |
426 | ExtendedData is assumed not have the standard status code header, so this function \r | |
427 | is responsible for allocating a buffer large enough for the standard header and \r | |
428 | the extended data passed into this function. The standard header is filled in \r | |
429 | with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a \r | |
430 | GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with \r | |
431 | an instance specified by Instance and a caller ID specified by CallerId. If \r | |
432 | CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.\r | |
433 | \r | |
434 | ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx() \r | |
435 | is called while processing another any other Report Status Code Library function, \r | |
436 | then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.\r | |
437 | \r | |
438 | If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().\r | |
439 | If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().\r | |
440 | \r | |
441 | @param Type Status code type. \r | |
442 | @param Value Status code value.\r | |
443 | @param Instance Status code instance number.\r | |
444 | @param CallerId Pointer to a GUID that identifies the caller of this \r | |
445 | function. If this parameter is NULL, then a caller \r | |
446 | ID of gEfiCallerIdGuid is used.\r | |
447 | @param ExtendedDataGuid Pointer to the GUID for the extended data buffer. \r | |
448 | If this parameter is NULL, then a the status code \r | |
449 | standard header is filled in with \r | |
450 | gEfiStatusCodeSpecificDataGuid.\r | |
451 | @param ExtendedData Pointer to the extended data buffer. This is an \r | |
452 | optional parameter that may be NULL.\r | |
453 | @param ExtendedDataSize The size, in bytes, of the extended data buffer.\r | |
454 | \r | |
455 | @retval EFI_SUCCESS The status code was reported.\r | |
456 | @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate \r | |
457 | the extended data section if it was specified.\r | |
458 | @retval EFI_UNSUPPORTED Report status code is not supported\r | |
459 | \r | |
460 | **/\r | |
461 | EFI_STATUS\r | |
462 | EFIAPI\r | |
463 | ReportStatusCodeEx (\r | |
464 | IN EFI_STATUS_CODE_TYPE Type,\r | |
465 | IN EFI_STATUS_CODE_VALUE Value,\r | |
466 | IN UINT32 Instance,\r | |
8960cdeb | 467 | IN CONST EFI_GUID *CallerId OPTIONAL,\r |
468 | IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,\r | |
469 | IN CONST VOID *ExtendedData OPTIONAL,\r | |
878ddf1f | 470 | IN UINTN ExtendedDataSize\r |
471 | )\r | |
472 | {\r | |
473 | EFI_STATUS Status;\r | |
474 | EFI_STATUS_CODE_DATA *StatusCodeData;\r | |
475 | \r | |
476 | ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));\r | |
477 | ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));\r | |
478 | \r | |
479 | //\r | |
480 | // Allocate space for the Status Code Header and its buffer\r | |
481 | //\r | |
482 | StatusCodeData = NULL;\r | |
483 | gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);\r | |
484 | if (StatusCodeData == NULL) {\r | |
485 | return EFI_OUT_OF_RESOURCES;\r | |
486 | }\r | |
487 | \r | |
488 | //\r | |
489 | // Fill in the extended data header\r | |
490 | //\r | |
491 | StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);\r | |
492 | StatusCodeData->Size = (UINT16)ExtendedDataSize;\r | |
493 | if (ExtendedDataGuid == NULL) {\r | |
494 | ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;\r | |
495 | }\r | |
496 | CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);\r | |
497 | \r | |
498 | //\r | |
499 | // Fill in the extended data buffer\r | |
500 | //\r | |
501 | CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);\r | |
502 | \r | |
503 | //\r | |
504 | // Report the status code\r | |
505 | //\r | |
506 | if (CallerId == NULL) {\r | |
507 | CallerId = &gEfiCallerIdGuid;\r | |
508 | }\r | |
509 | Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);\r | |
510 | \r | |
511 | //\r | |
512 | // Free the allocated buffer\r | |
513 | //\r | |
514 | gBS->FreePool (StatusCodeData);\r | |
515 | \r | |
516 | return Status;\r | |
517 | }\r | |
518 | \r | |
519 | \r | |
520 | /**\r | |
521 | Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled\r | |
522 | \r | |
523 | This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED \r | |
524 | bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.\r | |
525 | \r | |
526 | @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of \r | |
527 | PcdReportStatusCodeProperyMask is set.\r | |
528 | @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of \r | |
529 | PcdReportStatusCodeProperyMask is clear.\r | |
530 | \r | |
531 | **/\r | |
532 | BOOLEAN\r | |
533 | EFIAPI\r | |
534 | ReportProgressCodeEnabled (\r | |
535 | VOID\r | |
536 | )\r | |
537 | {\r | |
58251024 | 538 | return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);\r |
878ddf1f | 539 | }\r |
540 | \r | |
541 | \r | |
542 | /**\r | |
543 | Returns TRUE if status codes of type EFI_ERROR_CODE are enabled\r | |
544 | \r | |
545 | This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED \r | |
546 | bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.\r | |
547 | \r | |
548 | @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of \r | |
549 | PcdReportStatusCodeProperyMask is set.\r | |
550 | @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of \r | |
551 | PcdReportStatusCodeProperyMask is clear.\r | |
552 | \r | |
553 | **/\r | |
554 | BOOLEAN\r | |
555 | EFIAPI\r | |
556 | ReportErrorCodeEnabled (\r | |
557 | VOID\r | |
558 | )\r | |
559 | {\r | |
58251024 | 560 | return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);\r |
878ddf1f | 561 | }\r |
562 | \r | |
563 | \r | |
564 | /**\r | |
565 | Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled\r | |
566 | \r | |
567 | This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED \r | |
568 | bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.\r | |
569 | \r | |
570 | @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of \r | |
571 | PcdReportStatusCodeProperyMask is set.\r | |
572 | @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of \r | |
573 | PcdReportStatusCodeProperyMask is clear.\r | |
574 | \r | |
575 | **/\r | |
576 | BOOLEAN\r | |
577 | EFIAPI\r | |
578 | ReportDebugCodeEnabled (\r | |
579 | VOID\r | |
580 | )\r | |
581 | {\r | |
58251024 | 582 | return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r |
878ddf1f | 583 | }\r |