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