1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) 2009 by David Brownell
13 #include "armv8_dpm.h"
14 #include <jtag/jtag.h>
16 #include "breakpoints.h"
17 #include "target_type.h"
18 #include "armv8_opcodes.h"
20 #include "helper/time_support.h"
23 #define T32_FMTITR(instr) (((instr & 0x0000FFFF) << 16) | ((instr & 0xFFFF0000) >> 16))
27 * Implements various ARM DPM operations using architectural debug registers.
28 * These routines layer over core-specific communication methods to cope with
29 * implementation differences between cores like ARM1136 and Cortex-A8.
31 * The "Debug Programmers' Model" (DPM) for ARMv6 and ARMv7 is defined by
32 * Part C (Debug Architecture) of the ARM Architecture Reference Manual,
33 * ARMv7-A and ARMv7-R edition (ARM DDI 0406B). In OpenOCD, DPM operations
34 * are abstracted through internal programming interfaces to share code and
35 * to minimize needless differences in debug behavior between cores.
39 * Get core state from EDSCR, without necessity to retrieve CPSR
41 enum arm_state
armv8_dpm_get_core_state(struct arm_dpm
*dpm
)
43 int el
= (dpm
->dscr
>> 8) & 0x3;
44 int rw
= (dpm
->dscr
>> 10) & 0xF;
48 /* In Debug state, each bit gives the current Execution state of each EL */
50 return ARM_STATE_AARCH64
;
55 /*----------------------------------------------------------------------*/
57 static int dpmv8_write_dcc(struct armv8_common
*armv8
, uint32_t data
)
59 return mem_ap_write_u32(armv8
->debug_ap
,
60 armv8
->debug_base
+ CPUV8_DBG_DTRRX
, data
);
63 static int dpmv8_write_dcc_64(struct armv8_common
*armv8
, uint64_t data
)
66 ret
= mem_ap_write_u32(armv8
->debug_ap
,
67 armv8
->debug_base
+ CPUV8_DBG_DTRRX
, data
);
69 ret
= mem_ap_write_u32(armv8
->debug_ap
,
70 armv8
->debug_base
+ CPUV8_DBG_DTRTX
, data
>> 32);
74 static int dpmv8_read_dcc(struct armv8_common
*armv8
, uint32_t *data
,
77 uint32_t dscr
= DSCR_ITE
;
83 /* Wait for DTRRXfull */
84 long long then
= timeval_ms();
85 while ((dscr
& DSCR_DTR_TX_FULL
) == 0) {
86 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
87 armv8
->debug_base
+ CPUV8_DBG_DSCR
,
89 if (retval
!= ERROR_OK
)
91 if (timeval_ms() > then
+ 1000) {
92 LOG_ERROR("Timeout waiting for read dcc");
97 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
98 armv8
->debug_base
+ CPUV8_DBG_DTRTX
,
100 if (retval
!= ERROR_OK
)
109 static int dpmv8_read_dcc_64(struct armv8_common
*armv8
, uint64_t *data
,
112 uint32_t dscr
= DSCR_ITE
;
119 /* Wait for DTRRXfull */
120 long long then
= timeval_ms();
121 while ((dscr
& DSCR_DTR_TX_FULL
) == 0) {
122 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
123 armv8
->debug_base
+ CPUV8_DBG_DSCR
,
125 if (retval
!= ERROR_OK
)
127 if (timeval_ms() > then
+ 1000) {
128 LOG_ERROR("Timeout waiting for DTR_TX_FULL, dscr = 0x%08" PRIx32
, dscr
);
133 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
134 armv8
->debug_base
+ CPUV8_DBG_DTRTX
,
136 if (retval
!= ERROR_OK
)
139 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
140 armv8
->debug_base
+ CPUV8_DBG_DTRRX
,
142 if (retval
!= ERROR_OK
)
145 *data
= *(uint32_t *)data
| (uint64_t)higher
<< 32;
153 static int dpmv8_dpm_prepare(struct arm_dpm
*dpm
)
155 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
159 /* set up invariant: ITE is set after ever DPM operation */
160 long long then
= timeval_ms();
162 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
163 armv8
->debug_base
+ CPUV8_DBG_DSCR
,
165 if (retval
!= ERROR_OK
)
167 if ((dscr
& DSCR_ITE
) != 0)
169 if (timeval_ms() > then
+ 1000) {
170 LOG_ERROR("Timeout waiting for dpm prepare");
175 /* update the stored copy of dscr */
178 /* this "should never happen" ... */
179 if (dscr
& DSCR_DTR_RX_FULL
) {
180 LOG_ERROR("DSCR_DTR_RX_FULL, dscr 0x%08" PRIx32
, dscr
);
182 retval
= mem_ap_read_u32(armv8
->debug_ap
,
183 armv8
->debug_base
+ CPUV8_DBG_DTRRX
, &dscr
);
184 if (retval
!= ERROR_OK
)
191 static int dpmv8_dpm_finish(struct arm_dpm
*dpm
)
193 /* REVISIT what could be done here? */
197 static int dpmv8_exec_opcode(struct arm_dpm
*dpm
,
198 uint32_t opcode
, uint32_t *p_dscr
)
200 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
201 uint32_t dscr
= dpm
->dscr
;
207 /* Wait for InstrCompl bit to be set */
208 long long then
= timeval_ms();
209 while ((dscr
& DSCR_ITE
) == 0) {
210 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
211 armv8
->debug_base
+ CPUV8_DBG_DSCR
, &dscr
);
212 if (retval
!= ERROR_OK
) {
213 LOG_ERROR("Could not read DSCR register, opcode = 0x%08" PRIx32
, opcode
);
216 if (timeval_ms() > then
+ 1000) {
217 LOG_ERROR("Timeout waiting for aarch64_exec_opcode");
222 if (armv8_dpm_get_core_state(dpm
) != ARM_STATE_AARCH64
)
223 opcode
= T32_FMTITR(opcode
);
225 retval
= mem_ap_write_u32(armv8
->debug_ap
,
226 armv8
->debug_base
+ CPUV8_DBG_ITR
, opcode
);
227 if (retval
!= ERROR_OK
)
232 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
233 armv8
->debug_base
+ CPUV8_DBG_DSCR
, &dscr
);
234 if (retval
!= ERROR_OK
) {
235 LOG_ERROR("Could not read DSCR register");
238 if (timeval_ms() > then
+ 1000) {
239 LOG_ERROR("Timeout waiting for aarch64_exec_opcode");
242 } while ((dscr
& DSCR_ITE
) == 0); /* Wait for InstrCompl bit to be set */
244 /* update dscr and el after each command execution */
246 if (dpm
->last_el
!= ((dscr
>> 8) & 3))
247 LOG_DEBUG("EL %i -> %" PRIu32
, dpm
->last_el
, (dscr
>> 8) & 3);
248 dpm
->last_el
= (dscr
>> 8) & 3;
250 if (dscr
& DSCR_ERR
) {
251 LOG_ERROR("Opcode 0x%08" PRIx32
", DSCR.ERR=1, DSCR.EL=%i", opcode
, dpm
->last_el
);
252 armv8_dpm_handle_exception(dpm
, true);
262 static int dpmv8_instr_execute(struct arm_dpm
*dpm
, uint32_t opcode
)
264 return dpmv8_exec_opcode(dpm
, opcode
, NULL
);
267 static int dpmv8_instr_write_data_dcc(struct arm_dpm
*dpm
,
268 uint32_t opcode
, uint32_t data
)
270 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
273 retval
= dpmv8_write_dcc(armv8
, data
);
274 if (retval
!= ERROR_OK
)
277 return dpmv8_exec_opcode(dpm
, opcode
, NULL
);
280 static int dpmv8_instr_write_data_dcc_64(struct arm_dpm
*dpm
,
281 uint32_t opcode
, uint64_t data
)
283 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
286 retval
= dpmv8_write_dcc_64(armv8
, data
);
287 if (retval
!= ERROR_OK
)
290 return dpmv8_exec_opcode(dpm
, opcode
, NULL
);
293 static int dpmv8_instr_write_data_r0(struct arm_dpm
*dpm
,
294 uint32_t opcode
, uint32_t data
)
296 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
297 uint32_t dscr
= DSCR_ITE
;
300 retval
= dpmv8_write_dcc(armv8
, data
);
301 if (retval
!= ERROR_OK
)
304 retval
= dpmv8_exec_opcode(dpm
, armv8_opcode(armv8
, READ_REG_DTRRX
), &dscr
);
305 if (retval
!= ERROR_OK
)
308 /* then the opcode, taking data from R0 */
309 return dpmv8_exec_opcode(dpm
, opcode
, &dscr
);
312 static int dpmv8_instr_write_data_r0_64(struct arm_dpm
*dpm
,
313 uint32_t opcode
, uint64_t data
)
315 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
318 if (dpm
->arm
->core_state
!= ARM_STATE_AARCH64
)
319 return dpmv8_instr_write_data_r0(dpm
, opcode
, data
);
321 /* transfer data from DCC to R0 */
322 retval
= dpmv8_write_dcc_64(armv8
, data
);
323 if (retval
== ERROR_OK
)
324 retval
= dpmv8_exec_opcode(dpm
, ARMV8_MRS(SYSTEM_DBG_DBGDTR_EL0
, 0), &dpm
->dscr
);
326 /* then the opcode, taking data from R0 */
327 if (retval
== ERROR_OK
)
328 retval
= dpmv8_exec_opcode(dpm
, opcode
, &dpm
->dscr
);
333 static int dpmv8_instr_cpsr_sync(struct arm_dpm
*dpm
)
336 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
338 /* "Prefetch flush" after modifying execution status in CPSR */
339 retval
= dpmv8_exec_opcode(dpm
, armv8_opcode(armv8
, ARMV8_OPC_DSB_SY
), &dpm
->dscr
);
340 if (retval
== ERROR_OK
)
341 dpmv8_exec_opcode(dpm
, armv8_opcode(armv8
, ARMV8_OPC_ISB_SY
), &dpm
->dscr
);
345 static int dpmv8_instr_read_data_dcc(struct arm_dpm
*dpm
,
346 uint32_t opcode
, uint32_t *data
)
348 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
351 /* the opcode, writing data to DCC */
352 retval
= dpmv8_exec_opcode(dpm
, opcode
, &dpm
->dscr
);
353 if (retval
!= ERROR_OK
)
356 return dpmv8_read_dcc(armv8
, data
, &dpm
->dscr
);
359 static int dpmv8_instr_read_data_dcc_64(struct arm_dpm
*dpm
,
360 uint32_t opcode
, uint64_t *data
)
362 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
365 /* the opcode, writing data to DCC */
366 retval
= dpmv8_exec_opcode(dpm
, opcode
, &dpm
->dscr
);
367 if (retval
!= ERROR_OK
)
370 return dpmv8_read_dcc_64(armv8
, data
, &dpm
->dscr
);
373 static int dpmv8_instr_read_data_r0(struct arm_dpm
*dpm
,
374 uint32_t opcode
, uint32_t *data
)
376 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
379 /* the opcode, writing data to R0 */
380 retval
= dpmv8_exec_opcode(dpm
, opcode
, &dpm
->dscr
);
381 if (retval
!= ERROR_OK
)
384 /* write R0 to DCC */
385 retval
= dpmv8_exec_opcode(dpm
, armv8_opcode(armv8
, WRITE_REG_DTRTX
), &dpm
->dscr
);
386 if (retval
!= ERROR_OK
)
389 return dpmv8_read_dcc(armv8
, data
, &dpm
->dscr
);
392 static int dpmv8_instr_read_data_r0_64(struct arm_dpm
*dpm
,
393 uint32_t opcode
, uint64_t *data
)
395 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
398 if (dpm
->arm
->core_state
!= ARM_STATE_AARCH64
) {
400 retval
= dpmv8_instr_read_data_r0(dpm
, opcode
, &tmp
);
401 if (retval
== ERROR_OK
)
406 /* the opcode, writing data to R0 */
407 retval
= dpmv8_exec_opcode(dpm
, opcode
, &dpm
->dscr
);
408 if (retval
!= ERROR_OK
)
411 /* write R0 to DCC */
412 retval
= dpmv8_exec_opcode(dpm
, ARMV8_MSR_GP(SYSTEM_DBG_DBGDTR_EL0
, 0), &dpm
->dscr
);
413 if (retval
!= ERROR_OK
)
416 return dpmv8_read_dcc_64(armv8
, data
, &dpm
->dscr
);
420 static int dpmv8_bpwp_enable(struct arm_dpm
*dpm
, unsigned index_t
,
421 target_addr_t addr
, uint32_t control
)
423 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
424 uint32_t vr
= armv8
->debug_base
;
425 uint32_t cr
= armv8
->debug_base
;
429 case 0 ... 15: /* breakpoints */
430 vr
+= CPUV8_DBG_BVR_BASE
;
431 cr
+= CPUV8_DBG_BCR_BASE
;
433 case 16 ... 31: /* watchpoints */
434 vr
+= CPUV8_DBG_WVR_BASE
;
435 cr
+= CPUV8_DBG_WCR_BASE
;
444 LOG_DEBUG("A8: bpwp enable, vr %08x cr %08x",
445 (unsigned) vr
, (unsigned) cr
);
447 retval
= mem_ap_write_atomic_u32(armv8
->debug_ap
, vr
, addr
);
448 if (retval
!= ERROR_OK
)
450 return mem_ap_write_atomic_u32(armv8
->debug_ap
, cr
, control
);
454 static int dpmv8_bpwp_disable(struct arm_dpm
*dpm
, unsigned index_t
)
456 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
461 cr
= armv8
->debug_base
+ CPUV8_DBG_BCR_BASE
;
464 cr
= armv8
->debug_base
+ CPUV8_DBG_WCR_BASE
;
472 LOG_DEBUG("A: bpwp disable, cr %08x", (unsigned) cr
);
474 /* clear control register */
475 return mem_ap_write_atomic_u32(armv8
->debug_ap
, cr
, 0);
479 * Coprocessor support
482 /* Read coprocessor */
483 static int dpmv8_mrc(struct target
*target
, int cpnum
,
484 uint32_t op1
, uint32_t op2
, uint32_t crn
, uint32_t crm
,
487 struct arm
*arm
= target_to_arm(target
);
488 struct arm_dpm
*dpm
= arm
->dpm
;
491 retval
= dpm
->prepare(dpm
);
492 if (retval
!= ERROR_OK
)
495 LOG_DEBUG("MRC p%d, %d, r0, c%d, c%d, %d", cpnum
,
496 (int) op1
, (int) crn
,
497 (int) crm
, (int) op2
);
499 /* read coprocessor register into R0; return via DCC */
500 retval
= dpm
->instr_read_data_r0(dpm
,
501 ARMV4_5_MRC(cpnum
, op1
, 0, crn
, crm
, op2
),
504 /* (void) */ dpm
->finish(dpm
);
508 static int dpmv8_mcr(struct target
*target
, int cpnum
,
509 uint32_t op1
, uint32_t op2
, uint32_t crn
, uint32_t crm
,
512 struct arm
*arm
= target_to_arm(target
);
513 struct arm_dpm
*dpm
= arm
->dpm
;
516 retval
= dpm
->prepare(dpm
);
517 if (retval
!= ERROR_OK
)
520 LOG_DEBUG("MCR p%d, %d, r0, c%d, c%d, %d", cpnum
,
521 (int) op1
, (int) crn
,
522 (int) crm
, (int) op2
);
524 /* read DCC into r0; then write coprocessor register from R0 */
525 retval
= dpm
->instr_write_data_r0(dpm
,
526 ARMV4_5_MCR(cpnum
, op1
, 0, crn
, crm
, op2
),
529 /* (void) */ dpm
->finish(dpm
);
533 /*----------------------------------------------------------------------*/
536 * Register access utilities
539 int armv8_dpm_modeswitch(struct arm_dpm
*dpm
, enum arm_mode mode
)
541 struct armv8_common
*armv8
= (struct armv8_common
*)dpm
->arm
->arch_info
;
542 int retval
= ERROR_OK
;
543 unsigned int target_el
;
544 enum arm_state core_state
;
547 /* restore previous mode */
548 if (mode
== ARM_MODE_ANY
) {
549 cpsr
= buf_get_u32(dpm
->arm
->cpsr
->value
, 0, 32);
551 LOG_DEBUG("restoring mode, cpsr = 0x%08"PRIx32
, cpsr
);
554 LOG_DEBUG("setting mode 0x%x", mode
);
558 switch (cpsr
& 0x1f) {
571 * TODO: handle ARM_MODE_HYP
581 target_el
= (cpsr
>> 2) & 3;
584 if (target_el
> SYSTEM_CUREL_EL3
) {
585 LOG_ERROR("%s: Invalid target exception level %i", __func__
, target_el
);
589 LOG_DEBUG("target_el = %i, last_el = %i", target_el
, dpm
->last_el
);
590 if (dpm
->last_el
== target_el
)
591 return ERROR_OK
; /* nothing to do */
593 if (target_el
> dpm
->last_el
) {
594 retval
= dpm
->instr_execute(dpm
,
595 armv8_opcode(armv8
, ARMV8_OPC_DCPS
) | target_el
);
597 /* DCPS clobbers registers just like an exception taken */
598 armv8_dpm_handle_exception(dpm
, false);
600 core_state
= armv8_dpm_get_core_state(dpm
);
601 if (core_state
!= ARM_STATE_AARCH64
) {
602 /* cannot do DRPS/ERET when already in EL0 */
603 if (dpm
->last_el
!= 0) {
604 /* load SPSR with the desired mode and execute DRPS */
605 LOG_DEBUG("SPSR = 0x%08"PRIx32
, cpsr
);
606 retval
= dpm
->instr_write_data_r0(dpm
,
607 ARMV8_MSR_GP_XPSR_T1(1, 0, 15), cpsr
);
608 if (retval
== ERROR_OK
)
609 retval
= dpm
->instr_execute(dpm
, armv8_opcode(armv8
, ARMV8_OPC_DRPS
));
613 * need to execute multiple DRPS instructions until target_el
616 while (retval
== ERROR_OK
&& dpm
->last_el
!= target_el
) {
617 unsigned int cur_el
= dpm
->last_el
;
618 retval
= dpm
->instr_execute(dpm
, armv8_opcode(armv8
, ARMV8_OPC_DRPS
));
619 if (cur_el
== dpm
->last_el
) {
620 LOG_INFO("Cannot reach EL %i, SPSR corrupted?", target_el
);
626 /* On executing DRPS, DSPSR and DLR become UNKNOWN, mark them as dirty */
627 dpm
->arm
->cpsr
->dirty
= true;
628 dpm
->arm
->pc
->dirty
= true;
631 * re-evaluate the core state, we might be in Aarch32 state now
632 * we rely on dpm->dscr being up-to-date
634 core_state
= armv8_dpm_get_core_state(dpm
);
635 armv8_select_opcodes(armv8
, core_state
== ARM_STATE_AARCH64
);
636 armv8_select_reg_access(armv8
, core_state
== ARM_STATE_AARCH64
);
643 * Common register read, relies on armv8_select_reg_access() having been called.
645 static int dpmv8_read_reg(struct arm_dpm
*dpm
, struct reg
*r
, unsigned regnum
)
647 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
648 int retval
= ERROR_FAIL
;
652 retval
= armv8
->read_reg_u64(armv8
, regnum
, &value_64
);
654 if (retval
== ERROR_OK
) {
657 buf_set_u64(r
->value
, 0, r
->size
, value_64
);
659 LOG_DEBUG("READ: %s, %16.8llx", r
->name
, (unsigned long long) value_64
);
661 LOG_DEBUG("READ: %s, %8.8x", r
->name
, (unsigned int) value_64
);
663 } else if (r
->size
<= 128) {
664 uint64_t lvalue
= 0, hvalue
= 0;
665 retval
= armv8
->read_reg_u128(armv8
, regnum
, &lvalue
, &hvalue
);
667 if (retval
== ERROR_OK
) {
671 buf_set_u64(r
->value
, 0, 64, lvalue
);
672 buf_set_u64(r
->value
+ 8, 0, r
->size
- 64, hvalue
);
674 LOG_DEBUG("READ: %s, lvalue=%16.8llx", r
->name
, (unsigned long long) lvalue
);
675 LOG_DEBUG("READ: %s, hvalue=%16.8llx", r
->name
, (unsigned long long) hvalue
);
679 if (retval
!= ERROR_OK
)
680 LOG_DEBUG("Failed to read %s register", r
->name
);
686 * Common register write, relies on armv8_select_reg_access() having been called.
688 static int dpmv8_write_reg(struct arm_dpm
*dpm
, struct reg
*r
, unsigned regnum
)
690 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
691 int retval
= ERROR_FAIL
;
696 value_64
= buf_get_u64(r
->value
, 0, r
->size
);
697 retval
= armv8
->write_reg_u64(armv8
, regnum
, value_64
);
699 if (retval
== ERROR_OK
) {
702 LOG_DEBUG("WRITE: %s, %16.8llx", r
->name
, (unsigned long long)value_64
);
704 LOG_DEBUG("WRITE: %s, %8.8x", r
->name
, (unsigned int)value_64
);
706 } else if (r
->size
<= 128) {
707 uint64_t lvalue
, hvalue
;
709 lvalue
= buf_get_u64(r
->value
, 0, 64);
710 hvalue
= buf_get_u64(r
->value
+ 8, 0, r
->size
- 64);
711 retval
= armv8
->write_reg_u128(armv8
, regnum
, lvalue
, hvalue
);
713 if (retval
== ERROR_OK
) {
716 LOG_DEBUG("WRITE: %s, lvalue=%16.8llx", r
->name
, (unsigned long long) lvalue
);
717 LOG_DEBUG("WRITE: %s, hvalue=%16.8llx", r
->name
, (unsigned long long) hvalue
);
721 if (retval
!= ERROR_OK
)
722 LOG_DEBUG("Failed to write %s register", r
->name
);
728 * Read basic registers of the current context: R0 to R15, and CPSR in AArch32
729 * state or R0 to R31, PC and CPSR in AArch64 state;
730 * sets the core mode (such as USR or IRQ) and state (such as ARM or Thumb).
731 * In normal operation this is called on entry to halting debug state,
732 * possibly after some other operations supporting restore of debug state
733 * or making sure the CPU is fully idle (drain write buffer, etc).
735 int armv8_dpm_read_current_registers(struct arm_dpm
*dpm
)
737 struct arm
*arm
= dpm
->arm
;
738 struct armv8_common
*armv8
= (struct armv8_common
*)arm
->arch_info
;
739 struct reg_cache
*cache
;
744 retval
= dpm
->prepare(dpm
);
745 if (retval
!= ERROR_OK
)
748 cache
= arm
->core_cache
;
750 /* read R0 first (it's used for scratch), then CPSR */
751 r
= cache
->reg_list
+ ARMV8_R0
;
753 retval
= dpmv8_read_reg(dpm
, r
, ARMV8_R0
);
754 if (retval
!= ERROR_OK
)
759 /* read R1, too, it will be clobbered during memory access */
760 r
= cache
->reg_list
+ ARMV8_R1
;
762 retval
= dpmv8_read_reg(dpm
, r
, ARMV8_R1
);
763 if (retval
!= ERROR_OK
)
767 /* read cpsr to r0 and get it back */
768 retval
= dpm
->instr_read_data_r0(dpm
,
769 armv8_opcode(armv8
, READ_REG_DSPSR
), &cpsr
);
770 if (retval
!= ERROR_OK
)
773 /* update core mode and state */
774 armv8_set_cpsr(arm
, cpsr
);
776 /* read the remaining registers that would be required by GDB 'g' packet */
777 for (unsigned int i
= ARMV8_R2
; i
<= ARMV8_PC
; i
++) {
778 struct arm_reg
*arm_reg
;
780 /* in AArch32 skip AArch64 registers */
781 /* TODO: this should be detected below through arm_reg->mode */
782 if (arm
->core_state
!= ARM_STATE_AARCH64
&& i
> ARMV8_R14
&& i
< ARMV8_PC
)
785 r
= armv8_reg_current(arm
, i
);
786 if (!r
->exist
|| r
->valid
)
789 /* Skip reading FP-SIMD registers */
790 if (r
->number
>= ARMV8_V0
&& r
->number
<= ARMV8_FPCR
)
794 * Only read registers that are available from the
795 * current EL (or core mode).
797 arm_reg
= r
->arch_info
;
798 if (arm_reg
->mode
!= ARM_MODE_ANY
&&
799 dpm
->last_el
!= armv8_curel_from_core_mode(arm_reg
->mode
))
802 /* Special case: ARM_MODE_SYS has no SPSR at EL1 */
803 if (r
->number
== ARMV8_SPSR_EL1
&& arm
->core_mode
== ARM_MODE_SYS
)
806 retval
= dpmv8_read_reg(dpm
, r
, i
);
807 if (retval
!= ERROR_OK
)
817 /* Avoid needless I/O ... leave breakpoints and watchpoints alone
818 * unless they're removed, or need updating because of single-stepping
819 * or running debugger code.
821 static int dpmv8_maybe_update_bpwp(struct arm_dpm
*dpm
, bool bpwp
,
822 struct dpm_bpwp
*xp
, bool *set_p
)
824 int retval
= ERROR_OK
;
831 /* removed or startup; we must disable it */
836 /* disabled, but we must set it */
837 xp
->dirty
= disable
= false;
842 /* set, but we must temporarily disable it */
843 xp
->dirty
= disable
= true;
848 retval
= dpm
->bpwp_disable(dpm
, xp
->number
);
850 retval
= dpm
->bpwp_enable(dpm
, xp
->number
,
851 xp
->address
, xp
->control
);
853 if (retval
!= ERROR_OK
)
854 LOG_ERROR("%s: can't %s HW %spoint %d",
855 disable
? "disable" : "enable",
856 target_name(dpm
->arm
->target
),
857 (xp
->number
< 16) ? "break" : "watch",
863 static int dpmv8_add_breakpoint(struct target
*target
, struct breakpoint
*bp
);
866 * Writes all modified core registers for all processor modes. In normal
867 * operation this is called on exit from halting debug state.
869 * @param dpm: represents the processor
870 * @param bpwp: true ensures breakpoints and watchpoints are set,
871 * false ensures they are cleared
873 int armv8_dpm_write_dirty_registers(struct arm_dpm
*dpm
, bool bpwp
)
875 struct arm
*arm
= dpm
->arm
;
876 struct reg_cache
*cache
= arm
->core_cache
;
879 retval
= dpm
->prepare(dpm
);
880 if (retval
!= ERROR_OK
)
883 /* If we're managing hardware breakpoints for this core, enable
884 * or disable them as requested.
886 * REVISIT We don't yet manage them for ANY cores. Eventually
887 * we should be able to assume we handle them; but until then,
888 * cope with the hand-crafted breakpoint code.
890 if (arm
->target
->type
->add_breakpoint
== dpmv8_add_breakpoint
) {
891 for (unsigned i
= 0; i
< dpm
->nbp
; i
++) {
892 struct dpm_bp
*dbp
= dpm
->dbp
+ i
;
893 struct breakpoint
*bp
= dbp
->bp
;
895 retval
= dpmv8_maybe_update_bpwp(dpm
, bpwp
, &dbp
->bpwp
,
896 bp
? &bp
->is_set
: NULL
);
897 if (retval
!= ERROR_OK
)
902 /* enable/disable watchpoints */
903 for (unsigned i
= 0; i
< dpm
->nwp
; i
++) {
904 struct dpm_wp
*dwp
= dpm
->dwp
+ i
;
905 struct watchpoint
*wp
= dwp
->wp
;
907 retval
= dpmv8_maybe_update_bpwp(dpm
, bpwp
, &dwp
->bpwp
,
908 wp
? &wp
->is_set
: NULL
);
909 if (retval
!= ERROR_OK
)
913 /* NOTE: writes to breakpoint and watchpoint registers might
914 * be queued, and need (efficient/batched) flushing later.
917 /* Restore original core mode and state */
918 retval
= armv8_dpm_modeswitch(dpm
, ARM_MODE_ANY
);
919 if (retval
!= ERROR_OK
)
922 /* check everything except our scratch register R0 */
923 for (unsigned i
= 1; i
< cache
->num_regs
; i
++) {
926 /* skip non-existent */
927 if (!cache
->reg_list
[i
].exist
)
929 /* skip PC and CPSR */
930 if (i
== ARMV8_PC
|| i
== ARMV8_XPSR
)
933 if (!cache
->reg_list
[i
].valid
)
936 if (!cache
->reg_list
[i
].dirty
)
939 /* skip all registers not on the current EL */
940 r
= cache
->reg_list
[i
].arch_info
;
941 if (r
->mode
!= ARM_MODE_ANY
&&
942 dpm
->last_el
!= armv8_curel_from_core_mode(r
->mode
))
945 retval
= dpmv8_write_reg(dpm
, &cache
->reg_list
[i
], i
);
946 if (retval
!= ERROR_OK
)
950 /* flush CPSR and PC */
951 if (retval
== ERROR_OK
)
952 retval
= dpmv8_write_reg(dpm
, &cache
->reg_list
[ARMV8_XPSR
], ARMV8_XPSR
);
953 if (retval
== ERROR_OK
)
954 retval
= dpmv8_write_reg(dpm
, &cache
->reg_list
[ARMV8_PC
], ARMV8_PC
);
955 /* flush R0 -- it's *very* dirty by now */
956 if (retval
== ERROR_OK
)
957 retval
= dpmv8_write_reg(dpm
, &cache
->reg_list
[0], 0);
958 if (retval
== ERROR_OK
)
959 dpm
->instr_cpsr_sync(dpm
);
966 * Standard ARM register accessors ... there are three methods
967 * in "struct arm", to support individual read/write and bulk read
971 static int armv8_dpm_read_core_reg(struct target
*target
, struct reg
*r
,
972 int regnum
, enum arm_mode mode
)
974 struct arm
*arm
= target_to_arm(target
);
975 struct arm_dpm
*dpm
= target_to_arm(target
)->dpm
;
977 int max
= arm
->core_cache
->num_regs
;
979 if (regnum
< 0 || regnum
>= max
)
980 return ERROR_COMMAND_SYNTAX_ERROR
;
983 * REVISIT what happens if we try to read SPSR in a core mode
984 * which has no such register?
986 retval
= dpm
->prepare(dpm
);
987 if (retval
!= ERROR_OK
)
990 retval
= dpmv8_read_reg(dpm
, r
, regnum
);
991 if (retval
!= ERROR_OK
)
995 /* (void) */ dpm
->finish(dpm
);
999 static int armv8_dpm_write_core_reg(struct target
*target
, struct reg
*r
,
1000 int regnum
, enum arm_mode mode
, uint8_t *value
)
1002 struct arm
*arm
= target_to_arm(target
);
1003 struct arm_dpm
*dpm
= target_to_arm(target
)->dpm
;
1005 int max
= arm
->core_cache
->num_regs
;
1007 if (regnum
< 0 || regnum
> max
)
1008 return ERROR_COMMAND_SYNTAX_ERROR
;
1010 /* REVISIT what happens if we try to write SPSR in a core mode
1011 * which has no such register?
1014 retval
= dpm
->prepare(dpm
);
1015 if (retval
!= ERROR_OK
)
1018 retval
= dpmv8_write_reg(dpm
, r
, regnum
);
1020 /* always clean up, regardless of error */
1026 static int armv8_dpm_full_context(struct target
*target
)
1028 struct arm
*arm
= target_to_arm(target
);
1029 struct arm_dpm
*dpm
= arm
->dpm
;
1030 struct reg_cache
*cache
= arm
->core_cache
;
1034 retval
= dpm
->prepare(dpm
);
1035 if (retval
!= ERROR_OK
)
1039 enum arm_mode mode
= ARM_MODE_ANY
;
1043 /* We "know" arm_dpm_read_current_registers() was called so
1044 * the unmapped registers (R0..R7, PC, AND CPSR) and some
1045 * view of R8..R14 are current. We also "know" oddities of
1046 * register mapping: special cases for R8..R12 and SPSR.
1048 * Pick some mode with unread registers and read them all.
1049 * Repeat until done.
1051 for (unsigned i
= 0; i
< cache
->num_regs
; i
++) {
1054 if (!cache
->reg_list
[i
].exist
|| cache
->reg_list
[i
].valid
)
1056 r
= cache
->reg_list
[i
].arch_info
;
1058 /* may need to pick a mode and set CPSR */
1063 /* For regular (ARM_MODE_ANY) R8..R12
1064 * in case we've entered debug state
1065 * in FIQ mode we need to patch mode.
1067 if (mode
!= ARM_MODE_ANY
)
1068 retval
= armv8_dpm_modeswitch(dpm
, mode
);
1070 retval
= armv8_dpm_modeswitch(dpm
, ARM_MODE_USR
);
1072 if (retval
!= ERROR_OK
)
1075 if (r
->mode
!= mode
)
1078 /* CPSR was read, so "R16" must mean SPSR */
1079 retval
= dpmv8_read_reg(dpm
,
1080 &cache
->reg_list
[i
],
1081 (r
->num
== 16) ? 17 : r
->num
);
1082 if (retval
!= ERROR_OK
)
1088 retval
= armv8_dpm_modeswitch(dpm
, ARM_MODE_ANY
);
1089 /* (void) */ dpm
->finish(dpm
);
1095 /*----------------------------------------------------------------------*/
1098 * Breakpoint and Watchpoint support.
1100 * Hardware {break,watch}points are usually left active, to minimize
1101 * debug entry/exit costs. When they are set or cleared, it's done in
1102 * batches. Also, DPM-conformant hardware can update debug registers
1103 * regardless of whether the CPU is running or halted ... though that
1104 * fact isn't currently leveraged.
1107 static int dpmv8_bpwp_setup(struct arm_dpm
*dpm
, struct dpm_bpwp
*xp
,
1108 uint32_t addr
, uint32_t length
)
1112 control
= (1 << 0) /* enable */
1113 | (3 << 1); /* both user and privileged access */
1115 /* Match 1, 2, or all 4 byte addresses in this word.
1117 * FIXME: v7 hardware allows lengths up to 2 GB for BP and WP.
1118 * Support larger length, when addr is suitably aligned. In
1119 * particular, allow watchpoints on 8 byte "double" values.
1121 * REVISIT allow watchpoints on unaligned 2-bit values; and on
1122 * v7 hardware, unaligned 4-byte ones too.
1126 control
|= (1 << (addr
& 3)) << 5;
1129 /* require 2-byte alignment */
1131 control
|= (3 << (addr
& 2)) << 5;
1136 /* require 4-byte alignment */
1138 control
|= 0xf << 5;
1143 LOG_ERROR("unsupported {break,watch}point length/alignment");
1144 return ERROR_COMMAND_SYNTAX_ERROR
;
1147 /* other shared control bits:
1148 * bits 15:14 == 0 ... both secure and nonsecure states (v6.1+ only)
1149 * bit 20 == 0 ... not linked to a context ID
1150 * bit 28:24 == 0 ... not ignoring N LSBs (v7 only)
1153 xp
->address
= addr
& ~3;
1154 xp
->control
= control
;
1157 LOG_DEBUG("BPWP: addr %8.8" PRIx32
", control %" PRIx32
", number %d",
1158 xp
->address
, control
, xp
->number
);
1160 /* hardware is updated in write_dirty_registers() */
1164 static int dpmv8_add_breakpoint(struct target
*target
, struct breakpoint
*bp
)
1166 struct arm
*arm
= target_to_arm(target
);
1167 struct arm_dpm
*dpm
= arm
->dpm
;
1168 int retval
= ERROR_TARGET_RESOURCE_NOT_AVAILABLE
;
1171 return ERROR_COMMAND_SYNTAX_ERROR
;
1172 if (!dpm
->bpwp_enable
)
1175 /* FIXME we need a generic solution for software breakpoints. */
1176 if (bp
->type
== BKPT_SOFT
)
1177 LOG_DEBUG("using HW bkpt, not SW...");
1179 for (unsigned i
= 0; i
< dpm
->nbp
; i
++) {
1180 if (!dpm
->dbp
[i
].bp
) {
1181 retval
= dpmv8_bpwp_setup(dpm
, &dpm
->dbp
[i
].bpwp
,
1182 bp
->address
, bp
->length
);
1183 if (retval
== ERROR_OK
)
1184 dpm
->dbp
[i
].bp
= bp
;
1192 static int dpmv8_remove_breakpoint(struct target
*target
, struct breakpoint
*bp
)
1194 struct arm
*arm
= target_to_arm(target
);
1195 struct arm_dpm
*dpm
= arm
->dpm
;
1196 int retval
= ERROR_COMMAND_SYNTAX_ERROR
;
1198 for (unsigned i
= 0; i
< dpm
->nbp
; i
++) {
1199 if (dpm
->dbp
[i
].bp
== bp
) {
1200 dpm
->dbp
[i
].bp
= NULL
;
1201 dpm
->dbp
[i
].bpwp
.dirty
= true;
1203 /* hardware is updated in write_dirty_registers() */
1212 static int dpmv8_watchpoint_setup(struct arm_dpm
*dpm
, unsigned index_t
,
1213 struct watchpoint
*wp
)
1216 struct dpm_wp
*dwp
= dpm
->dwp
+ index_t
;
1219 /* this hardware doesn't support data value matching or masking */
1220 if (wp
->mask
!= WATCHPOINT_IGNORE_DATA_VALUE_MASK
) {
1221 LOG_DEBUG("watchpoint values and masking not supported");
1222 return ERROR_TARGET_RESOURCE_NOT_AVAILABLE
;
1225 retval
= dpmv8_bpwp_setup(dpm
, &dwp
->bpwp
, wp
->address
, wp
->length
);
1226 if (retval
!= ERROR_OK
)
1229 control
= dwp
->bpwp
.control
;
1241 dwp
->bpwp
.control
= control
;
1243 dpm
->dwp
[index_t
].wp
= wp
;
1248 static int dpmv8_add_watchpoint(struct target
*target
, struct watchpoint
*wp
)
1250 struct arm
*arm
= target_to_arm(target
);
1251 struct arm_dpm
*dpm
= arm
->dpm
;
1252 int retval
= ERROR_TARGET_RESOURCE_NOT_AVAILABLE
;
1254 if (dpm
->bpwp_enable
) {
1255 for (unsigned i
= 0; i
< dpm
->nwp
; i
++) {
1256 if (!dpm
->dwp
[i
].wp
) {
1257 retval
= dpmv8_watchpoint_setup(dpm
, i
, wp
);
1266 static int dpmv8_remove_watchpoint(struct target
*target
, struct watchpoint
*wp
)
1268 struct arm
*arm
= target_to_arm(target
);
1269 struct arm_dpm
*dpm
= arm
->dpm
;
1270 int retval
= ERROR_COMMAND_SYNTAX_ERROR
;
1272 for (unsigned i
= 0; i
< dpm
->nwp
; i
++) {
1273 if (dpm
->dwp
[i
].wp
== wp
) {
1274 dpm
->dwp
[i
].wp
= NULL
;
1275 dpm
->dwp
[i
].bpwp
.dirty
= true;
1277 /* hardware is updated in write_dirty_registers() */
1287 * Handle exceptions taken in debug state. This happens mostly for memory
1288 * accesses that violated a MMU policy. Taking an exception while in debug
1289 * state clobbers certain state registers on the target exception level.
1290 * Just mark those registers dirty so that they get restored on resume.
1291 * This works both for Aarch32 and Aarch64 states.
1293 * This function must not perform any actions that trigger another exception
1294 * or a recursion will happen.
1296 void armv8_dpm_handle_exception(struct arm_dpm
*dpm
, bool do_restore
)
1298 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
1299 struct reg_cache
*cache
= dpm
->arm
->core_cache
;
1300 enum arm_state core_state
;
1305 static const int clobbered_regs_by_el
[3][5] = {
1306 { ARMV8_PC
, ARMV8_XPSR
, ARMV8_ELR_EL1
, ARMV8_ESR_EL1
, ARMV8_SPSR_EL1
},
1307 { ARMV8_PC
, ARMV8_XPSR
, ARMV8_ELR_EL2
, ARMV8_ESR_EL2
, ARMV8_SPSR_EL2
},
1308 { ARMV8_PC
, ARMV8_XPSR
, ARMV8_ELR_EL3
, ARMV8_ESR_EL3
, ARMV8_SPSR_EL3
},
1311 el
= (dpm
->dscr
>> 8) & 3;
1313 /* safety check, must not happen since EL0 cannot be a target for an exception */
1314 if (el
< SYSTEM_CUREL_EL1
|| el
> SYSTEM_CUREL_EL3
) {
1315 LOG_ERROR("%s: EL %i is invalid, DSCR corrupted?", __func__
, el
);
1319 /* Clear sticky error */
1320 mem_ap_write_u32(armv8
->debug_ap
,
1321 armv8
->debug_base
+ CPUV8_DBG_DRCR
, DRCR_CSE
);
1323 armv8
->read_reg_u64(armv8
, ARMV8_XPSR
, &dlr
);
1325 armv8
->read_reg_u64(armv8
, ARMV8_PC
, &dlr
);
1327 LOG_DEBUG("Exception taken to EL %i, DLR=0x%016"PRIx64
" DSPSR=0x%08"PRIx32
,
1330 /* mark all clobbered registers as dirty */
1331 for (int i
= 0; i
< 5; i
++)
1332 cache
->reg_list
[clobbered_regs_by_el
[el
-1][i
]].dirty
= true;
1335 * re-evaluate the core state, we might be in Aarch64 state now
1336 * we rely on dpm->dscr being up-to-date
1338 core_state
= armv8_dpm_get_core_state(dpm
);
1339 armv8_select_opcodes(armv8
, core_state
== ARM_STATE_AARCH64
);
1340 armv8_select_reg_access(armv8
, core_state
== ARM_STATE_AARCH64
);
1343 armv8_dpm_modeswitch(dpm
, ARM_MODE_ANY
);
1346 /*----------------------------------------------------------------------*/
1349 * Other debug and support utilities
1352 void armv8_dpm_report_dscr(struct arm_dpm
*dpm
, uint32_t dscr
)
1354 struct target
*target
= dpm
->arm
->target
;
1357 dpm
->last_el
= (dscr
>> 8) & 3;
1359 /* Examine debug reason */
1360 switch (DSCR_ENTRY(dscr
)) {
1361 /* FALL THROUGH -- assume a v6 core in abort mode */
1362 case DSCRV8_ENTRY_EXT_DEBUG
: /* EDBGRQ */
1363 target
->debug_reason
= DBG_REASON_DBGRQ
;
1365 case DSCRV8_ENTRY_HALT_STEP_EXECLU
: /* HALT step */
1366 case DSCRV8_ENTRY_HALT_STEP_NORMAL
: /* Halt step*/
1367 case DSCRV8_ENTRY_HALT_STEP
:
1368 target
->debug_reason
= DBG_REASON_SINGLESTEP
;
1370 case DSCRV8_ENTRY_HLT
: /* HLT instruction (software breakpoint) */
1371 case DSCRV8_ENTRY_BKPT
: /* SW BKPT (?) */
1372 case DSCRV8_ENTRY_RESET_CATCH
: /* Reset catch */
1373 case DSCRV8_ENTRY_OS_UNLOCK
: /*OS unlock catch*/
1374 case DSCRV8_ENTRY_SW_ACCESS_DBG
: /*SW access dbg register*/
1375 target
->debug_reason
= DBG_REASON_BREAKPOINT
;
1377 case DSCRV8_ENTRY_WATCHPOINT
: /* asynch watchpoint */
1378 target
->debug_reason
= DBG_REASON_WATCHPOINT
;
1380 case DSCRV8_ENTRY_EXCEPTION_CATCH
: /*exception catch*/
1381 target
->debug_reason
= DBG_REASON_EXC_CATCH
;
1384 target
->debug_reason
= DBG_REASON_UNDEFINED
;
1390 /*----------------------------------------------------------------------*/
1393 * Setup and management support.
1397 * Hooks up this DPM to its associated target; call only once.
1398 * Initially this only covers the register cache.
1400 * Oh, and watchpoints. Yeah.
1402 int armv8_dpm_setup(struct arm_dpm
*dpm
)
1404 struct arm
*arm
= dpm
->arm
;
1405 struct target
*target
= arm
->target
;
1406 struct reg_cache
*cache
;
1409 /* register access setup */
1410 arm
->full_context
= armv8_dpm_full_context
;
1411 arm
->read_core_reg
= armv8_dpm_read_core_reg
;
1412 arm
->write_core_reg
= armv8_dpm_write_core_reg
;
1414 if (!arm
->core_cache
) {
1415 cache
= armv8_build_reg_cache(target
);
1420 /* coprocessor access setup */
1421 arm
->mrc
= dpmv8_mrc
;
1422 arm
->mcr
= dpmv8_mcr
;
1424 dpm
->prepare
= dpmv8_dpm_prepare
;
1425 dpm
->finish
= dpmv8_dpm_finish
;
1427 dpm
->instr_execute
= dpmv8_instr_execute
;
1428 dpm
->instr_write_data_dcc
= dpmv8_instr_write_data_dcc
;
1429 dpm
->instr_write_data_dcc_64
= dpmv8_instr_write_data_dcc_64
;
1430 dpm
->instr_write_data_r0
= dpmv8_instr_write_data_r0
;
1431 dpm
->instr_write_data_r0_64
= dpmv8_instr_write_data_r0_64
;
1432 dpm
->instr_cpsr_sync
= dpmv8_instr_cpsr_sync
;
1434 dpm
->instr_read_data_dcc
= dpmv8_instr_read_data_dcc
;
1435 dpm
->instr_read_data_dcc_64
= dpmv8_instr_read_data_dcc_64
;
1436 dpm
->instr_read_data_r0
= dpmv8_instr_read_data_r0
;
1437 dpm
->instr_read_data_r0_64
= dpmv8_instr_read_data_r0_64
;
1439 dpm
->arm_reg_current
= armv8_reg_current
;
1441 /* dpm->bpwp_enable = dpmv8_bpwp_enable; */
1442 dpm
->bpwp_disable
= dpmv8_bpwp_disable
;
1444 /* breakpoint setup -- optional until it works everywhere */
1445 if (!target
->type
->add_breakpoint
) {
1446 target
->type
->add_breakpoint
= dpmv8_add_breakpoint
;
1447 target
->type
->remove_breakpoint
= dpmv8_remove_breakpoint
;
1450 /* watchpoint setup */
1451 if (!target
->type
->add_watchpoint
) {
1452 target
->type
->add_watchpoint
= dpmv8_add_watchpoint
;
1453 target
->type
->remove_watchpoint
= dpmv8_remove_watchpoint
;
1456 /* FIXME add vector catch support */
1458 dpm
->nbp
= 1 + ((dpm
->didr
>> 12) & 0xf);
1459 dpm
->dbp
= calloc(dpm
->nbp
, sizeof(*dpm
->dbp
));
1461 dpm
->nwp
= 1 + ((dpm
->didr
>> 20) & 0xf);
1462 dpm
->dwp
= calloc(dpm
->nwp
, sizeof(*dpm
->dwp
));
1464 if (!dpm
->dbp
|| !dpm
->dwp
) {
1470 LOG_INFO("%s: hardware has %d breakpoints, %d watchpoints",
1471 target_name(target
), dpm
->nbp
, dpm
->nwp
);
1473 /* REVISIT ... and some of those breakpoints could match
1474 * execution context IDs...
1481 * Reinitializes DPM state at the beginning of a new debug session
1482 * or after a reset which may have affected the debug module.
1484 int armv8_dpm_initialize(struct arm_dpm
*dpm
)
1486 /* Disable all breakpoints and watchpoints at startup. */
1487 if (dpm
->bpwp_disable
) {
1490 for (i
= 0; i
< dpm
->nbp
; i
++) {
1491 dpm
->dbp
[i
].bpwp
.number
= i
;
1492 (void) dpm
->bpwp_disable(dpm
, i
);
1494 for (i
= 0; i
< dpm
->nwp
; i
++) {
1495 dpm
->dwp
[i
].bpwp
.number
= 16 + i
;
1496 (void) dpm
->bpwp_disable(dpm
, 16 + i
);
1499 LOG_WARNING("%s: can't disable breakpoints and watchpoints",
1500 target_name(dpm
->arm
->target
));