Message ID | 2fb531b99ce747e79d6496f67a6e42ce0312b406.1362387545.git.peter.crosthwaite@xilinx.com |
---|---|
State | New |
Headers | show |
On Mon, Mar 04, 2013 at 07:01:34PM +1000, Peter Crosthwaite wrote: > Set up the Device level halting API to halt cpus. This allows holders of a > pointer to the CPU to halt it from the TYPE_DEVICE abstraction. (i.e. they > can halt it even if they dont know its a CPU). > > Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> > --- > > qom/cpu.c | 16 ++++++++++++++++ > 1 files changed, 16 insertions(+), 0 deletions(-) > > diff --git a/qom/cpu.c b/qom/cpu.c > index e242dcb..00a07d9 100644 > --- a/qom/cpu.c > +++ b/qom/cpu.c > @@ -43,6 +43,20 @@ static void cpu_common_reset(CPUState *cpu) > cpu->halted = 0; > } > > +static void cpu_common_halt(DeviceState *dev) > +{ > + CPUState *s = CPU(dev); > + > + s->halted = 1; > +} > + > +static void cpu_common_unhalt(DeviceState *dev) > +{ > + CPUState *s = CPU(dev); > + > + s->halted = 0; > +} Hi, I might be wrong, but doesn't this also need to raise/lower CPU_INTERRUPT_HALT? (e.g if the CPU is i a tight tcg loop with interrupts disabled) Cheers, Edgar
diff --git a/qom/cpu.c b/qom/cpu.c index e242dcb..00a07d9 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -43,6 +43,20 @@ static void cpu_common_reset(CPUState *cpu) cpu->halted = 0; } +static void cpu_common_halt(DeviceState *dev) +{ + CPUState *s = CPU(dev); + + s->halted = 1; +} + +static void cpu_common_unhalt(DeviceState *dev) +{ + CPUState *s = CPU(dev); + + s->halted = 0; +} + ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model) { CPUClass *cc = CPU_CLASS(object_class_by_name(typename)); @@ -66,6 +80,8 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->class_by_name = cpu_common_class_by_name; k->reset = cpu_common_reset; + dc->halt = cpu_common_halt; + dc->unhalt = cpu_common_unhalt; dc->realize = cpu_common_realizefn; dc->no_user = 1; }
Set up the Device level halting API to halt cpus. This allows holders of a pointer to the CPU to halt it from the TYPE_DEVICE abstraction. (i.e. they can halt it even if they dont know its a CPU). Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> --- qom/cpu.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)