hw/block/nvme.h | 1 - hw/ppc/mac.h | 3 ++- hw/rdma/vmw/pvrdma.h | 3 ++- include/hw/acpi/tpm.h | 3 ++- include/hw/arm/fsl-imx7.h | 5 ++-- include/hw/arm/stm32f205_soc.h | 5 ++-- include/hw/devices.h | 7 ++---- include/hw/display/xlnx_dp.h | 5 ++-- include/hw/i386/ich9.h | 3 ++- include/hw/intc/mips_gic.h | 3 ++- include/hw/loader.h | 5 ++-- include/hw/mem/nvdimm.h | 3 ++- include/hw/mips/bios.h | 3 ++- include/hw/misc/mips_itu.h | 2 ++ include/hw/net/allwinner_emac.h | 5 ++-- include/hw/ppc/spapr.h | 3 ++- include/hw/virtio/virtio-net.h | 3 ++- include/qemu/cutils.h | 7 ------ include/qemu/units.h | 11 +++++++++ hw/alpha/typhoon.c | 17 +++++++------- hw/arm/bcm2835_peripherals.c | 3 ++- hw/arm/boot.c | 7 +++--- hw/arm/collie.c | 5 ++-- hw/arm/digic_boards.c | 7 +++--- hw/arm/exynos4_boards.c | 3 ++- hw/arm/gumstix.c | 3 ++- hw/arm/imx25_pdk.c | 1 + hw/arm/integratorcp.c | 3 ++- hw/arm/mainstone.c | 3 ++- hw/arm/msf2-soc.c | 2 +- hw/arm/msf2-som.c | 2 +- hw/arm/musicpal.c | 9 ++++---- hw/arm/omap_sx1.c | 11 +++++---- hw/arm/raspi.c | 5 ++-- hw/arm/stellaris.c | 5 ++-- hw/arm/versatilepb.c | 5 ++-- hw/arm/vexpress.c | 7 +++--- hw/arm/virt.c | 5 ++-- hw/arm/xilinx_zynq.c | 7 +++--- hw/block/nvme.c | 4 +++- hw/block/tc58128.c | 3 ++- hw/block/xen_disk.c | 5 ++-- hw/core/loader-fit.c | 2 +- hw/core/machine.c | 2 +- hw/cris/axis_dev88.c | 4 ++-- hw/display/cirrus_vga.c | 10 ++++---- hw/display/g364fb.c | 3 ++- hw/display/qxl.c | 27 ++++++++++------------ hw/display/sm501.c | 2 +- hw/display/vga-isa-mm.c | 5 ++-- hw/display/vga.c | 5 ++-- hw/display/virtio-gpu.c | 4 ++-- hw/display/vmware_vga.c | 3 ++- hw/display/xenfb.c | 3 ++- hw/hppa/dino.c | 3 ++- hw/hppa/machine.c | 10 ++++---- hw/i386/acpi-build.c | 5 ++-- hw/i386/pc.c | 19 ++++++++-------- hw/i386/pc_piix.c | 4 ++-- hw/i386/pc_q35.c | 3 ++- hw/i386/pc_sysfw.c | 9 ++++---- hw/i386/xen/xen-mapcache.c | 3 ++- hw/intc/apic_common.c | 3 ++- hw/ipack/tpci200.c | 5 ++-- hw/lm32/lm32_boards.c | 13 ++++++----- hw/lm32/milkymist.c | 10 ++++---- hw/m68k/mcf5208.c | 3 ++- hw/mem/nvdimm.c | 2 +- hw/microblaze/petalogix_ml605_mmu.c | 7 +++--- hw/microblaze/petalogix_s3adsp1800_mmu.c | 7 +++--- hw/mips/boston.c | 4 ++-- hw/mips/mips_fulong2e.c | 7 +++--- hw/mips/mips_malta.c | 23 +++++++++++-------- hw/mips/mips_r4k.c | 15 ++++++------ hw/misc/aspeed_sdmc.c | 9 ++++---- hw/misc/auxbus.c | 3 ++- hw/misc/edu.c | 3 ++- hw/misc/imx7_gpr.c | 3 ++- hw/misc/ivshmem.c | 3 ++- hw/misc/mips_itu.c | 8 +++---- hw/misc/omap_gpmc.c | 5 ++-- hw/net/e1000e.c | 7 +++--- hw/net/e1000x_common.c | 3 ++- hw/net/eepro100.c | 7 +++--- hw/nios2/boot.c | 6 ++--- hw/nvram/spapr_nvram.c | 10 ++++---- hw/pci-host/gpex.c | 3 ++- hw/pci-host/piix.c | 5 ++-- hw/pci-host/prep.c | 3 ++- hw/pci-host/q35.c | 17 +++++++------- hw/pci-host/xilinx-pcie.c | 5 ++-- hw/ppc/e500.c | 13 ++++++----- hw/ppc/e500plat.c | 3 ++- hw/ppc/mac_newworld.c | 1 - hw/ppc/mac_oldworld.c | 9 ++++---- hw/ppc/pnv.c | 2 +- hw/ppc/ppc405_boards.c | 9 ++++---- hw/ppc/ppc405_uc.c | 7 +++--- hw/ppc/ppc440_bamboo.c | 6 +++-- hw/ppc/ppc440_uc.c | 2 +- hw/ppc/ppc4xx_devs.c | 22 ++++++++++-------- hw/ppc/ppce500_spin.c | 3 ++- hw/ppc/prep.c | 4 ++-- hw/ppc/rs6000_mc.c | 13 ++++++----- hw/ppc/sam460ex.c | 16 +++++++------ hw/ppc/spapr.c | 2 +- hw/ppc/spapr_rtas.c | 1 + hw/ppc/virtex_ml507.c | 7 +++--- hw/riscv/virt.c | 3 ++- hw/s390x/s390-skeys.c | 3 ++- hw/s390x/s390-stattrib.c | 3 ++- hw/s390x/sclp.c | 5 ++-- hw/scsi/scsi-disk.c | 9 ++++---- hw/sd/sd.c | 4 ++-- hw/sd/sdhci.c | 4 ++-- hw/sh4/r2d.c | 4 ++-- hw/smbios/smbios.c | 15 +++++------- hw/sparc/leon3.c | 9 ++++---- hw/sparc/sun4m.c | 9 ++++---- hw/sparc64/niagara.c | 3 ++- hw/sparc64/sun4u.c | 4 ++-- hw/ssi/aspeed_smc.c | 29 ++++++++++++------------ hw/tricore/tricore_testboard.c | 13 ++++++----- hw/usb/ccid-card-passthru.c | 5 ++-- hw/usb/combined-packet.c | 3 ++- hw/usb/dev-smartcard-reader.c | 3 ++- hw/usb/redirect.c | 3 ++- hw/vfio/pci-quirks.c | 9 ++++---- hw/vfio/pci.c | 3 ++- hw/xenpv/xen_domainbuild.c | 13 ++++++----- hw/xtensa/xtfpga.c | 5 ++-- 131 files changed, 450 insertions(+), 358 deletions(-) create mode 100644 include/qemu/units.h
Hi, This series: - split the byte-based definitions from "qemu/cutils.h" to "qemu/units.h" - clean hw/ includes; - replace different constants used for byte size with their corresponding BYTE-based definitions. Since v2: - use "qemu/units.h" instead of "qemu/cunits.h" (Daniel P. Berrangé) - avoid rebuilding the world including "qemu/units.h" in "hw/hw.h" (Thomas Huth) - more constant replaced Since v1: - corrected Xen mult -> div (Alan Robinson) - tagged 'include "qemu/cunits.h" in "hw/hw.h" as RFC - fixed mips_r4k 'params_size' (Thomas Huth) - added command used to generate patch in each commit (Alistair Francis) - use G_BYTE for the raspi3 machine - added Reviewed-by tags Regards, Phil. $ git backport-diff -r master.. -u v2 001/41:[down] 'hw: Clean "hw/devices.h" includes' 002/41:[down] 'hw: Do not include "sysemu/block-backend.h" if it is not necessary' 003/41:[----] [--] 'hw/block/nvme: include the "qemu/cutils.h" in the source file' 004/41:[down] 'hw/misc/mips_itu: sort includes' 005/41:[----] [--] 'hw/mips/r4k: constify params_size' 006/41:[down] 'cutils: extract byte-based definitions into a new header: "qemu/units.h"' 007/41:[down] 'hw/ivshmem: use the BYTE-based definitions' 008/41:[0001] [FC] 'hw/ipack: use the BYTE-based definitions' 009/41:[0001] [FC] 'hw/scsi: use the BYTE-based definitions' 010/41:[0001] [FC] 'hw/smbios: use the BYTE-based definitions' 011/41:[down] 'hw/xen: use the BYTE-based definitions' 012/41:[down] 'hw/tpm: use the BYTE-based definitions' 013/41:[down] 'hw/block: use the BYTE-based definitions' 014/41:[0015] [FC] 'hw/display: use the BYTE-based definitions' 015/41:[0004] [FC] 'hw/misc: use the BYTE-based definitions' 016/41:[down] 'hw/riscv: use the BYTE-based definitions' 017/41:[down] 'hw/m68k: use the BYTE-based definitions' 018/41:[0006] [FC] 'hw/sparc: use the BYTE-based definitions' 019/41:[0007] [FC] 'hw/s390x: use the BYTE-based definitions' 020/41:[0003] [FC] 'hw/hppa: use the BYTE-based definitions' 021/41:[0003] [FC] 'hw/xtensa: use the BYTE-based definitions' 022/41:[0001] [FC] 'hw/alpha: use the BYTE-based definitions' 023/41:[0001] [FC] 'hw/tricore: use the BYTE-based definitions' 024/41:[0002] [FC] 'hw/microblaze: use the BYTE-based definitions' 025/41:[0004] [FC] 'hw/nios2: use the BYTE-based definitions' 026/41:[0001] [FC] 'hw/cris: use the BYTE-based definitions' 027/41:[0003] [FC] 'hw/lm32: use the BYTE-based definitions' 028/41:[0003] [FC] 'hw/sh4: use the BYTE-based definitions' 029/41:[0012] [FC] 'hw/mips: use the BYTE-based definitions' 030/41:[0052] [FC] 'hw/arm: use the BYTE-based definitions' 031/41:[0065] [FC] 'hw/ppc: use the BYTE-based definitions' 032/41:[0014] [FC] 'hw/i386: use the BYTE-based definitions' 033/41:[0006] [FC] 'hw/net: use the BYTE-based definitions' 034/41:[down] 'hw/usb: use the BYTE-based definitions' 035/41:[down] 'hw/sd: use the BYTE-based definitions' 036/41:[down] 'hw/vfio: use the BYTE-based definitions' 037/41:[down] 'hw/virtio: use the BYTE-based definitions' 038/41:[down] 'hw/rdma: use the BYTE-based definitions' 039/41:[down] 'hw/nvdimm: use the BYTE-based definitions' 040/41:[down] 'hw/loader: use the BYTE-based definitions' 041/41:[down] 'cutils: do not include "units.h" directly' Philippe Mathieu-Daudé (41): hw: Clean "hw/devices.h" includes hw: Do not include "sysemu/block-backend.h" if it is not necessary hw/block/nvme: include the "qemu/cutils.h" in the source file hw/misc/mips_itu: sort includes hw/mips/r4k: constify params_size cutils: extract byte-based definitions into a new header: "qemu/units.h" hw/ivshmem: use the BYTE-based definitions hw/ipack: use the BYTE-based definitions hw/scsi: use the BYTE-based definitions hw/smbios: use the BYTE-based definitions hw/xen: use the BYTE-based definitions hw/tpm: use the BYTE-based definitions hw/block: use the BYTE-based definitions hw/display: use the BYTE-based definitions hw/misc: use the BYTE-based definitions hw/riscv: use the BYTE-based definitions hw/m68k: use the BYTE-based definitions hw/sparc: use the BYTE-based definitions hw/s390x: use the BYTE-based definitions hw/hppa: use the BYTE-based definitions hw/xtensa: use the BYTE-based definitions hw/alpha: use the BYTE-based definitions hw/tricore: use the BYTE-based definitions hw/microblaze: use the BYTE-based definitions hw/nios2: use the BYTE-based definitions hw/cris: use the BYTE-based definitions hw/lm32: use the BYTE-based definitions hw/sh4: use the BYTE-based definitions hw/mips: use the BYTE-based definitions hw/arm: use the BYTE-based definitions hw/ppc: use the BYTE-based definitions hw/i386: use the BYTE-based definitions hw/net: use the BYTE-based definitions hw/usb: use the BYTE-based definitions hw/sd: use the BYTE-based definitions hw/vfio: use the BYTE-based definitions hw/virtio: use the BYTE-based definitions hw/rdma: use the BYTE-based definitions hw/nvdimm: use the BYTE-based definitions hw/loader: use the BYTE-based definitions cutils: do not include "qemu/units.h" directly hw/block/nvme.h | 1 - hw/ppc/mac.h | 3 ++- hw/rdma/vmw/pvrdma.h | 3 ++- include/hw/acpi/tpm.h | 3 ++- include/hw/arm/fsl-imx7.h | 5 ++-- include/hw/arm/stm32f205_soc.h | 5 ++-- include/hw/devices.h | 7 ++---- include/hw/display/xlnx_dp.h | 5 ++-- include/hw/i386/ich9.h | 3 ++- include/hw/intc/mips_gic.h | 3 ++- include/hw/loader.h | 5 ++-- include/hw/mem/nvdimm.h | 3 ++- include/hw/mips/bios.h | 3 ++- include/hw/misc/mips_itu.h | 2 ++ include/hw/net/allwinner_emac.h | 5 ++-- include/hw/ppc/spapr.h | 3 ++- include/hw/virtio/virtio-net.h | 3 ++- include/qemu/cutils.h | 7 ------ include/qemu/units.h | 11 +++++++++ hw/alpha/typhoon.c | 17 +++++++------- hw/arm/bcm2835_peripherals.c | 3 ++- hw/arm/boot.c | 7 +++--- hw/arm/collie.c | 5 ++-- hw/arm/digic_boards.c | 7 +++--- hw/arm/exynos4_boards.c | 3 ++- hw/arm/gumstix.c | 3 ++- hw/arm/imx25_pdk.c | 1 + hw/arm/integratorcp.c | 3 ++- hw/arm/mainstone.c | 3 ++- hw/arm/msf2-soc.c | 2 +- hw/arm/msf2-som.c | 2 +- hw/arm/musicpal.c | 9 ++++---- hw/arm/omap_sx1.c | 11 +++++---- hw/arm/raspi.c | 5 ++-- hw/arm/stellaris.c | 5 ++-- hw/arm/versatilepb.c | 5 ++-- hw/arm/vexpress.c | 7 +++--- hw/arm/virt.c | 5 ++-- hw/arm/xilinx_zynq.c | 7 +++--- hw/block/nvme.c | 4 +++- hw/block/tc58128.c | 3 ++- hw/block/xen_disk.c | 5 ++-- hw/core/loader-fit.c | 2 +- hw/core/machine.c | 2 +- hw/cris/axis_dev88.c | 4 ++-- hw/display/cirrus_vga.c | 10 ++++---- hw/display/g364fb.c | 3 ++- hw/display/qxl.c | 27 ++++++++++------------ hw/display/sm501.c | 2 +- hw/display/vga-isa-mm.c | 5 ++-- hw/display/vga.c | 5 ++-- hw/display/virtio-gpu.c | 4 ++-- hw/display/vmware_vga.c | 3 ++- hw/display/xenfb.c | 3 ++- hw/hppa/dino.c | 3 ++- hw/hppa/machine.c | 10 ++++---- hw/i386/acpi-build.c | 5 ++-- hw/i386/pc.c | 19 ++++++++-------- hw/i386/pc_piix.c | 4 ++-- hw/i386/pc_q35.c | 3 ++- hw/i386/pc_sysfw.c | 9 ++++---- hw/i386/xen/xen-mapcache.c | 3 ++- hw/intc/apic_common.c | 3 ++- hw/ipack/tpci200.c | 5 ++-- hw/lm32/lm32_boards.c | 13 ++++++----- hw/lm32/milkymist.c | 10 ++++---- hw/m68k/mcf5208.c | 3 ++- hw/mem/nvdimm.c | 2 +- hw/microblaze/petalogix_ml605_mmu.c | 7 +++--- hw/microblaze/petalogix_s3adsp1800_mmu.c | 7 +++--- hw/mips/boston.c | 4 ++-- hw/mips/mips_fulong2e.c | 7 +++--- hw/mips/mips_malta.c | 23 +++++++++++-------- hw/mips/mips_r4k.c | 15 ++++++------ hw/misc/aspeed_sdmc.c | 9 ++++---- hw/misc/auxbus.c | 3 ++- hw/misc/edu.c | 3 ++- hw/misc/imx7_gpr.c | 3 ++- hw/misc/ivshmem.c | 3 ++- hw/misc/mips_itu.c | 8 +++---- hw/misc/omap_gpmc.c | 5 ++-- hw/net/e1000e.c | 7 +++--- hw/net/e1000x_common.c | 3 ++- hw/net/eepro100.c | 7 +++--- hw/nios2/boot.c | 6 ++--- hw/nvram/spapr_nvram.c | 10 ++++---- hw/pci-host/gpex.c | 3 ++- hw/pci-host/piix.c | 5 ++-- hw/pci-host/prep.c | 3 ++- hw/pci-host/q35.c | 17 +++++++------- hw/pci-host/xilinx-pcie.c | 5 ++-- hw/ppc/e500.c | 13 ++++++----- hw/ppc/e500plat.c | 3 ++- hw/ppc/mac_newworld.c | 1 - hw/ppc/mac_oldworld.c | 9 ++++---- hw/ppc/pnv.c | 2 +- hw/ppc/ppc405_boards.c | 9 ++++---- hw/ppc/ppc405_uc.c | 7 +++--- hw/ppc/ppc440_bamboo.c | 6 +++-- hw/ppc/ppc440_uc.c | 2 +- hw/ppc/ppc4xx_devs.c | 22 ++++++++++-------- hw/ppc/ppce500_spin.c | 3 ++- hw/ppc/prep.c | 4 ++-- hw/ppc/rs6000_mc.c | 13 ++++++----- hw/ppc/sam460ex.c | 16 +++++++------ hw/ppc/spapr.c | 2 +- hw/ppc/spapr_rtas.c | 1 + hw/ppc/virtex_ml507.c | 7 +++--- hw/riscv/virt.c | 3 ++- hw/s390x/s390-skeys.c | 3 ++- hw/s390x/s390-stattrib.c | 3 ++- hw/s390x/sclp.c | 5 ++-- hw/scsi/scsi-disk.c | 9 ++++---- hw/sd/sd.c | 4 ++-- hw/sd/sdhci.c | 4 ++-- hw/sh4/r2d.c | 4 ++-- hw/smbios/smbios.c | 15 +++++------- hw/sparc/leon3.c | 9 ++++---- hw/sparc/sun4m.c | 9 ++++---- hw/sparc64/niagara.c | 3 ++- hw/sparc64/sun4u.c | 4 ++-- hw/ssi/aspeed_smc.c | 29 ++++++++++++------------ hw/tricore/tricore_testboard.c | 13 ++++++----- hw/usb/ccid-card-passthru.c | 5 ++-- hw/usb/combined-packet.c | 3 ++- hw/usb/dev-smartcard-reader.c | 3 ++- hw/usb/redirect.c | 3 ++- hw/vfio/pci-quirks.c | 9 ++++---- hw/vfio/pci.c | 3 ++- hw/xenpv/xen_domainbuild.c | 13 ++++++----- hw/xtensa/xtfpga.c | 5 ++-- 131 files changed, 450 insertions(+), 358 deletions(-) create mode 100644 include/qemu/units.h -- 2.17.0
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/devices.h | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/include/hw/devices.h b/include/hw/devices.h
index 861ddea8af..0e27feb0c2 100644
--- a/include/hw/devices.h
+++ b/include/hw/devices.h
@@ -1,13 +1,10 @@
#ifndef QEMU_DEVICES_H
#define QEMU_DEVICES_H
-#include "hw/irq.h"
-
-/* ??? Not all users of this file can include cpu-common.h. */
-struct MemoryRegion;
-
/* Devices that have nowhere better to go. */
+#include "hw/hw.h"
+
/* smc91c111.c */
void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
--
2.17.0
On 16.04.2018 01:42, Philippe Mathieu-Daudé wrote: > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > include/hw/devices.h | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/include/hw/devices.h b/include/hw/devices.h > index 861ddea8af..0e27feb0c2 100644 > --- a/include/hw/devices.h > +++ b/include/hw/devices.h > @@ -1,13 +1,10 @@ > #ifndef QEMU_DEVICES_H > #define QEMU_DEVICES_H > > -#include "hw/irq.h" > - > -/* ??? Not all users of this file can include cpu-common.h. */ > -struct MemoryRegion; > - > /* Devices that have nowhere better to go. */ > > +#include "hw/hw.h" > + > /* smc91c111.c */ > void smc91c111_init(NICInfo *, uint32_t, qemu_irq); IMHO we should rather get rid of devices.h (in a separate patch series) and introduce proper small headers à la smc91c111.h for the single sections in here... Just my 0.02 €. Thomas
Hi Thomas, On 04/16/2018 01:53 AM, Thomas Huth wrote: > On 16.04.2018 01:42, Philippe Mathieu-Daudé wrote: >> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> >> --- >> include/hw/devices.h | 7 ++----- >> 1 file changed, 2 insertions(+), 5 deletions(-) >> >> diff --git a/include/hw/devices.h b/include/hw/devices.h >> index 861ddea8af..0e27feb0c2 100644 >> --- a/include/hw/devices.h >> +++ b/include/hw/devices.h >> @@ -1,13 +1,10 @@ >> #ifndef QEMU_DEVICES_H >> #define QEMU_DEVICES_H >> >> -#include "hw/irq.h" >> - >> -/* ??? Not all users of this file can include cpu-common.h. */ >> -struct MemoryRegion; >> - >> /* Devices that have nowhere better to go. */ >> >> +#include "hw/hw.h" >> + >> /* smc91c111.c */ >> void smc91c111_init(NICInfo *, uint32_t, qemu_irq); > > IMHO we should rather get rid of devices.h (in a separate patch series) > and introduce proper small headers à la smc91c111.h for the single > sections in here... Just my 0.02 €. Yes, the idea is to QOM'ify those devices and drop this file.
Remove those unneeded includes to speed up the compilation
process a little bit. (Missed in 7eceff5b5a1fa)
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/cris/axis_dev88.c | 1 -
hw/sh4/r2d.c | 1 -
2 files changed, 2 deletions(-)
diff --git a/hw/cris/axis_dev88.c b/hw/cris/axis_dev88.c
index 9ccc4350a5..1775e53e25 100644
--- a/hw/cris/axis_dev88.c
+++ b/hw/cris/axis_dev88.c
@@ -34,7 +34,6 @@
#include "hw/loader.h"
#include "elf.h"
#include "boot.h"
-#include "sysemu/block-backend.h"
#include "exec/address-spaces.h"
#include "sysemu/qtest.h"
#include "sysemu/sysemu.h"
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 458ed83297..f5f3deab37 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -40,7 +40,6 @@
#include "hw/loader.h"
#include "hw/usb.h"
#include "hw/block/flash.h"
-#include "sysemu/block-backend.h"
#include "exec/address-spaces.h"
#define FLASH_BASE 0x00000000
--
2.17.0
where it is used.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
hw/block/nvme.h | 1 -
hw/block/nvme.c | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/block/nvme.h b/hw/block/nvme.h
index 8f3981121d..cabcf20c32 100644
--- a/hw/block/nvme.h
+++ b/hw/block/nvme.h
@@ -1,6 +1,5 @@
#ifndef HW_NVME_H
#define HW_NVME_H
-#include "qemu/cutils.h"
#include "block/nvme.h"
typedef struct NvmeAsyncEvent {
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 85d2406400..811084b6a7 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -35,6 +35,7 @@
#include "sysemu/block-backend.h"
#include "qemu/log.h"
+#include "qemu/cutils.h"
#include "trace.h"
#include "nvme.h"
--
2.17.0
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/misc/mips_itu.h | 2 ++
hw/misc/mips_itu.c | 5 +----
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/include/hw/misc/mips_itu.h b/include/hw/misc/mips_itu.h
index b3a4532036..030eb4ac62 100644
--- a/include/hw/misc/mips_itu.h
+++ b/include/hw/misc/mips_itu.h
@@ -20,6 +20,8 @@
#ifndef MIPS_ITU_H
#define MIPS_ITU_H
+#include "hw/sysbus.h"
+
#define TYPE_MIPS_ITU "mips-itu"
#define MIPS_ITU(obj) OBJECT_CHECK(MIPSITUState, (obj), TYPE_MIPS_ITU)
diff --git a/hw/misc/mips_itu.c b/hw/misc/mips_itu.c
index c84a48bbb7..ccc4c7d98a 100644
--- a/hw/misc/mips_itu.c
+++ b/hw/misc/mips_itu.c
@@ -18,13 +18,10 @@
*/
#include "qemu/osdep.h"
+#include "qemu/log.h"
#include "qapi/error.h"
#include "cpu.h"
-#include "qemu/log.h"
#include "exec/exec-all.h"
-#include "hw/hw.h"
-#include "hw/sysbus.h"
-#include "sysemu/sysemu.h"
#include "hw/misc/mips_itu.h"
#define ITC_TAG_ADDRSPACE_SZ (ITC_ADDRESSMAP_NUM * 8)
--
2.17.0
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/mips/mips_r4k.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
index aeadc4a340..c26a44da06 100644
--- a/hw/mips/mips_r4k.c
+++ b/hw/mips/mips_r4k.c
@@ -80,8 +80,9 @@ typedef struct ResetData {
static int64_t load_kernel(void)
{
+ const size_t params_size = 264;
int64_t entry, kernel_high;
- long kernel_size, initrd_size, params_size;
+ long kernel_size, initrd_size;
ram_addr_t initrd_offset;
uint32_t *params_buf;
int big_endian;
@@ -129,7 +130,6 @@ static int64_t load_kernel(void)
}
/* Store command line. */
- params_size = 264;
params_buf = g_malloc(params_size);
params_buf[0] = tswap32(ram_size);
@@ -144,7 +144,7 @@ static int64_t load_kernel(void)
}
rom_add_blob_fixed("params", params_buf, params_size,
- (16 << 20) - 264);
+ (16 << 20) - params_size);
g_free(params_buf);
return entry;
--
2.17.0
(added in 076b35b5a56)
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
include/qemu/cutils.h | 8 +-------
include/qemu/units.h | 11 +++++++++++
2 files changed, 12 insertions(+), 7 deletions(-)
create mode 100644 include/qemu/units.h
diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index a663340b23..056e6629bb 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -2,6 +2,7 @@
#define QEMU_CUTILS_H
#include "qemu/fprintf-fn.h"
+#include "qemu/units.h"
/**
* pstrcpy:
@@ -147,13 +148,6 @@ int qemu_strtosz(const char *nptr, char **end, uint64_t *result);
int qemu_strtosz_MiB(const char *nptr, char **end, uint64_t *result);
int qemu_strtosz_metric(const char *nptr, char **end, uint64_t *result);
-#define K_BYTE (1ULL << 10)
-#define M_BYTE (1ULL << 20)
-#define G_BYTE (1ULL << 30)
-#define T_BYTE (1ULL << 40)
-#define P_BYTE (1ULL << 50)
-#define E_BYTE (1ULL << 60)
-
/* used to print char* safely */
#define STR_OR_NULL(str) ((str) ? (str) : "null")
diff --git a/include/qemu/units.h b/include/qemu/units.h
new file mode 100644
index 0000000000..81f5cc6f7f
--- /dev/null
+++ b/include/qemu/units.h
@@ -0,0 +1,11 @@
+#ifndef QEMU_UNITS_H
+#define QEMU_UNITS_H
+
+#define K_BYTE (1ULL << 10)
+#define M_BYTE (1ULL << 20)
+#define G_BYTE (1ULL << 30)
+#define T_BYTE (1ULL << 40)
+#define P_BYTE (1ULL << 50)
+#define E_BYTE (1ULL << 60)
+
+#endif
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/misc/ivshmem.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 16f03701b7..2f4715abad 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -17,6 +17,7 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu/cutils.h"
#include "hw/hw.h"
@@ -1302,7 +1303,7 @@ static void ivshmem_realize(PCIDevice *dev, Error **errp)
}
if (s->sizearg == NULL) {
- s->legacy_size = 4 << 20; /* 4 MB default */
+ s->legacy_size = 4 * M_BYTE; /* 4 MB default */
} else {
int ret;
uint64_t size;
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alberto Garcia <berto@igalia.com>
---
hw/ipack/tpci200.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/ipack/tpci200.c b/hw/ipack/tpci200.c
index da05c8589d..8451bf8ad3 100644
--- a/hw/ipack/tpci200.c
+++ b/hw/ipack/tpci200.c
@@ -9,6 +9,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/ipack/ipack.h"
#include "hw/pci/pci.h"
#include "qemu/bitops.h"
@@ -597,9 +598,9 @@ static void tpci200_realize(PCIDevice *pci_dev, Error **errp)
memory_region_init_io(&s->las1, OBJECT(s), &tpci200_las1_ops,
s, "tpci200_las1", 1024);
memory_region_init_io(&s->las2, OBJECT(s), &tpci200_las2_ops,
- s, "tpci200_las2", 1024*1024*32);
+ s, "tpci200_las2", 32 * M_BYTE);
memory_region_init_io(&s->las3, OBJECT(s), &tpci200_las3_ops,
- s, "tpci200_las3", 1024*1024*16);
+ s, "tpci200_las3", 16 * M_BYTE);
pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio);
pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->io);
pci_register_bar(&s->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->las0);
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/scsi/scsi-disk.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index ded23d36ca..a67e7ffce5 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -29,6 +29,7 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0)
#endif
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "hw/scsi/scsi.h"
@@ -44,13 +45,13 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0)
#include <scsi/sg.h>
#endif
-#define SCSI_WRITE_SAME_MAX 524288
-#define SCSI_DMA_BUF_SIZE 131072
+#define SCSI_WRITE_SAME_MAX (512 * K_BYTE)
+#define SCSI_DMA_BUF_SIZE (128 * K_BYTE)
#define SCSI_MAX_INQUIRY_LEN 256
#define SCSI_MAX_MODE_LEN 256
-#define DEFAULT_DISCARD_GRANULARITY 4096
-#define DEFAULT_MAX_UNMAP_SIZE (1 << 30) /* 1 GB */
+#define DEFAULT_DISCARD_GRANULARITY (4 * K_BYTE)
+#define DEFAULT_MAX_UNMAP_SIZE (1 * G_BYTE)
#define DEFAULT_MAX_IO_SIZE INT_MAX /* 2 GB - 1 block */
#define TYPE_SCSI_DISK_BASE "scsi-disk-base"
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/smbios/smbios.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 27a07e96f4..a72f35d9f5 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -16,6 +16,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu/config-file.h"
#include "qemu/error-report.h"
@@ -625,10 +626,6 @@ static void smbios_build_type_11_table(void)
SMBIOS_BUILD_TABLE_POST;
}
-#define ONE_KB ((ram_addr_t)1 << 10)
-#define ONE_MB ((ram_addr_t)1 << 20)
-#define ONE_GB ((ram_addr_t)1 << 30)
-
#define MAX_T16_STD_SZ 0x80000000 /* 2T in Kilobytes */
static void smbios_build_type_16_table(unsigned dimm_cnt)
@@ -640,7 +637,7 @@ static void smbios_build_type_16_table(unsigned dimm_cnt)
t->location = 0x01; /* Other */
t->use = 0x03; /* System memory */
t->error_correction = 0x06; /* Multi-bit ECC (for Microsoft, per SeaBIOS) */
- size_kb = QEMU_ALIGN_UP(ram_size, ONE_KB) / ONE_KB;
+ size_kb = QEMU_ALIGN_UP(ram_size, K_BYTE) / K_BYTE;
if (size_kb < MAX_T16_STD_SZ) {
t->maximum_capacity = cpu_to_le32(size_kb);
t->extended_maximum_capacity = cpu_to_le64(0);
@@ -668,7 +665,7 @@ static void smbios_build_type_17_table(unsigned instance, uint64_t size)
t->memory_error_information_handle = cpu_to_le16(0xFFFE); /* Not provided */
t->total_width = cpu_to_le16(0xFFFF); /* Unknown */
t->data_width = cpu_to_le16(0xFFFF); /* Unknown */
- size_mb = QEMU_ALIGN_UP(size, ONE_MB) / ONE_MB;
+ size_mb = QEMU_ALIGN_UP(size, M_BYTE) / M_BYTE;
if (size_mb < MAX_T17_STD_SZ) {
t->size = cpu_to_le16(size_mb);
t->extended_size = cpu_to_le32(0);
@@ -707,8 +704,8 @@ static void smbios_build_type_19_table(unsigned instance,
end = start + size - 1;
assert(end > start);
- start_kb = start / ONE_KB;
- end_kb = end / ONE_KB;
+ start_kb = start / K_BYTE;
+ end_kb = end / K_BYTE;
if (start_kb < UINT32_MAX && end_kb < UINT32_MAX) {
t->starting_address = cpu_to_le32(start_kb);
t->ending_address = cpu_to_le32(end_kb);
@@ -869,7 +866,7 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
smbios_build_type_11_table();
-#define MAX_DIMM_SZ (16ll * ONE_GB)
+#define MAX_DIMM_SZ (16 * G_BYTE)
#define GET_DIMM_SZ ((i < dimm_cnt - 1) ? MAX_DIMM_SZ \
: ((ram_size - 1) % MAX_DIMM_SZ) + 1)
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alan Robinson <Alan.Robinson@ts.fujitsu.com>
---
hw/block/xen_disk.c | 5 +++--
hw/i386/xen/xen-mapcache.c | 3 ++-
hw/xenpv/xen_domainbuild.c | 13 +++++++------
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index f74fcd42d1..c342106fd5 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -20,6 +20,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include <sys/ioctl.h>
#include <sys/uio.h>
@@ -1153,9 +1154,9 @@ static int blk_connect(struct XenDevice *xendev)
}
xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
- " size %" PRId64 " (%" PRId64 " MB)\n",
+ " size %" PRId64 " (%llu MB)\n",
blkdev->type, blkdev->fileproto, blkdev->filename,
- blkdev->file_size, blkdev->file_size >> 20);
+ blkdev->file_size, blkdev->file_size / M_BYTE);
/* Fill in number of sector size and number of sectors */
xenstore_write_be_int(&blkdev->xendev, "sector-size", blkdev->file_blk);
diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c
index efa35dc6e0..068347495c 100644
--- a/hw/i386/xen/xen-mapcache.c
+++ b/hw/i386/xen/xen-mapcache.c
@@ -9,6 +9,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/error-report.h"
#include <sys/resource.h>
@@ -47,7 +48,7 @@
* From empirical tests I observed that qemu use 75MB more than the
* max_mcache_size.
*/
-#define NON_MCACHE_MEMORY_SIZE (80 * 1024 * 1024)
+#define NON_MCACHE_MEMORY_SIZE (80 * M_BYTE)
typedef struct MapCacheEntry {
hwaddr paddr_index;
diff --git a/hw/xenpv/xen_domainbuild.c b/hw/xenpv/xen_domainbuild.c
index 027f76fad1..4c77bb70a7 100644
--- a/hw/xenpv/xen_domainbuild.c
+++ b/hw/xenpv/xen_domainbuild.c
@@ -1,4 +1,5 @@
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/xen/xen_backend.h"
#include "xen_domainbuild.h"
#include "qemu/timer.h"
@@ -75,9 +76,9 @@ int xenstore_domain_init1(const char *kernel, const char *ramdisk,
xenstore_write_str(dom, "vm", vm);
/* memory */
- xenstore_write_int(dom, "memory/target", ram_size >> 10); // kB
- xenstore_write_int(vm, "memory", ram_size >> 20); // MB
- xenstore_write_int(vm, "maxmem", ram_size >> 20); // MB
+ xenstore_write_int(dom, "memory/target", ram_size / K_BYTE);
+ xenstore_write_int(vm, "memory", ram_size / M_BYTE);
+ xenstore_write_int(vm, "maxmem", ram_size / M_BYTE);
/* cpus */
for (i = 0; i < smp_cpus; i++) {
@@ -113,7 +114,7 @@ int xenstore_domain_init2(int xenstore_port, int xenstore_mfn,
/* console */
xenstore_write_str(dom, "console/type", "ioemu");
- xenstore_write_int(dom, "console/limit", 128 * 1024);
+ xenstore_write_int(dom, "console/limit", 128 * K_BYTE);
xenstore_write_int(dom, "console/ring-ref", console_mfn);
xenstore_write_int(dom, "console/port", console_port);
xen_config_dev_console(0);
@@ -260,7 +261,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
}
#endif
- rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size >> 10);
+ rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size / K_BYTE);
if (rc < 0) {
fprintf(stderr, "xen: xc_domain_setmaxmem() failed\n");
goto err;
@@ -269,7 +270,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
xenstore_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);
console_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);
- rc = xc_linux_build(xen_xc, xen_domid, ram_size >> 20,
+ rc = xc_linux_build(xen_xc, xen_domid, ram_size / M_BYTE,
kernel, ramdisk, cmdline,
0, flags,
xenstore_port, &xenstore_mfn,
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/hw/acpi/tpm.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/hw/acpi/tpm.h b/include/hw/acpi/tpm.h
index 46ac4dc581..5c72efe999 100644
--- a/include/hw/acpi/tpm.h
+++ b/include/hw/acpi/tpm.h
@@ -16,6 +16,7 @@
#ifndef HW_ACPI_TPM_H
#define HW_ACPI_TPM_H
+#include "qemu/units.h"
#include "hw/registerfields.h"
#define TPM_TIS_ADDR_BASE 0xFED40000
@@ -176,7 +177,7 @@ REG32(CRB_DATA_BUFFER, 0x80)
#define TPM_CRB_ADDR_CTRL (TPM_CRB_ADDR_BASE + A_CRB_CTRL_REQ)
#define TPM_CRB_R_MAX R_CRB_DATA_BUFFER
-#define TPM_LOG_AREA_MINIMUM_SIZE (64 * 1024)
+#define TPM_LOG_AREA_MINIMUM_SIZE (64 * K_BYTE)
#define TPM_TCPA_ACPI_CLASS_CLIENT 0
#define TPM_TCPA_ACPI_CLASS_SERVER 1
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/block/nvme.c | 3 ++-
hw/block/tc58128.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 811084b6a7..273d36de76 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -25,6 +25,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/block/block.h"
#include "hw/hw.h"
#include "hw/pci/msix.h"
@@ -648,7 +649,7 @@ static uint16_t nvme_identify_ns(NvmeCtrl *n, NvmeIdentify *c)
static uint16_t nvme_identify_nslist(NvmeCtrl *n, NvmeIdentify *c)
{
- static const int data_len = 4096;
+ static const int data_len = 4 * K_BYTE;
uint32_t min_nsid = le32_to_cpu(c->nsid);
uint64_t prp1 = le64_to_cpu(c->prp1);
uint64_t prp2 = le64_to_cpu(c->prp2);
diff --git a/hw/block/tc58128.c b/hw/block/tc58128.c
index 1d9f7ee000..42e1269546 100644
--- a/hw/block/tc58128.c
+++ b/hw/block/tc58128.c
@@ -1,4 +1,5 @@
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/hw.h"
#include "hw/sh4/sh.h"
#include "hw/loader.h"
@@ -26,7 +27,7 @@ typedef struct {
static tc58128_dev tc58128_devs[2];
-#define FLASH_SIZE (16*1024*1024)
+#define FLASH_SIZE (16 * M_BYTE)
static void init_dev(tc58128_dev * dev, const char *filename)
{
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/misc/auxbus.c | 3 ++-
hw/misc/edu.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/misc/auxbus.c b/hw/misc/auxbus.c
index b4cacd664b..0252c72654 100644
--- a/hw/misc/auxbus.c
+++ b/hw/misc/auxbus.c
@@ -27,6 +27,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/log.h"
#include "hw/misc/auxbus.h"
#include "hw/i2c/i2c.h"
@@ -68,7 +69,7 @@ AUXBus *aux_init_bus(DeviceState *parent, const char *name)
/* Memory related. */
bus->aux_io = g_malloc(sizeof(*bus->aux_io));
- memory_region_init(bus->aux_io, OBJECT(bus), "aux-io", (1 << 20));
+ memory_region_init(bus->aux_io, OBJECT(bus), "aux-io", 1 * M_BYTE);
address_space_init(&bus->aux_addr_space, bus->aux_io, "aux-io");
return bus;
}
diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index 34eb05d213..ceaa2e1679 100644
--- a/hw/misc/edu.c
+++ b/hw/misc/edu.c
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/pci/pci.h"
#include "hw/pci/msi.h"
#include "qemu/timer.h"
@@ -357,7 +358,7 @@ static void pci_edu_realize(PCIDevice *pdev, Error **errp)
edu, QEMU_THREAD_JOINABLE);
memory_region_init_io(&edu->mmio, OBJECT(edu), &edu_mmio_ops, edu,
- "edu-mmio", 1 << 20);
+ "edu-mmio", 1 * M_BYTE);
pci_register_bar(pdev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &edu->mmio);
}
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/riscv/virt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index e2c214e86a..eb465a0158 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/log.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
@@ -95,7 +96,7 @@ static hwaddr load_initrd(const char *filename, uint64_t mem_size,
* halfway into RAM, and for boards with 256MB of RAM or more we put
* the initrd at 128MB.
*/
- *start = kernel_entry + MIN(mem_size / 2, 128 * 1024 * 1024);
+ *start = kernel_entry + MIN(mem_size / 2, 128 * M_BYTE);
size = load_ramdisk(filename, *start, mem_size - *start);
if (size == -1) {
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/m68k/mcf5208.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c
index fac0d09cbc..673d65f8fd 100644
--- a/hw/m68k/mcf5208.c
+++ b/hw/m68k/mcf5208.c
@@ -6,6 +6,7 @@
* This code is licensed under the GPL
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "qemu-common.h"
@@ -241,7 +242,7 @@ static void mcf5208evb_init(MachineState *machine)
memory_region_add_subregion(address_space_mem, 0x40000000, ram);
/* Internal SRAM. */
- memory_region_init_ram(sram, NULL, "mcf5208.sram", 16384, &error_fatal);
+ memory_region_init_ram(sram, NULL, "mcf5208.sram", 16 * K_BYTE, &error_fatal);
memory_region_add_subregion(address_space_mem, 0x80000000, sram);
/* Internal peripherals. */
--
2.17.0
On 16.04.2018 01:42, Philippe Mathieu-Daudé wrote: > It eases code review, unit is explicit. > > Patch generated using: > > $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/ > > and modified manually. > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > hw/m68k/mcf5208.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c > index fac0d09cbc..673d65f8fd 100644 > --- a/hw/m68k/mcf5208.c > +++ b/hw/m68k/mcf5208.c > @@ -6,6 +6,7 @@ > * This code is licensed under the GPL > */ > #include "qemu/osdep.h" > +#include "qemu/units.h" > #include "qemu/error-report.h" > #include "qapi/error.h" > #include "qemu-common.h" > @@ -241,7 +242,7 @@ static void mcf5208evb_init(MachineState *machine) > memory_region_add_subregion(address_space_mem, 0x40000000, ram); > > /* Internal SRAM. */ > - memory_region_init_ram(sram, NULL, "mcf5208.sram", 16384, &error_fatal); > + memory_region_init_ram(sram, NULL, "mcf5208.sram", 16 * K_BYTE, &error_fatal); > memory_region_add_subregion(address_space_mem, 0x80000000, sram); > > /* Internal peripherals. */ > Reviewed-by: Thomas Huth <thuth@tuxfamily.org>
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/sparc/leon3.c | 9 +++++----
hw/sparc/sun4m.c | 9 ++++-----
hw/sparc64/niagara.c | 3 ++-
hw/sparc64/sun4u.c | 4 ++--
4 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index bba3aa3dee..97e13fab6d 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "qemu-common.h"
@@ -139,9 +140,9 @@ static void leon3_generic_hw_init(MachineState *machine)
env->qemu_irq_ack = leon3_irq_manager;
/* Allocate RAM */
- if ((uint64_t)ram_size > (1UL << 30)) {
- error_report("Too much memory for this machine: %d, maximum 1G",
- (unsigned int)(ram_size / (1024 * 1024)));
+ if (ram_size > 1 * G_BYTE) {
+ error_report("Too much memory for this machine: %lluMB, maximum 1G",
+ ram_size / M_BYTE);
exit(1);
}
@@ -149,7 +150,7 @@ static void leon3_generic_hw_init(MachineState *machine)
memory_region_add_subregion(address_space_mem, 0x40000000, ram);
/* Allocate BIOS */
- prom_size = 8 * 1024 * 1024; /* 8Mb */
+ prom_size = 8 * M_BYTE;
memory_region_init_ram(prom, NULL, "Leon3.bios", prom_size, &error_fatal);
memory_region_set_readonly(prom, true);
memory_region_add_subregion(address_space_mem, 0x00000000, prom);
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 6471aca25d..320122f1b5 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -45,7 +46,6 @@
#include "hw/loader.h"
#include "elf.h"
#include "trace.h"
-#include "qemu/cutils.h"
/*
* Sun4m architecture was used in the following machines:
@@ -66,7 +66,7 @@
#define KERNEL_LOAD_ADDR 0x00004000
#define CMDLINE_ADDR 0x007ff000
#define INITRD_LOAD_ADDR 0x00800000
-#define PROM_SIZE_MAX (1024 * 1024)
+#define PROM_SIZE_MAX (1 * M_BYTE)
#define PROM_VADDR 0xffd00000
#define PROM_FILENAME "openbios-sparc32"
#define CFG_ADDR 0xd00000510ULL
@@ -741,9 +741,8 @@ static void ram_init(hwaddr addr, ram_addr_t RAM_size,
/* allocate RAM */
if ((uint64_t)RAM_size > max_mem) {
- error_report("Too much memory for this machine: %d, maximum %d",
- (unsigned int)(RAM_size / (1024 * 1024)),
- (unsigned int)(max_mem / (1024 * 1024)));
+ error_report("Too much memory for this machine: %llu, maximum %llu",
+ RAM_size / M_BYTE, max_mem / M_BYTE);
exit(1);
}
dev = qdev_create(NULL, "memory");
diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
index 1874477ef6..957d98ef83 100644
--- a/hw/sparc64/niagara.c
+++ b/hw/sparc64/niagara.c
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu-common.h"
#include "cpu.h"
#include "hw/hw.h"
@@ -84,7 +85,7 @@ typedef struct NiagaraBoardState {
#define NIAGARA_PROM_BASE 0xfff0000000ULL
#define NIAGARA_Q_OFFSET 0x10000ULL
#define NIAGARA_OBP_OFFSET 0x80000ULL
-#define PROM_SIZE_MAX (4 * 1024 * 1024)
+#define PROM_SIZE_MAX (4 * M_BYTE)
static void add_rom_or_fail(const char *file, const hwaddr addr)
{
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 2044a52ded..f424f362ac 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "qemu-common.h"
@@ -52,11 +53,10 @@
#include "hw/loader.h"
#include "elf.h"
#include "trace.h"
-#include "qemu/cutils.h"
#define KERNEL_LOAD_ADDR 0x00404000
#define CMDLINE_ADDR 0x003ff000
-#define PROM_SIZE_MAX (4 * 1024 * 1024)
+#define PROM_SIZE_MAX (4 * M_BYTE)
#define PROM_VADDR 0x000ffd00000ULL
#define PBM_SPECIAL_BASE 0x1fe00000000ULL
#define PBM_MEM_BASE 0x1ff00000000ULL
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
---
hw/s390x/s390-skeys.c | 3 ++-
hw/s390x/s390-stattrib.c | 3 ++-
hw/s390x/sclp.c | 5 +++--
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c
index 76241c240e..a95373af94 100644
--- a/hw/s390x/s390-skeys.c
+++ b/hw/s390x/s390-skeys.c
@@ -10,6 +10,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/boards.h"
#include "hw/s390x/storage-keys.h"
#include "qapi/error.h"
@@ -19,7 +20,7 @@
#include "sysemu/kvm.h"
#include "migration/register.h"
-#define S390_SKEYS_BUFFER_SIZE 131072 /* Room for 128k storage keys */
+#define S390_SKEYS_BUFFER_SIZE (128 * K_BYTE) /* Room for 128k storage keys */
#define S390_SKEYS_SAVE_FLAG_EOS 0x01
#define S390_SKEYS_SAVE_FLAG_SKEYS 0x02
#define S390_SKEYS_SAVE_FLAG_ERROR 0x04
diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c
index 70b95550a8..7a4a4e61d3 100644
--- a/hw/s390x/s390-stattrib.c
+++ b/hw/s390x/s390-stattrib.c
@@ -10,6 +10,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/boards.h"
#include "cpu.h"
#include "migration/qemu-file.h"
@@ -20,7 +21,7 @@
#include "qapi/error.h"
#include "qapi/qmp/qdict.h"
-#define CMMA_BLOCK_SIZE (1 << 10)
+#define CMMA_BLOCK_SIZE (1 * K_BYTE)
#define STATTR_FLAG_EOS 0x01ULL
#define STATTR_FLAG_MORE 0x02ULL
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index 047d577313..4cd6548d49 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -13,6 +13,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "cpu.h"
#include "sysemu/sysemu.h"
@@ -288,8 +289,8 @@ static void sclp_realize(DeviceState *dev, Error **errp)
ret = s390_set_memory_limit(machine->maxram_size, &hw_limit);
if (ret == -E2BIG) {
- error_setg(&err, "host supports a maximum of %" PRIu64 " GB",
- hw_limit >> 30);
+ error_setg(&err, "host supports a maximum of %llu GB",
+ hw_limit / G_BYTE);
} else if (ret) {
error_setg(&err, "setting the guest size failed");
}
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/hppa/dino.c | 3 ++-
hw/hppa/machine.c | 10 +++++-----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index 15aefde09c..31d69ae61b 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -11,6 +11,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "cpu.h"
#include "hw/hw.h"
@@ -76,7 +77,7 @@
/* #define xxx 0x200 - bit 9 not used */
#define RS232INT 0x400
-#define DINO_MEM_CHUNK_SIZE (8 * 1024 * 1024) /* 8MB */
+#define DINO_MEM_CHUNK_SIZE (8 * M_BYTE)
#define DINO_PCI_HOST_BRIDGE(obj) \
OBJECT_CHECK(DinoState, (obj), TYPE_DINO_PCI_HOST_BRIDGE)
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 19033e268d..87dbb77987 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -17,7 +17,7 @@
#include "hw/timer/i8254.h"
#include "hw/char/serial.h"
#include "hw/hppa/hppa_sys.h"
-#include "qemu/cutils.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu/log.h"
@@ -178,8 +178,8 @@ static void machine_hppa_init(MachineState *machine)
}
qemu_log_mask(CPU_LOG_PAGE, "Kernel loaded at 0x%08" PRIx64
"-0x%08" PRIx64 ", entry at 0x%08" PRIx64
- ", size %ld kB.\n",
- kernel_low, kernel_high, kernel_entry, size / 1024);
+ ", size %llu kB\n",
+ kernel_low, kernel_high, kernel_entry, size / K_BYTE);
if (kernel_cmdline) {
cpu[0]->env.gr[24] = 0x4000;
@@ -203,8 +203,8 @@ static void machine_hppa_init(MachineState *machine)
(1) Due to sign-extension problems and PDC,
put the initrd no higher than 1G.
(2) Reserve 64k for stack. */
- initrd_base = MIN(ram_size, 1024 * 1024 * 1024);
- initrd_base = initrd_base - 64 * 1024;
+ initrd_base = MIN(ram_size, 1 * G_BYTE);
+ initrd_base = initrd_base - 64 * K_BYTE;
initrd_base = (initrd_base - initrd_size) & TARGET_PAGE_MASK;
if (initrd_base < kernel_high) {
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
---
hw/xtensa/xtfpga.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index 70686a2eb1..2d1cce1d31 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -26,6 +26,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "cpu.h"
#include "sysemu/sysemu.h"
@@ -153,7 +154,7 @@ static void xtfpga_net_init(MemoryRegion *address_space,
sysbus_mmio_get_region(s, 1));
ram = g_malloc(sizeof(*ram));
- memory_region_init_ram_nomigrate(ram, OBJECT(s), "open_eth.ram", 16384,
+ memory_region_init_ram_nomigrate(ram, OBJECT(s), "open_eth.ram", 16 * K_BYTE,
&error_fatal);
vmstate_register_ram_global(ram);
memory_region_add_subregion(address_space, buffers, ram);
@@ -230,7 +231,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
const char *kernel_cmdline = qemu_opt_get(machine_opts, "append");
const char *dtb_filename = qemu_opt_get(machine_opts, "dtb");
const char *initrd_filename = qemu_opt_get(machine_opts, "initrd");
- const unsigned system_io_size = 224 * 1024 * 1024;
+ const unsigned system_io_size = 224 * M_BYTE;
int n;
for (n = 0; n < smp_cpus; n++) {
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/alpha/typhoon.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c
index 6a40869488..85fe072063 100644
--- a/hw/alpha/typhoon.c
+++ b/hw/alpha/typhoon.c
@@ -7,6 +7,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "cpu.h"
#include "hw/hw.h"
@@ -812,8 +813,6 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
qemu_irq *p_rtc_irq,
AlphaCPU *cpus[4], pci_map_irq_fn sys_map_irq)
{
- const uint64_t MB = 1024 * 1024;
- const uint64_t GB = 1024 * MB;
MemoryRegion *addr_space = get_system_memory();
DeviceState *dev;
TyphoonState *s;
@@ -854,30 +853,30 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
/* Pchip0 CSRs, 0x801.8000.0000, 256MB. */
memory_region_init_io(&s->pchip.region, OBJECT(s), &pchip_ops, s, "pchip0",
- 256*MB);
+ 256 * M_BYTE);
memory_region_add_subregion(addr_space, 0x80180000000ULL,
&s->pchip.region);
/* Cchip CSRs, 0x801.A000.0000, 256MB. */
memory_region_init_io(&s->cchip.region, OBJECT(s), &cchip_ops, s, "cchip0",
- 256*MB);
+ 256 * M_BYTE);
memory_region_add_subregion(addr_space, 0x801a0000000ULL,
&s->cchip.region);
/* Dchip CSRs, 0x801.B000.0000, 256MB. */
memory_region_init_io(&s->dchip_region, OBJECT(s), &dchip_ops, s, "dchip0",
- 256*MB);
+ 256 * M_BYTE);
memory_region_add_subregion(addr_space, 0x801b0000000ULL,
&s->dchip_region);
/* Pchip0 PCI memory, 0x800.0000.0000, 4GB. */
- memory_region_init(&s->pchip.reg_mem, OBJECT(s), "pci0-mem", 4*GB);
+ memory_region_init(&s->pchip.reg_mem, OBJECT(s), "pci0-mem", 4 * G_BYTE);
memory_region_add_subregion(addr_space, 0x80000000000ULL,
&s->pchip.reg_mem);
/* Pchip0 PCI I/O, 0x801.FC00.0000, 32MB. */
memory_region_init_io(&s->pchip.reg_io, OBJECT(s), &alpha_pci_ignore_ops,
- NULL, "pci0-io", 32*MB);
+ NULL, "pci0-io", 32 * M_BYTE);
memory_region_add_subregion(addr_space, 0x801fc000000ULL,
&s->pchip.reg_io);
@@ -898,13 +897,13 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
/* Pchip0 PCI special/interrupt acknowledge, 0x801.F800.0000, 64MB. */
memory_region_init_io(&s->pchip.reg_iack, OBJECT(s), &alpha_pci_iack_ops,
- b, "pci0-iack", 64*MB);
+ b, "pci0-iack", 64 * M_BYTE);
memory_region_add_subregion(addr_space, 0x801f8000000ULL,
&s->pchip.reg_iack);
/* Pchip0 PCI configuration, 0x801.FE00.0000, 16MB. */
memory_region_init_io(&s->pchip.reg_conf, OBJECT(s), &alpha_pci_conf1_ops,
- b, "pci0-conf", 16*MB);
+ b, "pci0-conf", 16 * M_BYTE);
memory_region_add_subregion(addr_space, 0x801fe000000ULL,
&s->pchip.reg_conf);
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
---
hw/tricore/tricore_testboard.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/hw/tricore/tricore_testboard.c b/hw/tricore/tricore_testboard.c
index 8e61dfc3e6..a30a2f8345 100644
--- a/hw/tricore/tricore_testboard.c
+++ b/hw/tricore/tricore_testboard.c
@@ -19,6 +19,7 @@
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -72,17 +73,17 @@ static void tricore_testboard_init(MachineState *machine, int board_id)
cpu = TRICORE_CPU(cpu_create(machine->cpu_type));
env = &cpu->env;
memory_region_init_ram(ext_cram, NULL, "powerlink_ext_c.ram",
- 2 * 1024 * 1024, &error_fatal);
+ 2 * M_BYTE, &error_fatal);
memory_region_init_ram(ext_dram, NULL, "powerlink_ext_d.ram",
- 4 * 1024 * 1024, &error_fatal);
- memory_region_init_ram(int_cram, NULL, "powerlink_int_c.ram", 48 * 1024,
+ 4 * M_BYTE, &error_fatal);
+ memory_region_init_ram(int_cram, NULL, "powerlink_int_c.ram", 48 * K_BYTE,
&error_fatal);
- memory_region_init_ram(int_dram, NULL, "powerlink_int_d.ram", 48 * 1024,
+ memory_region_init_ram(int_dram, NULL, "powerlink_int_d.ram", 48 * K_BYTE,
&error_fatal);
memory_region_init_ram(pcp_data, NULL, "powerlink_pcp_data.ram",
- 16 * 1024, &error_fatal);
+ 16 * K_BYTE, &error_fatal);
memory_region_init_ram(pcp_text, NULL, "powerlink_pcp_text.ram",
- 32 * 1024, &error_fatal);
+ 32 * K_BYTE, &error_fatal);
memory_region_add_subregion(sysmem, 0x80000000, ext_cram);
memory_region_add_subregion(sysmem, 0xa1000000, ext_dram);
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/microblaze/petalogix_ml605_mmu.c | 7 ++++---
hw/microblaze/petalogix_s3adsp1800_mmu.c | 7 ++++---
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
index b664dc0f9c..5c4fe2345c 100644
--- a/hw/microblaze/petalogix_ml605_mmu.c
+++ b/hw/microblaze/petalogix_ml605_mmu.c
@@ -26,6 +26,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -45,8 +46,8 @@
#include "hw/stream.h"
-#define LMB_BRAM_SIZE (128 * 1024)
-#define FLASH_SIZE (32 * 1024 * 1024)
+#define LMB_BRAM_SIZE (128 * K_BYTE)
+#define FLASH_SIZE (32 * M_BYTE)
#define BINARY_DEVICE_TREE_FILE "petalogix-ml605.dtb"
@@ -110,7 +111,7 @@ petalogix_ml605_init(MachineState *machine)
pflash_cfi01_register(FLASH_BASEADDR,
NULL, "petalogix_ml605.flash", FLASH_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
- (64 * 1024), FLASH_SIZE >> 16,
+ 64 * K_BYTE, FLASH_SIZE >> 16,
2, 0x89, 0x18, 0x0000, 0x0, 0);
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
index 5cb4deb69e..32e73a589f 100644
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
@@ -24,6 +24,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -40,8 +41,8 @@
#include "boot.h"
-#define LMB_BRAM_SIZE (128 * 1024)
-#define FLASH_SIZE (16 * 1024 * 1024)
+#define LMB_BRAM_SIZE (128 * K_BYTE)
+#define FLASH_SIZE (16 * M_BYTE)
#define BINARY_DEVICE_TREE_FILE "petalogix-s3adsp1800.dtb"
@@ -88,7 +89,7 @@ petalogix_s3adsp1800_init(MachineState *machine)
pflash_cfi01_register(FLASH_BASEADDR,
NULL, "petalogix_s3adsp1800.flash", FLASH_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
- (64 * 1024), FLASH_SIZE >> 16,
+ 64 * K_BYTE, FLASH_SIZE >> 16,
1, 0x89, 0x18, 0x0000, 0x0, 1);
dev = qdev_create(NULL, "xlnx.xps-intc");
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/nios2/boot.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c
index 94f436e7fb..1cc924805b 100644
--- a/hw/nios2/boot.c
+++ b/hw/nios2/boot.c
@@ -29,6 +29,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu-common.h"
#include "cpu.h"
#include "qemu/option.h"
@@ -38,7 +39,6 @@
#include "sysemu/sysemu.h"
#include "hw/loader.h"
#include "elf.h"
-#include "qemu/cutils.h"
#include "boot.h"
@@ -177,7 +177,7 @@ void nios2_load_kernel(Nios2CPU *cpu, hwaddr ddr_base,
high = ddr_base + kernel_size;
}
- high = ROUND_UP(high, 1024 * 1024);
+ high = ROUND_UP(high, 1 * M_BYTE);
/* If initrd is available, it goes after the kernel, aligned to 1M. */
if (initrd_filename) {
@@ -213,7 +213,7 @@ void nios2_load_kernel(Nios2CPU *cpu, hwaddr ddr_base,
high += fdt_size;
/* Kernel command is at the end, 4k aligned. */
- boot_info.cmdline = ROUND_UP(high, 4096);
+ boot_info.cmdline = ROUND_UP(high, 4 * K_BYTE);
if (kernel_cmdline && strlen(kernel_cmdline)) {
pstrcpy_targphys("cmdline", boot_info.cmdline, 256, kernel_cmdline);
}
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/cris/axis_dev88.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/cris/axis_dev88.c b/hw/cris/axis_dev88.c
index 1775e53e25..a0f83f53d2 100644
--- a/hw/cris/axis_dev88.c
+++ b/hw/cris/axis_dev88.c
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -242,7 +243,7 @@ static const MemoryRegionOps gpio_ops = {
},
};
-#define INTMEM_SIZE (128 * 1024)
+#define INTMEM_SIZE (128 * K_BYTE)
static struct cris_load_info li;
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/lm32/lm32_boards.c | 13 +++++++------
hw/lm32/milkymist.c | 10 +++++-----
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/hw/lm32/lm32_boards.c b/hw/lm32/lm32_boards.c
index 527bcc229c..ef229dd315 100644
--- a/hw/lm32/lm32_boards.c
+++ b/hw/lm32/lm32_boards.c
@@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/error-report.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -88,10 +89,10 @@ static void lm32_evr_init(MachineState *machine)
/* memory map */
hwaddr flash_base = 0x04000000;
- size_t flash_sector_size = 256 * 1024;
- size_t flash_size = 32 * 1024 * 1024;
+ size_t flash_sector_size = 256 * K_BYTE;
+ size_t flash_size = 32 * M_BYTE;
hwaddr ram_base = 0x08000000;
- size_t ram_size = 64 * 1024 * 1024;
+ size_t ram_size = 64 * M_BYTE;
hwaddr timer0_base = 0x80002000;
hwaddr uart0_base = 0x80006000;
hwaddr timer1_base = 0x8000a000;
@@ -174,10 +175,10 @@ static void lm32_uclinux_init(MachineState *machine)
/* memory map */
hwaddr flash_base = 0x04000000;
- size_t flash_sector_size = 256 * 1024;
- size_t flash_size = 32 * 1024 * 1024;
+ size_t flash_sector_size = 256 * K_BYTE;
+ size_t flash_size = 32 * M_BYTE;
hwaddr ram_base = 0x08000000;
- size_t ram_size = 64 * 1024 * 1024;
+ size_t ram_size = 64 * M_BYTE;
hwaddr uart0_base = 0x80000000;
hwaddr timer0_base = 0x80002000;
hwaddr timer1_base = 0x80010000;
diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c
index 85d64fe58d..f530997abb 100644
--- a/hw/lm32/milkymist.c
+++ b/hw/lm32/milkymist.c
@@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/error-report.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -34,11 +35,10 @@
#include "milkymist-hw.h"
#include "lm32.h"
#include "exec/address-spaces.h"
-#include "qemu/cutils.h"
#define BIOS_FILENAME "mmone-bios.bin"
#define BIOS_OFFSET 0x00860000
-#define BIOS_SIZE (512*1024)
+#define BIOS_SIZE (512 * K_BYTE)
#define KERNEL_LOAD_ADDR 0x40000000
typedef struct {
@@ -97,10 +97,10 @@ milkymist_init(MachineState *machine)
/* memory map */
hwaddr flash_base = 0x00000000;
- size_t flash_sector_size = 128 * 1024;
- size_t flash_size = 32 * 1024 * 1024;
+ size_t flash_sector_size = 128 * K_BYTE;
+ size_t flash_size = 32 * M_BYTE;
hwaddr sdram_base = 0x40000000;
- size_t sdram_size = 128 * 1024 * 1024;
+ size_t sdram_size = 128 * M_BYTE;
hwaddr initrd_base = sdram_base + 0x1002000;
hwaddr cmdline_base = sdram_base + 0x1000000;
--
2.17.0
Am 2018-04-16 01:42, schrieb Philippe Mathieu-Daudé: > It eases code review, unit is explicit. > > Patch generated using: > > $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ > include/hw/ > > and modified manually. > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Acked-by: Michael Walle <michael@walle.cc>
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/sh4/r2d.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index f5f3deab37..e488fd49b1 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -24,6 +24,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -291,7 +292,7 @@ static void r2d_init(MachineState *machine)
dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi02_register(0x0, NULL, "r2d.flash", FLASH_SIZE,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
- (16 * 1024), FLASH_SIZE >> 16,
+ 16 * K_BYTE, FLASH_SIZE >> 16,
1, 4, 0x0000, 0x0000, 0x0000, 0x0000,
0x555, 0x2aa, 0);
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/intc/mips_gic.h | 3 ++-
include/hw/mips/bios.h | 3 ++-
hw/mips/boston.c | 4 ++--
hw/mips/mips_fulong2e.c | 7 ++++---
hw/mips/mips_malta.c | 23 +++++++++++++----------
hw/mips/mips_r4k.c | 11 ++++++-----
hw/misc/mips_itu.c | 3 ++-
hw/pci-host/xilinx-pcie.c | 5 +++--
8 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/include/hw/intc/mips_gic.h b/include/hw/intc/mips_gic.h
index b98d50094a..c0da44bdb3 100644
--- a/include/hw/intc/mips_gic.h
+++ b/include/hw/intc/mips_gic.h
@@ -11,6 +11,7 @@
#ifndef MIPS_GIC_H
#define MIPS_GIC_H
+#include "qemu/units.h"
#include "hw/timer/mips_gictimer.h"
#include "cpu.h"
/*
@@ -19,7 +20,7 @@
/* The MIPS default location */
#define GIC_BASE_ADDR 0x1bdc0000ULL
-#define GIC_ADDRSPACE_SZ (128 * 1024)
+#define GIC_ADDRSPACE_SZ (128 * K_BYTE)
/* Constants */
#define GIC_POL_POS 1
diff --git a/include/hw/mips/bios.h b/include/hw/mips/bios.h
index b4b88ac43d..b4c97ce87c 100644
--- a/include/hw/mips/bios.h
+++ b/include/hw/mips/bios.h
@@ -1,6 +1,7 @@
+#include "qemu/units.h"
#include "cpu.h"
-#define BIOS_SIZE (4 * 1024 * 1024)
+#define BIOS_SIZE (4 * M_BYTE)
#ifdef TARGET_WORDS_BIGENDIAN
#define BIOS_FILENAME "mips_bios.bin"
#else
diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index fb23161b33..edc39e91f7 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -32,7 +32,7 @@
#include "hw/mips/cpudevs.h"
#include "hw/pci-host/xilinx-pcie.h"
#include "qapi/error.h"
-#include "qemu/cutils.h"
+#include "qemu/units.h"
#include "qemu/error-report.h"
#include "qemu/log.h"
#include "chardev/char.h"
@@ -437,7 +437,7 @@ static void boston_mach_init(MachineState *machine)
bool is_64b;
if ((machine->ram_size % G_BYTE) ||
- (machine->ram_size > (2 * G_BYTE))) {
+ (machine->ram_size > 2 * G_BYTE)) {
error_report("Memory size must be 1GB or 2GB");
exit(1);
}
diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
index 02fb2fdcc4..779883db7c 100644
--- a/hw/mips/mips_fulong2e.c
+++ b/hw/mips/mips_fulong2e.c
@@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "hw/hw.h"
#include "hw/i386/pc.h"
@@ -159,7 +160,7 @@ static int64_t load_kernel (CPUMIPSState *env)
/* Setup minimum environment variables */
prom_set(prom_buf, index++, "busclock=33000000");
prom_set(prom_buf, index++, "cpuclock=100000000");
- prom_set(prom_buf, index++, "memsize=%i", loaderparams.ram_size/1024/1024);
+ prom_set(prom_buf, index++, "memsize=%llu", loaderparams.ram_size / M_BYTE);
prom_set(prom_buf, index++, "modetty0=38400n8r");
prom_set(prom_buf, index++, NULL);
@@ -303,10 +304,10 @@ static void mips_fulong2e_init(MachineState *machine)
qemu_register_reset(main_cpu_reset, cpu);
/* fulong 2e has 256M ram. */
- ram_size = 256 * 1024 * 1024;
+ ram_size = 256 * M_BYTE;
/* fulong 2e has a 1M flash.Winbond W39L040AP70Z */
- bios_size = 1024 * 1024;
+ bios_size = 1 * M_BYTE;
/* allocate RAM */
memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram", ram_size);
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index f6513a4fd5..240dd762be 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu-common.h"
#include "cpu.h"
#include "hw/hw.h"
@@ -844,7 +845,8 @@ static int64_t load_kernel (void)
/* The kernel allocates the bootmap memory in the low memory after
the initrd. It takes at most 128kiB for 2GB RAM and 4kiB
pages. */
- initrd_offset = (loaderparams.ram_low_size - initrd_size - 131072
+ initrd_offset = (loaderparams.ram_low_size - initrd_size
+ - (128 * K_BYTE)
- ~INITRD_PAGE_MASK) & INITRD_PAGE_MASK;
if (kernel_high >= initrd_offset) {
error_report("memory too small for initial ram disk '%s'",
@@ -1022,9 +1024,9 @@ void mips_malta_init(MachineState *machine)
mips_create_cpu(s, machine->cpu_type, &cbus_irq, &i8259_irq);
/* allocate RAM */
- if (ram_size > (2048u << 20)) {
- error_report("Too much memory for this machine: %dMB, maximum 2048MB",
- ((unsigned int)ram_size / (1 << 20)));
+ if (ram_size > 2 * G_BYTE) {
+ error_report("Too much memory for this machine: %lluMB, maximum 2048MB",
+ ram_size / M_BYTE);
exit(1);
}
@@ -1035,17 +1037,18 @@ void mips_malta_init(MachineState *machine)
/* alias for pre IO hole access */
memory_region_init_alias(ram_low_preio, NULL, "mips_malta_low_preio.ram",
- ram_high, 0, MIN(ram_size, (256 << 20)));
+ ram_high, 0, MIN(ram_size, 256 * M_BYTE));
memory_region_add_subregion(system_memory, 0, ram_low_preio);
/* alias for post IO hole access, if there is enough RAM */
- if (ram_size > (512 << 20)) {
+ if (ram_size > 512 * M_BYTE) {
ram_low_postio = g_new(MemoryRegion, 1);
memory_region_init_alias(ram_low_postio, NULL,
"mips_malta_low_postio.ram",
- ram_high, 512 << 20,
- ram_size - (512 << 20));
- memory_region_add_subregion(system_memory, 512 << 20, ram_low_postio);
+ ram_high, 512 * M_BYTE,
+ ram_size - 512 * M_BYTE);
+ memory_region_add_subregion(system_memory, 512 * M_BYTE,
+ ram_low_postio);
}
#ifdef TARGET_WORDS_BIGENDIAN
@@ -1082,7 +1085,7 @@ void mips_malta_init(MachineState *machine)
bios = pflash_cfi01_get_memory(fl);
fl_idx++;
if (kernel_filename) {
- ram_low_size = MIN(ram_size, 256 << 20);
+ ram_low_size = MIN(ram_size, 256 * M_BYTE);
/* For KVM we reserve 1MB of RAM for running bootloader */
if (kvm_enabled()) {
ram_low_size -= 0x100000;
diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
index c26a44da06..2a848bc1c2 100644
--- a/hw/mips/mips_r4k.c
+++ b/hw/mips/mips_r4k.c
@@ -8,6 +8,7 @@
* the standard PC ISA addresses.
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -144,7 +145,7 @@ static int64_t load_kernel(void)
}
rom_add_blob_fixed("params", params_buf, params_size,
- (16 << 20) - params_size);
+ 16 * M_BYTE - params_size);
g_free(params_buf);
return entry;
@@ -159,7 +160,7 @@ static void main_cpu_reset(void *opaque)
env->active_tc.PC = s->vector;
}
-static const int sector_len = 32 * 1024;
+static const int sector_len = 32 * K_BYTE;
static
void mips_r4k_init(MachineState *machine)
{
@@ -195,9 +196,9 @@ void mips_r4k_init(MachineState *machine)
qemu_register_reset(main_cpu_reset, reset_info);
/* allocate RAM */
- if (ram_size > (256 << 20)) {
- error_report("Too much memory for this machine: %dMB, maximum 256MB",
- ((unsigned int)ram_size / (1 << 20)));
+ if (ram_size > 256 * M_BYTE) {
+ error_report("Too much memory for this machine: %lluMB, maximum 256MB",
+ ram_size / M_BYTE);
exit(1);
}
memory_region_allocate_system_memory(ram, NULL, "mips_r4k.ram", ram_size);
diff --git a/hw/misc/mips_itu.c b/hw/misc/mips_itu.c
index ccc4c7d98a..e40d472108 100644
--- a/hw/misc/mips_itu.c
+++ b/hw/misc/mips_itu.c
@@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/log.h"
#include "qapi/error.h"
#include "cpu.h"
@@ -80,7 +81,7 @@ static void itc_reconfigure(MIPSITUState *tag)
uint64_t *am = &tag->ITCAddressMap[0];
MemoryRegion *mr = &tag->storage_io;
hwaddr address = am[0] & ITC_AM0_BASE_ADDRESS_MASK;
- uint64_t size = (1 << 10) + (am[1] & ITC_AM1_ADDR_MASK_MASK);
+ uint64_t size = (1 * K_BYTE) + (am[1] & ITC_AM1_ADDR_MASK_MASK);
bool is_enabled = (am[0] & ITC_AM0_EN_MASK) != 0;
memory_region_transaction_begin();
diff --git a/hw/pci-host/xilinx-pcie.c b/hw/pci-host/xilinx-pcie.c
index 044e312dc1..6758669ce9 100644
--- a/hw/pci-host/xilinx-pcie.c
+++ b/hw/pci-host/xilinx-pcie.c
@@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "hw/pci/pci_bridge.h"
#include "hw/pci-host/xilinx-pcie.h"
@@ -158,9 +159,9 @@ static void xilinx_pcie_host_init(Object *obj)
static Property xilinx_pcie_host_props[] = {
DEFINE_PROP_UINT32("bus_nr", XilinxPCIEHost, bus_nr, 0),
DEFINE_PROP_SIZE("cfg_base", XilinxPCIEHost, cfg_base, 0),
- DEFINE_PROP_SIZE("cfg_size", XilinxPCIEHost, cfg_size, 32 << 20),
+ DEFINE_PROP_SIZE("cfg_size", XilinxPCIEHost, cfg_size, 32 * M_BYTE),
DEFINE_PROP_SIZE("mmio_base", XilinxPCIEHost, mmio_base, 0),
- DEFINE_PROP_SIZE("mmio_size", XilinxPCIEHost, mmio_size, 1 << 20),
+ DEFINE_PROP_SIZE("mmio_size", XilinxPCIEHost, mmio_size, 1 * M_BYTE),
DEFINE_PROP_BOOL("link_up", XilinxPCIEHost, link_up, true),
DEFINE_PROP_END_OF_LIST(),
};
--
2.17.0
On Sun, Apr 15, 2018 at 4:42 PM, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote: > It eases code review, unit is explicit. > > Patch generated using: > > $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/ > > and modified manually. > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Alistair > --- > include/hw/intc/mips_gic.h | 3 ++- > include/hw/mips/bios.h | 3 ++- > hw/mips/boston.c | 4 ++-- > hw/mips/mips_fulong2e.c | 7 ++++--- > hw/mips/mips_malta.c | 23 +++++++++++++---------- > hw/mips/mips_r4k.c | 11 ++++++----- > hw/misc/mips_itu.c | 3 ++- > hw/pci-host/xilinx-pcie.c | 5 +++-- > 8 files changed, 34 insertions(+), 25 deletions(-) > > diff --git a/include/hw/intc/mips_gic.h b/include/hw/intc/mips_gic.h > index b98d50094a..c0da44bdb3 100644 > --- a/include/hw/intc/mips_gic.h > +++ b/include/hw/intc/mips_gic.h > @@ -11,6 +11,7 @@ > #ifndef MIPS_GIC_H > #define MIPS_GIC_H > > +#include "qemu/units.h" > #include "hw/timer/mips_gictimer.h" > #include "cpu.h" > /* > @@ -19,7 +20,7 @@ > > /* The MIPS default location */ > #define GIC_BASE_ADDR 0x1bdc0000ULL > -#define GIC_ADDRSPACE_SZ (128 * 1024) > +#define GIC_ADDRSPACE_SZ (128 * K_BYTE) > > /* Constants */ > #define GIC_POL_POS 1 > diff --git a/include/hw/mips/bios.h b/include/hw/mips/bios.h > index b4b88ac43d..b4c97ce87c 100644 > --- a/include/hw/mips/bios.h > +++ b/include/hw/mips/bios.h > @@ -1,6 +1,7 @@ > +#include "qemu/units.h" > #include "cpu.h" > > -#define BIOS_SIZE (4 * 1024 * 1024) > +#define BIOS_SIZE (4 * M_BYTE) > #ifdef TARGET_WORDS_BIGENDIAN > #define BIOS_FILENAME "mips_bios.bin" > #else > diff --git a/hw/mips/boston.c b/hw/mips/boston.c > index fb23161b33..edc39e91f7 100644 > --- a/hw/mips/boston.c > +++ b/hw/mips/boston.c > @@ -32,7 +32,7 @@ > #include "hw/mips/cpudevs.h" > #include "hw/pci-host/xilinx-pcie.h" > #include "qapi/error.h" > -#include "qemu/cutils.h" > +#include "qemu/units.h" > #include "qemu/error-report.h" > #include "qemu/log.h" > #include "chardev/char.h" > @@ -437,7 +437,7 @@ static void boston_mach_init(MachineState *machine) > bool is_64b; > > if ((machine->ram_size % G_BYTE) || > - (machine->ram_size > (2 * G_BYTE))) { > + (machine->ram_size > 2 * G_BYTE)) { > error_report("Memory size must be 1GB or 2GB"); > exit(1); > } > diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c > index 02fb2fdcc4..779883db7c 100644 > --- a/hw/mips/mips_fulong2e.c > +++ b/hw/mips/mips_fulong2e.c > @@ -19,6 +19,7 @@ > */ > > #include "qemu/osdep.h" > +#include "qemu/units.h" > #include "qapi/error.h" > #include "hw/hw.h" > #include "hw/i386/pc.h" > @@ -159,7 +160,7 @@ static int64_t load_kernel (CPUMIPSState *env) > /* Setup minimum environment variables */ > prom_set(prom_buf, index++, "busclock=33000000"); > prom_set(prom_buf, index++, "cpuclock=100000000"); > - prom_set(prom_buf, index++, "memsize=%i", loaderparams.ram_size/1024/1024); > + prom_set(prom_buf, index++, "memsize=%llu", loaderparams.ram_size / M_BYTE); > prom_set(prom_buf, index++, "modetty0=38400n8r"); > prom_set(prom_buf, index++, NULL); > > @@ -303,10 +304,10 @@ static void mips_fulong2e_init(MachineState *machine) > qemu_register_reset(main_cpu_reset, cpu); > > /* fulong 2e has 256M ram. */ > - ram_size = 256 * 1024 * 1024; > + ram_size = 256 * M_BYTE; > > /* fulong 2e has a 1M flash.Winbond W39L040AP70Z */ > - bios_size = 1024 * 1024; > + bios_size = 1 * M_BYTE; > > /* allocate RAM */ > memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram", ram_size); > diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c > index f6513a4fd5..240dd762be 100644 > --- a/hw/mips/mips_malta.c > +++ b/hw/mips/mips_malta.c > @@ -23,6 +23,7 @@ > */ > > #include "qemu/osdep.h" > +#include "qemu/units.h" > #include "qemu-common.h" > #include "cpu.h" > #include "hw/hw.h" > @@ -844,7 +845,8 @@ static int64_t load_kernel (void) > /* The kernel allocates the bootmap memory in the low memory after > the initrd. It takes at most 128kiB for 2GB RAM and 4kiB > pages. */ > - initrd_offset = (loaderparams.ram_low_size - initrd_size - 131072 > + initrd_offset = (loaderparams.ram_low_size - initrd_size > + - (128 * K_BYTE) > - ~INITRD_PAGE_MASK) & INITRD_PAGE_MASK; > if (kernel_high >= initrd_offset) { > error_report("memory too small for initial ram disk '%s'", > @@ -1022,9 +1024,9 @@ void mips_malta_init(MachineState *machine) > mips_create_cpu(s, machine->cpu_type, &cbus_irq, &i8259_irq); > > /* allocate RAM */ > - if (ram_size > (2048u << 20)) { > - error_report("Too much memory for this machine: %dMB, maximum 2048MB", > - ((unsigned int)ram_size / (1 << 20))); > + if (ram_size > 2 * G_BYTE) { > + error_report("Too much memory for this machine: %lluMB, maximum 2048MB", > + ram_size / M_BYTE); > exit(1); > } > > @@ -1035,17 +1037,18 @@ void mips_malta_init(MachineState *machine) > > /* alias for pre IO hole access */ > memory_region_init_alias(ram_low_preio, NULL, "mips_malta_low_preio.ram", > - ram_high, 0, MIN(ram_size, (256 << 20))); > + ram_high, 0, MIN(ram_size, 256 * M_BYTE)); > memory_region_add_subregion(system_memory, 0, ram_low_preio); > > /* alias for post IO hole access, if there is enough RAM */ > - if (ram_size > (512 << 20)) { > + if (ram_size > 512 * M_BYTE) { > ram_low_postio = g_new(MemoryRegion, 1); > memory_region_init_alias(ram_low_postio, NULL, > "mips_malta_low_postio.ram", > - ram_high, 512 << 20, > - ram_size - (512 << 20)); > - memory_region_add_subregion(system_memory, 512 << 20, ram_low_postio); > + ram_high, 512 * M_BYTE, > + ram_size - 512 * M_BYTE); > + memory_region_add_subregion(system_memory, 512 * M_BYTE, > + ram_low_postio); > } > > #ifdef TARGET_WORDS_BIGENDIAN > @@ -1082,7 +1085,7 @@ void mips_malta_init(MachineState *machine) > bios = pflash_cfi01_get_memory(fl); > fl_idx++; > if (kernel_filename) { > - ram_low_size = MIN(ram_size, 256 << 20); > + ram_low_size = MIN(ram_size, 256 * M_BYTE); > /* For KVM we reserve 1MB of RAM for running bootloader */ > if (kvm_enabled()) { > ram_low_size -= 0x100000; > diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c > index c26a44da06..2a848bc1c2 100644 > --- a/hw/mips/mips_r4k.c > +++ b/hw/mips/mips_r4k.c > @@ -8,6 +8,7 @@ > * the standard PC ISA addresses. > */ > #include "qemu/osdep.h" > +#include "qemu/units.h" > #include "qapi/error.h" > #include "qemu-common.h" > #include "cpu.h" > @@ -144,7 +145,7 @@ static int64_t load_kernel(void) > } > > rom_add_blob_fixed("params", params_buf, params_size, > - (16 << 20) - params_size); > + 16 * M_BYTE - params_size); > > g_free(params_buf); > return entry; > @@ -159,7 +160,7 @@ static void main_cpu_reset(void *opaque) > env->active_tc.PC = s->vector; > } > > -static const int sector_len = 32 * 1024; > +static const int sector_len = 32 * K_BYTE; > static > void mips_r4k_init(MachineState *machine) > { > @@ -195,9 +196,9 @@ void mips_r4k_init(MachineState *machine) > qemu_register_reset(main_cpu_reset, reset_info); > > /* allocate RAM */ > - if (ram_size > (256 << 20)) { > - error_report("Too much memory for this machine: %dMB, maximum 256MB", > - ((unsigned int)ram_size / (1 << 20))); > + if (ram_size > 256 * M_BYTE) { > + error_report("Too much memory for this machine: %lluMB, maximum 256MB", > + ram_size / M_BYTE); > exit(1); > } > memory_region_allocate_system_memory(ram, NULL, "mips_r4k.ram", ram_size); > diff --git a/hw/misc/mips_itu.c b/hw/misc/mips_itu.c > index ccc4c7d98a..e40d472108 100644 > --- a/hw/misc/mips_itu.c > +++ b/hw/misc/mips_itu.c > @@ -18,6 +18,7 @@ > */ > > #include "qemu/osdep.h" > +#include "qemu/units.h" > #include "qemu/log.h" > #include "qapi/error.h" > #include "cpu.h" > @@ -80,7 +81,7 @@ static void itc_reconfigure(MIPSITUState *tag) > uint64_t *am = &tag->ITCAddressMap[0]; > MemoryRegion *mr = &tag->storage_io; > hwaddr address = am[0] & ITC_AM0_BASE_ADDRESS_MASK; > - uint64_t size = (1 << 10) + (am[1] & ITC_AM1_ADDR_MASK_MASK); > + uint64_t size = (1 * K_BYTE) + (am[1] & ITC_AM1_ADDR_MASK_MASK); > bool is_enabled = (am[0] & ITC_AM0_EN_MASK) != 0; > > memory_region_transaction_begin(); > diff --git a/hw/pci-host/xilinx-pcie.c b/hw/pci-host/xilinx-pcie.c > index 044e312dc1..6758669ce9 100644 > --- a/hw/pci-host/xilinx-pcie.c > +++ b/hw/pci-host/xilinx-pcie.c > @@ -18,6 +18,7 @@ > */ > > #include "qemu/osdep.h" > +#include "qemu/units.h" > #include "qapi/error.h" > #include "hw/pci/pci_bridge.h" > #include "hw/pci-host/xilinx-pcie.h" > @@ -158,9 +159,9 @@ static void xilinx_pcie_host_init(Object *obj) > static Property xilinx_pcie_host_props[] = { > DEFINE_PROP_UINT32("bus_nr", XilinxPCIEHost, bus_nr, 0), > DEFINE_PROP_SIZE("cfg_base", XilinxPCIEHost, cfg_base, 0), > - DEFINE_PROP_SIZE("cfg_size", XilinxPCIEHost, cfg_size, 32 << 20), > + DEFINE_PROP_SIZE("cfg_size", XilinxPCIEHost, cfg_size, 32 * M_BYTE), > DEFINE_PROP_SIZE("mmio_base", XilinxPCIEHost, mmio_base, 0), > - DEFINE_PROP_SIZE("mmio_size", XilinxPCIEHost, mmio_size, 1 << 20), > + DEFINE_PROP_SIZE("mmio_size", XilinxPCIEHost, mmio_size, 1 * M_BYTE), > DEFINE_PROP_BOOL("link_up", XilinxPCIEHost, link_up, true), > DEFINE_PROP_END_OF_LIST(), > }; > -- > 2.17.0 > >
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
---
include/hw/arm/fsl-imx7.h | 5 +++--
include/hw/arm/stm32f205_soc.h | 5 +++--
hw/arm/bcm2835_peripherals.c | 3 ++-
hw/arm/boot.c | 7 ++++---
hw/arm/collie.c | 5 +++--
hw/arm/digic_boards.c | 7 ++++---
hw/arm/exynos4_boards.c | 3 ++-
hw/arm/gumstix.c | 3 ++-
hw/arm/imx25_pdk.c | 1 +
hw/arm/integratorcp.c | 3 ++-
hw/arm/mainstone.c | 3 ++-
hw/arm/msf2-soc.c | 2 +-
hw/arm/msf2-som.c | 2 +-
hw/arm/musicpal.c | 9 +++++----
hw/arm/omap_sx1.c | 11 ++++++-----
hw/arm/raspi.c | 5 +++--
hw/arm/stellaris.c | 5 +++--
hw/arm/versatilepb.c | 5 +++--
hw/arm/vexpress.c | 7 ++++---
hw/arm/virt.c | 5 +++--
hw/arm/xilinx_zynq.c | 7 ++++---
hw/misc/aspeed_sdmc.c | 9 +++++----
hw/misc/imx7_gpr.c | 3 ++-
hw/misc/omap_gpmc.c | 5 +++--
hw/pci-host/gpex.c | 3 ++-
hw/ssi/aspeed_smc.c | 29 +++++++++++++++--------------
26 files changed, 88 insertions(+), 64 deletions(-)
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
index d848262bfd..fa6bf1c455 100644
--- a/include/hw/arm/fsl-imx7.h
+++ b/include/hw/arm/fsl-imx7.h
@@ -19,6 +19,7 @@
#ifndef FSL_IMX7_H
#define FSL_IMX7_H
+#include "qemu/units.h"
#include "hw/arm/arm.h"
#include "hw/cpu/a15mpcore.h"
#include "hw/intc/imx_gpcv2.h"
@@ -86,7 +87,7 @@ typedef struct FslIMX7State {
enum FslIMX7MemoryMap {
FSL_IMX7_MMDC_ADDR = 0x80000000,
- FSL_IMX7_MMDC_SIZE = 2 * 1024 * 1024 * 1024UL,
+ FSL_IMX7_MMDC_SIZE = 2 * G_BYTE,
FSL_IMX7_GPIO1_ADDR = 0x30200000,
FSL_IMX7_GPIO2_ADDR = 0x30210000,
@@ -176,7 +177,7 @@ enum FslIMX7MemoryMap {
FSL_IMX7_A7MPCORE_DAP_ADDR = 0x30000000,
FSL_IMX7_PCIE_REG_ADDR = 0x33800000,
- FSL_IMX7_PCIE_REG_SIZE = 16 * 1024,
+ FSL_IMX7_PCIE_REG_SIZE = 16 * K_BYTE,
FSL_IMX7_GPR_ADDR = 0x30340000,
};
diff --git a/include/hw/arm/stm32f205_soc.h b/include/hw/arm/stm32f205_soc.h
index 922a733f88..aeac3338d0 100644
--- a/include/hw/arm/stm32f205_soc.h
+++ b/include/hw/arm/stm32f205_soc.h
@@ -25,6 +25,7 @@
#ifndef HW_ARM_STM32F205_SOC_H
#define HW_ARM_STM32F205_SOC_H
+#include "qemu/units.h"
#include "hw/misc/stm32f2xx_syscfg.h"
#include "hw/timer/stm32f2xx_timer.h"
#include "hw/char/stm32f2xx_usart.h"
@@ -43,9 +44,9 @@
#define STM_NUM_SPIS 3
#define FLASH_BASE_ADDRESS 0x08000000
-#define FLASH_SIZE (1024 * 1024)
+#define FLASH_SIZE (1 * M_BYTE)
#define SRAM_BASE_ADDRESS 0x20000000
-#define SRAM_SIZE (128 * 1024)
+#define SRAM_SIZE (128 * K_BYTE)
typedef struct STM32F205State {
/*< private >*/
diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index 13b63970d7..2db04bff6e 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -9,6 +9,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "hw/arm/bcm2835_peripherals.h"
#include "hw/misc/bcm2835_mbox_defs.h"
@@ -150,7 +151,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
for (n = 0; n < 4; n++) {
memory_region_init_alias(&s->ram_alias[n], OBJECT(s),
"bcm2835-gpu-ram-alias[*]", ram, 0, ram_size);
- memory_region_add_subregion_overlap(&s->gpu_bus_mr, (hwaddr)n << 30,
+ memory_region_add_subregion_overlap(&s->gpu_bus_mr, n * G_BYTE,
&s->ram_alias[n], 0);
}
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 26184bcd7c..ad169708d8 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -8,6 +8,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include <libfdt.h>
@@ -1039,7 +1040,7 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data)
* the initrd at 128MB.
*/
info->initrd_start = info->loader_start +
- MIN(info->ram_size / 2, 128 * 1024 * 1024);
+ MIN(info->ram_size / 2, 128 * M_BYTE);
/* Assume that raw images are linux kernels, and ELF images are not. */
kernel_size = arm_load_elf(info, &elf_entry, &elf_low_addr,
@@ -1126,13 +1127,13 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data)
*
* Let's play safe and prealign it to 2MB to give us some space.
*/
- align = 2 * 1024 * 1024;
+ align = 2 * M_BYTE;
} else {
/*
* Some 32bit kernels will trash anything in the 4K page the
* initrd ends in, so make sure the DTB isn't caught up in that.
*/
- align = 4096;
+ align = 4 * K_BYTE;
}
/* Place the DTB after the initrd in memory with alignment. */
diff --git a/hw/arm/collie.c b/hw/arm/collie.c
index f8c566e2e5..767a45f138 100644
--- a/hw/arm/collie.c
+++ b/hw/arm/collie.c
@@ -9,6 +9,7 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/hw.h"
#include "hw/sysbus.h"
#include "hw/boards.h"
@@ -39,12 +40,12 @@ static void collie_init(MachineState *machine)
dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi01_register(SA_CS0, NULL, "collie.fl1", 0x02000000,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
- (64 * 1024), 512, 4, 0x00, 0x00, 0x00, 0x00, 0);
+ 64 * K_BYTE, 512, 4, 0x00, 0x00, 0x00, 0x00, 0);
dinfo = drive_get(IF_PFLASH, 0, 1);
pflash_cfi01_register(SA_CS1, NULL, "collie.fl2", 0x02000000,
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
- (64 * 1024), 512, 4, 0x00, 0x00, 0x00, 0x00, 0);
+ 64 * K_BYTE, 512, 4, 0x00, 0x00, 0x00, 0x00, 0);
sysbus_create_simple("scoop", 0x40800000, NULL);
diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c
index 9f11dcd11f..0a865f6e45 100644
--- a/hw/arm/digic_boards.c
+++ b/hw/arm/digic_boards.c
@@ -24,6 +24,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -126,8 +127,8 @@ static void digic_load_rom(DigicBoardState *s, hwaddr addr,
static void digic4_add_k8p3215uqb_rom(DigicBoardState *s, hwaddr addr,
const char *def_filename)
{
-#define FLASH_K8P3215UQB_SIZE (4 * 1024 * 1024)
-#define FLASH_K8P3215UQB_SECTOR_SIZE (64 * 1024)
+#define FLASH_K8P3215UQB_SIZE (4 * M_BYTE)
+#define FLASH_K8P3215UQB_SECTOR_SIZE (64 * K_BYTE)
pflash_cfi02_register(addr, NULL, "pflash", FLASH_K8P3215UQB_SIZE,
NULL, FLASH_K8P3215UQB_SECTOR_SIZE,
@@ -141,7 +142,7 @@ static void digic4_add_k8p3215uqb_rom(DigicBoardState *s, hwaddr addr,
}
static DigicBoard digic4_board_canon_a1100 = {
- .ram_size = 64 * 1024 * 1024,
+ .ram_size = 64 * M_BYTE,
.add_rom1 = digic4_add_k8p3215uqb_rom,
.rom1_def_filename = "canon-a1100-rom1.bin",
};
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
index 750162cc95..11f5e44eb2 100644
--- a/hw/arm/exynos4_boards.c
+++ b/hw/arm/exynos4_boards.c
@@ -22,6 +22,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu-common.h"
@@ -143,7 +144,7 @@ exynos4_boards_init_common(MachineState *machine,
" kernel_filename: %s\n"
" kernel_cmdline: %s\n"
" initrd_filename: %s\n",
- exynos4_board_ram_size[board_type] / 1048576,
+ exynos4_board_ram_size[board_type] / M_BYTE,
exynos4_board_ram_size[board_type],
machine->kernel_filename,
machine->kernel_cmdline,
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
index ea2a3c532d..88c5ac2f62 100644
--- a/hw/arm/gumstix.c
+++ b/hw/arm/gumstix.c
@@ -35,6 +35,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/error-report.h"
#include "hw/hw.h"
#include "hw/arm/pxa.h"
@@ -47,7 +48,7 @@
#include "sysemu/qtest.h"
#include "cpu.h"
-static const int sector_len = 128 * 1024;
+static const int sector_len = 128 * K_BYTE;
static void connex_init(MachineState *machine)
{
diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c
index 9f3ee14739..29f907cedf 100644
--- a/hw/arm/imx25_pdk.c
+++ b/hw/arm/imx25_pdk.c
@@ -24,6 +24,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index 58b40efc19..466ba9dcb0 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -8,6 +8,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -616,7 +617,7 @@ static void integratorcp_init(MachineState *machine)
memory_region_add_subregion(address_space_mem, 0x80000000, ram_alias);
dev = qdev_create(NULL, TYPE_INTEGRATOR_CM);
- qdev_prop_set_uint32(dev, "memsz", ram_size >> 20);
+ qdev_prop_set_uint32(dev, "memsz", ram_size / M_BYTE);
qdev_init_nofail(dev);
sysbus_mmio_map((SysBusDevice *)dev, 0, 0x10000000);
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
index 4215c025fc..a89627c036 100644
--- a/hw/arm/mainstone.c
+++ b/hw/arm/mainstone.c
@@ -12,6 +12,7 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "hw/hw.h"
@@ -115,7 +116,7 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
MachineState *machine,
enum mainstone_model_e model, int arm_id)
{
- uint32_t sector_len = 256 * 1024;
+ uint32_t sector_len = 256 * K_BYTE;
hwaddr mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
PXA2xxState *mpu;
DeviceState *mst_irq;
diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index f68df56b97..993cee37c5 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -23,13 +23,13 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "hw/arm/arm.h"
#include "exec/address-spaces.h"
#include "hw/char/serial.h"
#include "hw/boards.h"
-#include "qemu/cutils.h"
#include "hw/arm/msf2-soc.h"
#include "hw/misc/unimp.h"
diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c
index 0795a3a3a1..829c5da65a 100644
--- a/hw/arm/msf2-som.c
+++ b/hw/arm/msf2-som.c
@@ -23,12 +23,12 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "hw/boards.h"
#include "hw/arm/arm.h"
#include "exec/address-spaces.h"
-#include "qemu/cutils.h"
#include "hw/arm/msf2-soc.h"
#include "cpu.h"
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 38d7322a19..4bc47d39eb 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -10,6 +10,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -62,8 +63,8 @@
#define MP_SRAM_BASE 0xC0000000
#define MP_SRAM_SIZE 0x00020000
-#define MP_RAM_DEFAULT_SIZE 32*1024*1024
-#define MP_FLASH_SIZE_MAX 32*1024*1024
+#define MP_RAM_DEFAULT_SIZE (32 * M_BYTE)
+#define MP_FLASH_SIZE_MAX (32 * M_BYTE)
#define MP_TIMER1_IRQ 4
#define MP_TIMER2_IRQ 5
@@ -1625,8 +1626,8 @@ static void musicpal_init(MachineState *machine)
BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
flash_size = blk_getlength(blk);
- if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 &&
- flash_size != 32*1024*1024) {
+ if (flash_size != 8 * M_BYTE && flash_size != 16 * M_BYTE &&
+ flash_size != 32 * M_BYTE) {
error_report("Invalid flash image size");
exit(1);
}
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
index eccc19c77b..5acb0055d3 100644
--- a/hw/arm/omap_sx1.c
+++ b/hw/arm/omap_sx1.c
@@ -26,6 +26,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "hw/hw.h"
#include "ui/console.h"
@@ -87,11 +88,11 @@ static const MemoryRegionOps static_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-#define sdram_size 0x02000000
-#define sector_size (128 * 1024)
-#define flash0_size (16 * 1024 * 1024)
-#define flash1_size ( 8 * 1024 * 1024)
-#define flash2_size (32 * 1024 * 1024)
+#define sdram_size (32 * M_BYTE)
+#define sector_size (128 * K_BYTE)
+#define flash0_size (16 * M_BYTE)
+#define flash1_size (8 * M_BYTE)
+#define flash2_size (32 * M_BYTE)
#define total_ram_v1 (sdram_size + flash0_size + flash1_size + OMAP15XX_SRAM_SIZE)
#define total_ram_v2 (sdram_size + flash2_size + OMAP15XX_SRAM_SIZE)
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 955a7c4e80..e406e47793 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -12,6 +12,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -230,7 +231,7 @@ static void raspi2_machine_init(MachineClass *mc)
mc->max_cpus = BCM283X_NCPUS;
mc->min_cpus = BCM283X_NCPUS;
mc->default_cpus = BCM283X_NCPUS;
- mc->default_ram_size = 1024 * 1024 * 1024;
+ mc->default_ram_size = 1 * G_BYTE;
mc->ignore_memory_transaction_failures = true;
};
DEFINE_MACHINE("raspi2", raspi2_machine_init)
@@ -253,7 +254,7 @@ static void raspi3_machine_init(MachineClass *mc)
mc->max_cpus = BCM283X_NCPUS;
mc->min_cpus = BCM283X_NCPUS;
mc->default_cpus = BCM283X_NCPUS;
- mc->default_ram_size = 1024 * 1024 * 1024;
+ mc->default_ram_size = 1 * G_BYTE;
}
DEFINE_MACHINE("raspi3", raspi3_machine_init)
#endif
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index de7c0fc4a6..9971556f0e 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -8,6 +8,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "hw/sysbus.h"
#include "hw/ssi/ssi.h"
@@ -1284,8 +1285,8 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
MemoryRegion *flash = g_new(MemoryRegion, 1);
MemoryRegion *system_memory = get_system_memory();
- flash_size = (((board->dc0 & 0xffff) + 1) << 1) * 1024;
- sram_size = ((board->dc0 >> 18) + 1) * 1024;
+ flash_size = (((board->dc0 & 0xffff) + 1) << 1) * K_BYTE;
+ sram_size = ((board->dc0 >> 18) + 1) * K_BYTE;
/* Flash programming is done via the SCU, so pretend it is ROM. */
memory_region_init_ram(flash, NULL, "stellaris.flash", flash_size,
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index 418792cd02..312ea97719 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -8,6 +8,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -26,8 +27,8 @@
#include "hw/char/pl011.h"
#define VERSATILE_FLASH_ADDR 0x34000000
-#define VERSATILE_FLASH_SIZE (64 * 1024 * 1024)
-#define VERSATILE_FLASH_SECT_SIZE (256 * 1024)
+#define VERSATILE_FLASH_SIZE (64 * M_BYTE)
+#define VERSATILE_FLASH_SECT_SIZE (256 * K_BYTE)
/* Primary interrupt controller. */
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index 9fad79177a..d0899278bd 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -22,6 +22,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -45,8 +46,8 @@
#include "hw/cpu/a15mpcore.h"
#define VEXPRESS_BOARD_ID 0x8e0
-#define VEXPRESS_FLASH_SIZE (64 * 1024 * 1024)
-#define VEXPRESS_FLASH_SECT_SIZE (256 * 1024)
+#define VEXPRESS_FLASH_SIZE (64 * M_BYTE)
+#define VEXPRESS_FLASH_SECT_SIZE (256 * K_BYTE)
/* Number of virtio transports to create (0..8; limited by
* number of available IRQ lines).
@@ -355,7 +356,7 @@ static void a15_daughterboard_init(const VexpressMachineState *vms,
* warning if we are on a host where ram_addr_t is 32 bits.
*/
uint64_t rsz = ram_size;
- if (rsz > (30ULL * 1024 * 1024 * 1024)) {
+ if (rsz > 30 * G_BYTE) {
error_report("vexpress-a15: cannot model more than 30GB RAM");
exit(1);
}
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 94dcb125d3..23679ff1ae 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -29,6 +29,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "hw/sysbus.h"
#include "hw/arm/arm.h"
@@ -110,7 +111,7 @@ static ARMPlatformBusSystemParams platform_bus_params;
* terabyte of physical address space.)
*/
#define RAMLIMIT_GB 255
-#define RAMLIMIT_BYTES (RAMLIMIT_GB * 1024ULL * 1024 * 1024)
+#define RAMLIMIT_BYTES (RAMLIMIT_GB * G_BYTE)
/* Addresses and sizes of our components.
* 0..128MB is space for a flash device so we can run bootrom code such as UEFI.
@@ -784,7 +785,7 @@ static void create_one_flash(const char *name, hwaddr flashbase,
DriveInfo *dinfo = drive_get_next(IF_PFLASH);
DeviceState *dev = qdev_create(NULL, "cfi.pflash01");
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
- const uint64_t sectorlength = 256 * 1024;
+ const uint64_t sectorlength = 256 * K_BYTE;
if (dinfo) {
qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo),
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index 0f76333770..0810038689 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -16,6 +16,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
@@ -40,8 +41,8 @@
#define NUM_QSPI_FLASHES 2
#define NUM_QSPI_BUSSES 2
-#define FLASH_SIZE (64 * 1024 * 1024)
-#define FLASH_SECTOR_SIZE (128 * 1024)
+#define FLASH_SIZE (64 * M_BYTE)
+#define FLASH_SECTOR_SIZE (128 * K_BYTE)
#define IRQ_OFFSET 32 /* pic interrupts start from index 32 */
@@ -199,7 +200,7 @@ static void zynq_init(MachineState *machine)
memory_region_add_subregion(address_space_mem, 0, ext_ram);
/* 256K of on-chip memory */
- memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 << 10,
+ memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 * K_BYTE,
&error_fatal);
memory_region_add_subregion(address_space_mem, 0xFFFC0000, ocm_ram);
diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c
index 0df008e52a..0b89a6c5f1 100644
--- a/hw/misc/aspeed_sdmc.c
+++ b/hw/misc/aspeed_sdmc.c
@@ -8,6 +8,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/log.h"
#include "qemu/error-report.h"
#include "hw/misc/aspeed_sdmc.h"
@@ -149,7 +150,7 @@ static const MemoryRegionOps aspeed_sdmc_ops = {
static int ast2400_rambits(AspeedSDMCState *s)
{
- switch (s->ram_size >> 20) {
+ switch (s->ram_size / M_BYTE) {
case 64:
return ASPEED_SDMC_DRAM_64MB;
case 128:
@@ -165,13 +166,13 @@ static int ast2400_rambits(AspeedSDMCState *s)
/* use a common default */
warn_report("Invalid RAM size 0x%" PRIx64 ". Using default 256M",
s->ram_size);
- s->ram_size = 256 << 20;
+ s->ram_size = 256 * M_BYTE;
return ASPEED_SDMC_DRAM_256MB;
}
static int ast2500_rambits(AspeedSDMCState *s)
{
- switch (s->ram_size >> 20) {
+ switch (s->ram_size / M_BYTE) {
case 128:
return ASPEED_SDMC_AST2500_128MB;
case 256:
@@ -187,7 +188,7 @@ static int ast2500_rambits(AspeedSDMCState *s)
/* use a common default */
warn_report("Invalid RAM size 0x%" PRIx64 ". Using default 512M",
s->ram_size);
- s->ram_size = 512 << 20;
+ s->ram_size = 512 * M_BYTE;
return ASPEED_SDMC_AST2500_512MB;
}
diff --git a/hw/misc/imx7_gpr.c b/hw/misc/imx7_gpr.c
index c2a9df29c6..b784cf05f2 100644
--- a/hw/misc/imx7_gpr.c
+++ b/hw/misc/imx7_gpr.c
@@ -13,6 +13,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/misc/imx7_gpr.h"
#include "qemu/log.h"
#include "sysemu/sysemu.h"
@@ -98,7 +99,7 @@ static void imx7_gpr_init(Object *obj)
IMX7GPRState *s = IMX7_GPR(obj);
memory_region_init_io(&s->mmio, obj, &imx7_gpr_ops, s,
- TYPE_IMX7_GPR, 64 * 1024);
+ TYPE_IMX7_GPR, 64 * K_BYTE);
sysbus_init_mmio(sd, &s->mmio);
}
diff --git a/hw/misc/omap_gpmc.c b/hw/misc/omap_gpmc.c
index 84f9e4c612..94960774f4 100644
--- a/hw/misc/omap_gpmc.c
+++ b/hw/misc/omap_gpmc.c
@@ -19,6 +19,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/hw.h"
#include "hw/block/flash.h"
#include "hw/arm/omap.h"
@@ -850,11 +851,11 @@ struct omap_gpmc_s *omap_gpmc_init(struct omap_mpu_state_s *mpu,
&omap_nand_ops,
&s->cs_file[cs],
"omap-nand",
- 256 * 1024 * 1024);
+ 256 * M_BYTE);
}
memory_region_init_io(&s->prefetch.iomem, NULL, &omap_prefetch_ops, s,
- "omap-gpmc-prefetch", 256 * 1024 * 1024);
+ "omap-gpmc-prefetch", 256 * M_BYTE);
return s;
}
diff --git a/hw/pci-host/gpex.c b/hw/pci-host/gpex.c
index 2583b151a4..21993d5e83 100644
--- a/hw/pci-host/gpex.c
+++ b/hw/pci-host/gpex.c
@@ -29,6 +29,7 @@
* http://www.firmware.org/1275/practice/imap/imap0_9d.pdf
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/hw.h"
#include "hw/pci-host/gpex.h"
@@ -79,7 +80,7 @@ static void gpex_host_realize(DeviceState *dev, Error **errp)
pcie_host_mmcfg_init(pex, PCIE_MMCFG_SIZE_MAX);
memory_region_init(&s->io_mmio, OBJECT(s), "gpex_mmio", UINT64_MAX);
- memory_region_init(&s->io_ioport, OBJECT(s), "gpex_ioport", 64 * 1024);
+ memory_region_init(&s->io_ioport, OBJECT(s), "gpex_ioport", 64 * K_BYTE);
sysbus_init_mmio(sbd, &pex->mmio);
sysbus_init_mmio(sbd, &s->io_mmio);
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index 5059396bc6..df21fdf8d3 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/sysbus.h"
#include "sysemu/sysemu.h"
#include "qemu/log.h"
@@ -149,35 +150,35 @@
* Segment Address Registers.
*/
static const AspeedSegments aspeed_segments_legacy[] = {
- { 0x10000000, 32 * 1024 * 1024 },
+ { 0x10000000, 32 * M_BYTE },
};
static const AspeedSegments aspeed_segments_fmc[] = {
- { 0x20000000, 64 * 1024 * 1024 }, /* start address is readonly */
- { 0x24000000, 32 * 1024 * 1024 },
- { 0x26000000, 32 * 1024 * 1024 },
- { 0x28000000, 32 * 1024 * 1024 },
- { 0x2A000000, 32 * 1024 * 1024 }
+ { 0x20000000, 64 * M_BYTE }, /* start address is readonly */
+ { 0x24000000, 32 * M_BYTE },
+ { 0x26000000, 32 * M_BYTE },
+ { 0x28000000, 32 * M_BYTE },
+ { 0x2A000000, 32 * M_BYTE }
};
static const AspeedSegments aspeed_segments_spi[] = {
- { 0x30000000, 64 * 1024 * 1024 },
+ { 0x30000000, 64 * M_BYTE },
};
static const AspeedSegments aspeed_segments_ast2500_fmc[] = {
- { 0x20000000, 128 * 1024 * 1024 }, /* start address is readonly */
- { 0x28000000, 32 * 1024 * 1024 },
- { 0x2A000000, 32 * 1024 * 1024 },
+ { 0x20000000, 128 * M_BYTE }, /* start address is readonly */
+ { 0x28000000, 32 * M_BYTE },
+ { 0x2A000000, 32 * M_BYTE },
};
static const AspeedSegments aspeed_segments_ast2500_spi1[] = {
- { 0x30000000, 32 * 1024 * 1024 }, /* start address is readonly */
- { 0x32000000, 96 * 1024 * 1024 }, /* end address is readonly */
+ { 0x30000000, 32 * M_BYTE }, /* start address is readonly */
+ { 0x32000000, 96 * M_BYTE }, /* end address is readonly */
};
static const AspeedSegments aspeed_segments_ast2500_spi2[] = {
- { 0x38000000, 32 * 1024 * 1024 }, /* start address is readonly */
- { 0x3A000000, 96 * 1024 * 1024 }, /* end address is readonly */
+ { 0x38000000, 32 * M_BYTE }, /* start address is readonly */
+ { 0x3A000000, 96 * M_BYTE }, /* end address is readonly */
};
static const AspeedSMCController controllers[] = {
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/net/allwinner_emac.h | 5 +++--
hw/net/e1000e.c | 7 ++++---
hw/net/e1000x_common.c | 3 ++-
hw/net/eepro100.c | 7 +++----
4 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/include/hw/net/allwinner_emac.h b/include/hw/net/allwinner_emac.h
index 4cc8aab7ec..4b53b6485c 100644
--- a/include/hw/net/allwinner_emac.h
+++ b/include/hw/net/allwinner_emac.h
@@ -23,6 +23,7 @@
#ifndef ALLWINNER_EMAC_H
#define ALLWINNER_EMAC_H
+#include "qemu/units.h"
#include "net/net.h"
#include "qemu/fifo8.h"
#include "hw/net/mii.h"
@@ -125,8 +126,8 @@
#define EMAC_INT_RX (1 << 8)
/* Due to lack of specifications, size of fifos is chosen arbitrarily */
-#define TX_FIFO_SIZE (4 * 1024)
-#define RX_FIFO_SIZE (32 * 1024)
+#define TX_FIFO_SIZE (4 * K_BYTE)
+#define RX_FIFO_SIZE (32 * K_BYTE)
#define NUM_TX_FIFOS 2
#define RX_HDR_SIZE 8
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
index 16a9417a85..101efe7c83 100644
--- a/hw/net/e1000e.c
+++ b/hw/net/e1000e.c
@@ -34,6 +34,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "net/net.h"
#include "net/tap.h"
#include "qemu/range.h"
@@ -81,10 +82,10 @@ typedef struct E1000EState {
#define E1000E_IO_IDX 2
#define E1000E_MSIX_IDX 3
-#define E1000E_MMIO_SIZE (128 * 1024)
-#define E1000E_FLASH_SIZE (128 * 1024)
+#define E1000E_MMIO_SIZE (128 * K_BYTE)
+#define E1000E_FLASH_SIZE (128 * K_BYTE)
#define E1000E_IO_SIZE (32)
-#define E1000E_MSIX_SIZE (16 * 1024)
+#define E1000E_MSIX_SIZE (16 * K_BYTE)
#define E1000E_MSIX_TABLE (0x0000)
#define E1000E_MSIX_PBA (0x2000)
diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c
index eb0e097137..58c8db77e9 100644
--- a/hw/net/e1000x_common.c
+++ b/hw/net/e1000x_common.c
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/hw.h"
#include "hw/pci/pci.h"
#include "net/net.h"
@@ -111,7 +112,7 @@ bool e1000x_is_oversized(uint32_t *mac, size_t size)
static const int maximum_ethernet_vlan_size = 1522;
/* this is the size past which hardware will
drop packets when setting LPE=1 */
- static const int maximum_ethernet_lpe_size = 16384;
+ static const int maximum_ethernet_lpe_size = 16 * K_BYTE;
if ((size > maximum_ethernet_lpe_size ||
(size > maximum_ethernet_vlan_size
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index a07a63247e..a02e2b55e8 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -41,6 +41,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/hw.h"
#include "hw/pci/pci.h"
#include "net/net.h"
@@ -60,8 +61,6 @@
* changed to pad short packets itself. */
#define CONFIG_PAD_RECEIVED_FRAMES
-#define KiB 1024
-
/* Debug EEPRO100 card. */
#if 0
# define DEBUG_EEPRO100
@@ -104,9 +103,9 @@
/* Use 64 word EEPROM. TODO: could be a runtime option. */
#define EEPROM_SIZE 64
-#define PCI_MEM_SIZE (4 * KiB)
+#define PCI_MEM_SIZE (4 * K_BYTE)
#define PCI_IO_SIZE 64
-#define PCI_FLASH_SIZE (128 * KiB)
+#define PCI_FLASH_SIZE (128 * K_BYTE)
#define BITS(n, m) (((0xffffffffU << (31 - n)) >> (31 - n + m)) << m)
--
2.17.0
Am 16.04.2018 um 01:42 schrieb Philippe Mathieu-Daudé: > It eases code review, unit is explicit. > > Patch generated using: > > $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/ > > and modified manually. > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > include/hw/net/allwinner_emac.h | 5 +++-- > hw/net/e1000e.c | 7 ++++--- > hw/net/e1000x_common.c | 3 ++- > hw/net/eepro100.c | 7 +++---- > 4 files changed, 12 insertions(+), 10 deletions(-) > > diff --git a/include/hw/net/allwinner_emac.h b/include/hw/net/allwinner_emac.h > index 4cc8aab7ec..4b53b6485c 100644 > --- a/include/hw/net/allwinner_emac.h > +++ b/include/hw/net/allwinner_emac.h > @@ -23,6 +23,7 @@ > #ifndef ALLWINNER_EMAC_H > #define ALLWINNER_EMAC_H > > +#include "qemu/units.h" > #include "net/net.h" > #include "qemu/fifo8.h" > #include "hw/net/mii.h" > @@ -125,8 +126,8 @@ > #define EMAC_INT_RX (1 << 8) > > /* Due to lack of specifications, size of fifos is chosen arbitrarily */ > -#define TX_FIFO_SIZE (4 * 1024) > -#define RX_FIFO_SIZE (32 * 1024) > +#define TX_FIFO_SIZE (4 * K_BYTE) > +#define RX_FIFO_SIZE (32 * K_BYTE) > > #define NUM_TX_FIFOS 2 > #define RX_HDR_SIZE 8 > diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c > index 16a9417a85..101efe7c83 100644 > --- a/hw/net/e1000e.c > +++ b/hw/net/e1000e.c > @@ -34,6 +34,7 @@ > */ > > #include "qemu/osdep.h" > +#include "qemu/units.h" > #include "net/net.h" > #include "net/tap.h" > #include "qemu/range.h" > @@ -81,10 +82,10 @@ typedef struct E1000EState { > #define E1000E_IO_IDX 2 > #define E1000E_MSIX_IDX 3 > > -#define E1000E_MMIO_SIZE (128 * 1024) > -#define E1000E_FLASH_SIZE (128 * 1024) > +#define E1000E_MMIO_SIZE (128 * K_BYTE) > +#define E1000E_FLASH_SIZE (128 * K_BYTE) > #define E1000E_IO_SIZE (32) > -#define E1000E_MSIX_SIZE (16 * 1024) > +#define E1000E_MSIX_SIZE (16 * K_BYTE) > > #define E1000E_MSIX_TABLE (0x0000) > #define E1000E_MSIX_PBA (0x2000) > diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c > index eb0e097137..58c8db77e9 100644 > --- a/hw/net/e1000x_common.c > +++ b/hw/net/e1000x_common.c > @@ -23,6 +23,7 @@ > */ > > #include "qemu/osdep.h" > +#include "qemu/units.h" > #include "hw/hw.h" > #include "hw/pci/pci.h" > #include "net/net.h" > @@ -111,7 +112,7 @@ bool e1000x_is_oversized(uint32_t *mac, size_t size) > static const int maximum_ethernet_vlan_size = 1522; > /* this is the size past which hardware will > drop packets when setting LPE=1 */ > - static const int maximum_ethernet_lpe_size = 16384; > + static const int maximum_ethernet_lpe_size = 16 * K_BYTE; > > if ((size > maximum_ethernet_lpe_size || > (size > maximum_ethernet_vlan_size > diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c > index a07a63247e..a02e2b55e8 100644 > --- a/hw/net/eepro100.c > +++ b/hw/net/eepro100.c > @@ -41,6 +41,7 @@ > */ > > #include "qemu/osdep.h" > +#include "qemu/units.h" > #include "hw/hw.h" > #include "hw/pci/pci.h" > #include "net/net.h" > @@ -60,8 +61,6 @@ > * changed to pad short packets itself. */ > #define CONFIG_PAD_RECEIVED_FRAMES > > -#define KiB 1024 > - > /* Debug EEPRO100 card. */ > #if 0 > # define DEBUG_EEPRO100 > @@ -104,9 +103,9 @@ > /* Use 64 word EEPROM. TODO: could be a runtime option. */ > #define EEPROM_SIZE 64 > > -#define PCI_MEM_SIZE (4 * KiB) > +#define PCI_MEM_SIZE (4 * K_BYTE) > #define PCI_IO_SIZE 64 > -#define PCI_FLASH_SIZE (128 * KiB) > +#define PCI_FLASH_SIZE (128 * K_BYTE) > > #define BITS(n, m) (((0xffffffffU << (31 - n)) >> (31 - n + m)) << m) Technically this is fine, therefore Reviewed-by: Stefan Weil <sw@weilnetz.de> Practically I'd prefer replacing all K_BYTE by KiB, because that is the standard name with a precise definition: https://en.wikipedia.org/wiki/Kibibyte. Stefan
Hi Stefan, On 04/16/2018 02:23 AM, Stefan Weil wrote: > Am 16.04.2018 um 01:42 schrieb Philippe Mathieu-Daudé: >> It eases code review, unit is explicit. >> >> Patch generated using: >> >> $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/ >> >> and modified manually. >> >> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> >> --- >> include/hw/net/allwinner_emac.h | 5 +++-- >> hw/net/e1000e.c | 7 ++++--- >> hw/net/e1000x_common.c | 3 ++- >> hw/net/eepro100.c | 7 +++---- >> 4 files changed, 12 insertions(+), 10 deletions(-) >> >> diff --git a/include/hw/net/allwinner_emac.h b/include/hw/net/allwinner_emac.h >> index 4cc8aab7ec..4b53b6485c 100644 >> --- a/include/hw/net/allwinner_emac.h >> +++ b/include/hw/net/allwinner_emac.h >> @@ -23,6 +23,7 @@ >> #ifndef ALLWINNER_EMAC_H >> #define ALLWINNER_EMAC_H >> >> +#include "qemu/units.h" >> #include "net/net.h" >> #include "qemu/fifo8.h" >> #include "hw/net/mii.h" >> @@ -125,8 +126,8 @@ >> #define EMAC_INT_RX (1 << 8) >> >> /* Due to lack of specifications, size of fifos is chosen arbitrarily */ >> -#define TX_FIFO_SIZE (4 * 1024) >> -#define RX_FIFO_SIZE (32 * 1024) >> +#define TX_FIFO_SIZE (4 * K_BYTE) >> +#define RX_FIFO_SIZE (32 * K_BYTE) >> >> #define NUM_TX_FIFOS 2 >> #define RX_HDR_SIZE 8 >> diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c >> index 16a9417a85..101efe7c83 100644 >> --- a/hw/net/e1000e.c >> +++ b/hw/net/e1000e.c >> @@ -34,6 +34,7 @@ >> */ >> >> #include "qemu/osdep.h" >> +#include "qemu/units.h" >> #include "net/net.h" >> #include "net/tap.h" >> #include "qemu/range.h" >> @@ -81,10 +82,10 @@ typedef struct E1000EState { >> #define E1000E_IO_IDX 2 >> #define E1000E_MSIX_IDX 3 >> >> -#define E1000E_MMIO_SIZE (128 * 1024) >> -#define E1000E_FLASH_SIZE (128 * 1024) >> +#define E1000E_MMIO_SIZE (128 * K_BYTE) >> +#define E1000E_FLASH_SIZE (128 * K_BYTE) >> #define E1000E_IO_SIZE (32) >> -#define E1000E_MSIX_SIZE (16 * 1024) >> +#define E1000E_MSIX_SIZE (16 * K_BYTE) >> >> #define E1000E_MSIX_TABLE (0x0000) >> #define E1000E_MSIX_PBA (0x2000) >> diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c >> index eb0e097137..58c8db77e9 100644 >> --- a/hw/net/e1000x_common.c >> +++ b/hw/net/e1000x_common.c >> @@ -23,6 +23,7 @@ >> */ >> >> #include "qemu/osdep.h" >> +#include "qemu/units.h" >> #include "hw/hw.h" >> #include "hw/pci/pci.h" >> #include "net/net.h" >> @@ -111,7 +112,7 @@ bool e1000x_is_oversized(uint32_t *mac, size_t size) >> static const int maximum_ethernet_vlan_size = 1522; >> /* this is the size past which hardware will >> drop packets when setting LPE=1 */ >> - static const int maximum_ethernet_lpe_size = 16384; >> + static const int maximum_ethernet_lpe_size = 16 * K_BYTE; >> >> if ((size > maximum_ethernet_lpe_size || >> (size > maximum_ethernet_vlan_size >> diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c >> index a07a63247e..a02e2b55e8 100644 >> --- a/hw/net/eepro100.c >> +++ b/hw/net/eepro100.c >> @@ -41,6 +41,7 @@ >> */ >> >> #include "qemu/osdep.h" >> +#include "qemu/units.h" >> #include "hw/hw.h" >> #include "hw/pci/pci.h" >> #include "net/net.h" >> @@ -60,8 +61,6 @@ >> * changed to pad short packets itself. */ >> #define CONFIG_PAD_RECEIVED_FRAMES >> >> -#define KiB 1024 >> - >> /* Debug EEPRO100 card. */ >> #if 0 >> # define DEBUG_EEPRO100 >> @@ -104,9 +103,9 @@ >> /* Use 64 word EEPROM. TODO: could be a runtime option. */ >> #define EEPROM_SIZE 64 >> >> -#define PCI_MEM_SIZE (4 * KiB) >> +#define PCI_MEM_SIZE (4 * K_BYTE) >> #define PCI_IO_SIZE 64 >> -#define PCI_FLASH_SIZE (128 * KiB) >> +#define PCI_FLASH_SIZE (128 * K_BYTE) >> >> #define BITS(n, m) (((0xffffffffU << (31 - n)) >> (31 - n + m)) << m) > > > Technically this is fine, therefore > > Reviewed-by: Stefan Weil <sw@weilnetz.de> > > Practically I'd prefer replacing all K_BYTE by KiB, because that is the > standard name with a precise definition: > https://en.wikipedia.org/wiki/Kibibyte. "1 kibibyte is 1024 bytes. The unit symbol for the kibibyte is KiB." I like your suggestion :) Mostly because this shortens the code and keeps it readable (while respecting the SI). If the other maintainers agree with this change, I'm OK to do the cleanup. I couldn't find a rule requiring #defines be all capital letter in CODING_STYLE, is this acceptable to have a lower case "i"? Regards, Phil.
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/usb/ccid-card-passthru.c | 5 +++--
hw/usb/combined-packet.c | 3 ++-
hw/usb/dev-smartcard-reader.c | 3 ++-
hw/usb/redirect.c | 3 ++-
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index b7dd3602dc..4bd1e2232e 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -9,6 +9,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include <cacard/vscard_common.h>
#include "chardev/char-fe.h"
#include "qemu/error-report.h"
@@ -40,7 +41,7 @@ static const uint8_t DEFAULT_ATR[] = {
0x13, 0x08
};
-#define VSCARD_IN_SIZE 65536
+#define VSCARD_IN_SIZE (64 * K_BYTE)
/* maximum size of ATR - from 7816-3 */
#define MAX_ATR_SIZE 40
@@ -276,7 +277,7 @@ static void ccid_card_vscard_read(void *opaque, const uint8_t *buf, int size)
if (card->vscard_in_pos + size > VSCARD_IN_SIZE) {
error_report(
- "no room for data: pos %d + size %d > %d. dropping connection.",
+ "no room for data: pos %d + size %d > %llu. dropping connection.",
card->vscard_in_pos, size, VSCARD_IN_SIZE);
ccid_card_vscard_drop_connection(card);
return;
diff --git a/hw/usb/combined-packet.c b/hw/usb/combined-packet.c
index 48cac87f6a..2f068af927 100644
--- a/hw/usb/combined-packet.c
+++ b/hw/usb/combined-packet.c
@@ -20,6 +20,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu-common.h"
#include "hw/usb.h"
#include "qemu/iov.h"
@@ -171,7 +172,7 @@ void usb_ep_combine_input_packets(USBEndpoint *ep)
if ((p->iov.size % ep->max_packet_size) != 0 || !p->short_not_ok ||
next == NULL ||
/* Work around for Linux usbfs bulk splitting + migration */
- (totalsize == 16348 && p->int_req)) {
+ (totalsize == (16 * K_BYTE - 36) && p->int_req)) {
usb_device_handle_data(ep->dev, first);
assert(first->status == USB_RET_ASYNC);
if (first->combined) {
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index e6468057a0..0cdee70f82 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -35,6 +35,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "qemu/error-report.h"
@@ -63,7 +64,7 @@ do { \
* or handle the migration complexity - VMState doesn't handle this case.
* sizes are expected never to be exceeded, unless guest misbehaves.
*/
-#define BULK_OUT_DATA_SIZE 65536
+#define BULK_OUT_DATA_SIZE (64 * K_BYTE)
#define PENDING_ANSWERS_NUM 128
#define BULK_IN_BUF_SIZE 384
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 65a9196c1a..3ed4a39be1 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -26,6 +26,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "qemu/timer.h"
@@ -1298,7 +1299,7 @@ static int usbredir_chardev_can_read(void *opaque)
}
/* usbredir_parser_do_read will consume *all* data we give it */
- return 1024 * 1024;
+ return 1 * M_BYTE;
}
static void usbredir_chardev_read(void *opaque, const uint8_t *buf, int size)
--
2.17.0
On Sun, Apr 15, 2018 at 08:43:00PM -0300, Philippe Mathieu-Daudé wrote: > It eases code review, unit is explicit. > > Patch generated using: > > $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/ > > and modified manually. > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/sd/sd.c | 4 ++--
hw/sd/sdhci.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 235e0518d6..3b2f925ae6 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -30,6 +30,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "hw/qdev.h"
#include "hw/hw.h"
#include "hw/registerfields.h"
@@ -37,7 +38,6 @@
#include "hw/sd/sd.h"
#include "qapi/error.h"
#include "qemu/bitmap.h"
-#include "qemu/cutils.h"
#include "hw/qdev-properties.h"
#include "qemu/error-report.h"
#include "qemu/timer.h"
@@ -394,7 +394,7 @@ static void sd_set_csd(SDState *sd, uint64_t size)
((HWBLOCK_SHIFT << 6) & 0xc0);
sd->csd[14] = 0x00; /* File format group */
} else { /* SDHC */
- size /= 512 * 1024;
+ size /= 512 * K_BYTE;
size -= 1;
sd->csd[0] = 0x40;
sd->csd[1] = 0x0e;
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index 63c44a4ee8..55e2054148 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#include "hw/hw.h"
@@ -34,7 +35,6 @@
#include "hw/sd/sdhci.h"
#include "sdhci-internal.h"
#include "qemu/log.h"
-#include "qemu/cutils.h"
#include "trace.h"
#define TYPE_SDHCI_BUS "sdhci-bus"
@@ -792,7 +792,7 @@ static void sdhci_do_adma(SDHCIState *s)
return;
}
- length = dscr.length ? dscr.length : 65536;
+ length = dscr.length ? dscr.length : 64 * K_BYTE;
switch (dscr.attr & SDHC_ADMA_ATTR_ACT_MASK) {
case SDHC_ADMA_ATTR_ACT_TRAN: /* data transfer */
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/vfio/pci-quirks.c | 9 +++++----
hw/vfio/pci.c | 3 ++-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index e5779a7ad3..4fa181a977 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -11,6 +11,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qemu/error-report.h"
#include "qemu/range.h"
#include "qapi/error.h"
@@ -1255,9 +1256,9 @@ static int vfio_igd_gtt_max(VFIOPCIDevice *vdev)
ggms = 1 << ggms;
}
- ggms *= 1024 * 1024;
+ ggms *= M_BYTE;
- return (ggms / (4 * 1024)) * (gen < 8 ? 4 : 8);
+ return (ggms / (4 * K_BYTE)) * (gen < 8 ? 4 : 8);
}
/*
@@ -1514,7 +1515,7 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
igd->vdev = vdev;
igd->index = ~0;
igd->bdsm = vfio_pci_read_config(&vdev->pdev, IGD_BDSM, 4);
- igd->bdsm &= ~((1 << 20) - 1); /* 1MB aligned */
+ igd->bdsm &= ~((1 * M_BYTE) - 1); /* 1MB aligned */
memory_region_init_io(&quirk->mem[0], OBJECT(vdev), &vfio_igd_index_quirk,
igd, "vfio-igd-index-quirk", 4);
@@ -1561,7 +1562,7 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
* config offset 0x5C.
*/
bdsm_size = g_malloc(sizeof(*bdsm_size));
- *bdsm_size = cpu_to_le64((ggms_mb + gms_mb) * 1024 * 1024);
+ *bdsm_size = cpu_to_le64((ggms_mb + gms_mb) * M_BYTE);
fw_cfg_add_file(fw_cfg_find(), "etc/igd-bdsm-size",
bdsm_size, sizeof(*bdsm_size));
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index b9bc6cd310..fb9450b3a4 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -28,6 +28,7 @@
#include "qemu/error-report.h"
#include "qemu/option.h"
#include "qemu/range.h"
+#include "qemu/units.h"
#include "sysemu/kvm.h"
#include "sysemu/sysemu.h"
#include "pci.h"
@@ -1417,7 +1418,7 @@ static void vfio_pci_relocate_msix(VFIOPCIDevice *vdev, Error **errp)
}
/* 2GB max size for 32-bit BARs, cannot double if already > 1G */
- if (vdev->bars[target_bar].size > (1 * 1024 * 1024 * 1024) &&
+ if (vdev->bars[target_bar].size > 1 * G_BYTE &&
!vdev->bars[target_bar].mem64) {
error_setg(errp, "Invalid MSI-X relocation BAR %d, "
"no space to extend 32-bit BAR", target_bar);
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/virtio/virtio-net.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index 02484dc94c..8765f6546e 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -14,6 +14,7 @@
#ifndef QEMU_VIRTIO_NET_H
#define QEMU_VIRTIO_NET_H
+#include "qemu/units.h"
#include "standard-headers/linux/virtio_net.h"
#include "hw/virtio/virtio.h"
@@ -44,7 +45,7 @@ typedef struct virtio_net_conf
} virtio_net_conf;
/* Maximum packet size we can receive from tap device: header + 64k */
-#define VIRTIO_NET_MAX_BUFSIZE (sizeof(struct virtio_net_hdr) + (64 << 10))
+#define VIRTIO_NET_MAX_BUFSIZE (sizeof(struct virtio_net_hdr) + (64 * K_BYTE))
typedef struct VirtIONetQueue {
VirtQueue *rx_vq;
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/rdma/vmw/pvrdma.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/rdma/vmw/pvrdma.h b/hw/rdma/vmw/pvrdma.h
index 8c173cb824..f17143f0e6 100644
--- a/hw/rdma/vmw/pvrdma.h
+++ b/hw/rdma/vmw/pvrdma.h
@@ -16,6 +16,7 @@
#ifndef PVRDMA_PVRDMA_H
#define PVRDMA_PVRDMA_H
+#include "qemu/units.h"
#include "hw/pci/pci.h"
#include "hw/pci/msix.h"
@@ -30,7 +31,7 @@
#define RDMA_MSIX_BAR_IDX 0
#define RDMA_REG_BAR_IDX 1
#define RDMA_UAR_BAR_IDX 2
-#define RDMA_BAR0_MSIX_SIZE (16 * 1024)
+#define RDMA_BAR0_MSIX_SIZE (16 * K_BYTE)
#define RDMA_BAR1_REGS_SIZE 256
#define RDMA_BAR2_UAR_SIZE (0x1000 * MAX_UCS) /* each uc gets page */
--
2.17.0
On 16/04/2018 2:43, Philippe Mathieu-Daudé wrote: > It eases code review, unit is explicit. > > Patch generated using: > > $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/ > > and modified manually. > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > hw/rdma/vmw/pvrdma.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/hw/rdma/vmw/pvrdma.h b/hw/rdma/vmw/pvrdma.h > index 8c173cb824..f17143f0e6 100644 > --- a/hw/rdma/vmw/pvrdma.h > +++ b/hw/rdma/vmw/pvrdma.h > @@ -16,6 +16,7 @@ > #ifndef PVRDMA_PVRDMA_H > #define PVRDMA_PVRDMA_H > > +#include "qemu/units.h" > #include "hw/pci/pci.h" > #include "hw/pci/msix.h" > > @@ -30,7 +31,7 @@ > #define RDMA_MSIX_BAR_IDX 0 > #define RDMA_REG_BAR_IDX 1 > #define RDMA_UAR_BAR_IDX 2 > -#define RDMA_BAR0_MSIX_SIZE (16 * 1024) > +#define RDMA_BAR0_MSIX_SIZE (16 * K_BYTE) > #define RDMA_BAR1_REGS_SIZE 256 > #define RDMA_BAR2_UAR_SIZE (0x1000 * MAX_UCS) /* each uc gets page */ > > Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Thanks, Marcel
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/mem/nvdimm.h | 3 ++-
hw/mem/nvdimm.c | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h
index 7fd87c4e1c..fda855ad1a 100644
--- a/include/hw/mem/nvdimm.h
+++ b/include/hw/mem/nvdimm.h
@@ -23,6 +23,7 @@
#ifndef QEMU_NVDIMM_H
#define QEMU_NVDIMM_H
+#include "qemu/units.h"
#include "hw/mem/pc-dimm.h"
#include "hw/acpi/bios-linker-loader.h"
@@ -40,7 +41,7 @@
* "NVDIMMs following the NVDIMM Block Mode Specification use an area
* at least 128KB in size, which holds around 1000 labels."
*/
-#define MIN_NAMESPACE_LABEL_SIZE (128UL << 10)
+#define MIN_NAMESPACE_LABEL_SIZE (128 * K_BYTE)
#define TYPE_NVDIMM "nvdimm"
#define NVDIMM(obj) OBJECT_CHECK(NVDIMMDevice, (obj), TYPE_NVDIMM)
diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
index acb656b672..0f83e9fb4c 100644
--- a/hw/mem/nvdimm.c
+++ b/hw/mem/nvdimm.c
@@ -54,7 +54,7 @@ static void nvdimm_set_label_size(Object *obj, Visitor *v, const char *name,
}
if (value < MIN_NAMESPACE_LABEL_SIZE) {
error_setg(&local_err, "Property '%s.%s' (0x%" PRIx64 ") is required"
- " at least 0x%lx", object_get_typename(obj),
+ " at least 0x%llx", object_get_typename(obj),
name, value, MIN_NAMESPACE_LABEL_SIZE);
goto out;
}
--
2.17.0
It eases code review, unit is explicit.
Patch generated using:
$ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/
and modified manually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/loader.h | 5 +++--
hw/core/loader-fit.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/hw/loader.h b/include/hw/loader.h
index 5ed3fd8ae6..2222ca4184 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -1,5 +1,6 @@
#ifndef LOADER_H
#define LOADER_H
+#include "qemu/units.h"
#include "hw/nvram/fw_cfg.h"
/* loader.c */
@@ -52,7 +53,7 @@ int load_image_mr(const char *filename, MemoryRegion *mr);
* load_image_gzipped_buffer() and load_image_gzipped() will read. It prevents
* g_malloc() in those functions from allocating a huge amount of memory.
*/
-#define LOAD_IMAGE_MAX_GUNZIP_BYTES (256 << 20)
+#define LOAD_IMAGE_MAX_GUNZIP_BYTES (256 * M_BYTE)
int load_image_gzipped_buffer(const char *filename, uint64_t max_sz,
uint8_t **buffer);
@@ -253,6 +254,6 @@ int rom_add_option(const char *file, int32_t bootindex);
/* This is the usual maximum in uboot, so if a uImage overflows this, it would
* overflow on real hardware too. */
-#define UBOOT_MAX_GUNZIP_BYTES (64 << 20)
+#define UBOOT_MAX_GUNZIP_BYTES (64 * M_BYTE)
#endif
diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c
index 0c4a7207f4..0117104d69 100644
--- a/hw/core/loader-fit.c
+++ b/hw/core/loader-fit.c
@@ -22,7 +22,7 @@
#include "exec/memory.h"
#include "hw/loader.h"
#include "hw/loader-fit.h"
-#include "qemu/cutils.h"
+#include "qemu/units.h"
#include "qemu/error-report.h"
#include "sysemu/device_tree.h"
#include "sysemu/sysemu.h"
--
2.17.0
All files using "qemu/units.h" definitions already include it directly,
we can now remove it from "qemu/cutils.h".
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/qemu/cutils.h | 1 -
hw/core/machine.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index 056e6629bb..cdb0f0db75 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -2,7 +2,6 @@
#define QEMU_CUTILS_H
#include "qemu/fprintf-fn.h"
-#include "qemu/units.h"
/**
* pstrcpy:
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 2040177664..8f70c5ad94 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -19,7 +19,7 @@
#include "sysemu/sysemu.h"
#include "sysemu/numa.h"
#include "qemu/error-report.h"
-#include "qemu/cutils.h"
+#include "qemu/units.h"
#include "sysemu/qtest.h"
static char *machine_get_accel(Object *obj, Error **errp)
--
2.17.0
On 16/04/2018 2:43, Philippe Mathieu-Daudé wrote: > All files using "qemu/units.h" definitions already include it directly, > we can now remove it from "qemu/cutils.h". > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > include/qemu/cutils.h | 1 - > hw/core/machine.c | 2 +- > 2 files changed, 1 insertion(+), 2 deletions(-) > > diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h > index 056e6629bb..cdb0f0db75 100644 > --- a/include/qemu/cutils.h > +++ b/include/qemu/cutils.h > @@ -2,7 +2,6 @@ > #define QEMU_CUTILS_H > > #include "qemu/fprintf-fn.h" > -#include "qemu/units.h" > > /** > * pstrcpy: > diff --git a/hw/core/machine.c b/hw/core/machine.c > index 2040177664..8f70c5ad94 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -19,7 +19,7 @@ > #include "sysemu/sysemu.h" > #include "sysemu/numa.h" > #include "qemu/error-report.h" > -#include "qemu/cutils.h" > +#include "qemu/units.h" > #include "sysemu/qtest.h" > > static char *machine_get_accel(Object *obj, Error **errp) > Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Thanks, Marcel
© 2016 - 2017 Red Hat, Inc.