1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
32 #define _DEBUG_INSTRUCTION_EXECUTION_
36 int arm920t_register_commands(struct command_context_s
*cmd_ctx
);
38 int arm920t_handle_cp15_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
39 int arm920t_handle_cp15i_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
40 int arm920t_handle_virt2phys_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
41 int arm920t_handle_cache_info_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
42 int arm920t_handle_md_phys_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
43 int arm920t_handle_mw_phys_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
45 int arm920t_handle_read_cache_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
46 int arm920t_handle_read_mmu_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
48 /* forward declarations */
49 int arm920t_target_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
, struct target_s
*target
);
50 int arm920t_init_target(struct command_context_s
*cmd_ctx
, struct target_s
*target
);
52 int arm920t_arch_state(struct target_s
*target
);
53 int arm920t_read_memory(struct target_s
*target
, u32 address
, u32 size
, u32 count
, u8
*buffer
);
54 int arm920t_write_memory(struct target_s
*target
, u32 address
, u32 size
, u32 count
, u8
*buffer
);
55 int arm920t_soft_reset_halt(struct target_s
*target
);
57 #define ARM920T_CP15_PHYS_ADDR(x, y, z) ((x << 5) | (y << 1) << (z))
59 target_type_t arm920t_target
=
64 .arch_state
= arm920t_arch_state
,
66 .target_request_data
= arm7_9_target_request_data
,
69 .resume
= arm7_9_resume
,
72 .assert_reset
= arm7_9_assert_reset
,
73 .deassert_reset
= arm7_9_deassert_reset
,
74 .soft_reset_halt
= arm920t_soft_reset_halt
,
76 .get_gdb_reg_list
= armv4_5_get_gdb_reg_list
,
78 .read_memory
= arm920t_read_memory
,
79 .write_memory
= arm920t_write_memory
,
80 .bulk_write_memory
= arm7_9_bulk_write_memory
,
81 .checksum_memory
= arm7_9_checksum_memory
,
83 .run_algorithm
= armv4_5_run_algorithm
,
85 .add_breakpoint
= arm7_9_add_breakpoint
,
86 .remove_breakpoint
= arm7_9_remove_breakpoint
,
87 .add_watchpoint
= arm7_9_add_watchpoint
,
88 .remove_watchpoint
= arm7_9_remove_watchpoint
,
90 .register_commands
= arm920t_register_commands
,
91 .target_command
= arm920t_target_command
,
92 .init_target
= arm920t_init_target
,
93 .examine
= arm9tdmi_examine
,
97 int arm920t_read_cp15_physical(target_t
*target
, int reg_addr
, u32
*value
)
99 armv4_5_common_t
*armv4_5
= target
->arch_info
;
100 arm7_9_common_t
*arm7_9
= armv4_5
->arch_info
;
101 arm_jtag_t
*jtag_info
= &arm7_9
->jtag_info
;
102 scan_field_t fields
[4];
103 u8 access_type_buf
= 1;
104 u8 reg_addr_buf
= reg_addr
& 0x3f;
107 jtag_add_end_state(TAP_RTI
);
108 arm_jtag_scann(jtag_info
, 0xf);
109 arm_jtag_set_instr(jtag_info
, jtag_info
->intest_instr
, NULL
);
111 fields
[0].device
= jtag_info
->chain_pos
;
112 fields
[0].num_bits
= 1;
113 fields
[0].out_value
= &access_type_buf
;
114 fields
[0].out_mask
= NULL
;
115 fields
[0].in_value
= NULL
;
116 fields
[0].in_check_value
= NULL
;
117 fields
[0].in_check_mask
= NULL
;
118 fields
[0].in_handler
= NULL
;
119 fields
[0].in_handler_priv
= NULL
;
121 fields
[1].device
= jtag_info
->chain_pos
;
122 fields
[1].num_bits
= 32;
123 fields
[1].out_value
= NULL
;
124 fields
[1].out_mask
= NULL
;
125 fields
[1].in_value
= NULL
;
126 fields
[1].in_check_value
= NULL
;
127 fields
[1].in_check_mask
= NULL
;
128 fields
[1].in_handler
= NULL
;
129 fields
[1].in_handler_priv
= NULL
;
131 fields
[2].device
= jtag_info
->chain_pos
;
132 fields
[2].num_bits
= 6;
133 fields
[2].out_value
= ®_addr_buf
;
134 fields
[2].out_mask
= NULL
;
135 fields
[2].in_value
= NULL
;
136 fields
[2].in_check_value
= NULL
;
137 fields
[2].in_check_mask
= NULL
;
138 fields
[2].in_handler
= NULL
;
139 fields
[2].in_handler_priv
= NULL
;
141 fields
[3].device
= jtag_info
->chain_pos
;
142 fields
[3].num_bits
= 1;
143 fields
[3].out_value
= &nr_w_buf
;
144 fields
[3].out_mask
= NULL
;
145 fields
[3].in_value
= NULL
;
146 fields
[3].in_check_value
= NULL
;
147 fields
[3].in_check_mask
= NULL
;
148 fields
[3].in_handler
= NULL
;
149 fields
[3].in_handler_priv
= NULL
;
151 jtag_add_dr_scan(4, fields
, -1);
153 fields
[1].in_handler_priv
= value
;
154 fields
[1].in_handler
= arm_jtag_buf_to_u32
;
156 jtag_add_dr_scan(4, fields
, -1);
158 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
159 jtag_execute_queue();
160 LOG_DEBUG("addr: 0x%x value: %8.8x", reg_addr
, *value
);
166 int arm920t_write_cp15_physical(target_t
*target
, int reg_addr
, u32 value
)
168 armv4_5_common_t
*armv4_5
= target
->arch_info
;
169 arm7_9_common_t
*arm7_9
= armv4_5
->arch_info
;
170 arm_jtag_t
*jtag_info
= &arm7_9
->jtag_info
;
171 scan_field_t fields
[4];
172 u8 access_type_buf
= 1;
173 u8 reg_addr_buf
= reg_addr
& 0x3f;
177 buf_set_u32(value_buf
, 0, 32, value
);
179 jtag_add_end_state(TAP_RTI
);
180 arm_jtag_scann(jtag_info
, 0xf);
181 arm_jtag_set_instr(jtag_info
, jtag_info
->intest_instr
, NULL
);
183 fields
[0].device
= jtag_info
->chain_pos
;
184 fields
[0].num_bits
= 1;
185 fields
[0].out_value
= &access_type_buf
;
186 fields
[0].out_mask
= NULL
;
187 fields
[0].in_value
= NULL
;
188 fields
[0].in_check_value
= NULL
;
189 fields
[0].in_check_mask
= NULL
;
190 fields
[0].in_handler
= NULL
;
191 fields
[0].in_handler_priv
= NULL
;
193 fields
[1].device
= jtag_info
->chain_pos
;
194 fields
[1].num_bits
= 32;
195 fields
[1].out_value
= value_buf
;
196 fields
[1].out_mask
= NULL
;
197 fields
[1].in_value
= NULL
;
198 fields
[1].in_check_value
= NULL
;
199 fields
[1].in_check_mask
= NULL
;
200 fields
[1].in_handler
= NULL
;
201 fields
[1].in_handler_priv
= NULL
;
203 fields
[2].device
= jtag_info
->chain_pos
;
204 fields
[2].num_bits
= 6;
205 fields
[2].out_value
= ®_addr_buf
;
206 fields
[2].out_mask
= NULL
;
207 fields
[2].in_value
= NULL
;
208 fields
[2].in_check_value
= NULL
;
209 fields
[2].in_check_mask
= NULL
;
210 fields
[2].in_handler
= NULL
;
211 fields
[2].in_handler_priv
= NULL
;
213 fields
[3].device
= jtag_info
->chain_pos
;
214 fields
[3].num_bits
= 1;
215 fields
[3].out_value
= &nr_w_buf
;
216 fields
[3].out_mask
= NULL
;
217 fields
[3].in_value
= NULL
;
218 fields
[3].in_check_value
= NULL
;
219 fields
[3].in_check_mask
= NULL
;
220 fields
[3].in_handler
= NULL
;
221 fields
[3].in_handler_priv
= NULL
;
223 jtag_add_dr_scan(4, fields
, -1);
225 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
226 LOG_DEBUG("addr: 0x%x value: %8.8x", reg_addr
, value
);
232 int arm920t_execute_cp15(target_t
*target
, u32 cp15_opcode
, u32 arm_opcode
)
234 armv4_5_common_t
*armv4_5
= target
->arch_info
;
235 arm7_9_common_t
*arm7_9
= armv4_5
->arch_info
;
236 arm_jtag_t
*jtag_info
= &arm7_9
->jtag_info
;
237 scan_field_t fields
[4];
238 u8 access_type_buf
= 0; /* interpreted access */
239 u8 reg_addr_buf
= 0x0;
241 u8 cp15_opcode_buf
[4];
243 jtag_add_end_state(TAP_RTI
);
244 arm_jtag_scann(jtag_info
, 0xf);
245 arm_jtag_set_instr(jtag_info
, jtag_info
->intest_instr
, NULL
);
247 buf_set_u32(cp15_opcode_buf
, 0, 32, cp15_opcode
);
249 fields
[0].device
= jtag_info
->chain_pos
;
250 fields
[0].num_bits
= 1;
251 fields
[0].out_value
= &access_type_buf
;
252 fields
[0].out_mask
= NULL
;
253 fields
[0].in_value
= NULL
;
254 fields
[0].in_check_value
= NULL
;
255 fields
[0].in_check_mask
= NULL
;
256 fields
[0].in_handler
= NULL
;
257 fields
[0].in_handler_priv
= NULL
;
259 fields
[1].device
= jtag_info
->chain_pos
;
260 fields
[1].num_bits
= 32;
261 fields
[1].out_value
= cp15_opcode_buf
;
262 fields
[1].out_mask
= NULL
;
263 fields
[1].in_value
= NULL
;
264 fields
[1].in_check_value
= NULL
;
265 fields
[1].in_check_mask
= NULL
;
266 fields
[1].in_handler
= NULL
;
267 fields
[1].in_handler_priv
= NULL
;
269 fields
[2].device
= jtag_info
->chain_pos
;
270 fields
[2].num_bits
= 6;
271 fields
[2].out_value
= ®_addr_buf
;
272 fields
[2].out_mask
= NULL
;
273 fields
[2].in_value
= NULL
;
274 fields
[2].in_check_value
= NULL
;
275 fields
[2].in_check_mask
= NULL
;
276 fields
[2].in_handler
= NULL
;
277 fields
[2].in_handler_priv
= NULL
;
279 fields
[3].device
= jtag_info
->chain_pos
;
280 fields
[3].num_bits
= 1;
281 fields
[3].out_value
= &nr_w_buf
;
282 fields
[3].out_mask
= NULL
;
283 fields
[3].in_value
= NULL
;
284 fields
[3].in_check_value
= NULL
;
285 fields
[3].in_check_mask
= NULL
;
286 fields
[3].in_handler
= NULL
;
287 fields
[3].in_handler_priv
= NULL
;
289 jtag_add_dr_scan(4, fields
, -1);
291 arm9tdmi_clock_out(jtag_info
, arm_opcode
, 0, NULL
, 0);
292 arm9tdmi_clock_out(jtag_info
, ARMV4_5_NOP
, 0, NULL
, 1);
293 arm7_9_execute_sys_speed(target
);
295 if (jtag_execute_queue() != ERROR_OK
)
297 LOG_ERROR("failed executing JTAG queue, exiting");
304 int arm920t_read_cp15_interpreted(target_t
*target
, u32 cp15_opcode
, u32 address
, u32
*value
)
306 armv4_5_common_t
*armv4_5
= target
->arch_info
;
311 /* load address into R1 */
313 arm9tdmi_write_core_regs(target
, 0x2, regs
);
315 /* read-modify-write CP15 test state register
316 * to enable interpreted access mode */
317 arm920t_read_cp15_physical(target
, 0x1e, &cp15c15
);
318 jtag_execute_queue();
319 cp15c15
|= 1; /* set interpret mode */
320 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
322 /* execute CP15 instruction and ARM load (reading from coprocessor) */
323 arm920t_execute_cp15(target
, cp15_opcode
, ARMV4_5_LDR(0, 1));
325 /* disable interpreted access mode */
326 cp15c15
&= ~1U; /* clear interpret mode */
327 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
329 /* retrieve value from R0 */
331 arm9tdmi_read_core_regs(target
, 0x1, regs_p
);
332 jtag_execute_queue();
334 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
335 LOG_DEBUG("cp15_opcode: %8.8x, address: %8.8x, value: %8.8x", cp15_opcode
, address
, *value
);
338 if (armv4_5_mode_to_number(armv4_5
->core_mode
)==-1)
341 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 0).dirty
= 1;
342 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 1).dirty
= 1;
347 int arm920t_write_cp15_interpreted(target_t
*target
, u32 cp15_opcode
, u32 value
, u32 address
)
350 armv4_5_common_t
*armv4_5
= target
->arch_info
;
353 /* load value, address into R0, R1 */
356 arm9tdmi_write_core_regs(target
, 0x3, regs
);
358 /* read-modify-write CP15 test state register
359 * to enable interpreted access mode */
360 arm920t_read_cp15_physical(target
, 0x1e, &cp15c15
);
361 jtag_execute_queue();
362 cp15c15
|= 1; /* set interpret mode */
363 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
365 /* execute CP15 instruction and ARM store (writing to coprocessor) */
366 arm920t_execute_cp15(target
, cp15_opcode
, ARMV4_5_STR(0, 1));
368 /* disable interpreted access mode */
369 cp15c15
&= ~1U; /* set interpret mode */
370 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
372 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
373 LOG_DEBUG("cp15_opcode: %8.8x, value: %8.8x, address: %8.8x", cp15_opcode
, value
, address
);
376 if (armv4_5_mode_to_number(armv4_5
->core_mode
)==-1)
379 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 0).dirty
= 1;
380 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 1).dirty
= 1;
385 u32
arm920t_get_ttb(target_t
*target
)
390 if ((retval
= arm920t_read_cp15_interpreted(target
, 0xeebf0f51, 0x0, &ttb
)) != ERROR_OK
)
396 void arm920t_disable_mmu_caches(target_t
*target
, int mmu
, int d_u_cache
, int i_cache
)
400 /* read cp15 control register */
401 arm920t_read_cp15_physical(target
, 0x2, &cp15_control
);
402 jtag_execute_queue();
405 cp15_control
&= ~0x1U
;
408 cp15_control
&= ~0x4U
;
411 cp15_control
&= ~0x1000U
;
413 arm920t_write_cp15_physical(target
, 0x2, cp15_control
);
416 void arm920t_enable_mmu_caches(target_t
*target
, int mmu
, int d_u_cache
, int i_cache
)
420 /* read cp15 control register */
421 arm920t_read_cp15_physical(target
, 0x2, &cp15_control
);
422 jtag_execute_queue();
425 cp15_control
|= 0x1U
;
428 cp15_control
|= 0x4U
;
431 cp15_control
|= 0x1000U
;
433 arm920t_write_cp15_physical(target
, 0x2, cp15_control
);
436 void arm920t_post_debug_entry(target_t
*target
)
439 armv4_5_common_t
*armv4_5
= target
->arch_info
;
440 arm7_9_common_t
*arm7_9
= armv4_5
->arch_info
;
441 arm9tdmi_common_t
*arm9tdmi
= arm7_9
->arch_info
;
442 arm920t_common_t
*arm920t
= arm9tdmi
->arch_info
;
444 /* examine cp15 control reg */
445 arm920t_read_cp15_physical(target
, 0x2, &arm920t
->cp15_control_reg
);
446 jtag_execute_queue();
447 LOG_DEBUG("cp15_control_reg: %8.8x", arm920t
->cp15_control_reg
);
449 if (arm920t
->armv4_5_mmu
.armv4_5_cache
.ctype
== -1)
452 /* identify caches */
453 arm920t_read_cp15_physical(target
, 0x1, &cache_type_reg
);
454 jtag_execute_queue();
455 armv4_5_identify_cache(cache_type_reg
, &arm920t
->armv4_5_mmu
.armv4_5_cache
);
458 arm920t
->armv4_5_mmu
.mmu_enabled
= (arm920t
->cp15_control_reg
& 0x1U
) ? 1 : 0;
459 arm920t
->armv4_5_mmu
.armv4_5_cache
.d_u_cache_enabled
= (arm920t
->cp15_control_reg
& 0x4U
) ? 1 : 0;
460 arm920t
->armv4_5_mmu
.armv4_5_cache
.i_cache_enabled
= (arm920t
->cp15_control_reg
& 0x1000U
) ? 1 : 0;
462 /* save i/d fault status and address register */
463 arm920t_read_cp15_interpreted(target
, 0xee150f10, 0x0, &arm920t
->d_fsr
);
464 arm920t_read_cp15_interpreted(target
, 0xee150f30, 0x0, &arm920t
->i_fsr
);
465 arm920t_read_cp15_interpreted(target
, 0xee160f10, 0x0, &arm920t
->d_far
);
466 arm920t_read_cp15_interpreted(target
, 0xee160f30, 0x0, &arm920t
->i_far
);
468 LOG_DEBUG("D FSR: 0x%8.8x, D FAR: 0x%8.8x, I FSR: 0x%8.8x, I FAR: 0x%8.8x",
469 arm920t
->d_fsr
, arm920t
->d_far
, arm920t
->i_fsr
, arm920t
->i_far
);
471 if (arm920t
->preserve_cache
)
473 /* read-modify-write CP15 test state register
474 * to disable I/D-cache linefills */
475 arm920t_read_cp15_physical(target
, 0x1e, &cp15c15
);
476 jtag_execute_queue();
478 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
482 void arm920t_pre_restore_context(target_t
*target
)
485 armv4_5_common_t
*armv4_5
= target
->arch_info
;
486 arm7_9_common_t
*arm7_9
= armv4_5
->arch_info
;
487 arm9tdmi_common_t
*arm9tdmi
= arm7_9
->arch_info
;
488 arm920t_common_t
*arm920t
= arm9tdmi
->arch_info
;
490 /* restore i/d fault status and address register */
491 arm920t_write_cp15_interpreted(target
, 0xee050f10, arm920t
->d_fsr
, 0x0);
492 arm920t_write_cp15_interpreted(target
, 0xee050f30, arm920t
->i_fsr
, 0x0);
493 arm920t_write_cp15_interpreted(target
, 0xee060f10, arm920t
->d_far
, 0x0);
494 arm920t_write_cp15_interpreted(target
, 0xee060f30, arm920t
->i_far
, 0x0);
496 /* read-modify-write CP15 test state register
497 * to reenable I/D-cache linefills */
498 if (arm920t
->preserve_cache
)
500 arm920t_read_cp15_physical(target
, 0x1e, &cp15c15
);
501 jtag_execute_queue();
503 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
507 int arm920t_get_arch_pointers(target_t
*target
, armv4_5_common_t
**armv4_5_p
, arm7_9_common_t
**arm7_9_p
, arm9tdmi_common_t
**arm9tdmi_p
, arm920t_common_t
**arm920t_p
)
509 armv4_5_common_t
*armv4_5
= target
->arch_info
;
510 arm7_9_common_t
*arm7_9
;
511 arm9tdmi_common_t
*arm9tdmi
;
512 arm920t_common_t
*arm920t
;
514 if (armv4_5
->common_magic
!= ARMV4_5_COMMON_MAGIC
)
519 arm7_9
= armv4_5
->arch_info
;
520 if (arm7_9
->common_magic
!= ARM7_9_COMMON_MAGIC
)
525 arm9tdmi
= arm7_9
->arch_info
;
526 if (arm9tdmi
->common_magic
!= ARM9TDMI_COMMON_MAGIC
)
531 arm920t
= arm9tdmi
->arch_info
;
532 if (arm920t
->common_magic
!= ARM920T_COMMON_MAGIC
)
537 *armv4_5_p
= armv4_5
;
539 *arm9tdmi_p
= arm9tdmi
;
540 *arm920t_p
= arm920t
;
545 int arm920t_arch_state(struct target_s
*target
)
547 armv4_5_common_t
*armv4_5
= target
->arch_info
;
548 arm7_9_common_t
*arm7_9
= armv4_5
->arch_info
;
549 arm9tdmi_common_t
*arm9tdmi
= arm7_9
->arch_info
;
550 arm920t_common_t
*arm920t
= arm9tdmi
->arch_info
;
554 "disabled", "enabled"
557 if (armv4_5
->common_magic
!= ARMV4_5_COMMON_MAGIC
)
559 LOG_ERROR("BUG: called for a non-ARMv4/5 target");
563 LOG_USER( "target halted in %s state due to %s, current mode: %s\n"
564 "cpsr: 0x%8.8x pc: 0x%8.8x\n"
565 "MMU: %s, D-Cache: %s, I-Cache: %s",
566 armv4_5_state_strings
[armv4_5
->core_state
],
567 target_debug_reason_strings
[target
->debug_reason
],
568 armv4_5_mode_strings
[armv4_5_mode_to_number(armv4_5
->core_mode
)],
569 buf_get_u32(armv4_5
->core_cache
->reg_list
[ARMV4_5_CPSR
].value
, 0, 32),
570 buf_get_u32(armv4_5
->core_cache
->reg_list
[15].value
, 0, 32),
571 state
[arm920t
->armv4_5_mmu
.mmu_enabled
],
572 state
[arm920t
->armv4_5_mmu
.armv4_5_cache
.d_u_cache_enabled
],
573 state
[arm920t
->armv4_5_mmu
.armv4_5_cache
.i_cache_enabled
]);
578 int arm920t_read_memory(struct target_s
*target
, u32 address
, u32 size
, u32 count
, u8
*buffer
)
582 retval
= arm7_9_read_memory(target
, address
, size
, count
, buffer
);
587 int arm920t_write_memory(struct target_s
*target
, u32 address
, u32 size
, u32 count
, u8
*buffer
)
590 armv4_5_common_t
*armv4_5
= target
->arch_info
;
591 arm7_9_common_t
*arm7_9
= armv4_5
->arch_info
;
592 arm9tdmi_common_t
*arm9tdmi
= arm7_9
->arch_info
;
593 arm920t_common_t
*arm920t
= arm9tdmi
->arch_info
;
595 if ((retval
= arm7_9_write_memory(target
, address
, size
, count
, buffer
)) != ERROR_OK
)
598 if (((size
== 4) || (size
== 2)) && (count
== 1))
600 if (arm920t
->armv4_5_mmu
.armv4_5_cache
.d_u_cache_enabled
)
602 LOG_DEBUG("D-Cache enabled, writing through to main memory");
606 pa
= armv4_5_mmu_translate_va(target
, &arm920t
->armv4_5_mmu
, address
, &type
, &cb
, &domain
, &ap
);
609 /* cacheable & bufferable means write-back region */
611 armv4_5_mmu_write_physical(target
, &arm920t
->armv4_5_mmu
, pa
, size
, count
, buffer
);
614 if (arm920t
->armv4_5_mmu
.armv4_5_cache
.i_cache_enabled
)
616 LOG_DEBUG("I-Cache enabled, invalidating affected I-Cache line");
617 arm920t_write_cp15_interpreted(target
, 0xee070f35, 0x0, address
);
624 int arm920t_soft_reset_halt(struct target_s
*target
)
626 armv4_5_common_t
*armv4_5
= target
->arch_info
;
627 arm7_9_common_t
*arm7_9
= armv4_5
->arch_info
;
628 arm9tdmi_common_t
*arm9tdmi
= arm7_9
->arch_info
;
629 arm920t_common_t
*arm920t
= arm9tdmi
->arch_info
;
630 reg_t
*dbg_stat
= &arm7_9
->eice_cache
->reg_list
[EICE_DBG_STAT
];
637 if (buf_get_u32(dbg_stat
->value
, EICE_DBG_STATUS_DBGACK
, 1) == 0)
639 embeddedice_read_reg(dbg_stat
);
640 jtag_execute_queue();
645 /* do not eat all CPU, time out after 1 se*/
650 LOG_ERROR("Failed to halt CPU after 1 sec");
651 return ERROR_TARGET_TIMEOUT
;
654 target
->state
= TARGET_HALTED
;
656 /* SVC, ARM state, IRQ and FIQ disabled */
657 buf_set_u32(armv4_5
->core_cache
->reg_list
[ARMV4_5_CPSR
].value
, 0, 8, 0xd3);
658 armv4_5
->core_cache
->reg_list
[ARMV4_5_CPSR
].dirty
= 1;
659 armv4_5
->core_cache
->reg_list
[ARMV4_5_CPSR
].valid
= 1;
661 /* start fetching from 0x0 */
662 buf_set_u32(armv4_5
->core_cache
->reg_list
[15].value
, 0, 32, 0x0);
663 armv4_5
->core_cache
->reg_list
[15].dirty
= 1;
664 armv4_5
->core_cache
->reg_list
[15].valid
= 1;
666 armv4_5
->core_mode
= ARMV4_5_MODE_SVC
;
667 armv4_5
->core_state
= ARMV4_5_STATE_ARM
;
669 arm920t_disable_mmu_caches(target
, 1, 1, 1);
670 arm920t
->armv4_5_mmu
.mmu_enabled
= 0;
671 arm920t
->armv4_5_mmu
.armv4_5_cache
.d_u_cache_enabled
= 0;
672 arm920t
->armv4_5_mmu
.armv4_5_cache
.i_cache_enabled
= 0;
674 target_call_event_callbacks(target
, TARGET_EVENT_HALTED
);
679 int arm920t_init_target(struct command_context_s
*cmd_ctx
, struct target_s
*target
)
681 arm9tdmi_init_target(cmd_ctx
, target
);
693 int arm920t_init_arch_info(target_t
*target
, arm920t_common_t
*arm920t
, int chain_pos
, char *variant
)
695 arm9tdmi_common_t
*arm9tdmi
= &arm920t
->arm9tdmi_common
;
696 arm7_9_common_t
*arm7_9
= &arm9tdmi
->arm7_9_common
;
698 /* initialize arm9tdmi specific info (including arm7_9 and armv4_5)
700 arm9tdmi_init_arch_info(target
, arm9tdmi
, chain_pos
, variant
);
702 arm9tdmi
->arch_info
= arm920t
;
703 arm920t
->common_magic
= ARM920T_COMMON_MAGIC
;
705 arm7_9
->post_debug_entry
= arm920t_post_debug_entry
;
706 arm7_9
->pre_restore_context
= arm920t_pre_restore_context
;
708 arm920t
->armv4_5_mmu
.armv4_5_cache
.ctype
= -1;
709 arm920t
->armv4_5_mmu
.get_ttb
= arm920t_get_ttb
;
710 arm920t
->armv4_5_mmu
.read_memory
= arm7_9_read_memory
;
711 arm920t
->armv4_5_mmu
.write_memory
= arm7_9_write_memory
;
712 arm920t
->armv4_5_mmu
.disable_mmu_caches
= arm920t_disable_mmu_caches
;
713 arm920t
->armv4_5_mmu
.enable_mmu_caches
= arm920t_enable_mmu_caches
;
714 arm920t
->armv4_5_mmu
.has_tiny_pages
= 1;
715 arm920t
->armv4_5_mmu
.mmu_enabled
= 0;
717 /* disabling linefills leads to lockups, so keep them enabled for now
718 * this doesn't affect correctness, but might affect timing issues, if
719 * important data is evicted from the cache during the debug session
721 arm920t
->preserve_cache
= 0;
723 /* override hw single-step capability from ARM9TDMI */
724 arm7_9
->has_single_step
= 1;
729 int arm920t_target_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
, struct target_s
*target
)
732 char *variant
= NULL
;
733 arm920t_common_t
*arm920t
= malloc(sizeof(arm920t_common_t
));
734 memset(arm920t
, 0, sizeof(*arm920t
));
738 LOG_ERROR("'target arm920t' requires at least one additional argument");
742 chain_pos
= strtoul(args
[3], NULL
, 0);
747 LOG_DEBUG("chain_pos: %i, variant: %s", chain_pos
, variant
);
749 arm920t_init_arch_info(target
, arm920t
, chain_pos
, variant
);
754 int arm920t_register_commands(struct command_context_s
*cmd_ctx
)
757 command_t
*arm920t_cmd
;
760 retval
= arm9tdmi_register_commands(cmd_ctx
);
762 arm920t_cmd
= register_command(cmd_ctx
, NULL
, "arm920t", NULL
, COMMAND_ANY
, "arm920t specific commands");
764 register_command(cmd_ctx
, arm920t_cmd
, "cp15", arm920t_handle_cp15_command
, COMMAND_EXEC
, "display/modify cp15 register <num> [value]");
765 register_command(cmd_ctx
, arm920t_cmd
, "cp15i", arm920t_handle_cp15i_command
, COMMAND_EXEC
, "display/modify cp15 (interpreted access) <opcode> [value] [address]");
766 register_command(cmd_ctx
, arm920t_cmd
, "cache_info", arm920t_handle_cache_info_command
, COMMAND_EXEC
, "display information about target caches");
767 register_command(cmd_ctx
, arm920t_cmd
, "virt2phys", arm920t_handle_virt2phys_command
, COMMAND_EXEC
, "translate va to pa <va>");
769 register_command(cmd_ctx
, arm920t_cmd
, "mdw_phys", arm920t_handle_md_phys_command
, COMMAND_EXEC
, "display memory words <physical addr> [count]");
770 register_command(cmd_ctx
, arm920t_cmd
, "mdh_phys", arm920t_handle_md_phys_command
, COMMAND_EXEC
, "display memory half-words <physical addr> [count]");
771 register_command(cmd_ctx
, arm920t_cmd
, "mdb_phys", arm920t_handle_md_phys_command
, COMMAND_EXEC
, "display memory bytes <physical addr> [count]");
773 register_command(cmd_ctx
, arm920t_cmd
, "mww_phys", arm920t_handle_mw_phys_command
, COMMAND_EXEC
, "write memory word <physical addr> <value>");
774 register_command(cmd_ctx
, arm920t_cmd
, "mwh_phys", arm920t_handle_mw_phys_command
, COMMAND_EXEC
, "write memory half-word <physical addr> <value>");
775 register_command(cmd_ctx
, arm920t_cmd
, "mwb_phys", arm920t_handle_mw_phys_command
, COMMAND_EXEC
, "write memory byte <physical addr> <value>");
777 register_command(cmd_ctx
, arm920t_cmd
, "read_cache", arm920t_handle_read_cache_command
, COMMAND_EXEC
, "display I/D cache content");
778 register_command(cmd_ctx
, arm920t_cmd
, "read_mmu", arm920t_handle_read_mmu_command
, COMMAND_EXEC
, "display I/D mmu content");
783 int arm920t_handle_read_cache_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
785 target_t
*target
= get_current_target(cmd_ctx
);
786 armv4_5_common_t
*armv4_5
;
787 arm7_9_common_t
*arm7_9
;
788 arm9tdmi_common_t
*arm9tdmi
;
789 arm920t_common_t
*arm920t
;
790 arm_jtag_t
*jtag_info
;
792 u32 cp15_ctrl
, cp15_ctrl_saved
;
795 u32 C15_C_D_Ind
, C15_C_I_Ind
;
798 arm920t_cache_line_t d_cache
[8][64], i_cache
[8][64];
803 command_print(cmd_ctx
, "usage: arm920t read_cache <filename>");
807 if ((output
= fopen(args
[0], "w")) == NULL
)
809 LOG_DEBUG("error opening cache content file");
813 for (i
= 0; i
< 16; i
++)
814 regs_p
[i
] = ®s
[i
];
816 if (arm920t_get_arch_pointers(target
, &armv4_5
, &arm7_9
, &arm9tdmi
, &arm920t
) != ERROR_OK
)
818 command_print(cmd_ctx
, "current target isn't an ARM920t target");
822 jtag_info
= &arm7_9
->jtag_info
;
824 /* disable MMU and Caches */
825 arm920t_read_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0x1, 0), &cp15_ctrl
);
826 jtag_execute_queue();
827 cp15_ctrl_saved
= cp15_ctrl
;
828 cp15_ctrl
&= ~(ARMV4_5_MMU_ENABLED
| ARMV4_5_D_U_CACHE_ENABLED
| ARMV4_5_I_CACHE_ENABLED
);
829 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0x1, 0), cp15_ctrl
);
831 /* read CP15 test state register */
832 arm920t_read_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), &cp15c15
);
833 jtag_execute_queue();
835 /* read DCache content */
836 fprintf(output
, "DCache:\n");
838 /* go through segments 0 to nsets (8 on ARM920T, 4 on ARM922T) */
839 for (segment
= 0; segment
< arm920t
->armv4_5_mmu
.armv4_5_cache
.d_u_size
.nsets
; segment
++)
841 fprintf(output
, "\nsegment: %i\n----------", segment
);
843 /* Ra: r0 = SBZ(31:8):segment(7:5):SBZ(4:0) */
844 regs
[0] = 0x0 | (segment
<< 5);
845 arm9tdmi_write_core_regs(target
, 0x1, regs
);
847 /* set interpret mode */
849 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), cp15c15
);
851 /* D CAM Read, loads current victim into C15.C.D.Ind */
852 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,2,0,15,6,2), ARMV4_5_LDR(1, 0));
854 /* read current victim */
855 arm920t_read_cp15_physical(target
, 0x3d, &C15_C_D_Ind
);
857 /* clear interpret mode */
859 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
861 for (index
= 0; index
< 64; index
++)
863 /* Ra: r0 = index(31:26):SBZ(25:8):segment(7:5):SBZ(4:0) */
864 regs
[0] = 0x0 | (segment
<< 5) | (index
<< 26);
865 arm9tdmi_write_core_regs(target
, 0x1, regs
);
867 /* set interpret mode */
869 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), cp15c15
);
871 /* Write DCache victim */
872 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,0,0,9,1,0), ARMV4_5_LDR(1, 0));
875 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,2,0,15,10,2), ARMV4_5_LDMIA(0, 0x1fe, 0, 0));
878 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,2,0,15,6,2), ARMV4_5_LDR(9, 0));
880 /* clear interpret mode */
882 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
884 /* read D RAM and CAM content */
885 arm9tdmi_read_core_regs(target
, 0x3fe, regs_p
);
886 jtag_execute_queue();
888 d_cache
[segment
][index
].cam
= regs
[9];
891 regs
[9] &= 0xfffffffe;
892 fprintf(output
, "\nsegment: %i, index: %i, CAM: 0x%8.8x, content (%s):\n", segment
, index
, regs
[9], (regs
[9] & 0x10) ? "valid" : "invalid");
894 for (i
= 1; i
< 9; i
++)
896 d_cache
[segment
][index
].data
[i
] = regs
[i
];
897 fprintf(output
, "%i: 0x%8.8x\n", i
-1, regs
[i
]);
902 /* Ra: r0 = index(31:26):SBZ(25:8):segment(7:5):SBZ(4:0) */
903 regs
[0] = 0x0 | (segment
<< 5) | (C15_C_D_Ind
<< 26);
904 arm9tdmi_write_core_regs(target
, 0x1, regs
);
906 /* set interpret mode */
908 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), cp15c15
);
910 /* Write DCache victim */
911 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,0,0,9,1,0), ARMV4_5_LDR(1, 0));
913 /* clear interpret mode */
915 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
918 /* read ICache content */
919 fprintf(output
, "ICache:\n");
921 /* go through segments 0 to nsets (8 on ARM920T, 4 on ARM922T) */
922 for (segment
= 0; segment
< arm920t
->armv4_5_mmu
.armv4_5_cache
.d_u_size
.nsets
; segment
++)
924 fprintf(output
, "segment: %i\n----------", segment
);
926 /* Ra: r0 = SBZ(31:8):segment(7:5):SBZ(4:0) */
927 regs
[0] = 0x0 | (segment
<< 5);
928 arm9tdmi_write_core_regs(target
, 0x1, regs
);
930 /* set interpret mode */
932 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), cp15c15
);
934 /* I CAM Read, loads current victim into C15.C.I.Ind */
935 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,2,0,15,5,2), ARMV4_5_LDR(1, 0));
937 /* read current victim */
938 arm920t_read_cp15_physical(target
, 0x3b, &C15_C_I_Ind
);
940 /* clear interpret mode */
942 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
944 for (index
= 0; index
< 64; index
++)
946 /* Ra: r0 = index(31:26):SBZ(25:8):segment(7:5):SBZ(4:0) */
947 regs
[0] = 0x0 | (segment
<< 5) | (index
<< 26);
948 arm9tdmi_write_core_regs(target
, 0x1, regs
);
950 /* set interpret mode */
952 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), cp15c15
);
954 /* Write ICache victim */
955 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,0,0,9,1,1), ARMV4_5_LDR(1, 0));
958 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,2,0,15,9,2), ARMV4_5_LDMIA(0, 0x1fe, 0, 0));
961 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,2,0,15,5,2), ARMV4_5_LDR(9, 0));
963 /* clear interpret mode */
965 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
967 /* read I RAM and CAM content */
968 arm9tdmi_read_core_regs(target
, 0x3fe, regs_p
);
969 jtag_execute_queue();
971 i_cache
[segment
][index
].cam
= regs
[9];
974 regs
[9] &= 0xfffffffe;
975 fprintf(output
, "\nsegment: %i, index: %i, CAM: 0x%8.8x, content (%s):\n", segment
, index
, regs
[9], (regs
[9] & 0x10) ? "valid" : "invalid");
977 for (i
= 1; i
< 9; i
++)
979 i_cache
[segment
][index
].data
[i
] = regs
[i
];
980 fprintf(output
, "%i: 0x%8.8x\n", i
-1, regs
[i
]);
986 /* Ra: r0 = index(31:26):SBZ(25:8):segment(7:5):SBZ(4:0) */
987 regs
[0] = 0x0 | (segment
<< 5) | (C15_C_D_Ind
<< 26);
988 arm9tdmi_write_core_regs(target
, 0x1, regs
);
990 /* set interpret mode */
992 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), cp15c15
);
994 /* Write ICache victim */
995 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,0,0,9,1,1), ARMV4_5_LDR(1, 0));
997 /* clear interpret mode */
999 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
1002 /* restore CP15 MMU and Cache settings */
1003 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0x1, 0), cp15_ctrl_saved
);
1005 command_print(cmd_ctx
, "cache content successfully output to %s", args
[0]);
1009 if (armv4_5_mode_to_number(armv4_5
->core_mode
)==-1)
1012 /* mark registers dirty. */
1013 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 0).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 0).valid
;
1014 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 1).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 1).valid
;
1015 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 2).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 2).valid
;
1016 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 3).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 3).valid
;
1017 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 4).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 4).valid
;
1018 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 5).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 5).valid
;
1019 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 6).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 6).valid
;
1020 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 7).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 7).valid
;
1021 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 8).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 8).valid
;
1022 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 9).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 9).valid
;
1027 int arm920t_handle_read_mmu_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
1029 target_t
*target
= get_current_target(cmd_ctx
);
1030 armv4_5_common_t
*armv4_5
;
1031 arm7_9_common_t
*arm7_9
;
1032 arm9tdmi_common_t
*arm9tdmi
;
1033 arm920t_common_t
*arm920t
;
1034 arm_jtag_t
*jtag_info
;
1036 u32 cp15_ctrl
, cp15_ctrl_saved
;
1041 u32 Dlockdown
, Ilockdown
;
1042 arm920t_tlb_entry_t d_tlb
[64], i_tlb
[64];
1047 command_print(cmd_ctx
, "usage: arm920t read_mmu <filename>");
1051 if ((output
= fopen(args
[0], "w")) == NULL
)
1053 LOG_DEBUG("error opening mmu content file");
1057 for (i
= 0; i
< 16; i
++)
1058 regs_p
[i
] = ®s
[i
];
1060 if (arm920t_get_arch_pointers(target
, &armv4_5
, &arm7_9
, &arm9tdmi
, &arm920t
) != ERROR_OK
)
1062 command_print(cmd_ctx
, "current target isn't an ARM920t target");
1066 jtag_info
= &arm7_9
->jtag_info
;
1068 /* disable MMU and Caches */
1069 arm920t_read_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0x1, 0), &cp15_ctrl
);
1070 jtag_execute_queue();
1071 cp15_ctrl_saved
= cp15_ctrl
;
1072 cp15_ctrl
&= ~(ARMV4_5_MMU_ENABLED
| ARMV4_5_D_U_CACHE_ENABLED
| ARMV4_5_I_CACHE_ENABLED
);
1073 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0x1, 0), cp15_ctrl
);
1075 /* read CP15 test state register */
1076 arm920t_read_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), &cp15c15
);
1077 jtag_execute_queue();
1079 /* prepare reading D TLB content
1082 /* set interpret mode */
1084 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), cp15c15
);
1086 /* Read D TLB lockdown */
1087 arm920t_execute_cp15(target
, ARMV4_5_MRC(15,0,0,10,0,0), ARMV4_5_LDR(1, 0));
1089 /* clear interpret mode */
1091 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
1093 /* read D TLB lockdown stored to r1 */
1094 arm9tdmi_read_core_regs(target
, 0x2, regs_p
);
1095 jtag_execute_queue();
1096 Dlockdown
= regs
[1];
1098 for (victim
= 0; victim
< 64; victim
+= 8)
1100 /* new lockdown value: base[31:26]:victim[25:20]:SBZ[19:1]:p[0]
1101 * base remains unchanged, victim goes through entries 0 to 63 */
1102 regs
[1] = (Dlockdown
& 0xfc000000) | (victim
<< 20);
1103 arm9tdmi_write_core_regs(target
, 0x2, regs
);
1105 /* set interpret mode */
1107 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), cp15c15
);
1109 /* Write D TLB lockdown */
1110 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,0,0,10,0,0), ARMV4_5_STR(1, 0));
1112 /* Read D TLB CAM */
1113 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,4,0,15,6,4), ARMV4_5_LDMIA(0, 0x3fc, 0, 0));
1115 /* clear interpret mode */
1117 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
1119 /* read D TLB CAM content stored to r2-r9 */
1120 arm9tdmi_read_core_regs(target
, 0x3fc, regs_p
);
1121 jtag_execute_queue();
1123 for (i
= 0; i
< 8; i
++)
1124 d_tlb
[victim
+ i
].cam
= regs
[i
+ 2];
1127 for (victim
= 0; victim
< 64; victim
++)
1129 /* new lockdown value: base[31:26]:victim[25:20]:SBZ[19:1]:p[0]
1130 * base remains unchanged, victim goes through entries 0 to 63 */
1131 regs
[1] = (Dlockdown
& 0xfc000000) | (victim
<< 20);
1132 arm9tdmi_write_core_regs(target
, 0x2, regs
);
1134 /* set interpret mode */
1136 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), cp15c15
);
1138 /* Write D TLB lockdown */
1139 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,0,0,10,0,0), ARMV4_5_STR(1, 0));
1141 /* Read D TLB RAM1 */
1142 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,4,0,15,10,4), ARMV4_5_LDR(2,0));
1144 /* Read D TLB RAM2 */
1145 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,4,0,15,2,5), ARMV4_5_LDR(3,0));
1147 /* clear interpret mode */
1149 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
1151 /* read D TLB RAM content stored to r2 and r3 */
1152 arm9tdmi_read_core_regs(target
, 0xc, regs_p
);
1153 jtag_execute_queue();
1155 d_tlb
[victim
].ram1
= regs
[2];
1156 d_tlb
[victim
].ram2
= regs
[3];
1159 /* restore D TLB lockdown */
1160 regs
[1] = Dlockdown
;
1161 arm9tdmi_write_core_regs(target
, 0x2, regs
);
1163 /* Write D TLB lockdown */
1164 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,0,0,10,0,0), ARMV4_5_STR(1, 0));
1166 /* prepare reading I TLB content
1169 /* set interpret mode */
1171 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), cp15c15
);
1173 /* Read I TLB lockdown */
1174 arm920t_execute_cp15(target
, ARMV4_5_MRC(15,0,0,10,0,1), ARMV4_5_LDR(1, 0));
1176 /* clear interpret mode */
1178 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
1180 /* read I TLB lockdown stored to r1 */
1181 arm9tdmi_read_core_regs(target
, 0x2, regs_p
);
1182 jtag_execute_queue();
1183 Ilockdown
= regs
[1];
1185 for (victim
= 0; victim
< 64; victim
+= 8)
1187 /* new lockdown value: base[31:26]:victim[25:20]:SBZ[19:1]:p[0]
1188 * base remains unchanged, victim goes through entries 0 to 63 */
1189 regs
[1] = (Ilockdown
& 0xfc000000) | (victim
<< 20);
1190 arm9tdmi_write_core_regs(target
, 0x2, regs
);
1192 /* set interpret mode */
1194 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), cp15c15
);
1196 /* Write I TLB lockdown */
1197 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,0,0,10,0,1), ARMV4_5_STR(1, 0));
1199 /* Read I TLB CAM */
1200 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,4,0,15,5,4), ARMV4_5_LDMIA(0, 0x3fc, 0, 0));
1202 /* clear interpret mode */
1204 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
1206 /* read I TLB CAM content stored to r2-r9 */
1207 arm9tdmi_read_core_regs(target
, 0x3fc, regs_p
);
1208 jtag_execute_queue();
1210 for (i
= 0; i
< 8; i
++)
1211 i_tlb
[i
+ victim
].cam
= regs
[i
+ 2];
1214 for (victim
= 0; victim
< 64; victim
++)
1216 /* new lockdown value: base[31:26]:victim[25:20]:SBZ[19:1]:p[0]
1217 * base remains unchanged, victim goes through entries 0 to 63 */
1218 regs
[1] = (Dlockdown
& 0xfc000000) | (victim
<< 20);
1219 arm9tdmi_write_core_regs(target
, 0x2, regs
);
1221 /* set interpret mode */
1223 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0xf, 0), cp15c15
);
1225 /* Write I TLB lockdown */
1226 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,0,0,10,0,1), ARMV4_5_STR(1, 0));
1228 /* Read I TLB RAM1 */
1229 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,4,0,15,9,4), ARMV4_5_LDR(2,0));
1231 /* Read I TLB RAM2 */
1232 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,4,0,15,1,5), ARMV4_5_LDR(3,0));
1234 /* clear interpret mode */
1236 arm920t_write_cp15_physical(target
, 0x1e, cp15c15
);
1238 /* read I TLB RAM content stored to r2 and r3 */
1239 arm9tdmi_read_core_regs(target
, 0xc, regs_p
);
1240 jtag_execute_queue();
1242 i_tlb
[victim
].ram1
= regs
[2];
1243 i_tlb
[victim
].ram2
= regs
[3];
1246 /* restore I TLB lockdown */
1247 regs
[1] = Ilockdown
;
1248 arm9tdmi_write_core_regs(target
, 0x2, regs
);
1250 /* Write I TLB lockdown */
1251 arm920t_execute_cp15(target
, ARMV4_5_MCR(15,0,0,10,0,1), ARMV4_5_STR(1, 0));
1253 /* restore CP15 MMU and Cache settings */
1254 arm920t_write_cp15_physical(target
, ARM920T_CP15_PHYS_ADDR(0, 0x1, 0), cp15_ctrl_saved
);
1256 /* output data to file */
1257 fprintf(output
, "D TLB content:\n");
1258 for (i
= 0; i
< 64; i
++)
1260 fprintf(output
, "%i: 0x%8.8x 0x%8.8x 0x%8.8x %s\n", i
, d_tlb
[i
].cam
, d_tlb
[i
].ram1
, d_tlb
[i
].ram2
, (d_tlb
[i
].cam
& 0x20) ? "(valid)" : "(invalid)");
1263 fprintf(output
, "\n\nI TLB content:\n");
1264 for (i
= 0; i
< 64; i
++)
1266 fprintf(output
, "%i: 0x%8.8x 0x%8.8x 0x%8.8x %s\n", i
, i_tlb
[i
].cam
, i_tlb
[i
].ram1
, i_tlb
[i
].ram2
, (i_tlb
[i
].cam
& 0x20) ? "(valid)" : "(invalid)");
1269 command_print(cmd_ctx
, "mmu content successfully output to %s", args
[0]);
1273 if (armv4_5_mode_to_number(armv4_5
->core_mode
)==-1)
1276 /* mark registers dirty */
1277 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 0).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 0).valid
;
1278 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 1).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 1).valid
;
1279 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 2).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 2).valid
;
1280 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 3).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 3).valid
;
1281 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 4).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 4).valid
;
1282 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 5).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 5).valid
;
1283 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 6).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 6).valid
;
1284 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 7).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 7).valid
;
1285 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 8).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 8).valid
;
1286 ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 9).dirty
= ARMV4_5_CORE_REG_MODE(armv4_5
->core_cache
, armv4_5
->core_mode
, 9).valid
;
1290 int arm920t_handle_cp15_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
1293 target_t
*target
= get_current_target(cmd_ctx
);
1294 armv4_5_common_t
*armv4_5
;
1295 arm7_9_common_t
*arm7_9
;
1296 arm9tdmi_common_t
*arm9tdmi
;
1297 arm920t_common_t
*arm920t
;
1298 arm_jtag_t
*jtag_info
;
1300 if (arm920t_get_arch_pointers(target
, &armv4_5
, &arm7_9
, &arm9tdmi
, &arm920t
) != ERROR_OK
)
1302 command_print(cmd_ctx
, "current target isn't an ARM920t target");
1306 jtag_info
= &arm7_9
->jtag_info
;
1308 if (target
->state
!= TARGET_HALTED
)
1310 command_print(cmd_ctx
, "target must be stopped for \"%s\" command", cmd
);
1314 /* one or more argument, access a single register (write if second argument is given */
1317 int address
= strtoul(args
[0], NULL
, 0);
1322 if ((retval
= arm920t_read_cp15_physical(target
, address
, &value
)) != ERROR_OK
)
1324 command_print(cmd_ctx
, "couldn't access reg %i", address
);
1327 jtag_execute_queue();
1329 command_print(cmd_ctx
, "%i: %8.8x", address
, value
);
1333 u32 value
= strtoul(args
[1], NULL
, 0);
1334 if ((retval
= arm920t_write_cp15_physical(target
, address
, value
)) != ERROR_OK
)
1336 command_print(cmd_ctx
, "couldn't access reg %i", address
);
1339 command_print(cmd_ctx
, "%i: %8.8x", address
, value
);
1346 int arm920t_handle_cp15i_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
1349 target_t
*target
= get_current_target(cmd_ctx
);
1350 armv4_5_common_t
*armv4_5
;
1351 arm7_9_common_t
*arm7_9
;
1352 arm9tdmi_common_t
*arm9tdmi
;
1353 arm920t_common_t
*arm920t
;
1354 arm_jtag_t
*jtag_info
;
1356 if (arm920t_get_arch_pointers(target
, &armv4_5
, &arm7_9
, &arm9tdmi
, &arm920t
) != ERROR_OK
)
1358 command_print(cmd_ctx
, "current target isn't an ARM920t target");
1362 jtag_info
= &arm7_9
->jtag_info
;
1364 if (target
->state
!= TARGET_HALTED
)
1366 command_print(cmd_ctx
, "target must be stopped for \"%s\" command", cmd
);
1370 /* one or more argument, access a single register (write if second argument is given */
1373 u32 opcode
= strtoul(args
[0], NULL
, 0);
1378 if ((retval
= arm920t_read_cp15_interpreted(target
, opcode
, 0x0, &value
)) != ERROR_OK
)
1380 command_print(cmd_ctx
, "couldn't execute %8.8x", opcode
);
1384 command_print(cmd_ctx
, "%8.8x: %8.8x", opcode
, value
);
1388 u32 value
= strtoul(args
[1], NULL
, 0);
1389 if ((retval
= arm920t_write_cp15_interpreted(target
, opcode
, value
, 0)) != ERROR_OK
)
1391 command_print(cmd_ctx
, "couldn't execute %8.8x", opcode
);
1394 command_print(cmd_ctx
, "%8.8x: %8.8x", opcode
, value
);
1398 u32 value
= strtoul(args
[1], NULL
, 0);
1399 u32 address
= strtoul(args
[2], NULL
, 0);
1400 if ((retval
= arm920t_write_cp15_interpreted(target
, opcode
, value
, address
)) != ERROR_OK
)
1402 command_print(cmd_ctx
, "couldn't execute %8.8x", opcode
);
1405 command_print(cmd_ctx
, "%8.8x: %8.8x %8.8x", opcode
, value
, address
);
1410 command_print(cmd_ctx
, "usage: arm920t cp15i <opcode> [value] [address]");
1416 int arm920t_handle_cache_info_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
1418 target_t
*target
= get_current_target(cmd_ctx
);
1419 armv4_5_common_t
*armv4_5
;
1420 arm7_9_common_t
*arm7_9
;
1421 arm9tdmi_common_t
*arm9tdmi
;
1422 arm920t_common_t
*arm920t
;
1424 if (arm920t_get_arch_pointers(target
, &armv4_5
, &arm7_9
, &arm9tdmi
, &arm920t
) != ERROR_OK
)
1426 command_print(cmd_ctx
, "current target isn't an ARM920t target");
1430 return armv4_5_handle_cache_info_command(cmd_ctx
, &arm920t
->armv4_5_mmu
.armv4_5_cache
);
1433 int arm920t_handle_virt2phys_command(command_context_t
*cmd_ctx
, char *cmd
, char **args
, int argc
)
1435 target_t
*target
= get_current_target(cmd_ctx
);
1436 armv4_5_common_t
*armv4_5
;
1437 arm7_9_common_t
*arm7_9
;
1438 arm9tdmi_common_t
*arm9tdmi
;
1439 arm920t_common_t
*arm920t
;
1440 arm_jtag_t
*jtag_info
;
1442 if (arm920t_get_arch_pointers(target
, &armv4_5
, &arm7_9
, &arm9tdmi
, &arm920t
) != ERROR_OK
)
1444 command_print(cmd_ctx
, "current target isn't an ARM920t target");
1448 jtag_info
= &arm7_9
->jtag_info
;
1450 if (target
->state
!= TARGET_HALTED
)
1452 command_print(cmd_ctx
, "target must be stopped for \"%s\" command", cmd
);
1456 return armv4_5_mmu_handle_virt2phys_command(cmd_ctx
, cmd
, args
, argc
, target
, &arm920t
->armv4_5_mmu
);
1459 int arm920t_handle_md_phys_command(command_context_t
*cmd_ctx
, char *cmd
, char **args
, int argc
)
1461 target_t
*target
= get_current_target(cmd_ctx
);
1462 armv4_5_common_t
*armv4_5
;
1463 arm7_9_common_t
*arm7_9
;
1464 arm9tdmi_common_t
*arm9tdmi
;
1465 arm920t_common_t
*arm920t
;
1466 arm_jtag_t
*jtag_info
;
1468 if (arm920t_get_arch_pointers(target
, &armv4_5
, &arm7_9
, &arm9tdmi
, &arm920t
) != ERROR_OK
)
1470 command_print(cmd_ctx
, "current target isn't an ARM920t target");
1474 jtag_info
= &arm7_9
->jtag_info
;
1476 if (target
->state
!= TARGET_HALTED
)
1478 command_print(cmd_ctx
, "target must be stopped for \"%s\" command", cmd
);
1482 return armv4_5_mmu_handle_md_phys_command(cmd_ctx
, cmd
, args
, argc
, target
, &arm920t
->armv4_5_mmu
);
1485 int arm920t_handle_mw_phys_command(command_context_t
*cmd_ctx
, char *cmd
, char **args
, int argc
)
1487 target_t
*target
= get_current_target(cmd_ctx
);
1488 armv4_5_common_t
*armv4_5
;
1489 arm7_9_common_t
*arm7_9
;
1490 arm9tdmi_common_t
*arm9tdmi
;
1491 arm920t_common_t
*arm920t
;
1492 arm_jtag_t
*jtag_info
;
1494 if (arm920t_get_arch_pointers(target
, &armv4_5
, &arm7_9
, &arm9tdmi
, &arm920t
) != ERROR_OK
)
1496 command_print(cmd_ctx
, "current target isn't an ARM920t target");
1500 jtag_info
= &arm7_9
->jtag_info
;
1502 if (target
->state
!= TARGET_HALTED
)
1504 command_print(cmd_ctx
, "target must be stopped for \"%s\" command", cmd
);
1508 return armv4_5_mmu_handle_mw_phys_command(cmd_ctx
, cmd
, args
, argc
, target
, &arm920t
->armv4_5_mmu
);
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)