33#include <sys/module.h>
34#include <sys/kernel.h>
41#include <sys/syslog.h>
53#define UHID_SNES_IFQ_MAX_LEN 8
55#define UREQ_GET_PORT_STATUS 0x01
56#define UREQ_SOFT_RESET 0x02
72#define SNES_DEV(v,p,i) { USB_VPI(v,p,i) }
112#define UHID_FLAG_IMMED 0x01
138 .basename[0] =
"uhid_snes"
145 .flags = {.short_xfer_ok = 1, .short_frames_ok = 1,
146 .pipe_bof =1, .proxy_buffer =1},
163 uint8_t
id,
void *kern_data,
void *user_data, uint16_t
len)
166 uint8_t free_data = 0;
168 if (kern_data == NULL) {
169 kern_data = malloc(
len, M_USBDEV, M_WAITOK);
180 err = copyout(kern_data, user_data,
len);
187 free(kern_data, M_USBDEV);
194 uint8_t
id,
void *kern_data,
void *user_data, uint16_t
len)
197 uint8_t free_data = 0;
199 if (kern_data == NULL) {
200 kern_data = malloc(
len, M_USBDEV, M_WAITOK);
202 err = copyin(user_data, kern_data,
len);
215 free(kern_data, M_USBDEV);
284#ifdef COMPAT_FREEBSD32
286 struct usb_gen_descriptor32 *ugd32 = NULL;
293#ifdef COMPAT_FREEBSD32
295 case USB_GET_REPORT_DESC32:
296 case USB_GET_REPORT32:
297 case USB_SET_REPORT32:
300 usb_gen_descriptor_from32(ugd, ugd32);
321 if (!(fflags & FREAD)) {
344 if (!(fflags & FREAD)) {
371 if (!(fflags & FWRITE)) {
407#ifdef COMPAT_FREEBSD32
409 update_usb_gen_descriptor32(ugd32, ugd);
419 mtx_assert(&sc->
sc_mutex, MA_OWNED);
501 uint8_t current_status, new_status;
523 new_status = current_status & ~sc->sc_previous_status;
552 int error,unit = device_get_unit(
dev);
557 mtx_init(&sc->
sc_mutex,
"uhid_snes", NULL, MTX_DEF | MTX_RECURSE);
567 (idesc->
bLength >=
sizeof(*idesc))) {
601 iface_index, UID_ROOT, GID_OPERATOR, 0644);
uint8_t sc_zero_length_packets
struct usb_fifo_sc sc_fifo_no_reset
struct usb_fifo * sc_fifo_open[2]
struct usb_callout sc_watchdog
struct usb_fifo_sc sc_fifo
struct usb_device * sc_usb_device
struct usb_xfer * sc_transfer[UHID_SNES_N_TRANSFER]
struct usb_device * sc_udev
uint8_t sc_previous_status
enum usb_hc_mode usb_mode
struct usbd_lookup_info info
struct usb_interface * iface
struct usb_device * device
usb_callback_t * callback
DRIVER_MODULE(uhid_snes, uhub, uhid_snes_driver, uhid_snes_devclass, NULL, 0)
MODULE_DEPEND(uhid_snes, usb, 1, 1, 1)
static usb_fifo_close_t uhid_snes_close
USB_PNP_HOST_INFO(snes_devs)
static int uhid_get_report(struct uhid_snes_softc *sc, uint8_t type, uint8_t id, void *kern_data, void *user_data, uint16_t len)
static device_probe_t uhid_snes_probe
static const struct usb_config uhid_snes_config[UHID_SNES_N_TRANSFER]
static device_attach_t uhid_snes_attach
static devclass_t uhid_snes_devclass
static usb_callback_t uhid_snes_read_callback
static void uhid_snes_watchdog(void *)
static device_detach_t uhid_snes_detach
static driver_t uhid_snes_driver
static struct usb_fifo_methods uhid_snes_fifo_methods
static void uhid_snes_reset(struct uhid_snes_softc *)
#define UREQ_GET_PORT_STATUS
#define SNES_DEV(v, p, i)
static int uhid_set_report(struct uhid_snes_softc *sc, uint8_t type, uint8_t id, void *kern_data, void *user_data, uint16_t len)
static usb_callback_t uhid_snes_status_callback
#define UHID_SNES_IFQ_MAX_LEN
static const uint8_t uhid_snes_report_descr[]
static usb_fifo_cmd_t uhid_snes_stop_read
static usb_fifo_open_t uhid_snes_open
static const STRUCT_USB_HOST_ID snes_devs[]
static device_method_t uhid_snes_methods[]
static usb_fifo_cmd_t uhid_snes_start_read
static usb_fifo_ioctl_t uhid_snes_ioctl
#define UT_READ_CLASS_INTERFACE
void usbd_copy_in(struct usb_page_cache *cache, usb_frlength_t offset, const void *ptr, usb_frlength_t len)
void usbd_copy_out(struct usb_page_cache *cache, usb_frlength_t offset, void *ptr, usb_frlength_t len)
usb_error_t usbd_set_alt_interface_index(struct usb_device *udev, uint8_t iface_index, uint8_t alt_index)
struct usb_interface_descriptor * usbd_get_interface_descriptor(struct usb_interface *iface)
struct usb_config_descriptor * usbd_get_config_descriptor(struct usb_device *udev)
#define USB_GET_REPORT_ID
#define USB_GET_REPORT_DESC
int usbd_lookup_id_by_uaa(const struct usb_device_id *id, usb_size_t sizeof_id, struct usb_attach_arg *uaa)
struct usb_descriptor * usb_desc_foreach(struct usb_config_descriptor *cd, struct usb_descriptor *_desc)
#define UHID_SNES_REPORT_DESCR
usb_error_t usbd_req_set_report(struct usb_device *udev, struct mtx *mtx, void *data, uint16_t len, uint8_t iface_index, uint8_t type, uint8_t id)
usb_error_t usbd_req_get_report(struct usb_device *udev, struct mtx *mtx, void *data, uint16_t len, uint8_t iface_index, uint8_t type, uint8_t id)
usb_error_t usbd_do_request_flags(struct usb_device *udev, struct mtx *mtx, struct usb_device_request *req, void *data, uint16_t flags, uint16_t *actlen, usb_timeout_t timeout)
void usbd_transfer_submit(struct usb_xfer *xfer)
void usbd_xfer_set_frames(struct usb_xfer *xfer, usb_frcount_t n)
void usbd_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup)
void usbd_xfer_set_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex, usb_frlength_t len)
struct usb_page_cache * usbd_xfer_get_frame(struct usb_xfer *xfer, usb_frcount_t frindex)
usb_error_t usbd_transfer_setup(struct usb_device *udev, const uint8_t *ifaces, struct usb_xfer **ppxfer, const struct usb_config *setup_start, uint16_t n_setup, void *priv_sc, struct mtx *xfer_mtx)
void usbd_transfer_start(struct usb_xfer *xfer)
void * usbd_xfer_softc(struct usb_xfer *xfer)
void usbd_xfer_set_stall(struct usb_xfer *xfer)
void usbd_xfer_set_interval(struct usb_xfer *xfer, int i)
void usbd_transfer_stop(struct usb_xfer *xfer)
void usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen, int *aframes, int *nframes)
usb_frlength_t usbd_xfer_max_len(struct usb_xfer *xfer)
void device_set_usb_desc(device_t dev)
int usb_fifo_alloc_buffer(struct usb_fifo *f, uint32_t bufsize, uint16_t nbuf)
int() usb_fifo_ioctl_t(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags)
void * usb_fifo_softc(struct usb_fifo *fifo)
void() usb_fifo_close_t(struct usb_fifo *fifo, int fflags)
#define usb_callout_init_mtx(c, m, f)
void usb_fifo_detach(struct usb_fifo_sc *f_sc)
void usb_fifo_put_data(struct usb_fifo *fifo, struct usb_page_cache *pc, usb_frlength_t offset, usb_frlength_t len, uint8_t what)
int usb_fifo_attach(struct usb_device *udev, void *priv_sc, struct mtx *priv_mtx, struct usb_fifo_methods *pm, struct usb_fifo_sc *f_sc, uint16_t unit, int16_t subunit, uint8_t iface_index, uid_t uid, gid_t gid, int mode)
#define usb_callout_reset(c,...)
void() usb_fifo_cmd_t(struct usb_fifo *fifo)
void usb_fifo_free_buffer(struct usb_fifo *f)
#define usb_callout_drain(c)
#define USB_ST_TRANSFERRED
void() usb_callback_t(struct usb_xfer *, usb_error_t)
int() usb_fifo_open_t(struct usb_fifo *fifo, int fflags)
#define STRUCT_USB_HOST_ID
#define usb_callout_stop(c)
#define USB_GET_STATE(xfer)
uint32_t usb_fifo_put_bytes_max(struct usb_fifo *fifo)
#define UHID_FEATURE_REPORT
#define UHID_OUTPUT_REPORT
#define UHID_INPUT_REPORT