aboutsummaryrefslogtreecommitdiff
path: root/hw/input/pl050.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2013-07-29 14:39:49 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2013-07-29 14:39:49 -0500
commit6a4992d0bdeb38a57314d731d9846063b2057e6c (patch)
tree10d359f7bec5918dd1fc6d9a445213f3019d1929 /hw/input/pl050.c
parenteddbf0ab9db8385d7cb57e23891c1d41488b303e (diff)
parentb67964d70219a864ec427e727754a205475c7d6c (diff)
downloadqemu-6a4992d0bdeb38a57314d731d9846063b2057e6c.zip
qemu-6a4992d0bdeb38a57314d731d9846063b2057e6c.tar.gz
qemu-6a4992d0bdeb38a57314d731d9846063b2057e6c.tar.bz2
Merge remote-tracking branch 'afaerber/tags/qom-devices-for-anthony' into staging
QOM device refactorings * Replace all uses of FROM_SYSBUS() macro with QOM cast macros i) "QOM cast cleanup for X" Indicates a mechanical 1:1 between TYPE_* and *State. ii) "QOM'ify X and Y" Indicates abstract types may have been inserted or similar changes to type hierarchy. ii) Renames Coding Style fixes such as CamelCase have been applied in some cases. * Fix for sparc floppy - cf. ii) above * Change PCI type hierarchy to provide PCI_BRIDGE() casts * In doing so, prepare for adopting QOM realize # gpg: Signature made Mon 29 Jul 2013 02:15:22 PM CDT using RSA key ID 3E7E013F # gpg: Can't check signature: public key not found # By Andreas Färber (171) and others # Via Andreas Färber * afaerber/tags/qom-devices-for-anthony: (173 commits) sysbus: QOM parent field cleanup for SysBusDevice spapr_pci: QOM cast cleanup ioapic: QOM cast cleanup kvm/ioapic: QOM cast cleanup kvmvapic: QOM cast cleanup mipsnet: QOM cast cleanup opencores_eth: QOM cast cleanup exynos4210_i2c: QOM cast cleanup sysbus: Remove unused sysbus_new() prototype sysbus: Drop FROM_SYSBUS() xilinx_timer: QOM cast cleanup tusb6010: QOM cast cleanup slavio_timer: QOM cast cleanup pxa2xx_timer: QOM'ify pxa25x-timer and pxa27x-timer puv3_ost: QOM cast cleanup pl031: QOM cast cleanup pl031: Rename pl031_state to PL031State milkymist-sysctl: QOM cast cleanup m48t59: QOM cast cleanup for M48t59SysBusState lm32_timer: QOM cast cleanup ...
Diffstat (limited to 'hw/input/pl050.c')
-rw-r--r--hw/input/pl050.c82
1 files changed, 44 insertions, 38 deletions
diff --git a/hw/input/pl050.c b/hw/input/pl050.c
index 2312ffc..c1b08d5 100644
--- a/hw/input/pl050.c
+++ b/hw/input/pl050.c
@@ -10,8 +10,12 @@
#include "hw/sysbus.h"
#include "hw/input/ps2.h"
-typedef struct {
- SysBusDevice busdev;
+#define TYPE_PL050 "pl050"
+#define PL050(obj) OBJECT_CHECK(PL050State, (obj), TYPE_PL050)
+
+typedef struct PL050State {
+ SysBusDevice parent_obj;
+
MemoryRegion iomem;
void *dev;
uint32_t cr;
@@ -19,18 +23,18 @@ typedef struct {
uint32_t last;
int pending;
qemu_irq irq;
- int is_mouse;
-} pl050_state;
+ bool is_mouse;
+} PL050State;
static const VMStateDescription vmstate_pl050 = {
.name = "pl050",
.version_id = 2,
.minimum_version_id = 2,
.fields = (VMStateField[]) {
- VMSTATE_UINT32(cr, pl050_state),
- VMSTATE_UINT32(clk, pl050_state),
- VMSTATE_UINT32(last, pl050_state),
- VMSTATE_INT32(pending, pl050_state),
+ VMSTATE_UINT32(cr, PL050State),
+ VMSTATE_UINT32(clk, PL050State),
+ VMSTATE_UINT32(last, PL050State),
+ VMSTATE_INT32(pending, PL050State),
VMSTATE_END_OF_LIST()
}
};
@@ -48,7 +52,7 @@ static const unsigned char pl050_id[] =
static void pl050_update(void *opaque, int level)
{
- pl050_state *s = (pl050_state *)opaque;
+ PL050State *s = (PL050State *)opaque;
int raise;
s->pending = level;
@@ -60,7 +64,7 @@ static void pl050_update(void *opaque, int level)
static uint64_t pl050_read(void *opaque, hwaddr offset,
unsigned size)
{
- pl050_state *s = (pl050_state *)opaque;
+ PL050State *s = (PL050State *)opaque;
if (offset >= 0xfe0 && offset < 0x1000)
return pl050_id[(offset - 0xfe0) >> 2];
@@ -103,7 +107,7 @@ static uint64_t pl050_read(void *opaque, hwaddr offset,
static void pl050_write(void *opaque, hwaddr offset,
uint64_t value, unsigned size)
{
- pl050_state *s = (pl050_state *)opaque;
+ PL050State *s = (PL050State *)opaque;
switch (offset >> 2) {
case 0: /* KMICR */
s->cr = value;
@@ -133,65 +137,67 @@ static const MemoryRegionOps pl050_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int pl050_init(SysBusDevice *dev, int is_mouse)
+static int pl050_initfn(SysBusDevice *dev)
{
- pl050_state *s = FROM_SYSBUS(pl050_state, dev);
+ PL050State *s = PL050(dev);
memory_region_init_io(&s->iomem, OBJECT(s), &pl050_ops, s, "pl050", 0x1000);
sysbus_init_mmio(dev, &s->iomem);
sysbus_init_irq(dev, &s->irq);
- s->is_mouse = is_mouse;
- if (s->is_mouse)
+ if (s->is_mouse) {
s->dev = ps2_mouse_init(pl050_update, s);
- else
+ } else {
s->dev = ps2_kbd_init(pl050_update, s);
+ }
return 0;
}
-static int pl050_init_keyboard(SysBusDevice *dev)
+static void pl050_keyboard_init(Object *obj)
{
- return pl050_init(dev, 0);
-}
+ PL050State *s = PL050(obj);
-static int pl050_init_mouse(SysBusDevice *dev)
-{
- return pl050_init(dev, 1);
+ s->is_mouse = false;
}
-static void pl050_kbd_class_init(ObjectClass *klass, void *data)
+static void pl050_mouse_init(Object *obj)
{
- DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
+ PL050State *s = PL050(obj);
- k->init = pl050_init_keyboard;
- dc->vmsd = &vmstate_pl050;
+ s->is_mouse = true;
}
static const TypeInfo pl050_kbd_info = {
.name = "pl050_keyboard",
- .parent = TYPE_SYS_BUS_DEVICE,
- .instance_size = sizeof(pl050_state),
- .class_init = pl050_kbd_class_init,
+ .parent = TYPE_PL050,
+ .instance_init = pl050_keyboard_init,
};
-static void pl050_mouse_class_init(ObjectClass *klass, void *data)
+static const TypeInfo pl050_mouse_info = {
+ .name = "pl050_mouse",
+ .parent = TYPE_PL050,
+ .instance_init = pl050_mouse_init,
+};
+
+static void pl050_class_init(ObjectClass *oc, void *data)
{
- DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(oc);
+ SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(oc);
- k->init = pl050_init_mouse;
+ sdc->init = pl050_initfn;
dc->vmsd = &vmstate_pl050;
}
-static const TypeInfo pl050_mouse_info = {
- .name = "pl050_mouse",
+static const TypeInfo pl050_type_info = {
+ .name = TYPE_PL050,
.parent = TYPE_SYS_BUS_DEVICE,
- .instance_size = sizeof(pl050_state),
- .class_init = pl050_mouse_class_init,
+ .instance_size = sizeof(PL050State),
+ .abstract = true,
+ .class_init = pl050_class_init,
};
static void pl050_register_types(void)
{
+ type_register_static(&pl050_type_info);
type_register_static(&pl050_kbd_info);
type_register_static(&pl050_mouse_info);
}