qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 34/47] hw/i386: Use the IEC binary prefix definitions
Date: Sat, 30 Jun 2018 08:10:27 +0200	[thread overview]
Message-ID: <20180630061040.6018-35-pbonzini@redhat.com> (raw)
In-Reply-To: <20180630061040.6018-1-pbonzini@redhat.com>

It eases code review, unit is explicit.

Patch generated using:

  $ git grep -E '[<>][<>]=? ?[1-5]0' hw/ include/hw/

and modified manually.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i386/acpi-build.c |  4 ++--
 hw/i386/pc.c         | 23 ++++++++++++-----------
 hw/i386/pc_piix.c    |  3 ++-
 hw/i386/pc_q35.c     |  3 ++-
 hw/i386/pc_sysfw.c   | 10 ++++------
 5 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 9bc6d97..796de91 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2248,8 +2248,8 @@ build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)
                  (void *)tpm2_ptr, "TPM2", sizeof(*tpm2_ptr), 4, NULL, NULL);
 }
 
-#define HOLE_640K_START  (640 * 1024)
-#define HOLE_640K_END   (1024 * 1024)
+#define HOLE_640K_START  (640 * KiB)
+#define HOLE_640K_END   (1 * MiB)
 
 static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base,
                                            uint64_t len, int default_node)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index f310040..50d5553 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "hw/i386/pc.h"
 #include "hw/char/serial.h"
@@ -448,12 +449,12 @@ void pc_cmos_init(PCMachineState *pcms,
 
     /* memory size */
     /* base memory (first MiB) */
-    val = MIN(pcms->below_4g_mem_size / 1024, 640);
+    val = MIN(pcms->below_4g_mem_size / KiB, 640);
     rtc_set_memory(s, 0x15, val);
     rtc_set_memory(s, 0x16, val >> 8);
     /* extended memory (next 64MiB) */
-    if (pcms->below_4g_mem_size > 1024 * 1024) {
-        val = (pcms->below_4g_mem_size - 1024 * 1024) / 1024;
+    if (pcms->below_4g_mem_size > 1 * MiB) {
+        val = (pcms->below_4g_mem_size - 1 * MiB) / KiB;
     } else {
         val = 0;
     }
@@ -464,8 +465,8 @@ void pc_cmos_init(PCMachineState *pcms,
     rtc_set_memory(s, 0x30, val);
     rtc_set_memory(s, 0x31, val >> 8);
     /* memory between 16MiB and 4GiB */
-    if (pcms->below_4g_mem_size > 16 * 1024 * 1024) {
-        val = (pcms->below_4g_mem_size - 16 * 1024 * 1024) / 65536;
+    if (pcms->below_4g_mem_size > 16 * MiB) {
+        val = (pcms->below_4g_mem_size - 16 * MiB) / (64 * KiB);
     } else {
         val = 0;
     }
@@ -1392,11 +1393,11 @@ void pc_memory_init(PCMachineState *pcms,
         }
 
         machine->device_memory->base =
-            ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, 1ULL << 30);
+            ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, 1 * GiB);
 
         if (pcmc->enforce_aligned_dimm) {
             /* size device region assuming 1G page max alignment per slot */
-            device_mem_size += (1ULL << 30) * machine->ram_slots;
+            device_mem_size += (1 * GiB) * machine->ram_slots;
         }
 
         if ((machine->device_memory->base + device_mem_size) <
@@ -1438,7 +1439,7 @@ void pc_memory_init(PCMachineState *pcms,
         if (!pcmc->broken_reserved_end) {
             res_mem_end += memory_region_size(&machine->device_memory->mr);
         }
-        *val = cpu_to_le64(ROUND_UP(res_mem_end, 0x1ULL << 30));
+        *val = cpu_to_le64(ROUND_UP(res_mem_end, 1 * GiB));
         fw_cfg_add_file(fw_cfg, "etc/reserved-memory-end", val, sizeof(*val));
     }
 
@@ -1475,7 +1476,7 @@ uint64_t pc_pci_hole64_start(void)
         hole64_start = 0x100000000ULL + pcms->above_4g_mem_size;
     }
 
-    return ROUND_UP(hole64_start, 1ULL << 30);
+    return ROUND_UP(hole64_start, 1 * GiB);
 }
 
 qemu_irq pc_allocate_cpu_irq(void)
@@ -2095,7 +2096,7 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
         error_propagate(errp, error);
         return;
     }
-    if (value > (1ULL << 32)) {
+    if (value > 4 * GiB) {
         error_setg(&error,
                    "Machine option 'max-ram-below-4g=%"PRIu64
                    "' expects size less than or equal to 4G", value);
@@ -2103,7 +2104,7 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
         return;
     }
 
-    if (value < (1ULL << 20)) {
+    if (value < 1 * MiB) {
         warn_report("Only %" PRIu64 " bytes of RAM below the 4GiB boundary,"
                     "BIOS may not work with less than 1MiB", value);
     }
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index d357907..dc09466 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -24,6 +24,7 @@
 
 #include "qemu/osdep.h"
 
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "hw/loader.h"
 #include "hw/i386/pc.h"
@@ -131,7 +132,7 @@ static void pc_init1(MachineState *machine,
                 if (lowmem > 0xc0000000) {
                     lowmem = 0xc0000000;
                 }
-                if (lowmem & ((1ULL << 30) - 1)) {
+                if (lowmem & (1 * GiB - 1)) {
                     warn_report("Large machine and max_ram_below_4g "
                                 "(%" PRIu64 ") not a multiple of 1G; "
                                 "possible bad performance.",
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 1a73e18..532241e 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -29,6 +29,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "hw/hw.h"
 #include "hw/loader.h"
 #include "sysemu/arch_init.h"
@@ -105,7 +106,7 @@ static void pc_q35_init(MachineState *machine)
     if (lowmem > pcms->max_ram_below_4g) {
         lowmem = pcms->max_ram_below_4g;
         if (machine->ram_size - lowmem > lowmem &&
-            lowmem & ((1ULL << 30) - 1)) {
+            lowmem & (1 * GiB - 1)) {
             warn_report("There is possibly poor performance as the ram size "
                         " (0x%" PRIx64 ") is more then twice the size of"
                         " max-ram-below-4g (%"PRIu64") and"
diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
index 73ac783..091e22d 100644
--- a/hw/i386/pc_sysfw.c
+++ b/hw/i386/pc_sysfw.c
@@ -28,6 +28,7 @@
 #include "sysemu/block-backend.h"
 #include "qemu/error-report.h"
 #include "qemu/option.h"
+#include "qemu/units.h"
 #include "hw/sysbus.h"
 #include "hw/hw.h"
 #include "hw/i386/pc.h"
@@ -56,7 +57,7 @@ static void pc_isa_bios_init(MemoryRegion *rom_memory,
     flash_size = memory_region_size(flash_mem);
 
     /* map the last 128KB of the BIOS in ISA space */
-    isa_bios_size = MIN(flash_size, 128 * 1024);
+    isa_bios_size = MIN(flash_size, 128 * KiB);
     isa_bios = g_malloc(sizeof(*isa_bios));
     memory_region_init_ram(isa_bios, NULL, "isa-bios", isa_bios_size,
                            &error_fatal);
@@ -83,7 +84,7 @@ static void pc_isa_bios_init(MemoryRegion *rom_memory,
  * only 18MB-4KB below 4G. For now, restrict the cumulative mapping to 8MB in
  * size.
  */
-#define FLASH_MAP_BASE_MIN ((hwaddr)(0x100000000ULL - 8*1024*1024))
+#define FLASH_MAP_BASE_MIN ((hwaddr)(4 * GiB - 8 * MiB))
 
 /* This function maps flash drives from 4G downward, in order of their unit
  * numbers. The mapping starts at unit#0, with unit number increments of 1, and
@@ -221,10 +222,7 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
     g_free(filename);
 
     /* map the last 128KB of the BIOS in ISA space */
-    isa_bios_size = bios_size;
-    if (isa_bios_size > (128 * 1024)) {
-        isa_bios_size = 128 * 1024;
-    }
+    isa_bios_size = MIN(bios_size, 128 * KiB);
     isa_bios = g_malloc(sizeof(*isa_bios));
     memory_region_init_alias(isa_bios, NULL, "isa-bios", bios,
                              bios_size - isa_bios_size, isa_bios_size);
-- 
1.8.3.1

  parent reply	other threads:[~2018-06-30  6:11 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-30  6:09 [Qemu-devel] [PULL 00/47] More misc patches for 3.0 soft freeze Paolo Bonzini
2018-06-30  6:09 ` [Qemu-devel] [PULL 01/47] i386/kvm: add support for Hyper-V TLB flush Paolo Bonzini
2018-06-30  6:09 ` [Qemu-devel] [PULL 02/47] configure: add sanity check to catch builds from "git archive" Paolo Bonzini
2018-06-30  6:09 ` [Qemu-devel] [PULL 03/47] include: Add IEC binary prefixes in "qemu/units.h" Paolo Bonzini
2018-06-30  6:09 ` [Qemu-devel] [PULL 04/47] vdi: Use definitions from "qemu/units.h" Paolo Bonzini
2018-06-30  6:09 ` [Qemu-devel] [PULL 05/47] x86/cpu: " Paolo Bonzini
2018-06-30  6:09 ` [Qemu-devel] [PULL 06/47] checkpatch: Recognize IEC binary prefix definitions Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 07/47] hw: Use IEC binary prefix definitions from "qemu/units.h" Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 08/47] hw: Directly use "qemu/units.h" instead of "qemu/cutils.h" Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 09/47] hw/ivshmem: Use the IEC binary prefix definitions Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 10/47] hw/ipack: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 11/47] hw/scsi: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 12/47] hw/smbios: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 13/47] hw/xen: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 14/47] hw/tpm: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 15/47] hw/block: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 16/47] hw/display: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 17/47] hw/misc: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 18/47] hw/riscv: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 19/47] hw/m68k: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 20/47] hw/sparc: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 21/47] hw/s390x: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 22/47] hw/hppa: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 23/47] hw/xtensa: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 24/47] hw/alpha: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 25/47] hw/tricore: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 26/47] hw/microblaze: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 27/47] hw/nios2: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 28/47] hw/cris: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 29/47] hw/lm32: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 30/47] hw/sh4: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 31/47] hw/mips/r4k: Constify params_size Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 32/47] hw/mips: Use the IEC binary prefix definitions Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 33/47] hw/ppc: " Paolo Bonzini
2018-06-30  6:10 ` Paolo Bonzini [this message]
2018-06-30  6:10 ` [Qemu-devel] [PULL 35/47] hw/net: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 36/47] hw/usb: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 37/47] hw/sd: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 38/47] hw/vfio: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 39/47] hw/virtio: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 40/47] hw/rdma: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 41/47] cutils: Do not include "qemu/units.h" directly Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 42/47] monitor: Use the IEC binary prefix definitions Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 43/47] vl: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 44/47] tests/crypto: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 45/47] linux-user: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 46/47] bsd-user: " Paolo Bonzini
2018-06-30  6:10 ` [Qemu-devel] [PULL 47/47] serial: Open non-block Paolo Bonzini
2018-06-30 15:39 ` [Qemu-devel] [PULL 00/47] More misc patches for 3.0 soft freeze Peter Maydell
2018-06-30 15:51   ` Paolo Bonzini
2018-06-30 16:50     ` [Qemu-devel] [PATCH] !fixup 052f529eb3d07170b18b8d0920bc8c450e389a2f Philippe Mathieu-Daudé
2018-07-02  8:37       ` Paolo Bonzini
2018-07-02 13:32       ` Paolo Bonzini

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=20180630061040.6018-35-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).