From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Anthony Liguori <aliguori@us.ibm.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
Markus Armbruster <armbru@redhat.com>,
Avi Kivity <avi@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH 15/15] i440fx: move ram initialization into i440fx-pmc
Date: Thu, 26 Jan 2012 13:01:00 -0600 [thread overview]
Message-ID: <1327604460-31142-16-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1327604460-31142-1-git-send-email-aliguori@us.ibm.com>
---
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
next prev parent reply other threads:[~2012-01-26 19:02 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-26 19:00 [Qemu-devel] [RFC 00/15] Refactor PC machine to take advantage of QOM Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 01/15] pc: merge pc_piix.c into pc.c Anthony Liguori
2012-01-26 19:40 ` Anthony Liguori
2012-01-27 8:50 ` Jan Kiszka
2012-01-27 13:07 ` Anthony Liguori
2012-01-27 13:32 ` Jan Kiszka
2012-01-27 14:06 ` Anthony Liguori
2012-01-27 14:15 ` Jan Kiszka
2012-01-27 14:23 ` Anthony Liguori
2012-01-27 14:03 ` Andreas Färber
2012-01-27 14:14 ` Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 02/15] pc: make some functions static Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 03/15] piix3: make PIIX3-xen a subclass of PIIX3 Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 04/15] piix: prepare for composition Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 05/15] piix: create the HPET and RTC through composition Anthony Liguori
2012-01-31 14:26 ` Jan Kiszka
2012-01-31 14:43 ` Anthony Liguori
2012-01-31 14:49 ` Jan Kiszka
2012-01-31 14:54 ` Anthony Liguori
2012-01-31 14:56 ` Jan Kiszka
2012-01-31 15:04 ` Anthony Liguori
2012-01-31 16:02 ` Jan Kiszka
2012-01-26 19:00 ` [Qemu-devel] [PATCH 06/15] piix: create i8254 " Anthony Liguori
2012-01-31 14:34 ` Jan Kiszka
2012-01-31 14:47 ` Anthony Liguori
2012-01-31 14:51 ` Jan Kiszka
2012-01-31 14:56 ` Anthony Liguori
2012-01-31 16:42 ` Jan Kiszka
2012-01-31 16:49 ` Anthony Liguori
2012-01-31 16:56 ` Jan Kiszka
2012-01-31 14:58 ` Paolo Bonzini
2012-01-31 16:04 ` Jan Kiszka
2012-01-31 16:12 ` Anthony Liguori
2012-01-31 16:19 ` Jan Kiszka
2012-01-31 16:47 ` Anthony Liguori
2012-01-31 16:59 ` Paolo Bonzini
2012-01-26 19:00 ` [Qemu-devel] [PATCH 07/15] i440fx: eliminate i440fx_common_init Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 08/15] i440fx: introduce some saner naming conventions Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 09/15] i440fx: create the PMC through composition Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 10/15] i440fx: move some logic to realize and make inheritance from PCIHost explicit Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 11/15] i440fx-pmc: refactor to take properties for memory geometry Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 12/15] i440fx-pmc: calculate PCI memory hole directly Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 13/15] i440fx: allocate MemoryRegion for pci memory space Anthony Liguori
2012-01-26 19:00 ` [Qemu-devel] [PATCH 14/15] i440fx: move bios loading to i440fx Anthony Liguori
2012-01-31 14:38 ` Jan Kiszka
2012-01-31 14:50 ` Anthony Liguori
2012-01-31 14:53 ` Jan Kiszka
2012-01-31 14:57 ` Anthony Liguori
2012-01-31 15:01 ` Jan Kiszka
2012-01-26 19:01 ` Anthony Liguori [this message]
2012-01-26 19:12 ` [Qemu-devel] [RFC 00/15] Refactor PC machine to take advantage of QOM Peter Maydell
2012-01-26 19:36 ` Anthony Liguori
2012-01-29 10:42 ` Avi Kivity
2012-01-26 19:57 ` Markus Armbruster
2012-01-26 20:00 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1327604460-31142-16-git-send-email-aliguori@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=armbru@redhat.com \
--cc=avi@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).