target/riscv: revive 'riscv resume_order'
authorTim Newsome <tim@sifive.com>
Thu, 16 Dec 2021 11:54:35 +0000 (12:54 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Mon, 14 Feb 2022 15:10:56 +0000 (15:10 +0000)
This functionality was lost in [1], which was merged as commit
615709d14049 ("Upstream a whole host of RISC-V changes.").
Now it works as expected again.

Add convenience macro foreach_smp_target_direction().

Link: [1] https://github.com/riscv/riscv-openocd/pull/567
Change-Id: I1545fa6b45b8a07e27c8ff9dcdcfa2fc4f950cd1
Signed-off-by: Tim Newsome <tim@sifive.com>
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6785
Tested-by: jenkins
src/target/riscv/riscv.c
src/target/smp.h

index 931f7629092690c5ccf249c1379d3b7508426ce4..367506dde8675496868c9cf3472813af2362782b 100644 (file)
@@ -1472,14 +1472,16 @@ int riscv_resume(
        int result = ERROR_OK;
        if (target->smp && !single_hart) {
                struct target_list *tlist;
-               foreach_smp_target(tlist, target->smp_targets) {
+               foreach_smp_target_direction(resume_order == RO_NORMAL,
+                                                                        tlist, target->smp_targets) {
                        struct target *t = tlist->target;
                        if (resume_prep(t, current, address, handle_breakpoints,
                                                debug_execution) != ERROR_OK)
                                result = ERROR_FAIL;
                }
 
-               foreach_smp_target(tlist, target->smp_targets) {
+               foreach_smp_target_direction(resume_order == RO_NORMAL,
+                                                                        tlist, target->smp_targets) {
                        struct target *t = tlist->target;
                        riscv_info_t *i = riscv_info(t);
                        if (i->prepped) {
@@ -1489,7 +1491,8 @@ int riscv_resume(
                        }
                }
 
-               foreach_smp_target(tlist, target->smp_targets) {
+               foreach_smp_target_direction(resume_order == RO_NORMAL,
+                                                                        tlist, target->smp_targets) {
                        struct target *t = tlist->target;
                        if (resume_finish(t) != ERROR_OK)
                                return ERROR_FAIL;
index 46fc55f750870c061cef602bdd1ed7fa76531f5d..490a4931051af1306e99a86626e05640c2e0c641 100644 (file)
@@ -25,6 +25,9 @@
 #define foreach_smp_target(pos, head) \
        list_for_each_entry(pos, head, lh)
 
+#define foreach_smp_target_direction(forward, pos, head) \
+       list_for_each_entry_direction(forward, pos, head, lh)
+
 extern const struct command_registration smp_command_handlers[];
 
 int gdb_read_smp_packet(struct connection *connection,