Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / src / devices / oprom / yabel / debug.h
1 /******************************************************************************
2  * Copyright (c) 2004, 2008 IBM Corporation
3  * Copyright (c) 2009 Pattrick Hueper <phueper@hueper.net>
4  * All rights reserved.
5  * This program and the accompanying materials
6  * are made available under the terms of the BSD License
7  * which accompanies this distribution, and is available at
8  * http://www.opensource.org/licenses/bsd-license.php
9  *
10  * Contributors:
11  *     IBM Corporation - initial implementation
12  *****************************************************************************/
13 #ifndef _BIOSEMU_DEBUG_H_
14 #define _BIOSEMU_DEBUG_H_
15
16 #include <types.h>
17
18 extern u32 debug_flags;
19 // from x86emu...needed for debugging
20 extern void x86emu_dump_xregs(void);
21
22 /* printf is not available in coreboot... use printk */
23 #include <console/console.h>
24 #include "x86emu/x86emu.h"
25 #define printf(x...) printk(BIOS_DEBUG, x)
26
27 /* PH: empty versions of set/clr_ci
28  * TODO: remove! */
29 static inline void clr_ci(void) {};
30 static inline void set_ci(void) {};
31
32 /* debug_flags is a binary switch that allows you to select the following items
33  * to debug. 1=on 0=off. After you decide what you want to debug create the
34  * binary value, convert to hex and set the option. These options can be
35  * selected in Kconfig.
36  *
37  * |-DEBUG_JMP - print info about JMP and RETF opcodes from x86emu
38  * ||-DEBUG_TRACE_X86EMU - print _all_ opcodes that are executed by x86emu (WARNING: this will produce a LOT of output)
39  * |||-Currently unused
40  * ||||-Currently unused
41  * |||||-Currently unused
42  * ||||||-DEBUG_PNP - Print Plug And Play access made by option rom
43  * |||||||-DEBUG_DISK - Print Disk I/O related messages, currently unused
44  * ||||||||-DEBUG_PMM - Print messages related to POST Memory Manager (PMM)
45  * |||||||||-DEBUG_VBE - Print messages related to VESA BIOS Extension (VBE) functions
46  * ||||||||||-DEBUG_PRINT_INT10 - let INT10 (i.e. character output) calls print messages to Debug output
47  * |||||||||||-DEBUG_INTR - Print messages related to interrupt handling
48  * ||||||||||||-DEBUG_CHECK_VMEM_ACCESS - Print messages related to accesse to certain areas of the virtual Memory (e.g. BDA (BIOS Data Area) or Interrupt Vectors)
49  * |||||||||||||-DEBUG_MEM - Print memory access made by option rom (NOTE: this also includes accesses to fetch instructions)
50  * ||||||||||||||-DEBUG_IO - Print I/O access made by option rom
51  * 11000111111111 - Max Binary Value, Debug All (WARNING: - This could run for hours)
52  */
53
54 #define DEBUG_IO 0x1
55 #define DEBUG_MEM 0x2
56 // set this to print messages for certain virtual memory accesses (Interrupt Vectors, ...)
57 #define DEBUG_CHECK_VMEM_ACCESS 0x4
58 #define DEBUG_INTR 0x8
59 #define DEBUG_PRINT_INT10 0x10  // set to have the INT10 routine print characters
60 #define DEBUG_VBE 0x20
61 #define DEBUG_PMM 0x40
62 #define DEBUG_DISK 0x80
63 #define DEBUG_PNP 0x100
64
65 #define DEBUG_TRACE_X86EMU 0x1000
66 // set to enable tracing of JMPs in x86emu
67 #define DEBUG_JMP 0x2000
68
69 #if defined(CONFIG_X86EMU_DEBUG) && CONFIG_X86EMU_DEBUG
70
71 #define CHECK_DBG(_flag) if (debug_flags & _flag)
72
73 #define DEBUG_PRINTF(_x...) printf(_x);
74 // prints the CS:IP before the printout, NOTE: actually its CS:IP of the _next_ instruction
75 // to be executed, since the x86emu advances CS:IP _before_ actually executing an instruction
76 #define DEBUG_PRINTF_CS_IP(_x...) DEBUG_PRINTF("%x:%x ", M.x86.R_CS, M.x86.R_IP); DEBUG_PRINTF(_x);
77
78 #define DEBUG_PRINTF_IO(_x...) CHECK_DBG(DEBUG_IO) { DEBUG_PRINTF_CS_IP(_x) }
79 #define DEBUG_PRINTF_MEM(_x...) CHECK_DBG(DEBUG_MEM) { DEBUG_PRINTF_CS_IP(_x) }
80 #define DEBUG_PRINTF_INTR(_x...) CHECK_DBG(DEBUG_INTR) { DEBUG_PRINTF_CS_IP(_x) }
81 #define DEBUG_PRINTF_VBE(_x...) CHECK_DBG(DEBUG_VBE) { DEBUG_PRINTF_CS_IP(_x) }
82 #define DEBUG_PRINTF_PMM(_x...) CHECK_DBG(DEBUG_PMM) { DEBUG_PRINTF_CS_IP(_x) }
83 #define DEBUG_PRINTF_DISK(_x...) CHECK_DBG(DEBUG_DISK) { DEBUG_PRINTF_CS_IP(_x) }
84 #define DEBUG_PRINTF_PNP(_x...) CHECK_DBG(DEBUG_PNP) { DEBUG_PRINTF_CS_IP(_x) }
85
86 #else
87
88 #define CHECK_DBG(_flag) if (0)
89
90 #define DEBUG_PRINTF(_x...)
91 #define DEBUG_PRINTF_CS_IP(_x...)
92
93 #define DEBUG_PRINTF_IO(_x...)
94 #define DEBUG_PRINTF_MEM(_x...)
95 #define DEBUG_PRINTF_INTR(_x...)
96 #define DEBUG_PRINTF_VBE(_x...)
97 #define DEBUG_PRINTF_PMM(_x...)
98 #define DEBUG_PRINTF_DISK(_x...)
99 #define DEBUG_PRINTF_PNP(_x...)
100
101 #endif                          //DEBUG
102
103 void dump(u8 * addr, u32 len);
104
105 #endif