From patchwork Tue Apr 30 15:47:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Rigby X-Patchwork-Id: 16539 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B58FB20065 for ; Tue, 30 Apr 2013 15:47:47 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id e13sf1020452vbg.1 for ; Tue, 30 Apr 2013 08:47:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=fNISnmPjBYdEJGiYmjcLO48qCyA+h7JJzsMGyWfUktg=; b=gLycdG8sBTNtZURzOvBYSnOOcylKKN/Iyx4zEKfIEmBbxEtxPR0EU370OJd5nUU2JD P9ewar+JElswOE/n4W6MB777FJHzcvS0rfMa5NrS3D3h142pcnytaXZqh2DSPnQ/jvb2 xBLMp8v6TyHnIBx4mbQ+CtaXtzYszsXybMLvlF9z/1kWC0d8hJ/lL8ggK2ZoPoaH0JoI SS4I6pIj/Lh8jAtv3VcgZ8jjCSCozlTeI/N5vaNbL6hjNblVWKCauaVurTAqMTGxAAyG vmm4X5iM0SFJrQrtDTEAHwhe+cl2EwdV8qMy4HfjrVABs/rTBmuFSj8/nNxuLWZfxSEj Ta4g== X-Received: by 10.236.62.166 with SMTP id y26mr9529920yhc.39.1367336864581; Tue, 30 Apr 2013 08:47:44 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.25.18 with SMTP id y18ls349531qef.5.gmail; Tue, 30 Apr 2013 08:47:44 -0700 (PDT) X-Received: by 10.59.9.39 with SMTP id dp7mr35275372ved.36.1367336864183; Tue, 30 Apr 2013 08:47:44 -0700 (PDT) Received: from mail-ve0-x231.google.com (mail-ve0-x231.google.com [2607:f8b0:400c:c01::231]) by mx.google.com with ESMTPS id nw10si3278559vcb.2.2013.04.30.08.47.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 08:47:44 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::231 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::231; Received: by mail-ve0-f177.google.com with SMTP id cy12so511426veb.8 for ; Tue, 30 Apr 2013 08:47:44 -0700 (PDT) X-Received: by 10.58.230.130 with SMTP id sy2mr3095560vec.22.1367336864086; Tue, 30 Apr 2013 08:47:44 -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.58.127.98 with SMTP id nf2csp113243veb; Tue, 30 Apr 2013 08:47:43 -0700 (PDT) X-Received: by 10.66.122.74 with SMTP id lq10mr64967093pab.78.1367336862979; Tue, 30 Apr 2013 08:47:42 -0700 (PDT) Received: from mail-pd0-f171.google.com (mail-pd0-f171.google.com [209.85.192.171]) by mx.google.com with ESMTPS id ra8si3977070pab.236.2013.04.30.08.47.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 08:47:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.171 is neither permitted nor denied by best guess record for domain of john.rigby@linaro.org) client-ip=209.85.192.171; Received: by mail-pd0-f171.google.com with SMTP id t10so376611pdi.30 for ; Tue, 30 Apr 2013 08:47:42 -0700 (PDT) X-Received: by 10.66.233.97 with SMTP id tv1mr49384957pac.96.1367336862584; Tue, 30 Apr 2013 08:47:42 -0700 (PDT) Received: from localhost.localdomain (c-76-23-54-220.hsd1.ut.comcast.net. [76.23.54.220]) by mx.google.com with ESMTPSA id fx2sm31135038pac.4.2013.04.30.08.47.40 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 08:47:41 -0700 (PDT) From: John Rigby To: qemu-devel@nongnu.org Cc: Peter Maydell , patches@linaro.org, John Rigby Subject: [PATCH 1/2] ARM: Allow boards to provide an fdt blob Date: Tue, 30 Apr 2013 09:47:17 -0600 Message-Id: <1367336838-23742-2-git-send-email-john.rigby@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1367336838-23742-1-git-send-email-john.rigby@linaro.org> References: <1367336838-23742-1-git-send-email-john.rigby@linaro.org> X-Gm-Message-State: ALoCoQmGhWieQlmNdl25P7HPdORbdxWr3zlFqi3AzrNmw1ReKvZ7MFB1URwjq27TBr2nBU4OWAVs X-Original-Sender: john.rigby@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::231 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: , 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. Also allow dumping of device tree by calling qemu_devtree_dumpdtb near the end of load_dtb. Signed-off-by: John Rigby --- hw/arm/boot.c | 31 ++++++++++++++++++++----------- include/hw/arm/arm.h | 6 ++++++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index f451529..de71edf 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -235,19 +235,27 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo) int size, rc; uint32_t acells, scells, hival; - 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); - return -1; - } + if (binfo->dtb_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); + return -1; + } - 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); + return -1; + } g_free(filename); - return -1; + } else if (binfo->get_dtb) { + fdt = binfo->get_dtb(addr, binfo, &size); + if (!fdt) { + fprintf(stderr, "Couldn't get dtb blob from board func\n"); + return -1; + } } - g_free(filename); acells = qemu_devtree_getprop_cell(fdt, "/", "#address-cells"); scells = qemu_devtree_getprop_cell(fdt, "/", "#size-cells"); @@ -304,6 +312,7 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo) fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); } } + qemu_devtree_dumpdtb(fdt, size); cpu_physical_memory_write(addr, fdt, size); @@ -440,7 +449,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 7b2b02d..4c56a1b 100644 --- a/include/hw/arm/arm.h +++ b/include/hw/arm/arm.h @@ -31,6 +31,10 @@ struct arm_boot_info { const char *kernel_cmdline; const char *initrd_filename; const char *dtb_filename; + /* 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. + */ + void *(*get_dtb)(hwaddr addr, const struct arm_boot_info *binfo, int *size); hwaddr loader_start; /* multicore boards that use the default secondary core boot functions * need to put the address of the secondary boot code, the boot reg, @@ -59,6 +63,8 @@ struct arm_boot_info { int is_linux; hwaddr initrd_start; hwaddr initrd_size; + void *dtb_blob; + int dtb_blob_size; hwaddr entry; }; void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info);