summary refs log tree commit diff stats
path: root/hw/adb.h
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2013-01-23 23:04:04 +0000
committerAlexander Graf <agraf@suse.de>2013-01-25 22:02:55 +0100
commit2e4a7c9c5df442d4223e738f7e8f73192b8b2a65 (patch)
tree64acdef5b26a80c151eeb3ac885719ed144da9b0 /hw/adb.h
parent84ede329083b649c54f078276e7e06d48e910b9d (diff)
downloadfocaccia-qemu-2e4a7c9c5df442d4223e738f7e8f73192b8b2a65.tar.gz
focaccia-qemu-2e4a7c9c5df442d4223e738f7e8f73192b8b2a65.zip
adb: QOM'ify ADB devices
They were not qdev'ified before. Derive ADBDevice from DeviceState and
convert reset callbacks to DeviceClass::reset, ADBDevice::opaque pointer
to ADBDevice subtypes for mouse and keyboard and adb_{kbd,mouse}_init()
to regular qdev functions.

Fixing Coding Style issues and splitting keyboard and mouse off into
their own files is left for a later point in time.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'hw/adb.h')
-rw-r--r--hw/adb.h31
1 files changed, 23 insertions, 8 deletions
diff --git a/hw/adb.h b/hw/adb.h
index c23f804fe4..2fe981ffaa 100644
--- a/hw/adb.h
+++ b/hw/adb.h
@@ -38,17 +38,32 @@ typedef struct ADBDevice ADBDevice;
 /* buf = NULL means polling */
 typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out,
                               const uint8_t *buf, int len);
-typedef int ADBDeviceReset(ADBDevice *d);
+
+#define TYPE_ADB_DEVICE "adb-device"
+#define ADB_DEVICE(obj) OBJECT_CHECK(ADBDevice, (obj), TYPE_ADB_DEVICE)
 
 struct ADBDevice {
-    ADBBusState *bus;
+    /*< private >*/
+    DeviceState parent_obj;
+    /*< public >*/
+
     int devaddr;
     int handler;
-    ADBDeviceRequest *devreq;
-    ADBDeviceReset *devreset;
-    void *opaque;
 };
 
+#define ADB_DEVICE_CLASS(cls) \
+    OBJECT_CLASS_CHECK(ADBDeviceClass, (cls), TYPE_ADB_DEVICE)
+#define ADB_DEVICE_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(ADBDeviceClass, (obj), TYPE_ADB_DEVICE)
+
+typedef struct ADBDeviceClass {
+    /*< private >*/
+    DeviceClass parent_class;
+    /*< public >*/
+
+    ADBDeviceRequest *devreq;
+} ADBDeviceClass;
+
 #define TYPE_ADB_BUS "apple-desktop-bus"
 #define ADB_BUS(obj) OBJECT_CHECK(ADBBusState, (obj), TYPE_ADB_BUS)
 
@@ -57,7 +72,7 @@ struct ADBBusState {
     BusState parent_obj;
     /*< public >*/
 
-    ADBDevice devices[MAX_ADB_DEVICES];
+    ADBDevice *devices[MAX_ADB_DEVICES];
     int nb_devices;
     int poll_index;
 };
@@ -66,8 +81,8 @@ int adb_request(ADBBusState *s, uint8_t *buf_out,
                 const uint8_t *buf, int len);
 int adb_poll(ADBBusState *s, uint8_t *buf_out);
 
-void adb_kbd_init(ADBBusState *bus);
-void adb_mouse_init(ADBBusState *bus);
+#define TYPE_ADB_KEYBOARD "adb-keyboard"
+#define TYPE_ADB_MOUSE "adb-mouse"
 
 extern ADBBusState adb_bus;
 #endif /* !defined(__ADB_H__) */