XenevaOS
Loading...
Searching...
No Matches
DebugLib.h
Go to the documentation of this file.
1
22#ifndef __DEBUG_LIB_H__
23#define __DEBUG_LIB_H__
24
25//
26// Declare bits for PcdDebugPropertyMask
27//
28#define DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED 0x01
29#define DEBUG_PROPERTY_DEBUG_PRINT_ENABLED 0x02
30#define DEBUG_PROPERTY_DEBUG_CODE_ENABLED 0x04
31#define DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED 0x08
32#define DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED 0x10
33#define DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED 0x20
34
35//
36// Declare bits for PcdDebugPrintErrorLevel and the ErrorLevel parameter of DebugPrint()
37//
38#define DEBUG_INIT 0x00000001 // Initialization
39#define DEBUG_WARN 0x00000002 // Warnings
40#define DEBUG_LOAD 0x00000004 // Load events
41#define DEBUG_FS 0x00000008 // EFI File system
42#define DEBUG_POOL 0x00000010 // Alloc & Free (pool)
43#define DEBUG_PAGE 0x00000020 // Alloc & Free (page)
44#define DEBUG_INFO 0x00000040 // Informational debug messages
45#define DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers
46#define DEBUG_VARIABLE 0x00000100 // Variable
47#define DEBUG_BM 0x00000400 // Boot Manager
48#define DEBUG_BLKIO 0x00001000 // BlkIo Driver
49#define DEBUG_NET 0x00004000 // Network Io Driver
50#define DEBUG_UNDI 0x00010000 // UNDI Driver
51#define DEBUG_LOADFILE 0x00020000 // LoadFile
52#define DEBUG_EVENT 0x00080000 // Event messages
53#define DEBUG_GCD 0x00100000 // Global Coherency Database changes
54#define DEBUG_CACHE 0x00200000 // Memory range cachability changes
55#define DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may
56 // significantly impact boot performance
57#define DEBUG_ERROR 0x80000000 // Error
58
59//
60// Aliases of debug message mask bits
61//
62#define EFI_D_INIT DEBUG_INIT
63#define EFI_D_WARN DEBUG_WARN
64#define EFI_D_LOAD DEBUG_LOAD
65#define EFI_D_FS DEBUG_FS
66#define EFI_D_POOL DEBUG_POOL
67#define EFI_D_PAGE DEBUG_PAGE
68#define EFI_D_INFO DEBUG_INFO
69#define EFI_D_DISPATCH DEBUG_DISPATCH
70#define EFI_D_VARIABLE DEBUG_VARIABLE
71#define EFI_D_BM DEBUG_BM
72#define EFI_D_BLKIO DEBUG_BLKIO
73#define EFI_D_NET DEBUG_NET
74#define EFI_D_UNDI DEBUG_UNDI
75#define EFI_D_LOADFILE DEBUG_LOADFILE
76#define EFI_D_EVENT DEBUG_EVENT
77#define EFI_D_VERBOSE DEBUG_VERBOSE
78#define EFI_D_ERROR DEBUG_ERROR
79
95VOID
98 IN UINTN ErrorLevel,
100 ...
101 );
102
103
125VOID
126EFIAPI
128 IN CONST CHAR8 *FileName,
130 IN CONST CHAR8 *Description
131 );
132
133
149VOID *
150EFIAPI
152 OUT VOID *Buffer,
154 );
155
156
168EFIAPI
170 VOID
171 );
172
173
185EFIAPI
187 VOID
188 );
189
190
202EFIAPI
204 VOID
205 );
206
207
219EFIAPI
221 VOID
222 );
223
234EFIAPI
236 IN CONST UINTN ErrorLevel
237 );
238
248#define _ASSERT(Expression) DebugAssert (__FILE__, __LINE__, #Expression)
249
250
264#if !defined(MDE_CPU_EBC) && (!defined (_MSC_VER) || _MSC_VER > 1400)
265 #define _DEBUG_PRINT(PrintLevel, ...) \
266 do { \
267 if (DebugPrintLevelEnabled (PrintLevel)) { \
268 DebugPrint (PrintLevel, ##__VA_ARGS__); \
269 } \
270 } while (FALSE)
271 #define _DEBUG(Expression) _DEBUG_PRINT Expression
272#else
273#define _DEBUG(Expression) DebugPrint Expression
274#endif
275
288#if !defined(MDEPKG_NDEBUG)
289 #define ASSERT(Expression) \
290 do { \
291 if (DebugAssertEnabled ()) { \
292 if (!(Expression)) { \
293 _ASSERT (Expression); \
294 ANALYZER_UNREACHABLE (); \
295 } \
296 } \
297 } while (FALSE)
298#else
299 #define ASSERT(Expression)
300#endif
301
314#if !defined(MDEPKG_NDEBUG)
315 #define DEBUG(Expression) \
316 do { \
317 if (DebugPrintEnabled ()) { \
318 _DEBUG (Expression); \
319 } \
320 } while (FALSE)
321#else
322 #define DEBUG(Expression)
323#endif
324
337#if !defined(MDEPKG_NDEBUG)
338 #define ASSERT_EFI_ERROR(StatusParameter) \
339 do { \
340 if (DebugAssertEnabled ()) { \
341 if (EFI_ERROR (StatusParameter)) { \
342 DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR (Status = %r)\n", StatusParameter)); \
343 _ASSERT (!EFI_ERROR (StatusParameter)); \
344 } \
345 } \
346 } while (FALSE)
347#else
348 #define ASSERT_EFI_ERROR(StatusParameter)
349#endif
350
363#if !defined(MDEPKG_NDEBUG)
364 #define ASSERT_RETURN_ERROR(StatusParameter) \
365 do { \
366 if (DebugAssertEnabled ()) { \
367 if (RETURN_ERROR (StatusParameter)) { \
368 DEBUG ((DEBUG_ERROR, "\nASSERT_RETURN_ERROR (Status = %r)\n", \
369 StatusParameter)); \
370 _ASSERT (!RETURN_ERROR (StatusParameter)); \
371 } \
372 } \
373 } while (FALSE)
374#else
375 #define ASSERT_RETURN_ERROR(StatusParameter)
376#endif
377
400#if !defined(MDEPKG_NDEBUG)
401 #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) \
402 do { \
403 if (DebugAssertEnabled ()) { \
404 VOID *Instance; \
405 ASSERT (Guid != NULL); \
406 if (Handle == NULL) { \
407 if (!EFI_ERROR (gBS->LocateProtocol ((EFI_GUID *)Guid, NULL, &Instance))) { \
408 _ASSERT (Guid already installed in database); \
409 } \
410 } else { \
411 if (!EFI_ERROR (gBS->HandleProtocol (Handle, (EFI_GUID *)Guid, &Instance))) { \
412 _ASSERT (Guid already installed on Handle); \
413 } \
414 } \
415 } \
416 } while (FALSE)
417#else
418 #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)
419#endif
420
430#define DEBUG_CODE_BEGIN() do { if (DebugCodeEnabled ()) { UINT8 __DebugCodeLocal
431
432
442#define DEBUG_CODE_END() __DebugCodeLocal = 0; __DebugCodeLocal++; } } while (FALSE)
443
444
453#define DEBUG_CODE(Expression) \
454 DEBUG_CODE_BEGIN (); \
455 Expression \
456 DEBUG_CODE_END ()
457
458
469#define DEBUG_CLEAR_MEMORY(Address, Length) \
470 do { \
471 if (DebugClearMemoryEnabled ()) { \
472 DebugClearMemory (Address, Length); \
473 } \
474 } while (FALSE)
475
476
519#if !defined(MDEPKG_NDEBUG)
520 #define CR(Record, TYPE, Field, TestSignature) \
521 (DebugAssertEnabled () && (BASE_CR (Record, TYPE, Field)->Signature != TestSignature)) ? \
522 (TYPE *) (_ASSERT (CR has Bad Signature), Record) : \
523 BASE_CR (Record, TYPE, Field)
524#else
525 #define CR(Record, TYPE, Field, TestSignature) \
526 BASE_CR (Record, TYPE, Field)
527#endif
528
529#endif
char CHAR8
Definition ProcessorBind.h:109
UINT64 UINTN
Definition ProcessorBind.h:118
#define EFIAPI
Definition ProcessorBind.h:172
#define CONST
Definition Base.h:327
#define IN
Definition Base.h:347
#define OUT
Definition Base.h:352
VOID EFIAPI DebugAssert(IN CONST CHAR8 *FileName, IN UINTN LineNumber, IN CONST CHAR8 *Description)
BOOLEAN EFIAPI DebugPrintLevelEnabled(IN CONST UINTN ErrorLevel)
VOID *EFIAPI DebugClearMemory(OUT VOID *Buffer, IN UINTN Length)
VOID EFIAPI DebugPrint(IN UINTN ErrorLevel, IN CONST CHAR8 *Format,...)
BOOLEAN EFIAPI DebugCodeEnabled(VOID)
BOOLEAN EFIAPI DebugClearMemoryEnabled(VOID)
BOOLEAN EFIAPI DebugPrintEnabled(VOID)
BOOLEAN EFIAPI DebugAssertEnabled(VOID)
#define VOID
Definition acefi.h:190
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 LineNumber
Definition acpixf.h:1302
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char * Format
Definition acpixf.h:1304
ACPI_PHYSICAL_ADDRESS ACPI_SIZE Length
Definition acpixf.h:638
unsigned char BOOLEAN
Definition actypes.h:235