]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Library / PeiDxeDebugLibReportStatusCode / DebugLib.c
CommitLineData
11ff2c71
LG
1/** @file\r
2 Debug Library based on report status code library.\r
3\r
4 Note that if the debug message length is larger than the maximum allowable\r
5 record length, then the debug message will be ignored directly.\r
6\r
bd68cddc 7 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
9d510e61 8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
11ff2c71
LG
9\r
10**/\r
11\r
12#include <PiPei.h>\r
13\r
14#include <Guid/StatusCodeDataTypeId.h>\r
15#include <Guid/StatusCodeDataTypeDebug.h>\r
16\r
17#include <Library/DebugLib.h>\r
18#include <Library/BaseLib.h>\r
19#include <Library/BaseMemoryLib.h>\r
20#include <Library/ReportStatusCodeLib.h>\r
21#include <Library/PcdLib.h>\r
22#include <Library/DebugPrintErrorLevelLib.h>\r
23\r
bd68cddc
BB
24//\r
25// VA_LIST can not initialize to NULL for all compiler, so we use this to\r
26// indicate a null VA_LIST\r
27//\r
28VA_LIST mVaListNull;\r
29\r
11ff2c71
LG
30/**\r
31 Prints a debug message to the debug output device if the specified error level is enabled.\r
32\r
d1102dba
LG
33 If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function\r
34 GetDebugPrintErrorLevel (), then print the message specified by Format and the\r
11ff2c71
LG
35 associated variable argument list to the debug output device.\r
36\r
37 If Format is NULL, then ASSERT().\r
38\r
39 If the length of the message string specificed by Format is larger than the maximum allowable\r
40 record length, then directly return and not print it.\r
41\r
42 @param ErrorLevel The error level of the debug message.\r
43 @param Format Format string for the debug message to print.\r
d1102dba 44 @param ... Variable argument list whose contents are accessed\r
11ff2c71
LG
45 based on the format string specified by Format.\r
46\r
47**/\r
48VOID\r
49EFIAPI\r
50DebugPrint (\r
51 IN UINTN ErrorLevel,\r
52 IN CONST CHAR8 *Format,\r
53 ...\r
54 )\r
bd68cddc
BB
55{\r
56 VA_LIST Marker;\r
57\r
58 VA_START (Marker, Format);\r
59 DebugVPrint (ErrorLevel, Format, Marker);\r
60 VA_END (Marker);\r
61}\r
62\r
63/**\r
64 Prints a debug message to the debug output device if the specified\r
65 error level is enabled base on Null-terminated format string and a\r
66 VA_LIST argument list or a BASE_LIST argument list.\r
67\r
68 If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function\r
69 GetDebugPrintErrorLevel (), then print the message specified by Format and\r
70 the associated variable argument list to the debug output device.\r
71\r
72 Only one list type is used.\r
73 If BaseListMarker == NULL, then use VaListMarker.\r
74 Otherwise use BaseListMarker and the VaListMarker should be initilized as\r
75 mVaListNull.\r
76\r
77 If Format is NULL, then ASSERT().\r
78\r
79 @param ErrorLevel The error level of the debug message.\r
80 @param Format Format string for the debug message to print.\r
81 @param VaListMarker VA_LIST marker for the variable argument list.\r
82 @param BaseListMarker BASE_LIST marker for the variable argument list.\r
83\r
84**/\r
85VOID\r
86DebugPrintMarker (\r
87 IN UINTN ErrorLevel,\r
88 IN CONST CHAR8 *Format,\r
89 IN VA_LIST VaListMarker,\r
90 IN BASE_LIST BaseListMarker\r
91 )\r
11ff2c71
LG
92{\r
93 UINT64 Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)) + 1];\r
94 EFI_DEBUG_INFO *DebugInfo;\r
95 UINTN TotalSize;\r
bd68cddc 96 BASE_LIST BaseListMarkerPointer;\r
11ff2c71
LG
97 CHAR8 *FormatString;\r
98 BOOLEAN Long;\r
99\r
100 //\r
101 // If Format is NULL, then ASSERT().\r
102 //\r
103 ASSERT (Format != NULL);\r
104\r
105 //\r
106 // Check driver Debug Level value and global debug level\r
107 //\r
108 if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) {\r
109 return;\r
110 }\r
111\r
112 //\r
113 // Compute the total size of the record.\r
d1102dba 114 // Note that the passing-in format string and variable parameters will be constructed to\r
11ff2c71
LG
115 // the following layout:\r
116 //\r
bd68cddc
BB
117 // Buffer->|------------------------|\r
118 // | Padding | 4 bytes\r
119 // DebugInfo->|------------------------|\r
120 // | EFI_DEBUG_INFO | sizeof(EFI_DEBUG_INFO)\r
121 // BaseListMarkerPointer->|------------------------|\r
122 // | ... |\r
123 // | variable arguments | 12 * sizeof (UINT64)\r
124 // | ... |\r
125 // |------------------------|\r
126 // | Format String |\r
127 // |------------------------|<- (UINT8 *)Buffer + sizeof(Buffer)\r
11ff2c71
LG
128 //\r
129 TotalSize = 4 + sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrSize (Format);\r
130\r
131 //\r
bd68cddc 132 // If the TotalSize is larger than the maximum record size, then truncate it.\r
11ff2c71
LG
133 //\r
134 if (TotalSize > sizeof (Buffer)) {\r
137ed155 135 TotalSize = sizeof (Buffer);\r
11ff2c71
LG
136 }\r
137\r
138 //\r
139 // Fill in EFI_DEBUG_INFO\r
140 //\r
bd68cddc
BB
141 // Here we skip the first 4 bytes of Buffer, because we must ensure BaseListMarkerPointer is\r
142 // 64-bit aligned, otherwise retrieving 64-bit parameter from BaseListMarkerPointer will cause\r
11ff2c71 143 // exception on IPF. Buffer starts at 64-bit aligned address, so skipping 4 types (sizeof(EFI_DEBUG_INFO))\r
bd68cddc 144 // just makes address of BaseListMarkerPointer, which follows DebugInfo, 64-bit aligned.\r
11ff2c71
LG
145 //\r
146 DebugInfo = (EFI_DEBUG_INFO *)(Buffer) + 1;\r
147 DebugInfo->ErrorLevel = (UINT32)ErrorLevel;\r
bd68cddc 148 BaseListMarkerPointer = (BASE_LIST)(DebugInfo + 1);\r
11ff2c71
LG
149 FormatString = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);\r
150\r
151 //\r
137ed155 152 // Copy the Format string into the record. It will be truncated if it's too long.\r
11ff2c71 153 //\r
137ed155
RN
154 AsciiStrnCpyS (\r
155 FormatString, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 * sizeof(UINT64)),\r
156 Format, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 * sizeof(UINT64)) - 1\r
157 );\r
11ff2c71
LG
158\r
159 //\r
160 // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments\r
161 // of format in DEBUG string, which is followed by the DEBUG format string.\r
162 // Here we will process the variable arguments and pack them in this area.\r
163 //\r
a7119c81
RN
164\r
165 //\r
166 // Use the actual format string.\r
167 //\r
168 Format = FormatString;\r
11ff2c71
LG
169 for (; *Format != '\0'; Format++) {\r
170 //\r
171 // Only format with prefix % is processed.\r
172 //\r
173 if (*Format != '%') {\r
174 continue;\r
175 }\r
176 Long = FALSE;\r
177 //\r
178 // Parse Flags and Width\r
179 //\r
180 for (Format++; TRUE; Format++) {\r
181 if (*Format == '.' || *Format == '-' || *Format == '+' || *Format == ' ') {\r
182 //\r
183 // These characters in format field are omitted.\r
184 //\r
185 continue;\r
186 }\r
187 if (*Format >= '0' && *Format <= '9') {\r
188 //\r
189 // These characters in format field are omitted.\r
190 //\r
191 continue;\r
192 }\r
193 if (*Format == 'L' || *Format == 'l') {\r
194 //\r
195 // 'L" or "l" in format field means the number being printed is a UINT64\r
196 //\r
197 Long = TRUE;\r
198 continue;\r
199 }\r
200 if (*Format == '*') {\r
201 //\r
202 // '*' in format field means the precision of the field is specified by\r
203 // a UINTN argument in the argument list.\r
204 //\r
bd68cddc
BB
205 if (BaseListMarker == NULL) {\r
206 BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker, UINTN);\r
207 } else {\r
208 BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG (BaseListMarker, UINTN);\r
209 }\r
11ff2c71
LG
210 continue;\r
211 }\r
212 if (*Format == '\0') {\r
213 //\r
214 // Make no output if Format string terminates unexpectedly when\r
d1102dba 215 // looking up for flag, width, precision and type.\r
11ff2c71
LG
216 //\r
217 Format--;\r
218 }\r
219 //\r
220 // When valid argument type detected or format string terminates unexpectedly,\r
221 // the inner loop is done.\r
222 //\r
223 break;\r
224 }\r
d1102dba 225\r
11ff2c71
LG
226 //\r
227 // Pack variable arguments into the storage area following EFI_DEBUG_INFO.\r
228 //\r
229 if ((*Format == 'p') && (sizeof (VOID *) > 4)) {\r
230 Long = TRUE;\r
231 }\r
796fecd8 232 if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' || *Format == 'u') {\r
11ff2c71 233 if (Long) {\r
bd68cddc
BB
234 if (BaseListMarker == NULL) {\r
235 BASE_ARG (BaseListMarkerPointer, INT64) = VA_ARG (VaListMarker, INT64);\r
236 } else {\r
237 BASE_ARG (BaseListMarkerPointer, INT64) = BASE_ARG (BaseListMarker, INT64);\r
238 }\r
11ff2c71 239 } else {\r
bd68cddc
BB
240 if (BaseListMarker == NULL) {\r
241 BASE_ARG (BaseListMarkerPointer, int) = VA_ARG (VaListMarker, int);\r
242 } else {\r
243 BASE_ARG (BaseListMarkerPointer, int) = BASE_ARG (BaseListMarker, int);\r
244 }\r
11ff2c71
LG
245 }\r
246 } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format == 'g' || *Format == 't') {\r
bd68cddc
BB
247 if (BaseListMarker == NULL) {\r
248 BASE_ARG (BaseListMarkerPointer, VOID *) = VA_ARG (VaListMarker, VOID *);\r
249 } else {\r
250 BASE_ARG (BaseListMarkerPointer, VOID *) = BASE_ARG (BaseListMarker, VOID *);\r
251 }\r
11ff2c71 252 } else if (*Format == 'c') {\r
bd68cddc
BB
253 if (BaseListMarker == NULL) {\r
254 BASE_ARG (BaseListMarkerPointer, UINTN) = VA_ARG (VaListMarker, UINTN);\r
255 } else {\r
256 BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG (BaseListMarker, UINTN);\r
257 }\r
11ff2c71 258 } else if (*Format == 'r') {\r
bd68cddc
BB
259 if (BaseListMarker == NULL) {\r
260 BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = VA_ARG (VaListMarker, RETURN_STATUS);\r
261 } else {\r
262 BASE_ARG (BaseListMarkerPointer, RETURN_STATUS) = BASE_ARG (BaseListMarker, RETURN_STATUS);\r
263 }\r
11ff2c71
LG
264 }\r
265\r
266 //\r
267 // If the converted BASE_LIST is larger than the 12 * sizeof (UINT64) allocated bytes, then ASSERT()\r
d1102dba 268 // This indicates that the DEBUG() macro is passing in more argument than can be handled by\r
11ff2c71
LG
269 // the EFI_DEBUG_INFO record\r
270 //\r
bd68cddc 271 ASSERT ((CHAR8 *)BaseListMarkerPointer <= FormatString);\r
11ff2c71
LG
272\r
273 //\r
274 // If the converted BASE_LIST is larger than the 12 * sizeof (UINT64) allocated bytes, then return\r
275 //\r
bd68cddc 276 if ((CHAR8 *)BaseListMarkerPointer > FormatString) {\r
11ff2c71
LG
277 return;\r
278 }\r
279 }\r
11ff2c71
LG
280\r
281 //\r
282 // Send the DebugInfo record\r
283 //\r
284 REPORT_STATUS_CODE_EX (\r
285 EFI_DEBUG_CODE,\r
286 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED),\r
287 0,\r
288 NULL,\r
289 &gEfiStatusCodeDataTypeDebugGuid,\r
290 DebugInfo,\r
291 TotalSize\r
292 );\r
293}\r
294\r
bd68cddc
BB
295/**\r
296 Prints a debug message to the debug output device if the specified\r
297 error level is enabled.\r
298\r
299 If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function\r
300 GetDebugPrintErrorLevel (), then print the message specified by Format and\r
301 the associated variable argument list to the debug output device.\r
302\r
303 If Format is NULL, then ASSERT().\r
304\r
305 @param ErrorLevel The error level of the debug message.\r
306 @param Format Format string for the debug message to print.\r
307 @param VaListMarker VA_LIST marker for the variable argument list.\r
308\r
309**/\r
310VOID\r
311EFIAPI\r
312DebugVPrint (\r
313 IN UINTN ErrorLevel,\r
314 IN CONST CHAR8 *Format,\r
315 IN VA_LIST VaListMarker\r
316 )\r
317{\r
318 DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);\r
319}\r
320\r
321/**\r
322 Prints a debug message to the debug output device if the specified\r
323 error level is enabled.\r
324 This function use BASE_LIST which would provide a more compatible\r
325 service than VA_LIST.\r
326\r
327 If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function\r
328 GetDebugPrintErrorLevel (), then print the message specified by Format and\r
329 the associated variable argument list to the debug output device.\r
330\r
331 If Format is NULL, then ASSERT().\r
332\r
333 @param ErrorLevel The error level of the debug message.\r
334 @param Format Format string for the debug message to print.\r
335 @param BaseListMarker BASE_LIST marker for the variable argument list.\r
336\r
337**/\r
338VOID\r
339EFIAPI\r
340DebugBPrint (\r
341 IN UINTN ErrorLevel,\r
342 IN CONST CHAR8 *Format,\r
343 IN BASE_LIST BaseListMarker\r
344 )\r
345{\r
346 DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);\r
347}\r
348\r
11ff2c71 349/**\r
d1102dba 350 Prints an assert message containing a filename, line number, and description.\r
11ff2c71
LG
351 This may be followed by a breakpoint or a dead loop.\r
352\r
353 Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n"\r
d1102dba
LG
354 to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of\r
355 PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if\r
356 DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then\r
357 CpuDeadLoop() is called. If neither of these bits are set, then this function\r
11ff2c71
LG
358 returns immediately after the message is printed to the debug output device.\r
359 DebugAssert() must actively prevent recursion. If DebugAssert() is called while\r
360 processing another DebugAssert(), then DebugAssert() must return immediately.\r
361\r
362 If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.\r
363 If Description is NULL, then a <Description> string of "(NULL) Description" is printed.\r
364\r
365 @param FileName Pointer to the name of the source file that generated the assert condition.\r
366 @param LineNumber The line number in the source file that generated the assert condition\r
367 @param Description Pointer to the description of the assert condition.\r
368\r
369**/\r
370VOID\r
371EFIAPI\r
372DebugAssert (\r
373 IN CONST CHAR8 *FileName,\r
374 IN UINTN LineNumber,\r
375 IN CONST CHAR8 *Description\r
376 )\r
377{\r
378 UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)];\r
379 EFI_DEBUG_ASSERT_DATA *AssertData;\r
380 UINTN HeaderSize;\r
381 UINTN TotalSize;\r
382 CHAR8 *Temp;\r
39eccb9c 383 UINTN ModuleNameSize;\r
11ff2c71
LG
384 UINTN FileNameSize;\r
385 UINTN DescriptionSize;\r
386\r
387 //\r
388 // Get string size\r
389 //\r
390 HeaderSize = sizeof (EFI_DEBUG_ASSERT_DATA);\r
39eccb9c
BA
391 //\r
392 // Compute string size of module name enclosed by []\r
393 //\r
394 ModuleNameSize = 2 + AsciiStrSize (gEfiCallerBaseName);\r
11ff2c71
LG
395 FileNameSize = AsciiStrSize (FileName);\r
396 DescriptionSize = AsciiStrSize (Description);\r
397\r
398 //\r
399 // Make sure it will all fit in the passed in buffer.\r
400 //\r
39eccb9c 401 if (HeaderSize + ModuleNameSize + FileNameSize + DescriptionSize > sizeof (Buffer)) {\r
11ff2c71 402 //\r
39eccb9c 403 // remove module name if it's too long to be filled into buffer\r
11ff2c71 404 //\r
39eccb9c
BA
405 ModuleNameSize = 0;\r
406 if (HeaderSize + FileNameSize + DescriptionSize > sizeof (Buffer)) {\r
11ff2c71 407 //\r
39eccb9c 408 // FileName + Description is too long to be filled into buffer.\r
11ff2c71 409 //\r
39eccb9c
BA
410 if (HeaderSize + FileNameSize < sizeof (Buffer)) {\r
411 //\r
412 // Description has enough buffer to be truncated.\r
413 //\r
414 DescriptionSize = sizeof (Buffer) - HeaderSize - FileNameSize;\r
415 } else {\r
416 //\r
417 // FileName is too long to be filled into buffer.\r
418 // FileName will be truncated. Reserved one byte for Description NULL terminator.\r
419 //\r
420 DescriptionSize = 1;\r
421 FileNameSize = sizeof (Buffer) - HeaderSize - DescriptionSize;\r
422 }\r
11ff2c71
LG
423 }\r
424 }\r
11ff2c71
LG
425 //\r
426 // Fill in EFI_DEBUG_ASSERT_DATA\r
427 //\r
428 AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer;\r
429 AssertData->LineNumber = (UINT32)LineNumber;\r
430 TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA);\r
431\r
39eccb9c
BA
432 Temp = (CHAR8 *)(AssertData + 1);\r
433\r
434 //\r
435 // Copy Ascii [ModuleName].\r
436 //\r
437 if (ModuleNameSize != 0) {\r
438 CopyMem(Temp, "[", 1);\r
439 CopyMem(Temp + 1, gEfiCallerBaseName, ModuleNameSize - 3);\r
440 CopyMem(Temp + ModuleNameSize - 2, "] ", 2);\r
441 }\r
442\r
11ff2c71
LG
443 //\r
444 // Copy Ascii FileName including NULL terminator.\r
445 //\r
39eccb9c 446 Temp = CopyMem (Temp + ModuleNameSize, FileName, FileNameSize);\r
11ff2c71 447 Temp[FileNameSize - 1] = 0;\r
39eccb9c 448 TotalSize += (ModuleNameSize + FileNameSize);\r
11ff2c71
LG
449\r
450 //\r
451 // Copy Ascii Description include NULL terminator.\r
452 //\r
453 Temp = CopyMem (Temp + FileNameSize, Description, DescriptionSize);\r
454 Temp[DescriptionSize - 1] = 0;\r
455 TotalSize += DescriptionSize;\r
456\r
457 REPORT_STATUS_CODE_EX (\r
458 (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),\r
459 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),\r
460 0,\r
461 NULL,\r
462 NULL,\r
463 AssertData,\r
464 TotalSize\r
465 );\r
466\r
467 //\r
468 // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings\r
469 //\r
470 if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {\r
471 CpuBreakpoint ();\r
472 } else if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {\r
473 CpuDeadLoop ();\r
474 }\r
475}\r
476\r
477\r
478/**\r
479 Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.\r
480\r
d1102dba 481 This function fills Length bytes of Buffer with the value specified by\r
11ff2c71
LG
482 PcdDebugClearMemoryValue, and returns Buffer.\r
483\r
484 If Buffer is NULL, then ASSERT().\r
d1102dba 485 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
11ff2c71
LG
486\r
487 @param Buffer Pointer to the target buffer to be filled with PcdDebugClearMemoryValue.\r
d1102dba 488 @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.\r
11ff2c71
LG
489\r
490 @return Buffer Pointer to the target buffer filled with PcdDebugClearMemoryValue.\r
491\r
492**/\r
493VOID *\r
494EFIAPI\r
495DebugClearMemory (\r
496 OUT VOID *Buffer,\r
497 IN UINTN Length\r
498 )\r
499{\r
500 ASSERT (Buffer != NULL);\r
501\r
502 return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));\r
503}\r
504\r
505\r
506/**\r
507 Returns TRUE if ASSERT() macros are enabled.\r
508\r
d1102dba 509 This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of\r
11ff2c71
LG
510 PcdDebugProperyMask is set. Otherwise FALSE is returned.\r
511\r
512 @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set.\r
513 @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear.\r
514\r
515**/\r
516BOOLEAN\r
517EFIAPI\r
518DebugAssertEnabled (\r
519 VOID\r
520 )\r
521{\r
522 return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);\r
523}\r
524\r
525\r
d1102dba 526/**\r
11ff2c71
LG
527 Returns TRUE if DEBUG() macros are enabled.\r
528\r
d1102dba 529 This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of\r
11ff2c71
LG
530 PcdDebugProperyMask is set. Otherwise FALSE is returned.\r
531\r
532 @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set.\r
533 @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear.\r
534\r
535**/\r
536BOOLEAN\r
537EFIAPI\r
538DebugPrintEnabled (\r
539 VOID\r
540 )\r
541{\r
542 return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);\r
543}\r
544\r
545\r
d1102dba 546/**\r
11ff2c71
LG
547 Returns TRUE if DEBUG_CODE() macros are enabled.\r
548\r
d1102dba 549 This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of\r
11ff2c71
LG
550 PcdDebugProperyMask is set. Otherwise FALSE is returned.\r
551\r
552 @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set.\r
553 @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear.\r
554\r
555**/\r
556BOOLEAN\r
557EFIAPI\r
558DebugCodeEnabled (\r
559 VOID\r
560 )\r
561{\r
562 return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);\r
563}\r
564\r
565\r
d1102dba 566/**\r
11ff2c71
LG
567 Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled.\r
568\r
d1102dba 569 This function returns TRUE if the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of\r
11ff2c71
LG
570 PcdDebugProperyMask is set. Otherwise FALSE is returned.\r
571\r
572 @retval TRUE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.\r
573 @retval FALSE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.\r
574\r
575**/\r
576BOOLEAN\r
577EFIAPI\r
578DebugClearMemoryEnabled (\r
579 VOID\r
580 )\r
581{\r
582 return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);\r
583}\r
584\r
585/**\r
586 Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixedDebugPrintErrorLevel.\r
587\r
588 This function compares the bit mask of ErrorLevel and PcdFixedDebugPrintErrorLevel.\r
589\r
590 @retval TRUE Current ErrorLevel is supported.\r
591 @retval FALSE Current ErrorLevel is not supported.\r
592\r
593**/\r
594BOOLEAN\r
595EFIAPI\r
596DebugPrintLevelEnabled (\r
597 IN CONST UINTN ErrorLevel\r
598 )\r
599{\r
600 return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0);\r
601}\r