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