aboutsummaryrefslogtreecommitdiff
path: root/target/avr
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2022-11-24 11:50:06 +0000
committerPeter Maydell <peter.maydell@linaro.org>2022-12-16 15:58:15 +0000
commit605787606eb24918b266a71319143430974db2de (patch)
treee02143e066a36247815854eef85636328629e98e /target/avr
parent9130cade5fc22d11eb05493737439918f501b752 (diff)
downloadqemu-605787606eb24918b266a71319143430974db2de.zip
qemu-605787606eb24918b266a71319143430974db2de.tar.gz
qemu-605787606eb24918b266a71319143430974db2de.tar.bz2
target/avr: Convert to 3-phase reset
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 <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Cédric Le Goater <clg@kaod.org> Message-id: 20221124115023.2437291-4-peter.maydell@linaro.org
Diffstat (limited to 'target/avr')
-rw-r--r--target/avr/cpu-qom.h4
-rw-r--r--target/avr/cpu.c13
2 files changed, 11 insertions, 6 deletions
diff --git a/target/avr/cpu-qom.h b/target/avr/cpu-qom.h
index b5c3507..01ea5f1 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 c7295b4..d013980 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;