From patchwork Fri Dec 16 21:42:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 634443 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1076140pvb; Fri, 16 Dec 2022 14:03:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf5VlVsHeVnWSOJLdKOx9lRfzOCnmzmxNUg5L/smiAz+QDWGgu8swuXemZVzjspPlIr2v8cP X-Received: by 2002:a0c:aa9a:0:b0:4d7:45fb:f5ab with SMTP id f26-20020a0caa9a000000b004d745fbf5abmr36802554qvb.51.1671228195897; Fri, 16 Dec 2022 14:03:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671228195; cv=none; d=google.com; s=arc-20160816; b=mz+JDcLKPSnAsOWrnQSDr260wlIl6SOA5MjNbjSlZSFo0irOuBTZNu1EVjY8MwTEy9 M7NqDW19j+VTAruIPm2Qv6kOLNN4MfZPEAoi/RCNkfY5raTR7fzhKLS7xbirldqjWWEv EGPO9XECR9DGgsf7XzT3vUopXts2scBBBQuie/dVQtuZwgQrH2FyPudV2QLxPwqDVzqK LC13+wGFtvrmzW1CBA61bIjqrx6RhLtfwKS4XLWAhS383sal2RseUpOFtcs2GcZgVa/+ cVUNGALeXv5KTl/qrJc4Px0Yuo+0j4zLfgRlcXVbYQPQznivmuAf9NqpE+AjKgInx9g5 HSGg== 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:to:from :dkim-signature; bh=PZCvJDQbNUr26OElgPGYt8xyDSU+rXGhRrJxQ62tt6I=; b=KBVuIiGDPjpBC9AMeth+tvoViHx2bKG1c7Te9CDuwg1BbV/XeJutV1iGAHNafZk2mL mSOvpSlmdgQBNBj3fKtcUlG8VjBcn8Bh+pzcAc7haTX2cEhmV/7tV9Js9CXbkDGV6Z6P M8/L40PKmpzcOTumE8DDJOShHytSDB9lLmfDIwJU19pibIcgDIEgnQJ1ueVAscDGo9X4 3Oj+9j6Ba0LMjkamK3vn8w4Duu/UFFfU0SS0u7FfIFZqwkMSqBJrR9GCQ+oENxQUM/6C no521aWmjnjVrkVB7sQcFj/ywNYdvq0HxWorQJTeNTOap4PGeRsUD/0RR7Vo/EkRpCG1 uWog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YYoy1aO3; 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 iw8-20020a0562140f2800b004ad70cb5675si1642805qvb.393.2022.12.16.14.03.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Dec 2022 14:03:15 -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=YYoy1aO3; 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 1p6IU4-00061Q-9s; Fri, 16 Dec 2022 16:43:12 -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 1p6ITt-0005wl-WA for qemu-devel@nongnu.org; Fri, 16 Dec 2022 16:43:06 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p6ITs-0000eW-Dd for qemu-devel@nongnu.org; Fri, 16 Dec 2022 16:43:01 -0500 Received: by mail-wm1-x335.google.com with SMTP id o15so2731588wmr.4 for ; Fri, 16 Dec 2022 13:42:59 -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:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PZCvJDQbNUr26OElgPGYt8xyDSU+rXGhRrJxQ62tt6I=; b=YYoy1aO3+lYoJh64G7LrZ1tDNp8x8plOkrOQNOYbQDes7vVon9JENG5KNnXcZAAiCx HMB7H5RvVMRahEd05i2omeeWh6daUiF/QHDkS6NKFdBFLpA4z+RJS4eGtztqFetahV2A NTW6SrhgZNrwgFSKMRbmFtpV5zJiTYTl/lBts4mPnsKwZ+SdIhWYvCngYaj7DieSJs5P fZtkBVWat/jZBaSZSRCu1EtKB1mdP0p7nzWFdhv+lytBMZYHDEOij6yZFdKLeiV7V35G 9iAI4qhgIWJBjE8mnwZxcnbJu4M+hRFD48vsHAliymr30BO+Ly21Sx7cgzXume0VM8jg veYg== 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:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PZCvJDQbNUr26OElgPGYt8xyDSU+rXGhRrJxQ62tt6I=; b=1pEM7DM6xqGTjRrotcuqX7n4KtUiYxo/ee/SbdsvOju9lQL09eBZ10vWWcV/Swzcj0 EEZRi5PwZGlyWS7SEOlBK+i7a9+Ux8mnqIjdavVtGaAGByWTKftwiqOJWP0MPlzNc0nq jVKdWQiLmR0vCi8TYj7nxQ0Se5FBGOTBrCnKPWy01THC3zocO/gmTAFiE8SUfUmHNKr0 SEhQvDQ/XjhasBmLb+raATWg//gljTg4y1p9X+7dhBBjgtGcG8Wh60MUxL1DQ1Ln5IZK Yvr1cdR5HRsspisHJQXC7liIBRZ1Qb4ln0Xn5su93WD2XXTcHNmty+q8P4wso2sU/SZv +Smw== X-Gm-Message-State: ANoB5plbhX23i+yHNCpKwZHLHKA1Jxv+WKZQoWw2dyeMzF8Z0sptGTpn mmDIwJ1Oc38u8xQbOCifaL2VQ9gdpZlv8iXY X-Received: by 2002:a05:600c:3c95:b0:3cf:e7c8:494 with SMTP id bg21-20020a05600c3c9500b003cfe7c80494mr26547301wmb.29.1671226978353; Fri, 16 Dec 2022 13:42:58 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y7-20020a05600c364700b003d33ab317dasm4135263wmq.14.2022.12.16.13.42.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 13:42:57 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/36] target/avr: Convert to 3-phase reset Date: Fri, 16 Dec 2022 21:42:21 +0000 Message-Id: <20221216214244.1391647-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221216214244.1391647-1-peter.maydell@linaro.org> References: <20221216214244.1391647-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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 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+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 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Cédric Le Goater Message-id: 20221124115023.2437291-4-peter.maydell@linaro.org --- 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;