22#ifndef __DEBUG_LIB_H__
23#define __DEBUG_LIB_H__
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
38#define DEBUG_INIT 0x00000001
39#define DEBUG_WARN 0x00000002
40#define DEBUG_LOAD 0x00000004
41#define DEBUG_FS 0x00000008
42#define DEBUG_POOL 0x00000010
43#define DEBUG_PAGE 0x00000020
44#define DEBUG_INFO 0x00000040
45#define DEBUG_DISPATCH 0x00000080
46#define DEBUG_VARIABLE 0x00000100
47#define DEBUG_BM 0x00000400
48#define DEBUG_BLKIO 0x00001000
49#define DEBUG_NET 0x00004000
50#define DEBUG_UNDI 0x00010000
51#define DEBUG_LOADFILE 0x00020000
52#define DEBUG_EVENT 0x00080000
53#define DEBUG_GCD 0x00100000
54#define DEBUG_CACHE 0x00200000
55#define DEBUG_VERBOSE 0x00400000
57#define DEBUG_ERROR 0x80000000
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
248#define _ASSERT(Expression) DebugAssert (__FILE__, __LINE__, #Expression)
264#if !defined(MDE_CPU_EBC) && (!defined (_MSC_VER) || _MSC_VER > 1400)
265 #define _DEBUG_PRINT(PrintLevel, ...) \
267 if (DebugPrintLevelEnabled (PrintLevel)) { \
268 DebugPrint (PrintLevel, ##__VA_ARGS__); \
271 #define _DEBUG(Expression) _DEBUG_PRINT Expression
273#define _DEBUG(Expression) DebugPrint Expression
288#if !defined(MDEPKG_NDEBUG)
289 #define ASSERT(Expression) \
291 if (DebugAssertEnabled ()) { \
292 if (!(Expression)) { \
293 _ASSERT (Expression); \
294 ANALYZER_UNREACHABLE (); \
299 #define ASSERT(Expression)
314#if !defined(MDEPKG_NDEBUG)
315 #define DEBUG(Expression) \
317 if (DebugPrintEnabled ()) { \
318 _DEBUG (Expression); \
322 #define DEBUG(Expression)
337#if !defined(MDEPKG_NDEBUG)
338 #define ASSERT_EFI_ERROR(StatusParameter) \
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)); \
348 #define ASSERT_EFI_ERROR(StatusParameter)
363#if !defined(MDEPKG_NDEBUG)
364 #define ASSERT_RETURN_ERROR(StatusParameter) \
366 if (DebugAssertEnabled ()) { \
367 if (RETURN_ERROR (StatusParameter)) { \
368 DEBUG ((DEBUG_ERROR, "\nASSERT_RETURN_ERROR (Status = %r)\n", \
370 _ASSERT (!RETURN_ERROR (StatusParameter)); \
375 #define ASSERT_RETURN_ERROR(StatusParameter)
400#if !defined(MDEPKG_NDEBUG)
401 #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) \
403 if (DebugAssertEnabled ()) { \
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); \
411 if (!EFI_ERROR (gBS->HandleProtocol (Handle, (EFI_GUID *)Guid, &Instance))) { \
412 _ASSERT (Guid already installed on Handle); \
418 #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)
430#define DEBUG_CODE_BEGIN() do { if (DebugCodeEnabled ()) { UINT8 __DebugCodeLocal
442#define DEBUG_CODE_END() __DebugCodeLocal = 0; __DebugCodeLocal++; } } while (FALSE)
453#define DEBUG_CODE(Expression) \
454 DEBUG_CODE_BEGIN (); \
469#define DEBUG_CLEAR_MEMORY(Address, Length) \
471 if (DebugClearMemoryEnabled ()) { \
472 DebugClearMemory (Address, Length); \
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)
525 #define CR(Record, TYPE, Field, TestSignature) \
526 BASE_CR (Record, TYPE, Field)
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