From patchwork Tue Jul 16 12:25:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 18376 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1AB8D2397D for ; Tue, 16 Jul 2013 12:25:25 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id m1sf844867ves.7 for ; Tue, 16 Jul 2013 05:25:24 -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=a52Q+3V+pnZ9HNILyQvcWj+raZ/5Ef2CzvJd90lMz80=; b=bdWVPnMEFh/z8lcd0CtK7kihYXPOPwAFQ8HN4cxhmMqCcab+XPS5frOfCV/9ob/LX9 dmNyn+weEbGTp0FkEIgd1jSx1Engj5kx6sSXti/ffyt4t+hEFjaCKmTz3ersQSDAXFyb JmDmxC9gFseK9IUzMAPuR5QGa4lWR9z8tYGnOSgMyvBNRzeEXbXvwzmBbQRsinqVTJYi v8pIMzQnGCHgVJzLgki5KOTYnadv7UEUPYzgYXOtrGcukhYeTNHMIIhm63bXWfOYCm2B 16+pYT/CWWFT4y2QZc326DmPmtiksMdK0AO2lcj+xUXKFsbOeoi7boh4O2HegbQtSajD Ojgw== X-Received: by 10.236.51.225 with SMTP id b61mr680894yhc.4.1373977524706; Tue, 16 Jul 2013 05:25:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.119.67 with SMTP id ks3ls208357qeb.57.gmail; Tue, 16 Jul 2013 05:25:24 -0700 (PDT) X-Received: by 10.220.45.132 with SMTP id e4mr362978vcf.56.1373977524591; Tue, 16 Jul 2013 05:25:24 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id x9si202991vec.80.2013.07.16.05.25.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Jul 2013 05:25:24 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.174 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.174; Received: by mail-ve0-f174.google.com with SMTP id oz10so431252veb.33 for ; Tue, 16 Jul 2013 05:25:24 -0700 (PDT) X-Received: by 10.58.128.71 with SMTP id nm7mr361781veb.51.1373977524504; Tue, 16 Jul 2013 05:25:24 -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 s13csp117214vcv; Tue, 16 Jul 2013 05:25:23 -0700 (PDT) X-Received: by 10.204.228.76 with SMTP id jd12mr239844bkb.133.1373977519717; Tue, 16 Jul 2013 05:25:19 -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 ki1si217812bkb.187.2013.07.16.05.25.19 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 16 Jul 2013 05:25:19 -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 1Uz4Jd-0007XF-2L; Tue, 16 Jul 2013 13:25:13 +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 , Peter Crosthwaite Subject: [PATCH v3 2/8] arm/boot: Use qemu_devtree_setprop_sized_cells() Date: Tue, 16 Jul 2013 13:25:06 +0100 Message-Id: <1373977512-28932-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1373977512-28932-1-git-send-email-peter.maydell@linaro.org> References: <1373977512-28932-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQlPrgCcXFfAO30bJ/Vv3y1wP91mnvaNwLF5Zf9/DQD+X+sddBRU9jMKo1kzQWG85SgAoYZZ X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.174 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 Reviewed-by: Peter Crosthwaite --- hw/arm/boot.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index a2e4032..1780316 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,29 +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) { - 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) { + if (scells < 2 && binfo->ram_size >= (1ULL << 32)) { + /* This is user error so deserves a friendlier error message + * than the failure of setprop_sized_cells would provide + */ 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)); + rc = qemu_devtree_setprop_sized_cells(fdt, "/memory", "reg", + acells, binfo->loader_start, + scells, binfo->ram_size); if (rc < 0) { fprintf(stderr, "couldn't set /memory/reg\n"); goto fail;