From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Paul Burton" <paul.burton@mips.com>,
	"Aurelien Jarno" <aurelien@aurel32.net>,
	"Yongbok Kim" <yongbok.kim@mips.com>
Subject: [Qemu-devel] [PATCH 06/30] hw/mips: use the BYTE-based definitions
Date: Thu, 15 Feb 2018 01:28:36 -0300	[thread overview]
Message-ID: <20180215042900.16078-7-f4bug@amsat.org> (raw)
In-Reply-To: <20180215042900.16078-1-f4bug@amsat.org>
It ease code review, unit is explicit.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/intc/mips_gic.h |  2 +-
 include/hw/mips/bios.h     |  2 +-
 hw/mips/boston.c           |  2 +-
 hw/mips/mips_fulong2e.c    |  6 +++---
 hw/mips/mips_malta.c       | 19 ++++++++++---------
 hw/mips/mips_r4k.c         | 10 +++++-----
 hw/misc/mips_itu.c         |  2 +-
 hw/pci-host/xilinx-pcie.c  |  4 ++--
 8 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/include/hw/intc/mips_gic.h b/include/hw/intc/mips_gic.h
index b98d50094a..5ae5a74249 100644
--- a/include/hw/intc/mips_gic.h
+++ b/include/hw/intc/mips_gic.h
@@ -19,7 +19,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..c70fab193a 100644
--- a/include/hw/mips/bios.h
+++ b/include/hw/mips/bios.h
@@ -1,6 +1,6 @@
 #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 e99f3638cf..1a1be57ba0 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -436,7 +436,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 f68c625666..428bf11fb4 100644
--- a/hw/mips/mips_fulong2e.c
+++ b/hw/mips/mips_fulong2e.c
@@ -164,7 +164,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);
 
@@ -281,10 +281,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 6f0deb99e7..7d27502b1a 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -1033,9 +1033,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);
     }
 
@@ -1046,17 +1046,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);
     }
 
     /* generate SPD EEPROM data */
@@ -1090,7 +1091,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 5a74c44b9a..d814045c27 100644
--- a/hw/mips/mips_r4k.c
+++ b/hw/mips/mips_r4k.c
@@ -143,7 +143,7 @@ static int64_t load_kernel(void)
     }
 
     rom_add_blob_fixed("params", params_buf, params_size,
-                       (16 << 20) - 264);
+                       16 * M_BYTE - params_size);
     g_free(params_buf);
     return entry;
 }
@@ -157,7 +157,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)
 {
@@ -193,9 +193,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 ef935b51a8..fc72d376e4 100644
--- a/hw/misc/mips_itu.c
+++ b/hw/misc/mips_itu.c
@@ -83,7 +83,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..b7272d173a 100644
--- a/hw/pci-host/xilinx-pcie.c
+++ b/hw/pci-host/xilinx-pcie.c
@@ -158,9 +158,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.16.1
next prev parent reply	other threads:[~2018-02-15  4:29 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-15  4:28 [Qemu-devel] [PATCH 00/30] hw: use the BYTE-based definitions when useful Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 01/30] util/cutils: extract byte-based definitions into a new header: "qemu/cunits.h" Philippe Mathieu-Daudé
2018-02-15  9:55   ` Marc-André Lureau
2018-02-15 11:11     ` Thomas Huth
2018-02-15  4:28 ` [Qemu-devel] [PATCH 02/30] hw: include "qemu/cunits.h" and clean unused "qemu/cutils.h" Philippe Mathieu-Daudé
2018-02-15  6:10   ` Thomas Huth
2018-03-05 10:50     ` Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 03/30] hw/block/nvme: include the "qemu/cutils.h" in the source file Philippe Mathieu-Daudé
2018-02-15  6:07   ` Thomas Huth
2018-02-15  4:28 ` [Qemu-devel] [PATCH 04/30] hw/lm32/milkymist: remove unused include Philippe Mathieu-Daudé
2018-02-15  6:20   ` Thomas Huth
2018-02-15  4:28 ` [Qemu-devel] [PATCH 05/30] hw/mips/r4k: constify params_size Philippe Mathieu-Daudé
2018-02-15  6:19   ` Thomas Huth
2018-02-15 12:27     ` Philippe Mathieu-Daudé
2018-02-15  4:28 ` Philippe Mathieu-Daudé [this message]
2018-02-15  4:28 ` [Qemu-devel] [PATCH 07/30] hw/arm: use the BYTE-based definitions Philippe Mathieu-Daudé
2018-02-15 22:31   ` Alistair Francis
2018-02-15 22:39     ` Philippe Mathieu-Daudé
2018-02-15 23:03       ` Alistair Francis
2018-02-15 23:09         ` Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 08/30] hw/i386: " Philippe Mathieu-Daudé
2018-03-05 12:29   ` Igor Mammedov
2018-03-05 13:00     ` Igor Mammedov
2018-02-15  4:28 ` [Qemu-devel] [PATCH 09/30] hw/sparc: " Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 10/30] hw/ppc: " Philippe Mathieu-Daudé
2018-02-15  4:38   ` David Gibson
2018-02-15  4:28 ` [Qemu-devel] [PATCH 11/30] hw/s390x: " Philippe Mathieu-Daudé
2018-02-15  7:05   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-03-05 10:06   ` [Qemu-devel] " Cornelia Huck
2018-02-15  4:28 ` [Qemu-devel] [PATCH 12/30] hw/hppa: " Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 13/30] hw/xtensa: " Philippe Mathieu-Daudé
2018-02-15 17:37   ` Max Filippov
2018-02-15  4:28 ` [Qemu-devel] [PATCH 14/30] hw/alpha: " Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 15/30] hw/lm32: " Philippe Mathieu-Daudé
2018-02-15 15:14   ` Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 16/30] hw/sh4: " Philippe Mathieu-Daudé
2018-02-15 14:43   ` Eric Blake
2018-02-15 15:09     ` Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 17/30] hw/tricore: " Philippe Mathieu-Daudé
2018-02-20 16:04   ` Bastian Koppelmann
2018-02-15  4:28 ` [Qemu-devel] [PATCH 18/30] hw/microblaze: " Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 19/30] hw/nios2: " Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 20/30] hw/cris: " Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 21/30] hw/misc: " Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 22/30] hw/display: " Philippe Mathieu-Daudé
2018-02-15 10:02   ` Gerd Hoffmann
2018-02-15  4:28 ` [Qemu-devel] [PATCH 23/30] hw/net: " Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 24/30] hw/ipack: " Philippe Mathieu-Daudé
2018-02-15  8:01   ` Alberto Garcia
2018-02-15  4:28 ` [Qemu-devel] [PATCH 25/30] hw/scsi: " Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 26/30] hw/smbios: " Philippe Mathieu-Daudé
2018-03-05 12:32   ` Igor Mammedov
2018-02-15  4:28 ` [Qemu-devel] [PATCH 27/30] vfio/pci: " Philippe Mathieu-Daudé
2018-02-15  4:28 ` [Qemu-devel] [PATCH 28/30] ivshmem: " Philippe Mathieu-Daudé
2018-02-15 15:16   ` Philippe Mathieu-Daudé
2018-02-15 15:40   ` Marc-André Lureau
2018-02-15  4:28 ` [Qemu-devel] [PATCH 29/30] tpm: " Philippe Mathieu-Daudé
2018-02-15  9:51   ` Marc-André Lureau
2018-02-15  4:29 ` [Qemu-devel] [PATCH 30/30] xen: " Philippe Mathieu-Daudé
2018-02-15 11:00   ` [Qemu-devel] [Xen-devel] " Alan Robinson
2018-02-15 12:23     ` Philippe Mathieu-Daudé
2018-02-15 13:28       ` Alan Robinson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=20180215042900.16078-7-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=aurelien@aurel32.net \
    --cc=paul.burton@mips.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yongbok.kim@mips.com \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).