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