From 0ac62e02bddc3f1147599efe9997fc4b09f1d642 Mon Sep 17 00:00:00 2001 From: yar Date: Fri, 3 Mar 2006 21:37:38 +0000 Subject: Take the functionality contained in the former "options TDFX_LINUX" into a separate module. Accordingly, convert the option into a device named similarly. Note for MFC: Perhaps the option should stay in RELENG_6 for POLA reasons. Suggested by: scottl Reviewed by: cokane MFC after: 5 days --- sys/dev/tdfx/tdfx_linux.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++ sys/dev/tdfx/tdfx_pci.c | 39 +-------------------- 2 files changed, 88 insertions(+), 38 deletions(-) create mode 100644 sys/dev/tdfx/tdfx_linux.c (limited to 'sys/dev/tdfx') diff --git a/sys/dev/tdfx/tdfx_linux.c b/sys/dev/tdfx/tdfx_linux.c new file mode 100644 index 0000000..2e877f6 --- /dev/null +++ b/sys/dev/tdfx/tdfx_linux.c @@ -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); diff --git a/sys/dev/tdfx/tdfx_pci.c b/sys/dev/tdfx/tdfx_pci.c index 5d07354..6c7a832 100644 --- a/sys/dev/tdfx/tdfx_pci.c +++ b/sys/dev/tdfx/tdfx_pci.c @@ -70,12 +70,6 @@ __FBSDID("$FreeBSD$"); #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, caddr_t data, int flag, struct thread * 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); -- cgit v1.1