From owner-freebsd-emulation@FreeBSD.ORG Mon Oct 27 11:46:01 2008 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B95981065673 for ; Mon, 27 Oct 2008 11:46:01 +0000 (UTC) (envelope-from rdivacky@lev.vlakno.cz) Received: from vlakno.cz (77-93-215-190.static.masterinter.net [77.93.215.190]) by mx1.freebsd.org (Postfix) with ESMTP id 5EE228FC30 for ; Mon, 27 Oct 2008 11:46:00 +0000 (UTC) (envelope-from rdivacky@lev.vlakno.cz) Received: from localhost (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 1156E9CB493; Mon, 27 Oct 2008 12:45:03 +0100 (CET) X-Virus-Scanned: amavisd-new at vlakno.cz Received: from vlakno.cz ([127.0.0.1]) by localhost (lev.vlakno.cz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yGCZKCrldRp4; Mon, 27 Oct 2008 12:44:51 +0100 (CET) Received: from lev.vlakno.cz (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 6359B9CB5DF; Mon, 27 Oct 2008 12:44:51 +0100 (CET) Received: (from rdivacky@localhost) by lev.vlakno.cz (8.14.2/8.14.2/Submit) id m9RBipbZ012764; Mon, 27 Oct 2008 12:44:51 +0100 (CET) (envelope-from rdivacky) Date: Mon, 27 Oct 2008 12:44:51 +0100 From: Roman Divacky To: Martin Laabs Message-ID: <20081027114451.GA12158@freebsd.org> References: <20081026105252.GA45809@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Cc: "freebsd-emulation@freebsd.org" Subject: Re: linux-libusb done X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Oct 2008 11:46:01 -0000 On Mon, Oct 27, 2008 at 10:27:17AM +0100, Martin Laabs wrote: > Hi, > > On Sun, 26 Oct 2008 11:52:52 +0100, Roman Divacky wrote: > > > please show us the linuxulator patch and I'll see what I can do about it... > > I've append the patch for the linux.ko module as well as the patch for the > bsd.c in libusb-0.12. >diff -Naur linux/linux_ioctl.c linux.usb/linux_ioctl.c >--- linux/linux_ioctl.c 2007-11-15 11:38:06.000000000 +0100 >+++ linux.usb/linux_ioctl.c 2008-10-26 11:49:59.000000000 +0100 >@@ -88,6 +88,8 @@ > static linux_ioctl_function_t linux_ioctl_drm; > static linux_ioctl_function_t linux_ioctl_sg; > static linux_ioctl_function_t linux_ioctl_special; >+//for hacked libusb >+static linux_ioctl_function_t linux_ioctl_usb; Don't use // comments, I wont repeat that for every occurance of this.. also you dont seem to be using proper indentation > static struct linux_ioctl_handler cdrom_handler = > { linux_ioctl_cdrom, LINUX_IOCTL_CDROM_MIN, LINUX_IOCTL_CDROM_MAX }; >@@ -111,6 +113,9 @@ > { linux_ioctl_drm, LINUX_IOCTL_DRM_MIN, LINUX_IOCTL_DRM_MAX }; > static struct linux_ioctl_handler sg_handler = > { linux_ioctl_sg, LINUX_IOCTL_SG_MIN, LINUX_IOCTL_SG_MAX }; >+//USB libusb compatibility mode ... >+static struct linux_ioctl_handler usb_handler = >+{ linux_ioctl_usb, LINUX_IOCTL_USB_MIN, LINUX_IOCTL_USB_MAX }; > > DATA_SET(linux_ioctl_handler_set, cdrom_handler); > DATA_SET(linux_ioctl_handler_set, vfat_handler); >@@ -123,6 +128,7 @@ > DATA_SET(linux_ioctl_handler_set, private_handler); > DATA_SET(linux_ioctl_handler_set, drm_handler); > DATA_SET(linux_ioctl_handler_set, sg_handler); >+DATA_SET(linux_ioctl_handler_set, usb_handler); > > struct handler_element > { >@@ -2542,6 +2548,60 @@ > return ioctl(td, (struct ioctl_args *)args); > } > >+static int >+linux_ioctl_usb(struct thread *td, struct linux_ioctl_args *args) >+{ >+ struct file *fp; >+ int error; >+ >+ if ((error = fget(td, args->fd, &fp)) != 0) >+ return (error); >+ >+#ifdef DEBUG >+ printf("%s(): USB-ioctl %d\n", __func__, >+ args->cmd & 0xffff); >+#endif >+ >+ switch (args->cmd & 0xffff) { >+ case LINUXBSD_IOCTL_USB_DEVICEINFO: >+ error = ioctl(td, (struct ioctl_args *)args); >+ break; >+ case LINUXBSD_IOCTL_SET_CONFIG: >+ error = ioctl(td, (struct ioctl_args *)args); >+ break; >+ case LINUXBSD_IOCTL_SET_ALTINTERFACE: >+ error = ioctl(td, (struct ioctl_args *)args); >+ break; >+ case LINUXBSD_IOCTL_SET_TIMEOUT: >+ error = ioctl(td, (struct ioctl_args *)args); >+ break; >+ case LINUXBSD_IOCTL_SET_SHORT_XFER: >+ error = ioctl(td, (struct ioctl_args *)args); >+ break; >+ case LINUXBSD_IOCTL_DO_REQUEST: >+ error = ioctl(td, (struct ioctl_args *)args); >+ break; >+ case LINUXBSD_IOCTL_GET_DEVICE_DESC: >+ error = ioctl(td, (struct ioctl_args *)args); >+ break; Please collapse this into a fallthrough statement, ie. case X: case Y: .... break; >+ default: >+ /* XXX */ >+ linux_msg(td, >+ "usb ioctl fd=%d, cmd=0x%x ('%c',%d) is not implemented", >+ args->fd, (int)(args->cmd & 0xffff), >+ (int)(args->cmd & 0xff00) >> 8, >+ (int)(args->cmd & 0xff)); >+ error=ENOIOCTL; >+ break; >+ } >+ fdrop(fp, td); >+#ifdef DEBUG >+printf("%s(): USB returning %d\n", __func__, error); >+#endif >+ return (error); >+} >+ > static int > linux_ioctl_sg(struct thread *td, struct linux_ioctl_args *args) > { >diff -Naur linux/linux_ioctl.h linux.usb/linux_ioctl.h >--- linux/linux_ioctl.h 2007-11-15 11:38:06.000000000 +0100 >+++ linux.usb/linux_ioctl.h 2008-10-25 14:16:13.000000000 +0200 >@@ -171,6 +171,15 @@ > #define LINUX_IOCTL_VFAT_MIN LINUX_VFAT_READDIR_BOTH > #define LINUX_IOCTL_VFAT_MAX LINUX_VFAT_READDIR_BOTH > >+ >+/* >+ * USB libusb compatibility mode ... >+ */ >+ >+#define LINUX_IOCTL_USB_MIN 0x5503 >+#define LINUX_IOCTL_USB_MAX 0x5573 >+ >+ > /* > * console > */ >@@ -567,6 +576,14 @@ > #define LINUX_IOCTL_DRM_MIN 0x6400 > #define LINUX_IOCTL_DRM_MAX 0x64ff > >+#define LINUXBSD_IOCTL_USB_DEVICEINFO 0x5504 >+#define LINUXBSD_IOCTL_SET_CONFIG 0x5565 >+#define LINUXBSD_IOCTL_SET_ALTINTERFACE 0x5567 >+#define LINUXBSD_IOCTL_SET_TIMEOUT 0x5572 >+#define LINUXBSD_IOCTL_SET_SHORT_XFER 0x5571 >+#define LINUXBSD_IOCTL_DO_REQUEST 0x556f >+#define LINUXBSD_IOCTL_GET_DEVICE_DESC 0x5569 >+ > /* > * This doesn't really belong here, but I can't think of a better > * place to put it. please fix those trivial bugs and submit once more. I believe it's commit ready by then (it's quite trivial :) ) thnx for the great work! roman