Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/usb_emul.h
Show All 35 Lines | |||||
#include <pthread.h> | #include <pthread.h> | ||||
#define USB_MAX_XFER_BLOCKS 8 | #define USB_MAX_XFER_BLOCKS 8 | ||||
#define USB_XFER_OUT 0 | #define USB_XFER_OUT 0 | ||||
#define USB_XFER_IN 1 | #define USB_XFER_IN 1 | ||||
struct usb_hci; | struct usb_hci; | ||||
struct usb_device_request; | struct usb_device_request; | ||||
struct usb_data_xfer; | struct usb_data_xfer; | ||||
struct vm_snapshot_meta; | |||||
/* Device emulation handlers */ | /* Device emulation handlers */ | ||||
struct usb_devemu { | struct usb_devemu { | ||||
char *ue_emu; /* name of device emulation */ | char *ue_emu; /* name of device emulation */ | ||||
int ue_usbver; /* usb version: 2 or 3 */ | int ue_usbver; /* usb version: 2 or 3 */ | ||||
int ue_usbspeed; /* usb device speed */ | int ue_usbspeed; /* usb device speed */ | ||||
/* instance creation */ | /* instance creation */ | ||||
void *(*ue_init)(struct usb_hci *hci, char *opt); | void *(*ue_init)(struct usb_hci *hci, char *opt); | ||||
/* handlers */ | /* handlers */ | ||||
int (*ue_request)(void *sc, struct usb_data_xfer *xfer); | int (*ue_request)(void *sc, struct usb_data_xfer *xfer); | ||||
int (*ue_data)(void *sc, struct usb_data_xfer *xfer, int dir, | int (*ue_data)(void *sc, struct usb_data_xfer *xfer, int dir, | ||||
int epctx); | int epctx); | ||||
int (*ue_reset)(void *sc); | int (*ue_reset)(void *sc); | ||||
int (*ue_remove)(void *sc); | int (*ue_remove)(void *sc); | ||||
int (*ue_stop)(void *sc); | int (*ue_stop)(void *sc); | ||||
int (*ue_snapshot)(void *scarg, struct vm_snapshot_meta *meta); | |||||
}; | }; | ||||
#define USB_EMUL_SET(x) DATA_SET(usb_emu_set, x); | #define USB_EMUL_SET(x) DATA_SET(usb_emu_set, x); | ||||
/* | /* | ||||
* USB device events to notify HCI when state changes | * USB device events to notify HCI when state changes | ||||
*/ | */ | ||||
enum hci_usbev { | enum hci_usbev { | ||||
USBDEV_ATTACH, | USBDEV_ATTACH, | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
#define USB_DATA_XFER_LOCK(x) do { \ | #define USB_DATA_XFER_LOCK(x) do { \ | ||||
pthread_mutex_lock(&((x)->mtx)); \ | pthread_mutex_lock(&((x)->mtx)); \ | ||||
} while (0) | } while (0) | ||||
#define USB_DATA_XFER_UNLOCK(x) do { \ | #define USB_DATA_XFER_UNLOCK(x) do { \ | ||||
pthread_mutex_unlock(&((x)->mtx)); \ | pthread_mutex_unlock(&((x)->mtx)); \ | ||||
} while (0) | } while (0) | ||||
struct usb_devemu *usb_emu_finddev(char *name); | struct usb_devemu *usb_emu_finddev(char *name); | ||||
struct usb_data_xfer_block *usb_data_xfer_append(struct usb_data_xfer *xfer, | struct usb_data_xfer_block *usb_data_xfer_append(struct usb_data_xfer *xfer, | ||||
void *buf, int blen, void *hci_data, int ccs); | void *buf, int blen, void *hci_data, int ccs); | ||||
#endif /* _USB_EMUL_H_ */ | #endif /* _USB_EMUL_H_ */ |