From patchwork Mon Jun 24 10:22: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: 18060 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 77F8325DEA for ; Mon, 24 Jun 2013 10:23:04 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id ey16sf3305867wid.1 for ; Mon, 24 Jun 2013 03:23:03 -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=3zyXiQa8e2zAZbs/8fSr21IZzczgT65GyvaETCNn/kA=; b=pWvIvBhNpVhqB1H3zCGCbLtzFxSJqulndPSp/cNFAmpXuqQlIKzOBtOVHf5j+I7OQc EsUov+6Vsw+kC7oNjwG4NObVADQHZk/Pvz3fB1+6v5HB2zohI1E+Ysxqna7Wz3wrR8yV kfoCIdtxYg4tHqMpofhnlvH5iOoaO/PjNYihjrQDMMeU/XGFkul9SPRQPbHfykWl56gE bECB0XVWED8Q3crPX5Nmd1pOQRqPk56viAzn3UmhStCVGVzzwvfMh/EX7uOA2cIV6m2Z IOzcSCCjDhXsl+bghPi0YVup7Q2EcIGtNf3/s2jotWe8FTDumybcU92CL/CoPkXnZMu9 n8oA== X-Received: by 10.180.207.44 with SMTP id lt12mr3364164wic.5.1372069383192; Mon, 24 Jun 2013 03:23:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.13.233 with SMTP id k9ls815445wic.53.gmail; Mon, 24 Jun 2013 03:23:03 -0700 (PDT) X-Received: by 10.180.85.8 with SMTP id d8mr3039385wiz.13.1372069382972; Mon, 24 Jun 2013 03:23:02 -0700 (PDT) Received: from mail-ve0-x22d.google.com (mail-ve0-x22d.google.com [2607:f8b0:400c:c01::22d]) by mx.google.com with ESMTPS id ln7si5878227wjb.86.2013.06.24.03.23.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Jun 2013 03:23:02 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22d 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::22d; Received: by mail-ve0-f173.google.com with SMTP id jw11so8428701veb.4 for ; Mon, 24 Jun 2013 03:23:01 -0700 (PDT) X-Received: by 10.52.27.172 with SMTP id u12mr8689268vdg.64.1372069381920; Mon, 24 Jun 2013 03:23:01 -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 yu8csp21610veb; Mon, 24 Jun 2013 03:23:01 -0700 (PDT) X-Received: by 10.204.61.71 with SMTP id s7mr1080209bkh.74.1372069380017; Mon, 24 Jun 2013 03:23:00 -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 w3si2199607bkh.281.2013.06.24.03.22.59 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 24 Jun 2013 03:22:59 -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 1Ur3vE-0007yn-Iw; Mon, 24 Jun 2013 11:22:56 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Peter Crosthwaite , Alexander Graf , David Gibson Subject: [PATCH 2/2] arm/boot: Use qemu_devtree_setprop_sized_cells() Date: Mon, 24 Jun 2013 11:22:56 +0100 Message-Id: <1372069376-30640-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1372069376-30640-1-git-send-email-peter.maydell@linaro.org> References: <1372069376-30640-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQkTrgGRRGuHVrlk+XdTdsca96fDHN/a2XGcEN0MLA832bboEk7RM8EEPTciNNN5/yq36VEt X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22d 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..7f98497 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, 0); + 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; }