You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
3.9 KiB
99 lines
3.9 KiB
From 1baf67564d4227d6ba98923217a15814c438c32b Mon Sep 17 00:00:00 2001
|
|
From: Bernhard Beschow <shentey@gmail.com>
|
|
Date: Wed, 8 May 2024 19:55:06 +0200
|
|
Subject: [PATCH 042/100] hw/i386/x86: Extract x86_isa_bios_init() from
|
|
x86_bios_rom_init()
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
RH-MergeRequest: 245: SEV-SNP support
|
|
RH-Jira: RHEL-39544
|
|
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
RH-Acked-by: Bandan Das <bdas@redhat.com>
|
|
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
RH-Commit: [42/91] 1db417a5995480924f7fd0661a306f2d2bfa0a77 (bonzini/rhel-qemu-kvm)
|
|
|
|
The function is inspired by pc_isa_bios_init() and should eventually replace it.
|
|
Using x86_isa_bios_init() rather than pc_isa_bios_init() fixes pflash commands
|
|
to work in the isa-bios region.
|
|
|
|
While at it convert the magic number 0x100000 (== 1MiB) to increase readability.
|
|
|
|
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
|
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
|
|
Message-ID: <20240508175507.22270-6-shentey@gmail.com>
|
|
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
|
(cherry picked from commit 5c5ffec12c30d2017cbdee6798f54d8fad3f9656)
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
---
|
|
hw/i386/x86.c | 25 ++++++++++++++++---------
|
|
include/hw/i386/x86.h | 2 ++
|
|
2 files changed, 18 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
|
|
index 29167de97d..c61f4ebfa6 100644
|
|
--- a/hw/i386/x86.c
|
|
+++ b/hw/i386/x86.c
|
|
@@ -1128,12 +1128,25 @@ void x86_load_linux(X86MachineState *x86ms,
|
|
nb_option_roms++;
|
|
}
|
|
|
|
+void x86_isa_bios_init(MemoryRegion *isa_bios, MemoryRegion *isa_memory,
|
|
+ MemoryRegion *bios, bool read_only)
|
|
+{
|
|
+ uint64_t bios_size = memory_region_size(bios);
|
|
+ uint64_t isa_bios_size = MIN(bios_size, 128 * KiB);
|
|
+
|
|
+ memory_region_init_alias(isa_bios, NULL, "isa-bios", bios,
|
|
+ bios_size - isa_bios_size, isa_bios_size);
|
|
+ memory_region_add_subregion_overlap(isa_memory, 1 * MiB - isa_bios_size,
|
|
+ isa_bios, 1);
|
|
+ memory_region_set_readonly(isa_bios, read_only);
|
|
+}
|
|
+
|
|
void x86_bios_rom_init(X86MachineState *x86ms, const char *default_firmware,
|
|
MemoryRegion *rom_memory, bool isapc_ram_fw)
|
|
{
|
|
const char *bios_name;
|
|
char *filename;
|
|
- int bios_size, isa_bios_size;
|
|
+ int bios_size;
|
|
ssize_t ret;
|
|
|
|
/* BIOS load */
|
|
@@ -1171,14 +1184,8 @@ void x86_bios_rom_init(X86MachineState *x86ms, const char *default_firmware,
|
|
g_free(filename);
|
|
|
|
/* map the last 128KB of the BIOS in ISA space */
|
|
- isa_bios_size = MIN(bios_size, 128 * KiB);
|
|
- memory_region_init_alias(&x86ms->isa_bios, NULL, "isa-bios", &x86ms->bios,
|
|
- bios_size - isa_bios_size, isa_bios_size);
|
|
- memory_region_add_subregion_overlap(rom_memory,
|
|
- 0x100000 - isa_bios_size,
|
|
- &x86ms->isa_bios,
|
|
- 1);
|
|
- memory_region_set_readonly(&x86ms->isa_bios, !isapc_ram_fw);
|
|
+ x86_isa_bios_init(&x86ms->isa_bios, rom_memory, &x86ms->bios,
|
|
+ !isapc_ram_fw);
|
|
|
|
/* map all the bios at the top of memory */
|
|
memory_region_add_subregion(rom_memory,
|
|
diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
|
|
index 55c6809ae0..d7b7d3f3ce 100644
|
|
--- a/include/hw/i386/x86.h
|
|
+++ b/include/hw/i386/x86.h
|
|
@@ -129,6 +129,8 @@ void x86_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
|
|
void x86_cpu_unplug_cb(HotplugHandler *hotplug_dev,
|
|
DeviceState *dev, Error **errp);
|
|
|
|
+void x86_isa_bios_init(MemoryRegion *isa_bios, MemoryRegion *isa_memory,
|
|
+ MemoryRegion *bios, bool read_only);
|
|
void x86_bios_rom_init(X86MachineState *x86ms, const char *default_firmware,
|
|
MemoryRegion *rom_memory, bool isapc_ram_fw);
|
|
|
|
--
|
|
2.39.3
|
|
|