From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Igor Mammedov" <imammedo@redhat.com>,
"Andreas Färber" <afaerber@suse.de>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH 13/27] pc: pass PCInitArgs struct to pc_memory_init()
Date: Wed, 24 Oct 2012 15:49:47 -0200 [thread overview]
Message-ID: <1351101001-14589-14-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1351101001-14589-1-git-send-email-ehabkost@redhat.com>
Instead of having a large list of arguments, just pass the PCInitArgs
struct to pc_memory_init().
This is being done mainly to facilitate the addition of an argument to
be used by bochs_bios_init() (enabling compatibility mode for APIC ID
generation).
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/pc.c | 34 +++++++++++++++-------------------
hw/pc.h | 16 ++++++++--------
hw/pc_piix.c | 45 +++++++++++++++++++--------------------------
3 files changed, 42 insertions(+), 53 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index f92c19f..dce9ce1 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -876,21 +876,14 @@ void pc_cpus_init(PCInitArgs *args)
}
}
-void *pc_memory_init(MemoryRegion *system_memory,
- 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,
- MemoryRegion **ram_memory)
+void *pc_memory_init(PCInitArgs *args)
{
int linux_boot, i;
MemoryRegion *ram, *option_rom_mr;
MemoryRegion *ram_below_4g, *ram_above_4g;
void *fw_cfg;
- linux_boot = (kernel_filename != NULL);
+ linux_boot = (args->qemu_args->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
@@ -898,29 +891,29 @@ void *pc_memory_init(MemoryRegion *system_memory,
*/
ram = g_malloc(sizeof(*ram));
memory_region_init_ram(ram, "pc.ram",
- below_4g_mem_size + above_4g_mem_size);
+ args->below_4g_mem_size + args->above_4g_mem_size);
vmstate_register_ram_global(ram);
- *ram_memory = ram;
+ args->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) {
+ 0, args->below_4g_mem_size);
+ memory_region_add_subregion(args->system_memory, 0, ram_below_4g);
+ if (args->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,
+ args->below_4g_mem_size, args->above_4g_mem_size);
+ memory_region_add_subregion(args->system_memory, 0x100000000ULL,
ram_above_4g);
}
/* Initialize PC system firmware */
- pc_system_firmware_init(rom_memory);
+ pc_system_firmware_init(args->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,
+ memory_region_add_subregion_overlap(args->rom_memory,
PC_ROM_MIN_VGA,
option_rom_mr,
1);
@@ -929,7 +922,10 @@ void *pc_memory_init(MemoryRegion *system_memory,
rom_set_fw(fw_cfg);
if (linux_boot) {
- load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline, below_4g_mem_size);
+ load_linux(fw_cfg, args->qemu_args->kernel_filename,
+ args->qemu_args->initrd_filename,
+ args->qemu_args->kernel_cmdline,
+ args->below_4g_mem_size);
}
for (i = 0; i < nb_option_roms; i++) {
diff --git a/hw/pc.h b/hw/pc.h
index 26388ba..53883f5 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -81,20 +81,20 @@ typedef struct PCInitArgs {
QEMUMachineInitArgs *qemu_args;
bool pci_enabled;
bool kvmclock_enabled;
+
+ /* Memory regions & sizes: */
+ MemoryRegion *system_memory;
+ MemoryRegion *system_io;
+ MemoryRegion *rom_memory;
+ MemoryRegion *ram_memory;
+ ram_addr_t below_4g_mem_size, above_4g_mem_size;
} PCInitArgs;
void pc_register_ferr_irq(qemu_irq irq);
void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
void pc_cpus_init(PCInitArgs *args);
-void *pc_memory_init(MemoryRegion *system_memory,
- 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,
- MemoryRegion **ram_memory);
+void *pc_memory_init(PCInitArgs *args);
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/hw/pc_piix.c b/hw/pc_piix.c
index 57d0c3b..7de8f0d 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -121,7 +121,6 @@ static void ioapic_init(GSIState *gsi_state)
static void pc_init1(PCInitArgs *pc_args)
{
int i;
- ram_addr_t below_4g_mem_size, above_4g_mem_size;
PCIBus *pci_bus;
ISABus *isa_bus;
PCII440FXState *i440fx_state;
@@ -135,20 +134,16 @@ static void pc_init1(PCInitArgs *pc_args)
BusState *idebus[MAX_IDE_BUS];
ISADevice *rtc_state;
ISADevice *floppy;
- MemoryRegion *ram_memory;
MemoryRegion *pci_memory;
- MemoryRegion *rom_memory;
- MemoryRegion *system_memory = get_system_memory();
- MemoryRegion *system_io = get_system_io();
void *fw_cfg = NULL;
QEMUMachineInitArgs *qemu_args = pc_args->qemu_args;
ram_addr_t ram_size = qemu_args->ram_size;
- const char *kernel_filename = qemu_args->kernel_filename;
- const char *kernel_cmdline = qemu_args->kernel_cmdline;
- const char *initrd_filename = qemu_args->initrd_filename;
const char *boot_device = qemu_args->boot_device;
bool pci_enabled = pc_args->pci_enabled;
+ pc_args->system_memory = get_system_memory();
+ pc_args->system_io = get_system_io();
+
pc_cpus_init(pc_args);
if (pc_args->kvmclock_enabled) {
@@ -156,28 +151,26 @@ static void pc_init1(PCInitArgs *pc_args)
}
if (ram_size >= 0xe0000000 ) {
- above_4g_mem_size = ram_size - 0xe0000000;
- below_4g_mem_size = 0xe0000000;
+ pc_args->above_4g_mem_size = ram_size - 0xe0000000;
+ pc_args->below_4g_mem_size = 0xe0000000;
} else {
- above_4g_mem_size = 0;
- below_4g_mem_size = ram_size;
+ pc_args->above_4g_mem_size = 0;
+ pc_args->below_4g_mem_size = ram_size;
}
if (pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, "pci", INT64_MAX);
- rom_memory = pci_memory;
+ pc_args->rom_memory = pci_memory;
} else {
pci_memory = NULL;
- rom_memory = system_memory;
+ pc_args->rom_memory = pc_args->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, &ram_memory);
+ /* pc_memory_init() will set pc_args->ram_memory */
+ fw_cfg = pc_memory_init(pc_args);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
@@ -191,18 +184,18 @@ static void pc_init1(PCInitArgs *pc_args)
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,
+ pc_args->system_memory, pc_args->system_io,
+ ram_size, pc_args->below_4g_mem_size,
+ 0x100000000ULL - pc_args->below_4g_mem_size,
+ 0x100000000ULL + pc_args->above_4g_mem_size,
(sizeof(hwaddr) == 4
? 0
: ((uint64_t)1 << 62)),
- pci_memory, ram_memory);
+ pci_memory, pc_args->ram_memory);
} else {
pci_bus = NULL;
i440fx_state = NULL;
- isa_bus = isa_bus_new(NULL, system_io);
+ isa_bus = isa_bus_new(NULL, pc_args->system_io);
no_hpet = 1;
}
isa_bus_irqs(isa_bus, gsi);
@@ -264,8 +257,8 @@ static void pc_init1(PCInitArgs *pc_args)
audio_init(isa_bus, pci_enabled ? pci_bus : NULL);
- pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
- floppy, idebus[0], idebus[1], rtc_state);
+ pc_cmos_init(pc_args->below_4g_mem_size, pc_args->above_4g_mem_size,
+ boot_device, floppy, idebus[0], idebus[1], rtc_state);
if (pci_enabled && usb_enabled) {
pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
--
1.7.11.7
next prev parent reply other threads:[~2012-10-24 18:25 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-24 17:49 [Qemu-devel] Subject: [PATCH 00/27] Fix APIC-ID-based CPU topology, take 3 Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 01/27] move I/O-related definitions from qemu-common.h to a new header (qemu-stdio.h) Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 02/27] cpus.h: include qemu-stdio.h Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 03/27] hw/apic.c: rename bit functions to not conflict with bitops.h Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 04/27] target-i386: initialize APIC at CPU level Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 05/27] kvm: create kvm_arch_vcpu_id() function Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 06/27] target-i386: kvm: set vcpu_id to APIC ID instead of CPU index Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 07/27] pc: pc_init1(): always use rom_memory on pc_memory_init() call Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 08/27] pc: pc_init1(): remove MemoryRegion arguments Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 09/27] pc: pc_init1(): get QEMUMachineInitArgs argument Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 10/27] pc: create PCInitArgs struct Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 11/27] pc: add PC_DEFAULT_CPU_MODEL #define Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 12/27] pc: add PCInitArgs parameter to pc_cpus_init() Eduardo Habkost
2012-10-24 17:49 ` Eduardo Habkost [this message]
2012-10-24 17:49 ` [Qemu-devel] [PATCH 14/27] pc: use FWCfgState* instead of void* for fw_cfg data Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 15/27] pc: rename bochs_bios_init() to pc_bios_init() Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 16/27] pc: pass PCInitArgs struct " Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 17/27] xen_machine_pv: use cpu_init() instead of cpu_x86_init() Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 18/27] pc: isolate the code that create CPUs Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 19/27] cpu_x86_init: check for x86_cpu_realize() errors Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 20/27] target-i386: do not call x86_cpu_realize() on cpu_x86_init() Eduardo Habkost
2012-10-31 16:32 ` Igor Mammedov
2012-10-31 16:43 ` Andreas Färber
2012-10-31 17:10 ` Eduardo Habkost
2012-11-01 12:53 ` Igor Mammedov
2012-10-31 17:01 ` Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 21/27] fw_cfg: remove FW_CFG_MAX_CPUS from fw_cfg_init() Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 22/27] pc: set CPU APIC ID explicitly Eduardo Habkost
2012-11-01 14:04 ` Igor Mammedov
2012-11-01 14:30 ` Eduardo Habkost
2012-11-01 14:50 ` Igor Mammedov
2012-10-24 17:49 ` [Qemu-devel] [PATCH 23/27] pc: set fw_cfg data based on APIC ID calculation Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 24/27] tests: support target-specific unit tests Eduardo Habkost
2012-10-24 17:49 ` [Qemu-devel] [PATCH 25/27] target-i386: topology & APIC ID utility functions Eduardo Habkost
2012-10-24 17:50 ` [Qemu-devel] [PATCH 26/27] pc: create separate init function for pc-1.3 Eduardo Habkost
2012-10-24 18:12 ` Michael S. Tsirkin
2012-10-25 13:23 ` Eduardo Habkost
2012-10-24 17:50 ` [Qemu-devel] [PATCH 27/27] pc: generate APIC IDs according to CPU topology Eduardo Habkost
2012-11-01 14:46 ` Igor Mammedov
2012-11-01 15:16 ` Eduardo Habkost
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=1351101001-14589-14-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=afaerber@suse.de \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--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).