From patchwork Thu Feb 15 04:28:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 873628 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Q9AOTL3l"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zhkGX39bvz9t2x for ; Thu, 15 Feb 2018 15:45:08 +1100 (AEDT) Received: from localhost ([::1]:37615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emBPq-0004Av-Vk for incoming@patchwork.ozlabs.org; Wed, 14 Feb 2018 23:45:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emBB5-0007nV-2A for qemu-devel@nongnu.org; Wed, 14 Feb 2018 23:29:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emBB3-000412-9B for qemu-devel@nongnu.org; Wed, 14 Feb 2018 23:29:47 -0500 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:37352) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1emBB3-00040r-3f; Wed, 14 Feb 2018 23:29:45 -0500 Received: by mail-qk0-x241.google.com with SMTP id c128so29442784qkb.4; Wed, 14 Feb 2018 20:29:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wufTFZdIEjwCYVBwc91eIiYQn5SPRxoheNx3nrMLoqw=; b=Q9AOTL3l9B4Sc+ybSUK0VXbX0ErKEcAA1EfWNDExh9dNzgdkAiaK7CShC3t7dEboZP nBonb2QpM0YXhupbIkIYzyHLWh1HFsXqbN5x/95zgbN7xextyHxM5wZ456mPtoB5K2ls Hh5v7qoOfVvgcjM5B++NfXEy4S3M0mgtI2iveuF1qEn7+TdFrDkmhZFT034zjZgqVsW8 TN/hE0gNKZf1fTmixsc2oyl8Z+5OhmqFfkp/Lkmwf1W6pCeBxkP7vYgr5Mk3p1iJ9jmv sYDi/SPgx4jvXCFJHVUgEPU0sGQvVfvKonsTaC3u8C1uRJHq23jjORZB2er/Ya6UXkRy 03TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=wufTFZdIEjwCYVBwc91eIiYQn5SPRxoheNx3nrMLoqw=; b=k1lJCUszETb2nsPL6mbnpHhXWsqsfP75Knt+Sib88pnIN5idrMXAZkCWA6nfXBdHpk aYWVWWM/IUPPIo172sUguLSMmVYj44RGD9DAwfA8x7ZLwEtAx8zImUQ8x3G3IcdFq14e j3ZTkJiaR9kSytyCX1mTLlyZfYS4Y0VAZMKHhvnWTbrCd9t8A7K+FdKakgbspDFrDEY3 GV0fBtGh9cTu/cqlwUv5Ez/28uER6BaAVJ7dnz4EqwbyLFd3z8pTJpK3s5bCXalD+Owi ireMKA3BZDhq1N3MioWUC3NWqNBz9qsd+o2OGJU77UxEAybv2BVLqmJYB8mX+JJLwD4I TB+g== X-Gm-Message-State: APf1xPA4dyqUdOUWGu1iaB2vRof58z93Cd0hAh4gWyusk2OnCCuLZJnp jXwZ1Ys5cTJjhONK/xdbwuQ5ydtX X-Google-Smtp-Source: AH8x227OpAWJNWNoiuysy6wvW8E+G0yCk6yujGhlRulc1AJZD78n0S07T4ck/L64vieKiX3p/ADRxA== X-Received: by 10.55.71.87 with SMTP id u84mr2025510qka.255.1518668984365; Wed, 14 Feb 2018 20:29:44 -0800 (PST) Received: from x1.local ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id t33sm10680312qtc.14.2018.02.14.20.29.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Feb 2018 20:29:43 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Thu, 15 Feb 2018 01:28:40 -0300 Message-Id: <20180215042900.16078-11-f4bug@amsat.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215042900.16078-1-f4bug@amsat.org> References: <20180215042900.16078-1-f4bug@amsat.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [PATCH 10/30] hw/ppc: use the BYTE-based definitions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexander Graf , =?utf-8?q?Herv=C3=A9_Poussineau?= , "open list:PReP" , "Edgar E. Iglesias" , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" It ease code review, unit is explicit. Signed-off-by: Philippe Mathieu-Daudé Acked-by: David Gibson --- include/hw/ppc/spapr.h | 2 +- hw/pci-host/prep.c | 2 +- hw/ppc/e500.c | 8 ++++---- hw/ppc/mac_oldworld.c | 7 +++---- hw/ppc/ppc405_boards.c | 8 ++++---- hw/ppc/ppc405_uc.c | 6 +++--- hw/ppc/ppc4xx_devs.c | 21 +++++++++++---------- hw/ppc/ppce500_spin.c | 2 +- hw/ppc/prep.c | 2 +- hw/ppc/rs6000_mc.c | 12 ++++++------ hw/ppc/virtex_ml507.c | 4 ++-- 11 files changed, 37 insertions(+), 37 deletions(-) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 62c077ac20..ceeb274205 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -746,7 +746,7 @@ int spapr_rng_populate_dt(void *fdt); #define SPAPR_MAX_RAM_SLOTS 32 /* 1GB alignment for hotplug memory region */ -#define SPAPR_HOTPLUG_MEM_ALIGN (1ULL << 30) +#define SPAPR_HOTPLUG_MEM_ALIGN (1 * G_BYTE) /* * Number of 32 bit words in each LMB list entry in ibm,dynamic-memory diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c index 01f67f9db1..d06498e131 100644 --- a/hw/pci-host/prep.c +++ b/hw/pci-host/prep.c @@ -70,7 +70,7 @@ typedef struct PRePPCIState { int contiguous_map; } PREPPCIState; -#define BIOS_SIZE (1024 * 1024) +#define BIOS_SIZE (1 * M_BYTE) static inline uint32_t raven_pci_io_config(hwaddr addr) { diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index a40d3ec3e3..02675c7be4 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -45,7 +45,7 @@ #define BINARY_DEVICE_TREE_FILE "mpc8544ds.dtb" #define DTC_LOAD_PAD 0x1800000 #define DTC_PAD_MASK 0xFFFFF -#define DTB_MAX_SIZE (8 * 1024 * 1024) +#define DTB_MAX_SIZE (8 * M_BYTE) #define INITRD_LOAD_PAD 0x2000000 #define INITRD_PAD_MASK 0xFFFFFF @@ -597,7 +597,7 @@ static int ppce500_prep_device_tree(MachineState *machine, /* Create -kernel TLB entries for BookE. */ hwaddr booke206_page_size_to_tlb(uint64_t size) { - return 63 - clz64(size >> 10); + return 63 - clz64(size / K_BYTE); } static int booke206_initial_map_tsize(CPUPPCState *env) @@ -913,9 +913,9 @@ void ppce500_init(MachineState *machine, PPCE500Params *params) /* Register spinning region */ sysbus_create_simple("e500-spin", params->spin_base, NULL); - if (cur_base < (32 * 1024 * 1024)) { + if (cur_base < 32 * M_BYTE) { /* u-boot occupies memory up to 32MB, so load blobs above */ - cur_base = (32 * 1024 * 1024); + cur_base = 32 * M_BYTE; } if (params->has_mpc8xxx_gpio) { diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 9b19551f56..a6b8b77937 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -117,10 +117,9 @@ static void ppc_heathrow_init(MachineState *machine) } /* allocate RAM */ - if (ram_size > (2047 << 20)) { - fprintf(stderr, - "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n", - ((unsigned int)ram_size / (1 << 20))); + if (ram_size > 2047 * M_BYTE) { + error_report("Too much memory for this machine: %llu MB, " + "maximum 2047 MB", ram_size / M_BYTE); exit(1); } diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c index 0b658931ee..8c742449b8 100644 --- a/hw/ppc/ppc405_boards.c +++ b/hw/ppc/ppc405_boards.c @@ -41,7 +41,7 @@ #include "exec/address-spaces.h" #define BIOS_FILENAME "ppc405_rom.bin" -#define BIOS_SIZE (2048 * 1024) +#define BIOS_SIZE (2 * M_BYTE) #define KERNEL_LOAD_ADDR 0x00000000 #define INITRD_LOAD_ADDR 0x01800000 @@ -217,14 +217,14 @@ static void ref405ep_init(MachineState *machine) memory_region_init(&ram_memories[1], NULL, "ef405ep.ram1", 0); ram_bases[1] = 0x00000000; ram_sizes[1] = 0x00000000; - ram_size = 128 * 1024 * 1024; + ram_size = 128 * M_BYTE; #ifdef DEBUG_BOARD_INIT printf("%s: register cpu\n", __func__); #endif env = ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes, 33333333, &pic, kernel_filename == NULL ? 0 : 1); /* allocate SRAM */ - sram_size = 512 * 1024; + sram_size = 512 * K_BYTE; memory_region_init_ram(sram, NULL, "ef405ep.sram", sram_size, &error_fatal); memory_region_add_subregion(sysmem, 0xFFF00000, sram); @@ -590,7 +590,7 @@ static void taihu_405ep_init(MachineState *machine) bios_size = blk_getlength(blk); /* XXX: should check that size is 32MB */ - bios_size = 32 * 1024 * 1024; + bios_size = 32 * M_BYTE; fl_sectors = (bios_size + 65535) >> 16; #ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size %lx" diff --git a/hw/ppc/ppc405_uc.c b/hw/ppc/ppc405_uc.c index 205ebcea93..0e9d5b0ff9 100644 --- a/hw/ppc/ppc405_uc.c +++ b/hw/ppc/ppc405_uc.c @@ -983,10 +983,10 @@ static void ppc405_ocm_init(CPUPPCState *env) ocm = g_malloc0(sizeof(ppc405_ocm_t)); /* XXX: Size is 4096 or 0x04000000 */ - memory_region_init_ram(&ocm->isarc_ram, NULL, "ppc405.ocm", 4096, + memory_region_init_ram(&ocm->isarc_ram, NULL, "ppc405.ocm", 4 * K_BYTE, &error_fatal); - memory_region_init_alias(&ocm->dsarc_ram, NULL, "ppc405.dsarc", &ocm->isarc_ram, - 0, 4096); + memory_region_init_alias(&ocm->dsarc_ram, NULL, "ppc405.dsarc", + &ocm->isarc_ram, 0, 4 * K_BYTE); qemu_register_reset(&ocm_reset, ocm); ppc_dcr_register(env, OCM0_ISARC, ocm, &dcr_read_ocm, &dcr_write_ocm); diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c index 2e963894fe..52de988b13 100644 --- a/hw/ppc/ppc4xx_devs.c +++ b/hw/ppc/ppc4xx_devs.c @@ -29,6 +29,7 @@ #include "hw/boards.h" #include "qemu/log.h" #include "exec/address-spaces.h" +#include "qemu/error-report.h" #define DEBUG_UIC @@ -353,25 +354,25 @@ static uint32_t sdram_bcr (hwaddr ram_base, uint32_t bcr; switch (ram_size) { - case (4 * 1024 * 1024): + case 4 * M_BYTE: bcr = 0x00000000; break; - case (8 * 1024 * 1024): + case 8 * M_BYTE: bcr = 0x00020000; break; - case (16 * 1024 * 1024): + case 16 * M_BYTE: bcr = 0x00040000; break; - case (32 * 1024 * 1024): + case 32 * M_BYTE: bcr = 0x00060000; break; - case (64 * 1024 * 1024): + case 64 * M_BYTE: bcr = 0x00080000; break; - case (128 * 1024 * 1024): + case 128 * M_BYTE: bcr = 0x000A0000; break; - case (256 * 1024 * 1024): + case 256 * M_BYTE: bcr = 0x000C0000; break; default: @@ -399,7 +400,7 @@ static target_ulong sdram_size (uint32_t bcr) if (sh == 7) size = -1; else - size = (4 * 1024 * 1024) << sh; + size = (4 * M_BYTE) << sh; return size; } @@ -702,8 +703,8 @@ ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks, ram_size -= size_left; if (size_left) { - printf("Truncating memory to %d MiB to fit SDRAM controller limits.\n", - (int)(ram_size >> 20)); + error_report("Truncating memory to %llu MiB to fit SDRAM " + "controller limits", ram_size / M_BYTE); } memory_region_allocate_system_memory(ram, NULL, "ppc4xx.sdram", ram_size); diff --git a/hw/ppc/ppce500_spin.c b/hw/ppc/ppce500_spin.c index 69ca2d0e42..b6d224c45b 100644 --- a/hw/ppc/ppce500_spin.c +++ b/hw/ppc/ppce500_spin.c @@ -89,7 +89,7 @@ static void spin_kick(CPUState *cs, run_on_cpu_data data) PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; SpinInfo *curspin = data.host_ptr; - hwaddr map_size = 64 * 1024 * 1024; + hwaddr map_size = 64 * M_BYTE; hwaddr map_start; cpu_synchronize_state(cs); diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index f7c0a48558..eae475a34d 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -59,7 +59,7 @@ #define CFG_ADDR 0xf0000510 -#define BIOS_SIZE (1024 * 1024) +#define BIOS_SIZE (1 * M_BYTE) #define BIOS_FILENAME "ppc_rom.bin" #define KERNEL_LOAD_ADDR 0x01000000 #define INITRD_LOAD_ADDR 0x01800000 diff --git a/hw/ppc/rs6000_mc.c b/hw/ppc/rs6000_mc.c index b6135650bd..6999994fe4 100644 --- a/hw/ppc/rs6000_mc.c +++ b/hw/ppc/rs6000_mc.c @@ -109,7 +109,7 @@ static void rs6000mc_port0820_write(void *opaque, uint32_t addr, uint32_t val) size = end_address - start_address; memory_region_set_enabled(&s->simm[socket - 1], size != 0); memory_region_set_address(&s->simm[socket - 1], - start_address * 8 * 1024 * 1024); + start_address * 8 * M_BYTE); } } } @@ -140,7 +140,7 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp) { RS6000MCState *s = RS6000MC_DEVICE(dev); int socket = 0; - unsigned int ram_size = s->ram_size / (1024 * 1024); + unsigned int ram_size = s->ram_size / M_BYTE; while (socket < 6) { if (ram_size >= 64) { @@ -163,8 +163,8 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp) char name[] = "simm.?"; name[5] = socket + '0'; memory_region_allocate_system_memory(&s->simm[socket], OBJECT(dev), - name, s->simm_size[socket] - * 1024 * 1024); + name, + s->simm_size[socket] * M_BYTE); memory_region_add_subregion_overlap(get_system_memory(), 0, &s->simm[socket], socket); } @@ -172,8 +172,8 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp) if (ram_size) { /* unable to push all requested RAM in SIMMs */ error_setg(errp, "RAM size incompatible with this board. " - "Try again with something else, like %d MB", - s->ram_size / 1024 / 1024 - ram_size); + "Try again with something else, like %lld MB", + s->ram_size / M_BYTE - ram_size); return; } diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index 77a1778e07..dcfb6c2670 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -47,7 +47,7 @@ #include "sysemu/block-backend.h" #define EPAPR_MAGIC (0x45504150) -#define FLASH_SIZE (16 * 1024 * 1024) +#define FLASH_SIZE (16 * M_BYTE) #define INTC_BASEADDR 0x81800000 #define UART16550_BASEADDR 0x83e01003 @@ -237,7 +237,7 @@ static void virtex_init(MachineState *machine) dinfo = drive_get(IF_PFLASH, 0, 0); pflash_cfi01_register(PFLASH_BASEADDR, NULL, "virtex.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); cpu_irq = (qemu_irq *) &env->irq_inputs[PPC40x_INPUT_INT];