This is an automated email from Gerrit.

Tomas Vanek ([email protected]) just uploaded a new patch set to Gerrit, which you 
can find at http://openocd.zylin.com/4870

-- gerrit

commit 839128f4d1a164ea483e45c41b9077ede68d2d2d
Author: Tomas Vanek <[email protected]>
Date:   Thu Jan 24 13:36:39 2019 +0100

    target/cortex_m: remove fp_code_available counting and target halted check
    
    fp_code_available loose sync with the real number of free comparators
    as soon as cortex_m_set_breakpoint() return an error. Remove the counter
    and always go through the fp_comparator_list to find a free one.
    
    Remove the target halted check from cortex_m_remove_breakpoint()
    as there is no such check in cortex_m_set_breakpoint() and bp can be safely
    removed from the running target. Call poll to resolve possible race 
condition
    if bp is hit just before unsetting.
    
    Change-Id: I9f6e06c36d8a57ad11df5155e8a1a3aff6d833a5
    Signed-off-by: Tomas Vanek <[email protected]>

diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c
index 434d43f..51d9b97 100644
--- a/src/target/cortex_m.c
+++ b/src/target/cortex_m.c
@@ -1128,7 +1128,7 @@ int cortex_m_set_breakpoint(struct target *target, struct 
breakpoint *breakpoint
                        fp_num++;
                if (fp_num >= cortex_m->fp_num_code) {
                        LOG_ERROR("Can not find free FPB Comparator!");
-                       return ERROR_FAIL;
+                       return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
                }
                breakpoint->set = fp_num + 1;
                fpcr_value = breakpoint->address | 1;
@@ -1243,13 +1243,6 @@ int cortex_m_unset_breakpoint(struct target *target, 
struct breakpoint *breakpoi
 
 int cortex_m_add_breakpoint(struct target *target, struct breakpoint 
*breakpoint)
 {
-       struct cortex_m_common *cortex_m = target_to_cm(target);
-
-       if ((breakpoint->type == BKPT_HARD) && (cortex_m->fp_code_available < 
1)) {
-               LOG_INFO("no flash patch comparator unit available for hardware 
breakpoint");
-               return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
-       }
-
        if (breakpoint->length == 3) {
                LOG_DEBUG("Using a two byte breakpoint for 32bit Thumb-2 
request");
                breakpoint->length = 2;
@@ -1260,27 +1253,23 @@ int cortex_m_add_breakpoint(struct target *target, 
struct breakpoint *breakpoint
                return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
        }
 
-       if (breakpoint->type == BKPT_HARD)
-               cortex_m->fp_code_available--;
-
        return cortex_m_set_breakpoint(target, breakpoint);
 }
 
 int cortex_m_remove_breakpoint(struct target *target, struct breakpoint 
*breakpoint)
 {
-       struct cortex_m_common *cortex_m = target_to_cm(target);
-
-       /* REVISIT why check? FPB can be updated with core running ... */
-       if (target->state != TARGET_HALTED) {
-               LOG_WARNING("target not halted");
-               return ERROR_TARGET_NOT_HALTED;
-       }
+       if (breakpoint->set) {
+               int res = cortex_m_unset_breakpoint(target, breakpoint);
 
-       if (breakpoint->set)
-               cortex_m_unset_breakpoint(target, breakpoint);
+               /* Call poll now.
+                * If we hit the bp just before we unset it, give poll the 
chance
+                * to find bp in the list.
+                * Ignore error from poll as it is not important in bp removing
+                */
+               (void)cortex_m_poll(target);
 
-       if (breakpoint->type == BKPT_HARD)
-               cortex_m->fp_code_available++;
+               return res;
+       }
 
        return ERROR_OK;
 }
@@ -2091,7 +2080,6 @@ int cortex_m_examine(struct target *target)
                /* bits [14:12] and [7:4] */
                cortex_m->fp_num_code = ((fpcr >> 8) & 0x70) | ((fpcr >> 4) & 
0xF);
                cortex_m->fp_num_lit = (fpcr >> 8) & 0xF;
-               cortex_m->fp_code_available = cortex_m->fp_num_code;
                /* Detect flash patch revision, see RM DDI 0403E.b page C1-817.
                   Revision is zero base, fp_rev == 1 means Rev.2 ! */
                cortex_m->fp_rev = (fpcr >> 28) & 0xf;
diff --git a/src/target/cortex_m.h b/src/target/cortex_m.h
index 22d9735..1a8dce7 100644
--- a/src/target/cortex_m.h
+++ b/src/target/cortex_m.h
@@ -172,7 +172,6 @@ struct cortex_m_common {
        /* Flash Patch and Breakpoint (FPB) */
        int fp_num_lit;
        int fp_num_code;
-       int fp_code_available;
        int fp_rev;
        int fpb_enabled;
        struct cortex_m_fp_comparator *fp_comparator_list;

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to