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