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