From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Bernhard Beschow <shentey@gmail.com>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Eduardo Habkost <eduardo@habkost.net>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Subject: Re: [PATCH 4/4] hw/i386: Consolidate isa-bios creation
Date: Thu, 25 Apr 2024 09:19:27 +0200 [thread overview]
Message-ID: <dc0ccf20-fa3f-4882-a179-17798ebe5106@linaro.org> (raw)
In-Reply-To: <20240422200625.2768-5-shentey@gmail.com>
Hi Bernhard,
On 22/4/24 22:06, Bernhard Beschow wrote:
> Now that the -bios and -pflash code paths work the same it is possible to have a
> common implementation.
>
> While at it convert the magic number 0x100000 (== 1MiB) to increase readability.
>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
> include/hw/i386/x86.h | 2 ++
> hw/i386/pc_sysfw.c | 28 ++++------------------------
> hw/i386/x86.c | 29 ++++++++++++++++++-----------
> 3 files changed, 24 insertions(+), 35 deletions(-)
> diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
> index 6e89671c26..e529182b48 100644
> --- a/hw/i386/pc_sysfw.c
> +++ b/hw/i386/pc_sysfw.c
> @@ -28,7 +28,6 @@
> #include "sysemu/block-backend.h"
> #include "qemu/error-report.h"
> #include "qemu/option.h"
> -#include "qemu/units.h"
> #include "hw/sysbus.h"
> #include "hw/i386/x86.h"
> #include "hw/i386/pc.h"
> @@ -40,27 +39,6 @@
>
> #define FLASH_SECTOR_SIZE 4096
>
> -static void pc_isa_bios_init(MemoryRegion *rom_memory,
> - MemoryRegion *flash_mem)
> -{
> - int isa_bios_size;
> - MemoryRegion *isa_bios;
> - uint64_t flash_size;
> -
> - flash_size = memory_region_size(flash_mem);
> -
> - /* map the last 128KB of the BIOS in ISA space */
> - isa_bios_size = MIN(flash_size, 128 * KiB);
> - isa_bios = g_malloc(sizeof(*isa_bios));
> - memory_region_init_alias(isa_bios, NULL, "isa-bios", flash_mem,
> - flash_size - isa_bios_size, isa_bios_size);
> - memory_region_add_subregion_overlap(rom_memory,
> - 0x100000 - isa_bios_size,
> - isa_bios,
> - 1);
> - memory_region_set_readonly(isa_bios, true);
> -}
> diff --git a/hw/i386/x86.c b/hw/i386/x86.c
> index 32cd22a4a8..7366b0cee4 100644
> --- a/hw/i386/x86.c
> +++ b/hw/i386/x86.c
> @@ -1136,13 +1136,28 @@ void x86_load_linux(X86MachineState *x86ms,
> nb_option_roms++;
> }
>
> +void x86_isa_bios_init(MemoryRegion *rom_memory, MemoryRegion *bios,
> + bool isapc_ram_fw)
> +{
> + int bios_size = memory_region_size(bios);
> + int isa_bios_size = MIN(bios_size, 128 * KiB);
> + MemoryRegion *isa_bios;
> +
> + isa_bios = g_malloc(sizeof(*isa_bios));
Pre-existing, but we shouldn't leak MR like that.
Probably better to pass pre-allocated as argument,
smth like:
/**
* x86_isa_bios_init: ... at fixed addr ...
* @isa_bios: MR to initialize
* @isa_mr: ISA bus
* @bios: BIOS MR to map on ISA bus
* @read_only: Map the BIOS as read-only
*/
void x86_isa_bios_init(MemoryRegion *isa_bios,
const MemoryRegion *isa_mr,
const MemoryRegion *bios,
bool read_only);
> + memory_region_init_alias(isa_bios, NULL, "isa-bios", bios,
> + bios_size - isa_bios_size, isa_bios_size);
> + memory_region_add_subregion_overlap(rom_memory, 1 * MiB - isa_bios_size,
> + isa_bios, 1);
> + memory_region_set_readonly(isa_bios, !isapc_ram_fw);
> +}
next prev parent reply other threads:[~2024-04-25 7:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-22 20:06 [PATCH 0/4] X86: Alias isa-bios area and clean up Bernhard Beschow
2024-04-22 20:06 ` [PATCH 1/4] hw/i386/pc_sysfw: Remove unused parameter from pc_isa_bios_init() Bernhard Beschow
2024-04-25 7:06 ` Philippe Mathieu-Daudé
2024-04-22 20:06 ` [PATCH 2/4] hw/i386/pc_sysfw: Alias rather than copy isa-bios region Bernhard Beschow
2024-04-22 20:06 ` [PATCH 3/4] hw/i386/x86: Eliminate two if statements in x86_bios_rom_init() Bernhard Beschow
2024-04-25 7:07 ` Philippe Mathieu-Daudé
2024-04-22 20:06 ` [PATCH 4/4] hw/i386: Consolidate isa-bios creation Bernhard Beschow
2024-04-25 7:19 ` Philippe Mathieu-Daudé [this message]
2024-04-26 13:08 ` Bernhard Beschow
2024-04-24 20:05 ` [PATCH 0/4] X86: Alias isa-bios area and clean up Bernhard Beschow
2024-04-25 8:07 ` Philippe Mathieu-Daudé
2024-04-26 13:09 ` Bernhard Beschow
2024-04-25 10:16 ` Michael S. Tsirkin
2024-04-26 13:05 ` Bernhard Beschow
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=dc0ccf20-fa3f-4882-a179-17798ebe5106@linaro.org \
--to=philmd@linaro.org \
--cc=eduardo@habkost.net \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=shentey@gmail.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).