1 /* Hey EMACS -*- linux-c -*- */ 2 /* $Id: bkpts.h 2689 2007-11-30 03:58:24Z kevinkofler $ */ 3 4 /* TiEmu - Tiemu Is an EMUlator 5 * 6 * Copyright (c) 2000-2001, Thomas Corvazier, Romain Lievin 7 * Copyright (c) 2001-2003, Romain Lievin 8 * Copyright (c) 2003, Julien Blache 9 * Copyright (c) 2004, Romain Li�vin 10 * Copyright (c) 2005, Romain Li�vin, Kevin Kofler 11 * Copyright (c) 2007, Romain Li�vin 12 * 13 * This program is free software; you can redistribute it and/or modify 14 * it under the terms of the GNU General Public License as published by 15 * the Free Software Foundation; either version 2 of the License, or 16 * (at your option) any later version. 17 * 18 * This program is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License 24 * along with this program; if not, write to the Free Software 25 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 26 */ 27 28 /* 29 Breakpoint definitions 30 */ 31 32 #ifndef __TI68K_BKPTS__ 33 #define __TI68K_BKPTS__ 34 35 #include <stdint.h> 36 37 /* 38 Macros: addresses are 24-bits. We use the MSB to encode 39 bkpt state (enabled/disabled or temporary). This is more 40 efficient than complex structures. 41 */ 42 43 #define BKPT_MASK 0xc0000000 44 45 #define BKPT_ADDR(addr) ((addr) & ~BKPT_MASK) 46 #define BKPT_INFO(addr) ((addr) & BKPT_MASK) 47 48 #define BKPT_ENABLE_BIT 31 49 #define BKPT_TMP_BIT 30 50 51 #define BKPT_ENABLE_MASK (1 << BKPT_ENABLE_BIT) 52 #define BKPT_ENABLE(addr) ((addr) &= ~BKPT_ENABLE_MASK) 53 #define BKPT_DISABLE(addr) ((addr) |= BKPT_ENABLE_MASK) 54 #define BKPT_IS_ENABLED(addr) (!((addr) & BKPT_ENABLE_MASK)) 55 56 #define BKPT_TMP_MASK (1 << BKPT_TMP_BIT) 57 #define BKPT_NOTMP(addr) ((addr) &= ~BKPT_TMP_MASK) 58 #define BKPT_TMP(addr) ((addr) |= BKPT_TMPSK) 59 #define BKPT_IS_TMP(addr) (((addr) & BKPT_TMP_MASK)) 60 61 /* Types */ 62 63 typedef struct 64 { 65 uint32_t val1; 66 uint32_t val2; 67 } ADDR_RANGE; 68 69 typedef struct 70 { 71 uint32_t addr; 72 uint8_t checks; 73 uint8_t states; 74 } ADDR_BIT; 75 76 /* Constants */ 77 78 // Breakpoints mode (ti68k_bkpt_set_[access|access_range]) 79 #define BK_BYTE 1 80 #define BK_WORD 2 81 #define BK_LONG 4 82 #define BK_READ 16 83 #define BK_WRITE 32 84 #define BK_RW (BK_READ | BK_WRITE) 85 86 #define BK_READ_BYTE (BK_READ | BK_BYTE) 87 #define BK_READ_WORD (BK_READ | BK_WORD) 88 #define BK_READ_LONG (BK_READ | BK_LONG) 89 90 #define BK_WRITE_BYTE (BK_WRITE | BK_BYTE) 91 #define BK_WRITE_WORD (BK_WRITE | BK_WORD) 92 #define BK_WRITE_LONG (BK_WRITE | BK_LONG) 93 94 #define BK_RW_BYTE (BK_READ_BYTE | BK_WRITE_BYTE) 95 #define BK_RW_WORD (BK_READ_WORD | BK_WRITE_WORD) 96 #define BK_RW_LONG (BK_READ_LONG | BK_WRITE_LONG) 97 98 // Breakpoints type 99 typedef enum { 100 BK_TYPE_ACCESS=1, BK_TYPE_RANGE, 101 BK_TYPE_CODE, BK_TYPE_EXCEPTION, 102 BK_TYPE_PGMENTRY, BK_TYPE_PROTECT, 103 BK_TYPE_BIT, 104 } Ti68kBkptType; 105 106 // Breakpoints cause (ti68k_bkpt_get_cause()) 107 typedef enum { 108 BK_CAUSE_ACCESS=1, BK_CAUSE_RANGE, BK_CAUSE_ADDRESS, 109 BK_CAUSE_EXCEPTION, BK_CAUSE_PGMENTRY, BK_CAUSE_PROTECT, 110 BK_CAUSE_BIT, 111 } Ti68kBkptCause; 112 113 #define DBG_BREAK 1 // user breakpoint 114 #define DBG_TRACE 2 // trace (T) 115 #define DBG_HWPV 3 // hardware protection violation 116 117 /* Functions */ 118 119 int ti68k_bkpt_add_address(uint32_t address); 120 int ti68k_bkpt_add_access(uint32_t address, int mode); 121 int ti68k_bkpt_add_range(uint32_t min, uint32_t max, int mode); 122 int ti68k_bkpt_add_exception(uint32_t n); 123 int ti68k_bkpt_add_pgmentry(uint16_t handle); 124 int ti68k_bkpt_add_bits(uint32_t address, uint8_t checks, uint8_t states); 125 126 int ti68k_bkpt_del_address(uint32_t address); 127 int ti68k_bkpt_del_access(uint32_t address, int mode); 128 int ti68k_bkpt_del_range(uint32_t min, uint32_t max, int mode); 129 int ti68k_bkpt_del_exception(uint32_t n); 130 int ti68k_bkpt_del_pgmentry(uint16_t handle); 131 int ti68k_bkpt_del_bits(uint32_t address); 132 133 int ti68k_bkpt_set_address(uint32_t address, uint32_t new_address); 134 int ti68k_bkpt_set_access(uint32_t address, int mode, uint32_t new_address); 135 int ti68k_bkpt_set_range(uint32_t min, uint32_t max, int mode, uint32_t new_min, uint32_t new_max); 136 int ti68k_bkpt_set_exception(uint32_t n, uint32_t new_n); 137 int ti68k_bkpt_set_pgmentry(uint16_t handle, uint16_t new_handle); 138 int ti68k_bkpt_set_bits(uint32_t old_address, uint32_t address); 139 int ti68k_bkpt_set_bits_ex(uint32_t old_address, uint32_t address, uint8_t checks, uint8_t states); 140 141 int ti68k_bkpt_get_address(unsigned int idx, uint32_t *address); 142 int ti68k_bkpt_get_access(unsigned int idx, uint32_t *address, int mode); 143 int ti68k_bkpt_get_range(unsigned int idx, uint32_t *min, uint32_t *max, int mode); 144 int ti68k_bkpt_get_exception(unsigned int idx, uint32_t *n); 145 int ti68k_bkpt_get_pgmentry(unsigned int idx, uint16_t *handle); 146 int ti68k_bkpt_get_pgmentry_offset(unsigned int idx, uint16_t *handle, uint16_t *offset); 147 int ti68k_bkpt_get_bits(unsigned int idx, uint32_t *address, uint8_t *checks, uint8_t *states); 148 149 void ti68k_bkpt_clear_address(void); 150 void ti68k_bkpt_clear_access(void); 151 void ti68k_bkpt_clear_range(void); 152 void ti68k_bkpt_clear_exception(void); 153 void ti68k_bkpt_clear_pgmentry(void); 154 void ti68k_bkpt_clear_bits(void); 155 156 void ti68k_bkpt_set_cause(int type, int mode, int id); 157 void ti68k_bkpt_get_cause(int *type, int *id, int *mode); 158 159 160 #endif 161