qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: QEMU-devel Developers <qemu-devel@nongnu.org>
Cc: Scott Wood <scottwood@freescale.com>
Subject: [Qemu-devel] [PATCH 09/23] PPC: E500: create multiple envs
Date: Thu, 21 Jul 2011 03:27:20 +0200	[thread overview]
Message-ID: <1311211654-14326-10-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1311211654-14326-1-git-send-email-agraf@suse.de>

When creating a VM, we should go through smp_cpus and create a virtual CPU for
every CPU the user requested. This patch adds support for that and moves some
code around to make that more convenient.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/ppce500_mpc8544ds.c |   44 +++++++++++++++++++++++++++++---------------
 1 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index b739ce2..cefb415 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -226,7 +226,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
                          const char *cpu_model)
 {
     PCIBus *pci_bus;
-    CPUState *env;
+    CPUState *env = NULL;
     uint64_t elf_entry;
     uint64_t elf_lowaddr;
     target_phys_addr_t entry=0;
@@ -240,24 +240,40 @@ static void mpc8544ds_init(ram_addr_t ram_size,
     qemu_irq *irqs, *mpic;
     DeviceState *dev;
     struct boot_info *boot_info;
+    CPUState *firstenv = NULL;
 
-    /* Setup CPU */
+    /* Setup CPUs */
     if (cpu_model == NULL) {
         cpu_model = "e500v2_v30";
     }
 
-    env = cpu_ppc_init(cpu_model);
-    if (!env) {
-        fprintf(stderr, "Unable to initialize CPU!\n");
-        exit(1);
-    }
+    for (i = 0; i < smp_cpus; i++) {
+        qemu_irq *input;
+        env = cpu_ppc_init(cpu_model);
+        if (!env) {
+            fprintf(stderr, "Unable to initialize CPU!\n");
+            exit(1);
+        }
+
+        if (!firstenv) {
+            firstenv = env;
+        }
 
-    /* XXX register timer? */
-    ppc_emb_timers_init(env, 400000000, PPC_INTERRUPT_DECR);
-    ppc_dcr_init(env, NULL, NULL);
+        env->spr[SPR_BOOKE_PIR] = env->cpu_index = i;
 
-    /* Register reset handler */
-    qemu_register_reset(mpc8544ds_cpu_reset, env);
+        /* XXX register timer? */
+        ppc_emb_timers_init(env, 400000000, PPC_INTERRUPT_DECR);
+        ppc_dcr_init(env, NULL, NULL);
+        /* XXX Enable DEC interrupts - probably wrong in the backend */
+        env->spr[SPR_40x_TCR] = 1 << 26;
+
+        /* Register reset handler */
+        boot_info = qemu_mallocz(sizeof(struct boot_info));
+        qemu_register_reset(mpc8544ds_cpu_reset, env);
+        env->load_info = boot_info;
+    }
+
+    env = firstenv;
 
     /* Fixup Memory size on a alignment boundary */
     ram_size &= ~(RAM_SIZES_ALIGN - 1);
@@ -336,8 +352,6 @@ static void mpc8544ds_init(ram_addr_t ram_size,
         }
     }
 
-    boot_info = qemu_mallocz(sizeof(struct boot_info));
-
     /* If we're loading a kernel directly, we must load the device tree too. */
     if (kernel_filename) {
 #ifndef CONFIG_FDT
@@ -350,10 +364,10 @@ static void mpc8544ds_init(ram_addr_t ram_size,
             exit(1);
         }
 
+        boot_info = env->load_info;
         boot_info->entry = entry;
         boot_info->dt_base = dt_base;
     }
-    env->load_info = boot_info;
 
     if (kvm_enabled()) {
         kvmppc_init();
-- 
1.6.0.2

  parent reply	other threads:[~2011-07-21  1:28 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-21  1:27 [Qemu-devel] [PATCH 00/23] SMP support for MPC8544DS Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 01/23] PPC: Add secondary CPU spinning code Alexander Graf
2011-07-21 16:38   ` Scott Wood
2011-07-21 16:49     ` Alexander Graf
2011-07-21 17:46       ` Scott Wood
2011-07-21  1:27 ` [Qemu-devel] [PATCH 02/23] PPC: Move openpic to target specific code compilation Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 03/23] PPC: Add CPU definitions for up to 32 guest CPUs Alexander Graf
2011-07-21 16:46   ` Scott Wood
2011-07-21 16:54     ` Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 04/23] PPC: Add CPU local MMIO regions to MPIC Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 05/23] PPC: Extend MPIC MMIO range Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 06/23] PPC: Fix IPI support in MPIC Alexander Graf
2011-07-22 14:08   ` Elie Richa
2011-07-22 15:01     ` Alexander Graf
2011-07-22 16:37       ` Scott Wood
2011-07-21  1:27 ` [Qemu-devel] [PATCH 07/23] PPC: Remove cINT code from MPIC Alexander Graf
2011-07-21 16:49   ` Scott Wood
2011-07-21 16:52     ` Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 08/23] PPC: Bump MPIC up to 32 supported CPUs Alexander Graf
2011-07-22 14:10   ` Elie Richa
2011-07-22 15:01     ` Alexander Graf
2011-07-21  1:27 ` Alexander Graf [this message]
2011-07-21  1:27 ` [Qemu-devel] [PATCH 10/23] PPC: E500: Generate IRQ lines for many CPUs Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 11/23] PPC: E500: Use spin code for secondary CPUs Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 12/23] device tree: add nop_node Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 13/23] PPC: bamboo: Move host fdt copy to target Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 14/23] PPC: KVM: Add generic function to read host clockfreq Alexander Graf
2011-07-21 17:51   ` Scott Wood
2011-07-21 18:59     ` Alexander Graf
2011-07-21 19:06       ` Scott Wood
2011-07-21  1:27 ` [Qemu-devel] [PATCH 15/23] PPC: E500: Use generic kvm function for freq Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 16/23] PPC: E500: Remove mpc8544_copy_soc_cell Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 17/23] PPC: bamboo: Use kvm api for freq and clock frequencies Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 18/23] PPC: KVM: Remove kvmppc_read_host_property Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 19/23] PPC: KVM: Add stubs for kvm helper functions Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 20/23] PPC: E500: Update freqs for all CPUs Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 21/23] PPC: E500: Remove unneeded CPU nodes Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 22/23] PPC: E500: Update cpu-release-addr property in cpu nodes Alexander Graf
2011-07-21  1:27 ` [Qemu-devel] [PATCH 23/23] PPC: E500: Bump CPU count to 32 Alexander Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1311211654-14326-10-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=qemu-devel@nongnu.org \
    --cc=scottwood@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).