[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 15/15] move bios loading to MemoryController and
From: |
Hu Tao |
Subject: |
[Qemu-devel] [PATCH RFC 15/15] move bios loading to MemoryController and ISAPc |
Date: |
Thu, 20 Jun 2013 18:15:14 +0800 |
Signed-off-by: Hu Tao <address@hidden>
---
hw/i386/pc.c | 35 ++++++++++++++---------------------
hw/i386/pc_piix.c | 13 ++-----------
hw/i386/pc_q35.c | 13 ++-----------
hw/isa/isa_pc.c | 11 +++++++++++
include/hw/i386/pc.h | 7 +++----
include/hw/isa/isa_pc.h | 1 +
6 files changed, 33 insertions(+), 47 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index c28baa2..5bb4989 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1023,36 +1023,19 @@ void pc_acpi_init(const char *default_dsdt)
}
}
-FWCfgState *pc_memory_init(MemoryRegion *system_memory,
- const char *kernel_filename,
+FWCfgState *pc_memory_init(const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
ram_addr_t below_4g_mem_size,
- ram_addr_t above_4g_mem_size,
- MemoryRegion *rom_memory)
+ ram_addr_t above_4g_mem_size)
{
- int linux_boot, i;
- MemoryRegion *option_rom_mr;
+ int i;
FWCfgState *fw_cfg;
- linux_boot = (kernel_filename != NULL);
-
-
- /* Initialize PC system firmware */
- pc_system_firmware_init(rom_memory);
-
- option_rom_mr = g_malloc(sizeof(*option_rom_mr));
- memory_region_init_ram(option_rom_mr, "pc.rom", PC_ROM_SIZE);
- vmstate_register_ram_global(option_rom_mr);
- memory_region_add_subregion_overlap(rom_memory,
- PC_ROM_MIN_VGA,
- option_rom_mr,
- 1);
-
fw_cfg = bochs_bios_init();
rom_set_fw(fw_cfg);
- if (linux_boot) {
+ if (kernel_filename) {
load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline,
below_4g_mem_size);
}
@@ -1380,6 +1363,16 @@ static int memory_controller_init(PCIDevice *dev)
dev->config[0x72] = 0x02;
cpu_smm_register(c->set_smm, m);
+
+ pc_system_firmware_init(m->pci_address_space);
+
+ memory_region_init_ram(&m->option_roms, "pc.rom", PC_ROM_SIZE);
+ vmstate_register_ram_global(&m->option_roms);
+ memory_region_add_subregion_overlap(m->pci_address_space,
+ PC_ROM_MIN_VGA,
+ &m->option_roms,
+ 1);
+
return 0;
}
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 2e84cc2..fb056df 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -86,7 +86,6 @@ static void pc_init1(MemoryRegion *system_memory,
ISADevice *rtc_state;
ISADevice *floppy;
MemoryRegion *pci_memory;
- MemoryRegion *rom_memory;
DeviceState *icc_bridge;
FWCfgState *fw_cfg = NULL;
ISAPc *isapc = NULL;
@@ -135,18 +134,10 @@ static void pc_init1(MemoryRegion *system_memory,
}
isa_bus_irqs(isa_bus, gsi);
- if (pci_enabled) {
- rom_memory = pci_memory;
- } else {
- rom_memory = system_memory;
- }
-
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
- fw_cfg = pc_memory_init(system_memory,
- kernel_filename, kernel_cmdline,
initrd_filename,
- below_4g_mem_size, above_4g_mem_size,
- rom_memory);
+ fw_cfg = pc_memory_init(kernel_filename, kernel_cmdline,
initrd_filename,
+ below_4g_mem_size, above_4g_mem_size);
}
if (kvm_irqchip_in_kernel()) {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index fde83b4..5fe14bb 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -64,7 +64,6 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
BusState *idebus[MAX_SATA_PORTS];
ISADevice *rtc_state;
ISADevice *floppy;
- MemoryRegion *rom_memory;
GSIState *gsi_state;
ISABus *isa_bus;
int pci_enabled = 1;
@@ -96,18 +95,10 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
below_4g_mem_size = ram_size;
}
- /* pci enabled */
- if (pci_enabled) {
- rom_memory = &q35_host->pci_address_space;
- } else {
- rom_memory = get_system_memory();
- }
-
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
- pc_memory_init(get_system_memory(), kernel_filename, kernel_cmdline,
- initrd_filename, below_4g_mem_size, above_4g_mem_size,
- rom_memory);
+ pc_memory_init(kernel_filename, kernel_cmdline,
+ initrd_filename, below_4g_mem_size, above_4g_mem_size);
}
/* irq lines */
diff --git a/hw/isa/isa_pc.c b/hw/isa/isa_pc.c
index f73cddb..ae9f2c8 100644
--- a/hw/isa/isa_pc.c
+++ b/hw/isa/isa_pc.c
@@ -1,4 +1,6 @@
+#include "hw/i386/pc.h"
#include "hw/isa/isa_pc.h"
+#include "hw/loader.h"
static void isa_pc_realize(DeviceState *dev, Error **errp)
{
@@ -17,6 +19,15 @@ static void isa_pc_realize(DeviceState *dev, Error **errp)
memory_region_init_ram(&isapc->ram, "pc.ram", isapc->ram_size);
vmstate_register_ram_global(&isapc->ram);
memory_region_add_subregion(isapc->address_space_mem, 0, &isapc->ram);
+
+ pc_system_firmware_init(isapc->address_space_mem);
+
+ memory_region_init_ram(&isapc->option_roms, "pc.rom", PC_ROM_SIZE);
+ vmstate_register_ram_global(&isapc->option_roms);
+ memory_region_add_subregion_overlap(isapc->address_space_mem,
+ PC_ROM_MIN_VGA,
+ &isapc->option_roms,
+ 1);
}
static void isa_pc_class_init(ObjectClass *klass, void *data)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index f06008b..5d36558 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -36,6 +36,7 @@ typedef struct MemoryController {
MemoryRegion *system_memory;
MemoryRegion *pci_address_space;
MemoryRegion *ram_memory;
+ MemoryRegion option_roms;
MemoryRegion pci_hole;
MemoryRegion pci_hole_64bit;
PAMMemoryRegion pam_regions[13];
@@ -128,13 +129,11 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int
level);
void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge);
void pc_hot_add_cpu(const int64_t id, Error **errp);
void pc_acpi_init(const char *default_dsdt);
-FWCfgState *pc_memory_init(MemoryRegion *system_memory,
- const char *kernel_filename,
+FWCfgState *pc_memory_init(const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
ram_addr_t below_4g_mem_size,
- ram_addr_t above_4g_mem_size,
- MemoryRegion *rom_memory);
+ ram_addr_t above_4g_mem_size);
qemu_irq *pc_allocate_cpu_irq(void);
DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
diff --git a/include/hw/isa/isa_pc.h b/include/hw/isa/isa_pc.h
index 91a0701..33a2e95 100644
--- a/include/hw/isa/isa_pc.h
+++ b/include/hw/isa/isa_pc.h
@@ -19,6 +19,7 @@ struct ISAPc {
MemoryRegion *address_space_mem;
MemoryRegion *address_space_io;
+ MemoryRegion option_roms;
MemoryRegion ram;
ram_addr_t ram_size;
};
--
1.8.3.1
- [Qemu-devel] [PATCH RFC 04/15] i440fx: prepare for composition, (continued)
- [Qemu-devel] [PATCH RFC 04/15] i440fx: prepare for composition, Hu Tao, 2013/06/20
- [Qemu-devel] [PATCH RFC 03/15] i440fx: rename i440FX-pcihost to i440FX, Hu Tao, 2013/06/20
- [Qemu-devel] [PATCH RFC 05/15] i440fx pmc: create pmc through comosition, Hu Tao, 2013/06/20
- [Qemu-devel] [PATCH RFC 09/15] i440fx-pmc: move ram initialization into i440fx-pmc, Hu Tao, 2013/06/20
- [Qemu-devel] [PATCH RFC 06/15] i440fx-pmc: calculate PCI memory hole directly, Hu Tao, 2013/06/20
- [Qemu-devel] [PATCH RFC 08/15] q35-mch: create pci address space, Hu Tao, 2013/06/20
- [Qemu-devel] [PATCH RFC 07/15] i440fx-pmc: create pci address space, Hu Tao, 2013/06/20
- [Qemu-devel] [PATCH RFC 10/15] q35-mch: move ram initialization into q35-mch, Hu Tao, 2013/06/20
- [Qemu-devel] [PATCH RFC 11/15] introduce ISAPc, Hu Tao, 2013/06/20
- [Qemu-devel] [PATCH RFC 12/15] introduce memory controller, Hu Tao, 2013/06/20
- [Qemu-devel] [PATCH RFC 15/15] move bios loading to MemoryController and ISAPc,
Hu Tao <=
- [Qemu-devel] [PATCH RFC 13/15] i440fx pmc: inherit from MemoryController, Hu Tao, 2013/06/20
- [Qemu-devel] [PATCH RFC 14/15] q35 mch: inherit from MemoryController, Hu Tao, 2013/06/20