|
|
0a122b |
From b9968ba04f7d8528d07c49bf523474ac4cb63acd Mon Sep 17 00:00:00 2001
|
|
|
0a122b |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
0a122b |
Date: Wed, 29 Jan 2014 07:06:24 +0100
|
|
|
0a122b |
Subject: [PATCH 12/22] pc_sysfw: do not make it a device anymore
|
|
|
0a122b |
|
|
|
0a122b |
Message-id: <1389463208-6278-13-git-send-email-lersek@redhat.com>
|
|
|
0a122b |
Patchwork-id: 56625
|
|
|
0a122b |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 12/18] pc_sysfw: do not make it a device anymore
|
|
|
0a122b |
Bugzilla: 1032346
|
|
|
0a122b |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Amos Kong <akong@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Andrew Jones <drjones@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
Move the code to hw/i386, the sole remaining property is available
|
|
|
0a122b |
as !pci_enabled.
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
0a122b |
Message-id: 1376069702-22330-4-git-send-email-aliguori@us.ibm.com
|
|
|
0a122b |
|
|
|
0a122b |
Rebased.
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
0a122b |
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
|
|
|
0a122b |
(cherry picked from commit 6dd2a5c98a6b1c9189d342bcc3493c9b5dd1217e)
|
|
|
0a122b |
|
|
|
0a122b |
Conflicts:
|
|
|
0a122b |
hw/block/Makefile.objs
|
|
|
0a122b |
hw/i386/pc_q35.c
|
|
|
0a122b |
include/hw/i386/pc.h
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
hw/block/Makefile.objs | 1 -
|
|
|
0a122b |
hw/i386/Makefile.objs | 1 +
|
|
|
0a122b |
include/hw/i386/pc.h | 4 ++-
|
|
|
0a122b |
hw/i386/pc.c | 2 +-
|
|
|
0a122b |
hw/i386/pc_piix.c | 6 +
|
|
|
0a122b |
hw/i386/pc_q35.c | 1 +
|
|
|
0a122b |
hw/{block => i386}/pc_sysfw.c | 52 +++
|
|
|
0a122b |
default-configs/i386-softmmu.mak | 1 -
|
|
|
0a122b |
default-configs/x86_64-softmmu.mak | 1 -
|
|
|
0a122b |
9 files changed, 10 insertions(+), 59 deletions(-)
|
|
|
0a122b |
rename hw/{block => i386}/pc_sysfw.c (81%)
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
default-configs/i386-softmmu.mak | 1 -
|
|
|
0a122b |
default-configs/x86_64-softmmu.mak | 1 -
|
|
|
0a122b |
hw/block/Makefile.objs | 1 -
|
|
|
0a122b |
hw/block/pc_sysfw.c | 231
|
|
|
0a122b |
hw/i386/Makefile.objs | 1 +
|
|
|
0a122b |
hw/i386/pc.c | 2 +-
|
|
|
0a122b |
hw/i386/pc_piix.c | 6 +-
|
|
|
0a122b |
hw/i386/pc_q35.c | 1 +
|
|
|
0a122b |
hw/i386/pc_sysfw.c | 185 +++++++++++++++++++++++++++++
|
|
|
0a122b |
include/hw/i386/pc.h | 4 +-
|
|
|
0a122b |
10 files changed, 192 insertions(+), 241 deletions(-)
|
|
|
0a122b |
delete mode 100644 hw/block/pc_sysfw.c
|
|
|
0a122b |
create mode 100644 hw/i386/pc_sysfw.c
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
|
|
|
0a122b |
index 03deca2..fb84f80 100644
|
|
|
0a122b |
|
|
|
0a122b |
+++ b/default-configs/i386-softmmu.mak
|
|
|
0a122b |
@@ -34,7 +34,6 @@ CONFIG_PAM=y
|
|
|
0a122b |
CONFIG_PCI_PIIX=y
|
|
|
0a122b |
CONFIG_PCI_HOTPLUG=y
|
|
|
0a122b |
CONFIG_WDT_IB700=y
|
|
|
0a122b |
-CONFIG_PC_SYSFW=y
|
|
|
0a122b |
CONFIG_XEN_I386=$(CONFIG_XEN)
|
|
|
0a122b |
CONFIG_ISA_DEBUG=y
|
|
|
0a122b |
CONFIG_ISA_TESTDEV=y
|
|
|
0a122b |
diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
|
|
|
0a122b |
index 7b8b05c..a6fdf84 100644
|
|
|
0a122b |
|
|
|
0a122b |
+++ b/default-configs/x86_64-softmmu.mak
|
|
|
0a122b |
@@ -27,7 +27,6 @@ CONFIG_PAM=y
|
|
|
0a122b |
CONFIG_PCI_PIIX=y
|
|
|
0a122b |
CONFIG_PCI_HOTPLUG=y
|
|
|
0a122b |
CONFIG_WDT_IB700=y
|
|
|
0a122b |
-CONFIG_PC_SYSFW=y
|
|
|
0a122b |
CONFIG_XEN_I386=$(CONFIG_XEN)
|
|
|
0a122b |
CONFIG_ISA_DEBUG=y
|
|
|
0a122b |
CONFIG_ISA_TESTDEV=y
|
|
|
0a122b |
diff
|
|
|
0a122b |
index e4329a0..94491bf 100644
|
|
|
0a122b |
|
|
|
0a122b |
|
|
|
0a122b |
@@ -7,7 +7,6 @@ common-obj-$(CONFIG_PFLASH_CFI02) += pflash_cfi02.o
|
|
|
0a122b |
common-obj-$(CONFIG_XEN_BACKEND) += xen_disk.o
|
|
|
0a122b |
common-obj-$(CONFIG_ECC) += ecc.o
|
|
|
0a122b |
common-obj-$(CONFIG_ONENAND) += onenand.o
|
|
|
0a122b |
-common-obj-$(CONFIG_PC_SYSFW) += pc_sysfw.o
|
|
|
0a122b |
|
|
|
0a122b |
obj-$(CONFIG_SH4) += tc58128.o
|
|
|
0a122b |
|
|
|
0a122b |
diff
|
|
|
0a122b |
deleted file mode 100644
|
|
|
0a122b |
index f9c0633..0000000
|
|
|
0a122b |
|
|
|
0a122b |
+++ /dev/null
|
|
|
0a122b |
@@ -1,231 +0,0 @@
|
|
|
0a122b |
-/*
|
|
|
0a122b |
- * QEMU PC System Firmware
|
|
|
0a122b |
- *
|
|
|
0a122b |
- * Copyright (c) 2003-2004 Fabrice Bellard
|
|
|
0a122b |
- * Copyright (c) 2011-2012 Intel Corporation
|
|
|
0a122b |
- *
|
|
|
0a122b |
- * Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
0a122b |
- * of this software and associated documentation files (the "Software"), to deal
|
|
|
0a122b |
- * in the Software without restriction, including without limitation the rights
|
|
|
0a122b |
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
0a122b |
- * copies of the Software, and to permit persons to whom the Software is
|
|
|
0a122b |
- * furnished to do so, subject to the following conditions:
|
|
|
0a122b |
- *
|
|
|
0a122b |
- * The above copyright notice and this permission notice shall be included in
|
|
|
0a122b |
- * all copies or substantial portions of the Software.
|
|
|
0a122b |
- *
|
|
|
0a122b |
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
0a122b |
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
0a122b |
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
0a122b |
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
0a122b |
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
0a122b |
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
0a122b |
- * THE SOFTWARE.
|
|
|
0a122b |
- */
|
|
|
0a122b |
-
|
|
|
0a122b |
-#include "sysemu/blockdev.h"
|
|
|
0a122b |
-#include "qemu/error-report.h"
|
|
|
0a122b |
-#include "hw/sysbus.h"
|
|
|
0a122b |
-#include "hw/hw.h"
|
|
|
0a122b |
-#include "hw/i386/pc.h"
|
|
|
0a122b |
-#include "hw/boards.h"
|
|
|
0a122b |
-#include "hw/loader.h"
|
|
|
0a122b |
-#include "sysemu/sysemu.h"
|
|
|
0a122b |
-#include "hw/block/flash.h"
|
|
|
0a122b |
-#include "sysemu/kvm.h"
|
|
|
0a122b |
-
|
|
|
0a122b |
-#define BIOS_FILENAME "bios.bin"
|
|
|
0a122b |
-
|
|
|
0a122b |
-typedef struct PcSysFwDevice {
|
|
|
0a122b |
- SysBusDevice busdev;
|
|
|
0a122b |
- uint8_t isapc_ram_fw;
|
|
|
0a122b |
-} PcSysFwDevice;
|
|
|
0a122b |
-
|
|
|
0a122b |
-static void pc_isa_bios_init(MemoryRegion *rom_memory,
|
|
|
0a122b |
- MemoryRegion *flash_mem,
|
|
|
0a122b |
- int ram_size)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- int isa_bios_size;
|
|
|
0a122b |
- MemoryRegion *isa_bios;
|
|
|
0a122b |
- uint64_t flash_size;
|
|
|
0a122b |
- void *flash_ptr, *isa_bios_ptr;
|
|
|
0a122b |
-
|
|
|
0a122b |
- flash_size = memory_region_size(flash_mem);
|
|
|
0a122b |
-
|
|
|
0a122b |
-
|
|
|
0a122b |
- isa_bios_size = MIN(flash_size, 128 * 1024);
|
|
|
0a122b |
- isa_bios = g_malloc(sizeof(*isa_bios));
|
|
|
0a122b |
- memory_region_init_ram(isa_bios, "isa-bios", isa_bios_size);
|
|
|
0a122b |
- vmstate_register_ram_global(isa_bios);
|
|
|
0a122b |
- memory_region_add_subregion_overlap(rom_memory,
|
|
|
0a122b |
- 0x100000 - isa_bios_size,
|
|
|
0a122b |
- isa_bios,
|
|
|
0a122b |
- 1);
|
|
|
0a122b |
-
|
|
|
0a122b |
- /* copy ISA rom image from top of flash memory */
|
|
|
0a122b |
- flash_ptr = memory_region_get_ram_ptr(flash_mem);
|
|
|
0a122b |
- isa_bios_ptr = memory_region_get_ram_ptr(isa_bios);
|
|
|
0a122b |
- memcpy(isa_bios_ptr,
|
|
|
0a122b |
- ((uint8_t*)flash_ptr) + (flash_size - isa_bios_size),
|
|
|
0a122b |
- isa_bios_size);
|
|
|
0a122b |
-
|
|
|
0a122b |
- memory_region_set_readonly(isa_bios, true);
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-static void pc_system_flash_init(MemoryRegion *rom_memory,
|
|
|
0a122b |
- DriveInfo *pflash_drv)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- BlockDriverState *bdrv;
|
|
|
0a122b |
- int64_t size;
|
|
|
0a122b |
- hwaddr phys_addr;
|
|
|
0a122b |
- int sector_bits, sector_size;
|
|
|
0a122b |
- pflash_t *system_flash;
|
|
|
0a122b |
- MemoryRegion *flash_mem;
|
|
|
0a122b |
-
|
|
|
0a122b |
- bdrv = pflash_drv->bdrv;
|
|
|
0a122b |
- size = bdrv_getlength(pflash_drv->bdrv);
|
|
|
0a122b |
- sector_bits = 12;
|
|
|
0a122b |
- sector_size = 1 << sector_bits;
|
|
|
0a122b |
-
|
|
|
0a122b |
- if ((size % sector_size) != 0) {
|
|
|
0a122b |
- fprintf(stderr,
|
|
|
0a122b |
- "qemu: PC system firmware (pflash) must be a multiple of 0x%x\n",
|
|
|
0a122b |
- sector_size);
|
|
|
0a122b |
- exit(1);
|
|
|
0a122b |
- }
|
|
|
0a122b |
-
|
|
|
0a122b |
- phys_addr = 0x100000000ULL - size;
|
|
|
0a122b |
- system_flash = pflash_cfi01_register(phys_addr, NULL, "system.flash", size,
|
|
|
0a122b |
- bdrv, sector_size, size >> sector_bits,
|
|
|
0a122b |
- 1, 0x0000, 0x0000, 0x0000, 0x0000, 0);
|
|
|
0a122b |
- flash_mem = pflash_cfi01_get_memory(system_flash);
|
|
|
0a122b |
-
|
|
|
0a122b |
- pc_isa_bios_init(rom_memory, flash_mem, size);
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- char *filename;
|
|
|
0a122b |
- MemoryRegion *bios, *isa_bios;
|
|
|
0a122b |
- int bios_size, isa_bios_size;
|
|
|
0a122b |
- int ret;
|
|
|
0a122b |
-
|
|
|
0a122b |
- /* BIOS load */
|
|
|
0a122b |
- if (bios_name == NULL) {
|
|
|
0a122b |
- bios_name = BIOS_FILENAME;
|
|
|
0a122b |
- }
|
|
|
0a122b |
- filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
|
|
|
0a122b |
- if (filename) {
|
|
|
0a122b |
- bios_size = get_image_size(filename);
|
|
|
0a122b |
- } else {
|
|
|
0a122b |
- bios_size = -1;
|
|
|
0a122b |
- }
|
|
|
0a122b |
- if (bios_size <= 0 ||
|
|
|
0a122b |
- (bios_size % 65536) != 0) {
|
|
|
0a122b |
- goto bios_error;
|
|
|
0a122b |
- }
|
|
|
0a122b |
- bios = g_malloc(sizeof(*bios));
|
|
|
0a122b |
- memory_region_init_ram(bios, "pc.bios", bios_size);
|
|
|
0a122b |
- vmstate_register_ram_global(bios);
|
|
|
0a122b |
- if (!isapc_ram_fw) {
|
|
|
0a122b |
- memory_region_set_readonly(bios, true);
|
|
|
0a122b |
- }
|
|
|
0a122b |
- ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
|
|
|
0a122b |
- if (ret != 0) {
|
|
|
0a122b |
- bios_error:
|
|
|
0a122b |
- fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
|
|
|
0a122b |
- exit(1);
|
|
|
0a122b |
- }
|
|
|
0a122b |
- if (filename) {
|
|
|
0a122b |
- g_free(filename);
|
|
|
0a122b |
- }
|
|
|
0a122b |
-
|
|
|
0a122b |
-
|
|
|
0a122b |
- isa_bios_size = bios_size;
|
|
|
0a122b |
- if (isa_bios_size > (128 * 1024)) {
|
|
|
0a122b |
- isa_bios_size = 128 * 1024;
|
|
|
0a122b |
- }
|
|
|
0a122b |
- isa_bios = g_malloc(sizeof(*isa_bios));
|
|
|
0a122b |
- memory_region_init_alias(isa_bios, "isa-bios", bios,
|
|
|
0a122b |
- bios_size - isa_bios_size, isa_bios_size);
|
|
|
0a122b |
- memory_region_add_subregion_overlap(rom_memory,
|
|
|
0a122b |
- 0x100000 - isa_bios_size,
|
|
|
0a122b |
- isa_bios,
|
|
|
0a122b |
- 1);
|
|
|
0a122b |
- if (!isapc_ram_fw) {
|
|
|
0a122b |
- memory_region_set_readonly(isa_bios, true);
|
|
|
0a122b |
- }
|
|
|
0a122b |
-
|
|
|
0a122b |
-
|
|
|
0a122b |
- memory_region_add_subregion(rom_memory,
|
|
|
0a122b |
- (uint32_t)(-bios_size),
|
|
|
0a122b |
- bios);
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-void pc_system_firmware_init(MemoryRegion *rom_memory)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- DriveInfo *pflash_drv;
|
|
|
0a122b |
- PcSysFwDevice *sysfw_dev;
|
|
|
0a122b |
-
|
|
|
0a122b |
- /*
|
|
|
0a122b |
- * TODO This device exists only so that users can switch between
|
|
|
0a122b |
- * use of flash and ROM for the BIOS. The ability to switch was
|
|
|
0a122b |
- * created because flash doesn't work with KVM. Once it does, we
|
|
|
0a122b |
- * should drop this device.
|
|
|
0a122b |
- */
|
|
|
0a122b |
- sysfw_dev = (PcSysFwDevice*) qdev_create(NULL, "pc-sysfw");
|
|
|
0a122b |
-
|
|
|
0a122b |
- qdev_init_nofail(DEVICE(sysfw_dev));
|
|
|
0a122b |
-
|
|
|
0a122b |
- pflash_drv = drive_get(IF_PFLASH, 0, 0);
|
|
|
0a122b |
-
|
|
|
0a122b |
- if (sysfw_dev->isapc_ram_fw || pflash_drv == NULL) {
|
|
|
0a122b |
-
|
|
|
0a122b |
- old_pc_system_rom_init(rom_memory, sysfw_dev->isapc_ram_fw);
|
|
|
0a122b |
- return;
|
|
|
0a122b |
- }
|
|
|
0a122b |
-
|
|
|
0a122b |
- if (kvm_enabled() && !kvm_readonly_mem_enabled()) {
|
|
|
0a122b |
- /* Older KVM cannot execute from device memory. So, flash memory
|
|
|
0a122b |
- * cannot be used unless the readonly memory kvm capability is present. */
|
|
|
0a122b |
- fprintf(stderr, "qemu: pflash with kvm requires KVM readonly memory support\n");
|
|
|
0a122b |
- exit(1);
|
|
|
0a122b |
- }
|
|
|
0a122b |
-
|
|
|
0a122b |
- pc_system_flash_init(rom_memory, pflash_drv);
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-static Property pcsysfw_properties[] = {
|
|
|
0a122b |
- DEFINE_PROP_UINT8("isapc_ram_fw", PcSysFwDevice, isapc_ram_fw, 0),
|
|
|
0a122b |
- DEFINE_PROP_END_OF_LIST(),
|
|
|
0a122b |
-};
|
|
|
0a122b |
-
|
|
|
0a122b |
-static int pcsysfw_init(DeviceState *dev)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- return 0;
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-static void pcsysfw_class_init (ObjectClass *klass, void *data)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- DeviceClass *dc = DEVICE_CLASS (klass);
|
|
|
0a122b |
-
|
|
|
0a122b |
- set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
|
|
|
0a122b |
- dc->desc = "PC System Firmware";
|
|
|
0a122b |
- dc->init = pcsysfw_init;
|
|
|
0a122b |
- dc->props = pcsysfw_properties;
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-static const TypeInfo pcsysfw_info = {
|
|
|
0a122b |
- .name = "pc-sysfw",
|
|
|
0a122b |
- .parent = TYPE_SYS_BUS_DEVICE,
|
|
|
0a122b |
- .instance_size = sizeof (PcSysFwDevice),
|
|
|
0a122b |
- .class_init = pcsysfw_class_init,
|
|
|
0a122b |
-};
|
|
|
0a122b |
-
|
|
|
0a122b |
-static void pcsysfw_register (void)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- type_register_static (&pcsysfw_info);
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-type_init (pcsysfw_register);
|
|
|
0a122b |
-
|
|
|
0a122b |
diff
|
|
|
0a122b |
index 6a17cf8..09ac433 100644
|
|
|
0a122b |
|
|
|
0a122b |
|
|
|
0a122b |
@@ -1,6 +1,7 @@
|
|
|
0a122b |
obj-$(CONFIG_KVM) += kvm/
|
|
|
0a122b |
obj-y += multiboot.o smbios.o
|
|
|
0a122b |
obj-y += pc.o pc_piix.o pc_q35.o
|
|
|
0a122b |
+obj-y += pc_sysfw.o
|
|
|
0a122b |
obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
|
|
|
0a122b |
|
|
|
0a122b |
obj-y += kvmvapic.o
|
|
|
0a122b |
diff
|
|
|
0a122b |
index 320f668..a0f0b24 100644
|
|
|
0a122b |
|
|
|
0a122b |
|
|
|
0a122b |
@@ -1162,7 +1162,7 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
|
|
|
0a122b |
|
|
|
0a122b |
|
|
|
0a122b |
|
|
|
0a122b |
- pc_system_firmware_init(rom_memory);
|
|
|
0a122b |
+ pc_system_firmware_init(rom_memory, guest_info->isapc_ram_fw);
|
|
|
0a122b |
|
|
|
0a122b |
option_rom_mr = g_malloc(sizeof(*option_rom_mr));
|
|
|
0a122b |
memory_region_init_ram(option_rom_mr, "pc.rom", PC_ROM_SIZE);
|
|
|
0a122b |
diff
|
|
|
0a122b |
index 6f273db..641f3d9 100644
|
|
|
0a122b |
|
|
|
0a122b |
|
|
|
0a122b |
@@ -141,6 +141,7 @@ static void pc_init1(QEMUMachineInitArgs *args,
|
|
|
0a122b |
guest_info->has_acpi_build = has_acpi_build;
|
|
|
0a122b |
|
|
|
0a122b |
guest_info->has_pci_info = has_pci_info;
|
|
|
0a122b |
+ guest_info->isapc_ram_fw = !pci_enabled;
|
|
|
0a122b |
|
|
|
0a122b |
/* allocate ram and load rom/bios */
|
|
|
0a122b |
if (!xen_enabled()) {
|
|
|
0a122b |
@@ -705,11 +706,6 @@ static QEMUMachine isapc_machine = {
|
|
|
0a122b |
.init = pc_init_isa,
|
|
|
0a122b |
.max_cpus = 1,
|
|
|
0a122b |
.compat_props = (GlobalProperty[]) {
|
|
|
0a122b |
- {
|
|
|
0a122b |
- .driver = "pc-sysfw",
|
|
|
0a122b |
- .property = "isapc_ram_fw",
|
|
|
0a122b |
- .value = stringify(1),
|
|
|
0a122b |
- },
|
|
|
0a122b |
{ }
|
|
|
0a122b |
},
|
|
|
0a122b |
DEFAULT_MACHINE_OPTIONS,
|
|
|
0a122b |
diff
|
|
|
0a122b |
index 7e46799..1ac46be 100644
|
|
|
0a122b |
|
|
|
0a122b |
|
|
|
0a122b |
@@ -114,6 +114,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
|
|
|
0a122b |
guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
|
|
|
0a122b |
guest_info->has_pci_info = has_pci_info;
|
|
|
0a122b |
guest_info->has_acpi_build = has_acpi_build;
|
|
|
0a122b |
+ guest_info->isapc_ram_fw = false;
|
|
|
0a122b |
|
|
|
0a122b |
/* allocate ram and load rom/bios */
|
|
|
0a122b |
if (!xen_enabled()) {
|
|
|
0a122b |
diff
|
|
|
0a122b |
new file mode 100644
|
|
|
0a122b |
index 0000000..eb56dee
|
|
|
0a122b |
--- /dev/null
|
|
|
0a122b |
|
|
|
0a122b |
@@ -0,0 +1,185 @@
|
|
|
0a122b |
+/*
|
|
|
0a122b |
+ * QEMU PC System Firmware
|
|
|
0a122b |
+ *
|
|
|
0a122b |
+ * Copyright (c) 2003-2004 Fabrice Bellard
|
|
|
0a122b |
+ * Copyright (c) 2011-2012 Intel Corporation
|
|
|
0a122b |
+ *
|
|
|
0a122b |
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
0a122b |
+ * of this software and associated documentation files (the "Software"), to deal
|
|
|
0a122b |
+ * in the Software without restriction, including without limitation the rights
|
|
|
0a122b |
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
0a122b |
+ * copies of the Software, and to permit persons to whom the Software is
|
|
|
0a122b |
+ * furnished to do so, subject to the following conditions:
|
|
|
0a122b |
+ *
|
|
|
0a122b |
+ * The above copyright notice and this permission notice shall be included in
|
|
|
0a122b |
+ * all copies or substantial portions of the Software.
|
|
|
0a122b |
+ *
|
|
|
0a122b |
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
0a122b |
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
0a122b |
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
0a122b |
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
0a122b |
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
0a122b |
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
0a122b |
+ * THE SOFTWARE.
|
|
|
0a122b |
+ */
|
|
|
0a122b |
+
|
|
|
0a122b |
+#include "sysemu/blockdev.h"
|
|
|
0a122b |
+#include "qemu/error-report.h"
|
|
|
0a122b |
+#include "hw/sysbus.h"
|
|
|
0a122b |
+#include "hw/hw.h"
|
|
|
0a122b |
+#include "hw/i386/pc.h"
|
|
|
0a122b |
+#include "hw/boards.h"
|
|
|
0a122b |
+#include "hw/loader.h"
|
|
|
0a122b |
+#include "sysemu/sysemu.h"
|
|
|
0a122b |
+#include "hw/block/flash.h"
|
|
|
0a122b |
+#include "sysemu/kvm.h"
|
|
|
0a122b |
+
|
|
|
0a122b |
+#define BIOS_FILENAME "bios.bin"
|
|
|
0a122b |
+
|
|
|
0a122b |
+typedef struct PcSysFwDevice {
|
|
|
0a122b |
+ SysBusDevice busdev;
|
|
|
0a122b |
+ uint8_t isapc_ram_fw;
|
|
|
0a122b |
+} PcSysFwDevice;
|
|
|
0a122b |
+
|
|
|
0a122b |
+static void pc_isa_bios_init(MemoryRegion *rom_memory,
|
|
|
0a122b |
+ MemoryRegion *flash_mem,
|
|
|
0a122b |
+ int ram_size)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ int isa_bios_size;
|
|
|
0a122b |
+ MemoryRegion *isa_bios;
|
|
|
0a122b |
+ uint64_t flash_size;
|
|
|
0a122b |
+ void *flash_ptr, *isa_bios_ptr;
|
|
|
0a122b |
+
|
|
|
0a122b |
+ flash_size = memory_region_size(flash_mem);
|
|
|
0a122b |
+
|
|
|
0a122b |
+
|
|
|
0a122b |
+ isa_bios_size = MIN(flash_size, 128 * 1024);
|
|
|
0a122b |
+ isa_bios = g_malloc(sizeof(*isa_bios));
|
|
|
0a122b |
+ memory_region_init_ram(isa_bios, "isa-bios", isa_bios_size);
|
|
|
0a122b |
+ vmstate_register_ram_global(isa_bios);
|
|
|
0a122b |
+ memory_region_add_subregion_overlap(rom_memory,
|
|
|
0a122b |
+ 0x100000 - isa_bios_size,
|
|
|
0a122b |
+ isa_bios,
|
|
|
0a122b |
+ 1);
|
|
|
0a122b |
+
|
|
|
0a122b |
+ /* copy ISA rom image from top of flash memory */
|
|
|
0a122b |
+ flash_ptr = memory_region_get_ram_ptr(flash_mem);
|
|
|
0a122b |
+ isa_bios_ptr = memory_region_get_ram_ptr(isa_bios);
|
|
|
0a122b |
+ memcpy(isa_bios_ptr,
|
|
|
0a122b |
+ ((uint8_t*)flash_ptr) + (flash_size - isa_bios_size),
|
|
|
0a122b |
+ isa_bios_size);
|
|
|
0a122b |
+
|
|
|
0a122b |
+ memory_region_set_readonly(isa_bios, true);
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
+static void pc_system_flash_init(MemoryRegion *rom_memory,
|
|
|
0a122b |
+ DriveInfo *pflash_drv)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ BlockDriverState *bdrv;
|
|
|
0a122b |
+ int64_t size;
|
|
|
0a122b |
+ hwaddr phys_addr;
|
|
|
0a122b |
+ int sector_bits, sector_size;
|
|
|
0a122b |
+ pflash_t *system_flash;
|
|
|
0a122b |
+ MemoryRegion *flash_mem;
|
|
|
0a122b |
+
|
|
|
0a122b |
+ bdrv = pflash_drv->bdrv;
|
|
|
0a122b |
+ size = bdrv_getlength(pflash_drv->bdrv);
|
|
|
0a122b |
+ sector_bits = 12;
|
|
|
0a122b |
+ sector_size = 1 << sector_bits;
|
|
|
0a122b |
+
|
|
|
0a122b |
+ if ((size % sector_size) != 0) {
|
|
|
0a122b |
+ fprintf(stderr,
|
|
|
0a122b |
+ "qemu: PC system firmware (pflash) must be a multiple of 0x%x\n",
|
|
|
0a122b |
+ sector_size);
|
|
|
0a122b |
+ exit(1);
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+
|
|
|
0a122b |
+ phys_addr = 0x100000000ULL - size;
|
|
|
0a122b |
+ system_flash = pflash_cfi01_register(phys_addr, NULL, "system.flash", size,
|
|
|
0a122b |
+ bdrv, sector_size, size >> sector_bits,
|
|
|
0a122b |
+ 1, 0x0000, 0x0000, 0x0000, 0x0000, 0);
|
|
|
0a122b |
+ flash_mem = pflash_cfi01_get_memory(system_flash);
|
|
|
0a122b |
+
|
|
|
0a122b |
+ pc_isa_bios_init(rom_memory, flash_mem, size);
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
+static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ char *filename;
|
|
|
0a122b |
+ MemoryRegion *bios, *isa_bios;
|
|
|
0a122b |
+ int bios_size, isa_bios_size;
|
|
|
0a122b |
+ int ret;
|
|
|
0a122b |
+
|
|
|
0a122b |
+ /* BIOS load */
|
|
|
0a122b |
+ if (bios_name == NULL) {
|
|
|
0a122b |
+ bios_name = BIOS_FILENAME;
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
|
|
|
0a122b |
+ if (filename) {
|
|
|
0a122b |
+ bios_size = get_image_size(filename);
|
|
|
0a122b |
+ } else {
|
|
|
0a122b |
+ bios_size = -1;
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+ if (bios_size <= 0 ||
|
|
|
0a122b |
+ (bios_size % 65536) != 0) {
|
|
|
0a122b |
+ goto bios_error;
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+ bios = g_malloc(sizeof(*bios));
|
|
|
0a122b |
+ memory_region_init_ram(bios, "pc.bios", bios_size);
|
|
|
0a122b |
+ vmstate_register_ram_global(bios);
|
|
|
0a122b |
+ if (!isapc_ram_fw) {
|
|
|
0a122b |
+ memory_region_set_readonly(bios, true);
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+ ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
|
|
|
0a122b |
+ if (ret != 0) {
|
|
|
0a122b |
+ bios_error:
|
|
|
0a122b |
+ fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
|
|
|
0a122b |
+ exit(1);
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+ if (filename) {
|
|
|
0a122b |
+ g_free(filename);
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+
|
|
|
0a122b |
+
|
|
|
0a122b |
+ isa_bios_size = bios_size;
|
|
|
0a122b |
+ if (isa_bios_size > (128 * 1024)) {
|
|
|
0a122b |
+ isa_bios_size = 128 * 1024;
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+ isa_bios = g_malloc(sizeof(*isa_bios));
|
|
|
0a122b |
+ memory_region_init_alias(isa_bios, "isa-bios", bios,
|
|
|
0a122b |
+ bios_size - isa_bios_size, isa_bios_size);
|
|
|
0a122b |
+ memory_region_add_subregion_overlap(rom_memory,
|
|
|
0a122b |
+ 0x100000 - isa_bios_size,
|
|
|
0a122b |
+ isa_bios,
|
|
|
0a122b |
+ 1);
|
|
|
0a122b |
+ if (!isapc_ram_fw) {
|
|
|
0a122b |
+ memory_region_set_readonly(isa_bios, true);
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+
|
|
|
0a122b |
+
|
|
|
0a122b |
+ memory_region_add_subregion(rom_memory,
|
|
|
0a122b |
+ (uint32_t)(-bios_size),
|
|
|
0a122b |
+ bios);
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
+void pc_system_firmware_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ DriveInfo *pflash_drv;
|
|
|
0a122b |
+
|
|
|
0a122b |
+ pflash_drv = drive_get(IF_PFLASH, 0, 0);
|
|
|
0a122b |
+
|
|
|
0a122b |
+ if (isapc_ram_fw || pflash_drv == NULL) {
|
|
|
0a122b |
+
|
|
|
0a122b |
+ old_pc_system_rom_init(rom_memory, isapc_ram_fw);
|
|
|
0a122b |
+ return;
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+
|
|
|
0a122b |
+ if (kvm_enabled() && !kvm_readonly_mem_enabled()) {
|
|
|
0a122b |
+ /* Older KVM cannot execute from device memory. So, flash memory
|
|
|
0a122b |
+ * cannot be used unless the readonly memory kvm capability is present. */
|
|
|
0a122b |
+ fprintf(stderr, "qemu: pflash with kvm requires KVM readonly memory support\n");
|
|
|
0a122b |
+ exit(1);
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+
|
|
|
0a122b |
+ pc_system_flash_init(rom_memory, pflash_drv);
|
|
|
0a122b |
+}
|
|
|
0a122b |
diff
|
|
|
0a122b |
index 5c69abe..413358f 100644
|
|
|
0a122b |
|
|
|
0a122b |
+++ b/include/hw/i386/pc.h
|
|
|
0a122b |
@@ -34,6 +34,7 @@ typedef struct PcPciInfo {
|
|
|
0a122b |
|
|
|
0a122b |
struct PcGuestInfo {
|
|
|
0a122b |
bool has_pci_info;
|
|
|
0a122b |
+ bool isapc_ram_fw;
|
|
|
0a122b |
hwaddr ram_size;
|
|
|
0a122b |
unsigned apic_id_limit;
|
|
|
0a122b |
bool apic_xrupt_override;
|
|
|
0a122b |
@@ -228,7 +229,8 @@ static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
|
|
|
0a122b |
-void pc_system_firmware_init(MemoryRegion *rom_memory);
|
|
|
0a122b |
+void pc_system_firmware_init(MemoryRegion *rom_memory,
|
|
|
0a122b |
+ bool isapc_ram_fw);
|
|
|
0a122b |
|
|
|
0a122b |
|
|
|
0a122b |
void pvpanic_init(ISABus *bus);
|
|
|
0a122b |
--
|
|
|
0a122b |
1.7.1
|
|
|
0a122b |
|