DragonFly submit List (threaded) for 2004-07
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
updated patch-dfly for x11/nvidia-driver override port
--Boundary-00=_hxi/AYelIthQPpp
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hey people,
Attached is a cleaned up patch for the x11/nvidia-driver override port. It
brings in some fixes I discussed with Joerg, and it also might fix this
driver for SMP systems. Please test this patch if you have SMP, or have
nothing better to do :)
Note: this is NOT related to the prerelease driver I got from NVIDIA.
to test:
Drop patch in /usr/dfports/x11/nvidia-driver/files, overwriting the one that's
there. make install, be merry.
Cheers,
Emiel
--
If only one could get that wonderful feeling of accomplishment without
having to accomplish anything.
--Boundary-00=_hxi/AYelIthQPpp
Content-Type: text/x-diff;
charset="us-ascii";
name="patch-dfly"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="patch-dfly"
diff -urN ./module/Makefile ../../nvidia-patched/module/Makefile
--- ./module/Makefile 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/module/Makefile 2004-07-21 10:14:32.000000000 +0200
@@ -6,7 +6,7 @@
KMOD= nvidia
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
SRCS+= device_if.h bus_if.h pci_if.h vnode_if.h
-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
+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 -Werror
NVOBJ= ${NVIDIA_ROOT}/obj/nv-kernel.o
OBJS+= NVIDIA.o
NOOBJ= true
diff -urN ./src/nv-dragonfly.h ../../nvidia-patched/src/nv-dragonfly.h
--- ./src/nv-dragonfly.h 1970-01-01 01:00:00.000000000 +0100
+++ ../../nvidia-patched/src/nv-dragonfly.h 2004-07-21 10:24:22.000000000 +0200
@@ -0,0 +1,297 @@
+/* _NVRM_COPYRIGHT_BEGIN_
+ *
+ * Copyright 2001 by NVIDIA Corporation. All rights reserved. All
+ * information contained herein is proprietary and confidential to NVIDIA
+ * Corporation. Any use, reproduction, or disclosure without the written
+ * permission of NVIDIA Corporation is prohibited.
+ *
+ * _NVRM_COPYRIGHT_END_
+ */
+
+#ifndef __NV_DRAGONFLY_H
+#define __NV_DRAGONFLY_H
+
+#ifdef TRUE
+#undef TRUE
+#endif
+
+#ifdef FALSE
+#undef FALSE
+#endif
+
+#include <sys/param.h>
+#include <stdarg.h>
+
+#include <sys/systm.h>
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/pciio.h>
+#include <sys/vnode.h>
+
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/ioccom.h>
+#include <sys/malloc.h>
+#include <sys/socket.h>
+#include <sys/sysent.h>
+#include <sys/sysctl.h>
+
+#include <machine/resource.h>
+#include <machine/clock.h>
+#include <machine/stdarg.h>
+#include <machine/bus.h>
+#include <machine/bus_memio.h>
+#include <machine/vm86.h>
+
+#include <sys/conf.h>
+#include <sys/rman.h>
+#include <sys/proc.h>
+#include <sys/lock.h>
+#include <sys/mman.h>
+#include <sys/file.h>
+#include <sys/poll.h>
+
+#include <sys/syscall.h>
+#include <sys/bus.h>
+#include <sys/memrange.h>
+#include <sys/sysproto.h>
+#include <sys/signalvar.h>
+
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/vm_kern.h>
+#include <vm/vm_page.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_object.h>
+#include <vm/pmap.h>
+#include <vm/vm_map.h>
+
+#include <dev/agp//agpvar.h>
+#include <sys/agpio.h>
+
+#include "net/if.h"
+#include "emulation/linux/i386/linux.h"
+#include "emulation/linux/linux_ioctl.h"
+
+#include <machine/smp.h>
+#include <bus/pci/pcireg.h>
+#include <bus/pci/pcivar.h>
+
+#include <sys/thread2.h>
+
+#define vm_page_lock_queues()
+#define vm_page_unlock_queues()
+
+/*
+ * The resource manager client tracking needs an identifier that uniquely
+ * represents a client connection across threads. It needs to be specific
+ * to the thread that allocated the client. The Linux struct file pointer
+ * is such an identifier. The per-process file descriptor table is enough
+ * on FreeBSD, due to its thread-aware reference counting.
+ */
+
+#define __TD_FDT(td) ((td)->td_proc->p_fd)
+#define __TD_FDT_CNT(td) ((td)->td_proc->p_fd->fd_refcnt)
+
+
+/*
+ * The NVIDIA kernel module's malloc identifier, needed for both tracking
+ * and actual allocation/freeing purposes - declared here, but defined in
+ * nvidia_os.c.
+ */
+
+MALLOC_DECLARE(M_NVIDIA);
+
+/*
+ * This define controls if the module will be built to support the NVIDIA
+ * AGP GART driver or the FreeBSD AGPGART driver module. If you decide to
+ * use AGPGART, the agp.ko module must be preloaded from loader.conf.
+ */
+
+#undef USE_OS_AGP_GART
+
+/*
+ * This flag determines if system memory for use with the NVIDIA AGP GART
+ * driver is allocated as a contiguous block of kernel virtual memory, or
+ * as a VM object. The latter is better (tm), and thus the default.
+ */
+
+#define NV_AGP_USE_VM_OBJECT 1
+
+/*
+ * This option decides if the driver will be built with support for Linux
+ * compatibility. This makes nvidia.ko dependant on linux.ko; if you have
+ * no need for Linux 3D applications, you can safely unset this flag.
+ */
+
+#define NV_SUPPORT_LINUX_COMPAT 1
+
+/*
+ * The DMA memory allocation tracking structure. DMA memory alloctions on
+ * FreeBSD are tracked with their base address and size. Since PCI memory
+ * is allocated from kernel virtual memory and since AGP allocations have
+ * a contiguous range of addresses in the AGP aperture, base and size are
+ * sufficient to track allocations.
+ */
+
+typedef
+struct nv_alloc {
+ SLIST_ENTRY(nv_alloc) list;
+ u_int32_t size;
+ vm_offset_t address;
+ u_int32_t offset;
+ struct vm_object *object;
+} nv_alloc_t;
+
+typedef
+struct nv_alloc_private {
+ u_int32_t count;
+ u_int32_t alloc_type_contiguous;
+ u_int32_t alloc_type_cached;
+ u_int32_t alloc_type_kernel;
+ u_int32_t class;
+} nv_alloc_private_t;
+
+typedef
+struct nvidia_softc {
+ device_t dev;
+ device_t agp_dev;
+
+ struct resource *reg;
+ int reg_rid;
+ int reg_type;
+
+ struct resource *mem;
+ int mem_rid;
+ int mem_type;
+
+ struct resource *irq;
+ void *irq_ih;
+ int irq_rid;
+
+ dev_t cdev;
+ nv_state_t *nv_state;
+
+ struct sysctl_ctx_list sysctl_ctx;
+ struct selinfo rsel;
+
+ struct callout timer_ch;
+
+ /* list of allocations */
+ SLIST_HEAD(alloc_list, nv_alloc) alloc_list;
+
+#if __FreeBSD_version >= 500000
+ struct mtx mtx_rm;
+ struct mtx mtx_api;
+#else
+ int spl;
+ struct lock api_lock;
+#endif
+} nvidia_softc_t;
+
+
+#define CDEV_MAJOR 180
+#define CDEV_CTL_MINOR 255
+
+extern devclass_t nvidia_devclass;
+extern nv_state_t nvidia_ctl_state;
+
+extern const char *pNVRM_ID;
+
+#define PCIR_CAP_LIST_ID 0x00
+#define PCIR_CAP_LIST_NEXT 0x01
+#define PCIR_CAP_ID_AGP 0x02
+
+/*
+ * Entries in the NVIDIA glue-layer registry are now described by the new
+ * shared nv_parm_t structure; please review nvidia_os_registry.c in case
+ * you need to make low-level configuration changes. The entries are also
+ * mapped into the SYSCTL hierarchy and thus easily accessible.
+ */
+
+extern nv_parm_t nv_parms[];
+
+
+/* nvidia_dev.c */
+int nvidia_dev_attach (struct nvidia_softc *);
+int nvidia_dev_detach (struct nvidia_softc *);
+
+/* nvidia_ctl.c */
+int nvidia_ctl_attach (void);
+int nvidia_ctl_detach (void);
+
+/* nvidia_subr.c */
+int nvidia_attach (device_t);
+int nvidia_detach (device_t);
+int nvidia_suspend (device_t);
+int nvidia_resume (device_t);
+int nvidia_alloc (device_t);
+int nvidia_free (device_t);
+void nvidia_intr (void *);
+int nvidia_modevent (module_t, int, void *);
+
+void nvidia_rc_timer (void *);
+
+void nv_lock_api (nv_state_t *);
+void nv_unlock_api (nv_state_t *);
+
+S032 nv_alloc_contig_pages (nv_state_t *, VOID **, U032);
+S032 nv_free_contig_pages (nv_state_t *, VOID *);
+S032 nv_alloc_system_pages (nv_state_t *, VOID **, U032);
+S032 nv_free_system_pages (nv_state_t *, VOID *);
+
+S032 nv_alloc_vm_object (nv_state_t *, VOID **, U032);
+S032 nv_free_vm_object (nv_state_t *, VOID *);
+
+void* nv_find_alloc (nv_state_t *, vm_offset_t);
+void* nv_find_alloc_obj (nv_state_t *, vm_offset_t);
+
+S032 nv_os_agp_init (nv_state_t *, VOID **, VOID **, U032 *);
+S032 nv_os_agp_teardown (nv_state_t *);
+S032 nv_alloc_agp_pages (nv_state_t *, VOID **, U032, U032, VOID **);
+S032 nv_free_agp_pages (nv_state_t *, VOID **, U032, VOID *);
+
+/* nvidia_sysctl.c */
+void nvidia_sysctl_init (void);
+void nvidia_sysctl_exit (void);
+
+U008 nvidia_find_cap (device_t);
+void* nvidia_find_bridge (void);
+
+int nvidia_sysctl_vbios (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_type (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_rates (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_fw (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_sba (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_regs (SYSCTL_HANDLER_ARGS);
+
+int nvidia_sysctl_driver (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_rate_s (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_fw_s (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_sba_s (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_status (SYSCTL_HANDLER_ARGS);
+
+void nv_sysctl_init (nv_state_t *);
+void nv_sysctl_exit (nv_state_t *);
+
+/* nvidia_linux.c */
+int linux_ioctl_nvidia (d_thread_t *, struct linux_ioctl_args *);
+void nvidia_linux_init (void);
+void nvidia_linux_exit (void);
+
+/* ioctl helpers */
+int nvidia_set_primary (struct nv_ioctl_primary_card *);
+int nvidia_get_card_info (struct nv_ioctl_card_info *);
+int nvidia_get_api_version (struct nv_ioctl_rm_api_version *);
+int nvidia_handle_ioctl (dev_t, u_long, caddr_t, int, d_thread_t *);
+
+
+/* device helpers */
+int nvidia_open_ctl (void);
+int nvidia_open_dev (struct nvidia_softc *);
+int nvidia_close_ctl (dev_t, d_thread_t *);
+int nvidia_close_dev (struct nvidia_softc *, dev_t, d_thread_t *);
+int nvidia_mmap_dev (struct nvidia_softc *, vm_offset_t, vm_offset_t *);
+
+#endif /* __NV_DRAGONFLY_H */
+
diff -urN ./src/nvidia_ctl.c ../../nvidia-patched/src/nvidia_ctl.c
--- ./src/nvidia_ctl.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_ctl.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
static d_open_t nvidia_ctl_open;
static d_close_t nvidia_ctl_close;
@@ -19,7 +23,7 @@
static d_poll_t nvidia_ctl_poll;
static struct cdevsw nvidia_ctl_cdevsw = {
-#if __FreeBSD_version < 500105
+#if __FreeBSD_version < 500105 && !defined(__DragonFly__)
/* open */ nvidia_ctl_open,
/* close */ nvidia_ctl_close,
/* read */ noread,
@@ -37,7 +41,7 @@
/* bmaj */ -1,
#endif
/* kqfilter */ NULL,
-#else
+#elif !defined(__DragonFly__)
.d_open = nvidia_ctl_open,
.d_close = nvidia_ctl_close,
.d_ioctl = nvidia_ctl_ioctl,
@@ -46,6 +50,25 @@
.d_maj = CDEV_MAJOR,
.d_flags = D_TRACKCLOSE
#endif
+
+/* Dragonfly */
+#if defined(__DragonFly__)
+ /* name */ "nvidiactl",
+ /* maj */ CDEV_MAJOR,
+ /* flags */ D_TRACKCLOSE,
+ /* port */ NULL,
+ /* autoq */ 0,
+
+ /* open */ nvidia_ctl_open,
+ /* close */ nvidia_ctl_close,
+ /* read */ noread,
+ /* write */ nowrite,
+ /* ioctl */ nvidia_ctl_ioctl,
+ /* poll */ nvidia_ctl_poll,
+ /* mmap */ nommap,
+ /* strategy */ nostrategy,
+ /* dump */ nodump,
+#endif
};
static dev_t nvidia_ctl_cdev;
@@ -200,16 +223,20 @@
struct nvidia_softc *sc;
if (nvidia_count == 0) {
+
+
/*
* This routine is called from nvidia_attach, multiple times when
* more than one device is installed - this makes it necessary to
* prevent multiple calls to make_dev.
*/
+ cdevsw_add(&nvidia_ctl_cdevsw, -1, 255); /* XXX */
nvidia_ctl_cdev = make_dev(&nvidia_ctl_cdevsw,
CDEV_CTL_MINOR,
UID_ROOT, GID_WHEEL, 0666,
"%s", nvidia_ctl_cdevsw.d_name);
+
sc = &nvidia_ctl_sc;
bzero(sc, sizeof(nvidia_softc_t));
nvidia_ctl_state.os_state = sc;
@@ -218,7 +245,7 @@
mtx_init(&sc->mtx_api, "ctl.mtx_api", NULL, MTX_DEF);
mtx_init(&sc->mtx_rm, "ctl.mtx_rm", NULL, MTX_SPIN);
#else
- lockinit(&sc->api_lock, PZERO, "ctl.api_lock", 0, 0);
+ lockinit(&sc->api_lock, 0, "ctl.api_lock", 0, 0);
#endif
}
@@ -242,10 +269,17 @@
#if __FreeBSD_version >= 500000
mtx_destroy(&sc->mtx_rm);
mtx_destroy(&sc->mtx_api);
-#else
+#elif defined(__FreeBSD__) && !defined(__DragonFly__)
lockmgr(&sc->api_lock, LK_DRAIN, 0, curproc);
-#endif
destroy_dev(nvidia_ctl_cdev);
+#else
+ lockmgr(&sc->api_lock, LK_DRAIN, NULL, curthread);
+#endif
+
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
+ cdevsw_remove(&nvidia_ctl_cdevsw, -1, 255); /* XXX */
+#endif
+
}
return 0;
diff -urN ./src/nvidia_dev.c ../../nvidia-patched/src/nvidia_dev.c
--- ./src/nvidia_dev.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_dev.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
static d_open_t nvidia_dev_open;
static d_close_t nvidia_dev_close;
@@ -20,7 +24,7 @@
static d_mmap_t nvidia_dev_mmap;
static struct cdevsw nvidia_dev_cdevsw = {
-#if __FreeBSD_version < 500105
+#if __FreeBSD_version < 500105 && !defined(__DragonFly__)
/* open */ nvidia_dev_open,
/* close */ nvidia_dev_close,
/* read */ noread,
@@ -38,7 +42,7 @@
/* bmaj */ -1,
#endif
/* kqfilter */ NULL,
-#else
+#elif !defined(__DragonFly__)
.d_open = nvidia_dev_open,
.d_close = nvidia_dev_close,
.d_ioctl = nvidia_dev_ioctl,
@@ -48,6 +52,26 @@
.d_maj = CDEV_MAJOR,
.d_flags = D_MEM|D_TRACKCLOSE
#endif
+
+#ifdef __DragonFly__
+ /* name */ "nvidia",
+ /* maj */ CDEV_MAJOR,
+ /* flags */ D_MEM|D_TRACKCLOSE,
+ /* port */ NULL,
+ /* autoq */ 0,
+
+ /* open */ nvidia_dev_open,
+ /* close */ nvidia_dev_close,
+ /* read */ noread,
+ /* write */ nowrite,
+ /* ioctl */ nvidia_dev_ioctl,
+ /* poll */ nvidia_dev_poll,
+ /* mmap */ nvidia_dev_mmap,
+ /* strategy */ nostrategy,
+ /* dump */ nodump,
+ /* psize */ nopsize,
+#endif
+
};
int nvidia_dev_open(
@@ -187,6 +211,7 @@
int nvidia_dev_attach (struct nvidia_softc *sc)
{
+ cdevsw_add(&nvidia_dev_cdevsw, -1, device_get_unit(sc->dev));
sc->cdev = make_dev(&nvidia_dev_cdevsw,
device_get_unit(sc->dev),
UID_ROOT, GID_WHEEL, 0666,
@@ -199,7 +224,11 @@
int nvidia_dev_detach (struct nvidia_softc *sc)
{
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
destroy_dev(sc->cdev);
+#else
+ cdevsw_remove(&nvidia_dev_cdevsw, -1, device_get_unit(sc->dev));
+#endif
return 0;
}
diff -urN ./src/nvidia_linux.c ../../nvidia-patched/src/nvidia_linux.c
--- ./src/nvidia_linux.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_linux.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
#define LINUX_IOCTL_NVIDIA_MIN 0x4600
#define LINUX_IOCTL_NVIDIA_MAX 0x46ff
@@ -33,7 +37,11 @@
* copy the user data in/out correctly.
*/
+#ifndef __DragonFly__
return (ioctl(td, (struct ioctl_args *) args));
+#else
+ return (ioctl((struct ioctl_args *) args));
+#endif
}
struct linux_ioctl_handler nvidia_handler = {
diff -urN ./src/nvidia_os.c ../../nvidia-patched/src/nvidia_os.c
--- ./src/nvidia_os.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_os.c 2004-07-21 10:24:00.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
/*
@@ -94,7 +98,11 @@
U032 size
)
{
+#ifndef __DragonFly__
*address = malloc(size, M_NVIDIA, M_NOWAIT|M_ZERO);
+#else
+ *address = malloc(size, M_NVIDIA, M_WAITOK|M_ZERO);
+#endif
return *address ? RM_OK : RM_ERROR;
}
@@ -164,7 +172,7 @@
BOOL os_is_administrator(PHWINFO pDev)
{
-#if __FreeBSD_version < 500000
+#if __FreeBSD_version < 500000 && !defined(__DragonFly__)
return suser(curproc);
#else
return suser(curthread);
@@ -301,7 +309,11 @@
*pte |= PG_N;
va += PAGE_SIZE;
} while (va < (vm_offset_t) vm + size);
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
invltlb();
+#else /* DragonFly BSD */
+ cpu_invltlb();
+#endif
}
return vm;
@@ -561,8 +573,13 @@
* XXX We need opt_global.h for the SMP and APIC_IO #define(s), which
* is in ../../compile/SYSTEM_NAME (see config(8)). How do we get it?
*/
+#if !defined(__DragonFly__)
return mp_ncpus;
#else
+ return ncpus;
+#endif
+
+#else
return 1; /* single processor system */
#endif
}
diff -urN ./src/nvidia_os_pci.c ../../nvidia-patched/src/nvidia_os_pci.c
--- ./src/nvidia_os_pci.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_os_pci.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
VOID* os_pci_init_handle(
diff -urN ./src/nvidia_os_registry.c ../../nvidia-patched/src/nvidia_os_registry.c
--- ./src/nvidia_os_registry.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_os_registry.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
/*
diff -urN ./src/nvidia_pci.c ../../nvidia-patched/src/nvidia_pci.c
--- ./src/nvidia_pci.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_pci.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
#define NVIDIA_VENDORID 0x10de
#define NVIDIA_PCI_REG 0x10
@@ -95,8 +99,10 @@
#if __FreeBSD_version >= 500000
mtx_init(&sc->mtx_api, "dev.mtx_api", NULL, MTX_DEF);
mtx_init(&sc->mtx_rm, "dev.mtx_rm", NULL, MTX_SPIN);
-#else
+#elif !defined(__DragonFly__)
lockinit(&sc->api_lock, PZERO, "dev.api_lock", 0, 0);
+#else
+ lockinit(&sc->api_lock, 0, "dev.api_lock", 0, 0);
#endif
return 0;
@@ -114,8 +120,10 @@
#if __FreeBSD_version >= 500000
mtx_destroy(&sc->mtx_rm);
mtx_destroy(&sc->mtx_api);
-#else
+#elif !defined(__DragonFly__)
lockmgr(&sc->api_lock, LK_DRAIN, 0, curproc);
+#else
+ lockmgr(&sc->api_lock, LK_DRAIN, NULL, curthread);
#endif
status = nvidia_detach(dev);
diff -urN ./src/nvidia_subr.c ../../nvidia-patched/src/nvidia_subr.c
--- ./src/nvidia_subr.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_subr.c 2004-07-21 10:27:21.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
devclass_t nvidia_devclass;
@@ -51,15 +55,21 @@
return status;
nv_sysctl_init(nv);
+
+ callout_init(&sc->timer_ch);
+
return 0;
}
int nvidia_detach(device_t dev)
{
int status;
- struct nvidia_softc *sc;
+ struct nvidia_softc *sc; /* gcc is a whiny bitch */
sc = device_get_softc(dev);
+
+ crit_enter();
+ callout_stop(&sc->timer_ch); /* just in case */
nv_sysctl_exit(sc->nv_state);
if ((status = nvidia_dev_detach(sc)) != 0)
@@ -67,6 +77,7 @@
if ((status = nvidia_ctl_detach()) != 0)
return status;
+ crit_exit();
return 0;
}
@@ -297,7 +308,11 @@
u_long cmd,
caddr_t data,
int fflag,
+#if !defined(__DragonFly__)
d_thread_t *td
+#else
+ struct thread *td
+#endif
)
{
struct nvidia_softc *sc;
@@ -338,7 +353,11 @@
int nvidia_close_ctl(
dev_t dev,
+#if !defined(__DragonFly__)
d_thread_t *td
+#else
+ struct thread *td
+#endif
)
{
nv_state_t *nv = &nvidia_ctl_state;
@@ -762,7 +781,12 @@
* of our system calls at a time.
*/
struct nvidia_softc *sc = nv->os_state;
+#ifndef __DragonFly__
lockmgr(&sc->api_lock, LK_EXCLUSIVE, 0, curproc);
+#else
+ lockmgr(&sc->api_lock, LK_EXCLUSIVE, NULL, curthread);
+#endif
+
#endif
}
@@ -781,7 +805,12 @@
* its system call.
*/
struct nvidia_softc *sc = nv->os_state;
+#ifndef __DragonFly__
lockmgr(&sc->api_lock, LK_RELEASE, 0, curproc);
+#else
+ lockmgr(&sc->api_lock, LK_RELEASE, NULL, curthread);
+#endif
+
#endif
}
@@ -1677,7 +1706,8 @@
* timeout.
*/
sc = nv->os_state;
- sc->timer_ch = timeout(nvidia_rc_timer, (void *) nv, hz);
+
+ callout_reset(&sc->timer_ch, hz, nvidia_rc_timer, nv);
}
int nv_start_rc_timer(
@@ -1689,7 +1719,8 @@
if (nv->rc_timer_enabled != 0)
return -EIO;
- sc->timer_ch = timeout(nvidia_rc_timer, (void *) nv, hz);
+ callout_reset(&sc->timer_ch, hz, nvidia_rc_timer, nv);
+
nv->rc_timer_enabled = 1;
return 0;
@@ -1704,7 +1735,8 @@
if (nv->rc_timer_enabled == 0)
return -EIO;
- untimeout(nvidia_rc_timer, (void *) nv, sc->timer_ch);
+ callout_stop(&sc->timer_ch);
+
nv->rc_timer_enabled = 0;
return 0;
diff -urN ./src/nvidia_sysctl.c ../../nvidia-patched/src/nvidia_sysctl.c
--- ./src/nvidia_sysctl.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_sysctl.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
struct sysctl_ctx_list sysctl_ctx;
@@ -231,7 +235,11 @@
* It also doesn't make sense to to iterate over multiple
* functions if this isn't a multi-function device.
*/
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
hdrtype = pci_read_config(dev, PCIR_HEADERTYPE, 1);
+#else
+ hdrtype = pci_read_config(dev, PCIR_HDRTYPE, 1);
+#endif
if ((hdrtype & PCIM_MFDEV) == 0)
break;
--Boundary-00=_hxi/AYelIthQPpp
Content-Type: Text/Plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hey people,
Attached is a cleaned up patch for the x11/nvidia-driver override port. It=
=20
brings in some fixes I discussed with Joerg, and it also might fix this=20
driver for SMP systems. Please test this patch if you have SMP, or have=20
nothing better to do :)
Note: this is NOT related to the prerelease driver I got from NVIDIA.
to test:
Drop patch in /usr/dfports/x11/nvidia-driver/files, overwriting the one tha=
t's=20
there. make install, be merry.
Cheers,
Emiel
=2D --=20
If only one could get that wonderful feeling of accomplishment without
having to accomplish anything.
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)
iD8DBQFA/ixY4hAlCajuF/wRAtkHAKCpJBdS2U6jP+R+VnWmMmOZKb9PxwCfd47o
koEppihlyHcFhzpByuVtMrQ=3D
=3De3ON
=2D----END PGP SIGNATURE-----
--Boundary-00=_hxi/AYelIthQPpp
Content-Type: text/x-diff;
charset="us-ascii";
name="patch-dfly"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="patch-dfly"
diff -urN ./module/Makefile ../../nvidia-patched/module/Makefile
--- ./module/Makefile 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/module/Makefile 2004-07-21 10:14:32.000000000 +0200
@@ -6,7 +6,7 @@
KMOD= nvidia
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
SRCS+= device_if.h bus_if.h pci_if.h vnode_if.h
-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
+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 -Werror
NVOBJ= ${NVIDIA_ROOT}/obj/nv-kernel.o
OBJS+= NVIDIA.o
NOOBJ= true
diff -urN ./src/nv-dragonfly.h ../../nvidia-patched/src/nv-dragonfly.h
--- ./src/nv-dragonfly.h 1970-01-01 01:00:00.000000000 +0100
+++ ../../nvidia-patched/src/nv-dragonfly.h 2004-07-21 10:24:22.000000000 +0200
@@ -0,0 +1,297 @@
+/* _NVRM_COPYRIGHT_BEGIN_
+ *
+ * Copyright 2001 by NVIDIA Corporation. All rights reserved. All
+ * information contained herein is proprietary and confidential to NVIDIA
+ * Corporation. Any use, reproduction, or disclosure without the written
+ * permission of NVIDIA Corporation is prohibited.
+ *
+ * _NVRM_COPYRIGHT_END_
+ */
+
+#ifndef __NV_DRAGONFLY_H
+#define __NV_DRAGONFLY_H
+
+#ifdef TRUE
+#undef TRUE
+#endif
+
+#ifdef FALSE
+#undef FALSE
+#endif
+
+#include <sys/param.h>
+#include <stdarg.h>
+
+#include <sys/systm.h>
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/pciio.h>
+#include <sys/vnode.h>
+
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/ioccom.h>
+#include <sys/malloc.h>
+#include <sys/socket.h>
+#include <sys/sysent.h>
+#include <sys/sysctl.h>
+
+#include <machine/resource.h>
+#include <machine/clock.h>
+#include <machine/stdarg.h>
+#include <machine/bus.h>
+#include <machine/bus_memio.h>
+#include <machine/vm86.h>
+
+#include <sys/conf.h>
+#include <sys/rman.h>
+#include <sys/proc.h>
+#include <sys/lock.h>
+#include <sys/mman.h>
+#include <sys/file.h>
+#include <sys/poll.h>
+
+#include <sys/syscall.h>
+#include <sys/memrange.h>
+#include <sys/sysproto.h>
+#include <sys/signalvar.h>
+
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/vm_kern.h>
+#include <vm/vm_page.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_object.h>
+#include <vm/pmap.h>
+#include <vm/vm_map.h>
+
+#include <dev/agp//agpvar.h>
+#include <sys/agpio.h>
+
+#include "net/if.h"
+#include "emulation/linux/i386/linux.h"
+#include "emulation/linux/linux_ioctl.h"
+
+#include <machine/smp.h>
+#include <bus/pci/pcireg.h>
+#include <bus/pci/pcivar.h>
+
+#include <sys/thread2.h>
+
+#define vm_page_lock_queues()
+#define vm_page_unlock_queues()
+
+/*
+ * The resource manager client tracking needs an identifier that uniquely
+ * represents a client connection across threads. It needs to be specific
+ * to the thread that allocated the client. The Linux struct file pointer
+ * is such an identifier. The per-process file descriptor table is enough
+ * on FreeBSD, due to its thread-aware reference counting.
+ */
+
+#define __TD_FDT(td) ((td)->td_proc->p_fd)
+#define __TD_FDT_CNT(td) ((td)->td_proc->p_fd->fd_refcnt)
+
+
+/*
+ * The NVIDIA kernel module's malloc identifier, needed for both tracking
+ * and actual allocation/freeing purposes - declared here, but defined in
+ * nvidia_os.c.
+ */
+
+MALLOC_DECLARE(M_NVIDIA);
+
+/*
+ * This define controls if the module will be built to support the NVIDIA
+ * AGP GART driver or the FreeBSD AGPGART driver module. If you decide to
+ * use AGPGART, the agp.ko module must be preloaded from loader.conf.
+ */
+
+#undef USE_OS_AGP_GART
+
+/*
+ * This flag determines if system memory for use with the NVIDIA AGP GART
+ * driver is allocated as a contiguous block of kernel virtual memory, or
+ * as a VM object. The latter is better (tm), and thus the default.
+ */
+
+#define NV_AGP_USE_VM_OBJECT 1
+
+/*
+ * This option decides if the driver will be built with support for Linux
+ * compatibility. This makes nvidia.ko dependant on linux.ko; if you have
+ * no need for Linux 3D applications, you can safely unset this flag.
+ */
+
+#define NV_SUPPORT_LINUX_COMPAT 1
+
+/*
+ * The DMA memory allocation tracking structure. DMA memory alloctions on
+ * FreeBSD are tracked with their base address and size. Since PCI memory
+ * is allocated from kernel virtual memory and since AGP allocations have
+ * a contiguous range of addresses in the AGP aperture, base and size are
+ * sufficient to track allocations.
+ */
+
+typedef
+struct nv_alloc {
+ SLIST_ENTRY(nv_alloc) list;
+ u_int32_t size;
+ vm_offset_t address;
+ u_int32_t offset;
+ struct vm_object *object;
+} nv_alloc_t;
+
+typedef
+struct nv_alloc_private {
+ u_int32_t count;
+ u_int32_t alloc_type_contiguous;
+ u_int32_t alloc_type_cached;
+ u_int32_t alloc_type_kernel;
+ u_int32_t class;
+} nv_alloc_private_t;
+
+typedef
+struct nvidia_softc {
+ device_t dev;
+ device_t agp_dev;
+
+ struct resource *reg;
+ int reg_rid;
+ int reg_type;
+
+ struct resource *mem;
+ int mem_rid;
+ int mem_type;
+
+ struct resource *irq;
+ void *irq_ih;
+ int irq_rid;
+
+ dev_t cdev;
+ nv_state_t *nv_state;
+
+ struct sysctl_ctx_list sysctl_ctx;
+ struct selinfo rsel;
+
+ struct callout timer_ch;
+
+ /* list of allocations */
+ SLIST_HEAD(alloc_list, nv_alloc) alloc_list;
+
+#if __FreeBSD_version >= 500000
+ struct mtx mtx_rm;
+ struct mtx mtx_api;
+#else
+ int spl;
+ struct lock api_lock;
+#endif
+} nvidia_softc_t;
+
+
+#define CDEV_MAJOR 180
+#define CDEV_CTL_MINOR 255
+
+extern devclass_t nvidia_devclass;
+extern nv_state_t nvidia_ctl_state;
+
+extern const char *pNVRM_ID;
+
+#define PCIR_CAP_LIST_ID 0x00
+#define PCIR_CAP_LIST_NEXT 0x01
+#define PCIR_CAP_ID_AGP 0x02
+
+/*
+ * Entries in the NVIDIA glue-layer registry are now described by the new
+ * shared nv_parm_t structure; please review nvidia_os_registry.c in case
+ * you need to make low-level configuration changes. The entries are also
+ * mapped into the SYSCTL hierarchy and thus easily accessible.
+ */
+
+extern nv_parm_t nv_parms[];
+
+
+/* nvidia_dev.c */
+int nvidia_dev_attach (struct nvidia_softc *);
+int nvidia_dev_detach (struct nvidia_softc *);
+
+/* nvidia_ctl.c */
+int nvidia_ctl_attach (void);
+int nvidia_ctl_detach (void);
+
+/* nvidia_subr.c */
+int nvidia_attach (device_t);
+int nvidia_detach (device_t);
+int nvidia_suspend (device_t);
+int nvidia_resume (device_t);
+int nvidia_alloc (device_t);
+int nvidia_free (device_t);
+void nvidia_intr (void *);
+int nvidia_modevent (module_t, int, void *);
+
+void nvidia_rc_timer (void *);
+
+void nv_lock_api (nv_state_t *);
+void nv_unlock_api (nv_state_t *);
+
+S032 nv_alloc_contig_pages (nv_state_t *, VOID **, U032);
+S032 nv_free_contig_pages (nv_state_t *, VOID *);
+S032 nv_alloc_system_pages (nv_state_t *, VOID **, U032);
+S032 nv_free_system_pages (nv_state_t *, VOID *);
+
+S032 nv_alloc_vm_object (nv_state_t *, VOID **, U032);
+S032 nv_free_vm_object (nv_state_t *, VOID *);
+
+void* nv_find_alloc (nv_state_t *, vm_offset_t);
+void* nv_find_alloc_obj (nv_state_t *, vm_offset_t);
+
+S032 nv_os_agp_init (nv_state_t *, VOID **, VOID **, U032 *);
+S032 nv_os_agp_teardown (nv_state_t *);
+S032 nv_alloc_agp_pages (nv_state_t *, VOID **, U032, U032, VOID **);
+S032 nv_free_agp_pages (nv_state_t *, VOID **, U032, VOID *);
+
+/* nvidia_sysctl.c */
+void nvidia_sysctl_init (void);
+void nvidia_sysctl_exit (void);
+
+U008 nvidia_find_cap (device_t);
+void* nvidia_find_bridge (void);
+
+int nvidia_sysctl_vbios (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_type (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_rates (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_fw (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_sba (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_regs (SYSCTL_HANDLER_ARGS);
+
+int nvidia_sysctl_driver (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_rate_s (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_fw_s (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_sba_s (SYSCTL_HANDLER_ARGS);
+int nvidia_sysctl_status (SYSCTL_HANDLER_ARGS);
+
+void nv_sysctl_init (nv_state_t *);
+void nv_sysctl_exit (nv_state_t *);
+
+/* nvidia_linux.c */
+int linux_ioctl_nvidia (d_thread_t *, struct linux_ioctl_args *);
+void nvidia_linux_init (void);
+void nvidia_linux_exit (void);
+
+/* ioctl helpers */
+int nvidia_set_primary (struct nv_ioctl_primary_card *);
+int nvidia_get_card_info (struct nv_ioctl_card_info *);
+int nvidia_get_api_version (struct nv_ioctl_rm_api_version *);
+int nvidia_handle_ioctl (dev_t, u_long, caddr_t, int, d_thread_t *);
+
+
+/* device helpers */
+int nvidia_open_ctl (void);
+int nvidia_open_dev (struct nvidia_softc *);
+int nvidia_close_ctl (dev_t, d_thread_t *);
+int nvidia_close_dev (struct nvidia_softc *, dev_t, d_thread_t *);
+int nvidia_mmap_dev (struct nvidia_softc *, vm_offset_t, vm_offset_t *);
+
+#endif /* __NV_DRAGONFLY_H */
+
diff -urN ./src/nvidia_ctl.c ../../nvidia-patched/src/nvidia_ctl.c
--- ./src/nvidia_ctl.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_ctl.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
static d_open_t nvidia_ctl_open;
static d_close_t nvidia_ctl_close;
@@ -19,7 +23,7 @@
static d_poll_t nvidia_ctl_poll;
static struct cdevsw nvidia_ctl_cdevsw = {
-#if __FreeBSD_version < 500105
+#if __FreeBSD_version < 500105 && !defined(__DragonFly__)
/* open */ nvidia_ctl_open,
/* close */ nvidia_ctl_close,
/* read */ noread,
@@ -37,7 +41,7 @@
/* bmaj */ -1,
#endif
/* kqfilter */ NULL,
-#else
+#elif !defined(__DragonFly__)
.d_open = nvidia_ctl_open,
.d_close = nvidia_ctl_close,
.d_ioctl = nvidia_ctl_ioctl,
@@ -46,6 +50,25 @@
.d_maj = CDEV_MAJOR,
.d_flags = D_TRACKCLOSE
#endif
+
+/* Dragonfly */
+#if defined(__DragonFly__)
+ /* name */ "nvidiactl",
+ /* maj */ CDEV_MAJOR,
+ /* flags */ D_TRACKCLOSE,
+ /* port */ NULL,
+ /* autoq */ 0,
+
+ /* open */ nvidia_ctl_open,
+ /* close */ nvidia_ctl_close,
+ /* read */ noread,
+ /* write */ nowrite,
+ /* ioctl */ nvidia_ctl_ioctl,
+ /* poll */ nvidia_ctl_poll,
+ /* mmap */ nommap,
+ /* strategy */ nostrategy,
+ /* dump */ nodump,
+#endif
};
static dev_t nvidia_ctl_cdev;
@@ -200,16 +223,20 @@
struct nvidia_softc *sc;
if (nvidia_count == 0) {
+
+
/*
* This routine is called from nvidia_attach, multiple times when
* more than one device is installed - this makes it necessary to
* prevent multiple calls to make_dev.
*/
+ cdevsw_add(&nvidia_ctl_cdevsw, -1, 255); /* XXX */
nvidia_ctl_cdev = make_dev(&nvidia_ctl_cdevsw,
CDEV_CTL_MINOR,
UID_ROOT, GID_WHEEL, 0666,
"%s", nvidia_ctl_cdevsw.d_name);
+
sc = &nvidia_ctl_sc;
bzero(sc, sizeof(nvidia_softc_t));
nvidia_ctl_state.os_state = sc;
@@ -218,7 +245,7 @@
mtx_init(&sc->mtx_api, "ctl.mtx_api", NULL, MTX_DEF);
mtx_init(&sc->mtx_rm, "ctl.mtx_rm", NULL, MTX_SPIN);
#else
- lockinit(&sc->api_lock, PZERO, "ctl.api_lock", 0, 0);
+ lockinit(&sc->api_lock, 0, "ctl.api_lock", 0, 0);
#endif
}
@@ -242,10 +269,17 @@
#if __FreeBSD_version >= 500000
mtx_destroy(&sc->mtx_rm);
mtx_destroy(&sc->mtx_api);
-#else
+#elif defined(__FreeBSD__) && !defined(__DragonFly__)
lockmgr(&sc->api_lock, LK_DRAIN, 0, curproc);
-#endif
destroy_dev(nvidia_ctl_cdev);
+#else
+ lockmgr(&sc->api_lock, LK_DRAIN, NULL, curthread);
+#endif
+
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
+ cdevsw_remove(&nvidia_ctl_cdevsw, -1, 255); /* XXX */
+#endif
+
}
return 0;
diff -urN ./src/nvidia_dev.c ../../nvidia-patched/src/nvidia_dev.c
--- ./src/nvidia_dev.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_dev.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
static d_open_t nvidia_dev_open;
static d_close_t nvidia_dev_close;
@@ -20,7 +24,7 @@
static d_mmap_t nvidia_dev_mmap;
static struct cdevsw nvidia_dev_cdevsw = {
-#if __FreeBSD_version < 500105
+#if __FreeBSD_version < 500105 && !defined(__DragonFly__)
/* open */ nvidia_dev_open,
/* close */ nvidia_dev_close,
/* read */ noread,
@@ -38,7 +42,7 @@
/* bmaj */ -1,
#endif
/* kqfilter */ NULL,
-#else
+#elif !defined(__DragonFly__)
.d_open = nvidia_dev_open,
.d_close = nvidia_dev_close,
.d_ioctl = nvidia_dev_ioctl,
@@ -48,6 +52,26 @@
.d_maj = CDEV_MAJOR,
.d_flags = D_MEM|D_TRACKCLOSE
#endif
+
+#ifdef __DragonFly__
+ /* name */ "nvidia",
+ /* maj */ CDEV_MAJOR,
+ /* flags */ D_MEM|D_TRACKCLOSE,
+ /* port */ NULL,
+ /* autoq */ 0,
+
+ /* open */ nvidia_dev_open,
+ /* close */ nvidia_dev_close,
+ /* read */ noread,
+ /* write */ nowrite,
+ /* ioctl */ nvidia_dev_ioctl,
+ /* poll */ nvidia_dev_poll,
+ /* mmap */ nvidia_dev_mmap,
+ /* strategy */ nostrategy,
+ /* dump */ nodump,
+ /* psize */ nopsize,
+#endif
+
};
int nvidia_dev_open(
@@ -187,6 +211,7 @@
int nvidia_dev_attach (struct nvidia_softc *sc)
{
+ cdevsw_add(&nvidia_dev_cdevsw, -1, device_get_unit(sc->dev));
sc->cdev = make_dev(&nvidia_dev_cdevsw,
device_get_unit(sc->dev),
UID_ROOT, GID_WHEEL, 0666,
@@ -199,7 +224,11 @@
int nvidia_dev_detach (struct nvidia_softc *sc)
{
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
destroy_dev(sc->cdev);
+#else
+ cdevsw_remove(&nvidia_dev_cdevsw, -1, device_get_unit(sc->dev));
+#endif
return 0;
}
diff -urN ./src/nvidia_linux.c ../../nvidia-patched/src/nvidia_linux.c
--- ./src/nvidia_linux.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_linux.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
#define LINUX_IOCTL_NVIDIA_MIN 0x4600
#define LINUX_IOCTL_NVIDIA_MAX 0x46ff
@@ -33,7 +37,11 @@
* copy the user data in/out correctly.
*/
+#ifndef __DragonFly__
return (ioctl(td, (struct ioctl_args *) args));
+#else
+ return (ioctl((struct ioctl_args *) args));
+#endif
}
struct linux_ioctl_handler nvidia_handler = {
diff -urN ./src/nvidia_os.c ../../nvidia-patched/src/nvidia_os.c
--- ./src/nvidia_os.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_os.c 2004-07-21 10:24:00.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
/*
@@ -94,7 +98,11 @@
U032 size
)
{
+#ifndef __DragonFly__
*address = malloc(size, M_NVIDIA, M_NOWAIT|M_ZERO);
+#else
+ *address = malloc(size, M_NVIDIA, M_WAITOK|M_ZERO);
+#endif
return *address ? RM_OK : RM_ERROR;
}
@@ -164,7 +172,7 @@
BOOL os_is_administrator(PHWINFO pDev)
{
-#if __FreeBSD_version < 500000
+#if __FreeBSD_version < 500000 && !defined(__DragonFly__)
return suser(curproc);
#else
return suser(curthread);
@@ -301,7 +309,11 @@
*pte |= PG_N;
va += PAGE_SIZE;
} while (va < (vm_offset_t) vm + size);
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
invltlb();
+#else /* DragonFly BSD */
+ cpu_invltlb();
+#endif
}
return vm;
@@ -561,8 +573,13 @@
* XXX We need opt_global.h for the SMP and APIC_IO #define(s), which
* is in ../../compile/SYSTEM_NAME (see config(8)). How do we get it?
*/
+#if !defined(__DragonFly__)
return mp_ncpus;
#else
+ return ncpus;
+#endif
+
+#else
return 1; /* single processor system */
#endif
}
diff -urN ./src/nvidia_os_pci.c ../../nvidia-patched/src/nvidia_os_pci.c
--- ./src/nvidia_os_pci.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_os_pci.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
VOID* os_pci_init_handle(
diff -urN ./src/nvidia_os_registry.c ../../nvidia-patched/src/nvidia_os_registry.c
--- ./src/nvidia_os_registry.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_os_registry.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
/*
diff -urN ./src/nvidia_pci.c ../../nvidia-patched/src/nvidia_pci.c
--- ./src/nvidia_pci.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_pci.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
#define NVIDIA_VENDORID 0x10de
#define NVIDIA_PCI_REG 0x10
@@ -95,8 +99,10 @@
#if __FreeBSD_version >= 500000
mtx_init(&sc->mtx_api, "dev.mtx_api", NULL, MTX_DEF);
mtx_init(&sc->mtx_rm, "dev.mtx_rm", NULL, MTX_SPIN);
-#else
+#elif !defined(__DragonFly__)
lockinit(&sc->api_lock, PZERO, "dev.api_lock", 0, 0);
+#else
+ lockinit(&sc->api_lock, 0, "dev.api_lock", 0, 0);
#endif
return 0;
@@ -114,8 +120,10 @@
#if __FreeBSD_version >= 500000
mtx_destroy(&sc->mtx_rm);
mtx_destroy(&sc->mtx_api);
-#else
+#elif !defined(__DragonFly__)
lockmgr(&sc->api_lock, LK_DRAIN, 0, curproc);
+#else
+ lockmgr(&sc->api_lock, LK_DRAIN, NULL, curthread);
#endif
status = nvidia_detach(dev);
diff -urN ./src/nvidia_subr.c ../../nvidia-patched/src/nvidia_subr.c
--- ./src/nvidia_subr.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_subr.c 2004-07-21 10:27:21.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
devclass_t nvidia_devclass;
@@ -51,15 +55,21 @@
return status;
nv_sysctl_init(nv);
+
+ callout_init(&sc->timer_ch);
+
return 0;
}
int nvidia_detach(device_t dev)
{
int status;
- struct nvidia_softc *sc;
+ struct nvidia_softc *sc; /* gcc is a whiny bitch */
sc = device_get_softc(dev);
+
+ crit_enter();
+ callout_stop(&sc->timer_ch); /* just in case */
nv_sysctl_exit(sc->nv_state);
if ((status = nvidia_dev_detach(sc)) != 0)
@@ -67,6 +77,7 @@
if ((status = nvidia_ctl_detach()) != 0)
return status;
+ crit_exit();
return 0;
}
@@ -297,7 +308,11 @@
u_long cmd,
caddr_t data,
int fflag,
+#if !defined(__DragonFly__)
d_thread_t *td
+#else
+ struct thread *td
+#endif
)
{
struct nvidia_softc *sc;
@@ -338,7 +353,11 @@
int nvidia_close_ctl(
dev_t dev,
+#if !defined(__DragonFly__)
d_thread_t *td
+#else
+ struct thread *td
+#endif
)
{
nv_state_t *nv = &nvidia_ctl_state;
@@ -762,7 +781,12 @@
* of our system calls at a time.
*/
struct nvidia_softc *sc = nv->os_state;
+#ifndef __DragonFly__
lockmgr(&sc->api_lock, LK_EXCLUSIVE, 0, curproc);
+#else
+ lockmgr(&sc->api_lock, LK_EXCLUSIVE, NULL, curthread);
+#endif
+
#endif
}
@@ -781,7 +805,12 @@
* its system call.
*/
struct nvidia_softc *sc = nv->os_state;
+#ifndef __DragonFly__
lockmgr(&sc->api_lock, LK_RELEASE, 0, curproc);
+#else
+ lockmgr(&sc->api_lock, LK_RELEASE, NULL, curthread);
+#endif
+
#endif
}
@@ -1677,7 +1706,8 @@
* timeout.
*/
sc = nv->os_state;
- sc->timer_ch = timeout(nvidia_rc_timer, (void *) nv, hz);
+
+ callout_reset(&sc->timer_ch, hz, nvidia_rc_timer, nv);
}
int nv_start_rc_timer(
@@ -1689,7 +1719,8 @@
if (nv->rc_timer_enabled != 0)
return -EIO;
- sc->timer_ch = timeout(nvidia_rc_timer, (void *) nv, hz);
+ callout_reset(&sc->timer_ch, hz, nvidia_rc_timer, nv);
+
nv->rc_timer_enabled = 1;
return 0;
@@ -1704,7 +1735,8 @@
if (nv->rc_timer_enabled == 0)
return -EIO;
- untimeout(nvidia_rc_timer, (void *) nv, sc->timer_ch);
+ callout_stop(&sc->timer_ch);
+
nv->rc_timer_enabled = 0;
return 0;
diff -urN ./src/nvidia_sysctl.c ../../nvidia-patched/src/nvidia_sysctl.c
--- ./src/nvidia_sysctl.c 2003-05-28 18:51:52.000000000 +0200
+++ ../../nvidia-patched/src/nvidia_sysctl.c 2004-07-21 10:14:32.000000000 +0200
@@ -11,7 +11,11 @@
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
#include "nv-freebsd.h"
+#else
+#include "nv-dragonfly.h"
+#endif
struct sysctl_ctx_list sysctl_ctx;
@@ -231,7 +235,11 @@
* It also doesn't make sense to to iterate over multiple
* functions if this isn't a multi-function device.
*/
+#if defined(__FreeBSD__) && !defined(__DragonFly__)
hdrtype = pci_read_config(dev, PCIR_HEADERTYPE, 1);
+#else
+ hdrtype = pci_read_config(dev, PCIR_HDRTYPE, 1);
+#endif
if ((hdrtype & PCIM_MFDEV) == 0)
break;
--Boundary-00=_hxi/AYelIthQPpp--
----
-------
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]