]> git.proxmox.com Git - qemu.git/commitdiff
dt: Add global option to set phandle start offset
authorAlexander Graf <agraf@suse.de>
Tue, 5 Jun 2012 23:01:23 +0000 (01:01 +0200)
committerAlexander Graf <agraf@suse.de>
Sat, 23 Jun 2012 23:04:50 +0000 (01:04 +0200)
If anyone outside of QEMU wants to mess with a QEMU generated device tree,
he needs to know which range phandles are valid in. So let's expose a
machine option that an external program can use to set the start allocate
id for phandles in QEMU.

Signed-off-by: Alexander Graf <agraf@suse.de>
device_tree.c
qemu-config.c

index cc83f0fb01486c978c2631c2140dbe2ffe84fb15..acae53e6b6319619eb96c34685af35631027adec 100644 (file)
@@ -22,6 +22,8 @@
 #include "qemu-common.h"
 #include "device_tree.h"
 #include "hw/loader.h"
+#include "qemu-option.h"
+#include "qemu-config.h"
 
 #include <libfdt.h>
 
@@ -200,7 +202,31 @@ int qemu_devtree_setprop_phandle(void *fdt, const char *node_path,
 
 uint32_t qemu_devtree_alloc_phandle(void *fdt)
 {
-    static int phandle = 0x8000;
+    static int phandle = 0x0;
+
+    /*
+     * We need to find out if the user gave us special instruction at
+     * which phandle id to start allocting phandles.
+     */
+    if (!phandle) {
+        QemuOpts *machine_opts;
+        machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
+        if (machine_opts) {
+            const char *phandle_start;
+            phandle_start = qemu_opt_get(machine_opts, "phandle_start");
+            if (phandle_start) {
+                phandle = strtoul(phandle_start, NULL, 0);
+            }
+        }
+    }
+
+    if (!phandle) {
+        /*
+         * None or invalid phandle given on the command line, so fall back to
+         * default starting point.
+         */
+        phandle = 0x8000;
+    }
 
     return phandle++;
 }
index 5bbebafa1b66acf3457c5cea22b26649535c0b9f..2cd27262e950d69623c94f6fcecb51cc2287a115 100644 (file)
@@ -587,6 +587,10 @@ static QemuOptsList qemu_machine_opts = {
             .name = "dumpdtb",
             .type = QEMU_OPT_STRING,
             .help = "Dump current dtb to a file and quit",
+        }, {
+            .name = "phandle_start",
+            .type = QEMU_OPT_STRING,
+            .help = "The first phandle ID we may generate dynamically",
         },
         { /* End of list */ }
     },