aboutsummaryrefslogtreecommitdiff
path: root/hw/misc/unimp.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/misc/unimp.c')
-rw-r--r--hw/misc/unimp.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/hw/misc/unimp.c b/hw/misc/unimp.c
index b4b318db1c..6cfc5727f0 100644
--- a/hw/misc/unimp.c
+++ b/hw/misc/unimp.c
@@ -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 = DIV_ROUND_UP(64 - clz64(s->size - 1), 4);
+
memory_region_init_io(&s->iomem, OBJECT(s), &unimp_ops, s,
s->name, s->size);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);