target->state = TARGET_RESET;
jtag_add_sleep(50000);
- armv4_5_invalidate_core_regs(target);
+ register_cache_invalidate(arm7_9->armv4_5_common.core_cache);
if ((target->reset_halt) && ((jtag_reset_config & RESET_SRST_PULLS_TRST) == 0))
{
}
/* all register content is now invalid */
- if ((retval = armv4_5_invalidate_core_regs(target)) != ERROR_OK)
- {
- return retval;
- }
+ register_cache_invalidate(armv4_5->core_cache);
/* SVC, ARM state, IRQ and FIQ disabled */
buf_set_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 8, 0xd3);
if (!debug_execution)
{
/* registers are now invalid */
- armv4_5_invalidate_core_regs(target);
+ register_cache_invalidate(armv4_5->core_cache);
target->state = TARGET_RUNNING;
if ((retval = target_call_event_callbacks(target, TARGET_EVENT_RESUMED)) != ERROR_OK)
{
arm7_9->disable_single_step(target);
/* registers are now invalid */
- armv4_5_invalidate_core_regs(target);
+ register_cache_invalidate(armv4_5->core_cache);
if (err != ERROR_OK)
{
.set = armv4_5_set_core_reg,
};
-/** Marks the contents of the register cache as invalid (and clean). */
-int armv4_5_invalidate_core_regs(struct target *target)
-{
- struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target);
- unsigned num_regs = armv4_5->core_cache->num_regs;
- struct reg *reg = armv4_5->core_cache->reg_list;
-
- for (unsigned i = 0; i < num_regs; i++, reg++) {
- reg->valid = 0;
- reg->dirty = 0;
- }
-
- /* FIXME don't bother returning a value then */
- return ERROR_OK;
-}
-
struct reg_cache* armv4_5_build_reg_cache(struct target *target, struct arm *armv4_5_common)
{
int num_regs = ARRAY_SIZE(arm_core_regs);
uint32_t entry_point, uint32_t exit_point,
int timeout_ms, void *arch_info);
-int armv4_5_invalidate_core_regs(struct target *target);
-
int arm_checksum_memory(struct target *target,
uint32_t address, uint32_t count, uint32_t *checksum);
int arm_blank_check_memory(struct target *target,
return ERROR_OK;
}
-/** Invalidates cache of core registers set up by armv7m_build_reg_cache(). */
-int armv7m_invalidate_core_regs(struct target *target)
-{
- struct armv7m_common *armv7m = target_to_armv7m(target);
- int i;
-
- for (i = 0; i < armv7m->core_cache->num_regs; i++)
- {
- armv7m->core_cache->reg_list[i].valid = 0;
- armv7m->core_cache->reg_list[i].dirty = 0;
- }
-
- return ERROR_OK;
-}
-
/**
* Returns generic ARM userspace registers to GDB.
* GDB doesn't quite understand that most ARMs don't have floating point
target->state = TARGET_RUNNING;
/* registers are now invalid */
- armv4_5_invalidate_core_regs(target);
+ register_cache_invalidate(armv4_5->core_cache);
if (!debug_execution)
{
static int cortex_a8_assert_reset(struct target *target)
{
+ struct armv7a_common *armv7a = target_to_armv7a(target);
LOG_DEBUG(" ");
/* registers are now invalid */
- armv4_5_invalidate_core_regs(target);
+ register_cache_invalidate(armv7a->armv4_5_common.core_cache);
target->state = TARGET_RESET;
}
swjdp_transaction_endcheck(swjdp);
- armv7m_invalidate_core_regs(target);
+ register_cache_invalidate(cortex_m3->armv7m.core_cache);
/* make sure we have latest dhcsr flags */
mem_ap_read_atomic_u32(swjdp, DCB_DHCSR, &cortex_m3->dcb_dhcsr);
target->state = TARGET_RESET;
/* registers are now invalid */
- armv7m_invalidate_core_regs(target);
+ register_cache_invalidate(cortex_m3->armv7m.core_cache);
while (timeout < 100)
{
target->debug_reason = DBG_REASON_NOTHALTED;
/* registers are now invalid */
- armv7m_invalidate_core_regs(target);
+ register_cache_invalidate(armv7m->core_cache);
+
if (!debug_execution)
{
target->state = TARGET_RUNNING;
mem_ap_read_atomic_u32(swjdp, DCB_DHCSR, &cortex_m3->dcb_dhcsr);
/* registers are now invalid */
- armv7m_invalidate_core_regs(target);
+ register_cache_invalidate(cortex_m3->armv7m.core_cache);
if (breakpoint)
cortex_m3_set_breakpoint(target, breakpoint);
target->state = TARGET_RESET;
jtag_add_sleep(50000);
- armv7m_invalidate_core_regs(target);
+ register_cache_invalidate(cortex_m3->armv7m.core_cache);
if (target->reset_halt)
{
static struct reg *etm_reg_lookup(struct etm_context *etm_ctx, unsigned id)
{
struct reg_cache *cache = etm_ctx->reg_cache;
- int i;
+ unsigned i;
for (i = 0; i < cache->num_regs; i++) {
struct etm_reg *reg = cache->reg_list[i].arch_info;
return ERROR_OK;
}
-int mips32_invalidate_core_regs(struct target *target)
-{
- /* get pointers to arch-specific information */
- struct mips32_common *mips32 = target->arch_info;
- int i;
-
- for (i = 0; i < mips32->core_cache->num_regs; i++)
- {
- mips32->core_cache->reg_list[i].valid = 0;
- mips32->core_cache->reg_list[i].dirty = 0;
- }
-
- return ERROR_OK;
-}
-
int mips32_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size)
{
/* get pointers to arch-specific information */
int mips32_register_commands(struct command_context *cmd_ctx);
-int mips32_invalidate_core_regs(struct target *target);
int mips32_get_gdb_reg_list(struct target *target,
struct reg **reg_list[], int *reg_list_size);
target->state = TARGET_RESET;
jtag_add_sleep(50000);
- mips32_invalidate_core_regs(target);
+ register_cache_invalidate(mips32->core_cache);
if (target->reset_halt)
{
target->debug_reason = DBG_REASON_NOTHALTED;
/* registers are now invalid */
- mips32_invalidate_core_regs(target);
+ register_cache_invalidate(mips32->core_cache);
if (!debug_execution)
{
mips_ejtag_exit_debug(ejtag_info);
/* registers are now invalid */
- mips32_invalidate_core_regs(target);
+ register_cache_invalidate(mips32->core_cache);
if (breakpoint)
mips_m4k_set_breakpoint(target, breakpoint);
#include "register.h"
#include "log.h"
+/**
+ * @file
+ * Holds utilities to work with register caches.
+ *
+ * OpenOCD uses machine registers internally, and exposes them by name
+ * to Tcl scripts. Sets of related registers are grouped into caches.
+ * For example, a CPU core will expose a set of registers, and there
+ * may be separate registers associated with debug or trace modules.
+ */
struct reg* register_get_by_name(struct reg_cache *first,
const char *name, bool search_all)
{
- int i;
+ unsigned i;
struct reg_cache *cache = first;
while (cache)
return cache_p;
}
+/** Marks the contents of the register cache as invalid (and clean). */
+void register_cache_invalidate(struct reg_cache *cache)
+{
+ struct reg *reg = cache->reg_list;
+
+ for (unsigned n = cache->num_regs; n != 0; n--, reg++) {
+ reg->valid = 0;
+ reg->dirty = 0;
+ }
+}
+
static int register_get_dummy_core_reg(struct reg *reg)
{
return ERROR_OK;
char *name;
struct reg_cache *next;
struct reg *reg_list;
- int num_regs;
+ unsigned num_regs;
};
struct reg_arch_type
struct reg* register_get_by_name(struct reg_cache *first,
const char *name, bool search_all);
struct reg_cache** register_get_last_cache_p(struct reg_cache **first);
+void register_cache_invalidate(struct reg_cache *cache);
void register_init_dummy(struct reg *reg);
{
struct target *target;
struct reg *reg = NULL;
- int count = 0;
+ unsigned count = 0;
char *value;
LOG_DEBUG("-");
count = 0;
while (cache)
{
- int i;
+ unsigned i;
command_print(CMD_CTX, "===== %s", cache->name);
count = 0;
while (cache)
{
- int i;
+ unsigned i;
for (i = 0; i < cache->num_regs; i++)
{
- if (count++ == (int)num)
+ if (count++ == num)
{
reg = &cache->reg_list[i];
break;
if (!debug_execution)
{
/* registers are now invalid */
- armv4_5_invalidate_core_regs(target);
+ register_cache_invalidate(armv4_5->core_cache);
target->state = TARGET_RUNNING;
target_call_event_callbacks(target, TARGET_EVENT_RESUMED);
}
target_call_event_callbacks(target, TARGET_EVENT_RESUMED);
/* registers are now invalid */
- if ((retval = armv4_5_invalidate_core_regs(target)) != ERROR_OK)
- return retval;
+ register_cache_invalidate(armv4_5->core_cache);
/* wait for and process debug entry */
if ((retval = xscale_debug_entry(target)) != ERROR_OK)
breakpoint = breakpoint->next;
}
- armv4_5_invalidate_core_regs(target);
+ register_cache_invalidate(xscale->armv4_5_common.core_cache);
/* FIXME mark hardware watchpoints got unset too. Also,
* at least some of the XScale registers are invalid...