aboutsummaryrefslogtreecommitdiff
path: root/src/rtos/rtos.c
diff options
context:
space:
mode:
authorMatthias Welwarsky <matthias.welwarsky@sysgo.com>2017-02-17 14:45:00 +0100
committerMatthias Welwarsky <matthias@welwarsky.de>2018-02-21 12:10:02 +0000
commit293fb9b25faf8c89a9d06d73b83526b86d4c14d8 (patch)
treeb1a30e24dbf56dae66f1c8a1ec3337cc8c6fd256 /src/rtos/rtos.c
parentd301d8b42f0bfe67d76d6f340db6570cc71c876e (diff)
downloadriscv-openocd-293fb9b25faf8c89a9d06d73b83526b86d4c14d8.zip
riscv-openocd-293fb9b25faf8c89a9d06d73b83526b86d4c14d8.tar.gz
riscv-openocd-293fb9b25faf8c89a9d06d73b83526b86d4c14d8.tar.bz2
rtos: facilitate RTOS SMP handling
The RTOS handlers present OS threads to gdb but the openocd target layer only knows about CPU cores (hardware threads). This patch allows closing this gap inside the RTOS handler. The default implementation just returns the current core, but a RTOS handler can provide its own function that associates a an OS thread with a core. Change-Id: I12cafe50b38a38b28057bc5d3a708aa20bf60515 Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com> Reviewed-on: http://openocd.zylin.com/3997 Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de> Tested-by: jenkins
Diffstat (limited to 'src/rtos/rtos.c')
-rw-r--r--src/rtos/rtos.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c
index 84ee498..4552a87 100644
--- a/src/rtos/rtos.c
+++ b/src/rtos/rtos.c
@@ -57,6 +57,15 @@ int rtos_smp_init(struct target *target)
return ERROR_TARGET_INIT_FAILED;
}
+static int rtos_target_for_threadid(struct connection *connection, int64_t threadid, struct target **t)
+{
+ struct target *curr = get_target_from_connection(connection);
+ if (t)
+ *t = curr;
+
+ return ERROR_OK;
+}
+
static int os_alloc(struct target *target, struct rtos_type *ostype)
{
struct rtos *os = target->rtos = calloc(1, sizeof(struct rtos));
@@ -72,6 +81,7 @@ static int os_alloc(struct target *target, struct rtos_type *ostype)
/* RTOS drivers can override the packet handler in _create(). */
os->gdb_thread_packet = rtos_thread_packet;
+ os->gdb_target_for_threadid = rtos_target_for_threadid;
return JIM_OK;
}