Patchwork [06/24] QEMUMachine: pass address space to machine init function

login
register
mail settings
Submitter Avi Kivity
Date Aug. 24, 2011, 10:11 a.m.
Message ID <1314180683-8227-7-git-send-email-avi@redhat.com>
Download mbox | patch
Permalink /patch/111327/
State New
Headers show

Comments

Avi Kivity - Aug. 24, 2011, 10:11 a.m.
Avoids get_system_memory() everywhere.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/an5206.c                   |    4 ++-
 hw/axis_dev88.c               |    4 ++-
 hw/boards.h                   |    5 +++-
 hw/collie.c                   |    4 ++-
 hw/dummy_m68k.c               |    4 ++-
 hw/gumstix.c                  |    8 +++++-
 hw/integratorcp.c             |    4 ++-
 hw/leon3.c                    |    4 ++-
 hw/lm32_boards.c              |    8 +++++-
 hw/mainstone.c                |    4 ++-
 hw/mcf5208.c                  |    4 ++-
 hw/milkymist.c                |    5 +++-
 hw/mips_fulong2e.c            |    4 ++-
 hw/mips_jazz.c                |    8 +++++-
 hw/mips_malta.c               |    4 ++-
 hw/mips_mipssim.c             |    4 ++-
 hw/mips_r4k.c                 |    4 ++-
 hw/musicpal.c                 |    4 ++-
 hw/nseries.c                  |   18 +++++++++++----
 hw/omap_sx1.c                 |    8 +++++-
 hw/palm.c                     |    4 ++-
 hw/pc_piix.c                  |   31 +++++++++++++++++---------
 hw/petalogix_ml605_mmu.c      |    4 ++-
 hw/petalogix_s3adsp1800_mmu.c |    4 ++-
 hw/ppc405_boards.c            |    8 +++++-
 hw/ppc440_bamboo.c            |    4 ++-
 hw/ppc_newworld.c             |    4 ++-
 hw/ppc_oldworld.c             |    4 ++-
 hw/ppc_prep.c                 |    4 ++-
 hw/ppce500_mpc8544ds.c        |    4 ++-
 hw/r2d.c                      |    4 ++-
 hw/realview.c                 |   33 ++++++++++++++++++++-------
 hw/s390-virtio.c              |    4 ++-
 hw/shix.c                     |    4 ++-
 hw/spitz.c                    |   32 +++++++++++++++++++-------
 hw/stellaris.c                |   18 +++++++++++----
 hw/sun4m.c                    |   48 ++++++++++++++++++++++++++++++----------
 hw/sun4u.c                    |   12 +++++++--
 hw/syborg.c                   |    4 ++-
 hw/tosa.c                     |    4 ++-
 hw/versatilepb.c              |   19 ++++++++++++----
 hw/vexpress.c                 |    4 ++-
 hw/virtex_ml507.c             |    4 ++-
 hw/xen_machine_pv.c           |    4 ++-
 hw/z2.c                       |    4 ++-
 vl.c                          |    3 +-
 46 files changed, 282 insertions(+), 102 deletions(-)
Avi Kivity - Aug. 24, 2011, 12:26 p.m.
On 08/24/2011 02:18 PM, Avi Kivity wrote:
> On 08/24/2011 01:53 PM, Peter Maydell wrote:
>> >  The purpose here is to allow removal of get_system_memory() from
>> >  the general code base.
>>
>> The right way to remove get_system_memory() from the general code base
>> is to actually model things correctly, for instance by having machine
>> models create a container memory region into which they insert the
>> memory regions for all the devices which currently use sysbus_mmio_map
>> to map themselves, and then pass the container memory region to the
>> "master" end of the bus, ie the CPU.
>>
>
> I think you're right.  This also allows eventual removal of system_io 
> on anything non-x86.
>
> So a replacement would look like:
>
> (before)
>
> -static void pc_init_isa(ram_addr_t ram_size,
> +static void pc_init_isa(MemoryRegion *address_space_mem,
> +                        MemoryRegion *address_space_io,
> +                        ram_addr_t ram_size,
>                          const char *boot_device,
>                          const char *kernel_filename,
>                          const char *kernel_cmdline,
> @@ -259,15 +265,17 @@ static void pc_init_isa(ram_addr_t ram_size,
>  {
>      if (cpu_model == NULL)
>          cpu_model = "486";
> -    pc_init1(get_system_memory(),
> -             get_system_io(),
> +    pc_init1(address_space_mem,
> +             address_space_io,
>               ram_size, boot_device,
>               kernel_filename, kernel_cmdline,
>               initrd_filename, cpu_model, 0, 1);
>  }
>
> (after)
> @@ -259,15 +265,17 @@ static void pc_init_isa(ram_addr_t ram_size,
>  {
> +    MemoryRegion *address_space_mem, *address_space_io;
> +
> +    setup_system_memory(&address_space_mem,&address_space_io);
>      if (cpu_model == NULL)
>          cpu_model = "486";
> -    pc_init1(get_system_memory(),
> -             get_system_io(),
> +    pc_init1(address_space_mem,
> +             address_space_io,
>               ram_size, boot_device,
>               kernel_filename, kernel_cmdline,
>               initrd_filename, cpu_model, 0, 1);
>  }
>
>
> Later on, we'd refine the setup_system_memory() calls, for example not 
> to create the io space on non-x86.
>
> A possible complication is whether anything currently uses 
> system_memory before ->init is called.  Anyone know?
>

Okay, it looks like I can just drop the patch and call 
get_system_memory() in the various _init functions.  This avoids the 
complication.  We can tidy up get_system_memory() later.

Patch

diff --git a/hw/an5206.c b/hw/an5206.c
index 04ca420..e34de39 100644
--- a/hw/an5206.c
+++ b/hw/an5206.c
@@ -28,7 +28,9 @@  void irq_info(Monitor *mon)
 
 /* Board init.  */
 
-static void an5206_init(ram_addr_t ram_size,
+static void an5206_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c
index 06200e2..cfc89c2 100644
--- a/hw/axis_dev88.c
+++ b/hw/axis_dev88.c
@@ -244,7 +244,9 @@  static CPUWriteMemoryFunc * const gpio_write[] = {
 static struct cris_load_info li;
 
 static
-void axisdev88_init (ram_addr_t ram_size,
+void axisdev88_init (MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
diff --git a/hw/boards.h b/hw/boards.h
index 716fd7b..5c12ce7 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -4,8 +4,11 @@ 
 #define HW_BOARDS_H
 
 #include "qdev.h"
+#include "memory.h"
 
-typedef void QEMUMachineInitFunc(ram_addr_t ram_size,
+typedef void QEMUMachineInitFunc(MemoryRegion *address_space_mem,
+                                 MemoryRegion *address_space_io,
+                                 ram_addr_t ram_size,
                                  const char *boot_device,
                                  const char *kernel_filename,
                                  const char *kernel_cmdline,
diff --git a/hw/collie.c b/hw/collie.c
index 156404d..9b724aa 100644
--- a/hw/collie.c
+++ b/hw/collie.c
@@ -19,7 +19,9 @@  static struct arm_boot_info collie_binfo = {
     .ram_size = 0x20000000,
 };
 
-static void collie_init(ram_addr_t ram_size,
+static void collie_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
diff --git a/hw/dummy_m68k.c b/hw/dummy_m68k.c
index eed9e38..2de69ad 100644
--- a/hw/dummy_m68k.c
+++ b/hw/dummy_m68k.c
@@ -15,7 +15,9 @@ 
 
 /* Board init.  */
 
-static void dummy_m68k_init(ram_addr_t ram_size,
+static void dummy_m68k_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
diff --git a/hw/gumstix.c b/hw/gumstix.c
index 853f7e1..ccdd834 100644
--- a/hw/gumstix.c
+++ b/hw/gumstix.c
@@ -41,7 +41,9 @@ 
 
 static const int sector_len = 128 * 1024;
 
-static void connex_init(ram_addr_t ram_size,
+static void connex_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
@@ -80,7 +82,9 @@  static void connex_init(ram_addr_t ram_size,
                     qdev_get_gpio_in(cpu->gpio, 36));
 }
 
-static void verdex_init(ram_addr_t ram_size,
+static void verdex_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index 2814108..3d4b339 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -450,7 +450,9 @@  static struct arm_boot_info integrator_binfo = {
     .board_id = 0x113,
 };
 
-static void integratorcp_init(ram_addr_t ram_size,
+static void integratorcp_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
diff --git a/hw/leon3.c b/hw/leon3.c
index a62a941..efe6c7c 100644
--- a/hw/leon3.c
+++ b/hw/leon3.c
@@ -92,7 +92,9 @@  static void leon3_set_pil_in(void *opaque, uint32_t pil_in)
     }
 }
 
-static void leon3_generic_hw_init(ram_addr_t  ram_size,
+static void leon3_generic_hw_init(MemoryRegion *address_space_mem,
+                                  MemoryRegion *address_space_io,
+                                  ram_addr_t  ram_size,
                                   const char *boot_device,
                                   const char *kernel_filename,
                                   const char *kernel_cmdline,
diff --git a/hw/lm32_boards.c b/hw/lm32_boards.c
index d18aad7..fced5d1 100644
--- a/hw/lm32_boards.c
+++ b/hw/lm32_boards.c
@@ -68,7 +68,9 @@  static void main_cpu_reset(void *opaque)
     env->deba = reset_info->flash_base;
 }
 
-static void lm32_evr_init(ram_addr_t ram_size_not_used,
+static void lm32_evr_init(MemoryRegion *address_space_mem,
+                          MemoryRegion *address_space_io,
+                          ram_addr_t ram_size_not_used,
                           const char *boot_device,
                           const char *kernel_filename,
                           const char *kernel_cmdline,
@@ -156,7 +158,9 @@  static void lm32_evr_init(ram_addr_t ram_size_not_used,
     qemu_register_reset(main_cpu_reset, reset_info);
 }
 
-static void lm32_uclinux_init(ram_addr_t ram_size_not_used,
+static void lm32_uclinux_init(MemoryRegion *address_space_mem,
+                          MemoryRegion *address_space_io,
+                          ram_addr_t ram_size_not_used,
                           const char *boot_device,
                           const char *kernel_filename,
                           const char *kernel_cmdline,
diff --git a/hw/mainstone.c b/hw/mainstone.c
index 4792f0e..227f6f8 100644
--- a/hw/mainstone.c
+++ b/hw/mainstone.c
@@ -165,7 +165,9 @@  static void mainstone_common_init(ram_addr_t ram_size,
     arm_load_kernel(cpu->env, &mainstone_binfo);
 }
 
-static void mainstone_init(ram_addr_t ram_size,
+static void mainstone_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
diff --git a/hw/mcf5208.c b/hw/mcf5208.c
index 8fe507f..f4d4fbd 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -197,7 +197,9 @@  static void mcf5208_sys_init(qemu_irq *pic)
     }
 }
 
-static void mcf5208evb_init(ram_addr_t ram_size,
+static void mcf5208evb_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
diff --git a/hw/milkymist.c b/hw/milkymist.c
index 93288c8..e599917 100644
--- a/hw/milkymist.c
+++ b/hw/milkymist.c
@@ -29,6 +29,7 @@ 
 #include "blockdev.h"
 #include "milkymist-hw.h"
 #include "lm32.h"
+#include "memory.h"
 
 #define BIOS_FILENAME    "mmone-bios.bin"
 #define BIOS_OFFSET      0x00860000
@@ -72,7 +73,9 @@  static void main_cpu_reset(void *opaque)
 }
 
 static void
-milkymist_init(ram_addr_t ram_size_not_used,
+milkymist_init(MemoryRegion *address_space_mem,
+                          MemoryRegion *address_space_io,
+                          ram_addr_t ram_size_not_used,
                           const char *boot_device,
                           const char *kernel_filename,
                           const char *kernel_cmdline,
diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index ec8c88e..8cd25ed 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -251,7 +251,9 @@  static void cpu_request_exit(void *opaque, int irq, int level)
     }
 }
 
-static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,
+static void mips_fulong2e_init(MemoryRegion *address_space_mem,
+                        MemoryRegion *address_space_io,
+                        ram_addr_t ram_size, const char *boot_device,
                         const char *kernel_filename, const char *kernel_cmdline,
                         const char *initrd_filename, const char *cpu_model)
 {
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 84ce061..d6fb82a 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -281,7 +281,9 @@  void mips_jazz_init (ram_addr_t ram_size,
 }
 
 static
-void mips_magnum_init (ram_addr_t ram_size,
+void mips_magnum_init (MemoryRegion *address_space_mem,
+                       MemoryRegion *address_space_io,
+                       ram_addr_t ram_size,
                        const char *boot_device,
                        const char *kernel_filename, const char *kernel_cmdline,
                        const char *initrd_filename, const char *cpu_model)
@@ -290,7 +292,9 @@  void mips_magnum_init (ram_addr_t ram_size,
 }
 
 static
-void mips_pica61_init (ram_addr_t ram_size,
+void mips_pica61_init (MemoryRegion *address_space_mem,
+                       MemoryRegion *address_space_io,
+                       ram_addr_t ram_size,
                        const char *boot_device,
                        const char *kernel_filename, const char *kernel_cmdline,
                        const char *initrd_filename, const char *cpu_model)
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 86a8ba0..ceb6254 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -755,7 +755,9 @@  static void cpu_request_exit(void *opaque, int irq, int level)
 }
 
 static
-void mips_malta_init (ram_addr_t ram_size,
+void mips_malta_init (MemoryRegion *address_space_mem,
+                      MemoryRegion *address_space_io,
+                      ram_addr_t ram_size,
                       const char *boot_device,
                       const char *kernel_filename, const char *kernel_cmdline,
                       const char *initrd_filename, const char *cpu_model)
diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c
index 0d46cc4..67e115b 100644
--- a/hw/mips_mipssim.c
+++ b/hw/mips_mipssim.c
@@ -113,7 +113,9 @@  static void main_cpu_reset(void *opaque)
 }
 
 static void
-mips_mipssim_init (ram_addr_t ram_size,
+mips_mipssim_init (MemoryRegion *address_space_mem,
+                   MemoryRegion *address_space_io,
+                   ram_addr_t ram_size,
                    const char *boot_device,
                    const char *kernel_filename, const char *kernel_cmdline,
                    const char *initrd_filename, const char *cpu_model)
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index 9d90568..7a07bcd 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -156,7 +156,9 @@  static void main_cpu_reset(void *opaque)
 
 static const int sector_len = 32 * 1024;
 static
-void mips_r4k_init (ram_addr_t ram_size,
+void mips_r4k_init (MemoryRegion *address_space_mem,
+                    MemoryRegion *address_space_io,
+                    ram_addr_t ram_size,
                     const char *boot_device,
                     const char *kernel_filename, const char *kernel_cmdline,
                     const char *initrd_filename, const char *cpu_model)
diff --git a/hw/musicpal.c b/hw/musicpal.c
index 63dd391..becd579 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -1483,7 +1483,9 @@  static struct arm_boot_info musicpal_binfo = {
     .board_id = 0x20e,
 };
 
-static void musicpal_init(ram_addr_t ram_size,
+static void musicpal_init(MemoryRegion *address_space_mem,
+               MemoryRegion *address_space_io,
+               ram_addr_t ram_size,
                const char *boot_device,
                const char *kernel_filename, const char *kernel_cmdline,
                const char *initrd_filename, const char *cpu_model)
diff --git a/hw/nseries.c b/hw/nseries.c
index f7aae7a..ec695ec 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -1266,7 +1266,9 @@  static int n810_atag_setup(const struct arm_boot_info *info, void *p)
     return n8x0_atag_setup(p, 810);
 }
 
-static void n8x0_init(ram_addr_t ram_size, const char *boot_device,
+static void n8x0_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size, const char *boot_device,
                 const char *kernel_filename,
                 const char *kernel_cmdline, const char *initrd_filename,
                 const char *cpu_model, struct arm_boot_info *binfo, int model)
@@ -1378,22 +1380,28 @@  static struct arm_boot_info n810_binfo = {
     .atag_board = n810_atag_setup,
 };
 
-static void n800_init(ram_addr_t ram_size,
+static void n800_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
 {
-    return n8x0_init(ram_size, boot_device,
+    return n8x0_init(address_space_mem, address_space_io,
+                    ram_size, boot_device,
                     kernel_filename, kernel_cmdline, initrd_filename,
                     cpu_model, &n800_binfo, 800);
 }
 
-static void n810_init(ram_addr_t ram_size,
+static void n810_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
 {
-    return n8x0_init(ram_size, boot_device,
+    return n8x0_init(address_space_mem, address_space_io,
+                    ram_size, boot_device,
                     kernel_filename, kernel_cmdline, initrd_filename,
                     cpu_model, &n810_binfo, 810);
 }
diff --git a/hw/omap_sx1.c b/hw/omap_sx1.c
index a7b687b..e1cceec 100644
--- a/hw/omap_sx1.c
+++ b/hw/omap_sx1.c
@@ -214,7 +214,9 @@  static void sx1_init(ram_addr_t ram_size,
     //~ qemu_console_resize(ds, 640, 480);
 }
 
-static void sx1_init_v1(ram_addr_t ram_size,
+static void sx1_init_v1(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
@@ -223,7 +225,9 @@  static void sx1_init_v1(ram_addr_t ram_size,
                 kernel_cmdline, initrd_filename, cpu_model, 1);
 }
 
-static void sx1_init_v2(ram_addr_t ram_size,
+static void sx1_init_v2(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
diff --git a/hw/palm.c b/hw/palm.c
index 4c67e75..7714a93 100644
--- a/hw/palm.c
+++ b/hw/palm.c
@@ -193,7 +193,9 @@  static struct arm_boot_info palmte_binfo = {
     .board_id = 0x331,
 };
 
-static void palmte_init(ram_addr_t ram_size,
+static void palmte_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 75d96d9..f7f7865 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -222,35 +222,41 @@  static void pc_init1(MemoryRegion *system_memory,
     }
 }
 
-static void pc_init_pci(ram_addr_t ram_size,
+static void pc_init_pci(MemoryRegion *address_space_mem,
+                        MemoryRegion *address_space_io,
+                        ram_addr_t ram_size,
                         const char *boot_device,
                         const char *kernel_filename,
                         const char *kernel_cmdline,
                         const char *initrd_filename,
                         const char *cpu_model)
 {
-    pc_init1(get_system_memory(),
-             get_system_io(),
+    pc_init1(address_space_mem,
+             address_space_io,
              ram_size, boot_device,
              kernel_filename, kernel_cmdline,
              initrd_filename, cpu_model, 1, 1);
 }
 
-static void pc_init_pci_no_kvmclock(ram_addr_t ram_size,
+static void pc_init_pci_no_kvmclock(MemoryRegion *address_space_mem,
+                                    MemoryRegion *address_space_io,
+                                    ram_addr_t ram_size,
                                     const char *boot_device,
                                     const char *kernel_filename,
                                     const char *kernel_cmdline,
                                     const char *initrd_filename,
                                     const char *cpu_model)
 {
-    pc_init1(get_system_memory(),
-             get_system_io(),
+    pc_init1(address_space_mem,
+             address_space_io,
              ram_size, boot_device,
              kernel_filename, kernel_cmdline,
              initrd_filename, cpu_model, 1, 0);
 }
 
-static void pc_init_isa(ram_addr_t ram_size,
+static void pc_init_isa(MemoryRegion *address_space_mem,
+                        MemoryRegion *address_space_io,
+                        ram_addr_t ram_size,
                         const char *boot_device,
                         const char *kernel_filename,
                         const char *kernel_cmdline,
@@ -259,15 +265,17 @@  static void pc_init_isa(ram_addr_t ram_size,
 {
     if (cpu_model == NULL)
         cpu_model = "486";
-    pc_init1(get_system_memory(),
-             get_system_io(),
+    pc_init1(address_space_mem,
+             address_space_io,
              ram_size, boot_device,
              kernel_filename, kernel_cmdline,
              initrd_filename, cpu_model, 0, 1);
 }
 
 #ifdef CONFIG_XEN
-static void pc_xen_hvm_init(ram_addr_t ram_size,
+static void pc_xen_hvm_init(MemoryRegion *address_space_mem,
+                            MemoryRegion *address_space_io,
+                            ram_addr_t ram_size,
                             const char *boot_device,
                             const char *kernel_filename,
                             const char *kernel_cmdline,
@@ -277,7 +285,8 @@  static void pc_xen_hvm_init(ram_addr_t ram_size,
     if (xen_hvm_init() != 0) {
         hw_error("xen hardware virtual machine initialisation failed");
     }
-    pc_init_pci_no_kvmclock(ram_size, boot_device,
+    pc_init_pci_no_kvmclock(address_space_mem, address_space_io,
+                            ram_size, boot_device,
                             kernel_filename, kernel_cmdline,
                             initrd_filename, cpu_model);
     xen_vcpu_init();
diff --git a/hw/petalogix_ml605_mmu.c b/hw/petalogix_ml605_mmu.c
index e3a66e5..b0758ea 100644
--- a/hw/petalogix_ml605_mmu.c
+++ b/hw/petalogix_ml605_mmu.c
@@ -134,7 +134,9 @@  static uint64_t translate_kernel_address(void *opaque, uint64_t addr)
 #define AXIDMA_BASEADDR 0x84600000
 
 static void
-petalogix_ml605_init(ram_addr_t ram_size,
+petalogix_ml605_init(MemoryRegion *address_space_mem,
+                          MemoryRegion *address_space_io,
+                          ram_addr_t ram_size,
                           const char *boot_device,
                           const char *kernel_filename,
                           const char *kernel_cmdline,
diff --git a/hw/petalogix_s3adsp1800_mmu.c b/hw/petalogix_s3adsp1800_mmu.c
index 589e8ca..b5d9f8a 100644
--- a/hw/petalogix_s3adsp1800_mmu.c
+++ b/hw/petalogix_s3adsp1800_mmu.c
@@ -111,7 +111,9 @@  static uint64_t translate_kernel_address(void *opaque, uint64_t addr)
 }
 
 static void
-petalogix_s3adsp1800_init(ram_addr_t ram_size,
+petalogix_s3adsp1800_init(MemoryRegion *address_space_mem,
+                          MemoryRegion *address_space_io,
+                          ram_addr_t ram_size,
                           const char *boot_device,
                           const char *kernel_filename,
                           const char *kernel_cmdline,
diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c
index dec165e..90eb98e 100644
--- a/hw/ppc405_boards.c
+++ b/hw/ppc405_boards.c
@@ -170,7 +170,9 @@  static void ref405ep_fpga_init (uint32_t base)
     qemu_register_reset(&ref405ep_fpga_reset, fpga);
 }
 
-static void ref405ep_init (ram_addr_t ram_size,
+static void ref405ep_init (MemoryRegion *address_space_mem,
+                           MemoryRegion *address_space_io,
+                           ram_addr_t ram_size,
                            const char *boot_device,
                            const char *kernel_filename,
                            const char *kernel_cmdline,
@@ -498,7 +500,9 @@  static void taihu_cpld_init (uint32_t base)
     qemu_register_reset(&taihu_cpld_reset, cpld);
 }
 
-static void taihu_405ep_init(ram_addr_t ram_size,
+static void taihu_405ep_init(MemoryRegion *address_space_mem,
+                             MemoryRegion *address_space_io,
+                             ram_addr_t ram_size,
                              const char *boot_device,
                              const char *kernel_filename,
                              const char *kernel_cmdline,
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index 1addb68..d43f8ba 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -88,7 +88,9 @@  out:
     return ret;
 }
 
-static void bamboo_init(ram_addr_t ram_size,
+static void bamboo_init(MemoryRegion *address_space_mem,
+                        MemoryRegion *address_space_io,
+                        ram_addr_t ram_size,
                         const char *boot_device,
                         const char *kernel_filename,
                         const char *kernel_cmdline,
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index 4727e07..68b719b 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -127,7 +127,9 @@  static target_phys_addr_t round_page(target_phys_addr_t addr)
 }
 
 /* PowerPC Mac99 hardware initialisation */
-static void ppc_core99_init (ram_addr_t ram_size,
+static void ppc_core99_init (MemoryRegion *address_space_mem,
+                             MemoryRegion *address_space_io,
+                             ram_addr_t ram_size,
                              const char *boot_device,
                              const char *kernel_filename,
                              const char *kernel_cmdline,
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index 0071fc9..b471257 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -65,7 +65,9 @@  static target_phys_addr_t round_page(target_phys_addr_t addr)
     return (addr + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
 }
 
-static void ppc_heathrow_init (ram_addr_t ram_size,
+static void ppc_heathrow_init (MemoryRegion *address_space_mem,
+                               MemoryRegion *address_space_io,
+                               ram_addr_t ram_size,
                                const char *boot_device,
                                const char *kernel_filename,
                                const char *kernel_cmdline,
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 515de42..1d9de45 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -527,7 +527,9 @@  static void cpu_request_exit(void *opaque, int irq, int level)
 }
 
 /* PowerPC PREP hardware initialisation */
-static void ppc_prep_init (ram_addr_t ram_size,
+static void ppc_prep_init (MemoryRegion *address_space_mem,
+                           MemoryRegion *address_space_io,
+                           ram_addr_t ram_size,
                            const char *boot_device,
                            const char *kernel_filename,
                            const char *kernel_cmdline,
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index 1274a3e..37efb83 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -218,7 +218,9 @@  static void mpc8544ds_cpu_reset(void *opaque)
     mmubooke_create_initial_mapping(env, 0, 0);
 }
 
-static void mpc8544ds_init(ram_addr_t ram_size,
+static void mpc8544ds_init(MemoryRegion *address_space_mem,
+                         MemoryRegion *address_space_io,
+                         ram_addr_t ram_size,
                          const char *boot_device,
                          const char *kernel_filename,
                          const char *kernel_cmdline,
diff --git a/hw/r2d.c b/hw/r2d.c
index 96a7ff8..923fd4e 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -223,7 +223,9 @@  static struct __attribute__((__packed__))
     char kernel_cmdline[256];
 } boot_params;
 
-static void r2d_init(ram_addr_t ram_size,
+static void r2d_init(MemoryRegion *address_space_mem,
+              MemoryRegion *address_space_io,
+              ram_addr_t ram_size,
               const char *boot_device,
 	      const char *kernel_filename, const char *kernel_cmdline,
 	      const char *initrd_filename, const char *cpu_model)
diff --git a/hw/realview.c b/hw/realview.c
index 549bb15..9b30331 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -18,6 +18,7 @@ 
 #include "boards.h"
 #include "bitbang_i2c.h"
 #include "blockdev.h"
+#include "memory.h"
 
 #define SMP_BOOT_ADDR 0xe0000000
 
@@ -118,7 +119,9 @@  static const int realview_board_id[] = {
     0x76d
 };
 
-static void realview_init(ram_addr_t ram_size,
+static void realview_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model,
@@ -378,7 +381,9 @@  static void realview_init(ram_addr_t ram_size,
     arm_load_kernel(first_cpu, &realview_binfo);
 }
 
-static void realview_eb_init(ram_addr_t ram_size,
+static void realview_eb_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
@@ -386,11 +391,14 @@  static void realview_eb_init(ram_addr_t ram_size,
     if (!cpu_model) {
         cpu_model = "arm926";
     }
-    realview_init(ram_size, boot_device, kernel_filename, kernel_cmdline,
+    realview_init(address_space_mem, address_space_io,
+                  ram_size, boot_device, kernel_filename, kernel_cmdline,
                   initrd_filename, cpu_model, BOARD_EB);
 }
 
-static void realview_eb_mpcore_init(ram_addr_t ram_size,
+static void realview_eb_mpcore_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
@@ -398,11 +406,14 @@  static void realview_eb_mpcore_init(ram_addr_t ram_size,
     if (!cpu_model) {
         cpu_model = "arm11mpcore";
     }
-    realview_init(ram_size, boot_device, kernel_filename, kernel_cmdline,
+    realview_init(address_space_mem, address_space_io,
+                  ram_size, boot_device, kernel_filename, kernel_cmdline,
                   initrd_filename, cpu_model, BOARD_EB_MPCORE);
 }
 
-static void realview_pb_a8_init(ram_addr_t ram_size,
+static void realview_pb_a8_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
@@ -410,11 +421,14 @@  static void realview_pb_a8_init(ram_addr_t ram_size,
     if (!cpu_model) {
         cpu_model = "cortex-a8";
     }
-    realview_init(ram_size, boot_device, kernel_filename, kernel_cmdline,
+    realview_init(address_space_mem, address_space_io,
+                  ram_size, boot_device, kernel_filename, kernel_cmdline,
                   initrd_filename, cpu_model, BOARD_PB_A8);
 }
 
-static void realview_pbx_a9_init(ram_addr_t ram_size,
+static void realview_pbx_a9_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
@@ -422,7 +436,8 @@  static void realview_pbx_a9_init(ram_addr_t ram_size,
     if (!cpu_model) {
         cpu_model = "cortex-a9";
     }
-    realview_init(ram_size, boot_device, kernel_filename, kernel_cmdline,
+    realview_init(address_space_mem, address_space_io,
+                  ram_size, boot_device, kernel_filename, kernel_cmdline,
                   initrd_filename, cpu_model, BOARD_PBX_A9);
 }
 
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index acbf026..78a77c0 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -131,7 +131,9 @@  int s390_virtio_hypercall(CPUState *env, uint64_t mem, uint64_t hypercall)
 }
 
 /* PC hardware initialisation */
-static void s390_init(ram_addr_t my_ram_size,
+static void s390_init(MemoryRegion *address_space_mem,
+                      MemoryRegion *address_space_io,
+                      ram_addr_t my_ram_size,
                       const char *boot_device,
                       const char *kernel_filename,
                       const char *kernel_cmdline,
diff --git a/hw/shix.c b/hw/shix.c
index 638bf16..0209f6a 100644
--- a/hw/shix.c
+++ b/hw/shix.c
@@ -47,7 +47,9 @@  void pic_info(Monitor *mon)
     /* XXXXX */
 }
 
-static void shix_init(ram_addr_t ram_size,
+static void shix_init(MemoryRegion *address_space_mem,
+               MemoryRegion *address_space_io,
+               ram_addr_t ram_size,
                const char *boot_device,
 	       const char *kernel_filename, const char *kernel_cmdline,
 	       const char *initrd_filename, const char *cpu_model)
diff --git a/hw/spitz.c b/hw/spitz.c
index c05b5f7..cac4669 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -893,7 +893,9 @@  static struct arm_boot_info spitz_binfo = {
     .ram_size = 0x04000000,
 };
 
-static void spitz_common_init(ram_addr_t ram_size,
+static void spitz_common_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *kernel_filename,
                 const char *kernel_cmdline, const char *initrd_filename,
                 const char *cpu_model, enum spitz_model_e model, int arm_id)
@@ -946,39 +948,51 @@  static void spitz_common_init(ram_addr_t ram_size,
     sl_bootparam_write(SL_PXA_PARAM_BASE);
 }
 
-static void spitz_init(ram_addr_t ram_size,
+static void spitz_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
 {
-    spitz_common_init(ram_size, kernel_filename,
+    spitz_common_init(address_space_mem, address_space_io,
+                ram_size, kernel_filename,
                 kernel_cmdline, initrd_filename, cpu_model, spitz, 0x2c9);
 }
 
-static void borzoi_init(ram_addr_t ram_size,
+static void borzoi_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
 {
-    spitz_common_init(ram_size, kernel_filename,
+    spitz_common_init(address_space_mem, address_space_io,
+                ram_size, kernel_filename,
                 kernel_cmdline, initrd_filename, cpu_model, borzoi, 0x33f);
 }
 
-static void akita_init(ram_addr_t ram_size,
+static void akita_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
 {
-    spitz_common_init(ram_size, kernel_filename,
+    spitz_common_init(address_space_mem, address_space_io,
+                ram_size, kernel_filename,
                 kernel_cmdline, initrd_filename, cpu_model, akita, 0x2e8);
 }
 
-static void terrier_init(ram_addr_t ram_size,
+static void terrier_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
 {
-    spitz_common_init(ram_size, kernel_filename,
+    spitz_common_init(address_space_mem, address_space_io,
+                ram_size, kernel_filename,
                 kernel_cmdline, initrd_filename, cpu_model, terrier, 0x33f);
 }
 
diff --git a/hw/stellaris.c b/hw/stellaris.c
index 9b0db7f..f47b06e 100644
--- a/hw/stellaris.c
+++ b/hw/stellaris.c
@@ -1250,7 +1250,9 @@  static stellaris_board_info stellaris_boards[] = {
   }
 };
 
-static void stellaris_init(const char *kernel_filename, const char *cpu_model,
+static void stellaris_init(MemoryRegion *address_space_mem,
+                           MemoryRegion *address_space_io,
+                           const char *kernel_filename, const char *cpu_model,
                            stellaris_board_info *board)
 {
     static const int uart_irq[] = {5, 6, 33, 34};
@@ -1377,20 +1379,26 @@  static void stellaris_init(const char *kernel_filename, const char *cpu_model,
 }
 
 /* FIXME: Figure out how to generate these from stellaris_boards.  */
-static void lm3s811evb_init(ram_addr_t ram_size,
+static void lm3s811evb_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
 {
-    stellaris_init(kernel_filename, cpu_model, &stellaris_boards[0]);
+    stellaris_init(address_space_mem, address_space_io,
+                   kernel_filename, cpu_model, &stellaris_boards[0]);
 }
 
-static void lm3s6965evb_init(ram_addr_t ram_size,
+static void lm3s6965evb_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
 {
-    stellaris_init(kernel_filename, cpu_model, &stellaris_boards[1]);
+    stellaris_init(address_space_mem, address_space_io,
+                   kernel_filename, cpu_model, &stellaris_boards[1]);
 }
 
 static QEMUMachine lm3s811evb_machine = {
diff --git a/hw/sun4m.c b/hw/sun4m.c
index dcaed38..6abfd44 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -1252,7 +1252,9 @@  static const struct sun4m_hwdef sun4m_hwdefs[] = {
 };
 
 /* SPARCstation 5 hardware initialisation */
-static void ss5_init(ram_addr_t RAM_size,
+static void ss5_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t RAM_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
@@ -1262,7 +1264,9 @@  static void ss5_init(ram_addr_t RAM_size,
 }
 
 /* SPARCstation 10 hardware initialisation */
-static void ss10_init(ram_addr_t RAM_size,
+static void ss10_init(MemoryRegion *address_space_mem,
+                      MemoryRegion *address_space_io,
+                      ram_addr_t RAM_size,
                       const char *boot_device,
                       const char *kernel_filename, const char *kernel_cmdline,
                       const char *initrd_filename, const char *cpu_model)
@@ -1272,7 +1276,9 @@  static void ss10_init(ram_addr_t RAM_size,
 }
 
 /* SPARCserver 600MP hardware initialisation */
-static void ss600mp_init(ram_addr_t RAM_size,
+static void ss600mp_init(MemoryRegion *address_space_mem,
+                         MemoryRegion *address_space_io,
+                         ram_addr_t RAM_size,
                          const char *boot_device,
                          const char *kernel_filename,
                          const char *kernel_cmdline,
@@ -1283,7 +1289,9 @@  static void ss600mp_init(ram_addr_t RAM_size,
 }
 
 /* SPARCstation 20 hardware initialisation */
-static void ss20_init(ram_addr_t RAM_size,
+static void ss20_init(MemoryRegion *address_space_mem,
+                      MemoryRegion *address_space_io,
+                      ram_addr_t RAM_size,
                       const char *boot_device,
                       const char *kernel_filename, const char *kernel_cmdline,
                       const char *initrd_filename, const char *cpu_model)
@@ -1293,7 +1301,9 @@  static void ss20_init(ram_addr_t RAM_size,
 }
 
 /* SPARCstation Voyager hardware initialisation */
-static void vger_init(ram_addr_t RAM_size,
+static void vger_init(MemoryRegion *address_space_mem,
+                      MemoryRegion *address_space_io,
+                      ram_addr_t RAM_size,
                       const char *boot_device,
                       const char *kernel_filename, const char *kernel_cmdline,
                       const char *initrd_filename, const char *cpu_model)
@@ -1303,7 +1313,9 @@  static void vger_init(ram_addr_t RAM_size,
 }
 
 /* SPARCstation LX hardware initialisation */
-static void ss_lx_init(ram_addr_t RAM_size,
+static void ss_lx_init(MemoryRegion *address_space_mem,
+                       MemoryRegion *address_space_io,
+                       ram_addr_t RAM_size,
                        const char *boot_device,
                        const char *kernel_filename, const char *kernel_cmdline,
                        const char *initrd_filename, const char *cpu_model)
@@ -1313,7 +1325,9 @@  static void ss_lx_init(ram_addr_t RAM_size,
 }
 
 /* SPARCstation 4 hardware initialisation */
-static void ss4_init(ram_addr_t RAM_size,
+static void ss4_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t RAM_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
@@ -1323,7 +1337,9 @@  static void ss4_init(ram_addr_t RAM_size,
 }
 
 /* SPARCClassic hardware initialisation */
-static void scls_init(ram_addr_t RAM_size,
+static void scls_init(MemoryRegion *address_space_mem,
+                      MemoryRegion *address_space_io,
+                      ram_addr_t RAM_size,
                       const char *boot_device,
                       const char *kernel_filename, const char *kernel_cmdline,
                       const char *initrd_filename, const char *cpu_model)
@@ -1333,7 +1349,9 @@  static void scls_init(ram_addr_t RAM_size,
 }
 
 /* SPARCbook hardware initialisation */
-static void sbook_init(ram_addr_t RAM_size,
+static void sbook_init(MemoryRegion *address_space_mem,
+                       MemoryRegion *address_space_io,
+                       ram_addr_t RAM_size,
                        const char *boot_device,
                        const char *kernel_filename, const char *kernel_cmdline,
                        const char *initrd_filename, const char *cpu_model)
@@ -1600,7 +1618,9 @@  static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
 }
 
 /* SPARCserver 1000 hardware initialisation */
-static void ss1000_init(ram_addr_t RAM_size,
+static void ss1000_init(MemoryRegion *address_space_mem,
+                        MemoryRegion *address_space_io,
+                        ram_addr_t RAM_size,
                         const char *boot_device,
                         const char *kernel_filename, const char *kernel_cmdline,
                         const char *initrd_filename, const char *cpu_model)
@@ -1610,7 +1630,9 @@  static void ss1000_init(ram_addr_t RAM_size,
 }
 
 /* SPARCcenter 2000 hardware initialisation */
-static void ss2000_init(ram_addr_t RAM_size,
+static void ss2000_init(MemoryRegion *address_space_mem,
+                        MemoryRegion *address_space_io,
+                        ram_addr_t RAM_size,
                         const char *boot_device,
                         const char *kernel_filename, const char *kernel_cmdline,
                         const char *initrd_filename, const char *cpu_model)
@@ -1792,7 +1814,9 @@  static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
 }
 
 /* SPARCstation 2 hardware initialisation */
-static void ss2_init(ram_addr_t RAM_size,
+static void ss2_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t RAM_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 1b60e4e..1595015 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -867,7 +867,9 @@  static const struct hwdef hwdefs[] = {
 };
 
 /* Sun4u hardware initialisation */
-static void sun4u_init(ram_addr_t RAM_size,
+static void sun4u_init(MemoryRegion *address_space_mem,
+                       MemoryRegion *address_space_io,
+                       ram_addr_t RAM_size,
                        const char *boot_devices,
                        const char *kernel_filename, const char *kernel_cmdline,
                        const char *initrd_filename, const char *cpu_model)
@@ -877,7 +879,9 @@  static void sun4u_init(ram_addr_t RAM_size,
 }
 
 /* Sun4v hardware initialisation */
-static void sun4v_init(ram_addr_t RAM_size,
+static void sun4v_init(MemoryRegion *address_space_mem,
+                       MemoryRegion *address_space_io,
+                       ram_addr_t RAM_size,
                        const char *boot_devices,
                        const char *kernel_filename, const char *kernel_cmdline,
                        const char *initrd_filename, const char *cpu_model)
@@ -887,7 +891,9 @@  static void sun4v_init(ram_addr_t RAM_size,
 }
 
 /* Niagara hardware initialisation */
-static void niagara_init(ram_addr_t RAM_size,
+static void niagara_init(MemoryRegion *address_space_mem,
+                         MemoryRegion *address_space_io,
+                         ram_addr_t RAM_size,
                          const char *boot_devices,
                          const char *kernel_filename, const char *kernel_cmdline,
                          const char *initrd_filename, const char *cpu_model)
diff --git a/hw/syborg.c b/hw/syborg.c
index bc200e4..4bdb3c0 100644
--- a/hw/syborg.c
+++ b/hw/syborg.c
@@ -29,7 +29,9 @@ 
 
 static struct arm_boot_info syborg_binfo;
 
-static void syborg_init(ram_addr_t ram_size,
+static void syborg_init(MemoryRegion *address_space_mem,
+                        MemoryRegion *address_space_io,
+                        ram_addr_t ram_size,
                         const char *boot_device,
                         const char *kernel_filename, const char *kernel_cmdline,
                         const char *initrd_filename, const char *cpu_model)
diff --git a/hw/tosa.c b/hw/tosa.c
index a7967a2..cce828f 100644
--- a/hw/tosa.c
+++ b/hw/tosa.c
@@ -205,7 +205,9 @@  static struct arm_boot_info tosa_binfo = {
     .ram_size = 0x04000000,
 };
 
-static void tosa_init(ram_addr_t ram_size,
+static void tosa_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 49f8f5f..aaab42c 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -17,6 +17,7 @@ 
 #include "usb-ohci.h"
 #include "boards.h"
 #include "blockdev.h"
+#include "memory.h"
 
 /* Primary interrupt controller.  */
 
@@ -169,7 +170,9 @@  static int vpb_sic_init(SysBusDevice *dev)
 
 static struct arm_boot_info versatile_binfo;
 
-static void versatile_init(ram_addr_t ram_size,
+static void versatile_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model,
@@ -309,23 +312,29 @@  static void versatile_init(ram_addr_t ram_size,
     arm_load_kernel(env, &versatile_binfo);
 }
 
-static void vpb_init(ram_addr_t ram_size,
+static void vpb_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
 {
-    versatile_init(ram_size,
+    versatile_init(address_space_mem, address_space_io,
+                   ram_size,
                    boot_device,
                    kernel_filename, kernel_cmdline,
                    initrd_filename, cpu_model, 0x183);
 }
 
-static void vab_init(ram_addr_t ram_size,
+static void vab_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
 {
-    versatile_init(ram_size,
+    versatile_init(address_space_mem, address_space_io,
+                   ram_size,
                    boot_device,
                    kernel_filename, kernel_cmdline,
                    initrd_filename, cpu_model, 0x25e);
diff --git a/hw/vexpress.c b/hw/vexpress.c
index c9766dd..3aa9e8a 100644
--- a/hw/vexpress.c
+++ b/hw/vexpress.c
@@ -34,7 +34,9 @@  static struct arm_boot_info vexpress_binfo = {
     .smp_loader_start = SMP_BOOT_ADDR,
 };
 
-static void vexpress_a9_init(ram_addr_t ram_size,
+static void vexpress_a9_init(MemoryRegion *address_space_mem,
+                     MemoryRegion *address_space_io,
+                     ram_addr_t ram_size,
                      const char *boot_device,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c
index 333050c..4503851 100644
--- a/hw/virtex_ml507.c
+++ b/hw/virtex_ml507.c
@@ -185,7 +185,9 @@  static int xilinx_load_device_tree(target_phys_addr_t addr,
     return fdt_size;
 }
 
-static void virtex_init(ram_addr_t ram_size,
+static void virtex_init(MemoryRegion *address_space_mem,
+                        MemoryRegion *address_space_io,
+                        ram_addr_t ram_size,
                         const char *boot_device,
                         const char *kernel_filename,
                         const char *kernel_cmdline,
diff --git a/hw/xen_machine_pv.c b/hw/xen_machine_pv.c
index 7985d11..e2d0b85 100644
--- a/hw/xen_machine_pv.c
+++ b/hw/xen_machine_pv.c
@@ -29,7 +29,9 @@ 
 #include "xen_domainbuild.h"
 #include "blockdev.h"
 
-static void xen_init_pv(ram_addr_t ram_size,
+static void xen_init_pv(MemoryRegion *address_space_mem,
+                        MemoryRegion *address_space_io,
+                        ram_addr_t ram_size,
 			const char *boot_device,
 			const char *kernel_filename,
 			const char *kernel_cmdline,
diff --git a/hw/z2.c b/hw/z2.c
index f93a1bf..f1db41b 100644
--- a/hw/z2.c
+++ b/hw/z2.c
@@ -272,7 +272,9 @@  static I2CSlaveInfo aer915_info = {
     .send = aer915_send
 };
 
-static void z2_init(ram_addr_t ram_size,
+static void z2_init(MemoryRegion *address_space_mem,
+                MemoryRegion *address_space_io,
+                ram_addr_t ram_size,
                 const char *boot_device,
                 const char *kernel_filename, const char *kernel_cmdline,
                 const char *initrd_filename, const char *cpu_model)
diff --git a/vl.c b/vl.c
index 5f1a177..5cdb083 100644
--- a/vl.c
+++ b/vl.c
@@ -148,6 +148,7 @@  int main(int argc, char **argv)
 #ifdef CONFIG_VIRTFS
 #include "fsdev/qemu-fsdev.h"
 #endif
+#include "exec-memory.h"
 
 #include "disas.h"
 
@@ -3244,7 +3245,7 @@  int main(int argc, char **argv, char **envp)
     }
     qemu_add_globals();
 
-    machine->init(ram_size, boot_devices,
+    machine->init(get_system_memory(), get_system_io(), ram_size, boot_devices,
                   kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
 
     cpu_synchronize_all_post_init();