All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Qemu-devel] [PATCH 4/4] PPC: e500: add generic e500 platform
       [not found] ` <20120627235104.GD9149@tyr.buserror.net>
@ 2012-07-02 16:33   ` Stuart Yoder
  2012-07-02 16:38     ` Scott Wood
  0 siblings, 1 reply; 11+ messages in thread
From: Stuart Yoder @ 2012-07-02 16:33 UTC (permalink / raw)
  To: Scott Wood; +Cc: qemu-ppc, agraf, qemu-devel

On Wed, Jun 27, 2012 at 6:51 PM, Scott Wood <scottwood@freescale.com> wrote:
> This gives the kernel a paravirtualized machine to target, without
> requiring both sides to pretend to be targeting a specific board
> that likely has little to do with the host in KVM scenarios.  This
> avoids the need to add new boards to QEMU, just to be able to
> run KVM on new CPUs.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> ---
>  hw/ppc/Makefile.objs |    3 +-
>  hw/ppc/e500plat.c    |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 62 insertions(+), 1 deletions(-)
>  create mode 100644 hw/ppc/e500plat.c
>
> diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
> index 23eb8ca..58d82c9 100644
> --- a/hw/ppc/Makefile.objs
> +++ b/hw/ppc/Makefile.objs
> @@ -15,7 +15,8 @@ obj-$(CONFIG_PSERIES) += spapr_pci.o pci-hotplug.o spapr_iommu.o
>  obj-y += ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o
>  obj-y += ppc440_bamboo.o
>  # PowerPC E500 boards
> -obj-$(CONFIG_FDT) += ppc/e500.o mpc8544_guts.o ppce500_spin.o ppc/mpc8544ds.o
> +obj-$(CONFIG_FDT) += ppc/e500.o mpc8544_guts.o ppce500_spin.o ppc/mpc8544ds.o \
> +       ppc/e500plat.o
>  # PowerPC 440 Xilinx ML507 reference board.
>  obj-y += virtex_ml507.o
>  # PowerPC OpenPIC
> diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c
> new file mode 100644
> index 0000000..a9ef5f8
> --- /dev/null
> +++ b/hw/ppc/e500plat.c
> @@ -0,0 +1,60 @@
> +/*
> + * Generic device-tree-driven paravirt PPC e500 platform
> + *
> + * Copyright 2012 Freescale Semiconductor, Inc.
> + *
> + * This is free software; you can redistribute it and/or modify
> + * it under the terms of  the GNU General  Public License as published by
> + * the Free Software Foundation;  either version 2 of the  License, or
> + * (at your option) any later version.
> + */
> +
> +#include "config.h"
> +#include "qemu-common.h"
> +#include "e500.h"
> +#include "../boards.h"
> +#include "device_tree.h"
> +
> +static void e500plat_fixup_devtree(PPCE500Params *params, void *fdt)
> +{
> +    const char model[] = "QEMU e500plat";
> +    const char compatible[] = "fsl,qemu-e500";
> +
> +    qemu_devtree_setprop(fdt, "/", "model", model, sizeof(model));
> +    qemu_devtree_setprop(fdt, "/", "compatible", compatible,
> +                         sizeof(compatible));
> +}
> +
> +static void e500plat_init(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)
> +{
> +    PPCE500Params params = {
> +        .ram_size = ram_size,
> +        .boot_device = boot_device,
> +        .kernel_filename = kernel_filename,
> +        .kernel_cmdline = kernel_cmdline,
> +        .initrd_filename = initrd_filename,
> +        .cpu_model = cpu_model,
> +        .fixup_devtree = e500plat_fixup_devtree,
> +    };
> +
> +    ppce500_init(&params);
> +}
> +
> +static QEMUMachine e500plat_machine = {
> +    .name = "e500plat",
> +    .desc = "e500plat",
> +    .init = e500plat_init,
> +    .max_cpus = 15,
> +};

Can we call the generic e500 machine  "ppce500"?  I like that better as
it denotes both the "Power/PPC" architecture and "e500".   I aesthetically
like -M ppce500 over -M e500plat when running QEMU.

Stuart

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 4/4] PPC: e500: add generic e500 platform
  2012-07-02 16:33   ` [Qemu-devel] [PATCH 4/4] PPC: e500: add generic e500 platform Stuart Yoder
@ 2012-07-02 16:38     ` Scott Wood
  2012-07-02 17:04       ` Andreas Färber
  0 siblings, 1 reply; 11+ messages in thread
From: Scott Wood @ 2012-07-02 16:38 UTC (permalink / raw)
  To: Stuart Yoder; +Cc: qemu-ppc, agraf, qemu-devel

On 07/02/2012 11:33 AM, Stuart Yoder wrote:
> On Wed, Jun 27, 2012 at 6:51 PM, Scott Wood <scottwood@freescale.com> wrote:
>> +static QEMUMachine e500plat_machine = {
>> +    .name = "e500plat",
>> +    .desc = "e500plat",
>> +    .init = e500plat_init,
>> +    .max_cpus = 15,
>> +};
> 
> Can we call the generic e500 machine  "ppce500"?

I wanted to distinguish the platform from the common e500 code.

-Scott

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH 4/4] PPC: e500: add generic e500 platform
  2012-07-02 16:38     ` Scott Wood
@ 2012-07-02 17:04       ` Andreas Färber
  0 siblings, 0 replies; 11+ messages in thread
From: Andreas Färber @ 2012-07-02 17:04 UTC (permalink / raw)
  To: Scott Wood; +Cc: qemu-devel, qemu-ppc, agraf, Stuart Yoder

Am 02.07.2012 18:38, schrieb Scott Wood:
> On 07/02/2012 11:33 AM, Stuart Yoder wrote:
>> On Wed, Jun 27, 2012 at 6:51 PM, Scott Wood <scottwood@freescale.com> wrote:
>>> +static QEMUMachine e500plat_machine = {
>>> +    .name = "e500plat",
>>> +    .desc = "e500plat",
>>> +    .init = e500plat_init,
>>> +    .max_cpus = 15,
>>> +};
>>
>> Can we call the generic e500 machine  "ppce500"?
> 
> I wanted to distinguish the platform from the common e500 code.

The machine name does not need to match the file name, so you can name
it "e500" and place it in e500plat.c or whatever. Common e500 code won't
show up as a user-visible machine I guess.

I concur that "-M e500plat" feels a bit odd for a user option. And
repeating that name in the description is not particularly helpful. ;)

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [RESEND PATCH v2 0/4] PPC: e500 platform refactoring
       [not found] <20120627234639.GA8974@tyr.buserror.net>
       [not found] ` <20120627235104.GD9149@tyr.buserror.net>
@ 2012-07-02 23:03 ` Scott Wood
  2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 1/4] PPC: e500: rename mpc8544ds into generic file Scott Wood
                     ` (5 more replies)
  1 sibling, 6 replies; 11+ messages in thread
From: Scott Wood @ 2012-07-02 23:03 UTC (permalink / raw)
  To: Alex Graf; +Cc: qemu-ppc, qemu-devel, Andreas Färber

[resent with the proper address for qemu-devel, sorry...]

The current ppc_mpc8544ds.c is split into a generic (eventually) e500
backend, and two platform frontends (mpc8544ds and a generic paravirt
e500 platform) that instantiate the backend.

Currently the only distinction between the subplatforms is toplevel
compatible and model in the device tree (the generic e500 backend isn't
very generic yet), but additional refactoring should happen in the
future.

Scott Wood (4):
  PPC: e500: rename mpc8544ds into generic file
  PPC: e500: change internal references away from mpc8544ds
  PPC: e500: split mpc8544ds machine from generic e500 code
  PPC: e500: add generic e500 platform

 hw/ppc/Makefile.objs                   |    4 +-
 hw/{ppce500_mpc8544ds.c => ppc/e500.c} |  110 +++++++++++++------------------
 hw/ppc/e500.h                          |   21 ++++++
 hw/ppc/e500plat.c                      |   60 +++++++++++++++++
 hw/ppc/mpc8544ds.c                     |   61 ++++++++++++++++++
 5 files changed, 191 insertions(+), 65 deletions(-)
 rename hw/{ppce500_mpc8544ds.c => ppc/e500.c} (88%)
 create mode 100644 hw/ppc/e500.h
 create mode 100644 hw/ppc/e500plat.c
 create mode 100644 hw/ppc/mpc8544ds.c

-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [RESEND PATCH v2 1/4] PPC: e500: rename mpc8544ds into generic file
  2012-07-02 23:03 ` [Qemu-devel] [RESEND PATCH v2 0/4] PPC: e500 platform refactoring Scott Wood
@ 2012-07-02 23:03   ` Scott Wood
  2012-07-03 10:40     ` Andreas Färber
  2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 2/4] PPC: e500: change internal references away from mpc8544ds Scott Wood
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Scott Wood @ 2012-07-02 23:03 UTC (permalink / raw)
  To: Alex Graf; +Cc: qemu-ppc, qemu-devel, Andreas Färber

Rename the file (with no changes other than fixing up the header paths)
in preparation for refactoring into a generic e500 platform.  Also move
it into the newly created ppc/ directory.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
v2: Use the right part of the makefile for hw/ppc files

 hw/ppc/Makefile.objs                   |    4 +++-
 hw/{ppce500_mpc8544ds.c => ppc/e500.c} |   16 ++++++++--------
 2 files changed, 11 insertions(+), 9 deletions(-)
 rename hw/{ppce500_mpc8544ds.c => ppc/e500.c} (99%)

diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index aa4bbeb..39a6c31 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -15,7 +15,7 @@ obj-$(CONFIG_PSERIES) += spapr_pci.o pci-hotplug.o spapr_iommu.o
 obj-y += ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o
 obj-y += ppc440_bamboo.o
 # PowerPC E500 boards
-obj-$(CONFIG_FDT) += ppce500_mpc8544ds.o mpc8544_guts.o ppce500_spin.o
+obj-$(CONFIG_FDT) += mpc8544_guts.o ppce500_spin.o
 # PowerPC 440 Xilinx ML507 reference board.
 obj-y += virtex_ml507.o
 # PowerPC OpenPIC
@@ -26,3 +26,5 @@ obj-$(CONFIG_FDT) += ../device_tree.o
 obj-y += xilinx_ethlite.o
 
 obj-y := $(addprefix ../,$(obj-y))
+
+obj-y += e500.o
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppc/e500.c
similarity index 99%
rename from hw/ppce500_mpc8544ds.c
rename to hw/ppc/e500.c
index 8b9fd83..0b383e6 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppc/e500.c
@@ -17,19 +17,19 @@
 #include "config.h"
 #include "qemu-common.h"
 #include "net.h"
-#include "hw.h"
-#include "pc.h"
-#include "pci.h"
-#include "boards.h"
+#include "hw/hw.h"
+#include "hw/pc.h"
+#include "hw/pci.h"
+#include "hw/boards.h"
 #include "sysemu.h"
 #include "kvm.h"
 #include "kvm_ppc.h"
 #include "device_tree.h"
-#include "openpic.h"
-#include "ppc.h"
-#include "loader.h"
+#include "hw/openpic.h"
+#include "hw/ppc.h"
+#include "hw/loader.h"
 #include "elf.h"
-#include "sysbus.h"
+#include "hw/sysbus.h"
 #include "exec-memory.h"
 #include "host-utils.h"
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [RESEND PATCH v2 2/4] PPC: e500: change internal references away from mpc8544ds
  2012-07-02 23:03 ` [Qemu-devel] [RESEND PATCH v2 0/4] PPC: e500 platform refactoring Scott Wood
  2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 1/4] PPC: e500: rename mpc8544ds into generic file Scott Wood
@ 2012-07-02 23:03   ` Scott Wood
  2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 3/4] PPC: e500: split mpc8544ds machine from generic e500 code Scott Wood
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Scott Wood @ 2012-07-02 23:03 UTC (permalink / raw)
  To: Alex Graf; +Cc: qemu-ppc, qemu-devel, Andreas Färber

No functional changes -- machine is still outwardly mpc8544ds.

The references that are not changed contain mpc8544 hardware details that
need to be parameterized if/when a different e500 platform wants to
change them.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
v2: no changes

 hw/ppc/e500.c |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 0b383e6..db5ca6e 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -1,5 +1,5 @@
 /*
- * QEMU PowerPC MPC8544DS board emulation
+ * QEMU PowerPC e500-based platforms
  *
  * Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved.
  *
@@ -42,6 +42,7 @@
 
 #define RAM_SIZES_ALIGN            (64UL << 20)
 
+/* TODO: parameterize */
 #define MPC8544_CCSRBAR_BASE       0xE0000000ULL
 #define MPC8544_CCSRBAR_SIZE       0x00100000ULL
 #define MPC8544_MPIC_REGS_BASE     (MPC8544_CCSRBAR_BASE + 0x40000ULL)
@@ -104,7 +105,7 @@ static void dt_serial_create(void *fdt, unsigned long long offset,
     }
 }
 
-static int mpc8544_load_device_tree(CPUPPCState *env,
+static int ppce500_load_device_tree(CPUPPCState *env,
                                     target_phys_addr_t addr,
                                     target_phys_addr_t ramsize,
                                     target_phys_addr_t initrd_base,
@@ -388,7 +389,7 @@ static void mmubooke_create_initial_mapping(CPUPPCState *env)
     env->tlb_dirty = true;
 }
 
-static void mpc8544ds_cpu_reset_sec(void *opaque)
+static void ppce500_cpu_reset_sec(void *opaque)
 {
     PowerPCCPU *cpu = opaque;
     CPUPPCState *env = &cpu->env;
@@ -401,7 +402,7 @@ static void mpc8544ds_cpu_reset_sec(void *opaque)
     env->exception_index = EXCP_HLT;
 }
 
-static void mpc8544ds_cpu_reset(void *opaque)
+static void ppce500_cpu_reset(void *opaque)
 {
     PowerPCCPU *cpu = opaque;
     CPUPPCState *env = &cpu->env;
@@ -417,7 +418,7 @@ static void mpc8544ds_cpu_reset(void *opaque)
     mmubooke_create_initial_mapping(env);
 }
 
-static void mpc8544ds_init(ram_addr_t ram_size,
+static void ppce500_init(ram_addr_t ram_size,
                          const char *boot_device,
                          const char *kernel_filename,
                          const char *kernel_cmdline,
@@ -478,11 +479,11 @@ static void mpc8544ds_init(ram_addr_t ram_size,
             /* Primary CPU */
             struct boot_info *boot_info;
             boot_info = g_malloc0(sizeof(struct boot_info));
-            qemu_register_reset(mpc8544ds_cpu_reset, cpu);
+            qemu_register_reset(ppce500_cpu_reset, cpu);
             env->load_info = boot_info;
         } else {
             /* Secondary CPUs */
-            qemu_register_reset(mpc8544ds_cpu_reset_sec, cpu);
+            qemu_register_reset(ppce500_cpu_reset_sec, cpu);
         }
     }
 
@@ -577,7 +578,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
         int dt_size;
 
         dt_base = (loadaddr + kernel_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK;
-        dt_size = mpc8544_load_device_tree(env, dt_base, ram_size, initrd_base,
+        dt_size = ppce500_load_device_tree(env, dt_base, ram_size, initrd_base,
                                            initrd_size, kernel_cmdline);
         if (dt_size < 0) {
             fprintf(stderr, "couldn't load device tree\n");
@@ -595,16 +596,16 @@ static void mpc8544ds_init(ram_addr_t ram_size,
     }
 }
 
-static QEMUMachine mpc8544ds_machine = {
+static QEMUMachine ppce500_machine = {
     .name = "mpc8544ds",
     .desc = "mpc8544ds",
-    .init = mpc8544ds_init,
+    .init = ppce500_init,
     .max_cpus = 15,
 };
 
-static void mpc8544ds_machine_init(void)
+static void ppce500_machine_init(void)
 {
-    qemu_register_machine(&mpc8544ds_machine);
+    qemu_register_machine(&ppce500_machine);
 }
 
-machine_init(mpc8544ds_machine_init);
+machine_init(ppce500_machine_init);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [RESEND PATCH v2 3/4] PPC: e500: split mpc8544ds machine from generic e500 code
  2012-07-02 23:03 ` [Qemu-devel] [RESEND PATCH v2 0/4] PPC: e500 platform refactoring Scott Wood
  2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 1/4] PPC: e500: rename mpc8544ds into generic file Scott Wood
  2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 2/4] PPC: e500: change internal references away from mpc8544ds Scott Wood
@ 2012-07-02 23:03   ` Scott Wood
  2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 4/4] PPC: e500: add generic e500 platform Scott Wood
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Scott Wood @ 2012-07-02 23:03 UTC (permalink / raw)
  To: Alex Graf; +Cc: qemu-ppc, qemu-devel, Andreas Färber

Currently the only mpc8544ds-ism that is factored out is
toplevel compatible and model.  In the future the generic e500
code is expected to become more generic.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
v2: Use the right part of the makefile for hw/ppc files

 hw/ppc/Makefile.objs |    3 +-
 hw/ppc/e500.c        |   81 +++++++++++++++++++-------------------------------
 hw/ppc/e500.h        |   21 +++++++++++++
 hw/ppc/mpc8544ds.c   |   61 +++++++++++++++++++++++++++++++++++++
 4 files changed, 115 insertions(+), 51 deletions(-)
 create mode 100644 hw/ppc/e500.h
 create mode 100644 hw/ppc/mpc8544ds.c

diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index 39a6c31..14debbc 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -27,4 +27,5 @@ obj-y += xilinx_ethlite.o
 
 obj-y := $(addprefix ../,$(obj-y))
 
-obj-y += e500.o
+obj-y += e500.o mpc8544ds.o
+
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index db5ca6e..f07be08 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -16,6 +16,7 @@
 
 #include "config.h"
 #include "qemu-common.h"
+#include "e500.h"
 #include "net.h"
 #include "hw/hw.h"
 #include "hw/pc.h"
@@ -106,24 +107,21 @@ static void dt_serial_create(void *fdt, unsigned long long offset,
 }
 
 static int ppce500_load_device_tree(CPUPPCState *env,
+                                    PPCE500Params *params,
                                     target_phys_addr_t addr,
-                                    target_phys_addr_t ramsize,
                                     target_phys_addr_t initrd_base,
-                                    target_phys_addr_t initrd_size,
-                                    const char *kernel_cmdline)
+                                    target_phys_addr_t initrd_size)
 {
     int ret = -1;
-    uint64_t mem_reg_property[] = { 0, cpu_to_be64(ramsize) };
+    uint64_t mem_reg_property[] = { 0, cpu_to_be64(params->ram_size) };
     int fdt_size;
     void *fdt;
     uint8_t hypercall[16];
     uint32_t clock_freq = 400000000;
     uint32_t tb_freq = 400000000;
     int i;
-    const char *compatible = "MPC8544DS\0MPC85xxDS";
-    int compatible_len = sizeof("MPC8544DS\0MPC85xxDS");
+    const char *toplevel_compat = NULL; /* user override */
     char compatible_sb[] = "fsl,mpc8544-immr\0simple-bus";
-    char model[] = "MPC8544DS";
     char soc[128];
     char mpic[128];
     uint32_t mpic_ph;
@@ -146,14 +144,9 @@ static int ppce500_load_device_tree(CPUPPCState *env,
 
     machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
     if (machine_opts) {
-        const char *tmp;
         dumpdtb = qemu_opt_get(machine_opts, "dumpdtb");
         dtb_file = qemu_opt_get(machine_opts, "dtb");
-        tmp = qemu_opt_get(machine_opts, "dt_compatible");
-        if (tmp) {
-            compatible = tmp;
-            compatible_len = strlen(compatible) + 1;
-        }
+        toplevel_compat = qemu_opt_get(machine_opts, "dt_compatible");
     }
 
     if (dtb_file) {
@@ -176,8 +169,6 @@ static int ppce500_load_device_tree(CPUPPCState *env,
     }
 
     /* Manipulate device tree in memory. */
-    qemu_devtree_setprop_string(fdt, "/", "model", model);
-    qemu_devtree_setprop(fdt, "/", "compatible", compatible, compatible_len);
     qemu_devtree_setprop_cell(fdt, "/", "#address-cells", 2);
     qemu_devtree_setprop_cell(fdt, "/", "#size-cells", 2);
 
@@ -202,7 +193,7 @@ static int ppce500_load_device_tree(CPUPPCState *env,
     }
 
     ret = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs",
-                                      kernel_cmdline);
+                                      params->kernel_cmdline);
     if (ret < 0)
         fprintf(stderr, "couldn't set /chosen/bootargs\n");
 
@@ -338,6 +329,13 @@ static int ppce500_load_device_tree(CPUPPCState *env,
     qemu_devtree_setprop_cell(fdt, pci, "#address-cells", 3);
     qemu_devtree_setprop_string(fdt, "/aliases", "pci0", pci);
 
+    params->fixup_devtree(params, fdt);
+
+    if (toplevel_compat) {
+        qemu_devtree_setprop(fdt, "/", "compatible", toplevel_compat,
+                             strlen(toplevel_compat) + 1);
+    }
+
 done:
     if (dumpdtb) {
         /* Dump the dtb to a file and quit */
@@ -418,12 +416,7 @@ static void ppce500_cpu_reset(void *opaque)
     mmubooke_create_initial_mapping(env);
 }
 
-static void ppce500_init(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)
+void ppce500_init(PPCE500Params *params)
 {
     MemoryRegion *address_space_mem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
@@ -444,8 +437,8 @@ static void ppce500_init(ram_addr_t ram_size,
     CPUPPCState *firstenv = NULL;
 
     /* Setup CPUs */
-    if (cpu_model == NULL) {
-        cpu_model = "e500v2_v30";
+    if (params->cpu_model == NULL) {
+        params->cpu_model = "e500v2_v30";
     }
 
     irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
@@ -454,7 +447,7 @@ static void ppce500_init(ram_addr_t ram_size,
         PowerPCCPU *cpu;
         qemu_irq *input;
 
-        cpu = cpu_ppc_init(cpu_model);
+        cpu = cpu_ppc_init(params->cpu_model);
         if (cpu == NULL) {
             fprintf(stderr, "Unable to initialize CPU!\n");
             exit(1);
@@ -543,43 +536,45 @@ static void ppce500_init(ram_addr_t ram_size,
     sysbus_create_simple("e500-spin", MPC8544_SPIN_BASE, NULL);
 
     /* Load kernel. */
-    if (kernel_filename) {
-        kernel_size = load_uimage(kernel_filename, &entry, &loadaddr, NULL);
+    if (params->kernel_filename) {
+        kernel_size = load_uimage(params->kernel_filename, &entry,
+                                  &loadaddr, NULL);
         if (kernel_size < 0) {
-            kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
-                                   &elf_lowaddr, NULL, 1, ELF_MACHINE, 0);
+            kernel_size = load_elf(params->kernel_filename, NULL, NULL,
+                                   &elf_entry, &elf_lowaddr, NULL, 1,
+                                   ELF_MACHINE, 0);
             entry = elf_entry;
             loadaddr = elf_lowaddr;
         }
         /* XXX try again as binary */
         if (kernel_size < 0) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n",
-                    kernel_filename);
+                    params->kernel_filename);
             exit(1);
         }
     }
 
     /* Load initrd. */
-    if (initrd_filename) {
+    if (params->initrd_filename) {
         initrd_base = (kernel_size + INITRD_LOAD_PAD) & ~INITRD_PAD_MASK;
-        initrd_size = load_image_targphys(initrd_filename, initrd_base,
+        initrd_size = load_image_targphys(params->initrd_filename, initrd_base,
                                           ram_size - initrd_base);
 
         if (initrd_size < 0) {
             fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
-                    initrd_filename);
+                    params->initrd_filename);
             exit(1);
         }
     }
 
     /* If we're loading a kernel directly, we must load the device tree too. */
-    if (kernel_filename) {
+    if (params->kernel_filename) {
         struct boot_info *boot_info;
         int dt_size;
 
         dt_base = (loadaddr + kernel_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK;
-        dt_size = ppce500_load_device_tree(env, dt_base, ram_size, initrd_base,
-                                           initrd_size, kernel_cmdline);
+        dt_size = ppce500_load_device_tree(env, params, dt_base, initrd_base,
+                                           initrd_size);
         if (dt_size < 0) {
             fprintf(stderr, "couldn't load device tree\n");
             exit(1);
@@ -595,17 +590,3 @@ static void ppce500_init(ram_addr_t ram_size,
         kvmppc_init();
     }
 }
-
-static QEMUMachine ppce500_machine = {
-    .name = "mpc8544ds",
-    .desc = "mpc8544ds",
-    .init = ppce500_init,
-    .max_cpus = 15,
-};
-
-static void ppce500_machine_init(void)
-{
-    qemu_register_machine(&ppce500_machine);
-}
-
-machine_init(ppce500_machine_init);
diff --git a/hw/ppc/e500.h b/hw/ppc/e500.h
new file mode 100644
index 0000000..7ae87f4
--- /dev/null
+++ b/hw/ppc/e500.h
@@ -0,0 +1,21 @@
+#ifndef PPCE500_H
+#define PPCE500_H
+
+typedef struct PPCE500Params {
+    /* Standard QEMU machine init params */
+    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;
+
+    /* e500-specific params */
+
+    /* required -- must at least add toplevel board compatible */
+    void (*fixup_devtree)(struct PPCE500Params *params, void *fdt);
+} PPCE500Params;
+
+void ppce500_init(PPCE500Params *params);
+
+#endif
diff --git a/hw/ppc/mpc8544ds.c b/hw/ppc/mpc8544ds.c
new file mode 100644
index 0000000..984d21c
--- /dev/null
+++ b/hw/ppc/mpc8544ds.c
@@ -0,0 +1,61 @@
+/*
+ * Support for the PPC e500-based mpc8544ds board
+ *
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of  the GNU General  Public License as published by
+ * the Free Software Foundation;  either version 2 of the  License, or
+ * (at your option) any later version.
+ */
+
+#include "config.h"
+#include "qemu-common.h"
+#include "e500.h"
+#include "../boards.h"
+#include "device_tree.h"
+
+static void mpc8544ds_fixup_devtree(PPCE500Params *params, void *fdt)
+{
+    const char model[] = "MPC8544DS";
+    const char compatible[] = "MPC8544DS\0MPC85xxDS";
+
+    qemu_devtree_setprop(fdt, "/", "model", model, sizeof(model));
+    qemu_devtree_setprop(fdt, "/", "compatible", compatible,
+                         sizeof(compatible));
+}
+
+static void mpc8544ds_init(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)
+{
+    PPCE500Params params = {
+        .ram_size = ram_size,
+        .boot_device = boot_device,
+        .kernel_filename = kernel_filename,
+        .kernel_cmdline = kernel_cmdline,
+        .initrd_filename = initrd_filename,
+        .cpu_model = cpu_model,
+        .fixup_devtree = mpc8544ds_fixup_devtree,
+    };
+
+    ppce500_init(&params);
+}
+
+
+static QEMUMachine ppce500_machine = {
+    .name = "mpc8544ds",
+    .desc = "mpc8544ds",
+    .init = mpc8544ds_init,
+    .max_cpus = 15,
+};
+
+static void ppce500_machine_init(void)
+{
+    qemu_register_machine(&ppce500_machine);
+}
+
+machine_init(ppce500_machine_init);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [RESEND PATCH v2 4/4] PPC: e500: add generic e500 platform
  2012-07-02 23:03 ` [Qemu-devel] [RESEND PATCH v2 0/4] PPC: e500 platform refactoring Scott Wood
                     ` (2 preceding siblings ...)
  2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 3/4] PPC: e500: split mpc8544ds machine from generic e500 code Scott Wood
@ 2012-07-02 23:03   ` Scott Wood
  2012-07-06 15:08   ` [Qemu-devel] [RESEND PATCH v2 0/4] PPC: e500 platform refactoring Alexander Graf
  2012-07-07  7:39   ` Alexander Graf
  5 siblings, 0 replies; 11+ messages in thread
From: Scott Wood @ 2012-07-02 23:03 UTC (permalink / raw)
  To: Alex Graf; +Cc: qemu-ppc, qemu-devel, Andreas Färber

This gives the kernel a paravirtualized machine to target, without
requiring both sides to pretend to be targeting a specific board
that likely has little to do with the host in KVM scenarios.  This
avoids the need to add new boards to QEMU, just to be able to
run KVM on new CPUs.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
v2:
 - Use the right part of the makefile for hw/ppc files
 - Update platform name to ppce500
 - Provide a proper platform description

 hw/ppc/Makefile.objs |    3 +-
 hw/ppc/e500plat.c    |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 2 deletions(-)
 create mode 100644 hw/ppc/e500plat.c

diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index 14debbc..81bcc72 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -27,5 +27,4 @@ obj-y += xilinx_ethlite.o
 
 obj-y := $(addprefix ../,$(obj-y))
 
-obj-y += e500.o mpc8544ds.o
-
+obj-y += e500.o mpc8544ds.o e500plat.o
diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c
new file mode 100644
index 0000000..60a5cb3
--- /dev/null
+++ b/hw/ppc/e500plat.c
@@ -0,0 +1,60 @@
+/*
+ * Generic device-tree-driven paravirt PPC e500 platform
+ *
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of  the GNU General  Public License as published by
+ * the Free Software Foundation;  either version 2 of the  License, or
+ * (at your option) any later version.
+ */
+
+#include "config.h"
+#include "qemu-common.h"
+#include "e500.h"
+#include "../boards.h"
+#include "device_tree.h"
+
+static void e500plat_fixup_devtree(PPCE500Params *params, void *fdt)
+{
+    const char model[] = "QEMU ppce500";
+    const char compatible[] = "fsl,qemu-e500";
+
+    qemu_devtree_setprop(fdt, "/", "model", model, sizeof(model));
+    qemu_devtree_setprop(fdt, "/", "compatible", compatible,
+                         sizeof(compatible));
+}
+
+static void e500plat_init(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)
+{
+    PPCE500Params params = {
+        .ram_size = ram_size,
+        .boot_device = boot_device,
+        .kernel_filename = kernel_filename,
+        .kernel_cmdline = kernel_cmdline,
+        .initrd_filename = initrd_filename,
+        .cpu_model = cpu_model,
+        .fixup_devtree = e500plat_fixup_devtree,
+    };
+
+    ppce500_init(&params);
+}
+
+static QEMUMachine e500plat_machine = {
+    .name = "ppce500",
+    .desc = "generic paravirt e500 platform",
+    .init = e500plat_init,
+    .max_cpus = 15,
+};
+
+static void e500plat_machine_init(void)
+{
+    qemu_register_machine(&e500plat_machine);
+}
+
+machine_init(e500plat_machine_init);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [RESEND PATCH v2 1/4] PPC: e500: rename mpc8544ds into generic file
  2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 1/4] PPC: e500: rename mpc8544ds into generic file Scott Wood
@ 2012-07-03 10:40     ` Andreas Färber
  0 siblings, 0 replies; 11+ messages in thread
From: Andreas Färber @ 2012-07-03 10:40 UTC (permalink / raw)
  To: Scott Wood; +Cc: qemu-ppc, Alex Graf, qemu-devel

Am 03.07.2012 01:03, schrieb Scott Wood:
> Rename the file (with no changes other than fixing up the header paths)
> in preparation for refactoring into a generic e500 platform.  Also move
> it into the newly created ppc/ directory.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> ---
> v2: Use the right part of the makefile for hw/ppc files

Reviewed-by: Andreas Färber <afaerber@suse.de>

Thanks,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [RESEND PATCH v2 0/4] PPC: e500 platform refactoring
  2012-07-02 23:03 ` [Qemu-devel] [RESEND PATCH v2 0/4] PPC: e500 platform refactoring Scott Wood
                     ` (3 preceding siblings ...)
  2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 4/4] PPC: e500: add generic e500 platform Scott Wood
@ 2012-07-06 15:08   ` Alexander Graf
  2012-07-07  7:39   ` Alexander Graf
  5 siblings, 0 replies; 11+ messages in thread
From: Alexander Graf @ 2012-07-06 15:08 UTC (permalink / raw)
  To: Scott Wood; +Cc: qemu-ppc, qemu-devel, Andreas Färber


On 03.07.2012, at 01:03, Scott Wood wrote:

> [resent with the proper address for qemu-devel, sorry...]
> 
> The current ppc_mpc8544ds.c is split into a generic (eventually) e500
> backend, and two platform frontends (mpc8544ds and a generic paravirt
> e500 platform) that instantiate the backend.
> 
> Currently the only distinction between the subplatforms is toplevel
> compatible and model in the device tree (the generic e500 backend isn't
> very generic yet), but additional refactoring should happen in the
> future.

Thanks, applied all to ppc-next.


Alex

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [RESEND PATCH v2 0/4] PPC: e500 platform refactoring
  2012-07-02 23:03 ` [Qemu-devel] [RESEND PATCH v2 0/4] PPC: e500 platform refactoring Scott Wood
                     ` (4 preceding siblings ...)
  2012-07-06 15:08   ` [Qemu-devel] [RESEND PATCH v2 0/4] PPC: e500 platform refactoring Alexander Graf
@ 2012-07-07  7:39   ` Alexander Graf
  5 siblings, 0 replies; 11+ messages in thread
From: Alexander Graf @ 2012-07-07  7:39 UTC (permalink / raw)
  To: Scott Wood; +Cc: qemu-ppc, qemu-devel, Andreas Färber


On 03.07.2012, at 01:03, Scott Wood wrote:

> [resent with the proper address for qemu-devel, sorry...]
> 
> The current ppc_mpc8544ds.c is split into a generic (eventually) e500
> backend, and two platform frontends (mpc8544ds and a generic paravirt
> e500 platform) that instantiate the backend.
> 
> Currently the only distinction between the subplatforms is toplevel
> compatible and model in the device tree (the generic e500 backend isn't
> very generic yet), but additional refactoring should happen in the
> future.
> 
> Scott Wood (4):
>  PPC: e500: rename mpc8544ds into generic file
>  PPC: e500: change internal references away from mpc8544ds
>  PPC: e500: split mpc8544ds machine from generic e500 code
>  PPC: e500: add generic e500 platform

http://buildbot.b1-systems.de/qemu/builders/ppc-next_x86_64_debian_6_0/builds/321/steps/compile/logs/stdio

Feel like fixing it? :)


Alex

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-07-07  7:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20120627234639.GA8974@tyr.buserror.net>
     [not found] ` <20120627235104.GD9149@tyr.buserror.net>
2012-07-02 16:33   ` [Qemu-devel] [PATCH 4/4] PPC: e500: add generic e500 platform Stuart Yoder
2012-07-02 16:38     ` Scott Wood
2012-07-02 17:04       ` Andreas Färber
2012-07-02 23:03 ` [Qemu-devel] [RESEND PATCH v2 0/4] PPC: e500 platform refactoring Scott Wood
2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 1/4] PPC: e500: rename mpc8544ds into generic file Scott Wood
2012-07-03 10:40     ` Andreas Färber
2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 2/4] PPC: e500: change internal references away from mpc8544ds Scott Wood
2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 3/4] PPC: e500: split mpc8544ds machine from generic e500 code Scott Wood
2012-07-02 23:03   ` [Qemu-devel] [RESEND PATCH v2 4/4] PPC: e500: add generic e500 platform Scott Wood
2012-07-06 15:08   ` [Qemu-devel] [RESEND PATCH v2 0/4] PPC: e500 platform refactoring Alexander Graf
2012-07-07  7:39   ` Alexander Graf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.