* [Qemu-devel] [RFC v3 0/2] use sizes.h macros for power-of-two sizes @ 2013-09-13 7:33 Antony Pavlov 2013-09-13 7:33 ` [Qemu-devel] [RFC v3 1/2] include/qemu: introduce sizes.h Antony Pavlov ` (3 more replies) 0 siblings, 4 replies; 7+ messages in thread From: Antony Pavlov @ 2013-09-13 7:33 UTC (permalink / raw) To: qemu-devel; +Cc: Paolo Bonzini, Richard Henderson, Aurelien Jarno, Stefan Weil Changes since v2: * commit messages: drop ALL 'Reviewed-by' tags. Drop Aurelien Jarno's tag because the patchseries was completely reworked, so it need additional review. Changes since v1: * include/sizes.h -> include/qemu/sizes.h * fix copyright header; * fix formatting: drop tabs; * use the BIT() macro, so it's easy-to-read the constants column; also the BIT() macro casts constant to UL; * rebase on updated master; * take into account the "mips_malta: support up to 2GiB RAM" commit. [RFC v3 1/2] include/qemu: introduce sizes.h [RFC v3 2/2] hw/mips: use sizes.h macros The sizes.h macros is a easy-to-read method of power-of-two memory sizes representation. The sizes.h macros are actively used in linux kernel and other projects, so let's use them in QEMU too. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [RFC v3 1/2] include/qemu: introduce sizes.h 2013-09-13 7:33 [Qemu-devel] [RFC v3 0/2] use sizes.h macros for power-of-two sizes Antony Pavlov @ 2013-09-13 7:33 ` Antony Pavlov 2013-09-13 7:33 ` [Qemu-devel] [RFC v3 2/2] hw/mips: use sizes.h macros Antony Pavlov ` (2 subsequent siblings) 3 siblings, 0 replies; 7+ messages in thread From: Antony Pavlov @ 2013-09-13 7:33 UTC (permalink / raw) To: qemu-devel Cc: Paolo Bonzini, Richard Henderson, Antony Pavlov, Aurelien Jarno, Stefan Weil The header file sizes.h is used in linux kernel, barebox bootloader and u-boot bootloader. It provides the short and easy-to-read names for power-of-two numbers. The numbers like this are othen used for memory range sizes. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> --- include/qemu/sizes.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 include/qemu/sizes.h diff --git a/include/qemu/sizes.h b/include/qemu/sizes.h new file mode 100644 index 0000000..a683b60 --- /dev/null +++ b/include/qemu/sizes.h @@ -0,0 +1,61 @@ +/* + * Handy size definitions + * + * Copyright (C) 2013 Antony Pavlov <antonynpavlov@gmail.com> + * + * Inspired by linux/sizes.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef QEMU_SIZES_H +#define QEMU_SIZES_H + +#include <qemu/bitops.h> + +#define SZ_1 BIT(0) +#define SZ_2 BIT(1) +#define SZ_4 BIT(2) +#define SZ_8 BIT(3) +#define SZ_16 BIT(4) +#define SZ_32 BIT(5) +#define SZ_64 BIT(6) +#define SZ_128 BIT(7) +#define SZ_256 BIT(8) +#define SZ_512 BIT(9) + +#define SZ_1K BIT(10) +#define SZ_2K BIT(11) +#define SZ_4K BIT(12) +#define SZ_8K BIT(13) +#define SZ_16K BIT(14) +#define SZ_32K BIT(15) +#define SZ_64K BIT(16) +#define SZ_128K BIT(17) +#define SZ_256K BIT(18) +#define SZ_512K BIT(19) + +#define SZ_1M BIT(20) +#define SZ_2M BIT(21) +#define SZ_4M BIT(22) +#define SZ_8M BIT(23) +#define SZ_16M BIT(24) +#define SZ_32M BIT(25) +#define SZ_64M BIT(26) +#define SZ_128M BIT(27) +#define SZ_256M BIT(28) +#define SZ_512M BIT(29) + +#define SZ_1G BIT(30) +#define SZ_2G BIT(31) + +#endif /* QEMU_SIZES_H */ -- 1.8.4.rc3 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [RFC v3 2/2] hw/mips: use sizes.h macros 2013-09-13 7:33 [Qemu-devel] [RFC v3 0/2] use sizes.h macros for power-of-two sizes Antony Pavlov 2013-09-13 7:33 ` [Qemu-devel] [RFC v3 1/2] include/qemu: introduce sizes.h Antony Pavlov @ 2013-09-13 7:33 ` Antony Pavlov 2013-09-14 18:36 ` [Qemu-devel] [RFC v3 0/2] use sizes.h macros for power-of-two sizes Richard Henderson 2013-09-24 4:32 ` Antony Pavlov 3 siblings, 0 replies; 7+ messages in thread From: Antony Pavlov @ 2013-09-13 7:33 UTC (permalink / raw) To: qemu-devel Cc: Paolo Bonzini, Richard Henderson, Antony Pavlov, Aurelien Jarno, Stefan Weil Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> --- hw/mips/mips_malta.c | 25 +++++++++++++------------ include/hw/mips/bios.h | 3 ++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index 05c8771..604832f 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -51,6 +51,7 @@ #include "sysemu/qtest.h" #include "qemu/error-report.h" #include "hw/empty_slot.h" +#include "qemu/sizes.h" //#define DEBUG_BOARD_INIT @@ -63,7 +64,7 @@ #define FPGA_ADDRESS 0x1f000000ULL #define RESET_ADDRESS 0x1fc00000ULL -#define FLASH_SIZE 0x400000 +#define FLASH_SIZE SZ_4M #define MAX_IDE_BUS 2 @@ -827,8 +828,8 @@ static int64_t load_kernel (void) } prom_set(prom_buf, prom_index++, "memsize"); - prom_set(prom_buf, prom_index++, "%i", - MIN(loaderparams.ram_size, 256 << 20)); + prom_set(prom_buf, prom_index++, "%li", + MIN(loaderparams.ram_size, SZ_256M)); prom_set(prom_buf, prom_index++, "modetty0"); prom_set(prom_buf, prom_index++, "38400n8r"); prom_set(prom_buf, prom_index++, NULL); @@ -954,10 +955,10 @@ void mips_malta_init(QEMUMachineInitArgs *args) env = &cpu->env; /* allocate RAM */ - if (ram_size > (2048u << 20)) { + if (ram_size > SZ_2G) { fprintf(stderr, - "qemu: Too much memory for this machine: %d MB, maximum 2048 MB\n", - ((unsigned int)ram_size / (1 << 20))); + "qemu: Too much memory for this machine: %ld MB, maximum 2048 MB\n", + ((unsigned long)ram_size / SZ_1M)); exit(1); } @@ -968,17 +969,17 @@ void mips_malta_init(QEMUMachineInitArgs *args) /* 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, SZ_256M)); 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 > SZ_512M) { 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, SZ_512M, + ram_size - SZ_512M); + memory_region_add_subregion(system_memory, SZ_512M, ram_low_postio); } /* generate SPD EEPROM data */ @@ -1012,7 +1013,7 @@ void mips_malta_init(QEMUMachineInitArgs *args) fl_idx++; if (kernel_filename) { /* Write a small bootloader to the flash location. */ - loaderparams.ram_size = MIN(ram_size, 256 << 20); + loaderparams.ram_size = MIN(ram_size, SZ_256M); loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; diff --git a/include/hw/mips/bios.h b/include/hw/mips/bios.h index b4b88ac..3d7da4b 100644 --- a/include/hw/mips/bios.h +++ b/include/hw/mips/bios.h @@ -1,6 +1,7 @@ #include "cpu.h" +#include "qemu/sizes.h" -#define BIOS_SIZE (4 * 1024 * 1024) +#define BIOS_SIZE SZ_4M #ifdef TARGET_WORDS_BIGENDIAN #define BIOS_FILENAME "mips_bios.bin" #else -- 1.8.4.rc3 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RFC v3 0/2] use sizes.h macros for power-of-two sizes 2013-09-13 7:33 [Qemu-devel] [RFC v3 0/2] use sizes.h macros for power-of-two sizes Antony Pavlov 2013-09-13 7:33 ` [Qemu-devel] [RFC v3 1/2] include/qemu: introduce sizes.h Antony Pavlov 2013-09-13 7:33 ` [Qemu-devel] [RFC v3 2/2] hw/mips: use sizes.h macros Antony Pavlov @ 2013-09-14 18:36 ` Richard Henderson 2013-09-24 4:32 ` Antony Pavlov 3 siblings, 0 replies; 7+ messages in thread From: Richard Henderson @ 2013-09-14 18:36 UTC (permalink / raw) To: Antony Pavlov; +Cc: Paolo Bonzini, qemu-devel, Aurelien Jarno, Stefan Weil On 09/13/2013 12:33 AM, Antony Pavlov wrote: > Changes since v2: > * commit messages: drop ALL 'Reviewed-by' tags. > Drop Aurelien Jarno's tag because the patchseries > was completely reworked, so it need additional review. > > Changes since v1: > > * include/sizes.h -> include/qemu/sizes.h > * fix copyright header; > * fix formatting: drop tabs; > * use the BIT() macro, so it's easy-to-read the constants column; > also the BIT() macro casts constant to UL; > * rebase on updated master; > * take into account the "mips_malta: support up to 2GiB RAM" commit. > > [RFC v3 1/2] include/qemu: introduce sizes.h > [RFC v3 2/2] hw/mips: use sizes.h macros > > The sizes.h macros is a easy-to-read method of > power-of-two memory sizes representation. The sizes.h > macros are actively used in linux kernel and other > projects, so let's use them in QEMU too. > Seems reasonable. I'd have said why bother with some of the multiples, except for the crossover with the linux kernel. Reviewed-by: Richard Henderson <rth@twiddle.net> r~ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RFC v3 0/2] use sizes.h macros for power-of-two sizes 2013-09-13 7:33 [Qemu-devel] [RFC v3 0/2] use sizes.h macros for power-of-two sizes Antony Pavlov ` (2 preceding siblings ...) 2013-09-14 18:36 ` [Qemu-devel] [RFC v3 0/2] use sizes.h macros for power-of-two sizes Richard Henderson @ 2013-09-24 4:32 ` Antony Pavlov 2013-10-23 12:16 ` Antony Pavlov 3 siblings, 1 reply; 7+ messages in thread From: Antony Pavlov @ 2013-09-24 4:32 UTC (permalink / raw) To: Antony Pavlov Cc: Paolo Bonzini, Richard Henderson, qemu-devel, Aurelien Jarno, Stefan Weil On Fri, 13 Sep 2013 11:33:24 +0400 Antony Pavlov <antonynpavlov@gmail.com> wrote: ping > Changes since v2: > * commit messages: drop ALL 'Reviewed-by' tags. > Drop Aurelien Jarno's tag because the patchseries > was completely reworked, so it need additional review. > > Changes since v1: > > * include/sizes.h -> include/qemu/sizes.h > * fix copyright header; > * fix formatting: drop tabs; > * use the BIT() macro, so it's easy-to-read the constants column; > also the BIT() macro casts constant to UL; > * rebase on updated master; > * take into account the "mips_malta: support up to 2GiB RAM" commit. > > [RFC v3 1/2] include/qemu: introduce sizes.h > [RFC v3 2/2] hw/mips: use sizes.h macros > > The sizes.h macros is a easy-to-read method of > power-of-two memory sizes representation. The sizes.h > macros are actively used in linux kernel and other > projects, so let's use them in QEMU too. -- Best regards, Antony Pavlov ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RFC v3 0/2] use sizes.h macros for power-of-two sizes 2013-09-24 4:32 ` Antony Pavlov @ 2013-10-23 12:16 ` Antony Pavlov 2013-10-28 10:30 ` Paolo Bonzini 0 siblings, 1 reply; 7+ messages in thread From: Antony Pavlov @ 2013-10-23 12:16 UTC (permalink / raw) To: qemu-devel; +Cc: Paolo Bonzini, Richard Henderson, Aurelien Jarno, Stefan Weil On Tue, 24 Sep 2013 08:32:10 +0400 Antony Pavlov <antonynpavlov@gmail.com> wrote: ping-ping > On Fri, 13 Sep 2013 11:33:24 +0400 > Antony Pavlov <antonynpavlov@gmail.com> wrote: > > ping > > > Changes since v2: > > * commit messages: drop ALL 'Reviewed-by' tags. > > Drop Aurelien Jarno's tag because the patchseries > > was completely reworked, so it need additional review. > > > > Changes since v1: > > > > * include/sizes.h -> include/qemu/sizes.h > > * fix copyright header; > > * fix formatting: drop tabs; > > * use the BIT() macro, so it's easy-to-read the constants column; > > also the BIT() macro casts constant to UL; > > * rebase on updated master; > > * take into account the "mips_malta: support up to 2GiB RAM" commit. > > > > [RFC v3 1/2] include/qemu: introduce sizes.h > > [RFC v3 2/2] hw/mips: use sizes.h macros > > > > The sizes.h macros is a easy-to-read method of > > power-of-two memory sizes representation. The sizes.h > > macros are actively used in linux kernel and other > > projects, so let's use them in QEMU too. > > -- > Best regards, > Antony Pavlov -- -- Best regards, Antony Pavlov ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [RFC v3 0/2] use sizes.h macros for power-of-two sizes 2013-10-23 12:16 ` Antony Pavlov @ 2013-10-28 10:30 ` Paolo Bonzini 0 siblings, 0 replies; 7+ messages in thread From: Paolo Bonzini @ 2013-10-28 10:30 UTC (permalink / raw) To: Antony Pavlov; +Cc: Stefan Weil, qemu-devel, Aurelien Jarno, Richard Henderson Il 23/10/2013 14:16, Antony Pavlov ha scritto: > On Tue, 24 Sep 2013 08:32:10 +0400 > Antony Pavlov <antonynpavlov@gmail.com> wrote: > > ping-ping > >> On Fri, 13 Sep 2013 11:33:24 +0400 >> Antony Pavlov <antonynpavlov@gmail.com> wrote: >> >> ping >> >>> Changes since v2: >>> * commit messages: drop ALL 'Reviewed-by' tags. >>> Drop Aurelien Jarno's tag because the patchseries >>> was completely reworked, so it need additional review. >>> >>> Changes since v1: >>> >>> * include/sizes.h -> include/qemu/sizes.h >>> * fix copyright header; >>> * fix formatting: drop tabs; >>> * use the BIT() macro, so it's easy-to-read the constants column; >>> also the BIT() macro casts constant to UL; >>> * rebase on updated master; >>> * take into account the "mips_malta: support up to 2GiB RAM" commit. >>> >>> [RFC v3 1/2] include/qemu: introduce sizes.h >>> [RFC v3 2/2] hw/mips: use sizes.h macros >>> >>> The sizes.h macros is a easy-to-read method of >>> power-of-two memory sizes representation. The sizes.h >>> macros are actively used in linux kernel and other >>> projects, so let's use them in QEMU too. >> >> -- >> Best regards, >> Antony Pavlov > > This unfortunately will miss 1.7. Please repost after 1.7 is released, without the "RFC" in the subject -- just use PATCH instead. Paolo ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-10-28 10:31 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-09-13 7:33 [Qemu-devel] [RFC v3 0/2] use sizes.h macros for power-of-two sizes Antony Pavlov 2013-09-13 7:33 ` [Qemu-devel] [RFC v3 1/2] include/qemu: introduce sizes.h Antony Pavlov 2013-09-13 7:33 ` [Qemu-devel] [RFC v3 2/2] hw/mips: use sizes.h macros Antony Pavlov 2013-09-14 18:36 ` [Qemu-devel] [RFC v3 0/2] use sizes.h macros for power-of-two sizes Richard Henderson 2013-09-24 4:32 ` Antony Pavlov 2013-10-23 12:16 ` Antony Pavlov 2013-10-28 10:30 ` Paolo Bonzini
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).