@@ -143,6 +143,7 @@ struct thread {
struct thread_state status;
void *gdbserver_priv;
int id;
+ int fc_id;
struct thread_state (*state)(struct thread *);
int (*step)(struct thread *, int);
int (*start)(struct thread *);
@@ -90,13 +90,32 @@ struct thread_state p10_thread_state(struct thread *thread)
return thread_state;
}
+static uint8_t p10_core_id(struct pdbg_target *core)
+{
+ return pdbg_target_index(core) & 0xff;
+}
+
static int p10_thread_probe(struct pdbg_target *target)
{
+ struct core *core = target_to_core(pdbg_target_require_parent("core", target));
struct thread *thread = target_to_thread(target);
thread->id = pdbg_target_index(target);
thread->status = thread->state(thread);
+ if (core->status.fused_core_mode) {
+ struct pdbg_target *parent;
+ uint8_t core_id;
+
+ /* P10 uses core id as core-id */
+ parent = pdbg_target_require_parent("core", target);
+ core_id = p10_core_id(parent);
+
+ thread->fc_id = thread->id * 2 + (core_id % 2);
+ } else {
+ thread->fc_id = thread->id;
+ }
+
return 0;
}
@@ -611,6 +611,7 @@ static int p8_thread_probe(struct pdbg_target *target)
struct thread *thread = target_to_thread(target);
thread->id = (pdbg_target_address(target, NULL) >> 4) & 0xf;
+ thread->fc_id = thread->id;
thread->status = thread->state(thread);
return 0;
@@ -111,13 +111,31 @@ struct thread_state p9_thread_state(struct thread *thread)
return thread_state;
}
+static uint8_t p9_core_id(struct pdbg_target *core)
+{
+ return pdbg_target_index(core) & 0xff;
+}
+
static int p9_thread_probe(struct pdbg_target *target)
{
+ struct core *core = target_to_core(pdbg_target_require_parent("core", target));
struct thread *thread = target_to_thread(target);
thread->id = pdbg_target_index(target);
thread->status = thread->state(thread);
+ if (core->status.fused_core_mode) {
+ struct pdbg_target *parent;
+ uint8_t core_id;
+
+ parent = pdbg_target_require_parent("core", target);
+ core_id = p9_core_id(parent);
+
+ thread->fc_id = thread->id * 2 + (core_id % 2);
+ } else {
+ thread->fc_id = thread->id;
+ }
+
return 0;
}
@@ -375,11 +375,21 @@ static uint8_t sbefifo_core_id(struct sbefifo_context *sctx, struct thread *thre
static int sbefifo_thread_probe(struct pdbg_target *target)
{
+ struct pdbg_target *parent = pdbg_target_require_parent("core", target);
+ struct core *core = target_to_core(parent);
struct thread *thread = target_to_thread(target);
thread->id = pdbg_target_index(target);
thread->status = thread->state(thread);
+ if (core->status.fused_core_mode) {
+ uint8_t core_id = pdbg_target_index(parent) & 0xff;
+
+ thread->fc_id = thread->id * 2 + (core_id % 2);
+ } else {
+ thread->fc_id = thread->id;
+ }
+
return 0;
}
libpdbg thread id is in small-core units because pervasive tends to be addressed by small core. However some PC registers contain fused-core thread ID fields, which need fused core indexing. Add thread->fc_id. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> --- libpdbg/hwunit.h | 1 + libpdbg/p10chip.c | 19 +++++++++++++++++++ libpdbg/p8chip.c | 1 + libpdbg/p9chip.c | 18 ++++++++++++++++++ libpdbg/sbefifo.c | 10 ++++++++++ 5 files changed, 49 insertions(+)