[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 15/15] i440fx: move ram initialization into i440fx-p
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 15/15] i440fx: move ram initialization into i440fx-pmc |
Date: |
Thu, 26 Jan 2012 13:01:00 -0600 |
---
hw/pc.c | 44 ++------------------------------------------
hw/pc.h | 6 ------
hw/piix_pci.c | 46 ++++++++++++++++++++++++++++++++--------------
3 files changed, 34 insertions(+), 62 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 4964a64..90bd638 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -993,36 +993,13 @@ static void pc_memory_init(MemoryRegion *system_memory,
const char *kernel_cmdline,
const char *initrd_filename,
ram_addr_t below_4g_mem_size,
- ram_addr_t above_4g_mem_size,
- MemoryRegion **ram_memory)
+ ram_addr_t above_4g_mem_size)
{
int linux_boot, i;
- MemoryRegion *ram, *ram_below_4g, *ram_above_4g;
void *fw_cfg;
linux_boot = (kernel_filename != NULL);
- /* Allocate RAM. We allocate it as a single memory region and use
- * aliases to address portions of it, mostly for backwards compatibility
- * with older qemus that used qemu_ram_alloc().
- */
- ram = g_malloc(sizeof(*ram));
- memory_region_init_ram(ram, "pc.ram",
- below_4g_mem_size + above_4g_mem_size);
- vmstate_register_ram_global(ram);
- *ram_memory = ram;
- ram_below_4g = g_malloc(sizeof(*ram_below_4g));
- memory_region_init_alias(ram_below_4g, "ram-below-4g", ram,
- 0, below_4g_mem_size);
- memory_region_add_subregion(system_memory, 0, ram_below_4g);
- if (above_4g_mem_size > 0) {
- ram_above_4g = g_malloc(sizeof(*ram_above_4g));
- memory_region_init_alias(ram_above_4g, "ram-above-4g", ram,
- below_4g_mem_size, above_4g_mem_size);
- memory_region_add_subregion(system_memory, 0x100000000ULL,
- ram_above_4g);
- }
-
fw_cfg = bochs_bios_init();
rom_set_fw(fw_cfg);
@@ -1239,8 +1216,6 @@ static void pc_init1(MemoryRegion *system_memory,
BusState *idebus[MAX_IDE_BUS];
ISADevice *rtc_state;
ISADevice *floppy;
- MemoryRegion *ram_memory = NULL;
- MemoryRegion *pci_memory;
DeviceState *dev;
pc_cpus_init(cpu_model);
@@ -1257,19 +1232,11 @@ static void pc_init1(MemoryRegion *system_memory,
below_4g_mem_size = ram_size;
}
- if (pci_enabled) {
- pci_memory = g_new(MemoryRegion, 1);
- memory_region_init(pci_memory, "pci", INT64_MAX);
- } else {
- pci_memory = NULL;
- }
-
/* allocate ram and load rom/bios */
if (!xen_enabled()) {
pc_memory_init(system_memory,
kernel_filename, kernel_cmdline, initrd_filename,
- below_4g_mem_size, above_4g_mem_size,
- &ram_memory);
+ below_4g_mem_size, above_4g_mem_size);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
@@ -1284,13 +1251,6 @@ static void pc_init1(MemoryRegion *system_memory,
if (pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
system_memory, system_io, ram_size,
- below_4g_mem_size,
- 0x100000000ULL - below_4g_mem_size,
- 0x100000000ULL + above_4g_mem_size,
- (sizeof(target_phys_addr_t) == 4
- ? 0
- : ((uint64_t)1 << 62)),
- pci_memory, ram_memory,
bios_name);
} else {
pci_bus = NULL;
diff --git a/hw/pc.h b/hw/pc.h
index 530f417..71bbfb3 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -161,12 +161,6 @@ PCIBus *i440fx_init(I440FXPMCState **pi440fx_state, int
*piix_devfn,
MemoryRegion *address_space_mem,
MemoryRegion *address_space_io,
ram_addr_t ram_size,
- target_phys_addr_t pci_hole_start,
- target_phys_addr_t pci_hole_size,
- target_phys_addr_t pci_hole64_start,
- target_phys_addr_t pci_hole64_size,
- MemoryRegion *pci_memory,
- MemoryRegion *ram_memory,
const char *bios_name);
/* piix4.c */
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 6dda019..0c2226b 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -111,7 +111,11 @@ struct I440FXPMCState {
PAMMemoryRegion pam_regions[13];
MemoryRegion smram_region;
uint8_t smm_enabled;
+
ram_addr_t ram_size;
+ MemoryRegion ram;
+ MemoryRegion ram_below_4g;
+ MemoryRegion ram_above_4g;
};
#define TYPE_I440FX "i440FX"
@@ -390,24 +394,46 @@ static void i440fx_initfn(Object *obj)
memory_region_init(&s->pci_address_space, "pci", INT64_MAX);
}
-static int i440fx_pmc_initfn(PCIDevice *dev)
+static int i440fx_pmc_realize(PCIDevice *dev)
{
I440FXPMCState *d = DO_UPCAST(I440FXPMCState, dev, dev);
ram_addr_t ram_size;
+ uint64_t below_4g_mem_size, above_4g_mem_size;
uint64_t pci_hole_start, pci_hole_size;
uint64_t pci_hole64_start, pci_hole64_size;
g_assert(d->ram_size != 0);
g_assert(d->system_memory != NULL);
g_assert(d->pci_address_space != NULL);
- g_assert(d->ram_memory != NULL);
- /* Calculate PCI geometry from RAM size */
+ /* Calculate memory geometry from RAM size */
if (d->ram_size > I440FX_PMC_PCI_HOLE) {
- pci_hole_start = I440FX_PMC_PCI_HOLE;
+ below_4g_mem_size = I440FX_PMC_PCI_HOLE;
+ above_4g_mem_size = d->ram_size - I440FX_PMC_PCI_HOLE;
} else {
- pci_hole_start = d->ram_size;
+ below_4g_mem_size = d->ram_size;
+ above_4g_mem_size = 0;
+ }
+
+ /* Allocate RAM. We allocate it as a single memory region and use
+ * aliases to address portions of it, mostly for backwards compatibility
+ * with older qemus that used qemu_ram_alloc().
+ */
+ memory_region_init_ram(&d->ram, "pc.ram",
+ below_4g_mem_size + above_4g_mem_size);
+ vmstate_register_ram_global(&d->ram);
+
+ memory_region_init_alias(&d->ram_below_4g, "ram-below-4g", &d->ram,
+ 0, below_4g_mem_size);
+ memory_region_add_subregion(d->system_memory, 0, &d->ram_below_4g);
+ if (above_4g_mem_size > 0) {
+ memory_region_init_alias(&d->ram_above_4g, "ram-above-4g", &d->ram,
+ below_4g_mem_size, above_4g_mem_size);
+ memory_region_add_subregion(d->system_memory, 0x100000000ULL,
+ &d->ram_above_4g);
}
+
+ pci_hole_start = below_4g_mem_size;
pci_hole_size = I440FX_PMC_PCI_HOLE_END - pci_hole_start;
pci_hole64_start = I440FX_PMC_PCI_HOLE_END + d->ram_size - pci_hole_start;
@@ -451,11 +477,6 @@ PCIBus *i440fx_init(I440FXPMCState **pi440fx_state, int
*piix3_devfn,
MemoryRegion *address_space_mem,
MemoryRegion *address_space_io,
ram_addr_t ram_size,
- target_phys_addr_t pci_hole_start,
- target_phys_addr_t pci_hole_size,
- target_phys_addr_t pci_hole64_start,
- target_phys_addr_t pci_hole64_size,
- MemoryRegion *pci_address_space, MemoryRegion *ram_memory,
const char *bios_name)
{
I440FXState *s;
@@ -472,9 +493,6 @@ PCIBus *i440fx_init(I440FXPMCState **pi440fx_state, int
*piix3_devfn,
g_free(s->bios_name);
s->bios_name = g_strdup(bios_name);
}
-
- /* FIXME pmc should create ram_memory */
- s->pmc.ram_memory = ram_memory;
s->pmc.ram_size = ram_size;
qdev_set_parent_bus(DEVICE(s), sysbus_get_default());
@@ -737,7 +755,7 @@ static void i440fx_pmc_class_init(ObjectClass *klass, void
*data)
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->no_hotplug = 1;
- k->init = i440fx_pmc_initfn;
+ k->init = i440fx_pmc_realize;
k->config_write = i440fx_pmc_write_config;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_82441;
--
1.7.4.1
- Re: [Qemu-devel] [PATCH 05/15] piix: create the HPET and RTC through composition, (continued)
[Qemu-devel] [PATCH 15/15] i440fx: move ram initialization into i440fx-pmc,
Anthony Liguori <=
[Qemu-devel] [PATCH 11/15] i440fx-pmc: refactor to take properties for memory geometry, Anthony Liguori, 2012/01/26
Re: [Qemu-devel] [RFC 00/15] Refactor PC machine to take advantage of QOM, Peter Maydell, 2012/01/26
[Qemu-devel] [PATCH 10/15] i440fx: move some logic to realize and make inheritance from PCIHost explicit, Anthony Liguori, 2012/01/26
[Qemu-devel] [PATCH 09/15] i440fx: create the PMC through composition, Anthony Liguori, 2012/01/26
[Qemu-devel] [PATCH 07/15] i440fx: eliminate i440fx_common_init, Anthony Liguori, 2012/01/26