From 84ede329083b649c54f078276e7e06d48e910b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 23 Jan 2013 23:04:03 +0000 Subject: adb: QOM'ify Apple Desktop Bus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was not a qbus before, turn it into a first-class bus and initialize it properly from CUDA. Leave it a global variable as long as devices are not QOM'ified yet. Signed-off-by: Andreas Färber Signed-off-by: Alexander Graf --- hw/adb.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'hw/adb.h') diff --git a/hw/adb.h b/hw/adb.h index 5b27da2dd3..c23f804fe4 100644 --- a/hw/adb.h +++ b/hw/adb.h @@ -26,10 +26,13 @@ #if !defined(__ADB_H__) #define __ADB_H__ +#include "qdev.h" + #define MAX_ADB_DEVICES 16 #define ADB_MAX_OUT_LEN 16 +typedef struct ADBBusState ADBBusState; typedef struct ADBDevice ADBDevice; /* buf = NULL means polling */ @@ -38,7 +41,7 @@ typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out, typedef int ADBDeviceReset(ADBDevice *d); struct ADBDevice { - struct ADBBusState *bus; + ADBBusState *bus; int devaddr; int handler; ADBDeviceRequest *devreq; @@ -46,11 +49,18 @@ struct ADBDevice { void *opaque; }; -typedef struct ADBBusState { +#define TYPE_ADB_BUS "apple-desktop-bus" +#define ADB_BUS(obj) OBJECT_CHECK(ADBBusState, (obj), TYPE_ADB_BUS) + +struct ADBBusState { + /*< private >*/ + BusState parent_obj; + /*< public >*/ + ADBDevice devices[MAX_ADB_DEVICES]; int nb_devices; int poll_index; -} ADBBusState; +}; int adb_request(ADBBusState *s, uint8_t *buf_out, const uint8_t *buf, int len); -- cgit v1.2.3 From 2e4a7c9c5df442d4223e738f7e8f73192b8b2a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 23 Jan 2013 23:04:04 +0000 Subject: adb: QOM'ify ADB devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Alexander Graf --- hw/adb.h | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'hw/adb.h') 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__) */ -- cgit v1.2.3 From 293c867d8c7399d17e6b593053411a6515171f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 23 Jan 2013 23:04:05 +0000 Subject: cuda: Move ADB bus into CUDA state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the global adb_bus with a CUDA-internal one, accessed using regular qdev child bus accessor. Signed-off-by: Andreas Färber Signed-off-by: Alexander Graf --- hw/adb.h | 1 - 1 file changed, 1 deletion(-) (limited to 'hw/adb.h') diff --git a/hw/adb.h b/hw/adb.h index 2fe981ffaa..721f1ac43e 100644 --- a/hw/adb.h +++ b/hw/adb.h @@ -84,5 +84,4 @@ int adb_poll(ADBBusState *s, uint8_t *buf_out); #define TYPE_ADB_KEYBOARD "adb-keyboard" #define TYPE_ADB_MOUSE "adb-mouse" -extern ADBBusState adb_bus; #endif /* !defined(__ADB_H__) */ -- cgit v1.2.3