qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marcel Apfelbaum" <marcel.a@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Alexander Graf" <agraf@suse.de>,
	"Don Slutz" <dslutz@verizon.com>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [RFC v3 35/35] pc: Move {ram, pci, rom}_memory variables to PCMachineState
Date: Fri,  4 Jul 2014 21:10:02 -0300	[thread overview]
Message-ID: <1404519002-10224-36-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1404519002-10224-1-git-send-email-ehabkost@redhat.com>

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v2:
 * Use PCMachineState fields inside pc_memory_init() too
---
 hw/i386/pc.c         |  8 +++-----
 hw/i386/pc_piix.c    | 19 ++++++++-----------
 hw/i386/pc_q35.c     | 22 +++++++++-------------
 include/hw/i386/pc.h |  5 +++--
 4 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index b028669..a89756e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1194,8 +1194,6 @@ FWCfgState *pc_memory_init(MachineState *machine,
                            MemoryRegion *system_memory,
                            ram_addr_t below_4g_mem_size,
                            ram_addr_t above_4g_mem_size,
-                           MemoryRegion *rom_memory,
-                           MemoryRegion **ram_memory,
                            PcGuestInfo *guest_info)
 {
     int linux_boot, i;
@@ -1215,7 +1213,7 @@ FWCfgState *pc_memory_init(MachineState *machine,
     ram = g_malloc(sizeof(*ram));
     memory_region_allocate_system_memory(ram, NULL, "pc.ram",
                                          machine->ram_size);
-    *ram_memory = ram;
+    pcms->ram_memory = ram;
     ram_below_4g = g_malloc(sizeof(*ram_below_4g));
     memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", ram,
                              0, below_4g_mem_size);
@@ -1269,12 +1267,12 @@ FWCfgState *pc_memory_init(MachineState *machine,
     }
 
     /* Initialize PC system firmware */
-    pc_system_firmware_init(rom_memory, guest_info->isapc_ram_fw);
+    pc_system_firmware_init(pcms->rom_memory, guest_info->isapc_ram_fw);
 
     option_rom_mr = g_malloc(sizeof(*option_rom_mr));
     memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE);
     vmstate_register_ram_global(option_rom_mr);
-    memory_region_add_subregion_overlap(rom_memory,
+    memory_region_add_subregion_overlap(pcms->rom_memory,
                                         PC_ROM_MIN_VGA,
                                         option_rom_mr,
                                         1);
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 3716f98..255bcbb 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -82,9 +82,6 @@ static void pc_init1(MachineState *machine)
     BusState *idebus[MAX_IDE_BUS];
     ISADevice *rtc_state;
     ISADevice *floppy;
-    MemoryRegion *ram_memory;
-    MemoryRegion *pci_memory;
-    MemoryRegion *rom_memory;
     DeviceState *icc_bridge;
     FWCfgState *fw_cfg = NULL;
     PcGuestInfo *guest_info;
@@ -125,7 +122,7 @@ static void pc_init1(MachineState *machine)
     }
 
     if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
-                                      &ram_memory) != 0) {
+                                      &pcms->ram_memory) != 0) {
         fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
         exit(1);
     }
@@ -141,12 +138,12 @@ static void pc_init1(MachineState *machine)
     }
 
     if (pci_enabled) {
-        pci_memory = g_new(MemoryRegion, 1);
-        memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
-        rom_memory = pci_memory;
+        pcms->pci_memory = g_new(MemoryRegion, 1);
+        memory_region_init(pcms->pci_memory, NULL, "pci", UINT64_MAX);
+        pcms->rom_memory = pcms->pci_memory;
     } else {
-        pci_memory = NULL;
-        rom_memory = system_memory;
+        pcms->pci_memory = NULL;
+        pcms->rom_memory = system_memory;
     }
 
     guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
@@ -168,7 +165,7 @@ static void pc_init1(MachineState *machine)
     if (!xen_enabled()) {
         fw_cfg = pc_memory_init(machine, system_memory,
                                 below_4g_mem_size, above_4g_mem_size,
-                                rom_memory, &ram_memory, guest_info);
+                                guest_info);
     }
 
     gsi_state = g_malloc0(sizeof(*gsi_state));
@@ -185,7 +182,7 @@ static void pc_init1(MachineState *machine)
                               system_memory, system_io, machine->ram_size,
                               below_4g_mem_size,
                               above_4g_mem_size,
-                              pci_memory, ram_memory);
+                              pcms->pci_memory, pcms->ram_memory);
     } else {
         pci_bus = NULL;
         i440fx_state = NULL;
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index d978567..f8ea2b5 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -63,9 +63,6 @@ static void pc_q35_init(MachineState *machine)
     BusState *idebus[MAX_SATA_PORTS];
     ISADevice *rtc_state;
     ISADevice *floppy;
-    MemoryRegion *pci_memory;
-    MemoryRegion *rom_memory;
-    MemoryRegion *ram_memory;
     GSIState *gsi_state;
     ISABus *isa_bus;
     qemu_irq *cpu_irq;
@@ -115,7 +112,7 @@ static void pc_q35_init(MachineState *machine)
     }
 
     if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
-                                      &ram_memory) != 0) {
+                                      &pcms->ram_memory) != 0) {
         fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
         exit(1);
     }
@@ -131,12 +128,12 @@ static void pc_q35_init(MachineState *machine)
 
     /* pci enabled */
     if (pci_enabled) {
-        pci_memory = g_new(MemoryRegion, 1);
-        memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
-        rom_memory = pci_memory;
+        pcms->pci_memory = g_new(MemoryRegion, 1);
+        memory_region_init(pcms->pci_memory, NULL, "pci", UINT64_MAX);
+        pcms->rom_memory = pcms->pci_memory;
     } else {
-        pci_memory = NULL;
-        rom_memory = get_system_memory();
+        pcms->pci_memory = NULL;
+        pcms->rom_memory = get_system_memory();
     }
 
     guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
@@ -155,8 +152,7 @@ static void pc_q35_init(MachineState *machine)
     /* allocate ram and load rom/bios */
     if (!xen_enabled()) {
         pc_memory_init(machine, get_system_memory(),
-                       below_4g_mem_size, above_4g_mem_size,
-                       rom_memory, &ram_memory, guest_info);
+                       below_4g_mem_size, above_4g_mem_size, guest_info);
     }
 
     /* irq lines */
@@ -173,8 +169,8 @@ static void pc_q35_init(MachineState *machine)
     q35_host = Q35_HOST_DEVICE(qdev_create(NULL, TYPE_Q35_HOST_DEVICE));
 
     object_property_add_child(qdev_get_machine(), "q35", OBJECT(q35_host), NULL);
-    q35_host->mch.ram_memory = ram_memory;
-    q35_host->mch.pci_address_space = pci_memory;
+    q35_host->mch.ram_memory = pcms->ram_memory;
+    q35_host->mch.pci_address_space = pcms->pci_memory;
     q35_host->mch.system_memory = get_system_memory();
     q35_host->mch.address_space_io = get_system_io();
     q35_host->mch.below_4g_mem_size = below_4g_mem_size;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 38d571b..3b0f886 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -32,6 +32,9 @@ struct PCMachineState {
     /* <public> */
     ram_addr_t hotplug_memory_base;
     MemoryRegion hotplug_memory;
+    MemoryRegion *ram_memory;
+    MemoryRegion *pci_memory;
+    MemoryRegion *rom_memory;
 
     HotplugHandler *acpi_dev;
 
@@ -208,8 +211,6 @@ FWCfgState *pc_memory_init(MachineState *machine,
                            MemoryRegion *system_memory,
                            ram_addr_t below_4g_mem_size,
                            ram_addr_t above_4g_mem_size,
-                           MemoryRegion *rom_memory,
-                           MemoryRegion **ram_memory,
                            PcGuestInfo *guest_info);
 qemu_irq *pc_allocate_cpu_irq(void);
 DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
-- 
1.9.3

      parent reply	other threads:[~2014-07-05  0:12 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-05  0:09 [Qemu-devel] [RFC v3 00/35] Convert PC machine-types to QOM classes Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 01/35] pc_piix: Add missing compat code to pc-0.1[0123] Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 02/35] target-i385: Add kvmclock_enabled static Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 03/35] pc_piix: Reuse pc_compat_1_2() on pc_init_pci_no_kvmclock() Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 04/35] pc: Replace tabs with spaces on pc.h Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 05/35] vl.c: Use qdev_prop_register_global() for single globals Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 06/35] piix: Move pc-0.14 qxl compat properties to PC_COMPAT_0_14 Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 07/35] piix: Move pc-0.13 virtio-9p-pci compat to PC_COMPAT_0_13 Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 08/35] piix: Move pc-0.1[23] rombar compat props " Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 09/35] piix: Move pc-0.11 drive version compat props TO PC_COMPAT_0_11 Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 10/35] machine: Make compat_props a linked list Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 11/35] pc: Register machine classes directly instead of using QEMUMachine Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 12/35] pc: Eliminate pc_common_machine_options() Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 13/35] pc: Eliminate pc_default_machine_options() Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 14/35] piix: Eliminate pc_i440fx_machine_options() Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 15/35] q35: Eliminate pc_q35_machine_options() Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 16/35] q35: Eliminate pc_q35_1_4_machine_options() Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 17/35] pc: Eliminate all *_machine_options() functions Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 18/35] machine: Eliminate QEMUMachine.compat_props Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 19/35] pc: Rename pc_machine variable to pcms Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 20/35] pc: Move pci_enabled parameter to PCMachineClass Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 21/35] q35: Use PCMachineClass.pci_enabled field Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 22/35] pc: Move kvmclock_enabled to PCMachineClass Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 23/35] pc: Move smbios_legacy_mode " Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 24/35] pc: Move smbios_defaults " Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 25/35] pc: Move has_acpi_build " Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 26/35] pc: Move has_pci_info " Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 27/35] pc: Move gigabyte_align " Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 28/35] pc: Move has_reserved_memory " Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 29/35] pc: Move option_rom_has_mr/rom_file_has_mr to MachineClass Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 30/35] piix: Eliminate pc_init_pci() Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 31/35] piix: Introduce struct PCI440FXMachineClass Eduardo Habkost
2014-07-05  0:09 ` [Qemu-devel] [RFC v3 32/35] pc: Create common machine init function Eduardo Habkost
2014-07-05  0:10 ` [Qemu-devel] [RFC v3 33/35] pc: Eliminate empty or trivial compat functions Eduardo Habkost
2014-07-05  0:10 ` [Qemu-devel] [RFC v3 34/35] piix: Move compat/init functions closer to corresponding class_init Eduardo Habkost
2014-07-05  0:10 ` Eduardo Habkost [this message]

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=1404519002-10224-36-git-send-email-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=dslutz@verizon.com \
    --cc=imammedo@redhat.com \
    --cc=marcel.a@redhat.com \
    --cc=mst@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).