This is an automated email from Gerrit.

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

-- gerrit

commit 78d40503064bc3d8e72867ba65ba9ae80fcf1ca4
Author: Stafford Horne <[email protected]>
Date:   Tue Apr 4 06:53:48 2017 +0900

    openrisc: implement basic "smp" commands
    
    Allow reset, halt and resme to work on all processesors if smp
    is enabled.
    
    Change-Id: Iba10755ceaff178fc8ffaaa7be67fdef4d850fce
    Signed-off-by: Stafford Horne <[email protected]>

diff --git a/src/target/openrisc/or1k.c b/src/target/openrisc/or1k.c
index 70eaca8..a0ac626 100644
--- a/src/target/openrisc/or1k.c
+++ b/src/target/openrisc/or1k.c
@@ -38,6 +38,9 @@
 #include "or1k.h"
 #include "or1k_du.h"
 
+#define foreach_smp_target(pos, head) \
+       for (pos = head; (pos != NULL); pos = pos->next)
+
 LIST_HEAD(tap_list);
 LIST_HEAD(du_list);
 
@@ -582,13 +585,13 @@ static int or1k_debug_entry(struct target *target)
        return retval;
 }
 
-static int or1k_halt(struct target *target)
+static int or1k_halt_one(struct target *target)
 {
        struct or1k_common *or1k = target_to_or1k(target);
        struct or1k_du *du_core = or1k_to_du(or1k);
 
-       LOG_DEBUG("target->state: %s",
-                 target_state_name(target));
+       LOG_DEBUG("target->state: %s, target->coreid: %d",
+                 target_state_name(target), target->coreid);
 
        if (target->state == TARGET_HALTED) {
                LOG_DEBUG("Target was already halted");
@@ -620,6 +623,24 @@ static int or1k_halt(struct target *target)
        return ERROR_OK;
 }
 
+static int or1k_halt(struct target *target)
+{
+       struct target *curr;
+       struct target_list *head;
+       int retval = 0;
+
+       foreach_smp_target(head, target->head) {
+               curr = head->target;
+               if (curr == target)
+                       continue;
+
+               retval += or1k_halt_one(curr);
+       }
+       retval += or1k_halt_one(target);
+
+       return retval;
+}
+
 static int or1k_is_cpu_running(struct target *target, int *running)
 {
        struct or1k_common *or1k = target_to_or1k(target);
@@ -726,7 +747,7 @@ static int or1k_poll(struct target *target)
        return ERROR_OK;
 }
 
-static int or1k_assert_reset(struct target *target)
+static int or1k_assert_reset_one(struct target *target)
 {
        struct or1k_common *or1k = target_to_or1k(target);
        struct or1k_du *du_core = or1k_to_du(or1k);
@@ -742,7 +763,25 @@ static int or1k_assert_reset(struct target *target)
        return ERROR_OK;
 }
 
-static int or1k_deassert_reset(struct target *target)
+static int or1k_assert_reset(struct target *target)
+{
+       struct target_list *head;
+       struct target *curr;
+       int retval = 0;
+
+       foreach_smp_target(head, target->head) {
+               curr = head->target;
+               if (curr == target)
+                       continue;
+
+               retval += or1k_assert_reset_one(curr);
+       }
+       retval += or1k_assert_reset_one(target);
+
+       return retval;
+}
+
+static int or1k_deassert_reset_one(struct target *target)
 {
        struct or1k_common *or1k = target_to_or1k(target);
        struct or1k_du *du_core = or1k_to_du(or1k);
@@ -758,6 +797,24 @@ static int or1k_deassert_reset(struct target *target)
        return ERROR_OK;
 }
 
+static int or1k_deassert_reset(struct target *target)
+{
+       struct target_list *head;
+       struct target *curr;
+       int retval = 0;
+
+       foreach_smp_target(head, target->head) {
+               curr = head->target;
+               if (curr == target)
+                       continue;
+
+               retval += or1k_deassert_reset_one(curr);
+       }
+       retval += or1k_deassert_reset_one(target);
+
+       return retval;
+}
+
 static int or1k_soft_reset_halt(struct target *target)
 {
        struct or1k_common *or1k = target_to_or1k(target);
@@ -905,7 +962,7 @@ static int or1k_resume_or_step(struct target *target, int 
current,
        return ERROR_OK;
 }
 
-static int or1k_resume(struct target *target, int current,
+static int or1k_resume_one(struct target *target, int current,
                       target_addr_t address, int handle_breakpoints,
                       int debug_execution)
 {
@@ -915,6 +972,28 @@ static int or1k_resume(struct target *target, int current,
                                   NO_SINGLE_STEP);
 }
 
+static int or1k_resume(struct target *target, int current,
+                      target_addr_t address, int handle_breakpoints,
+                      int debug_execution)
+{
+       struct target_list *head;
+       struct target *curr;
+       int retval = 0;
+
+       foreach_smp_target(head, target->head) {
+               curr = head->target;
+               if (curr == target)
+                       continue;
+
+               retval += or1k_resume_one(curr, current, address,
+                               handle_breakpoints, debug_execution);
+       }
+       retval += or1k_resume_one(target, current, address, handle_breakpoints,
+                               debug_execution);
+
+       return retval;
+}
+
 static int or1k_step(struct target *target, int current,
                     target_addr_t address, int handle_breakpoints)
 {

-- 

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