From patchwork Fri Aug 9 16:23:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 18932 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f69.google.com (mail-qe0-f69.google.com [209.85.128.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BA49D25E03 for ; Fri, 9 Aug 2013 16:23:25 +0000 (UTC) Received: by mail-qe0-f69.google.com with SMTP id 1sf2871570qec.0 for ; Fri, 09 Aug 2013 09:23:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state: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=q2DBT41UKxCUX837MDw+RFIwbGr22dTu7a7+M6FBFWU=; b=IFmVsu0k+t2x97xv1dS+1KkSdr/J9pMx4fPO3KvE0mRjOH6+I2Q9vl+JXpGfHysLuJ yKgqL81Pf7ZGRfSQDzZ9jfnMUpz4y/aTQpmhvS331Xy+VGOkCs4z5BqapI8mjyVrCKCg BCzW0DpAzQmKQRPcOQ2t8mk5YiUugASpU4JJiDXs6zVhnBACqmbn9C1xuGGDSzohjoiI 6W2ztmPX6T0Cp2z7Ns4tN6X7Zn6nGnRGRF1vnf3MnSebMXTe8lyY4CTtKrJoiuYFPNKn NsazV331/FS0PqY2fJ5yq82oTd+crXXCXx/2LY6nqGc5ty3bZ0EC0Hvjj/8DR9oa9vHZ U5Sw== X-Received: by 10.236.126.244 with SMTP id b80mr5760513yhi.31.1376065405526; Fri, 09 Aug 2013 09:23:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.62.99 with SMTP id x3ls1502290qer.56.gmail; Fri, 09 Aug 2013 09:23:25 -0700 (PDT) X-Received: by 10.220.76.69 with SMTP id b5mr7074842vck.85.1376065405390; Fri, 09 Aug 2013 09:23:25 -0700 (PDT) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by mx.google.com with ESMTPS id b1si4838747veg.23.2013.08.09.09.23.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 09 Aug 2013 09:23:25 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.46 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.46; Received: by mail-vb0-f46.google.com with SMTP id p13so4273563vbe.33 for ; Fri, 09 Aug 2013 09:23:25 -0700 (PDT) X-Gm-Message-State: ALoCoQmrHDfJOGYQruJ0YIkYWF9z6iunnEsYkFuSzj2Jw2zx0cIsekZgLWV/on/sE5hdK2zJ6bPh X-Received: by 10.58.134.84 with SMTP id pi20mr4622510veb.55.1376065405270; Fri, 09 Aug 2013 09:23:25 -0700 (PDT) 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 u4csp82113vcz; Fri, 9 Aug 2013 09:23:24 -0700 (PDT) X-Received: by 10.112.22.102 with SMTP id c6mr480521lbf.1.1376065402540; Fri, 09 Aug 2013 09:23:22 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id z2si8694469lad.63.2013.08.09.09.23.21 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 09 Aug 2013 09:23:22 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1V7pTD-0006yY-Ee; Fri, 09 Aug 2013 17:23:19 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, kvmarm@lists.cs.columbia.edu, "Mian M. Hamayun" , Anup Patel Subject: [PATCH v5 1/2] hw/arm/boot: Allow boards to provide an fdt blob Date: Fri, 9 Aug 2013 17:23:18 +0100 Message-Id: <1376065399-26785-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1376065399-26785-1-git-send-email-peter.maydell@linaro.org> References: <1376065399-26785-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.212.46 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 2cbeefd..9d790b7 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"); @@ -436,7 +444,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 bae87c6..4e51a9e 100644 --- a/include/hw/arm/arm.h +++ b/include/hw/arm/arm.h @@ -55,6 +55,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. */