mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 18:23:57 -06:00
hw/i386/pc: move shared x86 functions to x86.c and export them
Move x86 functions that will be shared between PC and non-PC machine types to x86.c, along with their helpers. Signed-off-by: Sergio Lopez <slp@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
86a9a7916b
commit
549e984e67
8 changed files with 730 additions and 642 deletions
|
@ -31,6 +31,7 @@
|
|||
#include "qemu/option.h"
|
||||
#include "qemu/units.h"
|
||||
#include "hw/sysbus.h"
|
||||
#include "hw/i386/x86.h"
|
||||
#include "hw/i386/pc.h"
|
||||
#include "hw/loader.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
|
@ -38,8 +39,6 @@
|
|||
#include "hw/block/flash.h"
|
||||
#include "sysemu/kvm.h"
|
||||
|
||||
#define BIOS_FILENAME "bios.bin"
|
||||
|
||||
/*
|
||||
* We don't have a theoretically justifiable exact lower bound on the base
|
||||
* address of any flash mapping. In practice, the IO-APIC MMIO range is
|
||||
|
@ -211,59 +210,6 @@ static void pc_system_flash_map(PCMachineState *pcms,
|
|||
}
|
||||
}
|
||||
|
||||
static void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
|
||||
{
|
||||
char *filename;
|
||||
MemoryRegion *bios, *isa_bios;
|
||||
int bios_size, isa_bios_size;
|
||||
int ret;
|
||||
|
||||
/* BIOS load */
|
||||
if (bios_name == NULL) {
|
||||
bios_name = BIOS_FILENAME;
|
||||
}
|
||||
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
|
||||
if (filename) {
|
||||
bios_size = get_image_size(filename);
|
||||
} else {
|
||||
bios_size = -1;
|
||||
}
|
||||
if (bios_size <= 0 ||
|
||||
(bios_size % 65536) != 0) {
|
||||
goto bios_error;
|
||||
}
|
||||
bios = g_malloc(sizeof(*bios));
|
||||
memory_region_init_ram(bios, NULL, "pc.bios", bios_size, &error_fatal);
|
||||
if (!isapc_ram_fw) {
|
||||
memory_region_set_readonly(bios, true);
|
||||
}
|
||||
ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
|
||||
if (ret != 0) {
|
||||
bios_error:
|
||||
fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
|
||||
exit(1);
|
||||
}
|
||||
g_free(filename);
|
||||
|
||||
/* map the last 128KB of the BIOS in ISA space */
|
||||
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);
|
||||
memory_region_add_subregion_overlap(rom_memory,
|
||||
0x100000 - isa_bios_size,
|
||||
isa_bios,
|
||||
1);
|
||||
if (!isapc_ram_fw) {
|
||||
memory_region_set_readonly(isa_bios, true);
|
||||
}
|
||||
|
||||
/* map all the bios at the top of memory */
|
||||
memory_region_add_subregion(rom_memory,
|
||||
(uint32_t)(-bios_size),
|
||||
bios);
|
||||
}
|
||||
|
||||
void pc_system_firmware_init(PCMachineState *pcms,
|
||||
MemoryRegion *rom_memory)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue