From nobody Thu Nov 13 18:05:17 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581794328242461.7423695771563; Sat, 15 Feb 2020 11:18:48 -0800 (PST) Received: from localhost ([::1]:53784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j32xi-0005Sv-TS for importer@patchew.org; Sat, 15 Feb 2020 14:18:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35248) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j32uv-0008GO-7H for qemu-devel@nongnu.org; Sat, 15 Feb 2020 14:15:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j32uu-0004Fd-2c for qemu-devel@nongnu.org; Sat, 15 Feb 2020 14:15:53 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:36508) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j32ut-0004FF-Su; Sat, 15 Feb 2020 14:15:52 -0500 Received: by mail-wm1-x342.google.com with SMTP id p17so14360082wma.1; Sat, 15 Feb 2020 11:15:51 -0800 (PST) Received: from localhost.localdomain (78.red-88-21-202.staticip.rima-tde.net. [88.21.202.78]) by smtp.gmail.com with ESMTPSA id o9sm9678605wrw.20.2020.02.15.11.15.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:15:50 -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=Vhel9ZGZgtP73tJjm81o+z0be/SYJCK2j79JJpUSkis=; b=WMZP+TjzLsFQppWB0y16uK/sT7iEKqlOh4hBh9gqphfZhuPEOs4nWIMt2++ephmSLa 1phZZlTV77uwZr4iVu0tXA4G+lYpVK3g5PJppU2HB74ordwrXZegyQXhuuKH+lz2aPQt Y0Wh9m72c01Mb+cG5XXO3ZzpJc32zbBozexrnD7f2UrB6UTmmt+g0AmgNBradd8vRcg0 7nG23W9Yco7eAlFdxzIvZp3t3YnXEkme3ztPou4gtM+/V+l8YKfYdhmYhy6+6LXzYZiF mzdtaQGnRJuDWG37Y3mysffUxtJB8Sf34mwHv4PGN2AUdHzbH2k18lv9iGIRXSYM8lfF CrxA== 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=Vhel9ZGZgtP73tJjm81o+z0be/SYJCK2j79JJpUSkis=; b=Dp80jNCtYasPlWlRVgNyIw3PKYgMdpdJdGW64h7mjpAy3xqKcoBi7uvcDObWuGnoF5 lcAN3TXwRNvgyHW8QVlKcIJAiAHSROtVsk+silOAER9LAG7O9lXu2dtV3XvW6IcD4l93 ML4Yq9P4dfp6Ug1BDxvRo6uj+7MXppp4FVVz6pLvu6XcnoxGUS+szpb1hXs+ZUrIbvlM EXMaMvlKx9b94MlvxwE2Z5W0hXHQmYe32aBGrRqxuZn1oUR9gL2rBjsuu+l97iMlsyBG eAuvU+08YulVBrmlmqSRDLoBYJ3mShnR9VMzk0g2nJu3wN/5eJs6xM+oo4vh9s16ziQi 2bhQ== X-Gm-Message-State: APjAAAVZAcAI/ly2ftbQvnNq4+4AKYDYH4ZsJB7G/WX2HdjZ9MWXjR8k i7w3N1McXoPPvVVVMkZ4axpTfWnQx5w= X-Google-Smtp-Source: APXvYqwoWH3WYhhhb1yRPA9ZB6GBBY8qWvuucLTn1BTY2Ihk/noIZrEN+00wV35h/uPudmFc/+UkRw== X-Received: by 2002:a1c:cc11:: with SMTP id h17mr11655881wmb.19.1581794150639; Sat, 15 Feb 2020 11:15:50 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 03/12] hw/arm/raspi: Introduce RaspiProcessorId enum Date: Sat, 15 Feb 2020 20:15:34 +0100 Message-Id: <20200215191543.3235-4-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200215191543.3235-1-f4bug@amsat.org> References: <20200215191543.3235-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::342 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, Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 --- 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 81cc5824c4..aa0a7e6276 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