From nobody Tue Nov 26 13:50:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707226343; cv=none; d=zohomail.com; s=zohoarc; b=oG+HMW46t/CKYi5H7NNzS9fJfX0LwYZlEIjGaiMms2GMcZAsIAiFht1F0saU01PwPzAjrzxPBfTAf2Ug7sw3so74hjaKtWOVe0uYQI/cOD0PAWCUzVvcONX4O3gLZG4mF/nRBIFBBeRypjbEcpT4x5kozED5jzcClfaa8tNUfNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707226343; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=oZgFljSXzG1VImEUFoQLz/HGzGAKeDy/fNBogZHhH70=; b=gM14YURwGCs5XSjV+dotM8WdngAlmWQYvqF5pAvkdsENRaNhOp9cYeRNFFcihD+Kz7XXxvGx4x1NrbDIPMQ8okaP6vcBanifJvNAwIB+Cydd+lwg/88HZgJna7YIdWWD0NBS2VlFGMJi4pMCJmPRitWG2f4oaIMQoAeuHOptwqw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707226343222929.5874222402026; Tue, 6 Feb 2024 05:32:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXLWC-0000cy-5k; Tue, 06 Feb 2024 08:29:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXLW6-0000OC-6V for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:38 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXLW3-0008Cw-6e for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:37 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-339289fead2so641597f8f.3 for ; Tue, 06 Feb 2024 05:29:34 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a056000108700b0033b470a137esm1492932wrw.79.2024.02.06.05.29.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:29:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707226173; x=1707830973; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=oZgFljSXzG1VImEUFoQLz/HGzGAKeDy/fNBogZHhH70=; b=cHxc/Z5CNx1DXq/tkCS5TxQEmms/y+jU2GhwqQasfEo7ee2KRjGsEK1NRro8E4T5Bb 5R65QjzqwjQdHbHL314TVQzYY8SYOHmW4a1AAUyLRgzYbDLMlojx+y7PZR45LqaRVlNR j5EMDBY9hewtoCF5CvXwW29LeUDCeBkjLy7RaHVuoL2OEt8LkcMAxnOf7oZ+Jf9hVE9u xxpWgFJh96Y2XcNhisce2xunLoqQrfHRqwShIRNVTz5hJa3DPVO1BKahPDbUT4KRt2ZD 5Qq6SY3Q2Pn/hDAlLrqVX84AqbWr6F6TaZkYIvMWj2b+GjH0N5oVN694KS/euT3ZuWA0 pPDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226173; x=1707830973; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oZgFljSXzG1VImEUFoQLz/HGzGAKeDy/fNBogZHhH70=; b=NLv6otSkgnl1/Idc8RhJneI79V7u5LZ9+5ypR05YZiGI8CblhAu9Xv4dAGA/8YKO7/ Y8mlJaqDTXap00qqP2w9F7/mlzOzqYD45JVdUGm3sNm9RLvIMOmnDH1hFVZDeTzEof0G lyzK3xnehFFre1zBjMFR9z2LsoHOonoKH3hXFepgTP/DjiWH5G17NmtSU4UeJKiiSaSZ UClwS9XQIOTxQPPN/sZkg1C3++dKBGl5KgfDet6/YAkTsralHEJbxeY3LOIFkI6qwXdh 37M8fyLYepSvD2aDfaEK2ONBekwFBO/NUzMFFw1w+AEHUcCyFBhNq9DCSfNDmMLV/v+4 xdqQ== X-Gm-Message-State: AOJu0YyDh1cyBFYhzsaeCzZiPiZG/UcpVjOkQtZK3UQI9gvsgQS0gOOm bilRgh0FcCu9RqFml/i1pW2rlaMJztPjADU6OXrWw+CLgwzd1mOXkVXj9ke6U+0= X-Google-Smtp-Source: AGHT+IG8kT0OopRP0FnBlh/k9L5AhZYrWcb4hSHKS05yr9FPmB/ZOLOEC8aegLBqSQ0N9SxEmL+ddA== X-Received: by 2002:a5d:6da2:0:b0:33b:48ee:8a35 with SMTP id u2-20020a5d6da2000000b0033b48ee8a35mr1339202wrs.3.1707226173085; Tue, 06 Feb 2024 05:29:33 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVt6wfrgPuWJrtV4jgVhPouQACGhuayC/NBZIDHzOCnrNGvpeCBLXr1DqETfCpbUXX36HzIZGxN2DqubvEZQ5Dg8SPD+bQ= From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 01/13] target/arm: Use new CBAR encoding for all v8 CPUs, not all aarch64 CPUs Date: Tue, 6 Feb 2024 13:29:19 +0000 Message-Id: <20240206132931.38376-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206132931.38376-1-peter.maydell@linaro.org> References: <20240206132931.38376-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707226345279100003 Content-Type: text/plain; charset="utf-8" We support two different encodings for the AArch32 IMPDEF CBAR register -- older cores like the Cortex A9, A7, A15 have this at 4, c15, c0, 0; newer cores like the Cortex A35, A53, A57 and A72 have it at 1 c15 c0 0. When we implemented this we picked which encoding to use based on whether the CPU set ARM_FEATURE_AARCH64. However this isn't right for three cases: * the qemu-system-arm 'max' CPU, which is supposed to be a variant on a Cortex-A57; it ought to use the same encoding the A57 does and which the AArch64 'max' exposes to AArch32 guest code * the Cortex-R52, which is AArch32-only but has the CBAR at the newer encoding (and where we incorrectly are not yet setting ARM_FEATURE_CBAR_RO anyway) * any possible future support for other v8 AArch32 only CPUs, or for supporting "boot the CPU into AArch32 mode" on our existing cores like the A57 etc Make the decision of the encoding be based on whether the CPU implements the ARM_FEATURE_V8 flag instead. This changes the behaviour only for the qemu-system-arm '-cpu max'. We don't expect anybody to be relying on the old behaviour because: * it's not what the real hardware Cortex-A57 does (and that's what our ID register claims we are) * we don't implement the memory-mapped GICv3 support which is the only thing that exists at the peripheral base address pointed to by the register Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 945d8571a61..2a2659aade2 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9519,7 +9519,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) * AArch64 cores we might need to add a specific feature flag * to indicate cores with "flavour 2" CBAR. */ - if (arm_feature(env, ARM_FEATURE_AARCH64)) { + if (arm_feature(env, ARM_FEATURE_V8)) { /* 32 bit view is [31:18] 0...0 [43:32]. */ uint32_t cbar32 =3D (extract64(cpu->reset_cbar, 18, 14) << 18) | extract64(cpu->reset_cbar, 32, 12); --=20 2.34.1 From nobody Tue Nov 26 13:50:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707226274; cv=none; d=zohomail.com; s=zohoarc; b=HeiVmEr9RYdb7kb0eUbulLT27TUsIRxczBeI6B874c9y3GJ4C6YfZYHHGs8IAfWw5fnFmP0rqvQ2Q6xUCwLv3BnQeEaQkEse2qKL01yO3s4YcthfIER/NoQL82tQgcM2xzlEYHn5uYSy8E3tm1tuLUuYT7YxGmjkM17qbOtzu8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707226274; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=xyto0qdSuakUvujUrl1EewzD93xhnNFTVZXku884bPo=; b=DtDH+qCSaOvdizoTuxhWmgluJHL8lYEAuK8gzwN6nTNxPYHpKcxiOVbt/jeK+RhyiwfioPtvScGC4Zxv/Q4yFv5h8gGXG9WPmf0ptDFKJ7V++zFbieYvMk6OQ1+iZg07PqQtUMADku95UOC/3LtfSZ4OQubPYaOhV4iDsqQwAEc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707226274345955.1770307817607; Tue, 6 Feb 2024 05:31:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXLWF-0000lc-0n; Tue, 06 Feb 2024 08:29:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXLW7-0000Ox-II for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:39 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXLW4-0008DU-DS for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:39 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3394ca0c874so3949428f8f.2 for ; Tue, 06 Feb 2024 05:29:35 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a056000108700b0033b470a137esm1492932wrw.79.2024.02.06.05.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:29:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707226173; x=1707830973; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xyto0qdSuakUvujUrl1EewzD93xhnNFTVZXku884bPo=; b=yQEuNbV9M2kDgteppxDS3TogvFmU99dlPAK1lUg9MOjNUWmmPhADqCrnvC2IXNtuBf OFrYbQYUEhxQe44GIeEwXs6EDgxYUvjT0hXuVmccA10dZNziqLiVj/KZ95B8461PCrQJ 6PAI9kCFUo+AJj8zW05Y/vXOd+bYWvtn+aqfJKaIeYmkhwmKa4ax2AzvrlL6tINa450Y buJuMT6D26REGvyFa4iMplxnyop93FZ1lwCOGWSLqWcncSlj9QRQd1MgrxrvoR0y8oNG fEaffQc0G8HXSF3a4mIW8rtuXlyIFB3txT3J0ywM6OPmoa+H7y/VFRKsks/PmRG3OKQe E1Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226173; x=1707830973; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xyto0qdSuakUvujUrl1EewzD93xhnNFTVZXku884bPo=; b=YqdnJPf4fs4Iv0MsM0mLanf6LROL6DgsD5pRJx+q+lih98lLwM01srpuMlh3AeXakI pVbDKB6NWMnI1VvazhIyoxLDwUWtyA7+p3ZuGi5qplD6ali0pGOp3ifCJ4dbSF6UKSPM 5m5stYARixVlkAZV9247au1crTGQu5Svz7FeI4cE8ZjExo3o3dJid+F9JV2tQDcu537N R0ig13C8zatNP80iCB2HJfXrAdE2T9U0pPXv+f1L2x3Ri5xFg/4yL+DUrCosHt1M9Rrk Z8YKvi9tpJj+na0SyPxy9hZVxriVO1mcep/FigcxndMVP0ipef4ugcAKEInFOonxkS5u M0wA== X-Gm-Message-State: AOJu0YzB9lmyCb9KGBqI0AnNe7IE+oNdrT1C7LN18zoWIe+7rd6HCwIi PheXmYzuhUsCYKxw2oixCp/NMN9pNY8yywkSvsC9pddaBsSrYZo7qEq5Je8NGFcHQ36RcYqgvST 4 X-Google-Smtp-Source: AGHT+IF2nime84bexsJ9Epx/LDzynylJDTRvAUqysWEQ85rzmefckrrVvJ0/FqclOYrdLVSKCrn6ew== X-Received: by 2002:adf:ce0c:0:b0:33b:312:e11b with SMTP id p12-20020adfce0c000000b0033b0312e11bmr1218815wrn.38.1707226173523; Tue, 06 Feb 2024 05:29:33 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUEIlGuibX0oEJFSwre5Y4D0Lo8vb16efeRH4uR4uwbYCKpCNJT5mDDAdBRLjv9VBIvgsw7ShJZh+FKvWPrBWV2o18KuME= From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 02/13] target/arm: The Cortex-R52 has a read-only CBAR Date: Tue, 6 Feb 2024 13:29:20 +0000 Message-Id: <20240206132931.38376-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206132931.38376-1-peter.maydell@linaro.org> References: <20240206132931.38376-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707226275134100001 Content-Type: text/plain; charset="utf-8" The Cortex-R52 implements the Configuration Base Address Register (CBAR), as a read-only register. Add ARM_FEATURE_CBAR_RO to this CPU type, so that our implementation provides the register and the associated qdev property. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/cpu32.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c index 11253051156..311d654cdce 100644 --- a/target/arm/tcg/cpu32.c +++ b/target/arm/tcg/cpu32.c @@ -809,6 +809,7 @@ static void cortex_r52_initfn(Object *obj) set_feature(&cpu->env, ARM_FEATURE_PMSA); set_feature(&cpu->env, ARM_FEATURE_NEON); set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); cpu->midr =3D 0x411fd133; /* r1p3 */ cpu->revidr =3D 0x00000000; cpu->reset_fpsid =3D 0x41034023; --=20 2.34.1 From nobody Tue Nov 26 13:50:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707226254; cv=none; d=zohomail.com; s=zohoarc; b=cmsOLtQj9fN7TOPbvyEAghj9JXkwzurl3ieF1ywLowm3eHIJq/1utaxZd3vYlIbqYk/8mOKsfNe3+dDFBQwHaGEx9gFcPfHI6FJeNJ4+7Fw63y3o6UPDOZSUpaVyTVdUYt8DdE8U2VTcjpEOlhhjYd3R+8YDtPPSKJQdk/OhRgo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707226254; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=h7YaNX76JwqZEJT0rHKxb3cowkocOAyFr6+DgbOiGaE=; b=GISj9pNJBq7jZeJXAd8eDrGJry7pwHrzaQ5bLH92u6+OU/Wa+fwrcBOFDJAEwKxc6W6NZLfWqRs9Sdc06iZDOKIIrfAQElWSVoMAMCCCtBbTnzwGVYoE4NTnJPpPJdZ9QHwjvtdObuBjwxSFhxy26cpRCaytBt1UiphCPbIFNxs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707226254725463.83597268858114; Tue, 6 Feb 2024 05:30:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXLWC-0000eY-Vy; Tue, 06 Feb 2024 08:29:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXLW7-0000PF-Qt for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:39 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXLW4-0008Di-F0 for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:39 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-33b4b121e28so25467f8f.1 for ; Tue, 06 Feb 2024 05:29:35 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a056000108700b0033b470a137esm1492932wrw.79.2024.02.06.05.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:29:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707226174; x=1707830974; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=h7YaNX76JwqZEJT0rHKxb3cowkocOAyFr6+DgbOiGaE=; b=VRAiac+QPyabZ6xxWZZoUs3NPPwiZkIzarYqWlx6s4yOMojHN+Eu29em/60mmub/DJ zn2j2SM4E9LbLy189ysGlihKb4afCpgV1tsx/lcuy09Bc9GnSKdwfrFikBE6vZjPAZPx +rTGs9mwFYzKjHQhVHicnbh3dWfNEwLETlfLW4/mxtDYFsuOpH1qu9KJMgESyMmglKuB otaYcUpSawbJq2180wHTgqJORsIol9rzUUUfM7uVT4pVhf2Sq5MdRtd7Oe4CpKG8PxEr C62nKQP0fv/9SUmMVQbDrPcEypQiTPGVaS1CxC7uX3ShBQwiqgP1RuqxauLyj7yqx3Vy or/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226174; x=1707830974; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h7YaNX76JwqZEJT0rHKxb3cowkocOAyFr6+DgbOiGaE=; b=VgG7JCM0kUpU2409xOofzqDU8rCO2FnD8vA3WaQLios/h9Z/WoDh/Hiy4lp6VU/Xa1 rAmu8NeUg4b2Em46ECU5RwjNb9YE51c02lVmT7ocJxXAXfUr+qQ/hbykP+Xqr96jG2sC QylBopA/L0c6UuR+a2RD72B0FKRLaYERjMRzr5dw88iOdr++pnbAllDK09veZdVZpYwJ vuaRLRyToxAGQhvweNEITXGLDtem/e17ZBEGi3FRdxHUl/qRn7vnbAntfhYhEjxBWOEa HpZmjoyezkesIrjYsjMc9HS4/Z/4ne/Rr1K3ezmxjQz95CLGJC9ls7KButACPoUy6+px DvKw== X-Gm-Message-State: AOJu0YzeFXnqttssyirKxm6ZvP3hP7FvskeO4czzIRBeOVKAT60bHrcS TihghJJUdsS+yPftpulOA+j6VWfZgcdtCBxTyaqS1hwFNucycoSlEirgdWivbnU= X-Google-Smtp-Source: AGHT+IHobB3hvfz2GrLp2gza7bUNw8EVpcsVCuiE7ZdgxPwSjoBlnjPaA964QgtrhrKlH5HskbuLXw== X-Received: by 2002:a5d:6682:0:b0:33a:eec4:c0c6 with SMTP id l2-20020a5d6682000000b0033aeec4c0c6mr1251743wru.12.1707226173986; Tue, 06 Feb 2024 05:29:33 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCU1s9rGIXOur/AiDMftwLUWKqfXHFK+gVeCGoeqCaVAy60DXB5ga24x9kX2ATYiBBTeQQ1hZeEMH/J+dtY5P+cDS7KIdCU= From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 03/13] target/arm: Add Cortex-R52 IMPDEF sysregs Date: Tue, 6 Feb 2024 13:29:21 +0000 Message-Id: <20240206132931.38376-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206132931.38376-1-peter.maydell@linaro.org> References: <20240206132931.38376-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707226256867100003 Content-Type: text/plain; charset="utf-8" Add the Cortex-R52 IMPDEF sysregs, by defining them here and also by enabling the AUXCR feature which defines the ACTLR and HACTLR registers. As is our usual practice, we make these simple reads-as-zero stubs for now. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/cpu32.c | 108 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c index 311d654cdce..6eb08a41b01 100644 --- a/target/arm/tcg/cpu32.c +++ b/target/arm/tcg/cpu32.c @@ -800,6 +800,111 @@ static void cortex_r5_initfn(Object *obj) define_arm_cp_regs(cpu, cortexr5_cp_reginfo); } =20 +static const ARMCPRegInfo cortex_r52_cp_reginfo[] =3D { + { .name =3D "CPUACTLR", .cp =3D 15, .opc1 =3D 0, .crm =3D 15, + .access =3D PL1_RW, .type =3D ARM_CP_CONST | ARM_CP_64BIT, .resetval= ue =3D 0 }, + { .name =3D "IMP_ATCMREGIONR", + .cp =3D 15, .opc1 =3D 0, .crn =3D 9, .crm =3D 1, .opc2 =3D 0, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_BTCMREGIONR", + .cp =3D 15, .opc1 =3D 0, .crn =3D 9, .crm =3D 1, .opc2 =3D 1, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_CTCMREGIONR", + .cp =3D 15, .opc1 =3D 0, .crn =3D 9, .crm =3D 1, .opc2 =3D 2, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_CSCTLR", + .cp =3D 15, .opc1 =3D 1, .crn =3D 9, .crm =3D 1, .opc2 =3D 0, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_BPCTLR", + .cp =3D 15, .opc1 =3D 1, .crn =3D 9, .crm =3D 1, .opc2 =3D 1, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_MEMPROTCLR", + .cp =3D 15, .opc1 =3D 1, .crn =3D 9, .crm =3D 1, .opc2 =3D 2, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_SLAVEPCTLR", + .cp =3D 15, .opc1 =3D 0, .crn =3D 11, .crm =3D 0, .opc2 =3D 0, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_PERIPHREGIONR", + .cp =3D 15, .opc1 =3D 0, .crn =3D 15, .crm =3D 0, .opc2 =3D 0, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_FLASHIFREGIONR", + .cp =3D 15, .opc1 =3D 0, .crn =3D 15, .crm =3D 0, .opc2 =3D 1, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_BUILDOPTR", + .cp =3D 15, .opc1 =3D 0, .crn =3D 15, .crm =3D 2, .opc2 =3D 0, + .access =3D PL1_R, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_PINOPTR", + .cp =3D 15, .opc1 =3D 0, .crn =3D 15, .crm =3D 2, .opc2 =3D 7, + .access =3D PL1_R, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_QOSR", + .cp =3D 15, .opc1 =3D 1, .crn =3D 15, .crm =3D 3, .opc2 =3D 1, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_BUSTIMEOUTR", + .cp =3D 15, .opc1 =3D 1, .crn =3D 15, .crm =3D 3, .opc2 =3D 2, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_INTMONR", + .cp =3D 15, .opc1 =3D 1, .crn =3D 15, .crm =3D 3, .opc2 =3D 4, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_ICERR0", + .cp =3D 15, .opc1 =3D 2, .crn =3D 15, .crm =3D 0, .opc2 =3D 0, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_ICERR1", + .cp =3D 15, .opc1 =3D 2, .crn =3D 15, .crm =3D 0, .opc2 =3D 1, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_DCERR0", + .cp =3D 15, .opc1 =3D 2, .crn =3D 15, .crm =3D 1, .opc2 =3D 0, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_DCERR1", + .cp =3D 15, .opc1 =3D 2, .crn =3D 15, .crm =3D 1, .opc2 =3D 1, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_TCMERR0", + .cp =3D 15, .opc1 =3D 2, .crn =3D 15, .crm =3D 2, .opc2 =3D 0, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_TCMERR1", + .cp =3D 15, .opc1 =3D 2, .crn =3D 15, .crm =3D 2, .opc2 =3D 1, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_TCMSYNDR0", + .cp =3D 15, .opc1 =3D 2, .crn =3D 15, .crm =3D 2, .opc2 =3D 2, + .access =3D PL1_R, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_TCMSYNDR1", + .cp =3D 15, .opc1 =3D 2, .crn =3D 15, .crm =3D 2, .opc2 =3D 3, + .access =3D PL1_R, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_FLASHERR0", + .cp =3D 15, .opc1 =3D 2, .crn =3D 15, .crm =3D 3, .opc2 =3D 0, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_FLASHERR1", + .cp =3D 15, .opc1 =3D 2, .crn =3D 15, .crm =3D 3, .opc2 =3D 1, + .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_CDBGDR0", + .cp =3D 15, .opc1 =3D 3, .crn =3D 15, .crm =3D 0, .opc2 =3D 0, + .access =3D PL1_R, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_CBDGBR1", + .cp =3D 15, .opc1 =3D 3, .crn =3D 15, .crm =3D 0, .opc2 =3D 1, + .access =3D PL1_R, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_TESTR0", + .cp =3D 15, .opc1 =3D 4, .crn =3D 15, .crm =3D 0, .opc2 =3D 0, + .access =3D PL1_R, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, + { .name =3D "IMP_TESTR1", + .cp =3D 15, .opc1 =3D 4, .crn =3D 15, .crm =3D 0, .opc2 =3D 1, + .access =3D PL1_W, .type =3D ARM_CP_NOP, .resetvalue =3D 0 }, + { .name =3D "IMP_CDBGDCI", + .cp =3D 15, .opc1 =3D 0, .crn =3D 15, .crm =3D 15, .opc2 =3D 0, + .access =3D PL1_W, .type =3D ARM_CP_NOP, .resetvalue =3D 0 }, + { .name =3D "IMP_CDBGDCT", + .cp =3D 15, .opc1 =3D 3, .crn =3D 15, .crm =3D 2, .opc2 =3D 0, + .access =3D PL1_W, .type =3D ARM_CP_NOP, .resetvalue =3D 0 }, + { .name =3D "IMP_CDBGICT", + .cp =3D 15, .opc1 =3D 3, .crn =3D 15, .crm =3D 2, .opc2 =3D 1, + .access =3D PL1_W, .type =3D ARM_CP_NOP, .resetvalue =3D 0 }, + { .name =3D "IMP_CDBGDCD", + .cp =3D 15, .opc1 =3D 3, .crn =3D 15, .crm =3D 4, .opc2 =3D 0, + .access =3D PL1_W, .type =3D ARM_CP_NOP, .resetvalue =3D 0 }, + { .name =3D "IMP_CDBGICD", + .cp =3D 15, .opc1 =3D 3, .crn =3D 15, .crm =3D 4, .opc2 =3D 1, + .access =3D PL1_W, .type =3D ARM_CP_NOP, .resetvalue =3D 0 }, +}; + + static void cortex_r52_initfn(Object *obj) { ARMCPU *cpu =3D ARM_CPU(obj); @@ -810,6 +915,7 @@ static void cortex_r52_initfn(Object *obj) set_feature(&cpu->env, ARM_FEATURE_NEON); set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); + set_feature(&cpu->env, ARM_FEATURE_AUXCR); cpu->midr =3D 0x411fd133; /* r1p3 */ cpu->revidr =3D 0x00000000; cpu->reset_fpsid =3D 0x41034023; @@ -840,6 +946,8 @@ static void cortex_r52_initfn(Object *obj) =20 cpu->pmsav7_dregion =3D 16; cpu->pmsav8r_hdregion =3D 16; + + define_arm_cp_regs(cpu, cortex_r52_cp_reginfo); } =20 static void cortex_r5f_initfn(Object *obj) --=20 2.34.1 From nobody Tue Nov 26 13:50:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707226205; cv=none; d=zohomail.com; s=zohoarc; b=eKPD1ZSXpWLCIs1HUNp+Nj0GVHMMCZrga/ri1BdGBLeeaDuEKI5DFLianM1cnmL9djo7F3JvHBPIA04bSZJms4E/QnufEi4mS+9zxpQ1US7KJtQRtWL/IhzzbMR4dOSGB+yxxtS7sEdO1jKlZpK5Q03kvhi+vTGLfRFWOG+86l8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707226205; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=tJkH1WKc0d+Tj/MyZyA5jaOYWrI3hG22yiWDaBwTxjc=; b=UT+VLQmfYZRNhZ6TFhLiTpwDrtCKKOW1VYcNdt7EASy/zq2l6GyTFWtgilpUqCXwFpPPSFMbDrf+/g6X4V5SLpAjKGy4wuKC6a2UTuhPVlfnsXTCrwgVNBgkPWhuBadGjj7v+6gZYxM62DfI9UtxMJfjo71dcTioEr3KrP4ezCE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707226205017491.6613630362049; Tue, 6 Feb 2024 05:30:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXLWB-0000Xy-Iu; Tue, 06 Feb 2024 08:29:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXLW9-0000Ra-Aa for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:41 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXLW4-0008Du-ID for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:40 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-33b2960ff60so366344f8f.1 for ; Tue, 06 Feb 2024 05:29:35 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a056000108700b0033b470a137esm1492932wrw.79.2024.02.06.05.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:29:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707226174; x=1707830974; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=tJkH1WKc0d+Tj/MyZyA5jaOYWrI3hG22yiWDaBwTxjc=; b=dfdS0QVMhgK0QmhVQr2+v2NnOFWAnWLYlQ26y13jCikV8tGnMkqgEppdgoYAke+nlj f37PCRAtXck/CW4KCz2EEjR/XAraZqgH3SOAo0ZG2klaasLIAg5LSCHUVJ94tRStCJT5 xQ++b4w7nNy4SyvUtDIkfXkAVeD871U7RZAtt2SQBASnrEW6T9ZlojKXQKswFbV1vfiE hcnU9Q263hc00V4358lB5Jek2SXKQ23jHCJY2tZbrBvrMvry2fsFGvuipRgDQbEtGsDG O74bj2SB6DJbIQX1/9w64luffhFnczOf4w0JAH23mhDeLH6ujfC0+nvQmJZAK69PaFfG 2Q2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226174; x=1707830974; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tJkH1WKc0d+Tj/MyZyA5jaOYWrI3hG22yiWDaBwTxjc=; b=EYTf53CfsQl1sMcapnfFJt3LPg1VGD84pXsGPMtHD6J+n/4jyOfVf1101PQgKr6ggB 5O/ShNcuCOYvUIjX+qbmXgsz5mZ8XykPEoJJs3XKjshDTPru5PcWYuFFnWjfJmpn0CO5 50u68T160H/73vzex3Tztip2F2XOpmKUHPpuGOKsE3WFJRcYVYFEV199jfu2HOpzwlYj SJScwB2IXMuhW1Rjn/qm6WNtfaGx+56fkXwCrXWvqsUSmUEReKlxupBcQ5IdHz3M+j+0 cXY4C/uGl1ns6cq4ouOuRXH8qydMsFyAnrxjuxM/n6+NvJsh1PFIrbpfbH74a8XX1y45 oWlQ== X-Gm-Message-State: AOJu0YzkFLbTt+7HxnB7WvlZtpJ/dvZAdYxnGC/JIw9nw9v5+nwH5K9G yv9xB6Jh+tqz7rZaS5sqzdyiKXBztpTZQDstqtNM5RakJh69Ip1dRm75FEiJ9YE= X-Google-Smtp-Source: AGHT+IHg6/FjIVNMcqM8p6YoGaSzOLiKxDOLAAqWjuB4h3lzIa3fvefg0pWc9LHuT0Hifn9dUM4k7w== X-Received: by 2002:a05:6000:10cd:b0:33b:304a:cf90 with SMTP id b13-20020a05600010cd00b0033b304acf90mr1419851wrx.2.1707226174460; Tue, 06 Feb 2024 05:29:34 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUDRJzIWc4Z6aMSmuLC+QdTahm9ynbYjPLaa07GAQ6KxecmjT4Z5RycpfFoeM8zGEV6PVV4O+GK7u0c+CLxA3Q+URtpZJ0= From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 04/13] target/arm: Allow access to SPSR_hyp from hyp mode Date: Tue, 6 Feb 2024 13:29:22 +0000 Message-Id: <20240206132931.38376-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206132931.38376-1-peter.maydell@linaro.org> References: <20240206132931.38376-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707226206565100003 Content-Type: text/plain; charset="utf-8" Architecturally, the AArch32 MSR/MRS to/from banked register instructions are UNPREDICTABLE for attempts to access a banked register that the guest could access in a more direct way (e.g. using this insn to access r8_fiq when already in FIQ mode). QEMU has chosen to UNDEF on all of these. However, for the case of accessing SPSR_hyp from hyp mode, it turns out that real hardware permits this, with the same effect as if the guest had directly written to SPSR. Further, there is some guest code out there that assumes it can do this, because it happens to work on hardware: an example Cortex-R52 startup code fragment uses this, and it got copied into various other places, including Zephyr. Zephyr was fixed to not use this: https://github.com/zephyrproject-rtos/zephyr/issues/47330 but other examples are still out there, like the selftest binary for the MPS3-AN536. For convenience of being able to run guest code, permit this UNPREDICTABLE access instead of UNDEFing it. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- Last time this came up I preferred the "keep QEMU behaviour as it is, try to get the guest code fixed" approach: https://www.mail-archive.com/qemu-devel@nongnu.org/msg899970.html but as this is the second time I lean a bit more towards behaving like the hardware. --- target/arm/tcg/op_helper.c | 43 ++++++++++++++++++++++++++------------ target/arm/tcg/translate.c | 19 +++++++++++------ 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c index b5ac26061c7..c199b69fbff 100644 --- a/target/arm/tcg/op_helper.c +++ b/target/arm/tcg/op_helper.c @@ -570,10 +570,24 @@ static void msr_mrs_banked_exc_checks(CPUARMState *en= v, uint32_t tgtmode, */ int curmode =3D env->uncached_cpsr & CPSR_M; =20 - if (regno =3D=3D 17) { - /* ELR_Hyp: a special case because access from tgtmode is OK */ - if (curmode !=3D ARM_CPU_MODE_HYP && curmode !=3D ARM_CPU_MODE_MON= ) { - goto undef; + if (tgtmode =3D=3D ARM_CPU_MODE_HYP) { + /* + * Handle Hyp target regs first because some are special cases + * which don't want the usual "not accessible from tgtmode" check. + */ + switch (regno) { + case 16 ... 17: /* ELR_Hyp, SPSR_Hyp */ + if (curmode !=3D ARM_CPU_MODE_HYP && curmode !=3D ARM_CPU_MODE= _MON) { + goto undef; + } + break; + case 13: + if (curmode !=3D ARM_CPU_MODE_MON) { + goto undef; + } + break; + default: + g_assert_not_reached(); } return; } @@ -604,13 +618,6 @@ static void msr_mrs_banked_exc_checks(CPUARMState *env= , uint32_t tgtmode, } } =20 - if (tgtmode =3D=3D ARM_CPU_MODE_HYP) { - /* SPSR_Hyp, r13_hyp: accessible from Monitor mode only */ - if (curmode !=3D ARM_CPU_MODE_MON) { - goto undef; - } - } - return; =20 undef: @@ -625,7 +632,12 @@ void HELPER(msr_banked)(CPUARMState *env, uint32_t val= ue, uint32_t tgtmode, =20 switch (regno) { case 16: /* SPSRs */ - env->banked_spsr[bank_number(tgtmode)] =3D value; + if (tgtmode =3D=3D (env->uncached_cpsr & CPSR_M)) { + /* Only happens for SPSR_Hyp access in Hyp mode */ + env->spsr =3D value; + } else { + env->banked_spsr[bank_number(tgtmode)] =3D value; + } break; case 17: /* ELR_Hyp */ env->elr_el[2] =3D value; @@ -659,7 +671,12 @@ uint32_t HELPER(mrs_banked)(CPUARMState *env, uint32_t= tgtmode, uint32_t regno) =20 switch (regno) { case 16: /* SPSRs */ - return env->banked_spsr[bank_number(tgtmode)]; + if (tgtmode =3D=3D (env->uncached_cpsr & CPSR_M)) { + /* Only happens for SPSR_Hyp access in Hyp mode */ + return env->spsr; + } else { + return env->banked_spsr[bank_number(tgtmode)]; + } case 17: /* ELR_Hyp */ return env->elr_el[2]; case 13: diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index 5fa82497238..f947c62c6be 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -2822,13 +2822,20 @@ static bool msr_banked_access_decode(DisasContext *= s, int r, int sysm, int rn, break; case ARM_CPU_MODE_HYP: /* - * SPSR_hyp and r13_hyp can only be accessed from Monitor mode - * (and so we can forbid accesses from EL2 or below). elr_hyp - * can be accessed also from Hyp mode, so forbid accesses from - * EL0 or EL1. + * r13_hyp can only be accessed from Monitor mode, and so we + * can forbid accesses from EL2 or below. + * elr_hyp can be accessed also from Hyp mode, so forbid + * accesses from EL0 or EL1. + * SPSR_hyp is supposed to be in the same category as r13_hyp + * and UNPREDICTABLE if accessed from anything except Monitor + * mode. However there is some real-world code that will do + * it because at least some hardware happens to permit the + * access. (Notably a standard Cortex-R52 startup code fragment + * does this.) So we permit SPSR_hyp from Hyp mode also, to allow + * this (incorrect) guest code to run. */ - if (!arm_dc_feature(s, ARM_FEATURE_EL2) || s->current_el < 2 || - (s->current_el < 3 && *regno !=3D 17)) { + if (!arm_dc_feature(s, ARM_FEATURE_EL2) || s->current_el < 2 + || (s->current_el < 3 && *regno !=3D 16 && *regno !=3D 17)) { goto undef; } break; --=20 2.34.1 From nobody Tue Nov 26 13:50:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707226208; cv=none; d=zohomail.com; s=zohoarc; b=g5VcNQVthMMZpRsHhE95WujHnKVUHV0EQ0LLxDHe1UmSzsZUkkMmU0EUgmXoc46+xXPNDt+IsW9so6GDtdfnAzSFxB+Jv+rpIfhV10hQDlJAZIxTia3zyW8Qg2oQzl4Vk++b6HOb9+8DUx3em+629UDfUyyPQAoxrEKoDaCIAW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707226208; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=UYUQj98bbU7K8bCUSnxlmHCzo3manDoNOSQ2wWBClxY=; b=itjlLPAlrr2T1a5dKP4FXKUO0s0rUhNWxhdNC2OwANuerXOlUSQ5m7jfyVBXaeziScGTciWtfrAAeboOuIvk9acCe8i7sLDeVPFMEUKjH/j2kQ1lS0vuDamu4dL6f49cs9ECn7H+S1Xlf0HTFA2WszGoPGwYVchti+FIjmee/hM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707226208594116.70987180470786; Tue, 6 Feb 2024 05:30:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXLW9-0000RU-IN; Tue, 06 Feb 2024 08:29:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXLW7-0000Oy-Is for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:39 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXLW4-0008E8-Fg for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:39 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40fc52c2ae4so38781035e9.3 for ; Tue, 06 Feb 2024 05:29:35 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a056000108700b0033b470a137esm1492932wrw.79.2024.02.06.05.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:29:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707226175; x=1707830975; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=UYUQj98bbU7K8bCUSnxlmHCzo3manDoNOSQ2wWBClxY=; b=ORbbrOJjJtcQa8VpKiqXg8tY37aePU8QLWQR2Hx35BPaKFT7geVIUIQKU1BaRLiyd/ n2C3Z7ReD/OiaS40wU3JJsxjTCHH7g+RyMtM/Wz8qfUGpK3558o2y9DxOOcBU91ZDWHF znLSUPs2W8Ks6T59eTmGDKoZzDZPXV3EFiZg8QfaJVYucqmg2Dko9EF1ejJrnZaqoq+g fvfhRUJgVT/fG+YJz2DswH97qMfBooqa+hPmhoRJm9yU/I2TDHFsEsNGKbEtLA7Q02aE R/6b78aXCBTuY03yFpfR2pXOgGQDkLax8XOsbWAFYjXsLqpxLnJYC5K6mtpA9wwYQBSS L67w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226175; x=1707830975; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UYUQj98bbU7K8bCUSnxlmHCzo3manDoNOSQ2wWBClxY=; b=cuBPLb/LUcwse74WW/moXFgl2HMqwZZ5gH00qNd+8KhRq5o7i0pVuFJk8A4tS9oXp3 WgDRFge9l+WG/Jgt6uwKTKAxS8RNKzOuVsWkThWXSvBwgoGzaFz44a1zkipww7510oxz W7n7P3jz6bVp+6hJS3gWCIm7H1mN7mdv06onZHzrPIeEsM41X+/iV29Di037xBSom8YW Urxyr+pAZNT/Va2x2ht2cGCQPGshkF//xuSbUegDgKYlOWVCAOqdAeHGQ/kIsFRkRE1/ +UjYSEiGPBcVGMtgR5xLDdJ+3yOdJYE357iu+O30eOH+az8afuubQc5Px9oOmcGnRReo nfPQ== X-Gm-Message-State: AOJu0YxBvxVxlL7gR/v2+HG6CWbtwX9cS7mxNWZ0RfYRMByqAZCKCwpf Ke0qUVjlYAfm0WMawoMhfFeCmkBX6NzmOufVqj2NfBnkyvvmoKCvmxmfNGIPinQ= X-Google-Smtp-Source: AGHT+IH2Cc78X7hKdcZqkQzj9IhYeqjAWZ0ZreqyoXDbmpACEwOm86fbJl57I1PvQXxuZGer2mfnZg== X-Received: by 2002:adf:ed0e:0:b0:33b:17e3:60d9 with SMTP id a14-20020adfed0e000000b0033b17e360d9mr976730wro.1.1707226174900; Tue, 06 Feb 2024 05:29:34 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWuZDECeXToWo71JfToqMViQWidwu2iSsTn6PCtvEkmwCFPW7afGs6iN0N+svrKXTZRV8oyliAgvxosw+MS2hzTo1PJBTQ= From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 05/13] hw/misc/mps2-scc: Fix condition for CFG3 register Date: Tue, 6 Feb 2024 13:29:23 +0000 Message-Id: <20240206132931.38376-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206132931.38376-1-peter.maydell@linaro.org> References: <20240206132931.38376-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707226210536100005 Content-Type: text/plain; charset="utf-8" We currently guard the CFG3 register read with (scc_partno(s) =3D=3D 0x524 && scc_partno(s) =3D=3D 0x547) which is clearly wrong as it is never true. This register is present on all board types except AN524 and AN527; correct the condition. Fixes: 6ac80818941829c0 ("hw/misc/mps2-scc: Implement changes for AN547") Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/misc/mps2-scc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c index 6cfb5ff1086..6c1b1cd3795 100644 --- a/hw/misc/mps2-scc.c +++ b/hw/misc/mps2-scc.c @@ -118,7 +118,7 @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offs= et, unsigned size) r =3D s->cfg2; break; case A_CFG3: - if (scc_partno(s) =3D=3D 0x524 && scc_partno(s) =3D=3D 0x547) { + if (scc_partno(s) =3D=3D 0x524 || scc_partno(s) =3D=3D 0x547) { /* CFG3 reserved on AN524 */ goto bad_offset; } --=20 2.34.1 From nobody Tue Nov 26 13:50:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707226410; cv=none; d=zohomail.com; s=zohoarc; b=W1mj0++kqF6XZ+9OWAVG3YqD4dED+ndMORoy63vF+OMeKxVQxmmW5oVBWgR5/yazGDrkbYfvaTUsyFos7O1zrXZt3yUQ0gDtMxYxVsBBMMonBdqeiDthETGmj77p6alGVa6BT9wIXKDLeG6l8KkAShrEm/keANrDCFrvXiwhEM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707226410; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=EMtxt4f4Pe35Y41NOxdIdqkHjaw4kvMUbL17jcA12tk=; b=BwUt9yogdhazXJQKtERclPMCTDeKz2RhsfQXGUXt1hjm+ccMCFSxqRVCrbzrI0bFYC/KTbG5NCNqzqQZ0yBr88ADTILZE89hkQa2KUEo7Mt9Kh8jd4VO1EdldVrwsjuz4Iu5o5yeAV4briqYEYxC7PcfDnGK0UI3remgum/qrUA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707226410628694.2958230360435; Tue, 6 Feb 2024 05:33:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXLWD-0000f2-1E; Tue, 06 Feb 2024 08:29:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXLW9-0000Rb-BE for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:41 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXLW4-0008EG-Np for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:40 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40fdc63f4feso16545405e9.3 for ; Tue, 06 Feb 2024 05:29:36 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a056000108700b0033b470a137esm1492932wrw.79.2024.02.06.05.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:29:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707226175; x=1707830975; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=EMtxt4f4Pe35Y41NOxdIdqkHjaw4kvMUbL17jcA12tk=; b=bT2+ZVlD5CAsctR3I0n7HIvROAxYZaraclQpnKol+KczY2+5FGCUzrdVvhAkruBIah /vkhoGMqco5GyFEkA3d7ULz8bxQAb3VHtKSF2rhIJtb87uth9kgBw7h/BwP7iyo5qB2d HPjrOD9d5fAduzw06bGazrn2DtPfvP6WvRCx6FQoQwDhXL+lDigfJW1YMC+7TMvEDPKl n0611NNyDWQ64U4DLB+AcNXd75dYujVL1N75MKSEfLPnNOFzdxcbC6sSmLGXnpaG0UkL dC03o1Qt+uxGn+T5BqaPJLe7oQfKNyIdbLxOvAwvqozP8O8amDwVSWjhWQqV6QTP8sRP Nu0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226175; x=1707830975; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EMtxt4f4Pe35Y41NOxdIdqkHjaw4kvMUbL17jcA12tk=; b=VZpl3Nof68987QOnNlMcLvYqqVTWk6YcPQJxMa6tT86PDvSFFPXimW7BMlGDqELnLv Nkd1eCRVDsGmRUNXGK1LAYWj3fVOZiapFSGEhRFWhAxFO0WWNFOsC6vIhZAJHBf8E7g0 fi2RshADH1IH1l63biczOw3aMoiycAZ1osjlW7v50//sJTFO19YttD0dWJOFTY+4YYNM dF49oowBjDP9rILHpkHsvWt8566VQsZDvgnxqGqqKwI0oNd81u/izInrJ3t5H3/6wQgW xHAp9ZpLHygKEHvkGN6AgsyDcb4Xk2nGTXaVx+jNgaBSg4Qa+mRgM3tge1b8a2A/B6lp PJkw== X-Gm-Message-State: AOJu0Yxi/v5eRJ6jBfDdR2CGlBkooxVapusHGQg8JZ3bZTd3M74BMktR ubGghfqTiy0MV/2wiMF75/lDErEEAJV3KZZXs3bxoYfdi+r2HMMAvwEnzUy1ZfM= X-Google-Smtp-Source: AGHT+IGdt9rl+fgak9USCnEUHAEQqb80qMbMZy811pXWnMh+J7g6tGiSdUhtYmk7T41c7+/Uly52XA== X-Received: by 2002:a05:600c:1c83:b0:40f:de06:fcee with SMTP id k3-20020a05600c1c8300b0040fde06fceemr1985249wms.7.1707226175333; Tue, 06 Feb 2024 05:29:35 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCULJhTN8UK1lKExvZU9CAgCvkM0dShiAaArMWSUIZtML0eKmpYmpaIZG8kG4YFcUyuWkyA1sE/zPv2tv349hAKAst+0Brs= From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 06/13] hw/misc/mps2-scc: Factor out which-board conditionals Date: Tue, 6 Feb 2024 13:29:24 +0000 Message-Id: <20240206132931.38376-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206132931.38376-1-peter.maydell@linaro.org> References: <20240206132931.38376-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707226411514100007 Content-Type: text/plain; charset="utf-8" The MPS SCC device has a lot of different flavours for the various different MPS FPGA images, which look mostly similar but have differences in how particular registers are handled. Currently we deal with this with a lot of open-coded checks on scc_partno(), but as we add more board types this is getting a bit hard to read. Factor out the conditions into some functions which we can give more descriptive names to. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/misc/mps2-scc.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c index 6c1b1cd3795..02a80bacd71 100644 --- a/hw/misc/mps2-scc.c +++ b/hw/misc/mps2-scc.c @@ -59,6 +59,30 @@ static int scc_partno(MPS2SCC *s) return extract32(s->id, 4, 8); } =20 +/* Is CFG_REG2 present? */ +static bool have_cfg2(MPS2SCC *s) +{ + return scc_partno(s) =3D=3D 0x524 || scc_partno(s) =3D=3D 0x547; +} + +/* Is CFG_REG3 present? */ +static bool have_cfg3(MPS2SCC *s) +{ + return scc_partno(s) !=3D 0x524 && scc_partno(s) !=3D 0x547; +} + +/* Is CFG_REG5 present? */ +static bool have_cfg5(MPS2SCC *s) +{ + return scc_partno(s) =3D=3D 0x524 || scc_partno(s) =3D=3D 0x547; +} + +/* Is CFG_REG6 present? */ +static bool have_cfg6(MPS2SCC *s) +{ + return scc_partno(s) =3D=3D 0x524; +} + /* Handle a write via the SYS_CFG channel to the specified function/device. * Return false on error (reported to guest via SYS_CFGCTRL ERROR bit). */ @@ -111,15 +135,13 @@ static uint64_t mps2_scc_read(void *opaque, hwaddr of= fset, unsigned size) r =3D s->cfg1; break; case A_CFG2: - if (scc_partno(s) !=3D 0x524 && scc_partno(s) !=3D 0x547) { - /* CFG2 reserved on other boards */ + if (!have_cfg2(s)) { goto bad_offset; } r =3D s->cfg2; break; case A_CFG3: - if (scc_partno(s) =3D=3D 0x524 || scc_partno(s) =3D=3D 0x547) { - /* CFG3 reserved on AN524 */ + if (!have_cfg3(s)) { goto bad_offset; } /* These are user-settable DIP switches on the board. We don't @@ -131,15 +153,13 @@ static uint64_t mps2_scc_read(void *opaque, hwaddr of= fset, unsigned size) r =3D s->cfg4; break; case A_CFG5: - if (scc_partno(s) !=3D 0x524 && scc_partno(s) !=3D 0x547) { - /* CFG5 reserved on other boards */ + if (!have_cfg5(s)) { goto bad_offset; } r =3D s->cfg5; break; case A_CFG6: - if (scc_partno(s) !=3D 0x524) { - /* CFG6 reserved on other boards */ + if (!have_cfg6(s)) { goto bad_offset; } r =3D s->cfg6; @@ -202,24 +222,21 @@ static void mps2_scc_write(void *opaque, hwaddr offse= t, uint64_t value, } break; case A_CFG2: - if (scc_partno(s) !=3D 0x524 && scc_partno(s) !=3D 0x547) { - /* CFG2 reserved on other boards */ + if (!have_cfg2(s)) { goto bad_offset; } /* AN524: QSPI Select signal */ s->cfg2 =3D value; break; case A_CFG5: - if (scc_partno(s) !=3D 0x524 && scc_partno(s) !=3D 0x547) { - /* CFG5 reserved on other boards */ + if (!have_cfg5(s)) { goto bad_offset; } /* AN524: ACLK frequency in Hz */ s->cfg5 =3D value; break; case A_CFG6: - if (scc_partno(s) !=3D 0x524) { - /* CFG6 reserved on other boards */ + if (!have_cfg6(s)) { goto bad_offset; } /* AN524: Clock divider for BRAM */ --=20 2.34.1 From nobody Tue Nov 26 13:50:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707226236; cv=none; d=zohomail.com; s=zohoarc; b=g44vI5wdEoaiXLts82HrzXFOgpMncNjLuqtxJnBGJtcOi2MATmo6cnazIOGQmQqsZkDK9Ub7mOSvCjKUYmRRNOYgC328evrbodtgc6a4K2FnWgbhAi+yj6VaUMl0hOtKkcFaeCJlCk1uZGPZ4jPns48AyWcrjC7ruG/kXUxK0t0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707226236; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=gFP5iyTPjpV1cEOb71+konTscrwLFnQ2qPt+jzXrQdw=; b=GGDuzG9LNmRh7yuD2DU6lP5UHyYevvayF5yov3cMnEw7oGgLMFN5S6z5IoCKLHjQxPfwtSK8Jv7e/3Gy34MLtiicgJBWy9o5cW13VHhtjamRRxXYFLaxPBFqUr/wpr2SkMRup5UJHGQaY2f7F2dHkLlOw2DO9iglhNrLx5YA0r8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17072262368241000.1180257411612; Tue, 6 Feb 2024 05:30:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXLWB-0000Y6-Mo; Tue, 06 Feb 2024 08:29:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXLW9-0000Se-M8 for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:42 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXLW5-0008ET-He for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:41 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-337cc8e72f5so4189546f8f.1 for ; Tue, 06 Feb 2024 05:29:36 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a056000108700b0033b470a137esm1492932wrw.79.2024.02.06.05.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:29:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707226176; x=1707830976; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=gFP5iyTPjpV1cEOb71+konTscrwLFnQ2qPt+jzXrQdw=; b=pJ9rOZPjc609bEUnrHEghLlOW1hNQdLyY9MEDfvMxwfg1/IOvlIVodEyAqFAdIyQo+ eymR81iPKS0YjjU7fA3HmCWHpbtJCA7jZCLKAWSpnXJrTtqzxikmLRjTqOrEk3r9Uhfj FvReNNb7o+lZS7PGwsesZuzfNff32V7x5S4bchZ8XSkPmol9u6M8nPeyauofaJ/OU7ry znnwRPPzt9HupWBRzFj+DLRHL6nQphwZcAvJgPR3Kd4/1uzkcRT9wD/UKmiZqlM2sqki H03eFi5peOp0bf0sL1KIVJFOVggTjTC///aW0z+d3tTCLV5DE0Tizt53sxONmllzaTrm kLXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226176; x=1707830976; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gFP5iyTPjpV1cEOb71+konTscrwLFnQ2qPt+jzXrQdw=; b=E+jGavqOh7VFPucuBtpxRRHJGsPG5D/RwVm6mhO7O5kAE2OA8IhwXl7xc7wKGpihBO 66sL8W5LQUIrGyxfxFeDm0vhD+NruSXgYXcCx9I5+iapUyXkBoBnHzmBgRJTeguyqsJe 4tF/lHgXrl5wc4HRqM+00xFAdG0fZ0k3BG7ZnkK2C8Coj2cOHI2lnm1AjRbvzuDHiCnG mQ4ORWUybxn9C3qaesGkTVdeaGqf2b9DRB55yCMWuDzjo0OU8RNtlmku+N3pdL53vh/U 6sPqY2nQTyKcQTc0cfMqFpDSaE0NWdx4by55q3EVr4JTF9w4ncSfgQWGa0GjBW0CHF62 NfOA== X-Gm-Message-State: AOJu0Yx9nQdQOz9NR2n/44fHqHDxSrF5tMIlXoma1eBPeZKo94KCLSUS RONPwH3BvfdcCyJwlb5ANr9trBnYQLiNJCc3/yUrMArPOYsnnuGNNnJWFkgZGGA= X-Google-Smtp-Source: AGHT+IEUPdsObKq4krLuGIK1SubBfL2QYoaVAa2UWG7J78QQxtGu0zUgFBi+wyeQvfHL16n2yb6iiA== X-Received: by 2002:a5d:4a45:0:b0:33a:e6dc:2e98 with SMTP id v5-20020a5d4a45000000b0033ae6dc2e98mr1432613wrs.5.1707226175753; Tue, 06 Feb 2024 05:29:35 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWDHAyClWhqwpDk43/Uy2geWAjD3CIEjPD2lJLDxzqg4gGZ2UoKx+LP5Lsbr6B2KgM4Rw6AqU4lc+gV6+cybMUXDFYN4JE= From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 07/13] hw/misc/mps2-scc: Make changes needed for AN536 FPGA image Date: Tue, 6 Feb 2024 13:29:25 +0000 Message-Id: <20240206132931.38376-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206132931.38376-1-peter.maydell@linaro.org> References: <20240206132931.38376-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707226238724100003 Content-Type: text/plain; charset="utf-8" The MPS2 SCC device is broadly the same for all FPGA images, but has minor differences in the behaviour of the CFG registers depending on the image. In many cases we don't really care about the functionality controlled by these registers and a reads-as-written or similar behaviour is sufficient for the moment. For the AN536 the required behaviour is: * A_CFG0 has CPU reset and halt bits - implement as reads-as-written for the moment * A_CFG1 has flash or ATCM address 0 remap handling - QEMU doesn't model this; implement as reads-as-written * A_CFG2 has QSPI select (like AN524) - implemented (no behaviour, as with AN524) * A_CFG3 is MCC_MSB_ADDR "additional MCC addressing bits" - QEMU doesn't care about these, so use the existing RAZ behaviour for convenience * A_CFG4 is board rev (like all other images) - no change needed * A_CFG5 is ACLK frq in hz (like AN524) - implemented as reads-as-written, as for other boards * A_CFG6 is core 0 vector table base address - implemented as reads-as-written for the moment * A_CFG7 is core 1 vector table base address - implemented as reads-as-written for the moment Make the changes necessary for this; leave TODO comments where appropriate to indicate where we might want to come back and implement things like CPU reset. The other aspects of the device specific to this FPGA image (like the values of the board ID and similar registers) will be set via the device's qdev properties. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- include/hw/misc/mps2-scc.h | 1 + hw/misc/mps2-scc.c | 101 +++++++++++++++++++++++++++++++++---- 2 files changed, 92 insertions(+), 10 deletions(-) diff --git a/include/hw/misc/mps2-scc.h b/include/hw/misc/mps2-scc.h index 3b2d13ac9c3..8ff188c06b1 100644 --- a/include/hw/misc/mps2-scc.h +++ b/include/hw/misc/mps2-scc.h @@ -51,6 +51,7 @@ struct MPS2SCC { uint32_t cfg4; uint32_t cfg5; uint32_t cfg6; + uint32_t cfg7; uint32_t cfgdata_rtn; uint32_t cfgdata_out; uint32_t cfgctrl; diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c index 02a80bacd71..18be74157ee 100644 --- a/hw/misc/mps2-scc.c +++ b/hw/misc/mps2-scc.c @@ -37,6 +37,7 @@ REG32(CFG3, 0xc) REG32(CFG4, 0x10) REG32(CFG5, 0x14) REG32(CFG6, 0x18) +REG32(CFG7, 0x1c) REG32(CFGDATA_RTN, 0xa0) REG32(CFGDATA_OUT, 0xa4) REG32(CFGCTRL, 0xa8) @@ -62,25 +63,46 @@ static int scc_partno(MPS2SCC *s) /* Is CFG_REG2 present? */ static bool have_cfg2(MPS2SCC *s) { - return scc_partno(s) =3D=3D 0x524 || scc_partno(s) =3D=3D 0x547; + return scc_partno(s) =3D=3D 0x524 || scc_partno(s) =3D=3D 0x547 || + scc_partno(s) =3D=3D 0x536; } =20 /* Is CFG_REG3 present? */ static bool have_cfg3(MPS2SCC *s) { - return scc_partno(s) !=3D 0x524 && scc_partno(s) !=3D 0x547; + return scc_partno(s) !=3D 0x524 && scc_partno(s) !=3D 0x547 && + scc_partno(s) !=3D 0x536; } =20 /* Is CFG_REG5 present? */ static bool have_cfg5(MPS2SCC *s) { - return scc_partno(s) =3D=3D 0x524 || scc_partno(s) =3D=3D 0x547; + return scc_partno(s) =3D=3D 0x524 || scc_partno(s) =3D=3D 0x547 || + scc_partno(s) =3D=3D 0x536; } =20 /* Is CFG_REG6 present? */ static bool have_cfg6(MPS2SCC *s) { - return scc_partno(s) =3D=3D 0x524; + return scc_partno(s) =3D=3D 0x524 || scc_partno(s) =3D=3D 0x536; +} + +/* Is CFG_REG7 present? */ +static bool have_cfg7(MPS2SCC *s) +{ + return scc_partno(s) =3D=3D 0x536; +} + +/* Does CFG_REG0 drive the 'remap' GPIO output? */ +static bool cfg0_is_remap(MPS2SCC *s) +{ + return scc_partno(s) !=3D 0x536; +} + +/* Is CFG_REG1 driving a set of LEDs? */ +static bool cfg1_is_leds(MPS2SCC *s) +{ + return scc_partno(s) !=3D 0x536; } =20 /* Handle a write via the SYS_CFG channel to the specified function/device. @@ -144,8 +166,16 @@ static uint64_t mps2_scc_read(void *opaque, hwaddr off= set, unsigned size) if (!have_cfg3(s)) { goto bad_offset; } - /* These are user-settable DIP switches on the board. We don't + /* + * These are user-settable DIP switches on the board. We don't * model that, so just return zeroes. + * + * TODO: for AN536 this is MCC_MSB_ADDR "additional MCC addressing + * bits". These change which part of the DDR4 the motherboard + * configuration controller can see in its memory map (see the + * appnote section 2.4). QEMU doesn't model the MCC at all, so the= se + * bits are not interesting to us; read-as-zero is as good as anyt= hing + * else. */ r =3D 0; break; @@ -164,6 +194,12 @@ static uint64_t mps2_scc_read(void *opaque, hwaddr off= set, unsigned size) } r =3D s->cfg6; break; + case A_CFG7: + if (!have_cfg7(s)) { + goto bad_offset; + } + r =3D s->cfg7; + break; case A_CFGDATA_RTN: r =3D s->cfgdata_rtn; break; @@ -211,28 +247,43 @@ static void mps2_scc_write(void *opaque, hwaddr offse= t, uint64_t value, * we always reflect bit 0 in the 'remap' GPIO output line, * and let the board wire it up or not as it chooses. * TODO on some boards bit 1 is CPU_WAIT. + * + * TODO: on the AN536 this register controls reset and halt + * for both CPUs. For the moment we don't implement this, so the + * register just reads as written. */ s->cfg0 =3D value; - qemu_set_irq(s->remap, s->cfg0 & 1); + if (cfg0_is_remap(s)) { + qemu_set_irq(s->remap, s->cfg0 & 1); + } break; case A_CFG1: s->cfg1 =3D value; - for (size_t i =3D 0; i < ARRAY_SIZE(s->led); i++) { - led_set_state(s->led[i], extract32(value, i, 1)); + /* + * On most boards this register drives LEDs. + * + * TODO: for AN536 this controls whether flash and ATCM are + * enabled or disabled on reset. QEMU doesn't model this, and + * always wires up RAM in the ATCM area and ROM in the flash area. + */ + if (cfg1_is_leds(s)) { + for (size_t i =3D 0; i < ARRAY_SIZE(s->led); i++) { + led_set_state(s->led[i], extract32(value, i, 1)); + } } break; case A_CFG2: if (!have_cfg2(s)) { goto bad_offset; } - /* AN524: QSPI Select signal */ + /* AN524, AN536: QSPI Select signal */ s->cfg2 =3D value; break; case A_CFG5: if (!have_cfg5(s)) { goto bad_offset; } - /* AN524: ACLK frequency in Hz */ + /* AN524, AN536: ACLK frequency in Hz */ s->cfg5 =3D value; break; case A_CFG6: @@ -240,6 +291,14 @@ static void mps2_scc_write(void *opaque, hwaddr offset= , uint64_t value, goto bad_offset; } /* AN524: Clock divider for BRAM */ + /* AN536: Core 0 vector table base address */ + s->cfg6 =3D value; + break; + case A_CFG7: + if (!have_cfg7(s)) { + goto bad_offset; + } + /* AN536: Core 1 vector table base address */ s->cfg6 =3D value; break; case A_CFGDATA_OUT: @@ -353,6 +412,24 @@ static void mps2_scc_finalize(Object *obj) g_free(s->oscclk_reset); } =20 +static bool cfg7_needed(void *opaque) +{ + MPS2SCC *s =3D opaque; + + return have_cfg7(s); +} + +static const VMStateDescription vmstate_cfg7 =3D { + .name =3D "mps2-scc/cfg7", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D cfg7_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32(cfg7, MPS2SCC), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription mps2_scc_vmstate =3D { .name =3D "mps2-scc", .version_id =3D 3, @@ -372,6 +449,10 @@ static const VMStateDescription mps2_scc_vmstate =3D { VMSTATE_VARRAY_UINT32(oscclk, MPS2SCC, num_oscclk, 0, vmstate_info_uint32, uint32_t), VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * const []) { + &vmstate_cfg7, + NULL } }; =20 --=20 2.34.1 From nobody Tue Nov 26 13:50:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707226340; cv=none; d=zohomail.com; s=zohoarc; b=DTfUtsahNxmTFKM/1BI724wYg9ZYFwPl4MpX/WaVwJNnnhzkWWZiXUMqPdmr/T28q8UBt+Ms2jOiNT+kaTAxjaQdsULQo8KUGVoAniROUjXCo6JNmWynNEs0yKUb0wHfh17qYdHp0c9mCvNtkIMpGvIJ3f+K/+KosJ0Ve7gedV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707226340; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=ERolA0aC2wCykerxlApD+LMGSL7zywOWVrO1yRbs12k=; b=Hq1xt8EJOjDRToRVryc/6O0Dc10C75rSGyipUeX/N8rSlPKT4XeCAtUb2mw4Cz/9Bg3FnEuX9XYYyF2QBJ+b/n11n6nYzUX+UeDbUR+drDKkKEvm5t6Nn/60P3ChfyLLzc9BCuabyVgOZfj3sPYN0t4dau/09zNKjmLZBPN0eGU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707226340228297.017465063126; Tue, 6 Feb 2024 05:32:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXLWG-0000nz-Mx; Tue, 06 Feb 2024 08:29:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXLWB-0000Xz-Cw for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:43 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXLW5-0008Eh-VU for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:43 -0500 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-33b401fd72bso1391056f8f.3 for ; Tue, 06 Feb 2024 05:29:37 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a056000108700b0033b470a137esm1492932wrw.79.2024.02.06.05.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:29:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707226176; x=1707830976; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ERolA0aC2wCykerxlApD+LMGSL7zywOWVrO1yRbs12k=; b=eHwc1qqECwaZZJPPgP975nXyJdjC7cRyzHyy9ul/mmxN0KWFAkB9AtegOhxNFn2rM/ ZvPPBJDiKPEI9SiPKuwf77gQ9CD04VRDSyzreLfttM+gFjb+/p15AvIC0YxMouAiruOC QmPgHN1g12ye4+5SHeA6ppzRz1EhQTWv/aP52G3UFy3/wNzgNiyFN2Qxkpircf9apsQ5 Yu9adJGE1sEbqrzvM5bK2Hw0k5J4OebplQqdg/g4VcR2H895LBFfCeC6t41hUk9uygdb TpVU9wUaQwSHsNRHPuxAZH4vglqe5O6mNyQOyLEHu+QvQuXXMDcWSmVGdPCAYoRfhwKI HLGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226176; x=1707830976; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ERolA0aC2wCykerxlApD+LMGSL7zywOWVrO1yRbs12k=; b=pdTtGxcxUfwlE8gm8S/qxgKCk7xnqvTyl5csc5onuHobayUSkeVefGasC7JLuBplqg e9oGHNShtZvTP/xDq+Wob00miQPYZYr0cFXfThSSs+crU0ihOBOE2kMCzngaLVniveE8 fNjzgZrK9HWzQ6gl/SqVKSnBJmTsq6394DlkWJkp9jyOrhGsd8Qt4jWMFkR5k1c5k8Cr ByNxtlmvhm3Fz+5C9JDa56y+t96a+bBkFnD08BBDmQb/qYh2riqkv/dNQo/+WMhUUEVr iKtSbh+8NqrdBk4WLR9qyPkOk7LYAf4ybhD1EAAGP0yaRxcn1/xvXgOCqmPiZp3kTF2U 2Rmg== X-Gm-Message-State: AOJu0Ywul2sYPvSYhZDyeVOZJnCKd6GJsYnyx+bYOidn01nW+HAOyEr6 93bHlGyau0Rni2FH1/SgtvAL6qt89UPVYZEmYzZ0+8kti3r6f+Uk/0k9Pv3iVCeXxxEUexa0f4D W X-Google-Smtp-Source: AGHT+IGusJCX7b8/iZoagEKCYVoDy75CckieKXbkCvdxMEXJZ5NGHiV+etbG8PEgWhdEfKuMZM+IJQ== X-Received: by 2002:a5d:518b:0:b0:33b:d01:3e39 with SMTP id k11-20020a5d518b000000b0033b0d013e39mr1394926wrv.68.1707226176561; Tue, 06 Feb 2024 05:29:36 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWQ7cUZwji/KkOiSduMjEyoc43UFh/phqduPO3TN6GPYYYL/RLxDwqJNZmYAp/CNSH2/SqfV1hZz6J0Sq2b01Exax5xEho= From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 08/13] hw/arm/mps3r: Initial skeleton for mps3-an536 board Date: Tue, 6 Feb 2024 13:29:26 +0000 Message-Id: <20240206132931.38376-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206132931.38376-1-peter.maydell@linaro.org> References: <20240206132931.38376-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707226341203100003 Content-Type: text/plain; charset="utf-8" The AN536 is another FPGA image for the MPS3 development board. Unlike the existing FPGA images we already model, this board uses a Cortex-R family CPU, and it does not use any equivalent to the M-profile "Subsystem for Embedded" SoC-equivalent that we model in hw/arm/armsse.c. It's therefore more convenient for us to model it as a completely separate C file. This commit adds the basic skeleton of the board model, and the code to create all the RAM and ROM. We assume that we're probably going to want to add more images in future, so use the same base class/subclass setup that mps2-tz.c uses, even though at the moment there's only a single subclass. Following commits will add the CPUs and the peripherals. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- MAINTAINERS | 3 +- configs/devices/arm-softmmu/default.mak | 1 + hw/arm/mps3r.c | 239 ++++++++++++++++++++++++ hw/arm/Kconfig | 5 + hw/arm/meson.build | 1 + 5 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 hw/arm/mps3r.c diff --git a/MAINTAINERS b/MAINTAINERS index 2f9741b898e..8219ed9068c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -819,12 +819,13 @@ F: include/hw/misc/imx7_*.h F: hw/pci-host/designware.c F: include/hw/pci-host/designware.h =20 -MPS2 +MPS2 / MPS3 M: Peter Maydell L: qemu-arm@nongnu.org S: Maintained F: hw/arm/mps2.c F: hw/arm/mps2-tz.c +F: hw/arm/mps3r.c F: hw/misc/mps2-*.c F: include/hw/misc/mps2-*.h F: hw/arm/armsse.c diff --git a/configs/devices/arm-softmmu/default.mak b/configs/devices/arm-= softmmu/default.mak index 023faa2f750..6ee31bc1ab9 100644 --- a/configs/devices/arm-softmmu/default.mak +++ b/configs/devices/arm-softmmu/default.mak @@ -13,6 +13,7 @@ CONFIG_ARM_VIRT=3Dy # CONFIG_INTEGRATOR=3Dn # CONFIG_FSL_IMX31=3Dn # CONFIG_MUSICPAL=3Dn +# CONFIG_MPS3R=3Dn # CONFIG_MUSCA=3Dn # CONFIG_CHEETAH=3Dn # CONFIG_SX1=3Dn diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c new file mode 100644 index 00000000000..888a846d23c --- /dev/null +++ b/hw/arm/mps3r.c @@ -0,0 +1,239 @@ +/* + * Arm MPS3 board emulation for Cortex-R-based FPGA images. + * (For M-profile images see mps2.c and mps2tz.c.) + * + * Copyright (c) 2017 Linaro Limited + * Written by Peter Maydell + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 or + * (at your option) any later version. + */ + +/* + * The MPS3 is an FPGA based dev board. This file handles FPGA images + * which use the Cortex-R CPUs. We model these separately from the + * M-profile images, because on M-profile the FPGA image is based on + * a "Subsystem for Embedded" which is similar to an SoC, whereas + * the R-profile FPGA images don't have that abstraction layer. + * + * We model the following FPGA images here: + * "mps3-an536" -- dual Cortex-R52 as documented in Arm Application Note = AN536 + * + * Application Note AN536: + * https://developer.arm.com/documentation/dai0536/latest/ + */ + +#include "qemu/osdep.h" +#include "qemu/units.h" +#include "qapi/error.h" +#include "exec/address-spaces.h" +#include "cpu.h" +#include "hw/boards.h" +#include "hw/arm/boot.h" + +/* Define the layout of RAM and ROM in a board */ +typedef struct RAMInfo { + const char *name; + hwaddr base; + hwaddr size; + int mrindex; /* index into rams[]; -1 for the system RAM block */ + int flags; +} RAMInfo; + +/* + * The MPS3 DDR is 3GiB, but on a 32-bit host QEMU doesn't permit + * emulation of that much guest RAM, so artificially make it smaller. + */ +#if HOST_LONG_BITS =3D=3D 32 +#define MPS3_DDR_SIZE (1 * GiB) +#else +#define MPS3_DDR_SIZE (3 * GiB) +#endif + +/* + * Flag values: + * IS_MAIN: this is the main machine RAM + * IS_ROM: this area is read-only + */ +#define IS_MAIN 1 +#define IS_ROM 2 + +#define MPS3R_RAM_MAX 9 + +typedef enum MPS3RFPGAType { + FPGA_AN536, +} MPS3RFPGAType; + +struct MPS3RMachineClass { + MachineClass parent; + MPS3RFPGAType fpga_type; + const RAMInfo *raminfo; +}; + +struct MPS3RMachineState { + MachineState parent; + MemoryRegion ram[MPS3R_RAM_MAX]; +}; + +#define TYPE_MPS3R_MACHINE "mps3r" +#define TYPE_MPS3R_AN536_MACHINE MACHINE_TYPE_NAME("mps3-an536") + +OBJECT_DECLARE_TYPE(MPS3RMachineState, MPS3RMachineClass, MPS3R_MACHINE) + +static const RAMInfo an536_raminfo[] =3D { + { + .name =3D "ATCM", + .base =3D 0x00000000, + .size =3D 0x00008000, + .mrindex =3D 0, + }, { + /* We model the QSPI flash as simple ROM for now */ + .name =3D "QSPI", + .base =3D 0x08000000, + .size =3D 0x00800000, + .flags =3D IS_ROM, + .mrindex =3D 1, + }, { + .name =3D "BRAM", + .base =3D 0x10000000, + .size =3D 0x00080000, + .mrindex =3D 2, + }, { + .name =3D "DDR", + .base =3D 0x20000000, + .size =3D MPS3_DDR_SIZE, + .mrindex =3D -1, + }, { + .name =3D "ATCM0", + .base =3D 0xee000000, + .size =3D 0x00008000, + .mrindex =3D 3, + }, { + .name =3D "BTCM0", + .base =3D 0xee100000, + .size =3D 0x00008000, + .mrindex =3D 4, + }, { + .name =3D "CTCM0", + .base =3D 0xee200000, + .size =3D 0x00008000, + .mrindex =3D 5, + }, { + .name =3D "ATCM1", + .base =3D 0xee400000, + .size =3D 0x00008000, + .mrindex =3D 6, + }, { + .name =3D "BTCM1", + .base =3D 0xee500000, + .size =3D 0x00008000, + .mrindex =3D 7, + }, { + .name =3D "CTCM1", + .base =3D 0xee600000, + .size =3D 0x00008000, + .mrindex =3D 8, + }, { + .name =3D NULL, + } +}; + +static MemoryRegion *mr_for_raminfo(MPS3RMachineState *mms, + const RAMInfo *raminfo) +{ + /* Return an initialized MemoryRegion for the RAMInfo. */ + MemoryRegion *ram; + + if (raminfo->mrindex < 0) { + /* Means this RAMInfo is for QEMU's "system memory" */ + MachineState *machine =3D MACHINE(mms); + assert(!(raminfo->flags & IS_ROM)); + return machine->ram; + } + + assert(raminfo->mrindex < MPS3R_RAM_MAX); + ram =3D &mms->ram[raminfo->mrindex]; + + memory_region_init_ram(ram, NULL, raminfo->name, + raminfo->size, &error_fatal); + if (raminfo->flags & IS_ROM) { + memory_region_set_readonly(ram, true); + } + return ram; +} + +static void mps3r_common_init(MachineState *machine) +{ + MPS3RMachineState *mms =3D MPS3R_MACHINE(machine); + MPS3RMachineClass *mmc =3D MPS3R_MACHINE_GET_CLASS(mms); + MemoryRegion *sysmem =3D get_system_memory(); + + for (const RAMInfo *ri =3D mmc->raminfo; ri->name; ri++) { + MemoryRegion *mr =3D mr_for_raminfo(mms, ri); + memory_region_add_subregion(sysmem, ri->base, mr); + } +} + +static void mps3r_set_default_ram_info(MPS3RMachineClass *mmc) +{ + /* + * Set mc->default_ram_size and default_ram_id from the + * information in mmc->raminfo. + */ + MachineClass *mc =3D MACHINE_CLASS(mmc); + const RAMInfo *p; + + for (p =3D mmc->raminfo; p->name; p++) { + if (p->mrindex < 0) { + /* Found the entry for "system memory" */ + mc->default_ram_size =3D p->size; + mc->default_ram_id =3D p->name; + return; + } + } + g_assert_not_reached(); +} + +static void mps3r_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + mc->init =3D mps3r_common_init; +} + +static void mps3r_an536_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + MPS3RMachineClass *mmc =3D MPS3R_MACHINE_CLASS(oc); + static const char * const valid_cpu_types[] =3D { + ARM_CPU_TYPE_NAME("cortex-r52"), + NULL + }; + + mc->desc =3D "ARM MPS3 with AN536 FPGA image for Cortex-R52"; + mc->default_cpus =3D 2; + mc->min_cpus =3D mc->default_cpus; + mc->max_cpus =3D mc->default_cpus; + mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("cortex-r52"); + mc->valid_cpu_types =3D valid_cpu_types; + mmc->raminfo =3D an536_raminfo; + mps3r_set_default_ram_info(mmc); +} + +static const TypeInfo mps3r_machine_types[] =3D { + { + .name =3D TYPE_MPS3R_MACHINE, + .parent =3D TYPE_MACHINE, + .abstract =3D true, + .instance_size =3D sizeof(MPS3RMachineState), + .class_size =3D sizeof(MPS3RMachineClass), + .class_init =3D mps3r_class_init, + }, { + .name =3D TYPE_MPS3R_AN536_MACHINE, + .parent =3D TYPE_MPS3R_MACHINE, + .class_init =3D mps3r_an536_class_init, + }, +}; + +DEFINE_TYPES(mps3r_machine_types); diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index db08a00a45b..8b45dc116ae 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -106,6 +106,11 @@ config MAINSTONE select PFLASH_CFI01 select SMC91C111 =20 +config MPS3R + bool + default y + depends on TCG && ARM + config MUSCA bool default y diff --git a/hw/arm/meson.build b/hw/arm/meson.build index c4017790670..a16d3479055 100644 --- a/hw/arm/meson.build +++ b/hw/arm/meson.build @@ -8,6 +8,7 @@ arm_ss.add(when: 'CONFIG_HIGHBANK', if_true: files('highban= k.c')) arm_ss.add(when: 'CONFIG_INTEGRATOR', if_true: files('integratorcp.c')) arm_ss.add(when: 'CONFIG_MAINSTONE', if_true: files('mainstone.c')) arm_ss.add(when: 'CONFIG_MICROBIT', if_true: files('microbit.c')) +arm_ss.add(when: 'CONFIG_MPS3R', if_true: files('mps3r.c')) arm_ss.add(when: 'CONFIG_MUSICPAL', if_true: files('musicpal.c')) arm_ss.add(when: 'CONFIG_NETDUINOPLUS2', if_true: files('netduinoplus2.c')) arm_ss.add(when: 'CONFIG_OLIMEX_STM32_H405', if_true: files('olimex-stm32-= h405.c')) --=20 2.34.1 From nobody Tue Nov 26 13:50:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707226209; cv=none; d=zohomail.com; s=zohoarc; b=fnXRebYU4GaXvfEmIiGFEkCPCET+UGDE5B5mN2Br+331AOVSM1ZsbKZ4+6IVuBaJ0iw5zcr8h2up7zCsJDI8/2JAjdpgSMxGZ7dJyZCO0rttfAA8nrQtQOMVnLGKpbdAgTmSZKj5ZrsOq8hNPyjXzv+pNvzWjKKhim2W++sP+pc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707226209; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Ggn5L22e93CND5ondADlE8/JR7HzOuNvJpvjSBhq8tQ=; b=hZCP3xDZTNqI48fmY3A9vW/bs0oVHJ5u4WzGq+VUm1PPkMB6V8mnpc8EYI2oY6yb6BRvw7+tgrgB6EkG/7AJnWDmiYaXvU/bug6JA9UpuQuh5gsXhTdXQPm7lFHUj4nnqTBQ9iVt1XWP1jPXi9raebQ7JWhFK7aCA9rfSWK/D/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707226209135727.6652244504039; Tue, 6 Feb 2024 05:30:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXLWI-0000pz-Sk; Tue, 06 Feb 2024 08:29:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXLWB-0000aq-K8 for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:43 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXLW6-0008Ep-KX for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:43 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-33b2960ff60so366378f8f.1 for ; Tue, 06 Feb 2024 05:29:38 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a056000108700b0033b470a137esm1492932wrw.79.2024.02.06.05.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:29:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707226177; x=1707830977; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Ggn5L22e93CND5ondADlE8/JR7HzOuNvJpvjSBhq8tQ=; b=rxm77YxmxMkcZDT8LozJeTvxEtvrtKCUfne0AKELt6iaxq3T86ZzdtG249tNAYgTWO q3OOuHZWegfuvcdkm1znssvjZK8yHohTcLMG5u+uUvVhJoJEfzjySiCFPt+R7srWJ/sr sLsbyYtTdDM+C0E1rJM/f22qLHOynlXU+O8wpD7Oc5bUrCfw+Cw7QA1o5NDkDr8JMVLX jWSuQBdqgWxlm11RYoXX5IoA4i0BeJtgULHjsbzweDD7zMmB6i8M7lsIE24+31p1y9UK W6czsInM8TPTf7y9ofTVFzsBNIq24r5ebTmp5JMGeA7c/Jenr3AaN1uM0N/tU+IHtO5h pXCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226177; x=1707830977; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ggn5L22e93CND5ondADlE8/JR7HzOuNvJpvjSBhq8tQ=; b=BnIuMB99i/JJIczVBlTSXadm6bxk0aj4ZW1frxkf6OqEmOHs5IwjJsZgqz9f3l8RUE zMWhNIS+mTIk62d+HMJzTzrEiZMFXAGGbLkoKPGXx9+8A68iBKmFR/rjvdPrXaxrSrnM BZ0qrxUvswgkFe4U70aNfBcGJfPTvpn07AYlAc3tk/JwcBSds0VcufqTAGU41WfmChp1 qIbTNzohFDtMHi9et9KUmId0UIc7kWijjQxOUGFC5AkojB1d0YeV24wgwQ9T119M6wLQ yN75kU4MueTkIPu/o5s34JQn++KUbUdopKEMadkqSmSsBv2gWIcmm9T4qd3hJzSdrYXz SJaA== X-Gm-Message-State: AOJu0YxLCmVwGKCUxhMhj5apE7OHx44zw8m3+mjE6KUj4PpugLeZ+cTl Eb0oVgv3pChyX0bye7mMK0DI4YMwqpiiFiU2ilbDQpVlLS4bg9ZpXQWfH6qLCps= X-Google-Smtp-Source: AGHT+IHfxYlHj4qmQuzavbLMudZkxiF84JSJcd71A8mF1EyhovJ0S6SegfsxOvfFXwpY9yDGVZ2gmQ== X-Received: by 2002:a5d:6e49:0:b0:33a:fe4a:90be with SMTP id j9-20020a5d6e49000000b0033afe4a90bemr1198815wrz.23.1707226177019; Tue, 06 Feb 2024 05:29:37 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVcoOzlr159A7/0k0w6XzNZmMFBGgp+i9cBxTw2DeOzMC6hWnVfjAqBy2xbEjgoiWXfe5tVGFumjolDD8wlRSZwSJ0vlvM= From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 09/13] hw/arm/mps3r: Add CPUs, GIC, and per-CPU RAM Date: Tue, 6 Feb 2024 13:29:27 +0000 Message-Id: <20240206132931.38376-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206132931.38376-1-peter.maydell@linaro.org> References: <20240206132931.38376-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707226210590100007 Content-Type: text/plain; charset="utf-8" Create the CPUs, the GIC, and the per-CPU RAM block for the mps3-an536 board. Signed-off-by: Peter Maydell Reviewed-by: Alex Benn=C3=A9e --- Some parts of this might need to end up parameterisable if/when we add another machine type to this source file, but rather than trying to guess which parts, I stuck with the simple code for now. I thought about creating a "wrapper" device like our hw/cpu/a15mpcore.c etc for the Cortex-R52 and GIC, since in hardware the GIC is part of the CPU proper, not an external device. However given the need for some of the devices in this system to be per-CPU and have per-CPU interrupts, this seemed too awkward, so I have open coded the creation of the CPUs and GIC here. We can always consider refactoring later if we get another Cortex-R52 board. --- hw/arm/mps3r.c | 180 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 177 insertions(+), 3 deletions(-) diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c index 888a846d23c..6473f62d677 100644 --- a/hw/arm/mps3r.c +++ b/hw/arm/mps3r.c @@ -27,10 +27,14 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "qapi/error.h" +#include "qapi/qmp/qlist.h" #include "exec/address-spaces.h" #include "cpu.h" #include "hw/boards.h" +#include "hw/qdev-properties.h" #include "hw/arm/boot.h" +#include "hw/arm/bsa.h" +#include "hw/intc/arm_gicv3.h" =20 /* Define the layout of RAM and ROM in a board */ typedef struct RAMInfo { @@ -60,6 +64,10 @@ typedef struct RAMInfo { #define IS_ROM 2 =20 #define MPS3R_RAM_MAX 9 +#define MPS3R_CPU_MAX 2 + +#define PERIPHBASE 0xf0000000 +#define NUM_SPIS 96 =20 typedef enum MPS3RFPGAType { FPGA_AN536, @@ -69,11 +77,18 @@ struct MPS3RMachineClass { MachineClass parent; MPS3RFPGAType fpga_type; const RAMInfo *raminfo; + hwaddr loader_start; }; =20 struct MPS3RMachineState { MachineState parent; + struct arm_boot_info bootinfo; MemoryRegion ram[MPS3R_RAM_MAX]; + Object *cpu[MPS3R_CPU_MAX]; + MemoryRegion cpu_sysmem[MPS3R_CPU_MAX]; + MemoryRegion sysmem_alias[MPS3R_CPU_MAX]; + MemoryRegion cpu_ram[MPS3R_CPU_MAX]; + GICv3State gic; }; =20 #define TYPE_MPS3R_MACHINE "mps3r" @@ -163,6 +178,107 @@ static MemoryRegion *mr_for_raminfo(MPS3RMachineState= *mms, return ram; } =20 +/* + * There is no defined secondary boot protocol for Linux for the AN536, + * because real hardware has a restriction that atomic operations between + * the two CPUs do not function correctly, and so true SMP is not + * possible. Therefore for cases where the user is directly booting + * a kernel, we treat the system as essentially uniprocessor, and + * put the secondary CPU into power-off state (as if the user on the + * real hardware had configured the secondary to be halted via the + * SCC config registers). + * + * Note that the default secondary boot code would not work here anyway + * as it assumes a GICv2, and we have a GICv3. + */ +static void mps3r_write_secondary_boot(ARMCPU *cpu, + const struct arm_boot_info *info) +{ + /* + * Power the secondary CPU off. This means we don't need to write any + * boot code into guest memory. Note that the 'cpu' argument to this + * function is the primary CPU we passed to arm_load_kernel(), not + * the secondary. Loop around all the other CPUs, as the boot.c + * code does for the "disable secondaries if PSCI is enabled" case. + */ + for (CPUState *cs =3D first_cpu; cs; cs =3D CPU_NEXT(cs)) { + if (cs !=3D first_cpu) { + object_property_set_bool(OBJECT(cs), "start-powered-off", true, + &error_abort); + } + } +} + +static void mps3r_secondary_cpu_reset(ARMCPU *cpu, + const struct arm_boot_info *info) +{ + /* We don't need to do anything here because the CPU will be off */ +} + +static void create_gic(MPS3RMachineState *mms, MemoryRegion *sysmem) +{ + MachineState *machine =3D MACHINE(mms); + DeviceState *gicdev; + QList *redist_region_count; + + object_initialize_child(OBJECT(mms), "gic", &mms->gic, TYPE_ARM_GICV3); + gicdev =3D DEVICE(&mms->gic); + qdev_prop_set_uint32(gicdev, "num-cpu", machine->smp.cpus); + qdev_prop_set_uint32(gicdev, "num-irq", NUM_SPIS + GIC_INTERNAL); + redist_region_count =3D qlist_new(); + qlist_append_int(redist_region_count, machine->smp.cpus); + qdev_prop_set_array(gicdev, "redist-region-count", redist_region_count= ); + object_property_set_link(OBJECT(&mms->gic), "sysmem", + OBJECT(sysmem), &error_fatal); + sysbus_realize(SYS_BUS_DEVICE(&mms->gic), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->gic), 0, PERIPHBASE); + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->gic), 1, PERIPHBASE + 0x100000); + /* + * Wire the outputs from each CPU's generic timer and the GICv3 + * maintenance interrupt signal to the appropriate GIC PPI inputs, + * and the GIC's IRQ/FIQ/VIRQ/VFIQ interrupt outputs to the CPU's inpu= ts. + */ + for (int i =3D 0; i < machine->smp.cpus; i++) { + DeviceState *cpudev =3D DEVICE(mms->cpu[i]); + SysBusDevice *gicsbd =3D SYS_BUS_DEVICE(&mms->gic); + int intidbase =3D NUM_SPIS + i * GIC_INTERNAL; + int irq; + /* + * Mapping from the output timer irq lines from the CPU to the + * GIC PPI inputs used for this board. This isn't a BSA board, + * but it uses the standard convention for the PPI numbers. + */ + const int timer_irq[] =3D { + [GTIMER_PHYS] =3D ARCH_TIMER_NS_EL1_IRQ, + [GTIMER_VIRT] =3D ARCH_TIMER_VIRT_IRQ, + [GTIMER_HYP] =3D ARCH_TIMER_NS_EL2_IRQ, + }; + + for (irq =3D 0; irq < ARRAY_SIZE(timer_irq); irq++) { + qdev_connect_gpio_out(cpudev, irq, + qdev_get_gpio_in(gicdev, + intidbase + timer_irq[i= rq])); + } + + qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt",= 0, + qdev_get_gpio_in(gicdev, + intidbase + ARCH_GIC_= MAINT_IRQ)); + + qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, + qdev_get_gpio_in(gicdev, + intidbase + VIRTUAL_P= MU_IRQ)); + + sysbus_connect_irq(gicsbd, i, + qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); + sysbus_connect_irq(gicsbd, i + machine->smp.cpus, + qdev_get_gpio_in(cpudev, ARM_CPU_FIQ)); + sysbus_connect_irq(gicsbd, i + 2 * machine->smp.cpus, + qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ)); + sysbus_connect_irq(gicsbd, i + 3 * machine->smp.cpus, + qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ)); + } +} + static void mps3r_common_init(MachineState *machine) { MPS3RMachineState *mms =3D MPS3R_MACHINE(machine); @@ -173,6 +289,50 @@ static void mps3r_common_init(MachineState *machine) MemoryRegion *mr =3D mr_for_raminfo(mms, ri); memory_region_add_subregion(sysmem, ri->base, mr); } + + assert(machine->smp.cpus <=3D MPS3R_CPU_MAX); + for (int i =3D 0; i < machine->smp.cpus; i++) { + g_autofree char *sysmem_name =3D g_strdup_printf("cpu-%d-memory", = i); + g_autofree char *ramname =3D g_strdup_printf("cpu-%d-memory", i); + g_autofree char *alias_name =3D g_strdup_printf("sysmem-alias-%d",= i); + + /* + * Each CPU has some private RAM/peripherals, so create the contai= ner + * which will house those, with the whole-machine system memory be= ing + * used where there's no CPU-specific device. Note that we need the + * sysmem_alias aliases because we can't put one MR (the original + * 'sysmem') into more than one other MR. + */ + memory_region_init(&mms->cpu_sysmem[i], OBJECT(machine), + sysmem_name, UINT64_MAX); + memory_region_init_alias(&mms->sysmem_alias[i], OBJECT(machine), + alias_name, sysmem, 0, UINT64_MAX); + memory_region_add_subregion_overlap(&mms->cpu_sysmem[i], 0, + &mms->sysmem_alias[i], -1); + + mms->cpu[i] =3D object_new(machine->cpu_type); + object_property_set_link(mms->cpu[i], "memory", + OBJECT(&mms->cpu_sysmem[i]), &error_abort= ); + object_property_set_int(mms->cpu[i], "reset-cbar", + PERIPHBASE, &error_abort); + qdev_realize(DEVICE(mms->cpu[i]), NULL, &error_fatal); + object_unref(mms->cpu[i]); + + /* Per-CPU RAM */ + memory_region_init_ram(&mms->cpu_ram[i], NULL, ramname, + 0x1000, &error_fatal); + memory_region_add_subregion(&mms->cpu_sysmem[i], 0xe7c01000, + &mms->cpu_ram[i]); + } + + create_gic(mms, sysmem); + + mms->bootinfo.ram_size =3D machine->ram_size; + mms->bootinfo.board_id =3D -1; + mms->bootinfo.loader_start =3D mmc->loader_start; + mms->bootinfo.write_secondary_boot =3D mps3r_write_secondary_boot; + mms->bootinfo.secondary_cpu_reset_hook =3D mps3r_secondary_cpu_reset; + arm_load_kernel(ARM_CPU(mms->cpu[0]), machine, &mms->bootinfo); } =20 static void mps3r_set_default_ram_info(MPS3RMachineClass *mmc) @@ -189,6 +349,7 @@ static void mps3r_set_default_ram_info(MPS3RMachineClas= s *mmc) /* Found the entry for "system memory" */ mc->default_ram_size =3D p->size; mc->default_ram_id =3D p->name; + mmc->loader_start =3D p->base; return; } } @@ -212,9 +373,22 @@ static void mps3r_an536_class_init(ObjectClass *oc, vo= id *data) }; =20 mc->desc =3D "ARM MPS3 with AN536 FPGA image for Cortex-R52"; - mc->default_cpus =3D 2; - mc->min_cpus =3D mc->default_cpus; - mc->max_cpus =3D mc->default_cpus; + /* + * In the real FPGA image there are always two cores, but the standard + * initial setting for the SCC SYSCON 0x000 register is 0x21, meaning + * that the second core is held in reset and halted. Many images built= for + * the board do not expect the second core to run at startup (especial= ly + * since on the real FPGA image it is not possible to use LDREX/STREX + * in RAM between the two cores, so a true SMP setup isn't supported). + * + * As QEMU's equivalent of this, we support both -smp 1 and -smp 2, + * with the default being -smp 1. This seems a more intuitive UI for + * QEMU users than, for instance, having a machine property to allow + * the user to set the initial value of the SYSCON 0x000 register. + */ + mc->default_cpus =3D 1; + mc->min_cpus =3D 1; + mc->max_cpus =3D 2; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("cortex-r52"); mc->valid_cpu_types =3D valid_cpu_types; mmc->raminfo =3D an536_raminfo; --=20 2.34.1 From nobody Tue Nov 26 13:50:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707226216; cv=none; d=zohomail.com; s=zohoarc; b=GlaybpcQT+FRlVlyh9O9JYnGOVPgBPhG+jgXqXEifAFdkRER5jdvTLgJG2wt2fb+uU/sq3vJugZ0Kdmdo4/4tHToTQ2pTXU2vVm8t00lDSu4AaJnHcwcYRiN8oeG5WrmJ2yMNwL6m7m6tvhche5c5g8J5uEj46g1RKm+rOiGY48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707226216; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=5XT5gTePVGhArpbMUY8v3dsz4XmvJEYLLepyCneiHRk=; b=ZaqYuCefkRXcsf2V4WIcpnOJBdETQlVRU7sHuFyoA9S1OzHFTDmc6qYKkxAAmYozw6K+rKqJT0hC26wPFZ8X2aP1+I8Uzd5CJh4qaebU/nyPzHDTM5I9Ws85mkO7NeBrapoxKNsb0dWhrVP+qMiKDDcCgy0qKpzA7pnFajmx7sM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707226216441665.9319950000902; Tue, 6 Feb 2024 05:30:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXLWK-0000sW-L1; Tue, 06 Feb 2024 08:29:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXLWC-0000dw-KE for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:44 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXLW7-0008F9-71 for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:44 -0500 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-33b436dbdcfso897708f8f.0 for ; Tue, 06 Feb 2024 05:29:38 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a056000108700b0033b470a137esm1492932wrw.79.2024.02.06.05.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:29:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707226177; x=1707830977; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=5XT5gTePVGhArpbMUY8v3dsz4XmvJEYLLepyCneiHRk=; b=Xm8Qxh/HAgCYHmHukAtKTxk3L6WJeNtovf/i4L4hJABhKoUi1REx0jXB4umIFzJ6/c z701PhKKPfp7QwnYHknzuH3/LhfRVvyM89SlGK5pRYPp76DT1ddVasvnptbTQknjJ318 dU1SXr5sYIOKWQ+agXAP7rmkSRoXJbaF3YgRem/DlvZrX9gxqp99zfjWzHy6lgg2ZI+7 DcevcTx9zmXeKYSlSEPfe/0eJPn+gs3RvqeDX/8gl/U79/UFlbi7NL9tMCbYWG7g71Ks bu4oqCdc7Q/XD6SsvfxNAUlLPf0qcr5S+Q+kEiWCpEvKhDFAqxCfngu2GjAFwRrcYWmA 0o5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226177; x=1707830977; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5XT5gTePVGhArpbMUY8v3dsz4XmvJEYLLepyCneiHRk=; b=rhX2dlR1nd8F+sVYRCjdCfITSOFLPtpk4j6JyKooJY+eVd5l5e47UT9URsxHYvMJZw WJeG7Qbg2eNCSyf33Cm0V7lwyvv/J2zSTfDONK8UH/kgbk+1pMwphl4tHLQeagt70KD7 f2V8GJriUVS/asZ1MLdkZt88LKvR0ZAvsi4gHx+6NXtgb9YhLVryv4hYJR1I4icwgID9 J9TMp1Z4XulUpcyfDIAx12+cJ16O/kINcUdzdKcEDfUsfp/rirQzCs943W4XHcycFpe3 RVlOve22Bb71bcH3JxSFd++wazwtBl6R7tWYCGRHDJtiyi7jilWlAcq+3kw0oAM1TV6h sxXA== X-Gm-Message-State: AOJu0YxUqV8yApG1rlQZBgi6hyX9C3emD6gi/yZZKGmco3mXgjZrf5mt AKKrchJf8XI84VvEGdR6PYPsSjJ1oKTWsa+BsdK17QKnHzZRa8nWYtyravoKMg4= X-Google-Smtp-Source: AGHT+IFbiSZvdqzkNrs6PCO5Mchn7awx6OSPT62aXBOZFwJWptQcgHDwQjSk2nInRqswXJ8KewHt+A== X-Received: by 2002:a5d:6651:0:b0:33b:39d5:553d with SMTP id f17-20020a5d6651000000b0033b39d5553dmr1337901wrw.60.1707226177494; Tue, 06 Feb 2024 05:29:37 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUhuN0FGd60/tZRwXvh8516idoF3MMXupZ2fhNcekubd+ytoCVUh/KYzZ3fDCOWSBE6oUCSxBILPjKkra/tp4DJmse9Wek= From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 10/13] hw/arm/mps3r: Add UARTs Date: Tue, 6 Feb 2024 13:29:28 +0000 Message-Id: <20240206132931.38376-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206132931.38376-1-peter.maydell@linaro.org> References: <20240206132931.38376-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707226218651100003 Content-Type: text/plain; charset="utf-8" This board has a lot of UARTs: there is one UART per CPU in the per-CPU peripheral part of the address map, whose interrupts are connected as per-CPU interrupt lines. Then there are 4 UARTs in the normal part of the peripheral space, whose interrupts are shared peripheral interrupts. Connect and wire them all up; this involves some OR gates where multiple overflow interrupts are wired into one GIC input. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/mps3r.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c index 6473f62d677..8c790313790 100644 --- a/hw/arm/mps3r.c +++ b/hw/arm/mps3r.c @@ -30,10 +30,13 @@ #include "qapi/qmp/qlist.h" #include "exec/address-spaces.h" #include "cpu.h" +#include "sysemu/sysemu.h" #include "hw/boards.h" +#include "hw/or-irq.h" #include "hw/qdev-properties.h" #include "hw/arm/boot.h" #include "hw/arm/bsa.h" +#include "hw/char/cmsdk-apb-uart.h" #include "hw/intc/arm_gicv3.h" =20 /* Define the layout of RAM and ROM in a board */ @@ -65,6 +68,7 @@ typedef struct RAMInfo { =20 #define MPS3R_RAM_MAX 9 #define MPS3R_CPU_MAX 2 +#define MPS3R_UART_MAX 4 /* shared UART count */ =20 #define PERIPHBASE 0xf0000000 #define NUM_SPIS 96 @@ -89,6 +93,10 @@ struct MPS3RMachineState { MemoryRegion sysmem_alias[MPS3R_CPU_MAX]; MemoryRegion cpu_ram[MPS3R_CPU_MAX]; GICv3State gic; + /* per-CPU UARTs followed by the shared UARTs */ + CMSDKAPBUART uart[MPS3R_CPU_MAX + MPS3R_UART_MAX]; + OrIRQState cpu_uart_oflow[MPS3R_CPU_MAX]; + OrIRQState uart_oflow; }; =20 #define TYPE_MPS3R_MACHINE "mps3r" @@ -96,6 +104,13 @@ struct MPS3RMachineState { =20 OBJECT_DECLARE_TYPE(MPS3RMachineState, MPS3RMachineClass, MPS3R_MACHINE) =20 +/* + * Main clock frequency CLK in Hz (50MHz). In the image there are also + * ACLK, MCLK, GPUCLK and PERIPHCLK at the same frequency; for our + * model we just roll them all into one. + */ +#define CLK_FRQ 50000000 + static const RAMInfo an536_raminfo[] =3D { { .name =3D "ATCM", @@ -279,11 +294,40 @@ static void create_gic(MPS3RMachineState *mms, Memory= Region *sysmem) } } =20 +/* + * Create UART uartno, and map it into the MemoryRegion mem at address bas= eaddr. + * The qemu_irq arguments are where we connect the various IRQs from the U= ART. + */ +static void create_uart(MPS3RMachineState *mms, int uartno, MemoryRegion *= mem, + hwaddr baseaddr, qemu_irq txirq, qemu_irq rxirq, + qemu_irq txoverirq, qemu_irq rxoverirq, + qemu_irq combirq) +{ + g_autofree char *s =3D g_strdup_printf("uart%d", uartno); + SysBusDevice *sbd; + + assert(uartno < ARRAY_SIZE(mms->uart)); + object_initialize_child(OBJECT(mms), s, &mms->uart[uartno], + TYPE_CMSDK_APB_UART); + qdev_prop_set_uint32(DEVICE(&mms->uart[uartno]), "pclk-frq", CLK_FRQ); + qdev_prop_set_chr(DEVICE(&mms->uart[uartno]), "chardev", serial_hd(uar= tno)); + sbd =3D SYS_BUS_DEVICE(&mms->uart[uartno]); + sysbus_realize(sbd, &error_fatal); + memory_region_add_subregion(mem, baseaddr, + sysbus_mmio_get_region(sbd, 0)); + sysbus_connect_irq(sbd, 0, txirq); + sysbus_connect_irq(sbd, 1, rxirq); + sysbus_connect_irq(sbd, 2, txoverirq); + sysbus_connect_irq(sbd, 3, rxoverirq); + sysbus_connect_irq(sbd, 4, combirq); +} + static void mps3r_common_init(MachineState *machine) { MPS3RMachineState *mms =3D MPS3R_MACHINE(machine); MPS3RMachineClass *mmc =3D MPS3R_MACHINE_GET_CLASS(mms); MemoryRegion *sysmem =3D get_system_memory(); + DeviceState *gicdev; =20 for (const RAMInfo *ri =3D mmc->raminfo; ri->name; ri++) { MemoryRegion *mr =3D mr_for_raminfo(mms, ri); @@ -326,6 +370,56 @@ static void mps3r_common_init(MachineState *machine) } =20 create_gic(mms, sysmem); + gicdev =3D DEVICE(&mms->gic); + + /* + * UARTs 0 and 1 are per-CPU; their interrupts are wired to + * the relevant CPU's PPI 0..3, aka INTID 16..19 + */ + for (int i =3D 0; i < machine->smp.cpus; i++) { + int intidbase =3D NUM_SPIS + i * GIC_INTERNAL; + g_autofree char *s =3D g_strdup_printf("cpu-uart-oflow-orgate%d", = i); + DeviceState *orgate; + + /* The two overflow IRQs from the UART are ORed together into PPI = 3 */ + object_initialize_child(OBJECT(mms), s, &mms->cpu_uart_oflow[i], + TYPE_OR_IRQ); + orgate =3D DEVICE(&mms->cpu_uart_oflow[i]); + qdev_prop_set_uint32(orgate, "num-lines", 2); + qdev_realize(orgate, NULL, &error_fatal); + qdev_connect_gpio_out(orgate, 0, + qdev_get_gpio_in(gicdev, intidbase + 19)); + + create_uart(mms, i, &mms->cpu_sysmem[i], 0xe7c00000, + qdev_get_gpio_in(gicdev, intidbase + 17), /* tx */ + qdev_get_gpio_in(gicdev, intidbase + 16), /* rx */ + qdev_get_gpio_in(orgate, 0), /* txover */ + qdev_get_gpio_in(orgate, 1), /* rxover */ + qdev_get_gpio_in(gicdev, intidbase + 18) /* combined *= /); + } + /* + * UARTs 2 to 5 are whole-system; all overflow IRQs are ORed + * together into IRQ 17 + */ + object_initialize_child(OBJECT(mms), "uart-oflow-orgate", + &mms->uart_oflow, TYPE_OR_IRQ); + qdev_prop_set_uint32(DEVICE(&mms->uart_oflow), "num-lines", + MPS3R_UART_MAX * 2); + qdev_realize(DEVICE(&mms->uart_oflow), NULL, &error_fatal); + qdev_connect_gpio_out(DEVICE(&mms->uart_oflow), 0, + qdev_get_gpio_in(gicdev, 17)); + + for (int i =3D 0; i < MPS3R_UART_MAX; i++) { + hwaddr baseaddr =3D 0xe0205000 + i * 0x1000; + int rxirq =3D 5 + i * 2, txirq =3D 6 + i * 2, combirq =3D 13 + i; + + create_uart(mms, i + MPS3R_CPU_MAX, sysmem, baseaddr, + qdev_get_gpio_in(gicdev, txirq), + qdev_get_gpio_in(gicdev, rxirq), + qdev_get_gpio_in(DEVICE(&mms->uart_oflow), i * 2), + qdev_get_gpio_in(DEVICE(&mms->uart_oflow), i * 2 + 1), + qdev_get_gpio_in(gicdev, combirq)); + } =20 mms->bootinfo.ram_size =3D machine->ram_size; mms->bootinfo.board_id =3D -1; --=20 2.34.1 From nobody Tue Nov 26 13:50:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707226344; cv=none; d=zohomail.com; s=zohoarc; b=Fk0p0PS3NtoQqo25JIH1RxXWAPRGY5bxY9CfaFMaziRGDadMndZ6763I9XEYosQ11Ue9gqsd4xgvMXKx6gCx8+i/GAKA8Y9OeEYuoZZA2tsK1mRK8jGVxzP6xmyQBEmX40mWGtuFsPa4fBFq21bgkcOUIkfS+tI5Yjz0DFb7cp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707226344; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=J5yMl9ruByZ2cE+u8xokLZN5yHG5tcwG0U9htQdpN5s=; b=fFIqEoWL0Uky9xSg32Sexm5JHz9GIIl1ATSxMVtyaC+ynsCJdAozFwyr3E0m/JTocU3jR2H3UDI3H4WYe6dqjn823IcGJSLZo/1p3ysudvrFA+ZgjuFfofhGpn15ACD6SY+T7o7PiD4FkohyGZZjOzLxM9B94WscluCTVG07i2w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707226344137141.13267566374907; Tue, 6 Feb 2024 05:32:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXLWL-0000wt-Jz; Tue, 06 Feb 2024 08:29:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXLWC-0000eb-TX for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:44 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXLW7-0008Fa-92 for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:44 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-33b4b121de1so22089f8f.0 for ; Tue, 06 Feb 2024 05:29:38 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a056000108700b0033b470a137esm1492932wrw.79.2024.02.06.05.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:29:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707226178; x=1707830978; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=J5yMl9ruByZ2cE+u8xokLZN5yHG5tcwG0U9htQdpN5s=; b=C4jwr3tIuzk9Hwwqph03lWD6AOZ2oaIWffPAJIgdU4w3QiokXpr78aDkunZpiYA7+l FMZQ6RspLhjjsJBUM2kRSKZ+NgvVaJAYqYmemYEC39MdvKY0mFNsKkMCalxaNHsdeR36 v8sSsBol54JRttECsE3yyFPV5/6Iwo13y7HrbGRhW1tMZYLiecS6V6XkaOZKEOX1FTnI pTWPm3lFukf4kvVmZqCWlu3dHomci5A1qWcn8UX0VkwzrYGLne4LjBXhkvhd/cB6h1s4 6LxDKIO1UXoIgO8Bwgs52FkZbVha0UESX5SjZlamLnXH6hOeXOzqw7f2bdZwBnFGNMQq 7tsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226178; x=1707830978; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J5yMl9ruByZ2cE+u8xokLZN5yHG5tcwG0U9htQdpN5s=; b=BjZHT7k9BWfYX/wjFnkrVMA9rYQnpyMoMwUiCTlNohAaA9w3fTCSJ5B750mCEl9+VI Lg5E6kRGkoeL0Bki9LoIQ1et5b/hz7vQp7JW8HSjgh4AOtsqF/Ugy3h7V71a342XXwpq Ut6JDX/25QZh2nzoKCPfPWlP395pw4A63ZMXb3J0vf5Eed/gEZHzjk3NQ4s0X8lt0Ggg iGt4IEOLrJ5o3UxzwuJJtJHsUiacdJrSqb75sZM/aaEHSj4rf/8jLPTXP2FrU+tDW7Q2 8tViKpbLP1psgQUTZ8lWIrHA28r8QzJVlx4xvsdpDirv32BEGwz2B+2fEMmyy0bhXwld MOOw== X-Gm-Message-State: AOJu0YygHyacwK7OJnnwWCC1Qc0XDFesAaXHg1XH3yzzXGE6Z9EbFkIL qgcHzfDLrXHZnLb09VuuSxFPLkaByJmN3R6P/IKLFEUsJljvyCcsaF/dIjkRKM1/fdo/Cp845t/ 6 X-Google-Smtp-Source: AGHT+IGJvFe6XqFhA1xaBxWHBA9Ghh+clmTanKzRnQWuoyED9yHlze9foDMZt4bqJnLnA9CxxQlUVA== X-Received: by 2002:a5d:6149:0:b0:33b:3bad:d3ee with SMTP id y9-20020a5d6149000000b0033b3badd3eemr1086210wrt.43.1707226177904; Tue, 06 Feb 2024 05:29:37 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUm3OJ+YgXMLd6kJSMRIxqT4sbIwJIZMJrMnDjLXvXMlACoLZFW3VVz/n6UR6uveoXDeeEmUZtD2D6m5ViNreTKdhtzkc4= From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 11/13] hw/arm/mps3r: Add GPIO, watchdog, dual-timer, I2C devices Date: Tue, 6 Feb 2024 13:29:29 +0000 Message-Id: <20240206132931.38376-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206132931.38376-1-peter.maydell@linaro.org> References: <20240206132931.38376-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707226345299100004 Content-Type: text/plain; charset="utf-8" Add the GPIO, watchdog, dual-timer and I2C devices to the mps3-an536 board. These are all simple devices that just need to be created and wired up. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/mps3r.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c index 8c790313790..803ed0ffb5c 100644 --- a/hw/arm/mps3r.c +++ b/hw/arm/mps3r.c @@ -33,11 +33,16 @@ #include "sysemu/sysemu.h" #include "hw/boards.h" #include "hw/or-irq.h" +#include "hw/qdev-clock.h" #include "hw/qdev-properties.h" #include "hw/arm/boot.h" #include "hw/arm/bsa.h" #include "hw/char/cmsdk-apb-uart.h" +#include "hw/i2c/arm_sbcon_i2c.h" #include "hw/intc/arm_gicv3.h" +#include "hw/misc/unimp.h" +#include "hw/timer/cmsdk-apb-dualtimer.h" +#include "hw/watchdog/cmsdk-apb-watchdog.h" =20 /* Define the layout of RAM and ROM in a board */ typedef struct RAMInfo { @@ -97,6 +102,10 @@ struct MPS3RMachineState { CMSDKAPBUART uart[MPS3R_CPU_MAX + MPS3R_UART_MAX]; OrIRQState cpu_uart_oflow[MPS3R_CPU_MAX]; OrIRQState uart_oflow; + CMSDKAPBWatchdog watchdog; + CMSDKAPBDualTimer dualtimer; + ArmSbconI2CState i2c[5]; + Clock *clk; }; =20 #define TYPE_MPS3R_MACHINE "mps3r" @@ -329,6 +338,9 @@ static void mps3r_common_init(MachineState *machine) MemoryRegion *sysmem =3D get_system_memory(); DeviceState *gicdev; =20 + mms->clk =3D clock_new(OBJECT(machine), "CLK"); + clock_set_hz(mms->clk, CLK_FRQ); + for (const RAMInfo *ri =3D mmc->raminfo; ri->name; ri++) { MemoryRegion *mr =3D mr_for_raminfo(mms, ri); memory_region_add_subregion(sysmem, ri->base, mr); @@ -421,6 +433,53 @@ static void mps3r_common_init(MachineState *machine) qdev_get_gpio_in(gicdev, combirq)); } =20 + for (int i =3D 0; i < 4; i++) { + /* CMSDK GPIO controllers */ + g_autofree char *s =3D g_strdup_printf("gpio%d", i); + create_unimplemented_device(s, 0xe0000000 + i * 0x1000, 0x1000); + } + + object_initialize_child(OBJECT(mms), "watchdog", &mms->watchdog, + TYPE_CMSDK_APB_WATCHDOG); + qdev_connect_clock_in(DEVICE(&mms->watchdog), "WDOGCLK", mms->clk); + sysbus_realize(SYS_BUS_DEVICE(&mms->watchdog), &error_fatal); + sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0, + qdev_get_gpio_in(gicdev, 0)); + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->watchdog), 0, 0xe0100000); + + object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer, + TYPE_CMSDK_APB_DUALTIMER); + qdev_connect_clock_in(DEVICE(&mms->dualtimer), "TIMCLK", mms->clk); + sysbus_realize(SYS_BUS_DEVICE(&mms->dualtimer), &error_fatal); + sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0, + qdev_get_gpio_in(gicdev, 3)); + sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 1, + qdev_get_gpio_in(gicdev, 1)); + sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 2, + qdev_get_gpio_in(gicdev, 2)); + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->dualtimer), 0, 0xe0101000); + + for (int i =3D 0; i < ARRAY_SIZE(mms->i2c); i++) { + static const hwaddr i2cbase[] =3D {0xe0102000, /* Touch */ + 0xe0103000, /* Audio */ + 0xe0107000, /* Shield0 */ + 0xe0108000, /* Shield1 */ + 0xe0109000}; /* DDR4 EEPROM */ + g_autofree char *s =3D g_strdup_printf("i2c%d", i); + + object_initialize_child(OBJECT(mms), s, &mms->i2c[i], + TYPE_ARM_SBCON_I2C); + sysbus_realize(SYS_BUS_DEVICE(&mms->i2c[i]), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->i2c[i]), 0, i2cbase[i]); + if (i !=3D 2 && i !=3D 3) { + /* + * internal-only bus: mark it full to avoid user-created + * i2c devices being plugged into it. + */ + qbus_mark_full(qdev_get_child_bus(DEVICE(&mms->i2c[i]), "i2c")= ); + } + } + mms->bootinfo.ram_size =3D machine->ram_size; mms->bootinfo.board_id =3D -1; mms->bootinfo.loader_start =3D mmc->loader_start; --=20 2.34.1 From nobody Tue Nov 26 13:50:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707226275; cv=none; d=zohomail.com; s=zohoarc; b=FR65Vm3wLz0jdyQUXCsKSA0s3VGZ683jGAAsA7LNTfDrkQkfvwh2kANLI5aWzuR+yMZzQIycc3kJJwK1L+/ERDpNujvLXZtJ6NuUY8hMnadkPqJl5WES5v05VdJTm6ALNJjTSTG62UG/WYoifI71ZOAfCAMlzbFkmV2TiLN3jPY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707226275; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Wky0NbjSBXe8xyXxuk64LeUJZz8/Cho+tc6oZQXhuNY=; b=C4Y6pjrsCfABCvjgZbYfh47j4l1UTaL3cyG1Rycv00dFCRytKq1/l/hqvFsCYlHWkpB1/1szm/Y+q6yS7987vMEU3azxcg5MPgTLqbsDRxODIUuS9rlMBrW8oZZrNqEG5V2LFH9N1rHEQczrzSwT0JRQ4dynUdnAArytfR0+CDE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707226275129546.8402236302651; Tue, 6 Feb 2024 05:31:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXLWO-0000yt-Dj; Tue, 06 Feb 2024 08:29:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXLWD-0000g6-9g for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:45 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXLW7-0008Fl-Mz for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:45 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-33b4b121de1so22093f8f.0 for ; Tue, 06 Feb 2024 05:29:39 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a056000108700b0033b470a137esm1492932wrw.79.2024.02.06.05.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:29:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707226178; x=1707830978; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Wky0NbjSBXe8xyXxuk64LeUJZz8/Cho+tc6oZQXhuNY=; b=GHkJ8vqbDp1Ucoz2HI2+pnQj3iHs597OQab+9zoAQpO13JyR2+cXAvvFNmqjrslGxl O+S9KZdWcYvTbsCX9nmYSbkM5Bs32tAcjIc8cZ4qXesAENkLAbDcz3el7qSG6l6m3dYz /EOeaiWMsfdfigzTlDh1XAAgNoY3uhljuLLxviu6m+N2dD7+k8SX5RdmA5GacN9N39cT ETs8pUIV7FWx1anPQmhcyRxegkoNEJkKeD4IsCr7nUKeFBYjPr5Sxqr3JdrU1vD01NME b+BYJC/B0O0i2f2TQEtspvWsB3guJsCMdJ97lcrJKQEcbtTVL/6RKbO4ldNrTO4lM8x5 kVbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226178; x=1707830978; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wky0NbjSBXe8xyXxuk64LeUJZz8/Cho+tc6oZQXhuNY=; b=Gh876kzj9JkPabSfyjiUhFZSKyEt9iusSdL6PnquxOFFntgrZiIBuC+dINxl6az+x2 +K6sK4spUogepr4o7lMo2Rp4UEKLGCexQ0WNuPibMxMez/jhA3kpnj2TgPMFYdAKXyay JKCFyZfOqAbycCliIWOPvFO1Vl4uThfXoGKVgKn0Jp2zd26HfWUoLU/RXvTr0WGeQXIZ 08Vz95/oXp2rJwC95SlKXd6xb92iUUVHsMvw+wuvDrDxdmykHM9+b5t7Eeb9kbFhtVQP dELiLDn2os/bcyTYxbj5wlScQW2guqD2s+WGD/3IGXsXdvBtpc9CRYLAPa8O5GqKSljg 6JqA== X-Gm-Message-State: AOJu0YxgMXLJz64dF6ARZwDjm7pzK/T6pkJuyghxR5L+i7/rAWsvjuTy Z6IjNvPFxZ8NSERe5Xp9ptFeVy01r2iBaGquq9HDKUffw0kOC3MBiq0CT4OWYYWIQlTEE7ykwg9 6 X-Google-Smtp-Source: AGHT+IHyIKX9jYkSJiRdRK0ixVf7Z+PN+74KD1aYcK0qZdF0W3zX8C1Ytjl05pWmQ+7L5NsfHxiHww== X-Received: by 2002:adf:f342:0:b0:33b:14e8:c97d with SMTP id e2-20020adff342000000b0033b14e8c97dmr1292890wrp.48.1707226178334; Tue, 06 Feb 2024 05:29:38 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXzGhvixY55YakPdRc8p3LtYr7Re3CfE/LnM7LEwuZNB6sy5cK2+/E7yCfTDDHDpemc+J1Idw9U77+J92AQEpSnKWNIrd8= From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 12/13] hw/arm/mps3r: Add remaining devices Date: Tue, 6 Feb 2024 13:29:30 +0000 Message-Id: <20240206132931.38376-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206132931.38376-1-peter.maydell@linaro.org> References: <20240206132931.38376-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707226276896100007 Content-Type: text/plain; charset="utf-8" Add the remaining devices (or unimplemented-device stubs) for this board: SPI controllers, SCC, FPGAIO, I2S, RTC, the QSPI write-config block, and ethernet. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/mps3r.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c index 803ed0ffb5c..4d55a6564c6 100644 --- a/hw/arm/mps3r.c +++ b/hw/arm/mps3r.c @@ -40,7 +40,12 @@ #include "hw/char/cmsdk-apb-uart.h" #include "hw/i2c/arm_sbcon_i2c.h" #include "hw/intc/arm_gicv3.h" +#include "hw/misc/mps2-scc.h" +#include "hw/misc/mps2-fpgaio.h" #include "hw/misc/unimp.h" +#include "hw/net/lan9118.h" +#include "hw/rtc/pl031.h" +#include "hw/ssi/pl022.h" #include "hw/timer/cmsdk-apb-dualtimer.h" #include "hw/watchdog/cmsdk-apb-watchdog.h" =20 @@ -105,6 +110,11 @@ struct MPS3RMachineState { CMSDKAPBWatchdog watchdog; CMSDKAPBDualTimer dualtimer; ArmSbconI2CState i2c[5]; + PL022State spi[3]; + MPS2SCC scc; + MPS2FPGAIO fpgaio; + UnimplementedDeviceState i2s_audio; + PL031State rtc; Clock *clk; }; =20 @@ -178,6 +188,16 @@ static const RAMInfo an536_raminfo[] =3D { } }; =20 +static const int an536_oscclk[] =3D { + 24000000, /* 24MHz reference for RTC and timers */ + 50000000, /* 50MHz ACLK */ + 50000000, /* 50MHz MCLK */ + 50000000, /* 50MHz GPUCLK */ + 24576000, /* 24.576MHz AUDCLK */ + 23750000, /* 23.75MHz HDLCDCLK */ + 100000000, /* 100MHz DDR4_REF_CLK */ +}; + static MemoryRegion *mr_for_raminfo(MPS3RMachineState *mms, const RAMInfo *raminfo) { @@ -337,6 +357,7 @@ static void mps3r_common_init(MachineState *machine) MPS3RMachineClass *mmc =3D MPS3R_MACHINE_GET_CLASS(mms); MemoryRegion *sysmem =3D get_system_memory(); DeviceState *gicdev; + QList *oscclk; =20 mms->clk =3D clock_new(OBJECT(machine), "CLK"); clock_set_hz(mms->clk, CLK_FRQ); @@ -480,6 +501,59 @@ static void mps3r_common_init(MachineState *machine) } } =20 + for (int i =3D 0; i < ARRAY_SIZE(mms->spi); i++) { + g_autofree char *s =3D g_strdup_printf("spi%d", i); + hwaddr baseaddr =3D 0xe0104000 + i * 0x1000; + + object_initialize_child(OBJECT(mms), s, &mms->spi[i], TYPE_PL022); + sysbus_realize(SYS_BUS_DEVICE(&mms->spi[i]), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->spi[i]), 0, baseaddr); + sysbus_connect_irq(SYS_BUS_DEVICE(&mms->spi[i]), 0, + qdev_get_gpio_in(gicdev, 22 + i)); + } + + object_initialize_child(OBJECT(mms), "scc", &mms->scc, TYPE_MPS2_SCC); + qdev_prop_set_uint32(DEVICE(&mms->scc), "scc-cfg0", 0); + qdev_prop_set_uint32(DEVICE(&mms->scc), "scc-cfg4", 0x2); + qdev_prop_set_uint32(DEVICE(&mms->scc), "scc-aid", 0x00200008); + qdev_prop_set_uint32(DEVICE(&mms->scc), "scc-id", 0x41055360); + oscclk =3D qlist_new(); + for (int i =3D 0; i < ARRAY_SIZE(an536_oscclk); i++) { + qlist_append_int(oscclk, an536_oscclk[i]); + } + qdev_prop_set_array(DEVICE(&mms->scc), "oscclk", oscclk); + sysbus_realize(SYS_BUS_DEVICE(&mms->scc), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->scc), 0, 0xe0200000); + + create_unimplemented_device("i2s-audio", 0xe0201000, 0x1000); + + object_initialize_child(OBJECT(mms), "fpgaio", &mms->fpgaio, + TYPE_MPS2_FPGAIO); + qdev_prop_set_uint32(DEVICE(&mms->fpgaio), "prescale-clk", an536_osccl= k[1]); + qdev_prop_set_uint32(DEVICE(&mms->fpgaio), "num-leds", 10); + qdev_prop_set_bit(DEVICE(&mms->fpgaio), "has-switches", true); + qdev_prop_set_bit(DEVICE(&mms->fpgaio), "has-dbgctrl", false); + sysbus_realize(SYS_BUS_DEVICE(&mms->fpgaio), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->fpgaio), 0, 0xe0202000); + + create_unimplemented_device("clcd", 0xe0209000, 0x1000); + + object_initialize_child(OBJECT(mms), "rtc", &mms->rtc, TYPE_PL031); + sysbus_realize(SYS_BUS_DEVICE(&mms->rtc), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->rtc), 0, 0xe020a000); + sysbus_connect_irq(SYS_BUS_DEVICE(&mms->rtc), 0, + qdev_get_gpio_in(gicdev, 4)); + + /* + * In hardware this is a LAN9220; the LAN9118 is software compatible + * except that it doesn't support the checksum-offload feature. + */ + lan9118_init(0xe0300000, + qdev_get_gpio_in(gicdev, 18)); + + create_unimplemented_device("usb", 0xe0301000, 0x1000); + create_unimplemented_device("qspi-write-config", 0xe0600000, 0x1000); + mms->bootinfo.ram_size =3D machine->ram_size; mms->bootinfo.board_id =3D -1; mms->bootinfo.loader_start =3D mmc->loader_start; --=20 2.34.1 From nobody Tue Nov 26 13:50:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707226292; cv=none; d=zohomail.com; s=zohoarc; b=FbhXVS5ShhjavR22rI8d4FiHL8hht51sg8qzD/bvE7OIsJKhZg4pZvkBASv/DGRVT/dbSNfGN91Yia9kWULr7BSmiFtFU/8WAJs3sZI1u7nhg2b/usyJXvsfXwqDTs8AQzTYQ1Dhp/yyZmDRe0967xFB0XkyCuJRS7TT2hWJuZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707226292; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=i5+zyl23hVZuAKNLfLW8qwmlrpXibq7GbXzW+djyeAc=; b=fH04tyX+UPVgnxp6/dU+qeBEshQcolA8x2f377twSgyF+PCSCccu6DckmG596f/wPP6ASb6XD5D25W8yMG2WD7khbJmDMm4OvH7vKII+Gv9vJiJbsa/GR6+vbfzIKmwhun3FQ9raQWx8JGBUANO3QNWA4Ec9ThiWuZgCD+676Nw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707226292025579.6605093682206; Tue, 6 Feb 2024 05:31:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXLWJ-0000rA-KN; Tue, 06 Feb 2024 08:29:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXLWE-0000iQ-D0 for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:46 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXLW8-0008G2-4G for qemu-devel@nongnu.org; Tue, 06 Feb 2024 08:29:46 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-33aeb088324so4188339f8f.2 for ; Tue, 06 Feb 2024 05:29:39 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a056000108700b0033b470a137esm1492932wrw.79.2024.02.06.05.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 05:29:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707226179; x=1707830979; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=i5+zyl23hVZuAKNLfLW8qwmlrpXibq7GbXzW+djyeAc=; b=Wy8dvwnGA+5VjV6Wv+iaQcV03x9idvLGSikV0kCTYNIZt0KW4dAjwwXAbFYf2Rge+d 7sWIqwT5Y+WA2oRF573VqPxISh04iFFFza+WfVC/AT5ePT3xwxFaxXUkV0ZJ/h4AjEtA nzc+si36ZYBp8HDqqItibgVtM/GPXQTQeNkzedaclAyrx2RZ2WVctqcN4xRl74Qfqz/x bxbgOKNeMa9bqncz2R2fVruu5A093CuG2NJZf88o9r+FUQT3ZthbsokMhawdN+k+izcA ZtM6nSTFerdUVewf8Jwgq5Sd9Cm74QPCM0qrCH0PAy3ZK/5dyZtXi9RHUlYYcJCS1Ek7 mmWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707226179; x=1707830979; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i5+zyl23hVZuAKNLfLW8qwmlrpXibq7GbXzW+djyeAc=; b=e0ZXkxLQ5JqbbIs/ZQXIz4m8vXEjv9Z3FB0dTYKhI8rmJXZw5rOucD3yubpP5vt7w/ obMcwPM7vIG234VkgZf7BWs3Dj/LVGCVVF6JNpjTQhGXYb1+ZhDOu2ViQCxgbovZuanP dMdYxsHkp64Dkg9dZxBTJ2uBa5EnMj4Iq1q/CogMTaYFQt5ZXD9KuK6V3NS5vuUqccI/ ODJ7MTaMajHttWckVim2T7TlJXd/IUSDmmNEtLmpEoOWxOCPKoZDESUOy1Y/PoBTKlzw TWokKlwuKeyrv3R13+0pg0YbgHymHgelm9P+NLjLAuwf/uPeDXEue3tCmYPdpL9/0kmr 61Og== X-Gm-Message-State: AOJu0YwjpXtvS+dtFMwD635f8oQyksbVLpmkzLSHSRZSZHROcf11FkXu TXTfTuzi7R3Glrn/uvzQBJtz7DJVSLaods6CTSHKFhQP4Ls0kp2gYyGldh6e/rk= X-Google-Smtp-Source: AGHT+IEUNUKb00BcI1fnhcPPBrN7Qlo+KuxbtaxhIbMJgMr6QynFawMmCKhdfACAvv/j6RFNO/ejwg== X-Received: by 2002:a05:6000:1208:b0:33b:3ceb:99cf with SMTP id e8-20020a056000120800b0033b3ceb99cfmr1167924wrx.67.1707226178817; Tue, 06 Feb 2024 05:29:38 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWC4xecCLiqv1PUBtXswhEAx7qbwncmvQ70KK11G8lL00ywQnQzlU0WOfEqVkp9ASqU8Jo/BZ6hJbUfKnPvMK/LLtOboNM= From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 13/13] docs: Add documentation for the mps3-an536 board Date: Tue, 6 Feb 2024 13:29:31 +0000 Message-Id: <20240206132931.38376-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206132931.38376-1-peter.maydell@linaro.org> References: <20240206132931.38376-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, WEIRD_QUOTING=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707226292919100003 Content-Type: text/plain; charset="utf-8" Add documentation for the mps3-an536 board type. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/system/arm/mps2.rst | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/system/arm/mps2.rst b/docs/system/arm/mps2.rst index 8a75beb3a08..a305935cc49 100644 --- a/docs/system/arm/mps2.rst +++ b/docs/system/arm/mps2.rst @@ -1,7 +1,7 @@ -Arm MPS2 and MPS3 boards (``mps2-an385``, ``mps2-an386``, ``mps2-an500``, = ``mps2-an505``, ``mps2-an511``, ``mps2-an521``, ``mps3-an524``, ``mps3-an54= 7``) -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D +Arm MPS2 and MPS3 boards (``mps2-an385``, ``mps2-an386``, ``mps2-an500``, = ``mps2-an505``, ``mps2-an511``, ``mps2-an521``, ``mps3-an524``, ``mps3-an53= 6``, ``mps3-an547``) +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -These board models all use Arm M-profile CPUs. +These board models use Arm M-profile or R-profile CPUs. =20 The Arm MPS2, MPS2+ and MPS3 dev boards are FPGA based (the 2+ has a bigger FPGA but is otherwise the same as the 2; the 3 has a bigger @@ -13,6 +13,8 @@ FPGA image. =20 QEMU models the following FPGA images: =20 +FPGA images using M-profile CPUs: + ``mps2-an385`` Cortex-M3 as documented in Arm Application Note AN385 ``mps2-an386`` @@ -30,6 +32,11 @@ QEMU models the following FPGA images: ``mps3-an547`` Cortex-M55 on an MPS3, as documented in Arm Application Note AN547 =20 +FPGA images using R-profile CPUs: + +``mps3-an536`` + Dual Cortex-R52 on an MPS3, as documented in Arm Application Note AN536 + Differences between QEMU and real hardware: =20 - AN385/AN386 remapping of low 16K of memory to either ZBT SSRAM1 or to @@ -45,6 +52,30 @@ Differences between QEMU and real hardware: flash, but only as simple ROM, so attempting to rewrite the flash from the guest will fail - QEMU does not model the USB controller in MPS3 boards +- AN536 does not support runtime control of CPU reset and halt via + the SCC CFG_REG0 register. +- AN536 does not support enabling or disabling the flash and ATCM + interfaces via the SCC CFG_REG1 register. +- AN536 does not support setting of the initial vector table + base address via the SCC CFG_REG6 and CFG_REG7 register config, + and does not provide a mechanism for specifying these values at + startup, so all guest images must be built to start from TCM + (i.e. to expect the interrupt vector base at 0 from reset). +- AN536 defaults to only creating a single CPU; this is the equivalent + of the way the real FPGA image usually runs with the second Cortex-R52 + held in halt via the initial SCC CFG_REG0 register setting. You can + create the second CPU with ``-smp 2``; both CPUs will then start + execution immediately on startup. + +Note that for the AN536 the first UART is accessible only by +CPU0, and the second UART is accessible only by CPU1. The +first UART accessible shared between both CPUs is the third +UART. Guest software might therefore be built to use either +the first UART or the third UART; if you don't see any output +from the UART you are looking at, try one of the others. +(Even if the AN536 machine is started with a single CPU and so +no "CPU1-only UART", the UART numbering remains the same, +with the third UART being the first of the shared ones.) =20 Machine-specific options """""""""""""""""""""""" --=20 2.34.1