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