1 // SPDX-License-Identifier: GPL-2.0-or-later
3 /***************************************************************************
4 * Copyright (C) 2008 by Spencer Oliver *
5 * spen@spen-soft.co.uk *
7 * Copyright (C) 2008 by David T.L. Wong *
9 * Copyright (C) 2009 by David N. Claffey <dnclaffey@gmail.com> *
11 * Copyright (C) 2011 by Drasko DRASKOVIC *
12 * drasko.draskovic@gmail.com *
13 ***************************************************************************/
19 #include "breakpoints.h"
22 #include "mips32_dmaacc.h"
23 #include "target_type.h"
27 static void mips_m4k_enable_breakpoints(struct target
*target
);
28 static void mips_m4k_enable_watchpoints(struct target
*target
);
29 static int mips_m4k_set_breakpoint(struct target
*target
,
30 struct breakpoint
*breakpoint
);
31 static int mips_m4k_unset_breakpoint(struct target
*target
,
32 struct breakpoint
*breakpoint
);
33 static int mips_m4k_internal_restore(struct target
*target
, int current
,
34 target_addr_t address
, int handle_breakpoints
,
36 static int mips_m4k_halt(struct target
*target
);
37 static int mips_m4k_bulk_write_memory(struct target
*target
, target_addr_t address
,
38 uint32_t count
, const uint8_t *buffer
);
40 static int mips_m4k_examine_debug_reason(struct target
*target
)
42 struct mips32_common
*mips32
= target_to_mips32(target
);
43 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
44 uint32_t break_status
;
47 if ((target
->debug_reason
!= DBG_REASON_DBGRQ
)
48 && (target
->debug_reason
!= DBG_REASON_SINGLESTEP
)) {
49 if (ejtag_info
->debug_caps
& EJTAG_DCR_IB
) {
50 /* get info about inst breakpoint support */
51 retval
= target_read_u32(target
,
52 ejtag_info
->ejtag_ibs_addr
, &break_status
);
53 if (retval
!= ERROR_OK
)
55 if (break_status
& 0x1f) {
56 /* we have halted on a breakpoint */
57 retval
= target_write_u32(target
,
58 ejtag_info
->ejtag_ibs_addr
, 0);
59 if (retval
!= ERROR_OK
)
61 target
->debug_reason
= DBG_REASON_BREAKPOINT
;
65 if (ejtag_info
->debug_caps
& EJTAG_DCR_DB
) {
66 /* get info about data breakpoint support */
67 retval
= target_read_u32(target
,
68 ejtag_info
->ejtag_dbs_addr
, &break_status
);
69 if (retval
!= ERROR_OK
)
71 if (break_status
& 0x1f) {
72 /* we have halted on a breakpoint */
73 retval
= target_write_u32(target
,
74 ejtag_info
->ejtag_dbs_addr
, 0);
75 if (retval
!= ERROR_OK
)
77 target
->debug_reason
= DBG_REASON_WATCHPOINT
;
85 static int mips_m4k_debug_entry(struct target
*target
)
87 struct mips32_common
*mips32
= target_to_mips32(target
);
88 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
90 mips32_save_context(target
);
92 /* make sure stepping disabled, SSt bit in CP0 debug register cleared */
93 mips_ejtag_config_step(ejtag_info
, 0);
95 /* make sure break unit configured */
96 mips32_configure_break_unit(target
);
98 /* attempt to find halt reason */
99 mips_m4k_examine_debug_reason(target
);
101 mips32_read_config_regs(target
);
103 /* default to mips32 isa, it will be changed below if required */
104 mips32
->isa_mode
= MIPS32_ISA_MIPS32
;
106 /* other than mips32 only and isa bit set ? */
107 if (mips32
->isa_imp
&& buf_get_u32(mips32
->core_cache
->reg_list
[MIPS32_PC
].value
, 0, 1))
108 mips32
->isa_mode
= mips32
->isa_imp
== 2 ? MIPS32_ISA_MIPS16E
: MIPS32_ISA_MMIPS32
;
110 LOG_DEBUG("entered debug state at PC 0x%" PRIx32
", target->state: %s",
111 buf_get_u32(mips32
->core_cache
->reg_list
[MIPS32_PC
].value
, 0, 32),
112 target_state_name(target
));
117 static struct target
*get_mips_m4k(struct target
*target
, int32_t coreid
)
119 struct target_list
*head
;
121 foreach_smp_target(head
, target
->smp_targets
) {
122 struct target
*curr
= head
->target
;
123 if ((curr
->coreid
== coreid
) && (curr
->state
== TARGET_HALTED
))
129 static int mips_m4k_halt_smp(struct target
*target
)
131 int retval
= ERROR_OK
;
132 struct target_list
*head
;
134 foreach_smp_target(head
, target
->smp_targets
) {
136 struct target
*curr
= head
->target
;
137 if ((curr
!= target
) && (curr
->state
!= TARGET_HALTED
))
138 ret
= mips_m4k_halt(curr
);
140 if (ret
!= ERROR_OK
) {
141 LOG_ERROR("halt failed target->coreid: %" PRId32
, curr
->coreid
);
148 static int update_halt_gdb(struct target
*target
)
150 int retval
= ERROR_OK
;
151 if (target
->gdb_service
->core
[0] == -1) {
152 target
->gdb_service
->target
= target
;
153 target
->gdb_service
->core
[0] = target
->coreid
;
154 retval
= mips_m4k_halt_smp(target
);
159 static int mips_m4k_poll(struct target
*target
)
161 int retval
= ERROR_OK
;
162 struct mips32_common
*mips32
= target_to_mips32(target
);
163 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
164 uint32_t ejtag_ctrl
= ejtag_info
->ejtag_ctrl
;
165 enum target_state prev_target_state
= target
->state
;
167 /* toggle to another core is done by gdb as follow */
168 /* maint packet J core_id */
170 /* the next polling trigger an halt event sent to gdb */
171 if ((target
->state
== TARGET_HALTED
) && (target
->smp
) &&
172 (target
->gdb_service
) &&
173 (!target
->gdb_service
->target
)) {
174 target
->gdb_service
->target
=
175 get_mips_m4k(target
, target
->gdb_service
->core
[1]);
176 target_call_event_callbacks(target
, TARGET_EVENT_HALTED
);
180 /* read ejtag control reg */
181 mips_ejtag_set_instr(ejtag_info
, EJTAG_INST_CONTROL
);
182 retval
= mips_ejtag_drscan_32(ejtag_info
, &ejtag_ctrl
);
183 if (retval
!= ERROR_OK
)
186 ejtag_info
->isa
= (ejtag_ctrl
& EJTAG_CTRL_DBGISA
) ? 1 : 0;
188 /* clear this bit before handling polling
189 * as after reset registers will read zero */
190 if (ejtag_ctrl
& EJTAG_CTRL_ROCC
) {
191 /* we have detected a reset, clear flag
192 * otherwise ejtag will not work */
193 ejtag_ctrl
= ejtag_info
->ejtag_ctrl
& ~EJTAG_CTRL_ROCC
;
195 mips_ejtag_set_instr(ejtag_info
, EJTAG_INST_CONTROL
);
196 retval
= mips_ejtag_drscan_32(ejtag_info
, &ejtag_ctrl
);
197 if (retval
!= ERROR_OK
)
199 LOG_DEBUG("Reset Detected");
202 /* check for processor halted */
203 if (ejtag_ctrl
& EJTAG_CTRL_BRKST
) {
204 if ((target
->state
!= TARGET_HALTED
)
205 && (target
->state
!= TARGET_DEBUG_RUNNING
)) {
206 if (target
->state
== TARGET_UNKNOWN
)
207 LOG_DEBUG("EJTAG_CTRL_BRKST already set during server startup.");
209 /* OpenOCD was was probably started on the board with EJTAG_CTRL_BRKST already set
210 * (maybe put on by HALT-ing the board in the previous session).
212 * Force enable debug entry for this session.
214 mips_ejtag_set_instr(ejtag_info
, EJTAG_INST_NORMALBOOT
);
215 target
->state
= TARGET_HALTED
;
216 retval
= mips_m4k_debug_entry(target
);
217 if (retval
!= ERROR_OK
)
221 ((prev_target_state
== TARGET_RUNNING
)
222 || (prev_target_state
== TARGET_RESET
))) {
223 retval
= update_halt_gdb(target
);
224 if (retval
!= ERROR_OK
)
227 target_call_event_callbacks(target
, TARGET_EVENT_HALTED
);
228 } else if (target
->state
== TARGET_DEBUG_RUNNING
) {
229 target
->state
= TARGET_HALTED
;
231 retval
= mips_m4k_debug_entry(target
);
232 if (retval
!= ERROR_OK
)
236 retval
= update_halt_gdb(target
);
237 if (retval
!= ERROR_OK
)
241 target_call_event_callbacks(target
, TARGET_EVENT_DEBUG_HALTED
);
244 target
->state
= TARGET_RUNNING
;
246 /* LOG_DEBUG("ctrl = 0x%08X", ejtag_ctrl); */
251 static int mips_m4k_halt(struct target
*target
)
253 struct mips32_common
*mips32
= target_to_mips32(target
);
254 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
256 LOG_DEBUG("target->state: %s", target_state_name(target
));
258 if (target
->state
== TARGET_HALTED
) {
259 LOG_DEBUG("target was already halted");
263 if (target
->state
== TARGET_UNKNOWN
)
264 LOG_WARNING("target was in unknown state when halt was requested");
266 if (target
->state
== TARGET_RESET
) {
267 if ((jtag_get_reset_config() & RESET_SRST_PULLS_TRST
) && jtag_get_srst()) {
268 LOG_ERROR("can't request a halt while in reset if nSRST pulls nTRST");
269 return ERROR_TARGET_FAILURE
;
271 /* we came here in a reset_halt or reset_init sequence
272 * debug entry was already prepared in mips_m4k_assert_reset()
274 target
->debug_reason
= DBG_REASON_DBGRQ
;
280 /* break processor */
281 mips_ejtag_enter_debug(ejtag_info
);
283 target
->debug_reason
= DBG_REASON_DBGRQ
;
288 static int mips_m4k_assert_reset(struct target
*target
)
290 struct mips_m4k_common
*mips_m4k
= target_to_m4k(target
);
291 struct mips_ejtag
*ejtag_info
= &mips_m4k
->mips32
.ejtag_info
;
293 /* TODO: apply hw reset signal in not examined state */
294 if (!(target_was_examined(target
))) {
295 LOG_WARNING("Reset is not asserted because the target is not examined.");
296 LOG_WARNING("Use a reset button or power cycle the target.");
297 return ERROR_TARGET_NOT_EXAMINED
;
300 LOG_DEBUG("target->state: %s",
301 target_state_name(target
));
303 enum reset_types jtag_reset_config
= jtag_get_reset_config();
305 /* some cores support connecting while srst is asserted
306 * use that mode is it has been configured */
308 bool srst_asserted
= false;
310 if (!(jtag_reset_config
& RESET_SRST_PULLS_TRST
) &&
311 (jtag_reset_config
& RESET_SRST_NO_GATING
)) {
312 jtag_add_reset(0, 1);
313 srst_asserted
= true;
317 /* EJTAG before v2.5/2.6 does not support EJTAGBOOT or NORMALBOOT */
318 if (ejtag_info
->ejtag_version
!= EJTAG_VERSION_20
) {
319 if (target
->reset_halt
) {
320 /* use hardware to catch reset */
321 mips_ejtag_set_instr(ejtag_info
, EJTAG_INST_EJTAGBOOT
);
323 mips_ejtag_set_instr(ejtag_info
, EJTAG_INST_NORMALBOOT
);
326 if (jtag_reset_config
& RESET_HAS_SRST
) {
327 /* here we should issue a srst only, but we may have to assert trst as well */
328 if (jtag_reset_config
& RESET_SRST_PULLS_TRST
)
329 jtag_add_reset(1, 1);
330 else if (!srst_asserted
)
331 jtag_add_reset(0, 1);
332 } else if (target_has_event_action(target
, TARGET_EVENT_RESET_ASSERT
)) {
333 target_handle_event(target
, TARGET_EVENT_RESET_ASSERT
);
335 if (mips_m4k
->is_pic32mx
) {
336 LOG_DEBUG("Using MTAP reset to reset processor...");
338 /* use microchip specific MTAP reset */
339 mips_ejtag_set_instr(ejtag_info
, MTAP_SW_MTAP
);
340 mips_ejtag_set_instr(ejtag_info
, MTAP_COMMAND
);
342 mips_ejtag_drscan_8_out(ejtag_info
, MCHP_ASERT_RST
);
343 mips_ejtag_drscan_8_out(ejtag_info
, MCHP_DE_ASSERT_RST
);
344 mips_ejtag_set_instr(ejtag_info
, MTAP_SW_ETAP
);
346 /* use ejtag reset - not supported by all cores */
347 uint32_t ejtag_ctrl
= ejtag_info
->ejtag_ctrl
| EJTAG_CTRL_PRRST
| EJTAG_CTRL_PERRST
;
348 LOG_DEBUG("Using EJTAG reset (PRRST) to reset processor...");
349 mips_ejtag_set_instr(ejtag_info
, EJTAG_INST_CONTROL
);
350 mips_ejtag_drscan_32_out(ejtag_info
, ejtag_ctrl
);
354 target
->state
= TARGET_RESET
;
355 jtag_add_sleep(50000);
357 register_cache_invalidate(mips_m4k
->mips32
.core_cache
);
359 if (target
->reset_halt
) {
360 int retval
= target_halt(target
);
361 if (retval
!= ERROR_OK
)
368 static int mips_m4k_deassert_reset(struct target
*target
)
370 LOG_DEBUG("target->state: %s", target_state_name(target
));
372 /* deassert reset lines */
373 jtag_add_reset(0, 0);
378 static int mips_m4k_single_step_core(struct target
*target
)
380 struct mips32_common
*mips32
= target_to_mips32(target
);
381 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
383 /* configure single step mode */
384 mips_ejtag_config_step(ejtag_info
, 1);
386 /* disable interrupts while stepping */
387 mips32_enable_interrupts(target
, 0);
389 /* exit debug mode */
390 mips_ejtag_exit_debug(ejtag_info
);
392 mips_m4k_debug_entry(target
);
397 static int mips_m4k_restore_smp(struct target
*target
, uint32_t address
, int handle_breakpoints
)
399 int retval
= ERROR_OK
;
400 struct target_list
*head
;
402 foreach_smp_target(head
, target
->smp_targets
) {
404 struct target
*curr
= head
->target
;
405 if ((curr
!= target
) && (curr
->state
!= TARGET_RUNNING
)) {
406 /* resume current address , not in step mode */
407 ret
= mips_m4k_internal_restore(curr
, 1, address
,
408 handle_breakpoints
, 0);
410 if (ret
!= ERROR_OK
) {
411 LOG_ERROR("target->coreid :%" PRId32
" failed to resume at address :0x%" PRIx32
,
412 curr
->coreid
, address
);
420 static int mips_m4k_internal_restore(struct target
*target
, int current
,
421 target_addr_t address
, int handle_breakpoints
, int debug_execution
)
423 struct mips32_common
*mips32
= target_to_mips32(target
);
424 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
425 struct breakpoint
*breakpoint
= NULL
;
428 if (target
->state
!= TARGET_HALTED
) {
429 LOG_WARNING("target not halted");
430 return ERROR_TARGET_NOT_HALTED
;
433 if (!debug_execution
) {
434 target_free_all_working_areas(target
);
435 mips_m4k_enable_breakpoints(target
);
436 mips_m4k_enable_watchpoints(target
);
439 /* current = 1: continue on current pc, otherwise continue at <address> */
441 mips_m4k_isa_filter(mips32
->isa_imp
, &address
);
442 buf_set_u32(mips32
->core_cache
->reg_list
[MIPS32_PC
].value
, 0, 32, address
);
443 mips32
->core_cache
->reg_list
[MIPS32_PC
].dirty
= true;
444 mips32
->core_cache
->reg_list
[MIPS32_PC
].valid
= true;
447 if ((mips32
->isa_imp
> 1) && debug_execution
) /* if more than one isa supported */
448 buf_set_u32(mips32
->core_cache
->reg_list
[MIPS32_PC
].value
, 0, 1, mips32
->isa_mode
);
453 resume_pc
= buf_get_u32(mips32
->core_cache
->reg_list
[MIPS32_PC
].value
, 0, 32);
455 mips32_restore_context(target
);
457 /* the front-end may request us not to handle breakpoints */
458 if (handle_breakpoints
) {
459 /* Single step past breakpoint at current address */
460 breakpoint
= breakpoint_find(target
, resume_pc
);
462 LOG_DEBUG("unset breakpoint at " TARGET_ADDR_FMT
"",
463 breakpoint
->address
);
464 mips_m4k_unset_breakpoint(target
, breakpoint
);
465 mips_m4k_single_step_core(target
);
466 mips_m4k_set_breakpoint(target
, breakpoint
);
470 /* enable interrupts if we are running */
471 mips32_enable_interrupts(target
, !debug_execution
);
473 /* exit debug mode */
474 mips_ejtag_exit_debug(ejtag_info
);
475 target
->debug_reason
= DBG_REASON_NOTHALTED
;
477 /* registers are now invalid */
478 register_cache_invalidate(mips32
->core_cache
);
480 if (!debug_execution
) {
481 target
->state
= TARGET_RUNNING
;
482 target_call_event_callbacks(target
, TARGET_EVENT_RESUMED
);
483 LOG_DEBUG("target resumed at 0x%" PRIx32
"", resume_pc
);
485 target
->state
= TARGET_DEBUG_RUNNING
;
486 target_call_event_callbacks(target
, TARGET_EVENT_DEBUG_RESUMED
);
487 LOG_DEBUG("target debug resumed at 0x%" PRIx32
"", resume_pc
);
493 static int mips_m4k_resume(struct target
*target
, int current
,
494 target_addr_t address
, int handle_breakpoints
, int debug_execution
)
496 int retval
= ERROR_OK
;
498 /* dummy resume for smp toggle in order to reduce gdb impact */
499 if ((target
->smp
) && (target
->gdb_service
->core
[1] != -1)) {
500 /* simulate a start and halt of target */
501 target
->gdb_service
->target
= NULL
;
502 target
->gdb_service
->core
[0] = target
->gdb_service
->core
[1];
503 /* fake resume at next poll we play the target core[1], see poll*/
504 target_call_event_callbacks(target
, TARGET_EVENT_RESUMED
);
508 retval
= mips_m4k_internal_restore(target
, current
, address
,
512 if (retval
== ERROR_OK
&& target
->smp
) {
513 target
->gdb_service
->core
[0] = -1;
514 retval
= mips_m4k_restore_smp(target
, address
, handle_breakpoints
);
520 static int mips_m4k_step(struct target
*target
, int current
,
521 target_addr_t address
, int handle_breakpoints
)
523 /* get pointers to arch-specific information */
524 struct mips32_common
*mips32
= target_to_mips32(target
);
525 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
526 struct breakpoint
*breakpoint
= NULL
;
528 if (target
->state
!= TARGET_HALTED
) {
529 LOG_WARNING("target not halted");
530 return ERROR_TARGET_NOT_HALTED
;
533 /* current = 1: continue on current pc, otherwise continue at <address> */
535 mips_m4k_isa_filter(mips32
->isa_imp
, &address
);
536 buf_set_u32(mips32
->core_cache
->reg_list
[MIPS32_PC
].value
, 0, 32, address
);
537 mips32
->core_cache
->reg_list
[MIPS32_PC
].dirty
= true;
538 mips32
->core_cache
->reg_list
[MIPS32_PC
].valid
= true;
541 /* the front-end may request us not to handle breakpoints */
542 if (handle_breakpoints
) {
543 breakpoint
= breakpoint_find(target
,
544 buf_get_u32(mips32
->core_cache
->reg_list
[MIPS32_PC
].value
, 0, 32));
546 mips_m4k_unset_breakpoint(target
, breakpoint
);
549 /* restore context */
550 mips32_restore_context(target
);
552 /* configure single step mode */
553 mips_ejtag_config_step(ejtag_info
, 1);
555 target
->debug_reason
= DBG_REASON_SINGLESTEP
;
557 target_call_event_callbacks(target
, TARGET_EVENT_RESUMED
);
559 /* disable interrupts while stepping */
560 mips32_enable_interrupts(target
, 0);
562 /* exit debug mode */
563 mips_ejtag_exit_debug(ejtag_info
);
565 /* registers are now invalid */
566 register_cache_invalidate(mips32
->core_cache
);
568 LOG_DEBUG("target stepped ");
569 mips_m4k_debug_entry(target
);
572 mips_m4k_set_breakpoint(target
, breakpoint
);
574 target_call_event_callbacks(target
, TARGET_EVENT_HALTED
);
579 static void mips_m4k_enable_breakpoints(struct target
*target
)
581 struct breakpoint
*breakpoint
= target
->breakpoints
;
583 /* set any pending breakpoints */
585 if (!breakpoint
->is_set
)
586 mips_m4k_set_breakpoint(target
, breakpoint
);
587 breakpoint
= breakpoint
->next
;
591 static int mips_m4k_set_breakpoint(struct target
*target
,
592 struct breakpoint
*breakpoint
)
594 struct mips32_common
*mips32
= target_to_mips32(target
);
595 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
596 struct mips32_comparator
*comparator_list
= mips32
->inst_break_list
;
599 if (breakpoint
->is_set
) {
600 LOG_WARNING("breakpoint already set");
604 if (breakpoint
->type
== BKPT_HARD
) {
607 while (comparator_list
[bp_num
].used
&& (bp_num
< mips32
->num_inst_bpoints
))
609 if (bp_num
>= mips32
->num_inst_bpoints
) {
610 LOG_ERROR("Can not find free FP Comparator(bpid: %" PRIu32
")",
611 breakpoint
->unique_id
);
612 return ERROR_TARGET_RESOURCE_NOT_AVAILABLE
;
614 breakpoint_hw_set(breakpoint
, bp_num
);
615 comparator_list
[bp_num
].used
= 1;
616 comparator_list
[bp_num
].bp_value
= breakpoint
->address
;
618 if (breakpoint
->length
!= 4) /* make sure isa bit set */
619 comparator_list
[bp_num
].bp_value
|= 1;
620 else /* make sure isa bit cleared */
621 comparator_list
[bp_num
].bp_value
&= ~1;
623 /* EJTAG 2.0 uses 30bit IBA. First 2 bits are reserved.
624 * Warning: there is no IB ASID registers in 2.0.
625 * Do not set it! :) */
626 if (ejtag_info
->ejtag_version
== EJTAG_VERSION_20
)
627 comparator_list
[bp_num
].bp_value
&= 0xFFFFFFFC;
629 target_write_u32(target
, comparator_list
[bp_num
].reg_address
,
630 comparator_list
[bp_num
].bp_value
);
631 target_write_u32(target
, comparator_list
[bp_num
].reg_address
+
632 ejtag_info
->ejtag_ibm_offs
, 0x00000000);
633 target_write_u32(target
, comparator_list
[bp_num
].reg_address
+
634 ejtag_info
->ejtag_ibc_offs
, 1);
635 LOG_DEBUG("bpid: %" PRIu32
", bp_num %i bp_value 0x%" PRIx32
"",
636 breakpoint
->unique_id
,
637 bp_num
, comparator_list
[bp_num
].bp_value
);
638 } else if (breakpoint
->type
== BKPT_SOFT
) {
639 LOG_DEBUG("bpid: %" PRIu32
, breakpoint
->unique_id
);
641 uint32_t isa_req
= breakpoint
->length
& 1; /* micro mips request bit */
642 uint32_t bplength
= breakpoint
->length
& ~1; /* drop micro mips request bit for length */
643 uint32_t bpaddr
= breakpoint
->address
& ~1; /* drop isa bit from address, if set */
646 uint32_t verify
= 0xffffffff;
647 uint32_t sdbbp32_instr
= MIPS32_SDBBP(isa_req
);
648 if (ejtag_info
->endianness
&& isa_req
)
649 sdbbp32_instr
= SWAP16(sdbbp32_instr
);
651 if ((breakpoint
->address
& 3) == 0) { /* word aligned */
653 retval
= target_read_memory(target
, bpaddr
, bplength
, 1, breakpoint
->orig_instr
);
654 if (retval
!= ERROR_OK
)
657 retval
= target_write_u32(target
, bpaddr
, sdbbp32_instr
);
658 if (retval
!= ERROR_OK
)
661 retval
= target_read_u32(target
, bpaddr
, &verify
);
662 if (retval
!= ERROR_OK
)
665 if (verify
!= sdbbp32_instr
)
668 } else { /* 16 bit aligned */
669 retval
= target_read_memory(target
, bpaddr
, 2, 2, breakpoint
->orig_instr
);
670 if (retval
!= ERROR_OK
)
673 uint8_t sdbbp_buf
[4];
674 target_buffer_set_u32(target
, sdbbp_buf
, sdbbp32_instr
);
676 retval
= target_write_memory(target
, bpaddr
, 2, 2, sdbbp_buf
);
677 if (retval
!= ERROR_OK
)
680 retval
= target_read_memory(target
, bpaddr
, 2, 2, sdbbp_buf
);
681 if (retval
!= ERROR_OK
)
684 if (target_buffer_get_u32(target
, sdbbp_buf
) != sdbbp32_instr
)
689 LOG_ERROR("Unable to set 32bit breakpoint at address %08" TARGET_PRIxADDR
690 " - check that memory is read/writable", breakpoint
->address
);
695 uint16_t verify
= 0xffff;
697 retval
= target_read_memory(target
, bpaddr
, bplength
, 1, breakpoint
->orig_instr
);
698 if (retval
!= ERROR_OK
)
701 retval
= target_write_u16(target
, bpaddr
, MIPS16_SDBBP(isa_req
));
702 if (retval
!= ERROR_OK
)
705 retval
= target_read_u16(target
, bpaddr
, &verify
);
706 if (retval
!= ERROR_OK
)
709 if (verify
!= MIPS16_SDBBP(isa_req
)) {
710 LOG_ERROR("Unable to set 16bit breakpoint at address %08" TARGET_PRIxADDR
711 " - check that memory is read/writable", breakpoint
->address
);
716 breakpoint
->is_set
= true;
722 static int mips_m4k_unset_breakpoint(struct target
*target
,
723 struct breakpoint
*breakpoint
)
725 /* get pointers to arch-specific information */
726 struct mips32_common
*mips32
= target_to_mips32(target
);
727 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
728 struct mips32_comparator
*comparator_list
= mips32
->inst_break_list
;
731 if (!breakpoint
->is_set
) {
732 LOG_WARNING("breakpoint not set");
736 if (breakpoint
->type
== BKPT_HARD
) {
737 int bp_num
= breakpoint
->number
;
738 if (bp_num
>= mips32
->num_inst_bpoints
) {
739 LOG_DEBUG("Invalid FP Comparator number in breakpoint (bpid: %" PRIu32
")",
740 breakpoint
->unique_id
);
743 LOG_DEBUG("bpid: %" PRIu32
" - releasing hw: %d",
744 breakpoint
->unique_id
,
746 comparator_list
[bp_num
].used
= 0;
747 comparator_list
[bp_num
].bp_value
= 0;
748 target_write_u32(target
, comparator_list
[bp_num
].reg_address
+
749 ejtag_info
->ejtag_ibc_offs
, 0);
752 /* restore original instruction (kept in target endianness) */
753 uint32_t isa_req
= breakpoint
->length
& 1;
754 uint32_t bplength
= breakpoint
->length
& ~1;
755 uint8_t current_instr
[4];
756 LOG_DEBUG("bpid: %" PRIu32
, breakpoint
->unique_id
);
758 uint32_t sdbbp32_instr
= MIPS32_SDBBP(isa_req
);
759 if (ejtag_info
->endianness
&& isa_req
)
760 sdbbp32_instr
= SWAP16(sdbbp32_instr
);
762 if ((breakpoint
->address
& 3) == 0) { /* 32bit aligned */
763 /* check that user program has not modified breakpoint instruction */
764 retval
= target_read_memory(target
, breakpoint
->address
, 4, 1, current_instr
);
765 if (retval
!= ERROR_OK
)
768 * target_read_memory() gets us data in _target_ endianness.
769 * If we want to use this data on the host for comparisons with some macros
770 * we must first transform it to _host_ endianness using target_buffer_get_u16().
772 if (sdbbp32_instr
== target_buffer_get_u32(target
, current_instr
)) {
773 retval
= target_write_memory(target
, breakpoint
->address
, 4, 1,
774 breakpoint
->orig_instr
);
775 if (retval
!= ERROR_OK
)
778 } else { /* 16bit aligned */
779 retval
= target_read_memory(target
, breakpoint
->address
, 2, 2, current_instr
);
780 if (retval
!= ERROR_OK
)
783 if (sdbbp32_instr
== target_buffer_get_u32(target
, current_instr
)) {
784 retval
= target_write_memory(target
, breakpoint
->address
, 2, 2,
785 breakpoint
->orig_instr
);
786 if (retval
!= ERROR_OK
)
791 /* check that user program has not modified breakpoint instruction */
792 retval
= target_read_memory(target
, breakpoint
->address
, 2, 1, current_instr
);
793 if (retval
!= ERROR_OK
)
796 if (target_buffer_get_u16(target
, current_instr
) == MIPS16_SDBBP(isa_req
)) {
797 retval
= target_write_memory(target
, breakpoint
->address
, 2, 1,
798 breakpoint
->orig_instr
);
799 if (retval
!= ERROR_OK
)
805 breakpoint
->is_set
= false;
810 static int mips_m4k_add_breakpoint(struct target
*target
, struct breakpoint
*breakpoint
)
812 struct mips32_common
*mips32
= target_to_mips32(target
);
814 if ((breakpoint
->length
> 5 || breakpoint
->length
< 2) || /* out of range */
815 (breakpoint
->length
== 4 && (breakpoint
->address
& 2)) || /* mips32 unaligned */
816 (mips32
->isa_imp
== MIPS32_ONLY
&& breakpoint
->length
!= 4) || /* misp32 specific */
817 ((mips32
->isa_imp
& 1) != (breakpoint
->length
& 1))) /* isa not implemented */
818 return ERROR_TARGET_RESOURCE_NOT_AVAILABLE
;
820 if (breakpoint
->type
== BKPT_HARD
) {
821 if (mips32
->num_inst_bpoints_avail
< 1) {
822 LOG_INFO("no hardware breakpoint available");
823 return ERROR_TARGET_RESOURCE_NOT_AVAILABLE
;
826 mips32
->num_inst_bpoints_avail
--;
829 return mips_m4k_set_breakpoint(target
, breakpoint
);
832 static int mips_m4k_remove_breakpoint(struct target
*target
,
833 struct breakpoint
*breakpoint
)
835 /* get pointers to arch-specific information */
836 struct mips32_common
*mips32
= target_to_mips32(target
);
838 if (target
->state
!= TARGET_HALTED
) {
839 LOG_WARNING("target not halted");
840 return ERROR_TARGET_NOT_HALTED
;
843 if (breakpoint
->is_set
)
844 mips_m4k_unset_breakpoint(target
, breakpoint
);
846 if (breakpoint
->type
== BKPT_HARD
)
847 mips32
->num_inst_bpoints_avail
++;
852 static int mips_m4k_set_watchpoint(struct target
*target
,
853 struct watchpoint
*watchpoint
)
855 struct mips32_common
*mips32
= target_to_mips32(target
);
856 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
857 struct mips32_comparator
*comparator_list
= mips32
->data_break_list
;
860 * watchpoint enabled, ignore all byte lanes in value register
861 * and exclude both load and store accesses from watchpoint
862 * condition evaluation
864 int enable
= EJTAG_DBCN_NOSB
| EJTAG_DBCN_NOLB
| EJTAG_DBCN_BE
|
865 (0xff << EJTAG_DBCN_BLM_SHIFT
);
867 if (watchpoint
->is_set
) {
868 LOG_WARNING("watchpoint already set");
872 while (comparator_list
[wp_num
].used
&& (wp_num
< mips32
->num_data_bpoints
))
874 if (wp_num
>= mips32
->num_data_bpoints
) {
875 LOG_ERROR("Can not find free FP Comparator");
879 if (watchpoint
->length
!= 4) {
880 LOG_ERROR("Only watchpoints of length 4 are supported");
881 return ERROR_TARGET_UNALIGNED_ACCESS
;
884 if (watchpoint
->address
% 4) {
885 LOG_ERROR("Watchpoints address should be word aligned");
886 return ERROR_TARGET_UNALIGNED_ACCESS
;
889 switch (watchpoint
->rw
) {
891 enable
&= ~EJTAG_DBCN_NOLB
;
894 enable
&= ~EJTAG_DBCN_NOSB
;
897 enable
&= ~(EJTAG_DBCN_NOLB
| EJTAG_DBCN_NOSB
);
900 LOG_ERROR("BUG: watchpoint->rw neither read, write nor access");
903 watchpoint
->number
= wp_num
;
904 comparator_list
[wp_num
].used
= 1;
905 comparator_list
[wp_num
].bp_value
= watchpoint
->address
;
907 /* EJTAG 2.0 uses 29bit DBA. First 3 bits are reserved.
908 * There is as well no ASID register support. */
909 if (ejtag_info
->ejtag_version
== EJTAG_VERSION_20
)
910 comparator_list
[wp_num
].bp_value
&= 0xFFFFFFF8;
912 target_write_u32(target
, comparator_list
[wp_num
].reg_address
+
913 ejtag_info
->ejtag_dbasid_offs
, 0x00000000);
915 target_write_u32(target
, comparator_list
[wp_num
].reg_address
,
916 comparator_list
[wp_num
].bp_value
);
917 target_write_u32(target
, comparator_list
[wp_num
].reg_address
+
918 ejtag_info
->ejtag_dbm_offs
, 0x00000000);
920 target_write_u32(target
, comparator_list
[wp_num
].reg_address
+
921 ejtag_info
->ejtag_dbc_offs
, enable
);
922 /* TODO: probably this value is ignored on 2.0 */
923 target_write_u32(target
, comparator_list
[wp_num
].reg_address
+
924 ejtag_info
->ejtag_dbv_offs
, 0);
925 LOG_DEBUG("wp_num %i bp_value 0x%" PRIx32
"", wp_num
, comparator_list
[wp_num
].bp_value
);
930 static int mips_m4k_unset_watchpoint(struct target
*target
,
931 struct watchpoint
*watchpoint
)
933 /* get pointers to arch-specific information */
934 struct mips32_common
*mips32
= target_to_mips32(target
);
935 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
936 struct mips32_comparator
*comparator_list
= mips32
->data_break_list
;
938 if (!watchpoint
->is_set
) {
939 LOG_WARNING("watchpoint not set");
943 int wp_num
= watchpoint
->number
;
944 if (wp_num
>= mips32
->num_data_bpoints
) {
945 LOG_DEBUG("Invalid FP Comparator number in watchpoint");
948 comparator_list
[wp_num
].used
= 0;
949 comparator_list
[wp_num
].bp_value
= 0;
950 target_write_u32(target
, comparator_list
[wp_num
].reg_address
+
951 ejtag_info
->ejtag_dbc_offs
, 0);
952 watchpoint
->is_set
= false;
957 static int mips_m4k_add_watchpoint(struct target
*target
, struct watchpoint
*watchpoint
)
959 struct mips32_common
*mips32
= target_to_mips32(target
);
961 if (mips32
->num_data_bpoints_avail
< 1) {
962 LOG_INFO("no hardware watchpoints available");
963 return ERROR_TARGET_RESOURCE_NOT_AVAILABLE
;
966 mips32
->num_data_bpoints_avail
--;
968 mips_m4k_set_watchpoint(target
, watchpoint
);
972 static int mips_m4k_remove_watchpoint(struct target
*target
,
973 struct watchpoint
*watchpoint
)
975 /* get pointers to arch-specific information */
976 struct mips32_common
*mips32
= target_to_mips32(target
);
978 if (target
->state
!= TARGET_HALTED
) {
979 LOG_WARNING("target not halted");
980 return ERROR_TARGET_NOT_HALTED
;
983 if (watchpoint
->is_set
)
984 mips_m4k_unset_watchpoint(target
, watchpoint
);
986 mips32
->num_data_bpoints_avail
++;
991 static void mips_m4k_enable_watchpoints(struct target
*target
)
993 struct watchpoint
*watchpoint
= target
->watchpoints
;
995 /* set any pending watchpoints */
997 if (!watchpoint
->is_set
)
998 mips_m4k_set_watchpoint(target
, watchpoint
);
999 watchpoint
= watchpoint
->next
;
1003 static int mips_m4k_read_memory(struct target
*target
, target_addr_t address
,
1004 uint32_t size
, uint32_t count
, uint8_t *buffer
)
1006 struct mips32_common
*mips32
= target_to_mips32(target
);
1007 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
1009 LOG_DEBUG("address: " TARGET_ADDR_FMT
", size: 0x%8.8" PRIx32
", count: 0x%8.8" PRIx32
"",
1010 address
, size
, count
);
1012 if (target
->state
!= TARGET_HALTED
) {
1013 LOG_WARNING("target not halted");
1014 return ERROR_TARGET_NOT_HALTED
;
1017 /* sanitize arguments */
1018 if (((size
!= 4) && (size
!= 2) && (size
!= 1)) || (count
== 0) || !(buffer
))
1019 return ERROR_COMMAND_SYNTAX_ERROR
;
1021 if (((size
== 4) && (address
& 0x3u
)) || ((size
== 2) && (address
& 0x1u
)))
1022 return ERROR_TARGET_UNALIGNED_ACCESS
;
1024 /* since we don't know if buffer is aligned, we allocate new mem that is always aligned */
1028 t
= malloc(count
* size
* sizeof(uint8_t));
1030 LOG_ERROR("Out of memory");
1036 /* if noDMA off, use DMAACC mode for memory read */
1038 if (ejtag_info
->impcode
& EJTAG_IMP_NODMA
)
1039 retval
= mips32_pracc_read_mem(ejtag_info
, address
, size
, count
, t
);
1041 retval
= mips32_dmaacc_read_mem(ejtag_info
, address
, size
, count
, t
);
1043 /* mips32_..._read_mem with size 4/2 returns uint32_t/uint16_t in host */
1044 /* endianness, but byte array should represent target endianness */
1045 if (retval
== ERROR_OK
) {
1048 target_buffer_set_u32_array(target
, buffer
, count
, t
);
1051 target_buffer_set_u16_array(target
, buffer
, count
, t
);
1062 static int mips_m4k_write_memory(struct target
*target
, target_addr_t address
,
1063 uint32_t size
, uint32_t count
, const uint8_t *buffer
)
1065 struct mips32_common
*mips32
= target_to_mips32(target
);
1066 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
1068 LOG_DEBUG("address: " TARGET_ADDR_FMT
", size: 0x%8.8" PRIx32
", count: 0x%8.8" PRIx32
"",
1069 address
, size
, count
);
1071 if (target
->state
!= TARGET_HALTED
) {
1072 LOG_WARNING("target not halted");
1073 return ERROR_TARGET_NOT_HALTED
;
1076 if (size
== 4 && count
> 32) {
1077 int retval
= mips_m4k_bulk_write_memory(target
, address
, count
, buffer
);
1078 if (retval
== ERROR_OK
)
1080 LOG_WARNING("Falling back to non-bulk write");
1083 /* sanitize arguments */
1084 if (((size
!= 4) && (size
!= 2) && (size
!= 1)) || (count
== 0) || !(buffer
))
1085 return ERROR_COMMAND_SYNTAX_ERROR
;
1087 if (((size
== 4) && (address
& 0x3u
)) || ((size
== 2) && (address
& 0x1u
)))
1088 return ERROR_TARGET_UNALIGNED_ACCESS
;
1090 /** correct endianness if we have word or hword access */
1093 /* mips32_..._write_mem with size 4/2 requires uint32_t/uint16_t in host */
1094 /* endianness, but byte array represents target endianness */
1095 t
= malloc(count
* size
* sizeof(uint8_t));
1097 LOG_ERROR("Out of memory");
1103 target_buffer_get_u32_array(target
, buffer
, count
, (uint32_t *)t
);
1106 target_buffer_get_u16_array(target
, buffer
, count
, (uint16_t *)t
);
1112 /* if noDMA off, use DMAACC mode for memory write */
1114 if (ejtag_info
->impcode
& EJTAG_IMP_NODMA
)
1115 retval
= mips32_pracc_write_mem(ejtag_info
, address
, size
, count
, buffer
);
1117 retval
= mips32_dmaacc_write_mem(ejtag_info
, address
, size
, count
, buffer
);
1121 if (retval
!= ERROR_OK
)
1127 static int mips_m4k_init_target(struct command_context
*cmd_ctx
,
1128 struct target
*target
)
1130 mips32_build_reg_cache(target
);
1135 static int mips_m4k_init_arch_info(struct target
*target
,
1136 struct mips_m4k_common
*mips_m4k
, struct jtag_tap
*tap
)
1138 struct mips32_common
*mips32
= &mips_m4k
->mips32
;
1140 mips_m4k
->common_magic
= MIPSM4K_COMMON_MAGIC
;
1142 /* initialize mips4k specific info */
1143 mips32_init_arch_info(target
, mips32
, tap
);
1144 mips32
->arch_info
= mips_m4k
;
1149 static int mips_m4k_target_create(struct target
*target
, Jim_Interp
*interp
)
1151 struct mips_m4k_common
*mips_m4k
= calloc(1, sizeof(struct mips_m4k_common
));
1153 mips_m4k_init_arch_info(target
, mips_m4k
, target
->tap
);
1158 static int mips_m4k_examine(struct target
*target
)
1160 struct mips_m4k_common
*mips_m4k
= target_to_m4k(target
);
1161 struct mips_ejtag
*ejtag_info
= &mips_m4k
->mips32
.ejtag_info
;
1163 if (!target_was_examined(target
)) {
1164 int retval
= mips_ejtag_get_idcode(ejtag_info
);
1165 if (retval
!= ERROR_OK
) {
1166 LOG_ERROR("idcode read failed");
1169 if (((ejtag_info
->idcode
>> 1) & 0x7FF) == 0x29) {
1170 /* we are using a pic32mx so select ejtag port
1171 * as it is not selected by default */
1172 mips_ejtag_set_instr(ejtag_info
, MTAP_SW_ETAP
);
1173 LOG_DEBUG("PIC32 Detected - using EJTAG Interface");
1174 mips_m4k
->is_pic32mx
= true;
1178 /* init rest of ejtag interface */
1179 int retval
= mips_ejtag_init(ejtag_info
);
1180 if (retval
!= ERROR_OK
)
1183 return mips32_examine(target
);
1186 static int mips_m4k_bulk_write_memory(struct target
*target
, target_addr_t address
,
1187 uint32_t count
, const uint8_t *buffer
)
1189 struct mips32_common
*mips32
= target_to_mips32(target
);
1190 struct mips_ejtag
*ejtag_info
= &mips32
->ejtag_info
;
1191 struct working_area
*fast_data_area
;
1195 LOG_DEBUG("address: " TARGET_ADDR_FMT
", count: 0x%8.8" PRIx32
"",
1198 /* check alignment */
1200 return ERROR_TARGET_UNALIGNED_ACCESS
;
1202 if (!mips32
->fast_data_area
) {
1203 /* Get memory for block write handler
1204 * we preserve this area between calls and gain a speed increase
1205 * of about 3kb/sec when writing flash
1206 * this will be released/nulled by the system when the target is resumed or reset */
1207 retval
= target_alloc_working_area(target
,
1208 MIPS32_FASTDATA_HANDLER_SIZE
,
1209 &mips32
->fast_data_area
);
1210 if (retval
!= ERROR_OK
) {
1211 LOG_ERROR("No working area available");
1215 /* reset fastadata state so the algo get reloaded */
1216 ejtag_info
->fast_access_save
= -1;
1219 fast_data_area
= mips32
->fast_data_area
;
1221 if (address
<= fast_data_area
->address
+ fast_data_area
->size
&&
1222 fast_data_area
->address
<= address
+ count
) {
1223 LOG_ERROR("fast_data (" TARGET_ADDR_FMT
") is within write area "
1224 "(" TARGET_ADDR_FMT
"-" TARGET_ADDR_FMT
").",
1225 fast_data_area
->address
, address
, address
+ count
);
1226 LOG_ERROR("Change work-area-phys or load_image address!");
1230 /* mips32_pracc_fastdata_xfer requires uint32_t in host endianness, */
1231 /* but byte array represents target endianness */
1233 t
= malloc(count
* sizeof(uint32_t));
1235 LOG_ERROR("Out of memory");
1239 target_buffer_get_u32_array(target
, buffer
, count
, t
);
1241 retval
= mips32_pracc_fastdata_xfer(ejtag_info
, mips32
->fast_data_area
, write_t
, address
,
1246 if (retval
!= ERROR_OK
)
1247 LOG_ERROR("Fastdata access Failed");
1252 static int mips_m4k_verify_pointer(struct command_invocation
*cmd
,
1253 struct mips_m4k_common
*mips_m4k
)
1255 if (mips_m4k
->common_magic
!= MIPSM4K_COMMON_MAGIC
) {
1256 command_print(cmd
, "target is not an MIPS_M4K");
1257 return ERROR_TARGET_INVALID
;
1262 COMMAND_HANDLER(mips_m4k_handle_cp0_command
)
1265 struct target
*target
= get_current_target(CMD_CTX
);
1266 struct mips_m4k_common
*mips_m4k
= target_to_m4k(target
);
1267 struct mips_ejtag
*ejtag_info
= &mips_m4k
->mips32
.ejtag_info
;
1269 retval
= mips_m4k_verify_pointer(CMD
, mips_m4k
);
1270 if (retval
!= ERROR_OK
)
1273 if (target
->state
!= TARGET_HALTED
) {
1274 command_print(CMD
, "target must be stopped for \"%s\" command", CMD_NAME
);
1278 /* two or more argument, access a single register/select (write if third argument is given) */
1280 return ERROR_COMMAND_SYNTAX_ERROR
;
1282 uint32_t cp0_reg
, cp0_sel
;
1283 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[0], cp0_reg
);
1284 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[1], cp0_sel
);
1286 if (CMD_ARGC
== 2) {
1288 retval
= mips32_cp0_read(ejtag_info
, &value
, cp0_reg
, cp0_sel
);
1289 if (retval
!= ERROR_OK
) {
1291 "couldn't access reg %" PRIu32
,
1295 command_print(CMD
, "cp0 reg %" PRIu32
", select %" PRIu32
": %8.8" PRIx32
,
1296 cp0_reg
, cp0_sel
, value
);
1298 } else if (CMD_ARGC
== 3) {
1300 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[2], value
);
1301 retval
= mips32_cp0_write(ejtag_info
, value
, cp0_reg
, cp0_sel
);
1302 if (retval
!= ERROR_OK
) {
1304 "couldn't access cp0 reg %" PRIu32
", select %" PRIu32
,
1308 command_print(CMD
, "cp0 reg %" PRIu32
", select %" PRIu32
": %8.8" PRIx32
,
1309 cp0_reg
, cp0_sel
, value
);
1316 COMMAND_HANDLER(mips_m4k_handle_scan_delay_command
)
1318 struct target
*target
= get_current_target(CMD_CTX
);
1319 struct mips_m4k_common
*mips_m4k
= target_to_m4k(target
);
1320 struct mips_ejtag
*ejtag_info
= &mips_m4k
->mips32
.ejtag_info
;
1323 COMMAND_PARSE_NUMBER(uint
, CMD_ARGV
[0], ejtag_info
->scan_delay
);
1324 else if (CMD_ARGC
> 1)
1325 return ERROR_COMMAND_SYNTAX_ERROR
;
1327 command_print(CMD
, "scan delay: %d nsec", ejtag_info
->scan_delay
);
1328 if (ejtag_info
->scan_delay
>= MIPS32_SCAN_DELAY_LEGACY_MODE
) {
1329 ejtag_info
->mode
= 0;
1330 command_print(CMD
, "running in legacy mode");
1332 ejtag_info
->mode
= 1;
1333 command_print(CMD
, "running in fast queued mode");
1339 static const struct command_registration mips_m4k_exec_command_handlers
[] = {
1342 .handler
= mips_m4k_handle_cp0_command
,
1343 .mode
= COMMAND_EXEC
,
1344 .usage
= "regnum [value]",
1345 .help
= "display/modify cp0 register",
1348 .name
= "scan_delay",
1349 .handler
= mips_m4k_handle_scan_delay_command
,
1350 .mode
= COMMAND_ANY
,
1351 .help
= "display/set scan delay in nano seconds",
1355 .chain
= smp_command_handlers
,
1357 COMMAND_REGISTRATION_DONE
1360 static const struct command_registration mips_m4k_command_handlers
[] = {
1362 .chain
= mips32_command_handlers
,
1366 .mode
= COMMAND_ANY
,
1367 .help
= "mips_m4k command group",
1369 .chain
= mips_m4k_exec_command_handlers
,
1371 COMMAND_REGISTRATION_DONE
1374 struct target_type mips_m4k_target
= {
1377 .poll
= mips_m4k_poll
,
1378 .arch_state
= mips32_arch_state
,
1380 .halt
= mips_m4k_halt
,
1381 .resume
= mips_m4k_resume
,
1382 .step
= mips_m4k_step
,
1384 .assert_reset
= mips_m4k_assert_reset
,
1385 .deassert_reset
= mips_m4k_deassert_reset
,
1387 .get_gdb_reg_list
= mips32_get_gdb_reg_list
,
1389 .read_memory
= mips_m4k_read_memory
,
1390 .write_memory
= mips_m4k_write_memory
,
1391 .checksum_memory
= mips32_checksum_memory
,
1392 .blank_check_memory
= mips32_blank_check_memory
,
1394 .run_algorithm
= mips32_run_algorithm
,
1396 .add_breakpoint
= mips_m4k_add_breakpoint
,
1397 .remove_breakpoint
= mips_m4k_remove_breakpoint
,
1398 .add_watchpoint
= mips_m4k_add_watchpoint
,
1399 .remove_watchpoint
= mips_m4k_remove_watchpoint
,
1401 .commands
= mips_m4k_command_handlers
,
1402 .target_create
= mips_m4k_target_create
,
1403 .init_target
= mips_m4k_init_target
,
1404 .examine
= mips_m4k_examine
,