i8259: Completely privatize PicState

Use DeviceState instead of PicState in the public i8259 API. This is
cleaner and allows to reorganize the PIC data structures for KVM reuse.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Jan Kiszka 2012-01-10 16:31:16 +01:00
parent 7a380ca350
commit 9aa78c425f
2 changed files with 14 additions and 10 deletions

View File

@ -40,6 +40,8 @@
//#define DEBUG_IRQ_LATENCY //#define DEBUG_IRQ_LATENCY
//#define DEBUG_IRQ_COUNT //#define DEBUG_IRQ_COUNT
typedef struct PicState PicState;
struct PicState { struct PicState {
ISADevice dev; ISADevice dev;
uint8_t last_irr; /* edge detection */ uint8_t last_irr; /* edge detection */
@ -76,7 +78,7 @@ static uint64_t irq_count[16];
#ifdef DEBUG_IRQ_LATENCY #ifdef DEBUG_IRQ_LATENCY
static int64_t irq_time[16]; static int64_t irq_time[16];
#endif #endif
PicState *isa_pic; DeviceState *isa_pic;
static PicState *slave_pic; static PicState *slave_pic;
/* return the highest priority found in mask (highest = smallest /* return the highest priority found in mask (highest = smallest
@ -206,8 +208,9 @@ static void pic_intack(PicState *s, int irq)
pic_update_irq(s); pic_update_irq(s);
} }
int pic_read_irq(PicState *s) int pic_read_irq(DeviceState *d)
{ {
PicState *s = DO_UPCAST(PicState, dev.qdev, d);
int irq, irq2, intno; int irq, irq2, intno;
irq = pic_get_irq(s); irq = pic_get_irq(s);
@ -269,7 +272,7 @@ static void pic_init_reset(PicState *s)
static void pic_reset(DeviceState *dev) static void pic_reset(DeviceState *dev)
{ {
PicState *s = container_of(dev, PicState, dev.qdev); PicState *s = DO_UPCAST(PicState, dev.qdev, dev);
pic_init_reset(s); pic_init_reset(s);
s->elcr = 0; s->elcr = 0;
@ -399,8 +402,10 @@ static uint64_t pic_ioport_read(void *opaque, target_phys_addr_t addr,
return ret; return ret;
} }
int pic_get_output(PicState *s) int pic_get_output(DeviceState *d)
{ {
PicState *s = DO_UPCAST(PicState, dev.qdev, d);
return (pic_get_irq(s) >= 0); return (pic_get_irq(s) >= 0);
} }
@ -491,7 +496,7 @@ void pic_info(Monitor *mon)
return; return;
} }
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
s = i == 0 ? isa_pic : slave_pic; s = i == 0 ? DO_UPCAST(PicState, dev.qdev, isa_pic) : slave_pic;
monitor_printf(mon, "pic%d: irr=%02x imr=%02x isr=%02x hprio=%d " monitor_printf(mon, "pic%d: irr=%02x imr=%02x isr=%02x hprio=%d "
"irq_base=%02x rr_sel=%d elcr=%02x fnm=%d\n", "irq_base=%02x rr_sel=%d elcr=%02x fnm=%d\n",
i, s->irr, s->imr, s->isr, s->priority_add, i, s->irr, s->imr, s->isr, s->priority_add,
@ -538,7 +543,7 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq)
irq_set[i] = qdev_get_gpio_in(&dev->qdev, i); irq_set[i] = qdev_get_gpio_in(&dev->qdev, i);
} }
isa_pic = DO_UPCAST(PicState, dev, dev); isa_pic = &dev->qdev;
dev = isa_create(bus, "isa-i8259"); dev = isa_create(bus, "isa-i8259");
qdev_prop_set_uint32(&dev->qdev, "iobase", 0xa0); qdev_prop_set_uint32(&dev->qdev, "iobase", 0xa0);

View File

@ -62,11 +62,10 @@ bool parallel_mm_init(MemoryRegion *address_space,
/* i8259.c */ /* i8259.c */
typedef struct PicState PicState; extern DeviceState *isa_pic;
extern PicState *isa_pic;
qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq); qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq);
int pic_read_irq(PicState *s); int pic_read_irq(DeviceState *d);
int pic_get_output(PicState *s); int pic_get_output(DeviceState *d);
void pic_info(Monitor *mon); void pic_info(Monitor *mon);
void irq_info(Monitor *mon); void irq_info(Monitor *mon);