aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2012-01-10 16:31:16 +0100
committerJan Kiszka <jan.kiszka@siemens.com>2012-01-19 12:14:40 +0100
commit9aa78c425f6cd6a57ec53dd1a76233a080dc83b6 (patch)
tree966d41aba4166404e61fc0ae60555e67168190c5 /hw
parent7a380ca350f84b5b99391da20a2b4ea505b0524d (diff)
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>
Diffstat (limited to 'hw')
-rw-r--r--hw/i8259.c17
-rw-r--r--hw/pc.h7
2 files changed, 14 insertions, 10 deletions
diff --git a/hw/i8259.c b/hw/i8259.c
index 7331e0e61c..cfaa35c092 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
@@ -40,6 +40,8 @@
//#define DEBUG_IRQ_LATENCY
//#define DEBUG_IRQ_COUNT
+typedef struct PicState PicState;
+
struct PicState {
ISADevice dev;
uint8_t last_irr; /* edge detection */
@@ -76,7 +78,7 @@ static uint64_t irq_count[16];
#ifdef DEBUG_IRQ_LATENCY
static int64_t irq_time[16];
#endif
-PicState *isa_pic;
+DeviceState *isa_pic;
static PicState *slave_pic;
/* 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);
}
-int pic_read_irq(PicState *s)
+int pic_read_irq(DeviceState *d)
{
+ PicState *s = DO_UPCAST(PicState, dev.qdev, d);
int irq, irq2, intno;
irq = pic_get_irq(s);
@@ -269,7 +272,7 @@ static void pic_init_reset(PicState *s)
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);
s->elcr = 0;
@@ -399,8 +402,10 @@ static uint64_t pic_ioport_read(void *opaque, target_phys_addr_t addr,
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);
}
@@ -491,7 +496,7 @@ void pic_info(Monitor *mon)
return;
}
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 "
"irq_base=%02x rr_sel=%d elcr=%02x fnm=%d\n",
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);
}
- isa_pic = DO_UPCAST(PicState, dev, dev);
+ isa_pic = &dev->qdev;
dev = isa_create(bus, "isa-i8259");
qdev_prop_set_uint32(&dev->qdev, "iobase", 0xa0);
diff --git a/hw/pc.h b/hw/pc.h
index 13e41f101e..ece069ad1f 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -62,11 +62,10 @@ bool parallel_mm_init(MemoryRegion *address_space,
/* i8259.c */
-typedef struct PicState PicState;
-extern PicState *isa_pic;
+extern DeviceState *isa_pic;
qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq);
-int pic_read_irq(PicState *s);
-int pic_get_output(PicState *s);
+int pic_read_irq(DeviceState *d);
+int pic_get_output(DeviceState *d);
void pic_info(Monitor *mon);
void irq_info(Monitor *mon);