[PATCH umr] add bits option for ring decoder to bitfield decode register writes
Tom St Denis
tom.stdenis at amd.com
Thu Nov 23 18:44:59 UTC 2017
Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
---
src/lib/find_reg.c | 14 ++++++++++++++
src/lib/ring_decode.c | 39 ++++++++++++++++++++++++++++++---------
src/umr.h | 1 +
3 files changed, 45 insertions(+), 9 deletions(-)
diff --git a/src/lib/find_reg.c b/src/lib/find_reg.c
index ecd7f132c9c9..c8f86c48a4bf 100644
--- a/src/lib/find_reg.c
+++ b/src/lib/find_reg.c
@@ -54,3 +54,17 @@ struct umr_reg *umr_find_reg_data(struct umr_asic *asic, char *regname)
{
return umr_find_reg_data_by_ip(asic, NULL, regname);
}
+
+struct umr_reg *umr_find_reg_by_addr(struct umr_asic *asic, uint64_t addr, struct umr_ip_block **ip)
+{
+ int i, j;
+
+ for (i = 0; i < asic->no_blocks; i++)
+ for (j = 0; j < asic->blocks[i]->no_regs; j++)
+ if (asic->blocks[i]->regs[j].type == REG_MMIO && asic->blocks[i]->regs[j].addr == addr) {
+ if (*ip)
+ *ip = asic->blocks[i];
+ return &asic->blocks[i]->regs[j];
+ }
+ return NULL;
+}
diff --git a/src/lib/ring_decode.c b/src/lib/ring_decode.c
index 52855ab4fb62..6654602184f3 100644
--- a/src/lib/ring_decode.c
+++ b/src/lib/ring_decode.c
@@ -363,18 +363,34 @@ static void add_ib(struct umr_ring_decoder *decoder)
static char *umr_reg_name(struct umr_asic *asic, uint64_t addr)
{
int i, j;
- static char regname[512];
+ struct umr_reg *reg;
+ struct umr_ip_block *ip;
+ static char name[512];
+
+ reg = umr_find_reg_by_addr(asic, addr, &ip);
+ if (reg) {
+ sprintf(name, "%s.%s", ip->ipname, reg->regname);
+ return name;
+ } else {
+ return "<unknown>";
+ }
+}
- strcpy(regname, "<unknown>");
+static void print_bits(struct umr_asic *asic, uint32_t regno, uint32_t value)
+{
+ struct umr_ip_block *ip;
+ struct umr_reg *reg = umr_find_reg_by_addr(asic, regno, &ip);
- for (i = 0; i < asic->no_blocks; i++)
- for (j = 0; j < asic->blocks[i]->no_regs; j++)
- if (asic->blocks[i]->regs[j].type == REG_MMIO && asic->blocks[i]->regs[j].addr == addr) {
- snprintf(regname, sizeof(regname)-1, "%s.%s", asic->blocks[i]->ipname, asic->blocks[i]->regs[j].regname);
- goto end;
+ if (reg && reg->bits && reg->no_bits && asic->options.bitfields) {
+ int k;
+ printf("\n");
+ for (k = 0; k < reg->no_bits; k++) {
+ uint32_t v;
+ printf("\t\t\t\t\t\t\t");
+ v = (value >> reg->bits[k].start) & (1UL << (reg->bits[k].stop - reg->bits[k].start));
+ reg->bits[k].bitfield_print(asic, asic->asicname, ip->ipname, reg->regname, reg->bits[k].regname, reg->bits[k].start, reg->bits[k].stop, v);
}
-end:
- return regname;
+ }
}
static void print_decode_pm4_pkt3(struct umr_asic *asic, struct umr_ring_decoder *decoder, uint32_t ib)
@@ -472,6 +488,7 @@ static void print_decode_pm4_pkt3(struct umr_asic *asic, struct umr_ring_decoder
default:
if (decoder->pm4.next_write_mem.type == 0) { // mem-mapped reg
printf("%s <= %08lx", umr_reg_name(asic, ((uint64_t)decoder->pm4.next_write_mem.addr_hi << 32) | decoder->pm4.next_write_mem.addr_lo), (unsigned long)ib);
+ print_bits(asic, decoder->pm4.next_write_mem.addr_lo, ib);
decoder->pm4.next_write_mem.addr_lo++;
if (!decoder->pm4.next_write_mem.addr_lo)
decoder->pm4.next_write_mem.addr_hi++;
@@ -623,6 +640,7 @@ static void print_decode_pm4_pkt3(struct umr_asic *asic, struct umr_ring_decoder
printf("OFFSET: 0x%lx", (unsigned long)BITS(ib, 0, 16));
break;
default: printf("%s <= 0x%08lx", umr_reg_name(asic, decoder->pm4.next_write_mem.addr_lo++), (unsigned long)ib);
+ print_bits(asic, decoder->pm4.next_write_mem.addr_lo - 1, ib);
break;
}
break;
@@ -632,6 +650,7 @@ static void print_decode_pm4_pkt3(struct umr_asic *asic, struct umr_ring_decoder
printf("OFFSET: 0x%lx", (unsigned long)BITS(ib, 0, 16));
break;
default: printf("%s <= 0x%08lx", umr_reg_name(asic, decoder->pm4.next_write_mem.addr_lo++), (unsigned long)ib);
+ print_bits(asic, decoder->pm4.next_write_mem.addr_lo - 1, ib);
break;
}
break;
@@ -641,6 +660,7 @@ static void print_decode_pm4_pkt3(struct umr_asic *asic, struct umr_ring_decoder
printf("OFFSET: 0x%lx", (unsigned long)BITS(ib, 0, 16));
break;
default: printf("%s <= 0x%08lx", umr_reg_name(asic, decoder->pm4.next_write_mem.addr_lo++), (unsigned long)ib);
+ print_bits(asic, decoder->pm4.next_write_mem.addr_lo - 1, ib);
break;
}
break;
@@ -650,6 +670,7 @@ static void print_decode_pm4_pkt3(struct umr_asic *asic, struct umr_ring_decoder
printf("OFFSET: 0x%lx", (unsigned long)BITS(ib, 0, 16));
break;
default: printf("%s <= 0x%08lx", umr_reg_name(asic, decoder->pm4.next_write_mem.addr_lo++), (unsigned long)ib);
+ print_bits(asic, decoder->pm4.next_write_mem.addr_lo - 1, ib);
break;
}
break;
diff --git a/src/umr.h b/src/umr.h
index 1742e7e1550b..6efe3a468253 100644
--- a/src/umr.h
+++ b/src/umr.h
@@ -504,6 +504,7 @@ uint32_t umr_find_reg(struct umr_asic *asic, char *regname);
// find the register data for a register
struct umr_reg *umr_find_reg_data_by_ip(struct umr_asic *asic, char *ip, char *regname);
struct umr_reg *umr_find_reg_data(struct umr_asic *asic, char *regname);
+struct umr_reg *umr_find_reg_by_addr(struct umr_asic *asic, uint64_t addr, struct umr_ip_block **ip);
// read/write a 32-bit register given a BYTE address
uint32_t umr_read_reg(struct umr_asic *asic, uint64_t addr, enum regclass type);
--
2.12.0
More information about the amd-gfx
mailing list