Patchwork [17/23] pc: grab system_memory

login
register
mail settings
Submitter Avi Kivity
Date July 25, 2011, 2:02 p.m.
Message ID <1311602584-23409-18-git-send-email-avi@redhat.com>
Download mbox | patch
Permalink /patch/106702/
State New
Headers show

Comments

Avi Kivity - July 25, 2011, 2:02 p.m.
While eventually this should come from the machine initialization function,
take a short cut to avoid converting all machines now.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/pc.c      |    3 ++-
 hw/pc.h      |    4 +++-
 hw/pc_piix.c |    8 +++++++-
 3 files changed, 12 insertions(+), 3 deletions(-)
Anthony Liguori - July 25, 2011, 7:22 p.m.
On 07/25/2011 09:02 AM, Avi Kivity wrote:
> While eventually this should come from the machine initialization function,
> take a short cut to avoid converting all machines now.
>
> Signed-off-by: Avi Kivity<avi@redhat.com>

I think it should happen in the i440fx actually.  We should treat RAM as 
just another device as it would allow for better support of platforms 
with more interesting RAM topologies.

But for right now, this is appropriate.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   hw/pc.c      |    3 ++-
>   hw/pc.h      |    4 +++-
>   hw/pc_piix.c |    8 +++++++-
>   3 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/hw/pc.c b/hw/pc.c
> index a3e8539..369566a 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> @@ -957,7 +957,8 @@ void pc_cpus_init(const char *cpu_model)
>       }
>   }
>
> -void pc_memory_init(const char *kernel_filename,
> +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,
> diff --git a/hw/pc.h b/hw/pc.h
> index 6d5730b..fa57583 100644
> --- a/hw/pc.h
> +++ b/hw/pc.h
> @@ -6,6 +6,7 @@
>   #include "isa.h"
>   #include "fdc.h"
>   #include "net.h"
> +#include "memory.h"
>
>   /* PC-style peripherals (also used by other machines).  */
>
> @@ -129,7 +130,8 @@ void pc_cmos_set_s3_resume(void *opaque, int irq, int level);
>   void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
>
>   void pc_cpus_init(const char *cpu_model);
> -void pc_memory_init(const char *kernel_filename,
> +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,
> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
> index c5c16b4..d83854c 100644
> --- a/hw/pc_piix.c
> +++ b/hw/pc_piix.c
> @@ -39,6 +39,8 @@
>   #include "blockdev.h"
>   #include "smbus.h"
>   #include "xen.h"
> +#include "memory.h"
> +#include "exec-memory.h"
>   #ifdef CONFIG_XEN
>   #  include<xen/hvm/hvm_info_table.h>
>   #endif
> @@ -89,6 +91,9 @@ static void pc_init1(ram_addr_t ram_size,
>       DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
>       BusState *idebus[MAX_IDE_BUS];
>       ISADevice *rtc_state;
> +    MemoryRegion *system_memory;
> +
> +    system_memory = get_system_memory();
>
>       pc_cpus_init(cpu_model);
>
> @@ -106,7 +111,8 @@ static void pc_init1(ram_addr_t ram_size,
>
>       /* allocate ram and load rom/bios */
>       if (!xen_enabled()) {
> -        pc_memory_init(kernel_filename, kernel_cmdline, initrd_filename,
> +        pc_memory_init(system_memory,
> +                       kernel_filename, kernel_cmdline, initrd_filename,
>                          below_4g_mem_size, above_4g_mem_size);
>       }
>

Patch

diff --git a/hw/pc.c b/hw/pc.c
index a3e8539..369566a 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -957,7 +957,8 @@  void pc_cpus_init(const char *cpu_model)
     }
 }
 
-void pc_memory_init(const char *kernel_filename,
+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,
diff --git a/hw/pc.h b/hw/pc.h
index 6d5730b..fa57583 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -6,6 +6,7 @@ 
 #include "isa.h"
 #include "fdc.h"
 #include "net.h"
+#include "memory.h"
 
 /* PC-style peripherals (also used by other machines).  */
 
@@ -129,7 +130,8 @@  void pc_cmos_set_s3_resume(void *opaque, int irq, int level);
 void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
 
 void pc_cpus_init(const char *cpu_model);
-void pc_memory_init(const char *kernel_filename,
+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,
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index c5c16b4..d83854c 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -39,6 +39,8 @@ 
 #include "blockdev.h"
 #include "smbus.h"
 #include "xen.h"
+#include "memory.h"
+#include "exec-memory.h"
 #ifdef CONFIG_XEN
 #  include <xen/hvm/hvm_info_table.h>
 #endif
@@ -89,6 +91,9 @@  static void pc_init1(ram_addr_t ram_size,
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     BusState *idebus[MAX_IDE_BUS];
     ISADevice *rtc_state;
+    MemoryRegion *system_memory;
+
+    system_memory = get_system_memory();
 
     pc_cpus_init(cpu_model);
 
@@ -106,7 +111,8 @@  static void pc_init1(ram_addr_t ram_size,
 
     /* allocate ram and load rom/bios */
     if (!xen_enabled()) {
-        pc_memory_init(kernel_filename, kernel_cmdline, initrd_filename,
+        pc_memory_init(system_memory,
+                       kernel_filename, kernel_cmdline, initrd_filename,
                        below_4g_mem_size, above_4g_mem_size);
     }