aboutsummaryrefslogtreecommitdiff
path: root/target/nios2
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2022-11-24 11:50:14 +0000
committerPeter Maydell <peter.maydell@linaro.org>2022-12-16 15:58:15 +0000
commit4245a71662648b804ccc19163f44f75d6e92dcad (patch)
tree344d43f294afba6d15b39ce556ae717f03ff455f /target/nios2
parentc08dfb7ae2bd1a5a22e452c8172a8131778fe77c (diff)
downloadqemu-4245a71662648b804ccc19163f44f75d6e92dcad.zip
qemu-4245a71662648b804ccc19163f44f75d6e92dcad.tar.gz
qemu-4245a71662648b804ccc19163f44f75d6e92dcad.tar.bz2
target/nios2: Convert to 3-phase reset
Convert the nios2 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> Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com> Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> Message-id: 20221124115023.2437291-12-peter.maydell@linaro.org
Diffstat (limited to 'target/nios2')
-rw-r--r--target/nios2/cpu.c12
-rw-r--r--target/nios2/cpu.h4
2 files changed, 10 insertions, 6 deletions
diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c
index 9a5351b..cff3082 100644
--- a/target/nios2/cpu.c
+++ b/target/nios2/cpu.c
@@ -57,14 +57,16 @@ static bool nios2_cpu_has_work(CPUState *cs)
return cs->interrupt_request & CPU_INTERRUPT_HARD;
}
-static void nios2_cpu_reset(DeviceState *dev)
+static void nios2_cpu_reset_hold(Object *obj)
{
- CPUState *cs = CPU(dev);
+ CPUState *cs = CPU(obj);
Nios2CPU *cpu = NIOS2_CPU(cs);
Nios2CPUClass *ncc = NIOS2_CPU_GET_CLASS(cpu);
CPUNios2State *env = &cpu->env;
- ncc->parent_reset(dev);
+ if (ncc->parent_phases.hold) {
+ ncc->parent_phases.hold(obj);
+ }
memset(env->ctrl, 0, sizeof(env->ctrl));
env->pc = cpu->reset_addr;
@@ -371,11 +373,13 @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data)
DeviceClass *dc = DEVICE_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
Nios2CPUClass *ncc = NIOS2_CPU_CLASS(oc);
+ ResettableClass *rc = RESETTABLE_CLASS(oc);
device_class_set_parent_realize(dc, nios2_cpu_realizefn,
&ncc->parent_realize);
device_class_set_props(dc, nios2_properties);
- device_class_set_parent_reset(dc, nios2_cpu_reset, &ncc->parent_reset);
+ resettable_class_set_parent_phases(rc, NULL, nios2_cpu_reset_hold, NULL,
+ &ncc->parent_phases);
cc->class_by_name = nios2_cpu_class_by_name;
cc->has_work = nios2_cpu_has_work;
diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index f85581e..b1a5549 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -37,7 +37,7 @@ OBJECT_DECLARE_CPU_TYPE(Nios2CPU, Nios2CPUClass, NIOS2_CPU)
/**
* Nios2CPUClass:
- * @parent_reset: The parent class' reset handler.
+ * @parent_phases: The parent class' reset phase handlers.
*
* A Nios2 CPU model.
*/
@@ -47,7 +47,7 @@ struct Nios2CPUClass {
/*< public >*/
DeviceRealize parent_realize;
- DeviceReset parent_reset;
+ ResettablePhases parent_phases;
};
#define TARGET_HAS_ICE 1