]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiDebugLibConOut/DebugLib.c
1) Fix a bug for PCD autogen tools, see track#115 in PVCS: Module's PCD informtion...
[mirror_edk2.git] / MdePkg / Library / UefiDebugLibConOut / DebugLib.c
CommitLineData
878ddf1f 1/** @file\r
2 UEFI Debug Library that uses PrintLib to send messages to CONOUT.\r
3\r
4 Copyright (c) 2006, Intel Corporation<BR>\r
5 All rights reserved. This program and the accompanying materials \r
6 are licensed and made available under the terms and conditions of the BSD License \r
7 which accompanies this distribution. The full text of the license may be found at \r
8 http://opensource.org/licenses/bsd-license.php \r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
13**/\r
14\r
15//\r
16// Define the maximum debug and assert message length that this library supports \r
17//\r
18#define MAX_DEBUG_MESSAGE_LENGTH 0x100\r
19\r
20\r
21/**\r
22\r
23 Prints a debug message to the debug output device if the specified error level is enabled.\r
24\r
25 If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print \r
26 the message specified by Format and the associated variable argument list to \r
27 the debug output device.\r
28\r
29 If Format is NULL, then ASSERT().\r
30\r
31 @param ErrorLevel The error level of the debug message.\r
32 @param Format Format string for the debug message to print.\r
33\r
34**/\r
35VOID\r
36EFIAPI\r
37DebugPrint (\r
d3665c47 38 IN UINTN ErrorLevel,\r
39 IN CONST CHAR8 *Format,\r
878ddf1f 40 ...\r
41 )\r
42{\r
43 CHAR16 Buffer[MAX_DEBUG_MESSAGE_LENGTH];\r
44 VA_LIST Marker;\r
45\r
46 //\r
47 // If Format is NULL, then ASSERT().\r
48 //\r
49 ASSERT (Format != NULL);\r
50\r
51 //\r
52 // Check driver debug mask value and global mask\r
53 //\r
54 if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) {\r
55 return;\r
56 }\r
57\r
58 //\r
59 // Convert the DEBUG() message to a Unicode String\r
60 //\r
61 VA_START (Marker, Format);\r
62 UnicodeVSPrintAsciiFormat (Buffer, sizeof (Buffer), Format, Marker);\r
63 VA_END (Marker);\r
64\r
65 //\r
66 // Send the print string to the Console Output device\r
67 //\r
68 if (gST->ConOut != NULL) {\r
69 gST->ConOut->OutputString (gST->ConOut, Buffer);\r
70 }\r
71}\r
72\r
73\r
74/**\r
75\r
76 Prints an assert message containing a filename, line number, and description. \r
77 This may be followed by a breakpoint or a dead loop.\r
78\r
79