[Pdbg] [PATCH 1/4] libpdbg: Add thread start/step/stop all api
Amitay Isaacs
amitay at ozlabs.org
Fri Aug 9 13:20:21 AEST 2019
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
libpdbg/chip.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++
libpdbg/libpdbg.h | 3 ++
2 files changed, 102 insertions(+)
diff --git a/libpdbg/chip.c b/libpdbg/chip.c
index a36a038..830c3ec 100644
--- a/libpdbg/chip.c
+++ b/libpdbg/chip.c
@@ -154,6 +154,105 @@ int thread_sreset(struct pdbg_target *thread_target)
return thread->sreset(thread);
}
+int thread_step_all(void)
+{
+ struct pdbg_target *pib, *thread;
+ int rc = 0, count = 0;
+
+ pdbg_for_each_class_target("pib", pib) {
+ struct sbefifo *sbefifo;
+
+ sbefifo = pib_to_sbefifo(pib);
+ if (!sbefifo)
+ break;
+
+ /*
+ * core_id = 0xff (all SMT4 cores)
+ * thread_id = 0xf (all 4 threads in the SMT4 core)
+ */
+ rc |= sbefifo->thread_step(sbefifo, 0xff, 0xf);
+ count++;
+ }
+
+ if (count > 0)
+ return rc;
+
+ pdbg_for_each_class_target("thread", thread) {
+ if (pdbg_target_status(thread) != PDBG_TARGET_ENABLED)
+ continue;
+
+ rc |= thread_step(thread, 1);
+ }
+
+ return rc;
+}
+
+int thread_start_all(void)
+{
+ struct pdbg_target *pib, *thread;
+ int rc = 0, count = 0;
+
+ pdbg_for_each_class_target("pib", pib) {
+ struct sbefifo *sbefifo;
+
+ sbefifo = pib_to_sbefifo(pib);
+ if (!sbefifo)
+ break;
+
+ /*
+ * core_id = 0xff (all SMT4 cores)
+ * thread_id = 0xf (all 4 threads in the SMT4 core)
+ */
+ rc |= sbefifo->thread_start(sbefifo, 0xff, 0xf);
+ count++;
+ }
+
+ if (count > 0)
+ return rc;
+
+ pdbg_for_each_class_target("thread", thread) {
+ if (pdbg_target_status(thread) != PDBG_TARGET_ENABLED)
+ continue;
+
+ rc |= thread_start(thread);
+ }
+
+ return rc;
+}
+
+int thread_stop_all(void)
+{
+ struct pdbg_target *pib, *thread;
+ int rc = 0, count = 0;
+
+ pdbg_for_each_class_target("pib", pib) {
+ struct sbefifo *sbefifo;
+
+ sbefifo = pib_to_sbefifo(pib);
+ if (!sbefifo)
+ break;
+
+ /*
+ * core_id = 0xff (all SMT4 cores)
+ * thread_id = 0xf (all 4 threads in the SMT4 core)
+ */
+ rc |= sbefifo->thread_stop(sbefifo, 0xff, 0xf);
+ count++;
+ }
+
+ if (count > 0)
+ return rc;
+
+ pdbg_for_each_class_target("thread", thread) {
+ if (pdbg_target_status(thread) != PDBG_TARGET_ENABLED)
+ continue;
+
+ rc |= thread_stop(thread);
+ }
+
+ return rc;
+}
+
int thread_sreset_all(void)
{
struct pdbg_target *pib, *thread;
diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
index 25bfd97..da81d30 100644
--- a/libpdbg/libpdbg.h
+++ b/libpdbg/libpdbg.h
@@ -204,6 +204,9 @@ int thread_start(struct pdbg_target *target);
int thread_step(struct pdbg_target *target, int steps);
int thread_stop(struct pdbg_target *target);
int thread_sreset(struct pdbg_target *target);
+int thread_start_all(void);
+int thread_step_all(void);
+int thread_stop_all(void);
int thread_sreset_all(void);
struct thread_state thread_status(struct pdbg_target *target);
--
2.21.0
More information about the Pdbg
mailing list