new override port: x11/nvidia-driver

Emiel Kollof coolvibe at hackerheaven.org
Mon Oct 13 08:43:47 PDT 2003


Hi,

Here's a shar-file to unpack in your dfports tree. Please test and give
feedback. It seems to build fine. Haven't tried installing yet, will test
that as soon as I get home from $work, where my workstation with nvidia
graphics card is installed in. But I think it should work (since I made
minimal changes). Don't yell at me when it doesn't :)

How to install:
# cd /usr/dfports
# sh /location/where/shar/file/exists.shar

Then install the port as usual.

Cheers,
Emiel

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	x11/nvidia-driver
#	x11/nvidia-driver/Makefile
#	x11/nvidia-driver/distinfo
#	x11/nvidia-driver/pkg-descr
#	x11/nvidia-driver/pkg-message
#	x11/nvidia-driver/pkg-plist
#	x11/nvidia-driver/files
#	x11/nvidia-driver/files/patch-aa
#
echo c - x11/nvidia-driver
mkdir -p x11/nvidia-driver > /dev/null 2>&1
echo x - x11/nvidia-driver/Makefile
sed 's/^X//' >x11/nvidia-driver/Makefile << 'END-of-x11/nvidia-driver/Makefile'
X# New ports collection makefile for:	nvidia-driver
X# Date created:				4 December 2002
X# Whom:					Stijn Hoop <stijn at xxxxxxxxxx>
X#
X# $FreeBSD: ports/x11/nvidia-driver/Makefile,v 1.11 2003/08/20 10:42:11 osa Exp $
X#
X
XPORTNAME=	nvidia-driver
XPORTVERSION=	1.0.${NVVERSION}
XPORTREVISION?=	0
XCATEGORIES=	x11
XMASTER_SITES=	http://download.nvidia.com/freebsd/1.0-${NVVERSION}/ \
X		ftp://download.nvidia.com/freebsd/1.0-${NVVERSION}/ \
X		http://download1.nvidia.com/freebsd/1.0-${NVVERSION}/ \
X		ftp://download1.nvidia.com/freebsd/1.0-${NVVERSION}/
XDISTNAME=	NVIDIA-FreeBSD-x86-${PORTVERSION:S/0./0-/}
X
XMAINTAINER=	danfe at xxxxxxxxxxxxxx
XCOMMENT=	NVidia graphics card binary drivers for hardware OpenGL rendering
X
XUSE_X_PREFIX=	yes
XNO_PACKAGE=	should be recompiled for a particular FreeBSD kernel
XINSTALLS_SHLIB=	yes
X
XNVVERSION=	4365
X
X.include <bsd.port.pre.mk>
X
X# XXX Should use ${PKG_INFO} XXX
X#
XXSERVVERSION!=	/usr/sbin/pkg_info -O x11-servers/XFree86-4-Server 2>/dev/null | ${GREP} Server- || true
XXLIBVERSION!=	/usr/sbin/pkg_info -O x11/XFree86-4-libraries 2>/dev/null | ${GREP} libraries- || true
X
XPLIST_SUB=	XSERVVERSION=${XSERVVERSION} XLIBVERSION=${XLIBVERSION} \
X		LINUXBASE=${LINUXBASE} NVVERSION=${NVVERSION}
X
X.if !defined(WITHOUT_LINUX)
XUSE_LINUX=	yes
X.endif
X
X.if ${OSVERSION} < 470000
XIGNORE=		"requires FreeBSD -STABLE, version 4.7-RELEASE or later"
X.endif
X
X.if ${OSVERSION} < 500000
XPLIST_SUB+=	FREEBSD5="@comment " FREEBSD4=""
X.else
XPLIST_SUB+=	FREEBSD5="" FREEBSD4="@comment "
X.endif
X
Xpre-everything::
X.if !defined(WITH_FREEBSD_AGP)
X	@${ECHO_MSG} "Define WITH_FREEBSD_AGP to use FreeBSD AGP GART driver"
X.endif
X.if !defined(FORCE_AGP_RATE)
X	@${ECHO_MSG} "Define FORCE_AGP_RATE to limit the driver to lower speeds"
X.endif
X.if !defined(WITH_NVIDIA_HACKS)
X	@${ECHO_MSG} "Define WITH_NVIDIA_HACKS to enable work-arounds to override basic AGP setup"
X.endif
X
X.if defined(WITH_FREEBSD_AGP) || defined(FORCE_AGP_RATE) || defined(WITH_NVIDIA_HACKS)
XUSE_REINPLACE=	yes
X
Xpost-patch:
X. if defined(WITH_FREEBSD_AGP)
X	@${REINPLACE_CMD} "s/undef USE_OS_AGP_GART/define USE_OS_AGP_GART/" \
X		${WRKSRC}/src/nv-freebsd.h
X. endif
X. if defined(FORCE_AGP_RATE)
X	@${REINPLACE_CMD} 's/NVreg_ReqAGPRate,[[:blank:]]*0/NVreg_ReqAGPRate, 1/' ${WRKSRC}/src/nvidia_os_registry.c
X. endif
X. if defined(WITH_NVIDIA_HACKS)
X	@${REINPLACE_CMD} 's/NVreg_UpdateKernelAGP,[[:blank:]]*1/NVreg_UpdateKernelAGP, 0/' ${WRKSRC}/src/nvidia_os_registry.c
X. endif
X.endif
X
Xpre-install:
X.if defined(WITHOUT_LINUX)
X	@${MKDIR} ${LINUXBASE}/usr/lib
X.endif
X	-@(kldstat -n linux || kldload linux)
X
Xpost-install:
X.if ${OSVERSION} < 500000
X.for dev in 0 1 2 3
X	@rm -f /dev/nvidia${dev}
X	@mknod /dev/nvidia${dev} c 180 ${dev}
X	@${CHMOD} 0666 /dev/nvidia${dev}
X.endfor
X	@rm -f /dev/nvidiactl
X	@mknod /dev/nvidiactl c 180 255
X	@${CHMOD} 0666 /dev/nvidiactl
X.endif
X	@${CAT} ${PKGMESSAGE}
X
X.include <bsd.port.post.mk>
END-of-x11/nvidia-driver/Makefile
echo x - x11/nvidia-driver/distinfo
sed 's/^X//' >x11/nvidia-driver/distinfo << 'END-of-x11/nvidia-driver/distinfo'
XMD5 (NVIDIA-FreeBSD-x86-1.0-4365.tar.gz) = e14d9f2668746ee4d8b47e1c9dbc78af
END-of-x11/nvidia-driver/distinfo
echo x - x11/nvidia-driver/pkg-descr
sed 's/^X//' >x11/nvidia-driver/pkg-descr << 'END-of-x11/nvidia-driver/pkg-descr'
XThese are the official NVidia binary drivers for hardware OpenGL rendering
Xin X, using the GLX extensions.
X
XWWW: http://www.nvidia.com/
END-of-x11/nvidia-driver/pkg-descr
echo x - x11/nvidia-driver/pkg-message
sed 's/^X//' >x11/nvidia-driver/pkg-message << 'END-of-x11/nvidia-driver/pkg-message'
XTo use these drivers, make sure that you have loaded the nvidia kernel
Xmodule, by doing
X
X	# kldload nvidia
X
XIf you compile this package with WITH_FREEBSD_AGP=yes, you must load
Xthe agp.ko kernel module *at boot time* by putting the following
Xline into your /boot/loader.conf:
X
X	agp_load="YES"
X
Xor have your kernel compiled with "device agp".
X
XOtherwise the nvidia kernel module will not load.
X
XSee ${PREFIX}/share/doc/NVIDIA/README for more information.
END-of-x11/nvidia-driver/pkg-message
echo x - x11/nvidia-driver/pkg-plist
sed 's/^X//' >x11/nvidia-driver/pkg-plist << 'END-of-x11/nvidia-driver/pkg-plist'
X at comment I can't add the below files to the package because pkg_delete
X at comment will complain when removing this package:
X at comment     lib/modules/extensions/XXX-libglx.a.%%XLIBVERSION%%
X at comment     lib/modules/extensions/XXX-libGLcore.a.%%XLIBVERSION%%
X at comment     lib/XXX-libGL.a.%%XLIBVERSION%%
X at comment     lib/XXX-libGL.so.1.%%XLIBVERSION%%
X at comment They are however restored when this package is removed:
X at unexec mv -f %D/lib/modules/extensions/XXX-libglx.a.%%%%.%%XSERVVERSION%% %D/lib/modules/extensions/libglx.a
X at unexec mv -f %D/lib/modules/extensions/XXX-libGLcore.a.%%%%.%%XSERVVERSION%% %D/lib/modules/extensions/libGLcore.a
X at unexec mv -f %D/lib/XXX-libGL.a.%%%%.%%XLIBVERSION%% %D/lib/libGL.a
Xlib/libGL.so.1
X at unexec mv -f %D/lib/XXX-libGL.so.1.%%%%.%%XLIBVERSION%% %D/lib/libGL.so.1
X at exec ln -sf %D/lib/libGL.so.1 %D/lib/libGL.so
X at comment no rm -f %D/lib/libGL.so because default XFree needs this also
Xlib/libGLcore.so.1
X at exec ln -sf %D/lib/libGLcore.so.1 %D/lib/libGLcore.so
X at unexec rm -f %D/lib/libGLcore.so
Xlib/libXvMCNVIDIA.so.1
X at exec ln -sf %D/lib/libXvMCNVIDIA.so.1 %D/lib/libXvMCNVIDIA.so
X at unexec rm -f %D/lib/libXvMCNVIDIA.so
Xlib/libXvMCNVIDIA.a
Xlib/modules/drivers/nvidia_drv.o
Xlib/modules/extensions/libglx.so.1
X at exec ln -sf %D/lib/modules/extensions/libglx.so.1 %D/lib/modules/extensions/libglx.so
X at unexec rm -f %D/lib/modules/extensions/libglx.so
Xshare/doc/NVIDIA/README
Xshare/doc/NVIDIA/README.Linux
Xshare/doc/NVIDIA/XF86Config.sample
Xshare/doc/NVIDIA/license.txt
X%%FREEBSD4%%@cwd /modules
X%%FREEBSD5%%@cwd /boot/kernel
Xnvidia.ko
X%%FREEBSD4%%@cwd /dev
X%%FREEBSD4%%MAKEDEV.nvidia
X%%FREEBSD4%%@exec mknod /dev/nvidia0 c 180 0
X%%FREEBSD4%%@exec chmod 0666 /dev/nvidia0
X%%FREEBSD4%%@exec mknod /dev/nvidia1 c 180 1
X%%FREEBSD4%%@exec chmod 0666 /dev/nvidia1
X%%FREEBSD4%%@exec mknod /dev/nvidia2 c 180 2
X%%FREEBSD4%%@exec chmod 0666 /dev/nvidia2
X%%FREEBSD4%%@exec mknod /dev/nvidia3 c 180 3
X%%FREEBSD4%%@exec chmod 0666 /dev/nvidia3
X%%FREEBSD4%%@exec mknod /dev/nvidiactl c 180 255
X%%FREEBSD4%%@exec chmod 0666 /dev/nvidiactl
X%%FREEBSD4%%@unexec rm -f /dev/nvidia0
X%%FREEBSD4%%@unexec rm -f /dev/nvidia1
X%%FREEBSD4%%@unexec rm -f /dev/nvidia2
X%%FREEBSD4%%@unexec rm -f /dev/nvidia3
X%%FREEBSD4%%@unexec rm -f /dev/nvidiactl
X at cwd %%LINUXBASE%%
Xusr/lib/libGL.so.1.0.%%NVVERSION%%
Xusr/lib/libGLcore.so.1.0.%%NVVERSION%%
X at exec ln -sf %D/usr/lib/libGL.so.1.0.%%NVVERSION%% %D/usr/lib/libGL.so.1
X at exec ln -sf %D/usr/lib/libGLcore.so.1.0.%%NVVERSION%% %D/usr/lib/libGLcore.so.1
END-of-x11/nvidia-driver/pkg-plist
echo c - x11/nvidia-driver/files
mkdir -p x11/nvidia-driver/files > /dev/null 2>&1
echo x - x11/nvidia-driver/files/patch-aa
sed 's/^X//' >x11/nvidia-driver/files/patch-aa << 'END-of-x11/nvidia-driver/files/patch-aa'
Xdiff -urN ../NVIDIA-FreeBSD-x86-1.0-4365/module/Makefile ./module/Makefile
X--- ../NVIDIA-FreeBSD-x86-1.0-4365/module/Makefile	Wed May 28 18:51:52 2003
X+++ ./module/Makefile	Fri Oct 10 13:09:27 2003
X@@ -6,7 +6,7 @@
X KMOD=		nvidia
X SRCS=		nvidia_ctl.c nvidia_dev.c nvidia_linux.c nvidia_os.c nvidia_os_pci.c nvidia_os_registry.c nvidia_pci.c nvidia_subr.c nvidia_sysctl.c 
X SRCS+=		device_if.h bus_if.h pci_if.h vnode_if.h
X-CFLAGS+=	-I${NVIDIA_ROOT}/src -D__KERNEL__ -DNV_MAJOR_VERSION=1 -DNV_MINOR_VERSION=0 -DNV_PATCHLEVEL=4365  -DNVCPU_X86   -DNV_BSD   -DNV_INT64_OK   -DNV_UNIX     
X+CFLAGS+=	-I${NVIDIA_ROOT}/src -D__KERNEL__ -DNV_MAJOR_VERSION=1 -DNV_MINOR_VERSION=0 -DNV_PATCHLEVEL=4365  -DNVCPU_X86   -DNV_BSD   -DNV_INT64_OK   -DNV_UNIX -DDRAGONFLY
X NVOBJ=		${NVIDIA_ROOT}/obj/nv-kernel.o
X OBJS+=		NVIDIA.o
X NOOBJ=		true
Xdiff -urN ../NVIDIA-FreeBSD-x86-1.0-4365/src/nv-freebsd.h ./src/nv-freebsd.h
X--- ../NVIDIA-FreeBSD-x86-1.0-4365/src/nv-freebsd.h	Wed Oct  8 18:22:17 2003
X+++ ./src/nv-freebsd.h	Fri Oct 10 13:26:26 2003
X@@ -75,12 +75,12 @@
X #include <vm/pmap.h>
X #include <vm/vm_map.h>
X 
X-#include <pci/agpvar.h>
X+#include <dev/agp/agpvar.h>
X #include <sys/agpio.h>
X 
X #include "net/if.h"
X-#include "machine/../linux/linux.h"
X-#include "compat/linux/linux_ioctl.h"
X+#include "emulation/linux/i386/linux.h"
X+#include "emulation/linux/linux_ioctl.h"
X 
X #if __FreeBSD_version >= 500000
X #include <sys/mutex.h>
X@@ -102,8 +102,8 @@
X 
X #else
X #include <machine/smp.h>
X-#include <pci/pcireg.h>
X-#include <pci/pcivar.h>
X+#include <bus/pci/pcireg.h>
X+#include <bus/pci/pcivar.h>
X 
X #define vm_page_lock_queues()
X #define vm_page_unlock_queues()
X@@ -116,8 +116,8 @@
X  * on FreeBSD, due to its thread-aware reference counting.
X  */
X 
X-#define __TD_FDT(td)     ((td)->p_fd)
X-#define __TD_FDT_CNT(td) ((td)->p_fd->fd_refcnt)
X+#define __TD_FDT(td)     ((td)->td_proc->p_fd)
X+#define __TD_FDT_CNT(td) ((td)->td_proc->p_fd->fd_refcnt)
X 
X #endif
X 
Xdiff -urN ../NVIDIA-FreeBSD-x86-1.0-4365/src/nvidia_ctl.c ./src/nvidia_ctl.c
X--- ../NVIDIA-FreeBSD-x86-1.0-4365/src/nvidia_ctl.c	Wed Oct  8 18:22:17 2003
X+++ ./src/nvidia_ctl.c	Fri Oct 10 13:27:59 2003
X@@ -20,6 +20,12 @@
X 
X static struct cdevsw nvidia_ctl_cdevsw = {
X #if __FreeBSD_version < 500105
X+    /* name */    "nvidiactl",
X+    /* maj */     CDEV_MAJOR,
X+    /* flags */    D_TRACKCLOSE,
X+    /* port */     NULL,
X+    /* autoq */    0,
X+
X     /* open    */  nvidia_ctl_open,
X     /* close */    nvidia_ctl_close,
X     /* read */     noread,
X@@ -28,15 +34,8 @@
X     /* poll */     nvidia_ctl_poll,
X     /* mmap */     nommap,
X     /* strategy */ nostrategy,
X-    /* name */     "nvidiactl",
X-    /* maj */      CDEV_MAJOR,
X     /* dump */     nodump,
X-    /* psize */    nopsize,
X-    /* flags */    D_TRACKCLOSE,
X-#if __FreeBSD_version < 500000
X-    /* bmaj */     -1,
X-#endif
X-    /* kqfilter */ NULL,
X+    /* psize */    nopsize
X #else
X     .d_open =      nvidia_ctl_open,
X     .d_close =     nvidia_ctl_close,
X@@ -218,7 +217,7 @@
X         mtx_init(&sc->mtx_api, "ctl.mtx_api", NULL, MTX_DEF);
X         mtx_init(&sc->mtx_rm,  "ctl.mtx_rm",  NULL, MTX_SPIN);
X #else
X-        lockinit(&sc->api_lock, PZERO, "ctl.api_lock", 0, 0); 
X+        lockinit(&sc->api_lock, 0, "ctl.api_lock", 0, 0); 
X #endif
X     }
X 
X@@ -243,7 +242,7 @@
X         mtx_destroy(&sc->mtx_rm);
X         mtx_destroy(&sc->mtx_api);
X #else
X-        lockmgr(&sc->api_lock, LK_DRAIN, 0, curproc);
X+        lockmgr(&sc->api_lock, LK_DRAIN, 0, curthread);
X #endif
X         destroy_dev(nvidia_ctl_cdev);
X     }
Xdiff -urN ../NVIDIA-FreeBSD-x86-1.0-4365/src/nvidia_dev.c ./src/nvidia_dev.c
X--- ../NVIDIA-FreeBSD-x86-1.0-4365/src/nvidia_dev.c	Wed Oct  8 18:22:17 2003
X+++ ./src/nvidia_dev.c	Fri Oct 10 13:19:08 2003
X@@ -21,6 +21,12 @@
X 
X static struct cdevsw nvidia_dev_cdevsw = {
X #if __FreeBSD_version < 500105
X+    /* name */     "nvidia",
X+    /* maj */      CDEV_MAJOR,
X+    /* flags */    D_MEM|D_TRACKCLOSE,
X+    /* port */	   NULL,
X+    /* autoq */    0,
X+
X     /* open    */  nvidia_dev_open,
X     /* close */    nvidia_dev_close,
X     /* read */     noread,
X@@ -29,15 +35,8 @@
X     /* poll */     nvidia_dev_poll,
X     /* mmap */     nvidia_dev_mmap,
X     /* strategy */ nostrategy,
X-    /* name */     "nvidia",
X-    /* maj */      CDEV_MAJOR,
X     /* dump */     nodump,
X-    /* psize */    nopsize,
X-    /* flags */    D_MEM|D_TRACKCLOSE,
X-#if __FreeBSD_version < 500000
X-    /* bmaj */     -1,
X-#endif
X-    /* kqfilter */ NULL,
X+    /* psize */    nopsize
X #else
X     .d_open =      nvidia_dev_open,
X     .d_close =     nvidia_dev_close,
Xdiff -urN ../NVIDIA-FreeBSD-x86-1.0-4365/src/nvidia_linux.c ./src/nvidia_linux.c
X--- ../NVIDIA-FreeBSD-x86-1.0-4365/src/nvidia_linux.c	Wed May 28 18:51:52 2003
X+++ ./src/nvidia_linux.c	Fri Oct 10 13:19:26 2003
X@@ -33,7 +33,7 @@
X      * copy the user data in/out correctly.
X      */
X 
X-    return (ioctl(td, (struct ioctl_args *) args));
X+    return (ioctl((struct ioctl_args *) args));
X }
X 
X struct linux_ioctl_handler nvidia_handler = {
Xdiff -urN ../NVIDIA-FreeBSD-x86-1.0-4365/src/nvidia_os.c ./src/nvidia_os.c
X--- ../NVIDIA-FreeBSD-x86-1.0-4365/src/nvidia_os.c	Wed Oct  8 18:22:17 2003
X+++ ./src/nvidia_os.c	Fri Oct 10 13:22:20 2003
X@@ -164,11 +164,7 @@
X 
X BOOL os_is_administrator(PHWINFO pDev)
X {
X-#if __FreeBSD_version < 500000
X-    return suser(curproc);
X-#else
X     return suser(curthread);
X-#endif
X }
X 
X U008 os_io_read_byte(
Xdiff -urN ../NVIDIA-FreeBSD-x86-1.0-4365/src/nvidia_pci.c ./src/nvidia_pci.c
X--- ../NVIDIA-FreeBSD-x86-1.0-4365/src/nvidia_pci.c	Wed Oct  8 18:22:17 2003
X+++ ./src/nvidia_pci.c	Fri Oct 10 13:20:24 2003
X@@ -96,7 +96,7 @@
X     mtx_init(&sc->mtx_api, "dev.mtx_api", NULL, MTX_DEF);
X     mtx_init(&sc->mtx_rm,  "dev.mtx_rm",  NULL, MTX_SPIN);
X #else
X-    lockinit(&sc->api_lock, PZERO, "dev.api_lock", 0, 0); 
X+    lockinit(&sc->api_lock, 0, "dev.api_lock", 0, 0); 
X #endif
X     return 0;
X 
X@@ -115,7 +115,7 @@
X     mtx_destroy(&sc->mtx_rm);
X     mtx_destroy(&sc->mtx_api);
X #else
X-    lockmgr(&sc->api_lock, LK_DRAIN, 0, curproc);
X+    lockmgr(&sc->api_lock, LK_DRAIN, 0, curthread);
X #endif
X 
X     status = nvidia_detach(dev);
Xdiff -urN ../NVIDIA-FreeBSD-x86-1.0-4365/src/nvidia_subr.c ./src/nvidia_subr.c
X--- ../NVIDIA-FreeBSD-x86-1.0-4365/src/nvidia_subr.c	Wed Oct  8 18:22:17 2003
X+++ ./src/nvidia_subr.c	Fri Oct 10 13:27:19 2003
X@@ -297,7 +297,7 @@
X     u_long cmd,
X     caddr_t data,
X     int fflag,
X-    d_thread_t *td
X+    struct thread *td
X )
X {
X     struct nvidia_softc *sc;
X@@ -338,7 +338,7 @@
X 
X int nvidia_close_ctl(
X     dev_t dev,
X-    d_thread_t *td
X+    struct thread *td
X )
X {
X     nv_state_t *nv = &nvidia_ctl_state;
X@@ -391,7 +391,7 @@
X int nvidia_close_dev(
X     struct nvidia_softc *sc,
X     dev_t dev,
X-    d_thread_t *td
X+    struct thread *td
X )
X {
X     nv_state_t *nv = sc->nv_state;
X@@ -762,7 +762,7 @@
X      * of our system calls at a time.
X      */
X     struct nvidia_softc *sc = nv->os_state;
X-    lockmgr(&sc->api_lock, LK_EXCLUSIVE, 0, curproc);
X+    lockmgr(&sc->api_lock, LK_EXCLUSIVE, 0, curthread);
X #endif
X }
X 
X@@ -781,7 +781,7 @@
X      * its system call.
X      */
X     struct nvidia_softc *sc = nv->os_state;
X-    lockmgr(&sc->api_lock, LK_RELEASE, 0, curproc);
X+    lockmgr(&sc->api_lock, LK_RELEASE, 0, curthread);
X #endif
X }
X 
END-of-x11/nvidia-driver/files/patch-aa
exit





More information about the Submit mailing list