2
2
* Copyright (C) 2005 by Dominic Rath *
3
3
* Dominic.Rath@gmx.de *
5
* Copyright (C) 2007,2008 �yvind Harboe *
5
* Copyright (C) 2007,2008,2009 Øyvind Harboe *
6
6
* oyvind.harboe@zylin.com *
8
8
* Copyright (C) 2008 by Spencer Oliver *
43
static int embeddedice_reg_arch_info[] =
46
0x8, 0x9, 0xa, 0xb, 0xc, 0xd,
47
0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
51
static char* embeddedice_reg_list[] =
63
"watch 0 control value",
64
"watch 0 control mask",
70
"watch 1 control value",
71
"watch 1 control mask",
45
* From: ARM9E-S TRM, DDI 0165, table C-4 (and similar, for other cores)
55
/* width is assigned based on EICE version */
58
.name = "debug_status",
60
/* width is assigned based on EICE version */
72
[EICE_W0_ADDR_VALUE] = {
73
.name = "watch_0_addr_value",
77
[EICE_W0_ADDR_MASK] = {
78
.name = "watch_0_addr_mask",
82
[EICE_W0_DATA_VALUE ] = {
83
.name = "watch_0_data_value",
87
[EICE_W0_DATA_MASK] = {
88
.name = "watch_0_data_mask",
92
[EICE_W0_CONTROL_VALUE] = {
93
.name = "watch_0_control_value",
97
[EICE_W0_CONTROL_MASK] = {
98
.name = "watch_0_control_mask",
102
[EICE_W1_ADDR_VALUE] = {
103
.name = "watch_1_addr_value",
107
[EICE_W1_ADDR_MASK] = {
108
.name = "watch_1_addr_mask",
112
[EICE_W1_DATA_VALUE] = {
113
.name = "watch_1_data_value",
117
[EICE_W1_DATA_MASK] = {
118
.name = "watch_1_data_mask",
122
[EICE_W1_CONTROL_VALUE] = {
123
.name = "watch_1_control_value",
127
[EICE_W1_CONTROL_MASK] = {
128
.name = "watch_1_control_mask",
132
/* vector_catch isn't always present */
134
.name = "vector_catch",
76
141
static int embeddedice_reg_arch_type = -1;
84
149
reg_t *reg_list = NULL;
85
150
embeddedice_reg_t *arch_info = NULL;
86
151
arm_jtag_t *jtag_info = &arm7_9->jtag_info;
152
int num_regs = ARRAY_SIZE(eice_regs);
89
154
int eice_version = 0;
91
156
/* register a register arch-type for EmbeddedICE registers only once */
92
157
if (embeddedice_reg_arch_type == -1)
93
embeddedice_reg_arch_type = register_reg_arch_type(embeddedice_get_reg, embeddedice_set_reg_w_exec);
158
embeddedice_reg_arch_type = register_reg_arch_type(
159
embeddedice_get_reg, embeddedice_set_reg_w_exec);
95
if (arm7_9->has_vector_catch)
161
/* vector_catch isn't always present */
162
if (!arm7_9->has_vector_catch)
100
165
/* the actual registers are kept in two arrays */
101
166
reg_list = calloc(num_regs, sizeof(reg_t));
110
175
/* set up registers */
111
176
for (i = 0; i < num_regs; i++)
113
reg_list[i].name = embeddedice_reg_list[i];
114
reg_list[i].size = 32;
178
reg_list[i].name = eice_regs[i].name;
179
reg_list[i].size = eice_regs[i].width;
115
180
reg_list[i].dirty = 0;
116
181
reg_list[i].valid = 0;
117
182
reg_list[i].bitfield_desc = NULL;
119
184
reg_list[i].value = calloc(1, 4);
120
185
reg_list[i].arch_info = &arch_info[i];
121
186
reg_list[i].arch_type = embeddedice_reg_arch_type;
122
arch_info[i].addr = embeddedice_reg_arch_info[i];
187
arch_info[i].addr = eice_regs[i].addr;
123
188
arch_info[i].jtag_info = jtag_info;
132
197
free(reg_list[i].value);
139
205
eice_version = buf_get_u32(reg_list[EICE_COMMS_CTRL].value, 28, 4);
206
LOG_INFO("Embedded ICE version %d", eice_version);
141
208
switch (eice_version)
211
/* ARM7TDMI r3, ARM7TDMI-S r3
213
* REVISIT docs say ARM7TDMI-S r4 uses version 1 but
214
* that it has 6-bit CTRL and 5-bit STAT... doc bug?
215
* ARM7TDMI r4 docs say EICE v4.
144
217
reg_list[EICE_DBG_CTRL].size = 3;
145
218
reg_list[EICE_DBG_STAT].size = 5;
148
222
reg_list[EICE_DBG_CTRL].size = 4;
149
223
reg_list[EICE_DBG_STAT].size = 5;
150
224
arm7_9->has_single_step = 1;
153
LOG_ERROR("EmbeddedICE version 3 detected, EmbeddedICE handling might be broken");
227
LOG_ERROR("EmbeddedICE v%d handling might be broken",
154
229
reg_list[EICE_DBG_CTRL].size = 6;
155
230
reg_list[EICE_DBG_STAT].size = 5;
156
231
arm7_9->has_single_step = 1;
157
232
arm7_9->has_monitor_mode = 1;
160
236
reg_list[EICE_DBG_CTRL].size = 6;
161
237
reg_list[EICE_DBG_STAT].size = 5;
162
238
arm7_9->has_monitor_mode = 1;
165
242
reg_list[EICE_DBG_CTRL].size = 6;
166
243
reg_list[EICE_DBG_STAT].size = 5;
167
244
arm7_9->has_single_step = 1;
168
245
arm7_9->has_monitor_mode = 1;
248
/* ARM7EJ-S, ARM9E-S rev 2, ARM9EJ-S */
171
249
reg_list[EICE_DBG_CTRL].size = 6;
172
250
reg_list[EICE_DBG_STAT].size = 10;
251
/* DBG_STAT has MOE bits */
173
252
arm7_9->has_monitor_mode = 1;
176
LOG_WARNING("EmbeddedICE version 7 detected, EmbeddedICE handling might be broken");
255
LOG_ERROR("EmbeddedICE v%d handling might be broken",
177
257
reg_list[EICE_DBG_CTRL].size = 6;
178
258
reg_list[EICE_DBG_STAT].size = 5;
179
259
arm7_9->has_monitor_mode = 1;
184
264
* in some unusual bits. Let feroceon.c validate it
185
265
* and do the appropriate setup itself.
187
if (strcmp(target_get_name(target), "feroceon") == 0)
267
if (strcmp(target_get_name(target), "feroceon") == 0 ||
268
strcmp(target_get_name(target), "dragonite") == 0)
189
270
LOG_ERROR("unknown EmbeddedICE version (comms ctrl: 0x%8.8" PRIx32 ")", buf_get_u32(reg_list[EICE_COMMS_CTRL].value, 0, 32));
276
357
* EICE_COMMS_DATA would read the register twice
277
358
* reading the control register is safe
279
buf_set_u32(fields[1].out_value, 0, 5, embeddedice_reg_arch_info[EICE_COMMS_CTRL]);
360
buf_set_u32(fields[1].out_value, 0, 5, eice_regs[EICE_COMMS_CTRL].addr);
281
362
jtag_add_dr_scan_check(3, fields, jtag_get_end_state());
305
386
fields[1].tap = jtag_info->tap;
306
387
fields[1].num_bits = 5;
307
388
fields[1].out_value = field1_out;
308
buf_set_u32(fields[1].out_value, 0, 5, embeddedice_reg_arch_info[EICE_COMMS_DATA]);
389
buf_set_u32(fields[1].out_value, 0, 5, eice_regs[EICE_COMMS_DATA].addr);
309
390
fields[1].in_value = NULL;
311
392
fields[2].tap = jtag_info->tap;
322
403
* to avoid reading additional data from the DCC data reg
325
buf_set_u32(fields[1].out_value, 0, 5, embeddedice_reg_arch_info[EICE_COMMS_CTRL]);
406
buf_set_u32(fields[1].out_value, 0, 5,
407
eice_regs[EICE_COMMS_CTRL].addr);
327
409
fields[0].in_value = (uint8_t *)data;
328
410
jtag_add_dr_scan(3, fields, jtag_get_end_state());
407
489
fields[1].tap = jtag_info->tap;
408
490
fields[1].num_bits = 5;
409
491
fields[1].out_value = field1_out;
410
buf_set_u32(fields[1].out_value, 0, 5, embeddedice_reg_arch_info[EICE_COMMS_DATA]);
492
buf_set_u32(fields[1].out_value, 0, 5, eice_regs[EICE_COMMS_DATA].addr);
411
493
fields[1].in_value = NULL;
413
495
fields[2].tap = jtag_info->tap;
462
544
fields[1].tap = jtag_info->tap;
463
545
fields[1].num_bits = 5;
464
546
fields[1].out_value = field1_out;
465
buf_set_u32(fields[1].out_value, 0, 5, embeddedice_reg_arch_info[EICE_COMMS_CTRL]);
547
buf_set_u32(fields[1].out_value, 0, 5, eice_regs[EICE_COMMS_DATA].addr);
466
548
fields[1].in_value = NULL;
468
550
fields[2].tap = jtag_info->tap;