diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 80 |
1 files changed, 2 insertions, 78 deletions
@@ -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; |