From patchwork Fri Nov 22 17:17:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 21707 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9AC5523FE1 for ; Fri, 22 Nov 2013 17:17:25 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id ld13sf2756355vcb.1 for ; Fri, 22 Nov 2013 09:17:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=VZoI4H2Pv5UW2c3jopVo3H4B/VWTwj5LEiH4PTo0zs4=; b=XEeydnQuXxsRLOudSINl+0iS0BamVQer2MklGtH2zUgfUtmjKRfHV1JuH/D5O/qpHQ k+PsBhb95utsxepTkWvigt32Z5JeH+2CJClNr/6lcGXv0R3L+0m5jumH+IZHF1KL9UnQ ddq39XryhTHviGAZv/yxbcceFYzQ+oXFXuG/BsbKt9lHLarxL0jetkfv7mokEEBnixHJ RFVQbmSEe1w4qHamEr6VOY0dkl/QiI1EJcrhTYa1/8js/g0YmYnvqpH1WRcxIPWNbSNp MrRPD5PaCDA2i97xf3Q4pmk9JgpZyuINfPPKwuJUBU+ytb3W5/p4GINUfmb0z+nK8L3j GQeg== X-Gm-Message-State: ALoCoQn0vqjYM6ajFNX1F9Lt4jDBF5zxbkYrw2AI4oMlGl7tWA/fN9Bx0m5ms6PtuV/LclJZOYxr X-Received: by 10.58.136.6 with SMTP id pw6mr4518491veb.32.1385140645491; Fri, 22 Nov 2013 09:17:25 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.104.9 with SMTP id ga9ls796937qeb.38.gmail; Fri, 22 Nov 2013 09:17:25 -0800 (PST) X-Received: by 10.58.136.231 with SMTP id qd7mr12190451veb.1.1385140645347; Fri, 22 Nov 2013 09:17:25 -0800 (PST) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id th8si5869249vdc.102.2013.11.22.09.17.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 09:17:25 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id id10so1047719vcb.5 for ; Fri, 22 Nov 2013 09:17:25 -0800 (PST) X-Received: by 10.58.108.196 with SMTP id hm4mr2756016veb.28.1385140645266; Fri, 22 Nov 2013 09:17:25 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp54993vcz; Fri, 22 Nov 2013 09:17:24 -0800 (PST) X-Received: by 10.152.143.101 with SMTP id sd5mr10460238lab.26.1385140641387; Fri, 22 Nov 2013 09:17:21 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id 6si5376248lby.22.2013.11.22.09.17.20 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 22 Nov 2013 09:17:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1VjuM2-0002j6-UI; Fri, 22 Nov 2013 17:17:18 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, kvmarm@lists.cs.columbia.edu Subject: [PATCH v9 03/11] hw/arm/boot: Allow boards to provide an fdt blob Date: Fri, 22 Nov 2013 17:17:10 +0000 Message-Id: <1385140638-10444-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1385140638-10444-1-git-send-email-peter.maydell@linaro.org> References: <1385140638-10444-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: John Rigby If no fdt is provided on command line and the new field get_dtb in struct arm_boot_info is set then call it to get a device tree blob. Signed-off-by: John Rigby [PMM: minor tweaks and cleanup] Signed-off-by: Peter Maydell --- hw/arm/boot.c | 32 ++++++++++++++++++++------------ include/hw/arm/arm.h | 7 +++++++ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 583ec79..55d552f 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -228,23 +228,31 @@ static void set_kernel_args_old(const struct arm_boot_info *info) static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo) { void *fdt = NULL; - char *filename; int size, rc; uint32_t acells, scells; - filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename); - if (!filename) { - fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename); - goto fail; - } + if (binfo->dtb_filename) { + char *filename; + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename); + if (!filename) { + fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename); + goto fail; + } - fdt = load_device_tree(filename, &size); - if (!fdt) { - fprintf(stderr, "Couldn't open dtb file %s\n", filename); + fdt = load_device_tree(filename, &size); + if (!fdt) { + fprintf(stderr, "Couldn't open dtb file %s\n", filename); + g_free(filename); + goto fail; + } g_free(filename); - goto fail; + } else if (binfo->get_dtb) { + fdt = binfo->get_dtb(binfo, &size); + if (!fdt) { + fprintf(stderr, "Board was unable to create a dtb blob\n"); + goto fail; + } } - g_free(filename); acells = qemu_devtree_getprop_cell(fdt, "/", "#address-cells"); scells = qemu_devtree_getprop_cell(fdt, "/", "#size-cells"); @@ -438,7 +446,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) /* for device tree boot, we pass the DTB directly in r2. Otherwise * we point to the kernel args. */ - if (info->dtb_filename) { + if (info->dtb_filename || info->get_dtb) { /* Place the DTB after the initrd in memory. Note that some * kernels will trash anything in the 4K page the initrd * ends in, so make sure the DTB isn't caught up in that. diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h index ecbbba8..cbbf4ca 100644 --- a/include/hw/arm/arm.h +++ b/include/hw/arm/arm.h @@ -50,6 +50,13 @@ struct arm_boot_info { const struct arm_boot_info *info); void (*secondary_cpu_reset_hook)(ARMCPU *cpu, const struct arm_boot_info *info); + /* if a board is able to create a dtb without a dtb file then it + * sets get_dtb. This will only be used if no dtb file is provided + * by the user. On success, sets *size to the length of the created + * dtb, and returns a pointer to it. (The caller must free this memory + * with g_free() when it has finished with it.) On failure, returns NULL. + */ + void *(*get_dtb)(const struct arm_boot_info *info, int *size); /* if a board needs to be able to modify a device tree provided by * the user it should implement this hook. */