Commit d537cf6c8624b27ce2b63431d2f8937f6356f652

Authored by pbrook
1 parent b6e27ab8

Unify IRQ handling.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2635 c046a42c-6fe2-441c-8c8c-71466251a162
Makefile.target
... ... @@ -360,6 +360,7 @@ VL_OBJS=vl.o osdep.o readline.o monitor.o pci.o console.o loader.o isa_mmio.o
360 360 VL_OBJS+=cutils.o
361 361 VL_OBJS+=block.o block-raw.o
362 362 VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o
  363 +VL_OBJS+=irq.o
363 364 ifdef CONFIG_WIN32
364 365 VL_OBJS+=tap-win32.o
365 366 endif
... ...
hw/acpi.c
... ... @@ -92,7 +92,7 @@ static void pm_update_sci(PIIX4PMState *s)
92 92 pmsts = get_pmsts(s);
93 93 sci_level = (((pmsts & s->pmen) &
94 94 (RTC_EN | PWRBTN_EN | GBL_EN | TMROF_EN)) != 0);
95   - pci_set_irq(&s->dev, 0, sci_level);
  95 + qemu_set_irq(s->dev.irq[0], sci_level);
96 96 /* schedule a timer interruption if needed */
97 97 if ((s->pmen & TMROF_EN) && !(pmsts & TMROF_EN)) {
98 98 expire_time = muldiv64(s->tmr_overflow_time, ticks_per_sec, PM_FREQ);
... ...
hw/adlib.c
... ... @@ -267,7 +267,7 @@ static void Adlib_fini (AdlibState *s)
267 267 AUD_remove_card (&s->card);
268 268 }
269 269  
270   -int Adlib_init (AudioState *audio)
  270 +int Adlib_init (AudioState *audio, qemu_irq *pic)
271 271 {
272 272 AdlibState *s = &glob_adlib;
273 273 audsettings_t as;
... ...
hw/apb_pci.c
... ... @@ -200,14 +200,14 @@ static int pci_pbm_map_irq(PCIDevice *pci_dev, int irq_num)
200 200 return bus_offset + irq_num;
201 201 }
202 202  
203   -static void pci_apb_set_irq(void *pic, int irq_num, int level)
  203 +static void pci_apb_set_irq(qemu_irq *pic, int irq_num, int level)
204 204 {
205 205 /* PCI IRQ map onto the first 32 INO. */
206   - pic_set_irq_new(pic, irq_num, level);
  206 + qemu_set_irq(pic[irq_num], level);
207 207 }
208 208  
209 209 PCIBus *pci_apb_init(target_ulong special_base, target_ulong mem_base,
210   - void *pic)
  210 + qemu_irq *pic)
211 211 {
212 212 APBState *s;
213 213 PCIDevice *d;
... ...
hw/arm_gic.c
... ... @@ -60,10 +60,8 @@ typedef struct gic_irq_state
60 60  
61 61 typedef struct gic_state
62 62 {
63   - arm_pic_handler handler;
64 63 uint32_t base;
65   - void *parent;
66   - int parent_irq;
  64 + qemu_irq parent_irq;
67 65 int enabled;
68 66 int cpu_enabled;
69 67  
... ... @@ -88,7 +86,7 @@ static void gic_update(gic_state *s)
88 86  
89 87 s->current_pending = 1023;
90 88 if (!s->enabled || !s->cpu_enabled) {
91   - pic_set_irq_new(s->parent, s->parent_irq, 0);
  89 + qemu_irq_lower(s->parent_irq);
92 90 return;
93 91 }
94 92 best_prio = 0x100;
... ... @@ -102,12 +100,12 @@ static void gic_update(gic_state *s)
102 100 }
103 101 }
104 102 if (best_prio > s->priority_mask) {
105   - pic_set_irq_new(s->parent, s->parent_irq, 0);
  103 + qemu_irq_lower(s->parent_irq);
106 104 } else {
107 105 s->current_pending = best_irq;
108 106 if (best_prio < s->running_priority) {
109 107 DPRINTF("Raised pending IRQ %d\n", best_irq);
110   - pic_set_irq_new(s->parent, s->parent_irq, 1);
  108 + qemu_irq_raise(s->parent_irq);
111 109 }
112 110 }
113 111 }
... ... @@ -150,7 +148,7 @@ static uint32_t gic_acknowledge_irq(gic_state *s)
150 148 DPRINTF("ACK no pending IRQ\n");
151 149 return 1023;
152 150 }
153   - pic_set_irq_new(s->parent, s->parent_irq, 0);
  151 + qemu_irq_lower(s->parent_irq);
154 152 s->last_active[new_irq] = s->running_irq;
155 153 /* For level triggered interrupts we clear the pending bit while
156 154 the interrupt is active. */
... ... @@ -520,16 +518,16 @@ static void gic_reset(gic_state *s)
520 518 s->cpu_enabled = 0;
521 519 }
522 520  
523   -void *arm_gic_init(uint32_t base, void *parent, int parent_irq)
  521 +qemu_irq *arm_gic_init(uint32_t base, qemu_irq parent_irq)
524 522 {
525 523 gic_state *s;
  524 + qemu_irq *qi;
526 525 int iomemtype;
527 526  
528 527 s = (gic_state *)qemu_mallocz(sizeof(gic_state));
529 528 if (!s)
530 529 return NULL;
531   - s->handler = gic_set_irq;
532   - s->parent = parent;
  530 + qi = qemu_allocate_irqs(gic_set_irq, s, GIC_NIRQ);
533 531 s->parent_irq = parent_irq;
534 532 if (base != 0xffffffff) {
535 533 iomemtype = cpu_register_io_memory(0, gic_cpu_readfn,
... ... @@ -543,5 +541,5 @@ void *arm_gic_init(uint32_t base, void *parent, int parent_irq)
543 541 s->base = 0;
544 542 }
545 543 gic_reset(s);
546   - return s;
  544 + return qi;
547 545 }
... ...
hw/arm_pic.c
... ... @@ -11,11 +11,6 @@
11 11 #include "arm_pic.h"
12 12  
13 13 /* Stub functions for hardware that doesn't exist. */
14   -void pic_set_irq(int irq, int level)
15   -{
16   - cpu_abort(cpu_single_env, "pic_set_irq");
17   -}
18   -
19 14 void pic_info(void)
20 15 {
21 16 }
... ... @@ -25,49 +20,29 @@ void irq_info(void)
25 20 }
26 21  
27 22  
28   -void pic_set_irq_new(void *opaque, int irq, int level)
29   -{
30   - arm_pic_handler *p = (arm_pic_handler *)opaque;
31   - /* Call the real handler. */
32   - (*p)(opaque, irq, level);
33   -}
34   -
35   -/* Model the IRQ/FIQ CPU interrupt lines as a two input interrupt controller.
36   - Input 0 is IRQ and input 1 is FIQ. */
37   -typedef struct
38   -{
39   - arm_pic_handler handler;
40   - CPUState *cpu_env;
41   -} arm_pic_cpu_state;
42   -
  23 +/* Input 0 is IRQ and input 1 is FIQ. */
43 24 static void arm_pic_cpu_handler(void *opaque, int irq, int level)
44 25 {
45   - arm_pic_cpu_state *s = (arm_pic_cpu_state *)opaque;
  26 + CPUState *env = (CPUState *)opaque;
46 27 switch (irq) {
47 28 case ARM_PIC_CPU_IRQ:
48 29 if (level)
49   - cpu_interrupt(s->cpu_env, CPU_INTERRUPT_HARD);
  30 + cpu_interrupt(env, CPU_INTERRUPT_HARD);
50 31 else
51   - cpu_reset_interrupt(s->cpu_env, CPU_INTERRUPT_HARD);
  32 + cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
52 33 break;
53 34 case ARM_PIC_CPU_FIQ:
54 35 if (level)
55   - cpu_interrupt(s->cpu_env, CPU_INTERRUPT_FIQ);
  36 + cpu_interrupt(env, CPU_INTERRUPT_FIQ);
56 37 else
57   - cpu_reset_interrupt(s->cpu_env, CPU_INTERRUPT_FIQ);
  38 + cpu_reset_interrupt(env, CPU_INTERRUPT_FIQ);
58 39 break;
59 40 default:
60   - cpu_abort(s->cpu_env, "arm_pic_cpu_handler: Bad interrput line %d\n",
61   - irq);
  41 + cpu_abort(env, "arm_pic_cpu_handler: Bad interrput line %d\n", irq);
62 42 }
63 43 }
64 44  
65   -void *arm_pic_init_cpu(CPUState *env)
  45 +qemu_irq *arm_pic_init_cpu(CPUState *env)
66 46 {
67   - arm_pic_cpu_state *s;
68   -
69   - s = (arm_pic_cpu_state *)malloc(sizeof(arm_pic_cpu_state));
70   - s->handler = arm_pic_cpu_handler;
71   - s->cpu_env = env;
72   - return s;
  47 + return qemu_allocate_irqs(arm_pic_cpu_handler, env, 2);
73 48 }
... ...
hw/arm_pic.h
... ... @@ -14,14 +14,10 @@
14 14 #ifndef ARM_INTERRUPT_H
15 15 #define ARM_INTERRUPT_H 1
16 16  
17   -/* The first element of an individual PIC state structures should
18   - be a pointer to the handler routine. */
19   -typedef void (*arm_pic_handler)(void *opaque, int irq, int level);
20   -
21 17 /* The CPU is also modeled as an interrupt controller. */
22 18 #define ARM_PIC_CPU_IRQ 0
23 19 #define ARM_PIC_CPU_FIQ 1
24   -void *arm_pic_init_cpu(CPUState *env);
  20 +qemu_irq *arm_pic_init_cpu(CPUState *env);
25 21  
26 22 #endif /* !ARM_INTERRUPT_H */
27 23  
... ...
hw/arm_timer.c
... ... @@ -32,8 +32,7 @@ typedef struct {
32 32 int raw_freq;
33 33 int freq;
34 34 int int_level;
35   - void *pic;
36   - int irq;
  35 + qemu_irq irq;
37 36 } arm_timer_state;
38 37  
39 38 /* Calculate the new expiry time of the given timer. */
... ... @@ -85,9 +84,9 @@ static void arm_timer_update(arm_timer_state *s, int64_t now)
85 84 }
86 85 /* Update interrupts. */
87 86 if (s->int_level && (s->control & TIMER_CTRL_IE)) {
88   - pic_set_irq_new(s->pic, s->irq, 1);
  87 + qemu_irq_raise(s->irq);
89 88 } else {
90   - pic_set_irq_new(s->pic, s->irq, 0);
  89 + qemu_irq_lower(s->irq);
91 90 }
92 91  
93 92 next = now;
... ... @@ -215,12 +214,11 @@ static void arm_timer_tick(void *opaque)
215 214 arm_timer_update((arm_timer_state *)opaque, now);
216 215 }
217 216  
218   -static void *arm_timer_init(uint32_t freq, void *pic, int irq)
  217 +static void *arm_timer_init(uint32_t freq, qemu_irq irq)
219 218 {
220 219 arm_timer_state *s;
221 220  
222 221 s = (arm_timer_state *)qemu_mallocz(sizeof(arm_timer_state));
223   - s->pic = pic;
224 222 s->irq = irq;
225 223 s->raw_freq = s->freq = 1000000;
226 224 s->control = TIMER_CTRL_IE;
... ... @@ -237,22 +235,19 @@ static void *arm_timer_init(uint32_t freq, void *pic, int irq)
237 235 Integrator/CP timer modules. */
238 236  
239 237 typedef struct {
240   - /* Include a pseudo-PIC device to merge the two interrupt sources. */
241   - arm_pic_handler handler;
242 238 void *timer[2];
243 239 int level[2];
244 240 uint32_t base;
245   - /* The output PIC device. */
246   - void *pic;
247   - int irq;
  241 + qemu_irq irq;
248 242 } sp804_state;
249 243  
  244 +/* Merge the IRQs from the two component devices. */
250 245 static void sp804_set_irq(void *opaque, int irq, int level)
251 246 {
252 247 sp804_state *s = (sp804_state *)opaque;
253 248  
254 249 s->level[irq] = level;
255   - pic_set_irq_new(s->pic, s->irq, s->level[0] || s->level[1]);
  250 + qemu_set_irq(s->irq, s->level[0] || s->level[1]);
256 251 }
257 252  
258 253 static uint32_t sp804_read(void *opaque, target_phys_addr_t offset)
... ... @@ -293,20 +288,20 @@ static CPUWriteMemoryFunc *sp804_writefn[] = {
293 288 sp804_write
294 289 };
295 290  
296   -void sp804_init(uint32_t base, void *pic, int irq)
  291 +void sp804_init(uint32_t base, qemu_irq irq)
297 292 {
298 293 int iomemtype;
299 294 sp804_state *s;
  295 + qemu_irq *qi;
300 296  
301 297 s = (sp804_state *)qemu_mallocz(sizeof(sp804_state));
302   - s->handler = sp804_set_irq;
  298 + qi = qemu_allocate_irqs(sp804_set_irq, s, 2);
303 299 s->base = base;
304   - s->pic = pic;
305 300 s->irq = irq;
306 301 /* ??? The timers are actually configurable between 32kHz and 1MHz, but
307 302 we don't implement that. */
308   - s->timer[0] = arm_timer_init(1000000, s, 0);
309   - s->timer[1] = arm_timer_init(1000000, s, 1);
  303 + s->timer[0] = arm_timer_init(1000000, qi[0]);
  304 + s->timer[1] = arm_timer_init(1000000, qi[1]);
310 305 iomemtype = cpu_register_io_memory(0, sp804_readfn,
311 306 sp804_writefn, s);
312 307 cpu_register_physical_memory(base, 0x00000fff, iomemtype);
... ... @@ -362,7 +357,7 @@ static CPUWriteMemoryFunc *icp_pit_writefn[] = {
362 357 icp_pit_write
363 358 };
364 359  
365   -void icp_pit_init(uint32_t base, void *pic, int irq)
  360 +void icp_pit_init(uint32_t base, qemu_irq *pic, int irq)
366 361 {
367 362 int iomemtype;
368 363 icp_pit_state *s;
... ... @@ -370,10 +365,10 @@ void icp_pit_init(uint32_t base, void *pic, int irq)
370 365 s = (icp_pit_state *)qemu_mallocz(sizeof(icp_pit_state));
371 366 s->base = base;
372 367 /* Timer 0 runs at the system clock speed (40MHz). */
373   - s->timer[0] = arm_timer_init(40000000, pic, irq);
  368 + s->timer[0] = arm_timer_init(40000000, pic[irq]);
374 369 /* The other two timers run at 1MHz. */
375   - s->timer[1] = arm_timer_init(1000000, pic, irq + 1);
376   - s->timer[2] = arm_timer_init(1000000, pic, irq + 2);
  370 + s->timer[1] = arm_timer_init(1000000, pic[irq + 1]);
  371 + s->timer[2] = arm_timer_init(1000000, pic[irq + 2]);
377 372  
378 373 iomemtype = cpu_register_io_memory(0, icp_pit_readfn,
379 374 icp_pit_writefn, s);
... ...
hw/cs4231.c
... ... @@ -47,9 +47,6 @@ typedef struct CSState {
47 47 #ifdef DEBUG_CS
48 48 #define DPRINTF(fmt, args...) \
49 49 do { printf("CS: " fmt , ##args); } while (0)
50   -#define pic_set_irq_new(intctl, irq, level) \
51   - do { printf("CS: set_irq(%d): %d\n", (irq), (level)); \
52   - pic_set_irq_new((intctl), (irq),(level));} while (0)
53 50 #else
54 51 #define DPRINTF(fmt, args...)
55 52 #endif
... ...
hw/cuda.c
... ... @@ -124,9 +124,7 @@ typedef struct CUDAState {
124 124 int data_in_index;
125 125 int data_out_index;
126 126  
127   - SetIRQFunc *set_irq;
128   - int irq;
129   - void *irq_opaque;
  127 + qemu_irq irq;
130 128 uint8_t autopoll;
131 129 uint8_t data_in[128];
132 130 uint8_t data_out[16];
... ... @@ -145,9 +143,9 @@ static void cuda_timer_update(CUDAState *s, CUDATimer *ti,
145 143 static void cuda_update_irq(CUDAState *s)
146 144 {
147 145 if (s->ifr & s->ier & (SR_INT | T1_INT)) {
148   - s->set_irq(s->irq_opaque, s->irq, 1);
  146 + qemu_irq_raise(s->irq);
149 147 } else {
150   - s->set_irq(s->irq_opaque, s->irq, 0);
  148 + qemu_irq_lower(s->irq);
151 149 }
152 150 }
153 151  
... ... @@ -630,13 +628,11 @@ static CPUReadMemoryFunc *cuda_read[] = {
630 628 &cuda_readl,
631 629 };
632 630  
633   -int cuda_init(SetIRQFunc *set_irq, void *irq_opaque, int irq)
  631 +int cuda_init(qemu_irq irq)
634 632 {
635 633 CUDAState *s = &cuda_state;
636 634 int cuda_mem_index;
637 635  
638   - s->set_irq = set_irq;
639   - s->irq_opaque = irq_opaque;
640 636 s->irq = irq;
641 637  
642 638 s->timers[0].index = 0;
... ...
hw/eepro100.c
... ... @@ -326,7 +326,7 @@ static void disable_interrupt(EEPRO100State * s)
326 326 {
327 327 if (s->int_stat) {
328 328 logout("interrupt disabled\n");
329   - pci_set_irq(s->pci_dev, 0, 0);
  329 + qemu_irq_lower(s->pci_dev->irq[0]);
330 330 s->int_stat = 0;
331 331 }
332 332 }
... ... @@ -335,7 +335,7 @@ static void enable_interrupt(EEPRO100State * s)
335 335 {
336 336 if (!s->int_stat) {
337 337 logout("interrupt enabled\n");
338   - pci_set_irq(s->pci_dev, 0, 1);
  338 + qemu_irq_raise(s->pci_dev->irq[0]);
339 339 s->int_stat = 1;
340 340 }
341 341 }
... ...
hw/es1370.c
... ... @@ -324,7 +324,7 @@ static void es1370_update_status (ES1370State *s, uint32_t new_status)
324 324 else {
325 325 s->status = new_status & ~STAT_INTR;
326 326 }
327   - pci_set_irq (s->pci_dev, 0, !!level);
  327 + qemu_set_irq(s->pci_dev->irq[0], !!level);
328 328 }
329 329  
330 330 static void es1370_reset (ES1370State *s)
... ... @@ -350,7 +350,7 @@ static void es1370_reset (ES1370State *s)
350 350 s->dac_voice[i] = NULL;
351 351 }
352 352 }
353   - pci_set_irq (s->pci_dev, 0, 0);
  353 + qemu_irq_lower(s->pci_dev->irq[0]);
354 354 }
355 355  
356 356 static void es1370_maybe_lower_irq (ES1370State *s, uint32_t sctl)
... ...
hw/fdc.c
... ... @@ -368,7 +368,7 @@ struct fdctrl_t {
368 368 /* Controller's identification */
369 369 uint8_t version;
370 370 /* HW */
371   - int irq_lvl;
  371 + qemu_irq irq;
372 372 int dma_chann;
373 373 uint32_t io_base;
374 374 /* Controller state */
... ... @@ -485,7 +485,7 @@ static CPUWriteMemoryFunc *fdctrl_mem_write[3] = {
485 485 fdctrl_write_mem,
486 486 };
487 487  
488   -fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped,
  488 +fdctrl_t *fdctrl_init (qemu_irq irq, int dma_chann, int mem_mapped,
489 489 uint32_t io_base,
490 490 BlockDriverState **fds)
491 491 {
... ... @@ -501,7 +501,7 @@ fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped,
501 501 fdctrl_result_timer, fdctrl);
502 502  
503 503 fdctrl->version = 0x90; /* Intel 82078 controller */
504   - fdctrl->irq_lvl = irq_lvl;
  504 + fdctrl->irq = irq;
505 505 fdctrl->dma_chann = dma_chann;
506 506 fdctrl->io_base = io_base;
507 507 fdctrl->config = 0x60; /* Implicit seek, polling & FIFO enabled */
... ... @@ -542,7 +542,7 @@ int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num)
542 542 static void fdctrl_reset_irq (fdctrl_t *fdctrl)
543 543 {
544 544 FLOPPY_DPRINTF("Reset interrupt\n");
545   - pic_set_irq(fdctrl->irq_lvl, 0);
  545 + qemu_set_irq(fdctrl->irq, 0);
546 546 fdctrl->state &= ~FD_CTRL_INTR;
547 547 }
548 548  
... ... @@ -557,7 +557,7 @@ static void fdctrl_raise_irq (fdctrl_t *fdctrl, uint8_t status)
557 557 }
558 558 #endif
559 559 if (~(fdctrl->state & FD_CTRL_INTR)) {
560   - pic_set_irq(fdctrl->irq_lvl, 1);
  560 + qemu_set_irq(fdctrl->irq, 1);
561 561 fdctrl->state |= FD_CTRL_INTR;
562 562 }
563 563 FLOPPY_DPRINTF("Set interrupt status to 0x%02x\n", status);
... ...
hw/grackle_pci.c
... ... @@ -80,12 +80,12 @@ static int pci_grackle_map_irq(PCIDevice *pci_dev, int irq_num)
80 80 return (irq_num + (pci_dev->devfn >> 3)) & 3;
81 81 }
82 82  
83   -static void pci_grackle_set_irq(void *pic, int irq_num, int level)
  83 +static void pci_grackle_set_irq(qemu_irq *pic, int irq_num, int level)
84 84 {
85   - heathrow_pic_set_irq(pic, irq_num + 8, level);
  85 + qemu_set_irq(pic[irq_num + 8], level);
86 86 }
87 87  
88   -PCIBus *pci_grackle_init(uint32_t base, void *pic)
  88 +PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic)
89 89 {
90 90 GrackleState *s;
91 91 PCIDevice *d;
... ...
hw/gt64xxx.c
... ... @@ -520,7 +520,7 @@ static int pci_gt64120_map_irq(PCIDevice *pci_dev, int irq_num)
520 520 extern PCIDevice *piix4_dev;
521 521 static int pci_irq_levels[4];
522 522  
523   -static void pci_gt64120_set_irq(void *pic, int irq_num, int level)
  523 +static void pci_gt64120_set_irq(qemu_irq *pic, int irq_num, int level)
524 524 {
525 525 int i, pic_irq, pic_level;
526 526  
... ... @@ -537,7 +537,7 @@ static void pci_gt64120_set_irq(void *pic, int irq_num, int level)
537 537 if (pic_irq == piix4_dev->config[0x60 + i])
538 538 pic_level |= pci_irq_levels[i];
539 539 }
540   - pic_set_irq(pic_irq, pic_level);
  540 + qemu_set_irq(pic[pic_irq], pic_level);
541 541 }
542 542 }
543 543  
... ... @@ -608,7 +608,7 @@ void gt64120_reset(void *opaque)
608 608 gt64120_pci_mapping(s);
609 609 }
610 610  
611   -PCIBus *pci_gt64120_init(void *pic)
  611 +PCIBus *pci_gt64120_init(qemu_irq *pic)
612 612 {
613 613 GT64120State *s;
614 614 PCIDevice *d;
... ...
hw/heathrow_pic.c
... ... @@ -32,9 +32,9 @@ typedef struct HeathrowPIC {
32 32 uint32_t level_triggered;
33 33 } HeathrowPIC;
34 34  
35   -struct HeathrowPICS {
  35 +typedef struct HeathrowPICS {
36 36 HeathrowPIC pics[2];
37   -};
  37 +} HeathrowPICS;
38 38  
39 39 static inline int check_irq(HeathrowPIC *pic)
40 40 {
... ... @@ -130,7 +130,7 @@ static CPUReadMemoryFunc *pic_read[] = {
130 130 };
131 131  
132 132  
133   -void heathrow_pic_set_irq(void *opaque, int num, int level)
  133 +static void heathrow_pic_set_irq(void *opaque, int num, int level)
134 134 {
135 135 HeathrowPICS *s = opaque;
136 136 HeathrowPIC *pic;
... ... @@ -156,7 +156,7 @@ void heathrow_pic_set_irq(void *opaque, int num, int level)
156 156 heathrow_pic_update(s);
157 157 }
158 158  
159   -HeathrowPICS *heathrow_pic_init(int *pmem_index)
  159 +qemu_irq *heathrow_pic_init(int *pmem_index)
160 160 {
161 161 HeathrowPICS *s;
162 162  
... ... @@ -164,5 +164,5 @@ HeathrowPICS *heathrow_pic_init(int *pmem_index)
164 164 s->pics[0].level_triggered = 0;
165 165 s->pics[1].level_triggered = 0x1ff00000;
166 166 *pmem_index = cpu_register_io_memory(0, pic_read, pic_write, s);
167   - return s;
  167 + return qemu_allocate_irqs(heathrow_pic_set_irq, s, 64);
168 168 }
... ...
hw/i8254.c
... ... @@ -47,7 +47,7 @@ typedef struct PITChannelState {
47 47 /* irq handling */
48 48 int64_t next_transition_time;
49 49 QEMUTimer *irq_timer;
50   - int irq;
  50 + qemu_irq irq;
51 51 } PITChannelState;
52 52  
53 53 struct PITState {
... ... @@ -366,7 +366,7 @@ static void pit_irq_timer_update(PITChannelState *s, int64_t current_time)
366 366 return;
367 367 expire_time = pit_get_next_transition_time(s, current_time);
368 368 irq_level = pit_get_out1(s, current_time);
369   - pic_set_irq(s->irq, irq_level);
  369 + qemu_set_irq(s->irq, irq_level);
370 370 #ifdef DEBUG_PIT
371 371 printf("irq_level=%d next_delay=%f\n",
372 372 irq_level,
... ... @@ -460,7 +460,7 @@ static void pit_reset(void *opaque)
460 460 }
461 461 }
462 462  
463   -PITState *pit_init(int base, int irq)
  463 +PITState *pit_init(int base, qemu_irq irq)
464 464 {
465 465 PITState *pit = &pit_state;
466 466 PITChannelState *s;
... ...
hw/i8259.c
... ... @@ -54,7 +54,7 @@ struct PicState2 {
54 54 /* 0 is master pic, 1 is slave pic */
55 55 /* XXX: better separation between the two pics */
56 56 PicState pics[2];
57   - IRQRequestFunc *irq_request;
  57 + qemu_irq parent_irq;
58 58 void *irq_request_opaque;
59 59 /* IOAPIC callback support */
60 60 SetIRQFunc *alt_irq_func;
... ... @@ -160,13 +160,13 @@ void pic_update_irq(PicState2 *s)
160 160 }
161 161 printf("pic: cpu_interrupt\n");
162 162 #endif
163   - s->irq_request(s->irq_request_opaque, 1);
  163 + qemu_irq_raise(s->parent_irq);
164 164 }
165 165  
166 166 /* all targets should do this rather than acking the IRQ in the cpu */
167 167 #if defined(TARGET_MIPS)
168 168 else {
169   - s->irq_request(s->irq_request_opaque, 0);
  169 + qemu_irq_lower(s->parent_irq);
170 170 }
171 171 #endif
172 172 }
... ... @@ -175,14 +175,14 @@ void pic_update_irq(PicState2 *s)
175 175 int64_t irq_time[16];
176 176 #endif
177 177  
178   -void pic_set_irq_new(void *opaque, int irq, int level)
  178 +void i8259_set_irq(void *opaque, int irq, int level)
179 179 {
180 180 PicState2 *s = opaque;
181 181  
182 182 #if defined(DEBUG_PIC) || defined(DEBUG_IRQ_COUNT)
183 183 if (level != irq_level[irq]) {
184 184 #if defined(DEBUG_PIC)
185   - printf("pic_set_irq: irq=%d level=%d\n", irq, level);
  185 + printf("i8259_set_irq: irq=%d level=%d\n", irq, level);
186 186 #endif
187 187 irq_level[irq] = level;
188 188 #ifdef DEBUG_IRQ_COUNT
... ... @@ -203,12 +203,6 @@ void pic_set_irq_new(void *opaque, int irq, int level)
203 203 pic_update_irq(s);
204 204 }
205 205  
206   -/* obsolete function */
207   -void pic_set_irq(int irq, int level)
208   -{
209   - pic_set_irq_new(isa_pic, irq, level);
210   -}
211   -
212 206 /* acknowledge interrupt 'irq' */
213 207 static inline void pic_intack(PicState *s, int irq)
214 208 {
... ... @@ -297,7 +291,7 @@ static void pic_ioport_write(void *opaque, uint32_t addr, uint32_t val)
297 291 /* init */
298 292 pic_reset(s);
299 293 /* deassert a pending interrupt */
300   - s->pics_state->irq_request(s->pics_state->irq_request_opaque, 0);
  294 + qemu_irq_lower(s->pics_state->parent_irq);
301 295 s->init_state = 1;
302 296 s->init4 = val & 1;
303 297 s->single_mode = val & 2;
... ... @@ -546,9 +540,10 @@ void irq_info(void)
546 540 #endif
547 541 }
548 542  
549   -PicState2 *pic_init(IRQRequestFunc *irq_request, void *irq_request_opaque)
  543 +qemu_irq *i8259_init(qemu_irq parent_irq)
550 544 {
551 545 PicState2 *s;
  546 +
552 547 s = qemu_mallocz(sizeof(PicState2));
553 548 if (!s)
554 549 return NULL;
... ... @@ -556,11 +551,11 @@ PicState2 *pic_init(IRQRequestFunc *irq_request, void *irq_request_opaque)
556 551 pic_init1(0xa0, 0x4d1, &s->pics[1]);
557 552 s->pics[0].elcr_mask = 0xf8;
558 553 s->pics[1].elcr_mask = 0xde;
559   - s->irq_request = irq_request;
560   - s->irq_request_opaque = irq_request_opaque;
  554 + s->parent_irq = parent_irq;
561 555 s->pics[0].pics_state = s;
562 556 s->pics[1].pics_state = s;
563   - return s;
  557 + isa_pic = s;
  558 + return qemu_allocate_irqs(i8259_set_irq, s, 16);
564 559 }
565 560  
566 561 void pic_set_alt_irq_func(PicState2 *s, SetIRQFunc *alt_irq_func,
... ...
hw/ide.c
... ... @@ -300,9 +300,7 @@ typedef struct IDEState {
300 300 int mult_sectors;
301 301 int identify_set;
302 302 uint16_t identify_data[256];
303   - SetIRQFunc *set_irq;
304   - void *irq_opaque;
305   - int irq;
  303 + qemu_irq irq;
306 304 PCIDevice *pci_dev;
307 305 struct BMDMAState *bmdma;
308 306 int drive_serial;
... ... @@ -575,7 +573,7 @@ static inline void ide_set_irq(IDEState *s)
575 573 if (bm) {
576 574 bm->status |= BM_STATUS_INT;
577 575 }
578   - s->set_irq(s->irq_opaque, s->irq, 1);
  576 + qemu_irq_raise(s->irq);
579 577 }
580 578 }
581 579  
... ... @@ -1889,7 +1887,7 @@ static uint32_t ide_ioport_read(void *opaque, uint32_t addr1)
1889 1887 ret = 0;
1890 1888 else
1891 1889 ret = s->status;
1892   - s->set_irq(s->irq_opaque, s->irq, 0);
  1890 + qemu_irq_lower(s->irq);
1893 1891 break;
1894 1892 }
1895 1893 #ifdef DEBUG_IDE
... ... @@ -2084,7 +2082,7 @@ static int guess_disk_lchs(IDEState *s,
2084 2082  
2085 2083 static void ide_init2(IDEState *ide_state,
2086 2084 BlockDriverState *hd0, BlockDriverState *hd1,
2087   - SetIRQFunc *set_irq, void *irq_opaque, int irq)
  2085 + qemu_irq irq)
2088 2086 {
2089 2087 IDEState *s;
2090 2088 static int drive_serial = 1;
... ... @@ -2155,8 +2153,6 @@ static void ide_init2(IDEState *ide_state,
2155 2153 }
2156 2154 }
2157 2155 s->drive_serial = drive_serial++;
2158   - s->set_irq = set_irq;
2159   - s->irq_opaque = irq_opaque;
2160 2156 s->irq = irq;
2161 2157 s->sector_write_timer = qemu_new_timer(vm_clock,
2162 2158 ide_sector_write_timer_cb, s);
... ... @@ -2183,7 +2179,7 @@ static void ide_init_ioport(IDEState *ide_state, int iobase, int iobase2)
2183 2179 /***********************************************************/
2184 2180 /* ISA IDE definitions */
2185 2181  
2186   -void isa_ide_init(int iobase, int iobase2, int irq,
  2182 +void isa_ide_init(int iobase, int iobase2, qemu_irq irq,
2187 2183 BlockDriverState *hd0, BlockDriverState *hd1)
2188 2184 {
2189 2185 IDEState *ide_state;
... ... @@ -2192,7 +2188,7 @@ void isa_ide_init(int iobase, int iobase2, int irq,
2192 2188 if (!ide_state)
2193 2189 return;
2194 2190  
2195   - ide_init2(ide_state, hd0, hd1, pic_set_irq_new, isa_pic, irq);
  2191 + ide_init2(ide_state, hd0, hd1, irq);
2196 2192 ide_init_ioport(ide_state, iobase, iobase2);
2197 2193 }
2198 2194  
... ... @@ -2399,7 +2395,7 @@ static void cmd646_update_irq(PCIIDEState *d)
2399 2395 !(d->dev.config[MRDMODE] & MRDMODE_BLK_CH0)) ||
2400 2396 ((d->dev.config[MRDMODE] & MRDMODE_INTR_CH1) &&
2401 2397 !(d->dev.config[MRDMODE] & MRDMODE_BLK_CH1));
2402   - pci_set_irq((PCIDevice *)d, 0, pci_level);
  2398 + qemu_set_irq(d->dev.irq[0], pci_level);
2403 2399 }
2404 2400  
2405 2401 /* the PCI irq level is the logical OR of the two channels */
... ... @@ -2423,6 +2419,7 @@ void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table,
2423 2419 PCIIDEState *d;
2424 2420 uint8_t *pci_conf;
2425 2421 int i;
  2422 + qemu_irq *irq;
2426 2423  
2427 2424 d = (PCIIDEState *)pci_register_device(bus, "CMD646 IDE",
2428 2425 sizeof(PCIIDEState),
... ... @@ -2462,10 +2459,10 @@ void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table,
2462 2459  
2463 2460 for(i = 0; i < 4; i++)
2464 2461 d->ide_if[i].pci_dev = (PCIDevice *)d;
2465   - ide_init2(&d->ide_if[0], hd_table[0], hd_table[1],
2466   - cmd646_set_irq, d, 0);
2467   - ide_init2(&d->ide_if[2], hd_table[2], hd_table[3],
2468   - cmd646_set_irq, d, 1);
  2462 +
  2463 + irq = qemu_allocate_irqs(cmd646_set_irq, d, 2);
  2464 + ide_init2(&d->ide_if[0], hd_table[0], hd_table[1], irq[0]);
  2465 + ide_init2(&d->ide_if[2], hd_table[2], hd_table[3], irq[1]);
2469 2466 }
2470 2467  
2471 2468 static void pci_ide_save(QEMUFile* f, void *opaque)
... ... @@ -2592,7 +2589,8 @@ static void piix3_reset(PCIIDEState *d)
2592 2589  
2593 2590 /* hd_table must contain 4 block drivers */
2594 2591 /* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */
2595   -void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn)
  2592 +void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,
  2593 + qemu_irq *pic)
2596 2594 {
2597 2595 PCIIDEState *d;
2598 2596 uint8_t *pci_conf;
... ... @@ -2619,10 +2617,8 @@ void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn)
2619 2617 pci_register_io_region((PCIDevice *)d, 4, 0x10,
2620 2618 PCI_ADDRESS_SPACE_IO, bmdma_map);
2621 2619  
2622   - ide_init2(&d->ide_if[0], hd_table[0], hd_table[1],
2623   - pic_set_irq_new, isa_pic, 14);
2624   - ide_init2(&d->ide_if[2], hd_table[2], hd_table[3],
2625   - pic_set_irq_new, isa_pic, 15);
  2620 + ide_init2(&d->ide_if[0], hd_table[0], hd_table[1], pic[14]);
  2621 + ide_init2(&d->ide_if[2], hd_table[2], hd_table[3], pic[15]);
2626 2622 ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6);
2627 2623 ide_init_ioport(&d->ide_if[2], 0x170, 0x376);
2628 2624  
... ... @@ -2741,15 +2737,13 @@ static CPUReadMemoryFunc *pmac_ide_read[] = {
2741 2737 /* hd_table must contain 4 block drivers */
2742 2738 /* PowerMac uses memory mapped registers, not I/O. Return the memory
2743 2739 I/O index to access the ide. */
2744   -int pmac_ide_init (BlockDriverState **hd_table,
2745   - SetIRQFunc *set_irq, void *irq_opaque, int irq)
  2740 +int pmac_ide_init (BlockDriverState **hd_table, qemu_irq irq)
2746 2741 {
2747 2742 IDEState *ide_if;
2748 2743 int pmac_ide_memory;
2749 2744  
2750 2745 ide_if = qemu_mallocz(sizeof(IDEState) * 2);
2751   - ide_init2(&ide_if[0], hd_table[0], hd_table[1],
2752   - set_irq, irq_opaque, irq);
  2746 + ide_init2(&ide_if[0], hd_table[0], hd_table[1], irq);
2753 2747  
2754 2748 pmac_ide_memory = cpu_register_io_memory(0, pmac_ide_read,
2755 2749 pmac_ide_write, &ide_if[0]);
... ...
hw/integratorcp.c
... ... @@ -267,28 +267,22 @@ static void integratorcm_init(int memsz, uint32_t flash_offset)
267 267  
268 268 typedef struct icp_pic_state
269 269 {
270   - arm_pic_handler handler;
271 270 uint32_t base;
272 271 uint32_t level;
273 272 uint32_t irq_enabled;
274 273 uint32_t fiq_enabled;
275   - void *parent;
276   - int parent_irq;
277   - int parent_fiq;
  274 + qemu_irq parent_irq;
  275 + qemu_irq parent_fiq;
278 276 } icp_pic_state;
279 277  
280 278 static void icp_pic_update(icp_pic_state *s)
281 279 {
282 280 uint32_t flags;
283 281  
284   - if (s->parent_irq != -1) {
285   - flags = (s->level & s->irq_enabled);
286   - pic_set_irq_new(s->parent, s->parent_irq, flags != 0);
287   - }
288   - if (s->parent_fiq != -1) {
289   - flags = (s->level & s->fiq_enabled);
290   - pic_set_irq_new(s->parent, s->parent_fiq, flags != 0);
291   - }
  282 + flags = (s->level & s->irq_enabled);
  283 + qemu_set_irq(s->parent_irq, flags != 0);
  284 + flags = (s->level & s->fiq_enabled);
  285 + qemu_set_irq(s->parent_fiq, flags != 0);
292 286 }
293 287  
294 288 static void icp_pic_set_irq(void *opaque, int irq, int level)
... ... @@ -345,11 +339,11 @@ static void icp_pic_write(void *opaque, target_phys_addr_t offset,
345 339 break;
346 340 case 4: /* INT_SOFTSET */
347 341 if (value & 1)
348   - pic_set_irq_new(s, 0, 1);
  342 + icp_pic_set_irq(s, 0, 1);
349 343 break;
350 344 case 5: /* INT_SOFTCLR */
351 345 if (value & 1)
352   - pic_set_irq_new(s, 0, 0);
  346 + icp_pic_set_irq(s, 0, 0);
353 347 break;
354 348 case 10: /* FRQ_ENABLESET */
355 349 s->fiq_enabled |= value;
... ... @@ -380,25 +374,25 @@ static CPUWriteMemoryFunc *icp_pic_writefn[] = {
380 374 icp_pic_write
381 375 };
382 376  
383   -static icp_pic_state *icp_pic_init(uint32_t base, void *parent,
384   - int parent_irq, int parent_fiq)
  377 +static qemu_irq *icp_pic_init(uint32_t base,
  378 + qemu_irq parent_irq, qemu_irq parent_fiq)
385 379 {
386 380 icp_pic_state *s;
387 381 int iomemtype;
  382 + qemu_irq *qi;
388 383  
389 384 s = (icp_pic_state *)qemu_mallocz(sizeof(icp_pic_state));
390 385 if (!s)
391 386 return NULL;
392   - s->handler = icp_pic_set_irq;
  387 + qi = qemu_allocate_irqs(icp_pic_set_irq, s, 32);
393 388 s->base = base;
394   - s->parent = parent;
395 389 s->parent_irq = parent_irq;
396 390 s->parent_fiq = parent_fiq;
397 391 iomemtype = cpu_register_io_memory(0, icp_pic_readfn,
398 392 icp_pic_writefn, s);
399 393 cpu_register_physical_memory(base, 0x007fffff, iomemtype);
400 394 /* ??? Save/restore. */
401   - return s;
  395 + return qi;
402 396 }
403 397  
404 398 /* CP control registers. */
... ... @@ -475,8 +469,8 @@ static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device,
475 469 {
476 470 CPUState *env;
477 471 uint32_t bios_offset;
478   - icp_pic_state *pic;
479   - void *cpu_pic;
  472 + qemu_irq *pic;
  473 + qemu_irq *cpu_pic;
480 474  
481 475 env = cpu_init();
482 476 if (!cpu_model)
... ... @@ -492,25 +486,26 @@ static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device,
492 486  
493 487 integratorcm_init(ram_size >> 20, bios_offset);
494 488 cpu_pic = arm_pic_init_cpu(env);
495   - pic = icp_pic_init(0x14000000, cpu_pic, ARM_PIC_CPU_IRQ, ARM_PIC_CPU_FIQ);
496   - icp_pic_init(0xca000000, pic, 26, -1);
  489 + pic = icp_pic_init(0x14000000, cpu_pic[ARM_PIC_CPU_IRQ],
  490 + cpu_pic[ARM_PIC_CPU_FIQ]);
  491 + icp_pic_init(0xca000000, pic[26], NULL);
497 492 icp_pit_init(0x13000000, pic, 5);
498   - pl011_init(0x16000000, pic, 1, serial_hds[0]);
499   - pl011_init(0x17000000, pic, 2, serial_hds[1]);
  493 + pl011_init(0x16000000, pic[1], serial_hds[0]);
  494 + pl011_init(0x17000000, pic[2], serial_hds[1]);
500 495 icp_control_init(0xcb000000);
501   - pl050_init(0x18000000, pic, 3, 0);
502   - pl050_init(0x19000000, pic, 4, 1);
503   - pl181_init(0x1c000000, sd_bdrv, pic, 23, 24);
  496 + pl050_init(0x18000000, pic[3], 0);
  497 + pl050_init(0x19000000, pic[4], 1);
  498 + pl181_init(0x1c000000, sd_bdrv, pic[23], pic[24]);
504 499 if (nd_table[0].vlan) {
505 500 if (nd_table[0].model == NULL
506 501 || strcmp(nd_table[0].model, "smc91c111") == 0) {
507   - smc91c111_init(&nd_table[0], 0xc8000000, pic, 27);
  502 + smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
508 503 } else {
509 504 fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
510 505 exit (1);
511 506 }
512 507 }
513   - pl110_init(ds, 0xc0000000, pic, 22, 0);
  508 + pl110_init(ds, 0xc0000000, pic[22], 0);
514 509  
515 510 arm_load_kernel(env, ram_size, kernel_filename, kernel_cmdline,
516 511 initrd_filename, 0x113);
... ...
hw/irq.c 0 โ†’ 100644
  1 +/*
  2 + * QEMU IRQ/GPIO common code.
  3 + *
  4 + * Copyright (c) 2007 CodeSourcery.
  5 + *
  6 + * Permission is hereby granted, free of charge, to any person obtaining a copy
  7 + * of this software and associated documentation files (the "Software"), to deal
  8 + * in the Software without restriction, including without limitation the rights
  9 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10 + * copies of the Software, and to permit persons to whom the Software is
  11 + * furnished to do so, subject to the following conditions:
  12 + *
  13 + * The above copyright notice and this permission notice shall be included in
  14 + * all copies or substantial portions of the Software.
  15 + *
  16 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22 + * THE SOFTWARE.
  23 + */
  24 +#include "vl.h"
  25 +
  26 +struct IRQState {
  27 + qemu_irq_handler handler;
  28 + void *opaque;
  29 + int n;
  30 +};
  31 +
  32 +void qemu_set_irq(qemu_irq irq, int level)
  33 +{
  34 + if (!irq)
  35 + return;
  36 +
  37 + irq->handler(irq->opaque, irq->n, level);
  38 +}
  39 +
  40 +qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n)
  41 +{
  42 + qemu_irq *s;
  43 + struct IRQState *p;
  44 + int i;
  45 +
  46 + s = (qemu_irq *)qemu_mallocz(sizeof(qemu_irq) * n);
  47 + p = (struct IRQState *)qemu_mallocz(sizeof(struct IRQState) * n);
  48 + for (i = 0; i < n; i++) {
  49 + p->handler = handler;
  50 + p->opaque = opaque;
  51 + p->n = i;
  52 + s[i] = p;
  53 + p++;
  54 + }
  55 + return s;
  56 +}
  57 +
... ...
hw/irq.h 0 โ†’ 100644
  1 +/* Generic IRQ/GPIO pin infrastructure. */
  2 +
  3 +typedef void (*qemu_irq_handler)(void *opaque, int n, int level);
  4 +
  5 +typedef struct IRQState *qemu_irq;
  6 +
  7 +void qemu_set_irq(qemu_irq irq, int level);
  8 +
  9 +static inline void qemu_irq_raise(qemu_irq irq)
  10 +{
  11 + qemu_set_irq(irq, 1);
  12 +}
  13 +
  14 +static inline void qemu_irq_lower(qemu_irq irq)
  15 +{
  16 + qemu_set_irq(irq, 0);
  17 +}
  18 +
  19 +/* Returns an array of N IRQs. */
  20 +qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n);
  21 +
... ...
hw/lsi53c895a.c
... ... @@ -374,7 +374,7 @@ static void lsi_update_irq(LSIState *s)
374 374 level, s->dstat, s->sist1, s->sist0);
375 375 last_level = level;
376 376 }
377   - pci_set_irq(&s->pci_dev, 0, level);
  377 + qemu_set_irq(s->pci_dev.irq[0], level);
378 378 }
379 379  
380 380 /* Stop SCRIPTS execution and raise a SCSI interrupt. */
... ...
hw/m48t59.c
... ... @@ -41,7 +41,7 @@ struct m48t59_t {
41 41 /* Model parameters */
42 42 int type; // 8 = m48t08, 59 = m48t59
43 43 /* Hardware parameters */
44   - int IRQ;
  44 + qemu_irq IRQ;
45 45 int mem_index;
46 46 uint32_t mem_base;
47 47 uint32_t io_base;
... ... @@ -100,7 +100,7 @@ static void alarm_cb (void *opaque)
100 100 uint64_t next_time;
101 101 m48t59_t *NVRAM = opaque;
102 102  
103   - pic_set_irq(NVRAM->IRQ, 1);
  103 + qemu_set_irq(NVRAM->IRQ, 1);
104 104 if ((NVRAM->buffer[0x1FF5] & 0x80) == 0 &&
105 105 (NVRAM->buffer[0x1FF4] & 0x80) == 0 &&
106 106 (NVRAM->buffer[0x1FF3] & 0x80) == 0 &&
... ... @@ -137,7 +137,7 @@ static void alarm_cb (void *opaque)
137 137 next_time = 1 + mktime(&tm_now);
138 138 }
139 139 qemu_mod_timer(NVRAM->alrm_timer, next_time * 1000);
140   - pic_set_irq(NVRAM->IRQ, 0);
  140 + qemu_set_irq(NVRAM->IRQ, 0);
141 141 }
142 142  
143 143  
... ... @@ -173,8 +173,8 @@ static void watchdog_cb (void *opaque)
173 173 /* May it be a hw CPU Reset instead ? */
174 174 qemu_system_reset_request();
175 175 } else {
176   - pic_set_irq(NVRAM->IRQ, 1);
177   - pic_set_irq(NVRAM->IRQ, 0);
  176 + qemu_set_irq(NVRAM->IRQ, 1);
  177 + qemu_set_irq(NVRAM->IRQ, 0);
178 178 }
179 179 }
180 180  
... ... @@ -576,7 +576,7 @@ static CPUReadMemoryFunc *nvram_read[] = {
576 576 };
577 577  
578 578 /* Initialisation routine */
579   -m48t59_t *m48t59_init (int IRQ, target_ulong mem_base,
  579 +m48t59_t *m48t59_init (qemu_irq IRQ, target_ulong mem_base,
580 580 uint32_t io_base, uint16_t size,
581 581 int type)
582 582 {
... ...
hw/m48t59.h
... ... @@ -6,7 +6,7 @@ typedef struct m48t59_t m48t59_t;
6 6 void m48t59_write (m48t59_t *NVRAM, uint32_t addr, uint32_t val);
7 7 uint32_t m48t59_read (m48t59_t *NVRAM, uint32_t addr);
8 8 void m48t59_toggle_lock (m48t59_t *NVRAM, int lock);
9   -m48t59_t *m48t59_init (int IRQ, target_ulong mem_base,
  9 +m48t59_t *m48t59_init (qemu_irq IRQ, target_ulong mem_base,
10 10 uint32_t io_base, uint16_t size,
11 11 int type);
12 12  
... ...
hw/mc146818rtc.c
... ... @@ -54,7 +54,7 @@ struct RTCState {
54 54 uint8_t cmos_data[128];
55 55 uint8_t cmos_index;
56 56 struct tm current_tm;
57   - int irq;
  57 + qemu_irq irq;
58 58 /* periodic timer */
59 59 QEMUTimer *periodic_timer;
60 60 int64_t next_periodic_time;
... ... @@ -95,7 +95,7 @@ static void rtc_periodic_timer(void *opaque)
95 95  
96 96 rtc_timer_update(s, s->next_periodic_time);
97 97 s->cmos_data[RTC_REG_C] |= 0xc0;
98   - pic_set_irq(s->irq, 1);
  98 + qemu_irq_raise(s->irq);
99 99 }
100 100  
101 101 static void cmos_ioport_write(void *opaque, uint32_t addr, uint32_t data)
... ... @@ -314,14 +314,14 @@ static void rtc_update_second2(void *opaque)
314 314 s->cmos_data[RTC_HOURS_ALARM] == s->current_tm.tm_hour)) {
315 315  
316 316 s->cmos_data[RTC_REG_C] |= 0xa0;
317   - pic_set_irq(s->irq, 1);
  317 + qemu_irq_raise(s->irq);
318 318 }
319 319 }
320 320  
321 321 /* update ended interrupt */
322 322 if (s->cmos_data[RTC_REG_B] & REG_B_UIE) {
323 323 s->cmos_data[RTC_REG_C] |= 0x90;
324   - pic_set_irq(s->irq, 1);
  324 + qemu_irq_raise(s->irq);
325 325 }
326 326  
327 327 /* clear update in progress bit */
... ... @@ -353,7 +353,7 @@ static uint32_t cmos_ioport_read(void *opaque, uint32_t addr)
353 353 break;
354 354 case RTC_REG_C:
355 355 ret = s->cmos_data[s->cmos_index];
356   - pic_set_irq(s->irq, 0);
  356 + qemu_irq_lower(s->irq);
357 357 s->cmos_data[RTC_REG_C] = 0x00;
358 358 break;
359 359 default:
... ... @@ -453,7 +453,7 @@ static int rtc_load(QEMUFile *f, void *opaque, int version_id)
453 453 return 0;
454 454 }
455 455  
456   -RTCState *rtc_init(int base, int irq)
  456 +RTCState *rtc_init(int base, qemu_irq irq)
457 457 {
458 458 RTCState *s;
459 459  
... ...
hw/mips_int.c
... ... @@ -17,7 +17,7 @@ void cpu_mips_update_irq(CPUState *env)
17 17 cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
18 18 }
19 19  
20   -void cpu_mips_irq_request(void *opaque, int irq, int level)
  20 +static void cpu_mips_irq_request(void *opaque, int irq, int level)
21 21 {
22 22 CPUState *env = (CPUState *)opaque;
23 23  
... ... @@ -31,3 +31,14 @@ void cpu_mips_irq_request(void *opaque, int irq, int level)
31 31 }
32 32 cpu_mips_update_irq(env);
33 33 }
  34 +
  35 +void cpu_mips_irq_init_cpu(CPUState *env)
  36 +{
  37 + qemu_irq *qi;
  38 + int i;
  39 +
  40 + qi = qemu_allocate_irqs(cpu_mips_irq_request, env, 8);
  41 + for (i = 0; i < 8; i++) {
  42 + env->irq[i] = qi[i];
  43 + }
  44 +}
... ...
hw/mips_malta.c
... ... @@ -60,12 +60,6 @@ typedef struct {
60 60  
61 61 static PITState *pit;
62 62  
63   -/* The 8259 is attached to the MIPS CPU INT0 pin, ie interrupt 2 */
64   -static void pic_irq_request(void *opaque, int level)
65   -{
66   - cpu_mips_irq_request(opaque, 2, level);
67   -}
68   -
69 63 /* Malta FPGA */
70 64 static void malta_fpga_update_display(void *opaque)
71 65 {
... ... @@ -451,8 +445,7 @@ MaltaFPGAState *malta_fpga_init(target_phys_addr_t base, CPUState *env)
451 445  
452 446 uart_chr = qemu_chr_open("vc");
453 447 qemu_chr_printf(uart_chr, "CBUS UART\r\n");
454   - s->uart = serial_mm_init(&cpu_mips_irq_request, env, base, 3, 2,
455   - uart_chr, 0);
  448 + s->uart = serial_mm_init(base, 3, env->irq[2], uart_chr, 0);
456 449  
457 450 malta_fpga_reset(s);
458 451 qemu_register_reset(malta_fpga_reset, s);
... ... @@ -676,6 +669,7 @@ void mips_malta_init (int ram_size, int vga_ram_size, int boot_device,
676 669 MaltaFPGAState *malta_fpga;
677 670 int ret;
678 671 mips_def_t *def;
  672 + qemu_irq *i8259;
679 673  
680 674 /* init CPUs */
681 675 if (cpu_model == NULL) {
... ... @@ -729,6 +723,7 @@ void mips_malta_init (int ram_size, int vga_ram_size, int boot_device,
729 723 stl_raw(phys_ram_base + bios_offset + 0x10, 0x00000420);
730 724  
731 725 /* Init internal devices */
  726 + cpu_mips_irq_init_cpu(env);
732 727 cpu_mips_clock_init(env);
733 728 cpu_mips_irqctrl_init();
734 729  
... ... @@ -736,31 +731,32 @@ void mips_malta_init (int ram_size, int vga_ram_size, int boot_device,
736 731 malta_fpga = malta_fpga_init(0x1f000000LL, env);
737 732  
738 733 /* Interrupt controller */
739   - isa_pic = pic_init(pic_irq_request, env);
  734 + /* The 8259 is attached to the MIPS CPU INT0 pin, ie interrupt 2 */
  735 + i8259 = i8259_init(env->irq[2]);
740 736  
741 737 /* Northbridge */
742   - pci_bus = pci_gt64120_init(isa_pic);
  738 + pci_bus = pci_gt64120_init(i8259);
743 739  
744 740 /* Southbridge */
745 741 piix4_init(pci_bus, 80);
746   - pci_piix3_ide_init(pci_bus, bs_table, 81);
  742 + pci_piix3_ide_init(pci_bus, bs_table, 81, i8259);
747 743 usb_uhci_init(pci_bus, 82);
748 744 piix4_pm_init(pci_bus, 83);
749   - pit = pit_init(0x40, 0);
  745 + pit = pit_init(0x40, i8259[0]);
750 746 DMA_init(0);
751 747  
752 748 /* Super I/O */
753   - kbd_init();
754   - rtc_state = rtc_init(0x70, 8);
  749 + i8042_init(i8259[1], i8259[12], 0x60);
  750 + rtc_state = rtc_init(0x70, i8259[8]);
755 751 if (serial_hds[0])
756   - serial_init(&pic_set_irq_new, isa_pic, 0x3f8, 4, serial_hds[0]);
  752 + serial_init(0x3f8, i8259[4], serial_hds[0]);
757 753 if (serial_hds[1])
758   - serial_init(&pic_set_irq_new, isa_pic, 0x2f8, 3, serial_hds[1]);
  754 + serial_init(0x2f8, i8259[3], serial_hds[1]);
759 755 if (parallel_hds[0])
760   - parallel_init(0x378, 7, parallel_hds[0]);
  756 + parallel_init(0x378, i8259[7], parallel_hds[0]);
761 757 /* XXX: The floppy controller does not work correctly, something is
762 758 probably wrong.
763   - floppy_controller = fdctrl_init(6, 2, 0, 0x3f0, fd_table); */
  759 + floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd_table); */
764 760  
765 761 /* Sound card */
766 762 #ifdef HAS_AUDIO
... ...
hw/mips_r4k.c
... ... @@ -35,11 +35,6 @@ extern FILE *logfile;
35 35 static PITState *pit; /* PIT i8254 */
36 36  
37 37 /*i8254 PIT is attached to the IRQ0 at PIC i8259 */
38   -/*The PIC is attached to the MIPS CPU INT0 pin */
39   -static void pic_irq_request(void *opaque, int level)
40   -{
41   - cpu_mips_irq_request(opaque, 2, level);
42   -}
43 38  
44 39 static void mips_qemu_writel (void *opaque, target_phys_addr_t addr,
45 40 uint32_t val)
... ... @@ -152,6 +147,7 @@ void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device,
152 147 RTCState *rtc_state;
153 148 int i;
154 149 mips_def_t *def;
  150 + qemu_irq *i8259;
155 151  
156 152 /* init CPUs */
157 153 if (cpu_model == NULL) {
... ... @@ -203,22 +199,24 @@ void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device,
203 199 }
204 200  
205 201 /* Init CPU internal devices */
  202 + cpu_mips_irq_init_cpu(env);
206 203 cpu_mips_clock_init(env);
207 204 cpu_mips_irqctrl_init();
208 205  
209   - rtc_state = rtc_init(0x70, 8);
  206 + /* The PIC is attached to the MIPS CPU INT0 pin */
  207 + i8259 = i8259_init(env->irq[2]);
  208 +
  209 + rtc_state = rtc_init(0x70, i8259[8]);
210 210  
211 211 /* Register 64 KB of ISA IO space at 0x14000000 */
212 212 isa_mmio_init(0x14000000, 0x00010000);
213 213 isa_mem_base = 0x10000000;
214 214  
215   - isa_pic = pic_init(pic_irq_request, env);
216   - pit = pit_init(0x40, 0);
  215 + pit = pit_init(0x40, i8259[0]);
217 216  
218 217 for(i = 0; i < MAX_SERIAL_PORTS; i++) {
219 218 if (serial_hds[i]) {
220   - serial_init(&pic_set_irq_new, isa_pic,
221   - serial_io[i], serial_irq[i], serial_hds[i]);
  219 + serial_init(serial_io[i], i8259[serial_irq[i]], serial_hds[i]);
222 220 }
223 221 }
224 222  
... ... @@ -228,7 +226,7 @@ void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device,
228 226 if (nd_table[0].vlan) {
229 227 if (nd_table[0].model == NULL
230 228 || strcmp(nd_table[0].model, "ne2k_isa") == 0) {
231   - isa_ne2000_init(0x300, 9, &nd_table[0]);
  229 + isa_ne2000_init(0x300, i8259[9], &nd_table[0]);
232 230 } else {
233 231 fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
234 232 exit (1);
... ... @@ -236,10 +234,10 @@ void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device,
236 234 }
237 235  
238 236 for(i = 0; i < 2; i++)
239   - isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
  237 + isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]],
240 238 bs_table[2 * i], bs_table[2 * i + 1]);
241 239  
242   - kbd_init();
  240 + i8042_init(i8259[1], i8259[12], 0x60);
243 241 ds1225y_init(0x9000, "nvram");
244 242 }
245 243  
... ...
hw/mips_timer.c
... ... @@ -63,7 +63,7 @@ void cpu_mips_store_compare (CPUState *env, uint32_t value)
63 63 cpu_mips_update_count(env, cpu_mips_get_count(env));
64 64 if ((env->CP0_Config0 & (0x7 << CP0C0_AR)) == (1 << CP0C0_AR))
65 65 env->CP0_Cause &= ~(1 << CP0Ca_TI);
66   - cpu_mips_irq_request(env, 7, 0);
  66 + qemu_irq_lower(env->irq[7]);
67 67 }
68 68  
69 69 static void mips_timer_cb (void *opaque)
... ... @@ -79,7 +79,7 @@ static void mips_timer_cb (void *opaque)
79 79 cpu_mips_update_count(env, cpu_mips_get_count(env));
80 80 if ((env->CP0_Config0 & (0x7 << CP0C0_AR)) == (1 << CP0C0_AR))
81 81 env->CP0_Cause |= 1 << CP0Ca_TI;
82   - cpu_mips_irq_request(env, 7, 1);
  82 + qemu_irq_raise(env->irq[7]);
83 83 }
84 84  
85 85 void cpu_mips_clock_init (CPUState *env)
... ...
hw/ne2000.c
... ... @@ -136,7 +136,7 @@ typedef struct NE2000State {
136 136 uint8_t phys[6]; /* mac address */
137 137 uint8_t curpag;
138 138 uint8_t mult[8]; /* multicast mask array */
139   - int irq;
  139 + qemu_irq irq;
140 140 PCIDevice *pci_dev;
141 141 VLANClientState *vc;
142 142 uint8_t macaddr[6];
... ... @@ -164,16 +164,10 @@ static void ne2000_update_irq(NE2000State *s)
164 164 int isr;
165 165 isr = (s->isr & s->imr) & 0x7f;
166 166 #if defined(DEBUG_NE2000)
167   - printf("NE2000: Set IRQ line %d to %d (%02x %02x)\n",
168   - s->irq, isr ? 1 : 0, s->isr, s->imr);
  167 + printf("NE2000: Set IRQ to %d (%02x %02x)\n",
  168 + isr ? 1 : 0, s->isr, s->imr);
169 169 #endif
170   - if (s->irq == 16) {
171   - /* PCI irq */
172   - pci_set_irq(s->pci_dev, 0, (isr != 0));
173   - } else {
174   - /* ISA irq */
175   - pic_set_irq(s->irq, (isr != 0));
176   - }
  170 + qemu_set_irq(s->irq, (isr != 0));
177 171 }
178 172  
179 173 #define POLYNOMIAL 0x04c11db6
... ... @@ -647,6 +641,7 @@ static uint32_t ne2000_reset_ioport_read(void *opaque, uint32_t addr)
647 641 static void ne2000_save(QEMUFile* f,void* opaque)
648 642 {
649 643 NE2000State* s=(NE2000State*)opaque;
  644 + int tmp;
650 645  
651 646 if (s->pci_dev)
652 647 pci_device_save(s->pci_dev, f);
... ... @@ -669,7 +664,8 @@ static void ne2000_save(QEMUFile* f,void* opaque)
669 664 qemu_put_buffer(f, s->phys, 6);
670 665 qemu_put_8s(f, &s->curpag);
671 666 qemu_put_buffer(f, s->mult, 8);
672   - qemu_put_be32s(f, &s->irq);
  667 + tmp = 0;
  668 + qemu_put_be32s(f, &tmp); /* ignored, was irq */
673 669 qemu_put_buffer(f, s->mem, NE2000_MEM_SIZE);
674 670 }
675 671  
... ... @@ -677,6 +673,7 @@ static int ne2000_load(QEMUFile* f,void* opaque,int version_id)
677 673 {
678 674 NE2000State* s=(NE2000State*)opaque;
679 675 int ret;
  676 + int tmp;
680 677  
681 678 if (version_id > 3)
682 679 return -EINVAL;
... ... @@ -709,13 +706,13 @@ static int ne2000_load(QEMUFile* f,void* opaque,int version_id)
709 706 qemu_get_buffer(f, s->phys, 6);
710 707 qemu_get_8s(f, &s->curpag);
711 708 qemu_get_buffer(f, s->mult, 8);
712   - qemu_get_be32s(f, &s->irq);
  709 + qemu_get_be32s(f, &tmp); /* ignored */
713 710 qemu_get_buffer(f, s->mem, NE2000_MEM_SIZE);
714 711  
715 712 return 0;
716 713 }
717 714  
718   -void isa_ne2000_init(int base, int irq, NICInfo *nd)
  715 +void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)
719 716 {
720 717 NE2000State *s;
721 718  
... ... @@ -804,7 +801,7 @@ void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn)
804 801 pci_register_io_region(&d->dev, 0, 0x100,
805 802 PCI_ADDRESS_SPACE_IO, ne2000_map);
806 803 s = &d->ne2000;
807   - s->irq = 16; // PCI interrupt
  804 + s->irq = d->dev.irq[0];
808 805 s->pci_dev = (PCIDevice *)d;
809 806 memcpy(s->macaddr, nd->macaddr, 6);
810 807 ne2000_reset(s);
... ...
hw/openpic.c
... ... @@ -162,7 +162,7 @@ typedef struct IRQ_dst_t {
162 162 CPUState *env;
163 163 } IRQ_dst_t;
164 164  
165   -struct openpic_t {
  165 +typedef struct openpic_t {
166 166 PCIDevice pci_dev;
167 167 SetIRQFunc *set_irq;
168 168 int mem_index;
... ... @@ -196,7 +196,7 @@ struct openpic_t {
196 196 uint32_t mbr; /* Mailbox register */
197 197 } mailboxes[MAX_MAILBOXES];
198 198 #endif
199   -};
  199 +} openpic_t;
200 200  
201 201 static inline void IRQ_setbit (IRQ_queue_t *q, int n_IRQ)
202 202 {
... ... @@ -321,7 +321,7 @@ static void openpic_update_irq(openpic_t *opp, int n_IRQ)
321 321 }
322 322 }
323 323  
324   -void openpic_set_irq(void *opaque, int n_IRQ, int level)
  324 +static void openpic_set_irq(void *opaque, int n_IRQ, int level)
325 325 {
326 326 openpic_t *opp = opaque;
327 327 IRQ_src_t *src;
... ... @@ -964,7 +964,7 @@ static void openpic_map(PCIDevice *pci_dev, int region_num,
964 964 #endif
965 965 }
966 966  
967   -openpic_t *openpic_init (PCIBus *bus, SetIRQFunc *set_irq,
  967 +qemu_irq *openpic_init (PCIBus *bus, SetIRQFunc *set_irq,
968 968 int *pmem_index, int nb_cpus, CPUState **envp)
969 969 {
970 970 openpic_t *opp;
... ... @@ -1024,5 +1024,5 @@ openpic_t *openpic_init (PCIBus *bus, SetIRQFunc *set_irq,
1024 1024 openpic_reset(opp);
1025 1025 if (pmem_index)
1026 1026 *pmem_index = opp->mem_index;
1027   - return opp;
  1027 + return qemu_allocate_irqs(openpic_set_irq, opp, MAX_IRQ);
1028 1028 }
... ...
hw/parallel.c
... ... @@ -65,7 +65,7 @@ struct ParallelState {
65 65 uint8_t datar;
66 66 uint8_t status;
67 67 uint8_t control;
68   - int irq;
  68 + qemu_irq irq;
69 69 int irq_pending;
70 70 CharDriverState *chr;
71 71 int hw_driver;
... ... @@ -76,9 +76,9 @@ struct ParallelState {
76 76 static void parallel_update_irq(ParallelState *s)
77 77 {
78 78 if (s->irq_pending)
79   - pic_set_irq(s->irq, 1);
  79 + qemu_irq_raise(s->irq);
80 80 else
81   - pic_set_irq(s->irq, 0);
  81 + qemu_irq_lower(s->irq);
82 82 }
83 83  
84 84 static void
... ... @@ -401,7 +401,7 @@ static uint32_t parallel_ioport_ecp_read(void *opaque, uint32_t addr)
401 401 }
402 402  
403 403 /* If fd is zero, it means that the parallel device uses the console */
404   -ParallelState *parallel_init(int base, int irq, CharDriverState *chr)
  404 +ParallelState *parallel_init(int base, qemu_irq irq, CharDriverState *chr)
405 405 {
406 406 ParallelState *s;
407 407 uint8_t dummy;
... ...
... ... @@ -49,15 +49,16 @@ static void ioport80_write(void *opaque, uint32_t addr, uint32_t data)
49 49 }
50 50  
51 51 /* MSDOS compatibility mode FPU exception support */
  52 +static qemu_irq ferr_irq;
52 53 /* XXX: add IGNNE support */
53 54 void cpu_set_ferr(CPUX86State *s)
54 55 {
55   - pic_set_irq(13, 1);
  56 + qemu_irq_raise(ferr_irq);
56 57 }
57 58  
58 59 static void ioportF0_write(void *opaque, uint32_t addr, uint32_t data)
59 60 {
60   - pic_set_irq(13, 0);
  61 + qemu_irq_lower(ferr_irq);
61 62 }
62 63  
63 64 /* TSC handling */
... ... @@ -101,7 +102,7 @@ int cpu_get_pic_interrupt(CPUState *env)
101 102 return intno;
102 103 }
103 104  
104   -static void pic_irq_request(void *opaque, int level)
  105 +static void pic_irq_request(void *opaque, int irq, int level)
105 106 {
106 107 CPUState *env = opaque;
107 108 if (level)
... ... @@ -403,7 +404,7 @@ static int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
403 404 static int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 };
404 405  
405 406 #ifdef HAS_AUDIO
406   -static void audio_init (PCIBus *pci_bus)
  407 +static void audio_init (PCIBus *pci_bus, qemu_irq *pic)
407 408 {
408 409 struct soundhw *c;
409 410 int audio_enabled = 0;
... ... @@ -420,7 +421,7 @@ static void audio_init (PCIBus *pci_bus)
420 421 for (c = soundhw; c->name; ++c) {
421 422 if (c->enabled) {
422 423 if (c->isa) {
423   - c->init.init_isa (s);
  424 + c->init.init_isa (s, pic);
424 425 }
425 426 else {
426 427 if (pci_bus) {
... ... @@ -434,13 +435,13 @@ static void audio_init (PCIBus *pci_bus)
434 435 }
435 436 #endif
436 437  
437   -static void pc_init_ne2k_isa(NICInfo *nd)
  438 +static void pc_init_ne2k_isa(NICInfo *nd, qemu_irq *pic)
438 439 {
439 440 static int nb_ne2k = 0;
440 441  
441 442 if (nb_ne2k == NE2000_NB_MAX)
442 443 return;
443   - isa_ne2000_init(ne2000_io[nb_ne2k], ne2000_irq[nb_ne2k], nd);
  444 + isa_ne2000_init(ne2000_io[nb_ne2k], pic[ne2000_irq[nb_ne2k]], nd);
444 445 nb_ne2k++;
445 446 }
446 447  
... ... @@ -460,6 +461,8 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
460 461 int piix3_devfn = -1;
461 462 CPUState *env;
462 463 NICInfo *nd;
  464 + qemu_irq *cpu_irq;
  465 + qemu_irq *i8259;
463 466  
464 467 linux_boot = (kernel_filename != NULL);
465 468  
... ... @@ -643,8 +646,12 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
643 646 stw_raw(phys_ram_base + KERNEL_PARAMS_ADDR + 0x210, 0x01);
644 647 }
645 648  
  649 + cpu_irq = qemu_allocate_irqs(pic_irq_request, first_cpu, 1);
  650 + i8259 = i8259_init(cpu_irq[0]);
  651 + ferr_irq = i8259[13];
  652 +
646 653 if (pci_enabled) {
647   - pci_bus = i440fx_init(&i440fx_state);
  654 + pci_bus = i440fx_init(&i440fx_state, i8259);
648 655 piix3_devfn = piix3_init(pci_bus, -1);
649 656 } else {
650 657 pci_bus = NULL;
... ... @@ -680,7 +687,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
680 687 }
681 688 }
682 689  
683   - rtc_state = rtc_init(0x70, 8);
  690 + rtc_state = rtc_init(0x70, i8259[8]);
684 691  
685 692 register_ioport_read(0x92, 1, 1, ioport92_read, NULL);
686 693 register_ioport_write(0x92, 1, 1, ioport92_write, NULL);
... ... @@ -688,8 +695,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
688 695 if (pci_enabled) {
689 696 ioapic = ioapic_init();
690 697 }
691   - isa_pic = pic_init(pic_irq_request, first_cpu);
692   - pit = pit_init(0x40, 0);
  698 + pit = pit_init(0x40, i8259[0]);
693 699 pcspk_init(pit);
694 700 if (pci_enabled) {
695 701 pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic);
... ... @@ -697,14 +703,14 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
697 703  
698 704 for(i = 0; i < MAX_SERIAL_PORTS; i++) {
699 705 if (serial_hds[i]) {
700   - serial_init(&pic_set_irq_new, isa_pic,
701   - serial_io[i], serial_irq[i], serial_hds[i]);
  706 + serial_init(serial_io[i], i8259[serial_irq[i]], serial_hds[i]);
702 707 }
703 708 }
704 709  
705 710 for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
706 711 if (parallel_hds[i]) {
707   - parallel_init(parallel_io[i], parallel_irq[i], parallel_hds[i]);
  712 + parallel_init(parallel_io[i], i8259[parallel_irq[i]],
  713 + parallel_hds[i]);
708 714 }
709 715 }
710 716  
... ... @@ -718,7 +724,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
718 724 }
719 725 }
720 726 if (strcmp(nd->model, "ne2k_isa") == 0) {
721   - pc_init_ne2k_isa(nd);
  727 + pc_init_ne2k_isa(nd, i8259);
722 728 } else if (pci_enabled) {
723 729 pci_nic_init(pci_bus, nd, -1);
724 730 } else {
... ... @@ -728,21 +734,21 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
728 734 }
729 735  
730 736 if (pci_enabled) {
731   - pci_piix3_ide_init(pci_bus, bs_table, piix3_devfn + 1);
  737 + pci_piix3_ide_init(pci_bus, bs_table, piix3_devfn + 1, i8259);
732 738 } else {
733 739 for(i = 0; i < 2; i++) {
734   - isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
  740 + isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]],
735 741 bs_table[2 * i], bs_table[2 * i + 1]);
736 742 }
737 743 }
738 744  
739   - kbd_init();
  745 + i8042_init(i8259[1], i8259[12], 0x60);
740 746 DMA_init(0);
741 747 #ifdef HAS_AUDIO
742   - audio_init(pci_enabled ? pci_bus : NULL);
  748 + audio_init(pci_enabled ? pci_bus : NULL, i8259);
743 749 #endif
744 750  
745   - floppy_controller = fdctrl_init(6, 2, 0, 0x3f0, fd_table);
  751 + floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd_table);
746 752  
747 753 cmos_init(ram_size, boot_device, bs_table);
748 754  
... ...
hw/pci.c
... ... @@ -33,7 +33,7 @@ struct PCIBus {
33 33 uint32_t config_reg; /* XXX: suppress */
34 34 /* low level pic */
35 35 SetIRQFunc *low_set_irq;
36   - void *irq_opaque;
  36 + qemu_irq *irq_opaque;
37 37 PCIDevice *devices[256];
38 38 PCIDevice *parent_dev;
39 39 PCIBus *next;
... ... @@ -43,13 +43,14 @@ struct PCIBus {
43 43 };
44 44  
45 45 static void pci_update_mappings(PCIDevice *d);
  46 +static void pci_set_irq(void *opaque, int irq_num, int level);
46 47  
47 48 target_phys_addr_t pci_mem_base;
48 49 static int pci_irq_index;
49 50 static PCIBus *first_bus;
50 51  
51 52 PCIBus *pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
52   - void *pic, int devfn_min, int nirq)
  53 + qemu_irq *pic, int devfn_min, int nirq)
53 54 {
54 55 PCIBus *bus;
55 56 bus = qemu_mallocz(sizeof(PCIBus) + (nirq * sizeof(int)));
... ... @@ -129,6 +130,7 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name,
129 130 pci_dev->config_write = config_write;
130 131 pci_dev->irq_index = pci_irq_index++;
131 132 bus->devices[devfn] = pci_dev;
  133 + pci_dev->irq = qemu_allocate_irqs(pci_set_irq, pci_dev, 4);
132 134 return pci_dev;
133 135 }
134 136  
... ... @@ -433,8 +435,9 @@ uint32_t pci_data_read(void *opaque, uint32_t addr, int len)
433 435 /* generic PCI irq support */
434 436  
435 437 /* 0 <= irq_num <= 3. level must be 0 or 1 */
436   -void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level)
  438 +static void pci_set_irq(void *opaque, int irq_num, int level)
437 439 {
  440 + PCIDevice *pci_dev = (PCIDevice *)opaque;
438 441 PCIBus *bus;
439 442 int change;
440 443  
... ...
hw/pckbd.c
... ... @@ -122,8 +122,8 @@ typedef struct KBDState {
122 122 void *kbd;
123 123 void *mouse;
124 124  
125   - int irq_kbd;
126   - int irq_mouse;
  125 + qemu_irq irq_kbd;
  126 + qemu_irq irq_mouse;
127 127 } KBDState;
128 128  
129 129 KBDState kbd_state;
... ... @@ -151,8 +151,8 @@ static void kbd_update_irq(KBDState *s)
151 151 irq_kbd_level = 1;
152 152 }
153 153 }
154   - pic_set_irq(s->irq_kbd, irq_kbd_level);
155   - pic_set_irq(s->irq_mouse, irq_mouse_level);
  154 + qemu_set_irq(s->irq_kbd, irq_kbd_level);
  155 + qemu_set_irq(s->irq_mouse, irq_mouse_level);
156 156 }
157 157  
158 158 static void kbd_update_kbd_irq(void *opaque, int level)
... ... @@ -356,12 +356,12 @@ static int kbd_load(QEMUFile* f, void* opaque, int version_id)
356 356 return 0;
357 357 }
358 358  
359   -void i8042_init(int kbd_irq_lvl, int mouse_irq_lvl, uint32_t io_base)
  359 +void i8042_init(qemu_irq kbd_irq, qemu_irq mouse_irq, uint32_t io_base)
360 360 {
361 361 KBDState *s = &kbd_state;
362 362  
363   - s->irq_kbd = kbd_irq_lvl;
364   - s->irq_mouse = mouse_irq_lvl;
  363 + s->irq_kbd = kbd_irq;
  364 + s->irq_mouse = mouse_irq;
365 365  
366 366 kbd_reset(s);
367 367 register_savevm("pckbd", 0, 3, kbd_save, kbd_load, s);
... ... @@ -377,8 +377,3 @@ void i8042_init(int kbd_irq_lvl, int mouse_irq_lvl, uint32_t io_base)
377 377 #endif
378 378 qemu_register_reset(kbd_reset, s);
379 379 }
380   -
381   -void kbd_init(void)
382   -{
383   - return i8042_init(1, 12, 0x60);
384   -}
... ...
hw/pcnet.c
... ... @@ -69,7 +69,7 @@ struct PCNetState_st {
69 69 int xmit_pos, recv_pos;
70 70 uint8_t buffer[4096];
71 71 int tx_busy;
72   - void (*set_irq_cb)(void *s, int isr);
  72 + qemu_irq irq;
73 73 void (*phys_mem_read)(void *dma_opaque, target_phys_addr_t addr,
74 74 uint8_t *buf, int len, int do_bswap);
75 75 void (*phys_mem_write)(void *dma_opaque, target_phys_addr_t addr,
... ... @@ -823,7 +823,7 @@ static void pcnet_update_irq(PCNetState *s)
823 823 printf("pcnet: INTA=%d\n", isr);
824 824 #endif
825 825 }
826   - s->set_irq_cb(s, isr);
  826 + qemu_set_irq(s->irq, isr);
827 827 s->isr = isr;
828 828 }
829 829  
... ... @@ -1940,13 +1940,6 @@ static void pcnet_mmio_map(PCIDevice *pci_dev, int region_num,
1940 1940 cpu_register_physical_memory(addr, PCNET_PNPMMIO_SIZE, d->mmio_index);
1941 1941 }
1942 1942  
1943   -static void pcnet_pci_set_irq_cb(void *opaque, int isr)
1944   -{
1945   - PCNetState *s = opaque;
1946   -
1947   - pci_set_irq(&s->dev, 0, isr);
1948   -}
1949   -
1950 1943 static void pci_physical_memory_write(void *dma_opaque, target_phys_addr_t addr,
1951 1944 uint8_t *buf, int len, int do_bswap)
1952 1945 {
... ... @@ -2001,7 +1994,7 @@ void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn)
2001 1994 pci_register_io_region((PCIDevice *)d, 1, PCNET_PNPMMIO_SIZE,
2002 1995 PCI_ADDRESS_SPACE_MEM, pcnet_mmio_map);
2003 1996  
2004   - d->set_irq_cb = pcnet_pci_set_irq_cb;
  1997 + d->irq = d->dev.irq[0];
2005 1998 d->phys_mem_read = pci_physical_memory_read;
2006 1999 d->phys_mem_write = pci_physical_memory_write;
2007 2000 d->pci_dev = &d->dev;
... ... @@ -2025,14 +2018,7 @@ static CPUWriteMemoryFunc *lance_mem_write[3] = {
2025 2018 (CPUWriteMemoryFunc *)&pcnet_ioport_writew,
2026 2019 };
2027 2020  
2028   -static void pcnet_sparc_set_irq_cb(void *opaque, int isr)
2029   -{
2030   - PCNetState *s = opaque;
2031   -
2032   - ledma_set_irq(s->dma_opaque, isr);
2033   -}
2034   -
2035   -void *lance_init(NICInfo *nd, uint32_t leaddr, void *dma_opaque)
  2021 +void *lance_init(NICInfo *nd, uint32_t leaddr, void *dma_opaque, qemu_irq irq)
2036 2022 {
2037 2023 PCNetState *d;
2038 2024 int lance_io_memory;
... ... @@ -2047,7 +2033,7 @@ void *lance_init(NICInfo *nd, uint32_t leaddr, void *dma_opaque)
2047 2033 d->dma_opaque = dma_opaque;
2048 2034 cpu_register_physical_memory(leaddr, 4, lance_io_memory);
2049 2035  
2050   - d->set_irq_cb = pcnet_sparc_set_irq_cb;
  2036 + d->irq = irq;
2051 2037 d->phys_mem_read = ledma_memory_read;
2052 2038 d->phys_mem_write = ledma_memory_write;
2053 2039  
... ...
hw/pcspk.c
... ... @@ -92,7 +92,7 @@ static void pcspk_callback(void *opaque, int free)
92 92 }
93 93 }
94 94  
95   -int pcspk_audio_init(AudioState *audio)
  95 +int pcspk_audio_init(AudioState *audio, qemu_irq *pic)
96 96 {
97 97 PCSpkState *s = &pcspk_state;
98 98 audsettings_t as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
... ...
hw/piix_pci.c
... ... @@ -40,7 +40,7 @@ static uint32_t i440fx_addr_readl(void* opaque, uint32_t addr)
40 40 return s->config_reg;
41 41 }
42 42  
43   -static void piix3_set_irq(void *pic, int irq_num, int level);
  43 +static void piix3_set_irq(qemu_irq *pic, int irq_num, int level);
44 44  
45 45 /* return the global irq number corresponding to a given device irq
46 46 pin. We could also use the bus number to have a more precise
... ... @@ -155,14 +155,14 @@ static int i440fx_load(QEMUFile* f, void *opaque, int version_id)
155 155 return 0;
156 156 }
157 157  
158   -PCIBus *i440fx_init(PCIDevice **pi440fx_state)
  158 +PCIBus *i440fx_init(PCIDevice **pi440fx_state, qemu_irq *pic)
159 159 {
160 160 PCIBus *b;
161 161 PCIDevice *d;
162 162 I440FXState *s;
163 163  
164 164 s = qemu_mallocz(sizeof(I440FXState));
165   - b = pci_register_bus(piix3_set_irq, pci_slot_get_pirq, NULL, 0, 4);
  165 + b = pci_register_bus(piix3_set_irq, pci_slot_get_pirq, pic, 0, 4);
166 166 s->bus = b;
167 167  
168 168 register_ioport_write(0xcf8, 4, 4, i440fx_addr_writel, s);
... ... @@ -204,7 +204,7 @@ PCIDevice *piix4_dev;
204 204  
205 205 static int pci_irq_levels[4];
206 206  
207   -static void piix3_set_irq(void *pic, int irq_num, int level)
  207 +static void piix3_set_irq(qemu_irq *pic, int irq_num, int level)
208 208 {
209 209 int i, pic_irq, pic_level;
210 210  
... ... @@ -221,7 +221,7 @@ static void piix3_set_irq(void *pic, int irq_num, int level)
221 221 if (pic_irq == piix3_dev->config[0x60 + i])
222 222 pic_level |= pci_irq_levels[i];
223 223 }
224   - pic_set_irq(pic_irq, pic_level);
  224 + qemu_set_irq(pic[pic_irq], pic_level);
225 225 }
226 226 }
227 227  
... ...
hw/pl011.c
... ... @@ -27,8 +27,7 @@ typedef struct {
27 27 int read_count;
28 28 int read_trigger;
29 29 CharDriverState *chr;
30   - void *pic;
31   - int irq;
  30 + qemu_irq irq;
32 31 } pl011_state;
33 32  
34 33 #define PL011_INT_TX 0x20
... ... @@ -47,7 +46,7 @@ static void pl011_update(pl011_state *s)
47 46 uint32_t flags;
48 47  
49 48 flags = s->int_level & s->int_enabled;
50   - pic_set_irq_new(s->pic, s->irq, flags != 0);
  49 + qemu_set_irq(s->irq, flags != 0);
51 50 }
52 51  
53 52 static uint32_t pl011_read(void *opaque, target_phys_addr_t offset)
... ... @@ -224,7 +223,7 @@ static CPUWriteMemoryFunc *pl011_writefn[] = {
224 223 pl011_write
225 224 };
226 225  
227   -void pl011_init(uint32_t base, void *pic, int irq,
  226 +void pl011_init(uint32_t base, qemu_irq irq,
228 227 CharDriverState *chr)
229 228 {
230 229 int iomemtype;
... ... @@ -235,7 +234,6 @@ void pl011_init(uint32_t base, void *pic, int irq,
235 234 pl011_writefn, s);
236 235 cpu_register_physical_memory(base, 0x00000fff, iomemtype);
237 236 s->base = base;
238   - s->pic = pic;
239 237 s->irq = irq;
240 238 s->chr = chr;
241 239 s->read_trigger = 1;
... ...
hw/pl050.c
... ... @@ -15,9 +15,8 @@ typedef struct {
15 15 uint32_t cr;
16 16 uint32_t clk;
17 17 uint32_t last;
18   - void *pic;
19 18 int pending;
20   - int irq;
  19 + qemu_irq irq;
21 20 int is_mouse;
22 21 } pl050_state;
23 22  
... ... @@ -32,7 +31,7 @@ static void pl050_update(void *opaque, int level)
32 31 s->pending = level;
33 32 raise = (s->pending && (s->cr & 0x10) != 0)
34 33 || (s->cr & 0x08) != 0;
35   - pic_set_irq_new(s->pic, s->irq, raise);
  34 + qemu_set_irq(s->irq, raise);
36 35 }
37 36  
38 37 static uint32_t pl050_read(void *opaque, target_phys_addr_t offset)
... ... @@ -105,7 +104,7 @@ static CPUWriteMemoryFunc *pl050_writefn[] = {
105 104 pl050_write
106 105 };
107 106  
108   -void pl050_init(uint32_t base, void *pic, int irq, int is_mouse)
  107 +void pl050_init(uint32_t base, qemu_irq irq, int is_mouse)
109 108 {
110 109 int iomemtype;
111 110 pl050_state *s;
... ... @@ -115,7 +114,6 @@ void pl050_init(uint32_t base, void *pic, int irq, int is_mouse)
115 114 pl050_writefn, s);
116 115 cpu_register_physical_memory(base, 0x00000fff, iomemtype);
117 116 s->base = base;
118   - s->pic = pic;
119 117 s->irq = irq;
120 118 s->is_mouse = is_mouse;
121 119 if (is_mouse)
... ...
hw/pl080.c
... ... @@ -49,8 +49,7 @@ typedef struct {
49 49 int nchannels;
50 50 /* Flag to avoid recursive DMA invocations. */
51 51 int running;
52   - void *pic;
53   - int irq;
  52 + qemu_irq irq;
54 53 } pl080_state;
55 54  
56 55 static const unsigned char pl080_id[] =
... ... @@ -63,9 +62,9 @@ static void pl080_update(pl080_state *s)
63 62 {
64 63 if ((s->tc_int & s->tc_mask)
65 64 || (s->err_int & s->err_mask))
66   - pic_set_irq_new(s->pic, s->irq, 1);
  65 + qemu_irq_raise(s->irq);
67 66 else
68   - pic_set_irq_new(s->pic, s->irq, 1);
  67 + qemu_irq_lower(s->irq);
69 68 }
70 69  
71 70 static void pl080_run(pl080_state *s)
... ... @@ -325,7 +324,7 @@ static CPUWriteMemoryFunc *pl080_writefn[] = {
325 324  
326 325 /* The PL080 and PL081 are the same except for the number of channels
327 326 they implement (8 and 2 respectively). */
328   -void *pl080_init(uint32_t base, void *pic, int irq, int nchannels)
  327 +void *pl080_init(uint32_t base, qemu_irq irq, int nchannels)
329 328 {
330 329 int iomemtype;
331 330 pl080_state *s;
... ... @@ -335,7 +334,6 @@ void *pl080_init(uint32_t base, void *pic, int irq, int nchannels)
335 334 pl080_writefn, s);
336 335 cpu_register_physical_memory(base, 0x00000fff, iomemtype);
337 336 s->base = base;
338   - s->pic = pic;
339 337 s->irq = irq;
340 338 s->nchannels = nchannels;
341 339 /* ??? Save/restore. */
... ...
hw/pl110.c
... ... @@ -29,7 +29,6 @@ typedef struct {
29 29 DisplayState *ds;
30 30 /* The Versatile/PB uses a slightly modified PL110 controller. */
31 31 int versatile;
32   - void *pic;
33 32 uint32_t timing[4];
34 33 uint32_t cr;
35 34 uint32_t upbase;
... ... @@ -42,7 +41,7 @@ typedef struct {
42 41 int invalidate;
43 42 uint32_t pallette[256];
44 43 uint32_t raw_pallette[128];
45   - int irq;
  44 + qemu_irq irq;
46 45 } pl110_state;
47 46  
48 47 static const unsigned char pl110_id[] =
... ... @@ -399,7 +398,7 @@ static CPUWriteMemoryFunc *pl110_writefn[] = {
399 398 pl110_write
400 399 };
401 400  
402   -void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq,
  401 +void *pl110_init(DisplayState *ds, uint32_t base, qemu_irq irq,
403 402 int versatile)
404 403 {
405 404 pl110_state *s;
... ... @@ -412,7 +411,6 @@ void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq,
412 411 s->base = base;
413 412 s->ds = ds;
414 413 s->versatile = versatile;
415   - s->pic = pic;
416 414 s->irq = irq;
417 415 graphic_console_init(ds, pl110_update_display, pl110_invalidate_display,
418 416 NULL, s);
... ...
hw/pl181.c
... ... @@ -40,8 +40,7 @@ typedef struct {
40 40 int fifo_pos;
41 41 int fifo_len;
42 42 uint32_t fifo[PL181_FIFO_LEN];
43   - void *pic;
44   - int irq[2];
  43 + qemu_irq irq[2];
45 44 } pl181_state;
46 45  
47 46 #define PL181_CMD_INDEX 0x3f
... ... @@ -96,7 +95,7 @@ static void pl181_update(pl181_state *s)
96 95 {
97 96 int i;
98 97 for (i = 0; i < 2; i++) {
99   - pic_set_irq_new(s->pic, s->irq[i], (s->status & s->mask[i]) != 0);
  98 + qemu_set_irq(s->irq[i], (s->status & s->mask[i]) != 0);
100 99 }
101 100 }
102 101  
... ... @@ -425,7 +424,7 @@ static void pl181_reset(void *opaque)
425 424 }
426 425  
427 426 void pl181_init(uint32_t base, BlockDriverState *bd,
428   - void *pic, int irq0, int irq1)
  427 + qemu_irq irq0, qemu_irq irq1)
429 428 {
430 429 int iomemtype;
431 430 pl181_state *s;
... ... @@ -436,7 +435,6 @@ void pl181_init(uint32_t base, BlockDriverState *bd,
436 435 cpu_register_physical_memory(base, 0x00000fff, iomemtype);
437 436 s->base = base;
438 437 s->card = sd_init(bd);
439   - s->pic = pic;
440 438 s->irq[0] = irq0;
441 439 s->irq[1] = irq1;
442 440 qemu_register_reset(pl181_reset, s);
... ...
hw/pl190.c
... ... @@ -17,7 +17,6 @@
17 17 #define PL190_NUM_PRIO 17
18 18  
19 19 typedef struct {
20   - arm_pic_handler handler;
21 20 uint32_t base;
22 21 DisplayState *ds;
23 22 uint32_t level;
... ... @@ -33,9 +32,8 @@ typedef struct {
33 32 /* Current priority level. */
34 33 int priority;
35 34 int prev_prio[PL190_NUM_PRIO];
36   - void *parent;
37   - int irq;
38   - int fiq;
  35 + qemu_irq irq;
  36 + qemu_irq fiq;
39 37 } pl190_state;
40 38  
41 39 static const unsigned char pl190_id[] =
... ... @@ -53,9 +51,9 @@ static void pl190_update(pl190_state *s)
53 51 int set;
54 52  
55 53 set = (level & s->prio_mask[s->priority]) != 0;
56   - pic_set_irq_new(s->parent, s->irq, set);
  54 + qemu_set_irq(s->irq, set);
57 55 set = ((s->level | s->soft_level) & s->fiq_select) != 0;
58   - pic_set_irq_new(s->parent, s->fiq, set);
  56 + qemu_set_irq(s->fiq, set);
59 57 }
60 58  
61 59 static void pl190_set_irq(void *opaque, int irq, int level)
... ... @@ -232,21 +230,21 @@ void pl190_reset(pl190_state *s)
232 230 pl190_update_vectors(s);
233 231 }
234 232  
235   -void *pl190_init(uint32_t base, void *parent, int irq, int fiq)
  233 +qemu_irq *pl190_init(uint32_t base, qemu_irq irq, qemu_irq fiq)
236 234 {
237 235 pl190_state *s;
  236 + qemu_irq *qi;
238 237 int iomemtype;
239 238  
240 239 s = (pl190_state *)qemu_mallocz(sizeof(pl190_state));
241 240 iomemtype = cpu_register_io_memory(0, pl190_readfn,
242 241 pl190_writefn, s);
243 242 cpu_register_physical_memory(base, 0x00000fff, iomemtype);
244   - s->handler = pl190_set_irq;
  243 + qi = qemu_allocate_irqs(pl190_set_irq, s, 16);
245 244 s->base = base;
246   - s->parent = parent;
247 245 s->irq = irq;
248 246 s->fiq = fiq;
249 247 pl190_reset(s);
250 248 /* ??? Save/restore. */
251   - return s;
  249 + return qi;
252 250 }
... ...
hw/ppc.c
... ... @@ -31,8 +31,7 @@ extern int loglevel;
31 31 /* PowerPC internal fake IRQ controller
32 32 * used to manage multiple sources hardware events
33 33 */
34   -/* XXX: should be protected */
35   -void ppc_set_irq (void *opaque, int n_IRQ, int level)
  34 +static void ppc_set_irq (void *opaque, int n_IRQ, int level)
36 35 {
37 36 CPUState *env;
38 37  
... ... @@ -51,6 +50,17 @@ void ppc_set_irq (void *opaque, int n_IRQ, int level)
51 50 #endif
52 51 }
53 52  
  53 +void cpu_ppc_irq_init_cpu(CPUState *env)
  54 +{
  55 + qemu_irq *qi;
  56 + int i;
  57 +
  58 + qi = qemu_allocate_irqs(ppc_set_irq, env, 32);
  59 + for (i = 0; i < 32; i++) {
  60 + env->irq[i] = qi[i];
  61 + }
  62 +}
  63 +
54 64 /* External IRQ callback from OpenPIC IRQ controller */
55 65 void ppc_openpic_irq (void *opaque, int n_IRQ, int level)
56 66 {
... ...
hw/ppc_chrp.c
... ... @@ -264,11 +264,6 @@ static int vga_osi_call(CPUState *env)
264 264 return 1; /* osi_call handled */
265 265 }
266 266  
267   -/* XXX: suppress that */
268   -static void pic_irq_request(void *opaque, int level)
269   -{
270   -}
271   -
272 267 static uint8_t nvram_chksum(const uint8_t *buf, int n)
273 268 {
274 269 int sum, i;
... ... @@ -303,8 +298,7 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
303 298 {
304 299 CPUState *env;
305 300 char buf[1024];
306   - SetIRQFunc *set_irq;
307   - void *pic;
  301 + qemu_irq *pic;
308 302 m48t59_t *nvram;
309 303 int unin_memory;
310 304 int linux_boot, i;
... ... @@ -314,6 +308,7 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
314 308 PCIBus *pci_bus;
315 309 const char *arch_name;
316 310 int vga_bios_size, bios_size;
  311 + qemu_irq *dummy_irq;
317 312  
318 313 linux_boot = (kernel_filename != NULL);
319 314  
... ... @@ -335,6 +330,7 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
335 330 cpu_abort(env, "Unable to find PowerPC CPU definition\n");
336 331 }
337 332 cpu_ppc_register(env, def);
  333 + cpu_ppc_irq_init_cpu(env);
338 334  
339 335 /* Set time-base frequency to 100 Mhz */
340 336 cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
... ... @@ -416,17 +412,16 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
416 412  
417 413 /* init basic PC hardware */
418 414 pic = heathrow_pic_init(&heathrow_pic_mem_index);
419   - set_irq = heathrow_pic_set_irq;
420 415 pci_bus = pci_grackle_init(0xfec00000, pic);
421 416 pci_vga_init(pci_bus, ds, phys_ram_base + ram_size,
422 417 ram_size, vga_ram_size,
423 418 vga_bios_offset, vga_bios_size);
424 419  
425 420 /* XXX: suppress that */
426   - isa_pic = pic_init(pic_irq_request, NULL);
  421 + dummy_irq = i8259_init(NULL);
427 422  
428 423 /* XXX: use Mac Serial port */
429   - serial_init(&pic_set_irq_new, isa_pic, 0x3f8, 4, serial_hds[0]);
  424 + serial_init(0x3f8, dummy_irq[4], serial_hds[0]);
430 425  
431 426 for(i = 0; i < nb_nics; i++) {
432 427 if (!nd_table[i].model)
... ... @@ -437,7 +432,7 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
437 432 pci_cmd646_ide_init(pci_bus, &bs_table[0], 0);
438 433  
439 434 /* cuda also initialize ADB */
440   - cuda_mem_index = cuda_init(set_irq, pic, 0x12);
  435 + cuda_mem_index = cuda_init(pic[0x12]);
441 436  
442 437 adb_kbd_init(&adb_bus);
443 438 adb_mouse_init(&adb_bus);
... ... @@ -450,7 +445,7 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
450 445  
451 446 macio_init(pci_bus, 0x0017);
452 447  
453   - nvram = m48t59_init(8, 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
  448 + nvram = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
454 449  
455 450 arch_name = "HEATHROW";
456 451 } else {
... ... @@ -464,7 +459,6 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
464 459 cpu_register_physical_memory(0xf8000000, 0x00001000, unin_memory);
465 460  
466 461 pic = openpic_init(NULL, &ppc_openpic_irq, &openpic_mem_index, 1, &env);
467   - set_irq = openpic_set_irq;
468 462 pci_bus = pci_pmac_init(pic);
469 463 /* init basic PC hardware */
470 464 pci_vga_init(pci_bus, ds, phys_ram_base + ram_size,
... ... @@ -472,30 +466,30 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
472 466 vga_bios_offset, vga_bios_size);
473 467  
474 468 /* XXX: suppress that */
475   - isa_pic = pic_init(pic_irq_request, NULL);
  469 + dummy_irq = i8259_init(NULL);
476 470  
477 471 /* XXX: use Mac Serial port */
478   - serial_init(&pic_set_irq_new, isa_pic, 0x3f8, 4, serial_hds[0]);
  472 + serial_init(0x3f8, dummy_irq[4], serial_hds[0]);
479 473 for(i = 0; i < nb_nics; i++) {
480 474 if (!nd_table[i].model)
481 475 nd_table[i].model = "ne2k_pci";
482 476 pci_nic_init(pci_bus, &nd_table[i], -1);
483 477 }
484 478 #if 1
485   - ide0_mem_index = pmac_ide_init(&bs_table[0], set_irq, pic, 0x13);
486   - ide1_mem_index = pmac_ide_init(&bs_table[2], set_irq, pic, 0x14);
  479 + ide0_mem_index = pmac_ide_init(&bs_table[0], pic[0x13]);
  480 + ide1_mem_index = pmac_ide_init(&bs_table[2], pic[0x14]);
487 481 #else
488 482 pci_cmd646_ide_init(pci_bus, &bs_table[0], 0);
489 483 #endif
490 484 /* cuda also initialize ADB */
491   - cuda_mem_index = cuda_init(set_irq, pic, 0x19);
  485 + cuda_mem_index = cuda_init(pic[0x19]);
492 486  
493 487 adb_kbd_init(&adb_bus);
494 488 adb_mouse_init(&adb_bus);
495 489  
496 490 macio_init(pci_bus, 0x0022);
497 491  
498   - nvram = m48t59_init(8, 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
  492 + nvram = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
499 493  
500 494 arch_name = "MAC99";
501 495 }
... ...
hw/ppc_prep.c
... ... @@ -96,11 +96,6 @@ static uint32_t speaker_ioport_read (void *opaque, uint32_t addr)
96 96 return 0;
97 97 }
98 98  
99   -static void pic_irq_request (void *opaque, int level)
100   -{
101   - ppc_set_irq(opaque, PPC_INTERRUPT_EXT, level);
102   -}
103   -
104 99 /* PCI intack register */
105 100 /* Read-only register (?) */
106 101 static void _PPC_intack_write (void *opaque,
... ... @@ -532,6 +527,7 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
532 527 uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
533 528 ppc_def_t *def;
534 529 PCIBus *pci_bus;
  530 + qemu_irq *i8259;
535 531  
536 532 sysctrl = qemu_mallocz(sizeof(sysctrl_t));
537 533 if (sysctrl == NULL)
... ... @@ -552,6 +548,7 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
552 548 cpu_abort(env, "Unable to find PowerPC CPU definition\n");
553 549 }
554 550 cpu_ppc_register(env, def);
  551 + cpu_ppc_irq_init_cpu(env);
555 552 /* Set time-base frequency to 100 Mhz */
556 553 cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
557 554  
... ... @@ -602,7 +599,8 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
602 599 }
603 600  
604 601 isa_mem_base = 0xc0000000;
605   - pci_bus = pci_prep_init();
  602 + i8259 = i8259_init(first_cpu->irq[PPC_INTERRUPT_EXT]);
  603 + pci_bus = pci_prep_init(i8259);
606 604 // pci_bus = i440fx_init();
607 605 /* Register 8 MB of ISA IO space (needed for non-contiguous map) */
608 606 PPC_io_memory = cpu_register_io_memory(0, PPC_prep_io_read,
... ... @@ -612,19 +610,18 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
612 610 /* init basic PC hardware */
613 611 pci_vga_init(pci_bus, ds, phys_ram_base + ram_size, ram_size,
614 612 vga_ram_size, 0, 0);
615   - rtc_init(0x70, 8);
616 613 // openpic = openpic_init(0x00000000, 0xF0000000, 1);
617   - isa_pic = pic_init(pic_irq_request, first_cpu);
618   - // pit = pit_init(0x40, 0);
  614 + // pit = pit_init(0x40, i8259[0]);
  615 + rtc_init(0x70, i8259[8]);
619 616  
620   - serial_init(&pic_set_irq_new, isa_pic, 0x3f8, 4, serial_hds[0]);
  617 + serial_init(0x3f8, i8259[4], serial_hds[0]);
621 618 nb_nics1 = nb_nics;
622 619 if (nb_nics1 > NE2000_NB_MAX)
623 620 nb_nics1 = NE2000_NB_MAX;
624 621 for(i = 0; i < nb_nics1; i++) {
625 622 if (nd_table[0].model == NULL
626 623 || strcmp(nd_table[0].model, "ne2k_isa") == 0) {
627   - isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]);
  624 + isa_ne2000_init(ne2000_io[i], i8259[ne2000_irq[i]], &nd_table[i]);
628 625 } else {
629 626 fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
630 627 exit (1);
... ... @@ -632,15 +629,15 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
632 629 }
633 630  
634 631 for(i = 0; i < 2; i++) {
635   - isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
  632 + isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]],
636 633 bs_table[2 * i], bs_table[2 * i + 1]);
637 634 }
638   - kbd_init();
  635 + i8042_init(i8259[1], i8259[12], 0x60);
639 636 DMA_init(1);
640 637 // AUD_init();
641 638 // SB16_init();
642 639  
643   - fdctrl_init(6, 2, 0, 0x3f0, fd_table);
  640 + fdctrl_init(i8259[6], 2, 0, 0x3f0, fd_table);
644 641  
645 642 /* Register speaker port */
646 643 register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL);
... ... @@ -667,7 +664,7 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
667 664 usb_ohci_init_pci(pci_bus, 3, -1);
668 665 }
669 666  
670   - nvram = m48t59_init(8, 0, 0x0074, NVRAM_SIZE, 59);
  667 + nvram = m48t59_init(i8259[8], 0, 0x0074, NVRAM_SIZE, 59);
671 668 if (nvram == NULL)
672 669 return;
673 670 sysctrl->nvram = nvram;
... ...
hw/prep_pci.c
... ... @@ -123,19 +123,19 @@ static int prep_map_irq(PCIDevice *pci_dev, int irq_num)
123 123 return (irq_num + (pci_dev->devfn >> 3)) & 1;
124 124 }
125 125  
126   -static void prep_set_irq(void *pic, int irq_num, int level)
  126 +static void prep_set_irq(qemu_irq *pic, int irq_num, int level)
127 127 {
128   - pic_set_irq(irq_num ? 11 : 9, level);
  128 + qemu_set_irq(pic[irq_num ? 11 : 9], level);
129 129 }
130 130  
131   -PCIBus *pci_prep_init(void)
  131 +PCIBus *pci_prep_init(qemu_irq *pic)
132 132 {
133 133 PREPPCIState *s;
134 134 PCIDevice *d;
135 135 int PPC_io_memory;
136 136  
137 137 s = qemu_mallocz(sizeof(PREPPCIState));
138   - s->bus = pci_register_bus(prep_set_irq, prep_map_irq, NULL, 0, 2);
  138 + s->bus = pci_register_bus(prep_set_irq, prep_map_irq, pic, 0, 2);
139 139  
140 140 register_ioport_write(0xcf8, 4, 4, pci_prep_addr_writel, s);
141 141 register_ioport_read(0xcf8, 4, 4, pci_prep_addr_readl, s);
... ...
hw/realview.c
... ... @@ -18,7 +18,7 @@ static void realview_init(int ram_size, int vga_ram_size, int boot_device,
18 18 const char *initrd_filename, const char *cpu_model)
19 19 {
20 20 CPUState *env;
21   - void *pic;
  21 + qemu_irq *pic;
22 22 void *scsi_hba;
23 23 PCIBus *pci_bus;
24 24 NICInfo *nd;
... ... @@ -38,24 +38,24 @@ static void realview_init(int ram_size, int vga_ram_size, int boot_device,
38 38 /* ??? The documentation says GIC1 is nFIQ and either GIC2 or GIC3
39 39 is nIRQ (there are inconsistencies). However Linux 2.6.17 expects
40 40 GIC1 to be nIRQ and ignores all the others, so do that for now. */
41   - pic = arm_gic_init(0x10040000, pic, ARM_PIC_CPU_IRQ);
42   - pl050_init(0x10006000, pic, 20, 0);
43   - pl050_init(0x10007000, pic, 21, 1);
  41 + pic = arm_gic_init(0x10040000, pic[ARM_PIC_CPU_IRQ]);
  42 + pl050_init(0x10006000, pic[20], 0);
  43 + pl050_init(0x10007000, pic[21], 1);
44 44  
45   - pl011_init(0x10009000, pic, 12, serial_hds[0]);
46   - pl011_init(0x1000a000, pic, 13, serial_hds[1]);
47   - pl011_init(0x1000b000, pic, 14, serial_hds[2]);
48   - pl011_init(0x1000c000, pic, 15, serial_hds[3]);
  45 + pl011_init(0x10009000, pic[12], serial_hds[0]);
  46 + pl011_init(0x1000a000, pic[13], serial_hds[1]);
  47 + pl011_init(0x1000b000, pic[14], serial_hds[2]);
  48 + pl011_init(0x1000c000, pic[15], serial_hds[3]);
49 49  
50 50 /* DMA controller is optional, apparently. */
51   - pl080_init(0x10030000, pic, 24, 2);
  51 + pl080_init(0x10030000, pic[24], 2);
52 52  
53   - sp804_init(0x10011000, pic, 4);
54   - sp804_init(0x10012000, pic, 5);
  53 + sp804_init(0x10011000, pic[4]);
  54 + sp804_init(0x10012000, pic[5]);
55 55  
56   - pl110_init(ds, 0x10020000, pic, 23, 1);
  56 + pl110_init(ds, 0x10020000, pic[23], 1);
57 57  
58   - pl181_init(0x10005000, sd_bdrv, pic, 17, 18);
  58 + pl181_init(0x10005000, sd_bdrv, pic[17], pic[18]);
59 59  
60 60 pci_bus = pci_vpb_init(pic, 48, 1);
61 61 if (usb_enabled) {
... ... @@ -72,7 +72,7 @@ static void realview_init(int ram_size, int vga_ram_size, int boot_device,
72 72 if (!nd->model)
73 73 nd->model = done_smc ? "rtl8139" : "smc91c111";
74 74 if (strcmp(nd->model, "smc91c111") == 0) {
75   - smc91c111_init(nd, 0x4e000000, pic, 28);
  75 + smc91c111_init(nd, 0x4e000000, pic[28]);
76 76 } else {
77 77 pci_nic_init(pci_bus, nd, -1);
78 78 }
... ...
hw/rtl8139.c
... ... @@ -687,7 +687,7 @@ static void rtl8139_update_irq(RTL8139State *s)
687 687 DEBUG_PRINT(("RTL8139: Set IRQ to %d (%04x %04x)\n",
688 688 isr ? 1 : 0, s->IntrStatus, s->IntrMask));
689 689  
690   - pci_set_irq(s->pci_dev, 0, (isr != 0));
  690 + qemu_set_irq(s->pci_dev->irq[0], (isr != 0));
691 691 }
692 692  
693 693 #define POLYNOMIAL 0x04c11db6
... ...
hw/sb16.c
... ... @@ -54,6 +54,7 @@ static struct {
54 54  
55 55 typedef struct SB16State {
56 56 QEMUSoundCard card;
  57 + qemu_irq *pic;
57 58 int irq;
58 59 int dma;
59 60 int hdma;
... ... @@ -187,7 +188,7 @@ static void aux_timer (void *opaque)
187 188 {
188 189 SB16State *s = opaque;
189 190 s->can_write = 1;
190   - pic_set_irq (s->irq, 1);
  191 + qemu_irq_raise (s->pic[s->irq]);
191 192 }
192 193  
193 194 #define DMA8_AUTO 1
... ... @@ -595,7 +596,7 @@ static void command (SB16State *s, uint8_t cmd)
595 596 case 0xf3:
596 597 dsp_out_data (s, 0xaa);
597 598 s->mixer_regs[0x82] |= (cmd == 0xf2) ? 1 : 2;
598   - pic_set_irq (s->irq, 1);
  599 + qemu_irq_raise (s->pic[s->irq]);
599 600 break;
600 601  
601 602 case 0xf9:
... ... @@ -763,7 +764,7 @@ static void complete (SB16State *s)
763 764 bytes = samples << s->fmt_stereo << (s->fmt_bits == 16);
764 765 ticks = (bytes * ticks_per_sec) / freq;
765 766 if (ticks < ticks_per_sec / 1024) {
766   - pic_set_irq (s->irq, 1);
  767 + qemu_irq_raise (s->pic[s->irq]);
767 768 }
768 769 else {
769 770 if (s->aux_ts) {
... ... @@ -855,10 +856,10 @@ static void legacy_reset (SB16State *s)
855 856  
856 857 static void reset (SB16State *s)
857 858 {
858   - pic_set_irq (s->irq, 0);
  859 + qemu_irq_lower (s->pic[s->irq]);
859 860 if (s->dma_auto) {
860   - pic_set_irq (s->irq, 1);
861   - pic_set_irq (s->irq, 0);
  861 + qemu_irq_raise (s->pic[s->irq]);
  862 + qemu_irq_lower (s->pic[s->irq]);
862 863 }
863 864  
864 865 s->mixer_regs[0x82] = 0;
... ... @@ -894,7 +895,7 @@ static IO_WRITE_PROTO (dsp_write)
894 895 if (s->v2x6 == 1) {
895 896 if (0 && s->highspeed) {
896 897 s->highspeed = 0;
897   - pic_set_irq (s->irq, 0);
  898 + qemu_irq_lower (s->pic[s->irq]);
898 899 control (s, 0);
899 900 }
900 901 else {
... ... @@ -1005,7 +1006,7 @@ static IO_READ_PROTO (dsp_read)
1005 1006 if (s->mixer_regs[0x82] & 1) {
1006 1007 ack = 1;
1007 1008 s->mixer_regs[0x82] &= 1;
1008   - pic_set_irq (s->irq, 0);
  1009 + qemu_irq_lower (s->pic[s->irq]);
1009 1010 }
1010 1011 break;
1011 1012  
... ... @@ -1014,7 +1015,7 @@ static IO_READ_PROTO (dsp_read)
1014 1015 if (s->mixer_regs[0x82] & 2) {
1015 1016 ack = 1;
1016 1017 s->mixer_regs[0x82] &= 2;
1017   - pic_set_irq (s->irq, 0);
  1018 + qemu_irq_lower (s->pic[s->irq]);
1018 1019 }
1019 1020 break;
1020 1021  
... ... @@ -1222,7 +1223,7 @@ static int SB_read_DMA (void *opaque, int nchan, int dma_pos, int dma_len)
1222 1223  
1223 1224 if (s->left_till_irq <= 0) {
1224 1225 s->mixer_regs[0x82] |= (nchan & 4) ? 2 : 1;
1225   - pic_set_irq (s->irq, 1);
  1226 + qemu_irq_raise (s->pic[s->irq]);
1226 1227 if (0 == s->dma_auto) {
1227 1228 control (s, 0);
1228 1229 speaker (s, 0);
... ... @@ -1389,7 +1390,7 @@ static int SB_load (QEMUFile *f, void *opaque, int version_id)
1389 1390 return 0;
1390 1391 }
1391 1392  
1392   -int SB16_init (AudioState *audio)
  1393 +int SB16_init (AudioState *audio, qemu_irq *pic)
1393 1394 {
1394 1395 SB16State *s;
1395 1396 int i;
... ... @@ -1409,6 +1410,7 @@ int SB16_init (AudioState *audio)
1409 1410 }
1410 1411  
1411 1412 s->cmd = -1;
  1413 + s->pic = pic;
1412 1414 s->irq = conf.irq;
1413 1415 s->dma = conf.dma;
1414 1416 s->hdma = conf.hdma;
... ...
hw/serial.c
... ... @@ -83,9 +83,7 @@ struct SerialState {
83 83 /* NOTE: this hidden state is necessary for tx irq generation as
84 84 it can be reset while reading iir */
85 85 int thr_ipending;
86   - SetIRQFunc *set_irq;
87   - void *irq_opaque;
88   - int irq;
  86 + qemu_irq irq;
89 87 CharDriverState *chr;
90 88 int last_break_enable;
91 89 target_ulong base;
... ... @@ -102,9 +100,9 @@ static void serial_update_irq(SerialState *s)
102 100 s->iir = UART_IIR_NO_INT;
103 101 }
104 102 if (s->iir != UART_IIR_NO_INT) {
105   - s->set_irq(s->irq_opaque, s->irq, 1);
  103 + qemu_irq_raise(s->irq);
106 104 } else {
107   - s->set_irq(s->irq_opaque, s->irq, 0);
  105 + qemu_irq_lower(s->irq);
108 106 }
109 107 }
110 108  
... ... @@ -345,16 +343,13 @@ static int serial_load(QEMUFile *f, void *opaque, int version_id)
345 343 }
346 344  
347 345 /* If fd is zero, it means that the serial device uses the console */
348   -SerialState *serial_init(SetIRQFunc *set_irq, void *opaque,
349   - int base, int irq, CharDriverState *chr)
  346 +SerialState *serial_init(int base, qemu_irq irq, CharDriverState *chr)
350 347 {
351 348 SerialState *s;
352 349  
353 350 s = qemu_mallocz(sizeof(SerialState));
354 351 if (!s)
355 352 return NULL;
356   - s->set_irq = set_irq;
357   - s->irq_opaque = opaque;
358 353 s->irq = irq;
359 354 s->lsr = UART_LSR_TEMT | UART_LSR_THRE;
360 355 s->iir = UART_IIR_NO_INT;
... ... @@ -428,9 +423,8 @@ static CPUWriteMemoryFunc *serial_mm_write[] = {
428 423 &serial_mm_writel,
429 424 };
430 425  
431   -SerialState *serial_mm_init (SetIRQFunc *set_irq, void *opaque,
432   - target_ulong base, int it_shift,
433   - int irq, CharDriverState *chr,
  426 +SerialState *serial_mm_init (target_ulong base, int it_shift,
  427 + qemu_irq irq, CharDriverState *chr,
434 428 int ioregister)
435 429 {
436 430 SerialState *s;
... ... @@ -439,8 +433,6 @@ SerialState *serial_mm_init (SetIRQFunc *set_irq, void *opaque,
439 433 s = qemu_mallocz(sizeof(SerialState));
440 434 if (!s)
441 435 return NULL;
442   - s->set_irq = set_irq;
443   - s->irq_opaque = opaque;
444 436 s->irq = irq;
445 437 s->lsr = UART_LSR_TEMT | UART_LSR_THRE;
446 438 s->iir = UART_IIR_NO_INT;
... ...
hw/shix.c
... ... @@ -42,11 +42,6 @@ void irq_info(void)
42 42 /* XXXXX */
43 43 }
44 44  
45   -void pic_set_irq(int irq, int level)
46   -{
47   - /* XXXXX */
48   -}
49   -
50 45 void pic_info()
51 46 {
52 47 /* XXXXX */
... ...
hw/slavio_intctl.c
... ... @@ -277,7 +277,7 @@ static void slavio_check_interrupts(void *opaque)
277 277 * "irq" here is the bit number in the system interrupt register to
278 278 * separate serial and keyboard interrupts sharing a level.
279 279 */
280   -void pic_set_irq_new(void *opaque, int irq, int level)
  280 +void slavio_set_irq(void *opaque, int irq, int level)
281 281 {
282 282 SLAVIO_INTCTLState *s = opaque;
283 283  
... ... @@ -305,7 +305,7 @@ void pic_set_irq_cpu(void *opaque, int irq, int level, unsigned int cpu)
305 305  
306 306 DPRINTF("Set cpu %d local irq %d level %d\n", cpu, irq, level);
307 307 if (cpu == (unsigned int)-1) {
308   - pic_set_irq_new(opaque, irq, level);
  308 + slavio_set_irq(opaque, irq, level);
309 309 return;
310 310 }
311 311 if (irq < 32) {
... ... @@ -372,7 +372,8 @@ void slavio_intctl_set_cpu(void *opaque, unsigned int cpu, CPUState *env)
372 372 }
373 373  
374 374 void *slavio_intctl_init(uint32_t addr, uint32_t addrg,
375   - const uint32_t *intbit_to_level)
  375 + const uint32_t *intbit_to_level,
  376 + qemu_irq **irq)
376 377 {
377 378 int slavio_intctl_io_memory, slavio_intctlm_io_memory, i;
378 379 SLAVIO_INTCTLState *s;
... ... @@ -392,6 +393,7 @@ void *slavio_intctl_init(uint32_t addr, uint32_t addrg,
392 393  
393 394 register_savevm("slavio_intctl", addr, 1, slavio_intctl_save, slavio_intctl_load, s);
394 395 qemu_register_reset(slavio_intctl_reset, s);
  396 + *irq = qemu_allocate_irqs(slavio_set_irq, s, 32);
395 397 slavio_intctl_reset(s);
396 398 return s;
397 399 }
... ...
hw/slavio_misc.c
... ... @@ -36,19 +36,15 @@
36 36 #ifdef DEBUG_MISC
37 37 #define MISC_DPRINTF(fmt, args...) \
38 38 do { printf("MISC: " fmt , ##args); } while (0)
39   -#define pic_set_irq_new(intctl, irq, level) \
40   - do { printf("MISC: set_irq(%d): %d\n", (irq), (level)); \
41   - pic_set_irq_new((intctl), (irq),(level));} while (0)
42 39 #else
43 40 #define MISC_DPRINTF(fmt, args...)
44 41 #endif
45 42  
46 43 typedef struct MiscState {
47   - int irq;
  44 + qemu_irq irq;
48 45 uint8_t config;
49 46 uint8_t aux1, aux2;
50 47 uint8_t diag, mctrl, sysctrl;
51   - void *intctl;
52 48 } MiscState;
53 49  
54 50 #define MISC_MAXADDR 1
... ... @@ -58,9 +54,11 @@ static void slavio_misc_update_irq(void *opaque)
58 54 MiscState *s = opaque;
59 55  
60 56 if ((s->aux2 & 0x4) && (s->config & 0x8)) {
61   - pic_set_irq_new(s->intctl, s->irq, 1);
  57 + MISC_DPRINTF("Raise IRQ\n");
  58 + qemu_irq_raise(s->irq);
62 59 } else {
63   - pic_set_irq_new(s->intctl, s->irq, 0);
  60 + MISC_DPRINTF("Lower IRQ\n");
  61 + qemu_irq_lower(s->irq);
64 62 }
65 63 }
66 64  
... ... @@ -184,8 +182,10 @@ static CPUWriteMemoryFunc *slavio_misc_mem_write[3] = {
184 182 static void slavio_misc_save(QEMUFile *f, void *opaque)
185 183 {
186 184 MiscState *s = opaque;
  185 + int tmp;
187 186  
188   - qemu_put_be32s(f, &s->irq);
  187 + tmp = 0;
  188 + qemu_put_be32s(f, &tmp); /* ignored, was IRQ. */
189 189 qemu_put_8s(f, &s->config);
190 190 qemu_put_8s(f, &s->aux1);
191 191 qemu_put_8s(f, &s->aux2);
... ... @@ -197,11 +197,12 @@ static void slavio_misc_save(QEMUFile *f, void *opaque)
197 197 static int slavio_misc_load(QEMUFile *f, void *opaque, int version_id)
198 198 {
199 199 MiscState *s = opaque;
  200 + int tmp;
200 201  
201 202 if (version_id != 1)
202 203 return -EINVAL;
203 204  
204   - qemu_get_be32s(f, &s->irq);
  205 + qemu_get_be32s(f, &tmp);
205 206 qemu_get_8s(f, &s->config);
206 207 qemu_get_8s(f, &s->aux1);
207 208 qemu_get_8s(f, &s->aux2);
... ... @@ -211,7 +212,7 @@ static int slavio_misc_load(QEMUFile *f, void *opaque, int version_id)
211 212 return 0;
212 213 }
213 214  
214   -void *slavio_misc_init(uint32_t base, int irq, void *intctl)
  215 +void *slavio_misc_init(uint32_t base, qemu_irq irq)
215 216 {
216 217 int slavio_misc_io_memory;
217 218 MiscState *s;
... ... @@ -237,7 +238,6 @@ void *slavio_misc_init(uint32_t base, int irq, void *intctl)
237 238 cpu_register_physical_memory(base + 0xa000000, MISC_MAXADDR, slavio_misc_io_memory);
238 239  
239 240 s->irq = irq;
240   - s->intctl = intctl;
241 241  
242 242 register_savevm("slavio_misc", base, 1, slavio_misc_save, slavio_misc_load, s);
243 243 qemu_register_reset(slavio_misc_reset, s);
... ...
hw/slavio_serial.c
... ... @@ -52,9 +52,6 @@
52 52 #ifdef DEBUG_SERIAL
53 53 #define SER_DPRINTF(fmt, args...) \
54 54 do { printf("SER: " fmt , ##args); } while (0)
55   -#define pic_set_irq_new(intctl, irq, level) \
56   - do { printf("SER: set_irq(%d): %d\n", (irq), (level)); \
57   - pic_set_irq_new((intctl), (irq),(level));} while (0)
58 55 #else
59 56 #define SER_DPRINTF(fmt, args...)
60 57 #endif
... ... @@ -89,7 +86,7 @@ typedef struct {
89 86 } SERIOQueue;
90 87  
91 88 typedef struct ChannelState {
92   - int irq;
  89 + qemu_irq irq;
93 90 int reg;
94 91 int rxint, txint, rxint_under_svc, txint_under_svc;
95 92 chn_id_t chn; // this channel, A (base+4) or B (base+0)
... ... @@ -98,7 +95,6 @@ typedef struct ChannelState {
98 95 uint8_t rx, tx, wregs[16], rregs[16];
99 96 SERIOQueue queue;
100 97 CharDriverState *chr;
101   - void *intctl;
102 98 } ChannelState;
103 99  
104 100 struct SerialState {
... ... @@ -166,7 +162,8 @@ static void slavio_serial_update_irq(ChannelState *s)
166 162 irq = slavio_serial_update_irq_chn(s);
167 163 irq |= slavio_serial_update_irq_chn(s->otherchn);
168 164  
169   - pic_set_irq_new(s->intctl, s->irq, irq);
  165 + SER_DPRINTF("IRQ = %d\n", irq);
  166 + qemu_set_irq(s->irq, irq);
170 167 }
171 168  
172 169 static void slavio_serial_reset_chn(ChannelState *s)
... ... @@ -494,7 +491,9 @@ static CPUWriteMemoryFunc *slavio_serial_mem_write[3] = {
494 491  
495 492 static void slavio_serial_save_chn(QEMUFile *f, ChannelState *s)
496 493 {
497   - qemu_put_be32s(f, &s->irq);
  494 + int tmp;
  495 + tmp = 0;
  496 + qemu_put_be32s(f, &tmp); /* unused, was IRQ. */
498 497 qemu_put_be32s(f, &s->reg);
499 498 qemu_put_be32s(f, &s->rxint);
500 499 qemu_put_be32s(f, &s->txint);
... ... @@ -516,10 +515,12 @@ static void slavio_serial_save(QEMUFile *f, void *opaque)
516 515  
517 516 static int slavio_serial_load_chn(QEMUFile *f, ChannelState *s, int version_id)
518 517 {
  518 + int tmp;
  519 +
519 520 if (version_id > 2)
520 521 return -EINVAL;
521 522  
522   - qemu_get_be32s(f, &s->irq);
  523 + qemu_get_be32s(f, &tmp); /* unused */
523 524 qemu_get_be32s(f, &s->reg);
524 525 qemu_get_be32s(f, &s->rxint);
525 526 qemu_get_be32s(f, &s->txint);
... ... @@ -547,8 +548,8 @@ static int slavio_serial_load(QEMUFile *f, void *opaque, int version_id)
547 548  
548 549 }
549 550  
550   -SerialState *slavio_serial_init(int base, int irq, CharDriverState *chr1,
551   - CharDriverState *chr2, void *intctl)
  551 +SerialState *slavio_serial_init(int base, qemu_irq irq, CharDriverState *chr1,
  552 + CharDriverState *chr2)
552 553 {
553 554 int slavio_serial_io_memory, i;
554 555 SerialState *s;
... ... @@ -567,7 +568,6 @@ SerialState *slavio_serial_init(int base, int irq, CharDriverState *chr1,
567 568 s->chn[i].irq = irq;
568 569 s->chn[i].chn = 1 - i;
569 570 s->chn[i].type = ser;
570   - s->chn[i].intctl = intctl;
571 571 if (s->chn[i].chr) {
572 572 qemu_chr_add_handlers(s->chn[i].chr, serial_can_receive,
573 573 serial_receive1, serial_event, &s->chn[i]);
... ... @@ -665,7 +665,7 @@ static void sunmouse_event(void *opaque,
665 665 put_queue(s, 0);
666 666 }
667 667  
668   -void slavio_serial_ms_kbd_init(int base, int irq, void *intctl)
  668 +void slavio_serial_ms_kbd_init(int base, qemu_irq irq)
669 669 {
670 670 int slavio_serial_io_memory, i;
671 671 SerialState *s;
... ... @@ -677,7 +677,6 @@ void slavio_serial_ms_kbd_init(int base, int irq, void *intctl)
677 677 s->chn[i].irq = irq;
678 678 s->chn[i].chn = 1 - i;
679 679 s->chn[i].chr = NULL;
680   - s->chn[i].intctl = intctl;
681 680 }
682 681 s->chn[0].otherchn = &s->chn[1];
683 682 s->chn[1].otherchn = &s->chn[0];
... ...
hw/slavio_timer.c
... ... @@ -28,9 +28,6 @@
28 28 #ifdef DEBUG_TIMER
29 29 #define DPRINTF(fmt, args...) \
30 30 do { printf("TIMER: " fmt , ##args); } while (0)
31   -#define pic_set_irq_new(intctl, irq, level) \
32   - do { printf("TIMER: set_irq(%d): %d\n", (irq), (level)); \
33   - pic_set_irq_new((intctl), (irq),(level));} while (0)
34 31 #else
35 32 #define DPRINTF(fmt, args...)
36 33 #endif
... ...
hw/smc91c111.c
... ... @@ -24,8 +24,7 @@ typedef struct {
24 24 uint16_t gpr;
25 25 uint16_t ptr;
26 26 uint16_t ercv;
27   - void *pic;
28   - int irq;
  27 + qemu_irq irq;
29 28 int bank;
30 29 int packet_num;
31 30 int tx_alloc;
... ... @@ -86,7 +85,7 @@ static void smc91c111_update(smc91c111_state *s)
86 85 if (s->tx_fifo_done_len != 0)
87 86 s->int_level |= INT_TX;
88 87 level = (s->int_level & s->int_mask) != 0;
89   - pic_set_irq_new(s->pic, s->irq, level);
  88 + qemu_set_irq(s->irq, level);
90 89 }
91 90  
92 91 /* Try to allocate a packet. Returns 0x80 on failure. */
... ... @@ -693,7 +692,7 @@ static CPUWriteMemoryFunc *smc91c111_writefn[] = {
693 692 smc91c111_writel
694 693 };
695 694  
696   -void smc91c111_init(NICInfo *nd, uint32_t base, void *pic, int irq)
  695 +void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq)
697 696 {
698 697 smc91c111_state *s;
699 698 int iomemtype;
... ... @@ -703,7 +702,6 @@ void smc91c111_init(NICInfo *nd, uint32_t base, void *pic, int irq)
703 702 smc91c111_writefn, s);
704 703 cpu_register_physical_memory(base, 16, iomemtype);
705 704 s->base = base;
706   - s->pic = pic;
707 705 s->irq = irq;
708 706 memcpy(s->macaddr, nd->macaddr, 6);
709 707  
... ...
hw/sparc32_dma.c
... ... @@ -37,9 +37,6 @@
37 37 #ifdef DEBUG_DMA
38 38 #define DPRINTF(fmt, args...) \
39 39 do { printf("DMA: " fmt , ##args); } while (0)
40   -#define pic_set_irq_new(ctl, irq, level) \
41   - do { printf("DMA: set_irq(%d): %d\n", (irq), (level)); \
42   - pic_set_irq_new((ctl), (irq),(level));} while (0)
43 40 #else
44 41 #define DPRINTF(fmt, args...)
45 42 #endif
... ... @@ -58,17 +55,11 @@ typedef struct DMAState DMAState;
58 55  
59 56 struct DMAState {
60 57 uint32_t dmaregs[DMA_REGS];
61   - int espirq, leirq;
62   - void *iommu, *esp_opaque, *lance_opaque, *intctl;
  58 + qemu_irq espirq, leirq;
  59 + void *iommu, *esp_opaque, *lance_opaque;
  60 + qemu_irq *pic;
63 61 };
64 62  
65   -void ledma_set_irq(void *opaque, int isr)
66   -{
67   - DMAState *s = opaque;
68   -
69   - pic_set_irq_new(s->intctl, s->leirq, isr);
70   -}
71   -
72 63 /* Note: on sparc, the lance 16 bit bus is swapped */
73 64 void ledma_memory_read(void *opaque, target_phys_addr_t addr,
74 65 uint8_t *buf, int len, int do_bswap)
... ... @@ -125,8 +116,9 @@ void espdma_raise_irq(void *opaque)
125 116 {
126 117 DMAState *s = opaque;
127 118  
  119 + DPRINTF("Raise ESP IRQ\n");
128 120 s->dmaregs[0] |= DMA_INTR;
129   - pic_set_irq_new(s->intctl, s->espirq, 1);
  121 + qemu_irq_raise(s->espirq);
130 122 }
131 123  
132 124 void espdma_clear_irq(void *opaque)
... ... @@ -134,7 +126,8 @@ void espdma_clear_irq(void *opaque)
134 126 DMAState *s = opaque;
135 127  
136 128 s->dmaregs[0] &= ~DMA_INTR;
137   - pic_set_irq_new(s->intctl, s->espirq, 0);
  129 + DPRINTF("Lower ESP IRQ\n");
  130 + qemu_irq_lower(s->espirq);
138 131 }
139 132  
140 133 void espdma_memory_read(void *opaque, uint8_t *buf, int len)
... ... @@ -179,8 +172,10 @@ static void dma_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
179 172 DPRINTF("write dmareg[%d]: 0x%8.8x -> 0x%8.8x\n", saddr, s->dmaregs[saddr], val);
180 173 switch (saddr) {
181 174 case 0:
182   - if (!(val & DMA_INTREN))
183   - pic_set_irq_new(s->intctl, s->espirq, 0);
  175 + if (!(val & DMA_INTREN)) {
  176 + DPRINTF("Lower ESP IRQ\n");
  177 + qemu_irq_lower(s->espirq);
  178 + }
184 179 if (val & DMA_RESET) {
185 180 esp_reset(s->esp_opaque);
186 181 } else if (val & 0x40) {
... ... @@ -194,8 +189,12 @@ static void dma_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
194 189 s->dmaregs[0] |= DMA_LOADED;
195 190 break;
196 191 case 4:
197   - if (!(val & DMA_INTREN))
198   - pic_set_irq_new(s->intctl, s->leirq, 0);
  192 + /* ??? Should this mask out the lance IRQ? The NIC may re-assert
  193 + this IRQ unexpectedly. */
  194 + if (!(val & DMA_INTREN)) {
  195 + DPRINTF("Lower Lance IRQ\n");
  196 + qemu_irq_lower(s->leirq);
  197 + }
199 198 if (val & DMA_RESET)
200 199 pcnet_h_reset(s->lance_opaque);
201 200 val &= 0x0fffffff;
... ... @@ -250,7 +249,8 @@ static int dma_load(QEMUFile *f, void *opaque, int version_id)
250 249 return 0;
251 250 }
252 251  
253   -void *sparc32_dma_init(uint32_t daddr, int espirq, int leirq, void *iommu, void *intctl)
  252 +void *sparc32_dma_init(uint32_t daddr, qemu_irq espirq, qemu_irq leirq,
  253 + void *iommu)
254 254 {
255 255 DMAState *s;
256 256 int dma_io_memory;
... ... @@ -262,7 +262,6 @@ void *sparc32_dma_init(uint32_t daddr, int espirq, int leirq, void *iommu, void
262 262 s->espirq = espirq;
263 263 s->leirq = leirq;
264 264 s->iommu = iommu;
265   - s->intctl = intctl;
266 265  
267 266 dma_io_memory = cpu_register_io_memory(0, dma_mem_read, dma_mem_write, s);
268 267 cpu_register_physical_memory(daddr, 16 * 2, dma_io_memory);
... ...
hw/sun4m.c
... ... @@ -182,11 +182,6 @@ void irq_info()
182 182 slavio_irq_info(slavio_intctl);
183 183 }
184 184  
185   -void pic_set_irq(int irq, int level)
186   -{
187   - pic_set_irq_new(slavio_intctl, irq, level);
188   -}
189   -
190 185 static void *slavio_misc;
191 186  
192 187 void qemu_system_powerdown(void)
... ... @@ -208,6 +203,7 @@ static void sun4m_hw_init(const struct hwdef *hwdef, int ram_size,
208 203 unsigned int i;
209 204 void *iommu, *dma, *main_esp, *main_lance = NULL;
210 205 const sparc_def_t *def;
  206 + qemu_irq *slavio_irq;
211 207  
212 208 /* init CPUs */
213 209 sparc_find_by_name(cpu_model, &def);
... ... @@ -230,38 +226,40 @@ static void sun4m_hw_init(const struct hwdef *hwdef, int ram_size,
230 226 iommu = iommu_init(hwdef->iommu_base);
231 227 slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
232 228 hwdef->intctl_base + 0x10000,
233   - &hwdef->intbit_to_level[0]);
  229 + &hwdef->intbit_to_level[0],
  230 + &slavio_irq);
234 231 for(i = 0; i < smp_cpus; i++) {
235 232 slavio_intctl_set_cpu(slavio_intctl, i, envs[i]);
236 233 }
237   - dma = sparc32_dma_init(hwdef->dma_base, hwdef->esp_irq,
238   - hwdef->le_irq, iommu, slavio_intctl);
  234 + dma = sparc32_dma_init(hwdef->dma_base, slavio_irq[hwdef->esp_irq],
  235 + slavio_irq[hwdef->le_irq], iommu);
239 236  
240 237 tcx_init(ds, hwdef->tcx_base, phys_ram_base + ram_size, ram_size,
241 238 hwdef->vram_size, graphic_width, graphic_height);
242 239 if (nd_table[0].vlan) {
243 240 if (nd_table[0].model == NULL
244 241 || strcmp(nd_table[0].model, "lance") == 0) {
245   - main_lance = lance_init(&nd_table[0], hwdef->le_base, dma);
  242 + main_lance = lance_init(&nd_table[0], hwdef->le_base, dma,
  243 + slavio_irq[hwdef->le_irq]);
246 244 } else {
247 245 fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
248 246 exit (1);
249 247 }
250 248 }
251   - nvram = m48t59_init(0, hwdef->nvram_base, 0, hwdef->nvram_size, 8);
  249 + nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
  250 + hwdef->nvram_size, 8);
252 251 for (i = 0; i < MAX_CPUS; i++) {
253 252 slavio_timer_init(hwdef->counter_base + i * TARGET_PAGE_SIZE,
254 253 hwdef->clock_irq, 0, i, slavio_intctl);
255 254 }
256 255 slavio_timer_init(hwdef->counter_base + 0x10000, hwdef->clock1_irq, 2,
257 256 (unsigned int)-1, slavio_intctl);
258   - slavio_serial_ms_kbd_init(hwdef->ms_kb_base, hwdef->ms_kb_irq,
259   - slavio_intctl);
  257 + slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq]);
260 258 // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
261 259 // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
262   - slavio_serial_init(hwdef->serial_base, hwdef->ser_irq,
263   - serial_hds[1], serial_hds[0], slavio_intctl);
264   - fdctrl_init(hwdef->fd_irq, 0, 1, hwdef->fd_base, fd_table);
  260 + slavio_serial_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq],
  261 + serial_hds[1], serial_hds[0]);
  262 + fdctrl_init(slavio_irq[hwdef->fd_irq], 0, 1, hwdef->fd_base, fd_table);
265 263 main_esp = esp_init(bs_table, hwdef->esp_base, dma);
266 264  
267 265 for (i = 0; i < MAX_DISKS; i++) {
... ... @@ -270,8 +268,8 @@ static void sun4m_hw_init(const struct hwdef *hwdef, int ram_size,
270 268 }
271 269 }
272 270  
273   - slavio_misc = slavio_misc_init(hwdef->slavio_base, hwdef->me_irq,
274   - slavio_intctl);
  271 + slavio_misc = slavio_misc_init(hwdef->slavio_base,
  272 + slavio_irq[hwdef->me_irq]);
275 273 if (hwdef->cs_base != (target_ulong)-1)
276 274 cs_init(hwdef->cs_base, hwdef->cs_irq, slavio_intctl);
277 275 sparc32_dma_set_reset_data(dma, main_esp, main_lance);
... ...
hw/sun4u.c
... ... @@ -223,14 +223,6 @@ void irq_info()
223 223 {
224 224 }
225 225  
226   -void pic_set_irq(int irq, int level)
227   -{
228   -}
229   -
230   -void pic_set_irq_new(void *opaque, int irq, int level)
231   -{
232   -}
233   -
234 226 void qemu_system_powerdown(void)
235 227 {
236 228 }
... ... @@ -340,14 +332,13 @@ static void sun4u_init(int ram_size, int vga_ram_size, int boot_device,
340 332  
341 333 for(i = 0; i < MAX_SERIAL_PORTS; i++) {
342 334 if (serial_hds[i]) {
343   - serial_init(&pic_set_irq_new, NULL,
344   - serial_io[i], serial_irq[i], serial_hds[i]);
  335 + serial_init(serial_io[i], NULL/*serial_irq[i]*/, serial_hds[i]);
345 336 }
346 337 }
347 338  
348 339 for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
349 340 if (parallel_hds[i]) {
350   - parallel_init(parallel_io[i], parallel_irq[i], parallel_hds[i]);
  341 + parallel_init(parallel_io[i], NULL/*parallel_irq[i]*/, parallel_hds[i]);
351 342 }
352 343 }
353 344  
... ... @@ -358,9 +349,10 @@ static void sun4u_init(int ram_size, int vga_ram_size, int boot_device,
358 349 }
359 350  
360 351 pci_cmd646_ide_init(pci_bus, bs_table, 1);
361   - kbd_init();
362   - floppy_controller = fdctrl_init(6, 2, 0, 0x3f0, fd_table);
363   - nvram = m48t59_init(8, 0, 0x0074, NVRAM_SIZE, 59);
  352 + /* FIXME: wire up interrupts. */
  353 + i8042_init(NULL/*1*/, NULL/*12*/, 0x60);
  354 + floppy_controller = fdctrl_init(NULL/*6*/, 2, 0, 0x3f0, fd_table);
  355 + nvram = m48t59_init(NULL/*8*/, 0, 0x0074, NVRAM_SIZE, 59);
364 356 sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", ram_size, boot_device,
365 357 KERNEL_LOAD_ADDR, kernel_size,
366 358 kernel_cmdline,
... ...
hw/unin_pci.c
... ... @@ -146,12 +146,12 @@ static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
146 146 return (irq_num + (pci_dev->devfn >> 3)) & 3;
147 147 }
148 148  
149   -static void pci_unin_set_irq(void *pic, int irq_num, int level)
  149 +static void pci_unin_set_irq(qemu_irq *pic, int irq_num, int level)
150 150 {
151   - openpic_set_irq(pic, irq_num + 8, level);
  151 + qemu_set_irq(pic[irq_num + 8], level);
152 152 }
153 153  
154   -PCIBus *pci_pmac_init(void *pic)
  154 +PCIBus *pci_pmac_init(qemu_irq *pic)
155 155 {
156 156 UNINState *s;
157 157 PCIDevice *d;
... ...
hw/usb-ohci.c
... ... @@ -59,8 +59,7 @@ enum ohci_type {
59 59 };
60 60  
61 61 typedef struct {
62   - void *pic;
63   - int irq;
  62 + qemu_irq irq;
64 63 enum ohci_type type;
65 64 target_phys_addr_t mem_base;
66 65 int mem;
... ... @@ -282,10 +281,7 @@ static inline void ohci_intr_update(OHCIState *ohci)
282 281 (ohci->intr_status & ohci->intr))
283 282 level = 1;
284 283  
285   - if (ohci->type == OHCI_TYPE_PCI)
286   - pci_set_irq((PCIDevice *)ohci->pic, ohci->irq, level);
287   - else
288   - pic_set_irq_new(ohci->pic, ohci->irq, level);
  284 + qemu_set_irq(ohci->irq, level);
289 285 }
290 286  
291 287 /* Set an interrupt */
... ... @@ -1263,7 +1259,7 @@ static CPUWriteMemoryFunc *ohci_writefn[3]={
1263 1259 };
1264 1260  
1265 1261 static void usb_ohci_init(OHCIState *ohci, int num_ports, int devfn,
1266   - void *pic, int irq, enum ohci_type type, const char *name)
  1262 + qemu_irq irq, enum ohci_type type, const char *name)
1267 1263 {
1268 1264 int i;
1269 1265  
... ... @@ -1286,7 +1282,6 @@ static void usb_ohci_init(OHCIState *ohci, int num_ports, int devfn,
1286 1282 ohci->mem = cpu_register_io_memory(0, ohci_readfn, ohci_writefn, ohci);
1287 1283 ohci->name = name;
1288 1284  
1289   - ohci->pic = pic;
1290 1285 ohci->irq = irq;
1291 1286 ohci->type = type;
1292 1287  
... ... @@ -1334,19 +1329,19 @@ void usb_ohci_init_pci(struct PCIBus *bus, int num_ports, int devfn)
1334 1329 ohci->pci_dev.config[0x0b] = 0xc;
1335 1330 ohci->pci_dev.config[0x3d] = 0x01; /* interrupt pin 1 */
1336 1331  
1337   - usb_ohci_init(&ohci->state, num_ports, devfn, &ohci->pci_dev,
1338   - 0, OHCI_TYPE_PCI, ohci->pci_dev.name);
  1332 + usb_ohci_init(&ohci->state, num_ports, devfn, ohci->pci_dev.irq[0],
  1333 + OHCI_TYPE_PCI, ohci->pci_dev.name);
1339 1334  
1340 1335 pci_register_io_region((struct PCIDevice *)ohci, 0, 256,
1341 1336 PCI_ADDRESS_SPACE_MEM, ohci_mapfunc);
1342 1337 }
1343 1338  
1344 1339 void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, int devfn,
1345   - void *pic, int irq)
  1340 + qemu_irq irq)
1346 1341 {
1347 1342 OHCIState *ohci = (OHCIState *)qemu_mallocz(sizeof(OHCIState));
1348 1343  
1349   - usb_ohci_init(ohci, num_ports, devfn, pic, irq,
  1344 + usb_ohci_init(ohci, num_ports, devfn, irq,
1350 1345 OHCI_TYPE_PXA, "OHCI USB");
1351 1346 ohci->mem_base = base;
1352 1347  
... ...
hw/usb-uhci.c
... ... @@ -119,7 +119,7 @@ static void uhci_update_irq(UHCIState *s)
119 119 } else {
120 120 level = 0;
121 121 }
122   - pci_set_irq(&s->dev, 3, level);
  122 + qemu_set_irq(s->dev.irq[3], level);
123 123 }
124 124  
125 125 static void uhci_reset(UHCIState *s)
... ...
hw/usb.h
... ... @@ -208,7 +208,7 @@ void usb_uhci_init(PCIBus *bus, int devfn);
208 208 /* usb-ohci.c */
209 209 void usb_ohci_init_pci(struct PCIBus *bus, int num_ports, int devfn);
210 210 void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, int devfn,
211   - void *pic, int irq);
  211 + qemu_irq irq);
212 212  
213 213 /* usb-linux.c */
214 214 USBDevice *usb_host_device_open(const char *devname);
... ...
hw/versatile_pci.c
... ... @@ -84,12 +84,12 @@ static int pci_vpb_map_irq(PCIDevice *d, int irq_num)
84 84 return irq_num;
85 85 }
86 86  
87   -static void pci_vpb_set_irq(void *pic, int irq_num, int level)
  87 +static void pci_vpb_set_irq(qemu_irq *pic, int irq_num, int level)
88 88 {
89   - pic_set_irq_new(pic, pci_vpb_irq + irq_num, level);
  89 + qemu_set_irq(pic[pci_vpb_irq + irq_num], level);
90 90 }
91 91  
92   -PCIBus *pci_vpb_init(void *pic, int irq, int realview)
  92 +PCIBus *pci_vpb_init(qemu_irq *pic, int irq, int realview)
93 93 {
94 94 PCIBus *s;
95 95 PCIDevice *d;
... ...
hw/versatilepb.c
... ... @@ -14,12 +14,11 @@
14 14  
15 15 typedef struct vpb_sic_state
16 16 {
17   - arm_pic_handler handler;
18 17 uint32_t base;
19 18 uint32_t level;
20 19 uint32_t mask;
21 20 uint32_t pic_enable;
22   - void *parent;
  21 + qemu_irq *parent;
23 22 int irq;
24 23 } vpb_sic_state;
25 24  
... ... @@ -28,7 +27,7 @@ static void vpb_sic_update(vpb_sic_state *s)
28 27 uint32_t flags;
29 28  
30 29 flags = s->level & s->mask;
31   - pic_set_irq_new(s->parent, s->irq, flags != 0);
  30 + qemu_set_irq(s->parent[s->irq], flags != 0);
32 31 }
33 32  
34 33 static void vpb_sic_update_pic(vpb_sic_state *s)
... ... @@ -40,7 +39,7 @@ static void vpb_sic_update_pic(vpb_sic_state *s)
40 39 mask = 1u << i;
41 40 if (!(s->pic_enable & mask))
42 41 continue;
43   - pic_set_irq_new(s->parent, i, (s->level & mask) != 0);
  42 + qemu_set_irq(s->parent[i], (s->level & mask) != 0);
44 43 }
45 44 }
46 45  
... ... @@ -52,7 +51,7 @@ static void vpb_sic_set_irq(void *opaque, int irq, int level)
52 51 else
53 52 s->level &= ~(1u << irq);
54 53 if (s->pic_enable & (1u << irq))
55   - pic_set_irq_new(s->parent, irq, level);
  54 + qemu_set_irq(s->parent[irq], level);
56 55 vpb_sic_update(s);
57 56 }
58 57  
... ... @@ -126,15 +125,16 @@ static CPUWriteMemoryFunc *vpb_sic_writefn[] = {
126 125 vpb_sic_write
127 126 };
128 127  
129   -static vpb_sic_state *vpb_sic_init(uint32_t base, void *parent, int irq)
  128 +static qemu_irq *vpb_sic_init(uint32_t base, qemu_irq *parent, int irq)
130 129 {
131 130 vpb_sic_state *s;
  131 + qemu_irq *qi;
132 132 int iomemtype;
133 133  
134 134 s = (vpb_sic_state *)qemu_mallocz(sizeof(vpb_sic_state));
135 135 if (!s)
136 136 return NULL;
137   - s->handler = vpb_sic_set_irq;
  137 + qi = qemu_allocate_irqs(vpb_sic_set_irq, s, 32);
138 138 s->base = base;
139 139 s->parent = parent;
140 140 s->irq = irq;
... ... @@ -142,7 +142,7 @@ static vpb_sic_state *vpb_sic_init(uint32_t base, void *parent, int irq)
142 142 vpb_sic_writefn, s);
143 143 cpu_register_physical_memory(base, 0x00000fff, iomemtype);
144 144 /* ??? Save/restore. */
145   - return s;
  145 + return qi;
146 146 }
147 147  
148 148 /* Board init. */
... ... @@ -158,8 +158,8 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
158 158 int board_id)
159 159 {
160 160 CPUState *env;
161   - void *pic;
162   - void *sic;
  161 + qemu_irq *pic;
  162 + qemu_irq *sic;
163 163 void *scsi_hba;
164 164 PCIBus *pci_bus;
165 165 NICInfo *nd;
... ... @@ -176,10 +176,10 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
176 176  
177 177 arm_sysctl_init(0x10000000, 0x41007004);
178 178 pic = arm_pic_init_cpu(env);
179   - pic = pl190_init(0x10140000, pic, ARM_PIC_CPU_IRQ, ARM_PIC_CPU_FIQ);
  179 + pic = pl190_init(0x10140000, pic[0], pic[1]);
180 180 sic = vpb_sic_init(0x10003000, pic, 31);
181   - pl050_init(0x10006000, sic, 3, 0);
182   - pl050_init(0x10007000, sic, 4, 1);
  181 + pl050_init(0x10006000, sic[3], 0);
  182 + pl050_init(0x10007000, sic[4], 1);
183 183  
184 184 pci_bus = pci_vpb_init(sic, 27, 0);
185 185 /* The Versatile PCI bridge does not provide access to PCI IO space,
... ... @@ -189,7 +189,7 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
189 189 if (!nd->model)
190 190 nd->model = done_smc ? "rtl8139" : "smc91c111";
191 191 if (strcmp(nd->model, "smc91c111") == 0) {
192   - smc91c111_init(nd, 0x10010000, sic, 25);
  192 + smc91c111_init(nd, 0x10010000, sic[25]);
193 193 } else {
194 194 pci_nic_init(pci_bus, nd, -1);
195 195 }
... ... @@ -204,20 +204,20 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
204 204 }
205 205 }
206 206  
207   - pl011_init(0x101f1000, pic, 12, serial_hds[0]);
208   - pl011_init(0x101f2000, pic, 13, serial_hds[1]);
209   - pl011_init(0x101f3000, pic, 14, serial_hds[2]);
210   - pl011_init(0x10009000, sic, 6, serial_hds[3]);
  207 + pl011_init(0x101f1000, pic[12], serial_hds[0]);
  208 + pl011_init(0x101f2000, pic[13], serial_hds[1]);
  209 + pl011_init(0x101f3000, pic[14], serial_hds[2]);
  210 + pl011_init(0x10009000, sic[6], serial_hds[3]);
211 211  
212   - pl080_init(0x10130000, pic, 17, 8);
213   - sp804_init(0x101e2000, pic, 4);
214   - sp804_init(0x101e3000, pic, 5);
  212 + pl080_init(0x10130000, pic[17], 8);
  213 + sp804_init(0x101e2000, pic[4]);
  214 + sp804_init(0x101e3000, pic[5]);
215 215  
216 216 /* The versatile/PB actually has a modified Color LCD controller
217 217 that includes hardware cursor support from the PL111. */
218   - pl110_init(ds, 0x10120000, pic, 16, 1);
  218 + pl110_init(ds, 0x10120000, pic[16], 1);
219 219  
220   - pl181_init(0x10005000, sd_bdrv, sic, 22, 1);
  220 + pl181_init(0x10005000, sd_bdrv, sic[22], sic[1]);
221 221 #if 0
222 222 /* Disabled because there's no way of specifying a block device. */
223 223 pl181_init(0x1000b000, NULL, sic, 23, 2);
... ...
target-mips/cpu.h
... ... @@ -269,6 +269,8 @@ struct CPUMIPSState {
269 269  
270 270 #if defined(CONFIG_USER_ONLY)
271 271 target_ulong tls_value;
  272 +#else
  273 + void *irq[8];
272 274 #endif
273 275  
274 276 CPU_COMMON
... ...
target-ppc/cpu.h
... ... @@ -758,6 +758,7 @@ struct CPUPPCState {
758 758 int error_code;
759 759 int interrupt_request;
760 760 uint32_t pending_interrupts;
  761 + void *irq[32];
761 762  
762 763 /* Those resources are used only during code translation */
763 764 /* Next instruction pointer */
... ...
... ... @@ -709,7 +709,6 @@ typedef struct QEMUMachine {
709 709 int qemu_register_machine(QEMUMachine *m);
710 710  
711 711 typedef void SetIRQFunc(void *opaque, int irq_num, int level);
712   -typedef void IRQRequestFunc(void *opaque, int level);
713 712  
714 713 #if defined(TARGET_PPC)
715 714 void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
... ... @@ -719,6 +718,8 @@ void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
719 718 void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
720 719 #endif
721 720  
  721 +#include "hw/irq.h"
  722 +
722 723 /* ISA bus */
723 724  
724 725 extern target_phys_addr_t isa_mem_base;
... ... @@ -791,6 +792,9 @@ struct PCIDevice {
791 792 /* ??? This is a PC-specific hack, and should be removed. */
792 793 int irq_index;
793 794  
  795 + /* IRQ objects for the INTA-INTD pins. */
  796 + qemu_irq *irq;
  797 +
794 798 /* Current IRQ levels. Used internally by the generic PCI code. */
795 799 int irq_state[4];
796 800 };
... ... @@ -804,8 +808,6 @@ void pci_register_io_region(PCIDevice *pci_dev, int region_num,
804 808 uint32_t size, int type,
805 809 PCIMapIORegionFunc *map_func);
806 810  
807   -void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level);
808   -
809 811 uint32_t pci_default_read_config(PCIDevice *d,
810 812 uint32_t address, int len);
811 813 void pci_default_write_config(PCIDevice *d,
... ... @@ -813,10 +815,10 @@ void pci_default_write_config(PCIDevice *d,
813 815 void pci_device_save(PCIDevice *s, QEMUFile *f);
814 816 int pci_device_load(PCIDevice *s, QEMUFile *f);
815 817  
816   -typedef void (*pci_set_irq_fn)(void *pic, int irq_num, int level);
  818 +typedef void (*pci_set_irq_fn)(qemu_irq *pic, int irq_num, int level);
817 819 typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num);
818 820 PCIBus *pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
819   - void *pic, int devfn_min, int nirq);
  821 + qemu_irq *pic, int devfn_min, int nirq);
820 822  
821 823 void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn);
822 824 void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);
... ... @@ -829,22 +831,22 @@ PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,
829 831 pci_map_irq_fn map_irq, const char *name);
830 832  
831 833 /* prep_pci.c */
832   -PCIBus *pci_prep_init(void);
  834 +PCIBus *pci_prep_init(qemu_irq *pic);
833 835  
834 836 /* grackle_pci.c */
835   -PCIBus *pci_grackle_init(uint32_t base, void *pic);
  837 +PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic);
836 838  
837 839 /* unin_pci.c */
838   -PCIBus *pci_pmac_init(void *pic);
  840 +PCIBus *pci_pmac_init(qemu_irq *pic);
839 841  
840 842 /* apb_pci.c */
841 843 PCIBus *pci_apb_init(target_ulong special_base, target_ulong mem_base,
842   - void *pic);
  844 + qemu_irq *pic);
843 845  
844   -PCIBus *pci_vpb_init(void *pic, int irq, int realview);
  846 +PCIBus *pci_vpb_init(qemu_irq *pic, int irq, int realview);
845 847  
846 848 /* piix_pci.c */
847   -PCIBus *i440fx_init(PCIDevice **pi440fx_state);
  849 +PCIBus *i440fx_init(PCIDevice **pi440fx_state, qemu_irq *pic);
848 850 void i440fx_set_smm(PCIDevice *d, int val);
849 851 int piix3_init(PCIBus *bus, int devfn);
850 852 void i440fx_init_memory_mappings(PCIDevice *d);
... ... @@ -852,7 +854,6 @@ void i440fx_init_memory_mappings(PCIDevice *d);
852 854 int piix4_init(PCIBus *bus, int devfn);
853 855  
854 856 /* openpic.c */
855   -typedef struct openpic_t openpic_t;
856 857 enum {
857 858 OPENPIC_EVT_INT = 0, /* IRQ */
858 859 OPENPIC_EVT_CINT, /* critical IRQ */
... ... @@ -860,18 +861,15 @@ enum {
860 861 OPENPIC_EVT_DEBUG, /* Inconditional debug event */
861 862 OPENPIC_EVT_RESET, /* Core reset event */
862 863 };
863   -void openpic_set_irq(void *opaque, int n_IRQ, int level);
864   -openpic_t *openpic_init (PCIBus *bus, SetIRQFunc *set_irq,
865   - int *pmem_index, int nb_cpus,
866   - struct CPUState **envp);
  864 +qemu_irq *openpic_init (PCIBus *bus, SetIRQFunc *set_irq,
  865 + int *pmem_index, int nb_cpus,
  866 + struct CPUState **envp);
867 867  
868 868 /* heathrow_pic.c */
869   -typedef struct HeathrowPICS HeathrowPICS;
870   -void heathrow_pic_set_irq(void *opaque, int num, int level);
871   -HeathrowPICS *heathrow_pic_init(int *pmem_index);
  869 +qemu_irq *heathrow_pic_init(int *pmem_index);
872 870  
873 871 /* gt64xxx.c */
874   -PCIBus *pci_gt64120_init(void *pic);
  872 +PCIBus *pci_gt64120_init(qemu_irq *pic);
875 873  
876 874 #ifdef HAS_AUDIO
877 875 struct soundhw {
... ... @@ -880,7 +878,7 @@ struct soundhw {
880 878 int enabled;
881 879 int isa;
882 880 union {
883   - int (*init_isa) (AudioState *s);
  881 + int (*init_isa) (AudioState *s, qemu_irq *pic);
884 882 int (*init_pci) (PCIBus *bus, AudioState *s);
885 883 } init;
886 884 };
... ... @@ -958,13 +956,13 @@ extern uint8_t _translate_keycode(const int key);
958 956 extern BlockDriverState *bs_table[MAX_DISKS + 1];
959 957 extern BlockDriverState *sd_bdrv;
960 958  
961   -void isa_ide_init(int iobase, int iobase2, int irq,
  959 +void isa_ide_init(int iobase, int iobase2, qemu_irq irq,
962 960 BlockDriverState *hd0, BlockDriverState *hd1);
963 961 void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table,
964 962 int secondary_ide_enabled);
965   -void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn);
966   -int pmac_ide_init (BlockDriverState **hd_table,
967   - SetIRQFunc *set_irq, void *irq_opaque, int irq);
  963 +void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,
  964 + qemu_irq *pic);
  965 +int pmac_ide_init (BlockDriverState **hd_table, qemu_irq irq);
968 966  
969 967 /* cdrom.c */
970 968 int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track);
... ... @@ -978,13 +976,13 @@ ds1225y_t *ds1225y_init(target_ulong mem_base, const char *filename);
978 976 int es1370_init (PCIBus *bus, AudioState *s);
979 977  
980 978 /* sb16.c */
981   -int SB16_init (AudioState *s);
  979 +int SB16_init (AudioState *s, qemu_irq *pic);
982 980  
983 981 /* adlib.c */
984   -int Adlib_init (AudioState *s);
  982 +int Adlib_init (AudioState *s, qemu_irq *pic);
985 983  
986 984 /* gus.c */
987   -int GUS_init (AudioState *s);
  985 +int GUS_init (AudioState *s, qemu_irq *pic);
988 986  
989 987 /* dma.c */
990 988 typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
... ... @@ -1005,7 +1003,7 @@ extern BlockDriverState *fd_table[MAX_FD];
1005 1003  
1006 1004 typedef struct fdctrl_t fdctrl_t;
1007 1005  
1008   -fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped,
  1006 +fdctrl_t *fdctrl_init (qemu_irq irq, int dma_chann, int mem_mapped,
1009 1007 uint32_t io_base,
1010 1008 BlockDriverState **fds);
1011 1009 int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
... ... @@ -1018,7 +1016,7 @@ void pci_i82559er_init(PCIBus *bus, NICInfo *nd, int devfn);
1018 1016  
1019 1017 /* ne2000.c */
1020 1018  
1021   -void isa_ne2000_init(int base, int irq, NICInfo *nd);
  1019 +void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd);
1022 1020 void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn);
1023 1021  
1024 1022 /* rtl8139.c */
... ... @@ -1029,31 +1027,29 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn);
1029 1027  
1030 1028 void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn);
1031 1029 void pcnet_h_reset(void *opaque);
1032   -void *lance_init(NICInfo *nd, uint32_t leaddr, void *dma_opaque);
  1030 +void *lance_init(NICInfo *nd, uint32_t leaddr, void *dma_opaque, qemu_irq irq);
1033 1031  
1034 1032 /* vmmouse.c */
1035 1033 void *vmmouse_init(void *m);
1036 1034  
1037 1035 /* pckbd.c */
1038 1036  
1039   -void kbd_init(void);
  1037 +void i8042_init(qemu_irq kdb_irq, qemu_irq mouse_irq, uint32_t io_base);
1040 1038  
1041 1039 /* mc146818rtc.c */
1042 1040  
1043 1041 typedef struct RTCState RTCState;
1044 1042  
1045   -RTCState *rtc_init(int base, int irq);
  1043 +RTCState *rtc_init(int base, qemu_irq irq);
1046 1044 void rtc_set_memory(RTCState *s, int addr, int val);
1047 1045 void rtc_set_date(RTCState *s, const struct tm *tm);
1048 1046  
1049 1047 /* serial.c */
1050 1048  
1051 1049 typedef struct SerialState SerialState;
1052   -SerialState *serial_init(SetIRQFunc *set_irq, void *opaque,
1053   - int base, int irq, CharDriverState *chr);
1054   -SerialState *serial_mm_init (SetIRQFunc *set_irq, void *opaque,
1055   - target_ulong base, int it_shift,
1056   - int irq, CharDriverState *chr,
  1050 +SerialState *serial_init(int base, qemu_irq irq, CharDriverState *chr);
  1051 +SerialState *serial_mm_init (target_ulong base, int it_shift,
  1052 + qemu_irq irq, CharDriverState *chr,
1057 1053 int ioregister);
1058 1054 uint32_t serial_mm_readb (void *opaque, target_phys_addr_t addr);
1059 1055 void serial_mm_writeb (void *opaque, target_phys_addr_t addr, uint32_t value);
... ... @@ -1065,7 +1061,7 @@ void serial_mm_writel (void *opaque, target_phys_addr_t addr, uint32_t value);
1065 1061 /* parallel.c */
1066 1062  
1067 1063 typedef struct ParallelState ParallelState;
1068   -ParallelState *parallel_init(int base, int irq, CharDriverState *chr);
  1064 +ParallelState *parallel_init(int base, qemu_irq irq, CharDriverState *chr);
1069 1065  
1070 1066 /* i8259.c */
1071 1067  
... ... @@ -1073,7 +1069,7 @@ typedef struct PicState2 PicState2;
1073 1069 extern PicState2 *isa_pic;
1074 1070 void pic_set_irq(int irq, int level);
1075 1071 void pic_set_irq_new(void *opaque, int irq, int level);
1076   -PicState2 *pic_init(IRQRequestFunc *irq_request, void *irq_request_opaque);
  1072 +qemu_irq *i8259_init(qemu_irq parent_irq);
1077 1073 void pic_set_alt_irq_func(PicState2 *s, SetIRQFunc *alt_irq_func,
1078 1074 void *alt_irq_opaque);
1079 1075 int pic_read_irq(PicState2 *s);
... ... @@ -1096,7 +1092,7 @@ void ioapic_set_irq(void *opaque, int vector, int level);
1096 1092  
1097 1093 typedef struct PITState PITState;
1098 1094  
1099   -PITState *pit_init(int base, int irq);
  1095 +PITState *pit_init(int base, qemu_irq irq);
1100 1096 void pit_set_gate(PITState *pit, int channel, int val);
1101 1097 int pit_get_gate(PITState *pit, int channel);
1102 1098 int pit_get_initial_count(PITState *pit, int channel);
... ... @@ -1105,7 +1101,7 @@ int pit_get_out(PITState *pit, int channel, int64_t current_time);
1105 1101  
1106 1102 /* pcspk.c */
1107 1103 void pcspk_init(PITState *);
1108   -int pcspk_audio_init(AudioState *);
  1104 +int pcspk_audio_init(AudioState *, qemu_irq *pic);
1109 1105  
1110 1106 #include "hw/smbus.h"
1111 1107  
... ... @@ -1138,7 +1134,7 @@ extern QEMUMachine mips_machine;
1138 1134 extern QEMUMachine mips_malta_machine;
1139 1135  
1140 1136 /* mips_int */
1141   -extern void cpu_mips_irq_request(void *opaque, int irq, int level);
  1137 +extern void cpu_mips_irq_init_cpu(CPUState *env);
1142 1138  
1143 1139 /* mips_timer.c */
1144 1140 extern void cpu_mips_clock_init(CPUState *);
... ... @@ -1149,7 +1145,7 @@ extern QEMUMachine shix_machine;
1149 1145  
1150 1146 #ifdef TARGET_PPC
1151 1147 /* PowerPC hardware exceptions management helpers */
1152   -void ppc_set_irq (void *opaque, int n_IRQ, int level);
  1148 +void cpu_ppc_irq_init_cpu(CPUState *env);
1153 1149 void ppc_openpic_irq (void *opaque, int n_IRQ, int level);
1154 1150 int ppc_hw_interrupt (CPUState *env);
1155 1151 ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq);
... ... @@ -1188,12 +1184,11 @@ void tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
1188 1184 /* slavio_intctl.c */
1189 1185 void pic_set_irq_cpu(void *opaque, int irq, int level, unsigned int cpu);
1190 1186 void *slavio_intctl_init(uint32_t addr, uint32_t addrg,
1191   - const uint32_t *intbit_to_level);
  1187 + const uint32_t *intbit_to_level,
  1188 + qemu_irq **irq);
1192 1189 void slavio_intctl_set_cpu(void *opaque, unsigned int cpu, CPUState *env);
1193 1190 void slavio_pic_info(void *opaque);
1194 1191 void slavio_irq_info(void *opaque);
1195   -void slavio_pic_set_irq(void *opaque, int irq, int level);
1196   -void slavio_pic_set_irq_cpu(void *opaque, int irq, int level, unsigned int cpu);
1197 1192  
1198 1193 /* loader.c */
1199 1194 int get_image_size(const char *filename);
... ... @@ -1208,12 +1203,12 @@ void slavio_timer_init(uint32_t addr, int irq, int mode, unsigned int cpu,
1208 1203 void *intctl);
1209 1204  
1210 1205 /* slavio_serial.c */
1211   -SerialState *slavio_serial_init(int base, int irq, CharDriverState *chr1,
1212   - CharDriverState *chr2, void *intctl);
1213   -void slavio_serial_ms_kbd_init(int base, int irq, void *intctl);
  1206 +SerialState *slavio_serial_init(int base, qemu_irq irq, CharDriverState *chr1,
  1207 + CharDriverState *chr2);
  1208 +void slavio_serial_ms_kbd_init(int base, qemu_irq);
1214 1209  
1215 1210 /* slavio_misc.c */
1216   -void *slavio_misc_init(uint32_t base, int irq, void *intctl);
  1211 +void *slavio_misc_init(uint32_t base, qemu_irq irq);
1217 1212 void slavio_set_power_fail(void *opaque, int power_failing);
1218 1213  
1219 1214 /* esp.c */
... ... @@ -1222,8 +1217,8 @@ void *esp_init(BlockDriverState **bd, uint32_t espaddr, void *dma_opaque);
1222 1217 void esp_reset(void *opaque);
1223 1218  
1224 1219 /* sparc32_dma.c */
1225   -void *sparc32_dma_init(uint32_t daddr, int espirq, int leirq, void *iommu,
1226   - void *intctl);
  1220 +void *sparc32_dma_init(uint32_t daddr, qemu_irq espirq, qemu_irq leirq,
  1221 + void *iommu);
1227 1222 void ledma_set_irq(void *opaque, int isr);
1228 1223 void ledma_memory_read(void *opaque, target_phys_addr_t addr,
1229 1224 uint8_t *buf, int len, int do_bswap);
... ... @@ -1307,7 +1302,7 @@ void adb_mouse_init(ADBBusState *bus);
1307 1302 /* cuda.c */
1308 1303  
1309 1304 extern ADBBusState adb_bus;
1310   -int cuda_init(SetIRQFunc *set_irq, void *irq_opaque, int irq);
  1305 +int cuda_init(qemu_irq irq);
1311 1306  
1312 1307 #include "hw/usb.h"
1313 1308  
... ... @@ -1372,36 +1367,36 @@ void ps2_keyboard_set_translation(void *opaque, int mode);
1372 1367 void ps2_mouse_fake_event(void *opaque);
1373 1368  
1374 1369 /* smc91c111.c */
1375   -void smc91c111_init(NICInfo *, uint32_t, void *, int);
  1370 +void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
1376 1371  
1377 1372 /* pl110.c */
1378   -void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq, int);
  1373 +void *pl110_init(DisplayState *ds, uint32_t base, qemu_irq irq, int);
1379 1374  
1380 1375 /* pl011.c */
1381   -void pl011_init(uint32_t base, void *pic, int irq, CharDriverState *chr);
  1376 +void pl011_init(uint32_t base, qemu_irq irq, CharDriverState *chr);
1382 1377  
1383 1378 /* pl050.c */
1384   -void pl050_init(uint32_t base, void *pic, int irq, int is_mouse);
  1379 +void pl050_init(uint32_t base, qemu_irq irq, int is_mouse);
1385 1380  
1386 1381 /* pl080.c */
1387   -void *pl080_init(uint32_t base, void *pic, int irq, int nchannels);
  1382 +void *pl080_init(uint32_t base, qemu_irq irq, int nchannels);
1388 1383  
1389 1384 /* pl181.c */
1390 1385 void pl181_init(uint32_t base, BlockDriverState *bd,
1391   - void *pic, int irq0, int irq1);
  1386 + qemu_irq irq0, qemu_irq irq1);
1392 1387  
1393 1388 /* pl190.c */
1394   -void *pl190_init(uint32_t base, void *parent, int irq, int fiq);
  1389 +qemu_irq *pl190_init(uint32_t base, qemu_irq irq, qemu_irq fiq);
1395 1390  
1396 1391 /* arm-timer.c */
1397   -void sp804_init(uint32_t base, void *pic, int irq);
1398   -void icp_pit_init(uint32_t base, void *pic, int irq);
  1392 +void sp804_init(uint32_t base, qemu_irq irq);
  1393 +void icp_pit_init(uint32_t base, qemu_irq *pic, int irq);
1399 1394  
1400 1395 /* arm_sysctl.c */
1401 1396 void arm_sysctl_init(uint32_t base, uint32_t sys_id);
1402 1397  
1403 1398 /* arm_gic.c */
1404   -void *arm_gic_init(uint32_t base, void *parent, int parent_irq);
  1399 +qemu_irq *arm_gic_init(uint32_t base, qemu_irq parent_irq);
1405 1400  
1406 1401 /* arm_boot.c */
1407 1402  
... ...