uint8_t elcr; /* PIIX edge/trigger selection*/
uint8_t elcr_mask;
qemu_irq int_out;
- PicState2 *pics_state;
+ bool master; /* reflects /SP input pin */
MemoryRegion base_io;
MemoryRegion elcr_io;
} PicState;
mask = s->isr;
if (s->special_mask)
mask &= ~s->imr;
- if (s->special_fully_nested_mode && s == &s->pics_state->pics[0])
+ if (s->special_fully_nested_mode && s->master) {
mask &= ~(1 << 2);
+ }
cur_priority = get_priority(s, mask);
if (priority < cur_priority) {
/* higher priority found: an irq should be generated */
irq = pic_get_irq(s);
if (irq >= 0) {
DPRINTF("pic%d: imr=%x irr=%x padd=%d\n",
- s == &s->pics_state->pics[0] ? 0 : 1, s->imr, s->irr,
- s->priority_add);
+ s->master ? 0 : 1, s->imr, s->irr, s->priority_add);
qemu_irq_raise(s->int_out);
} else {
qemu_irq_lower(s->int_out);
};
/* XXX: add generic master/slave system */
-static void pic_init(int io_addr, int elcr_addr, PicState *s, qemu_irq int_out)
+static void pic_init(int io_addr, int elcr_addr, PicState *s, qemu_irq int_out,
+ bool master)
{
s->int_out = int_out;
+ s->master = master;
memory_region_init_io(&s->base_io, &pic_base_ioport_ops, s, "pic", 2);
memory_region_init_io(&s->elcr_io, &pic_elcr_ioport_ops, s, "elcr", 1);
s = g_malloc0(sizeof(PicState2));
irqs = qemu_allocate_irqs(i8259_set_irq, s, 16);
- pic_init(0x20, 0x4d0, &s->pics[0], parent_irq);
- pic_init(0xa0, 0x4d1, &s->pics[1], irqs[2]);
+ pic_init(0x20, 0x4d0, &s->pics[0], parent_irq, true);
+ pic_init(0xa0, 0x4d1, &s->pics[1], irqs[2], false);
s->pics[0].elcr_mask = 0xf8;
s->pics[1].elcr_mask = 0xde;
- s->pics[0].pics_state = s;
- s->pics[1].pics_state = s;
isa_pic = s;
return irqs;
}