From patchwork Tue Jun 5 23:53:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 163211 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5B2F8B6F62 for ; Wed, 6 Jun 2012 10:29:05 +1000 (EST) Received: from localhost ([::1]:49072 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc3eS-0006le-De for incoming@patchwork.ozlabs.org; Tue, 05 Jun 2012 19:59:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc3d0-0003wK-5z for qemu-devel@nongnu.org; Tue, 05 Jun 2012 19:58:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sc3ZA-0002Tx-M1 for qemu-devel@nongnu.org; Tue, 05 Jun 2012 19:57:33 -0400 Received: from cantor2.suse.de ([195.135.220.15]:36458 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc3ZA-0002TN-Bn; Tue, 05 Jun 2012 19:53:36 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id E2868A2110; Wed, 6 Jun 2012 01:53:34 +0200 (CEST) From: Alexander Graf To: "qemu-devel@nongnu.org Developers" Date: Wed, 6 Jun 2012 01:53:21 +0200 Message-Id: <1338940402-28502-31-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1338940402-28502-1-git-send-email-agraf@suse.de> References: <1338940402-28502-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: qemu-ppc Mailing List Subject: [Qemu-devel] [PATCH 30/31] dt: Add global option to set phandle start offset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- device_tree.c | 27 ++++++++++++++++++++++++++- qemu-config.c | 4 ++++ 2 files changed, 30 insertions(+), 1 deletions(-) diff --git a/device_tree.c b/device_tree.c index a2039e5..5bbe3cd 100644 --- a/device_tree.c +++ b/device_tree.c @@ -22,6 +22,7 @@ #include "qemu-common.h" #include "device_tree.h" #include "hw/loader.h" +#include "sysemu.h" #include @@ -229,7 +230,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 of invalid phandle given on the command line, so fall back to + * default starting point. + */ + phandle = 0x8000; + } return phandle++; } diff --git a/qemu-config.c b/qemu-config.c index ef4714e..a96b247 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -586,6 +586,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 */ } },