[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/21] adb: QOM'ify Apple Desktop Bus
From: |
Alexander Graf |
Subject: |
[Qemu-devel] [PATCH 10/21] adb: QOM'ify Apple Desktop Bus |
Date: |
Fri, 25 Jan 2013 13:52:53 +0100 |
From: Andreas Färber <address@hidden>
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 <address@hidden>
Signed-off-by: Alexander Graf <address@hidden>
---
hw/adb.c | 14 ++++++++++++++
hw/adb.h | 16 +++++++++++++---
hw/cuda.c | 3 +++
3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/hw/adb.c b/hw/adb.c
index cc8ad8e..5d46f59 100644
--- a/hw/adb.c
+++ b/hw/adb.c
@@ -126,6 +126,12 @@ static ADBDevice *adb_register_device(ADBBusState *s, int
devaddr,
return d;
}
+static const TypeInfo adb_bus_type_info = {
+ .name = TYPE_ADB_BUS,
+ .parent = TYPE_BUS,
+ .instance_size = sizeof(ADBBusState),
+};
+
/***************************************************************/
/* Keyboard ADB device */
@@ -453,3 +459,11 @@ void adb_mouse_init(ADBBusState *bus)
qemu_add_mouse_event_handler(adb_mouse_event, d, 0, "QEMU ADB Mouse");
vmstate_register(NULL, -1, &vmstate_adb_mouse, s);
}
+
+
+static void adb_register_types(void)
+{
+ type_register_static(&adb_bus_type_info);
+}
+
+type_init(adb_register_types)
diff --git a/hw/adb.h b/hw/adb.h
index 5b27da2..c23f804 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);
diff --git a/hw/cuda.c b/hw/cuda.c
index f863c38..b3a875c 100644
--- a/hw/cuda.c
+++ b/hw/cuda.c
@@ -712,6 +712,9 @@ static void cuda_initfn(Object *obj)
for (i = 0; i < ARRAY_SIZE(s->timers); i++) {
s->timers[i].index = i;
}
+
+ qbus_create_inplace((BusState *)&adb_bus, TYPE_ADB_BUS, DEVICE(obj),
+ "adb.0");
}
static void cuda_class_init(ObjectClass *oc, void *data)
--
1.6.0.2
- [Qemu-devel] [PATCH 03/21] macio: Delay qdev init until all fields are initialized, (continued)
- [Qemu-devel] [PATCH 03/21] macio: Delay qdev init until all fields are initialized, Alexander Graf, 2013/01/25
- [Qemu-devel] [PATCH 02/21] macio: QOM'ify some more, Alexander Graf, 2013/01/25
- [Qemu-devel] [PATCH 08/21] ide/macio: QOM'ify MacIO IDE, Alexander Graf, 2013/01/25
- [Qemu-devel] [PATCH 04/21] macio: Split MacIO in two, Alexander Graf, 2013/01/25
- [Qemu-devel] [PATCH 07/21] mac_nvram: QOM'ify MacIO NVRAM, Alexander Graf, 2013/01/25
- [Qemu-devel] [PATCH 12/21] cuda: Move ADB bus into CUDA state, Alexander Graf, 2013/01/25
- [Qemu-devel] [PATCH 05/21] mac_nvram: Clean up public API, Alexander Graf, 2013/01/25
- [Qemu-devel] [PATCH 11/21] adb: QOM'ify ADB devices, Alexander Graf, 2013/01/25
- [Qemu-devel] [PATCH 15/21] pseries: Adjust default VIO address allocations to play better with libvirt, Alexander Graf, 2013/01/25
- [Qemu-devel] [PATCH 13/21] target-ppc: Give a meaningful error if too many threads are specified, Alexander Graf, 2013/01/25
- [Qemu-devel] [PATCH 10/21] adb: QOM'ify Apple Desktop Bus,
Alexander Graf <=
- [Qemu-devel] [PATCH 18/21] openpic: add basic support for MPIC v4.2, Alexander Graf, 2013/01/25
- [Qemu-devel] [PATCH 20/21] PPC: e500: Select MPIC v4.2 on ppce500 platform, Alexander Graf, 2013/01/25
- [Qemu-devel] [PATCH 14/21] pseries: Improve handling of multiple PCI host bridges, Alexander Graf, 2013/01/25
- Re: [Qemu-devel] [PULL 00/21] ppc patch queue 2013-01-25, Andreas Färber, 2013/01/25
- [Qemu-devel] [PATCH 21/21] PPC: Move ppc specific hw emulation to hw/ppc, Alexander Graf, 2013/01/25