diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index 261126bf7069..b6de86a3c012 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -65,6 +65,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #ifdef COMPAT_LINUX32 #include #include @@ -123,7 +125,7 @@ static struct linux_ioctl_handler sg_handler = static struct linux_ioctl_handler video_handler = { linux_ioctl_v4l, LINUX_IOCTL_VIDEO_MIN, LINUX_IOCTL_VIDEO_MAX }; static struct linux_ioctl_handler fbsd_usb = -{ linux_ioctl_fbsd_usb, LINUX_FBSD_USB_MIN, LINUX_FBSD_USB_MAX }; +{ linux_ioctl_fbsd_usb, FBSD_LUSB_MIN, FBSD_LUSB_MAX }; DATA_SET(linux_ioctl_handler_set, cdrom_handler); DATA_SET(linux_ioctl_handler_set, vfat_handler); @@ -2983,21 +2985,119 @@ linux_ioctl_special(struct thread *td, struct linux_ioctl_args *args) } /* - * Support for mounting our devfs under /compat/linux/dev and using - * our libusb(3) compiled on Linux to access it from within Linuxolator - * environment. + * Support for emulators/linux-libusb. This port uses FBSD_LUSB* macros + * instead of USB* ones. This lets us to provide correct values for cmd. + * 0xffffffe0 -- 0xffffffff range seemed to be the least collision-prone. */ static int linux_ioctl_fbsd_usb(struct thread *td, struct linux_ioctl_args *args) { + int error; - /* - * Because on GNU/Linux we build our libusb(3) with our header - * files and ioccom.h macros, ioctl() will contain our native - * command value. This means that we can basically redirect this - * call further. - */ - return (ioctl(td, (struct ioctl_args *)args)); + error = 0; + switch (args->cmd) { + case FBSD_LUSB_DEVICEENUMERATE: + args->cmd = USB_DEVICEENUMERATE; + break; + case FBSD_LUSB_DEV_QUIRK_ADD: + args->cmd = USB_DEV_QUIRK_ADD; + break; + case FBSD_LUSB_DEV_QUIRK_GET: + args->cmd = USB_DEV_QUIRK_GET; + break; + case FBSD_LUSB_DEV_QUIRK_REMOVE: + args->cmd = USB_DEV_QUIRK_REMOVE; + break; + case FBSD_LUSB_DO_REQUEST: + args->cmd = USB_DO_REQUEST; + break; + case FBSD_LUSB_FS_CLEAR_STALL_SYNC: + args->cmd = USB_FS_CLEAR_STALL_SYNC; + break; + case FBSD_LUSB_FS_CLOSE: + args->cmd = USB_FS_CLOSE; + break; + case FBSD_LUSB_FS_COMPLETE: + args->cmd = USB_FS_COMPLETE; + break; + case FBSD_LUSB_FS_INIT: + args->cmd = USB_FS_INIT; + break; + case FBSD_LUSB_FS_OPEN: + args->cmd = USB_FS_OPEN; + break; + case FBSD_LUSB_FS_START: + args->cmd = USB_FS_START; + break; + case FBSD_LUSB_FS_STOP: + args->cmd = USB_FS_STOP; + break; + case FBSD_LUSB_FS_UNINIT: + args->cmd = USB_FS_UNINIT; + break; + case FBSD_LUSB_GET_CONFIG: + args->cmd = USB_GET_CONFIG; + break; + case FBSD_LUSB_GET_DEVICEINFO: + args->cmd = USB_GET_DEVICEINFO; + break; + case FBSD_LUSB_GET_DEVICE_DESC: + args->cmd = USB_GET_DEVICE_DESC; + break; + case FBSD_LUSB_GET_FULL_DESC: + args->cmd = USB_GET_FULL_DESC; + break; + case FBSD_LUSB_GET_IFACE_DRIVER: + args->cmd = USB_GET_IFACE_DRIVER; + break; + case FBSD_LUSB_GET_PLUGTIME: + args->cmd = USB_GET_PLUGTIME; + break; + case FBSD_LUSB_GET_POWER_MODE: + args->cmd = USB_GET_POWER_MODE; + break; + case FBSD_LUSB_GET_REPORT_DESC: + args->cmd = USB_GET_REPORT_DESC; + break; + case FBSD_LUSB_GET_REPORT_ID: + args->cmd = USB_GET_REPORT_ID; + break; + case FBSD_LUSB_GET_TEMPLATE: + args->cmd = USB_GET_TEMPLATE; + break; + case FBSD_LUSB_IFACE_DRIVER_ACTIVE: + args->cmd = USB_IFACE_DRIVER_ACTIVE; + break; + case FBSD_LUSB_IFACE_DRIVER_DETACH: + args->cmd = USB_IFACE_DRIVER_DETACH; + break; + case FBSD_LUSB_QUIRK_NAME_GET: + args->cmd = USB_QUIRK_NAME_GET; + break; + case FBSD_LUSB_READ_DIR: + args->cmd = USB_READ_DIR; + break; + case FBSD_LUSB_SET_ALTINTERFACE: + args->cmd = USB_SET_ALTINTERFACE; + break; + case FBSD_LUSB_SET_CONFIG: + args->cmd = USB_SET_CONFIG; + break; + case FBSD_LUSB_SET_IMMED: + args->cmd = USB_SET_IMMED; + break; + case FBSD_LUSB_SET_POWER_MODE: + args->cmd = USB_SET_POWER_MODE; + break; + case FBSD_LUSB_SET_TEMPLATE: + args->cmd = USB_SET_TEMPLATE; + break; + default: + error = ENOIOCTL; + } + if (error != ENOIOCTL) + error = ioctl(td, (struct ioctl_args *)args); + return (error); } /* diff --git a/sys/compat/linux/linux_ioctl.h b/sys/compat/linux/linux_ioctl.h index 5503362f4b78..608db4bddad6 100644 --- a/sys/compat/linux/linux_ioctl.h +++ b/sys/compat/linux/linux_ioctl.h @@ -612,9 +612,42 @@ int linux_ifname(struct ifnet *, char *, size_t); #define LINUX_IOCTL_VIDEO_MAX LINUX_VIDIOCSVBIFMT /* - * Keep in sync with our include/dev/usb/usb_ioctl.h. + * Our libusb(8) calls emulated within linux(4). */ -#define LINUX_FBSD_USB_MIN 0x5100 -#define LINUX_FBSD_USB_MAX 0x55c7 +#define FBSD_LUSB_DEVICEENUMERATE 0xffff +#define FBSD_LUSB_DEV_QUIRK_ADD 0xfffe +#define FBSD_LUSB_DEV_QUIRK_GET 0xfffd +#define FBSD_LUSB_DEV_QUIRK_REMOVE 0xfffc +#define FBSD_LUSB_DO_REQUEST 0xfffb +#define FBSD_LUSB_FS_CLEAR_STALL_SYNC 0xfffa +#define FBSD_LUSB_FS_CLOSE 0xfff9 +#define FBSD_LUSB_FS_COMPLETE 0xfff8 +#define FBSD_LUSB_FS_INIT 0xfff7 +#define FBSD_LUSB_FS_OPEN 0xfff6 +#define FBSD_LUSB_FS_START 0xfff5 +#define FBSD_LUSB_FS_STOP 0xfff4 +#define FBSD_LUSB_FS_UNINIT 0xfff3 +#define FBSD_LUSB_GET_CONFIG 0xfff2 +#define FBSD_LUSB_GET_DEVICEINFO 0xfff1 +#define FBSD_LUSB_GET_DEVICE_DESC 0xfff0 +#define FBSD_LUSB_GET_FULL_DESC 0xffef +#define FBSD_LUSB_GET_IFACE_DRIVER 0xffee +#define FBSD_LUSB_GET_PLUGTIME 0xffed +#define FBSD_LUSB_GET_POWER_MODE 0xffec +#define FBSD_LUSB_GET_REPORT_DESC 0xffeb +#define FBSD_LUSB_GET_REPORT_ID 0xffea +#define FBSD_LUSB_GET_TEMPLATE 0xffe9 +#define FBSD_LUSB_IFACE_DRIVER_ACTIVE 0xffe8 +#define FBSD_LUSB_IFACE_DRIVER_DETACH 0xffe7 +#define FBSD_LUSB_QUIRK_NAME_GET 0xffe6 +#define FBSD_LUSB_READ_DIR 0xffe5 +#define FBSD_LUSB_SET_ALTINTERFACE 0xffe4 +#define FBSD_LUSB_SET_CONFIG 0xffe3 +#define FBSD_LUSB_SET_IMMED 0xffe2 +#define FBSD_LUSB_SET_POWER_MODE 0xffe1 +#define FBSD_LUSB_SET_TEMPLATE 0xffe0 + +#define FBSD_LUSB_MAX 0xffff +#define FBSD_LUSB_MIN 0xffe0 #endif /* !_LINUX_IOCTL_H_ */ diff --git a/sys/modules/linux/Makefile b/sys/modules/linux/Makefile index a67fcc70284b..6474327df4fa 100644 --- a/sys/modules/linux/Makefile +++ b/sys/modules/linux/Makefile @@ -13,7 +13,7 @@ SRCS= linux${SFX}_dummy.c linux_emul.c linux_file.c \ linux${SFX}_machdep.c linux_mib.c linux_misc.c linux_signal.c \ linux_socket.c linux_stats.c linux_sysctl.c linux${SFX}_sysent.c \ linux${SFX}_sysvec.c linux_uid16.c linux_util.c linux_time.c \ - opt_inet6.h opt_compat.h opt_posix.h vnode_if.h \ + opt_inet6.h opt_compat.h opt_posix.h opt_usb.h vnode_if.h \ device_if.h bus_if.h assym.s # XXX: for assym.s diff --git a/sys/sys/param.h b/sys/sys/param.h index 1db46203df9b..9821646b8e2c 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 900012 /* Master, propagated to newvers */ +#define __FreeBSD_version 900013 /* Master, propagated to newvers */ #ifndef LOCORE #include