]> git.gag.com Git - fw/openocd/blobdiff - src/target/cortex_m.c
target/cortex_m: minor refactoring in cortex_m_store_core_reg_u32()
[fw/openocd] / src / target / cortex_m.c
index 721cf0a2469b9acdaccdda10471c3154fccdb2bc..7125e9e8309f41873a81dbe8b2a05fecbfa6a56e 100644 (file)
@@ -397,11 +397,9 @@ static int cortex_m_store_core_reg_u32(struct target *target,
        /* check if value is written into register */
        then = timeval_ms();
        while (1) {
-               retval = mem_ap_read_atomic_u32(armv7m->debug_ap, DCB_DHCSR,
-                                                                               &cortex_m->dcb_dhcsr);
+               retval = cortex_m_read_dhcsr_atomic_sticky(target);
                if (retval != ERROR_OK)
                        return retval;
-               cortex_m_cumulate_dhcsr_sticky(cortex_m, cortex_m->dcb_dhcsr);
                if (cortex_m->dcb_dhcsr & S_REGRDY)
                        break;
                if (timeval_ms() > then + DHCSR_S_REGRDY_TIMEOUT) {
@@ -2292,7 +2290,6 @@ int cortex_m_examine(struct target *target)
                        armv7m->debug_ap = dap_ap(swjdp, cortex_m->apsel);
                }
 
-               /* Leave (only) generic DAP stuff for debugport_init(); */
                armv7m->debug_ap->memaccess_tck = 8;
 
                retval = mem_ap_init(armv7m->debug_ap);
@@ -2589,7 +2586,7 @@ static int cortex_m_target_create(struct target *target, Jim_Interp *interp)
 static int cortex_m_verify_pointer(struct command_invocation *cmd,
        struct cortex_m_common *cm)
 {
-       if (cm->common_magic != CORTEX_M_COMMON_MAGIC) {
+       if (!is_cortex_m_with_dap_access(cm)) {
                command_print(cmd, "target is not a Cortex-M");
                return ERROR_TARGET_INVALID;
        }