summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authorwkoszek <wkoszek@FreeBSD.org>2010-05-24 07:04:00 +0000
committerwkoszek <wkoszek@FreeBSD.org>2010-05-24 07:04:00 +0000
commitab9f5dbe35c315e6966c118cb2076d184be6c09f (patch)
tree83ada656a98853f5aaefc61addf26dfb58da056f /sys/compat
parent60e8c402f34a3b6cd2d0dc500b0239ebf10dfd74 (diff)
downloadFreeBSD-src-ab9f5dbe35c315e6966c118cb2076d184be6c09f.zip
FreeBSD-src-ab9f5dbe35c315e6966c118cb2076d184be6c09f.tar.gz
Bring USB fixes for linux(4).
Intention of this commit is to let us take a full advantage of libusb(8) ported to Linux. This decreases a possibility of getting any collisions within ioctl() "command" space, especially with relation to LINUX_SNDCTL_SEQ... stuff. Basically, we provide commands, that will be mapped in the kernel to correct ones and forward those to the USB layer. Port enabling functionality brought with this patch is here: http://www.freebsd.org/cgi/query-pr.cgi?pr=146895 Bump __FreeBSD_version to catch, since which version installing a port makes sense. This patch should bring no regressions. So far, only i386 is tested. Tested by: thompsa@ Reviewed by: thompsa@ OKed by: netchild@
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linux/linux_ioctl.c122
-rw-r--r--sys/compat/linux/linux_ioctl.h39
2 files changed, 147 insertions, 14 deletions
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
index 261126b..b6de86a 100644
--- a/sys/compat/linux/linux_ioctl.c
+++ b/sys/compat/linux/linux_ioctl.c
@@ -65,6 +65,8 @@ __FBSDID("$FreeBSD$");
#include <net/if_types.h>
#include <net/vnet.h>
+#include <dev/usb/usb_ioctl.h>
+
#ifdef COMPAT_LINUX32
#include <machine/../linux32/linux.h>
#include <machine/../linux32/linux32_proto.h>
@@ -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 5503362..608db4b 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_ */
OpenPOWER on IntegriCloud