From patchwork Tue Apr 30 16:04:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Rigby X-Patchwork-Id: 16541 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f198.google.com (mail-ye0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 56AA520065 for ; Tue, 30 Apr 2013 16:04:51 +0000 (UTC) Received: by mail-ye0-f198.google.com with SMTP id m9sf916910yen.5 for ; Tue, 30 Apr 2013 09:04:48 -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=SB2NDZZa+D6s0aXvGnJxTsRLz6q2vngx9bzUPMSwzsnWFuYKtE4Wvvupi5n+O4YKva ayxbtqFPoVLNkuTPyhpELttnZOA2Z6HZfCneaDxCvhTciLsDJq+Q/URII5vaCHpMLhO6 wRmmY4eDgarN5XkvIPnMgFxPIhI8fF86EPOnjJsGfAfqyhbQsuwCxd8El8aFJs2pQMvJ i172cEksATOAejQvRdM7uWQ+8CZsKLAJ8hV346GwCb7yJ3A4ECSoRzw6EwKDx3KE3JeF pcFkKjIzImS5ZOjkV3GC074HKKLqcaY/JpIcrYtdQ/dA0y+AJp4P5GYE8EuDZGm3Y7n1 wkJg== X-Received: by 10.236.194.131 with SMTP id m3mr32069674yhn.31.1367337888188; Tue, 30 Apr 2013 09:04:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.58.5 with SMTP id m5ls316562qeq.40.gmail; Tue, 30 Apr 2013 09:04:47 -0700 (PDT) X-Received: by 10.220.138.75 with SMTP id z11mr22379459vct.0.1367337887784; Tue, 30 Apr 2013 09:04:47 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id ha8si12354542vdb.9.2013.04.30.09.04.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 09:04:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 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.169; Received: by mail-vc0-f169.google.com with SMTP id gd11so562933vcb.14 for ; Tue, 30 Apr 2013 09:04:47 -0700 (PDT) X-Received: by 10.52.228.71 with SMTP id sg7mr28963622vdc.51.1367337887667; Tue, 30 Apr 2013 09:04:47 -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 nf2csp113946veb; Tue, 30 Apr 2013 09:04:47 -0700 (PDT) X-Received: by 10.68.1.138 with SMTP id 10mr12420363pbm.136.1367337886792; Tue, 30 Apr 2013 09:04:46 -0700 (PDT) Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com [209.85.220.42]) by mx.google.com with ESMTPS id zm10si21012427pbc.328.2013.04.30.09.04.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 09:04:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.42 is neither permitted nor denied by best guess record for domain of john.rigby@linaro.org) client-ip=209.85.220.42; Received: by mail-pa0-f42.google.com with SMTP id kl13so427718pab.29 for ; Tue, 30 Apr 2013 09:04:46 -0700 (PDT) X-Received: by 10.68.99.226 with SMTP id et2mr76735069pbb.91.1367337886419; Tue, 30 Apr 2013 09:04:46 -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 xz4sm29023702pbb.18.2013.04.30.09.04.44 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 09:04:45 -0700 (PDT) From: John Rigby To: qemu-devel@nongnu.org Cc: Peter Maydell , patches@linaro.org, John Rigby Subject: [PATCH v2 1/2] ARM: Allow boards to provide an fdt blob Date: Tue, 30 Apr 2013 10:04:22 -0600 Message-Id: <1367337863-24730-2-git-send-email-john.rigby@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1367337863-24730-1-git-send-email-john.rigby@linaro.org> References: <1367337863-24730-1-git-send-email-john.rigby@linaro.org> X-Gm-Message-State: ALoCoQmVu9fPV4i2sKgQoDG4dAZO69DljaYDMf6ZeFioutMjdcW7l3aGc5oISD6ebhSUGqNFa+A+ X-Original-Sender: john.rigby@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.169 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);