Skip to contentSkip to conversation

dt: add helper for empty dt creation

PATCH Alexander Graf 2 participants 3 messages Jun 5, 2012 – Jun 6, 2012 5 messages not in the archive

lore
Share & tools
lore
#3 lore raw
In reply to a message not in the archive
Quoted 9 lines · David Gibson
Quoted 5 lines · Alexander Graf

We want to get rid of the concept of loading an external device tree and instead generate our own. However, to do this we need to also create a device tree template programatically.

This patch adds a helper to create an empty device tree in memory.

Hm, this make-an-empty-template thing is common enough that I'll make a helper for it in libfdt.

Very cool :). That would still mean that we need the in-QEMU helper for a while though, until we can reasonably expect people to have newer versions of libfdt on their systems, right? :)

Alex

#7 lore raw

Re: [Qemu-devel] [PATCH 19/25] PPC: e500: dt: create pci node dynamically

In reply to a message not in the archive
Quoted 44 lines · Scott Wood
Quoted 43 lines · Alexander Graf

---

hw/ppce500_mpc8544ds.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++
pc-bios/mpc8544ds.dtb  |  Bin 1810 -> 72 bytes
pc-bios/mpc8544ds.dts  |   46 --------------------------------------------
3 files changed, 50 insertions(+), 46 deletions(-)
hw/ppce500_mpc8544ds.c +21 -0
index 3f6c6e3..d9a3d50 100644
@@ -62,6 +62,27 @@ struct boot_info
    uint32_t entry;
 };
 
+static void pci_map_create(void *fdt, uint32_t *pci_map, uint32_t mpic)
+{
+    int i;
+    const uint32_t tmp[] = {
+                             /* IDSEL 0x11 J17 Slot 1 */
+                             0x8800, 0x0, 0x0, 0x1, mpic, 0x2, 0x1,
+                             0x8800, 0x0, 0x0, 0x2, mpic, 0x3, 0x1,
+                             0x8800, 0x0, 0x0, 0x3, mpic, 0x4, 0x1,
+                             0x8800, 0x0, 0x0, 0x4, mpic, 0x1, 0x1,
+
+                             /* IDSEL 0x12 J16 Slot 2 */
+                             0x9000, 0x0, 0x0, 0x1, mpic, 0x3, 0x1,
+                             0x9000, 0x0, 0x0, 0x2, mpic, 0x4, 0x1,
+                             0x9000, 0x0, 0x0, 0x3, mpic, 0x2, 0x1,
+                             0x9000, 0x0, 0x0, 0x4, mpic, 0x1, 0x1,
+                           };
+    for (i = 0; i < (7 * 8); i++) {
+        pci_map[i] = cpu_to_be32(tmp[i]);
+    }
+}
+
 static int mpc8544_load_device_tree(CPUPPCState *env,
                                    target_phys_addr_t addr,
                                    uint32_t ramsize,
@@ -86,6 +107,11 @@ static int mpc8544_load_device_tree(CPUPPCState *env,
    char mpic[128];
    uint32_t mpic_ph;
    char gutil[128];
Quoted 8 lines

hw/ppce500_mpc8544ds.c static int mpc8544_load_device_tree(CPUPPCState *env, · line 114

Quoted 5 lines
hw/ppce500_mpc8544ds.c +5 -0
+    char pci[128];
+    uint32_t pci_map[7 * 8];
+    uint32_t pci_ranges[12] = { 0x2000000, 0x0, 0xc0000000, 0xc0000000, 0x0,
+                                0x20000000, 0x1000000, 0x0, 0x0, 0xe1000000,
+                                0x0, 0x10000 };

At least put in a FIXME for dynamically generating this from the actual data QEMU uses.

There's a big fat FIXME for that all over the place throughout the dynamic dt generation. We need to do that for interrupt lines, every time we see an address encoded, heck, even above in the map creation we want to be able to support more than 2 slots depending on the pci controller we're using, no? :)

So I don't think a FIXME here will help. Let's just keep in mind that all of this dt generation code needs quite some more love.

Alex

#4 lore raw
In reply to Alexander Graf
Quoted 8 lines · Alexander Graf
Quoted 5 lines · David Gibson
Quoted 4 lines · Alexander Graf

We want to get rid of the concept of loading an external device tree and instead generate our own. However, to do this we need to also create a device tree template programatically.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

This patch adds a helper to create an empty device tree in memory.

Hm, this make-an-empty-template thing is common enough that I'll make a helper for it in libfdt.

Very cool :). That would still mean that we need the in-QEMU helper for a while though, until we can reasonably expect people to have newer versions of libfdt on their systems, right? :)

True. The helper is in upstream libfdt git now, btw.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson