DebugLib.c 19 KB

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