Revision 73cfd29f hw/etraxfs_pic.c
b/hw/etraxfs_pic.c | ||
---|---|---|
118 | 118 |
{ |
119 | 119 |
} |
120 | 120 |
|
121 |
static void irq_handler(void *opaque, int irq, int level) |
|
122 |
{ |
|
123 |
struct fs_pic_state *fs = (void *)opaque; |
|
124 |
irq -= 1; |
|
125 |
fs->regs[R_R_VECT] &= ~(1 << irq); |
|
126 |
fs->regs[R_R_VECT] |= (!!level << irq); |
|
127 |
|
|
128 |
pic_update(fs); |
|
129 |
} |
|
130 |
|
|
131 | 121 |
static void nmi_handler(void *opaque, int irq, int level) |
132 | 122 |
{ |
133 | 123 |
struct fs_pic_state *fs = (void *)opaque; |
... | ... | |
146 | 136 |
cpu_reset_interrupt(env, CPU_INTERRUPT_NMI); |
147 | 137 |
} |
148 | 138 |
|
149 |
static void guru_handler(void *opaque, int irq, int level)
|
|
139 |
static void irq_handler(void *opaque, int irq, int level)
|
|
150 | 140 |
{ |
151 |
hw_error("%s unsupported exception\n", __func__); |
|
141 |
struct fs_pic_state *fs = (void *)opaque; |
|
142 |
|
|
143 |
if (irq >= 30) |
|
144 |
return nmi_handler(opaque, irq, level); |
|
145 |
|
|
146 |
irq -= 1; |
|
147 |
fs->regs[R_R_VECT] &= ~(1 << irq); |
|
148 |
fs->regs[R_R_VECT] |= (!!level << irq); |
|
149 |
pic_update(fs); |
|
152 | 150 |
} |
153 | 151 |
|
154 |
struct etraxfs_pic *etraxfs_pic_init(CPUState *env, target_phys_addr_t base)
|
|
152 |
qemu_irq *etraxfs_pic_init(CPUState *env, target_phys_addr_t base)
|
|
155 | 153 |
{ |
156 | 154 |
struct fs_pic_state *fs = NULL; |
157 |
struct etraxfs_pic *pic = NULL;
|
|
155 |
qemu_irq *irq;
|
|
158 | 156 |
int intr_vect_regs; |
159 | 157 |
|
160 |
pic = qemu_mallocz(sizeof *pic); |
|
161 |
pic->internal = fs = qemu_mallocz(sizeof *fs); |
|
162 |
|
|
158 |
fs = qemu_mallocz(sizeof *fs); |
|
163 | 159 |
fs->env = env; |
164 |
pic->irq = qemu_allocate_irqs(irq_handler, fs, 30); |
|
165 |
pic->nmi = qemu_allocate_irqs(nmi_handler, fs, 2); |
|
166 |
pic->guru = qemu_allocate_irqs(guru_handler, fs, 1); |
|
160 |
irq = qemu_allocate_irqs(irq_handler, fs, 32); |
|
167 | 161 |
|
168 | 162 |
intr_vect_regs = cpu_register_io_memory(0, pic_read, pic_write, fs); |
169 | 163 |
cpu_register_physical_memory(base, R_MAX * 4, intr_vect_regs); |
170 |
|
|
171 |
return pic; |
|
164 |
return irq; |
|
172 | 165 |
} |
Also available in: Unified diff