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/4289

-- gerrit

commit 31af3d1a9b0037228f22300ccd467315cd4de05c
Author: Tomas Vanek <[email protected]>
Date:   Sat Nov 4 09:47:02 2017 +0100

    target: add examine-fail event
    
    A configuration script may want to check the reason why examine fails
    e.g. device has security lock engaged.
    
    Change-Id: Id1d3a79d24e84b513f4ea35586cd2ab0437ff9b3
    Signed-off-by: Tomas Vanek <[email protected]>

diff --git a/src/target/startup.tcl b/src/target/startup.tcl
index 375c329..3c5b797 100644
--- a/src/target/startup.tcl
+++ b/src/target/startup.tcl
@@ -41,7 +41,9 @@ proc arp_examine_one { target } {
        if [arp_is_tap_enabled $target] {
                $target invoke-event examine-start
                set err [catch "$target arp_examine allow-defer"]
-               if {!$err} {
+               if { $err } {
+                       $target invoke-event examine-fail
+               } else {
                        $target invoke-event examine-end
                }
        }
diff --git a/src/target/target.c b/src/target/target.c
index 30ef3b4..046cdd4 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -212,6 +212,7 @@ static const Jim_Nvp nvp_target_event[] = {
        { .value = TARGET_EVENT_RESET_END,           .name = "reset-end" },
 
        { .value = TARGET_EVENT_EXAMINE_START, .name = "examine-start" },
+       { .value = TARGET_EVENT_EXAMINE_FAIL, .name = "examine-fail" },
        { .value = TARGET_EVENT_EXAMINE_END, .name = "examine-end" },
 
        { .value = TARGET_EVENT_DEBUG_HALTED, .name = "debug-halted" },
@@ -708,13 +709,17 @@ static int default_check_reset(struct target *target)
        return ERROR_OK;
 }
 
+/* Equvivalent Tcl code arp_examine_one is in src/target/startup.tcl
+ * Keep in sync */
 int target_examine_one(struct target *target)
 {
        target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_START);
 
        int retval = target->type->examine(target);
-       if (retval != ERROR_OK)
+       if (retval != ERROR_OK) {
+               target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_FAIL);
                return retval;
+       }
 
        target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_END);
 
diff --git a/src/target/target.h b/src/target/target.h
index 16fa867..1d12d24 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -275,6 +275,7 @@ enum target_event {
        TARGET_EVENT_DEBUG_RESUMED, /* target resumed to execute on behalf of 
the debugger */
 
        TARGET_EVENT_EXAMINE_START,
+       TARGET_EVENT_EXAMINE_FAIL,
        TARGET_EVENT_EXAMINE_END,
 
        TARGET_EVENT_GDB_ATTACH,

-- 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to