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