* [Qemu-devel] [5601] Halt the CPU using a qemu_irq
@ 2008-11-02 10:51 Blue Swirl
2008-11-02 12:12 ` Paul Brook
0 siblings, 1 reply; 3+ messages in thread
From: Blue Swirl @ 2008-11-02 10:51 UTC (permalink / raw)
To: qemu-devel
Revision: 5601
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5601
Author: blueswir1
Date: 2008-11-02 10:51:05 +0000 (Sun, 02 Nov 2008)
Log Message:
-----------
Halt the CPU using a qemu_irq
Modified Paths:
--------------
trunk/hw/slavio_misc.c
trunk/hw/sun4m.c
trunk/hw/sun4m.h
Modified: trunk/hw/slavio_misc.c
===================================================================
--- trunk/hw/slavio_misc.c 2008-11-02 08:23:14 UTC (rev 5600)
+++ trunk/hw/slavio_misc.c 2008-11-02 10:51:05 UTC (rev 5601)
@@ -50,7 +50,7 @@
uint8_t diag, mctrl;
uint32_t sysctrl;
uint16_t leds;
- CPUState *env;
+ qemu_irq cpu_halt;
qemu_irq fdc_tc;
} MiscState;
@@ -256,7 +256,7 @@
MiscState *s = opaque;
MISC_DPRINTF("Write power management %2.2x\n", val & 0xff);
- cpu_interrupt(s->env, CPU_INTERRUPT_HALT);
+ qemu_irq_raise(s->cpu_halt);
}
static uint32_t apc_mem_readb(void *opaque, target_phys_addr_t addr)
@@ -417,7 +417,7 @@
void *slavio_misc_init(target_phys_addr_t base, target_phys_addr_t power_base,
target_phys_addr_t aux1_base,
target_phys_addr_t aux2_base, qemu_irq irq,
- CPUState *env, qemu_irq **fdc_tc)
+ qemu_irq cpu_halt, qemu_irq **fdc_tc)
{
int io;
MiscState *s;
@@ -471,7 +471,7 @@
}
s->irq = irq;
- s->env = env;
+ s->cpu_halt = cpu_halt;
*fdc_tc = &s->fdc_tc;
register_savevm("slavio_misc", base, 1, slavio_misc_save, slavio_misc_load,
Modified: trunk/hw/sun4m.c
===================================================================
--- trunk/hw/sun4m.c 2008-11-02 08:23:14 UTC (rev 5600)
+++ trunk/hw/sun4m.c 2008-11-02 10:51:05 UTC (rev 5601)
@@ -360,6 +360,12 @@
env->halted = 1;
}
+static void cpu_halt_signal(void *opaque, int irq, int level)
+{
+ if (level && cpu_single_env)
+ cpu_interrupt(cpu_single_env, CPU_INTERRUPT_HALT);
+}
+
static unsigned long sun4m_load_kernel(const char *kernel_filename,
const char *initrd_filename,
ram_addr_t RAM_size)
@@ -426,6 +432,7 @@
*espdma_irq, *ledma_irq;
qemu_irq *esp_reset, *le_reset;
qemu_irq *fdc_tc;
+ qemu_irq *cpu_halt;
unsigned long prom_offset, kernel_size;
int ret;
char buf[1024];
@@ -547,9 +554,10 @@
slavio_serial_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq],
serial_hds[1], serial_hds[0]);
+ cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1);
slavio_misc = slavio_misc_init(hwdef->slavio_base, hwdef->apc_base,
hwdef->aux1_base, hwdef->aux2_base,
- slavio_irq[hwdef->me_irq], envs[0],
+ slavio_irq[hwdef->me_irq], cpu_halt[0],
&fdc_tc);
if (hwdef->fd_base != (target_phys_addr_t)-1) {
@@ -1575,7 +1583,7 @@
serial_hds[1], serial_hds[0]);
slavio_misc = slavio_misc_init(0, -1, hwdef->aux1_base, -1,
- slavio_irq[hwdef->me_irq], env, &fdc_tc);
+ slavio_irq[hwdef->me_irq], NULL, &fdc_tc);
if (hwdef->fd_base != (target_phys_addr_t)-1) {
/* there is zero or one floppy drive */
Modified: trunk/hw/sun4m.h
===================================================================
--- trunk/hw/sun4m.h 2008-11-02 08:23:14 UTC (rev 5600)
+++ trunk/hw/sun4m.h 2008-11-02 10:51:05 UTC (rev 5601)
@@ -58,7 +58,7 @@
void *slavio_misc_init(target_phys_addr_t base, target_phys_addr_t power_base,
target_phys_addr_t aux1_base,
target_phys_addr_t aux2_base, qemu_irq irq,
- CPUState *env, qemu_irq **fdc_tc);
+ qemu_irq cpu_halt, qemu_irq **fdc_tc);
void slavio_set_power_fail(void *opaque, int power_failing);
/* cs4231.c */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [5601] Halt the CPU using a qemu_irq
2008-11-02 10:51 [Qemu-devel] [5601] Halt the CPU using a qemu_irq Blue Swirl
@ 2008-11-02 12:12 ` Paul Brook
2008-11-02 12:23 ` Blue Swirl
0 siblings, 1 reply; 3+ messages in thread
From: Paul Brook @ 2008-11-02 12:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Blue Swirl
> +static void cpu_halt_signal(void *opaque, int irq, int level)
> +{
> + if (level && cpu_single_env)
> + cpu_interrupt(cpu_single_env, CPU_INTERRUPT_HALT);
> +}
>...
> + cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1);
Will this DTRT for SMP, or should we be including cpu_env as an argument to
cpu_halt_signal? Relying on cpu_single_env being set in an IRQ handler seems
kinda sketchy.
Paul
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [5601] Halt the CPU using a qemu_irq
2008-11-02 12:12 ` Paul Brook
@ 2008-11-02 12:23 ` Blue Swirl
0 siblings, 0 replies; 3+ messages in thread
From: Blue Swirl @ 2008-11-02 12:23 UTC (permalink / raw)
To: Paul Brook; +Cc: qemu-devel
On 11/2/08, Paul Brook <paul@codesourcery.com> wrote:
> > +static void cpu_halt_signal(void *opaque, int irq, int level)
> > +{
> > + if (level && cpu_single_env)
> > + cpu_interrupt(cpu_single_env, CPU_INTERRUPT_HALT);
> > +}
>
> >...
>
> > + cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1);
>
>
> Will this DTRT for SMP, or should we be including cpu_env as an argument to
> cpu_halt_signal? Relying on cpu_single_env being set in an IRQ handler seems
> kinda sketchy.
I actually had a version like that too, so that the first CPU was
halted like before. We could also halt all CPUs. But then I decided to
use cpu_single_env, because then the currently executing CPU that
touches the register will be halted. Given that Linux does not halt
the CPU when in SMP mode (arch/sparc/kernel/process.c) it's difficult
to say which way is correct. I don't have docs for the APC and PMC
chips used.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-11-02 12:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-02 10:51 [Qemu-devel] [5601] Halt the CPU using a qemu_irq Blue Swirl
2008-11-02 12:12 ` Paul Brook
2008-11-02 12:23 ` Blue Swirl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).