mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-08 04:12:41 +00:00
adb: QOM'ify Apple Desktop Bus
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 <afaerber@suse.de> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
45fa67fb68
commit
84ede32908
14
hw/adb.c
14
hw/adb.c
@ -126,6 +126,12 @@ static ADBDevice *adb_register_device(ADBBusState *s, int devaddr,
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const TypeInfo adb_bus_type_info = {
|
||||||
|
.name = TYPE_ADB_BUS,
|
||||||
|
.parent = TYPE_BUS,
|
||||||
|
.instance_size = sizeof(ADBBusState),
|
||||||
|
};
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/* Keyboard ADB device */
|
/* 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");
|
qemu_add_mouse_event_handler(adb_mouse_event, d, 0, "QEMU ADB Mouse");
|
||||||
vmstate_register(NULL, -1, &vmstate_adb_mouse, s);
|
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)
|
||||||
|
16
hw/adb.h
16
hw/adb.h
@ -26,10 +26,13 @@
|
|||||||
#if !defined(__ADB_H__)
|
#if !defined(__ADB_H__)
|
||||||
#define __ADB_H__
|
#define __ADB_H__
|
||||||
|
|
||||||
|
#include "qdev.h"
|
||||||
|
|
||||||
#define MAX_ADB_DEVICES 16
|
#define MAX_ADB_DEVICES 16
|
||||||
|
|
||||||
#define ADB_MAX_OUT_LEN 16
|
#define ADB_MAX_OUT_LEN 16
|
||||||
|
|
||||||
|
typedef struct ADBBusState ADBBusState;
|
||||||
typedef struct ADBDevice ADBDevice;
|
typedef struct ADBDevice ADBDevice;
|
||||||
|
|
||||||
/* buf = NULL means polling */
|
/* buf = NULL means polling */
|
||||||
@ -38,7 +41,7 @@ typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out,
|
|||||||
typedef int ADBDeviceReset(ADBDevice *d);
|
typedef int ADBDeviceReset(ADBDevice *d);
|
||||||
|
|
||||||
struct ADBDevice {
|
struct ADBDevice {
|
||||||
struct ADBBusState *bus;
|
ADBBusState *bus;
|
||||||
int devaddr;
|
int devaddr;
|
||||||
int handler;
|
int handler;
|
||||||
ADBDeviceRequest *devreq;
|
ADBDeviceRequest *devreq;
|
||||||
@ -46,11 +49,18 @@ struct ADBDevice {
|
|||||||
void *opaque;
|
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];
|
ADBDevice devices[MAX_ADB_DEVICES];
|
||||||
int nb_devices;
|
int nb_devices;
|
||||||
int poll_index;
|
int poll_index;
|
||||||
} ADBBusState;
|
};
|
||||||
|
|
||||||
int adb_request(ADBBusState *s, uint8_t *buf_out,
|
int adb_request(ADBBusState *s, uint8_t *buf_out,
|
||||||
const uint8_t *buf, int len);
|
const uint8_t *buf, int len);
|
||||||
|
@ -712,6 +712,9 @@ static void cuda_initfn(Object *obj)
|
|||||||
for (i = 0; i < ARRAY_SIZE(s->timers); i++) {
|
for (i = 0; i < ARRAY_SIZE(s->timers); i++) {
|
||||||
s->timers[i].index = 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)
|
static void cuda_class_init(ObjectClass *oc, void *data)
|
||||||
|
Loading…
Reference in New Issue
Block a user