From patchwork Thu Nov 24 11:50:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 628328 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp302330pvb; Thu, 24 Nov 2022 04:01:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf7+SmHs2c0ST++n+lf/cdjaBeWpjbaYp9syec872A1amvfqXj0Je/f0BcdLzC4Cnkr4ydmP X-Received: by 2002:ac8:741a:0:b0:3a5:2932:3a77 with SMTP id p26-20020ac8741a000000b003a529323a77mr30841647qtq.591.1669291266950; Thu, 24 Nov 2022 04:01:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669291266; cv=none; d=google.com; s=arc-20160816; b=c9+yRcTgzICrkEapE8Ax7Tub9ADn4ydjfoN/BhWCxCyWSXHeGDwFeiNOBxB5X+TuRU gq46bx/tXy4M/MxwNWlFwvrQKmk02/qu5vhnV4t6MlkIG/KFeYR2ZLPKTtUwFuqVF7Qv fEmp6p7SOBGJU7Z8KSLVVM4aoW13IRA+jTnDglMR66lDNPcG2+hXqE7l0aSMq8Tv2UjC 7eB5GJBLcIsJNQUgmGemFsIlozhumIBKfuPuWJx9hnabqdkj16m+6B1uqC5CpT7Ax8GD fpIQwnyl3q8obbEErFISxHXgcw8UP+lRk8wq/qY9WTonQlUVVH7m4C4kqr9vBILXPIHZ M5CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+6WeqXETEAN/JcQ5LzZg6NwphS26sTdkAogbV0qOYE4=; b=Jl3N9xfzfDlO2n+BxTLbPg46gBAa9zxJnIVpVce8NeJ2Z1YI1CU/Z/H/V5bIjfcgtk rvaiBKLclh20ZosfpzQJ/n2qJSidJfAItEAoeZ2QO6Dapv64bdS9PgZLnQYTJeJ12eBm BnvJNg1jNqWdEuKzOSvugSR744doo5KgAkx283M7TPfNspTaIeH9dqNLyo1uT/3zaoZw Uuk3kwglA+RjF6X/mD1uWB1YNxmiHzsr9PMzzf2+AiBKEnBssliAPb51vMXw+3U0Kqo+ 9lkyVICvHROkS43wKHc6LMj5zwUdnGdhI+jBYmGFlD/A65ZHEUKfJO2EtYS8tOzxHkl4 x5mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rwRVagaB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d10-20020a05620a240a00b006fa20f8e705si707174qkn.715.2022.11.24.04.01.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Nov 2022 04:01:06 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rwRVagaB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oyAkr-0003p1-Fa; Thu, 24 Nov 2022 06:50:57 -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 1oyAkZ-0003WM-Ei for qemu-devel@nongnu.org; Thu, 24 Nov 2022 06:50:43 -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 1oyAkT-0004qq-Cy for qemu-devel@nongnu.org; Thu, 24 Nov 2022 06:50:39 -0500 Received: by mail-wm1-x331.google.com with SMTP id o7-20020a05600c510700b003cffc0b3374so1091382wms.0 for ; Thu, 24 Nov 2022 03:50:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+6WeqXETEAN/JcQ5LzZg6NwphS26sTdkAogbV0qOYE4=; b=rwRVagaBLVz6jP/hsd7gDhmw4fr2FJ9MF3b1SaUrsyVjHlkg8DvPxh0PziMvz+wiTF ifosIa4hC0XFMhEMA5bvvP7bnmsR+GLasGAuNSZgExMGe+OVn+ZQWMBESx1wg5Eesj4F z+VsVrEmtUu1XoLR+XqK5RvA71Z2eDyKzINZfWOjZAIbapFtl6HwxTDc4Vp+cA6LFH2M v4qxIScGBgKoBJKv1UVxng4R4uLmwRIy9t4xZJAVYh19GifXwhitqkvzwVEc4vX+8jTK b3XSlIDKFEaVBS4sCXcIFIzLuPRolC++6YCFSvbRcm9+Z7vdyGWQ6NJ308GXHvR6kIET PAhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+6WeqXETEAN/JcQ5LzZg6NwphS26sTdkAogbV0qOYE4=; b=28fJyDFclSY+kKdUIIOLQToKDi7nUKmRqdyabvkrVSHdOvvR/rRo85rIHRZqOJVQe5 4J6Sy3Dj7BsQutQDHN2qhUUe6VTjgS4mfvWDpk+6ASbnCFICbNYQumGuxSfy6+CCaFpE DNniQPJBMHn9TVo7s2YgK6FxId9VIH/a+rQKjte3LFR1Mc4qpWPh6FHVEWECSwB3h5/6 wMwUh6hv8WDcfMqoEK9verBPDqWmtFutPiMTy86pP1mfNIwHcxgJy6v1G3thOhK0Lw0W ABDHnh9wMDm1rISgmqFt0llYVqmJVNRNcOtTqNn07yAz08HlhZsHocDofU+l1iK0g4wD Grbg== X-Gm-Message-State: ANoB5plEAAxr/a0JLKnUrKRwR1ajh2jdH8z7kHF8WAK/65m0zYxSAI9+ LHLonUii8KjW9hYB86dVv5pdsGzQq84RqA== X-Received: by 2002:a1c:7c01:0:b0:3b3:3256:647 with SMTP id x1-20020a1c7c01000000b003b332560647mr9510555wmc.197.1669290630701; Thu, 24 Nov 2022 03:50:30 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f14-20020a05600c154e00b003c6f3e5ba42sm6212559wmg.46.2022.11.24.03.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 03:50:30 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Peter Maydell , Michael Rolnik , "Edgar E. Iglesias" , Taylor Simpson , Song Gao , Xiaojuan Yang , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo , Chris Wulff , Marek Vasut , Stafford Horne , Daniel Henrique Barboza , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , David Gibson , Greg Kurz , Palmer Dabbelt , Alistair Francis , Bin Meng , Yoshinori Sato , Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , Max Filippov , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH for-8.0 03/19] target/avr: Convert to 3-phase reset Date: Thu, 24 Nov 2022 11:50:06 +0000 Message-Id: <20221124115023.2437291-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124115023.2437291-1-peter.maydell@linaro.org> References: <20221124115023.2437291-1-peter.maydell@linaro.org> MIME-Version: 1.0 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_PASS=-0.001, T_SPF_HELO_TEMPERROR=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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Convert the avr CPU class to use 3-phase reset, so it doesn't need to use device_class_set_parent_reset() any more. Signed-off-by: Peter Maydell --- target/avr/cpu-qom.h | 4 ++-- target/avr/cpu.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/target/avr/cpu-qom.h b/target/avr/cpu-qom.h index b5c3507d6d7..01ea5f160b6 100644 --- a/target/avr/cpu-qom.h +++ b/target/avr/cpu-qom.h @@ -31,7 +31,7 @@ OBJECT_DECLARE_CPU_TYPE(AVRCPU, AVRCPUClass, AVR_CPU) /** * AVRCPUClass: * @parent_realize: The parent class' realize handler. - * @parent_reset: The parent class' reset handler. + * @parent_phases: The parent class' reset phase handlers. * * A AVR CPU model. */ @@ -40,7 +40,7 @@ struct AVRCPUClass { CPUClass parent_class; /*< public >*/ DeviceRealize parent_realize; - DeviceReset parent_reset; + ResettablePhases parent_phases; }; diff --git a/target/avr/cpu.c b/target/avr/cpu.c index c7295b488d1..d0139804b9f 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -67,14 +67,16 @@ static void avr_restore_state_to_opc(CPUState *cs, env->pc_w = data[0]; } -static void avr_cpu_reset(DeviceState *ds) +static void avr_cpu_reset_hold(Object *obj) { - CPUState *cs = CPU(ds); + CPUState *cs = CPU(obj); AVRCPU *cpu = AVR_CPU(cs); AVRCPUClass *mcc = AVR_CPU_GET_CLASS(cpu); CPUAVRState *env = &cpu->env; - mcc->parent_reset(ds); + if (mcc->parent_phases.hold) { + mcc->parent_phases.hold(obj); + } env->pc_w = 0; env->sregI = 1; @@ -223,9 +225,12 @@ static void avr_cpu_class_init(ObjectClass *oc, void *data) DeviceClass *dc = DEVICE_CLASS(oc); CPUClass *cc = CPU_CLASS(oc); AVRCPUClass *mcc = AVR_CPU_CLASS(oc); + ResettableClass *rc = RESETTABLE_CLASS(oc); device_class_set_parent_realize(dc, avr_cpu_realizefn, &mcc->parent_realize); - device_class_set_parent_reset(dc, avr_cpu_reset, &mcc->parent_reset); + + resettable_class_set_parent_phases(rc, NULL, avr_cpu_reset_hold, NULL, + &mcc->parent_phases); cc->class_by_name = avr_cpu_class_by_name;