From nobody Thu Nov 13 18:08:16 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=amsat.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581940150136822.0604307243539; Mon, 17 Feb 2020 03:49:10 -0800 (PST) Received: from localhost ([::1]:44138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3etg-0002fl-SW for importer@patchew.org; Mon, 17 Feb 2020 06:49:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40618) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3eqN-0006VY-Fj for qemu-devel@nongnu.org; Mon, 17 Feb 2020 06:45:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3eqM-0002Po-BV for qemu-devel@nongnu.org; Mon, 17 Feb 2020 06:45:43 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:51764) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j3eqM-0002P7-5H; Mon, 17 Feb 2020 06:45:42 -0500 Received: by mail-wm1-x341.google.com with SMTP id t23so16826858wmi.1; Mon, 17 Feb 2020 03:45:42 -0800 (PST) Received: from x1w.redhat.com (78.red-88-21-202.staticip.rima-tde.net. [88.21.202.78]) by smtp.gmail.com with ESMTPSA id i2sm268149wmb.28.2020.02.17.03.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 03:45:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GA3hSTRvUjj0h1sIVU2hxdzg27YAXWTu1THZdiNMV1A=; b=VyI27O8qMg45Z8IULsRRahYlyIn66s55ZoN7piORnzwJE1lT40pqywukJ7PhcuDo35 PFtafWyqmuD3ysSf900SWt5sXt3tRtaHYGFRTBjbTTJxCwQcQyCIcs2n9VdmzjJSdUQo wgQQOxwtaBi1ZzZlKfU8L/TynqVNQ1KnqzFYrWv1OKa9PGZ7mRu+KvKJttLC97KnxUVC K/5UXkV7ADoMPFiguIkZCjdtjvE4hDRzXMepyj/SGIT8cNa8ZLBHxB4/ETCjwELZhB7G 5CyxTge0jSmMkz+WRFJJeNMaSGaUEAJMwLJUIJVkjf4nEmYNbw0L3hXN9j1uGZr2PVVF QjYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=GA3hSTRvUjj0h1sIVU2hxdzg27YAXWTu1THZdiNMV1A=; b=Q9c8NDmenPBWFEfCznAY9pEUD5WWsgk/wei5ecPhwl1+THpuHXa+UjEBWh4saOmzha Sid8WRYjvtbRsVW9LfolTjGS/BnoEEWp56K+QIJTxRfHbtHioWW4cBmNdcuXe0dw9NGu /FFIM/Tm58+CKdxfbL3UVXb+DD1LyS0BnvbbunwN2x5RlXhEh9x9LVzmqVYZ666f4E06 2hSrPFLi4g8FmsWFqiKVHjfVujepJykATyHbPAhdg7T4tV9EpPcG0u4XYFBaO3bGfioE 3Eo173JVpwESSAKkmuCzBNcmVRH9Svxt7mRmcDrK/3fZRuiWVVdMLEEZZgWZBvKa/Lwj TnsQ== X-Gm-Message-State: APjAAAUUYbG7Ju4I6x0p1GZAvOlfct7mZ1h4XXWh8Bk2KKS5GjqCXRWj IK9nJg57dr41b3vCw9j/JsHJ/gITwYE= X-Google-Smtp-Source: APXvYqyW6KGbl2DL28qt4BzkxFfHoEuCamqT/0zWHnB/UKhBz+fum1f8lgDh4aUTeZXGZUyJbLASHQ== X-Received: by 2002:a7b:ce18:: with SMTP id m24mr21938382wmc.123.1581939940880; Mon, 17 Feb 2020 03:45:40 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 04/13] hw/arm/raspi: Introduce RaspiProcessorId enum Date: Mon, 17 Feb 2020 12:45:24 +0100 Message-Id: <20200217114533.17779-5-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200217114533.17779-1-f4bug@amsat.org> References: <20200217114533.17779-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 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: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Baumann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) As we only support a reduced set of the REV_CODE_PROCESSOR id encoded in the board revision, define the PROCESSOR_ID values as an enum. We can simplify the board_soc_type and cores_count methods. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Luc Michel --- hw/arm/raspi.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index d9e8acfe3b..b628dadf34 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -69,16 +69,33 @@ FIELD(REV_CODE, MANUFACTURER, 16, 4); FIELD(REV_CODE, MEMORY_SIZE, 20, 3); FIELD(REV_CODE, STYLE, 23, 1); =20 +typedef enum RaspiProcessorId { + PROCESSOR_ID_BCM2836 =3D 1, + PROCESSOR_ID_BCM2837 =3D 2, +} RaspiProcessorId; + +static const struct { + const char *type; + int cores_count; +} soc_property[] =3D { + [PROCESSOR_ID_BCM2836] =3D {TYPE_BCM2836, BCM283X_NCPUS}, + [PROCESSOR_ID_BCM2837] =3D {TYPE_BCM2837, BCM283X_NCPUS}, +}; + 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); } =20 -static int board_processor_id(uint32_t board_rev) +static RaspiProcessorId board_processor_id(uint32_t board_rev) { + int proc_id =3D FIELD_EX32(board_rev, REV_CODE, PROCESSOR);; + assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ - return FIELD_EX32(board_rev, REV_CODE, PROCESSOR); + assert(proc_id < ARRAY_SIZE(soc_property) && soc_property[proc_id].typ= e); + + return proc_id; } =20 static int board_version(uint32_t board_rev) @@ -88,32 +105,12 @@ static int board_version(uint32_t board_rev) =20 static const char *board_soc_type(uint32_t board_rev) { - static const char *soc_types[] =3D { - NULL, TYPE_BCM2836, TYPE_BCM2837, - }; - int proc_id =3D board_processor_id(board_rev); - - if (proc_id >=3D ARRAY_SIZE(soc_types) || !soc_types[proc_id]) { - error_report("Unsupported processor id '%d' (board revision: 0x%x)= ", - proc_id, board_rev); - exit(1); - } - return soc_types[proc_id]; + return soc_property[board_processor_id(board_rev)].type; } =20 static int cores_count(uint32_t board_rev) { - static const int soc_cores_count[] =3D { - 0, BCM283X_NCPUS, BCM283X_NCPUS, - }; - int proc_id =3D board_processor_id(board_rev); - - if (proc_id >=3D ARRAY_SIZE(soc_cores_count) || !soc_cores_count[proc_= id]) { - error_report("Unsupported processor id '%d' (board revision: 0x%x)= ", - proc_id, board_rev); - exit(1); - } - return soc_cores_count[proc_id]; + return soc_property[board_processor_id(board_rev)].cores_count; } =20 static const char *board_type(uint32_t board_rev) --=20 2.21.1