Revision 5ef98b47 hw/etraxfs_pic.c
b/hw/etraxfs_pic.c | ||
---|---|---|
24 | 24 |
|
25 | 25 |
#include <stdio.h> |
26 | 26 |
#include "hw.h" |
27 |
#include "etraxfs.h" |
|
27 | 28 |
|
28 | 29 |
#define D(x) |
29 | 30 |
|
... | ... | |
143 | 144 |
{ |
144 | 145 |
} |
145 | 146 |
|
146 |
static void etraxfs_pic_handler(void *opaque, int irq, int level)
|
|
147 |
static void irq_handler(void *opaque, int irq, int level)
|
|
147 | 148 |
{ |
148 | 149 |
struct fs_pic_state_t *fs = (void *)opaque; |
149 | 150 |
CPUState *env = fs->env; |
... | ... | |
187 | 188 |
} |
188 | 189 |
} |
189 | 190 |
|
190 |
qemu_irq *etraxfs_pic_init(CPUState *env, target_phys_addr_t base) |
|
191 |
static void nmi_handler(void *opaque, int irq, int level) |
|
192 |
{ |
|
193 |
struct fs_pic_state_t *fs = (void *)opaque; |
|
194 |
CPUState *env = fs->env; |
|
195 |
uint32_t mask; |
|
196 |
|
|
197 |
mask = 1 << irq; |
|
198 |
if (level) |
|
199 |
fs->r_nmi |= mask; |
|
200 |
else |
|
201 |
fs->r_nmi &= ~mask; |
|
202 |
|
|
203 |
if (fs->r_nmi) |
|
204 |
cpu_interrupt(env, CPU_INTERRUPT_NMI); |
|
205 |
else |
|
206 |
cpu_reset_interrupt(env, CPU_INTERRUPT_NMI); |
|
207 |
} |
|
208 |
|
|
209 |
static void guru_handler(void *opaque, int irq, int level) |
|
210 |
{ |
|
211 |
struct fs_pic_state_t *fs = (void *)opaque; |
|
212 |
CPUState *env = fs->env; |
|
213 |
cpu_abort(env, "%s unsupported exception\n", __func__); |
|
214 |
|
|
215 |
} |
|
216 |
|
|
217 |
|
|
218 |
struct etraxfs_pic *etraxfs_pic_init(CPUState *env, target_phys_addr_t base) |
|
191 | 219 |
{ |
192 |
struct fs_pic_state_t *fs; |
|
193 |
qemu_irq *pic;
|
|
220 |
struct fs_pic_state_t *fs = NULL;
|
|
221 |
struct etraxfs_pic *pic = NULL;
|
|
194 | 222 |
int intr_vect_regs; |
195 | 223 |
|
196 |
fs = qemu_mallocz(sizeof *fs);
|
|
197 |
if (!fs)
|
|
198 |
return NULL;
|
|
199 |
fs->env = env;
|
|
224 |
pic = qemu_mallocz(sizeof *pic);
|
|
225 |
pic->internal = fs = qemu_mallocz(sizeof *fs);
|
|
226 |
if (!fs || !pic)
|
|
227 |
goto err;
|
|
200 | 228 |
|
201 |
pic = qemu_allocate_irqs(etraxfs_pic_handler, fs, 30); |
|
229 |
fs->env = env; |
|
230 |
pic->irq = qemu_allocate_irqs(irq_handler, fs, 30); |
|
231 |
pic->nmi = qemu_allocate_irqs(nmi_handler, fs, 2); |
|
232 |
pic->guru = qemu_allocate_irqs(guru_handler, fs, 1); |
|
202 | 233 |
|
203 | 234 |
intr_vect_regs = cpu_register_io_memory(0, pic_read, pic_write, fs); |
204 | 235 |
cpu_register_physical_memory(base, 0x14, intr_vect_regs); |
205 | 236 |
fs->base = base; |
206 | 237 |
|
207 | 238 |
return pic; |
239 |
err: |
|
240 |
free(pic); |
|
241 |
free(fs); |
|
242 |
return NULL; |
|
208 | 243 |
} |
Also available in: Unified diff