Skip to content

Commit

Permalink
target/xtensa: Convert to 3-phase reset
Browse files Browse the repository at this point in the history
Convert the xtensa 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 <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: Edgar E. Iglesias <[email protected]>
Reviewed-by: Taylor Simpson <[email protected]>
Reviewed-by: Greg Kurz <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Message-id: [email protected]
  • Loading branch information
pm215 committed Dec 16, 2022
1 parent efcc106 commit d66e64d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions target/xtensa/cpu-qom.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ typedef struct XtensaConfig XtensaConfig;
/**
* XtensaCPUClass:
* @parent_realize: The parent class' realize handler.
* @parent_reset: The parent class' reset handler.
* @parent_phases: The parent class' reset phase handlers.
* @config: The CPU core configuration.
*
* An Xtensa CPU model.
Expand All @@ -52,7 +52,7 @@ struct XtensaCPUClass {
/*< public >*/

DeviceRealize parent_realize;
DeviceReset parent_reset;
ResettablePhases parent_phases;

const XtensaConfig *config;
};
Expand Down
12 changes: 8 additions & 4 deletions target/xtensa/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,18 @@ bool xtensa_abi_call0(void)
}
#endif

static void xtensa_cpu_reset(DeviceState *dev)
static void xtensa_cpu_reset_hold(Object *obj)
{
CPUState *s = CPU(dev);
CPUState *s = CPU(obj);
XtensaCPU *cpu = XTENSA_CPU(s);
XtensaCPUClass *xcc = XTENSA_CPU_GET_CLASS(cpu);
CPUXtensaState *env = &cpu->env;
bool dfpu = xtensa_option_enabled(env->config,
XTENSA_OPTION_DFP_COPROCESSOR);

xcc->parent_reset(dev);
if (xcc->parent_phases.hold) {
xcc->parent_phases.hold(obj);
}

env->pc = env->config->exception_vector[EXC_RESET0 + env->static_vectors];
env->sregs[LITBASE] &= ~1;
Expand Down Expand Up @@ -240,11 +242,13 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data)
DeviceClass *dc = DEVICE_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
XtensaCPUClass *xcc = XTENSA_CPU_CLASS(cc);
ResettableClass *rc = RESETTABLE_CLASS(oc);

device_class_set_parent_realize(dc, xtensa_cpu_realizefn,
&xcc->parent_realize);

device_class_set_parent_reset(dc, xtensa_cpu_reset, &xcc->parent_reset);
resettable_class_set_parent_phases(rc, NULL, xtensa_cpu_reset_hold, NULL,
&xcc->parent_phases);

cc->class_by_name = xtensa_cpu_class_by_name;
cc->has_work = xtensa_cpu_has_work;
Expand Down

0 comments on commit d66e64d

Please sign in to comment.