From owner-freebsd-current@FreeBSD.ORG Sat Feb 25 14:05:19 2006 Return-Path: X-Original-To: current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 43DED16A420; Sat, 25 Feb 2006 14:05:19 +0000 (GMT) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0136443D46; Sat, 25 Feb 2006 14:05:14 +0000 (GMT) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.13.3/8.13.3) with ESMTP id k1PE5AtG080242; Sat, 25 Feb 2006 17:05:10 +0300 (MSK) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.13.3/8.13.3/Submit) id k1PE59u5080240; Sat, 25 Feb 2006 17:05:10 +0300 (MSK) (envelope-from yar) Date: Sat, 25 Feb 2006 17:05:09 +0300 From: Yar Tikhiy To: current@FreeBSD.org Message-ID: <20060225140509.GC79616@comp.chem.msu.su> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i Cc: cokane@FreeBSD.org Subject: RFC: separate 3dfx_linux module X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Feb 2006 14:05:19 -0000 Hi there, In the course of reviewing and cleaning up the default configuration of kernel options, it was suggested by the Release Engineers that we had a separate module for TDFX_LINUX instead of placing the burden on the device tdfx and module 3dfx. Could anybody interested test this change? I've made sure it builds, but I have no 3dfx hw to really test it. The testing is as simple as building the new 3dfx and 3dfx_linux modules, loading them, and verifying that the linux apps work with the device as before. Thanks in advance! -- Yar Index: dev/tdfx/tdfx_linux.c =================================================================== RCS file: dev/tdfx/tdfx_linux.c diff -N dev/tdfx/tdfx_linux.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ dev/tdfx/tdfx_linux.c 24 Feb 2006 18:44:27 -0000 @@ -0,0 +1,87 @@ +/*- + * Copyright (c) 2006 The FreeBSD Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include + +LINUX_IOCTL_SET(tdfx, LINUX_IOCTL_TDFX_MIN, LINUX_IOCTL_TDFX_MAX); + +/* + * Linux emulation IOCTL for /dev/tdfx + */ +static int +linux_ioctl_tdfx(struct thread *td, struct linux_ioctl_args* args) +{ + int error = 0; + u_long cmd = args->cmd & 0xffff; + + /* The structure passed to ioctl has two shorts, one int + and one void*. */ + char d_pio[2*sizeof(short) + sizeof(int) + sizeof(void*)]; + + struct file *fp; + + if ((error = fget(td, args->fd, &fp)) != 0) + return (error); + /* We simply copy the data and send it right to ioctl */ + copyin((caddr_t)args->arg, &d_pio, sizeof(d_pio)); + error = fo_ioctl(fp, cmd, (caddr_t)&d_pio, td->td_ucred, td); + fdrop(fp, td); + return error; +} + +static int +tdfx_linux_modevent(struct module *mod __unused, int what, void *arg __unused) +{ + + switch (what) { + case MOD_LOAD: + case MOD_UNLOAD: + return (0); + } + return (EOPNOTSUPP); +} + +static moduledata_t tdfx_linux_mod = { + "tdfx_linux", + tdfx_linux_modevent, + 0 +}; + +/* As in SYSCALL_MODULE */ +DECLARE_MODULE(tdfx_linux, tdfx_linux_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE); +MODULE_VERSION(tdfx_linux, 1); +MODULE_DEPEND(tdfx_linux, tdfx, 1, 1, 1); +MODULE_DEPEND(tdfx_linux, linux, 1, 1, 1); Index: dev/tdfx/tdfx_pci.c =================================================================== RCS file: /home/ncvs/src/sys/dev/tdfx/tdfx_pci.c,v retrieving revision 1.38 diff -u -p -r1.38 tdfx_pci.c --- dev/tdfx/tdfx_pci.c 31 Oct 2005 15:41:19 -0000 1.38 +++ dev/tdfx/tdfx_pci.c 24 Feb 2006 18:44:28 -0000 @@ -70,12 +70,6 @@ __FBSDID("$FreeBSD: src/sys/dev/tdfx/tdf #include #include -/* This must come first */ -#include "opt_tdfx.h" -#ifdef TDFX_LINUX -#include -#endif - #include #include #include @@ -98,11 +92,6 @@ static device_method_t tdfx_methods[] = MALLOC_DEFINE(M_TDFX,"tdfx_driver","3DFX Graphics[/2D]/3D Accelerator(s)"); -#ifdef TDFX_LINUX -MODULE_DEPEND(tdfx, linux, 1, 1, 1); -LINUX_IOCTL_SET(tdfx, LINUX_IOCTL_TDFX_MIN, LINUX_IOCTL_TDFX_MAX); -#endif - /* Char. Dev. file operations structure */ static struct cdevsw tdfx_cdev = { .d_version = D_VERSION, @@ -822,33 +811,6 @@ tdfx_ioctl(struct cdev *dev, u_long cmd, return 0; } -#ifdef TDFX_LINUX -/* - * Linux emulation IOCTL for /dev/tdfx - */ -static int -linux_ioctl_tdfx(struct thread *td, struct linux_ioctl_args* args) -{ - int error = 0; - u_long cmd = args->cmd & 0xffff; - - /* The structure passed to ioctl has two shorts, one int - and one void*. */ - char d_pio[2*sizeof(short) + sizeof(int) + sizeof(void*)]; - - struct file *fp; - - if ((error = fget(td, args->fd, &fp)) != 0) - return (error); - /* We simply copy the data and send it right to ioctl */ - copyin((caddr_t)args->arg, &d_pio, sizeof(d_pio)); - error = fo_ioctl(fp, cmd, (caddr_t)&d_pio, td->td_ucred, td); - fdrop(fp, td); - return error; -} -#endif /* TDFX_LINUX */ - - /* This is the device driver struct. This is sent to the driver subsystem to * register the method structure and the info strcut space for this particular * instance of the driver. @@ -861,3 +823,4 @@ static driver_t tdfx_driver = { /* Tell Mr. Kernel about us! */ DRIVER_MODULE(tdfx, pci, tdfx_driver, tdfx_devclass, 0, 0); +MODULE_VERSION(tdfx, 1); Index: modules/3dfx/Makefile =================================================================== RCS file: /home/ncvs/src/sys/modules/3dfx/Makefile,v retrieving revision 1.12 diff -u -p -r1.12 Makefile --- modules/3dfx/Makefile 14 Oct 2005 23:30:06 -0000 1.12 +++ modules/3dfx/Makefile 24 Feb 2006 18:44:28 -0000 @@ -5,22 +5,11 @@ MAINTAINER= cokane@FreeBSD.org .PATH: $(.CURDIR)/../../dev/tdfx KMOD= 3dfx -SRCS= opt_tdfx.h bus_if.h pci_if.h device_if.h tdfx_pci.h tdfx_io.h\ +SRCS= bus_if.h pci_if.h device_if.h tdfx_pci.h tdfx_io.h\ tdfx_vars.h tdfx_pci.c INCSRC= ../../sys -.if ${MACHINE_ARCH} == "i386" -# This line enables linux ioctl handling by default -# comment out if you don't want it -TDFX_OPTS= "\#define TDFX_LINUX" -.endif - # Uncomment this for debugging messages #CFLAGS+= -DDEBUG -.if !defined(KERNBUILDDIR) -opt_tdfx.h: - echo $(TDFX_OPTS) > opt_tdfx.h -.endif - .include Index: modules/3dfx_linux/Makefile =================================================================== RCS file: modules/3dfx_linux/Makefile diff -N modules/3dfx_linux/Makefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/3dfx_linux/Makefile 24 Feb 2006 18:44:28 -0000 @@ -0,0 +1,8 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../dev/tdfx + +KMOD= 3dfx_linux +SRCS= tdfx_linux.c + +.include Index: conf/files =================================================================== RCS file: /home/ncvs/src/sys/conf/files,v retrieving revision 1.1096 diff -u -p -r1.1096 files --- conf/files 7 Feb 2006 18:41:56 -0000 1.1096 +++ conf/files 24 Feb 2006 18:44:28 -0000 @@ -913,6 +913,7 @@ dev/syscons/rain/rain_saver.c optional r dev/syscons/snake/snake_saver.c optional snake_saver dev/syscons/star/star_saver.c optional star_saver dev/syscons/warp/warp_saver.c optional warp_saver +dev/tdfx/tdfx_linux.c optional tdfx_linux tdfx compat_linux dev/tdfx/tdfx_pci.c optional tdfx pci dev/ti/if_ti.c optional ti pci dev/trm/trm.c optional trm Index: conf/options =================================================================== RCS file: /home/ncvs/src/sys/conf/options,v retrieving revision 1.528 diff -u -p -r1.528 options --- conf/options 1 Feb 2006 21:00:16 -0000 1.528 +++ conf/options 24 Feb 2006 18:44:29 -0000 @@ -598,7 +598,7 @@ ROOTDEVNAME FDC_DEBUG opt_fdc.h PCFCLOCK_VERBOSE opt_pcfclock.h PCFCLOCK_MAX_RETRIES opt_pcfclock.h -TDFX_LINUX opt_tdfx.h +TDFX_LINUX KTR opt_global.h KTR_ALQ opt_ktr.h