diff -u nvidia.orig/src/nv-freebsd.h NVIDIA_FreeBSD-1.0-3203/src/nv-freebsd.h
--- nvidia.orig/src/nv-freebsd.h	Wed Oct 30 15:30:58 2002
+++ NVIDIA_FreeBSD-1.0-3203/src/nv-freebsd.h	Thu Mar  6 01:27:10 2003
@@ -27,12 +27,6 @@
  * active development and also unsupported.
  */
 
-#if __FreeBSD_version >= 500000
-#error This driver does not support FreeBSD 5.0/-CURRENT!
-#elif __FreeBSD_version < 470000
-#error This driver requires FreeBSD 4.7 or later!
-#endif
-
 #include <sys/systm.h>
 #include <sys/types.h>
 #include <sys/queue.h>
@@ -86,6 +80,7 @@
 
 #if __FreeBSD_version >= 500000
 #include <sys/mutex.h>
+#include <sys/filedesc.h>
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 
@@ -115,6 +110,9 @@
 #define __TD_FDT(td)     ((td)->p_fd)
 #define __TD_FDT_CNT(td) ((td)->p_fd->fd_refcnt)
 
+#define vm_page_lock_queues()
+#define vm_page_unlock_queues()
+
 #endif
 
 /*
@@ -306,7 +304,8 @@
 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);
+int    nvidia_mmap_dev       (struct nvidia_softc *, vm_offset_t,
+    				vm_offset_t *);
 
 #endif /* __NV_FREEBSD_H__ */
 
diff -u nvidia.orig/src/nvidia_ctl.c NVIDIA_FreeBSD-1.0-3203/src/nvidia_ctl.c
--- nvidia.orig/src/nvidia_ctl.c	Wed Oct 30 15:30:58 2002
+++ NVIDIA_FreeBSD-1.0-3203/src/nvidia_ctl.c	Thu Mar  6 01:07:57 2003
@@ -19,6 +19,7 @@
 static d_poll_t  nvidia_ctl_poll;
 
 static struct cdevsw nvidia_ctl_cdevsw = {
+#if __FreeBSD_version < 500000
     /* open    */  nvidia_ctl_open,
     /* close */    nvidia_ctl_close,
     /* read */     noread,
@@ -32,10 +33,17 @@
     /* dump */     nodump,
     /* psize */    nopsize,
     /* flags */    D_TRACKCLOSE,
-#if __FreeBSD_version < 500000
     /* bmaj */     -1,
-#endif
     /* kqfilter */ NULL,
+#else
+    .d_open =      nvidia_ctl_open,
+    .d_close =     nvidia_ctl_close,
+    .d_ioctl =     nvidia_ctl_ioctl,
+    .d_poll =      nvidia_ctl_poll,
+    .d_name =      "nvidiactl",
+    .d_maj =       CDEV_MAJOR,
+    .d_flags =     D_TRACKCLOSE
+#endif
 };
 
 static dev_t          nvidia_ctl_cdev;
diff -u nvidia.orig/src/nvidia_dev.c NVIDIA_FreeBSD-1.0-3203/src/nvidia_dev.c
--- nvidia.orig/src/nvidia_dev.c	Wed Oct 30 15:30:58 2002
+++ NVIDIA_FreeBSD-1.0-3203/src/nvidia_dev.c	Thu Mar  6 01:09:05 2003
@@ -20,6 +20,7 @@
 static d_mmap_t  nvidia_dev_mmap;
 
 static struct cdevsw nvidia_dev_cdevsw = {
+#if __FreeBSD_version < 500000
     /* open    */  nvidia_dev_open,
     /* close */    nvidia_dev_close,
     /* read */     noread,
@@ -33,10 +34,18 @@
     /* dump */     nodump,
     /* psize */    nopsize,
     /* flags */    D_MEM|D_TRACKCLOSE,
-#if __FreeBSD_version < 500000
     /* bmaj */     -1,
-#endif
     /* kqfilter */ NULL,
+#else
+    .d_open =      nvidia_dev_open,
+    .d_close =     nvidia_dev_close,
+    .d_ioctl =     nvidia_dev_ioctl,
+    .d_poll =      nvidia_dev_poll,
+    .d_mmap =      nvidia_dev_mmap,
+    .d_name =      "nvidia",
+    .d_maj =       CDEV_MAJOR,
+    .d_flags =     D_MEM|D_TRACKCLOSE
+#endif
 };
 
 int nvidia_dev_open(
@@ -135,11 +144,15 @@
 int nvidia_dev_mmap(
     dev_t dev,
     vm_offset_t offset,
+#if __FreeBSD_version >= 500000
+    vm_offset_t *paddr,
+#endif
     int nprot
 )
 {
     nv_state_t *nv;
     struct nvidia_softc *sc;
+    vm_offset_t phys;
 
     int status;
     int unit = minor(dev);
@@ -148,10 +161,17 @@
     nv = sc->nv_state;
 
     nv_lock_api(nv);
-    status = nvidia_mmap_dev(sc, offset);
+    status = nvidia_mmap_dev(sc, offset, &phys);
     nv_unlock_api(nv);
 
+#if __FreeBSD_version >= 500000
+    *paddr = phys;
     return status;
+#else
+    if (status == -1)
+	    return -1;
+    return atop(phys);
+#endif
 }
 
 int nvidia_dev_attach (struct nvidia_softc *sc)
diff -u nvidia.orig/src/nvidia_subr.c NVIDIA_FreeBSD-1.0-3203/src/nvidia_subr.c
--- nvidia.orig/src/nvidia_subr.c	Wed Oct 30 15:30:58 2002
+++ NVIDIA_FreeBSD-1.0-3203/src/nvidia_subr.c	Fri Mar 14 20:47:44 2003
@@ -130,7 +130,7 @@
     sc = device_get_softc(dev);
     sc->dev = dev;
 
-    sc->nv_state = malloc(sizeof(nv_state_t), M_DEVBUF, M_ZERO);
+    sc->nv_state = malloc(sizeof(nv_state_t), M_DEVBUF, M_WAITOK | M_ZERO);
     if (sc->nv_state == NULL) {
         error = ENOMEM;
         goto fail;
@@ -901,12 +901,12 @@
     void *vm;
     u_int32_t i, size = count * PAGE_SIZE;
 
-    at = malloc(sizeof(nv_alloc_t), M_NVIDIA, M_ZERO);
+    at = malloc(sizeof(nv_alloc_t), M_NVIDIA, M_WAITOK | M_ZERO);
     if (!at) {
         return -ENOMEM;
     }
 
-    vm = malloc(size, M_NVIDIA, M_ZERO);
+    vm = malloc(size, M_NVIDIA, M_WAITOK | M_ZERO);
     if (!vm) {
         /*
          * This error condition is not unlikely to occur. We allocate our
@@ -925,7 +925,9 @@
          * prevent random crashes.
          */
         pa = vtophys((vm_offset_t) vm + (i * PAGE_SIZE));
+        vm_page_lock_queues();
         vm_page_wire(PHYS_TO_VM_PAGE(pa));
+        vm_page_unlock_queues();
     }
 
     at->object = 0;
@@ -963,6 +965,7 @@
     count = at->size / PAGE_SIZE;
     SLIST_REMOVE(&sc->alloc_list, at, nv_alloc, list);
 
+    vm_page_lock_queues();
     for (i = 0; i < count; i++) {
         /*
          * Release "one wiring" of this page; this may reenable paging as
@@ -971,6 +974,7 @@
         pa = vtophys(at->address + (i * PAGE_SIZE));
         vm_page_unwire(PHYS_TO_VM_PAGE(pa), 0);
     }
+    vm_page_unlock_queues();
 
     free(at, M_NVIDIA);
     free(address, M_NVIDIA);
@@ -993,7 +997,7 @@
     vm_page_t m;
     vm_object_t object;
 
-    at = malloc(sizeof(nv_alloc_t), M_NVIDIA, M_ZERO);
+    at = malloc(sizeof(nv_alloc_t), M_NVIDIA, M_WAITOK | M_ZERO);
     if (!at) {
         return -ENOMEM;
     }
@@ -1007,13 +1011,19 @@
          * will be allocated.
          */
 
+#if __FreeBSD_version < 500000
         m = vm_page_grab(object, i, VM_ALLOC_NORMAL);
+#else
+        m = vm_page_grab(object, i, VM_ALLOC_NORMAL | VM_ALLOC_WIRED);
+#endif
         if (!m) {
+            vm_page_lock_queues();
             for (i -= 1; i >= 0; i--) {
                 m = vm_page_lookup(object, i);
                 vm_page_wakeup(m);
                 vm_page_unwire(m, 0);
             }
+            vm_page_unlock_queues();
             return -ENOMEM;
         }
 
@@ -1022,7 +1032,9 @@
          * paging it out while we're still using it. This is necessary to
          * prevent random crashes.
          */
+#if __FreeBSD_version < 500000
         vm_page_wire(m);
+#endif
         vm_page_wakeup(m);
     }
 
@@ -1061,6 +1073,7 @@
     count = at->size / PAGE_SIZE;
     SLIST_REMOVE(&sc->alloc_list, at, nv_alloc, list);
 
+    vm_page_lock_queues();
     for (i = 0; i < count; i++) {
         /*
          * Release "one wiring" of this page; this may reenable paging as
@@ -1069,6 +1082,7 @@
         m = vm_page_lookup(at->object, i);
         vm_page_unwire(m, 0);
     }
+    vm_page_unlock_queues();
 
     free(at, M_NVIDIA);
     vm_object_deallocate(at->object);
@@ -1401,7 +1415,8 @@
 
 int nvidia_mmap_dev(
     struct nvidia_softc *sc,
-    vm_offset_t offset
+    vm_offset_t offset,
+    vm_offset_t *paddr
 )
 {
     nv_alloc_t *at;
@@ -1412,14 +1427,20 @@
      * are physical addresses and mapped into user-space directly. We can
      * only do some basic sanity checking here.
      */
-    if (IS_FB_OFFSET(nv, offset, PAGE_SIZE))
-        return atop(offset);
+    if (IS_FB_OFFSET(nv, offset, PAGE_SIZE)) {
+        *paddr = offset; 
+        return 0;
+    }
     
-    if (IS_REG_OFFSET(nv, offset, PAGE_SIZE))
-        return atop(offset);
+    if (IS_REG_OFFSET(nv, offset, PAGE_SIZE)) {
+        *paddr = offset; 
+        return 0;
+    }
     
-    if (IS_AGP_OFFSET(nv, offset, PAGE_SIZE))
-        return atop(offset);
+    if (IS_AGP_OFFSET(nv, offset, PAGE_SIZE)) {
+        *paddr = offset; 
+        return 0;
+    }
 
     /*
      * If the offset does not fall into any of the relevant apertures, we
@@ -1430,8 +1451,10 @@
      */
     SLIST_FOREACH(at, &sc->alloc_list, list) {
         if (offset >= at->address &&
-                offset < at->address + at->size)
-            return atop(vtophys(offset));
+                offset < at->address + at->size) {
+            *paddr = vtophys(offset);
+            return 0;
+        }
     }
 
     return -1;
