]> git.sur5r.net Git - openocd/blob - src/target/xscale.h
SEGFAULT gaffe in dummy register handling
[openocd] / src / target / xscale.h
1 /***************************************************************************
2  *   Copyright (C) 2005 by Dominic Rath                                    *
3  *   Dominic.Rath@gmx.de                                                   *
4  *                                                                         *
5  *   Copyright (C) 2007,2008 Ã˜yvind Harboe                                 *
6  *   oyvind.harboe@zylin.com                                               *
7  *                                                                         *
8  *   This program is free software; you can redistribute it and/or modify  *
9  *   it under the terms of the GNU General Public License as published by  *
10  *   the Free Software Foundation; either version 2 of the License, or     *
11  *   (at your option) any later version.                                   *
12  *                                                                         *
13  *   This program is distributed in the hope that it will be useful,       *
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
16  *   GNU General Public License for more details.                          *
17  *                                                                         *
18  *   You should have received a copy of the GNU General Public License     *
19  *   along with this program; if not, write to the                         *
20  *   Free Software Foundation, Inc.,                                       *
21  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
22  ***************************************************************************/
23 #ifndef XSCALE_H
24 #define XSCALE_H
25
26 #include "target.h"
27 #include "register.h"
28 #include "armv4_5.h"
29 #include "armv4_5_mmu.h"
30 #include "trace.h"
31 #include "image.h"
32
33 #define XSCALE_COMMON_MAGIC 0x58534341
34
35 typedef struct xscale_jtag_s
36 {
37         /* position in JTAG scan chain */
38         int chain_pos;
39
40         /* IR length and instructions */        
41         int ir_length;
42         u32 dbgrx;
43         u32 dbgtx;
44         u32 ldic;
45         u32 dcsr;
46 } xscale_jtag_t;
47
48 enum xscale_debug_reason
49 {
50         XSCALE_DBG_REASON_GENERIC,
51         XSCALE_DBG_REASON_RESET,
52         XSCALE_DBG_REASON_TB_FULL,
53 };
54
55 enum xscale_trace_entry_type
56 {
57         XSCALE_TRACE_MESSAGE = 0x0,
58         XSCALE_TRACE_ADDRESS = 0x1,
59 };
60
61 typedef struct xscale_trace_entry_s
62 {
63         u8 data;
64         enum xscale_trace_entry_type type;
65 } xscale_trace_entry_t;
66
67 typedef struct xscale_trace_data_s
68 {
69         xscale_trace_entry_t *entries;
70         int depth;
71         u32 chkpt0;
72         u32 chkpt1;
73         u32 last_instruction;
74         struct xscale_trace_data_s *next;
75 } xscale_trace_data_t;
76
77 typedef struct xscale_trace_s
78 {
79         trace_status_t capture_status;  /* current state of capture run */
80         image_t *image;                                 /* source for target opcodes */
81         xscale_trace_data_t *data;              /* linked list of collected trace data */
82         int buffer_enabled;                             /* whether trace buffer is enabled */
83         int buffer_fill;                                /* maximum number of trace runs to read (-1 for wrap-around) */
84         int pc_ok;
85         u32 current_pc;
86         armv4_5_state_t core_state;             /* current core state (ARM, Thumb, Jazelle) */
87 } xscale_trace_t;
88
89 typedef struct xscale_common_s
90 {
91         int common_magic;
92         
93         /* XScale registers (CP15, DBG) */
94         reg_cache_t *reg_cache;
95
96         /* pxa250, pxa255, pxa27x, ixp42x, ... */
97         char *variant;
98
99         xscale_jtag_t jtag_info;
100         
101         /* current state of the debug handler */
102         int handler_installed;
103         int handler_running;
104         u32 handler_address;
105         
106         /* target-endian buffers with exception vectors */
107         u32 low_vectors[8];
108         u32 high_vectors[8];
109         
110         /* static low vectors */
111         u8 static_low_vectors_set;      /* bit field with static vectors set by the user */
112         u8 static_high_vectors_set; /* bit field with static vectors set by the user */
113         u32 static_low_vectors[8];
114         u32 static_high_vectors[8];
115
116         /* DCache cleaning */   
117         u32 cache_clean_address;
118         
119         /* whether hold_rst and ext_dbg_break should be set */
120         int hold_rst;
121         int external_debug_break;
122         
123         /* breakpoint / watchpoint handling */
124         int force_hw_bkpts;
125         int dbr_available;
126         int dbr0_used;
127         int dbr1_used;
128         int ibcr_available;
129         int ibcr0_used;
130         int     ibcr1_used;
131         u32 arm_bkpt;
132         u16 thumb_bkpt;
133         
134         u8 vector_catch;
135
136         xscale_trace_t trace;
137         
138         int arch_debug_reason;
139         
140         /* armv4/5 common stuff */
141         armv4_5_common_t armv4_5_common;
142         
143         /* MMU/Caches */
144         armv4_5_mmu_common_t armv4_5_mmu;
145         u32 cp15_control_reg;
146         
147         /* possible future enhancements that go beyond XScale common stuff */
148         void *arch_info;
149         
150         int fast_memory_access;
151 } xscale_common_t;
152
153 typedef struct xscale_reg_s
154 {
155         int dbg_handler_number;
156         target_t *target;
157 } xscale_reg_t;
158
159 enum
160 {
161         XSCALE_MAINID,          /* 0 */
162         XSCALE_CACHETYPE,
163         XSCALE_CTRL,
164         XSCALE_AUXCTRL,
165         XSCALE_TTB,
166         XSCALE_DAC,
167         XSCALE_FSR,
168         XSCALE_FAR,
169         XSCALE_PID,
170         XSCALE_CPACCESS,
171         XSCALE_IBCR0,           /* 10 */
172         XSCALE_IBCR1,
173         XSCALE_DBR0,
174         XSCALE_DBR1,
175         XSCALE_DBCON,
176         XSCALE_TBREG,
177         XSCALE_CHKPT0,
178         XSCALE_CHKPT1,
179         XSCALE_DCSR,
180         XSCALE_TX,
181         XSCALE_RX,                      /* 20 */
182         XSCALE_TXRXCTRL,
183 };
184
185 #define ERROR_XSCALE_NO_TRACE_DATA      (-1500)
186
187 #endif /* XSCALE_H */