From patchwork Thu Feb 13 14:41:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 183390 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp646823ile; Thu, 13 Feb 2020 07:16:21 -0800 (PST) X-Google-Smtp-Source: APXvYqxQ6HAa/vihEZS80VGHwkpCvwfuFjGJKDp8E9dHHoi6XZRZscpIvrZbXSLgJxMmBYZ8sKsj X-Received: by 2002:ae9:dc82:: with SMTP id q124mr16246139qkf.20.1581606981445; Thu, 13 Feb 2020 07:16:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581606981; cv=none; d=google.com; s=arc-20160816; b=Km+cFc8bvcrAT5Gd5kFVtBhBz9jfVyXc1Z76SVTbR94cbvhFMHx1m+J6BV87wZxlgR 1yf5iXDGAkHo2yYE1D+6AJnfRMbOLDyhw7+FXKmJwyfT2/tPsyp7BesE/koE6luXThXi 0YvrY8iptRlFEi0ARl80wTZvQ26gsdflVN8UPY9M8YOFzPDNAsTqT7O0upIXoMJ2c19m XNbrB9fqR8x1lCgggJEn2vsN22Qd09xCI1od4+89B2VNEvkvuEcP1uGuhcSKPp5TbpfX uErzR9zzWF+X7Sa2mkXTcnHA/S7ublOI7Mi+PM9hn7CEgjE4BgTOpzQtxnHXn9gWt7sc jYuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=N0Kibz+Zwr8u1oAxdBoyGL/jmEs53LkcKtGIGXIk9Jc=; b=rV81vELP4k68StYLH2up80XXzVA3K+NPdm0/4Q6vIokWbEQkjvps4vRXCoAw7e+JRT +HkOc4IC5QbNK0HBrAnxU8838k7tx5rFO0FkQyZhXyt714TBWStIuVFFd0USfysbnqlG fqfGnGb1NxYcHReY52d+Xvk91tMHrBweSCevLWmIxsoA0hwSN0C44eoqRSryIGyH57HH WFWAbsKOEC5yCy/0yzTEsHT7J9hFKGpvpZjmNtG+CjfD16qwC4OozLrxOtevvhQRcDPe rkz2TbNvvNh3BWRVGevYqwUAp+vzUOvn2UA18n1+chRXtsy3JE9w2TyOg7UzTxK4nmv4 sEmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wb2dCeNI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m4si1038775qvp.52.2020.02.13.07.16.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Feb 2020 07:16:21 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wb2dCeNI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:54492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2GE0-0006ux-NF for patch@linaro.org; Thu, 13 Feb 2020 10:16:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60572) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2FhP-0004pB-0Y for qemu-devel@nongnu.org; Thu, 13 Feb 2020 09:42:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2FhN-0002Q3-No for qemu-devel@nongnu.org; Thu, 13 Feb 2020 09:42:38 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:51274) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j2FhN-0002Je-Gl for qemu-devel@nongnu.org; Thu, 13 Feb 2020 09:42:37 -0500 Received: by mail-wm1-x32c.google.com with SMTP id t23so6545404wmi.1 for ; Thu, 13 Feb 2020 06:42:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=N0Kibz+Zwr8u1oAxdBoyGL/jmEs53LkcKtGIGXIk9Jc=; b=wb2dCeNIurBpUwfbb+APC04g/OdzVnWqKdQvnLa1cLt/2n93PP9Vf1kWWSq8fEkjlk KJZ2xAPZbx8IrjqXXwMKL6k2a4b+MB417a8gGkizabplGLFcLGXLDMcw3/RGsNZi46tY yegTzrkI/t2qo2MjxOg2Qayz3jda1whapC657j3/CaPmZuRZxx4WJx7mbBR7vxbG7Y5V 1jQy4VZ/9Tl1cTGYuNeDUO+35ibMXhHeQ5JTvulG8hePM9XzFr7H4GykaeU+2Jqcjx9R cDgceb3pbdCBkciuAdXtYq/4rRZJlWeylBXOOiuK0siJwYGO4LSaQSjkp8YL8R1+d+xO BejA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N0Kibz+Zwr8u1oAxdBoyGL/jmEs53LkcKtGIGXIk9Jc=; b=uily8rNaLX37ezcvUErvrew1jQEYk0i/MZj8Sc6maGdqvy6W1qWPJDP8/NGXTAZw7n eXLRUSV3CFAHSS9BDMspNMARxO6oJOZ/TlhzSxjRn/WHKhgLXEmNfTc0b6c+yUu4g9i/ M3LSGvlEzbMYr1qRegl4IZnHAIUZbrwHMkqjjMLLKQSrCdNe+Ulh7IuIBXDVxC6KrTUz jpgCRgaxa+t9NsrmhS1C3SFy+9DVct0CknN8drlA373mXnC/MQB8Uds3Vnnhs0x7/IXM iiPE3dtmvGWtq9v8oKhk4t2PYfcXTzrdjdsHPkUl7qRmDT9fnPUoxKAm/XjsLnqe+E87 Gaxw== X-Gm-Message-State: APjAAAXmUoSUyPk62cJEXOXPax1/Rl21+IlAN53rXXdejr0G7xBTbCpk d7NKSh3d91yuyCC0WHkIlwBC0ijscnY= X-Received: by 2002:a7b:cbc9:: with SMTP id n9mr6268103wmi.89.1581604948544; Thu, 13 Feb 2020 06:42:28 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id e22sm3362454wme.45.2020.02.13.06.42.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2020 06:42:27 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 36/46] hw/arm/raspi: Extract the RAM size from the board revision Date: Thu, 13 Feb 2020 14:41:35 +0000 Message-Id: <20200213144145.818-37-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200213144145.818-1-peter.maydell@linaro.org> References: <20200213144145.818-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé The board revision encode the amount of RAM. Add a helper to extract the RAM size, and use it. Since the amount of RAM is fixed (it is impossible to physically modify to have more or less RAM), do not allow sizes different than the one anounced by the manufacturer. Acked-by: Igor Mammedov Signed-off-by: Philippe Mathieu-Daudé Message-id: 20200208165645.15657-5-f4bug@amsat.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/raspi.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index f285e2988fc..dcd8d2d6d38 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/cutils.h" #include "qapi/error.h" #include "cpu.h" #include "hw/arm/bcm2836.h" @@ -49,6 +50,12 @@ FIELD(REV_CODE, MANUFACTURER, 16, 4); FIELD(REV_CODE, MEMORY_SIZE, 20, 3); FIELD(REV_CODE, STYLE, 23, 1); +static uint64_t board_ram_size(uint32_t board_rev) +{ + assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ + return 256 * MiB << FIELD_EX32(board_rev, REV_CODE, MEMORY_SIZE); +} + static int board_processor_id(uint32_t board_rev) { assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ @@ -191,15 +198,17 @@ static void raspi_init(MachineState *machine, uint32_t board_rev) { RasPiState *s = g_new0(RasPiState, 1); int version = board_version(board_rev); + uint64_t ram_size = board_ram_size(board_rev); uint32_t vcram_size; DriveInfo *di; BlockBackend *blk; BusState *bus; DeviceState *carddev; - if (machine->ram_size > 1 * GiB) { - error_report("Requested ram size is too large for this machine: " - "maximum is 1GB"); + if (machine->ram_size != ram_size) { + char *size_str = size_to_str(ram_size); + error_report("Invalid RAM size, should be %s", size_str); + g_free(size_str); exit(1); }