summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--src/main.c80
-rw-r--r--src/main.h4
-rw-r--r--src/thread.c103
-rw-r--r--src/thread.h28
5 files changed, 136 insertions, 81 deletions
diff --git a/Makefile.am b/Makefile.am
index b01ff0f..3c24e0c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,7 +11,7 @@ ACLOCAL_AMFLAGS = -Im4
AM_CFLAGS = -I$(top_srcdir)/ccan/array_size -Wall -Werror
pdbg_SOURCES = \
- src/main.c src/cfam.c src/scom.c src/reg.c src/mem.c
+ src/main.c src/cfam.c src/scom.c src/reg.c src/mem.c src/thread.c
pdbg_LDADD = fake.dtb.o p8-fsi.dtb.o p8-i2c.dtb.o p9w-fsi.dtb.o p8-host.dtb.o \
p9z-fsi.dtb.o p9r-fsi.dtb.o p9-kernel.dtb.o libpdbg.la libfdt.la \
p9-host.dtb.o \
diff --git a/src/main.c b/src/main.c
index 3d6a5e7..20af95d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -35,6 +35,7 @@
#include "scom.h"
#include "reg.h"
#include "mem.h"
+#include "thread.h"
#undef PR_DEBUG
#define PR_DEBUG(...)
@@ -388,7 +389,7 @@ static bool parse_command(int argc, char *argv[])
}
/* Returns the sum of return codes. This can be used to count how many targets the callback was run on. */
-static int for_each_child_target(char *class, struct pdbg_target *parent,
+int for_each_child_target(char *class, struct pdbg_target *parent,
int (*cb)(struct pdbg_target *, uint32_t, uint64_t *, uint64_t *),
uint64_t *arg1, uint64_t *arg2)
{
@@ -431,83 +432,6 @@ static int for_each_target(char *class, int (*cb)(struct pdbg_target *, uint32_t
return rc;
}
-static int print_thread_status(struct pdbg_target *target, uint32_t index, uint64_t *status, uint64_t *unused1)
-{
- *status = SETFIELD(0xf << (index * 4), *status, thread_status(target) & 0xf);
- return 1;
-}
-
-static int print_core_thread_status(struct pdbg_target *core_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
-{
- uint64_t status = -1UL;
- int i, rc;
-
- printf("c%02d:", index);
- rc = for_each_child_target("thread", core_target, print_thread_status, &status, NULL);
- for (i = 0; i < 8; i++)
- switch ((status >> (i * 4)) & 0xf) {
- case THREAD_STATUS_ACTIVE:
- printf(" A");
- break;
-
- case THREAD_STATUS_DOZE:
- case THREAD_STATUS_QUIESCE | THREAD_STATUS_DOZE:
- printf(" D");
- break;
-
- case THREAD_STATUS_NAP:
- case THREAD_STATUS_QUIESCE | THREAD_STATUS_NAP:
- printf(" N");
- break;
-
- case THREAD_STATUS_SLEEP:
- case THREAD_STATUS_QUIESCE | THREAD_STATUS_SLEEP:
- printf(" S");
- break;
-
- case THREAD_STATUS_ACTIVE | THREAD_STATUS_QUIESCE:
- printf(" Q");
- break;
-
- case 0xf:
- printf(" ");
- break;
-
- default:
- printf(" U");
- break;
- }
- printf("\n");
-
- return rc;
-}
-
-static int print_proc_thread_status(struct pdbg_target *pib_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
-{
- printf("\np%01dt: 0 1 2 3 4 5 6 7\n", index);
- return for_each_child_target("core", pib_target, print_core_thread_status, NULL, NULL);
-};
-
-static int start_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
-{
- return ram_start_thread(thread_target) ? 0 : 1;
-}
-
-static int step_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *count, uint64_t *unused1)
-{
- return ram_step_thread(thread_target, *count) ? 0 : 1;
-}
-
-static int stop_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
-{
- return ram_stop_thread(thread_target) ? 0 : 1;
-}
-
-static int sreset_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
-{
- return ram_sreset_thread(thread_target) ? 0 : 1;
-}
-
static char *get_htm_dump_filename(void)
{
char *filename;
diff --git a/src/main.h b/src/main.h
index bfa8c37..ef22ba8 100644
--- a/src/main.h
+++ b/src/main.h
@@ -18,6 +18,6 @@
#include <target.h>
/* Returns the sum of return codes. This can be used to count how many targets the callback was run on. */
-int for_each_child_target(char *class, struct target *parent,
- int (*cb)(struct target *, uint32_t, uint64_t *, uint64_t *),
+int for_each_child_target(char *class, struct pdbg_target *parent,
+ int (*cb)(struct pdbg_target *, uint32_t, uint64_t *, uint64_t *),
uint64_t *arg1, uint64_t *arg2);
diff --git a/src/thread.c b/src/thread.c
new file mode 100644
index 0000000..c01049f
--- /dev/null
+++ b/src/thread.c
@@ -0,0 +1,103 @@
+/* Copyright 2017 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <inttypes.h>
+#include <stdio.h>
+
+#include <bitutils.h>
+
+#include <target.h>
+#include <operations.h>
+
+#include "main.h"
+
+static int print_thread_status(struct pdbg_target *target, uint32_t index, uint64_t *status, uint64_t *unused1)
+{
+ *status = SETFIELD(0xf << (index * 4), *status, thread_status(target) & 0xf);
+ return 1;
+}
+
+static int print_core_thread_status(struct pdbg_target *core_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
+{
+ uint64_t status = -1UL;
+ int i, rc;
+
+ printf("c%02d:", index);
+ rc = for_each_child_target("thread", core_target, print_thread_status, &status, NULL);
+ for (i = 0; i < 8; i++)
+ switch ((status >> (i * 4)) & 0xf) {
+ case THREAD_STATUS_ACTIVE:
+ printf(" A");
+ break;
+
+ case THREAD_STATUS_DOZE:
+ case THREAD_STATUS_QUIESCE | THREAD_STATUS_DOZE:
+ printf(" D");
+ break;
+
+ case THREAD_STATUS_NAP:
+ case THREAD_STATUS_QUIESCE | THREAD_STATUS_NAP:
+ printf(" N");
+ break;
+
+ case THREAD_STATUS_SLEEP:
+ case THREAD_STATUS_QUIESCE | THREAD_STATUS_SLEEP:
+ printf(" S");
+ break;
+
+ case THREAD_STATUS_ACTIVE | THREAD_STATUS_QUIESCE:
+ printf(" Q");
+ break;
+
+ case 0xf:
+ printf(" ");
+ break;
+
+ default:
+ printf(" U");
+ break;
+ }
+ printf("\n");
+
+ return rc;
+}
+
+int print_proc_thread_status(struct pdbg_target *pib_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
+{
+ printf("\np%01dt: 0 1 2 3 4 5 6 7\n", index);
+ return for_each_child_target("core", pib_target, print_core_thread_status, NULL, NULL);
+};
+
+int start_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
+{
+ return ram_start_thread(thread_target) ? 0 : 1;
+}
+
+int step_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *count, uint64_t *unused1)
+{
+ return ram_step_thread(thread_target, *count) ? 0 : 1;
+}
+
+int stop_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
+{
+ return ram_stop_thread(thread_target) ? 0 : 1;
+}
+
+int sreset_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1)
+{
+ return ram_sreset_thread(thread_target) ? 0 : 1;
+}
+
+
diff --git a/src/thread.h b/src/thread.h
new file mode 100644
index 0000000..8a9c901
--- /dev/null
+++ b/src/thread.h
@@ -0,0 +1,28 @@
+/* Copyright 2017 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <inttypes.h>
+
+#include <target.h>
+
+int print_proc_thread_status(struct pdbg_target *pib_target, uint32_t index, uint64_t *unused, uint64_t *unused1);
+
+int start_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1);
+
+int step_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *count, uint64_t *unused1);
+
+int stop_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1);
+
+int sreset_thread(struct pdbg_target *thread_target, uint32_t index, uint64_t *unused, uint64_t *unused1);
OpenPOWER on IntegriCloud