From nobody Tue Feb 10 04:16:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) client-ip=209.85.128.65; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f65.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1600946299; cv=none; d=zohomail.com; s=zohoarc; b=jbn1F+IZOTN3jiNbkLD0HkOenx4+xMqAJZQTf2O01/2j1kOBPdgQyaONy0lvj7u3tVC8m8ANqMTyKQjO3FwoK81ZqC5KcGr89E46Dg15KIIqgOnWNtrld/zsJcytdsG33KyUZHHPNmWMAnT6tGgMMhBcRE5yK2vsC9KCvN8G6eM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600946299; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PocNKqZn4p1bTkwGmp+nEPuAjYmk0VY+dPd4muqyYJI=; b=TtNXJNLzDvD/1CLFmqYX8E0bTaX4krnkCyZsA3Q5A9C/Gr7l3NoFb9nFbtcZc4xDjZlpHEZgjllsFT0YJycytyEOSCPBtetkb59u9Lwftp6MfDzjIhIb86nwiox75jk4G3sy4Z4IOwFjEpqMO8qajVX/4eGk27ggeQgvtOz7/fM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.65 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by mx.zohomail.com with SMTPS id 1600946299710665.2988334358247; Thu, 24 Sep 2020 04:18:19 -0700 (PDT) Received: by mail-wm1-f65.google.com with SMTP id y15so3201169wmi.0 for ; Thu, 24 Sep 2020 04:18:19 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (234.red-88-10-103.dynamicip.rima-tde.net. [88.10.103.234]) by smtp.gmail.com with ESMTPSA id h76sm3400363wme.10.2020.09.24.04.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 04:18:17 -0700 (PDT) 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=PocNKqZn4p1bTkwGmp+nEPuAjYmk0VY+dPd4muqyYJI=; b=ShotNMr6DAnlxQtldQDuMt5c4YW74YxTLbKH1//mF+LUqs6vJxHj0RjtrplEGcL19j sRAxHfiFeQrRPVCWuEb1IGrMWuvv/g/yCamgsv/zbp3ginzFAcVZ5F9SkUnTcp5Biu6y yiDEYrwVsp8IABGxBROqCBwN3MnptKgxyZ5SThaBE7FQ8s8fMy6d3TaQh/kyUNNlQILj BAdfyG92NXa2WKrdbmUNaugWUh0ZqrnhyMHLtvGDaqo//lcMpCdbDrf6V9MtQJ4oLYJd upgLlI7gBQmjvPvrUHHxR9GnJed0r/jnJGGuTc9EKaDMqOfgETjRpgt7qVguClf+N2LH y5Og== 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=PocNKqZn4p1bTkwGmp+nEPuAjYmk0VY+dPd4muqyYJI=; b=H+eKVQJ0O9F+2ZG0oZIdKCDSpVdTRhFFW21a7PIchvHeMItENRyvWEsIDEVHzjzTGh dKp9PdkPen/uOEGUhGYpkgQYP+AlMHOTY7sH43/fDOesTj0VZXoUkmEAtYh65qoTtlpT rMzYOYB53pnwyhbdtM4+2iYxPyYbQ7KhR8nuLjLzYXwMuIQS7xVRush8oRacTT4A/SbZ ZXckybQFwzeSXhrzNskTChTQjkho6SWnP3q7I/CVLHSZ9wQ5UEtYB25FlXQCfoZIGEZp 2aL8jbshmC8A2/TxghMAdrAJgDHmM7kAL3HcMQ0+DPt0BX2YTMV316RVAWtfmRe3ZlEM SNRQ== X-Gm-Message-State: AOAM533QD+n4EvS59EAX7Db4xnKCq/PDalgMHosR2oCPWZfAvDBkpISp LS09Cm9kG9uduQK5vCams7A= X-Google-Smtp-Source: ABdhPJwiIBjKw1WHonGQh/aBe4NDBJJ6f1zBukZR8FP06cuTY1aGAS11ckgQxAAmXZ7ptqAUsSQwGA== X-Received: by 2002:a1c:8f:: with SMTP id 137mr4232847wma.158.1600946297860; Thu, 24 Sep 2020 04:18:17 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Andrew Baumann , Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v4 6/8] hw/arm/raspi: Introduce RaspiProcessorId enum Date: Thu, 24 Sep 2020 13:18:06 +0200 Message-Id: <20200924111808.77168-7-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924111808.77168-1-f4bug@amsat.org> References: <20200924111808.77168-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-ZohoMail-DKIM: pass (identity @gmail.com) 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. Reviewed-by: Luc Michel 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 3426521379e..0d8e5a34c78 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.26.2