cortex_m: avoid reading and writing non-existent registers

Change-Id: Iedc24352c8d3444372da06d00fcec9603540f950
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6059
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Tarek BOCHKATI 2021-02-12 21:12:43 +01:00 committed by Antonio Borneo
parent 5e57090203
commit bc0c9907d6
3 changed files with 6 additions and 6 deletions

View File

@ -166,10 +166,10 @@ int armv7m_restore_context(struct target *target)
* packing of ARMV7M_PMSK_BPRI_FLTMSK_CTRL!
* See also comments in the register table above */
for (i = cache->num_regs - 1; i >= 0; i--) {
if (cache->reg_list[i].dirty) {
armv7m->arm.write_core_reg(target, &cache->reg_list[i], i,
ARM_MODE_ANY, cache->reg_list[i].value);
}
struct reg *r = &cache->reg_list[i];
if (r->exist && r->dirty)
armv7m->arm.write_core_reg(target, r, i, ARM_MODE_ANY, r->value);
}
return ERROR_OK;

View File

@ -521,7 +521,7 @@ static int cortex_m_debug_entry(struct target *target)
for (i = 0; i < num_regs; i++) {
r = &armv7m->arm.core_cache->reg_list[i];
if (!r->valid)
if (r->exist && !r->valid)
arm->read_core_reg(target, r, i, ARM_MODE_ANY);
}

View File

@ -226,7 +226,7 @@ static int adapter_load_context(struct target *target)
for (int i = 0; i < num_regs; i++) {
struct reg *r = &armv7m->arm.core_cache->reg_list[i];
if (!r->valid)
if (r->exist && !r->valid)
armv7m->arm.read_core_reg(target, r, i, ARM_MODE_ANY);
}