diff options
author | Tim Newsome <tim@sifive.com> | 2018-11-29 12:52:06 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-29 12:52:06 -0800 |
commit | 42be17aed602405a8a36aa06671ea7566ec3f2e4 (patch) | |
tree | 8c29fdf405a24066cae3e3c7583ecb0314116916 /src | |
parent | b911e07d75efbfe175657588a64e4ffa67d29ac3 (diff) | |
download | riscv-openocd-42be17aed602405a8a36aa06671ea7566ec3f2e4.zip riscv-openocd-42be17aed602405a8a36aa06671ea7566ec3f2e4.tar.gz riscv-openocd-42be17aed602405a8a36aa06671ea7566ec3f2e4.tar.bz2 |
Add idle count to debug output. (#337)
Few other minor cleanups/debug improvements.
Change-Id: I370a86ddc17a2d888afa178448125661e12caf72
Diffstat (limited to 'src')
-rw-r--r-- | src/target/riscv/batch.c | 21 | ||||
-rw-r--r-- | src/target/riscv/riscv-013.c | 29 |
2 files changed, 33 insertions, 17 deletions
diff --git a/src/target/riscv/batch.c b/src/target/riscv/batch.c index e6d37e6..d041ed1 100644 --- a/src/target/riscv/batch.c +++ b/src/target/riscv/batch.c @@ -9,23 +9,20 @@ #define get_field(reg, mask) (((reg) & (mask)) / ((mask) & ~((mask) << 1))) #define set_field(reg, mask, val) (((reg) & ~(mask)) | (((val) * ((mask) & ~((mask) << 1))) & (mask))) -static void dump_field(const struct scan_field *field); +static void dump_field(int idle, const struct scan_field *field); struct riscv_batch *riscv_batch_alloc(struct target *target, size_t scans, size_t idle) { scans += 4; - struct riscv_batch *out = malloc(sizeof(*out)); - memset(out, 0, sizeof(*out)); + struct riscv_batch *out = calloc(1, sizeof(*out)); out->target = target; out->allocated_scans = scans; - out->used_scans = 0; out->idle_count = idle; out->data_out = malloc(sizeof(*out->data_out) * (scans) * sizeof(uint64_t)); out->data_in = malloc(sizeof(*out->data_in) * (scans) * sizeof(uint64_t)); out->fields = malloc(sizeof(*out->fields) * (scans)); out->last_scan = RISCV_SCAN_TYPE_INVALID; out->read_keys = malloc(sizeof(*out->read_keys) * (scans)); - out->read_keys_used = 0; return out; } @@ -65,7 +62,7 @@ int riscv_batch_run(struct riscv_batch *batch) } for (size_t i = 0; i < batch->used_scans; ++i) - dump_field(batch->fields + i); + dump_field(batch->idle_count, batch->fields + i); return ERROR_OK; } @@ -96,7 +93,7 @@ size_t riscv_batch_add_dmi_read(struct riscv_batch *batch, unsigned address) batch->used_scans++; /* FIXME We get the read response back on the next scan. For now I'm - * just sticking a NOP in there, but this should be coelesced away. */ + * just sticking a NOP in there, but this should be coalesced away. */ riscv_batch_add_nop(batch); batch->read_keys[batch->read_keys_used] = batch->used_scans - 1; @@ -132,7 +129,7 @@ void riscv_batch_add_nop(struct riscv_batch *batch) batch->used_scans++; } -void dump_field(const struct scan_field *field) +void dump_field(int idle, const struct scan_field *field) { static const char * const op_string[] = {"-", "r", "w", "?"}; static const char * const status_string[] = {"+", "?", "F", "b"}; @@ -154,13 +151,13 @@ void dump_field(const struct scan_field *field) log_printf_lf(LOG_LVL_DEBUG, __FILE__, __LINE__, __PRETTY_FUNCTION__, - "%db %s %08x @%02x -> %s %08x @%02x", - field->num_bits, + "%db %di %s %08x @%02x -> %s %08x @%02x", + field->num_bits, idle, op_string[out_op], out_data, out_address, status_string[in_op], in_data, in_address); } else { log_printf_lf(LOG_LVL_DEBUG, - __FILE__, __LINE__, __PRETTY_FUNCTION__, "%db %s %08x @%02x -> ?", - field->num_bits, op_string[out_op], out_data, out_address); + __FILE__, __LINE__, __PRETTY_FUNCTION__, "%db %di %s %08x @%02x -> ?", + field->num_bits, idle, op_string[out_op], out_data, out_address); } } diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 00714aa..b734104 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -357,7 +357,7 @@ static void decode_dmi(char *text, unsigned address, unsigned data) } } -static void dump_field(const struct scan_field *field) +static void dump_field(int idle, const struct scan_field *field) { static const char * const op_string[] = {"-", "r", "w", "?"}; static const char * const status_string[] = {"+", "?", "F", "b"}; @@ -377,8 +377,8 @@ static void dump_field(const struct scan_field *field) log_printf_lf(LOG_LVL_DEBUG, __FILE__, __LINE__, "scan", - "%db %s %08x @%02x -> %s %08x @%02x", - field->num_bits, + "%db %di %s %08x @%02x -> %s %08x @%02x", + field->num_bits, idle, op_string[out_op], out_data, out_address, status_string[in_op], in_data, in_address); @@ -498,7 +498,7 @@ static dmi_status_t dmi_scan(struct target *target, uint32_t *address_in, if (address_in) *address_in = buf_get_u32(in, DTM_DMI_ADDRESS_OFFSET, info->abits); - dump_field(&field); + dump_field(idle_count, &field); return buf_get_u32(in, DTM_DMI_OP_OFFSET, DTM_DMI_OP_LENGTH); } @@ -697,7 +697,24 @@ static int wait_for_idle(struct target *target, uint32_t *abstractcs) static int execute_abstract_command(struct target *target, uint32_t command) { RISCV013_INFO(info); - LOG_DEBUG("command=0x%x", command); + if (debug_level >= LOG_LVL_DEBUG) { + switch (get_field(command, DMI_COMMAND_CMDTYPE)) { + case 0: + LOG_DEBUG("command=0x%x; access register, size=%d, postexec=%d, " + "transfer=%d, write=%d, regno=0x%x", + command, + 8 << get_field(command, AC_ACCESS_REGISTER_SIZE), + get_field(command, AC_ACCESS_REGISTER_POSTEXEC), + get_field(command, AC_ACCESS_REGISTER_TRANSFER), + get_field(command, AC_ACCESS_REGISTER_WRITE), + get_field(command, AC_ACCESS_REGISTER_REGNO)); + break; + default: + LOG_DEBUG("command=0x%x", command); + break; + } + } + dmi_write(target, DMI_COMMAND, command); uint32_t abstractcs = 0; @@ -2326,6 +2343,8 @@ static int read_memory_progbuf(struct target *target, target_addr_t address, uint8_t *buffer_i = buffer; for (uint32_t i = 0; i < count; i++, address_i += size_i, buffer_i += size_i) { + /* TODO: This is much slower than it needs to be because we end up + * writing the address to read for every word we read. */ result = read_memory_progbuf_inner(target, address_i, size_i, count_i, buffer_i); /* The read of a single word failed, so we will just return 0 for that instead */ |