cleaned up x11/nvidia-driver override port

Emiel Kollof coolvibe at hackerheaven.org
Tue Feb 10 13:36:35 PST 2004


Hey folks,

Here's a cleaned up override port. What's different with the former is that
I split out the freebsd and dragonfly specific stuff, and even patched,
this module should still work/compile on FreeBSD as well.

Cheers,
Emiel
-- 
Law of Communications:
        The inevitable result of improved and enlarged communications
between different levels in a hierarchy is a vastly increased area of
misunderstanding.
# 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/CVS
#	x11/nvidia-driver/CVS/Root
#	x11/nvidia-driver/CVS/Repository
#	x11/nvidia-driver/CVS/Entries
#	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/CVS
#	x11/nvidia-driver/files/CVS/Root
#	x11/nvidia-driver/files/CVS/Repository
#	x11/nvidia-driver/files/CVS/Entries
#	x11/nvidia-driver/files/patch-dfly
#
echo c - x11/nvidia-driver/
mkdir -p x11/nvidia-driver/ > /dev/null 2>&1
echo c - x11/nvidia-driver/CVS
mkdir -p x11/nvidia-driver/CVS > /dev/null 2>&1
echo x - x11/nvidia-driver/CVS/Root
sed 's/^X//' >x11/nvidia-driver/CVS/Root << 'END-of-x11/nvidia-driver/CVS/Root'
X/home/dcvs
END-of-x11/nvidia-driver/CVS/Root
echo x - x11/nvidia-driver/CVS/Repository
sed 's/^X//' >x11/nvidia-driver/CVS/Repository << 'END-of-x11/nvidia-driver/CVS/Repository'
Xdfports/x11/nvidia-driver
END-of-x11/nvidia-driver/CVS/Repository
echo x - x11/nvidia-driver/CVS/Entries
sed 's/^X//' >x11/nvidia-driver/CVS/Entries << 'END-of-x11/nvidia-driver/CVS/Entries'
X/Makefile/1.2/Wed Jan 14 02:57:54 2004//
X/distinfo/1.1/Tue Oct 14 00:01:43 2003//
X/pkg-descr/1.1/Tue Oct 14 00:01:43 2003//
X/pkg-message/1.1/Tue Oct 14 00:01:43 2003//
X/pkg-plist/1.1/Tue Oct 14 00:01:43 2003//
XD/files////
END-of-x11/nvidia-driver/CVS/Entries
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# $DragonFly: dfports/x11/nvidia-driver/Makefile,v 1.2 2004/01/14 02:57:54 drhodus 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.dfport.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	-rm ${WRKSRC}/module/i386 # hack
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.dfport.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 c - x11/nvidia-driver/files/CVS
mkdir -p x11/nvidia-driver/files/CVS > /dev/null 2>&1
echo x - x11/nvidia-driver/files/CVS/Root
sed 's/^X//' >x11/nvidia-driver/files/CVS/Root << 'END-of-x11/nvidia-driver/files/CVS/Root'
X/home/dcvs
END-of-x11/nvidia-driver/files/CVS/Root
echo x - x11/nvidia-driver/files/CVS/Repository
sed 's/^X//' >x11/nvidia-driver/files/CVS/Repository << 'END-of-x11/nvidia-driver/files/CVS/Repository'
Xdfports/x11/nvidia-driver/files
END-of-x11/nvidia-driver/files/CVS/Repository
echo x - x11/nvidia-driver/files/CVS/Entries
sed 's/^X//' >x11/nvidia-driver/files/CVS/Entries << 'END-of-x11/nvidia-driver/files/CVS/Entries'
X/patch-aa/1.2/Wed Jan 14 02:57:54 2004//
XD
END-of-x11/nvidia-driver/files/CVS/Entries
echo x - x11/nvidia-driver/files/patch-dfly
sed 's/^X//' >x11/nvidia-driver/files/patch-dfly << 'END-of-x11/nvidia-driver/files/patch-dfly'
Xdiff -urN ./src/nv-dragonfly.h ../../nvidia-patched/src/nv-dragonfly.h
X--- ./src/nv-dragonfly.h	Thu Jan  1 01:00:00 1970
X+++ ../../nvidia-patched/src/nv-dragonfly.h	Tue Feb 10 22:25:38 2004
X@@ -0,0 +1,295 @@
X+/* _NVRM_COPYRIGHT_BEGIN_
X+ *
X+ * Copyright 2001 by NVIDIA Corporation.  All rights reserved.  All
X+ * information contained herein is proprietary and confidential to NVIDIA
X+ * Corporation.  Any use, reproduction, or disclosure without the written
X+ * permission of NVIDIA Corporation is prohibited.
X+ *
X+ * _NVRM_COPYRIGHT_END_
X+ */
X+
X+#ifndef __NV_DRAGONFLY_H
X+#define __NV_DRAGONFLY_H
X+
X+#ifdef TRUE
X+#undef TRUE
X+#endif
X+
X+#ifdef FALSE
X+#undef FALSE
X+#endif
X+
X+#include <sys/param.h>
X+#include <stdarg.h>
X+
X+#include <sys/systm.h>
X+#include <sys/types.h>
X+#include <sys/queue.h>
X+#include <sys/pciio.h>
X+#include <sys/vnode.h>
X+
X+#include <sys/kernel.h>
X+#include <sys/module.h>
X+#include <sys/ioccom.h>
X+#include <sys/malloc.h>
X+#include <sys/socket.h>
X+#include <sys/sysent.h>
X+#include <sys/sysctl.h>
X+
X+#include <machine/resource.h>
X+#include <machine/clock.h>
X+#include <machine/stdarg.h>
X+#include <machine/bus.h>
X+#include <machine/bus_memio.h>
X+#include <machine/vm86.h>
X+
X+#include <sys/conf.h>
X+#include <sys/rman.h>
X+#include <sys/proc.h>
X+#include <sys/lock.h>
X+#include <sys/mman.h>
X+#include <sys/file.h>
X+#include <sys/poll.h>
X+
X+#include <sys/syscall.h>
X+#include <sys/bus.h>
X+#include <sys/memrange.h>
X+#include <sys/sysproto.h>
X+#include <sys/signalvar.h>
X+
X+#include <vm/vm.h>
X+#include <vm/vm_param.h>
X+#include <vm/vm_kern.h>
X+#include <vm/vm_page.h>
X+#include <vm/vm_extern.h>
X+#include <vm/vm_object.h>
X+#include <vm/pmap.h>
X+#include <vm/vm_map.h>
X+
X+#include <dev/agp//agpvar.h>
X+#include <sys/agpio.h>
X+
X+#include "net/if.h"
X+#include "emulation/linux/i386/linux.h"
X+#include "emulation/linux/linux_ioctl.h"
X+
X+#include <machine/smp.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+
X+/*
X+ * The resource manager client tracking needs an identifier that uniquely
X+ * represents a client connection across threads. It needs to be specific
X+ * to the thread that allocated the client. The Linux struct file pointer
X+ * is such an identifier. The per-process file descriptor table is enough
X+ * on FreeBSD, due to its thread-aware reference counting.
X+ */
X+
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+
X+/*
X+ * The NVIDIA kernel module's malloc identifier, needed for both tracking
X+ * and actual allocation/freeing purposes - declared here, but defined in
X+ * nvidia_os.c.
X+ */
X+
X+MALLOC_DECLARE(M_NVIDIA);
X+
X+/*
X+ * This define controls if the module will be built to support the NVIDIA
X+ * AGP GART driver or the FreeBSD AGPGART driver module. If you decide to
X+ * use AGPGART, the agp.ko module must be preloaded from loader.conf.
X+ */
X+
X+#undef USE_OS_AGP_GART
X+
X+/*
X+ * This flag determines if system memory for use with the NVIDIA AGP GART
X+ * driver is allocated as a contiguous block of kernel virtual memory, or
X+ * as a VM object. The latter is better (tm), and thus the default.
X+ */
X+
X+#define NV_AGP_USE_VM_OBJECT 1
X+
X+/*
X+ * This option decides if the driver will be built with support for Linux
X+ * compatibility. This makes nvidia.ko dependant on linux.ko; if you have
X+ * no need for Linux 3D applications, you can safely unset this flag.
X+ */
X+
X+#define NV_SUPPORT_LINUX_COMPAT 1
X+
X+/*
X+ * The DMA memory allocation tracking structure. DMA memory alloctions on
X+ * FreeBSD are tracked with their base address and size. Since PCI memory
X+ * is allocated from kernel virtual memory and since AGP allocations have
X+ * a contiguous range of addresses in the AGP aperture, base and size are
X+ * sufficient to track allocations.
X+ */
X+
X+typedef
X+struct nv_alloc {
X+    SLIST_ENTRY(nv_alloc) list;
X+    u_int32_t size;
X+    vm_offset_t address;
X+    u_int32_t offset;
X+    struct vm_object *object;
X+} nv_alloc_t;
X+
X+typedef
X+struct nv_alloc_private {
X+    u_int32_t count;
X+    u_int32_t alloc_type_contiguous;
X+    u_int32_t alloc_type_cached;
X+    u_int32_t alloc_type_kernel;
X+    u_int32_t class;
X+} nv_alloc_private_t;
X+
X+typedef
X+struct nvidia_softc {
X+    device_t dev;
X+    device_t agp_dev;
X+
X+    struct resource *reg;
X+    int reg_rid;
X+    int reg_type;
X+
X+    struct resource *mem;
X+    int mem_rid;
X+    int mem_type;
X+
X+    struct resource *irq;
X+    void *irq_ih;
X+    int   irq_rid;
X+
X+    dev_t cdev;
X+    nv_state_t *nv_state;
X+
X+    struct sysctl_ctx_list sysctl_ctx;
X+    struct selinfo rsel;
X+
X+    struct callout_handle timer_ch;
X+
X+    /* list of allocations */
X+    SLIST_HEAD(alloc_list, nv_alloc) alloc_list;
X+
X+#if __FreeBSD_version >= 500000
X+    struct mtx mtx_rm;
X+    struct mtx mtx_api;
X+#else
X+    int spl;
X+    struct lock api_lock;
X+#endif
X+} nvidia_softc_t;
X+
X+
X+#define CDEV_MAJOR      180
X+#define CDEV_CTL_MINOR  255
X+
X+extern devclass_t nvidia_devclass;
X+extern nv_state_t nvidia_ctl_state;
X+
X+extern const char *pNVRM_ID;
X+
X+#define PCIR_CAP_LIST_ID   0x00
X+#define PCIR_CAP_LIST_NEXT 0x01
X+#define PCIR_CAP_ID_AGP    0x02
X+
X+/*
X+ * Entries in the NVIDIA glue-layer registry are now described by the new
X+ * shared nv_parm_t structure; please review nvidia_os_registry.c in case
X+ * you need to make low-level configuration changes. The entries are also
X+ * mapped into the SYSCTL hierarchy and thus easily accessible.
X+ */
X+
X+extern nv_parm_t nv_parms[];
X+
X+
X+/* nvidia_dev.c */
X+int    nvidia_dev_attach     (struct nvidia_softc *);
X+int    nvidia_dev_detach     (struct nvidia_softc *);
X+
X+/* nvidia_ctl.c */
X+int    nvidia_ctl_attach     (void);
X+int    nvidia_ctl_detach     (void);
X+
X+/* nvidia_subr.c */
X+int    nvidia_attach         (device_t);
X+int    nvidia_detach         (device_t);
X+int    nvidia_suspend        (device_t);
X+int    nvidia_resume         (device_t);
X+int    nvidia_alloc          (device_t);
X+int    nvidia_free           (device_t);
X+void   nvidia_intr           (void *);
X+int    nvidia_modevent       (module_t, int, void *);
X+
X+void   nvidia_rc_timer       (void *);
X+
X+void   nv_lock_api           (nv_state_t *);
X+void   nv_unlock_api         (nv_state_t *);
X+
X+S032   nv_alloc_contig_pages (nv_state_t *, VOID **, U032);
X+S032   nv_free_contig_pages  (nv_state_t *, VOID *);
X+S032   nv_alloc_system_pages (nv_state_t *, VOID **, U032);
X+S032   nv_free_system_pages  (nv_state_t *, VOID *);
X+
X+S032   nv_alloc_vm_object    (nv_state_t *, VOID **, U032);
X+S032   nv_free_vm_object     (nv_state_t *, VOID *);
X+
X+void*  nv_find_alloc         (nv_state_t *, vm_offset_t);
X+void*  nv_find_alloc_obj     (nv_state_t *, vm_offset_t);
X+
X+S032   nv_os_agp_init        (nv_state_t *, VOID **, VOID **, U032 *);
X+S032   nv_os_agp_teardown    (nv_state_t *);
X+S032   nv_alloc_agp_pages    (nv_state_t *, VOID **, U032, U032, VOID **);
X+S032   nv_free_agp_pages     (nv_state_t *, VOID **, U032, VOID *);
X+
X+/* nvidia_sysctl.c */
X+void   nvidia_sysctl_init    (void);
X+void   nvidia_sysctl_exit    (void);
X+
X+U008   nvidia_find_cap       (device_t);
X+void*  nvidia_find_bridge    (void);
X+
X+int    nvidia_sysctl_vbios   (SYSCTL_HANDLER_ARGS);
X+int    nvidia_sysctl_type    (SYSCTL_HANDLER_ARGS);
X+int    nvidia_sysctl_rates   (SYSCTL_HANDLER_ARGS);
X+int    nvidia_sysctl_fw      (SYSCTL_HANDLER_ARGS);
X+int    nvidia_sysctl_sba     (SYSCTL_HANDLER_ARGS);
X+int    nvidia_sysctl_regs    (SYSCTL_HANDLER_ARGS);
X+
X+int    nvidia_sysctl_driver  (SYSCTL_HANDLER_ARGS);
X+int    nvidia_sysctl_rate_s  (SYSCTL_HANDLER_ARGS);
X+int    nvidia_sysctl_fw_s    (SYSCTL_HANDLER_ARGS);
X+int    nvidia_sysctl_sba_s   (SYSCTL_HANDLER_ARGS);
X+int    nvidia_sysctl_status  (SYSCTL_HANDLER_ARGS);
X+
X+void   nv_sysctl_init        (nv_state_t *);
X+void   nv_sysctl_exit        (nv_state_t *);
X+
X+/* nvidia_linux.c */
X+int    linux_ioctl_nvidia    (d_thread_t *, struct linux_ioctl_args *);
X+void   nvidia_linux_init     (void);
X+void   nvidia_linux_exit     (void);
X+
X+/* ioctl helpers */
X+int    nvidia_set_primary     (struct nv_ioctl_primary_card *);
X+int    nvidia_get_card_info   (struct nv_ioctl_card_info *);
X+int    nvidia_get_api_version (struct nv_ioctl_rm_api_version *);
X+int    nvidia_handle_ioctl    (dev_t, u_long, caddr_t, int, d_thread_t *);
X+
X+
X+/* device helpers */
X+int    nvidia_open_ctl       (void);
X+int    nvidia_open_dev       (struct nvidia_softc *);
X+int    nvidia_close_ctl      (dev_t, d_thread_t *);
X+int    nvidia_close_dev      (struct nvidia_softc *, dev_t, d_thread_t *);
X+int    nvidia_mmap_dev       (struct nvidia_softc *, vm_offset_t, vm_offset_t *);
X+
X+#endif /* __NV_DRAGONFLY_H */
X+
Xdiff -urN ./src/nvidia_ctl.c ../../nvidia-patched/src/nvidia_ctl.c
X--- ./src/nvidia_ctl.c	Wed May 28 18:51:52 2003
X+++ ../../nvidia-patched/src/nvidia_ctl.c	Tue Feb 10 22:14:00 2004
X@@ -11,7 +11,11 @@
X #include "nv-misc.h"
X #include "os-interface.h"
X #include "nv.h"
X+#if defined(__FreeBSD__) && !defined(__DragonFly__)
X #include "nv-freebsd.h"
X+#else
X+#include "nv-dragonfly.h"
X+#endif
X 
X static d_open_t  nvidia_ctl_open;
X static d_close_t nvidia_ctl_close;
X@@ -19,7 +23,7 @@
X static d_poll_t  nvidia_ctl_poll;
X 
X static struct cdevsw nvidia_ctl_cdevsw = {
X-#if __FreeBSD_version < 500105
X+#if __FreeBSD_version < 500105 && !defined(__DragonFly__)
X     /* open    */  nvidia_ctl_open,
X     /* close */    nvidia_ctl_close,
X     /* read */     noread,
X@@ -37,7 +41,7 @@
X     /* bmaj */     -1,
X #endif
X     /* kqfilter */ NULL,
X-#else
X+#elif !defined(__DragonFly__)
X     .d_open =      nvidia_ctl_open,
X     .d_close =     nvidia_ctl_close,
X     .d_ioctl =     nvidia_ctl_ioctl,
X@@ -46,6 +50,25 @@
X     .d_maj =       CDEV_MAJOR,
X     .d_flags =     D_TRACKCLOSE
X #endif
X+
X+/* Dragonfly */
X+#if defined(__DragonFly__)
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+    /* write */    nowrite,
X+    /* ioctl */    nvidia_ctl_ioctl,
X+    /* poll */     nvidia_ctl_poll,
X+    /* mmap */     nommap,
X+    /* strategy */ nostrategy,
X+    /* dump */     nodump,
X+#endif
X };
X 
X static dev_t          nvidia_ctl_cdev;
X@@ -218,7 +241,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@@ -242,8 +265,10 @@
X #if __FreeBSD_version >= 500000
X         mtx_destroy(&sc->mtx_rm);
X         mtx_destroy(&sc->mtx_api);
X-#else
X+#elif defined(__FreeBSD__) && !defined(__DragonFly__)
X         lockmgr(&sc->api_lock, LK_DRAIN, 0, curproc);
X+#else 
X+        lockmgr(&sc->api_lock, LK_DRAIN, 0, curthread);
X #endif
X         destroy_dev(nvidia_ctl_cdev);
X     }
Xdiff -urN ./src/nvidia_dev.c ../../nvidia-patched/src/nvidia_dev.c
X--- ./src/nvidia_dev.c	Wed May 28 18:51:52 2003
X+++ ../../nvidia-patched/src/nvidia_dev.c	Tue Feb 10 22:15:53 2004
X@@ -11,7 +11,11 @@
X #include "nv-misc.h"
X #include "os-interface.h"
X #include "nv.h"
X+#if defined(__FreeBSD__) && !defined(__DragonFly__)
X #include "nv-freebsd.h"
X+#else 
X+#include "nv-dragonfly.h"
X+#endif
X 
X static d_open_t  nvidia_dev_open;
X static d_close_t nvidia_dev_close;
X@@ -20,7 +24,7 @@
X static d_mmap_t  nvidia_dev_mmap;
X 
X static struct cdevsw nvidia_dev_cdevsw = {
X-#if __FreeBSD_version < 500105
X+#if __FreeBSD_version < 500105 && !defined(__DragonFly__)
X     /* open    */  nvidia_dev_open,
X     /* close */    nvidia_dev_close,
X     /* read */     noread,
X@@ -38,7 +42,7 @@
X     /* bmaj */     -1,
X #endif
X     /* kqfilter */ NULL,
X-#else
X+#elif !defined(__DragonFly__)
X     .d_open =      nvidia_dev_open,
X     .d_close =     nvidia_dev_close,
X     .d_ioctl =     nvidia_dev_ioctl,
X@@ -48,6 +52,26 @@
X     .d_maj =       CDEV_MAJOR,
X     .d_flags =     D_MEM|D_TRACKCLOSE
X #endif
X+
X+#ifdef __DragonFly__
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+    /* write */    nowrite,
X+    /* ioctl */    nvidia_dev_ioctl,
X+    /* poll */     nvidia_dev_poll,
X+    /* mmap */     nvidia_dev_mmap,
X+    /* strategy */ nostrategy,
X+    /* dump */     nodump,
X+    /* psize */    nopsize,
X+#endif
X+
X };
X 
X int nvidia_dev_open(
Xdiff -urN ./src/nvidia_linux.c ../../nvidia-patched/src/nvidia_linux.c
X--- ./src/nvidia_linux.c	Wed May 28 18:51:52 2003
X+++ ../../nvidia-patched/src/nvidia_linux.c	Tue Feb 10 22:16:38 2004
X@@ -11,7 +11,11 @@
X #include "nv-misc.h"
X #include "os-interface.h"
X #include "nv.h"
X+#if defined(__FreeBSD__) && !defined(__DragonFly__)
X #include "nv-freebsd.h"
X+#else
X+#include "nv-dragonfly.h"
X+#endif
X 
X #define LINUX_IOCTL_NVIDIA_MIN 0x4600
X #define LINUX_IOCTL_NVIDIA_MAX 0x46ff
X@@ -33,7 +37,11 @@
X      * copy the user data in/out correctly.
X      */
X 
X+#ifndef __DragonFly__
X     return (ioctl(td, (struct ioctl_args *) args));
X+#else 
X+    return (ioctl((struct ioctl_args *) args));
X+#endif
X }
X 
X struct linux_ioctl_handler nvidia_handler = {
Xdiff -urN ./src/nvidia_os.c ../../nvidia-patched/src/nvidia_os.c
X--- ./src/nvidia_os.c	Wed May 28 18:51:52 2003
X+++ ../../nvidia-patched/src/nvidia_os.c	Tue Feb 10 22:18:50 2004
X@@ -11,7 +11,11 @@
X #include "nv-misc.h"
X #include "os-interface.h"
X #include "nv.h"
X+#if defined(__FreeBSD__) && !defined(__DragonFly__)
X #include "nv-freebsd.h"
X+#else
X+#include "nv-dragonfly.h"
X+#endif
X 
X 
X /*
X@@ -164,7 +168,7 @@
X 
X BOOL os_is_administrator(PHWINFO pDev)
X {
X-#if __FreeBSD_version < 500000
X+#if __FreeBSD_version < 500000 && !defined(__DragonFly__)
X     return suser(curproc);
X #else
X     return suser(curthread);
Xdiff -urN ./src/nvidia_os_pci.c ../../nvidia-patched/src/nvidia_os_pci.c
X--- ./src/nvidia_os_pci.c	Wed May 28 18:51:52 2003
X+++ ../../nvidia-patched/src/nvidia_os_pci.c	Tue Feb 10 22:20:42 2004
X@@ -11,7 +11,11 @@
X #include "nv-misc.h"
X #include "os-interface.h"
X #include "nv.h"
X+#if defined(__FreeBSD__) && !defined(__DragonFly__)
X #include "nv-freebsd.h"
X+#else
X+#include "nv-dragonfly.h"
X+#endif
X 
X 
X VOID* os_pci_init_handle(
Xdiff -urN ./src/nvidia_os_registry.c ../../nvidia-patched/src/nvidia_os_registry.c
X--- ./src/nvidia_os_registry.c	Wed May 28 18:51:52 2003
X+++ ../../nvidia-patched/src/nvidia_os_registry.c	Tue Feb 10 22:21:20 2004
X@@ -11,7 +11,11 @@
X #include "nv-misc.h"
X #include "os-interface.h"
X #include "nv.h"
X+#if defined(__FreeBSD__) && !defined(__DragonFly__)
X #include "nv-freebsd.h"
X+#else
X+#include "nv-dragonfly.h"
X+#endif
X 
X 
X /*
Xdiff -urN ./src/nvidia_pci.c ../../nvidia-patched/src/nvidia_pci.c
X--- ./src/nvidia_pci.c	Wed May 28 18:51:52 2003
X+++ ../../nvidia-patched/src/nvidia_pci.c	Tue Feb 10 22:22:11 2004
X@@ -11,7 +11,11 @@
X #include "nv-misc.h"
X #include "os-interface.h"
X #include "nv.h"
X+#if defined(__FreeBSD__) && !defined(__DragonFly__)
X #include "nv-freebsd.h"
X+#else
X+#include "nv-dragonfly.h"
X+#endif
X 
X #define NVIDIA_VENDORID 0x10de
X #define NVIDIA_PCI_REG  0x10
X@@ -95,8 +99,10 @@
X #if __FreeBSD_version >= 500000
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+#elif !defined(__DragonFly__)
X     lockinit(&sc->api_lock, PZERO, "dev.api_lock", 0, 0); 
X+#else
X+    lockinit(&sc->api_lock, 0, "dev.api_lock", 0, 0); 
X #endif
X     return 0;
X 
X@@ -114,8 +120,10 @@
X #if __FreeBSD_version >= 500000
X     mtx_destroy(&sc->mtx_rm);
X     mtx_destroy(&sc->mtx_api);
X-#else
X+#elif !defined(__DragonFly__)
X     lockmgr(&sc->api_lock, LK_DRAIN, 0, curproc);
X+#else
X+    lockmgr(&sc->api_lock, LK_DRAIN, 0, curthread);
X #endif
X 
X     status = nvidia_detach(dev);
Xdiff -urN ./src/nvidia_subr.c ../../nvidia-patched/src/nvidia_subr.c
X--- ./src/nvidia_subr.c	Wed May 28 18:51:52 2003
X+++ ../../nvidia-patched/src/nvidia_subr.c	Tue Feb 10 22:22:58 2004
X@@ -11,7 +11,11 @@
X #include "nv-misc.h"
X #include "os-interface.h"
X #include "nv.h"
X+#if defined(__FreeBSD__) && !defined(__DragonFly__)
X #include "nv-freebsd.h"
X+#else
X+#include "nv-dragonfly.h"
X+#endif
X 
X 
X devclass_t nvidia_devclass;
X@@ -297,7 +301,11 @@
X     u_long cmd,
X     caddr_t data,
X     int fflag,
X+#if !defined(__DragonFly__)
X     d_thread_t *td
X+#else 
X+    struct thread *td
X+#endif
X )
X {
X     struct nvidia_softc *sc;
X@@ -338,7 +346,11 @@
X 
X int nvidia_close_ctl(
X     dev_t dev,
X+#if !defined(__DragonFly__)
X     d_thread_t *td
X+#else
X+    struct thread *td
X+#endif
X )
X {
X     nv_state_t *nv = &nvidia_ctl_state;
X@@ -762,7 +774,12 @@
X      * of our system calls at a time.
X      */
X     struct nvidia_softc *sc = nv->os_state;
X+#ifndef __DragonFly__
X     lockmgr(&sc->api_lock, LK_EXCLUSIVE, 0, curproc);
X+#else
X+    lockmgr(&sc->api_lock, LK_EXCLUSIVE, 0, curthread);
X+#endif
X+
X #endif
X }
X 
X@@ -781,7 +798,12 @@
X      * its system call.
X      */
X     struct nvidia_softc *sc = nv->os_state;
X+#ifndef __DragonFly__
X     lockmgr(&sc->api_lock, LK_RELEASE, 0, curproc);
X+#else
X+    lockmgr(&sc->api_lock, LK_RELEASE, 0, curthread);
X+#endif
X+
X #endif
X }
X 
Xdiff -urN ./src/nvidia_sysctl.c ../../nvidia-patched/src/nvidia_sysctl.c
X--- ./src/nvidia_sysctl.c	Wed May 28 18:51:52 2003
X+++ ../../nvidia-patched/src/nvidia_sysctl.c	Tue Feb 10 22:23:53 2004
X@@ -11,7 +11,11 @@
X #include "nv-misc.h"
X #include "os-interface.h"
X #include "nv.h"
X+#if defined(__FreeBSD__) && !defined(__DragonFly__)
X #include "nv-freebsd.h"
X+#else
X+#include "nv-dragonfly.h"
X+#endif
X 
X struct sysctl_ctx_list sysctl_ctx;
X 
END-of-x11/nvidia-driver/files/patch-dfly
exit





More information about the Submit mailing list