From patchwork Thu Jun 27 13:04:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 18159 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 597BF25E0D for ; Thu, 27 Jun 2013 13:24:49 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id d41sf595399eek.11 for ; Thu, 27 Jun 2013 06:24:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to: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=6GED356bmcdYbDh7YW034aE8S4YZfP7OoIv2Iib7gD8=; b=WOqu2gFUb6Epd2/8b5B2aTTmxfFzeslHxxjcKOWAhTmUznZj+kCsqDJHzdpnuM1jvP /kqAuc5ZcJ9oBEOO+kCXrA+Jbcg6PtIITPyaR+TmlrXBlqpgPTrANSivPFFF/+u6pB/D irchBxFr9B39LsecoyxQhm1hVepOhSDgDzFAPwzVEwScETbZXzJco1Ap1NQLMEvqWJ9O NVVjabjbJVbUt2naiLax8gd6CdpOjEtRoA6+FnUCYndJoWVzma8RRfjtcgJ4gAUCl4aD VnDNuGn2Eap+TtdGiKPDOpa6iIEJqIrI6DSFJnQ9q5FCXNNqDc7GJeEEfJSv5/mVgUy4 4TqA== X-Received: by 10.180.210.168 with SMTP id mv8mr2529622wic.0.1372339487814; Thu, 27 Jun 2013 06:24:47 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.78.167 with SMTP id c7ls259733wix.39.canary; Thu, 27 Jun 2013 06:24:47 -0700 (PDT) X-Received: by 10.180.160.165 with SMTP id xl5mr13989114wib.46.1372339487447; Thu, 27 Jun 2013 06:24:47 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id wl8si1047480wjc.17.2013.06.27.06.24.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Jun 2013 06:24:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.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.128.169; Received: by mail-ve0-f169.google.com with SMTP id m1so648624ves.28 for ; Thu, 27 Jun 2013 06:24:46 -0700 (PDT) X-Received: by 10.52.77.5 with SMTP id o5mr2950362vdw.46.1372339486215; Thu, 27 Jun 2013 06:24:46 -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.165.8 with SMTP id yu8csp148427veb; Thu, 27 Jun 2013 06:24:45 -0700 (PDT) X-Received: by 10.194.63.46 with SMTP id d14mr6372149wjs.81.1372339484726; Thu, 27 Jun 2013 06:24:44 -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 p7si1050595wjb.0.2013.06.27.06.24.44 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 27 Jun 2013 06:24:44 -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 1UsBrz-000123-Ux; Thu, 27 Jun 2013 14:04:16 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, kvmarm@lists.cs.columbia.edu, Anthony Liguori , Alexander Graf , KONRAD Frederic , David Gibson Subject: [PATCH 2/8] arm/boot: Use qemu_devtree_setprop_sized_cells() Date: Thu, 27 Jun 2013 14:04:09 +0100 Message-Id: <1372338255-3934-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1372338255-3934-1-git-send-email-peter.maydell@linaro.org> References: <1372338255-3934-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQnw0EMibwDwgz+5S+AI9tGDvY3HWPLhcwB4qZIKxwx+NQoq8f27TtV3VQJGhgvKAluQnS98 X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.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: , Replace the opencoded assembly of the reg property array for the /memory node with a call to qemu_devtree_setprop_sized_cells(). Signed-off-by: Peter Maydell --- hw/arm/boot.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 7c0090f..eb9a864 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -227,12 +227,10 @@ static void set_kernel_args_old(const struct arm_boot_info *info) static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo) { - uint32_t *mem_reg_property; - uint32_t mem_reg_propsize; void *fdt = NULL; char *filename; int size, rc; - uint32_t acells, scells, hival; + uint32_t acells, scells; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename); if (!filename) { @@ -255,30 +253,18 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo) goto fail; } - mem_reg_propsize = acells + scells; - mem_reg_property = g_new0(uint32_t, mem_reg_propsize); - mem_reg_property[acells - 1] = cpu_to_be32(binfo->loader_start); - hival = cpu_to_be32(binfo->loader_start >> 32); - if (acells > 1) { - mem_reg_property[acells - 2] = hival; - } else if (hival != 0) { + rc = qemu_devtree_setprop_sized_cells(fdt, "/memory", "reg", + acells, binfo->loader_start, + scells, binfo->ram_size); + if (rc == 1) { fprintf(stderr, "qemu: dtb file not compatible with " "RAM start address > 4GB\n"); goto fail; - } - mem_reg_property[acells + scells - 1] = cpu_to_be32(binfo->ram_size); - hival = cpu_to_be32(binfo->ram_size >> 32); - if (scells > 1) { - mem_reg_property[acells + scells - 2] = hival; - } else if (hival != 0) { + } else if (rc == 2) { fprintf(stderr, "qemu: dtb file not compatible with " "RAM size > 4GB\n"); goto fail; - } - - rc = qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property, - mem_reg_propsize * sizeof(uint32_t)); - if (rc < 0) { + } else if (rc != 0) { fprintf(stderr, "couldn't set /memory/reg\n"); goto fail; }