hw/misc/unimp: Improve how offset/value are displayed
cover hw/misc/unimp: Improve how offset/value are displayed
This series aims to ease looking at the '-d unimp' output reported by the UnimplementedDevice.
- read/write accesses are now aligned
- the value format width uses the access size
- the offset (address) uses the size of the memory region it belongs
Philippe Mathieu-Daudé (3):
hw/misc/unimp: Display value after offset hw/misc/unimp: Display the value with width of the access size hw/misc/unimp: Display the offset with width of the region size
include/hw/misc/unimp.h | 1 + hw/misc/unimp.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-)
Signature · 1 line
2.21.3
PATCH 1/3 hw/misc/unimp: Display value after offset
To better align the read/write accesses, display the value after the offset (read accesses only display the offset).
--- hw/misc/unimp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/misc/unimp.c +4 -4
@@ -22,7 +22,7 @@ static uint64_t unimp_read(void *opaque, hwaddr offset, unsigned size) {UnimplementedDeviceState *s =UNIMPLEMENTED_DEVICE (opaque); -qemu_log_mask (LOG_UNIMP ,"%s: unimplemented device read " +qemu_log_mask (LOG_UNIMP ,"%s: unimplemented device read " "(size %d, offset 0x%" HWADDR_PRIx")\n" , s->name, size, offset);return 0 ;
@@ -34,9 +34,9 @@ static void unimp_write(void *opaque, hwaddr offset,UnimplementedDeviceState *s =UNIMPLEMENTED_DEVICE (opaque);qemu_log_mask (LOG_UNIMP ,"%s: unimplemented device write " -"(size %d, value 0x%" PRIx64 -", offset 0x%" HWADDR_PRIx")\n" , - s->name, size, value, offset); +"(size %d, offset 0x%" HWADDR_PRIx +", value 0x%" PRIx64")\n" , + s->name, size, offset, value); }static const MemoryRegionOps unimp_ops = {
Signature · 1 line
2.21.3
Re: [PATCH-for-5.2 1/3] hw/misc/unimp: Display value after offset
Quoted 4 lines · Philippe Mathieu-Daudé
To better align the read/write accesses, display the value after the offset (read accesses only display the offset).
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
r~
PATCH 2/3 hw/misc/unimp: Display the value with width of the access size
In reply to Philippe Mathieu-DaudéTo quickly notice the access size, display the value with the width of the access (i.e. 16-bit access is displayed 0x0000, while 8-bit access 0x00).
--- hw/misc/unimp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/misc/unimp.c +2 -2
@@ -35,8 +35,8 @@ static void unimp_write(void *opaque, hwaddr offset,qemu_log_mask (LOG_UNIMP ,"%s: unimplemented device write " "(size %d, offset 0x%" HWADDR_PRIx -", value 0x%" PRIx64")\n" , - s->name, size, offset, value); +", value 0x%0*" PRIx64")\n" , + s->name, size, offset, size <<1 , value); }static const MemoryRegionOps unimp_ops = {
Signature · 1 line
2.21.3
Re: [PATCH-for-5.2 2/3] hw/misc/unimp: Display the value with width of the access size
Quoted 8 lines · Philippe Mathieu-Daudé
To quickly notice the access size, display the value with the width of the access (i.e. 16-bit access is displayed
0x0000, while 8-bit access0x00).Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/misc/unimp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
r~
PATCH 3/3 hw/misc/unimp: Display the offset with width of the region size
In reply to Philippe Mathieu-DaudéTo have a better idea of how big is the region where the offset belongs, display the value with the width of the region size (i.e. a region of 0x1000 bytes uses 0x000 format).
--- include/hw/misc/unimp.h | 1 + hw/misc/unimp.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-)
include/hw/misc/unimp.h +1 -0
@@ -20,6 +20,7 @@typedef struct {SysBusDevice parent_obj;MemoryRegion iomem; +unsigned offset_fmt_width;char *name;uint64_t size; }UnimplementedDeviceState ;
hw/misc/unimp.c +6 -4
@@ -23,8 +23,8 @@ static uint64_t unimp_read(void *opaque, hwaddr offset, unsigned size)UnimplementedDeviceState *s =UNIMPLEMENTED_DEVICE (opaque);qemu_log_mask (LOG_UNIMP ,"%s: unimplemented device read " -"(size %d, offset 0x%" HWADDR_PRIx")\n" , - s->name, size, offset); +"(size %d, offset 0x%0*" HWADDR_PRIx")\n" , + s->name, size, s->offset_fmt_width, offset);return 0 ; }
@@ -34,9 +34,9 @@ static void unimp_write(void *opaque, hwaddr offset,UnimplementedDeviceState *s =UNIMPLEMENTED_DEVICE (opaque);qemu_log_mask (LOG_UNIMP ,"%s: unimplemented device write " -"(size %d, offset 0x%" HWADDR_PRIx +"(size %d, offset 0x%0*" HWADDR_PRIx", value 0x%0*" PRIx64")\n" , - s->name, size, offset, size <<1 , value); + s->name, size, s->offset_fmt_width, offset, size <<1 , value); }static const MemoryRegionOps unimp_ops = {
@@ -63,6 +63,8 @@ static void unimp_realize(DeviceState *dev, Error **errp)return ; } + s->offset_fmt_width =ROUND_UP (64 -clz64 (s->size -1 ),4 ) >>2 ; +memory_region_init_io (&s->iomem,OBJECT (s), &unimp_ops, s, s->name, s->size);sysbus_init_mmio (SYS_BUS_DEVICE (s), &s->iomem);
Signature · 1 line
2.21.3
Re: [PATCH-for-5.2 3/3] hw/misc/unimp: Display the offset with width of the region size
Quoted 1 line · Philippe Mathieu-Daudé
+
s->offset_fmt_width=ROUND_UP(64 - clz64(s->size - 1), 4)>> 2;
Better with DIV_ROUND_UP, I think. Otherwise,
r~
Re: [PATCH-for-5.2 3/3] hw/misc/unimp: Display the offset with width of the region size
Quoted 4 lines · Richard Henderson
Quoted 1 line · Philippe Mathieu-Daudé
+
s->offset_fmt_width=ROUND_UP(64 - clz64(s->size - 1), 4)>> 2;Better with
DIV_ROUND_UP, I think. Otherwise,
Thanks for the tip! (and for reviewing the other series) :)
Quoted 6 lines
Reviewed-by Richard Henderson <[email protected]>r~