From patchwork Fri Jul 12 20:36:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 18347 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f197.google.com (mail-gg0-f197.google.com [209.85.161.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B78B925E05 for ; Fri, 12 Jul 2013 20:37:13 +0000 (UTC) Received: by mail-gg0-f197.google.com with SMTP id x14sf10458224ggx.8 for ; Fri, 12 Jul 2013 13:37:13 -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=VI7rHVDoWiXGYILP9jOvqQT5NamOW/WGRcwqUlSH24w=; b=jxxSvzb8IWFxB2FbwmDHeyl2DFywXf3KwGMqwYzVPJiX24MgCJBngn5PWyRhJ/+lux vzs0cfdKAc7ZRePZ3pnEODua1Hvv9ye64TEkDl2hyjXCwynwDi2CIDT7xQpwczejRLQR 0kiUbMwwcIrLhWKglQszflEmFwk4ZaIIPYmBHRr+7LOpzVdHrWGwkCShIX3dKjEVQBRs djl7aXPDTW4AidaquCKWc8usNMjFqo3XMtqufQQ1X5bNqS6uXFmWfPBj7PPRxSX7sowT SeiRkYz4Ml2noE0ad2YGAKyoMCGgVBJVrWgcvEnXGt4Z26Hj/XFJTryNocSIW26RtXYQ AYlw== X-Received: by 10.236.91.173 with SMTP id h33mr23440594yhf.17.1373661433271; Fri, 12 Jul 2013 13:37:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.24.162 with SMTP id v2ls3427615qef.8.gmail; Fri, 12 Jul 2013 13:37:13 -0700 (PDT) X-Received: by 10.221.20.1 with SMTP id qm1mr25258859vcb.48.1373661433172; Fri, 12 Jul 2013 13:37:13 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id tj1si9174658vcb.108.2013.07.12.13.37.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Jul 2013 13:37:13 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.179 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.179; Received: by mail-vc0-f179.google.com with SMTP id hz11so8032355vcb.10 for ; Fri, 12 Jul 2013 13:37:13 -0700 (PDT) X-Received: by 10.220.164.138 with SMTP id e10mr25407234vcy.27.1373661433014; Fri, 12 Jul 2013 13:37:13 -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.149.77 with SMTP id s13csp147884vcv; Fri, 12 Jul 2013 13:37:12 -0700 (PDT) X-Received: by 10.60.164.33 with SMTP id yn1mr37350674oeb.5.1373661428318; Fri, 12 Jul 2013 13:37:08 -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 ko2si21456786oeb.20.2013.07.12.13.37.07 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 12 Jul 2013 13:37:07 -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 1Uxk5P-00069L-1y; Fri, 12 Jul 2013 21:37:03 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Anthony Liguori , Alexander Graf , David Gibson , kvmarm@lists.cs.columbia.edu Subject: [PATCH v2 2/8] arm/boot: Use qemu_devtree_setprop_sized_cells() Date: Fri, 12 Jul 2013 21:36:56 +0100 Message-Id: <1373661422-23606-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1373661422-23606-1-git-send-email-peter.maydell@linaro.org> References: <1373661422-23606-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQnLMbHEovc4Zg2efADy6sRxNcj5BN1KBnVUWhK204vS40UfGWoW3OeMsdLjJ/yhtahP/cAN X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.179 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 a2e4032..1166632 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; }