2 * Copyright (C) 2009 by David Brownell
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
22 #include "armv8_dpm.h"
23 #include <jtag/jtag.h>
25 #include "breakpoints.h"
26 #include "target_type.h"
27 #include "armv8_opcodes.h"
29 #include "helper/time_support.h"
32 #define T32_FMTITR(instr) (((instr & 0x0000FFFF) << 16) | ((instr & 0xFFFF0000) >> 16))
36 * Implements various ARM DPM operations using architectural debug registers.
37 * These routines layer over core-specific communication methods to cope with
38 * implementation differences between cores like ARM1136 and Cortex-A8.
40 * The "Debug Programmers' Model" (DPM) for ARMv6 and ARMv7 is defined by
41 * Part C (Debug Architecture) of the ARM Architecture Reference Manual,
42 * ARMv7-A and ARMv7-R edition (ARM DDI 0406B). In OpenOCD, DPM operations
43 * are abstracted through internal programming interfaces to share code and
44 * to minimize needless differences in debug behavior between cores.
48 * Get core state from EDSCR, without necessity to retrieve CPSR
50 enum arm_state
armv8_dpm_get_core_state(struct arm_dpm
*dpm
)
52 int el
= (dpm
->dscr
>> 8) & 0x3;
53 int rw
= (dpm
->dscr
>> 10) & 0xF;
58 /* find the first '0' in DSCR.RW */
59 for (pos
= 3; pos
>= 0; pos
--) {
60 if ((rw
& (1 << pos
)) == 0)
65 return ARM_STATE_AARCH64
;
70 /*----------------------------------------------------------------------*/
72 static int dpmv8_write_dcc(struct armv8_common
*armv8
, uint32_t data
)
74 LOG_DEBUG("write DCC 0x%08" PRIx32
, data
);
75 return mem_ap_write_u32(armv8
->debug_ap
,
76 armv8
->debug_base
+ CPUV8_DBG_DTRRX
, data
);
79 static int dpmv8_write_dcc_64(struct armv8_common
*armv8
, uint64_t data
)
82 LOG_DEBUG("write DCC Low word 0x%08" PRIx32
, (unsigned)data
);
83 LOG_DEBUG("write DCC High word 0x%08" PRIx32
, (unsigned)(data
>> 32));
84 ret
= mem_ap_write_u32(armv8
->debug_ap
,
85 armv8
->debug_base
+ CPUV8_DBG_DTRRX
, data
);
86 ret
+= mem_ap_write_u32(armv8
->debug_ap
,
87 armv8
->debug_base
+ CPUV8_DBG_DTRTX
, data
>> 32);
91 static int dpmv8_read_dcc(struct armv8_common
*armv8
, uint32_t *data
,
94 uint32_t dscr
= DSCR_ITE
;
100 /* Wait for DTRRXfull */
101 long long then
= timeval_ms();
102 while ((dscr
& DSCR_DTR_TX_FULL
) == 0) {
103 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
104 armv8
->debug_base
+ CPUV8_DBG_DSCR
,
106 if (retval
!= ERROR_OK
)
108 if (timeval_ms() > then
+ 1000) {
109 LOG_ERROR("Timeout waiting for read dcc");
114 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
115 armv8
->debug_base
+ CPUV8_DBG_DTRTX
,
117 if (retval
!= ERROR_OK
)
119 LOG_DEBUG("read DCC 0x%08" PRIx32
, *data
);
127 static int dpmv8_read_dcc_64(struct armv8_common
*armv8
, uint64_t *data
,
130 uint32_t dscr
= DSCR_ITE
;
137 /* Wait for DTRRXfull */
138 long long then
= timeval_ms();
139 while ((dscr
& DSCR_DTR_TX_FULL
) == 0) {
140 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
141 armv8
->debug_base
+ CPUV8_DBG_DSCR
,
143 if (retval
!= ERROR_OK
)
145 if (timeval_ms() > then
+ 1000) {
146 LOG_ERROR("Timeout waiting for read dcc");
151 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
152 armv8
->debug_base
+ CPUV8_DBG_DTRTX
,
154 if (retval
!= ERROR_OK
)
157 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
158 armv8
->debug_base
+ CPUV8_DBG_DTRRX
,
160 if (retval
!= ERROR_OK
)
163 *data
= *(uint32_t *)data
| (uint64_t)higher
<< 32;
164 LOG_DEBUG("read DCC 0x%16.16" PRIx64
, *data
);
172 static int dpmv8_dpm_prepare(struct arm_dpm
*dpm
)
174 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
178 /* set up invariant: INSTR_COMP is set after ever DPM operation */
179 long long then
= timeval_ms();
181 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
182 armv8
->debug_base
+ CPUV8_DBG_DSCR
,
184 if (retval
!= ERROR_OK
)
186 if ((dscr
& DSCR_ITE
) != 0)
188 if (timeval_ms() > then
+ 1000) {
189 LOG_ERROR("Timeout waiting for dpm prepare");
194 /* update the stored copy of dscr */
197 /* this "should never happen" ... */
198 if (dscr
& DSCR_DTR_RX_FULL
) {
199 LOG_ERROR("DSCR_DTR_RX_FULL, dscr 0x%08" PRIx32
, dscr
);
201 retval
= mem_ap_read_u32(armv8
->debug_ap
,
202 armv8
->debug_base
+ CPUV8_DBG_DTRRX
, &dscr
);
203 if (retval
!= ERROR_OK
)
206 /* Clear sticky error */
207 retval
= mem_ap_write_u32(armv8
->debug_ap
,
208 armv8
->debug_base
+ CPUV8_DBG_DRCR
, DRCR_CSE
);
209 if (retval
!= ERROR_OK
)
216 static int dpmv8_dpm_finish(struct arm_dpm
*dpm
)
218 /* REVISIT what could be done here? */
222 static int dpmv8_exec_opcode(struct arm_dpm
*dpm
,
223 uint32_t opcode
, uint32_t *p_dscr
)
225 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
226 uint32_t dscr
= DSCR_ITE
;
229 LOG_DEBUG("exec opcode 0x%08" PRIx32
, opcode
);
234 /* Wait for InstrCompl bit to be set */
235 long long then
= timeval_ms();
236 while ((dscr
& DSCR_ITE
) == 0) {
237 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
238 armv8
->debug_base
+ CPUV8_DBG_DSCR
, &dscr
);
239 if (retval
!= ERROR_OK
) {
240 LOG_ERROR("Could not read DSCR register, opcode = 0x%08" PRIx32
, opcode
);
243 if (timeval_ms() > then
+ 1000) {
244 LOG_ERROR("Timeout waiting for aarch64_exec_opcode");
249 if (armv8_dpm_get_core_state(dpm
) != ARM_STATE_AARCH64
)
250 opcode
= T32_FMTITR(opcode
);
252 retval
= mem_ap_write_u32(armv8
->debug_ap
,
253 armv8
->debug_base
+ CPUV8_DBG_ITR
, opcode
);
254 if (retval
!= ERROR_OK
)
259 retval
= mem_ap_read_atomic_u32(armv8
->debug_ap
,
260 armv8
->debug_base
+ CPUV8_DBG_DSCR
, &dscr
);
261 if (retval
!= ERROR_OK
) {
262 LOG_ERROR("Could not read DSCR register");
265 if (timeval_ms() > then
+ 1000) {
266 LOG_ERROR("Timeout waiting for aarch64_exec_opcode");
269 } while ((dscr
& DSCR_ITE
) == 0); /* Wait for InstrCompl bit to be set */
271 /* update dscr and el after each command execution */
273 if (dpm
->last_el
!= ((dscr
>> 8) & 3))
274 LOG_DEBUG("EL %i -> %i", dpm
->last_el
, (dscr
>> 8) & 3);
275 dpm
->last_el
= (dscr
>> 8) & 3;
277 if (dscr
& DSCR_ERR
) {
278 LOG_ERROR("Opcode 0x%08"PRIx32
", DSCR.ERR=1, DSCR.EL=%i", opcode
, dpm
->last_el
);
279 /* clear the sticky error condition */
280 mem_ap_write_atomic_u32(armv8
->debug_ap
,
281 armv8
->debug_base
+ CPUV8_DBG_DRCR
, DRCR_CSE
);
282 armv8_dpm_handle_exception(dpm
);
292 static int dpmv8_instr_execute(struct arm_dpm
*dpm
, uint32_t opcode
)
294 return dpmv8_exec_opcode(dpm
, opcode
, NULL
);
297 static int dpmv8_instr_write_data_dcc(struct arm_dpm
*dpm
,
298 uint32_t opcode
, uint32_t data
)
300 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
303 retval
= dpmv8_write_dcc(armv8
, data
);
304 if (retval
!= ERROR_OK
)
307 return dpmv8_exec_opcode(dpm
, opcode
, 0);
310 static int dpmv8_instr_write_data_dcc_64(struct arm_dpm
*dpm
,
311 uint32_t opcode
, uint64_t data
)
313 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
316 retval
= dpmv8_write_dcc_64(armv8
, data
);
317 if (retval
!= ERROR_OK
)
320 return dpmv8_exec_opcode(dpm
, opcode
, 0);
323 static int dpmv8_instr_write_data_r0(struct arm_dpm
*dpm
,
324 uint32_t opcode
, uint32_t data
)
326 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
327 uint32_t dscr
= DSCR_ITE
;
330 retval
= dpmv8_write_dcc(armv8
, data
);
331 if (retval
!= ERROR_OK
)
334 retval
= dpmv8_exec_opcode(dpm
, armv8_opcode(armv8
, READ_REG_DTRRX
), &dscr
);
335 if (retval
!= ERROR_OK
)
338 /* then the opcode, taking data from R0 */
339 return dpmv8_exec_opcode(dpm
, opcode
, &dscr
);
342 static int dpmv8_instr_write_data_r0_64(struct arm_dpm
*dpm
,
343 uint32_t opcode
, uint64_t data
)
345 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
346 uint32_t dscr
= DSCR_ITE
;
349 retval
= dpmv8_write_dcc_64(armv8
, data
);
350 if (retval
!= ERROR_OK
)
353 retval
= dpmv8_exec_opcode(dpm
, ARMV8_MRS(SYSTEM_DBG_DBGDTR_EL0
, 0), &dscr
);
354 if (retval
!= ERROR_OK
)
357 /* then the opcode, taking data from R0 */
358 return dpmv8_exec_opcode(dpm
, opcode
, &dscr
);
361 static int dpmv8_instr_cpsr_sync(struct arm_dpm
*dpm
)
364 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
366 /* "Prefetch flush" after modifying execution status in CPSR */
367 retval
= dpmv8_exec_opcode(dpm
, armv8_opcode(armv8
, ARMV8_OPC_DSB_SY
), &dpm
->dscr
);
368 if (retval
== ERROR_OK
)
369 dpmv8_exec_opcode(dpm
, armv8_opcode(armv8
, ARMV8_OPC_ISB_SY
), &dpm
->dscr
);
373 static int dpmv8_instr_read_data_dcc(struct arm_dpm
*dpm
,
374 uint32_t opcode
, uint32_t *data
)
376 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
377 uint32_t dscr
= DSCR_ITE
;
380 /* the opcode, writing data to DCC */
381 retval
= dpmv8_exec_opcode(dpm
, opcode
, &dscr
);
382 if (retval
!= ERROR_OK
)
385 return dpmv8_read_dcc(armv8
, data
, &dscr
);
388 static int dpmv8_instr_read_data_dcc_64(struct arm_dpm
*dpm
,
389 uint32_t opcode
, uint64_t *data
)
391 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
392 uint32_t dscr
= DSCR_ITE
;
395 /* the opcode, writing data to DCC */
396 retval
= dpmv8_exec_opcode(dpm
, opcode
, &dscr
);
397 if (retval
!= ERROR_OK
)
400 return dpmv8_read_dcc_64(armv8
, data
, &dscr
);
403 static int dpmv8_instr_read_data_r0(struct arm_dpm
*dpm
,
404 uint32_t opcode
, uint32_t *data
)
406 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
407 uint32_t dscr
= DSCR_ITE
;
410 /* the opcode, writing data to R0 */
411 retval
= dpmv8_exec_opcode(dpm
, opcode
, &dscr
);
412 if (retval
!= ERROR_OK
)
415 /* write R0 to DCC */
416 retval
= dpmv8_exec_opcode(dpm
, armv8_opcode(armv8
, WRITE_REG_DTRTX
), &dscr
);
417 if (retval
!= ERROR_OK
)
420 return dpmv8_read_dcc(armv8
, data
, &dscr
);
423 static int dpmv8_instr_read_data_r0_64(struct arm_dpm
*dpm
,
424 uint32_t opcode
, uint64_t *data
)
426 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
427 uint32_t dscr
= DSCR_ITE
;
430 /* the opcode, writing data to R0 */
431 retval
= dpmv8_exec_opcode(dpm
, opcode
, &dscr
);
432 if (retval
!= ERROR_OK
)
435 /* write R0 to DCC */
436 retval
= dpmv8_exec_opcode(dpm
, ARMV8_MSR_GP(SYSTEM_DBG_DBGDTR_EL0
, 0), &dscr
);
437 if (retval
!= ERROR_OK
)
440 return dpmv8_read_dcc_64(armv8
, data
, &dscr
);
444 static int dpmv8_bpwp_enable(struct arm_dpm
*dpm
, unsigned index_t
,
445 target_addr_t addr
, uint32_t control
)
447 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
448 uint32_t vr
= armv8
->debug_base
;
449 uint32_t cr
= armv8
->debug_base
;
453 case 0 ... 15: /* breakpoints */
454 vr
+= CPUV8_DBG_BVR_BASE
;
455 cr
+= CPUV8_DBG_BCR_BASE
;
457 case 16 ... 31: /* watchpoints */
458 vr
+= CPUV8_DBG_WVR_BASE
;
459 cr
+= CPUV8_DBG_WCR_BASE
;
468 LOG_DEBUG("A8: bpwp enable, vr %08x cr %08x",
469 (unsigned) vr
, (unsigned) cr
);
471 retval
= mem_ap_write_atomic_u32(armv8
->debug_ap
, vr
, addr
);
472 if (retval
!= ERROR_OK
)
474 return mem_ap_write_atomic_u32(armv8
->debug_ap
, cr
, control
);
478 static int dpmv8_bpwp_disable(struct arm_dpm
*dpm
, unsigned index_t
)
480 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
485 cr
= armv8
->debug_base
+ CPUV8_DBG_BCR_BASE
;
488 cr
= armv8
->debug_base
+ CPUV8_DBG_WCR_BASE
;
496 LOG_DEBUG("A: bpwp disable, cr %08x", (unsigned) cr
);
498 /* clear control register */
499 return mem_ap_write_atomic_u32(armv8
->debug_ap
, cr
, 0);
503 * Coprocessor support
506 /* Read coprocessor */
507 static int dpmv8_mrc(struct target
*target
, int cpnum
,
508 uint32_t op1
, uint32_t op2
, uint32_t CRn
, uint32_t CRm
,
511 struct arm
*arm
= target_to_arm(target
);
512 struct arm_dpm
*dpm
= arm
->dpm
;
515 retval
= dpm
->prepare(dpm
);
516 if (retval
!= ERROR_OK
)
519 LOG_DEBUG("MRC p%d, %d, r0, c%d, c%d, %d", cpnum
,
520 (int) op1
, (int) CRn
,
521 (int) CRm
, (int) op2
);
523 /* read coprocessor register into R0; return via DCC */
524 retval
= dpm
->instr_read_data_r0(dpm
,
525 ARMV4_5_MRC(cpnum
, op1
, 0, CRn
, CRm
, op2
),
528 /* (void) */ dpm
->finish(dpm
);
532 static int dpmv8_mcr(struct target
*target
, int cpnum
,
533 uint32_t op1
, uint32_t op2
, uint32_t CRn
, uint32_t CRm
,
536 struct arm
*arm
= target_to_arm(target
);
537 struct arm_dpm
*dpm
= arm
->dpm
;
540 retval
= dpm
->prepare(dpm
);
541 if (retval
!= ERROR_OK
)
544 LOG_DEBUG("MCR p%d, %d, r0, c%d, c%d, %d", cpnum
,
545 (int) op1
, (int) CRn
,
546 (int) CRm
, (int) op2
);
548 /* read DCC into r0; then write coprocessor register from R0 */
549 retval
= dpm
->instr_write_data_r0(dpm
,
550 ARMV4_5_MCR(cpnum
, op1
, 0, CRn
, CRm
, op2
),
553 /* (void) */ dpm
->finish(dpm
);
557 static int dpmv8_mrs(struct target
*target
, uint32_t op0
,
558 uint32_t op1
, uint32_t op2
, uint32_t CRn
, uint32_t CRm
,
561 struct arm
*arm
= target_to_arm(target
);
562 struct arm_dpm
*dpm
= arm
->dpm
;
566 retval
= dpm
->prepare(dpm
);
567 if (retval
!= ERROR_OK
)
569 op_code
= ((op0
& 0x3) << 19 | (op1
& 0x7) << 16 | (CRn
& 0xF) << 12 |\
570 (CRm
& 0xF) << 8 | (op2
& 0x7) << 5);
572 LOG_DEBUG("MRS p%d, %d, r0, c%d, c%d, %d", (int)op0
,
573 (int) op1
, (int) CRn
,
574 (int) CRm
, (int) op2
);
575 /* read coprocessor register into R0; return via DCC */
576 retval
= dpm
->instr_read_data_r0(dpm
,
577 ARMV8_MRS(op_code
, 0),
580 /* (void) */ dpm
->finish(dpm
);
584 static int dpmv8_msr(struct target
*target
, uint32_t op0
,
585 uint32_t op1
, uint32_t op2
, uint32_t CRn
, uint32_t CRm
,
588 struct arm
*arm
= target_to_arm(target
);
589 struct arm_dpm
*dpm
= arm
->dpm
;
593 retval
= dpm
->prepare(dpm
);
594 if (retval
!= ERROR_OK
)
597 op_code
= ((op0
& 0x3) << 19 | (op1
& 0x7) << 16 | (CRn
& 0xF) << 12 |\
598 (CRm
& 0xF) << 8 | (op2
& 0x7) << 5);
600 LOG_DEBUG("MSR p%d, %d, r0, c%d, c%d, %d", (int)op0
,
601 (int) op1
, (int) CRn
,
602 (int) CRm
, (int) op2
);
604 /* read DCC into r0; then write coprocessor register from R0 */
605 retval
= dpm
->instr_write_data_r0(dpm
,
606 ARMV8_MSR_GP(op_code
, 0),
609 /* (void) */ dpm
->finish(dpm
);
613 /*----------------------------------------------------------------------*/
616 * Register access utilities
619 int armv8_dpm_modeswitch(struct arm_dpm
*dpm
, enum arm_mode mode
)
621 struct armv8_common
*armv8
= (struct armv8_common
*)dpm
->arm
->arch_info
;
622 int retval
= ERROR_OK
;
623 unsigned int target_el
;
624 enum arm_state core_state
;
627 /* restore previous mode */
628 if (mode
== ARM_MODE_ANY
) {
629 cpsr
= buf_get_u32(dpm
->arm
->cpsr
->value
, 0, 32);
631 LOG_DEBUG("restoring mode, cpsr = 0x%08"PRIx32
, cpsr
);
634 LOG_DEBUG("setting mode 0x%"PRIx32
, mode
);
636 /* else force to the specified mode */
637 if (is_arm_mode(mode
))
643 switch (cpsr
& 0x1f) {
655 * TODO: handle ARM_MODE_HYP
665 target_el
= (cpsr
>> 2) & 3;
668 if (target_el
> SYSTEM_CUREL_EL3
) {
669 LOG_ERROR("%s: Invalid target exception level %i", __func__
, target_el
);
673 LOG_DEBUG("target_el = %i, last_el = %i", target_el
, dpm
->last_el
);
674 if (target_el
> dpm
->last_el
) {
675 retval
= dpm
->instr_execute(dpm
,
676 armv8_opcode(armv8
, ARMV8_OPC_DCPS
) | target_el
);
678 /* DCPS clobbers registers just like an exception taken */
679 armv8_dpm_handle_exception(dpm
);
681 core_state
= armv8_dpm_get_core_state(dpm
);
682 if (core_state
!= ARM_STATE_AARCH64
) {
683 /* cannot do DRPS/ERET when already in EL0 */
684 if (dpm
->last_el
!= 0) {
685 /* load SPSR with the desired mode and execute DRPS */
686 LOG_DEBUG("SPSR = 0x%08"PRIx32
, cpsr
);
687 retval
= dpm
->instr_write_data_r0(dpm
,
688 ARMV8_MSR_GP_xPSR_T1(1, 0, 15), cpsr
);
689 if (retval
== ERROR_OK
)
690 retval
= dpm
->instr_execute(dpm
, armv8_opcode(armv8
, ARMV8_OPC_DRPS
));
694 * need to execute multiple DRPS instructions until target_el
697 while (retval
== ERROR_OK
&& dpm
->last_el
!= target_el
) {
698 unsigned int cur_el
= dpm
->last_el
;
699 retval
= dpm
->instr_execute(dpm
, armv8_opcode(armv8
, ARMV8_OPC_DRPS
));
700 if (cur_el
== dpm
->last_el
) {
701 LOG_INFO("Cannot reach EL %i, SPSR corrupted?", target_el
);
707 /* On executing DRPS, DSPSR and DLR become UNKNOWN, mark them as dirty */
708 dpm
->arm
->cpsr
->dirty
= true;
709 dpm
->arm
->pc
->dirty
= true;
712 * re-evaluate the core state, we might be in Aarch32 state now
713 * we rely on dpm->dscr being up-to-date
715 core_state
= armv8_dpm_get_core_state(dpm
);
716 armv8_select_opcodes(armv8
, core_state
== ARM_STATE_AARCH64
);
717 armv8_select_reg_access(armv8
, core_state
== ARM_STATE_AARCH64
);
724 * Common register read, relies on armv8_select_reg_access() having been called.
726 static int dpmv8_read_reg(struct arm_dpm
*dpm
, struct reg
*r
, unsigned regnum
)
728 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
732 retval
= armv8
->read_reg_u64(armv8
, regnum
, &value_64
);
734 if (retval
== ERROR_OK
) {
737 buf_set_u64(r
->value
, 0, r
->size
, value_64
);
739 LOG_DEBUG("READ: %s, %16.8llx", r
->name
, (unsigned long long) value_64
);
741 LOG_DEBUG("READ: %s, %8.8x", r
->name
, (unsigned int) value_64
);
747 * Common register write, relies on armv8_select_reg_access() having been called.
749 static int dpmv8_write_reg(struct arm_dpm
*dpm
, struct reg
*r
, unsigned regnum
)
751 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
752 int retval
= ERROR_FAIL
;
755 value_64
= buf_get_u64(r
->value
, 0, r
->size
);
757 retval
= armv8
->write_reg_u64(armv8
, regnum
, value_64
);
758 if (retval
== ERROR_OK
) {
761 LOG_DEBUG("WRITE: %s, %16.8llx", r
->name
, (unsigned long long)value_64
);
763 LOG_DEBUG("WRITE: %s, %8.8x", r
->name
, (unsigned int)value_64
);
770 * Read basic registers of the the current context: R0 to R15, and CPSR;
771 * sets the core mode (such as USR or IRQ) and state (such as ARM or Thumb).
772 * In normal operation this is called on entry to halting debug state,
773 * possibly after some other operations supporting restore of debug state
774 * or making sure the CPU is fully idle (drain write buffer, etc).
776 int armv8_dpm_read_current_registers(struct arm_dpm
*dpm
)
778 struct arm
*arm
= dpm
->arm
;
779 struct armv8_common
*armv8
= (struct armv8_common
*)arm
->arch_info
;
780 struct reg_cache
*cache
;
785 retval
= dpm
->prepare(dpm
);
786 if (retval
!= ERROR_OK
)
789 cache
= arm
->core_cache
;
791 /* read R0 first (it's used for scratch), then CPSR */
792 r
= cache
->reg_list
+ 0;
794 retval
= dpmv8_read_reg(dpm
, r
, 0);
795 if (retval
!= ERROR_OK
)
800 /* read cpsr to r0 and get it back */
801 retval
= dpm
->instr_read_data_r0(dpm
,
802 armv8_opcode(armv8
, READ_REG_DSPSR
), &cpsr
);
803 if (retval
!= ERROR_OK
)
806 /* update core mode and state */
807 armv8_set_cpsr(arm
, cpsr
);
809 for (unsigned int i
= 1; i
< cache
->num_regs
; i
++) {
810 struct arm_reg
*arm_reg
;
812 r
= armv8_reg_current(arm
, i
);
817 * Only read registers that are available from the
818 * current EL (or core mode).
820 arm_reg
= r
->arch_info
;
821 if (arm_reg
->mode
!= ARM_MODE_ANY
&&
822 dpm
->last_el
!= armv8_curel_from_core_mode(arm_reg
->mode
))
825 retval
= dpmv8_read_reg(dpm
, r
, i
);
826 if (retval
!= ERROR_OK
)
836 /* Avoid needless I/O ... leave breakpoints and watchpoints alone
837 * unless they're removed, or need updating because of single-stepping
838 * or running debugger code.
840 static int dpmv8_maybe_update_bpwp(struct arm_dpm
*dpm
, bool bpwp
,
841 struct dpm_bpwp
*xp
, int *set_p
)
843 int retval
= ERROR_OK
;
850 /* removed or startup; we must disable it */
855 /* disabled, but we must set it */
856 xp
->dirty
= disable
= false;
861 /* set, but we must temporarily disable it */
862 xp
->dirty
= disable
= true;
867 retval
= dpm
->bpwp_disable(dpm
, xp
->number
);
869 retval
= dpm
->bpwp_enable(dpm
, xp
->number
,
870 xp
->address
, xp
->control
);
872 if (retval
!= ERROR_OK
)
873 LOG_ERROR("%s: can't %s HW %spoint %d",
874 disable
? "disable" : "enable",
875 target_name(dpm
->arm
->target
),
876 (xp
->number
< 16) ? "break" : "watch",
882 static int dpmv8_add_breakpoint(struct target
*target
, struct breakpoint
*bp
);
885 * Writes all modified core registers for all processor modes. In normal
886 * operation this is called on exit from halting debug state.
888 * @param dpm: represents the processor
889 * @param bpwp: true ensures breakpoints and watchpoints are set,
890 * false ensures they are cleared
892 int armv8_dpm_write_dirty_registers(struct arm_dpm
*dpm
, bool bpwp
)
894 struct arm
*arm
= dpm
->arm
;
895 struct reg_cache
*cache
= arm
->core_cache
;
898 retval
= dpm
->prepare(dpm
);
899 if (retval
!= ERROR_OK
)
902 /* If we're managing hardware breakpoints for this core, enable
903 * or disable them as requested.
905 * REVISIT We don't yet manage them for ANY cores. Eventually
906 * we should be able to assume we handle them; but until then,
907 * cope with the hand-crafted breakpoint code.
909 if (arm
->target
->type
->add_breakpoint
== dpmv8_add_breakpoint
) {
910 for (unsigned i
= 0; i
< dpm
->nbp
; i
++) {
911 struct dpm_bp
*dbp
= dpm
->dbp
+ i
;
912 struct breakpoint
*bp
= dbp
->bp
;
914 retval
= dpmv8_maybe_update_bpwp(dpm
, bpwp
, &dbp
->bpwp
,
915 bp
? &bp
->set
: NULL
);
916 if (retval
!= ERROR_OK
)
921 /* enable/disable watchpoints */
922 for (unsigned i
= 0; i
< dpm
->nwp
; i
++) {
923 struct dpm_wp
*dwp
= dpm
->dwp
+ i
;
924 struct watchpoint
*wp
= dwp
->wp
;
926 retval
= dpmv8_maybe_update_bpwp(dpm
, bpwp
, &dwp
->bpwp
,
927 wp
? &wp
->set
: NULL
);
928 if (retval
!= ERROR_OK
)
932 /* NOTE: writes to breakpoint and watchpoint registers might
933 * be queued, and need (efficient/batched) flushing later.
936 /* Restore original core mode and state */
937 retval
= armv8_dpm_modeswitch(dpm
, ARM_MODE_ANY
);
938 if (retval
!= ERROR_OK
)
941 /* check everything except our scratch register R0 */
942 for (unsigned i
= 1; i
< cache
->num_regs
; i
++) {
945 /* skip PC and CPSR */
946 if (i
== ARMV8_PC
|| i
== ARMV8_xPSR
)
949 if (!cache
->reg_list
[i
].valid
)
952 if (!cache
->reg_list
[i
].dirty
)
955 /* skip all registers not on the current EL */
956 r
= cache
->reg_list
[i
].arch_info
;
957 if (r
->mode
!= ARM_MODE_ANY
&&
958 dpm
->last_el
!= armv8_curel_from_core_mode(r
->mode
))
961 retval
= dpmv8_write_reg(dpm
, &cache
->reg_list
[i
], i
);
962 if (retval
!= ERROR_OK
)
966 /* flush CPSR and PC */
967 if (retval
== ERROR_OK
)
968 retval
= dpmv8_write_reg(dpm
, &cache
->reg_list
[ARMV8_xPSR
], ARMV8_xPSR
);
969 if (retval
== ERROR_OK
)
970 retval
= dpmv8_write_reg(dpm
, &cache
->reg_list
[ARMV8_PC
], ARMV8_PC
);
971 /* flush R0 -- it's *very* dirty by now */
972 if (retval
== ERROR_OK
)
973 retval
= dpmv8_write_reg(dpm
, &cache
->reg_list
[0], 0);
974 if (retval
== ERROR_OK
)
975 dpm
->instr_cpsr_sync(dpm
);
982 * Standard ARM register accessors ... there are three methods
983 * in "struct arm", to support individual read/write and bulk read
987 static int armv8_dpm_read_core_reg(struct target
*target
, struct reg
*r
,
988 int regnum
, enum arm_mode mode
)
990 struct arm
*arm
= target_to_arm(target
);
991 struct arm_dpm
*dpm
= target_to_arm(target
)->dpm
;
993 int max
= arm
->core_cache
->num_regs
;
995 if (regnum
< 0 || regnum
>= max
)
996 return ERROR_COMMAND_SYNTAX_ERROR
;
999 * REVISIT what happens if we try to read SPSR in a core mode
1000 * which has no such register?
1002 retval
= dpm
->prepare(dpm
);
1003 if (retval
!= ERROR_OK
)
1006 retval
= dpmv8_read_reg(dpm
, r
, regnum
);
1007 if (retval
!= ERROR_OK
)
1011 /* (void) */ dpm
->finish(dpm
);
1015 static int armv8_dpm_write_core_reg(struct target
*target
, struct reg
*r
,
1016 int regnum
, enum arm_mode mode
, uint8_t *value
)
1018 struct arm
*arm
= target_to_arm(target
);
1019 struct arm_dpm
*dpm
= target_to_arm(target
)->dpm
;
1021 int max
= arm
->core_cache
->num_regs
;
1023 if (regnum
< 0 || regnum
> max
)
1024 return ERROR_COMMAND_SYNTAX_ERROR
;
1026 /* REVISIT what happens if we try to write SPSR in a core mode
1027 * which has no such register?
1030 retval
= dpm
->prepare(dpm
);
1031 if (retval
!= ERROR_OK
)
1034 retval
= dpmv8_write_reg(dpm
, r
, regnum
);
1036 /* always clean up, regardless of error */
1042 static int armv8_dpm_full_context(struct target
*target
)
1044 struct arm
*arm
= target_to_arm(target
);
1045 struct arm_dpm
*dpm
= arm
->dpm
;
1046 struct reg_cache
*cache
= arm
->core_cache
;
1050 retval
= dpm
->prepare(dpm
);
1051 if (retval
!= ERROR_OK
)
1055 enum arm_mode mode
= ARM_MODE_ANY
;
1059 /* We "know" arm_dpm_read_current_registers() was called so
1060 * the unmapped registers (R0..R7, PC, AND CPSR) and some
1061 * view of R8..R14 are current. We also "know" oddities of
1062 * register mapping: special cases for R8..R12 and SPSR.
1064 * Pick some mode with unread registers and read them all.
1065 * Repeat until done.
1067 for (unsigned i
= 0; i
< cache
->num_regs
; i
++) {
1070 if (cache
->reg_list
[i
].valid
)
1072 r
= cache
->reg_list
[i
].arch_info
;
1074 /* may need to pick a mode and set CPSR */
1079 /* For regular (ARM_MODE_ANY) R8..R12
1080 * in case we've entered debug state
1081 * in FIQ mode we need to patch mode.
1083 if (mode
!= ARM_MODE_ANY
)
1084 retval
= armv8_dpm_modeswitch(dpm
, mode
);
1086 retval
= armv8_dpm_modeswitch(dpm
, ARM_MODE_USR
);
1088 if (retval
!= ERROR_OK
)
1091 if (r
->mode
!= mode
)
1094 /* CPSR was read, so "R16" must mean SPSR */
1095 retval
= dpmv8_read_reg(dpm
,
1096 &cache
->reg_list
[i
],
1097 (r
->num
== 16) ? 17 : r
->num
);
1098 if (retval
!= ERROR_OK
)
1104 retval
= armv8_dpm_modeswitch(dpm
, ARM_MODE_ANY
);
1105 /* (void) */ dpm
->finish(dpm
);
1111 /*----------------------------------------------------------------------*/
1114 * Breakpoint and Watchpoint support.
1116 * Hardware {break,watch}points are usually left active, to minimize
1117 * debug entry/exit costs. When they are set or cleared, it's done in
1118 * batches. Also, DPM-conformant hardware can update debug registers
1119 * regardless of whether the CPU is running or halted ... though that
1120 * fact isn't currently leveraged.
1123 static int dpmv8_bpwp_setup(struct arm_dpm
*dpm
, struct dpm_bpwp
*xp
,
1124 uint32_t addr
, uint32_t length
)
1128 control
= (1 << 0) /* enable */
1129 | (3 << 1); /* both user and privileged access */
1131 /* Match 1, 2, or all 4 byte addresses in this word.
1133 * FIXME: v7 hardware allows lengths up to 2 GB for BP and WP.
1134 * Support larger length, when addr is suitably aligned. In
1135 * particular, allow watchpoints on 8 byte "double" values.
1137 * REVISIT allow watchpoints on unaligned 2-bit values; and on
1138 * v7 hardware, unaligned 4-byte ones too.
1142 control
|= (1 << (addr
& 3)) << 5;
1145 /* require 2-byte alignment */
1147 control
|= (3 << (addr
& 2)) << 5;
1152 /* require 4-byte alignment */
1154 control
|= 0xf << 5;
1159 LOG_ERROR("unsupported {break,watch}point length/alignment");
1160 return ERROR_COMMAND_SYNTAX_ERROR
;
1163 /* other shared control bits:
1164 * bits 15:14 == 0 ... both secure and nonsecure states (v6.1+ only)
1165 * bit 20 == 0 ... not linked to a context ID
1166 * bit 28:24 == 0 ... not ignoring N LSBs (v7 only)
1169 xp
->address
= addr
& ~3;
1170 xp
->control
= control
;
1173 LOG_DEBUG("BPWP: addr %8.8" PRIx32
", control %" PRIx32
", number %d",
1174 xp
->address
, control
, xp
->number
);
1176 /* hardware is updated in write_dirty_registers() */
1180 static int dpmv8_add_breakpoint(struct target
*target
, struct breakpoint
*bp
)
1182 struct arm
*arm
= target_to_arm(target
);
1183 struct arm_dpm
*dpm
= arm
->dpm
;
1184 int retval
= ERROR_TARGET_RESOURCE_NOT_AVAILABLE
;
1187 return ERROR_COMMAND_SYNTAX_ERROR
;
1188 if (!dpm
->bpwp_enable
)
1191 /* FIXME we need a generic solution for software breakpoints. */
1192 if (bp
->type
== BKPT_SOFT
)
1193 LOG_DEBUG("using HW bkpt, not SW...");
1195 for (unsigned i
= 0; i
< dpm
->nbp
; i
++) {
1196 if (!dpm
->dbp
[i
].bp
) {
1197 retval
= dpmv8_bpwp_setup(dpm
, &dpm
->dbp
[i
].bpwp
,
1198 bp
->address
, bp
->length
);
1199 if (retval
== ERROR_OK
)
1200 dpm
->dbp
[i
].bp
= bp
;
1208 static int dpmv8_remove_breakpoint(struct target
*target
, struct breakpoint
*bp
)
1210 struct arm
*arm
= target_to_arm(target
);
1211 struct arm_dpm
*dpm
= arm
->dpm
;
1212 int retval
= ERROR_COMMAND_SYNTAX_ERROR
;
1214 for (unsigned i
= 0; i
< dpm
->nbp
; i
++) {
1215 if (dpm
->dbp
[i
].bp
== bp
) {
1216 dpm
->dbp
[i
].bp
= NULL
;
1217 dpm
->dbp
[i
].bpwp
.dirty
= true;
1219 /* hardware is updated in write_dirty_registers() */
1228 static int dpmv8_watchpoint_setup(struct arm_dpm
*dpm
, unsigned index_t
,
1229 struct watchpoint
*wp
)
1232 struct dpm_wp
*dwp
= dpm
->dwp
+ index_t
;
1235 /* this hardware doesn't support data value matching or masking */
1236 if (wp
->value
|| wp
->mask
!= ~(uint32_t)0) {
1237 LOG_DEBUG("watchpoint values and masking not supported");
1238 return ERROR_TARGET_RESOURCE_NOT_AVAILABLE
;
1241 retval
= dpmv8_bpwp_setup(dpm
, &dwp
->bpwp
, wp
->address
, wp
->length
);
1242 if (retval
!= ERROR_OK
)
1245 control
= dwp
->bpwp
.control
;
1257 dwp
->bpwp
.control
= control
;
1259 dpm
->dwp
[index_t
].wp
= wp
;
1264 static int dpmv8_add_watchpoint(struct target
*target
, struct watchpoint
*wp
)
1266 struct arm
*arm
= target_to_arm(target
);
1267 struct arm_dpm
*dpm
= arm
->dpm
;
1268 int retval
= ERROR_TARGET_RESOURCE_NOT_AVAILABLE
;
1270 if (dpm
->bpwp_enable
) {
1271 for (unsigned i
= 0; i
< dpm
->nwp
; i
++) {
1272 if (!dpm
->dwp
[i
].wp
) {
1273 retval
= dpmv8_watchpoint_setup(dpm
, i
, wp
);
1282 static int dpmv8_remove_watchpoint(struct target
*target
, struct watchpoint
*wp
)
1284 struct arm
*arm
= target_to_arm(target
);
1285 struct arm_dpm
*dpm
= arm
->dpm
;
1286 int retval
= ERROR_COMMAND_SYNTAX_ERROR
;
1288 for (unsigned i
= 0; i
< dpm
->nwp
; i
++) {
1289 if (dpm
->dwp
[i
].wp
== wp
) {
1290 dpm
->dwp
[i
].wp
= NULL
;
1291 dpm
->dwp
[i
].bpwp
.dirty
= true;
1293 /* hardware is updated in write_dirty_registers() */
1302 void armv8_dpm_report_wfar(struct arm_dpm
*dpm
, uint64_t addr
)
1304 switch (dpm
->arm
->core_state
) {
1306 case ARM_STATE_AARCH64
:
1309 case ARM_STATE_THUMB
:
1310 case ARM_STATE_THUMB_EE
:
1313 case ARM_STATE_JAZELLE
:
1317 LOG_DEBUG("Unknow core_state");
1324 * Handle exceptions taken in debug state. This happens mostly for memory
1325 * accesses that violated a MMU policy. Taking an exception while in debug
1326 * state clobbers certain state registers on the target exception level.
1327 * Just mark those registers dirty so that they get restored on resume.
1328 * This works both for Aarch32 and Aarch64 states.
1330 * This function must not perform any actions that trigger another exception
1331 * or a recursion will happen.
1333 void armv8_dpm_handle_exception(struct arm_dpm
*dpm
)
1335 struct armv8_common
*armv8
= dpm
->arm
->arch_info
;
1336 struct reg_cache
*cache
= dpm
->arm
->core_cache
;
1337 enum arm_state core_state
;
1342 static const int clobbered_regs_by_el
[3][5] = {
1343 { ARMV8_PC
, ARMV8_xPSR
, ARMV8_ELR_EL1
, ARMV8_ESR_EL1
, ARMV8_SPSR_EL1
},
1344 { ARMV8_PC
, ARMV8_xPSR
, ARMV8_ELR_EL2
, ARMV8_ESR_EL2
, ARMV8_SPSR_EL2
},
1345 { ARMV8_PC
, ARMV8_xPSR
, ARMV8_ELR_EL3
, ARMV8_ESR_EL3
, ARMV8_SPSR_EL3
},
1348 el
= (dpm
->dscr
>> 8) & 3;
1350 /* safety check, must not happen since EL0 cannot be a target for an exception */
1351 if (el
< SYSTEM_CUREL_EL1
|| el
> SYSTEM_CUREL_EL3
) {
1352 LOG_ERROR("%s: EL %i is invalid, DSCR corrupted?", __func__
, el
);
1356 armv8
->read_reg_u64(armv8
, ARMV8_xPSR
, &dlr
);
1358 armv8
->read_reg_u64(armv8
, ARMV8_PC
, &dlr
);
1360 LOG_DEBUG("Exception taken to EL %i, DLR=0x%016"PRIx64
" DSPSR=0x%08"PRIx32
,
1363 /* mark all clobbered registers as dirty */
1364 for (int i
= 0; i
< 5; i
++)
1365 cache
->reg_list
[clobbered_regs_by_el
[el
-1][i
]].dirty
= true;
1368 * re-evaluate the core state, we might be in Aarch64 state now
1369 * we rely on dpm->dscr being up-to-date
1371 core_state
= armv8_dpm_get_core_state(dpm
);
1372 armv8_select_opcodes(armv8
, core_state
== ARM_STATE_AARCH64
);
1373 armv8_select_reg_access(armv8
, core_state
== ARM_STATE_AARCH64
);
1376 /*----------------------------------------------------------------------*/
1379 * Other debug and support utilities
1382 void armv8_dpm_report_dscr(struct arm_dpm
*dpm
, uint32_t dscr
)
1384 struct target
*target
= dpm
->arm
->target
;
1387 dpm
->last_el
= (dscr
>> 8) & 3;
1389 /* Examine debug reason */
1390 switch (DSCR_ENTRY(dscr
)) {
1391 /* FALL THROUGH -- assume a v6 core in abort mode */
1392 case DSCRV8_ENTRY_EXT_DEBUG
: /* EDBGRQ */
1393 target
->debug_reason
= DBG_REASON_DBGRQ
;
1395 case DSCRV8_ENTRY_HALT_STEP_EXECLU
: /* HALT step */
1396 case DSCRV8_ENTRY_HALT_STEP_NORMAL
: /* Halt step*/
1397 case DSCRV8_ENTRY_HALT_STEP
:
1398 target
->debug_reason
= DBG_REASON_SINGLESTEP
;
1400 case DSCRV8_ENTRY_HLT
: /* HLT instruction (software breakpoint) */
1401 case DSCRV8_ENTRY_BKPT
: /* SW BKPT (?) */
1402 case DSCRV8_ENTRY_RESET_CATCH
: /* Reset catch */
1403 case DSCRV8_ENTRY_OS_UNLOCK
: /*OS unlock catch*/
1404 case DSCRV8_ENTRY_EXCEPTION_CATCH
: /*exception catch*/
1405 case DSCRV8_ENTRY_SW_ACCESS_DBG
: /*SW access dbg register*/
1406 target
->debug_reason
= DBG_REASON_BREAKPOINT
;
1408 case DSCRV8_ENTRY_WATCHPOINT
: /* asynch watchpoint */
1409 target
->debug_reason
= DBG_REASON_WATCHPOINT
;
1412 target
->debug_reason
= DBG_REASON_UNDEFINED
;
1418 /*----------------------------------------------------------------------*/
1421 * Setup and management support.
1425 * Hooks up this DPM to its associated target; call only once.
1426 * Initially this only covers the register cache.
1428 * Oh, and watchpoints. Yeah.
1430 int armv8_dpm_setup(struct arm_dpm
*dpm
)
1432 struct arm
*arm
= dpm
->arm
;
1433 struct target
*target
= arm
->target
;
1434 struct reg_cache
*cache
;
1437 /* register access setup */
1438 arm
->full_context
= armv8_dpm_full_context
;
1439 arm
->read_core_reg
= armv8_dpm_read_core_reg
;
1440 arm
->write_core_reg
= armv8_dpm_write_core_reg
;
1442 if (arm
->core_cache
== NULL
) {
1443 cache
= armv8_build_reg_cache(target
);
1448 /* coprocessor access setup */
1449 arm
->mrc
= dpmv8_mrc
;
1450 arm
->mcr
= dpmv8_mcr
;
1451 arm
->mrs
= dpmv8_mrs
;
1452 arm
->msr
= dpmv8_msr
;
1454 dpm
->prepare
= dpmv8_dpm_prepare
;
1455 dpm
->finish
= dpmv8_dpm_finish
;
1457 dpm
->instr_execute
= dpmv8_instr_execute
;
1458 dpm
->instr_write_data_dcc
= dpmv8_instr_write_data_dcc
;
1459 dpm
->instr_write_data_dcc_64
= dpmv8_instr_write_data_dcc_64
;
1460 dpm
->instr_write_data_r0
= dpmv8_instr_write_data_r0
;
1461 dpm
->instr_write_data_r0_64
= dpmv8_instr_write_data_r0_64
;
1462 dpm
->instr_cpsr_sync
= dpmv8_instr_cpsr_sync
;
1464 dpm
->instr_read_data_dcc
= dpmv8_instr_read_data_dcc
;
1465 dpm
->instr_read_data_dcc_64
= dpmv8_instr_read_data_dcc_64
;
1466 dpm
->instr_read_data_r0
= dpmv8_instr_read_data_r0
;
1467 dpm
->instr_read_data_r0_64
= dpmv8_instr_read_data_r0_64
;
1469 dpm
->arm_reg_current
= armv8_reg_current
;
1471 /* dpm->bpwp_enable = dpmv8_bpwp_enable; */
1472 dpm
->bpwp_disable
= dpmv8_bpwp_disable
;
1474 /* breakpoint setup -- optional until it works everywhere */
1475 if (!target
->type
->add_breakpoint
) {
1476 target
->type
->add_breakpoint
= dpmv8_add_breakpoint
;
1477 target
->type
->remove_breakpoint
= dpmv8_remove_breakpoint
;
1480 /* watchpoint setup */
1481 target
->type
->add_watchpoint
= dpmv8_add_watchpoint
;
1482 target
->type
->remove_watchpoint
= dpmv8_remove_watchpoint
;
1484 /* FIXME add vector catch support */
1486 dpm
->nbp
= 1 + ((dpm
->didr
>> 12) & 0xf);
1487 dpm
->dbp
= calloc(dpm
->nbp
, sizeof *dpm
->dbp
);
1489 dpm
->nwp
= 1 + ((dpm
->didr
>> 20) & 0xf);
1490 dpm
->dwp
= calloc(dpm
->nwp
, sizeof *dpm
->dwp
);
1492 if (!dpm
->dbp
|| !dpm
->dwp
) {
1498 LOG_INFO("%s: hardware has %d breakpoints, %d watchpoints",
1499 target_name(target
), dpm
->nbp
, dpm
->nwp
);
1501 /* REVISIT ... and some of those breakpoints could match
1502 * execution context IDs...
1509 * Reinitializes DPM state at the beginning of a new debug session
1510 * or after a reset which may have affected the debug module.
1512 int armv8_dpm_initialize(struct arm_dpm
*dpm
)
1514 /* Disable all breakpoints and watchpoints at startup. */
1515 if (dpm
->bpwp_disable
) {
1518 for (i
= 0; i
< dpm
->nbp
; i
++) {
1519 dpm
->dbp
[i
].bpwp
.number
= i
;
1520 (void) dpm
->bpwp_disable(dpm
, i
);
1522 for (i
= 0; i
< dpm
->nwp
; i
++) {
1523 dpm
->dwp
[i
].bpwp
.number
= 16 + i
;
1524 (void) dpm
->bpwp_disable(dpm
, 16 + i
);
1527 LOG_WARNING("%s: can't disable breakpoints and watchpoints",
1528 target_name(dpm
->arm
->target
));