Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * Copyright (c) 2004, 2008 IBM Corporation |
| 3 | * Copyright (c) 2009 Pattrick Hueper <phueper@hueper.net> |
Martin Roth | a9e1a22 | 2016-01-14 14:15:24 -0700 | [diff] [blame] | 4 | * |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 5 | * All rights reserved. |
Martin Roth | a9e1a22 | 2016-01-14 14:15:24 -0700 | [diff] [blame] | 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions are |
| 9 | * met: |
| 10 | * |
| 11 | * Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * |
| 14 | * Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer |
| 16 | * in the documentation and/or other materials provided with the |
| 17 | * distribution. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 30 | * |
| 31 | * Contributors: |
| 32 | * IBM Corporation - initial implementation |
| 33 | *****************************************************************************/ |
| 34 | #ifndef _BIOSEMU_DEBUG_H_ |
| 35 | #define _BIOSEMU_DEBUG_H_ |
| 36 | |
Denis 'GNUtoo' Carikli | 4cdc5d6 | 2013-05-15 00:19:49 +0200 | [diff] [blame] | 37 | #include <timer.h> |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 38 | #include <types.h> |
| 39 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 40 | #if CONFIG(X86EMU_DEBUG_TIMINGS) |
Denis 'GNUtoo' Carikli | 4cdc5d6 | 2013-05-15 00:19:49 +0200 | [diff] [blame] | 41 | extern struct mono_time zero; |
| 42 | #endif |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 43 | extern u32 debug_flags; |
| 44 | // from x86emu...needed for debugging |
| 45 | extern void x86emu_dump_xregs(void); |
| 46 | |
| 47 | /* printf is not available in coreboot... use printk */ |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 48 | #include <console/console.h> |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 49 | #include "x86emu/x86emu.h" |
Uwe Hermann | 01ce601 | 2010-03-05 10:03:50 +0000 | [diff] [blame] | 50 | #define printf(x...) printk(BIOS_DEBUG, x) |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 51 | |
| 52 | /* PH: empty versions of set/clr_ci |
| 53 | * TODO: remove! */ |
| 54 | static inline void clr_ci(void) {}; |
| 55 | static inline void set_ci(void) {}; |
| 56 | |
Uwe Hermann | 01ce601 | 2010-03-05 10:03:50 +0000 | [diff] [blame] | 57 | /* debug_flags is a binary switch that allows you to select the following items |
| 58 | * to debug. 1=on 0=off. After you decide what you want to debug create the |
| 59 | * binary value, convert to hex and set the option. These options can be |
| 60 | * selected in Kconfig. |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 61 | * |
| 62 | * |-DEBUG_JMP - print info about JMP and RETF opcodes from x86emu |
| 63 | * ||-DEBUG_TRACE_X86EMU - print _all_ opcodes that are executed by x86emu (WARNING: this will produce a LOT of output) |
| 64 | * |||-Currently unused |
| 65 | * ||||-Currently unused |
| 66 | * |||||-Currently unused |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 67 | * ||||||-DEBUG_PNP - Print Plug And Play access made by option rom |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 68 | * |||||||-DEBUG_DISK - Print Disk I/O related messages, currently unused |
| 69 | * ||||||||-DEBUG_PMM - Print messages related to POST Memory Manager (PMM) |
| 70 | * |||||||||-DEBUG_VBE - Print messages related to VESA BIOS Extension (VBE) functions |
| 71 | * ||||||||||-DEBUG_PRINT_INT10 - let INT10 (i.e. character output) calls print messages to Debug output |
| 72 | * |||||||||||-DEBUG_INTR - Print messages related to interrupt handling |
| 73 | * ||||||||||||-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) |
Elyes HAOUAS | fa640a2 | 2016-07-28 21:31:40 +0200 | [diff] [blame] | 74 | * |||||||||||||-DEBUG_MEM - Print memory access made by option ROM (NOTE: this also includes accesses to fetch instructions) |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 75 | * ||||||||||||||-DEBUG_IO - Print I/O access made by option rom |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 76 | * 11000111111111 - Max Binary Value, Debug All (WARNING: - This could run for hours) |
| 77 | */ |
| 78 | |
| 79 | #define DEBUG_IO 0x1 |
| 80 | #define DEBUG_MEM 0x2 |
| 81 | // set this to print messages for certain virtual memory accesses (Interrupt Vectors, ...) |
| 82 | #define DEBUG_CHECK_VMEM_ACCESS 0x4 |
| 83 | #define DEBUG_INTR 0x8 |
| 84 | #define DEBUG_PRINT_INT10 0x10 // set to have the INT10 routine print characters |
| 85 | #define DEBUG_VBE 0x20 |
| 86 | #define DEBUG_PMM 0x40 |
| 87 | #define DEBUG_DISK 0x80 |
| 88 | #define DEBUG_PNP 0x100 |
| 89 | |
| 90 | #define DEBUG_TRACE_X86EMU 0x1000 |
| 91 | // set to enable tracing of JMPs in x86emu |
| 92 | #define DEBUG_JMP 0x2000 |
| 93 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 94 | #if CONFIG(X86EMU_DEBUG) |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 95 | |
| 96 | #define CHECK_DBG(_flag) if (debug_flags & _flag) |
| 97 | |
| 98 | #define DEBUG_PRINTF(_x...) printf(_x); |
| 99 | // prints the CS:IP before the printout, NOTE: actually its CS:IP of the _next_ instruction |
| 100 | // to be executed, since the x86emu advances CS:IP _before_ actually executing an instruction |
Denis 'GNUtoo' Carikli | 4cdc5d6 | 2013-05-15 00:19:49 +0200 | [diff] [blame] | 101 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 102 | #if CONFIG(X86EMU_DEBUG_TIMINGS) |
Denis 'GNUtoo' Carikli | 4cdc5d6 | 2013-05-15 00:19:49 +0200 | [diff] [blame] | 103 | #define DEBUG_PRINTF_CS_IP(_x...) DEBUG_PRINTF("[%08lx]%x:%x ", (current_time_from(&zero)).microseconds, M.x86.R_CS, M.x86.R_IP); DEBUG_PRINTF(_x); |
| 104 | #else |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 105 | #define DEBUG_PRINTF_CS_IP(_x...) DEBUG_PRINTF("%x:%x ", M.x86.R_CS, M.x86.R_IP); DEBUG_PRINTF(_x); |
Denis 'GNUtoo' Carikli | 4cdc5d6 | 2013-05-15 00:19:49 +0200 | [diff] [blame] | 106 | #endif |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 107 | |
| 108 | #define DEBUG_PRINTF_IO(_x...) CHECK_DBG(DEBUG_IO) { DEBUG_PRINTF_CS_IP(_x) } |
| 109 | #define DEBUG_PRINTF_MEM(_x...) CHECK_DBG(DEBUG_MEM) { DEBUG_PRINTF_CS_IP(_x) } |
| 110 | #define DEBUG_PRINTF_INTR(_x...) CHECK_DBG(DEBUG_INTR) { DEBUG_PRINTF_CS_IP(_x) } |
| 111 | #define DEBUG_PRINTF_VBE(_x...) CHECK_DBG(DEBUG_VBE) { DEBUG_PRINTF_CS_IP(_x) } |
| 112 | #define DEBUG_PRINTF_PMM(_x...) CHECK_DBG(DEBUG_PMM) { DEBUG_PRINTF_CS_IP(_x) } |
| 113 | #define DEBUG_PRINTF_DISK(_x...) CHECK_DBG(DEBUG_DISK) { DEBUG_PRINTF_CS_IP(_x) } |
| 114 | #define DEBUG_PRINTF_PNP(_x...) CHECK_DBG(DEBUG_PNP) { DEBUG_PRINTF_CS_IP(_x) } |
| 115 | |
| 116 | #else |
| 117 | |
| 118 | #define CHECK_DBG(_flag) if (0) |
| 119 | |
| 120 | #define DEBUG_PRINTF(_x...) |
| 121 | #define DEBUG_PRINTF_CS_IP(_x...) |
| 122 | |
| 123 | #define DEBUG_PRINTF_IO(_x...) |
| 124 | #define DEBUG_PRINTF_MEM(_x...) |
| 125 | #define DEBUG_PRINTF_INTR(_x...) |
| 126 | #define DEBUG_PRINTF_VBE(_x...) |
| 127 | #define DEBUG_PRINTF_PMM(_x...) |
| 128 | #define DEBUG_PRINTF_DISK(_x...) |
| 129 | #define DEBUG_PRINTF_PNP(_x...) |
| 130 | |
Myles Watson | 8e9234f | 2010-02-19 19:08:11 +0000 | [diff] [blame] | 131 | #endif //DEBUG |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 132 | |
Elyes HAOUAS | b0b0c8c | 2018-07-08 12:33:47 +0200 | [diff] [blame] | 133 | void dump(u8 *addr, u32 len); |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 134 | |
| 135 | #endif |