d271618dda416cc840a9eba21cd1e939f9485dc3
[reactos.git] / reactos / boot / freeldr / freeldr / include / debug.h
1 /*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 #include <reactos/debug.h>
20
21 #ifndef __DEBUG_H
22 #define __DEBUG_H
23
24 #define DPRINT_NONE 0x00000000 // No debug print
25 #define DPRINT_WARNING 0x00000001 // OR this with DebugPrintMask to enable debugger messages and other misc stuff
26 #define DPRINT_MEMORY 0x00000002 // OR this with DebugPrintMask to enable memory management messages
27 #define DPRINT_FILESYSTEM 0x00000004 // OR this with DebugPrintMask to enable file system messages
28 #define DPRINT_INIFILE 0x00000008 // OR this with DebugPrintMask to enable .ini file messages
29 #define DPRINT_UI 0x00000010 // OR this with DebugPrintMask to enable user interface messages
30 #define DPRINT_DISK 0x00000020 // OR this with DebugPrintMask to enable disk messages
31 #define DPRINT_CACHE 0x00000040 // OR this with DebugPrintMask to enable cache messages
32 #define DPRINT_REGISTRY 0x00000080 // OR this with DebugPrintMask to enable registry messages
33 #define DPRINT_REACTOS 0x00000100 // OR this with DebugPrintMask to enable ReactOS messages
34 #define DPRINT_LINUX 0x00000200 // OR this with DebugPrintMask to enable Linux messages
35 #define DPRINT_HWDETECT 0x00000400 // OR this with DebugPrintMask to enable hardware detection messages
36 #define DPRINT_WINDOWS 0x00000800 // OR this with DebugPrintMask to enable messages from Windows loader
37
38 extern char* g_file;
39 extern int g_line;
40
41 #ifdef DBG
42
43 VOID DbgPrintMask(ULONG Mask, char *format, ...);
44 VOID DebugInit(VOID);
45 ULONG DbgPrint(const char *Format, ...);
46
47 VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length);
48
49 #define DPRINTM g_file=__FILE__;g_line=__LINE__;DbgPrintMask
50 #define BugCheck(_x_) { DbgPrintMask(DPRINT_WARNING, "Fatal Error: %s:%d(%s)\n", __FILE__, __LINE__, __FUNCTION__); DbgPrintMask _x_ ; for (;;); }
51 #define DbgDumpBuffer(_x_, _y_, _z_) DebugDumpBuffer(_x_, _y_, _z_)
52
53 #ifdef __i386__
54
55 // Debugging support functions:
56 //
57 // BREAKPOINT() - Inserts an "int 3" instruction
58 // INSTRUCTION_BREAKPOINTX(x) - Enters exception handler right before instruction at address "x" is executed
59 // MEMORY_READWRITE_BREAKPOINTX(x) - Enters exception handler when a read or write occurs at address "x"
60 // MEMORY_WRITE_BREAKPOINTX(x) - Enters exception handler when a write occurs at address "x"
61 //
62 // You may have as many BREAKPOINT()'s as you like but you may only
63 // have up to four of any of the others.
64 #define BREAKPOINT() __asm__ ("int $3");
65 void INSTRUCTION_BREAKPOINT1(unsigned long addr);
66 void MEMORY_READWRITE_BREAKPOINT1(unsigned long addr);
67 void MEMORY_WRITE_BREAKPOINT1(unsigned long addr);
68 void INSTRUCTION_BREAKPOINT2(unsigned long addr);
69 void MEMORY_READWRITE_BREAKPOINT2(unsigned long addr);
70 void MEMORY_WRITE_BREAKPOINT2(unsigned long addr);
71 void INSTRUCTION_BREAKPOINT3(unsigned long addr);
72 void MEMORY_READWRITE_BREAKPOINT3(unsigned long addr);
73 void MEMORY_WRITE_BREAKPOINT3(unsigned long addr);
74 void INSTRUCTION_BREAKPOINT4(unsigned long addr);
75 void MEMORY_READWRITE_BREAKPOINT4(unsigned long addr);
76 void MEMORY_WRITE_BREAKPOINT4(unsigned long addr);
77
78 #endif // defined __i386__
79
80 #else
81
82 #define DebugInit()
83 #define DPRINTM(_x_, ...)
84 #define BugCheck(_x_)
85 #define DbgDumpBuffer(_x_, _y_, _z_)
86
87 #endif // defined DBG
88
89 #endif // defined __DEBUG_H