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