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
This commit is contained in:
yar 2006-03-03 21:37:38 +00:00
parent d8eb71788e
commit 0ac62e02bd
11 changed files with 114 additions and 61 deletions

View File

@ -21,6 +21,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 7.x IS SLOW:
developers choose to disable these features on build machines
to maximize performance.
20060303:
The TDFX_LINUX kernel option was retired and replaced by the
tdfx_linux device. The latter can be loaded as a kernel module.
Loading it alone should suffice to get 3dfx support for Linux
apps because it will pull in tdfx.ko and linux.ko through its
dependencies.
20060201:
The kernel ABI to file system modules was changed on i386.
Please make sure that your kernel and modules are in sync.

View File

@ -477,6 +477,7 @@ MLINKS+=stf.4 if_stf.4
MLINKS+=syncache.4 syncookies.4
MLINKS+=syscons.4 sc.4
MLINKS+=tap.4 if_tap.4
MLINKS+=tdfx.4 tdfx_linux.4
MLINKS+=ti.4 if_ti.4
MLINKS+=tl.4 if_tl.4
MLINKS+=tun.4 if_tun.4

View File

@ -9,8 +9,7 @@
.Nd Voodoo Graphics and VoodooII Memory Access GLIDE device driver
.Sh SYNOPSIS
.Cd device tdfx
.Pp
.Cd options TDFX_LINUX
.Cd device tdfx_linux
.Sh DESCRIPTION
This driver creates an entry in
.Pa /dev
@ -51,11 +50,9 @@ It also does not currently support the Voodoo Rush.
It also does not yet handle the SLI feature of the Voodoo II boards.
You can only use each of them separately.
.Pp
The following kernel configuration options are available:
.Pp
.Cd options LINUX_TDFX
.Pp
Enable the linux ioctl code for this driver, where the only supported
By including
.Nm tdfx_linux ,
you can enable the linux ioctl code for this driver, where the only supported
applications currently reside.
.Sh FILES
.Bl -tag -width /dev/voodoo* -compact

View File

@ -914,6 +914,7 @@ dev/syscons/rain/rain_saver.c optional rain_saver
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

View File

@ -598,7 +598,6 @@ ROOTDEVNAME
FDC_DEBUG opt_fdc.h
PCFCLOCK_VERBOSE opt_pcfclock.h
PCFCLOCK_MAX_RETRIES opt_pcfclock.h
TDFX_LINUX opt_tdfx.h
KTR opt_global.h
KTR_ALQ opt_ktr.h

87
sys/dev/tdfx/tdfx_linux.c Normal file
View File

@ -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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/file.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/proc.h>
#include <sys/systm.h>
#include <dev/tdfx/tdfx_linux.h>
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);

View File

@ -70,12 +70,6 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#include <sys/rman.h>
/* This must come first */
#include "opt_tdfx.h"
#ifdef TDFX_LINUX
#include <dev/tdfx/tdfx_linux.h>
#endif
#include <dev/tdfx/tdfx_io.h>
#include <dev/tdfx/tdfx_vars.h>
#include <dev/tdfx/tdfx_pci.h>
@ -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);

View File

@ -415,11 +415,10 @@ hint.npx.0.irq="13"
# the tdfx DRI module from XFree86 and is completely unrelated.
#
# To enable Linuxulator support, one must also include COMPAT_LINUX in the
# config as well, or you will not have the dependencies. The other option
# is to load both as modules.
# config as well. The other option is to load both as modules.
device tdfx # Enable 3Dfx Voodoo support
options TDFX_LINUX # Enable Linuxulator support
device tdfx_linux # Enable Linuxulator support
#
# ACPI support using the Intel ACPI Component Architecture reference

View File

@ -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 <bsd.kmod.mk>

View File

@ -0,0 +1,8 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../dev/tdfx
KMOD= 3dfx_linux
SRCS= tdfx_linux.c
.include <bsd.kmod.mk>

View File

@ -1,6 +1,7 @@
# $FreeBSD$
SUBDIR= ${_3dfx} \
${_3dfx_linux} \
${_aac} \
accf_data \
accf_http \
@ -317,6 +318,7 @@ _pflog= pflog
# XXX some of these can move to the general case when de-i386'ed
# XXX some of these can move now, but are untested on other architectures.
_3dfx= 3dfx
_3dfx_linux= 3dfx_linux
_agp= agp
_aic= aic
_amd= amd