diff options
author | Edgar E. Iglesias <edgar.iglesias@gmail.com> | 2009-05-16 00:23:15 +0200 |
---|---|---|
committer | Edgar E. Iglesias <edgar.iglesias@gmail.com> | 2009-05-16 02:13:08 +0200 |
commit | 73cfd29fb34568f926386c2f43811362f2c22154 (patch) | |
tree | 1c49809001b05a8871fb462e7e717163075d439d /hw/etraxfs_pic.c | |
parent | df84e4f34504ffc2d9daaa0238fcf67f3dbbf681 (diff) |
ETRAX: Simplify PIC interface.
Instead of exporting a custom structure to represent different
interrupt types, just export the irq array and have the top
elements point to the NMI lines.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Diffstat (limited to 'hw/etraxfs_pic.c')
-rw-r--r-- | hw/etraxfs_pic.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/hw/etraxfs_pic.c b/hw/etraxfs_pic.c index 49e991c718..622d655ac3 100644 --- a/hw/etraxfs_pic.c +++ b/hw/etraxfs_pic.c @@ -118,16 +118,6 @@ void irq_info(Monitor *mon) { } -static void irq_handler(void *opaque, int irq, int level) -{ - struct fs_pic_state *fs = (void *)opaque; - irq -= 1; - fs->regs[R_R_VECT] &= ~(1 << irq); - fs->regs[R_R_VECT] |= (!!level << irq); - - pic_update(fs); -} - static void nmi_handler(void *opaque, int irq, int level) { struct fs_pic_state *fs = (void *)opaque; @@ -146,27 +136,30 @@ static void nmi_handler(void *opaque, int irq, int level) cpu_reset_interrupt(env, CPU_INTERRUPT_NMI); } -static void guru_handler(void *opaque, int irq, int level) +static void irq_handler(void *opaque, int irq, int level) { - hw_error("%s unsupported exception\n", __func__); + struct fs_pic_state *fs = (void *)opaque; + + if (irq >= 30) + return nmi_handler(opaque, irq, level); + + irq -= 1; + fs->regs[R_R_VECT] &= ~(1 << irq); + fs->regs[R_R_VECT] |= (!!level << irq); + pic_update(fs); } -struct etraxfs_pic *etraxfs_pic_init(CPUState *env, target_phys_addr_t base) +qemu_irq *etraxfs_pic_init(CPUState *env, target_phys_addr_t base) { struct fs_pic_state *fs = NULL; - struct etraxfs_pic *pic = NULL; + qemu_irq *irq; int intr_vect_regs; - pic = qemu_mallocz(sizeof *pic); - pic->internal = fs = qemu_mallocz(sizeof *fs); - + fs = qemu_mallocz(sizeof *fs); fs->env = env; - pic->irq = qemu_allocate_irqs(irq_handler, fs, 30); - pic->nmi = qemu_allocate_irqs(nmi_handler, fs, 2); - pic->guru = qemu_allocate_irqs(guru_handler, fs, 1); + irq = qemu_allocate_irqs(irq_handler, fs, 32); intr_vect_regs = cpu_register_io_memory(0, pic_read, pic_write, fs); cpu_register_physical_memory(base, R_MAX * 4, intr_vect_regs); - - return pic; + return irq; } |