3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 UEFI Debug Library that uses PrintLib to send messages to CONOUT
22 static BOOLEAN mDebugLevelInstalled
= FALSE
;
23 static EFI_DEBUG_LEVEL_PROTOCOL mDebugLevel
= { 0 };
27 IN EFI_HANDLE ImageHandle
,
28 IN EFI_SYSTEM_TABLE
*SystemTable
43 // Initialize Debug Level Protocol
45 mDebugLevel
.DebugLevel
= PcdGet32(PcdDebugPrintErrorLevel
);
48 // Install Debug Level Protocol
50 Status
= gBS
->InstallMultipleProtocolInterfaces (
52 &gEfiDebugLevelProtocolGuid
, &mDebugLevel
,
55 ASSERT_EFI_ERROR (Status
);
58 // Set flag to show that the Debug Level Protocol has been installed
60 mDebugLevelInstalled
= TRUE
;
76 Wrapper for DebugVPrint ()
80 ErrorLevel - If error level is set do the debug print.
82 Format - String to use for the print, followed by Print arguments.
84 ... - Print arguments.
93 CHAR16 UnicodeBuffer
[0x100];
98 // Check to see if CONOUT is avilable
100 if (gST
->ConOut
== NULL
) {
105 // Check driver Debug Level value and global debug level
107 if (mDebugLevelInstalled
) {
108 if ((ErrorLevel
& mDebugLevel
.DebugLevel
) == 0) {
112 if ((ErrorLevel
& PcdGet32(PcdDebugPrintErrorLevel
)) == 0) {
118 // BUGBUG: Need print that take CHAR8 Format and returns CHAR16 Buffer
120 for (Index
= 0; Format
[Index
] != 0; Index
++) {
121 UnicodeBuffer
[Index
] = Format
[Index
];
123 UnicodeBuffer
[Index
] = Format
[Index
];
126 // Convert the DEBUG() message to a Unicode String
128 VA_START (Marker
, Format
);
129 UnicodeVSPrint (Buffer
, sizeof (Buffer
), UnicodeBuffer
, Marker
);
133 // Send the print string to the Standard Error device
135 gST
->ConOut
->OutputString (gST
->ConOut
, Buffer
);
143 IN CHAR8
*Description
149 Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT
150 information. If Error Logging hub is not loaded CpuBreakpoint ().
152 We use UINT64 buffers due to IPF alignment concerns.
156 FileName - File name of failing routine.
158 LineNumber - Line number of failing ASSERT().
160 Description - Descritption, usally the assertion,
168 CHAR16 Buffer
[0x100];
171 // Check to see if CONOUT is avilable
173 if (gST
->ConOut
== NULL
) {
178 // Generate the ASSERT() message in Unicode format
180 UnicodeSPrint (Buffer
, sizeof (Buffer
), (CHAR16
*)L
"ASSERT %s(%d): %s\n", FileName
, LineNumber
, Description
);
183 // Send the print string to the Standard Error device
185 gST
->ConOut
->OutputString (gST
->ConOut
, Buffer
);
188 // Put break point in module that contained the error.
194 Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
196 This function fills Length bytes of Buffer with the value specified by
197 PcdDebugClearMemoryValue, and returns Buffer.
199 If Buffer is NULL, then ASSERT().
201 If Length is greater than (MAX_ADDRESS \96 Buffer + 1), then ASSERT().
203 @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue.
204 @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.
216 // SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue));
217 SetMem (Buffer
, Length
, 0xAF);
227 return ((PcdGet8(PcdDebugPropertyMask
) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED
) != 0);
236 return ((PcdGet8(PcdDebugPropertyMask
) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED
) != 0);
245 return ((PcdGet8(PcdDebugPropertyMask
) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED
) != 0);
250 DebugClearMemoryEnabled (
254 return ((PcdGet8(PcdDebugPropertyMask
) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED
) != 0);