OpenOCD
arm_dpm.c File Reference

Implements various ARM DPM operations using architectural debug registers. More...

Include dependency graph for arm_dpm.c:

Go to the source code of this file.

Functions

static int arm_dpm_full_context (struct target *target)
 
int arm_dpm_initialize (struct arm_dpm *dpm)
 Reinitializes DPM state at the beginning of a new debug session or after a reset which may have affected the debug module. More...
 
int arm_dpm_modeswitch (struct arm_dpm *dpm, enum arm_mode mode)
 
static int arm_dpm_read_core_reg (struct target *target, struct reg *r, int regnum, enum arm_mode mode)
 
int arm_dpm_read_current_registers (struct arm_dpm *dpm)
 Read basic registers of the current context: R0 to R15, and CPSR; sets the core mode (such as USR or IRQ) and state (such as ARM or Thumb). More...
 
int arm_dpm_read_reg (struct arm_dpm *dpm, struct reg *r, unsigned regnum)
 
void arm_dpm_report_dscr (struct arm_dpm *dpm, uint32_t dscr)
 
void arm_dpm_report_wfar (struct arm_dpm *dpm, uint32_t addr)
 
int arm_dpm_setup (struct arm_dpm *dpm)
 Hooks up this DPM to its associated target; call only once. More...
 
static int arm_dpm_write_core_reg (struct target *target, struct reg *r, int regnum, enum arm_mode mode, uint8_t *value)
 
int arm_dpm_write_dirty_registers (struct arm_dpm *dpm, bool bpwp)
 Writes all modified core registers for all processor modes. More...
 
static int dpm_add_breakpoint (struct target *target, struct breakpoint *bp)
 
static int dpm_add_watchpoint (struct target *target, struct watchpoint *wp)
 
static int dpm_bpwp_setup (struct arm_dpm *dpm, struct dpm_bpwp *xp, uint32_t addr, uint32_t length)
 
static enum arm_mode dpm_mapmode (struct arm *arm, unsigned num, enum arm_mode mode)
 
static int dpm_maybe_update_bpwp (struct arm_dpm *dpm, bool bpwp, struct dpm_bpwp *xp, bool *set_p)
 
static int dpm_mcr (struct target *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t value)
 
static int dpm_mrc (struct target *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t *value)
 
static int dpm_read_reg_u64 (struct arm_dpm *dpm, struct reg *r, unsigned regnum)
 
static int dpm_remove_breakpoint (struct target *target, struct breakpoint *bp)
 
static int dpm_remove_watchpoint (struct target *target, struct watchpoint *wp)
 
static int dpm_watchpoint_setup (struct arm_dpm *dpm, unsigned index_t, struct watchpoint *wp)
 
static int dpm_write_pc_core_state (struct arm_dpm *dpm, struct reg *r)
 Write to program counter and switch the core state (arm/thumb) according to the address. More...
 
static int dpm_write_reg (struct arm_dpm *dpm, struct reg *r, unsigned regnum)
 
static int dpm_write_reg_u64 (struct arm_dpm *dpm, struct reg *r, unsigned regnum)
 

Detailed Description

Implements various ARM DPM operations using architectural debug registers.

These routines layer over core-specific communication methods to cope with implementation differences between cores like ARM1136 and Cortex-A8.

The "Debug Programmers' Model" (DPM) for ARMv6 and ARMv7 is defined by Part C (Debug Architecture) of the ARM Architecture Reference Manual, ARMv7-A and ARMv7-R edition (ARM DDI 0406B). In OpenOCD, DPM operations are abstracted through internal programming interfaces to share code and to minimize needless differences in debug behavior between cores.

Definition in file arm_dpm.c.

Function Documentation

◆ arm_dpm_full_context()

◆ arm_dpm_initialize()

int arm_dpm_initialize ( struct arm_dpm dpm)

Reinitializes DPM state at the beginning of a new debug session or after a reset which may have affected the debug module.

Definition at line 1114 of file arm_dpm.c.

References arm_dpm::arm, dpm_bp::bpwp, dpm_wp::bpwp, arm_dpm::bpwp_disable, arm_dpm::dbp, arm_dpm::dwp, ERROR_OK, LOG_WARNING, arm_dpm::nbp, dpm_bpwp::number, arm_dpm::nwp, arm::target, and target_name().

Referenced by arm11_dpm_init(), and cortex_a_dpm_setup().

◆ arm_dpm_modeswitch()

◆ arm_dpm_read_core_reg()

static int arm_dpm_read_core_reg ( struct target target,
struct reg r,
int  regnum,
enum arm_mode  mode 
)
static

◆ arm_dpm_read_current_registers()

int arm_dpm_read_current_registers ( struct arm_dpm dpm)

Read basic registers of the current context: R0 to R15, and CPSR; sets the core mode (such as USR or IRQ) and state (such as ARM or Thumb).

In normal operation this is called on entry to halting debug state, possibly after some other operations supporting restore of debug state or making sure the CPU is fully idle (drain write buffer, etc).

Definition at line 333 of file arm_dpm.c.

References arm_dpm::arm, arm_dpm_read_reg(), arm_reg_current(), arm_set_cpsr(), ARMV4_5_MRS, arm::core_cache, arm::cpsr, reg::dirty, arm::dpm, ERROR_OK, arm_dpm::finish, arm_dpm::instr_read_data_r0, arm_dpm::prepare, reg_cache::reg_list, and reg::valid.

Referenced by arm11_debug_entry(), and cortex_a_debug_entry().

◆ arm_dpm_read_reg()

◆ arm_dpm_report_dscr()

◆ arm_dpm_report_wfar()

void arm_dpm_report_wfar ( struct arm_dpm dpm,
uint32_t  addr 
)

◆ arm_dpm_setup()

◆ arm_dpm_write_core_reg()

static int arm_dpm_write_core_reg ( struct target target,
struct reg r,
int  regnum,
enum arm_mode  mode,
uint8_t *  value 
)
static

◆ arm_dpm_write_dirty_registers()

int arm_dpm_write_dirty_registers ( struct arm_dpm dpm,
bool  bpwp 
)

Writes all modified core registers for all processor modes.

In normal operation this is called on exit from halting debug state.

Parameters
dpmrepresents the processor
bpwptrue ensures breakpoints and watchpoints are set, false ensures they are cleared

Definition at line 441 of file arm_dpm.c.

References target_type::add_breakpoint, reg::arch_info, arm_dpm::arm, arm_dpm_modeswitch(), ARM_MODE_ANY, ARM_MODE_FIQ, ARM_MODE_USR, dpm_bp::bp, dpm_bp::bpwp, dpm_wp::bpwp, arm::core_cache, arm::core_mode, arm::cpsr, arm_dpm::dbp, reg::dirty, arm::dpm, dpm_add_breakpoint(), dpm_maybe_update_bpwp(), dpm_write_pc_core_state(), dpm_write_reg(), arm_dpm::dwp, ERROR_OK, reg::exist, arm_dpm::finish, breakpoint::is_set, watchpoint::is_set, arm_reg::mode, mode, arm_dpm::nbp, NULL, arm_reg::num, reg_cache::num_regs, arm_dpm::nwp, arm::pc, arm_dpm::prepare, reg_cache::reg_list, arm::target, target::type, and dpm_wp::wp.

Referenced by arm11_leave_debug_state(), and cortex_a_restore_context().

◆ dpm_add_breakpoint()

◆ dpm_add_watchpoint()

static int dpm_add_watchpoint ( struct target target,
struct watchpoint wp 
)
static

◆ dpm_bpwp_setup()

static int dpm_bpwp_setup ( struct arm_dpm dpm,
struct dpm_bpwp xp,
uint32_t  addr,
uint32_t  length 
)
static

◆ dpm_mapmode()

static enum arm_mode dpm_mapmode ( struct arm arm,
unsigned  num,
enum arm_mode  mode 
)
static

Definition at line 441 of file arm_dpm.c.

Referenced by arm_dpm_read_core_reg(), and arm_dpm_write_core_reg().

◆ dpm_maybe_update_bpwp()

static int dpm_maybe_update_bpwp ( struct arm_dpm dpm,
bool  bpwp,
struct dpm_bpwp xp,
bool *  set_p 
)
static

◆ dpm_mcr()

static int dpm_mcr ( struct target target,
int  cpnum,
uint32_t  op1,
uint32_t  op2,
uint32_t  crn,
uint32_t  crm,
uint32_t  value 
)
static

◆ dpm_mrc()

static int dpm_mrc ( struct target target,
int  cpnum,
uint32_t  op1,
uint32_t  op2,
uint32_t  crn,
uint32_t  crm,
uint32_t *  value 
)
static

◆ dpm_read_reg_u64()

static int dpm_read_reg_u64 ( struct arm_dpm dpm,
struct reg r,
unsigned  regnum 
)
static

◆ dpm_remove_breakpoint()

static int dpm_remove_breakpoint ( struct target target,
struct breakpoint bp 
)
static

◆ dpm_remove_watchpoint()

static int dpm_remove_watchpoint ( struct target target,
struct watchpoint wp 
)
static

◆ dpm_watchpoint_setup()

static int dpm_watchpoint_setup ( struct arm_dpm dpm,
unsigned  index_t,
struct watchpoint wp 
)
static

◆ dpm_write_pc_core_state()

static int dpm_write_pc_core_state ( struct arm_dpm dpm,
struct reg r 
)
static

Write to program counter and switch the core state (arm/thumb) according to the address.

Definition at line 318 of file arm_dpm.c.

References ARMV4_5_BX, buf_get_u32(), arm_dpm::instr_write_data_r0, and reg::value.

Referenced by arm_dpm_write_dirty_registers().

◆ dpm_write_reg()

◆ dpm_write_reg_u64()

static int dpm_write_reg_u64 ( struct arm_dpm dpm,
struct reg r,
unsigned  regnum 
)
static