Skip to contentSkip to conversation

Convert bamboo to qdev

PATCH New Alexander Graf 1 participant 6 messages Jan 10, 2012 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Convert bamboo to qdev

During discussions on the weekly QEMU call today Anthony brought up the fact that bamboo isn't qdev'ified, which kept him from QOM'ing it.

This patch set cleans up bamboo for a bit and also qdev'ifies the PCI parts of it. I'm not sure about the PIC and serial devices, since I haven't found example code for those yet.

This patch set bases on top of my previous bamboo-on-tcg patches.

Alexander Graf (5):
PPC: bamboo: remove old machine descriptions
PPC: bamboo: fix whitespace
PPC: 4xx: Qdevify the 440 PCI host controller
PPC: Bamboo: fold ppc440.c and ppc440_bamboo.c into a single file
PPC: Bamboo: Integrate SoC instatiation, use qdev for PCI

 Makefile.target    |    2 +-
 hw/ppc440.c        |  107 --------------------------------------------
 hw/ppc440.h        |   21 ---------
 hw/ppc440_bamboo.c |  108 +++++++++++++++++++++++++++++++++-----------
 hw/ppc4xx_pci.c    |  125 +++++++++++++++++++++++++++-------------------------
 hw/virtex_ml507.c  |    1 -
 6 files changed, 147 insertions(+), 217 deletions(-)
 delete mode 100644 hw/ppc440.c
 delete mode 100644 hw/ppc440.h
#1 lore raw

PATCH 1/5 PPC: bamboo: remove old machine descriptions

Nobody needs to run bamboo in 0.12 compat mode. Remove the machine.

---
 hw/ppc440_bamboo.c |   22 +---------------------
 1 files changed, 1 insertions(+), 21 deletions(-)
hw/ppc440_bamboo.c +1 -21
index c17f6f7..84e45b4 100644
@@ -214,34 +214,14 @@ static void bamboo_init(ram_addr_t ram_size,
 }
 
 static QEMUMachine bamboo_machine = {
-    .name = "bamboo-0.13",
-    .alias = "bamboo",
+    .name = "bamboo",
     .desc = "bamboo",
     .init = bamboo_init,
 };
 
-static QEMUMachine bamboo_machine_v0_12 = {
-    .name = "bamboo-0.12",
-    .desc = "bamboo",
-    .init = bamboo_init,
-    .compat_props = (GlobalProperty[]) {
-        {
-            .driver   = "virtio-serial-pci",
-            .property = "max_ports",
-            .value    = stringify(1),
-        },{
-            .driver   = "virtio-serial-pci",
-            .property = "vectors",
-            .value    = stringify(0),
-        },
-        { /* end of list */ }
-    },
-};
-
 static void bamboo_machine_init(void)
 {
     qemu_register_machine(&bamboo_machine);
-    qemu_register_machine(&bamboo_machine_v0_12);
 }
 
 machine_init(bamboo_machine_init);
Signature · 1 line
1.6.0.2
#2 lore raw

PATCH 2/5 PPC: bamboo: fix whitespace

In reply to Alexander Graf

Tabs followed by spaces are a no-go. My editor shows it red, distracting me from actual work! :)

---
 hw/ppc440_bamboo.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
hw/ppc440_bamboo.c +3 -3
index 84e45b4..2369fba 100644
@@ -3,9 +3,9 @@
  *
  * Copyright 2007 IBM Corporation.
  * Authors:
- * 	Jerone Young <[email protected]>
- * 	Christian Ehrhardt <[email protected]>
- * 	Hollis Blanchard <[email protected]>
+ *	Jerone Young <[email protected]>
+ *	Christian Ehrhardt <[email protected]>
+ *	Hollis Blanchard <[email protected]>
  *
  * This work is licensed under the GNU GPL license version 2 or later.
  *
Signature · 1 line
1.6.0.2
#3 lore raw

PATCH 3/5 PPC: 4xx: Qdevify the 440 PCI host controller

In reply to Alexander Graf

Due to popular demand, this qdevifies the PCI host controller of 4xx SoCs the same way as e500.

We have to introduce a small stub function for pci init that will be removed in a later patch, once we qdev'ified the board, to keep the build working.

---
 hw/ppc440_bamboo.c |    9 ++++
 hw/ppc4xx_pci.c    |  125 +++++++++++++++++++++++++++-------------------------
 2 files changed, 74 insertions(+), 60 deletions(-)
hw/ppc440_bamboo.c +9 -0
index 2369fba..124e7d7 100644
@@ -34,6 +34,15 @@
 
 static target_phys_addr_t entry;
 
+static PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],
+                               target_phys_addr_t config_space,
+                               target_phys_addr_t int_ack,
+                               target_phys_addr_t special_cycle,
+                               target_phys_addr_t registers)
+{
+    return NULL;
+}
+
 static int bamboo_load_device_tree(target_phys_addr_t addr,
                                      uint32_t ramsize,
                                      target_phys_addr_t initrd_base,
hw/ppc4xx_pci.c +65 -60

153 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#4 lore raw

PATCH 4/5 PPC: Bamboo: fold ppc440.c and ppc440_bamboo.c into a single file

In reply to Alexander Graf

The separation of ppc440 and ppc440_bamboo makes some sense, since ppc440 is the SoC while ppc440_bamboo is the actual board. But the separation makes things harder for us for no good reason, so let's just fold them in together with each other.

---
 Makefile.target    |    2 +-
 hw/ppc440.c        |  107 ----------------------------------------------------
 hw/ppc440.h        |   21 ----------
 hw/ppc440_bamboo.c |   90 +++++++++++++++++++++++++++++++++++++++++++-
 hw/virtex_ml507.c  |    1 -
 5 files changed, 90 insertions(+), 131 deletions(-)
 delete mode 100644 hw/ppc440.c
 delete mode 100644 hw/ppc440.h
Makefile.target +1 -1
index 06d79b8..a67e1fe 100644
@@ -250,7 +250,7 @@ obj-ppc-$(CONFIG_PSERIES) += xics.o spapr_vty.o spapr_llan.o spapr_vscsi.o
 obj-ppc-$(CONFIG_PSERIES) += spapr_pci.o device-hotplug.o pci-hotplug.o
 # PowerPC 4xx boards
 obj-ppc-y += ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o
-obj-ppc-y += ppc440.o ppc440_bamboo.o
+obj-ppc-y += ppc440_bamboo.o
 # PowerPC E500 boards
 obj-ppc-y += ppce500_mpc8544ds.o mpc8544_guts.o ppce500_spin.o
 # PowerPC 440 Xilinx ML507 reference board.
hw/ppc440.c deleted +0 -107

107 lines not on this page · raw message

hw/ppc440.h deleted +0 -21
deleted file mode 100644
index 9c27c36..0000000
@@ -1,21 +0,0 @@
-/*
- * Qemu PowerPC 440 board emualtion
- *
- * Copyright 2007 IBM Corporation.
- * Authors: Jerone Young <[email protected]>
- * 	    Christian Ehrhardt <[email protected]>
- *
- * This work is licensed under the GNU GPL licence version 2 or later
- *
- */
-
-#ifndef QEMU_PPC440_H
-#define QEMU_PPC440_H
-
-#include "hw.h"
-
-CPUState *ppc440ep_init(MemoryRegion *address_space, ram_addr_t *ram_size,
-                        PCIBus **pcip, const unsigned int pci_irq_nrs[4],
-                        int do_init, const char *cpu_model);
-
-#endif
hw/ppc440_bamboo.c +89 -1

114 lines not on this page · raw message

hw/virtex_ml507.c +0 -1
index bd16b97..f8d2b1b 100644
@@ -38,7 +38,6 @@
 
 #include "ppc.h"
 #include "ppc4xx.h"
-#include "ppc440.h"
 #include "ppc405.h"
 
 #include "blockdev.h"
Signature · 1 line
1.6.0.2
#5 lore raw

PATCH 5/5 PPC: Bamboo: Integrate SoC instatiation, use qdev for PCI

In reply to Alexander Graf

Now that we have the SoC init function in the same file, let's integrate it with the board initialization.

While at it, also make use of the newly qdev'ified PCI host controller.

---
 hw/ppc440_bamboo.c |  143 ++++++++++++++++++++++------------------------------
 1 files changed, 60 insertions(+), 83 deletions(-)
hw/ppc440_bamboo.c +60 -83
index d00bdda..f86b168 100644
@@ -27,6 +27,7 @@
 #include "ppc.h"
 #include "ppc405.h"
 #include "sysemu.h"
+#include "sysbus.h"
 
 #define BINARY_DEVICE_TREE_FILE "bamboo.dtb"
 
@@ -50,87 +51,6 @@ static const unsigned int ppc440ep_sdram_bank_sizes[] = {
 
 static target_phys_addr_t entry;
 
-static PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],
-                               target_phys_addr_t config_space,
-                               target_phys_addr_t int_ack,
-                               target_phys_addr_t special_cycle,
-                               target_phys_addr_t registers)
-{
-    return NULL;
-}
-
-CPUState *ppc440ep_init(MemoryRegion *address_space_mem, ram_addr_t *ram_size,
-                        PCIBus **pcip, const unsigned int pci_irq_nrs[4],
-                        int do_init, const char *cpu_model)
-{
-    MemoryRegion *ram_memories
-        = g_malloc(PPC440EP_SDRAM_NR_BANKS * sizeof(*ram_memories));
-    target_phys_addr_t ram_bases[PPC440EP_SDRAM_NR_BANKS];
-    target_phys_addr_t ram_sizes[PPC440EP_SDRAM_NR_BANKS];
-    CPUState *env;
-    qemu_irq *pic;
-    qemu_irq *irqs;
-    qemu_irq *pci_irqs;
-
-    if (cpu_model == NULL) {
-        cpu_model = "440EP";
-    }
-    env = cpu_init(cpu_model);
-    if (!env) {
-        fprintf(stderr, "Unable to initialize CPU!\n");
-        exit(1);
-    }
-
-    ppc_booke_timers_init(env, 400000000, 0);
-    ppc_dcr_init(env, NULL, NULL);
-
-    /* interrupt controller */
-    irqs = g_malloc0(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
-    irqs[PPCUIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
-    irqs[PPCUIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];
-    pic = ppcuic_init(env, irqs, 0x0C0, 0, 1);
-
-    /* SDRAM controller */
-    memset(ram_bases, 0, sizeof(ram_bases));
-    memset(ram_sizes, 0, sizeof(ram_sizes));
-    *ram_size = ppc4xx_sdram_adjust(*ram_size, PPC440EP_SDRAM_NR_BANKS,
-                                    ram_memories,
-                                    ram_bases, ram_sizes,
-                                    ppc440ep_sdram_bank_sizes);
-    /* XXX 440EP's ECC interrupts are on UIC1, but we've only created UIC0. */
-    ppc4xx_sdram_init(env, pic[14], PPC440EP_SDRAM_NR_BANKS, ram_memories,
-                      ram_bases, ram_sizes, do_init);
-
-    /* PCI */
-    pci_irqs = g_malloc(sizeof(qemu_irq) * 4);
-    pci_irqs[0] = pic[pci_irq_nrs[0]];
-    pci_irqs[1] = pic[pci_irq_nrs[1]];
-    pci_irqs[2] = pic[pci_irq_nrs[2]];
-    pci_irqs[3] = pic[pci_irq_nrs[3]];
-    *pcip = ppc4xx_pci_init(env, pci_irqs,
-                            PPC440EP_PCI_CONFIG,
-                            PPC440EP_PCI_INTACK,
-                            PPC440EP_PCI_SPECIAL,
-                            PPC440EP_PCI_REGS);
-    if (!*pcip)
-        printf("couldn't create PCI controller!\n");
-
-    isa_mmio_init(PPC440EP_PCI_IO, PPC440EP_PCI_IOLEN);
-
-    if (serial_hds[0] != NULL) {
-        serial_mm_init(address_space_mem, 0xef600300, 0, pic[0],
-                       PPC_SERIAL_MM_BAUDBASE, serial_hds[0],
-                       DEVICE_BIG_ENDIAN);
-    }
-    if (serial_hds[1] != NULL) {
-        serial_mm_init(address_space_mem, 0xef600400, 0, pic[1],
-                       PPC_SERIAL_MM_BAUDBASE, serial_hds[1],
-                       DEVICE_BIG_ENDIAN);
-    }
-
-    return env;
-}
-
 static int bamboo_load_device_tree(target_phys_addr_t addr,
                                      uint32_t ramsize,
                                      target_phys_addr_t initrd_base,
@@ -245,19 +165,76 @@ static void bamboo_init(ram_addr_t ram_size,
 {
     unsigned int pci_irq_nrs[4] = { 28, 27, 26, 25 };
     MemoryRegion *address_space_mem = get_system_memory();
+    MemoryRegion *ram_memories
+        = g_malloc(PPC440EP_SDRAM_NR_BANKS * sizeof(*ram_memories));
+    target_phys_addr_t ram_bases[PPC440EP_SDRAM_NR_BANKS];
+    target_phys_addr_t ram_sizes[PPC440EP_SDRAM_NR_BANKS];
+    qemu_irq *pic;
+    qemu_irq *irqs;
     PCIBus *pcibus;
     CPUState *env;
     uint64_t elf_entry;
     uint64_t elf_lowaddr;
     target_phys_addr_t loadaddr = 0;
     target_long initrd_size = 0;
+    DeviceState *dev;
     int success;
     int i;
 
     /* Setup CPU. */
-    env = ppc440ep_init(address_space_mem, &ram_size, &pcibus,
-                        pci_irq_nrs, 1, cpu_model);
+    if (cpu_model == NULL) {
+        cpu_model = "440EP";
+    }
+    env = cpu_init(cpu_model);
+    if (!env) {
+        fprintf(stderr, "Unable to initialize CPU!\n");
+        exit(1);
+    }
+
     qemu_register_reset(main_cpu_reset, env);
+    ppc_booke_timers_init(env, 400000000, 0);
+    ppc_dcr_init(env, NULL, NULL);
+
+    /* interrupt controller */
+    irqs = g_malloc0(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
+    irqs[PPCUIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
+    irqs[PPCUIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];
+    pic = ppcuic_init(env, irqs, 0x0C0, 0, 1);
+
+    /* SDRAM controller */
+    memset(ram_bases, 0, sizeof(ram_bases));
+    memset(ram_sizes, 0, sizeof(ram_sizes));
+    ram_size = ppc4xx_sdram_adjust(ram_size, PPC440EP_SDRAM_NR_BANKS,
+                                   ram_memories,
+                                   ram_bases, ram_sizes,
+                                   ppc440ep_sdram_bank_sizes);
+    /* XXX 440EP's ECC interrupts are on UIC1, but we've only created UIC0. */
+    ppc4xx_sdram_init(env, pic[14], PPC440EP_SDRAM_NR_BANKS, ram_memories,
+                      ram_bases, ram_sizes, 1);
+
+    /* PCI */
+    dev = sysbus_create_varargs("ppc4xx-pcihost", PPC440EP_PCI_CONFIG,
+                                pic[pci_irq_nrs[0]], pic[pci_irq_nrs[1]],
+                                pic[pci_irq_nrs[2]], pic[pci_irq_nrs[3]],
+                                NULL);
+    pcibus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
+    if (!pcibus) {
+        fprintf(stderr, "couldn't create PCI controller!\n");
+        exit(1);
+    }
+
+    isa_mmio_init(PPC440EP_PCI_IO, PPC440EP_PCI_IOLEN);
+
+    if (serial_hds[0] != NULL) {
+        serial_mm_init(address_space_mem, 0xef600300, 0, pic[0],
+                       PPC_SERIAL_MM_BAUDBASE, serial_hds[0],
+                       DEVICE_BIG_ENDIAN);
+    }
+    if (serial_hds[1] != NULL) {
+        serial_mm_init(address_space_mem, 0xef600400, 0, pic[1],
+                       PPC_SERIAL_MM_BAUDBASE, serial_hds[1],
+                       DEVICE_BIG_ENDIAN);
+    }
 
     if (pcibus) {
         /* Register network interfaces. */
Signature · 1 line
1.6.0.2