Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches/xen.patch
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches/xen.patch	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches/xen.patch	(revision 5887)
@@ -0,0 +1,162 @@
+diff -ruN usr/src/nv/nv.c usr/src/nv/nv.c
+--- usr/src/nv/nv.c	2008-05-30 10:06:36.000000000 -0400
++++ usr/src/nv/nv.c	2008-05-30 10:28:33.000000000 -0400
+@@ -2020,17 +2020,6 @@
+             goto failed;
+         }
+ 
+-#if defined(CONFIG_XEN) && defined(NVCPU_X86)
+-        if (HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL) > 0xfffff)
+-        {
+-            nv_printf(NV_DBG_ERRORS,
+-                "NVRM: Systems with system memory mapped above the 4GB boundary\n"
+-                "NVRM: are not supported when using x86 Xen kernels.\n");
+-            rc = -EIO;
+-            goto failed;
+-        }
+-#endif
+-
+         if (!rm_init_adapter(sp, nv))
+         {
+             free_irq(nv->interrupt_line, (void *) nvl);
+@@ -2043,20 +2032,6 @@
+         nvl->tasklet.data = (unsigned long) nv;
+         tasklet_enable(&nvl->tasklet);
+ 
+-#if defined(CONFIG_XEN)
+-        if ((nvl->dev->dma_mask <= 0xffffffff) &&
+-            (HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL) > 0xfffff))
+-        {
+-            NV_SHUTDOWN_ADAPTER(sp, nv, nvl);
+-            nv_printf(NV_DBG_ERRORS,
+-                "NVRM: GPUs incapable of addressing more than 4GB of memory\n"
+-                "NVRM: are not supported when using Xen kernels on systems with\n"
+-                "NVRM: system memory mapped above the 4GB boundary.\n");
+-            rc = -EIO;
+-            goto failed;
+-        }
+-#endif
+-
+         nv->flags |= NV_FLAG_OPEN;
+     }
+ 
+@@ -3928,7 +3903,6 @@
+     U032         config
+ )
+ {
+-#if !defined(CONFIG_XEN)
+     RM_STATUS status = RM_ERROR;
+     static int old_error = 0;
+     nv_stack_t *sp = NULL;
+@@ -4066,10 +4040,6 @@
+         old_error = 0; /* report new errors */
+ 
+     return status;
+-#else
+-    nv_printf(NV_DBG_ERRORS, "NVRM: AGP is not supported on Xen kernels.\n");
+-    return RM_ERR_NOT_SUPPORTED;
+-#endif
+ }
+ 
+ RM_STATUS NV_API_CALL nv_agp_teardown(
+diff -ruN usr/src/nv/nv-linux.h usr/src/nv/nv-linux.h
+--- usr/src/nv/nv-linux.h	2008-05-30 10:06:36.000000000 -0400
++++ usr/src/nv/nv-linux.h	2008-05-30 10:07:58.000000000 -0400
+@@ -108,11 +108,6 @@
+ #include <linux/completion.h>
+ #include <linux/highmem.h>
+ 
+-#ifdef CONFIG_XEN
+-#include <asm/maddr.h>
+-#include <xen/interface/memory.h>
+-#endif
+-
+ #ifdef CONFIG_PROC_FS
+ #include <linux/proc_fs.h>
+ #endif
+@@ -152,7 +147,7 @@
+ #include <linux/agpgart.h>
+ #endif
+ 
+-#if (defined(NVCPU_X86) || defined(NVCPU_X86_64)) && !defined(CONFIG_XEN)
++#if (defined(NVCPU_X86) || defined(NVCPU_X86_64))
+ #define NV_ENABLE_PAT_SUPPORT
+ #endif
+ 
+@@ -717,11 +712,7 @@
+ #define NV_TASK_STRUCT_RLIM(current)  ((current)->rlim)
+ #endif
+ 
+-#ifdef CONFIG_XEN
+-#define NV_GET_DMA_ADDRESS(phys_addr) phys_to_machine(phys_addr)
+-#else
+ #define NV_GET_DMA_ADDRESS(phys_addr) (phys_addr)
+-#endif
+ 
+ #define NV_GET_PAGE_STRUCT(phys_page) virt_to_page(__va(phys_page))
+ #define NV_VMA_PGOFF(vma)             ((vma)->vm_pgoff)
+@@ -874,13 +865,8 @@
+ #else
+ #error "NV_REMAP_PAGE_RANGE() undefined!"
+ #endif
+-#if !defined(CONFIG_XEN)
+ #define NV_IO_REMAP_PAGE_RANGE(from, offset, x...) \
+     NV_REMAP_PAGE_RANGE(from, offset, x)
+-#else
+-#define NV_IO_REMAP_PAGE_RANGE(from, offset, x...) \
+-    io_remap_pfn_range(vma, from, ((offset) >> PAGE_SHIFT), x)
+-#endif
+ 
+ #define NV_PGD_OFFSET(address, kernel, mm)              \
+    ({                                                   \
+diff -ruN usr/src/nv/nv-vm.c usr/src/nv/nv-vm.c
+--- usr/src/nv/nv-vm.c	2008-05-30 10:06:36.000000000 -0400
++++ usr/src/nv/nv-vm.c	2008-05-30 10:35:13.000000000 -0400
+@@ -312,7 +312,7 @@
+ #endif
+ 
+ #if (defined(KERNEL_2_4) || defined(NV_CPA_DF_LIST_BUG) || \
+-  (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20))) && !defined(CONFIG_XEN)
++  (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)))
+ #define NV_CPA_NEEDS_FLUSHING 1
+ #endif
+ 
+diff -ruN usr/src/nv/os-interface.c usr/src/nv/os-interface.c
+--- usr/src/nv/os-interface.c	2008-05-30 10:06:36.000000000 -0400
++++ usr/src/nv/os-interface.c	2008-05-30 10:33:26.000000000 -0400
+@@ -609,7 +609,6 @@
+     if (jiffies) 
+     {
+         // if we have at least 1 full jiffy to wait, give up the cpu
+-#if !defined(CONFIG_XEN)
+         // but first, make sure we haven't raised the irql level on
+         // this cpu (most likely holding a lock). I'm seeing cases
+         // where we give up the cpu with raised irql, and never get
+@@ -620,10 +619,8 @@
+         // the local CPU.
+         if (!NV_IRQL_IS_RAISED())
+         {
+-#endif
+             /* give up the cpu */
+             current->state = TASK_INTERRUPTIBLE;
+-#if !defined(CONFIG_XEN)
+         }
+         else
+         {
+@@ -633,7 +630,6 @@
+             os_dbg_breakpoint();
+             return RM_ERROR;
+         }
+-#endif
+         do
+         {
+             schedule_timeout(jiffies);
+@@ -1377,7 +1373,7 @@
+      * If you prefer to manually grant the necessary capability and 
+      * adjust the resource limit, disable the lines below.
+      */
+-#if !defined(CONFIG_XEN) && !defined(CONFIG_X86_4G)
++#if !defined(CONFIG_X86_4G)
+     struct rlimit *rlim = NV_TASK_STRUCT_RLIM(current);
+     rlim[RLIMIT_MEMLOCK].rlim_cur = RLIM_INFINITY;
+     cap_raise(current->cap_effective, CAP_IPC_LOCK);
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/conftest.h
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/conftest.h	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/conftest.h	(revision 5887)
@@ -0,0 +1,229 @@
+/* Implement conftest.sh function remap_page_range */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+  #define NV_REMAP_PAGE_RANGE_PRESENT
+  #define NV_REMAP_PAGE_RANGE_ARGUMENT_COUNT 4
+ #else
+  #define NV_REMAP_PAGE_RANGE_PRESENT
+  #define NV_REMAP_PAGE_RANGE_ARGUMENT_COUNT 5
+ #endif
+#else
+ #undef NV_REMAP_PAGE_RANGE_PRESENT
+#endif
+
+/* Implement conftest.sh function set_pages_uc */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+ #ifdef NV_CHANGE_PAGE_ATTR_PRESENT
+  #undef NV_CHANGE_PAGE_ATTR_PRESENT
+ #endif
+ #define NV_SET_PAGES_UC_PRESENT
+#else
+ #undef NV_SET_PAGES_UC_PRESENT
+#endif
+
+/* Implement conftest.sh function change_page_attr */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) && \
+               LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+ #ifndef NV_SET_PAGES_UC_PRESENT
+  #define NV_CHANGE_PAGE_ATTR_PRESENT
+ #endif
+#else
+ #undef NV_CHANGE_PAGE_ATTR_PRESENT
+#endif
+
+/* Implement conftest.sh function pci_get_class */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+ #define NV_PCI_GET_CLASS_PRESENT
+#else
+ #undef NV_PCI_GET_CLASS_PRESENT
+#endif
+
+/* Implement conftest.sh function remap_pfn_range */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+ #define NV_REMAP_PFN_RANGE_PRESENT
+#else
+ #undef NV_REMAP_PFN_RANGE_PRESENT
+#endif
+
+/* Implement conftest.sh function signal_struct */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+ #define NV_SIGNAL_STRUCT_HAS_RLIM
+#else
+ #undef NV_SIGNAL_STRUCT_HAS_RLIM
+#endif
+
+/* Implement conftest.sh function agp_backend_acquire */
+/* Only kernels sometime before 2.4.0 don't have this function, and who */
+/* cares anymore */
+#define NV_AGP_BACKEND_ACQUIRE_PRESENT
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
+ #define NV_AGP_BACKEND_ACQUIRE_ARGUMENT_COUNT 1
+#else
+ #define NV_AGP_BACKEND_ACQUIRE_ARGUMENT_COUNT 0
+#endif
+
+/* Implement conftest.sh function vmap */
+/* I can not find any released kernel that uses the 2 argument variant */
+/* of vmap */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,22)
+ #define NV_VMAP_PRESENT
+ #define NV_VMAP_ARGUMENT_COUNT 4
+#else
+ #undef NV_VMAP_PRESENT
+#endif
+
+/* Implement conftest.sh function i2c_adapter */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ #define NV_I2C_ADAPTER_HAS_INC_USE
+ #define NV_I2C_ADAPTER_HAS_DEC_USE
+ #define NV_I2C_ADAPTER_HAS_CLIENT_REGISTER
+#else
+ #undef NV_I2C_ADAPTER_HAS_INC_USE
+ #undef NV_I2C_ADAPTER_HAS_DEC_USE
+ #undef NV_I2C_ADAPTER_HAS_CLIENT_REGISTER
+#endif
+
+/* Implement conftest.sh function sysctl_max_map_count */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,5)
+ #define NV_SYSCTL_MAX_MAP_COUNT_PRESENT
+#else
+ #undef NV_SYSCTL_MAX_MAP_COUNT_PRESENT
+#endif
+
+/* Implement conftest.sh function pm_message_t */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+ #define NV_PM_MESSAGE_T_PRESENT
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
+  #define NV_PM_MESSAGE_T_HAS_EVENT
+ #else
+  #undef NV_PM_MESSAGE_T_HAS_EVENT
+ #endif
+#else
+ #undef NV_PM_MESSAGE_T_PRESENT
+#endif
+
+/* Implement conftest.sh function pci_choose_state */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+ #define NV_PCI_CHOOSE_STATE_PRESENT
+#else
+ #undef NV_PCI_CHOOSE_STATE_PRESENT
+#endif
+
+/* Implement conftest.sh function vm_insert_page */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
+ #define NV_VM_INSERT_PAGE_PRESENT
+#else
+ #undef NV_VM_INSERT_PAGE_PRESENT
+#endif
+
+/* Implement conftest.sh function irq_handler_t */
+/* I can not find any released kernel that uses the 3 argument variant */
+/* of irq_handler_t */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+ #define NV_IRQ_HANDLER_T_PRESENT
+ #define NV_IRQ_HANDLER_T_ARGUMENT_COUNT 2
+#else
+ #undef NV_IRQ_HANDLER_T_PRESENT
+#endif
+
+/* Implement conftest.sh function acpi_device_ops */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) && \
+               LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
+ #define NV_ACPI_DEVICE_OPS_HAS_MATCH
+#else
+ #undef NV_ACPI_DEVICE_OPS_HAS_MATCH
+#endif
+
+/* Implement conftest.sh function acpi_device_id */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
+ #define NV_ACPI_DEVICE_ID_HAS_DRIVER_DATA
+#else
+ #undef NV_ACPI_DEVICE_ID_HAS_DRIVER_DATA
+#endif
+
+/* Implement conftest.sh function acquire_console_sem */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,10)
+ #define NV_ACQUIRE_CONSOLE_SEM_PRESENT
+#else
+ #undef NV_ACQUIRE_CONSOLE_SEM_PRESENT
+#endif
+
+/* Implement conftest.sh function kmem_cache_create */
+/* Only kernels sometime before 2.4.0 don't have this function, and who */
+/* cares anymore */
+#define NV_KMEM_CACHE_CREATE_PRESENT
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
+ #define NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT 5
+#else
+ #define NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT 6
+#endif
+
+/* Implement conftest.sh function smp_call_function */
+/* Only kernels sometime before 2.4.0 don't have this function, and who */
+/* cares anymore */
+#define NV_SMP_CALL_FUNCTION_PRESENT
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ #define NV_SMP_CALL_FUNCTION_ARGUMENT_COUNT 3
+#else
+ #define NV_SMP_CALL_FUNCTION_ARGUMENT_COUNT 4
+#endif
+
+/* Implement conftest.sh function on_each_cpu */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ #define NV_ON_EACH_CPU_PRESENT
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+  #define NV_ON_EACH_CPU_ARGUMENT_COUNT 3
+ #else
+  #define NV_ON_EACH_CPU_ARGUMENT_COUNT 4
+ #endif
+#else
+ #undef NV_ON_EACH_CPU_PRESENT
+#endif
+
+/* Implement conftest.sh function acpi_evaluate_interger */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,19)
+ #define NV_ACPI_EVALUATE_INTEGER_PRESENT
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
+  typedef unsigned long long nv_acpi_integer_t;
+ #else
+  typedef unsigned long nv_acpi_integer_t;
+ #endif
+#else
+ #undef NV_ON_EACH_CPU_PRESENT
+ typedef unsigned long nv_acpi_integer_t;
+#endif
+
+/* Implement conftest.sh function ioremap_wc */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
+ #define NV_IOREMAP_WC_PRESENT
+#else
+ #undef NV_IOREMAP_WC_PRESENT
+#endif
+
+/* Implement conftest.sh function proc_dir_entry */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
+ #define NV_PROC_DIR_ENTRY_HAS_OWNER
+#else
+ #undef NV_PROC_DIR_ENTRY_HAS_OWNER
+#endif
+
+/* Implement conftest.sh function agp_memory */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
+ #define NV_AGP_MEMORY_HAS_PAGES
+#else
+ #undef NV_AGP_MEMORY_HAS_PAGES
+#endif
+
+/* Check for linux/semaphore.h */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
+ #define NV_LINUX_SEMAPHORE_H_PRESENT
+#else
+ #undef NV_LINUX_SEMAPHORE_H_PRESENT
+#endif
+
+/* Check for linux/cred.h */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ #define NV_LINUX_CRED_H_PRESENT
+#else
+ #undef NV_LINUX_CRED_H_PRESENT
+#endif
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/Makefile
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/Makefile	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/Makefile	(revision 5887)
@@ -0,0 +1,179 @@
+# Makefile -- For the nvidia module
+
+#
+# By default, the build is done against the running linux kernel source.
+# To build against a different kernel source tree, set LINUXDIR:
+#
+#    make LINUXDIR=/path/to/kernel/source
+
+SHELL=/bin/sh
+
+.SUFFIXES:
+
+ifndef LINUXDIR
+RUNNING_REL := $(shell uname -r)
+
+LINUXDIR := $(shell if [ -e /lib/modules/$(RUNNING_REL)/source ]; then \
+		 echo /lib/modules/$(RUNNING_REL)/source; \
+		 else echo /lib/modules/$(RUNNING_REL)/build; fi)
+endif
+
+ifndef O
+O := $(shell if [ -e /lib/modules/$(RUNNING_REL)/build ]; then \
+		 echo /lib/modules/$(RUNNING_REL)/build; \
+		 else echo ""; fi)
+#O := $(LINUXDIR)
+endif
+
+ifdef ARCH
+MACHINE := $(ARCH)
+else
+MACHINE := $(shell uname -m)
+endif
+
+# Modules for all architectures
+MODULE_LIST := nvidia.o
+
+CLEANFILES = *.o *.ko .depend .*.flags .*.d .*.cmd *.mod.c .tmp_versions
+
+# VERSION is not defined from the initial invocation.  It is defined when
+# this Makefile is invoked from the kernel's root Makefile.
+
+ifndef VERSION
+
+ifdef RUNNING_REL
+
+# SuSE has the version.h and autoconf.h headers for the current kernel
+# in /boot as /boot/vmlinuz.version.h and /boot/vmlinuz.autoconf.h.
+# Check these first to see if they match the running kernel.
+
+BOOTVERSION_PREFIX = /boot/vmlinuz.
+
+V := $(shell if [ -f $(BOOTVERSION_PREFIX)version.h ]; then \
+	grep UTS_RELEASE $(BOOTVERSION_PREFIX)version.h | \
+	cut -d' ' -f3; fi)
+
+ifeq ($(V),"$(RUNNING_REL)")
+HEADERFROMBOOT := 1
+GETCONFIG := MAKEFILES=$(shell /bin/pwd)/.config
+HAVECONFIG := y
+endif
+
+# On Red Hat we need to check if there is a .config file in the kernel
+# source directory.  If there isn't, we need to check if there's a
+# matching file in the configs subdirectory.
+
+ifneq ($(HAVECONFIG),y)
+HAVECONFIG := $(shell if [ -e $(LINUXDIR)/.config ]; then echo y; fi)
+endif
+
+ifneq ($(HAVECONFIG),y)
+REL_BASE := $(shell echo $(RUNNING_REL) | sed 's/-.*//')
+REL_TYPE := $(shell echo $(RUNNING_REL) | sed 's/[0-9.-]//g')
+ifeq ($(REL_TYPE),)
+RHCONFIG := configs/kernel-$(REL_BASE)-$(MACHINE).config
+else
+RHCONFIG := configs/kernel-$(REL_BASE)-$(MACHINE)-$(REL_TYPE).config
+endif
+HAVECONFIG := $(shell if [ -e $(LINUXDIR)/$(RHCONFIG) ]; then echo y; fi)
+ifneq ($(HAVECONFIG),y)
+RHCONFIG :=
+endif
+endif
+
+ifneq ($(HAVECONFIG),y)
+ifneq ($(0),$(LINUXDIR))
+GETCONFIG += O=$(O)
+endif
+HAVECONFIG := $(shell if [ -e $(O)/.config ]; then echo y; fi)
+endif
+
+ifneq ($(HAVECONFIG),y)
+$(error Cannot find a kernel config file)
+endif
+
+endif
+
+CLEANCONFIG := $(shell if cmp -s $(LINUXDIR)/.config .config; then echo y; fi)
+ifeq ($(CLEANCONFIG),y)
+CLEANFILES += $(LINUXDIR)/.config .config $(LINUXDIR)/tmp_include_depends
+endif
+
+all: modules
+
+modules: includes
+	+make -C $(LINUXDIR) $(GETCONFIG) M=`/bin/pwd` modules
+
+ifeq ($(HEADERFROMBOOT),1)
+
+BOOTHEADERS = version.h autoconf.h
+BOOTCONFIG = .config
+
+CLEANFILES += $(BOOTHEADERS) $(BOOTCONFIG)
+
+includes:: $(BOOTHEADERS) $(BOOTCONFIG)
+
+version.h: $(BOOTVERSION_PREFIX)version.h
+	rm -f $@
+	ln -s $< $@
+
+autoconf.h: $(BOOTVERSION_PREFIX)autoconf.h
+	rm -f $@
+	ln -s $< $@
+
+.config: $(BOOTVERSION_PREFIX)config
+	rm -f $@
+	ln -s $< $@
+endif
+
+# This prepares an unused Red Hat kernel tree for the build.
+ifneq ($(RHCONFIG),)
+includes:: $(LINUXDIR)/.config $(LINUXDIR)/tmp_include_depends .config
+
+$(LINUXDIR)/.config: $(LINUXDIR)/$(RHCONFIG)
+	rm -f $@
+	ln -s $< $@
+
+.config: $(LINUXDIR)/$(RHCONFIG)
+	rm -f $@
+	ln -s $< $@
+
+$(LINUXDIR)/tmp_include_depends:
+	echo all: > $@
+endif
+
+clean cleandir:
+	rm -rf $(CLEANFILES)
+
+$(MODULE_LIST)::
+	make modules
+
+install:
+	make -C $(LINUXDIR) $(GETCONFIG) M=`/bin/pwd` modules_install
+
+else
+
+# Check for kernel versions that we don't support.
+
+BELOW26 := $(shell if [ $(VERSION) -lt 2 -o $(PATCHLEVEL) -lt 6 ]; then \
+		echo y; fi)
+
+ifeq ($(BELOW26),y)
+$(error Only 2.6.x and later kernels are supported \
+	($(VERSION).$(PATCHLEVEL).$(SUBLEVEL)))
+endif
+
+# This needs to go before all other include paths.
+CC += -I$(M)
+
+ifeq ($(CONFIG_X86_64),y)
+NVARCH = .x86_64
+else
+NVARCH = .i386
+endif
+
+include $(M)/Makefile.kbuild
+
+endif
+
+.PHONY: includes
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.h
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.h	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.h	(revision 5887)
@@ -0,0 +1,5 @@
+static struct {
+	const char *short_description;
+	const char *description;
+} __nv_patches[] = {
+{ NULL, NULL } };
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/conftest.sh
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/conftest.sh	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/conftest.sh	(revision 5887)
@@ -0,0 +1,7 @@
+#!/bin/sh
+# This is a replacement for nvidia's conftest.sh
+#
+# We have a new conftest.h that works with kbuild that we don't want
+# overwritten or generated or anything else, so we want any call to
+# conftest.sh to do absolutely nothing.
+exit 0
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau-dev.links
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau-dev.links	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau-dev.links	(revision 5887)
@@ -0,0 +1,1 @@
+usr/lib/libvdpau.so.1	usr/lib/libvdpau.so
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1-dev.install.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1-dev.install.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1-dev.install.in	(revision 5887)
@@ -0,0 +1,2 @@
+#DIRNAME#/usr/include/cuda/cuda.h		/usr/include/cuda
+#DIRNAME#/usr/include/cuda/cudaGL.h		/usr/include/cuda
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau-ia32.dirs
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau-ia32.dirs	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau-ia32.dirs	(revision 5887)
@@ -0,0 +1,1 @@
+
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.lintian-overrides.amd64.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.lintian-overrides.amd64.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.lintian-overrides.amd64.in	(revision 5887)
@@ -0,0 +1,7 @@
+nvidia-libvdpau1: binary-has-unneeded-section ./usr/lib/libvdpau.so.#VERSION# .comment
+nvidia-libvdpau1: binary-has-unneeded-section ./usr/lib/libvdpau_nvidia.so.#VERSION# .comment
+nvidia-libvdpau1: binary-has-unneeded-section ./usr/lib/libvdpau_trace.so.#VERSION# .comment
+
+# libvdpau.so.1 does dlopen("libvdpau_*.so")
+nvidia-libvdpau1: non-dev-pkg-with-shlib-symlink usr/lib/libvdpau_nvidia.so.#VERSION# usr/lib/libvdpau_nvidia.so
+nvidia-libvdpau1: non-dev-pkg-with-shlib-symlink usr/lib/libvdpau_trace.so.#VERSION# usr/lib/libvdpau_trace.so
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.lintian-overrides
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.lintian-overrides	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.lintian-overrides	(revision 5887)
@@ -0,0 +1,2 @@
+# the diversions are placed there
+nvidia-glx-dev: package-contains-empty-directory usr/lib/nvidia/
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.NEWS
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.NEWS	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.NEWS	(revision 5887)
@@ -0,0 +1,27 @@
+nvidia-graphics-drivers (1.0.8174-1) unstable; urgency=low
+
+  * LEGACY GPUs: If you have a TNT, TNT2, Vanta, GeForce 256, GeForce DDR,
+  Quadro, GeForce2 Pro, GeForce2 GTS, GeForce2 Ultra, GeForce2 Ti, Quadro2 Pro,
+  DO NOT INSTALL THIS RELEASE!!! They are no longer supported. 
+      
+ -- Randall Donald <rdonald@debian.org>  Sat, 10 Dec 2005 00:01:32 -0800
+
+nvidia-graphics-drivers (1.0.7667-2) unstable; urgency=low
+
+  * LEGACY GPUs: If you have a TNT, TNT2, Vanta, GeForce 256, GeForce DDR,
+  Quadro, GeForce2 Pro, GeForce2 GTS, GeForce2 Ultra, GeForce2 Ti, Quadro2 Pro,
+  DO NOT INSTALL THIS RELEASE!!!  Use the nvidia-glx-legacy,
+  nvidia-glx-legacy-dev, nvidia-kernel-source-legacy packages instead.  
+      
+ -- Randall Donald <rdonald@debian.org>  Wed, 13 Jun 2005 00:01:32 -0700
+
+nvidia-graphics-drivers (1.0.7664-1) experimental; urgency=low
+
+  * LEGACY GPUs: If you have a TNT, TNT2, Vanta, GeForce 256, GeForce DDR,
+  Quadro, GeForce2 Pro, GeForce2 GTS, GeForce2 Ultra, GeForce2 Ti, Quadro2 Pro,
+  DO NOT INSTALL THIS RELEASE!!!  NVIDIA will be supporting these cards in a
+  special legacy driver (as yet unreleased and not included in this package). 
+  So if you have the one of the above listed GPUs, 
+  remain with the 1.0.7174-3 release.
+      
+ -- Randall Donald <rdonald@debian.org>  Tue, 21 Jun 2005 00:01:32 -0700
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/copyright.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/copyright.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/copyright.in	(revision 5887)
@@ -0,0 +1,191 @@
+This package was debianized by Randall Donald <rdonald@debian.org> on
+Mon, 31 Mar 2003 23:40:05 -0800.
+
+It was downloaded from
+#URL#
+
+Upstream Author: NVIDIA <linux-bugs@nvidia.com>
+
+
+Copyright:
+
+First a note from the README file
+
+Q: Why does NVIDIA not provide rpms anymore?
+
+A: Not every Linux distribution uses rpm, and NVIDIA wanted a single
+   solution that would work across all Linux distributions.  As indicated
+   in the NVIDIA Software License, Linux distributions are welcome to
+   repackage and redistribute the NVIDIA Linux driver in whatever package
+   format they wish.
+
+Furthermore, an email from NVIDIA:
+
+Greetings, Randall!  Comments below:
+
+On 30 Jul 2003, Randall Donald wrote:
+
+> To whom it may concern,
+> 
+> My name is Randall Donald and I am the maintainer for the Debian
+> downloader packages nvidia-glx-src and nvidia-kernel-src. 
+> As stated in your license and the README file 
+> ( "As indicated in the NVIDIA Software License, Linux distributions 
+>   are welcome to repackage and redistribute the NVIDIA Linux driver in 
+>   whatever package format they wish." )
+> I wish to include packages containing the Linux driver files in the Debian archive. 
+> I'd like to know if it is legally permitted to distribute binary kernel modules 
+> compiled from the NVIDIA kernel module source and Debian kernel headers. 
+
+This is fine; thanks for asking.
+
+> I am also wondering if the "No Separation of Components" clause 
+> ( No Separation of Components.  The SOFTWARE is licensed as a
+>   single product.  Its component parts may not be separated for use
+>   on more than one computer, nor otherwise used separately from the
+>   other parts.) applies to splitting the glx driver and kernel module source into
+>  multiple binary packages.
+
+This is also fine.  I believe this section of the license was
+intended to prevent users from doing things like using our Windows
+control panel with a competitor's display driver (that's not actually
+possible, but you get the idea...).  In the case of separating the
+driver into a glx package and a kernel package (like we used to
+do ourselves), this is simply a packaging issue; of course users
+will use the packages together when they install.
+
+Please feel free to redistribute the NVIDIA graphics driver.
+
+Thank you for doing this for the NVIDIA+Debian community!
+
+- Andy
+
+
+
+The NVIDIA Software Licence is as follows.   
+   
+From http://www.nvidia.com/view.asp?IO=nv_swlicense and extracted from the 
+installer: 
+
+
+           License For Customer Use of NVIDIA Software
+
+
+IMPORTANT NOTICE -- READ CAREFULLY: This License For Customer Use of
+NVIDIA Software ("LICENSE") is the agreement which governs use of
+the software of NVIDIA Corporation and its subsidiaries ("NVIDIA")
+downloadable herefrom, including computer software and associated
+printed materials ("SOFTWARE").  By downloading, installing, copying,
+or otherwise using the SOFTWARE, you agree to be bound by the terms
+of this LICENSE.  If you do not agree to the terms of this LICENSE,
+do not download the SOFTWARE.
+
+RECITALS
+
+Use of NVIDIA's products requires three elements: the SOFTWARE, the
+hardware on a graphics controller board, and a personal computer. The
+SOFTWARE is protected by copyright laws and international copyright
+treaties, as well as other intellectual property laws and treaties.
+The SOFTWARE is not sold, and instead is only licensed for use,
+strictly in accordance with this document.  The hardware is protected
+by various patents, and is sold, but this agreement does not cover
+that sale, since it may not necessarily be sold as a package with
+the SOFTWARE.  This agreement sets forth the terms and conditions
+of the SOFTWARE LICENSE only.
+
+1.  DEFINITIONS
+
+1.1  Customer.  Customer means the entity or individual that
+downloads the SOFTWARE.
+
+2.  GRANT OF LICENSE
+
+2.1  Rights and Limitations of Grant.  NVIDIA hereby grants Customer
+the following non-exclusive, non-transferable right to use the
+SOFTWARE, with the following limitations:
+
+2.1.1  Rights.  Customer may install and use one copy of the SOFTWARE
+on a single computer, and except for making one back-up copy of
+the Software, may not otherwise copy the SOFTWARE.  This LICENSE
+of SOFTWARE may not be shared or used concurrently on different
+computers.
+
+2.1.2  Linux Exception.  Notwithstanding the foregoing terms of
+Section 2.1.1, SOFTWARE designed exclusively for use on the Linux
+operating system may be copied and redistributed, provided that
+the binary files thereof are not modified in any way (except for
+unzipping of compressed files).
+
+2.1.3  Limitations.
+
+No Reverse Engineering.  Customer may not reverse engineer,
+decompile, or disassemble the SOFTWARE, nor attempt in any other
+manner to obtain the source code.
+
+No Separation of Components.  The SOFTWARE is licensed as a
+single product.  Its component parts may not be separated for use
+on more than one computer, nor otherwise used separately from the
+other parts.
+
+No Rental.  Customer may not rent or lease the SOFTWARE to someone
+else.
+
+3.  TERMINATION
+
+This LICENSE will automatically terminate if Customer fails to
+comply with any of the terms and conditions hereof.  In such event,
+Customer must destroy all copies of the SOFTWARE and all of its
+component parts.
+
+4.  COPYRIGHT
+
+All title and copyrights in and to the SOFTWARE (including but
+not limited to all images, photographs, animations, video, audio,
+music, text, and other information incorporated into the SOFTWARE),
+the accompanying printed materials, and any copies of the SOFTWARE,
+are owned by NVIDIA, or its suppliers.  The SOFTWARE is protected
+by copyright laws and international treaty provisions.  Accordingly,
+Customer is required to treat the SOFTWARE like any other copyrighted
+material, except as otherwise allowed pursuant to this LICENSE
+and that it may make one copy of the SOFTWARE solely for backup or
+archive purposes.
+
+5.  APPLICABLE LAW
+
+This agreement shall be deemed to have been made in, and shall be
+construed pursuant to, the laws of the State of California.
+
+6.  DISCLAIMER OF WARRANTIES AND LIMITATION ON LIABILITY
+
+6.1  No Warranties.  TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE
+LAW, THE SOFTWARE IS PROVIDED "AS IS" AND NVIDIA AND ITS SUPPLIERS
+DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT
+NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE.
+
+6.2  No Liability for Consequential Damages.  TO THE MAXIMUM
+EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL NVIDIA OR
+ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR
+CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
+DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS
+OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT
+OF THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF NVIDIA HAS
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7.  MISCELLANEOUS 
+
+The United Nations Convention on Contracts for the International
+Sale of Goods is specifically disclaimed.  If any provision of this
+LICENSE is inconsistent with, or cannot be fully enforced under,
+the law, such provision will be construed as limited to the extent
+necessary to be consistent with and fully enforceable under the law.
+This agreement is the final, complete and exclusive agreement between
+the parties relating to the subject matter hereof, and supersedes
+all prior or contemporaneous understandings and agreements relating
+to such subject matter, whether oral or written.  Customer agrees
+that it will not ship, transfer or export the SOFTWARE into any
+country, or use the SOFTWARE in any manner, prohibited by the
+United States Bureau of Export Administration or any export laws,
+restrictions or regulations.  This LICENSE may only be modified in
+writing signed by an authorized officer of NVIDIA.
+
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1-ia32.postinst
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1-ia32.postinst	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1-ia32.postinst	(revision 5887)
@@ -0,0 +1,49 @@
+#!/bin/sh
+# postinst script for nvidia-libvdpau1-ia32
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <postinst> `abort-remove'
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    configure)
+
+	# these files were not shipped in the package nvidia-libvdpau (before
+	# the emul/ia32-linux transiotion) but generated by ldconfig
+	test ! -L /emul/ia32-linux/usr/lib/libvdpau.so.1 || \
+		rm /emul/ia32-linux/usr/lib/libvdpau.so.1 || true
+	test ! -L /emul/ia32-linux/usr/lib/libvdpau_nvidia.so || \
+		rm /emul/ia32-linux/usr/lib/libvdpau_nvidia.so || true
+	test ! -L /emul/ia32-linux/usr/lib/libvdpau_trace.so || \
+		rm /emul/ia32-linux/usr/lib/libvdpau_trace.so || true
+
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.lintian-overrides.i386.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.lintian-overrides.i386.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.lintian-overrides.i386.in	(revision 5887)
@@ -0,0 +1,6 @@
+libcuda1: shlib-with-non-pic-code usr/lib/libcuda.so.#VERSION#
+libcuda1: shlib-without-PT_GNU_STACK-section usr/lib/libcuda.so.#VERSION#
+libcuda1: unstripped-binary-or-object ./usr/lib/libcuda.so.#VERSION#
+
+# libcudart.so.2 does dlopen("libcuda.so")
+libcuda1: non-dev-pkg-with-shlib-symlink usr/lib/libcuda.so.#VERSION# usr/lib/libcuda.so
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.dirs
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.dirs	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.dirs	(revision 5887)
@@ -0,0 +1,2 @@
+usr/include/GL
+usr/lib/nvidia
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.README.Debian
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.README.Debian	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.README.Debian	(revision 5887)
@@ -0,0 +1,70 @@
+nvidia-graphics-drivers for Debian
+----------------------------------
+
+
+INTRODUCTION:
+-----------------------------------------------------------------------
+
+Welcome to the Debian NVIDIA packages. This document has notes on the
+X Server and GL libraries of the NVIDIA driver offering.
+
+
+A Note about Thread Local Storage (TLS):
+----------------------------------------
+Under 2.6.x kernels a new TLS method is used and different libraries are
+required. NVIDIA provides these libraries and at boot time (via
+/etc/init.d/nvidia-glx)  a test is performed on your system to see if 
+your require these extra libraries. Having the TLS libraries installed 
+(in /usr/lib/tls and libglx.so) running under a 2.4.x kernel will cause 
+problems when running GL applications. Likewise, not having these libraries 
+installed under 2.6.x might prevent X from starting at all. 
+
+Simple Explanation: 
+To switch back and forth between the two systems simply run:
+
+      /etc/init.d/nvidia-glx start
+      
+      This is run automatically at boot time. 
+
+To force a certain setting (e.g. you may have a 2.4 kernel patched for
+NPTL) place  USE_TLS=1 in /etc/defaults/nvidia-glx for using the nvidia tls
+libraries. USE_TLS=0 for not using tls libraries.  This isn't normally
+necessary for most users. 
+
+
+What Happens:
+Symlinks are created in /usr/lib/tls from libraries installed in
+/usr/lib/nvidia. 
+
+
+For any news on this package check http://people.debian.org/~rdonald and
+http://bugs.debian.org/nvidia-glx
+
+
+NOTES ABOUT GLX DRIVER AND OPENGL:
+-----------------------------------------------------------------------
+
+Using the nvidia X driver requires some user modification. 
+
+	First, modify your /etc/X11/XF86Config-4 or /etc/X11/xorg.conf
+
+	Minimum requirements:
+	In Section "Module"
+	   add Load "glx"
+	   remove Load "dri"
+       	   remove Load "GLcore"
+	In Section "Device"
+	   Change Driver "nv" to Driver "nvidia"
+	
+	See /usr/share/doc/nvidia-glx/README.txt.gz and
+	/usr/share/doc/nvidia-glx/examples/XF86Config.sample.gz
+	for descriptions of all supported options. 
+	Chapter 12: Configuring AGP is an important section.
+
+
+Also note all users using GLX must be in group video. (i.e. adduser <user>
+video)
+
+
+
+ -- Randall Donald <rdonald@debian.org>, Mon, 31 Mar 2003 23:40:05 -0800
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1-ia32.links.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1-ia32.links.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1-ia32.links.in	(revision 5887)
@@ -0,0 +1,4 @@
+usr/lib32/libvdpau.so.#VERSION#		usr/lib32/libvdpau.so.1
+usr/lib32/libvdpau.so.1			usr/lib32/libvdpau.so
+usr/lib32/libvdpau_nvidia.so.#VERSION#	usr/lib32/libvdpau_nvidia.so
+usr/lib32/libvdpau_trace.so.#VERSION#	usr/lib32/libvdpau_trace.so
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.postinst
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.postinst	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.postinst	(revision 5887)
@@ -0,0 +1,55 @@
+#!/bin/sh
+# postinst script for nvidia-glx-ia32
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <postinst> `abort-remove'
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    configure)
+
+	# remove diversion created before the
+	# /emul/ia32-linux/usr/lib => /usr/lib32 transition
+	dpkg-divert --remove --rename --package nvidia-glx-ia32 --divert \
+		/emul/ia32-linux/usr/lib/nvidia/libGL.so.ia32-libs \
+		/emul/ia32-linux/usr/lib/libGL.so > /dev/null
+	dpkg-divert --remove --rename --package nvidia-glx-ia32 --divert \
+		/emul/ia32-linux/usr/lib/nvidia/libGL.so.1.ia32-libs \
+		/emul/ia32-linux/usr/lib/libGL.so.1 > /dev/null
+	dpkg-divert --remove --rename --package nvidia-glx-ia32 --divert \
+		/emul/ia32-linux/usr/lib/nvidia/libGL.so.1.2.ia32-libs \
+		/emul/ia32-linux/usr/lib/libGL.so.1.2 > /dev/null
+
+	test -d /emul/ia32-linux/usr/lib/nvidia && \
+		rmdir /emul/ia32-linux/usr/lib/nvidia || true;
+
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/control
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/control	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/control	(revision 5887)
@@ -0,0 +1,185 @@
+Source: nvidia-graphics-drivers
+Section: non-free/x11
+Priority: optional
+Maintainer: Debian NVIDIA Maintainers <pkg-nvidia-devel@lists.alioth.debian.org>
+Uploaders: Randall Donald <rdonald@debian.org>
+Vcs-Svn: svn://svn.debian.org/svn/pkg-nvidia/packages/nvidia-graphics-drivers
+Vcs-Browser: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-graphics-drivers
+Build-Depends: debhelper (>= 6.0.7~), sed (>> 3.0), libxext6, bzip2,
+ libc6-dev-i386 [amd64], lib32gcc1 [amd64], lib32z1 [amd64],
+ ia32-libs (<< 3) [amd64] | ia32-libs (>= 20090804) [amd64] | ia32-libxext6 [amd64],
+Standards-Version: 3.6.2
+Homepage: http://www.nvidia.com
+
+Package: nvidia-glx-ia32
+Architecture: amd64
+Pre-Depends: libc6-i386 (>= 2.9-18)
+Depends: nvidia-kernel-185.18.36, ${shlibs:Depends}, ${misc:Depends}
+Suggests: nvidia-settings, nvidia-kernel-source (>= 185.18.36)
+Conflicts: nvidia-glx-src
+Replaces: nvidia-glx-src
+Description: NVIDIA binary driver 32bit libs
+ These binary drivers provide optimized hardware acceleration of
+ OpenGL applications via a direct-rendering X Server. AGP, TV-out and
+ flat panel displays are also supported.
+ .
+ This version only supports GeForce 6xxx and higher of the Geforce GPUs
+ plus complimentary Quadros and nforce.
+ .
+ See /usr/share/doc/nvidia-glx/README.txt.gz for a complete list 
+ of supported GPUs and PCIIDs
+ .
+
+Package: nvidia-glx
+Architecture: i386 amd64
+Depends: nvidia-kernel-185.18.36, x11-common (>= 1:7.0.0), ${shlibs:Depends}, ${misc:Depends}
+Suggests: nvidia-settings, nvidia-kernel-source (>= 185.18.36)
+Conflicts: nvidia-glx-src, nvidia-glx-dev (<< 1.0.8774-5)
+Replaces: nvidia-glx-src
+Description: NVIDIA binary Xorg driver
+ These binary drivers provide optimized hardware 
+ acceleration of  OpenGL applications via a direct-rendering X Server. 
+ AGP, PCIe, SLI, TV-out and flat panel displays are also supported.
+ .
+ Please see the nvidia-kernel-source package for building the kernel module
+ required by this package. This will provide nvidia-kernel-<version>
+ .
+ GPUs of Geforce 6xxx and above are supported. Look to the legacy packages 
+ for older cards.
+ . 
+ See /usr/share/doc/nvidia-glx/README.txt.gz for a complete list 
+ of supported GPUs and PCIIDs
+ .
+
+Package: nvidia-glx-dev
+Architecture: i386 amd64
+Depends: nvidia-glx (>= 185.18.36), ${misc:Depends}
+Provides: libgl-dev
+Conflicts: nvidia-glx (>= 185.18.37), libgl-dev, mesa-common-dev
+Replaces: libgl-dev
+Description: NVIDIA binary Xorg driver development files
+ This package contains the NVIDIA binary Xorg driver
+ development files.
+ .
+ For more information on this source package visit NVIDIA's homepage
+ at http://www.nvidia.com/ .
+
+Package: nvidia-libvdpau1-ia32
+Section: non-free/libs
+Architecture: amd64
+Pre-Depends: libc6-i386 (>= 2.9-18)
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Recommends: nvidia-kernel-185.18.36
+Suggests: nvidia-kernel-source (>= 185.18.36)
+Replaces: nvidia-glx-ia32 (< 180.51), nvidia-libvdpau-ia32
+Conflicts: nvidia-glx-ia32 (< 180.51), nvidia-libvdpau-ia32
+Description: NVIDIA vdpau 32bit libraries
+ These libraries provide the Video Decode and Presentation API for Unix
+ (32 bit). They provide accelerated video playback (incl. H.264) for the 
+ supported graphics cards. See /usr/share/doc/nvidia-libvdpau/README.txt.gz 
+ for more information.
+
+Package: nvidia-libvdpau1
+Section: non-free/libs
+Architecture: i386 amd64
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Recommends: nvidia-kernel-185.18.36
+Suggests: nvidia-kernel-source (>= 185.18.36)
+Replaces: nvidia-glx (< 180.51), nvidia-libvdpau
+Conflicts: nvidia-glx (< 180.51), nvidia-libvdpau
+Description: NVIDIA vdpau libraries
+ These libraries provide the Video Decode and Presentation API for Unix.
+ They provide accelerated video playback (incl. H.264) for the supported 
+ graphics cards. See /usr/share/doc/nvidia-libvdpau/README.txt.gz for 
+ more information.
+
+Package: nvidia-libvdpau-dev
+Section: non-free/libdevel
+Architecture: i386 amd64
+Depends: nvidia-libvdpau1 (>= 185.18.36), ${misc:Depends}
+Conflicts: nvidia-glx-dev (< 180.51), nvidia-libvdpau1 (>= 185.18.37)
+Provides: nvidia-libvdpau1-dev
+Replaces: nvidia-libvdpau, nvidia-glx-dev (< 180.51)
+Description: NVIDIA vdpau development files
+ The NVIDIA Video Decode and Presentation API for Unix (VDPAU) provides a
+ complete solution for decoding, post-processing, compositing, and displaying
+ compressed or uncompressed video streams.
+ .
+ This package contains the VDPAU development files.
+
+Package: nvidia-kernel-source
+Architecture: i386 amd64
+Depends: debhelper (>> 4.0.0), make, sed (>> 3.0), dpatch (>= 2.0.0), ${misc:Depends}
+Recommends: nvidia-glx (>= 185.18.36), kernel-package (>= 8.082), module-assistant, devscripts
+Conflicts: nvidia-kernel-src
+Replaces: nvidia-kernel-src
+Description: NVIDIA binary kernel module source
+ This package builds the NVIDIA Xorg  binary kernel module 
+ needed  by nvidia-glx. The drivers provide optimized hardware acceleration 
+ of OpenGL applications via a direct-rendering X Server AGP,
+ PCIe, SLI, TV-out, and flat panel displays are also supported.
+ .
+ PLEASE read /usr/share/doc/nvidia-kernel-source/README.Debian for building
+ information.
+ .
+
+Package: libcuda1
+Section: non-free/libs
+Architecture: i386 amd64
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Recommends: nvidia-kernel-185.18.36
+Suggests: nvidia-kernel-source (>= 185.18.36)
+Replaces: nvidia-glx (<< 185.18.14-2), nvidia-glx-dev (<< 185.18.14-2)
+Description: NVIDIA CUDA runtime library
+ The Compute Unified Device Architecture (CUDA) enables NVIDIA
+ graphics processing units (GPUs) to be used for massively parallel
+ general purpose computation.
+ .
+ This package contains the driver specific runtime library.
+ .
+ Supported NVIDIA devices include GPUs starting from GeForce 8 and Quadro FX
+ series, as well as the Tesla computing processors.
+ .
+ Please see the nvidia-kernel-source package for building the kernel module
+ required by this package. This will provide nvidia-kernel-<version>
+ .
+
+Package: libcuda1-ia32
+Section: non-free/libs
+Architecture: amd64
+Pre-Depends: libc6-i386 (>= 2.9-18)
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Recommends: nvidia-kernel-185.18.36
+Suggests: nvidia-kernel-source (>= 185.18.36)
+Replaces: nvidia-glx-ia32 (<< 185.18.14-2)
+Description: NVIDIA CUDA runtime library (32-bit)
+ The Compute Unified Device Architecture (CUDA) enables NVIDIA
+ graphics processing units (GPUs) to be used for massively parallel
+ general purpose computation.
+ .
+ This package contains the driver specific runtime library (32-bit).
+ .
+ Supported NVIDIA devices include GPUs starting from GeForce 8 and Quadro FX
+ series, as well as the Tesla computing processors.
+ .
+ Please see the nvidia-kernel-source package for building the kernel module
+ required by this package. This will provide nvidia-kernel-<version>
+ .
+
+Package: libcuda1-dev
+Section: non-free/libdevel
+Architecture: i386 amd64
+Depends: libcuda1 (>= 185.18.36), ${misc:Depends}
+Provides: libcuda-dev
+Replaces: nvidia-glx-dev (<< 185.18.14-2)
+Description: NVIDIA CUDA development files
+ The Compute Unified Device Architecture (CUDA) enables NVIDIA
+ graphics processing units (GPUs) to be used for massively parallel
+ general purpose computation.
+ .
+ This package contains the driver specific NVIDIA CUDA
+ development files.
+ .
+ For more information on this source package visit NVIDIA's CUDA Zone
+ at http://www.nvidia.com/object/cuda_home.html .
+
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.shlibs
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.shlibs	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.shlibs	(revision 5887)
@@ -0,0 +1,3 @@
+libGL 1 ia32-libs (<< 15) | ia32-libgl1-mesa-glx
+libGLcore 1 nvidia-glx-ia32
+libnvidia-tls 1 nvidia-glx-ia32
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.preinst
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.preinst	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.preinst	(revision 5887)
@@ -0,0 +1,55 @@
+#! /bin/sh
+# preinst script for nvidia-glx-ia32
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <new-preinst> `install'
+#        * <new-preinst> `install' <old-version>
+#        * <new-preinst> `upgrade' <old-version>
+#        * <old-preinst> `abort-upgrade' <new-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    install|upgrade)
+
+	# divert libGL.so* from ia32-libs to /usr/lib32/nvidia
+	test -d /usr/lib32/nvidia || \
+		mkdir -p /usr/lib32/nvidia || true
+
+	dpkg-divert --add --rename --package nvidia-glx-ia32 --divert \
+		/usr/lib32/nvidia/libGL.so.ia32-libs \
+		/usr/lib32/libGL.so > /dev/null
+	dpkg-divert --add --rename --package nvidia-glx-ia32 --divert \
+		/usr/lib32/nvidia/libGL.so.1.ia32-libs \
+		/usr/lib32/libGL.so.1 > /dev/null
+	dpkg-divert --add --rename --package nvidia-glx-ia32 --divert \
+		/usr/lib32/nvidia/libGL.so.1.2.ia32-libs \
+		/usr/lib32/libGL.so.1.2 > /dev/null
+
+	# this file was not shipped in the package but generated by ldconfig
+	test ! -L /emul/ia32-linux/usr/lib/tls/libnvidia-tls.so.1 || \
+		rm /emul/ia32-linux/usr/lib/tls/libnvidia-tls.so.1 || true
+
+    ;;
+
+    abort-upgrade)
+    ;;
+
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 0
+    ;;
+esac
+
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.links.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.links.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.links.in	(revision 5887)
@@ -0,0 +1,5 @@
+usr/lib32/libGL.so.#VERSION# usr/lib32/libGL.so.1
+usr/lib32/libGL.so.1 usr/lib32/libGL.so
+usr/lib32/libGLcore.so.#VERSION# usr/lib32/libGLcore.so.1
+usr/lib32/libnvidia-tls.so.#VERSION# usr/lib32/libnvidia-tls.so.1
+usr/lib32/tls/libnvidia-tls.so.#VERSION# usr/lib32/tls/libnvidia-tls.so.1
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-kernel-source.docs.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-kernel-source.docs.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-kernel-source.docs.in	(revision 5887)
@@ -0,0 +1,2 @@
+#DIRNAME#/usr/share/doc/NVIDIA_Changelog
+#DIRNAME#/usr/share/doc/README.txt
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.examples.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.examples.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.examples.in	(revision 5887)
@@ -0,0 +1,2 @@
+#DIRNAME#/usr/share/doc/XF86Config.sample
+
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.postinst
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.postinst	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.postinst	(revision 5887)
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -e
+
+#make sure wfb diversion is removed
+dpkg-divert --rename --remove --package nvidia-glx --divert /usr/lib/nvidia/libwfb.so.xserver-xorg-core /usr/lib/xorg/modules/libwfb.so >/dev/null || true
+
+
+
+
+
+#DEBHELPER#
+
+
+
+ldconfig
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/control.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/control.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/control.in	(revision 5887)
@@ -0,0 +1,185 @@
+Source: nvidia-graphics-drivers
+Section: non-free/x11
+Priority: optional
+Maintainer: Debian NVIDIA Maintainers <pkg-nvidia-devel@lists.alioth.debian.org>
+Uploaders: Randall Donald <rdonald@debian.org>
+Vcs-Svn: svn://svn.debian.org/svn/pkg-nvidia/packages/nvidia-graphics-drivers
+Vcs-Browser: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvidia-graphics-drivers
+Build-Depends: debhelper (>= 6.0.7~), sed (>> 3.0), libxext6, bzip2,
+ libc6-dev-i386 [amd64], lib32gcc1 [amd64], lib32z1 [amd64],
+ ia32-libs (<< 3) [amd64] | ia32-libs (>= 20090804) [amd64] | ia32-libxext6 [amd64],
+Standards-Version: 3.6.2
+Homepage: http://www.nvidia.com
+
+Package: nvidia-glx-ia32
+Architecture: amd64
+Pre-Depends: libc6-i386 (>= 2.9-18)
+Depends: nvidia-kernel-#VERSION#, ${shlibs:Depends}, ${misc:Depends}
+Suggests: nvidia-settings, nvidia-kernel-source (>= #VERSION#)
+Conflicts: nvidia-glx-src
+Replaces: nvidia-glx-src
+Description: NVIDIA binary driver 32bit libs
+ These binary drivers provide optimized hardware acceleration of
+ OpenGL applications via a direct-rendering X Server. AGP, TV-out and
+ flat panel displays are also supported.
+ .
+ This version only supports GeForce 6xxx and higher of the Geforce GPUs
+ plus complimentary Quadros and nforce.
+ .
+ See /usr/share/doc/nvidia-glx/README.txt.gz for a complete list 
+ of supported GPUs and PCIIDs
+ .
+
+Package: nvidia-glx
+Architecture: i386 amd64
+Depends: nvidia-kernel-#VERSION#, x11-common (>= 1:7.0.0), ${shlibs:Depends}, ${misc:Depends}
+Suggests: nvidia-settings, nvidia-kernel-source (>= #VERSION#)
+Conflicts: nvidia-glx-src, nvidia-glx-dev (<< 1.0.8774-5)
+Replaces: nvidia-glx-src
+Description: NVIDIA binary Xorg driver
+ These binary drivers provide optimized hardware 
+ acceleration of  OpenGL applications via a direct-rendering X Server. 
+ AGP, PCIe, SLI, TV-out and flat panel displays are also supported.
+ .
+ Please see the nvidia-kernel-source package for building the kernel module
+ required by this package. This will provide nvidia-kernel-<version>
+ .
+ GPUs of Geforce 6xxx and above are supported. Look to the legacy packages 
+ for older cards.
+ . 
+ See /usr/share/doc/nvidia-glx/README.txt.gz for a complete list 
+ of supported GPUs and PCIIDs
+ .
+
+Package: nvidia-glx-dev
+Architecture: i386 amd64
+Depends: nvidia-glx (>= #VERSION#), ${misc:Depends}
+Provides: libgl-dev
+Conflicts: nvidia-glx (>= #NEXTVER#), libgl-dev, mesa-common-dev
+Replaces: libgl-dev
+Description: NVIDIA binary Xorg driver development files
+ This package contains the NVIDIA binary Xorg driver
+ development files.
+ .
+ For more information on this source package visit NVIDIA's homepage
+ at http://www.nvidia.com/ .
+
+Package: nvidia-libvdpau1-ia32
+Section: non-free/libs
+Architecture: amd64
+Pre-Depends: libc6-i386 (>= 2.9-18)
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Recommends: nvidia-kernel-#VERSION#
+Suggests: nvidia-kernel-source (>= #VERSION#)
+Replaces: nvidia-glx-ia32 (< 180.51), nvidia-libvdpau-ia32
+Conflicts: nvidia-glx-ia32 (< 180.51), nvidia-libvdpau-ia32
+Description: NVIDIA vdpau 32bit libraries
+ These libraries provide the Video Decode and Presentation API for Unix
+ (32 bit). They provide accelerated video playback (incl. H.264) for the 
+ supported graphics cards. See /usr/share/doc/nvidia-libvdpau/README.txt.gz 
+ for more information.
+
+Package: nvidia-libvdpau1
+Section: non-free/libs
+Architecture: i386 amd64
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Recommends: nvidia-kernel-#VERSION#
+Suggests: nvidia-kernel-source (>= #VERSION#)
+Replaces: nvidia-glx (< 180.51), nvidia-libvdpau
+Conflicts: nvidia-glx (< 180.51), nvidia-libvdpau
+Description: NVIDIA vdpau libraries
+ These libraries provide the Video Decode and Presentation API for Unix.
+ They provide accelerated video playback (incl. H.264) for the supported 
+ graphics cards. See /usr/share/doc/nvidia-libvdpau/README.txt.gz for 
+ more information.
+
+Package: nvidia-libvdpau-dev
+Section: non-free/libdevel
+Architecture: i386 amd64
+Depends: nvidia-libvdpau1 (>= #VERSION#), ${misc:Depends}
+Conflicts: nvidia-glx-dev (< 180.51), nvidia-libvdpau1 (>= #NEXTVER#)
+Provides: nvidia-libvdpau1-dev
+Replaces: nvidia-libvdpau, nvidia-glx-dev (< 180.51)
+Description: NVIDIA vdpau development files
+ The NVIDIA Video Decode and Presentation API for Unix (VDPAU) provides a
+ complete solution for decoding, post-processing, compositing, and displaying
+ compressed or uncompressed video streams.
+ .
+ This package contains the VDPAU development files.
+
+Package: nvidia-kernel-source
+Architecture: i386 amd64
+Depends: debhelper (>> 4.0.0), make, sed (>> 3.0), dpatch (>= 2.0.0), ${misc:Depends}
+Recommends: nvidia-glx (>= #VERSION#), kernel-package (>= 8.082), module-assistant, devscripts
+Conflicts: nvidia-kernel-src
+Replaces: nvidia-kernel-src
+Description: NVIDIA binary kernel module source
+ This package builds the NVIDIA Xorg  binary kernel module 
+ needed  by nvidia-glx. The drivers provide optimized hardware acceleration 
+ of OpenGL applications via a direct-rendering X Server AGP,
+ PCIe, SLI, TV-out, and flat panel displays are also supported.
+ .
+ PLEASE read /usr/share/doc/nvidia-kernel-source/README.Debian for building
+ information.
+ .
+
+Package: libcuda1
+Section: non-free/libs
+Architecture: i386 amd64
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Recommends: nvidia-kernel-#VERSION#
+Suggests: nvidia-kernel-source (>= #VERSION#)
+Replaces: nvidia-glx (<< 185.18.14-2), nvidia-glx-dev (<< 185.18.14-2)
+Description: NVIDIA CUDA runtime library
+ The Compute Unified Device Architecture (CUDA) enables NVIDIA
+ graphics processing units (GPUs) to be used for massively parallel
+ general purpose computation.
+ .
+ This package contains the driver specific runtime library.
+ .
+ Supported NVIDIA devices include GPUs starting from GeForce 8 and Quadro FX
+ series, as well as the Tesla computing processors.
+ .
+ Please see the nvidia-kernel-source package for building the kernel module
+ required by this package. This will provide nvidia-kernel-<version>
+ .
+
+Package: libcuda1-ia32
+Section: non-free/libs
+Architecture: amd64
+Pre-Depends: libc6-i386 (>= 2.9-18)
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Recommends: nvidia-kernel-#VERSION#
+Suggests: nvidia-kernel-source (>= #VERSION#)
+Replaces: nvidia-glx-ia32 (<< 185.18.14-2)
+Description: NVIDIA CUDA runtime library (32-bit)
+ The Compute Unified Device Architecture (CUDA) enables NVIDIA
+ graphics processing units (GPUs) to be used for massively parallel
+ general purpose computation.
+ .
+ This package contains the driver specific runtime library (32-bit).
+ .
+ Supported NVIDIA devices include GPUs starting from GeForce 8 and Quadro FX
+ series, as well as the Tesla computing processors.
+ .
+ Please see the nvidia-kernel-source package for building the kernel module
+ required by this package. This will provide nvidia-kernel-<version>
+ .
+
+Package: libcuda1-dev
+Section: non-free/libdevel
+Architecture: i386 amd64
+Depends: libcuda1 (>= #VERSION#), ${misc:Depends}
+Provides: libcuda-dev
+Replaces: nvidia-glx-dev (<< 185.18.14-2)
+Description: NVIDIA CUDA development files
+ The Compute Unified Device Architecture (CUDA) enables NVIDIA
+ graphics processing units (GPUs) to be used for massively parallel
+ general purpose computation.
+ .
+ This package contains the driver specific NVIDIA CUDA
+ development files.
+ .
+ For more information on this source package visit NVIDIA's CUDA Zone
+ at http://www.nvidia.com/object/cuda_home.html .
+
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.preinst
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.preinst	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.preinst	(revision 5887)
@@ -0,0 +1,116 @@
+#! /bin/sh
+# preinst script for nvidia-glx
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <new-preinst> `install'
+#        * <new-preinst> `install' <old-version>
+#        * <new-preinst> `upgrade' <old-version>
+#        * <old-preinst> `abort-upgrade' <new-version>
+#
+# For details see /usr/share/doc/packaging-manual/
+
+case "$1" in
+    install|upgrade)
+	
+	
+	# Hack right now.
+	# rm -f /usr/X11R6/lib/modules/extensions/libglx.so.1.0.5336  2>/dev/null || true
+	
+	# clean up from old diversions
+	if [ -d /usr/share/nvidia-glx/diversions ]; then
+		rm -f /usr/lib/libGL.so.1
+		rm -f /usr/lib/libGL.so.1.2
+		
+		dpkg-divert --remove --rename  --package nvidia-glx --divert /usr/share/nvidia-glx/diversions/libGL.so.1 /usr/lib/libGL.so.1 > /dev/null
+		dpkg-divert --remove  --rename  --package nvidia-glx --divert /usr/share/nvidia-glx/diversions/libGL.so.1.2 /usr/lib/libGL.so.1.2 > /dev/null
+
+		rm -f /usr/lib/xorg/modules/extensions/libGLcore.a
+		rm -f /usr/lib/xorg/modules/extensions/libglx.a
+		dpkg-divert --remove --rename  --package nvidia-glx --divert /usr/share/nvidia-glx/diversions/libGLcore.a /usr/lib/xorg/modules/extensions/libGLcore.a > /dev/null
+		dpkg-divert --remove --rename   --package nvidia-glx --divert /usr/share/nvidia-glx/diversions/libglx.a /usr/lib/xorg/modules/extensions/libglx.a > /dev/null
+
+		rmdir /usr/share/nvidia-glx/diversions || true;
+		rmdir /usr/share/nvidia-glx || true;
+	fi
+	if [ -d /usr/share/nvidia-glx/diversions ]; then
+
+		rm -f /usr/lib/libGL.so.1
+		rm -f /usr/lib/libGL.so.1.2
+		
+		dpkg-divert --remove  --rename --package nvidia-glx --divert /usr/share/nvidia-glx/diversions/libGL.so.1 /usr/lib/libGL.so.1 > /dev/null
+		dpkg-divert --remove --rename --package nvidia-glx --divert /usr/share/nvidia-glx/diversions/libGL.so.1.2 /usr/lib/libGL.so.1.2 > /dev/null
+
+		rmdir /usr/share/nvidia-glx/diversions || true;
+		rmdir /usr/share/nvidia-glx || true;
+	fi
+	# remove X11R6 diversions
+	
+        if dpkg-divert --list /usr/X11R6/lib/libGL.so.1 | grep 'nvidia-glx' > /dev/null ; then
+		dpkg-divert --remove --rename --package nvidia-glx --divert /usr/X11R6/lib/nvidia/libGL.so.1.xlibmesa /usr/X11R6/lib/libGL.so.1 > /dev/null
+	fi
+	
+	if dpkg-divert --list /usr/X11R6/lib/libGL.so.1.2 | grep 'nvidia-glx' > /dev/null ; then
+		dpkg-divert --remove --rename --package nvidia-glx --divert /usr/X11R6/lib/nvidia/libGL.so.1.2.xlibmesa /usr/X11R6/lib/libGL.so.1.2 > /dev/null
+	fi
+	if dpkg-divert --list /usr/X11R6/lib/modules/extensions/libGLcore.a | grep 'nvidia-glx' > /dev/null ; then
+ 		dpkg-divert --remove --rename --package nvidia-glx --divert /usr/X11R6/lib/nvidia/libGLcore.a.xlibmesa /usr/X11R6/lib/modules/extensions/libGLcore.a > /dev/null
+  	fi
+	if dpkg-divert --list /usr/X11R6/lib/modules/extensions/libglx.a | grep 'nvidia-glx' > /dev/null ; then
+		dpkg-divert --remove --rename --package nvidia-glx --divert /usr/X11R6/lib/nvidia/libglx.a.xlibmesa /usr/X11R6/lib/modules/extensions/libglx.a > /dev/null
+	fi
+	if dpkg-divert --list /usr/X11R6/lib/modules/extensions/libglx.so | grep 'nvidia-glx' > /dev/null ; then
+		dpkg-divert --remove --rename --package nvidia-glx --divert /usr/X11R6/lib/nvidia/libglx.so.xlibmesa /usr/X11R6/lib/modules/extensions/libglx.so > /dev/null
+        fi
+
+        # make sure these diversions don't exist anymore
+        if dpkg-divert --list /usr/lib/libGL.so | grep 'nvidia-glx-dev' > /dev/null ; then
+                dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/lib/nvidia/libGL.so.xlibmesa /usr/lib/libGL.so > /dev/null
+        fi
+        if dpkg-divert --list /usr/lib/libGL.a | grep 'nvidia-glx-dev' > /dev/null ; then
+                dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/lib/nvidia/libGL.a.xlibmesa /usr/lib/libGL.a > /dev/null
+        fi
+        if dpkg-divert --list /usr/X11R6/lib/libGL.so | grep 'nvidia-glx-dev' > /dev/null ; then
+               dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/X11R6/lib/nvidia/libGL.so.xlibmesa /usr/X11R6/lib/libGL.so > /dev/null
+        fi
+        if dpkg-divert --list /usr/X11R6/lib/libGL.so | grep 'nvidia-glx-dev' > /dev/null ; then
+               dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/X11R6/lib/nvidia/libGL.a.xlibmesa /usr/X11R6/lib/libGL.a > /dev/null
+        fi
+	# create new diversion directories
+	if [ ! -d /usr/lib/nvidia ]; then
+		mkdir -p /usr/lib/nvidia || true
+	fi
+
+	# make new diversions
+	dpkg-divert --add --rename --package nvidia-glx --divert /usr/lib/nvidia/libGL.so.1.xlibmesa /usr/lib/libGL.so.1 > /dev/null
+	dpkg-divert --add --rename --package nvidia-glx --divert /usr/lib/nvidia/libGL.so.1.2.xlibmesa /usr/lib/libGL.so.1.2 > /dev/null
+
+	dpkg-divert --add --rename --package nvidia-glx --divert /usr/lib/nvidia/libGLcore.a.xlibmesa /usr/lib/xorg/modules/extensions/libGLcore.a > /dev/null
+	dpkg-divert --add --rename --package nvidia-glx --divert /usr/lib/nvidia/libGLcore.so.xlibmesa /usr/lib/xorg/modules/extensions/libGLcore.so > /dev/null
+	dpkg-divert --add --rename --package nvidia-glx --divert /usr/lib/nvidia/libglx.a.xlibmesa /usr/lib/xorg/modules/extensions/libglx.a > /dev/null
+	dpkg-divert --add --rename --package nvidia-glx --divert /usr/lib/nvidia/libglx.so.xlibmesa /usr/lib/xorg/modules/extensions/libglx.so > /dev/null	
+
+	dpkg-divert --add --rename --package nvidia-glx --divert /usr/lib/nvidia/libGL.so.xlibmesa /usr/lib/libGL.so > /dev/null
+#	dpkg-divert --add --rename --package nvidia-glx --divert /usr/lib/nvidia/libwfb.so.xserver-xorg-core /usr/lib/xorg/modules/libwfb.so > /dev/null
+	;;
+
+    abort-upgrade)
+    ;;
+
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 0
+    ;;
+esac
+
+
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.shlibs
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.shlibs	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.shlibs	(revision 5887)
@@ -0,0 +1,4 @@
+libGL     1 libgl1-mesa-glx | libgl1
+libGLcore 1 nvidia-glx
+libXvMCNVIDIA_dynamic 1 nvidia-glx
+libnvidia-tls 1 nvidia-glx
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.links.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.links.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.links.in	(revision 5887)
@@ -0,0 +1,6 @@
+usr/lib/libGL.so.#VERSION# usr/lib/libGL.so.1
+usr/lib/libGLcore.so.#VERSION# usr/lib/libGLcore.so.1
+usr/lib/libnvidia-tls.so.#VERSION# usr/lib/libnvidia-tls.so.1
+usr/lib/xorg/modules/extensions/libglx.so.#VERSION# usr/lib/xorg/modules/extensions/libglx.so
+usr/lib/libXvMCNVIDIA.so.#VERSION# usr/lib/libXvMCNVIDIA.so.1
+usr/lib/libXvMCNVIDIA.so.#VERSION# usr/lib/libXvMCNVIDIA_dynamic.so.1
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-kernel-source.dirs
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-kernel-source.dirs	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-kernel-source.dirs	(revision 5887)
@@ -0,0 +1,1 @@
+usr/src
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.lintian-overrides.i386.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.lintian-overrides.i386.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.lintian-overrides.i386.in	(revision 5887)
@@ -0,0 +1,12 @@
+nvidia-libvdpau1: shlib-without-PT_GNU_STACK-section usr/lib/libvdpau.so.#VERSION#
+nvidia-libvdpau1: shlib-without-PT_GNU_STACK-section usr/lib/libvdpau_nvidia.so.#VERSION#
+nvidia-libvdpau1: shlib-without-PT_GNU_STACK-section usr/lib/libvdpau_trace.so.#VERSION#
+nvidia-libvdpau1: shlib-with-non-pic-code usr/lib/libvdpau_nvidia.so.#VERSION#
+nvidia-libvdpau1: binary-has-unneeded-section ./usr/lib/libvdpau.so.#VERSION# .comment
+nvidia-libvdpau1: binary-has-unneeded-section ./usr/lib/libvdpau_nvidia.so.#VERSION# .comment
+nvidia-libvdpau1: binary-has-unneeded-section ./usr/lib/libvdpau_nvidia.so.#VERSION# .note
+nvidia-libvdpau1: binary-has-unneeded-section ./usr/lib/libvdpau_trace.so.#VERSION# .comment
+
+# libvdpau.so.1 does dlopen("libvdpau_*.so")
+nvidia-libvdpau1: non-dev-pkg-with-shlib-symlink usr/lib/libvdpau_nvidia.so.#VERSION# usr/lib/libvdpau_nvidia.so
+nvidia-libvdpau1: non-dev-pkg-with-shlib-symlink usr/lib/libvdpau_trace.so.#VERSION# usr/lib/libvdpau_trace.so
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.postrm.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.postrm.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.postrm.in	(revision 5887)
@@ -0,0 +1,60 @@
+#! /bin/sh
+# postrm script for nvidia-glx
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
+# for details, see /usr/share/doc/packaging-manual/
+
+case "$1" in
+    remove|purge)
+        # remove file created by init script
+    	rm /usr/lib/libGL.so || true
+	dpkg-divert --remove --rename --package nvidia-glx --divert /usr/lib/nvidia/libGL.so.1.xlibmesa /usr/lib/libGL.so.1 > /dev/null
+	dpkg-divert --remove --rename --package nvidia-glx --divert /usr/lib/nvidia/libGL.so.1.2.xlibmesa /usr/lib/libGL.so.1.2 > /dev/null
+	
+	dpkg-divert --remove --rename --package nvidia-glx --divert /usr/lib/nvidia/libGLcore.a.xlibmesa /usr/lib/xorg/modules/extensions/libGLcore.a > /dev/null
+	dpkg-divert --remove --rename --package nvidia-glx --divert /usr/lib/nvidia/libGLcore.so.xlibmesa /usr/lib/xorg/modules/extensions/libGLcore.so > /dev/null	
+	dpkg-divert --remove --rename --package nvidia-glx --divert /usr/lib/nvidia/libglx.a.xlibmesa /usr/lib/xorg/modules/extensions/libglx.a > /dev/null
+	dpkg-divert --remove --rename --package nvidia-glx --divert /usr/lib/nvidia/libglx.so.xlibmesa /usr/lib/xorg/modules/extensions/libglx.so > /dev/null
+
+	dpkg-divert --remove --rename --package nvidia-glx --divert /usr/lib/nvidia/libGL.so.xlibmesa /usr/lib/libGL.so > /dev/null
+	rm -f /usr/lib/xorg/modules/extensions/libglx.so.#VERSION# 2> /dev/null || true
+	if [ -d /usr/lib/nvidia ]; then
+		rmdir /usr/lib/nvidia/ || true;
+	fi
+	ldconfig
+		
+    ;;
+    
+    upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+
+
+        ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 0
+
+esac
+
+
+#rm -f /usr/lib/xorg/modules/extensions/libglx.so.#VERSION# 2> /dev/null || true
+
+    
+
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1-ia32.install.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1-ia32.install.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1-ia32.install.in	(revision 5887)
@@ -0,0 +1,1 @@
+#DIRNAME#/usr/lib32/libcuda.so.#VERSION#	usr/lib32
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.docs.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.docs.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.docs.in	(revision 5887)
@@ -0,0 +1,2 @@
+#DIRNAME#/usr/share/doc/NVIDIA_Changelog
+#DIRNAME#/usr/share/doc/README.txt
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1-ia32.dirs
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1-ia32.dirs	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1-ia32.dirs	(revision 5887)
@@ -0,0 +1,1 @@
+usr/lib32
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.lintian-overrides.i386.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.lintian-overrides.i386.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.lintian-overrides.i386.in	(revision 5887)
@@ -0,0 +1,35 @@
+nvidia-glx: shared-lib-without-dependency-information ./usr/lib/libnvidia-tls.so.#VERSION#
+nvidia-glx: shared-lib-without-dependency-information ./usr/lib/tls/libnvidia-tls.so.#VERSION#
+
+nvidia-glx: shlib-with-non-pic-code usr/lib/libGL.so.#VERSION#
+nvidia-glx: shlib-with-non-pic-code usr/lib/libGLcore.so.#VERSION#
+nvidia-glx: shlib-with-non-pic-code usr/lib/libXvMCNVIDIA.so.#VERSION#
+nvidia-glx: shlib-with-non-pic-code usr/lib/libnvidia-tls.so.#VERSION#
+nvidia-glx: shlib-with-non-pic-code usr/lib/nvidia/libnvidia-cfg.so.#VERSION#
+nvidia-glx: shlib-with-non-pic-code usr/lib/tls/libnvidia-tls.so.#VERSION#
+nvidia-glx: shlib-with-non-pic-code usr/lib/xorg/modules/extensions/libglx.so.#VERSION#
+
+nvidia-glx: shlib-without-PT_GNU_STACK-section usr/lib/libGL.so.#VERSION#
+nvidia-glx: shlib-without-PT_GNU_STACK-section usr/lib/libGLcore.so.#VERSION#
+nvidia-glx: shlib-without-PT_GNU_STACK-section usr/lib/libXvMCNVIDIA.so.#VERSION#
+nvidia-glx: shlib-without-PT_GNU_STACK-section usr/lib/libnvidia-tls.so.#VERSION#
+nvidia-glx: shlib-without-PT_GNU_STACK-section usr/lib/nvidia/libnvidia-cfg.so.#VERSION#
+nvidia-glx: shlib-without-PT_GNU_STACK-section usr/lib/tls/libnvidia-tls.so.#VERSION#
+nvidia-glx: shlib-without-PT_GNU_STACK-section usr/lib/xorg/modules/extensions/libglx.so.#VERSION#
+
+nvidia-glx: binary-has-unneeded-section ./usr/lib/libGL.so.#VERSION# .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/libGLcore.so.#VERSION# .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/libXvMCNVIDIA.so.#VERSION# .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/libnvidia-tls.so.#VERSION# .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/nvidia/libnvidia-cfg.so.#VERSION# .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/nvidia/tls_test .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/nvidia/tls_test_dso.so .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/tls/libnvidia-tls.so.#VERSION# .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/xorg/modules/drivers/nvidia_drv.so .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/xorg/modules/extensions/libglx.so.#VERSION# .comment
+
+nvidia-glx: binary-has-unneeded-section ./usr/lib/libGLcore.so.#VERSION# .note
+nvidia-glx: binary-has-unneeded-section ./usr/lib/libXvMCNVIDIA.so.#VERSION# .note
+nvidia-glx: binary-has-unneeded-section ./usr/lib/nvidia/libnvidia-cfg.so.#VERSION# .note
+nvidia-glx: binary-has-unneeded-section ./usr/lib/xorg/modules/drivers/nvidia_drv.so .note
+
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.dirs
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.dirs	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.dirs	(revision 5887)
@@ -0,0 +1,2 @@
+usr/lib32/nvidia
+usr/lib32/tls
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.docs.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.docs.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.docs.in	(revision 5887)
@@ -0,0 +1,2 @@
+#DIRNAME#/usr/share/doc/NVIDIA_Changelog
+#DIRNAME#/usr/share/doc/README.txt
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.install.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.install.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.install.in	(revision 5887)
@@ -0,0 +1,1 @@
+#DIRNAME#/usr/lib/libcuda.so.#VERSION#	usr/lib
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.symbols.amd64
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.symbols.amd64	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.symbols.amd64	(revision 5887)
@@ -0,0 +1,14 @@
+libvdpau.so.1 nvidia-libvdpau1 #MINVER#
+ NV_VDPAU_WRAPPER_ID@Base 180.06
+ pNV_VDPAU_WRAPPER_ID@Base 180.06
+ vdp_device_create_x11@Base 180.06
+libvdpau_nvidia.so nvidia-libvdpau1 #MINVER#
+ vdp_imp_device_create_x11@Base 180.06
+libvdpau_trace.so nvidia-libvdpau1 #MINVER#
+ NV_VDPAU_TRACE_ID@Base 180.06
+ _Z40_vdp_cap_init_planes_adapt_surface_videojPjS_S_@Base 180.06
+ _Z41_vdp_cap_init_planes_adapt_surface_bitmapjPjS_S_@Base 180.06
+ _Z41_vdp_cap_init_planes_adapt_surface_outputjPjS_S_@Base 180.06
+ pNV_VDPAU_TRACE_ID@Base 180.06
+ vdp_trace_device_create_x11@Base 180.06
+ vdp_trace_set_backend_handle@Base 180.06
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.lintian-overrides.amd64.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.lintian-overrides.amd64.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.lintian-overrides.amd64.in	(revision 5887)
@@ -0,0 +1,4 @@
+libcuda1: unstripped-binary-or-object ./usr/lib/libcuda.so.#VERSION#
+
+# libcudart.so.2 does dlopen("libcuda.so")
+libcuda1: non-dev-pkg-with-shlib-symlink usr/lib/libcuda.so.#VERSION# usr/lib/libcuda.so
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.postrm
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.postrm	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.postrm	(revision 5887)
@@ -0,0 +1,48 @@
+#! /bin/sh
+# postrm script for nvidia-glx
+#
+# see: dh_installdeb(1)
+
+set -e
+
+case "$1" in
+    remove|purge)
+#	dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/lib/nvidia/libGL.so.xlibmesa /usr/lib/libGL.so > /dev/null
+#	dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/lib/nvidia/libGL.so.xlibmesa /usr/lib/libGL.so > /dev/null
+        rm /usr/lib/libGL.so || true
+	/etc/init.d/nvidia-glx start || true		
+#	ln -s /usr/lib/nvidia/libGL.so.1.2.xlibmesa /usr/lib/libGL.so
+	
+
+	dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/lib/nvidia/libGL.a.xlibmesa  /usr/lib/libGL.a > /dev/null
+
+#	dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/gl.h /usr/include/GL/gl.h > /dev/null
+#	dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/glx.h /usr/include/GL/glx.h > /dev/null
+#	dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/glxtokens.h /usr/include/GL/glxtokens.h > /dev/null
+
+#	dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/gl.h /usr/include/GL/gl.h > /dev/null
+#	dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/glx.h /usr/include/GL/glx.h > /dev/null
+#	dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/glxtokens.h /usr/include/GL/glxtokens.h > /dev/null
+
+	if [ -d /usr/lib/nvidia/ ]; then
+		rmdir /usr/lib/nvidia || true;
+
+	fi
+
+    ;;
+    
+    upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+
+
+        ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 0
+
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.dirs
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.dirs	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.dirs	(revision 5887)
@@ -0,0 +1,11 @@
+usr/bin
+usr/lib
+usr/share/lintian/overrides
+usr/lib/xorg/modules/drivers
+usr/lib/xorg/modules/extensions
+usr/lib/tls
+usr/lib/nvidia
+usr/share/bug/nvidia-glx
+etc
+etc/default
+etc/init.d
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.preinst.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.preinst.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.preinst.in	(revision 5887)
@@ -0,0 +1,102 @@
+#! /bin/sh
+# preinst script for nvidia-glx
+#
+# see: dh_installdeb(1)
+
+set -e
+
+case "$1" in
+    install|upgrade)
+        # diversion transition
+	if [ -d /usr/share/nvidia-glx/diversions/ ] ; then
+		rm -f /usr/lib/libGL.so 
+	        rm -f /usr/lib/libGL.a 
+        	dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/libGL.so /usr/lib/libGL.so > /dev/null
+		dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/libGL.a  /usr/lib/libGL.a > /dev/null
+
+		rmdir  /usr/share/nvidia-glx/diversions/ || true
+		rmdir /usr/share/nvidia-glx || true
+
+	fi
+	
+	if [ -d /usr/share/nvidia-glx/diversions ] ; then 
+		rm -f /usr/lib/libGL.so 
+		rm -f /usr/lib/libGL.a
+	
+		dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/libGL.so /usr/lib/libGL.so > /dev/null
+		dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/libGL.a /usr/lib/libGL.a > /dev/null
+				
+
+                rmdir  /usr/share/nvidia-glx/diversions || true
+		rmdir /usr/share/nvidia-glx || true
+	fi				                
+						
+
+	if [ ! -d /usr/lib/nvidia ]; then
+		mkdir -p /usr/lib/nvidia || true
+	fi
+
+# to remove old old old gl header diversions
+
+
+	if [ -e /usr/share/nvidia-glx/diversions/gl.h ]; then
+	  if [ -e /usr/include/GL/gl.h ]; then 
+	  	rm -f /usr/include/GL/gl.h /usr/include/GL/glx.h /usr/include/GL/glxtokens.h
+	  fi		
+	  dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/gl.h /usr/include/GL/gl.h > /dev/null
+	  dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/glx.h /usr/include/GL/glx.h > /dev/null
+	  dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/glxext.h /usr/include/GL/glxext.h > /dev/null
+
+	  dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/gl.h /usr/include/GL/gl.h > /dev/null
+	  dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/glx.h /usr/include/GL/glx.h > /dev/null
+	  dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/glxext.h /usr/include/GL/glxext.h > /dev/null
+
+	fi
+        
+	# make sure these diversions don't exist anymore
+	if dpkg-divert --list /usr/lib/libGL.so | grep 'nvidia-glx-dev' > /dev/null ; then 
+		dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/lib/nvidia/libGL.so.xlibmesa /usr/lib/libGL.so > /dev/null
+	fi
+	if dpkg-divert --list /usr/lib/libGL.a | grep 'nvidia-glx-dev' > /dev/null ; then 
+		dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/lib/nvidia/libGL.a.xlibmesa /usr/lib/libGL.a > /dev/null
+	fi
+	if dpkg-divert --list /usr/X11R6/lib/libGL.so | grep 'nvidia-glx-dev' > /dev/null ; then  
+	       dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/X11R6/lib/nvidia/libGL.so.xlibmesa /usr/X11R6/lib/libGL.so > /dev/null
+	fi
+	if dpkg-divert --list /usr/X11R6/lib/libGL.so | grep 'nvidia-glx-dev' > /dev/null ; then 
+		dpkg-divert --remove --rename --package nvidia-glx-dev --divert /usr/X11R6/lib/nvidia/libGL.a.xlibmesa /usr/X11R6/lib/libGL.a > /dev/null	
+	fi
+#	dpkg-divert --add --rename --package nvidia-glx-dev --divert /usr/lib/nvidia/libGL.so.xlibmesa /usr/lib/libGL.so > /dev/null
+#	dpkg-divert --add --rename --package nvidia-glx-dev --divert /usr/lib/nvidia/libGL.so.xlibmesa /usr/lib/libGL.so > /dev/null
+#	rm /usr/lib/libGL.so || true
+	
+#	ln -s /usr/lib/libGL.so.#VERSION# /usr/lib/libGL.so || true
+	
+	
+#	dpkg-divert --add --rename --package nvidia-glx-dev --divert /usr/lib/nvidia/libGL.a.xlibmesa /usr/lib/libGL.a > /dev/null
+
+#	dpkg-divert --add --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/gl.h /usr/include/GL/gl.h > /dev/null
+#	dpkg-divert --add --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/glx.h /usr/include/GL/glx.h > /dev/null
+#	dpkg-divert --add --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/glxtokens.h /usr/include/GL/glxtokens.h > /dev/null
+
+#	dpkg-divert --add --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/gl.h /usr/include/GL/gl.h > /dev/null
+#	dpkg-divert --add --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/glx.h /usr/include/GL/glx.h > /dev/null
+#	dpkg-divert --add --rename --package nvidia-glx-dev --divert /usr/share/nvidia-glx/diversions/glxtokens.h /usr/include/GL/glxtokens.h > /dev/null
+
+  ;;
+
+    abort-upgrade)
+    ;;
+
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 0
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/watch
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/watch	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/watch	(revision 5887)
@@ -0,0 +1,6 @@
+version=3
+
+# The download page is based on javascript modifications that seem unparsable by uscan.
+version=3
+
+# The download page is based on javascript modifications that seem unparsable by uscan.
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-settings.dirs
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-settings.dirs	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-settings.dirs	(revision 5887)
@@ -0,0 +1,2 @@
+usr/bin
+usr/share/doc/nvidia-settings
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-kernel-source.README.Debian.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-kernel-source.README.Debian.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-kernel-source.README.Debian.in	(revision 5887)
@@ -0,0 +1,171 @@
+nvidia-graphics-drivers for Debian
+----------------------------------
+
+
+INTRODUCTION:
+-----------------------------------------------------------------------
+
+Welcome to Debian NVIDIA packages. This document contains notes on  the 
+kernel module interface for the NVIDIA driver offering.
+
+
+KERNEL MODULE INSTRUCTIONS:
+-----------------------------------------------------------------------
+
+There are TWO ways to build the nvidia-kernel package. Which one depends on
+your situation with your kernel.
+
+ METHOD #1: You are running a Debian supplied kernel or built a 
+    linux-headers package along with your own self-built kernel. 
+
+ METHOD #2: You are running your own self-built kernel built from kernel
+    source. 
+
+*** An additional method is to use module-assistant 
+(e.g. module-assistant auto-install nvidia)
+For more information on module-assistant, see it's man page and package
+documentation,
+
+Which method you choose really depends on what kernel headers you wish to
+use, those from a kernel-headers package or those from kernel
+source (from which you built your own kernel). 
+
+As mentioned above, if you are running a Debian supplied kernel you will
+probably want to choose METHOD #1. If you compile your own kernels, METHOD #2.
+
+
+
+PRELIMINARY: 
+- Decide where you want to build your module. By default it 
+will build under /usr/src like other kernel modules but you may choose 
+to build it under your home directory as some people prefer and writing to 
+/usr violates the FHS. 
+
+
+SUPPORT FOR 2.6 KERNELS:
+------------------------
+As of 1.0.5336-1, NVIDIA includes support for a 2.6 kernel. No extra steps are
+required.
+
+
+HOTPLUG SUPPORT:
+------------------------
+As of version 1.0.5336-8 there is hotplug/udev module loading support provided.
+
+
+METHOD #1 Using a linux-headers or kernel-headers package
+***********************************************************************
+
+As root (or using fakeroot)
+1. cd /usr/src 
+   tar xjvf nvidia-kernel.tar.bz2 -C <YOUR BUILD LOCATION>         
+   (It will install in <YOU BUILD LOCATION>/modules) 
+   - or -
+   tar xjvf nvidia-kernel.tar.bz2  (if building in /usr/src) 
+   
+   The standard build location is /usr/src
+   
+2. Find out your kernel version:
+	             
+   uname -r   For example: 2.6.14-2-k7
+				          
+3. Download and install package: linux-headers-2.6.14-2-k7
+   It will install in /usr/src/
+   Note that packages prior to 2.6.12 used the kernel- prefix rather than
+   linux-
+   
+   Make sure your kernel image and headers have matching release numbers to
+   avoid possible problems in packages built from different sources. 
+   
+4. Set some environment variables (if bash is your shell):
+	           
+    export KSRC=/usr/src/linux-headers-2.6.14-2-k7
+    export KVERS=2.6.14-2-k7
+			 		            
+5. Then build nvidia-kernel package:
+	      	           
+   cd <YOUR BUILD LOCATION>/modules/nvidia-kernel
+   debian/rules binary_modules
+   
+(You can also combine step 4 and 5 into one line:
+KSRC=/usr/src/linux-headers-2.6.14-k7 KVERS=2.6.14-4-k7 debian/rules binary_modules)
+				 	      		    	   
+6. Install nvidia-kernel-common on the machine where the module will be
+deployed:
+   
+   If not installed already
+   apt-get install nvidia-kernel-common
+   
+7. Install the nvidia-kernel package:
+	    		     
+   dpkg -i ../nvidia-kernel-2.6.14-2-k7_#VERSION#-1+_.Custom_i386.deb
+   ( or similar filename )
+
+Now see GENERAL NOTES below method #2
+
+METHOD #2: Using your own kernel source headers
+***********************************************************************
+
+To build the nvidia-kernel deb you need to first make sure you have
+kernel-package installed, then do the following:
+
+As root
+1. cd /usr/src
+   tar xjvf nvidia-kernel.tar.bz2 -C <YOUR BUILD LOCATION>         
+   (It will install in <YOU BUILD LOCATION>/modules) 
+   - or -
+   tar xjvf nvidia-kernel.tar.bz2  (if building in /usr/src) 
+
+2. If you are NOT using the default modules location /usr/src/modules
+   then you must set an environment variable that points to your modules
+   location.
+     
+     export MODULE_LOC=<YOUR BUILD LOCATION>/modules
+     
+   This is needed by make-kpkg which is used later. If 
+   <YOUR BUILD LOCATION> is /usr/src there is no need to set this.
+     
+3. Build the modules under MODULE_LOC i.e. <YOU BUILD LOCATION>/modules 
+
+     cd linux (or your kernel source directory)
+     make-kpkg modules_image
+
+4. Install nvidia-kernel-common on the machine where the module will be
+installed:
+
+   apt-get install nvidia-kernel-common
+
+5. Install the nvidia-kernel package:
+     
+     cd <YOUR BUILD LOCATION>    (e.g. /usr/src)
+     dpkg -i nvidia-kernel-KVER*.deb
+
+Notes for method #2: 
+
+- It is advised not to clean the kernel source tree between 
+"make-kpkg kernel_image" and "make-kpkg modules_image". 
+
+- The Riva framebuffer is known to conflict with the nvidia X driver. If you
+are using X it would be wise not to compile it in. The vesa framebuffer is
+known to work in some cases, and not in others. (people have recently been
+having problems with the vesa driver as well) 
+
+GENERAL NOTES:
+
+Also you must add any users who wish to use OpenGL applications to the group
+video. You can do this with:
+
+	adduser username video
+
+Also note for AGP issues and further information please see the NVIDIA
+README file (README.gz) in the nvidia-glx package 
+
+An old nvidia.o might be already loaded (run 'lsmod' to check) so 
+do 'rmmod nvidia.o' to remove the module from memory.
+
+
+For any news on this package check http://people.debian.org/~rdonald and
+http://bugs.debian.org/nvidia-kernel-source
+
+
+ -- Randall Donald <rdonald@debian.org>, Fri, 30 Apr 2004 19:02:04 -0700
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.init.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.init.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.init.in	(revision 5887)
@@ -0,0 +1,118 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides:          nvidia-glx
+# Required-Start:    $remote_fs
+# Required-Stop:     $remote_fs
+# Default-Start:     2 3 4 5
+# Default-Stop:      
+# Short-Description: adjust nVidia TLS libraries
+# Description:       adjust nVidia TLS libraries
+### END INIT INFO
+
+
+
+PATH=/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+. /lib/lsb/init-functions
+
+
+
+
+
+# to force usage or non-usage of TLS libs edit /etc/defaults/nvidia-glx
+[ -e /etc/default/nvidia-glx ] && . /etc/default/nvidia-glx
+
+
+
+
+
+# test if /usr/lib is writable.
+if [ ! -w /usr/lib  ]; then
+  #we can't change anything so just exit.
+  exit 0
+fi  
+
+
+# if nothing has been specified do some guesswork
+if [ -z "$USE_TLS" ]
+then
+  if [ `uname -r | cut -f 1,2 -d.` = "2.6"  ] && \
+     [ -x /usr/lib/nvidia/tls_test ] && \
+     /usr/lib/nvidia/tls_test /usr/lib/nvidia/tls_test_dso.so
+  then
+    USE_TLS=1
+  else
+    USE_TLS=0
+  fi
+fi
+
+setup_links () {
+  # check if all the symlinks are in place
+  if [ "$(readlink -f /usr/lib/tls/libnvidia-tls.so.1)" != /usr/lib/nvidia/libnvidia-tls.so.#VERSION# ]
+  then
+    echo -n "Creating NVIDIA TLS links..."
+    # remove the symlinks
+    rm -f /usr/lib/tls/libGL.so
+    rm -f /usr/lib/tls/libGL.so.*
+    rm -f /usr/lib/tls/libnvidia-tls.so
+    
+    rm -f /usr/lib/tls/libnvidia-tls.so.*
+    rm -f /usr/lib/tls/libGL.la
+
+    #remove old ones
+    rm -f /usr/lib/tls/libGLcore.so.1
+    rm -f /usr/lib/tls/libGLcore.so.*
+    # create the symlinks
+    ln -s /usr/lib/nvidia/libnvidia-tls.so.#VERSION# /usr/lib/tls/libnvidia-tls.so.#VERSION#
+    # reconfigure dynamic linker run-time bindings
+    ldconfig
+    echo " done."
+  fi
+}
+
+remove_links () {
+  # check if all the symlinks are gone or correct
+  if [  -e /usr/lib/tls/libnvidia-tls.so.#VERSION# \
+	-o -e /usr/lib/tls/libnvidia-tls.so \
+	-o -e /usr/lib/tls/libnvidia-tls.so.1 ]
+  then
+    echo -n "Removing NVIDIA TLS links..."
+    # remove the symlinks
+    rm -f /usr/lib/tls/libGL.so
+    rm -f /usr/lib/tls/libGL.so.*
+    rm -f /usr/lib/tls/libGL.la
+    rm -f /usr/lib/tls/libGLcore.so.*    
+    rm -f /usr/lib/tls/libnvidia-tls.so
+    rm -f /usr/lib/tls/libnvidia-tls.so.*
+    # reconfigure dynamic linker run-time bindings
+    ldconfig
+    echo " done."
+  fi
+}
+
+case "$1" in
+  start|restart|reload|force-reload)
+    rm -f  /usr/lib/libGL.so || true 
+    if [ -L /usr/lib/nvidia/libGL.so.xlibmesa ] && [ -d /usr/share/doc/libgl1-mesa-dev ] ; then
+    	ln -s /usr/lib/nvidia/libGL.so.1.2.xlibmesa /usr/lib/libGL.so
+    fi
+    if [ -d /usr/share/doc/nvidia-glx-dev ] ; then
+        ln -s /usr/lib/libGL.so.#VERSION# /usr/lib/libGL.so
+    fi
+    ;;
+
+  stop) 
+    :
+    ;;
+
+  *)
+    echo "Usage: /etc/init.d/nvidia-glx {start|stop|restart|reload|force-reload}"
+    exit 1
+    ;;
+esac
+	
+exit 0
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.symbols
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.symbols	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.symbols	(revision 5887)
@@ -0,0 +1,111 @@
+libcuda.so.1 libcuda1 #MINVER#
+#MISSING: 185.18.04# _nvGpuDebugExportAPI@Base 177.67
+ cuArray3DCreate@Base 177.67
+ cuArray3DGetDescriptor@Base 177.67
+ cuArrayCreate@Base 169.07
+ cuArrayDestroy@Base 169.07
+ cuArrayGetDescriptor@Base 169.07
+ cuCtxAttach@Base 169.07
+ cuCtxCreate@Base 169.07
+ cuCtxDestroy@Base 177.67
+ cuCtxDetach@Base 169.07
+ cuCtxGetDevice@Base 177.67
+ cuCtxPopCurrent@Base 177.67
+ cuCtxPushCurrent@Base 177.67
+ cuCtxSynchronize@Base 169.07
+ cuDeviceComputeCapability@Base 169.07
+ cuDeviceGet@Base 169.07
+ cuDeviceGetAttribute@Base 169.07
+ cuDeviceGetCount@Base 169.07
+ cuDeviceGetName@Base 169.07
+ cuDeviceGetProperties@Base 169.07
+ cuDeviceTotalMem@Base 169.07
+ cuDriverGetVersion@Base 185.18.04
+ cuEventCreate@Base 169.07
+ cuEventDestroy@Base 169.07
+ cuEventElapsedTime@Base 169.07
+ cuEventQuery@Base 169.07
+ cuEventRecord@Base 169.07
+ cuEventSynchronize@Base 169.07
+ cuFuncGetAttribute@Base 185.18.04
+ cuFuncSetBlockShape@Base 169.07
+ cuFuncSetSharedSize@Base 169.07
+ cuGLCtxCreate@Base 177.67
+ cuGLInit@Base 169.07
+ cuGLMapBufferObject@Base 169.07
+ cuGLRegisterBufferObject@Base 169.07
+ cuGLUnmapBufferObject@Base 169.07
+ cuGLUnregisterBufferObject@Base 169.07
+ cuInit@Base 169.07
+ cuLaunch@Base 169.07
+ cuLaunchGrid@Base 169.07
+ cuLaunchGridAsync@Base 169.07
+ cuMemAlloc@Base 169.07
+ cuMemAllocHost@Base 169.07
+ cuMemAllocPitch@Base 169.07
+ cuMemFree@Base 169.07
+ cuMemFreeHost@Base 169.07
+ cuMemGetAddressRange@Base 169.07
+ cuMemGetAttribute@Base 185.18.31
+ cuMemGetInfo@Base 169.07
+ cuMemHostAlloc@Base 185.18.04
+ cuMemHostGetDevicePointer@Base 185.18.04
+ cuMemcpy2D@Base 169.07
+ cuMemcpy2DAsync@Base 169.07
+ cuMemcpy2DUnaligned@Base 169.07
+ cuMemcpy3D@Base 177.67
+ cuMemcpy3DAsync@Base 177.67
+ cuMemcpyAtoA@Base 169.07
+ cuMemcpyAtoD@Base 169.07
+ cuMemcpyAtoH@Base 169.07
+ cuMemcpyAtoHAsync@Base 169.07
+ cuMemcpyDtoA@Base 169.07
+ cuMemcpyDtoD@Base 169.07
+ cuMemcpyDtoH@Base 169.07
+ cuMemcpyDtoHAsync@Base 169.07
+ cuMemcpyHtoA@Base 169.07
+ cuMemcpyHtoAAsync@Base 169.07
+ cuMemcpyHtoD@Base 169.07
+ cuMemcpyHtoDAsync@Base 169.07
+ cuMemsetD16@Base 169.07
+ cuMemsetD2D16@Base 169.07
+ cuMemsetD2D32@Base 169.07
+ cuMemsetD2D8@Base 169.07
+ cuMemsetD32@Base 169.07
+ cuMemsetD8@Base 169.07
+ cuModuleGetFunction@Base 169.07
+ cuModuleGetGlobal@Base 169.07
+ cuModuleGetTexRef@Base 169.07
+ cuModuleLoad@Base 169.07
+ cuModuleLoadData@Base 169.07
+ cuModuleLoadDataEx@Base 180.06
+ cuModuleLoadFatBinary@Base 169.07
+ cuModuleUnload@Base 169.07
+ cuParamSetSize@Base 169.07
+ cuParamSetTexRef@Base 169.07
+ cuParamSetf@Base 169.07
+ cuParamSeti@Base 169.07
+ cuParamSetv@Base 169.07
+ cuStreamCreate@Base 169.07
+ cuStreamDestroy@Base 169.07
+ cuStreamQuery@Base 169.07
+ cuStreamSynchronize@Base 169.07
+ cuTexRefCreate@Base 169.07
+ cuTexRefDestroy@Base 169.07
+ cuTexRefGetAddress@Base 169.07
+ cuTexRefGetAddressMode@Base 169.07
+ cuTexRefGetArray@Base 169.07
+ cuTexRefGetFilterMode@Base 169.07
+ cuTexRefGetFlags@Base 169.07
+ cuTexRefGetFormat@Base 177.67
+ cuTexRefSetAddress2D@Base 185.18.04
+ cuTexRefSetAddress@Base 169.07
+ cuTexRefSetAddressMode@Base 169.07
+ cuTexRefSetArray@Base 169.07
+#MISSING: 177.67# cuTexRefSetCPUAddress@Base 169.07
+ cuTexRefSetFilterMode@Base 169.07
+ cuTexRefSetFlags@Base 169.07
+ cuTexRefSetFormat@Base 169.07
+ cudbgExportAPI@Base 185.18.04
+ gpudbgDebuggerAttached@Base 177.67
+ gpudbgReportDeviceFunctionLaunch@Base 177.67
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/upstream_info
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/upstream_info	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/upstream_info	(revision 5887)
@@ -0,0 +1,69 @@
+eval `dpkg-architecture`
+
+#BASE_VERSION=1.0
+RELEASE=185.18.36
+NEXTVER=185.18.37
+
+if [ "$DEB_BUILD_ARCH" = "amd64" ] ; then
+	BASE_URL=ftp://download.nvidia.com/XFree86/Linux-x86_64/${RELEASE}
+	DIRNAME=NVIDIA-Linux-x86_64-${RELEASE}-pkg2
+	# change this on next version release
+	FILENAME=$DIRNAME.run
+elif [ "$DEB_BUILD_ARCH" = "i386" ] ; then
+	BASE_URL=ftp://download.nvidia.com/XFree86/Linux-x86/${RELEASE}
+	DIRNAME=NVIDIA-Linux-x86-${RELEASE}-pkg0
+	FILENAME="$DIRNAME.run"	
+else
+	echo "huh? dont know about a version of this driver for your architecture."
+	exit 1
+fi
+FILENAME_X86=NVIDIA-Linux-x86-${RELEASE}-pkg0.run
+FILENAME_X86_64=NVIDIA-Linux-x86_64-${RELEASE}-pkg2.run
+DIRNAME_X86=NVIDIA-Linux-x86-${RELEASE}-pkg0
+DIRNAME_X86_64=NVIDIA-Linux-x86_64-${RELEASE}-pkg2
+
+VERSION=${RELEASE}
+UPSTREAMVERSION=${RELEASE}
+URL=${BASE_URL}/${FILENAME}
+
+case "$1" in
+    BASE_VERSION)
+        echo "${BASE_VERSION}"
+        ;;
+    RELEASE)
+        echo "$RELEASE"
+        ;;
+    VERSION)
+        echo "$VERSION"
+        ;;
+    NEXTVER)
+        echo "$NEXTVER"
+        ;;
+    URL)
+        echo "$URL"
+        ;;
+    FILENAME)
+	echo "$FILENAME"
+	;;
+    FILENAME_X86_64)
+	echo "$FILENAME_X86_64"
+	;;
+    FILENAME_X86)
+	echo "$FILENAME_X86"
+	;;
+    DIRNAME_X86_64)
+	echo "$DIRNAME_X86_64"
+	;;
+    DIRNAME_X86)
+	echo "$DIRNAME_X86"
+	;;
+    DIRNAME)
+	echo "$DIRNAME"
+	;;
+    UPSTREAMVERSION)
+    	echo "$UPSTREAMVERSION"
+	;;
+	
+esac
+
+exit 0
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.lintian-overrides.amd64.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.lintian-overrides.amd64.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.lintian-overrides.amd64.in	(revision 5887)
@@ -0,0 +1,22 @@
+nvidia-glx: shared-lib-without-dependency-information ./usr/lib/libnvidia-tls.so.#VERSION#
+nvidia-glx: shared-lib-without-dependency-information ./usr/lib/tls/libnvidia-tls.so.#VERSION#
+
+nvidia-glx: shlib-with-executable-stack usr/lib/libGL.so.#VERSION#
+nvidia-glx: shlib-with-executable-stack usr/lib/libGLcore.so.#VERSION#
+nvidia-glx: shlib-with-executable-stack usr/lib/libXvMCNVIDIA.so.#VERSION#
+nvidia-glx: shlib-with-executable-stack usr/lib/libnvidia-tls.so.#VERSION#
+nvidia-glx: shlib-with-executable-stack usr/lib/nvidia/libnvidia-cfg.so.#VERSION#
+nvidia-glx: shlib-with-executable-stack usr/lib/tls/libnvidia-tls.so.#VERSION#
+nvidia-glx: shlib-with-executable-stack usr/lib/xorg/modules/extensions/libglx.so.#VERSION#
+
+nvidia-glx: binary-has-unneeded-section ./usr/lib/libGL.so.#VERSION# .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/libGLcore.so.#VERSION# .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/libXvMCNVIDIA.so.#VERSION# .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/libnvidia-tls.so.#VERSION# .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/nvidia/libnvidia-cfg.so.#VERSION# .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/nvidia/tls_test .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/nvidia/tls_test_dso.so .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/tls/libnvidia-tls.so.#VERSION# .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/xorg/modules/drivers/nvidia_drv.so .comment
+nvidia-glx: binary-has-unneeded-section ./usr/lib/xorg/modules/extensions/libglx.so.#VERSION# .comment
+
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.symbols.i386
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.symbols.i386	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.symbols.i386	(revision 5887)
@@ -0,0 +1,16 @@
+libvdpau.so.1 nvidia-libvdpau1 #MINVER#
+ NV_VDPAU_WRAPPER_ID@Base 180.06
+ pNV_VDPAU_WRAPPER_ID@Base 180.06
+ vdp_device_create_x11@Base 180.06
+libvdpau_nvidia.so nvidia-libvdpau1 #MINVER#
+ mknod@Base 180.06
+ stat@Base 180.06
+ vdp_imp_device_create_x11@Base 180.06
+libvdpau_trace.so nvidia-libvdpau1 #MINVER#
+ NV_VDPAU_TRACE_ID@Base 180.06
+ _Z40_vdp_cap_init_planes_adapt_surface_videojPjS_S_@Base 180.06
+ _Z41_vdp_cap_init_planes_adapt_surface_bitmapjPjS_S_@Base 180.06
+ _Z41_vdp_cap_init_planes_adapt_surface_outputjPjS_S_@Base 180.06
+ pNV_VDPAU_TRACE_ID@Base 180.06
+ vdp_trace_device_create_x11@Base 180.06
+ vdp_trace_set_backend_handle@Base 180.06
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.postrm
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.postrm	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.postrm	(revision 5887)
@@ -0,0 +1,56 @@
+#! /bin/sh
+# postrm script for nvidia-glx-ia32
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <overwriter>
+#          <overwriter-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove|purge)
+
+	# restore libGL.so* from ia32-libs, diverted to /usr/lib32/nvidia
+	dpkg-divert --remove --rename --package nvidia-glx-ia32 --divert \
+		/usr/lib32/nvidia/libGL.so.ia32-libs \
+		/usr/lib32/libGL.so > /dev/null
+	dpkg-divert --remove --rename --package nvidia-glx-ia32 --divert \
+		/usr/lib32/nvidia/libGL.so.1.ia32-libs \
+		/usr/lib32/libGL.so.1 > /dev/null
+	dpkg-divert --remove --rename --package nvidia-glx-ia32 --divert \
+		/usr/lib32/nvidia/libGL.so.1.2.ia32-libs \
+		/usr/lib32/libGL.so.1.2 > /dev/null
+
+	test -d /usr/lib32/nvidia && \
+		rmdir /usr/lib32/nvidia || true;
+
+    ;;
+
+    upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+    ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 0
+    ;;
+esac
+
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.links.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.links.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.links.in	(revision 5887)
@@ -0,0 +1,3 @@
+usr/lib/libvdpau.so.#VERSION#		usr/lib/libvdpau.so.1
+usr/lib/libvdpau_nvidia.so.#VERSION#	usr/lib/libvdpau_nvidia.so
+usr/lib/libvdpau_trace.so.#VERSION#	usr/lib/libvdpau_trace.so
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/compat
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/compat	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/compat	(revision 5887)
@@ -0,0 +1,1 @@
+4
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.default
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.default	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.default	(revision 5887)
@@ -0,0 +1,16 @@
+##############################################
+# For use with the Debian nvidia-glx package
+#
+# The USE_TLS variable is to force TLS (Thread
+# Local Storage) versioning.
+# This is normally not needed since TLS is detected
+# by the /etc/init.d/nvidia-glx script automatically.
+# For more information about TLS see
+# http://people.redhat.com/drepper/tls.pdf
+
+
+# Uncomment to force the use of NVIDIA TLS libs
+#USE_TLS=1
+
+# Uncomment to force the use of NVIDIA non-TLS libs
+#USE_TLS=0
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.prerm
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.prerm	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx.prerm	(revision 5887)
@@ -0,0 +1,43 @@
+#! /bin/sh
+# prerm script for nvidia-drivers
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <prerm> `remove'
+#        * <old-prerm> `upgrade' <new-version>
+#        * <new-prerm> `failed-upgrade' <old-version>
+#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+#        * <deconfigured's-prerm> `deconfigure' `in-favour'
+#          <package-being-installed> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove|upgrade|deconfigure)
+#       install-info --quiet --remove /usr/info/nvidia-drivers.info.gz
+	rm -f /usr/lib/libGL.so || true
+	/etc/init.d/nvidia-glx start || true
+	;;
+    failed-upgrade)
+        ;;
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/changelog
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/changelog	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/changelog	(revision 5887)
@@ -0,0 +1,956 @@
+nvidia-graphics-drivers (185.18.36-2) unstable; urgency=low
+
+  [ Randall Donald ]
+  * Add 2.6.31 support in conftest.h (closes: #540663) 
+
+ -- Alan Baghumian <alan@technotux.org>  Thu, 05 Nov 2009 19:04:40 -0800
+
+nvidia-graphics-drivers (185.18.36-1) unstable; urgency=low
+
+  * New Upstream (closes: #542889, #543155)
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 24 Aug 2009 15:54:18 -0700
+
+nvidia-graphics-drivers (185.18.31-2) unstable; urgency=low
+
+  * actually build using ia32-libs. thwapp!! 
+
+ -- Randall Donald <rdonald@debian.org>  Fri, 21 Aug 2009 15:21:16 -0700
+
+nvidia-graphics-drivers (185.18.31-1) unstable; urgency=low
+
+  [ Andreas Beckmann ]
+  * New upstream: 185.18.31
+  * use the re-introduced monolithic ia32-libs on amd64 (closes: #536545)
+
+ -- Randall Donald <rdonald@debian.org>  Fri, 21 Aug 2009 12:28:32 -0700 
+
+nvidia-graphics-drivers (185.18.14-2) unstable; urgency=low
+
+  [ Andreas Beckmann ]
+  * do not ship generated files in the source package
+  * nvidia-kernel-source: recommend module-assistant
+  * shlibs cleanup (closes: #533515)
+    - update Build-Depends to include all needed libraries
+    - updates for ia32-libs changes, now separate ia32-lib* packages
+    - let the shlibs system generate all dependencies
+    - debian/nvidia-glx.shlibs: switch to libgl1-mesa-glx | libgl1 (closes:
+      #526463)
+    - debian/nvidia-glx-ia32.shlibs: new file
+  * debian/nvidia-glx-dev.links.in: remove comment (generates unwanted and
+    invalid symlink)
+  * switch to dh_lintian
+  * update lintian overrides for nvidia-glx*
+  * nvidia-libvdpau* cleanup (closes: #519792)
+  * debian/nvidia-libvdpau.shlibs: removed, identical to generated shlibs
+  * rename nvidia-libvdpau* to nvidia-libvdpau1* (closes: #534536)
+  * cleanup leftover files from nvidia-libvdpau-ia32
+  * add overrides and symbol files for nvidia-libvdpau1*
+  * libcuda1, libcuda1-ia32, libcuda-dev: split from their respective
+    nvidia-glx-* packages (closes: #497077)
+  * add overrides and symbol files for libcuda1*
+  * restore support for 2.6.2[78] (closes: #523727)
+  * really put 32 and 64 bit versions of nv-kernel.o in the source package
+    (closes: #533279)
+  * nvidia-kernel-source: abort module compilation with helpful error message
+    if build directory was not cleaned after old package build (closes:
+    #533217, #523947)
+  * debian/nvidia-glx.README.Debian:
+    - update references (closes: #533195)
+    - drop outdated section about header installation (closes: #411894)
+  * debian/nvidia-glx-dev.links.in: removed, contained only a dangling symlink
+  * debian/nvidia-kernel-source.README.Debian.in: fix typo (closes: #434376)
+  * lintian cleanup
+    - nvidia-glx.NEWS, nvidia-kernel-source.NEWS: reindent
+    - debian/watch: add dummy file, website is not parsable
+    - debian/control.in: cosmetics 
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 06 Jul 2009 12:28:32 -0700
+
+nvidia-graphics-drivers (185.18.14-1) unstable; urgency=low
+
+  [ Randall Donald ]
+  * New upstream: (closes: #532568, #532568, #532774)
+  * still only builds via module-assistant
+  
+  [ Harald Dunkel ]
+  * create empty patches.h
+  * new nvidia-libvdpau, nvidia-libvdpau-ia32, nvidia-libvdpau-dev: (closes: #519792)
+
+ -- Randall Donald <rdonald@debian.org>  Wed, 10 Jun 2009 15:35:55 -0700
+
+nvidia-graphics-drivers (180.44-2) unstable; urgency=low
+
+  * Fix the dh_clean issue that just showed up now for some reason
+    and freaked everyone out. (closes: #523716, #523757, #523764)
+
+ -- Randall Donald <rdonald@debian.org>  Sun, 12 Apr 2009 15:11:36 -0700
+
+nvidia-graphics-drivers (180.44-1) unstable; urgency=low
+  
+  [ Randall Donald ]
+  * The "Len is a super guy" release
+  * New upstream (closes: #523583, #523566)
+  * set kernel debhelper compat at 7
+  * change nvidia-glx card support subscription.
+  
+  [ Lennart Sorensen ]
+  * Patch for Debian 2.6.29
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 11 Apr 2009 10:51:06 -0700
+
+nvidia-graphics-drivers (180.29-1) unstable; urgency=low
+
+  [ Harald Dunkel ]
+  * new upstream 
+  * add shlibs information for libvdpau
+  * add 32bit libraries for vdpau
+  * remove debian/temp during cleanup
+	  
+  [ Randall Donald ]
+  * Add vdpau.so links (closes: #513765) 
+  * Yay Lenny released. Now upload to unstable (closes: #514788)
+
+ -- Randall Donald <rdonald@debian.org>  Thu, 19 Jan 2009 12:09:26 -0800
+ 
+nvidia-graphics-drivers (180.22-2) experimental; urgency=low
+
+  * Add VDPAU stuff (closes: #511524) 
+
+ -- Randall Donald <rdonald@debian.org>  Sun, 11 Jan 2009 13:09:26 -0800
+
+nvidia-graphics-drivers (180.22-1) experimental; urgency=low
+
+  * New upstream. (closes: #501668)
+
+ -- Randall Donald <rdonald@debian.org>  Fri, 09 Jan 2009 21:27:48 -0800
+
+nvidia-graphics-drivers (177.82-1) experimental; urgency=low
+
+  * New upstream.
+  * non-SSE re-enabled (closes: #462429)
+  * replace supported cards list with summary. 
+
+ -- Randall Donald <rdonald@debian.org>  Sun, 21 Dec 2008 15:18:21 -0800
+
+nvidia-graphics-drivers (177.80-2) experimental; urgency=low
+
+  * Temporarily remove the Provides on xserver-xorg-video-2 for those using
+  experimental Xorg. (closes: #504585)
+
+ -- Randall Donald <rdonald@debian.org>  Wed, 12 Nov 2008 11:25:41 -0800
+
+nvidia-graphics-drivers (177.80-1) experimental; urgency=low
+
+  * New upstream.  
+
+ -- Randall Donald <rdonald@debian.org>  Tue, 07 Oct 2008 16:10:53 -0700
+
+nvidia-graphics-drivers (173.14.09-5) unstable; urgency=high
+
+  * RC bug:  write *.deb and *.changes file into the same subdirectory 
+  (closes: #493470)
+  * ARCH is undefined, define and use DEB_HOST_ARCH instead
+  (Thanks to Harald Dunkel <harald.dunkel@t-online.de>)
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 01 Sep 2008 10:58:05 -0700
+
+nvidia-graphics-drivers (173.14.09-4) unstable; urgency=medium
+
+  * Fix bashism for nvidia-glx-ia32 (closes: #495478)
+
+ -- Randall Donald <rdonald@debian.org>  Thu, 28 Aug 2008 11:03:15 -0700
+
+nvidia-graphics-drivers (173.14.09-3) unstable; urgency=high
+
+  * Only ship TLS libs. RC bug fix (closes: #441975)
+
+ -- Randall Donald <rdonald@debian.org>  Wed, 23 Jul 2008 09:41:44 -0700
+
+nvidia-graphics-drivers (173.14.09-2) unstable; urgency=low
+
+  * comment out chmod on missing patch directory. (closes: #487624, #487350)
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 23 Jun 2008 10:31:33 -0700
+
+nvidia-graphics-drivers (173.14.09-1) unstable; urgency=low
+
+  * New upstream.
+
+ -- Randall Donald <rdonald@debian.org>  Thu, 19 Jun 2008 17:42:28 -0700
+
+nvidia-graphics-drivers (173.14.05-1) unstable; urgency=low
+
+  [ Randall Donald ]
+  * New upstream. (closes: #483619)
+  * move xen patch to source build patches.
+  * remove 2.6.25 patch, now is upstream.
+  
+  [ Lennart Sorensen ]
+  * new Xen patch for 173.04.05.
+
+  [ Randall Donald ]
+  * add Lsb headers (closes: #479242) 
+
+ -- Randall Donald <rdonald@debian.org>  Tue, 03 Jun 2008 21:14:40 -0700
+
+nvidia-graphics-drivers (169.12-4) unstable; urgency=low
+
+  * Fix permissions on kernel patches directory (closes: #483074) 
+
+ -- Randall Donald <rdonald@debian.org>  Tue, 27 May 2008 20:24:29 -0700
+
+nvidia-graphics-drivers (169.12-3) unstable; urgency=low
+
+  * Make sure wfb diversion is removed. (closes: #482995)
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 26 May 2008 09:27:40 -0700
+
+nvidia-graphics-drivers (169.12-2) unstable; urgency=low
+
+  * Add initial linux-modules-nonfree-2.6 intergration, 2.6.24 only
+  * create storage directories for old patches and don't include in binary
+    packages.
+  * Remove wfb diversion and don't install nvidia's copy.
+  * Patch for 2.6.25 support
+  * Patch to compile on xen enabled kernels (closes: #476504, #481485)
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 24 May 2008 19:57:18 -0700
+
+nvidia-graphics-drivers (169.12-1) unstable; urgency=low
+
+  * fix shlib dep
+  * New upstream.
+  * remove xserver-xorg-core dependency. 
+  * add cuda files (closes: #463776)
+  * add bzip2 to build-depends. (closes: #466139)
+  * add uploaders field that went missing: (closes: #454999, #472448)
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 05 Apr 2008 17:59:56 -0700
+
+nvidia-graphics-drivers (169.09-1) unstable; urgency=low
+
+  * New upstream. (with fan fix!)
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 02 Feb 2008 15:21:28 -0800
+
+nvidia-graphics-drivers (169.07-2) unstable; urgency=low
+
+  * Fix permissions on patches.old (closes: #459848, #460173)
+  * fix root_cmd (closes: #459833)
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 12 Jan 2008 17:10:40 -0800
+
+nvidia-graphics-drivers (169.07-1) unstable; urgency=low
+
+  * New upstream.
+  * Remove ROOT_CMD from debian.binary/rules (closes: 416594)
+  * always include x86_64 nv-kernel.o and detect which to use at kernel-source
+  build time. (closes: #458295, #437128)
+  * move patches dir out of the way.
+  * rename tarball to nvidia-kernel.tar.bz2 for upcoming module packaging.
+    
+ -- Randall Donald <rdonald@debian.org>  Mon, 07 Jan 2008 12:15:15 -0800
+
+nvidia-graphics-drivers (100.14.19-1) unstable; urgency=low
+
+  * new upstream.
+  * Xorg 7.3 compatible (closes: #420177 )
+  * divert libwfb.so and libGLcore.so (closes: #442846, #441400)
+  * change maintainer to packaging team.
+  * change x11-common depends to 1:7.3+2
+  * change provides to xserver-xorg-video-2
+  * remove use of update-modules (closes: #435650)
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 22 Sep 2007 17:16:06 -0700
+
+nvidia-graphics-drivers (100.14.11-1) unstable; urgency=low
+
+  * New upstream. (closes: #430841)
+  * add more GPUs to supported list
+  * Disable Xen patch until it compiles again.
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 02 Jul 2007 17:41:57 -0700
+
+nvidia-graphics-drivers (100.14.09-1) unstable; urgency=low
+
+  * The "use the released version and not the beta drivers" release.
+  * Remove root_cmd from module rules file. (closes: #416594)
+
+ -- Randall Donald <rdonald@debian.org>  Tue, 19 Jun 2007 23:50:31 -0700
+
+nvidia-graphics-drivers (100.14.06-1) unstable; urgency=low
+
+  * New upstream.
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 16 Jun 2007 20:12:55 -0700
+
+nvidia-graphics-drivers (1.0.9755-1) unstable; urgency=low
+
+  * new upstream uploaded to unstable (closes: #415041)
+  * change description to refer only to xorg. (closes: #404599, #402223)
+  * fix Description regarding supported cards. (closes: #416946)
+  * Add Vcs header
+  * Add Xen support (thanks to Marco Nenciarini) (closes: #367326)
+ 
+ -- Randall Donald <rdonald@debian.org>  Sun, 22 Apr 2007 20:26:57 -0700
+
+nvidia-graphics-drivers (1.0.9746-2) experimental; urgency=low
+
+  * include libnvidia-wfb.so.<version> for 8800 peeps.
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 30 Dec 2006 17:00:50 -0800
+
+nvidia-graphics-drivers (1.0.9746-1) experimental; urgency=low
+
+  * new upstream with 8800 support.
+
+ -- Randall Donald <rdonald@debian.org>  Tue, 26 Dec 2006 15:56:06 -0800
+
+nvidia-graphics-drivers (1.0.9631-1) experimental; urgency=low
+
+  * New Upstream. 
+  * Uploaded to experimental while 8776 is being settled for etch.
+
+ -- Randall Donald <rdonald@debian.org>  Thu,  7 Dec 2006 19:38:58 -0800
+
+nvidia-graphics-drivers (1.0.9629-2) unstable; urgency=low
+
+  * remove libGL.so created by init script. (closes: #400129) 
+
+ -- Randall Donald <rdonald@debian.org>  Sat,  2 Dec 2006 13:28:04 -0800
+
+nvidia-graphics-drivers (1.0.9629-1) unstable; urgency=low
+
+  * New Upstream (closes: #397505)
+  * Check for compiler existance (closes: #319544)
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 11 Nov 2006 13:35:39 -0800
+
+nvidia-graphics-drivers (1.0.8776-1) unstable; urgency=medium
+
+  * New upstream.
+  * Includes upstream hotfix for Rapid7 Advisory R7-0025 Buffer Overflow
+    (closes: #393573)
+  * urgency=medium for RC bug fix  
+
+ -- Randall Donald <rdonald@debian.org>  Thu, 19 Oct 2006 18:26:24 -0700
+
+nvidia-graphics-drivers (1.0.8774-7) unstable; urgency=low
+
+  * add diversion of libGL.so to nvidia-glx-ia32 (closes: #393056)
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 14 Oct 2006 13:36:34 -0700
+
+nvidia-graphics-drivers (1.0.8774-6) unstable; urgency=low
+
+  * make init script create libGL.so for nvidia-glx-dev as well
+  as providing the file will get diverted. Also remove the extra
+  nvidia-glx-dev removal diversions not needed anymore. (closes: #392639)
+
+ -- Randall Donald <rdonald@debian.org>  Fri, 13 Oct 2006 10:42:25 -0700
+
+nvidia-graphics-drivers (1.0.8774-5) unstable; urgency=high
+
+  * make sure nvidia-glx-dev diversions are removed and conflict with older
+  versions of -dev
+  * urgency=high for fixing broken upgrade path.
+
+ -- Randall Donald <rdonald@debian.org>  Wed, 11 Oct 2006 11:21:39 -0700
+
+nvidia-graphics-drivers (1.0.8774-4) unstable; urgency=high
+
+  * The problem in #208198 no longer exists but another one has arisen due
+  to unwanted linking against NVIDIA's libGL.so.1. Solution: Have nvidia-glx
+  divert libGL.so and have the init script test for the existence of the 
+  diverted libGL.so.xlibmesa file and then create a /usr/lib/libGL.so symlink
+  to libGL.so.1.2.xlibmesa. Slightly evil but doesn't leave any dangling 
+  symlinks after the init script is called.  (closes: #208198)
+  * High-urgency upload for RC bugfix.
+  * run a version-change to update files in subversion, especially control
+  (closes: #391795)
+  * Clean up X11R6 diversions. (closes: #380433) 
+
+ -- Randall Donald <rdonald@debian.org>  Mon,  9 Oct 2006 16:18:26 -0700
+
+nvidia-graphics-drivers (1.0.8774-3) unstable; urgency=low
+
+  * make nvidia-glx provide xserver-xorg-video-1.0 for xorg 7.1
+    (closes: #385114)
+  * upload xorg 7.1 version to unstable
+
+ -- Randall Donald <rdonald@debian.org>  Thu, 21 Sep 2006 10:44:17 -0700
+
+nvidia-graphics-drivers (1.0.8774-2) experimental; urgency=low
+
+  * make nvidia-glx provide xserver-xorg-video-1.0 for xord 7.1 
+  (closes: #385114) 
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 28 Aug 2006 20:54:34 -0700
+
+nvidia-graphics-drivers (1.0.8774-1) unstable; urgency=low
+
+  * New upstream. (closes: #384608)
+  * uncomment dh_installmodules in module's rules file.
+  * Some important bugs will be fixed with -2
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 28 Aug 2006 20:27:45 -0700
+
+nvidia-graphics-drivers (1.0.8762-2) unstable; urgency=low
+
+  * Have nvidia-glx-dev conflict with mesa-common-dev
+
+ -- Randall Donald <rdonald@debian.org>  Fri,  2 Jun 2006 20:44:38 -0700
+
+nvidia-graphics-drivers (1.0.8762-1) unstable; urgency=low
+
+  * New upstream.
+  * take out dh_strip temporarily while the current strip fails on the
+    nvidia libs. 
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 22 May 2006 15:26:58 -0700
+
+nvidia-graphics-drivers (1.0.8756-4) unstable; urgency=low
+
+  * Include a good nvidia-kernel-source.tar.gz
+
+ -- Randall Donald <rdonald@debian.org>  Tue, 11 Apr 2006 22:48:33 -0700
+
+nvidia-graphics-drivers (1.0.8756-3) unstable; urgency=low
+
+  * Adjust for Xorg7.0 support. Thanks to Rasmus Bog Hansen <moffe@zz9.dk>
+
+ -- Randall Donald <rdonald@debian.org>  Tue, 11 Apr 2006 10:08:13 -0700
+
+nvidia-graphics-drivers (1.0.8756-2) unstable; urgency=low
+
+  * nvidia-glx-dev: Add the missing Provides: libgl-dev (closes: #361589)  
+
+ -- Randall Donald <rdonald@debian.org>  Sun,  9 Apr 2006 09:54:21 -0700
+
+nvidia-graphics-drivers (1.0.8756-1) unstable; urgency=low
+
+  * New upstream (closes: #361352)
+  * Please don't file wishlist bugs after only a few hours.
+  * nvdia-glx-dev: put headers under /usr/include and conflict 
+    with other libgl-dev
+  * nvidia-glx-dev: stricter depends on nvidia-glx (closes: #335539)
+  * nvidia-glx: include libnvidia-cfg (closes: #356800)
+  * lower debhelper level back to sarge ver. 4 level (closes: #356775)
+
+ -- Randall Donald <rdonald@debian.org>  Fri,  7 Apr 2006 18:55:06 -0700
+
+nvidia-graphics-drivers (1.0.8178-3) unstable; urgency=low
+
+  * upload fix for 2.6.16 (closes: #357992, #346355)
+
+ -- Randall Donald <rdonald@debian.org>  Tue, 28 Mar 2006 19:48:59 -0800
+
+nvidia-graphics-drivers (1.0.8178-2.1) unstable; urgency=low
+
+  * add new upstream patch NVIDIA_kernel-1.0-8178-U012206.diff.txt,
+    closes #357992
+
+ -- Harald Dunkel <harald.dunkel@t-online.de>  Fri, 24 Mar 2006 06:51:49 +0100
+
+nvidia-graphics-drivers (1.0.8178-2) unstable; urgency=low
+
+  * very belated change of kernel-image to linux-image in Recommends. 
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 13 Feb 2006 20:26:15 -0800
+
+nvidia-graphics-drivers (1.0.8178-1) unstable; urgency=low
+
+  * Upload to archive.
+
+ -- Randall Donald <rdonald@debian.org>  Tue, 27 Dec 2005 13:46:44 -0800
+
+nvidia-graphics-drivers (1.0.8178-0.1) unstable; urgency=low
+
+  * patch scheme added
+  * applied NVidia's patch NVIDIA_kernel-1.0-8178-U122205
+
+ -- Harald Dunkel <harald.dunkel@t-online.de>  Tue, 27 Dec 2005 15:23:41 +0100
+
+nvidia-graphics-drivers (1.0.8178-0) unstable; urgency=low
+
+  * new upstream
+
+ -- Harald Dunkel <harald.dunkel@t-online.de>  Sat, 24 Dec 2005 09:27:56 +0100
+
+nvidia-graphics-drivers (1.0.8174-1) unstable; urgency=low
+
+  * The "Radiohead" Release ;)
+  * New upstream.
+  * Upload to unstable.
+  * Thanks to Harald Dunkel for initial build.
+  * LEGACY GPUs: If you have a TNT, TNT2, Vanta, GeForce 256, GeForce DDR,
+    Quadro, GeForce2 Pro, GeForce2 GTS, GeForce2 Ultra, GeForce2 Ti,
+    Quadro2Pro, DO NOT INSTALL THIS RELEASE!!! They are not supported.
+  * update NEWS files again.
+  * add Xorg 6.8 to the descriptions to cut down on confusion.
+  * add reference to linux- kernel packages in README.Debian
+  * nvidia-xconfig will be in a separate package.  
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 10 Dec 2005 18:33:37 -0800
+
+nvidia-graphics-drivers (1.0.8174-0) unstable; urgency=low
+
+  * new upstream
+
+ -- Harald Dunkel <harald.dunkel@t-online.de>  Wed,  7 Dec 2005 19:40:50 +0100
+
+nvidia-graphics-drivers (1.0.7676-2) experimental; urgency=low
+
+  * add exit 0 to module postrm (closes: #252018)
+  * add more documentation to /etc/default/nvidia-glx (closes: #280237)
+  * reorganize nvidia-glx init script
+  * remove xserver provides (man this was an old addition) (closes: #329320)
+  * fix nvidia-glx-dev missing links (closes: #336778)
+  * now that sarge is stable upgrade DH_COMPAT to 5 (closes: #336734)
+  * Supply diversion for libglx.so to work with newer xorg.
+
+ -- Randall Donald <rdonald@debian.org>  Wed, 23 Nov 2005 01:20:12 +0000
+
+nvidia-graphics-drivers (1.0.7676-1) experimental; urgency=low
+
+  * New Upstream. (includes fix for GeForce FX 7880)
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 29 Aug 2005 15:48:27 -0700
+
+nvidia-graphics-drivers (1.0.7676-0) experimental; urgency=low
+
+  * new upstream
+
+ -- Harald Dunkel <harald.dunkel@t-online.de>  Mon, 15 Aug 2005 21:53:07 +0200
+
+nvidia-graphics-drivers (1.0.7667-3) experimental; urgency=low
+
+  * back out libGL.so mess until it upgrades properly.
+  * move back to experimental while work is being done on the above.
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 18 Jul 2005 13:08:11 -0700
+
+nvidia-graphics-drivers (1.0.7667-2) unstable; urgency=low
+
+  * fix dangling libGL.so issue. nvidia-glx by itself will now
+    link to the diverted xlibmesa library (closes: #208198, #306533, #272438)
+  * Move nvidia-kernel-source to Suggests in nvidia-glx (closes: #295891)
+  * Modify description to make note of GPUs NOT supported
+  * update module README.Debian to refer to  nvnews.net forum.
+    (closes: #299916)
+  * Update nvidia-kernel-source README.Debian to mention module-assistant
+    and remove mention of patches that are unnecessary and other old
+    references.
+  * change upstream_info to not use bashisms. (closes: #304322)
+  * Update to policy 3.6.2
+  * Move GL headers to /usr/share/nvidia/includes/GL. (closes: #268274)
+  * Remove unnecessary dependancy on libglu
+  * Add NEWS item about using legacy packages.
+  * LEGACY GPUs: If you have a TNT, TNT2, Vanta, GeForce 256, GeForce DDR,
+  Quadro, GeForce2 Pro, GeForce2 GTS, GeForce2 Ultra, GeForce2 Ti, Quadro2Pro,
+  DO NOT INSTALL THIS RELEASE!!! Use the nvidia-glx-legacy and
+  nvidia-kernel-source-legacy packages instead.
+
+ -- Randall Donald <rdonald@debian.org>  Wed, 13 Jul 2005 14:23:26 -0700
+
+nvidia-graphics-drivers (1.0.7667-1) experimental; urgency=low
+
+  * New upstream (closes: #315446)
+  * Thanks again to Harald Dunkel for patch and amd64 testing.
+
+ -- Randall Donald <rdonald@debian.org>  Fri, 24 Jun 2005 22:51:46 -0700
+
+nvidia-graphics-drivers (1.0.7664-2) experimental; urgency=low
+
+  * downgrade the libc6 change back to the version in unstable. 
+    (closes: #315313) 
+
+ -- Randall Donald <rdonald@debian.org>  Tue, 21 Jun 2005 14:07:42 -0700
+
+nvidia-graphics-drivers (1.0.7664-1) experimental; urgency=low
+
+  * The "Commander Cool Drew Hess" release.
+  * New upstream. (Thanks to Harald Dunkel for initial work)
+  * uploaded to experimental due to needing GLIBC_2.3.3
+  and legacy support for some GPU's has been removed. 
+  * Add news item about legacy support.
+  * LEGACY GPUs: If you have a TNT, TNT2, Vanta, GeForce 256, GeForce DDR,
+  Quadro, GeForce2 Pro, GeForce2 GTS, GeForce2 Ultra, GeForce2 Ti, Quadro2Pro,
+  DO NOT INSTALL THIS RELEASE!!!  NVIDIA will be supporting these cards in a
+  special legacy driver (as yet unreleased and not included in this package).
+  So if you have the one of the above listed GPUs,
+  remain with the 1.0.7174-3 release.
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 18 Jun 2005 16:46:48 -0700
+
+nvidia-graphics-drivers (1.0.7664-0) unstable; urgency=low
+
+  * New upstream.
+
+ -- Harald Dunkel <harald.dunkel@t-online.de>  Sat, 11 Jun 2005 22:42:26 +0200
+
+nvidia-graphics-drivers (1.0.7174-3) unstable; urgency=low
+
+  * reinclude nvidia docs 
+
+ -- Randall Donald <rdonald@debian.org>  Thu,  7 Apr 2005 02:39:50 -0700
+
+nvidia-graphics-drivers (1.0.7174-2) unstable; urgency=low
+
+  * use -pkg2 (renamed to pkg0) for lib32 files in nvidia-glx-ia32 package 
+    (closes: #257375)
+
+ -- Randall Donald <rdonald@debian.org>  Tue,  5 Apr 2005 15:10:03 -0700
+
+nvidia-graphics-drivers (1.0.7174-1) unstable; urgency=low
+
+  * New upstream.
+  * add nvidia-glx-ia32 package for amd64 (closes: #257375) 
+
+ -- Randall Donald <rdonald@debian.org>  Fri,  1 Apr 2005 14:54:17 -0800
+
+nvidia-graphics-drivers (1.0.7167-1) unstable; urgency=low
+
+  * New upstream. (closes: #299073)
+  * Disable patching for new version.
+
+ -- Randall Donald <rdonald@debian.org>  Fri, 11 Mar 2005 13:46:57 -0800
+
+nvidia-graphics-drivers (1.0.6629+1-2) unstable; urgency=high
+
+  * Add patches for new (> 2.6.10-rc3-bk13) kernels from
+    minion.de. Thanks to Drew Hess <dhess@bothan.net>
+    (closes: #280224, #281640, #287226)
+  * updated minion patches from 16 Feb 2005
+  * urgency high to get back in to sarge asap. 
+
+ -- Randall Donald <rdonald@debian.org>  Fri, 18 Feb 2005 15:31:00 -0800
+
+nvidia-graphics-drivers (1.0.6629+1-1) unstable; urgency=low
+
+  * change version to allow for new .orig 
+
+ -- Randall Donald <rdonald@debian.org>  Fri, 12 Nov 2004 11:06:00 -0800
+
+nvidia-graphics-drivers (1.0.6629-2) unstable; urgency=low
+
+  * Add amd64 support based on work from
+    Markus Benning <me@w3r3wolf.de> and 
+    Harald Dunkel <harald.dunkel@t-online.de>
+    Thanks guys.
+
+ -- Randall Donald <rdonald@debian.org>  Tue,  9 Nov 2004 23:13:49 -0800
+
+nvidia-graphics-drivers (1.0.6629-1) unstable; urgency=low
+
+  * New upstream.
+  * Undo 2.6.9 patching.
+
+ -- Randall Donald <rdonald@debian.org>  Sat,  6 Nov 2004 23:21:06 -0800
+
+nvidia-graphics-drivers (1.0.6111-2) unstable; urgency=low
+
+  * Provide patches for kernels 2.6.9 and 2.6.10  
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 25 Oct 2004 16:40:05 -0700
+
+nvidia-graphics-drivers (1.0.6111-1) unstable; urgency=low
+
+  * New upstream.
+  * add executable check for update-devfsd.
+
+ -- Randall Donald <rdonald@debian.org>  Thu,  5 Aug 2004 11:43:28 -0700
+
+nvidia-graphics-drivers (1.0.6106-4) unstable; urgency=low
+
+  * Use init script patch by Arthur de Jong <adejong@debian.org>
+    (closes: #243308, #261165)
+  * Add read-only check to init script. (closes: #262176)
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 31 Jul 2004 14:40:59 -0700
+
+nvidia-graphics-drivers (1.0.6106-3) unstable; urgency=low
+
+  * Remove libglx.so.version symlink cleaning now that it is an actual file
+    again. 
+
+ -- Randall Donald <rdonald@debian.org>  Wed, 30 Jun 2004 22:00:09 -0700
+
+nvidia-graphics-drivers (1.0.6106-2) unstable; urgency=low
+
+  * Remove package nvidia-settings so I can use the GPL source in a separate
+    source package in contrib.
+  * Fix nvidia-glx-dev depends on nvidia-glx version.
+
+ -- Randall Donald <rdonald@debian.org>  Wed, 30 Jun 2004 17:48:06 -0700
+
+nvidia-graphics-drivers (1.0.6106-1) unstable; urgency=low
+
+  * New upstream.
+ 	fixed GL library symbols (closes: #242525)
+  * new nvidia-settings package.
+  * remolded TLS handling for new libnvidia-tls.so
+  * sysfs support now builtin, both dpatches disabled. 
+
+ -- Randall Donald <rdonald@debian.org>  Wed, 30 Jun 2004 11:35:08 -0700
+
+nvidia-graphics-drivers (1.0.5336-12) unstable; urgency=low
+
+  * Include newer sysfs patch by Martin Schlemmer <azarah@gentoo.org> which
+    should now create udev nodes. 
+    (closes: #248451) 
+
+ -- Randall Donald <rdonald@debian.org>  Tue, 29 Jun 2004 23:46:22 -0700
+
+nvidia-graphics-drivers (1.0.5336-11) unstable; urgency=low
+
+  * Correct nvidia-glx.shlibs. (closes: #249194)
+  * New init script from Arthur de Jong <adejong@debian.org>. 
+  (closes: #243308, #252569)
+
+ -- Randall Donald <rdonald@debian.org>  Tue,  8 Jun 2004 19:04:42 -0700
+
+nvidia-graphics-drivers (1.0.5336-10) unstable; urgency=low
+
+  * remove immediate exit in nvida-glx init.d so tls detection doesn't exit.
+    (closes: #247188)
+
+ -- Randall Donald <rdonald@debian.org>  Sat,  8 May 2004 13:44:21 -0700
+
+nvidia-graphics-drivers (1.0.5336-9) unstable; urgency=low
+
+  * use corrected 02_pcialias patch from Juergen Kreileder <jk@blackdown.de>
+  
+ -- Randall Donald <rdonald@debian.org>  Fri, 30 Apr 2004 19:38:57 -0700
+
+nvidia-graphics-drivers (1.0.5336-8) unstable; urgency=low
+
+  * Allow for presence of 01_sysfs fuzz in 02_pcialias. (closes: #246773)
+  * Document in n-k-s.README.Debian about IGNORE_PCI_CLASS_DISPLAY 
+    (closes: #246775)
+
+ -- Randall Donald <rdonald@debian.org>  Fri, 30 Apr 2004 18:52:47 -0700
+
+nvidia-graphics-drivers (1.0.5336-7) unstable; urgency=low
+
+  * also detect uppercase "GCC" in compiler detection. (closes: #243988)
+  * version dpatch at >= 2.0.0. (closes: #242465)
+  * patch for hotplugging. Thanks to Juergen Kreileder <jk@blackdown.de>
+    (closes: #239992)
+  * move libtool files to nvidia-glx-dev. (closes: #229110)
+  * apply patch from Joachim Breitner <nomeata@debian.org> for init script.
+  (closes: #243308)
+  * change shlibs to xlibmesa-gl | libgl1
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 17 Apr 2004 16:40:26 -0700
+
+nvidia-graphics-drivers (1.0.5336-6) unstable; urgency=low
+
+  * Introduce a boot init script for TLS detection. With this we can get rid
+    of the debconf prompting. (closes: #234612, #231397, #234323)
+  * Provide patch for sysfs. (closes: #236714, #234150)
+  * depend on dpatch for above patch.
+  * fix typo in clean target for SYSSRC. (closes: #237793)
+  * modify debian.binary/rules for patching and Makefile existance. 
+
+ -- Randall Donald <rdonald@debian.org>  Fri, 19 Mar 2004 14:39:56 -0800
+
+nvidia-graphics-drivers (1.0.5336-5) unstable; urgency=low
+
+  * add SYSRC to clean target. (closes: #232313)
+  * Make GL depends more X 4.3 friendly. (closes: #188189)
+  * pass KPKG_EXTRAV_ARG in for proper 2.6 EXTRAVERSIONing
+  * version kernel-package at >=8.082.
+  * add root_cmd. (closes: #162323) 
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 21 Feb 2004 15:04:42 -0800
+
+nvidia-graphics-drivers (1.0.5336-4) unstable; urgency=low
+
+  * Add glext.h to nvidia-glx-dev. (closes: #231169) 
+  * Add Makefile to clean target in nvidia-kernel-source rules file.
+
+ -- Randall Donald <rdonald@debian.org>  Wed,  4 Feb 2004 16:03:42 -0800
+
+nvidia-graphics-drivers (1.0.5336-3) unstable; urgency=low
+
+  * Depend on libc6-dev for KBUILD building. (closes: #230307) 
+
+ -- Randall Donald <rdonald@debian.org>  Sat, 31 Jan 2004 14:26:02 -0800
+
+nvidia-graphics-drivers (1.0.5336-2) unstable; urgency=low
+
+  * Bypass NVIDIA's select_makefile (closes: #230307)
+  * Remove patch from nvidia-kernel-source Depends and add sed.
+  * Remove dangling libglx.so.VERSION symlink.  
+
+ -- Randall Donald <rdonald@debian.org>  Fri, 30 Jan 2004 14:54:32 -0800
+
+nvidia-graphics-drivers (1.0.5336-1) unstable; urgency=low
+
+  * New upstream.
+  * generate nvidia-kernel changelog from nvidia-graphics-drivers at build.
+  * change nvidia-kernel-source arch to i386. (closes: #229060)
+  * remove 2.6 patch as it is now provided upstream.
+  * create a makefile selector and change the patchlevel detection to be based
+    on KERNEL_VERSION_CODE.
+  * switch back to Makefile.kbuild for 2.6.x.  
+  * remove no longer needed apm patch. (closes: #228487) 
+  * reflect 2.6 changes in nvidia-kernel-source.README.Debian.
+
+ -- Randall Donald <rdonald@debian.org>  Tue, 27 Jan 2004 00:01:32 -0800
+
+nvidia-graphics-drivers (1.0.5328-4) unstable; urgency=low
+
+  * Provide fixed .la files. (closes: #228677) 
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 19 Jan 2004 23:05:20 -0800
+
+nvidia-graphics-drivers (1.0.5328-3) unstable; urgency=low
+
+  * Remove bad/broken LibGL.la files for now. (closes: #228499)
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 19 Jan 2004 14:56:14 -0800
+
+nvidia-graphics-drivers (1.0.5328-2) unstable; urgency=low
+
+  * Fix typo in nvidia-glx.README.Debian
+
+ -- Randall Donald <rdonald@debian.org>  Fri, 16 Jan 2004 23:53:35 -0800
+
+nvidia-graphics-drivers (1.0.5328-1) unstable; urgency=low
+
+  * New upstream. (closes #227066)
+  * Apply 2.6 patch in nvidia-kernel building with env override.
+    Manual patching no longer required!!! (closes: #193379)
+  * Change text of TLS question to a positive tone. (closes: #221963)
+  * Quote $(CC) for a multi word compiler e.g. distcc (closes: #222390)
+  * Change reportbug script to use (lspci --version) instead of which.
+  * Add tls/libGL.so to nvidia-glx (so one can switch with only one step)
+  * Make note about reconfiguring for TLS switching.
+  * fix gcc detection again for kernel compiler. (closes: #227412)
+  * fix typo in nvidia-kernel-source.README.Debian (closes: #226991)
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 22 Dec 2003 01:21:58 -0800
+
+nvidia-graphics-drivers (1.0.4496-10) unstable; urgency=low
+
+  * TLS problems related to installation of TLS libs on 2.4 systems. 
+    Solution: provide a debconf note and set a default based on runtime
+    detection of a TLS/2.6 system. Hopefully this will solve most of the 
+    tls bugs.
+  * Add note about nvidia-kernel-source in nvidia-glx description. 
+    (closes: #220038)
+
+ -- Randall Donald <rdonald@debian.org>  Wed, 19 Nov 2003 13:17:50 -0800
+
+nvidia-graphics-drivers (1.0.4496-9) unstable; urgency=low
+
+  * Change nvidia-kernel-source.README.Debian.in to reflect 2.6 makefile
+    change. (closes: #219003) 
+  * Note the difference in KSRC for 2.6 headers (closes: #220452)
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 17 Nov 2003 20:47:20 -0800
+
+nvidia-graphics-drivers (1.0.4496-8) unstable; urgency=low
+
+  * Correctly install tls libglx. 
+
+ -- Randall Donald <rdonald@debian.org>  Sat,  1 Nov 2003 12:46:04 -0800
+
+nvidia-graphics-drivers (1.0.4496-7) unstable; urgency=low
+
+  * add tls files. (closes: #218408, #218417, #218434, #218487)
+
+ -- Randall Donald <rdonald@debian.org>  Fri, 31 Oct 2003 21:01:18 -0800
+
+nvidia-graphics-drivers (1.0.4496-6) unstable; urgency=low
+
+  * use Makefile.nvidia instead of Makefile.kbuild so the 2.6 support
+    can use kernel-headers. Manual patching still required.
+    README.Debian changed to instruct this change.
+    (closes: #208535, #203369) 
+  * remove wget build-dep from kernel module (closes: #212742)
+  * install kernel module to /lib/modules/KVERS/nvidia. (closes: #207290)
+  * re-fix GCC detection from compile.h (closes: #205871)  
+  
+ -- Randall Donald <rdonald@debian.org>  Mon,  6 Oct 2003 21:41:13 -0700
+
+nvidia-graphics-drivers (1.0.4496-5) unstable; urgency=low
+
+  * Add symlink instruction to nvidia-kernel-source.README.Debian 
+  * Fix patchlevel version detection.  
+  
+ -- Randall Donald <rdonald@debian.org>  Tue, 23 Sep 2003 01:21:29 -0700
+
+nvidia-graphics-drivers (1.0.4496-4) unstable; urgency=low
+
+  * Add Provides: nvidia-kernel-src to nvidia-kernel-source (closes: #211713)
+  * Upload new diversions and 2.6 support to unstable packages.
+  * change == to = in kernel rules file.
+  
+ -- Randall Donald <rdonald@debian.org>  Mon, 22 Sep 2003 15:34:32 -0700
+
+nvidia-graphics-drivers (1.0.4496-3) experimental; urgency=low
+
+  * Fix nvidia-kernel-source.README.Debian about installing
+    nvidia-kernel-common first.
+  * Fix typo in nvidia-kernel-source.README.Debian regarding
+    modules/nvidia-kernel-1.0.4496 directory. (closes: #205684)
+  * Change diversions to stay within /usr/lib and /usr/X11R6/lib.
+    This allows for installs on systems of /usr split between several
+    partitions. (closes: #205955)
+  * Move nvidia-glx dependancy on nvidia-kernel-source to a recommends.
+  * Fix part of gcc 3.3.1 detection that I missed last time. (closes: #205871)
+  * Update nvidia-kernel-source.README.Debian to reflect 2.4.21-4-k7.
+  * Add preliminary 2.6 support. See README.Debian for details (closes: #203369, #193379)
+  * Include CONFIG_APM_MODULE patch file in nvidia-kernel-source. 
+  * Upload to experimental due to diversion changes and preliminary 2.6
+    support 
+  * Incorporate the NMU by martin f. krafft <madduck@debian.org>  
+
+ -- Randall Donald <rdonald@debian.org>  Tue, 26 Aug 2003 14:42:57 -0700
+
+nvidia-graphics-drivers (1.0.4496-2.1) unstable; urgency=low
+
+  * debian.binary/rules used the -a flag to copy the control.template file
+    to debian-binary/control. If the former was a symlink, this would result
+    in the erasure of the template file as the destionation of the copy would
+    also be a symlink to the same file. Removed the -a, now it works just
+    fine.
+      Closes: Bug#206445, Bug#206449
+	      
+ -- martin f. krafft <madduck@debian.org>  Tue, 26 Aug 2003 08:50:46 +0200
+
+nvidia-graphics-drivers (1.0.4496-2) unstable; urgency=low
+
+  * Add email from NVIDIA to copyright file. 
+
+ -- Randall Donald <rdonald@debian.org>  Thu, 31 Jul 2003 15:18:25 -0700
+
+nvidia-graphics-drivers (1.0.4496-1) unstable; urgency=low
+
+  * New upstream. 
+  * include shlibs file.
+  * Re-split nvidia-glx-dev by request.
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 28 Jul 2003 14:18:45 -0700
+
+nvidia-graphics-drivers (1.0.4363-1) unstable; urgency=low
+
+  * Put nvidia drivers into one source package
+  * Move from contrib to non-free
+  * Rename nvidia-kernel-src to nvidia-kernel-source
+  * Include driver files in nvidia-glx and nvidia-kernel-source instead of
+    downloading.
+  * Put nvidia-glx-dev files back into nvidia-glx.
+  * Separate out modules and devfs files into nvidia-kernel-common.
+  * Drop .deb in builder-specified location. Thanks David B Harris
+    <david@eelf.ddts.net> (closes: #192112)
+  * Lose the version number in modules directory. (closes: #199509)
+  * Use automation of versioning based on patches by Marcello Magallon
+    <mmagallo@debian.org>. Thanks. (closes: #192312, #192311) 
+
+ -- Randall Donald <rdonald@debian.org>  Fri,  9 May 2003 14:51:15 -0700
+
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/rules
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/rules	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/rules	(revision 5887)
@@ -0,0 +1,338 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+#
+# Modified to make a template file for a multi-binary package with separated
+# build-arch and build-indep targets  by Bill Allombert 2001
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# This has to be exported to make some magic below work.
+export DH_OPTIONS
+
+DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+base_version:=$(shell sh debian/upstream_info BASE_VERSION)
+release:=$(shell sh debian/upstream_info RELEASE)
+version:=$(shell sh debian/upstream_info VERSION)
+nextver:=$(shell sh debian/upstream_info NEXTVER)
+upstreamversion:=$(shell sh debian/upstream_info UPSTREAMVERSION)
+url:=$(shell sh debian/upstream_info URL)
+dirname:=$(shell sh debian/upstream_info DIRNAME)
+filename:=$(shell sh debian/upstream_info FILENAME)
+filename_x86:=$(shell sh debian/upstream_info FILENAME_X86)
+filename_x86_64:=$(shell sh debian/upstream_info FILENAME_X86_64)
+dirname_x86:=$(shell sh debian/upstream_info DIRNAME_X86)
+dirname_x86_64:=$(shell sh debian/upstream_info DIRNAME_X86_64)
+
+AUTOCLEAN=debian/nvidia-kernel-source.README.Debian \
+debian/nvidia-glx.links \
+debian/nvidia-glx.lintian-overrides.amd64 debian/nvidia-glx.lintian-overrides.i386 \
+debian/nvidia-glx.docs debian/nvidia-glx.examples \
+debian/nvidia-libvdpau1.links debian/nvidia-libvdpau1.docs \
+debian/nvidia-glx.postrm debian/nvidia-glx.init \
+debian/nvidia-glx-ia32.lintian-overrides debian/nvidia-glx-ia32.links \
+debian/nvidia-libvdpau1-ia32.links \
+debian/nvidia-kernel-source.docs debian/nvidia-glx-dev.preinst \
+debian/libcuda1.install debian/libcuda1-ia32.install debian/libcuda1-dev.install \
+debian/libcuda1.links debian/libcuda1-ia32.links \
+debian/libcuda1.lintian-overrides.amd64 debian/libcuda1.lintian-overrides.i386 \
+debian/libcuda1-ia32.lintian-overrides \
+debian/libcuda1-ia32.symbols \
+debian/nvidia-libvdpau1.lintian-overrides.amd64 debian/nvidia-libvdpau1.lintian-overrides.i386 \
+debian/nvidia-libvdpau1-ia32.lintian-overrides \
+debian/nvidia-libvdpau1-ia32.symbols 
+
+AUTOGEN=$(AUTOCLEAN) debian/copyright
+
+
+
+
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+	CFLAGS += -O0
+else
+	CFLAGS += -O2
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+	INSTALL_PROGRAM += -s
+endif
+
+version-change: version-clean debian/control $(AUTOGEN) clean
+
+configure: configure-stamp
+
+.PHONY: configure-stamp
+configure-stamp: version-clean debian/control $(AUTOGEN)
+	dh_testdir
+	# extract both so we can fetch the kernel object code for both arches
+	./${filename_x86} --extract-only
+	./${filename_x86_64} --extract-only
+	if test -d $(CURDIR)/patches; \
+	then \
+		pwd; \
+		ls -al; \
+		cd $(dirname)/usr/src/nv; \
+#		for i in $(CURDIR)/patches/*; \
+#			do patch -p3 <$$i; \
+#		done; \
+	fi
+
+	touch configure-stamp
+
+
+.PHONY: build
+build: configure-stamp build-stamp
+
+.PHONY: build-stamp
+build-stamp:
+	    touch build-stamp
+
+.PHONY: build-kernel
+build-kernel:
+
+.PHONY: build-kernel-stamp 
+build-kernel-stamp: debian.binary/changelog
+	    dh_testroot
+	    dh_testdir
+
+	    # build kernel module source tarball
+	    mkdir -p $(CURDIR)/debian/temp/modules/nvidia-kernel/debian
+	    
+		# Prepare debian files for module package
+	    cp -a $(CURDIR)/debian.binary/* $(CURDIR)/debian/temp/modules/nvidia-kernel/debian
+	    for f in `ls $(CURDIR)/debian.binary` ; do \
+		perl -p \
+		-e 's{#BASE_VERSION#}{$(base_version)}g;' \
+		-e 's{#RELEASE#}{$(release)}g;' \
+		-e 's{#VERSION#}{$(version)}g;' \
+		-e 's{#UPSTREAMVERSION#}{$(upstreamversion)}g;' \
+		-e 's{#URL#}{$(url)}g' \
+		< $(CURDIR)/debian.binary/$$f >		$(CURDIR)/debian/temp/modules/nvidia-kernel/debian/$$f ; \
+		chmod 0644 $(CURDIR)/debian/temp/modules/nvidia-kernel/debian/$$f ; \
+	    done
+
+#	    chmod 775 $(CURDIR)/debian/temp/modules/nvidia-kernel/debian/patches
+	    cp $(CURDIR)/$(dirname)/usr/src/nv/* $(CURDIR)/debian/temp/modules/nvidia-kernel/
+
+		# We don't want these makefiles that don't work with kbuild
+		rm $(CURDIR)/debian/temp/modules/nvidia-kernel/makefile
+
+		# We want both 32 and 64 bit versions of nv-kernel.o
+	cp $(CURDIR)/$(dirname_x86)/usr/src/nv/nv-kernel.o $(CURDIR)/debian/temp/modules/nvidia-kernel/nv-kernel.o.i386
+	cp $(CURDIR)/$(dirname_x86_64)/usr/src/nv/nv-kernel.o $(CURDIR)/debian/temp/modules/nvidia-kernel/nv-kernel.o.x86_64
+	rm -f $(CURDIR)/debian/temp/modules/nvidia-kernel/nv-kernel.o
+
+		# and then make Makefile.kbuild actually use our names
+		sed -i -e 's/nv-kernel.o$$/nv-kernel.o$$(NVARCH)/' $(CURDIR)/debian/temp/modules/nvidia-kernel/Makefile.kbuild
+
+		# We have new conftest files that work purely with kbuild and doesn't require root
+	    cp $(CURDIR)/Makefile $(CURDIR)/conftest.* $(CURDIR)/debian/temp/modules/nvidia-kernel/
+	    cp $(CURDIR)/patches.h $(CURDIR)/debian/temp/modules/nvidia-kernel/
+
+		# Fix permissions
+	    chmod 755 $(CURDIR)/debian/temp/modules/nvidia-kernel/debian/rules
+	    chown -R root:src $(CURDIR)/debian/temp/modules
+	    
+	    tar -jcvf $(CURDIR)/nvidia-kernel.tar.bz2 -C $(CURDIR)/debian/temp modules
+	    rm -rf debian/temp 
+	    touch build-kernel-stamp
+
+.PHONY: clean					
+clean: version-clean
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp build-kernel-stamp configure-stamp
+	dh_clean 
+
+	rm -fr $(dirname_x86) $(dirname_x86_64)  nvidia-kernel.tar.bz2
+	rm -fr debian/temp
+
+	$(MAKE) -f debian/rules debian/control
+
+
+.PHONY: install
+install: build-stamp build-kernel-stamp
+	dh_testdir
+	dh_testroot
+	dh_clean -k 
+	dh_installdirs 
+
+	install -m 644 $(CURDIR)/nvidia-kernel.tar.bz2 $(CURDIR)/debian/nvidia-kernel-source/usr/src
+
+
+	install -m 0644 $(dirname)/usr/X11R6/lib/modules/drivers/nvidia_drv.so \
+		$(CURDIR)/debian/nvidia-glx/usr/lib/xorg/modules/drivers
+
+
+
+	install $(dirname)/usr/X11R6/lib/libXvMCNVIDIA.a $(CURDIR)/debian/nvidia-glx-dev/usr/lib/libXvMCNVIDIA.a;
+	install $(dirname)/usr/X11R6/lib/libXvMCNVIDIA.so.${version} $(CURDIR)/debian/nvidia-glx/usr/lib/libXvMCNVIDIA.so.${version};
+
+
+
+
+	install -m 0644 $(dirname)/usr/include/GL/gl.h \
+		$(CURDIR)/debian/nvidia-glx-dev/usr/include/GL
+	install -m 0644 $(dirname)/usr/include/GL/glext.h \
+		$(CURDIR)/debian/nvidia-glx-dev/usr/include/GL
+
+	install -m 0644 $(dirname)/usr/include/vdpau/vdpau.h \
+		$(CURDIR)/debian/nvidia-libvdpau-dev/usr/include/vdpau
+	install -m 0644 $(dirname)/usr/include/vdpau/vdpau_x11.h \
+		$(CURDIR)/debian/nvidia-libvdpau-dev/usr/include/vdpau
+
+	install -m 0644 $(dirname)/usr/include/GL/glx.h \
+		$(CURDIR)/debian/nvidia-glx-dev/usr/include/GL
+	install -m 0644 $(dirname)/usr/include/GL/glxext.h \
+		$(CURDIR)/debian/nvidia-glx-dev/usr/include/GL
+
+	install -m 0644 $(dirname)/usr/lib/libGL.so.${version} \
+			$(CURDIR)/debian/nvidia-glx/usr/lib
+	install -m 0644 $(dirname)/usr/lib/libGLcore.so.${version} \
+		$(CURDIR)/debian/nvidia-glx/usr/lib
+	install -m 0644 $(dirname)/usr/lib/libvdpau_nvidia.so.${version} \
+			$(CURDIR)/debian/nvidia-libvdpau1/usr/lib
+	install -m 0644 $(dirname)/usr/lib/libvdpau.so.${version} \
+			$(CURDIR)/debian/nvidia-libvdpau1/usr/lib
+	install -m 0644 $(dirname)/usr/lib/libvdpau_trace.so.${version} \
+			$(CURDIR)/debian/nvidia-libvdpau1/usr/lib
+			
+
+
+	sed "s/__GENERATED_BY__/Debian nvidia-graphics-drivers/" $(dirname)/usr/lib/libGL.la | sed "s/__LIBGL_PATH__/\/usr\/lib/" > $(CURDIR)/debian/nvidia-glx-dev/usr/lib/libGL.la
+	# install -m 0644 $(dirname)/usr/lib/libGL.la $(CURDIR)/debian/nvidia-glx/usr/lib/libGL.la
+
+	# TLS (nvidia-tls new for 6106)
+	#install $(dirname)/usr/lib/libnvidia-tls.so.${version} $(CURDIR)/debian/nvidia-glx/usr/lib/
+	install $(dirname)/usr/lib/tls/libnvidia-tls.so.${version} $(CURDIR)/debian/nvidia-glx/usr/lib/
+
+	#install $(dirname)/usr/lib/tls/libnvidia-tls.so.${version} $(CURDIR)/debian/nvidia-glx/usr/lib/nvidia
+	install $(dirname)/usr/lib/tls/libnvidia-tls.so.${version} $(CURDIR)/debian/nvidia-glx/usr/lib/tls/
+		
+
+	#sed "s/__GENERATED_BY__/Debian nvidia-graphics-drivers/" $(dirname)/usr/lib/tls/libGL.la | sed "s/__LIBGL_PATH__/\/usr\/lib\/tls/" > $(CURDIR)/debian/nvidia-glx-dev/usr/lib/nvidia/libGL.la
+	# install -m 0644 $(dirname)/usr/lib/tls/libGL.la $(CURDIR)/debian/nvidia-glx/usr/lib/nvidia/libGL.la
+	
+	install -m 0644 $(dirname)/usr/lib/libnvidia-cfg.so.${version} $(CURDIR)/debian/nvidia-glx/usr/lib/nvidia/
+
+
+	install $(dirname)/usr/X11R6/lib/modules/extensions/libglx.so.${version} $(CURDIR)/debian/nvidia-glx/usr/lib/xorg/modules/extensions/
+#	install $(dirname)/usr/X11R6/lib/modules/libnvidia-wfb.so.${version} $(CURDIR)/debian/nvidia-glx/usr/lib/xorg/modules/
+
+	install $(dirname)/usr/bin/tls_test $(CURDIR)/debian/nvidia-glx/usr/lib/nvidia
+	install $(dirname)/usr/bin/tls_test_dso.so $(CURDIR)/debian/nvidia-glx/usr/lib/nvidia
+
+	if [ "$(DEB_BUILD_ARCH)" = "amd64" ] ; then \
+		install $(dirname)/usr/lib32/libGLcore.so.${version} \
+			$(CURDIR)/debian/nvidia-glx-ia32/usr/lib32 ; \
+		install $(dirname)/usr/lib32/libGL.so.${version} \
+			$(CURDIR)/debian/nvidia-glx-ia32/usr/lib32 ; \
+		install $(dirname)/usr/lib32/libvdpau.so.${version} \
+			$(CURDIR)/debian/nvidia-libvdpau1-ia32/usr/lib32 ; \
+		install $(dirname)/usr/lib32/libvdpau_nvidia.so.${version} \
+			$(CURDIR)/debian/nvidia-libvdpau1-ia32/usr/lib32 ; \
+		install $(dirname)/usr/lib32/libvdpau_trace.so.${version} \
+			$(CURDIR)/debian/nvidia-libvdpau1-ia32/usr/lib32 ; \
+		install $(dirname)/usr/lib32/libnvidia-tls.so.${version} \
+			$(CURDIR)/debian/nvidia-glx-ia32/usr/lib32 ; \
+		install $(dirname)/usr/lib32/tls/libnvidia-tls.so.${version} \
+			$(CURDIR)/debian/nvidia-glx-ia32/usr/lib32/tls ; \
+	fi
+
+	install -m 755 $(dirname)/usr/bin/nvidia-bug-report.sh $(CURDIR)/debian/nvidia-glx/usr/bin/
+	# use separate package
+	#install -m 755 $(dirname)/usr/bin/nvidia-xconfig $(CURDIR)/debian/nvidia-glx/usr/bin/
+
+	# use separate source package instead
+	#install -m 755 $(dirname)/usr/bin/nvidia-settings $(CURDIR)/debian/nvidia-settings/usr/bin/
+	#install -m 644 $(dirname)/usr/share/doc/nvidia-settings-user-guide.txt $(CURDIR)/debian/nvidia-settings/usr/share/doc/nvidia-settings
+
+
+	install $(CURDIR)/script $(CURDIR)/debian/nvidia-glx/usr/share/bug/nvidia-glx
+
+	dh_install -s
+	dh_lintian
+
+
+# Must not depend on anything. This is to be called by
+# binary-arch/binary-multi
+# in another 'make' thread.
+.PHONY: binary-common
+binary-common:
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs 
+	dh_installdocs -s 
+	dh_installexamples
+#	dh_installmenu
+	dh_installdebconf
+#	dh_installlogrotate
+#	dh_installemacsen
+#	dh_installpam
+#	dh_installmime
+	dh_installinit
+#	dh_installcron
+#	dh_installinfo
+	dh_installman
+	dh_link
+#	dh_strip
+	dh_compress -X.h -X README.Debian 
+	dh_fixperms
+#	dh_perl
+#	dh_python
+	dh_makeshlibs -s
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol -s
+	dh_md5sums
+	dh_builddeb -s
+
+
+# Generating control files
+%:	%.in debian/upstream_info
+	perl -p \
+	-e 's{#BASE_VERSION#}{$(base_version)}g;' \
+	-e 's{#RELEASE#}{$(release)}g;' \
+	-e 's{#VERSION#}{$(version)}g;' \
+	-e 's{#NEXTVER#}{$(nextver)}g;' \
+	-e 's{#UPSTREAMVERSION#}{$(upstreamversion)}g;' \
+	-e 's{#DIRNAME#}{$(dirname)}g;' \
+	-e 's{#FILENAME#}{$(filename)}g;' \
+	-e 's{#URL#}{$(url)}g' \
+	< $< > $@
+
+debian.binary/changelog: debian/changelog
+	sed 's/^nvidia-graphics-drivers/nvidia-kernel/g' $< > $@
+
+debian/nvidia-libvdpau1-ia32.symbols: debian/nvidia-libvdpau1.symbols.i386
+	sed 's/nvidia-libvdpau1/nvidia-libvdpau1-ia32/g' $< > $@
+
+debian/nvidia-libvdpau1-ia32.lintian-overrides: debian/nvidia-libvdpau1.lintian-overrides.i386
+	sed 's/^nvidia-libvdpau1:/nvidia-libvdpau1-ia32:/; s%usr/lib/%usr/lib32/%g' $< > $@
+
+debian/libcuda1-ia32.symbols: debian/libcuda1.symbols
+	sed 's/libcuda1/libcuda1-ia32/g' $< > $@
+
+debian/libcuda1-ia32.lintian-overrides: debian/libcuda1.lintian-overrides.i386
+	sed 's/^libcuda1:/libcuda1-ia32:/; s%usr/lib/%usr/lib32/%g' $< > $@
+
+
+# Build architecture dependant packages using the common target.
+.PHONY: binary-arch
+binary-arch: build-stamp build-kernel-stamp install
+	$(MAKE) -f debian/rules binary-common
+
+.PHONY: binary
+binary: binary-arch
+
+.PHONY: version-clean
+version-clean: 
+	rm -f ${AUTOCLEAN} || true
+
+.PHONY: autogen
+autogen: debian/control ${AUTOGEN}
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau-dev.dirs
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau-dev.dirs	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau-dev.dirs	(revision 5887)
@@ -0,0 +1,1 @@
+usr/include/vdpau
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.dirs
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.dirs	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-libvdpau1.dirs	(revision 5887)
@@ -0,0 +1,1 @@
+usr/lib
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.postinst
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.postinst	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-dev.postinst	(revision 5887)
@@ -0,0 +1,14 @@
+#!/bin/sh 
+
+set -e
+
+
+case "$1" in
+	configure)
+		if [ -e /etc/init.d/nvidia-glx ] ; then
+			/etc/init.d/nvidia-glx start
+		fi
+		;;
+esac		
+	
+#DEBHELPER#
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.lintian-overrides.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.lintian-overrides.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-glx-ia32.lintian-overrides.in	(revision 5887)
@@ -0,0 +1,22 @@
+# the diversions are placed there
+nvidia-glx-ia32: package-contains-empty-directory usr/lib32/nvidia/
+
+nvidia-glx-ia32: shared-lib-without-dependency-information ./usr/lib32/libnvidia-tls.so.#VERSION#
+nvidia-glx-ia32: shared-lib-without-dependency-information ./usr/lib32/tls/libnvidia-tls.so.#VERSION#
+
+nvidia-glx-ia32: shlib-with-non-pic-code usr/lib32/libGL.so.#VERSION#
+nvidia-glx-ia32: shlib-with-non-pic-code usr/lib32/libGLcore.so.#VERSION#
+nvidia-glx-ia32: shlib-with-non-pic-code usr/lib32/libnvidia-tls.so.#VERSION#
+nvidia-glx-ia32: shlib-with-non-pic-code usr/lib32/tls/libnvidia-tls.so.#VERSION#
+
+nvidia-glx-ia32: shlib-without-PT_GNU_STACK-section usr/lib32/libGL.so.#VERSION#
+nvidia-glx-ia32: shlib-without-PT_GNU_STACK-section usr/lib32/libGLcore.so.#VERSION#
+nvidia-glx-ia32: shlib-without-PT_GNU_STACK-section usr/lib32/libnvidia-tls.so.#VERSION#
+nvidia-glx-ia32: shlib-without-PT_GNU_STACK-section usr/lib32/tls/libnvidia-tls.so.#VERSION#
+
+nvidia-glx-ia32: binary-has-unneeded-section ./usr/lib32/libGL.so.#VERSION# .comment
+nvidia-glx-ia32: binary-has-unneeded-section ./usr/lib32/libGLcore.so.#VERSION# .note
+nvidia-glx-ia32: binary-has-unneeded-section ./usr/lib32/libGLcore.so.#VERSION# .comment
+nvidia-glx-ia32: binary-has-unneeded-section ./usr/lib32/libnvidia-tls.so.#VERSION# .comment
+nvidia-glx-ia32: binary-has-unneeded-section ./usr/lib32/tls/libnvidia-tls.so.#VERSION# .comment
+
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-kernel-source.NEWS
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-kernel-source.NEWS	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-kernel-source.NEWS	(revision 5887)
@@ -0,0 +1,44 @@
+nvidia-graphics-drivers (1.0.8174-1) unstable; urgency=low
+
+  * LEGACY GPUs: If you have a TNT, TNT2, Vanta, GeForce 256, GeForce DDR,
+  Quadro, GeForce2 Pro, GeForce2 GTS, GeForce2 Ultra, GeForce2 Ti, Quadro2
+  Pro,  DO NOT INSTALL THIS RELEASE!!! They are no longer supported.
+  
+ -- Randall Donald <rdonald@debian.org>  Sat, 10 Dec 2005 00:01:32 -0800
+
+nvidia-graphics-drivers (1.0.7667-2) unstable; urgency=low
+
+  * LEGACY GPUs: If you have a TNT, TNT2, Vanta, GeForce 256, GeForce DDR,
+  Quadro, GeForce2 Pro, GeForce2 GTS, GeForce2 Ultra, GeForce2 Ti, Quadro2
+  Pro,  DO NOT INSTALL THIS RELEASE!!!  Use the nvidia-glx-legacy,
+  nvidia-glx-legacy-dev, nvidia-kernel-source-legacy packages instead.
+  
+ -- Randall Donald <rdonald@debian.org>  Wed, 13 Jun 2005 00:01:32 -0700
+   
+nvidia-graphics-drivers (1.0.7664-1) experimental; urgency=low
+
+  * LEGACY GPUs: If you have a TNT, TNT2, Vanta, GeForce 256, GeForce DDR,
+  Quadro, GeForce2 Pro, GeForce2 GTS, GeForce2 Ultra, GeForce2 Ti, Quadro2 Pro,
+  DO NOT INSTALL THIS RELEASE!!!  NVIDIA will be supporting these cards in a
+  special legacy driver (as yet unreleased and not included in this package). 
+  So if you have the one of the above listed GPUs, 
+  remain with the 1.0.7174-3 release.
+      
+ -- Randall Donald <rdonald@debian.org>  Tue, 21 Jun 2005 00:01:32 -0700
+
+nvidia-graphics-drivers (1.0.5336-1) unstable; urgency=low
+
+  With this upstream release, no more patching for 2.6.0 kernels 
+  is neccessary. 
+      
+ -- Randall Donald <rdonald@debian.org>  Tue, 27 Jan 2004 00:01:32 -0800
+       
+nvidia-graphics-drivers (1.0.5328-1) unstable; urgency=low
+
+  This release now applies the minion.de patch automatically at build time 
+  on nvidia-kernel-source. It should work for both 2.4 and 2.6 kernels. It
+  also provides a fix for some newer Via chips where an oops would occur 
+  upon X startup. To bypass this patching set the DO_NOT_PATCH_NV environment
+  variable.
+
+ -- Randall Donald <rdonald@debian.org>  Mon, 22 Dec 2003 01:21:58 -0800
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-settings.substvars
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-settings.substvars	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/nvidia-settings.substvars	(revision 5887)
@@ -0,0 +1,1 @@
+shlibs:Depends=libatk1.0-0 (>= 1.6.0), libc6 (>= 2.3.2.ds1-4), libglib2.0-0 (>= 2.4.1), libgtk2.0-0 (>= 2.4.3), libpango1.0-0 (>= 1.4.0), libx11-6 | xlibs (>> 4.1.0), libxext6 | xlibs (>> 4.1.0)
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1-ia32.links.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1-ia32.links.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1-ia32.links.in	(revision 5887)
@@ -0,0 +1,2 @@
+usr/lib32/libcuda.so.#VERSION#	usr/lib32/libcuda.so.1
+usr/lib32/libcuda.so.1		usr/lib32/libcuda.so
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.links.in
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.links.in	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/libcuda1.links.in	(revision 5887)
@@ -0,0 +1,2 @@
+usr/lib/libcuda.so.#VERSION#	usr/lib/libcuda.so.1
+usr/lib/libcuda.so.1		usr/lib/libcuda.so
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/copyright
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/copyright	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian/copyright	(revision 5887)
@@ -0,0 +1,191 @@
+This package was debianized by Randall Donald <rdonald@debian.org> on
+Mon, 31 Mar 2003 23:40:05 -0800.
+
+It was downloaded from
+ftp://download.nvidia.com/XFree86/Linux-x86_64/185.18.36/NVIDIA-Linux-x86_64-185.18.36-pkg2.run
+
+Upstream Author: NVIDIA <linux-bugs@nvidia.com>
+
+
+Copyright:
+
+First a note from the README file
+
+Q: Why does NVIDIA not provide rpms anymore?
+
+A: Not every Linux distribution uses rpm, and NVIDIA wanted a single
+   solution that would work across all Linux distributions.  As indicated
+   in the NVIDIA Software License, Linux distributions are welcome to
+   repackage and redistribute the NVIDIA Linux driver in whatever package
+   format they wish.
+
+Furthermore, an email from NVIDIA:
+
+Greetings, Randall!  Comments below:
+
+On 30 Jul 2003, Randall Donald wrote:
+
+> To whom it may concern,
+> 
+> My name is Randall Donald and I am the maintainer for the Debian
+> downloader packages nvidia-glx-src and nvidia-kernel-src. 
+> As stated in your license and the README file 
+> ( "As indicated in the NVIDIA Software License, Linux distributions 
+>   are welcome to repackage and redistribute the NVIDIA Linux driver in 
+>   whatever package format they wish." )
+> I wish to include packages containing the Linux driver files in the Debian archive. 
+> I'd like to know if it is legally permitted to distribute binary kernel modules 
+> compiled from the NVIDIA kernel module source and Debian kernel headers. 
+
+This is fine; thanks for asking.
+
+> I am also wondering if the "No Separation of Components" clause 
+> ( No Separation of Components.  The SOFTWARE is licensed as a
+>   single product.  Its component parts may not be separated for use
+>   on more than one computer, nor otherwise used separately from the
+>   other parts.) applies to splitting the glx driver and kernel module source into
+>  multiple binary packages.
+
+This is also fine.  I believe this section of the license was
+intended to prevent users from doing things like using our Windows
+control panel with a competitor's display driver (that's not actually
+possible, but you get the idea...).  In the case of separating the
+driver into a glx package and a kernel package (like we used to
+do ourselves), this is simply a packaging issue; of course users
+will use the packages together when they install.
+
+Please feel free to redistribute the NVIDIA graphics driver.
+
+Thank you for doing this for the NVIDIA+Debian community!
+
+- Andy
+
+
+
+The NVIDIA Software Licence is as follows.   
+   
+From http://www.nvidia.com/view.asp?IO=nv_swlicense and extracted from the 
+installer: 
+
+
+           License For Customer Use of NVIDIA Software
+
+
+IMPORTANT NOTICE -- READ CAREFULLY: This License For Customer Use of
+NVIDIA Software ("LICENSE") is the agreement which governs use of
+the software of NVIDIA Corporation and its subsidiaries ("NVIDIA")
+downloadable herefrom, including computer software and associated
+printed materials ("SOFTWARE").  By downloading, installing, copying,
+or otherwise using the SOFTWARE, you agree to be bound by the terms
+of this LICENSE.  If you do not agree to the terms of this LICENSE,
+do not download the SOFTWARE.
+
+RECITALS
+
+Use of NVIDIA's products requires three elements: the SOFTWARE, the
+hardware on a graphics controller board, and a personal computer. The
+SOFTWARE is protected by copyright laws and international copyright
+treaties, as well as other intellectual property laws and treaties.
+The SOFTWARE is not sold, and instead is only licensed for use,
+strictly in accordance with this document.  The hardware is protected
+by various patents, and is sold, but this agreement does not cover
+that sale, since it may not necessarily be sold as a package with
+the SOFTWARE.  This agreement sets forth the terms and conditions
+of the SOFTWARE LICENSE only.
+
+1.  DEFINITIONS
+
+1.1  Customer.  Customer means the entity or individual that
+downloads the SOFTWARE.
+
+2.  GRANT OF LICENSE
+
+2.1  Rights and Limitations of Grant.  NVIDIA hereby grants Customer
+the following non-exclusive, non-transferable right to use the
+SOFTWARE, with the following limitations:
+
+2.1.1  Rights.  Customer may install and use one copy of the SOFTWARE
+on a single computer, and except for making one back-up copy of
+the Software, may not otherwise copy the SOFTWARE.  This LICENSE
+of SOFTWARE may not be shared or used concurrently on different
+computers.
+
+2.1.2  Linux Exception.  Notwithstanding the foregoing terms of
+Section 2.1.1, SOFTWARE designed exclusively for use on the Linux
+operating system may be copied and redistributed, provided that
+the binary files thereof are not modified in any way (except for
+unzipping of compressed files).
+
+2.1.3  Limitations.
+
+No Reverse Engineering.  Customer may not reverse engineer,
+decompile, or disassemble the SOFTWARE, nor attempt in any other
+manner to obtain the source code.
+
+No Separation of Components.  The SOFTWARE is licensed as a
+single product.  Its component parts may not be separated for use
+on more than one computer, nor otherwise used separately from the
+other parts.
+
+No Rental.  Customer may not rent or lease the SOFTWARE to someone
+else.
+
+3.  TERMINATION
+
+This LICENSE will automatically terminate if Customer fails to
+comply with any of the terms and conditions hereof.  In such event,
+Customer must destroy all copies of the SOFTWARE and all of its
+component parts.
+
+4.  COPYRIGHT
+
+All title and copyrights in and to the SOFTWARE (including but
+not limited to all images, photographs, animations, video, audio,
+music, text, and other information incorporated into the SOFTWARE),
+the accompanying printed materials, and any copies of the SOFTWARE,
+are owned by NVIDIA, or its suppliers.  The SOFTWARE is protected
+by copyright laws and international treaty provisions.  Accordingly,
+Customer is required to treat the SOFTWARE like any other copyrighted
+material, except as otherwise allowed pursuant to this LICENSE
+and that it may make one copy of the SOFTWARE solely for backup or
+archive purposes.
+
+5.  APPLICABLE LAW
+
+This agreement shall be deemed to have been made in, and shall be
+construed pursuant to, the laws of the State of California.
+
+6.  DISCLAIMER OF WARRANTIES AND LIMITATION ON LIABILITY
+
+6.1  No Warranties.  TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE
+LAW, THE SOFTWARE IS PROVIDED "AS IS" AND NVIDIA AND ITS SUPPLIERS
+DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT
+NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE.
+
+6.2  No Liability for Consequential Damages.  TO THE MAXIMUM
+EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL NVIDIA OR
+ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR
+CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
+DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS
+OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT
+OF THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF NVIDIA HAS
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7.  MISCELLANEOUS 
+
+The United Nations Convention on Contracts for the International
+Sale of Goods is specifically disclaimed.  If any provision of this
+LICENSE is inconsistent with, or cannot be fully enforced under,
+the law, such provision will be construed as limited to the extent
+necessary to be consistent with and fully enforceable under the law.
+This agreement is the final, complete and exclusive agreement between
+the parties relating to the subject matter hereof, and supersedes
+all prior or contemporaneous understandings and agreements relating
+to such subject matter, whether oral or written.  Customer agrees
+that it will not ship, transfer or export the SOFTWARE into any
+country, or use the SOFTWARE in any manner, prohibited by the
+United States Bureau of Export Administration or any export laws,
+restrictions or regulations.  This LICENSE may only be modified in
+writing signed by an authorized officer of NVIDIA.
+
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/mail
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/mail	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/mail	(revision 5887)
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+PATH=/sbin:$PATH
+
+printf "uname -r:\n" >&3 
+echo `uname -a` >&3
+printf "\n\n/proc/version:\n" >&3
+cat /proc/version >&3
+printf "\n\n" >&3
+
+if [ -e /proc/driver/nvidia/version ]; then
+  printf "/proc/driver/nvidia/version:\n" >&3 
+  cat /proc/driver/nvidia/version
+  printf "\n\n" >&3
+fi
+
+if (lspci --version) > /dev/null 2>&1; then
+  LC_ALL=C lspci | grep 'VGA compatible controller:' >&3
+  LC_ALL=C lspci -n | grep 'Class 0300:' >&3
+  printf "\n" >&3
+fi
+
+#if [ -e /etc/X11/XF86Config-4 ]; then
+#  cat /etc/X11/XF86Config-4 >&3
+#  printf "\n" >&3
+#fi
+
+#if [ -e /var/log/XFree86.0.log ]; then
+#  cat /var/log/XFree86.0.log >&3
+#  printf "\n" >&3
+#fi
+
+#ls -d -l /var/log/XFree86.*.log >&3 2> /dev/null
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.save/xenrt
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.save/xenrt	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.save/xenrt	(revision 5887)
@@ -0,0 +1,143 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 05_xenrt by  <mnencia@debian.org>
+##
+## DP: This patch will allow nvidia to be compile and run on Xen or
+## DP: Realtime Preemption enabled kernels.
+
+@DPATCH@
+Index: usr/src/nv/nv-linux.h
+===================================================================
+--- usr/src/nv/nv-linux.h.orig	2007-03-26 15:58:49.000000000 +0200
++++ usr/src/nv/nv-linux.h	2007-03-26 15:59:11.000000000 +0200
+@@ -244,7 +244,7 @@
+  * tiny, and the kernel panics when it is exhausted. try to warn the user that
+  * they need to boost the size of their pool.
+  */
+-#if defined(CONFIG_SWIOTLB) && !defined(GFP_DMA32)
++#if defined(CONFIG_SWIOTLB) && !defined(GFP_DMA32) && !defined(CONFIG_XEN)
+ #define NV_SWIOTLB 1
+ #endif
+ 
+@@ -776,7 +776,10 @@
+ #define NV_VM_INSERT_PAGE(vma, addr, page) \
+     vm_insert_page(vma, addr, page)
+ #endif
+-#if defined(NV_REMAP_PFN_RANGE_PRESENT)
++#if defined(CONFIG_XEN)
++#define NV_REMAP_PAGE_RANGE(from, offset, x...) \
++    io_remap_pfn_range(vma, from, ((offset) >> PAGE_SHIFT), x)
++#elif defined(NV_REMAP_PFN_RANGE_PRESENT)
+ #define NV_REMAP_PAGE_RANGE(from, offset, x...) \
+     remap_pfn_range(vma, from, ((offset) >> PAGE_SHIFT), x)
+ #elif defined(NV_REMAP_PAGE_RANGE_5_PRESENT)
+@@ -788,6 +791,9 @@
+ #define NV_REMAP_PAGE_RANGE(x...) remap_page_range(x)
+ #endif
+ 
++#if !defined(CONFIG_XEN)
++#define phys_to_machine(x) x
++#endif
+ 
+ #define NV_PGD_OFFSET(address, kernel, mm)              \
+    ({                                                   \
+Index: usr/src/nv/nv-vm.c
+===================================================================
+--- usr/src/nv/nv-vm.c.orig	2007-03-26 15:58:49.000000000 +0200
++++ usr/src/nv/nv-vm.c	2007-03-26 15:59:11.000000000 +0200
+@@ -352,6 +352,9 @@
+ 
+ static void nv_flush_caches(void)
+ {
++#if defined(CONFIG_PREEMPT_RT)
++    if(!nv_pat_enabled) return;
++#endif
+ #if defined(KERNEL_2_4)
+     // for 2.4 kernels, just automatically flush the caches and invalidate tlbs
+     nv_execute_on_all_cpus(cache_flush, NULL);
+@@ -502,7 +505,7 @@
+         page_ptr->phys_addr = phys_addr;
+         page_ptr->page_count = NV_GET_PAGE_COUNT(page_ptr);
+         page_ptr->virt_addr = virt_addr;
+-        page_ptr->dma_addr = page_ptr->phys_addr;
++        page_ptr->dma_addr = phys_to_machine(page_ptr->phys_addr);
+ 
+         /* lock the page for dma purposes */
+         nv_lock_page(page_ptr);
+Index: usr/src/nv/nv.c
+===================================================================
+--- usr/src/nv/nv.c.orig	2007-03-26 15:58:49.000000000 +0200
++++ usr/src/nv/nv.c	2007-03-26 15:59:11.000000000 +0200
+@@ -42,8 +42,26 @@
+ 
+ int nv_pat_enabled = 0;
+ 
++/*
++ * disable PAT support if XEN or PREEMPT_RT is configured in kernel
++ */
++
++#if defined(CONFIG_XEN) || defined(CONFIG_PREEMPT_RT)
++static int nv_disable_pat = 1;
++#else
+ static int nv_disable_pat = 0;
++#endif
++
++/*
++ * you can re-enable PAT support for PREEMPT_RT when applying
++ * "nv_disable_pat=0" as kernel parameter for the sake of slightly
++ * better 3D performance but at the expense of higher latencies.
++ * if XEN is configured, then PAT support can't be enabled!
++ */
++
++#if !defined(CONFIG_XEN)
+ NV_MODULE_PARAMETER(nv_disable_pat);
++#endif
+ 
+ #if defined(NVCPU_X86) || defined(NVCPU_X86_64)
+ NvU64 __nv_supported_pte_mask = ~_PAGE_NX;
+Index: usr/src/nv/os-agp.c
+===================================================================
+--- usr/src/nv/os-agp.c.orig	2007-03-26 15:58:49.000000000 +0200
++++ usr/src/nv/os-agp.c	2007-03-26 15:59:11.000000000 +0200
+@@ -286,7 +286,7 @@
+ 
+          page_ptr->phys_addr = (ptr->memory[i] & PAGE_MASK);
+          page_ptr->virt_addr = (unsigned long) __va(page_ptr->phys_addr);
+-         page_ptr->dma_addr  = page_ptr->phys_addr;
++         page_ptr->dma_addr  = phys_to_machine(page_ptr->phys_addr);
+     }
+ 
+     return RM_OK;
+Index: usr/src/nv/os-interface.c
+===================================================================
+--- usr/src/nv/os-interface.c.orig	2007-03-26 15:58:49.000000000 +0200
++++ usr/src/nv/os-interface.c	2007-03-26 15:59:11.000000000 +0200
+@@ -533,6 +533,7 @@
+     MicroSeconds = MilliSeconds * 1000;
+     tm_end.tv_usec = MicroSeconds;
+     tm_end.tv_sec = 0;
++#if !defined(CONFIG_XEN)
+     NV_TIMERADD(&tm_aux, &tm_end, &tm_end);
+ 
+     /* do we have a full jiffie to wait? */
+@@ -570,6 +571,7 @@
+                 MicroSeconds = 0;
+         } while ((jiffies = NV_USECS_TO_JIFFIES(MicroSeconds)) != 0);
+     }
++#endif
+ 
+     if (MicroSeconds > 1000)
+     {
+Index: usr/src/nv/conftest.sh
+===================================================================
+--- usr/src/nv/conftest.sh.orig	2007-03-26 15:58:49.000000000 +0200
++++ usr/src/nv/conftest.sh	2007-03-26 15:59:11.000000000 +0200
+@@ -901,7 +901,8 @@
+         # Check if the target kernel is a Xen kernel. If so, then exit, since
+         # the driver doesn't currently work with Xen.
+         #
+-        RET=1
++        ##MNENCIA## Switched to 0 because we have the xenrt patch :-)
++        RET=0
+         VERBOSE=$6
+         FILE="linux/autoconf.h"
+ 
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/script
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/script	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/script	(revision 5887)
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+PATH=/sbin:$PATH
+
+printf "uname -r:\n" >&3 
+echo `uname -a` >&3
+printf "\n\n/proc/version:\n" >&3
+cat /proc/version >&3
+printf "\n\n" >&3
+
+if [ -e /proc/driver/nvidia/version ]; then
+  printf "/proc/driver/nvidia/version:\n" >&3 
+  cat /proc/driver/nvidia/version
+  printf "\n\n" >&3
+fi
+
+if (lspci --version) > /dev/null 2>&1; then
+  LC_ALL=C lspci | grep 'VGA compatible controller:' >&3
+  LC_ALL=C lspci -n | grep 'Class 0300:' >&3
+  printf "\n" >&3
+fi
+
+#if [ -e /etc/X11/XF86Config-4 ]; then
+#  cat /etc/X11/XF86Config-4 >&3
+#  printf "\n" >&3
+#fi
+
+#if [ -e /var/log/XFree86.0.log ]; then
+#  cat /var/log/XFree86.0.log >&3
+#  printf "\n" >&3
+#fi
+
+#ls -d -l /var/log/XFree86.*.log >&3 2> /dev/null
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/copyright
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/copyright	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/copyright	(revision 5887)
@@ -0,0 +1,195 @@
+This package was debianized by Randall Donald <rconald@debian.org> on
+Sat, 11 Aug 2001 14:27:28 -0700.
+
+It was downloaded from
+#URL#
+
+Upstream Author: NVIDIA <linux-bugs@nvidia.com>
+
+Copyright:
+
+Packaging Scripts Copyright (c) 2003 Randall Donald <rdonald@debian.org>
+Based on packages by Christopher Cheney 
+These scripts are covered under the GNU GPL, the text of the license
+is available here /usr/share/common-licenses/GPL .
+
+
+First a note from the README file
+
+Q: Why does NVIDIA not provide rpms anymore?
+
+A: Not every Linux distribution uses rpm, and NVIDIA wanted a single
+   solution that would work across all Linux distributions.  As indicated
+   in the NVIDIA Software License, Linux distributions are welcome to
+   repackage and redistribute the NVIDIA Linux driver in whatever package
+   format they wish.
+   
+
+Furthermore an email from NVIDIA:
+
+Greetings, Randall!  Comments below:
+
+On 30 Jul 2003, Randall Donald wrote:
+
+> To whom it may concern,
+> 
+> My name is Randall Donald and I am the maintainer for the Debian
+> downloader packages nvidia-glx-src and nvidia-kernel-src. 
+> As stated in your license and the README file 
+> ( "As indicated in the NVIDIA Software License, Linux distributions 
+>   are welcome to repackage and redistribute the NVIDIA Linux driver in 
+>   whatever package format they wish." )
+> I wish to include packages containing the Linux driver files in the Debian archive. 
+> I'd like to know if it is legally permitted to distribute binary kernel modules 
+> compiled from the NVIDIA kernel module source and Debian kernel headers. 
+
+This is fine; thanks for asking.
+
+> I am also wondering if the "No Separation of Components" clause 
+> ( No Separation of Components.  The SOFTWARE is licensed as a
+>   single product.  Its component parts may not be separated for use
+>   on more than one computer, nor otherwise used separately from the
+>   other parts.) applies to splitting the glx driver and kernel module source into
+>  multiple binary packages.
+
+This is also fine.  I believe this section of the license was
+intended to prevent users from doing things like using our Windows
+control panel with a competitor's display driver (that's not actually
+possible, but you get the idea...).  In the case of separating the
+driver into a glx package and a kernel package (like we used to
+do ourselves), this is simply a packaging issue; of course users
+will use the packages together when they install.
+
+Please feel free to redistribute the NVIDIA graphics driver.
+
+Thank you for doing this for the NVIDIA+Debian community!
+
+- Andy
+
+
+---
+
+License:
+http://www.nvidia.com/view.asp?IO=nv_swlicense
+
+       License For Customer Use of NVIDIA Software
+
+
+IMPORTANT NOTICE -- READ CAREFULLY: This License For Customer Use of
+NVIDIA Software ("LICENSE") is the agreement which governs use of
+the software of NVIDIA Corporation and its subsidiaries ("NVIDIA")
+downloadable herefrom, including computer software and associated
+printed materials ("SOFTWARE").  By downloading, installing, copying,
+or otherwise using the SOFTWARE, you agree to be bound by the terms
+of this LICENSE.  If you do not agree to the terms of this LICENSE,
+do not download the SOFTWARE.
+
+RECITALS
+
+Use of NVIDIA's products requires three elements: the SOFTWARE, the
+hardware on a graphics controller board, and a personal computer. The
+SOFTWARE is protected by copyright laws and international copyright
+treaties, as well as other intellectual property laws and treaties.
+The SOFTWARE is not sold, and instead is only licensed for use,
+strictly in accordance with this document.  The hardware is protected
+by various patents, and is sold, but this agreement does not cover
+that sale, since it may not necessarily be sold as a package with
+the SOFTWARE.  This agreement sets forth the terms and conditions
+of the SOFTWARE LICENSE only.
+
+1.  DEFINITIONS
+
+1.1  Customer.  Customer means the entity or individual that
+downloads the SOFTWARE.
+
+2.  GRANT OF LICENSE
+
+2.1  Rights and Limitations of Grant.  NVIDIA hereby grants Customer
+the following non-exclusive, non-transferable right to use the
+SOFTWARE, with the following limitations:
+
+2.1.1  Rights.  Customer may install and use one copy of the SOFTWARE
+on a single computer, and except for making one back-up copy of
+the Software, may not otherwise copy the SOFTWARE.  This LICENSE
+of SOFTWARE may not be shared or used concurrently on different
+computers.
+
+2.1.2  Linux Exception.  Notwithstanding the foregoing terms of
+Section 2.1.1, SOFTWARE designed exclusively for use on the Linux
+operating system may be copied and redistributed, provided that
+the binary files thereof are not modified in any way (except for
+unzipping of compressed files).
+
+2.1.3  Limitations.
+
+No Reverse Engineering.  Customer may not reverse engineer,
+decompile, or disassemble the SOFTWARE, nor attempt in any other
+manner to obtain the source code.
+
+No Separation of Components.  The SOFTWARE is licensed as a
+single product.  Its component parts may not be separated for use
+on more than one computer, nor otherwise used separately from the
+other parts.
+
+No Rental.  Customer may not rent or lease the SOFTWARE to someone
+else.
+
+3.  TERMINATION
+
+This LICENSE will automatically terminate if Customer fails to
+comply with any of the terms and conditions hereof.  In such event,
+Customer must destroy all copies of the SOFTWARE and all of its
+component parts.
+
+4.  COPYRIGHT
+
+All title and copyrights in and to the SOFTWARE (including but
+not limited to all images, photographs, animations, video, audio,
+music, text, and other information incorporated into the SOFTWARE),
+the accompanying printed materials, and any copies of the SOFTWARE,
+are owned by NVIDIA, or its suppliers.  The SOFTWARE is protected
+by copyright laws and international treaty provisions.  Accordingly,
+Customer is required to treat the SOFTWARE like any other copyrighted
+material, except as otherwise allowed pursuant to this LICENSE
+and that it may make one copy of the SOFTWARE solely for backup or
+archive purposes.
+
+5.  APPLICABLE LAW
+
+This agreement shall be deemed to have been made in, and shall be
+construed pursuant to, the laws of the State of California.
+
+6.  DISCLAIMER OF WARRANTIES AND LIMITATION ON LIABILITY
+
+6.1  No Warranties.  TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE
+LAW, THE SOFTWARE IS PROVIDED "AS IS" AND NVIDIA AND ITS SUPPLIERS
+DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT
+NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE.
+
+6.2  No Liability for Consequential Damages.  TO THE MAXIMUM
+EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL NVIDIA OR
+ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR
+CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
+DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS
+OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT
+OF THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF NVIDIA HAS
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7.  MISCELLANEOUS 
+
+The United Nations Convention on Contracts for the International
+Sale of Goods is specifically disclaimed.  If any provision of this
+LICENSE is inconsistent with, or cannot be fully enforced under,
+the law, such provision will be construed as limited to the extent
+necessary to be consistent with and fully enforceable under the law.
+This agreement is the final, complete and exclusive agreement between
+the parties relating to the subject matter hereof, and supersedes
+all prior or contemporaneous understandings and agreements relating
+to such subject matter, whether oral or written.  Customer agrees
+that it will not ship, transfer or export the SOFTWARE into any
+country, or use the SOFTWARE in any manner, prohibited by the
+United States Bureau of Export Administration or any export laws,
+restrictions or regulations.  This LICENSE may only be modified in
+writing signed by an authorized officer of NVIDIA.
+
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/devfs.devices
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/devfs.devices	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/devfs.devices	(revision 5887)
@@ -0,0 +1,7 @@
+# devices file
+# format: name [bc] major minor uid gid mode
+nvidia0		c	195	0	root	video	0660
+nvidia1		c	195	1	root	video	0660
+nvidia2		c	195	2	root	video	0660
+nvidia3		c	195	3	root	video	0660
+nvidiactl	c	195	255	root	video	0660
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/override.template
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/override.template	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/override.template	(revision 5887)
@@ -0,0 +1,2 @@
+nvidia-kernel-#KVERS#: mknod-in-maintainer-script postinst:36
+nvidia-kernel-#KVERS#: mknod-in-maintainer-script postinst:45
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/control.template
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/control.template	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/control.template	(revision 5887)
@@ -0,0 +1,21 @@
+Source: nvidia-kernel
+Section: non-free/x11
+Priority: optional
+Maintainer: Randall Donald <rdonald@debian.org>
+Build-Depends: debhelper (>> 3.0.0), make, libc6-dev
+Standards-Version: 3.6.0
+
+Package: nvidia-kernel-#KVERS#
+Architecture: i386 amd64
+Provides: nvidia-kernel-#VERSION#
+Depends: nvidia-kernel-common (>= 20051028+1-0.1)
+Recommends: linux-image-#KVERS#
+Description: NVIDIA binary kernel module for Linux #KVERS#
+ These Xorg binary drivers provide optimized hardware acceleration of 
+ OpenGL applications via a direct-rendering X Server. 
+ .
+ This package contains the NVIDIA binary kernel module needed by
+ nvidia-glx.
+ .
+ For more information on this source package visit NVIDIA's homepage
+ at http://www.nvidia.com/ .
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/rules
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/rules	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/rules	(revision 5887)
@@ -0,0 +1,105 @@
+#!/usr/bin/make -f
+
+
+CFLAGS = -Wall -g
+ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
+	CFLAGS += -O0
+else
+	CFLAGS += -O2
+endif
+ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+	MAKEFLAGS += -j$(NUMJOBS)
+endif
+
+DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+
+# Prefix of the target package name
+PACKAGE		= nvidia-kernel
+
+-include /usr/share/modass/include/generic.make
+-include /usr/share/modass/include/common-rules.make
+
+configure:
+	sed 's/#KVERS#/$(KVERS)/g' debian/control.template > $(CURDIR)/debian/control
+	sed 's/#KVERS#/$(KVERS)/g' debian/dirs.template > $(CURDIR)/debian/dirs
+	sed 's/#KVERS#/$(KVERS)/g' debian/override.template > $(CURDIR)/debian/override
+
+binary-modules: configure
+	dh_testroot
+
+	dh_prep
+
+ifneq (,$(wildcard makefile))
+	@echo "ERROR: unclean build directory from older version found, please clean first:"
+	@echo "    module-assistant clean nvidia"
+	@exit 1
+endif
+
+	# Build the modules
+	$(MAKE) -C . LINUXDIR=$(KSRC) KVERREL=$(KVERS)
+
+	# Install the modules
+	dh_installdirs
+	install -m 0644 $(CURDIR)/debian/override $(CURDIR)/debian/nvidia-kernel-$(KVERS)/usr/share/lintian/overrides/nvidia-kernel-$(KVERS)
+	install -m 0644 $(CURDIR)/nvidia.ko $(CURDIR)/debian/nvidia-kernel-$(KVERS)/lib/modules/$(KVERS)/nvidia/nvidia.ko ; \
+
+	dh_installdocs
+	dh_installmodules
+	dh_installchangelogs
+	dh_installmodules
+	dh_strip
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_gencontrol -- -v$(VERSION)
+	dh_md5sums
+	dh_builddeb  --destdir=$(KPKG_DEST_DIR)
+	dh_prep
+
+clean:   unpatch
+	if [ -f $(CURDIR)/debian/control.template ]; then \
+		cp  $(CURDIR)/debian/control.template $(CURDIR)/debian/control; \
+	fi
+
+	dh_testroot
+	rm -f build-stamp configure-stamp
+
+
+	$(MAKE) clean SYSSRC=$(KSRC) -C $(CURDIR)/$(dirname) -f Makefile $(KPKG_EXTRAV_ARG)
+        
+	-rm $(CURDIR)/$(dirname)/gcc-check
+	-rm $(CURDIR)/$(dirname)/cc-sanity-check
+	
+	-dh_clean
+
+	-rm $(CURDIR)/debian/control
+	-rm $(CURDIR)/debian/dirs
+	-rm $(CURDIR)/debian/override
+
+
+unpatch: 
+	if [ -e patch-stamp ]; then \
+	   dpatch deapply-all ; \
+	   rm -rf patch-stamp debian/patched ; \
+	fi
+
+binary_modules: binary-modules	
+	   
+
+# The kdist_configure target is called by make-kpkg modules_config. It
+# should configure the module so it is ready for compilation (mostly
+# useful for calling configure)
+kdist_config kdist_configure:
+	    $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules configure
+
+# the kdist_clean target is called by make-kpkg modules_clean. It is
+# responsible for cleaning up any changes that have been made by the
+# other kdist_commands (except for the .deb files created).
+kdist_clean: 
+	$(MAKE) -C . LINUXDIR=$(KSRC) KVERREL=$(KVERS) clean
+	-dh_clean
+
+.PHONY: clean binary-modules
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/dirs.template
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/dirs.template	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/dirs.template	(revision 5887)
@@ -0,0 +1,2 @@
+lib/modules/#KVERS#/nvidia
+usr/share/lintian/overrides
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/README.Debian
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/README.Debian	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/README.Debian	(revision 5887)
@@ -0,0 +1,12 @@
+nvidia-kernel for Debian
+------------------------
+
+Please report any actual driver related bugs (not packaging related) to
+NVIDIA directly.
+
+Please check http://www.nvidia.com/object/linux.html 
+and
+http://www.nvnews.net/vbulletin/forumdisplay.php?s=&forumid=14
+for known bugs.
+
+ -- Randall Donald <rdonald@debian.org>, Tue,  12 Jul 2005 23:30:00 -0700
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/compat
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/compat	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/compat	(revision 5887)
@@ -0,0 +1,1 @@
+7
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/postinst
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/postinst	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/postinst	(revision 5887)
@@ -0,0 +1,78 @@
+#! /bin/sh
+# postinst script for nvidia-kernel
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see /usr/share/doc/packaging-manual/
+#
+# quoting from the policy:
+#     Any necessary prompting should almost always be confined to the
+#     post-installation script, and should be protected with a conditional
+#     so that unnecessary prompting doesn't happen if a package's
+#     installation fails and the `postinst' is called with `abort-upgrade',
+#     `abort-remove' or `abort-deconfigure'.
+
+
+
+case "$1" in
+    configure)
+	major=195
+	
+	if [ ! -f /dev/.devfsd ] ; then
+	
+		for i in 0 1 2 3; do
+			devfile="/dev/nvidia$i"
+			if [ ! -c "$devfile" ]; then
+				mknod $devfile c $major $i
+				chown root:video $devfile
+				chmod 0660 $devfile
+			fi
+		done
+
+		devfile=/dev/nvidiactl
+      
+		if [ ! -c "$devfile" ]; then
+			mknod $devfile c $major 255
+			chown root:video $devfile
+			chmod 0660 $devfile
+		fi
+	fi
+       	if [ -x /usr/sbin/update-devfsd ] ; then
+		/usr/sbin/update-devfsd 
+	fi
+	
+;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 0
+    ;;
+esac
+
+
+
+
+
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/postrm
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/postrm	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/debian.binary/postrm	(revision 5887)
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+
+
+
+exit 0
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/03_pci_get_class
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/03_pci_get_class	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/03_pci_get_class	(revision 5887)
@@ -0,0 +1,40 @@
+#!/bin/sh -e
+
+# Patch by Juergen Kreileder <jk@blackdown.de>
+
+if [ $# -lt 1 ]; then
+    echo >&2 "basename $0: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+	  
+patch_opts="-f -N --no-backup-if-mismatch -p3"
+	  
+echo $1
+	  
+case "$1" in
+     -patch) patch $patch_opts -p0 < $0;;
+     -unpatch) patch $patch_opts -p0 -R < $0;;
+     *)
+        echo >&2 "basename $0: script expects -patch|-unpatch as argument"
+        exit 1;;
+esac
+	       
+exit 0
+	       
+@DPATCH@
+--- nv/nv.c.orig        2004-07-27 17:30:05.000000000 +0200
++++ nv/nv.c     2004-10-24 18:34:11.035105823 +0200
+@@ -15,6 +15,13 @@
+ #include "nv_compiler.h"
+ #include "os-agp.h"
+ 
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 8))
++#define __VMALLOC_RESERVE (128 << 20)
++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 9))
++#define pci_find_class(a, b) pci_get_class(a, b)
++#endif
++#endif
++
+ #ifdef MODULE_ALIAS_CHARDEV_MAJOR
+ MODULE_ALIAS_CHARDEV_MAJOR(NV_MAJOR_DEVICE_NUMBER);
+ #endif
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/02_pcialias
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/02_pcialias	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/02_pcialias	(revision 5887)
@@ -0,0 +1,48 @@
+#!/bin/sh -e
+
+# Patch by Juergen Kreileder <jk@blackdown.de>
+
+if [ $# -lt 1 ]; then
+    echo >&2 "basename $0: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+	  
+patch_opts="-f -N --no-backup-if-mismatch -p3"
+	  
+echo $1
+	  
+case "$1" in
+     -patch) patch $patch_opts -p0 < $0;;
+     -unpatch) patch $patch_opts -p0 -R < $0;;
+     *)
+        echo >&2 "basename $0: script expects -patch|-unpatch as argument"
+        exit 1;;
+esac
+	       
+exit 0
+	       
+@DPATCH@
+--- /home/jk/nv.c	2004-03-25 07:24:42.000000000 +0100
++++ nv/nv.c	2004-03-25 07:44:24.000000000 +0100
+@@ -47,6 +47,21 @@
+ devfs_handle_t nv_devfs_handles[NV_MAX_DEVICES+1];
+ #endif
+ 
++#if defined(KERNEL_2_6) && defined(HAVE_CLASS_SIMPLE)
++static struct pci_device_id nvidia_pci_tbl[] = {
++    {
++        .class          = (PCI_CLASS_DISPLAY_VGA << 8),
++        .class_mask     = ~0,
++        .vendor         = PCI_VENDOR_ID_NVIDIA,
++        .device         = PCI_ANY_ID,
++        .subvendor      = PCI_ANY_ID,
++        .subdevice      = PCI_ANY_ID,
++    },
++    { }
++};
++MODULE_DEVICE_TABLE (pci, nvidia_pci_tbl);
++#endif
++
+ // #define NV_DBG_MEM 1
+ #undef NV_DBG_MEM
+ 
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/01_sysfs
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/01_sysfs	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/01_sysfs	(revision 5887)
@@ -0,0 +1,207 @@
+#!/bin/sh -e
+
+# Patch by  Martin Schlemmer (i believe as posted to the lkml)
+
+if [ $# -lt 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+	
+patch_opts="-f -N --no-backup-if-mismatch -p3"
+
+echo $1
+
+case "$1" in
+	-patch) patch $patch_opts -p3 < $0;;
+	-unpatch) patch $patch_opts -p3 -R < $0;;
+	*)
+     		echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+		exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+
+diff -urN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/Makefile.kbuild NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/Makefile.kbuild
+--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/Makefile.kbuild	2004-01-15 05:29:12.000000000 +0200
++++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/Makefile.kbuild	2004-05-22 21:04:52.143088872 +0200
+@@ -117,6 +117,9 @@
+   MODULE_OBJECT := $(MODULE_NAME).o
+ else
+   MODULE_OBJECT := $(MODULE_NAME).ko
++
++  # We need this for the conftest.sh tests to work
++  KERNEL_HEADERS += -I$(KERNEL_SOURCES)/include/asm/mach-generic
+ endif
+ 
+ #
+@@ -146,6 +149,16 @@
+   EXTRA_CFLAGS += -DREMAP_PAGE_RANGE_4
+ endif
+ 
++ifeq ($(shell sh $(src)/conftest.sh remap_page_range $(KERNEL_HEADERS)),)
++  # Check if 'conftest.sh remap_page_rage' have no output - if so, we
++  # can expect issues ... !
++  $(error Cannot compile tests!  Please check $$KERNEL_HEADERS)
++endif
++
++ifeq ($(shell sh $(src)/conftest.sh class_simple $(KERNEL_HEADERS)), yes)
++  EXTRA_CFLAGS += -DHAVE_CLASS_SIMPLE
++endif
++  
+ #
+ # NVIDIA binary object file includes .common section.
+ #
+diff -urN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/conftest.sh NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/conftest.sh
+--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/conftest.sh	2004-01-15 05:29:11.000000000 +0200
++++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/conftest.sh	2004-05-22 20:58:19.382797512 +0200
+@@ -42,6 +42,29 @@
+         fi
+     ;;
+ 
++    class_simple)
++        shift
++        #
++        # Determine if we have struct class_simple needed for limited sysfs
++        # support in 2.6
++        #
++        echo "#include <linux/device.h>
++        void add_test_class(void) {
++           struct class_simple *test_class;
++           test_class = class_simple_create(THIS_MODULE, \"test\");
++        }" > conftest.c
++
++        gcc -Wall -c conftest.c -o conftest.o $* -D__KERNEL__  > output.log 2>&1
++
++        if test -f conftest.o && test -z "`cat output.log`"; then
++          echo "yes"
++        else
++          echo "no"
++        fi
++
++        rm -f conftest.{c,o} output.log
++    ;;
++
+     cc_sanity_check)
+         shift
+         #
+diff -urN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/nv-linux.h NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/nv-linux.h
+--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/nv-linux.h	2004-01-15 05:29:11.000000000 +0200
++++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/nv-linux.h	2004-05-22 20:58:19.387796752 +0200
+@@ -448,6 +448,33 @@
+ #  endif // defined(KERNEL_2_4)
+ #endif // defined(CONFIG_DEVFS_FS)
+ 
++#if defined(KERNEL_2_6) && defined(HAVE_CLASS_SIMPLE)
++#  define NV_SYSFS_REGISTER						\
++    nvidia_class = class_simple_create(THIS_MODULE, "nvidia");
++
++#  define NV_SYSFS_ADD_CONTROL						\
++     class_simple_device_add(nvidia_class,				\
++                             MKDEV(NV_MAJOR_DEVICE_NUMBER, 255),	\
++                             NULL, "nvidiactl");
++
++#  define NV_SYSFS_ADD_DEVICE(_name, _minor)				\
++     class_simple_device_add(nvidia_class,				\
++                             MKDEV(NV_MAJOR_DEVICE_NUMBER, _minor),	\
++                             &nv_linux_devices[_minor].dev->dev, _name);
++
++#  define NV_SYSFS_REMOVE_DEVICE(i)					\
++            class_simple_device_remove(MKDEV(NV_MAJOR_DEVICE_NUMBER, i));
++
++#  define NV_SYSFS_UNREGISTER						\
++    class_simple_destroy(nvidia_class);
++#else
++#  define NV_SYSFS_REGISTER
++#  define NV_SYSFS_ADD_CONTROL
++#  define NV_SYSFS_ADD_DEVICE(_name, _minor)
++#  define NV_SYSFS_REMOVE_DEVICE(i)
++#  define NV_SYSFS_UNREGISTER
++#endif
++
+ 
+ /*
+  * Linux 2.5 introduced the five argument version of remap_page_range, all
+diff -urN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/nv.c NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/nv.c
+--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/nv.c	2004-01-15 05:29:11.000000000 +0200
++++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/nv.c	2004-05-22 20:58:19.393795840 +0200
+@@ -47,6 +47,10 @@
+ devfs_handle_t nv_devfs_handles[NV_MAX_DEVICES+1];
+ #endif
+ 
++#if defined(KERNEL_2_6) && defined(HAVE_CLASS_SIMPLE)
++struct class_simple *nvidia_class;
++#endif
++
+ // #define NV_DBG_MEM 1
+ #undef NV_DBG_MEM
+ 
+@@ -874,23 +878,31 @@
+     rc = register_chrdev(nv_major, "nvidia", &nv_fops);
+ #endif
+ 
++    NV_SYSFS_REGISTER;
++
+     if (rc < 0)
+     {
+         nv_printf(NV_DBG_ERRORS, "nvidia_init_module: register failed\n");
+         return rc;
+     }
+ 
+-#ifdef CONFIG_DEVFS_FS
++#if defined(CONFIG_DEVFS_FS) || defined(KERNEL_2_6)
+     do
+     {
+         char name[10];
+ 
++# if defined(CONFIG_DEVFS_FS)
+         nv_devfs_handles[0] = NV_DEVFS_REGISTER("nvidiactl", 255);
++# endif
++        NV_SYSFS_ADD_CONTROL;
+ 
+         for (i = 0; i < num_nv_devices; i++)
+         {
+             sprintf(name, "nvidia%d", i);
++# if defined(CONFIG_DEVFS_FS)
+             nv_devfs_handles[i+1] = NV_DEVFS_REGISTER(name, i);
++# endif
++            NV_SYSFS_ADD_DEVICE(name, i);
+         }
+     } while(0);
+ #endif
+@@ -951,6 +963,7 @@
+ #else
+     unregister_chrdev(nv_major, "nvidia");
+ #endif
++    NV_SYSFS_UNREGISTER;
+     return rc;
+ }
+ 
+@@ -1011,15 +1024,24 @@
+         nv_printf(NV_DBG_ERRORS, "nvidia_exit_module: unregister nv failed\n");
+     }
+ 
+-#ifdef CONFIG_DEVFS_FS
++#if defined(CONFIG_DEVFS_FS) || defined(KERNEL_2_6)
+     do {
+         int i;
++# if defined(CONFIG_DEVFS_FS)
+         NV_DEVFS_REMOVE_CONTROL();
+-        for (i = 0; i < num_nv_devices; i++)
++# endif
++        NV_SYSFS_REMOVE_DEVICE(255);
++        for (i = 0; i < num_nv_devices; i++) {
++# if defined(CONFIG_DEVFS_FS)
+             NV_DEVFS_REMOVE_DEVICE(i);
++# endif
++            NV_SYSFS_REMOVE_DEVICE(i);
++        }
+     } while (0);
+ #endif
+ 
++    NV_SYSFS_UNREGISTER;
++
+ #if NV_ENABLE_MEM_TRACKING
+     nv_list_mem(vm_list);
+     nv_list_mem(km_list);
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/00list
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/00list	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/00list	(revision 5887)
@@ -0,0 +1,4 @@
+01_sysfs
+02_pcialias
+03_pci_get_class
+04_minion
Index: /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/04_minion
===================================================================
--- /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/04_minion	(revision 5887)
+++ /pkg/tags/nvidia-graphics-drivers-185.18.36-2/patches.dpatch.save/04_minion	(revision 5887)
@@ -0,0 +1,5911 @@
+#!/bin/sh -e
+
+# Patch from accumulated from http://www.minion.de/files/1.0-6629/
+
+if [ $# -lt 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+	
+patch_opts="-f -N --no-backup-if-mismatch -p2"
+
+echo $1
+
+case "$1" in
+	-patch) patch $patch_opts -p1 < $0;;
+	-unpatch) patch $patch_opts -p1 -R < $0;;
+	*)
+     		echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+		exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+
+diff -ruN nvidia-kernel.orig/nv/nv-linux.h nvidia-kernel/nv/nv-linux.h
+--- nvidia-kernel.orig/nv/nv-linux.h	2005-01-11 17:19:49.000000000 -0800
++++ nvidia-kernel/nv/nv-linux.h	2005-02-18 15:08:12.951057467 -0800
+@@ -155,6 +155,10 @@
+ #endif
+ #endif /* defined(NVCPU_X86) */
+ 
++#ifndef get_cpu
++#define get_cpu() smp_processor_id()
++#define put_cpu()
++#endif
+ 
+ #if !defined (list_for_each)
+ #define list_for_each(pos, head) \
+@@ -429,6 +433,30 @@
+         free_pages(ptr, order); \
+     }
+ 
++#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type)            \
++    {                                                           \
++        kmem_cache = kmem_cache_create(name, sizeof(type),      \
++                        0, 0, NULL, NULL);                      \
++    } 
++
++#define NV_KMEM_CACHE_DESTROY(kmem_cache)                       \
++    {                                                           \
++        kmem_cache_destroy(kmem_cache);                         \
++        kmem_cache = NULL;                                      \
++    } 
++
++#define NV_KMEM_CACHE_ALLOC(ptr, kmem_cache, type)              \
++    {                                                           \
++        (ptr) = kmem_cache_alloc(kmem_cache, GFP_KERNEL);       \
++        KM_ALLOC_RECORD(ptr, sizeof(type), "km_cache_alloc");   \
++    } 
++
++#define NV_KMEM_CACHE_FREE(ptr, type, kmem_cache)               \
++    {                                                           \
++        KM_FREE_RECORD(ptr, sizeof(type), "km_cache_free");     \
++        kmem_cache_free(kmem_cache, ptr);                       \
++    } 
++
+ #endif /* !defined NVWATCH */
+ 
+ 
+@@ -480,12 +508,22 @@
+ #define NV_PCI_RESOURCE_SIZE(dev, bar)  ((dev)->resource[(bar) - 1].end - (dev)->resource[(bar) - 1].start + 1)
+ 
+ #define NV_PCI_BUS_NUMBER(dev)        (dev)->bus->number
+-#define NV_PCI_SLOT_NUMBER(dev)       PCI_SLOT((dev)->devfn)
++#define NV_PCI_DEVFN(dev)             (dev)->devfn
++#define NV_PCI_SLOT_NUMBER(dev)       PCI_SLOT(NV_PCI_DEVFN(dev))
+ 
+ #ifdef NV_PCI_GET_CLASS_PRESENT
+ #define NV_PCI_DEV_PUT(dev)                    pci_dev_put(dev)
+ #define NV_PCI_GET_DEVICE(vendor,device,from)  pci_get_device(vendor,device,from)
+-#define NV_PCI_GET_SLOT(bus,devfn)             pci_get_slot(pci_find_bus(0,bus),devfn)
++#define NV_PCI_GET_SLOT(bus,devfn)                                       \
++   ({                                                                    \
++        struct pci_dev *__dev = NULL;                                    \
++        while ((__dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, __dev)))  \
++        {                                                                \
++            if (NV_PCI_BUS_NUMBER(__dev) == bus                          \
++                    && NV_PCI_DEVFN(__dev) == devfn) break;              \
++        }                                                                \
++        __dev;                                                           \
++    })
+ #define NV_PCI_GET_CLASS(class,from)           pci_get_class(class,from)
+ #else
+ #define NV_PCI_DEV_PUT(dev)
+@@ -533,6 +571,7 @@
+  */
+ #if defined(CONFIG_SWIOTLB)
+ #define NV_SWIOTLB 1
++#define NV_SWIOTLB_MAX_RETRIES 16
+ extern int nv_swiotlb;
+ #endif
+ 
+@@ -565,11 +604,6 @@
+ #define PCI_CAP_ID_EXP 0x10
+ #endif
+ 
+-#if defined(KERNEL_2_6) && defined(AGPGART)
+-typedef struct agp_kern_info agp_kern_info;
+-typedef struct agp_memory agp_memory;
+-#endif
+-
+ #if defined(CONFIG_DEVFS_FS)
+ #  if defined(KERNEL_2_6)
+      typedef void* devfs_handle_t;
+@@ -627,75 +661,109 @@
+ #define NV_REMAP_PAGE_RANGE(x...) remap_page_range(x)
+ #endif
+ 
++
++#define NV_PGD_OFFSET(address, kernel, mm)              \
++   ({                                                   \
++        pgd_t *__pgd;                                   \
++        if (!kernel)                                    \
++            __pgd = pgd_offset(mm, address);            \
++        else                                            \
++            __pgd = pgd_offset_k(address);              \
++        __pgd;                                          \
++    })
++
++#define NV_PGD_PRESENT(pgd)                             \
++   ({                                                   \
++         if ((pgd != NULL) &&                           \
++             (pgd_bad(*pgd) || pgd_none(*pgd)))         \
++            /* static */ pgd = NULL;                    \
++         pgd != NULL;                                   \
++    })
++
+ #if defined(pmd_offset_map)
+-#define NV_PMD_OFFSET(addres, pg_dir, pg_mid_dir) \
+-    { \
+-        pg_mid_dir = pmd_offset_map(pg_dir, address); \
+-    }
+-#define NV_PMD_UNMAP(pg_mid_dir) \
+-    { \
+-        pmd_unmap(pg_mid_dir); \
+-    }
+-#else
+-#define NV_PMD_OFFSET(addres, pg_dir, pg_mid_dir) \
+-    { \
+-        pg_mid_dir = pmd_offset(pg_dir, address); \
+-    }
+-#define NV_PMD_UNMAP(pg_mid_dir)
++#define NV_PMD_OFFSET(address, pgd)                     \
++   ({                                                   \
++        pmd_t *__pmd;                                   \
++        __pmd = pmd_offset_map(pgd, address);           \
++   })
++#define NV_PMD_UNMAP(pmd) pmd_unmap(pmd);
++#else
++#if defined(PUD_SHIFT) /* 4-level pgtable */
++#define NV_PMD_OFFSET(address, pgd)                     \
++   ({                                                   \
++        pmd_t *__pmd = NULL;                            \
++        pud_t *__pud;                                   \
++        __pud = pud_offset(pgd, address);               \
++        if ((__pud != NULL) &&                          \
++            !(pud_bad(*__pud) || pud_none(*__pud)))     \
++            __pmd = pmd_offset(__pud, address);         \
++        __pmd;                                          \
++    })
++#else /* 3-level pgtable */
++#define NV_PMD_OFFSET(address, pgd)                     \
++   ({                                                   \
++        pmd_t *__pmd;                                   \
++        __pmd = pmd_offset(pgd, address);               \
++    })
++#endif
++#define NV_PMD_UNMAP(pmd)
+ #endif
+ 
+-#define NV_PMD_PRESENT(pg_mid_dir) \
+-    ({ \
+-        if ( (pg_mid_dir) && (pmd_none(*pg_mid_dir))) { \
+-            NV_PMD_UNMAP(pg_mid_dir); pg_mid_dir = NULL; \
+-        } pg_mid_dir != NULL; \
++#define NV_PMD_PRESENT(pmd)                             \
++   ({                                                   \
++        if ((pmd != NULL) &&                            \
++            (pmd_bad(*pmd) || pmd_none(*pmd)))          \
++        {                                               \
++            NV_PMD_UNMAP(pmd);                          \
++            pmd = NULL; /* mark invalid */              \
++        }                                               \
++        pmd != NULL;                                    \
+     })
+ 
+ #if defined(pte_offset_atomic)
+-#define NV_PTE_OFFSET(addres, pg_mid_dir, pte) \
+-    { \
+-        pte = pte_offset_atomic(pg_mid_dir, address); \
+-        NV_PMD_UNMAP(pg_mid_dir); \
+-    }
+-#define NV_PTE_UNMAP(pte) \
+-    { \
+-        pte_kunmap(pte); \
+-    }
++#define NV_PTE_OFFSET(address, pmd)                     \
++   ({                                                   \
++        pte_t *__pte;                                   \
++        __pte = pte_offset_atomic(pmd, address);        \
++        NV_PMD_UNMAP(pmd); __pte;                       \
++    })
++#define NV_PTE_UNMAP(pte) pte_kunmap(pte);
+ #elif defined(pte_offset)
+-#define NV_PTE_OFFSET(addres, pg_mid_dir, pte) \
+-    { \
+-        pte = pte_offset(pg_mid_dir, address); \
+-        NV_PMD_UNMAP(pg_mid_dir); \
+-    }
++#define NV_PTE_OFFSET(address, pmd)                     \
++   ({                                                   \
++        pte_t *__pte;                                   \
++        __pte = pte_offset(pmd, address);               \
++        NV_PMD_UNMAP(pmd); __pte;                       \
++    })
+ #define NV_PTE_UNMAP(pte)
+ #else
+-#define NV_PTE_OFFSET(addres, pg_mid_dir, pte) \
+-    { \
+-        pte = pte_offset_map(pg_mid_dir, address); \
+-        NV_PMD_UNMAP(pg_mid_dir); \
+-    }
+-#define NV_PTE_UNMAP(pte) \
+-    { \
+-        pte_unmap(pte); \
+-    }
++#define NV_PTE_OFFSET(address, pmd)                     \
++   ({                                                   \
++        pte_t *__pte;                                   \
++        __pte = pte_offset_map(pmd, address);           \
++        NV_PMD_UNMAP(pmd); __pte;                       \
++    })
++#define NV_PTE_UNMAP(pte) pte_unmap(pte);
+ #endif
+ 
+-#define NV_PTE_PRESENT(pte) \
+-    ({ \
+-        if (pte) { \
+-            if (!pte_present(*pte)) { \
+-                NV_PTE_UNMAP(pte); pte = NULL; \
+-            } \
+-        } pte != NULL; \
++#define NV_PTE_PRESENT(pte)                             \
++   ({                                                   \
++        if ((pte != NULL) && !pte_present(*pte))        \
++        {                                               \
++            NV_PTE_UNMAP(pte);                          \
++            pte = NULL; /* mark invalid */              \
++        }                                               \
++        pte != NULL;                                    \
+     })
+ 
+-#define NV_PTE_VALUE(pte) \
+-    ({ \
+-        unsigned long __pte_value = pte_val(*pte); \
+-        NV_PTE_UNMAP(pte); \
+-        __pte_value; \
++#define NV_PTE_VALUE(pte)                               \
++   ({                                                   \
++        unsigned long __pte_value = pte_val(*pte);      \
++        NV_PTE_UNMAP(pte);                              \
++        __pte_value;                                    \
+     })
+ 
++
+ #define NV_PAGE_ALIGN(addr)             ( ((addr) + PAGE_SIZE - 1) / PAGE_SIZE)
+ #define NV_MASK_OFFSET(addr)            ( (addr) & (PAGE_SIZE - 1) )
+ 
+@@ -729,12 +797,21 @@
+         return order;
+     }
+ 
++/* mark memory UC-, rather than UC (don't use _PAGE_PWT) */
++static inline pgprot_t pgprot_noncached_weak(pgprot_t old_prot)
++    {
++        pgprot_t new_prot = old_prot;
++        if (boot_cpu_data.x86 > 3)
++            new_prot = __pgprot(pgprot_val(old_prot) | _PAGE_PCD);
++        return new_prot;
++    }
++
+ #if !defined (pgprot_noncached)
+ static inline pgprot_t pgprot_noncached(pgprot_t old_prot)
+     {
+         pgprot_t new_prot = old_prot;
+         if (boot_cpu_data.x86 > 3)
+-            new_prot = __pgprot(pgprot_val(old_prot) | _PAGE_PCD);
++            new_prot = __pgprot(pgprot_val(old_prot) | _PAGE_PCD | _PAGE_PWT);
+         return new_prot;
+     }
+ #endif
+@@ -776,6 +853,9 @@
+     unsigned long   phys_addr;
+     unsigned long   virt_addr;
+     dma_addr_t      dma_addr;
++#ifdef NV_SG_MAP_BUFFERS
++    struct scatterlist sg_list;
++#endif
+ #ifdef CONFIG_SWIOTLB
+     unsigned long   orig_phys_addr;
+     unsigned long   orig_virt_addr;
+@@ -789,15 +869,11 @@
+     unsigned int   num_pages;
+     unsigned int   order;
+     unsigned int   size;
+-    nv_pte_t      *page_table;          /* list of physical pages allocated */
++    nv_pte_t     **page_table;          /* list of physical pages allocated */
+     void          *key_mapping;         /* mapping used as a key for finding this nv_alloc_t */
+                                         /*   may be the same as page_table                   */
+     unsigned int   class;
+     void          *priv_data;
+-#if defined(NV_SG_MAP_BUFFERS)
+-    struct pci_dev *dev;
+-    struct scatterlist *sg_list;        /* list of physical pages allocated */
+-#endif
+ } nv_alloc_t;
+ 
+ 
+@@ -939,21 +1015,60 @@
+ #if defined(NV_SG_MAP_BUFFERS)
+ static inline int nv_sg_map_buffer(
+     struct pci_dev     *dev,
+-    struct scatterlist *sg_ptr,
++    nv_pte_t          **page_list,
+     void               *base,
+     unsigned int        num_pages
+ )
+ {
+-    int i;
++    struct scatterlist *sg_ptr = &page_list[0]->sg_list;
++    unsigned int i;
+ 
+     sg_ptr->page = virt_to_page(base);
+     sg_ptr->offset = (unsigned long)base & ~PAGE_MASK;
+     sg_ptr->length  = num_pages * PAGE_SIZE;
+ 
++#if defined(NV_SWIOTLB)
++    i = NV_SWIOTLB_MAX_RETRIES;
++    do {
++        if (pci_map_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL) == 0)
++            return 1;
++
++        if (sg_ptr->dma_address & ~PAGE_MASK)
++        {
++            struct scatterlist sg_tmp;
++            pci_unmap_sg(dev, sg_ptr, num_pages, PCI_DMA_BIDIRECTIONAL);
++
++            memset(&sg_tmp, 0, sizeof(struct scatterlist));
++            sg_tmp.page = sg_ptr->page;
++            sg_tmp.offset = sg_ptr->offset;
++            sg_tmp.length = 2048;
++
++            if (pci_map_sg(dev, &sg_tmp, 1, PCI_DMA_BIDIRECTIONAL) == 0)
++                return 1;
++
++            if (pci_map_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL) == 0)
++            {
++                pci_unmap_sg(dev, &sg_tmp, num_pages, PCI_DMA_BIDIRECTIONAL);
++                return 1;
++            }
++
++            pci_unmap_sg(dev, &sg_tmp, num_pages, PCI_DMA_BIDIRECTIONAL);
++        }
++    } while (i-- && sg_ptr->dma_address & ~PAGE_MASK);
++#else
+     if (pci_map_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL) == 0)
+     {
+         return 1;
+     }
++#endif
++
++    if (sg_ptr->dma_address & ~PAGE_MASK)
++    {
++        nv_printf(NV_DBG_ERRORS,
++            "NVRM: VM: nv_sg_map_buffer: failed to obtain aligned mapping\n");
++        pci_unmap_sg(dev, sg_ptr, num_pages, PCI_DMA_BIDIRECTIONAL);
++        return 1;
++    }
+ 
+     NV_FIXUP_SWIOTLB_VIRT_ADDR_BUG(sg_ptr->dma_address);
+ 
+@@ -966,7 +1081,7 @@
+     // note we start with index 1, since index 0 is already correct
+     for (i = 1; i < num_pages; i++)
+     {
+-        sg_ptr[i].dma_address = sg_ptr[0].dma_address + (i * PAGE_SIZE);
++        page_list[i]->sg_list.dma_address = sg_ptr->dma_address + (i * PAGE_SIZE);
+     }
+ 
+     return 0;
+diff -ruN nvidia-kernel.orig/nv/nv-linux.h.orig nvidia-kernel/nv/nv-linux.h.orig
+--- nvidia-kernel.orig/nv/nv-linux.h.orig	1969-12-31 16:00:00.000000000 -0800
++++ nvidia-kernel/nv/nv-linux.h.orig	2005-02-18 15:08:04.602166384 -0800
+@@ -0,0 +1,1165 @@
++/* _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_LINUX_H_
++#define _NV_LINUX_H_
++
++#include "nv.h"
++
++#include <linux/config.h>
++#include <linux/version.h>
++
++
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
++#  error This driver does not support pre-2.4 kernels!
++#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
++#  define KERNEL_2_4
++#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
++#  error This driver does not support 2.5 kernels!
++#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 7, 0)
++#  define KERNEL_2_6
++#else
++#  error This driver does not support development kernels!
++#endif
++
++#if defined (__ia64)
++#  if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 13)
++#    error This driver does not support 2.4.12 or earlier kernels!
++#  endif
++#endif
++
++#if defined (CONFIG_SMP) && !defined (__SMP__)
++#define __SMP__
++#endif
++
++#if defined (CONFIG_MODVERSIONS) && !defined (MODVERSIONS)
++#  define MODVERSIONS
++#endif
++
++#if defined (MODVERSIONS) && !defined (KERNEL_2_6)
++#include <linux/modversions.h>
++#endif
++
++#include <linux/kernel.h>
++#include <linux/module.h>
++
++#include <linux/init.h>             /* module_init, module_exit         */
++#include <linux/types.h>            /* pic_t, size_t, __u32, etc        */
++#include <linux/errno.h>            /* error codes                      */
++#include <linux/list.h>             /* circular linked list             */
++#include <linux/stddef.h>           /* NULL, offsetof                   */
++#include <linux/wait.h>             /* wait queues                      */
++
++#include <linux/slab.h>             /* kmalloc, kfree, etc              */
++#include <linux/vmalloc.h>          /* vmalloc, vfree, etc              */
++
++#include <linux/poll.h>             /* poll_wait                        */
++#include <linux/delay.h>            /* mdelay, udelay                   */
++
++#ifdef KERNEL_2_6
++#include <linux/sched.h>            /* suser(), capable() replacement   */
++#include <linux/moduleparam.h>      /* module_param()                   */
++#include <linux/smp_lock.h>         /* kernel_locked                    */
++#include <asm/tlbflush.h>           /* flush_tlb(), flush_tlb_all()     */
++#include <asm/kmap_types.h>         /* page table entry lookup          */
++#endif
++
++#include <linux/pci.h>              /* pci_find_class, etc              */
++#include <linux/interrupt.h>        /* tasklets, interrupt helpers      */
++#include <linux/timer.h>
++
++#include <asm/system.h>             /* cli, sli, save_flags             */
++#include <asm/io.h>                 /* ioremap, virt_to_phys            */
++#include <asm/uaccess.h>            /* access_ok                        */
++#include <asm/page.h>               /* PAGE_OFFSET                      */
++#include <asm/pgtable.h>            /* pte bit definitions              */
++
++#if defined(NVCPU_X86_64) && defined(KERNEL_2_6)
++#include <linux/syscalls.h>         /* sys_ioctl()                      */
++#include <linux/ioctl32.h>          /* register_ioctl32_conversion()    */
++#endif
++
++#if defined(NVCPU_X86_64) && defined(KERNEL_2_4)
++#include <asm/ioctl32.h>            /* sys_ioctl() (ioctl32)            */
++#endif
++
++#include <linux/spinlock.h>
++#include <asm/semaphore.h>
++#include <linux/highmem.h>
++
++#ifdef CONFIG_PROC_FS
++#include <linux/proc_fs.h>
++#endif
++
++#ifdef CONFIG_DEVFS_FS
++#include <linux/devfs_fs_kernel.h>
++#endif
++
++#ifdef CONFIG_KMOD
++#include <linux/kmod.h>
++#endif
++
++#ifdef CONFIG_PM
++#include <linux/pm.h>
++#endif
++
++#ifdef CONFIG_MTRR
++#include <asm/mtrr.h>
++#endif
++
++#ifdef CONFIG_KDB
++#include <linux/kdb.h>
++#include <asm/kdb.h>
++#endif
++
++#if defined (CONFIG_AGP) || defined (CONFIG_AGP_MODULE)
++#ifndef NOAGPGART
++#  define AGPGART
++#  include <linux/agp_backend.h>
++#  include <linux/agpgart.h>
++#endif
++#endif
++
++#if defined(NVCPU_X86) || defined(NVCPU_X86_64)
++#define NV_BUILD_NV_PAT_SUPPORT 1
++#endif
++
++#if defined(NV_BUILD_NV_PAT_SUPPORT)
++#include "pat.h"
++#endif
++
++#if defined(NVCPU_X86)
++#ifndef write_cr4
++#define write_cr4(x) __asm__ ("movl %0,%%cr4" :: "r" (x));
++#endif
++
++#ifndef read_cr4
++#define read_cr4()                                  \
++ ({                                                 \
++      unsigned int __cr4;                           \
++      __asm__ ("movl %%cr4,%0" : "=r" (__cr4));     \
++      __cr4;                                        \
++  })
++#endif
++
++#ifndef wbinvd
++#define wbinvd() __asm__ __volatile__("wbinvd" ::: "memory");
++#endif
++#endif /* defined(NVCPU_X86) */
++
++#ifndef get_cpu
++#define get_cpu() smp_processor_id()
++#define put_cpu()
++#endif
++
++#if !defined (list_for_each)
++#define list_for_each(pos, head) \
++        for (pos = (head)->next; pos != (head); pos = (pos)->next)
++#endif
++
++#ifdef EXPORT_NO_SYMBOLS
++/* don't clutter the kernel namespace with our symbols */
++EXPORT_NO_SYMBOLS;
++#endif
++
++#if !defined(DEBUG) && defined(__GFP_NOWARN)
++#define NV_GFP_KERNEL (GFP_KERNEL | __GFP_NOWARN)
++#define NV_GFP_ATOMIC (GFP_ATOMIC | __GFP_NOWARN)
++#else
++#define NV_GFP_KERNEL (GFP_KERNEL)
++#define NV_GFP_ATOMIC (GFP_ATOMIC)
++#endif
++
++#if defined(NVCPU_IA64)
++#define NV_GFP_DMA32 (NV_GFP_KERNEL | __GFP_DMA)
++#define CACHE_FLUSH()
++#else
++#define NV_GFP_DMA32 (NV_GFP_KERNEL)
++#define CACHE_FLUSH()  asm volatile("wbinvd":::"memory")
++#endif
++
++#ifndef NVWATCH
++
++/* various memory tracking/debugging techniques
++ * disabled for retail builds, enabled for debug builds
++ */
++
++// allow an easy way to convert all debug printfs related to memory
++// management back and forth between 'info' and 'errors'
++#if defined(NV_DBG_MEM)
++#define NV_DBG_MEMINFO NV_DBG_ERRORS
++#else
++#define NV_DBG_MEMINFO NV_DBG_INFO
++#endif
++
++#ifdef DEBUG
++#define NV_ENABLE_MEM_TRACKING 1
++#endif
++
++#if NV_ENABLE_MEM_TRACKING
++#define NV_MEM_TRACKING_PAD_SIZE(size)   ((size) += sizeof(void *))
++#define NV_MEM_TRACKING_HIDE_SIZE(ptr, size)            \
++    if ((ptr) && *(ptr)) {                              \
++        U008 *__ptr;                                    \
++        *(unsigned long *) *(ptr) = (size);             \
++        __ptr = *(ptr); __ptr += sizeof(void *);        \
++        *(ptr) = (void *) __ptr;                        \
++    }
++#define NV_MEM_TRACKING_RETRIEVE_SIZE(ptr, size)        \
++    {                                                   \
++        U008 *__ptr = (ptr); __ptr -= sizeof(void *);   \
++        (ptr) = (void *) __ptr;                         \
++        size = *(unsigned long *) (ptr);                \
++    }
++#else
++#define NV_MEM_TRACKING_PAD_SIZE(size)
++#define NV_MEM_TRACKING_HIDE_SIZE(ptr, size)
++#define NV_MEM_TRACKING_RETRIEVE_SIZE(ptr, size)  ((size) = 0)
++#endif
++
++
++/* poor man's memory allocation tracker.
++ * main intention is just to see how much memory is being used to recognize
++ * when memory usage gets out of control or if memory leaks are happening
++ */
++
++/* keep track of memory usage */
++#if NV_ENABLE_MEM_TRACKING
++extern int vm_usage;
++extern int km_usage;
++extern int fp_usage;
++
++/* print out a running tally of memory allocation amounts, disabled by default */
++// #define POOR_MANS_MEM_CHECK 1
++
++
++/* slightly more advanced memory allocation tracker.
++ * track who's allocating memory and print out a list of currently allocated
++ * memory at key points in the driver
++ */
++
++#define MEMDBG_ALLOC(a,b) (a = kmalloc(b, NV_GFP_ATOMIC))
++#define MEMDBG_FREE(a)    (kfree(a))
++
++#include "nv-memdbg.h"
++
++#undef MEMDBG_ALLOC
++#undef MEMDBG_FREE
++
++extern struct mem_track_t *vm_list;
++extern struct mem_track_t *km_list;
++extern struct mem_track_t *fp_list;
++
++/* print out list of memory allocations */
++/* default to enabled for now */
++#define LIST_MEM_CHECK 1
++
++/* decide which memory types to apply mem trackers to */
++#define VM_CHECKER 1
++#define KM_CHECKER 1
++#define FP_CHECKER 1
++
++#endif  /* NV_ENABLE_MEM_TRACKING */
++
++#define VM_PRINT(str, args...)
++#define KM_PRINT(str, args...)
++#define FP_PRINT(str, args...)
++
++#define VM_ADD_MEM(a,b,c,d)
++#define VM_FREE_MEM(a,b,c,d)
++#define KM_ADD_MEM(a,b,c,d)
++#define KM_FREE_MEM(a,b,c,d)
++#define FP_ADD_MEM(a,b,c,d)
++#define FP_FREE_MEM(a,b,c,d)
++
++#define VM_ALLOC_RECORD(a,b,c)
++#define VM_FREE_RECORD(a,b,c)
++#define KM_ALLOC_RECORD(a,b,c)
++#define KM_FREE_RECORD(a,b,c)
++
++
++#if defined(VM_CHECKER)
++#  if defined(POOR_MANS_MEM_CHECK)
++#    undef  VM_PRINT
++#    define VM_PRINT(str, args...)   printk(str, ##args)
++#  endif
++#  if defined(LIST_MEM_CHECK)
++#    undef  VM_ADD_MEM
++#    define VM_ADD_MEM(a,b,c,d)      nv_add_mem(&vm_list, a, b, c, d)
++#    undef  VM_FREE_MEM
++#    define VM_FREE_MEM(a,b,c,d)     nv_free_mem(&vm_list, a, b, c, d)
++#  endif
++#  undef VM_ALLOC_RECORD
++#  define VM_ALLOC_RECORD(ptr, size, name) \
++      if (ptr) { \
++            vm_usage += size; \
++            VM_PRINT("%s (0x%x: 0x%x): vm_usage is now 0x%x\n", \
++                name, ptr, size, vm_usage); \
++            VM_ADD_MEM(ptr, size, __FILE__, __LINE__); \
++        }
++#  undef VM_FREE_RECORD
++#  define VM_FREE_RECORD(ptr, size, name) \
++        if (ptr) { \
++            vm_usage -= size; \
++            VM_PRINT("%s (0x%x: 0x%x): vm_usage is now 0x%x\n", \
++                name, ptr, size, vm_usage); \
++            VM_FREE_MEM(ptr, size, __FILE__, __LINE__); \
++        }
++#endif
++
++#if defined(KM_CHECKER)
++#  if defined(POOR_MANS_MEM_CHECK)
++#    undef  KM_PRINT
++#    define KM_PRINT(str, args...)   printk(str, ##args)
++#  endif
++#  if defined(LIST_MEM_CHECK)
++#    undef  KM_ADD_MEM
++#    define KM_ADD_MEM(a,b,c,d)      nv_add_mem(&km_list, a, b, c, d)
++#    undef  KM_FREE_MEM
++#    define KM_FREE_MEM(a,b,c,d)     nv_free_mem(&km_list, a, b, c, d)
++#  endif
++#  undef KM_ALLOC_RECORD
++#  define KM_ALLOC_RECORD(ptr, size, name) \
++      if (ptr) { \
++            km_usage += size; \
++            KM_PRINT("%s (0x%x: 0x%x): km_usage is now 0x%x\n", \
++                name, ptr, size, km_usage); \
++            KM_ADD_MEM(ptr, size, __FILE__, __LINE__); \
++        }
++#  undef KM_FREE_RECORD
++#  define KM_FREE_RECORD(ptr, size, name) \
++        if (ptr) { \
++            km_usage -= size; \
++            KM_PRINT("%s (0x%x: 0x%x): km_usage is now 0x%x\n", \
++                name, ptr, size, km_usage); \
++            KM_FREE_MEM(ptr, size, __FILE__, __LINE__); \
++        }
++#endif
++
++#if defined(FP_CHECKER)
++#  if defined(POOR_MANS_MEM_CHECK)
++#    undef  FP_PRINT
++#    define FP_PRINT(str, args...)   printk(str, ##args)
++#  endif
++#if 0  // I had some problems tracking fp mem, so disable for now
++#  if defined(LIST_MEM_CHECK)
++#    undef  FP_ADD_MEM
++#    define FP_ADD_MEM(a,b,c,d)      nv_add_mem(&fp_list, a, b, c, d)
++#    undef  FP_FREE_MEM
++#    define FP_FREE_MEM(a,b,c,d)     nv_free_mem(&fp_list, a, b, c, d)
++#  endif
++#endif
++#endif
++
++/* NV_VMALLOC has to allocate memory under the 4GB mark suitable for
++ * DMA use with the hardware.  This has to be done differently for
++ * different platforms and kernel versions.
++ */
++#if defined(NVCPU_IA64)
++#define NV_VMALLOC(ptr, size) \
++    { \
++        (ptr) = vmalloc_dma(size); \
++        VM_ALLOC_RECORD(ptr, size, "vm_alloc"); \
++    }
++#else
++#define NV_VMALLOC(ptr, size) \
++    { \
++        (ptr) = vmalloc_32(size); \
++        VM_ALLOC_RECORD(ptr, size, "vm_alloc"); \
++    }
++#endif
++
++#define NV_VFREE(ptr, size) \
++    { \
++        VM_FREE_RECORD(ptr, size, "vm_alloc"); \
++        vfree((void *) (ptr)); \
++    }
++
++#define NV_IOREMAP(ptr, physaddr, size) \
++    { \
++        (ptr) = ioremap(physaddr, size); \
++        VM_ALLOC_RECORD(ptr, size, "vm_ioremap"); \
++    }
++
++#define NV_IOREMAP_NOCACHE(ptr, physaddr, size) \
++    { \
++        (ptr) = ioremap_nocache(physaddr, size); \
++        VM_ALLOC_RECORD(ptr, size, "vm_ioremap_nocache"); \
++    }
++
++#define NV_IOUNMAP(ptr, size) \
++    { \
++        VM_FREE_RECORD(ptr, size, "vm_iounmap"); \
++        iounmap(ptr); \
++    }
++
++/* only use this because GFP_KERNEL may sleep..
++ * GFP_ATOMIC is ok, it won't sleep
++ */
++#define NV_KMALLOC(ptr, size) \
++    { \
++        (ptr) = kmalloc(size, NV_GFP_KERNEL); \
++        KM_ALLOC_RECORD(ptr, size, "km_alloc"); \
++    }
++
++#define NV_KMALLOC_ATOMIC(ptr, size) \
++    { \
++        (ptr) = kmalloc(size, NV_GFP_ATOMIC); \
++        KM_ALLOC_RECORD(ptr, size, "km_alloc_atomic"); \
++    }  
++
++
++#define NV_KFREE(ptr, size) \
++    { \
++        KM_FREE_RECORD(ptr, size, "km_free"); \
++        kfree((void *) (ptr)); \
++    }
++
++#define NV_GET_FREE_PAGES(ptr, order) \
++    { \
++        (ptr) = __get_free_pages(NV_GFP_DMA32, order); \
++    }
++        
++#define NV_FREE_PAGES(ptr, order) \
++    { \
++        free_pages(ptr, order); \
++    }
++
++#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type)            \
++    {                                                           \
++        kmem_cache = kmem_cache_create(name, sizeof(type),      \
++                        0, 0, NULL, NULL);                      \
++    } 
++
++#define NV_KMEM_CACHE_DESTROY(kmem_cache)                       \
++    {                                                           \
++        kmem_cache_destroy(kmem_cache);                         \
++        kmem_cache = NULL;                                      \
++    } 
++
++#define NV_KMEM_CACHE_ALLOC(ptr, kmem_cache, type)              \
++    {                                                           \
++        (ptr) = kmem_cache_alloc(kmem_cache, GFP_KERNEL);       \
++        KM_ALLOC_RECORD(ptr, sizeof(type), "km_cache_alloc");   \
++    } 
++
++#define NV_KMEM_CACHE_FREE(ptr, type, kmem_cache)               \
++    {                                                           \
++        KM_FREE_RECORD(ptr, sizeof(type), "km_cache_free");     \
++        kmem_cache_free(kmem_cache, ptr);                       \
++    } 
++
++#endif /* !defined NVWATCH */
++
++
++#if defined (KERNEL_2_4)
++#  define NV_IS_SUSER()                 suser()
++#  define NV_PCI_DEVICE_NAME(dev)       ((dev)->name)
++#  define NV_NUM_CPUS()                 smp_num_cpus
++#  define NV_CLI()                      __cli()
++#  define NV_SAVE_FLAGS(eflags)         __save_flags(eflags)
++#  define NV_RESTORE_FLAGS(eflags)      __restore_flags(eflags)
++#  define NV_MAY_SLEEP()                (!in_interrupt())
++#  define NV_MODULE_PARAMETER(x)        MODULE_PARM(x, "i")
++#endif
++
++#if defined (KERNEL_2_6)
++#  define NV_IS_SUSER()                 capable(CAP_SYS_ADMIN)
++#  define NV_PCI_DEVICE_NAME(dev)       ((dev)->pretty_name)
++#  define NV_NUM_CPUS()                 num_online_cpus()
++#  define NV_CLI()                      local_irq_disable()
++#  define NV_SAVE_FLAGS(eflags)         local_save_flags(eflags)
++#  define NV_RESTORE_FLAGS(eflags)      local_irq_restore(eflags)
++#  define NV_MAY_SLEEP()                (!in_interrupt() && !in_atomic())
++#  define NV_MODULE_PARAMETER(x)        module_param(x, int, 0)
++
++   // the following macro causes problems when used in the same module
++   // as module_param(); undef it so we don't accidentally mix the two
++#  undef  MODULE_PARM
++#endif
++
++   // Earlier 2.4.x kernels don't have pci_disable_device()
++#ifdef NV_PCI_DISABLE_DEVICE_PRESENT
++#define NV_PCI_DISABLE_DEVICE(dev)      pci_disable_device(dev)
++#else
++#define NV_PCI_DISABLE_DEVICE(dev)
++#endif
++
++/* common defines */
++#define GET_MODULE_SYMBOL(mod,sym)    (const void *) inter_module_get(sym)
++#define PUT_MODULE_SYMBOL(sym)        inter_module_put((char *) sym)
++
++#define NV_GET_PAGE_STRUCT(phys_page) virt_to_page(__va(phys_page))
++#define NV_VMA_OFFSET(vma)            (((vma)->vm_pgoff) << PAGE_SHIFT)
++#define NV_VMA_PRIVATE(vma)           ((vma)->vm_private_data)
++
++#define NV_DEVICE_NUMBER(x)           minor((x)->i_rdev)
++#define NV_IS_CONTROL_DEVICE(x)       (minor((x)->i_rdev) == 255)
++
++#define NV_PCI_RESOURCE_START(dev, bar) ((dev)->resource[(bar) - 1].start)
++#define NV_PCI_RESOURCE_SIZE(dev, bar)  ((dev)->resource[(bar) - 1].end - (dev)->resource[(bar) - 1].start + 1)
++
++#define NV_PCI_BUS_NUMBER(dev)        (dev)->bus->number
++#define NV_PCI_DEVFN(dev)             (dev)->devfn
++#define NV_PCI_SLOT_NUMBER(dev)       PCI_SLOT(NV_PCI_DEVFN(dev))
++
++#ifdef NV_PCI_GET_CLASS_PRESENT
++#define NV_PCI_DEV_PUT(dev)                    pci_dev_put(dev)
++#define NV_PCI_GET_DEVICE(vendor,device,from)  pci_get_device(vendor,device,from)
++#define NV_PCI_GET_SLOT(bus,devfn)                                       \
++   ({                                                                    \
++        struct pci_dev *__dev = NULL;                                    \
++        while ((__dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, __dev)))  \
++        {                                                                \
++            if (NV_PCI_BUS_NUMBER(__dev) == bus                          \
++                    && NV_PCI_DEVFN(__dev) == devfn) break;              \
++        }                                                                \
++        __dev;                                                           \
++    })
++#define NV_PCI_GET_CLASS(class,from)           pci_get_class(class,from)
++#else
++#define NV_PCI_DEV_PUT(dev)
++#define NV_PCI_GET_DEVICE(vendor,device,from)  pci_find_device(vendor,device,from)
++#define NV_PCI_GET_SLOT(bus,devfn)             pci_find_slot(bus,devfn)
++#define NV_PCI_GET_CLASS(class,from)           pci_find_class(class,from)
++#endif
++
++#if defined(DEBUG)
++#define NV_PRINT_AT(at)                                                    \
++    nv_printf(NV_DBG_ERRORS, "nvidia lost alloc_t: %4d  %2d  %05x 0x%08x 0x%08x\n", \
++        at->num_pages, at->usage_count, \
++        at->flags, at->page_table, at->key_mapping)
++#else
++#define NV_PRINT_AT(at)
++#endif
++
++// acpi support has been back-ported to the 2.4 kernel, but the 2.4 driver
++// model is not sufficient for full acpi support. it may work in some cases,
++// but not enough for us to officially support this configuration.
++#if defined(CONFIG_ACPI) && defined(KERNEL_2_6)
++#define NV_PM_SUPPORT_ACPI
++#endif
++
++#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
++#define NV_PM_SUPPORT_APM
++#endif
++
++/* add support for iommu.
++ * on x86_64 platforms, this uses the gart to remap pages that are > 32-bits
++ * to < 32-bits.
++ */
++#if defined(NVCPU_X86_64)
++#define NV_SG_MAP_BUFFERS 1
++#endif
++
++/* add support for software i/o tlb support.
++ * normally, you'd expect this to be transparent, but unfortunately this is not
++ * the case. for starters, the sw io tlb is a pool of pre-allocated pages that
++ * are < 32-bits. when we ask to remap a page through this sw io tlb, we are
++ * returned one of these pages, which means we have 2 different pages, rather
++ * than 2 mappings to the same page. secondly, this pre-allocated pool is very
++ * tiny, and the kernel panics when it is exhausted. try to warn the user that
++ * they need to boost the size of their pool.
++ */
++#if defined(CONFIG_SWIOTLB)
++#define NV_SWIOTLB 1
++#define NV_SWIOTLB_MAX_RETRIES 16
++extern int nv_swiotlb;
++#endif
++
++/*
++ * early 2.6 kernels changed their swiotlb codepath, running into a
++ * latent bug that returns virtual addresses when it should return
++ * physical addresses. we try to gracefully account for that, by 
++ * comparing the returned address to what should be it's virtual
++ * equivalent. this should hopefully account for when the bug is 
++ * fixed in the core kernel.
++ */
++#if defined(NV_SWIOTLB) && defined(KERNEL_2_6)
++#define NV_FIXUP_SWIOTLB_VIRT_ADDR_BUG(dma_addr) \
++    if ((dma_addr) == ((dma_addr) | PAGE_OFFSET)) \
++        (dma_addr) = __pa((dma_addr))
++#else
++#define NV_FIXUP_SWIOTLB_VIRT_ADDR_BUG(dma_addr)
++#endif
++
++#ifndef minor
++# define minor(x) MINOR(x)
++#endif
++
++#ifndef IRQ_HANDLED
++typedef void irqreturn_t;
++#define IRQ_HANDLED
++#endif
++
++#ifndef PCI_CAP_ID_EXP
++#define PCI_CAP_ID_EXP 0x10
++#endif
++
++#if defined(KERNEL_2_6) && defined(AGPGART)
++typedef struct agp_kern_info agp_kern_info;
++typedef struct agp_memory agp_memory;
++#endif
++
++#if defined(CONFIG_DEVFS_FS)
++#  if defined(KERNEL_2_6)
++     typedef void* devfs_handle_t;
++#    define NV_DEVFS_REGISTER(_name, _minor)                             \
++     ({                                                                  \
++         devfs_handle_t __handle = NULL;                                 \
++         if (devfs_mk_cdev(MKDEV(NV_MAJOR_DEVICE_NUMBER, _minor),        \
++                 S_IFCHR | S_IRUGO | S_IWUGO, _name) == 0)               \
++            __handle = (void *) 1; /* XXX Fix me! (boolean) */           \
++         __handle;                                                       \
++     })
++
++#    define NV_DEVFS_REMOVE_DEVICE(i) devfs_remove("nvidia%d", i)
++#    define NV_DEVFS_REMOVE_CONTROL() devfs_remove("nvidiactl")
++#  else // defined(KERNEL_2_4)
++#    define NV_DEVFS_REGISTER(_name, _minor)                             \
++     ({                                                                  \
++         devfs_handle_t __handle =                                       \
++             devfs_register(NULL, _name, DEVFS_FL_DEFAULT,               \
++                     NV_MAJOR_DEVICE_NUMBER, _minor,                     \
++                     S_IFCHR | S_IRUGO | S_IWUGO, &nv_fops, NULL);       \
++         __handle;                                                       \
++     })
++
++#    define NV_DEVFS_REMOVE_DEVICE(i)                                    \
++     ({                                                                  \
++         if (nv_devfs_handles[i+1] != NULL)                              \
++             devfs_unregister(nv_devfs_handles[i+1]);                    \
++      })
++#    define NV_DEVFS_REMOVE_CONTROL()                                    \
++     ({                                                                  \
++         if (nv_devfs_handles[0] != NULL)                                \
++             devfs_unregister(nv_devfs_handles[0]);                      \
++      })
++#  endif // defined(KERNEL_2_4)
++#endif // defined(CONFIG_DEVFS_FS)
++
++#if defined(CONFIG_DEVFS_FS) && !defined(KERNEL_2_6)
++#define NV_REGISTER_CHRDEV(x...)    devfs_register_chrdev(x)
++#define NV_UNREGISTER_CHRDEV(x...)  devfs_unregister_chrdev(x)
++#else
++#define NV_REGISTER_CHRDEV(x...)    register_chrdev(x)
++#define NV_UNREGISTER_CHRDEV(x...)  unregister_chrdev(x)
++#endif
++
++#if defined(NV_REMAP_PFN_RANGE_PRESENT)
++#define NV_REMAP_PAGE_RANGE(from, offset, x...) \
++     remap_pfn_range(vma, from, ((offset) >> PAGE_SHIFT), x)
++#elif defined(NV_REMAP_PAGE_RANGE_5)
++#define NV_REMAP_PAGE_RANGE(x...) remap_page_range(vma, x)
++#elif defined(NV_REMAP_PAGE_RANGE_4)
++#define NV_REMAP_PAGE_RANGE(x...) remap_page_range(x)
++#else
++#warning "conftest.sh failed, assuming remap_page_range(4)!"
++#define NV_REMAP_PAGE_RANGE(x...) remap_page_range(x)
++#endif
++
++
++#define NV_PGD_OFFSET(address, kernel, mm)              \
++   ({                                                   \
++        pgd_t *__pgd;                                   \
++        if (!kernel)                                    \
++            __pgd = pgd_offset(mm, address);            \
++        else                                            \
++            __pgd = pgd_offset_k(address);              \
++        __pgd;                                          \
++    })
++
++#define NV_PGD_PRESENT(pgd)                             \
++   ({                                                   \
++         if ((pgd != NULL) &&                           \
++             (pgd_bad(*pgd) || pgd_none(*pgd)))         \
++            /* static */ pgd = NULL;                    \
++         pgd != NULL;                                   \
++    })
++
++#if defined(pmd_offset_map)
++#define NV_PMD_OFFSET(address, pgd)                     \
++   ({                                                   \
++        pmd_t *__pmd;                                   \
++        __pmd = pmd_offset_map(pgd, address);           \
++   })
++#define NV_PMD_UNMAP(pmd) pmd_unmap(pmd);
++#else
++#if defined(PUD_SHIFT) /* 4-level pgtable */
++#define NV_PMD_OFFSET(address, pgd)                     \
++   ({                                                   \
++        pmd_t *__pmd = NULL;                            \
++        pud_t *__pud;                                   \
++        __pud = pud_offset(pgd, address);               \
++        if ((__pud != NULL) &&                          \
++            !(pud_bad(*__pud) || pud_none(*__pud)))     \
++            __pmd = pmd_offset(__pud, address);         \
++        __pmd;                                          \
++    })
++#else /* 3-level pgtable */
++#define NV_PMD_OFFSET(address, pgd)                     \
++   ({                                                   \
++        pmd_t *__pmd;                                   \
++        __pmd = pmd_offset(pgd, address);               \
++    })
++#endif
++#define NV_PMD_UNMAP(pmd)
++#endif
++
++#define NV_PMD_PRESENT(pmd)                             \
++   ({                                                   \
++        if ((pmd != NULL) &&                            \
++            (pmd_bad(*pmd) || pmd_none(*pmd)))          \
++        {                                               \
++            NV_PMD_UNMAP(pmd);                          \
++            pmd = NULL; /* mark invalid */              \
++        }                                               \
++        pmd != NULL;                                    \
++    })
++
++#if defined(pte_offset_atomic)
++#define NV_PTE_OFFSET(address, pmd)                     \
++   ({                                                   \
++        pte_t *__pte;                                   \
++        __pte = pte_offset_atomic(pmd, address);        \
++        NV_PMD_UNMAP(pmd); __pte;                       \
++    })
++#define NV_PTE_UNMAP(pte) pte_kunmap(pte);
++#elif defined(pte_offset)
++#define NV_PTE_OFFSET(address, pmd)                     \
++   ({                                                   \
++        pte_t *__pte;                                   \
++        __pte = pte_offset(pmd, address);               \
++        NV_PMD_UNMAP(pmd); __pte;                       \
++    })
++#define NV_PTE_UNMAP(pte)
++#else
++#define NV_PTE_OFFSET(address, pmd)                     \
++   ({                                                   \
++        pte_t *__pte;                                   \
++        __pte = pte_offset_map(pmd, address);           \
++        NV_PMD_UNMAP(pmd); __pte;                       \
++    })
++#define NV_PTE_UNMAP(pte) pte_unmap(pte);
++#endif
++
++#define NV_PTE_PRESENT(pte)                             \
++   ({                                                   \
++        if ((pte != NULL) && !pte_present(*pte))        \
++        {                                               \
++            NV_PTE_UNMAP(pte);                          \
++            pte = NULL; /* mark invalid */              \
++        }                                               \
++        pte != NULL;                                    \
++    })
++
++#define NV_PTE_VALUE(pte)                               \
++   ({                                                   \
++        unsigned long __pte_value = pte_val(*pte);      \
++        NV_PTE_UNMAP(pte);                              \
++        __pte_value;                                    \
++    })
++
++
++#define NV_PAGE_ALIGN(addr)             ( ((addr) + PAGE_SIZE - 1) / PAGE_SIZE)
++#define NV_MASK_OFFSET(addr)            ( (addr) & (PAGE_SIZE - 1) )
++
++#if defined(NVCPU_X86) || defined(NVCPU_X86_64)
++/* this isn't defined in some older kernel header files */
++#define NV_CPU_INTERRUPT_FLAGS_BIT (1<<9)
++#elif defined(NVCPU_IA64)
++/* For whatever reason this is not defined an any header file I could
++ * find.  From Intel IA64 Architecture Software Developers Manual Volume 2: 
++ * IA64 System Architecture page 3-7 we have:
++ */
++#define NV_CPU_INTERRUPT_FLAGS_BIT (1<<14)
++#else
++#error define NV_CPU_INTERRUPT_FLAGS_BIT
++#endif
++
++static inline int NV_IRQL_IS_RAISED(void)
++    {
++        unsigned long int eflags;
++        NV_SAVE_FLAGS(eflags);
++        return !(eflags & NV_CPU_INTERRUPT_FLAGS_BIT);
++    }
++ 
++static inline int nv_calc_order(int size)
++    {
++        int order = 0;
++        while ( ((1 << order) * PAGE_SIZE) < (size))
++        {
++            order++;
++        }
++        return order;
++    }
++
++/* mark memory UC-, rather than UC (don't use _PAGE_PWT) */
++static inline pgprot_t pgprot_noncached_weak(pgprot_t old_prot)
++    {
++        pgprot_t new_prot = old_prot;
++        if (boot_cpu_data.x86 > 3)
++            new_prot = __pgprot(pgprot_val(old_prot) | _PAGE_PCD);
++        return new_prot;
++    }
++
++#if !defined (pgprot_noncached)
++static inline pgprot_t pgprot_noncached(pgprot_t old_prot)
++    {
++        pgprot_t new_prot = old_prot;
++        if (boot_cpu_data.x86 > 3)
++            new_prot = __pgprot(pgprot_val(old_prot) | _PAGE_PCD | _PAGE_PWT);
++        return new_prot;
++    }
++#endif
++
++#if defined(NV_BUILD_NV_PAT_SUPPORT) && !defined (pgprot_writecombined)
++static inline pgprot_t pgprot_writecombined(pgprot_t old_prot)
++    {
++        pgprot_t new_prot = old_prot;
++        if (boot_cpu_data.x86 > 3)
++        {
++            pgprot_val(old_prot) &= ~(_PAGE_PCD | _PAGE_PWT);
++            new_prot = __pgprot(pgprot_val(old_prot) | _PAGE_WRTCOMB);
++        }
++        return new_prot;
++    }
++#endif
++
++#if !defined(page_to_pfn)
++#define page_to_pfn(page)  ((page) - mem_map)
++#endif
++
++/* On IA64 physical memory is partitioned into a cached and an
++ * uncached view controlled by bit 63.  Set this bit when remapping
++ * page ranges.  
++ */
++#if defined(NVCPU_IA64)
++#define phys_to_uncached(addr) ((addr) | ((unsigned long) 1<<63))
++#else
++/* Some other scheme must be used on this platform */
++#define phys_to_uncached(addr) (addr)
++#endif
++
++/*
++ * An allocated bit of memory using NV_MEMORY_ALLOCATION_OFFSET
++ *   looks like this in the driver
++ */
++
++typedef struct nv_pte_t {
++    unsigned long   phys_addr;
++    unsigned long   virt_addr;
++    dma_addr_t      dma_addr;
++#ifdef NV_SG_MAP_BUFFERS
++    struct scatterlist sg_list;
++#endif
++#ifdef CONFIG_SWIOTLB
++    unsigned long   orig_phys_addr;
++    unsigned long   orig_virt_addr;
++#endif
++} nv_pte_t;
++
++typedef struct nv_alloc_s {
++    struct nv_alloc_s *next;    
++    atomic_t       usage_count;
++    unsigned int   flags;
++    unsigned int   num_pages;
++    unsigned int   order;
++    unsigned int   size;
++    nv_pte_t     **page_table;          /* list of physical pages allocated */
++    void          *key_mapping;         /* mapping used as a key for finding this nv_alloc_t */
++                                        /*   may be the same as page_table                   */
++    unsigned int   class;
++    void          *priv_data;
++} nv_alloc_t;
++
++
++#define NV_ALLOC_TYPE_PCI      (1<<0)
++#define NV_ALLOC_TYPE_AGP      (1<<1)
++#define NV_ALLOC_TYPE_CONTIG   (1<<2)
++#define NV_ALLOC_TYPE_KERNEL   (1<<3)
++#define NV_ALLOC_TYPE_VMALLOC  (1<<4)
++
++#define NV_ALLOC_MAPPING_SHIFT      16
++#define NV_ALLOC_MAPPING(flags)     (((flags)>>NV_ALLOC_MAPPING_SHIFT)&0xff)
++#define NV_ALLOC_ENC_MAPPING(flags) ((flags)<<NV_ALLOC_MAPPING_SHIFT)
++
++#define NV_ALLOC_MAPPING_CACHED(flags) ((NV_ALLOC_MAPPING(flags) == NV_MEMORY_DEFAULT) || \
++                                        (NV_ALLOC_MAPPING(flags) == NV_MEMORY_WRITEBACK))
++
++#define NV_ALLOC_MAPPING_CONTIG(flags) ((flags) & NV_ALLOC_TYPE_CONTIG)
++#define NV_ALLOC_MAPPING_VMALLOC(flags) ((flags) & NV_ALLOC_TYPE_VMALLOC)
++
++static inline U032 nv_alloc_init_flags(int cached, int agp, int contig, int kernel)
++{
++    U032 flags = NV_ALLOC_ENC_MAPPING(cached);
++    if (agp)    flags |= NV_ALLOC_TYPE_AGP;
++    else        flags |= NV_ALLOC_TYPE_PCI;
++    if (kernel) flags |= NV_ALLOC_TYPE_KERNEL; 
++    if (kernel && !contig) flags |= NV_ALLOC_TYPE_VMALLOC;
++    if (contig && !agp) flags |= NV_ALLOC_TYPE_CONTIG;
++    return flags;
++}
++
++/* linux-specific version of old nv_state_t */
++/* this is a general os-specific state structure. the first element *must* be
++   the general state structure, for the generic unix-based code */
++typedef struct {
++    nv_state_t nv_state;
++    atomic_t usage_count;
++
++    struct pci_dev *dev;
++    nv_alloc_t *alloc_queue;
++
++    /* keep track of any pending bottom halfes */
++    struct tasklet_struct tasklet;
++
++    /* get a timer callback every second */
++    struct timer_list rc_timer;
++
++    /* per-device locking mechanism for access to core rm */
++    spinlock_t rm_lock;
++    int rm_lock_cpu;
++    int rm_lock_count;
++
++    /* lock for linux-specific data, not used by core rm */
++    struct semaphore ldata_lock;
++
++    /* lock for linux-specific alloc queue */
++    struct semaphore at_lock;
++} nv_linux_state_t;
++
++
++/*
++ * file-private data
++ * hide a pointer to our data structures in a file-private ptr
++ * there are times we need to grab this data back from the file
++ * data structure..
++ */
++
++#define NV_EVENT_FIFO_SIZE 6
++
++typedef struct
++{
++    void *nvptr;
++    U032 num_events;
++    U032 put, get;
++    spinlock_t fp_lock;
++    wait_queue_head_t waitqueue;
++    nv_event_t *event_fifo;     // fifo for storing events
++} nv_file_private_t;
++
++#define FILE_PRIVATE(filep)     ((filep)->private_data)
++
++#define NV_GET_NVFP(filep)      ((nv_file_private_t *) FILE_PRIVATE(filep))
++
++/* for the card devices */
++#define NVL_FROM_FILEP(filep)   (NV_GET_NVFP(filep)->nvptr)
++
++#define NV_GET_NVL_FROM_NV_STATE(nv) \
++    ((nv_linux_state_t *) nv->os_state)
++
++#define NV_STATE_PTR(nvl)   (&((nvl)->nv_state))
++
++
++#define NV_ATOMIC_SET(data,val)         atomic_set(&(data), (val))
++#define NV_ATOMIC_INC(data)             atomic_inc(&(data))
++#define NV_ATOMIC_DEC(data)             atomic_dec(&(data))
++#define NV_ATOMIC_DEC_AND_TEST(data)    atomic_dec_and_test(&(data))
++#define NV_ATOMIC_READ(data)            atomic_read(&(data))
++
++/*
++ * AMD Athlon processors expose a subtle bug in the Linux
++ * kernel, that may lead to AGP memory corruption. Recent
++ * kernel versions had a workaround for this problem, but
++ * 2.4.20 is the first kernel to address it properly. The
++ * page_attr API provides the means to solve the problem. 
++ */
++#if defined(NVCPU_X86) && defined(NV_CHANGE_PAGE_ATTR_PRESENT)
++static inline void NV_SET_PAGE_ATTRIB_UNCACHED(nv_pte_t *page_ptr)
++    {
++        struct page *page = virt_to_page(__va(page_ptr->phys_addr));
++        change_page_attr(page, 1, PAGE_KERNEL_NOCACHE);
++    }
++static inline void NV_SET_PAGE_ATTRIB_CACHED(nv_pte_t *page_ptr)
++    {
++        struct page *page = virt_to_page(__va(page_ptr->phys_addr));
++#ifdef CONFIG_SWIOTLB
++        if (page_ptr->orig_phys_addr)
++        {
++            nv_printf(NV_DBG_ERRORS, "NVRM: trying to set page attrib on wrong page!\n");
++            os_dbg_breakpoint();
++        }
++#endif
++        change_page_attr(page, 1, PAGE_KERNEL);
++    }
++#else
++#define NV_SET_PAGE_ATTRIB_UNCACHED(page_list)
++#define NV_SET_PAGE_ATTRIB_CACHED(page_list)
++#endif
++
++static inline void NV_UNLOCK_PAGE(nv_pte_t *page_ptr)
++    {
++        unsigned long phys_addr;
++#ifdef CONFIG_SWIOTLB
++    	if (page_ptr->orig_phys_addr) phys_addr = page_ptr->orig_phys_addr;
++        else
++#endif
++    	    phys_addr = page_ptr->phys_addr;
++        ClearPageReserved(NV_GET_PAGE_STRUCT(phys_addr));
++    }
++
++#if defined(NV_SG_MAP_BUFFERS)
++static inline int nv_sg_map_buffer(
++    struct pci_dev     *dev,
++    nv_pte_t          **page_list,
++    void               *base,
++    unsigned int        num_pages
++)
++{
++    struct scatterlist *sg_ptr = &page_list[0]->sg_list;
++    unsigned int i;
++
++    sg_ptr->page = virt_to_page(base);
++    sg_ptr->offset = (unsigned long)base & ~PAGE_MASK;
++    sg_ptr->length  = num_pages * PAGE_SIZE;
++
++#if defined(NV_SWIOTLB)
++    i = NV_SWIOTLB_MAX_RETRIES;
++    do {
++        if (pci_map_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL) == 0)
++            return 1;
++
++        if (sg_ptr->dma_address & ~PAGE_MASK)
++        {
++            struct scatterlist sg_tmp;
++            pci_unmap_sg(dev, sg_ptr, num_pages, PCI_DMA_BIDIRECTIONAL);
++
++            memset(&sg_tmp, 0, sizeof(struct scatterlist));
++            sg_tmp.page = sg_ptr->page;
++            sg_tmp.offset = sg_ptr->offset;
++            sg_tmp.length = 2048;
++
++            if (pci_map_sg(dev, &sg_tmp, 1, PCI_DMA_BIDIRECTIONAL) == 0)
++                return 1;
++
++            if (pci_map_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL) == 0)
++            {
++                pci_unmap_sg(dev, &sg_tmp, num_pages, PCI_DMA_BIDIRECTIONAL);
++                return 1;
++            }
++
++            pci_unmap_sg(dev, &sg_tmp, num_pages, PCI_DMA_BIDIRECTIONAL);
++        }
++    } while (i-- && sg_ptr->dma_address & ~PAGE_MASK);
++#else
++    if (pci_map_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL) == 0)
++    {
++        return 1;
++    }
++#endif
++
++    if (sg_ptr->dma_address & ~PAGE_MASK)
++    {
++        nv_printf(NV_DBG_ERRORS,
++            "NVRM: VM: nv_sg_map_buffer: failed to obtain aligned mapping\n");
++        pci_unmap_sg(dev, sg_ptr, num_pages, PCI_DMA_BIDIRECTIONAL);
++        return 1;
++    }
++
++    NV_FIXUP_SWIOTLB_VIRT_ADDR_BUG(sg_ptr->dma_address);
++
++    // this is a bit of a hack to make contiguous allocations easier to handle
++    // nv_sg_load below relies on the page_ptr addresses being filed in, as 
++    // well as the sg_ptr having a valid dma_address. most allocations call
++    // nv_sg_map_buffers page-by-page, but contiguous allocations will make
++    // one call for the whole allocation. make sure we correctly propogate 
++    // our dma_address through the rest of the sg_ptrs for these allocations.
++    // note we start with index 1, since index 0 is already correct
++    for (i = 1; i < num_pages; i++)
++    {
++        page_list[i]->sg_list.dma_address = sg_ptr->dma_address + (i * PAGE_SIZE);
++    }
++
++    return 0;
++}
++
++static inline int nv_sg_load(
++    struct scatterlist *sg_ptr,
++    nv_pte_t           *page_ptr
++)
++{
++    page_ptr->dma_addr = sg_ptr->dma_address;
++
++#if defined(NV_SWIOTLB)
++    // with the sw io tlb, we've actually switched to different physical pages
++    // wire in the new page's addresses, but save the original off to free later
++    if (nv_swiotlb)
++    {
++        page_ptr->orig_phys_addr = page_ptr->phys_addr;
++        page_ptr->phys_addr      = page_ptr->dma_addr;
++        page_ptr->orig_virt_addr = page_ptr->virt_addr;
++        page_ptr->virt_addr      = (unsigned long) __va(page_ptr->dma_addr);
++    }
++#endif
++
++    return 0;
++}
++
++// make sure we only unmap the page if it was really mapped through the iommu,
++// in which case the dma_addr and phys_addr will not match.
++static inline void nv_sg_unmap_buffer(
++    struct pci_dev     *dev,
++    struct scatterlist *sg_ptr,
++    nv_pte_t           *page_ptr
++)
++{
++#ifdef CONFIG_SWIOTLB
++    // for sw io tlbs, dma_addr == phys_addr currently, so the check below fails
++    // restore the original settings first, then the following check will work
++    if (nv_swiotlb && page_ptr->orig_phys_addr)
++    {
++        page_ptr->phys_addr      = page_ptr->orig_phys_addr;
++        page_ptr->virt_addr      = page_ptr->orig_virt_addr;
++        page_ptr->orig_phys_addr = 0;
++        page_ptr->orig_virt_addr = 0;
++    }
++#endif
++
++    if (page_ptr->dma_addr != page_ptr->phys_addr)
++    {
++        pci_unmap_sg(dev, sg_ptr, 1, PCI_DMA_BIDIRECTIONAL);
++        page_ptr->dma_addr = 0;
++    }
++}
++#endif  /* NV_SG_MAP_BUFFERS */
++
++/*
++ * Basic support for kgdb assertions.
++ */
++#if defined(CONFIG_X86_REMOTE_DEBUG)
++#include <linux/gdb.h>
++
++#define NV_ASSERT(message, condition) KGDB_ASSERT(message, condition)
++#else
++#if defined(DEBUG)
++#define NV_ASSERT(message, condition) \
++if (!(condition)) { \
++    nv_printf(NV_DBG_ERRORS, "NVRM: ASSERT: %s\n", message); \
++    os_dbg_breakpoint(); \
++}
++#else
++#define NV_ASSERT(message, condition)
++#endif /* DEBUG */
++#endif
++
++
++#endif  /* _NV_LINUX_H_ */
+diff -ruN nvidia-kernel.orig/nv/nv-vm.c nvidia-kernel/nv/nv-vm.c
+--- nvidia-kernel.orig/nv/nv-vm.c	2005-01-11 17:19:49.000000000 -0800
++++ nvidia-kernel/nv/nv-vm.c	2005-02-18 15:08:04.603166251 -0800
+@@ -53,12 +53,13 @@
+  * conflicts. we try to rely on the kernel's provided interfaces when possible,
+  * but need additional flushing on earlier kernels.
+  */
+-
++#if defined(KERNEL_2_4)
+ /* wrap CACHE_FLUSH so we can pass it to smp_call_function */
+ static void cache_flush(void *p)
+ {
+     CACHE_FLUSH();
+ }
++#endif
+ 
+ /*
+  * 2.4 kernels handle flushing in the change_page_attr() call, but kernels 
+@@ -138,13 +139,18 @@
+  */
+ 
+ int nv_vm_malloc_pages(
+-    nv_alloc_t       *at
++    nv_state_t *nv,
++    nv_alloc_t *at
+ )
+ {
+     /* point page_ptr at the start of the actual page list */
+-    nv_pte_t *page_ptr = at->page_table;
++    nv_pte_t *page_ptr = *at->page_table;
+     int i;
+     unsigned long virt_addr = 0, phys_addr;
++#if defined(NV_SG_MAP_BUFFERS)
++    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++    struct pci_dev *dev = nvl->dev;
++#endif
+ 
+     nv_printf(NV_DBG_MEMINFO, "NVRM: VM: nv_vm_malloc_pages: %d pages\n",
+         at->num_pages);
+@@ -175,8 +181,7 @@
+         // for amd 64-bit platforms, remap pages to make them 32-bit addressable
+         // in this case, we need the final remapping to be contiguous, so we
+         // have to do the whole mapping at once, instead of page by page
+-        if (nv_sg_map_buffer(at->dev, &at->sg_list[0],
+-                             (void *) virt_addr, at->num_pages))
++        if (nv_sg_map_buffer(dev, at->page_table, (void *) virt_addr, at->num_pages))
+         {
+             nv_printf(NV_DBG_ERRORS,
+                 "NVRM: VM: nv_vm_malloc_pages: failed to sg map contiguous pages\n");
+@@ -224,7 +229,7 @@
+         /* lock the page for dma purposes */
+         SetPageReserved(NV_GET_PAGE_STRUCT(phys_addr));
+ 
+-        page_ptr = &at->page_table[i];
++        page_ptr = at->page_table[i];
+         page_ptr->phys_addr = phys_addr;
+         page_ptr->virt_addr = virt_addr;
+         page_ptr->dma_addr = page_ptr->phys_addr;
+@@ -235,7 +240,7 @@
+ #if defined(NV_SG_MAP_BUFFERS)
+         if (!NV_ALLOC_MAPPING_CONTIG(at->flags))
+         {
+-            if (nv_sg_map_buffer(at->dev, &at->sg_list[i], 
++            if (nv_sg_map_buffer(dev, &at->page_table[i],
+                                  __va(page_ptr->phys_addr), 1))
+             {
+                 nv_printf(NV_DBG_ERRORS,
+@@ -243,7 +248,7 @@
+                 goto failed;
+             }
+         }
+-        nv_sg_load(&at->sg_list[i], page_ptr);
++        nv_sg_load(&at->page_table[i]->sg_list, page_ptr);
+ #endif
+         virt_addr += PAGE_SIZE;
+     }
+@@ -258,7 +263,7 @@
+ 
+     for (; i >= 0; i--)
+     {
+-        page_ptr = &at->page_table[i];
++        page_ptr = at->page_table[i];
+ 
+         // if we failed when allocating this page, skip over it
+         // but if we failed pci_map_sg, make sure to free this page
+@@ -267,7 +272,7 @@
+             NV_UNLOCK_PAGE(page_ptr);
+ #if defined(NV_SG_MAP_BUFFERS)
+             if (!NV_ALLOC_MAPPING_CONTIG(at->flags))
+-                nv_sg_unmap_buffer(at->dev, &at->sg_list[i], page_ptr);
++                nv_sg_unmap_buffer(dev, &at->page_table[i]->sg_list, page_ptr);
+ #endif
+             if (!NV_ALLOC_MAPPING_CACHED(at->flags))
+                 NV_SET_PAGE_ATTRIB_CACHED(page_ptr);
+@@ -279,15 +284,15 @@
+ 
+     if (NV_ALLOC_MAPPING_CONTIG(at->flags))
+     {
+-        page_ptr = at->page_table;
++        page_ptr = *at->page_table;
+ #if defined(NV_SG_MAP_BUFFERS)
+-        nv_sg_unmap_buffer(at->dev, &at->sg_list[0], page_ptr);
++        nv_sg_unmap_buffer(dev, &at->page_table[0]->sg_list, page_ptr);
+ #endif
+         NV_FREE_PAGES(page_ptr->virt_addr, at->order);
+     }
+     else if (NV_ALLOC_MAPPING_VMALLOC(at->flags))
+     {
+-        page_ptr = at->page_table;
++        page_ptr = *at->page_table;
+         NV_VFREE((void *) page_ptr->virt_addr, at->size);
+     }
+ 
+@@ -296,7 +301,7 @@
+ 
+ // unlock the pages we've locked down for dma purposes
+ void nv_vm_unlock_pages(
+-    nv_alloc_t       *at
++    nv_alloc_t *at
+ )
+ {
+     nv_pte_t *page_ptr;
+@@ -315,17 +320,22 @@
+ 
+     for (i = 0; i < at->num_pages; i++)
+     {
+-        page_ptr = &at->page_table[i];
++        page_ptr = at->page_table[i];
+         NV_UNLOCK_PAGE(page_ptr);
+     }
+ }
+ 
+ void nv_vm_free_pages(
+-    nv_alloc_t       *at
++    nv_state_t *nv,
++    nv_alloc_t *at
+ )
+ {
+     nv_pte_t *page_ptr;
+     int i;
++#if defined(NV_SG_MAP_BUFFERS)
++    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++    struct pci_dev *dev = nvl->dev;
++#endif
+ 
+     nv_printf(NV_DBG_MEMINFO, "NVRM: VM: nv_vm_free_pages: %d pages\n",
+         at->num_pages);
+@@ -339,10 +349,10 @@
+ 
+     for (i = 0; i < at->num_pages; i++)
+     {
+-        page_ptr = &at->page_table[i];
++        page_ptr = at->page_table[i];
+ #if defined(NV_SG_MAP_BUFFERS)
+         if (!NV_ALLOC_MAPPING_CONTIG(at->flags))
+-            nv_sg_unmap_buffer(at->dev, &at->sg_list[i], page_ptr);
++            nv_sg_unmap_buffer(dev, &at->page_table[i]->sg_list, page_ptr);
+ #endif
+         if (!NV_ALLOC_MAPPING_CACHED(at->flags))
+             NV_SET_PAGE_ATTRIB_CACHED(page_ptr);
+@@ -353,15 +363,15 @@
+ 
+     if (NV_ALLOC_MAPPING_CONTIG(at->flags))
+     {
+-        page_ptr = at->page_table;
++        page_ptr = *at->page_table;
+ #if defined(NV_SG_MAP_BUFFERS)
+-        nv_sg_unmap_buffer(at->dev, &at->sg_list[0], page_ptr);
++        nv_sg_unmap_buffer(dev, &at->page_table[0]->sg_list, page_ptr);
+ #endif
+         NV_FREE_PAGES(page_ptr->virt_addr, at->order);
+     }
+     else if (NV_ALLOC_MAPPING_VMALLOC(at->flags))
+     {
+-        page_ptr = at->page_table;
++        page_ptr = *at->page_table;
+         NV_VFREE((void *) page_ptr->virt_addr, at->size);
+     }
+ }
+diff -ruN nvidia-kernel.orig/nv/nv-vm.h nvidia-kernel/nv/nv-vm.h
+--- nvidia-kernel.orig/nv/nv-vm.h	2005-01-11 17:19:49.000000000 -0800
++++ nvidia-kernel/nv/nv-vm.h	2005-02-18 15:07:19.974094183 -0800
+@@ -11,9 +11,9 @@
+ #ifndef _NV_VM_H_
+ #define _NV_VM_H_
+ 
+-int      nv_vm_malloc_pages(nv_alloc_t *);
++int      nv_vm_malloc_pages(nv_state_t *, nv_alloc_t *);
+ void     nv_vm_unlock_pages(nv_alloc_t *);
+-void     nv_vm_free_pages(nv_alloc_t *);
++void     nv_vm_free_pages(nv_state_t *, nv_alloc_t *);
+ 
+ #if defined(NV_DBG_MEM)
+ void     nv_vm_list_page_count(nv_pte_t *, unsigned long);
+@@ -21,11 +21,12 @@
+ #define  nv_vm_list_page_count(page_ptr, num_pages)
+ #endif
+ 
+-#define nv_vm_unlock_and_free_pages(at_count, at) \
+-    if (at->page_table) {                         \
+-        if (at_count == 0)                        \
+-            nv_vm_unlock_pages(at);               \
+-        nv_vm_free_pages(at);                     \
++#define NV_VM_UNLOCK_AND_FREE_PAGES(nv, at_count, at)   \
++    if (at->page_table)                                 \
++    {                                                   \
++        if (at_count == 0)                              \
++            nv_vm_unlock_pages(at);                     \
++        nv_vm_free_pages(nv, at);                       \
+     }
+ 
+ #endif
+diff -ruN nvidia-kernel.orig/nv/nv.c nvidia-kernel/nv/nv.c
+--- nvidia-kernel.orig/nv/nv.c	2005-01-11 17:19:49.000000000 -0800
++++ nvidia-kernel/nv/nv.c	2005-02-18 15:08:12.955056936 -0800
+@@ -63,6 +63,8 @@
+ int nv_swiotlb = 0;
+ #endif
+ 
++static kmem_cache_t *nv_pte_t_cache = NULL;
++
+ // allow an easy way to convert all debug printfs related to events
+ // back and forth between 'info' and 'errors'
+ #if defined(NV_DBG_EVENTS)
+@@ -266,42 +268,41 @@
+ )
+ {
+     nv_alloc_t *at;
+-    int pt_size;
++    unsigned int pt_size, i;
+ 
+     NV_KMALLOC(at, sizeof(nv_alloc_t));
+     if (at == NULL)
+     {
+-        nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate alloc_t\n");
++        nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate alloc info\n");
+         return NULL;
+     }
+ 
+     memset(at, 0, sizeof(nv_alloc_t));
+ 
+-    pt_size = num_pages *  sizeof(nv_pte_t);
+-    NV_KMALLOC(at->page_table, pt_size);
+-    if (at->page_table == NULL)
++    pt_size = num_pages *  sizeof(nv_pte_t *);
++    if (os_alloc_mem((void **)&at->page_table, pt_size) != RM_OK)
+     {
+         nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate page table\n");
+         NV_KFREE(at, sizeof(nv_alloc_t));
+         return NULL;
+     }
++
+     memset(at->page_table, 0, pt_size);
+     at->num_pages = num_pages;
+     NV_ATOMIC_SET(at->usage_count, 0);
+ 
+-#if defined(NV_SG_MAP_BUFFERS)
+-    at->dev = dev;
+-    pt_size = num_pages * sizeof(struct scatterlist);
+-    NV_KMALLOC(at->sg_list, pt_size);
+-    if (at->sg_list == NULL)
++    for (i = 0; i < at->num_pages; i++)
+     {
+-        nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate scatter gather list\n");
+-        NV_KFREE(at->page_table, pt_size);
+-        NV_KFREE(at, sizeof(nv_alloc_t));
+-        return NULL;
++        NV_KMEM_CACHE_ALLOC(at->page_table[i], nv_pte_t_cache, nv_pte_t);
++        if (at->page_table[i] == NULL)
++        {
++            nv_printf(NV_DBG_ERRORS,
++                      "NVRM: failed to allocate page table entry\n");
++            nvos_free_alloc(at);
++            return NULL;
++        }
++        memset(at->page_table[i], 0, sizeof(nv_pte_t));
+     }
+-    memset(at->sg_list, 0, pt_size);
+-#endif
+ 
+     return at;
+ }
+@@ -311,6 +312,8 @@
+     nv_alloc_t *at
+ )
+ {
++    unsigned int pt_size, i;
++
+     if (at == NULL)
+         return -1;
+ 
+@@ -320,13 +323,16 @@
+     // we keep the page_table around after freeing the pages
+     // for bookkeeping reasons. Free the page_table and assume
+     // the underlying pages are already unlocked and freed.
+-    if (at->page_table)
+-        NV_KFREE(at->page_table, at->num_pages * sizeof(nv_pte_t));
+-
+-#if defined(NV_SG_MAP_BUFFERS)
+-    if (at->sg_list)
+-        NV_KFREE(at->sg_list, at->num_pages * sizeof(struct scatterlist));
+-#endif
++    if (at->page_table != NULL)
++    {
++        for (i = 0; i < at->num_pages; i++)
++        {
++            if (at->page_table[i] != NULL)
++                NV_KMEM_CACHE_FREE(at->page_table[i], nv_pte_t, nv_pte_t_cache);
++        }
++        pt_size = at->num_pages * sizeof(nv_pte_t *);
++        os_free_mem(at->page_table);
++    }
+ 
+     NV_KFREE(at, sizeof(nv_alloc_t));
+ 
+@@ -594,7 +600,7 @@
+             int i;
+             for (i = 0; i < at->num_pages; i++)
+             {
+-                unsigned long offset = at->page_table[i].phys_addr;
++                unsigned long offset = at->page_table[i]->phys_addr;
+                 if ((address >= offset) &&
+                     (address < (offset + PAGE_SIZE)))
+                     return at;
+@@ -931,6 +937,13 @@
+     }
+ #endif
+ 
++    NV_KMEM_CACHE_CREATE(nv_pte_t_cache, "nv_pte_t", nv_pte_t);
++    if (nv_pte_t_cache == NULL)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: pte cache allocation failed\n");
++        goto failed;
++    }
++ 
+     // Init the resource manager
+     if (!rm_init_rm())
+     {
+@@ -972,6 +985,14 @@
+     return 0;
+ 
+ failed:
++    if (nv_pte_t_cache != NULL)
++        NV_KMEM_CACHE_DESTROY(nv_pte_t_cache);
++
++#if defined(NV_PM_SUPPORT_APM)
++    for (i = 0; i < num_nv_devices; i++)
++        if (apm_nv_dev[i] != NULL) pm_unregister(apm_nv_dev[i]);
++#endif
++
+ #ifdef CONFIG_DEVFS_FS
+     NV_DEVFS_REMOVE_CONTROL();
+     for (i = 0; i < num_nv_devices; i++)
+@@ -1101,6 +1122,8 @@
+     nv_printf(NV_DBG_ERRORS, "NVRM: final mem usage: vm 0x%x km 0x%x fp 0x%x\n",
+         vm_usage, km_usage, fp_usage);
+ #endif
++
++    NV_KMEM_CACHE_DESTROY(nv_pte_t_cache);
+ }
+ 
+ module_init(nvidia_init_module);
+@@ -1249,15 +1272,15 @@
+     index = (address - vma->vm_start)>>PAGE_SHIFT;
+ 
+     // save that index into our page list (make sure it doesn't already exist)
+-    if (at->page_table[index].phys_addr)
++    if (at->page_table[index]->phys_addr)
+     {
+         nv_printf(NV_DBG_ERRORS, "NVRM: page slot already filled in nopage handler!\n");
+         os_dbg_breakpoint();
+     }
+ 
+-    at->page_table[index].phys_addr = (page_to_pfn(page_ptr) << PAGE_SHIFT);
+-    at->page_table[index].dma_addr  = (page_to_pfn(page_ptr) << PAGE_SHIFT);
+-    at->page_table[index].virt_addr = (unsigned long) __va(page_to_pfn(page_ptr) << PAGE_SHIFT);
++    at->page_table[index]->phys_addr = (page_to_pfn(page_ptr) << PAGE_SHIFT);
++    at->page_table[index]->dma_addr  = (page_to_pfn(page_ptr) << PAGE_SHIFT);
++    at->page_table[index]->virt_addr = (unsigned long) __va(page_to_pfn(page_ptr) << PAGE_SHIFT);
+ 
+     return page_ptr;
+ #endif
+@@ -1551,7 +1574,7 @@
+     /* NV fb space */
+     else if (IS_FB_OFFSET(nv, NV_VMA_OFFSET(vma), vma->vm_end - vma->vm_start))
+     {
+-        vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
++        vma->vm_page_prot = pgprot_noncached_weak(vma->vm_page_prot);
+         if (NV_REMAP_PAGE_RANGE(vma->vm_start,
+                              NV_VMA_OFFSET(vma),
+                              vma->vm_end - vma->vm_start,
+@@ -1604,9 +1627,8 @@
+         }
+         nv_vm_list_page_count(at->page_table, at->num_pages);
+ 
+-        /* prevent the swapper from swapping it out */
+-        /* mark the memory i/o so the buffers aren't dumped on core dumps */
+-        vma->vm_flags |= (VM_LOCKED | VM_IO);
++        // mark it as IO so that we don't dump it on core dump
++        vma->vm_flags |= VM_IO;
+     }
+ 
+     /* Magic allocator */
+@@ -1670,7 +1692,7 @@
+         start = vma->vm_start;
+         while (pages--)
+         {
+-            page = (unsigned long) at->page_table[i++].phys_addr;
++            page = (unsigned long) at->page_table[i++]->phys_addr;
+             if (NV_REMAP_PAGE_RANGE(start, page, PAGE_SIZE, vma->vm_page_prot))
+                 return -EAGAIN;
+             start += PAGE_SIZE;
+@@ -2368,8 +2390,8 @@
+ 
+         for (i = 0; i < at->num_pages; i++)
+         {
+-            if (address == at->page_table[i].phys_addr)
+-                return (void *)(at->page_table[i].virt_addr + offset);
++            if (address == at->page_table[i]->phys_addr)
++                return (void *)(at->page_table[i]->virt_addr + offset);
+         }
+     }
+ 
+@@ -2400,8 +2422,8 @@
+ 
+         for (i = 0; i < at->num_pages; i++)
+         {
+-            if (address == at->page_table[i].phys_addr)
+-                return (unsigned long)at->page_table[i].dma_addr + offset;
++            if (address == at->page_table[i]->phys_addr)
++                return (unsigned long)at->page_table[i]->dma_addr + offset;
+         }
+     }
+ 
+@@ -2427,9 +2449,9 @@
+             unsigned long address = dma_address & PAGE_MASK;
+             for (i = 0; i < at->num_pages; i++)
+             {
+-                if (address == at->page_table[i].dma_addr)
++                if (address == at->page_table[i]->dma_addr)
+                 {
+-                    return at->page_table[i].phys_addr + offset;
++                    return at->page_table[i]->phys_addr + offset;
+                 }
+             }
+         }
+@@ -2466,7 +2488,7 @@
+         int i;
+         for (i = 0; i < at->num_pages; i++)
+         {
+-            if (address == (unsigned long) at->page_table[i].dma_addr)
++            if (address == (unsigned long) at->page_table[i]->dma_addr)
+             {
+                 return (void *)((unsigned long) at->key_mapping + 
+                     (i * PAGE_SIZE));
+@@ -2492,26 +2514,23 @@
+ )
+ {
+     struct mm_struct *mm;
+-    pgd_t *pg_dir;
+-    pmd_t *pg_mid_dir;
+-    pte_t *pte;
++    pgd_t *pgd = NULL;
++    pmd_t *pmd = NULL;
++    pte_t *pte = NULL;
+     unsigned long retval;
+ 
+     mm = (kern) ? &init_mm : current->mm;
+     spin_lock(&mm->page_table_lock);
+ 
+-    if (kern) pg_dir = pgd_offset_k(address);
+-    else pg_dir = pgd_offset(mm, address);
+-
+-    if (!pg_dir || pgd_none(*pg_dir))
++    pgd = NV_PGD_OFFSET(address, kern, mm);
++    if (!NV_PGD_PRESENT(pgd))
+         goto failed;
+ 
+-    NV_PMD_OFFSET(address, pg_dir, pg_mid_dir);
+-    if (!NV_PMD_PRESENT(pg_mid_dir))
++    pmd = NV_PMD_OFFSET(address, pgd);
++    if (!NV_PMD_PRESENT(pmd))
+         goto failed;
+ 
+-    NV_PTE_OFFSET(address, pg_mid_dir, pte);
+-
++    pte = NV_PTE_OFFSET(address, pmd);
+     if (!NV_PTE_PRESENT(pte))
+         goto failed;
+ 
+@@ -2630,7 +2649,7 @@
+             nvl_add_alloc(nvl, at);
+         } else {
+             /* use nvidia's nvagp support */
+-            if (nv_vm_malloc_pages(at))
++            if (nv_vm_malloc_pages(nv, at))
+                 goto failed;
+ 
+             at->class = class;
+@@ -2654,7 +2673,7 @@
+             if (rm_status)
+             {
+                 nvl_remove_alloc(nvl, at);
+-                nv_vm_unlock_and_free_pages(NV_ATOMIC_READ(at->usage_count), at);
++                NV_VM_UNLOCK_AND_FREE_PAGES(nv, NV_ATOMIC_READ(at->usage_count), at);
+                 goto failed;
+             }
+             at->priv_data = *priv_data;
+@@ -2666,12 +2685,12 @@
+     else 
+     {
+ 
+-        if (nv_vm_malloc_pages(at))
++        if (nv_vm_malloc_pages(nv, at))
+             goto failed;
+ 
+         if (kernel)
+         {
+-            *pAddress = (void *) at->page_table[0].virt_addr;
++            *pAddress = (void *) at->page_table[0]->virt_addr;
+         }
+         else
+         {
+@@ -2679,7 +2698,7 @@
+              * so use the first page, which is page-aligned. this way, our 
+              * allocated page table does not need to be page-aligned
+              */
+-            *pAddress = (void *) at->page_table[0].phys_addr;
++            *pAddress = (void *) at->page_table[0]->phys_addr;
+         }
+ 
+         nvl_add_alloc(nvl, at);
+@@ -2743,7 +2762,7 @@
+             rmStatus = rm_free_agp_pages(nv, pAddress, priv_data);
+             if (rmStatus == RM_OK)
+             {
+-                nv_vm_unlock_and_free_pages(NV_ATOMIC_READ(at->usage_count), at);
++                NV_VM_UNLOCK_AND_FREE_PAGES(nv, NV_ATOMIC_READ(at->usage_count), at);
+             }
+         }
+     } else {
+@@ -2759,7 +2778,7 @@
+ 
+         NV_ATOMIC_DEC(at->usage_count);
+ 
+-        nv_vm_unlock_and_free_pages(NV_ATOMIC_READ(at->usage_count), at);
++        NV_VM_UNLOCK_AND_FREE_PAGES(nv, NV_ATOMIC_READ(at->usage_count), at);
+     }
+ 
+     if (NV_ATOMIC_READ(at->usage_count) == 0)
+@@ -2769,21 +2788,13 @@
+ }
+ 
+ 
+-/* avoid compiler warnings on UP kernels, 
+- * when spinlock macros are defined away 
+- */
+-#define NO_COMPILER_WARNINGS(nvl) \
+-    if (nvl == NULL) return
+-
+-
+ static void nv_lock_init_locks
+ ( 
+     nv_state_t *nv
+ )
+ {
+-    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
+-
+-    NO_COMPILER_WARNINGS(nvl);
++    nv_linux_state_t *nvl;
++    nvl = NV_GET_NVL_FROM_NV_STATE(nv);
+ 
+     spin_lock_init(&nvl->rm_lock);
+ 
+@@ -2799,28 +2810,33 @@
+     nv_state_t *nv
+ )
+ {
+-    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
+-    NO_COMPILER_WARNINGS(nvl);
++    nv_linux_state_t *nvl;
++    int cpu;
++
++    nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++    cpu = get_cpu();
+ 
+-    if (nvl->rm_lock_cpu == smp_processor_id())
++    if (nvl->rm_lock_cpu == cpu)
+     {
+         nvl->rm_lock_count++;
++        put_cpu();
+         return;
+     }
+ 
++    put_cpu();
+     spin_unlock_wait(&nvl->rm_lock);
+     spin_lock_irq(&nvl->rm_lock);
+ 
+-   nvl->rm_lock_cpu = smp_processor_id();
+-   nvl->rm_lock_count = 1;
++    nvl->rm_lock_cpu = smp_processor_id();
++    nvl->rm_lock_count = 1;
+ }
+ 
+ void NV_API_CALL nv_unlock_rm(
+     nv_state_t *nv
+ )
+ {
+-    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
+-    NO_COMPILER_WARNINGS(nvl);
++    nv_linux_state_t *nvl;
++    nvl = NV_GET_NVL_FROM_NV_STATE(nv);
+ 
+     if (--nvl->rm_lock_count)
+         return;
+@@ -2987,32 +3003,47 @@
+      */
+     if ( (!NV_AGP_ENABLED(nv)) && (config & NVOS_AGP_CONFIG_NVAGP) )
+     {
+-        /* make sure the user does not have agpgart loaded */
+-        if (inter_module_get("drm_agp")) {
++#if defined(KERNEL_2_4)
++        if (inter_module_get("drm_agp"))
++        {
+             inter_module_put("drm_agp");
+-            nv_printf(NV_DBG_WARNINGS, "NVRM: not using NVAGP, AGPGART is loaded!!\n");
+-        } else {
+-#if defined(CONFIG_X86_64) && defined(CONFIG_GART_IOMMU)
++            nv_printf(NV_DBG_WARNINGS, "NVRM: not using NVAGP, AGPGART is loaded!\n");
++            return status;
++        }
++#elif defined(AGPGART)
++        int error;
++        /*
++         * We can only safely use NvAGP when no backend has been
++         * registered with the AGPGART frontend. This condition
++         * is only met when the acquire function returns -EINVAL.
++         *
++         * Other return codes indicate that a backend is present
++         * and was either acquired, busy or else unavailable.
++         */
++        if ((error = agp_backend_acquire()) != -EINVAL)
++        {
++            if (!error) agp_backend_release();
+             nv_printf(NV_DBG_WARNINGS,
+-                "NVRM: not using NVAGP, kernel was compiled with GART_IOMMU support!!\n");
+-#else
+-            status = rm_init_agp(nv);
+-            if (status == RM_OK)
+-            {
+-                nv->agp_config = NVOS_AGP_CONFIG_NVAGP;
+-                nv->agp_status = NV_AGP_STATUS_ENABLED;
+-            }
++                      "NVRM: not using NVAGP, an AGPGART backend is loaded!\n");
++            return status;
++        }
+ #endif
++#if defined(CONFIG_X86_64) && defined(CONFIG_GART_IOMMU)
++        nv_printf(NV_DBG_WARNINGS,
++            "NVRM: not using NVAGP, kernel was compiled with GART_IOMMU support!\n");
++#else
++        status = rm_init_agp(nv);
++        if (status == RM_OK)
++        {
++            nv->agp_config = NVOS_AGP_CONFIG_NVAGP;
++            nv->agp_status = NV_AGP_STATUS_ENABLED;
+         }
++#endif
+     }
+ 
+     if (NV_AGP_ENABLED(nv))
+         old_error = 0; /* report new errors */
+ 
+-    nv_printf(NV_DBG_SETUP, 
+-        "NVRM: agp_init finished with status 0x%x and config %d\n",
+-        status, nv->agp_config);
+-
+     return status;
+ }
+ 
+@@ -3036,9 +3067,6 @@
+     nv->agp_config = NVOS_AGP_CONFIG_DISABLE_AGP;
+     nv->agp_status = NV_AGP_STATUS_DISABLED;
+ 
+-    nv_printf(NV_DBG_SETUP, "NVRM: teardown finished with status 0x%x\n", 
+-        status);
+-
+     return status;
+ }
+ 
+@@ -3065,7 +3093,7 @@
+     }
+ 
+     /* get the physical address of this page */
+-    *paddr = (U032) ((NV_UINTPTR_T)at->page_table[index].dma_addr);
++    *paddr = (U032) ((NV_UINTPTR_T)at->page_table[index]->dma_addr);
+ 
+     return RM_OK;
+ }
+diff -ruN nvidia-kernel.orig/nv/nv.c.orig nvidia-kernel/nv/nv.c.orig
+--- nvidia-kernel.orig/nv/nv.c.orig	1969-12-31 16:00:00.000000000 -0800
++++ nvidia-kernel/nv/nv.c.orig	2005-02-18 15:08:04.612165056 -0800
+@@ -0,0 +1,3396 @@
++/* _NVRM_COPYRIGHT_BEGIN_
++ *
++ * Copyright 1999-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_
++ */
++
++
++#include "nv-misc.h"
++#include "os-interface.h"
++#include "nv-linux.h"
++#include "nv_compiler.h"
++#include "os-agp.h"
++#include "nv-vm.h"
++
++#ifdef MODULE_ALIAS_CHARDEV_MAJOR
++MODULE_ALIAS_CHARDEV_MAJOR(NV_MAJOR_DEVICE_NUMBER);
++#endif
++
++/*
++ * our global state; one per device
++ */
++
++static int num_nv_devices = 0;
++
++nv_linux_state_t nv_linux_devices[NV_MAX_DEVICES] = { { { 0 } } };
++
++#if defined(NV_PM_SUPPORT_APM)
++static struct pm_dev *apm_nv_dev[NV_MAX_DEVICES] = { 0 };
++#endif
++
++#if defined(NV_BUILD_NV_PAT_SUPPORT)
++static int pat_enabled = 0;
++#endif
++
++/*
++ * And one for the control device
++ */
++
++nv_linux_state_t nv_ctl_device = { { 0 } };
++wait_queue_head_t nv_ctl_waitqueue;
++
++// keep track of opened clients and their process id so they
++//   can be free'd up on abnormal close
++nv_client_t       nv_clients[NV_MAX_CLIENTS];
++
++#ifdef CONFIG_PROC_FS
++struct proc_dir_entry *proc_nvidia;
++#endif
++
++#ifdef CONFIG_DEVFS_FS
++devfs_handle_t nv_devfs_handles[NV_MAX_DEVICES+1];
++#endif
++
++#ifdef NV_CLASS_SIMPLE_CREATE_PRESENT
++struct class_simple *class_nvidia;
++#endif
++
++#ifdef NV_SWIOTLB
++int nv_swiotlb = 0;
++#endif
++
++static kmem_cache_t *nv_pte_t_cache = NULL;
++
++// allow an easy way to convert all debug printfs related to events
++// back and forth between 'info' and 'errors'
++#if defined(NV_DBG_EVENTS)
++#define NV_DBG_EVENTINFO NV_DBG_ERRORS
++#else
++#define NV_DBG_EVENTINFO NV_DBG_INFO
++#endif
++
++// verify access to pci config space wasn't disabled behind our back
++// unfortunately, XFree86 enables/disables memory access in pci config space at
++// various times (such as restoring initial pci config space settings during vt
++// switches or when doing mulicard). As a result, all of our register accesses
++// are garbage at this point. add a check to see if access was disabled and
++// reenable any such access.
++#define NV_CHECK_PCI_CONFIG(nv) \
++    nv_check_pci_config(nv, __LINE__)
++
++static inline void nv_check_pci_config(nv_state_t *nv, int line)
++{
++    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++    unsigned short cmd, flag = 0;
++
++    // don't do this on the control device, only the actual devices
++    if (nv->flags & NV_FLAG_CONTROL)
++        return;
++
++    pci_read_config_word(nvl->dev, PCI_COMMAND, &cmd);
++    if (!(cmd & PCI_COMMAND_MASTER))
++    {
++        nv_printf(NV_DBG_USERERRORS, "NVRM: restoring bus mastering! (%d)\n", line);
++        cmd |= PCI_COMMAND_MASTER;
++        flag = 1;
++    }
++
++    if (!(cmd & PCI_COMMAND_MEMORY))
++    {
++        nv_printf(NV_DBG_USERERRORS, "NVRM: restoring MEM access! (%d)\n", line);
++        cmd |= PCI_COMMAND_MEMORY;
++        flag = 1;
++    }
++
++    if (flag)
++        pci_write_config_word(nvl->dev, PCI_COMMAND, cmd);
++}
++
++/***
++ *** STATIC functions, only in this file
++ ***/
++
++/* nvos_ functions.. do not take a state device parameter  */
++static int      nvos_post_vbios(nv_ioctl_post_vbios_t *info);
++static void     nvos_proc_create(void);
++static void     nvos_proc_remove_all(struct proc_dir_entry *);
++static void     nvos_proc_remove(void);
++static int      nvos_count_devices(void);
++
++static nv_alloc_t  *nvos_create_alloc(struct pci_dev *, int);
++static int          nvos_free_alloc(nv_alloc_t *);
++
++/* nvl_ functions.. take a linux state device pointer */
++static nv_alloc_t  *nvl_find_alloc(nv_linux_state_t *, unsigned long, unsigned long);
++static int          nvl_add_alloc(nv_linux_state_t *, nv_alloc_t *);
++static int          nvl_remove_alloc(nv_linux_state_t *, nv_alloc_t *);
++
++/* lock-related functions that should only be called from this file */
++static void nv_lock_init_locks(nv_state_t *nv);
++
++#define nv_init_lock(lock)  spin_lock_init(&lock)
++#define nv_lock(lock)       spin_lock(&lock)
++#define nv_unlock(lock)     spin_unlock(&lock)
++#define nv_down(lock)       down(&lock)
++#define nv_up(lock)         up(&lock)
++
++#define nv_lock_irq(lock,flags)    spin_lock_irqsave(&lock,flags)
++#define nv_unlock_irq(lock,flags)  spin_unlock_irqrestore(&lock,flags)
++
++
++/***
++ *** EXPORTS to Linux Kernel
++ ***/
++
++/* nv_kern_ functions, interfaces used by linux kernel */
++void          nv_kern_vma_open(struct vm_area_struct *vma);
++void          nv_kern_vma_release(struct vm_area_struct *vma);
++
++int           nv_kern_open(struct inode *, struct file *);
++int           nv_kern_close(struct inode *, struct file *);
++int           nv_kern_mmap(struct file *, struct vm_area_struct *);
++unsigned int  nv_kern_poll(struct file *, poll_table *);
++int           nv_kern_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
++void          nv_kern_isr_bh(unsigned long);
++irqreturn_t   nv_kern_isr(int, void *, struct pt_regs *);
++void          nv_kern_rc_timer(unsigned long);
++#if defined(NV_PM_SUPPORT_APM)
++int           nv_kern_apm_event(struct pm_dev *dev, pm_request_t rqst, void *data);
++#endif
++
++int           nv_kern_read_cardinfo(char *, char **, off_t off, int, int *, void *);
++int           nv_kern_read_status(char *, char **, off_t off, int, int *, void *);
++int           nv_kern_read_agpinfo(char *, char **, off_t off, int, int *, void *);
++int           nv_kern_read_version(char *, char **, off_t off, int, int *, void *);
++
++int           nv_kern_ctl_open(struct inode *, struct file *);
++int           nv_kern_ctl_close(struct inode *, struct file *);
++unsigned int  nv_kern_ctl_poll(struct file *, poll_table *);
++
++int nv_kern_probe(struct pci_dev *, const struct pci_device_id *);
++#if defined(NV_PM_SUPPORT_ACPI)
++int nv_kern_acpi_standby(struct pci_dev *, u32);
++int nv_kern_acpi_resume(struct pci_dev *);
++#endif
++
++/***
++ *** see nv.h for functions exported to other parts of resman
++ ***/
++
++static struct pci_device_id nv_pci_table[] = {
++    { 
++        .vendor      = PCI_VENDOR_ID_NVIDIA,
++        .device      = PCI_ANY_ID,
++        .subvendor   = PCI_ANY_ID,
++        .subdevice   = PCI_ANY_ID,
++        .class       = (PCI_CLASS_DISPLAY_VGA << 8),
++        .class_mask  = ~0,
++    },
++    { }
++};
++
++MODULE_DEVICE_TABLE(pci, nv_pci_table);
++
++static struct pci_driver nv_pci_driver = {
++    .name     = "nvidia",
++    .id_table = nv_pci_table,
++    .probe    = nv_kern_probe,
++#if defined(NV_PM_SUPPORT_ACPI)
++    .suspend  = nv_kern_acpi_standby,
++    .resume   = nv_kern_acpi_resume,
++#endif
++};
++
++/* character driver entry points */
++
++static struct file_operations nv_fops = {
++    .owner     = THIS_MODULE,
++    .poll      = nv_kern_poll,
++    .ioctl     = nv_kern_ioctl,
++    .mmap      = nv_kern_mmap,
++    .open      = nv_kern_open,
++    .release   = nv_kern_close,
++};
++
++// Our reserved major device number.
++int nv_major = NV_MAJOR_DEVICE_NUMBER;
++
++// pull in the pointer to the NVID stamp from the binary module
++extern const char *pNVRM_ID;
++
++#if NV_ENABLE_MEM_TRACKING
++// poor man's memory tracker, see nv-linux.h
++int vm_usage = 0;
++int km_usage = 0;
++int fp_usage = 0;
++
++struct mem_track_t *vm_list = NULL;
++struct mem_track_t *km_list = NULL;
++struct mem_track_t *fp_list = NULL;
++#endif /* NV_ENABLE_MEM_TRACKING */
++
++/***
++ *** STATIC functions
++ ***/
++
++/* specify that this card needs it's vbios posted */
++static int nvos_post_vbios(nv_ioctl_post_vbios_t *info)
++{
++    int i;
++
++    for (i = 0; i < NV_MAX_DEVICES; i++)
++    {
++        nv_state_t *nv = NV_STATE_PTR(&nv_linux_devices[i]);
++        if (nv->bus == info->bus && nv->slot == info->slot)
++        {
++            // we assume any device was already posted and rely on
++            // X to tell us which cards need posting. But if we've
++            // already manually posted a card, it doesn't need to 
++            // be reposted again.
++            if (!(nv->flags & NV_FLAG_WAS_POSTED))
++            {
++                nv->flags |= NV_FLAG_NEEDS_POSTING;
++            }
++        }
++    }
++
++    return 0;
++}
++
++static 
++nv_alloc_t *nvos_create_alloc(
++    struct pci_dev *dev,
++    int num_pages
++)
++{
++    nv_alloc_t *at;
++    unsigned int pt_size, i;
++
++    NV_KMALLOC(at, sizeof(nv_alloc_t));
++    if (at == NULL)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate alloc info\n");
++        return NULL;
++    }
++
++    memset(at, 0, sizeof(nv_alloc_t));
++
++    pt_size = num_pages *  sizeof(nv_pte_t *);
++    if (os_alloc_mem((void **)&at->page_table, pt_size) != RM_OK)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate page table\n");
++        NV_KFREE(at, sizeof(nv_alloc_t));
++        return NULL;
++    }
++
++    memset(at->page_table, 0, pt_size);
++    at->num_pages = num_pages;
++    NV_ATOMIC_SET(at->usage_count, 0);
++
++    for (i = 0; i < at->num_pages; i++)
++    {
++        NV_KMEM_CACHE_ALLOC(at->page_table[i], nv_pte_t_cache, nv_pte_t);
++        if (at->page_table[i] == NULL)
++        {
++            nv_printf(NV_DBG_ERRORS,
++                      "NVRM: failed to allocate page table entry\n");
++            nvos_free_alloc(at);
++            return NULL;
++        }
++        memset(at->page_table[i], 0, sizeof(nv_pte_t));
++    }
++
++    return at;
++}
++
++static 
++int nvos_free_alloc(
++    nv_alloc_t *at
++)
++{
++    unsigned int pt_size, i;
++
++    if (at == NULL)
++        return -1;
++
++    if (NV_ATOMIC_READ(at->usage_count))
++        return 1;
++
++    // we keep the page_table around after freeing the pages
++    // for bookkeeping reasons. Free the page_table and assume
++    // the underlying pages are already unlocked and freed.
++    if (at->page_table != NULL)
++    {
++        for (i = 0; i < at->num_pages; i++)
++        {
++            if (at->page_table[i] != NULL)
++                NV_KMEM_CACHE_FREE(at->page_table[i], nv_pte_t, nv_pte_t_cache);
++        }
++        pt_size = at->num_pages * sizeof(nv_pte_t *);
++        os_free_mem(at->page_table);
++    }
++
++    NV_KFREE(at, sizeof(nv_alloc_t));
++
++    return 0;
++}
++
++static u8 nvos_find_agp_capability(struct pci_dev *dev)
++{
++    u16 status;
++    u8  cap_ptr, cap_id;
++
++    pci_read_config_word(dev, PCI_STATUS, &status);
++    status &= PCI_STATUS_CAP_LIST;
++    if (!status)
++        return 0;
++
++    switch (dev->hdr_type) {
++        case PCI_HEADER_TYPE_NORMAL:
++        case PCI_HEADER_TYPE_BRIDGE:
++            pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &cap_ptr);
++            break;
++        default:
++            return 0;
++    }
++
++    do {
++        cap_ptr &= 0xfc;
++        pci_read_config_byte(dev, cap_ptr + PCI_CAP_LIST_ID, &cap_id);
++        if (cap_id == PCI_CAP_ID_AGP)
++            return cap_ptr;
++        pci_read_config_byte(dev, cap_ptr + PCI_CAP_LIST_NEXT, &cap_ptr);
++    } while (cap_ptr && cap_id != 0xff);
++
++    return 0;
++}
++
++static u8 nvos_find_pci_express_capability(struct pci_dev *dev)
++{
++    u16 status;
++    u8  cap_ptr, cap_id;
++
++    pci_read_config_word(dev, PCI_STATUS, &status);
++    status &= PCI_STATUS_CAP_LIST;
++    if (!status)
++        return 0;
++
++    switch (dev->hdr_type) {
++        case PCI_HEADER_TYPE_NORMAL:
++        case PCI_HEADER_TYPE_BRIDGE:
++            pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &cap_ptr);
++            break;
++        default:
++            return 0;
++    }
++
++    do {
++        cap_ptr &= 0xfc;
++        pci_read_config_byte(dev, cap_ptr + PCI_CAP_LIST_ID, &cap_id);
++        if (cap_id == PCI_CAP_ID_EXP)
++            return cap_ptr;
++        pci_read_config_byte(dev, cap_ptr + PCI_CAP_LIST_NEXT, &cap_ptr);
++    } while (cap_ptr && cap_id != 0xff);
++
++    return 0;
++}
++
++static struct pci_dev* nvos_get_agp_device_by_class(unsigned int class)
++{
++    struct pci_dev *dev, *fdev;
++    u32 slot, func, fn;
++
++    dev = NV_PCI_GET_CLASS(class << 8, NULL);
++    while (dev) {
++        slot = NV_PCI_SLOT_NUMBER(dev);
++        for (func = 0; func < 8; func++) {
++            fn = PCI_DEVFN(slot, func);
++            fdev = NV_PCI_GET_SLOT(NV_PCI_BUS_NUMBER(dev), fn);
++            if (!fdev)
++                continue;
++            if (nvos_find_agp_capability(fdev)) {
++                NV_PCI_DEV_PUT(dev);
++                return fdev;
++            }
++            NV_PCI_DEV_PUT(fdev);
++        }
++        dev = NV_PCI_GET_CLASS(class << 8, dev);
++    }
++
++    return NULL;
++}
++
++static struct pci_dev* nv_get_pci_device(nv_state_t *nv)
++{
++    struct pci_dev *dev;
++
++    dev = NV_PCI_GET_DEVICE(nv->vendor_id, nv->device_id, NULL);
++    while (dev) {
++        if (NV_PCI_SLOT_NUMBER(dev) == nv->slot
++                && NV_PCI_BUS_NUMBER(dev) == nv->bus)
++            return dev;
++        dev = NV_PCI_GET_DEVICE(nv->vendor_id, nv->device_id, dev);
++    }
++
++    return NULL;
++}
++
++static void nvos_proc_create(void)
++{
++#ifdef CONFIG_PROC_FS
++    struct pci_dev *dev;
++    int i = 0;
++    char name[6];
++
++    struct proc_dir_entry *entry;
++    struct proc_dir_entry *proc_nvidia_agp, *proc_nvidia_cards;
++
++    /* world readable directory */
++    int flags = S_IFDIR | S_IRUGO | S_IXUGO;
++
++    nv_state_t *nv;
++    nv_linux_state_t *nvl;
++    nv_linux_state_t *nv_max_devices;
++
++    proc_nvidia = create_proc_entry("nvidia", flags, proc_root_driver);
++    if (!proc_nvidia)
++        goto failed;
++
++    proc_nvidia_cards = create_proc_entry("cards", flags, proc_nvidia);
++    if (!proc_nvidia_cards)
++        goto failed;
++
++    proc_nvidia_agp = create_proc_entry("agp", flags, proc_nvidia);
++    if (!proc_nvidia_agp)
++        goto failed;
++
++    /*
++     * Set the module owner to ensure that the reference
++     * count reflects accesses to the proc files.
++     */
++    proc_nvidia->owner       = THIS_MODULE;
++    proc_nvidia_cards->owner = THIS_MODULE;
++    proc_nvidia_agp->owner   = THIS_MODULE;
++
++    nv_max_devices = nv_linux_devices + NV_MAX_DEVICES;
++    for (nvl = nv_linux_devices; nvl < nv_max_devices; nvl++) 
++    {
++        nv = NV_STATE_PTR(nvl);
++
++        if (nv->device_id == 0)
++            break;
++
++        /* world readable file */
++        flags = S_IFREG | S_IRUGO;
++
++        dev = nv_get_pci_device(nv);
++        if (!dev)
++            break;
++
++        sprintf(name, "%d", i++);
++        entry = create_proc_entry(name, flags, proc_nvidia_cards);
++        if (!entry) {
++            NV_PCI_DEV_PUT(dev);
++            goto failed;
++        }
++
++        entry->data = nv;
++        entry->read_proc = nv_kern_read_cardinfo;
++        entry->owner = THIS_MODULE;
++
++        if (nvos_find_agp_capability(dev)) {
++            entry = create_proc_entry("status", flags, proc_nvidia_agp);
++            if (!entry) {
++                NV_PCI_DEV_PUT(dev);
++                goto failed;
++            }
++
++            entry->data = nv;
++            entry->read_proc = nv_kern_read_status;
++            entry->owner = THIS_MODULE;
++
++            entry = create_proc_entry("card", flags, proc_nvidia_agp);
++            if (!entry) {
++                NV_PCI_DEV_PUT(dev);
++                goto failed;
++            }
++
++            entry->data = nv;
++            entry->read_proc = nv_kern_read_agpinfo;
++            entry->owner = THIS_MODULE;
++        }
++
++        NV_PCI_DEV_PUT(dev);
++    }
++
++    entry = create_proc_entry("version", flags, proc_nvidia);
++    if (!entry)
++        goto failed;
++
++    entry->read_proc = nv_kern_read_version;
++    entry->owner = THIS_MODULE;
++
++    entry = create_proc_entry("host-bridge", flags, proc_nvidia_agp);
++    if (!entry)
++        goto failed;
++
++    entry->data = NULL;
++    entry->read_proc = nv_kern_read_agpinfo;
++    entry->owner = THIS_MODULE;
++
++    return;
++
++failed:
++    nv_printf(NV_DBG_ERRORS, "NVRM: failed to create /proc entries!\n");
++    nvos_proc_remove_all(proc_nvidia);
++#endif
++}
++
++#ifdef CONFIG_PROC_FS
++static void nvos_proc_remove_all(struct proc_dir_entry *entry)
++{
++    while (entry) {
++        struct proc_dir_entry *next = entry->next;
++        if (entry->subdir)
++            nvos_proc_remove_all(entry->subdir);
++        remove_proc_entry(entry->name, entry->parent);
++        if (entry == proc_nvidia)
++            break;
++        entry = next;
++    }
++}
++#endif
++
++static void nvos_proc_remove(void)
++{
++#ifdef CONFIG_PROC_FS
++    nvos_proc_remove_all(proc_nvidia);
++#endif
++}
++
++/*
++ * Given a virtual address, fid the 'at' that owns it
++ * Uses the physical address as the key.
++ */
++static nv_alloc_t *nvl_find_alloc(
++    nv_linux_state_t    *nvl,
++    unsigned long  address,
++    unsigned long  flags
++)
++{
++    nv_alloc_t *at;
++
++    for (at = nvl->alloc_queue; at; at = at->next)
++    {
++        // make sure this 'at' matches the flags the caller provided
++        // ie, don't mistake a pci allocation with an agp allocation
++        if (!(at->flags & flags))
++            continue;
++
++        // most mappings will be found based on the 'key'
++        if (address == ((unsigned long) at->key_mapping))
++            return at;
++
++        if (at->page_table)
++        {
++            int i;
++            for (i = 0; i < at->num_pages; i++)
++            {
++                unsigned long offset = at->page_table[i]->phys_addr;
++                if ((address >= offset) &&
++                    (address < (offset + PAGE_SIZE)))
++                    return at;
++            }
++        }
++
++    }
++
++    /* failure is not necessarily an error if the caller
++       was just probing an address */
++    nv_printf(NV_DBG_INFO, "NVRM: could not find map for vm 0x%lx\n", address);
++    return NULL;
++}
++
++static int nvl_add_alloc(
++    nv_linux_state_t *nvl, 
++    nv_alloc_t *at
++)
++{
++    nv_down(nvl->at_lock);
++    at->next = nvl->alloc_queue;
++    nvl->alloc_queue = at;
++    nv_up(nvl->at_lock);
++    return 0;
++}
++
++static int nvl_remove_alloc(
++    nv_linux_state_t *nvl, 
++    nv_alloc_t *at
++)
++{
++    nv_alloc_t *tmp, *prev;
++
++    if (nvl->alloc_queue == at)
++    {
++        nvl->alloc_queue = nvl->alloc_queue->next;
++        return 0;
++    }
++
++    for (tmp = prev = nvl->alloc_queue; tmp; prev = tmp, tmp = tmp->next)
++    {
++        if (tmp == at)
++        {
++            prev->next = tmp->next;
++            return 0;
++        }
++    }
++
++    return -1;
++}
++
++#if defined(NV_BUILD_NV_PAT_SUPPORT)
++/*
++ * Private PAT support for use by the NVIDIA driver. This is an
++ * interim solution until the kernel offers PAT support.
++ */
++static int   __check_pat_support       (void);
++static void  __nv_setup_pat_entries    (void *);
++static void  __nv_restore_pat_entries  (void *);
++static int   __nv_enable_pat_support   (void);
++static void  __nv_disable_pat_support  (void);
++
++#define NV_READ_PAT_ENTRIES(pat1, pat2)   rdmsr(IA32_CR_PAT, (pat1), (pat2))
++#define NV_WRITE_PAT_ENTRIES(pat1, pat2)  wrmsr(IA32_CR_PAT, (pat1), (pat2))
++#define NV_PAT_ENTRY(pat, index)          (((pat) & (0xff<<((index)*8)))>>((index)*8))
++
++static inline void __nv_disable_caches(unsigned long *cr4)
++{
++    unsigned long cr0 = read_cr0();
++    write_cr0(((cr0 & (0xdfffffff)) | 0x40000000));
++    wbinvd();
++    *cr4 = read_cr4();
++    if (*cr4 & 0x80) write_cr4(*cr4 & ~0x80);
++    __flush_tlb();
++}
++
++static inline void __nv_enable_caches(unsigned long cr4)
++{
++    unsigned long cr0 = read_cr0();
++    wbinvd();
++    __flush_tlb();
++    write_cr0((cr0 & 0x9fffffff));
++    if (cr4 & 0x80) write_cr4(cr4);
++}
++
++static int __check_pat_support()
++{
++    unsigned int pat1, pat2, i;
++
++    if (!test_bit(X86_FEATURE_PAT, (volatile unsigned long *)&boot_cpu_data.x86_capability))
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: cpu does not support PAT, aborting..\n");
++        return 0;
++    }
++
++    NV_READ_PAT_ENTRIES(pat1, pat2);
++
++    for (i = 0; i < 4; i++)
++    {
++         if (NV_PAT_ENTRY(pat1, i) == 1)
++         {
++             nv_printf(NV_DBG_ERRORS, "NVRM: PAT index %d already configured for Write-Combining!\n", i);
++             nv_printf(NV_DBG_ERRORS, "NVRM: Aborting, due to PAT already being configured\n");
++             return 0;
++         }
++    }
++
++    for (i = 0; i < 4; i++)
++    {
++         if (NV_PAT_ENTRY(pat2, i) == 1)
++         {
++             nv_printf(NV_DBG_ERRORS, "NVRM: PAT index %d already configured for Write-Combining!\n", i + 4);
++             nv_printf(NV_DBG_ERRORS, "NVRM: Aborting, due to PAT already being configured\n");
++             return 0;
++         }
++    }
++
++    return 1;
++}
++
++static unsigned long orig_pat1, orig_pat2;
++
++static void __nv_setup_pat_entries(void *info)
++{
++    unsigned long pat1, pat2, cr4;
++    unsigned long eflags;
++
++    NV_SAVE_FLAGS(eflags);
++    NV_CLI();
++    __nv_disable_caches(&cr4);
++
++    NV_READ_PAT_ENTRIES(pat1, pat2);
++
++    pat1 &= 0xffff00ff;
++    pat1 |= 0x00000100;
++
++    NV_WRITE_PAT_ENTRIES(pat1, pat2);
++
++    __nv_enable_caches(cr4);
++    NV_RESTORE_FLAGS(eflags);
++}
++
++static void __nv_restore_pat_entries(void *info)
++{
++    unsigned long cr4;
++    unsigned long eflags;
++
++    NV_SAVE_FLAGS(eflags);
++    NV_CLI();
++    __nv_disable_caches(&cr4);
++
++    NV_WRITE_PAT_ENTRIES(orig_pat1, orig_pat2);
++
++    __nv_enable_caches(cr4);
++    NV_RESTORE_FLAGS(eflags);
++}
++
++static int __nv_enable_pat_support()
++{
++    unsigned long pat1, pat2;
++
++    if (pat_enabled)
++        return 1;
++
++    if (!__check_pat_support())
++        return 0;
++
++    NV_READ_PAT_ENTRIES(orig_pat1, orig_pat2);
++    nv_printf(NV_DBG_SETUP, "saved orig pats as 0x%lx 0x%lx\n", orig_pat1, orig_pat2);
++
++#ifdef CONFIG_SMP
++    if (smp_call_function(__nv_setup_pat_entries, NULL, 1, 1) != 0)
++        return 0;
++#endif
++
++    __nv_setup_pat_entries(NULL);
++
++    pat_enabled = 1;
++
++    NV_READ_PAT_ENTRIES(pat1, pat2);
++    nv_printf(NV_DBG_SETUP, "changed pats to 0x%lx 0x%lx\n", pat1, pat2);
++
++    return 1;
++}
++
++static void __nv_disable_pat_support()
++{
++    unsigned long pat1, pat2;
++
++    if (!pat_enabled)
++        return;
++
++#ifdef CONFIG_SMP
++    if (smp_call_function(__nv_restore_pat_entries, NULL, 1, 1) != 0)
++        return;
++#endif
++
++    __nv_restore_pat_entries(NULL);
++
++    pat_enabled = 0;
++
++    NV_READ_PAT_ENTRIES(pat1, pat2);
++    nv_printf(NV_DBG_SETUP, "restored orig pats as 0x%lx 0x%lx\n", pat1, pat2);
++}
++
++#endif /* defined(NV_BUILD_NV_PAT_SUPPORT) */
++
++/***
++ *** EXPORTS to Linux Kernel
++ ***/
++
++static int __init nvidia_init_module(void)
++{
++    int rc, i, count;
++
++    memset(nv_linux_devices, 0, sizeof(nv_linux_devices));
++
++    if (pci_register_driver(&nv_pci_driver) < 0)
++    {
++        pci_unregister_driver(&nv_pci_driver); // XXX ???
++        nv_printf(NV_DBG_ERRORS, "NVRM: no NVIDIA graphics adapter found\n");
++        return -ENODEV;
++    }
++
++    count = nvos_count_devices();
++    if (num_nv_devices != count)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: the NVIDIA probe routine was not "
++            "called for %d device(s)!!\n", count - num_nv_devices);
++        if (!num_nv_devices)
++        {
++            nv_printf(NV_DBG_ERRORS, "NVRM: no devices probed, aborting!\n");
++            nv_printf(NV_DBG_ERRORS, "NVRM: this often occurs when rivafb is "
++                "loaded and claims the device's resources.\n");
++            nv_printf(NV_DBG_ERRORS, "NVRM: try removing the rivafb module "
++                "(or reconfiguring your kernel to remove\n");
++            nv_printf(NV_DBG_ERRORS, "NVRM: rivafb support) and then try "
++                "loading the NVIDIA kernel module again.\n");
++            pci_unregister_driver(&nv_pci_driver);
++            return -ENODEV;
++        }
++    }
++
++    nv_printf(NV_DBG_ERRORS, "NVRM: loading %s\n", pNVRM_ID);
++
++    rc = NV_REGISTER_CHRDEV(nv_major, "nvidia", &nv_fops);
++    if (rc < 0)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: register chrdev failed\n");
++        pci_unregister_driver(&nv_pci_driver);
++        return rc;
++    }
++
++#ifdef NV_CLASS_SIMPLE_CREATE_PRESENT
++    class_nvidia = class_simple_create(THIS_MODULE, "nvidia");
++    if (IS_ERR(class_nvidia))
++    {
++        rc = PTR_ERR(class_nvidia);
++        nv_printf(NV_DBG_ERRORS, "NVRM: class_simple creation failed\n");
++        /* goto failed; */
++    }
++#endif
++
++#ifdef CONFIG_DEVFS_FS
++    do
++    {
++        char name[10];
++
++        nv_devfs_handles[0] = NV_DEVFS_REGISTER("nvidiactl", 255);
++
++        for (i = 0; i < num_nv_devices; i++)
++        {
++            sprintf(name, "nvidia%d", i);
++            nv_devfs_handles[i+1] = NV_DEVFS_REGISTER(name, i);
++        }
++
++        for (i = 0; i <= num_nv_devices; i++)
++        {
++            if (nv_devfs_handles[i] == NULL)
++            {
++                rc = -ENOMEM; /* XXX Fix me? (rc) */
++                nv_printf(NV_DBG_ERRORS, "NVRM: devfs register failed\n");
++                goto failed;
++            }
++        }
++    } while(0);
++#endif
++
++#ifdef NV_CLASS_SIMPLE_CREATE_PRESENT
++    if (!IS_ERR(class_nvidia))
++    {
++        /*
++         * XXX We don't consider class_simple errors fatal for
++         * now to avoid unexpected failures.
++         */
++        char name[10];
++
++        class_simple_device_add(class_nvidia,
++            MKDEV(NV_MAJOR_DEVICE_NUMBER, 255), NULL, "nvidiactl");
++
++        for (i = 0; i < num_nv_devices; i++)
++        {
++            sprintf(name, "nvidia%d", i);
++            class_simple_device_add(class_nvidia,
++                MKDEV(NV_MAJOR_DEVICE_NUMBER, i), &nv_linux_devices[i].dev->dev, name);
++        }
++    }
++#endif
++
++    nv_printf(NV_DBG_INFO, "NVRM: major number %d\n", nv_major);
++
++    /* instantiate tasklets */
++    for (i = 0; i < NV_MAX_DEVICES; i++)
++    {
++        /*
++         * We keep one tasklet per card to avoid latency issues with more
++         * than one device; no two instances of a single tasklet are ever
++         * executed concurrently.
++         */
++        NV_ATOMIC_SET(nv_linux_devices[i].tasklet.count, 1);
++    }
++
++    // init the nvidia control device
++    {
++        nv_state_t *nv_ctl = NV_STATE_PTR(&nv_ctl_device);
++        nv_ctl->os_state = (void *) &nv_ctl_device;
++        nv_lock_init_locks(nv_ctl);
++    }
++
++#if defined(NV_PM_SUPPORT_APM)
++    for (i = 0; i < num_nv_devices; i++)
++    {
++        apm_nv_dev[i] = pm_register(PM_PCI_DEV, PM_SYS_VGA, nv_kern_apm_event);
++    }
++#endif
++
++    NV_KMEM_CACHE_CREATE(nv_pte_t_cache, "nv_pte_t", nv_pte_t);
++    if (nv_pte_t_cache == NULL)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: pte cache allocation failed\n");
++        goto failed;
++    }
++ 
++    // Init the resource manager
++    if (!rm_init_rm())
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: rm_init_rm() failed\n");
++        rc = -EIO;
++        goto failed;
++    }
++
++    // load our local registry entries into the registry
++    {
++        extern nv_parm_t nv_parms[];
++        rm_load_registry(nv_parms);
++    }
++
++    /* create /proc/driver/nvidia */
++    nvos_proc_create();
++
++#if defined(DEBUG)
++    inter_module_register("nv_linux_devices", THIS_MODULE, nv_linux_devices);
++#endif
++
++    /* Register ioctl conversions for 32 bit clients */
++    rm_register_ioctl_conversions();
++
++#ifdef NV_SWIOTLB
++    // may need a better test than this eventually
++    if (swiotlb)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: WARNING:  You are probably using the kernel's swiotlb interface.\n");
++        nv_printf(NV_DBG_ERRORS, "NVRM: Be very careful with this interface, as it is easy\n");
++        nv_printf(NV_DBG_ERRORS, "NVRM: to exhaust this interface's memory buffer, at which\n");
++        nv_printf(NV_DBG_ERRORS, "NVRM: point it panics the kernel.  Please increase the size\n");
++        nv_printf(NV_DBG_ERRORS, "NVRM: of this buffer by specifying a larger buffer size with\n");
++        nv_printf(NV_DBG_ERRORS, "NVRM: the swiotlb kernel option, eg: \"swiotlb=16384\"\n");
++        nv_swiotlb = 1;
++    }
++#endif
++
++    return 0;
++
++failed:
++    if (nv_pte_t_cache != NULL)
++        NV_KMEM_CACHE_DESTROY(nv_pte_t_cache);
++
++#if defined(NV_PM_SUPPORT_APM)
++    for (i = 0; i < num_nv_devices; i++)
++        if (apm_nv_dev[i] != NULL) pm_unregister(apm_nv_dev[i]);
++#endif
++
++#ifdef CONFIG_DEVFS_FS
++    NV_DEVFS_REMOVE_CONTROL();
++    for (i = 0; i < num_nv_devices; i++)
++        NV_DEVFS_REMOVE_DEVICE(i);
++#endif
++
++    if (NV_UNREGISTER_CHRDEV(nv_major, "nvidia") < 0)
++        nv_printf(NV_DBG_ERRORS, "NVRM: unregister nv chrdev failed\n");
++
++#ifdef NV_CLASS_SIMPLE_CREATE_PRESENT
++    class_simple_device_remove(MKDEV(NV_MAJOR_DEVICE_NUMBER, 255));
++    for (i = 0; i < num_nv_devices; i++)
++        class_simple_device_remove(MKDEV(NV_MAJOR_DEVICE_NUMBER, i));
++    class_simple_destroy(class_nvidia);
++#endif
++
++    for (i = 0; i < num_nv_devices; i++)
++    {
++        if (nv_linux_devices[i].dev)
++        {
++            struct pci_dev *dev = nv_linux_devices[i].dev;
++            release_mem_region(NV_PCI_RESOURCE_START(dev, 1),
++                               NV_PCI_RESOURCE_SIZE(dev, 1));
++        }
++    }
++
++    pci_unregister_driver(&nv_pci_driver);
++    return rc;
++}
++
++static void __exit nvidia_exit_module(void)
++{
++    int i;
++    nv_linux_state_t *nvl, *max_devices;
++
++    nv_printf(NV_DBG_INFO, "NVRM: nvidia_exit_module\n");
++
++#ifdef CONFIG_DEVFS_FS
++    NV_DEVFS_REMOVE_CONTROL();
++    for (i = 0; i < num_nv_devices; i++)
++        NV_DEVFS_REMOVE_DEVICE(i);
++#endif
++
++    if (NV_UNREGISTER_CHRDEV(nv_major, "nvidia") < 0)
++        nv_printf(NV_DBG_ERRORS, "NVRM: unregister nv chrdev failed\n");
++
++#ifdef NV_CLASS_SIMPLE_CREATE_PRESENT
++    class_simple_device_remove(MKDEV(NV_MAJOR_DEVICE_NUMBER, 255));
++    for (i = 0; i < num_nv_devices; i++)
++        class_simple_device_remove(MKDEV(NV_MAJOR_DEVICE_NUMBER, i));
++    class_simple_destroy(class_nvidia);
++#endif
++
++    for (i = 0; i < num_nv_devices; i++)
++    {
++        if (nv_linux_devices[i].dev)
++        {
++            struct pci_dev *dev = nv_linux_devices[i].dev;
++            release_mem_region(NV_PCI_RESOURCE_START(dev, 1),
++                               NV_PCI_RESOURCE_SIZE(dev, 1));
++            NV_PCI_DISABLE_DEVICE(dev);
++        }
++    }
++
++    pci_unregister_driver(&nv_pci_driver);
++
++    /* remove /proc/driver/nvidia */
++    nvos_proc_remove();
++
++#if defined(DEBUG)
++    inter_module_unregister("nv_linux_devices");
++#endif
++
++#if defined(NV_PM_SUPPORT_APM)
++    for (i = 0; i < num_nv_devices; i++)
++    {
++        pm_unregister(apm_nv_dev[i]);
++    }
++#endif
++
++    // Shutdown the resource manager
++    rm_shutdown_rm();
++
++    /*
++     * Make sure we freed up all the mappings. The kernel should
++     * do this automatically before calling close.
++     */
++    max_devices = nv_linux_devices + NV_MAX_DEVICES;
++    for (nvl = nv_linux_devices; nvl < max_devices; nvl++)
++    {
++        nv_state_t *nv = NV_STATE_PTR(nvl);
++
++        if (nvl->alloc_queue)
++        {
++            nv_alloc_t *at = nvl->alloc_queue;
++            while (at)
++            {
++                NV_PRINT_AT(at);
++                at = at->next;
++            }
++        }
++
++        if (nv->flags & NV_FLAG_MAP_REGS_EARLY)
++        {
++            NV_ASSERT("regs not mapped when they should be!",
++                      nv->bar.regs.map != NULL);
++            os_unmap_kernel_space(nv->bar.regs.map, nv->bar.regs.size);
++            nv->bar.regs.map = NULL;
++            nv->bar.regs.map_u = (nv_phwreg_t) NULL;
++        }
++    }
++
++    /* Unregister ioctl conversions for 32 bit clients */
++    rm_unregister_ioctl_conversions();
++
++#if defined(NV_BUILD_NV_PAT_SUPPORT)
++    if (pat_enabled)
++    {
++        __nv_disable_pat_support();
++    }
++#endif
++
++#if NV_ENABLE_MEM_TRACKING
++    nv_list_mem(vm_list);
++    nv_list_mem(km_list);
++    nv_list_mem(fp_list);
++    nv_printf(NV_DBG_ERRORS, "NVRM: final mem usage: vm 0x%x km 0x%x fp 0x%x\n",
++        vm_usage, km_usage, fp_usage);
++#endif
++
++    NV_KMEM_CACHE_DESTROY(nv_pte_t_cache);
++}
++
++module_init(nvidia_init_module);
++module_exit(nvidia_exit_module);
++
++
++/* this is only called when the vmas are duplicated.
++ * this appears to only happen when the process is cloned to create
++ * a new process, and not when the process is threaded.
++ *
++ * increment the usage count for the physical pages, so when this
++ * clone unmaps the mappings, the pages are not deallocated under
++ * the original process.
++ */
++void
++nv_kern_vma_open(struct vm_area_struct *vma)
++{
++    nv_printf(NV_DBG_MEMINFO, "NVRM: VM: vma_open for 0x%x - 0x%x, offset 0x%x\n",
++        vma->vm_start, vma->vm_end, NV_VMA_OFFSET(vma));
++
++    if (NV_VMA_PRIVATE(vma))
++    {
++        nv_alloc_t *at = (nv_alloc_t *) NV_VMA_PRIVATE(vma);
++        NV_ATOMIC_INC(at->usage_count);
++
++        nv_printf(NV_DBG_MEMINFO,
++            "NVRM: VM:   at 0x%x, usage count %d, page_table 0x%x\n",
++            at, at->usage_count, at->page_table);
++
++        nv_vm_list_page_count(at->page_table, at->num_pages);
++    }
++}
++
++
++void
++nv_kern_vma_release(struct vm_area_struct *vma)
++{
++    nv_printf(NV_DBG_MEMINFO,
++        "NVRM: VM: vma_release for 0x%x - 0x%x, offset 0x%x\n",
++        vma->vm_start, vma->vm_end, NV_VMA_OFFSET(vma));
++
++    if (NV_VMA_PRIVATE(vma))
++    {
++        nv_alloc_t *at = (nv_alloc_t *) NV_VMA_PRIVATE(vma);
++
++        NV_ATOMIC_DEC(at->usage_count);
++
++        nv_printf(NV_DBG_MEMINFO,
++            "NVRM: VM:  at 0x%x, usage count %d, page_table 0x%x\n",
++            at, at->usage_count, at->page_table);
++
++        nv_vm_list_page_count(at->page_table, at->num_pages);
++
++        // if usage_count is down to 0, the kernel virtual mapping was freed
++        // but the underlying physical pages were not, due to the reserved bit
++        // being set. We need to clear the reserved bit, then munmap will
++        // zap the pages and free the physical pages.
++        if (NV_ATOMIC_READ(at->usage_count) == 0)
++        {
++            if (at->page_table)
++                nv_vm_unlock_pages(at);
++            nvos_free_alloc(at);
++            NV_VMA_PRIVATE(vma) = NULL;
++        }
++    }
++}
++
++
++/* at this point, this code just plain won't work with 2.2 kernels.
++ * additionally, only ia64 & the 460GX need a nopage handler, and 2.2 doesn't
++ * work on ia64 anyways. It's expected that at some point other agp chipsets
++ * will work similar to the 460GX (AGP 3.0 spec), so pre-emptively make sure
++ * this works on our standard ia32 driver.
++ */
++
++/* AGP allocations under the 460GX are not mapped to the aperture
++ * addresses by the CPU.  This nopage handler will fault on CPU
++ * accesses to AGP memory and map the address to the correct page.
++ */
++struct page *nv_kern_vma_nopage(
++    struct vm_area_struct *vma,
++    unsigned long address,
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 1))
++    int *type
++#else
++    int write_access
++#endif
++)
++{
++#if defined(NVCPU_IA64) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 9))
++    nv_alloc_t *at, *tmp;
++    nv_linux_state_t *nvl;
++    nv_state_t *nv;
++    struct page *page_ptr;
++    int rm_status, index;
++
++    at = NV_VMA_PRIVATE(vma);
++    if (at == NULL)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: nopage handler called without an at: "
++                  "vm_start 0x%x, at 0x%x\n", vma->vm_start, at);
++        return NOPAGE_SIGBUS;
++    }
++
++    // let's verify this 'at' is valid
++    // I can imagine cases where something went wrong, the 'at' and underlying
++    // pages were freed, but the virtual mapping still exists and this 'at'
++    // pointer is potentially pointing to freed memory. Let's make sure we can
++    // still find the 'at' in our alloc_queue.
++    nvl = NVL_FROM_FILEP(vma->vm_file);
++    if (nvl == NULL)
++        return NOPAGE_SIGBUS;
++
++    nv = (nv_state_t *) nvl;
++
++    rm_status = RM_ERROR;
++    tmp = nvl->alloc_queue;
++    while (tmp)
++    {
++        if (tmp == at)
++        {
++            rm_status = RM_OK;
++            break;
++        }
++        tmp = tmp->next;
++    }
++
++    if (rm_status != RM_OK)
++    {
++        // we didn't find the 'at' (and haven't dereferenced it yet).
++        // let's bail before something bad happens, but first print an
++        // error message and NULL the pointer out so we don't come this
++        // far again
++        nv_printf(NV_DBG_ERRORS, "NVRM: nopage handler called on a freed"
++                  "address: vm_start 0x%x, at 0x%x\n", vma->vm_start, at);
++        NV_VMA_PRIVATE(vma) = NULL;
++        return NOPAGE_SIGBUS;
++    }
++
++    rm_status = KernMapAGPNopage((void *)address, vma, at->priv_data, 
++                                 (void **)&page_ptr);
++    if (rm_status)
++        return NOPAGE_SIGBUS;
++
++    // get the index of this page into the allocation
++    index = (address - vma->vm_start)>>PAGE_SHIFT;
++
++    // save that index into our page list (make sure it doesn't already exist)
++    if (at->page_table[index]->phys_addr)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: page slot already filled in nopage handler!\n");
++        os_dbg_breakpoint();
++    }
++
++    at->page_table[index]->phys_addr = (page_to_pfn(page_ptr) << PAGE_SHIFT);
++    at->page_table[index]->dma_addr  = (page_to_pfn(page_ptr) << PAGE_SHIFT);
++    at->page_table[index]->virt_addr = (unsigned long) __va(page_to_pfn(page_ptr) << PAGE_SHIFT);
++
++    return page_ptr;
++#endif
++    return NOPAGE_SIGBUS;
++}
++
++struct vm_operations_struct nv_vm_ops = {
++    .open   = nv_kern_vma_open,
++    .close  = nv_kern_vma_release,  /* "close" */
++    .nopage = nv_kern_vma_nopage,
++};
++
++static nv_file_private_t *
++nv_alloc_file_private(void)
++{
++    nv_file_private_t *nvfp;
++
++    NV_KMALLOC(nvfp, sizeof(nv_file_private_t));
++    if (!nvfp)
++        return NULL;
++
++    memset(nvfp, 0, sizeof(nv_file_private_t));
++
++    // initialize this file's event queue
++    init_waitqueue_head(&nvfp->waitqueue);
++
++    nv_init_lock(nvfp->fp_lock);
++
++    NV_KMALLOC(nvfp->event_fifo, sizeof(nv_event_t) * NV_EVENT_FIFO_SIZE);
++    if (nvfp->event_fifo == NULL)
++    {
++        NV_KFREE(nvfp, sizeof(nv_file_private_t));
++        return NULL;
++    }
++
++    return nvfp;
++}
++
++static void
++nv_free_file_private(nv_file_private_t *nvfp)
++{
++    if (nvfp == NULL)
++        return;
++
++    NV_KFREE(nvfp->event_fifo, sizeof(nv_event_t) * NV_EVENT_FIFO_SIZE);
++    NV_KFREE(nvfp, sizeof(nv_file_private_t));
++}
++
++
++/*
++** nv_kern_open
++**
++** nv driver open entry point.  Sessions are created here.
++*/
++int nv_kern_open(
++    struct inode *inode,
++    struct file *file
++)
++{
++    nv_state_t *nv = NULL;
++    nv_linux_state_t *nvl = NULL;
++    int devnum;
++    int rc = 0, status;
++
++    nv_printf(NV_DBG_INFO, "NVRM: nv_kern_open...\n");
++
++    FILE_PRIVATE(file) = nv_alloc_file_private();
++    if (FILE_PRIVATE(file) == NULL)
++        return -ENOMEM;
++
++    /* for control device, just jump to its open routine */
++    /* after setting up the private data */
++    if (NV_IS_CONTROL_DEVICE(inode))
++        return nv_kern_ctl_open(inode, file);
++
++    /* what device are we talking about? */
++    devnum = NV_DEVICE_NUMBER(inode);
++    if (devnum >= NV_MAX_DEVICES)
++    {
++        nv_free_file_private(FILE_PRIVATE(file));
++        FILE_PRIVATE(file) = NULL;
++        return -ENODEV;
++    }
++
++    nvl = &nv_linux_devices[devnum];
++    nv = NV_STATE_PTR(nvl);
++
++    nv_printf(NV_DBG_INFO, "NVRM: nv_kern_open on device %d\n", devnum);
++    nv_down(nvl->ldata_lock);
++
++    NV_CHECK_PCI_CONFIG(nv);
++
++    NVL_FROM_FILEP(file) = nvl;
++
++    /*
++     * map the memory and allocate isr on first open
++     */
++
++    if ( ! (nv->flags & NV_FLAG_OPEN))
++    {
++        if (nv->device_id == 0)
++        {
++            nv_printf(NV_DBG_ERRORS, "NVRM: open of nonexistent device %d\n",
++                devnum);
++            rc = -ENXIO;
++            goto failed;
++        }
++
++        status = request_irq(nv->interrupt_line, nv_kern_isr,
++                             SA_INTERRUPT | SA_SHIRQ, "nvidia",
++                             (void *) nvl);
++        if (status != 0)
++        {
++            if ( nv->interrupt_line && (status == -EBUSY) )
++            {
++                nv_printf(NV_DBG_ERRORS,
++                    "NVRM: Tried to get irq %d, but another driver",
++                    (unsigned int) nv->interrupt_line);
++                nv_printf(NV_DBG_ERRORS, "NVRM: has it and is not sharing it.\n");
++                nv_printf(NV_DBG_ERRORS, "NVRM: you may want to verify that an audio driver");
++                nv_printf(NV_DBG_ERRORS, " isn't using the irq\n");
++            }
++            nv_printf(NV_DBG_ERRORS, "NVRM: isr request failed 0x%x\n", status);
++            rc = -EIO;
++            goto failed;
++        }
++
++        if ( ! rm_init_adapter(nv))
++        {
++            free_irq(nv->interrupt_line, (void *) nvl);
++            nv_printf(NV_DBG_ERRORS, "NVRM: rm_init_adapter failed\n");
++            rc = -EIO;
++            goto failed;
++        }
++
++        nvl->tasklet.func = nv_kern_isr_bh;
++        nvl->tasklet.data = (unsigned long) nv;
++        tasklet_enable(&nvl->tasklet);
++
++        nv->flags |= NV_FLAG_OPEN;
++    }
++
++    NV_ATOMIC_INC(nvl->usage_count);
++
++ failed:
++    nv_up(nvl->ldata_lock);
++
++    if ((rc) && FILE_PRIVATE(file))
++    {
++        nv_free_file_private(FILE_PRIVATE(file));
++        FILE_PRIVATE(file) = NULL;
++    }
++
++    return rc;
++}
++
++
++/*
++** nv_kern_close
++**
++** Master driver close entry point.
++*/
++
++int nv_kern_close(
++    struct inode *inode,
++    struct file *file
++)
++{
++    nv_linux_state_t *nvl = NVL_FROM_FILEP(file);
++    nv_state_t *nv = NV_STATE_PTR(nvl);
++
++    NV_CHECK_PCI_CONFIG(nv);
++
++    /* for control device, just jump to its open routine */
++    /* after setting up the private data */
++    if (NV_IS_CONTROL_DEVICE(inode))
++        return nv_kern_ctl_close(inode, file);
++
++    nv_printf(NV_DBG_INFO, "NVRM: nv_kern_close on device %d\n",
++        NV_DEVICE_NUMBER(inode));
++
++    rm_free_unused_clients(nv, current->pid, (void *) file);
++
++    nv_down(nvl->ldata_lock);
++    if (NV_ATOMIC_DEC_AND_TEST(nvl->usage_count))
++    {
++        /*
++         * The usage count for this device has dropped to zero, it can be shut
++         * down safely; disable its interrupts.
++         */
++        rm_disable_adapter(nv);
++
++        /*
++         * Disable this device's tasklet to make sure that no bottom half will
++         * run with undefined device state.
++         */
++        tasklet_disable(&nvl->tasklet);
++
++        /*
++         * Free the IRQ, which may block until all pending interrupt processing
++         * has completed.
++         */
++        free_irq(nv->interrupt_line, (void *) nvl);
++
++        rm_shutdown_adapter(nv);
++
++        /*
++         * Make sure we have freed up all the mappings. The kernel
++         * should do this automagically before calling close
++         */
++        if (nvl->alloc_queue)
++        {
++            nv_alloc_t *at = nvl->alloc_queue;
++            while (at)
++            {
++                NV_PRINT_AT(at);
++                at = at->next;
++            }
++        }
++
++        /* leave INIT flag alone so we don't reinit every time */
++        nv->flags &= ~NV_FLAG_OPEN;
++    }
++    nv_up(nvl->ldata_lock);
++
++    if (FILE_PRIVATE(file))
++    {
++        nv_free_file_private(FILE_PRIVATE(file));
++        FILE_PRIVATE(file) = NULL;
++    }
++
++    return 0;
++}
++
++int nv_kern_mmap(
++    struct file  *file,
++    struct vm_area_struct *vma
++)
++{
++    int pages;
++    nv_alloc_t *at;
++    nv_linux_state_t *nvl = NVL_FROM_FILEP(file);
++    nv_state_t *nv = NV_STATE_PTR(nvl);
++
++    nv_printf(NV_DBG_MEMINFO, "NVRM: VM: mmap([0x%p-0x%p] off=0x%lx)\n",
++        vma->vm_start,
++        vma->vm_end,
++        NV_VMA_OFFSET(vma));
++
++    NV_CHECK_PCI_CONFIG(nv);
++
++    // be a bit paranoid for now
++    if ( NV_MASK_OFFSET(vma->vm_start) ||
++         NV_MASK_OFFSET(vma->vm_end))
++    {
++        nv_printf(NV_DBG_ERRORS, 
++            "NVRM: bad mmap range: %lx - %lx\n",
++            vma->vm_start, vma->vm_end);
++        return -ENXIO;
++    }
++
++#if defined(NVCPU_X86)
++    // check for addresses > 32-bits
++    if (vma->vm_pgoff & ~0xfffff)
++    {
++        nv_printf(NV_DBG_ERRORS, 
++            "NVRM: bad mmap offset: %lx\n", vma->vm_pgoff);
++        return -ENXIO;
++    }
++#endif
++
++    pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
++
++    // we have our own version to keep the module count right
++    vma->vm_ops = &nv_vm_ops;
++
++    /* NV reg space */
++    if (IS_REG_OFFSET(nv, NV_VMA_OFFSET(vma), vma->vm_end - vma->vm_start))
++    {
++        vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
++        if (NV_REMAP_PAGE_RANGE(vma->vm_start,
++                             NV_VMA_OFFSET(vma),
++                             vma->vm_end - vma->vm_start,
++                             vma->vm_page_prot))
++            return -EAGAIN;
++
++        /* mark it as IO so that we don't dump it on core dump */
++        vma->vm_flags |= VM_IO;
++    }
++
++    /* NV fb space */
++    else if (IS_FB_OFFSET(nv, NV_VMA_OFFSET(vma), vma->vm_end - vma->vm_start))
++    {
++        vma->vm_page_prot = pgprot_noncached_weak(vma->vm_page_prot);
++        if (NV_REMAP_PAGE_RANGE(vma->vm_start,
++                             NV_VMA_OFFSET(vma),
++                             vma->vm_end - vma->vm_start,
++                             vma->vm_page_prot))
++            return -EAGAIN;
++
++        // mark it as IO so that we don't dump it on core dump
++        vma->vm_flags |= VM_IO;
++    }
++
++    /* AGP allocator */
++    else if (IS_AGP_OFFSET(nv, NV_VMA_OFFSET(vma), vma->vm_end - vma->vm_start))
++    {
++        nv_down(nvl->at_lock);
++        at = nvl_find_alloc(nvl, NV_VMA_OFFSET(vma), NV_ALLOC_TYPE_AGP);
++
++        if (at == NULL)
++        {
++            nv_printf(NV_DBG_ERRORS,
++                "NVRM: couldn't find pre-allocated agp memory!\n");
++            nv_up(nvl->at_lock);
++            return -EAGAIN;
++        }
++
++        if (at->num_pages != pages)
++        {
++            nv_printf(NV_DBG_ERRORS,
++                "NVRM: pre-allocated agp memory has wrong number of pages!\n");
++            nv_up(nvl->at_lock);
++            return -EAGAIN;
++        }
++
++        NV_VMA_PRIVATE(vma) = at;
++        NV_ATOMIC_INC(at->usage_count);
++        nv_up(nvl->at_lock);
++
++        if (NV_OSAGP_ENABLED(nv))
++        {
++#if !defined(NVCPU_IA64) || (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 9))
++            KernMapAGPPages(vma, at->priv_data);
++#else
++            /* Note: on IA64 the AGP chipset is cache coherent, so we
++             * leave the AGP allocation mapped cached. */
++#endif
++        }
++        else
++        {
++            struct vm_area_struct *_vma = vma;
++            rm_map_agp_pages(nv, (void **) &_vma, at->class, at->priv_data);
++        }
++        nv_vm_list_page_count(at->page_table, at->num_pages);
++
++        // mark it as IO so that we don't dump it on core dump
++        vma->vm_flags |= VM_IO;
++    }
++
++    /* Magic allocator */
++    else // if (NV_VMA_OFFSET(vma) == NV_MMAP_ALLOCATION_OFFSET)
++    {
++        unsigned long page = 0, pos, start;
++        int i = 0;
++
++        nv_down(nvl->at_lock);
++        at = nvl_find_alloc(nvl, NV_VMA_OFFSET(vma), NV_ALLOC_TYPE_PCI);
++
++        if (at == NULL)
++        {
++            nv_printf(NV_DBG_ERRORS,
++                "NVRM: couldn't find pre-allocated memory!\n");
++            nv_up(nvl->at_lock);
++            return -EAGAIN;
++        }
++
++        if (at->num_pages != pages)
++        {
++            nv_printf(NV_DBG_ERRORS,
++                "NVRM: pre-allocated sys memory has wrong number of pages!\n");
++            nv_up(nvl->at_lock);
++            return -EAGAIN;
++        }
++
++        // allow setting or refusal of specific caching types
++        switch (NV_ALLOC_MAPPING(at->flags))
++        {
++            case NV_MEMORY_DEFAULT:
++            case NV_MEMORY_WRITEBACK:
++                break;
++            case NV_MEMORY_UNCACHED:
++                vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
++                break;
++            case NV_MEMORY_WRITECOMBINED:
++#if defined(NV_BUILD_NV_PAT_SUPPORT)
++                if (pat_enabled)
++                {
++                    vma->vm_page_prot = pgprot_writecombined(vma->vm_page_prot);
++                    break;
++                }
++#endif
++            case NV_MEMORY_WRITETHRU:
++            case NV_MEMORY_WRITEPROTECT:
++            default:
++                nv_printf(NV_DBG_INFO,
++                    "NVRM: memory caching type 0x%x not supported!\n",
++                    NV_ALLOC_MAPPING(at->flags));
++                nv_up(nvl->at_lock);
++                return -EAGAIN;
++        }
++
++        NV_VMA_PRIVATE(vma) = at;
++        NV_ATOMIC_INC(at->usage_count);
++        nv_up(nvl->at_lock);
++
++        nv_printf(NV_DBG_INFO, "NVRM: remapping %d system pages for at 0x%x\n",
++            pages, at);
++        start = vma->vm_start;
++        while (pages--)
++        {
++            page = (unsigned long) at->page_table[i++]->phys_addr;
++            if (NV_REMAP_PAGE_RANGE(start, page, PAGE_SIZE, vma->vm_page_prot))
++                return -EAGAIN;
++            start += PAGE_SIZE;
++            pos += PAGE_SIZE;
++        }
++        nv_vm_list_page_count(at->page_table, at->num_pages);
++
++        /* prevent the swapper from swapping it out */
++        /* mark the memory i/o so the buffers aren't dumped on core dumps */
++        vma->vm_flags |= (VM_IO | VM_LOCKED);
++    }
++
++    vma->vm_file = file;
++
++    return 0;
++}
++
++
++unsigned int nv_kern_poll(
++    struct file *file,
++    poll_table *wait
++)
++{
++    unsigned int mask = 0;
++    nv_file_private_t *nvfp;
++    nv_linux_state_t *nvl;
++    unsigned long eflags;
++
++    nvl = NVL_FROM_FILEP(file);
++
++    if (NV_STATE_PTR(nvl)->device_number == NV_CONTROL_DEVICE_NUMBER)
++        return nv_kern_ctl_poll (file, wait);
++
++    nvfp = NV_GET_NVFP(file);
++
++    if ( !(file->f_flags & O_NONBLOCK))
++    {
++        // add us to the list
++        poll_wait(file, &nvfp->waitqueue, wait);
++    }
++
++    nv_lock_irq(nvfp->fp_lock, eflags);
++
++    // wake the user on any event
++    if (nvfp->num_events)
++    {
++        nv_printf(NV_DBG_EVENTINFO, "NVRM: Hey, an event occured!\n");
++        // trigger the client, when they grab the event, 
++        // we'll decrement the event count
++        mask |= (POLLPRI|POLLIN);
++    }
++
++    nv_unlock_irq(nvfp->fp_lock, eflags);
++
++    return mask;
++}
++
++//
++// nv_kern_ioctl
++//
++// nv driver ioctl entry point.
++//
++
++/*
++ * some ioctl's can only be done on actual device, others only on the control device
++ */
++#define CTL_DEVICE_ONLY(nv) { if ( ! ((nv)->flags & NV_FLAG_CONTROL)) { status = -EINVAL; goto done; } }
++
++#define ACTUAL_DEVICE_ONLY(nv) { if ((nv)->flags & NV_FLAG_CONTROL) { status = -EINVAL; goto done; } }
++
++
++/* todo:
++   need ioctl to raise a thread priority that is not superuser
++       set its priority to SCHED_FIFO which is simple
++       priority scheduling w/ disabled timeslicing
++*/
++
++int nv_kern_ioctl(
++    struct inode *inode,
++    struct file *file,
++    unsigned int cmd,
++    unsigned long i_arg)
++{
++    int status = 0;
++    nv_linux_state_t *nvl;
++    nv_state_t *nv;
++    void *arg = (void *) i_arg;
++    void *arg_copy;
++    int arg_size;
++
++    nvl = NVL_FROM_FILEP(file);
++    nv = NV_STATE_PTR(nvl);
++
++    nv_printf(NV_DBG_INFO, "NVRM: ioctl(0x%x, 0x%x, 0x%x)\n",
++        _IOC_NR(cmd), (unsigned int) i_arg, _IOC_SIZE(cmd));
++
++    NV_CHECK_PCI_CONFIG(nv);
++
++    arg_size = _IOC_SIZE(cmd);
++    NV_KMALLOC(arg_copy, arg_size);
++    if (arg_copy == NULL)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate ioctl memory\n");
++        return -ENOMEM;
++    }
++
++    if (copy_from_user(arg_copy, arg, arg_size))
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: failed to copy ioctl data\n");
++        NV_KFREE(arg_copy, arg_size);
++        return -ENOMEM;
++    }
++
++    switch (_IOC_NR(cmd))
++    {
++        /* pass out info about the card */
++        case NV_ESC_CARD_INFO:
++        {
++            nv_ioctl_card_info_t *ci;
++            nv_linux_state_t *tnvl;
++            nv_ioctl_rm_api_version_t *rm_api;
++            int i;
++
++            CTL_DEVICE_ONLY(nv);
++
++            /* the first element of card info passed from the client will have
++             * the rm_api_version_magic value to show that the client is new
++             * enough to support versioning. If the client is too old to 
++             * support versioning, our mmap interfaces are probably different
++             * enough to cause serious damage.
++             * just copy in the one dword to check.
++             */
++            rm_api = arg_copy;
++            if ((rm_api->magic   != NV_RM_API_VERSION_MAGIC_REQ) ||
++                (rm_api->version != NV_RM_API_VERSION))
++            {
++                if (rm_api->magic != NV_RM_API_VERSION_MAGIC_REQ)
++                {
++                    nv_printf(NV_DBG_ERRORS, 
++                        "NVRM: client does not support versioning!!\n");
++                } else
++                if (rm_api->version != NV_RM_API_VERSION)
++                {
++                    nv_printf(NV_DBG_ERRORS, 
++                        "NVRM: client supports wrong rm api version!!\n");
++                }
++                nv_printf(NV_DBG_ERRORS,
++                    "NVRM:    aborting to avoid catastrophe!\n");
++                rm_api->magic   = NV_RM_API_VERSION_MAGIC_REP;
++                rm_api->version = NV_RM_API_VERSION;
++                rm_api->major   = NV_MAJOR_VERSION;
++                rm_api->minor   = NV_MINOR_VERSION;
++                rm_api->patch   = NV_PATCHLEVEL;
++                status = -EINVAL;
++                break;
++            }
++
++            ci = arg_copy;
++            memset(ci, 0, arg_size);
++            for (i = 0, tnvl = nv_linux_devices; tnvl < nv_linux_devices + NV_MAX_DEVICES; tnvl++, i++)
++            {
++                nv_state_t *tnv = NV_STATE_PTR(tnvl);
++                if (tnv->device_id)
++                {
++                    ci->flags = NV_IOCTL_CARD_INFO_FLAG_PRESENT;
++                    ci->bus = tnv->bus;
++                    ci->slot = tnv->slot;
++                    ci->vendor_id = tnv->vendor_id;
++                    ci->device_id = tnv->device_id;
++                    ci->interrupt_line = tnv->interrupt_line;
++                    ci->reg_address = tnv->bar.regs.address;
++                    ci->reg_size = tnv->bar.regs.size;
++                    ci->fb_address = tnv->bar.fb.address;
++                    ci->fb_size = tnv->bar.fb.size;
++                    ci++;
++                }
++            }
++            break;
++        }
++
++        /* set a card to be posted */
++        case NV_ESC_POST_VBIOS:
++        {
++            nv_ioctl_post_vbios_t *params = arg_copy;
++
++            CTL_DEVICE_ONLY(nv);
++
++            status = nvos_post_vbios(params);
++
++            break;
++        }
++
++        /* get the sim environment info for this setup */
++        case NV_ESC_SIM_ENV:
++        {
++            nv_ioctl_sim_env_t *simenv = arg_copy;
++
++            CTL_DEVICE_ONLY(nv);
++
++            simenv->sim_env = nv->sim_env;
++
++            break;
++        }
++
++        case NV_ESC_RM_API_VERSION:
++        {
++            nv_ioctl_rm_api_version_t *rm_api = arg_copy;
++
++            CTL_DEVICE_ONLY(nv);
++
++            rm_api->version = NV_RM_API_VERSION;
++            rm_api->major   = NV_MAJOR_VERSION;
++            rm_api->minor   = NV_MINOR_VERSION;
++            rm_api->patch   = NV_PATCHLEVEL;
++
++            break;
++        }
++
++
++        default:
++            status = rm_ioctl(nv, file, _IOC_NR(cmd), arg_copy) ? 0 : -EINVAL;
++            break;
++    }
++
++ done:
++    if (RM_OK != copy_to_user(arg, arg_copy, arg_size))
++        nv_printf(NV_DBG_ERRORS, "NVRM: failed to copyout ioctl data\n");
++    NV_KFREE(arg_copy, arg_size);
++    return status;
++}
++
++/*
++ * driver receives an interrupt
++ *    if someone waiting, then hand it off.
++ */
++irqreturn_t nv_kern_isr(
++    int   irq,
++    void *arg,
++    struct pt_regs *regs
++)
++{
++    nv_linux_state_t *nvl = (void *) arg;
++    nv_state_t *nv = NV_STATE_PTR(nvl);
++    U032 need_to_run_bottom_half = 0;
++
++    NV_CHECK_PCI_CONFIG(nv);
++    rm_isr(nv->device_number, &need_to_run_bottom_half);
++    if (need_to_run_bottom_half)
++    {
++        tasklet_schedule(&nvl->tasklet);
++    }
++
++    return IRQ_HANDLED;
++}
++
++void nv_kern_isr_bh(
++    unsigned long data
++)
++{
++    nv_state_t *nv = (nv_state_t *) data;
++    /*
++     * XXX: This level of indirection is necessary to work around
++     * problems with Linux kernels using a non-standard calling
++     * convention, i.e. Arjan van de Ven's/RedHat's 2.6.0 kernels.
++     */
++    NV_CHECK_PCI_CONFIG(nv);
++    rm_isr_bh(nv->pdev);
++}
++
++void nv_kern_rc_timer(
++    unsigned long data
++)
++{
++    nv_linux_state_t *nvl = (nv_linux_state_t *) data;
++
++    // nv_printf(NV_DBG_INFO, "NVRM: rc timer\n");
++
++    NV_CHECK_PCI_CONFIG((nv_state_t *) data);
++    rm_run_rc_callback((nv_state_t *) data);
++    mod_timer(&nvl->rc_timer, jiffies + HZ);  /* set another timeout in 1 second */
++}
++
++#if defined(NV_PM_SUPPORT_APM)
++/* kernel calls us with a power management event */
++int
++nv_kern_apm_event(
++    struct pm_dev *dev,
++    pm_request_t rqst,
++    void *data
++)
++{
++    nv_state_t *nv;
++    nv_linux_state_t *lnv;
++    int devnum;
++    int status = RM_OK;
++
++    nv_printf(NV_DBG_INFO, "NVRM: nv_kern_apm_event: %d (0x%p)\n", rqst, data);
++
++    for (devnum = 0; devnum < num_nv_devices; devnum++)
++    {
++        if (apm_nv_dev[devnum] == dev)
++        {
++            break;
++        }
++    }
++
++    if (devnum == num_nv_devices)
++    {
++        nv_printf(NV_DBG_WARNINGS, "NVRM: APM: invalid device!\n");
++        return 1;
++    }
++
++    lnv = &nv_linux_devices[devnum];
++    nv = NV_STATE_PTR(lnv);
++
++    if (nv->pdev == NULL)
++    {
++        nv_printf(NV_DBG_WARNINGS, "NVRM: APM: device not initialized!\n");
++        return 1;
++    }
++
++    NV_CHECK_PCI_CONFIG(NV_STATE_PTR(lnv));
++
++    switch (rqst)
++    {
++#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
++        case PM_RESUME:
++            nv_printf(NV_DBG_INFO, "NVRM: APM: received resume event\n");
++            status = rm_power_management(nv, 0, NV_PM_APM_RESUME);
++            break;
++
++        case PM_SUSPEND:
++            nv_printf(NV_DBG_INFO, "NVRM: APM: received suspend event\n");
++            status = rm_power_management(nv, 0, NV_PM_APM_SUSPEND);
++            break;
++#endif
++        default:
++            nv_printf(NV_DBG_WARNINGS, "NVRM: APM: unsupported event: %d\n", rqst);
++            return 1;
++    }
++
++    if (status != RM_OK)
++        nv_printf(NV_DBG_ERRORS, "NVRM: APM: failed event: %d\n", rqst);
++
++    return status;
++}
++#endif
++
++/*
++** nv_kern_ctl_open
++**
++** nv control driver open entry point.  Sessions are created here.
++*/
++int nv_kern_ctl_open(
++    struct inode *inode,
++    struct file *file
++)
++{
++    nv_state_t *nv;
++    nv_linux_state_t *nvl;
++    int rc = 0;
++
++    nvl = &nv_ctl_device;
++    nv = (nv_state_t *) nvl;
++
++    nv_printf(NV_DBG_INFO, "NVRM: nv_kern_ctl_open\n");
++
++    nv_down(nvl->ldata_lock);
++
++    nv->device_number = NV_CONTROL_DEVICE_NUMBER;
++
++    /* save the nv away in file->private_data */
++    NVL_FROM_FILEP(file) = nvl;
++
++    if (NV_ATOMIC_READ(nvl->usage_count) == 0)
++    {
++        init_waitqueue_head(&nv_ctl_waitqueue);
++    }
++
++    nv->flags |= NV_FLAG_OPEN + NV_FLAG_CONTROL;
++
++    /* turn off the hotkey occurred bit */
++    nv->flags &= ~NV_FLAG_HOTKEY_OCCURRED;
++
++    NV_ATOMIC_INC(nvl->usage_count);
++    nv_up(nvl->ldata_lock);
++
++    return rc;
++}
++
++
++/*
++** nv_kern_ctl_close
++*/
++int nv_kern_ctl_close(
++    struct inode *inode,
++    struct file *file
++)
++{
++    nv_linux_state_t *nvl =  NVL_FROM_FILEP(file);
++    nv_state_t *nv = NV_STATE_PTR(nvl);
++
++    nv_printf(NV_DBG_INFO, "NVRM: nv_kern_ctl_close\n");
++
++    nv_down(nvl->ldata_lock);
++    if (NV_ATOMIC_DEC_AND_TEST(nvl->usage_count))
++    {
++        nv->flags = 0;
++    }
++    nv_up(nvl->ldata_lock);
++
++    rm_free_unused_clients(nv, current->pid, (void *) file);
++
++    if (FILE_PRIVATE(file))
++    {
++        nv_free_file_private(FILE_PRIVATE(file));
++        FILE_PRIVATE(file) = NULL;
++    }
++
++    return 0;
++}
++
++
++/*
++ * nv_kern_ctl_poll() - add the process to the wait queue
++ */
++
++unsigned int nv_kern_ctl_poll(
++    struct file *file,
++    poll_table *wait
++)
++{
++    nv_linux_state_t *nvl;
++    nv_state_t *nv;
++    unsigned int ret = 0;
++
++    nvl = NVL_FROM_FILEP(file);
++    nv = NV_STATE_PTR(nvl);
++
++    if ( !(file->f_flags & O_NONBLOCK) )
++    {
++        poll_wait(file, &nv_ctl_waitqueue, wait);
++    }
++
++    nv_lock_rm(nv);
++    if (nv->flags & NV_FLAG_HOTKEY_OCCURRED)
++    {
++        nv_printf(NV_DBG_EVENTINFO, "NVRM: a hotkey event has occurred\n");
++        nv->flags &= ~NV_FLAG_HOTKEY_OCCURRED;
++        ret = POLLIN | POLLRDNORM;
++    }
++    nv_unlock_rm(nv);
++
++    return ret;
++}
++
++
++
++
++/*
++ * nv_set_hotkey_occurred_flag() - set the hotkey flag and wake up anybody
++ * waiting on the wait queue
++ */
++
++void NV_API_CALL nv_set_hotkey_occurred_flag(void)
++{
++    nv_state_t *nv = NV_STATE_PTR(&nv_ctl_device);
++
++    nv_printf(NV_DBG_EVENTINFO, "NVRM: setting the hotkey occurred flag!\n");
++
++    nv_lock_rm(nv);
++    nv_ctl_device.nv_state.flags |= NV_FLAG_HOTKEY_OCCURRED;
++    nv_unlock_rm(nv);
++
++    wake_up_interruptible(&nv_ctl_waitqueue);
++}
++
++int nv_kern_read_cardinfo(char *page, char **start, off_t off,
++        int count, int *eof, void *data)
++{
++    struct pci_dev *dev;
++    char *type, *fmt, tmpstr[NV_DEVICE_NAME_LENGTH];
++    int len = 0, status;
++    U032 vbios_rev1, vbios_rev2, vbios_rev3, vbios_rev4, vbios_rev5;
++
++    nv_state_t *nv;
++    nv = (nv_state_t *) data;
++
++    dev = nv_get_pci_device(nv);
++    if (!dev)
++        return 0;
++    
++    if (rm_get_device_name(nv, dev->device, NV_DEVICE_NAME_LENGTH,
++                           tmpstr) != RM_OK) {
++        strcpy (tmpstr, "Unknown");
++    }
++    
++    len += sprintf(page+len, "Model: \t\t %s\n", tmpstr);
++    len += sprintf(page+len, "IRQ:   \t\t %d\n", nv->interrupt_line);
++
++    status = rm_get_vbios_version(nv, &vbios_rev1, &vbios_rev2,
++                                  &vbios_rev3, &vbios_rev4, &vbios_rev5);
++
++    if (status < 0) {
++        /* before rm_init_adapter */
++        len += sprintf(page+len, "Video BIOS: \t ??.??.??.??.??\n");
++    } else {
++        fmt = "Video BIOS: \t %02x.%02x.%02x.%02x.%02x\n";
++        len += sprintf(page+len, fmt, vbios_rev1, vbios_rev2, vbios_rev3,
++                                                  vbios_rev4, vbios_rev5);
++    }
++
++    type = nvos_find_agp_capability(dev) ? "AGP" : "PCI";
++    len += sprintf(page+len, "Card Type: \t %s\n", type);
++
++    NV_PCI_DEV_PUT(dev);
++    return len;
++}
++
++int nv_kern_read_version(char *page, char **start, off_t off,
++        int count, int *eof, void *data)
++{
++    int len = 0;
++    
++    len += sprintf(page+len, "NVRM version: %s\n", pNVRM_ID);
++    len += sprintf(page+len, "GCC version:  %s\n", NV_COMPILER);
++    
++    return len;
++}
++
++int nv_kern_read_agpinfo(char *page, char **start, off_t off,
++        int count, int *eof, void *data)
++{
++    struct pci_dev *dev;
++    char   *fw, *sba;
++    u8     cap_ptr;
++    u32    status, command, agp_rate;
++    int    len = 0;
++    
++    nv_state_t *nv;
++    nv = (nv_state_t *) data;
++
++    if (nv) {
++        dev = nv_get_pci_device(nv);
++        if (!dev)
++            return 0;
++    } else {
++        dev = nvos_get_agp_device_by_class(PCI_CLASS_BRIDGE_HOST);
++        if (!dev)
++            return 0;
++
++        len += sprintf(page+len, "Host Bridge: \t ");
++
++#if defined(CONFIG_PCI_NAMES)
++        len += sprintf(page+len, "%s\n", NV_PCI_DEVICE_NAME(dev));
++#else
++        len += sprintf(page+len, "PCI device %04x:%04x\n",
++                dev->vendor, dev->device);
++#endif
++    }
++
++    /* what can this AGP device do? */
++    cap_ptr = nvos_find_agp_capability(dev);
++
++    pci_read_config_dword(dev, cap_ptr + 4, &status);
++    pci_read_config_dword(dev, cap_ptr + 8, &command);
++
++    fw  = (status & 0x00000010) ? "Supported" : "Not Supported";
++    sba = (status & 0x00000200) ? "Supported" : "Not Supported";
++
++    len += sprintf(page+len, "Fast Writes: \t %s\n", fw);
++    len += sprintf(page+len, "SBA: \t\t %s\n", sba);
++
++    agp_rate = status & 0x7;
++    if (status & 0x8) // agp 3.0
++        agp_rate <<= 2;
++
++    len += sprintf(page+len, "AGP Rates: \t %s%s%s%s\n",
++            (agp_rate & 0x00000008) ? "8x " : "",
++            (agp_rate & 0x00000004) ? "4x " : "",
++            (agp_rate & 0x00000002) ? "2x " : "",
++            (agp_rate & 0x00000001) ? "1x " : "");
++
++    len += sprintf(page+len, "Registers: \t 0x%08x:0x%08x\n", status, command);
++
++    NV_PCI_DEV_PUT(dev);
++    return len;
++}
++
++int nv_kern_read_status(char *page, char **start, off_t off,
++        int count, int *eof, void *data)
++{
++    struct pci_dev *dev;
++    char   *fw, *sba, *drv;
++    int    len = 0;
++    u8     cap_ptr;
++    u32    scratch;
++    u32    status, command, agp_rate;
++
++    nv_state_t *nv;
++    nv = (nv_state_t *) data;
++
++    dev = nvos_get_agp_device_by_class(PCI_CLASS_BRIDGE_HOST);
++    if (!dev)
++        return 0;
++    cap_ptr = nvos_find_agp_capability(dev);
++
++    pci_read_config_dword(dev, cap_ptr + 4, &status);
++    pci_read_config_dword(dev, cap_ptr + 8, &command);
++    NV_PCI_DEV_PUT(dev);
++
++    dev = nvos_get_agp_device_by_class(PCI_CLASS_DISPLAY_VGA);
++    if (!dev)
++        return 0;
++    cap_ptr = nvos_find_agp_capability(dev);
++
++    pci_read_config_dword(dev, cap_ptr + 4, &scratch);
++    status &= scratch;
++    pci_read_config_dword(dev, cap_ptr + 8, &scratch);
++    command &= scratch;
++
++    if (NV_AGP_ENABLED(nv) && (command & 0x100)) {
++        len += sprintf(page+len, "Status: \t Enabled\n");
++
++        drv = NV_OSAGP_ENABLED(nv) ? "AGPGART" : "NVIDIA";
++        len += sprintf(page+len, "Driver: \t %s\n", drv);
++
++        // mask off agp rate. 
++        // If this is agp 3.0, we need to shift the value
++        agp_rate = command & 0x7;
++        if (status & 0x8) // agp 3.0
++            agp_rate <<= 2;
++
++        len += sprintf(page+len, "AGP Rate: \t %dx\n", agp_rate);
++
++        fw = (command & 0x00000010) ? "Enabled" : "Disabled";
++        len += sprintf(page+len, "Fast Writes: \t %s\n", fw);
++
++        sba = (command & 0x00000200) ? "Enabled" : "Disabled";
++        len += sprintf(page+len, "SBA: \t\t %s\n", sba);
++    } else {
++        int agp_config = 0;
++
++        len += sprintf(page+len, "Status: \t Disabled\n\n");
++
++        /*
++         * If we find AGP is disabled, but the RM registry indicates it
++         * was requested, direct the user to the kernel log (we, or even
++         * the kernel may have printed a warning/an error message).
++         *
++         * Note that the "XNvAGP" registry key reflects the user request
++         * and overrides the RM "NvAGP" key, if present.
++         */
++        rm_read_registry_dword(nv, "NVreg", "NvAGP",  &agp_config);
++        rm_read_registry_dword(nv, "NVreg", "XNvAGP", &agp_config);
++
++        if (agp_config != NVOS_AGP_CONFIG_DISABLE_AGP && NV_AGP_FAILED(nv)) {
++            len += sprintf(page+len,
++                  "AGP initialization failed, please check the ouput  \n"
++                  "of the 'dmesg' command and/or your system log file \n"
++                  "for additional information on this problem.        \n");
++        }
++    }
++
++    NV_PCI_DEV_PUT(dev);
++    return len;
++}
++
++
++/***
++ *** EXPORTS to rest of resman
++ ***/
++
++void* NV_API_CALL  nv_find_nv_mapping(
++    nv_state_t    *nv,
++    unsigned long  address
++)
++{
++    nv_alloc_t *at;
++
++    at = nvl_find_alloc(NV_GET_NVL_FROM_NV_STATE(nv), address, 
++                                    NV_ALLOC_TYPE_PCI);
++    if (at && at->page_table)
++    {
++        // we've found the mapping and associated 'at' (in theory)
++        // track down the actual page within this allocation and return
++        // a kernel virtual mapping to it.
++        int i;
++        unsigned long offset;
++
++        // save the page offset so we can add it to the returned address
++        // page-align our address to make finding it a little easier
++        offset = address & ~PAGE_MASK;
++        address &= PAGE_MASK;
++
++        for (i = 0; i < at->num_pages; i++)
++        {
++            if (address == at->page_table[i]->phys_addr)
++                return (void *)(at->page_table[i]->virt_addr + offset);
++        }
++    }
++
++    return NULL;
++}
++
++ULONG NV_API_CALL nv_find_dma_mapping(
++    nv_state_t    *nv,
++    unsigned long  address
++)
++{
++    nv_alloc_t *at = NULL;
++
++    at = nvl_find_alloc(NV_GET_NVL_FROM_NV_STATE(nv), address, 
++                        NV_ALLOC_TYPE_PCI);
++    if (at && at->page_table)
++    {
++        // we've found the mapping and associated 'at' (in theory)
++        // track down the actual page within this allocation and return
++        // the corresponding DMA address.
++        int i;
++        unsigned long offset;
++
++        // save the page offset so we can add it to the returned address
++        // page-align our address to make finding it a little easier
++        offset = address & ~PAGE_MASK;
++        address &= PAGE_MASK;
++
++        for (i = 0; i < at->num_pages; i++)
++        {
++            if (address == at->page_table[i]->phys_addr)
++                return (unsigned long)at->page_table[i]->dma_addr + offset;
++        }
++    }
++
++    return 0;
++}
++
++/* Lookup the physiscal address of the page that backs a dma address */
++ULONG  NV_API_CALL nv_dma_to_phys_address(
++    nv_state_t    *nv,
++    ULONG          dma_address
++)
++{
++    nv_alloc_t *at;
++    nv_linux_state_t    *nvl;
++
++    nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++    for (at = nvl->alloc_queue; at; at = at->next)
++    {
++        if (at->page_table)
++        {
++            int i;
++            unsigned long offset = dma_address & ~PAGE_MASK;
++            unsigned long address = dma_address & PAGE_MASK;
++            for (i = 0; i < at->num_pages; i++)
++            {
++                if (address == at->page_table[i]->dma_addr)
++                {
++                    return at->page_table[i]->phys_addr + offset;
++                }
++            }
++        }
++    }
++
++    return 0;
++}
++
++/* For some newer AGP chipsets, such as the 460GX, the user's virtual address 
++ * is not mapped directly to the agp aperture on the CPU's page tables. Instead,
++ * they map to the underlying physical pages. This function is passed the
++ * address of the underlying physical page (which is loaded into the GART) and
++ * returns the agp aperture that the page is mapped to, so we can load that
++ * page into the graphics card.
++ * use the standard nvl_find_alloc to search on the physical page and rely on
++ * the TYPE_AGP flag to differeniate it from a PCI allocation.
++ * failure is fine, we may just be checking if a given page is agp
++ */
++void* NV_API_CALL nv_find_agp_kernel_mapping(
++    nv_state_t    *nv,
++    unsigned long  address
++)
++{
++    nv_alloc_t *at = NULL;
++
++    at = nvl_find_alloc(NV_GET_NVL_FROM_NV_STATE(nv), address, 
++                        NV_ALLOC_TYPE_AGP);
++    if (at && at->page_table)
++    {
++        // we've found the mapping and associated 'at' (in theory)
++        // track down the actual page within this allocation and return
++        // the agp aperture mapping to it (key_mapping should be the base
++        // of this aperture mapping, so track down the page within that mapping)
++        int i;
++        for (i = 0; i < at->num_pages; i++)
++        {
++            if (address == (unsigned long) at->page_table[i]->dma_addr)
++            {
++                return (void *)((unsigned long) at->key_mapping + 
++                    (i * PAGE_SIZE));
++            }
++        }
++    }
++
++    return NULL;
++}
++
++
++#if defined(NVCPU_IA64)
++#  define KERN_PAGE_MASK      _PFN_MASK
++#else
++#  define KERN_PAGE_MASK      PAGE_MASK
++#endif
++
++/* virtual address to physical page address */
++static unsigned long
++_get_phys_address(
++    unsigned long address,
++    int kern
++)
++{
++    struct mm_struct *mm;
++    pgd_t *pgd = NULL;
++    pmd_t *pmd = NULL;
++    pte_t *pte = NULL;
++    unsigned long retval;
++
++    mm = (kern) ? &init_mm : current->mm;
++    spin_lock(&mm->page_table_lock);
++
++    pgd = NV_PGD_OFFSET(address, kern, mm);
++    if (!NV_PGD_PRESENT(pgd))
++        goto failed;
++
++    pmd = NV_PMD_OFFSET(address, pgd);
++    if (!NV_PMD_PRESENT(pmd))
++        goto failed;
++
++    pte = NV_PTE_OFFSET(address, pmd);
++    if (!NV_PTE_PRESENT(pte))
++        goto failed;
++
++    retval = ((NV_PTE_VALUE(pte) & KERN_PAGE_MASK) | NV_MASK_OFFSET(address));
++
++#if defined(NVCPU_X86_64) && defined(_PAGE_NX)
++    // mask out the non-executable page bit for the true physical address
++    retval &= ~_PAGE_NX;
++#endif
++
++    spin_unlock(&mm->page_table_lock);
++    return retval;
++
++failed:
++    spin_unlock(&mm->page_table_lock);
++    return 0;
++}
++
++unsigned long NV_API_CALL nv_get_kern_phys_address(
++    unsigned long address
++)
++{
++    // make sure this address is a kernel pointer
++    // IA64's memory layout is different from X86, at least in some cases.
++    // instead of fine-tuning it, let's just bail, since we're really just 
++    // trying to catch programming mistakes when debugging
++#if defined(DEBUG) && !defined(CONFIG_X86_4G) && !defined(NVCPU_IA64)
++    if (address < PAGE_OFFSET)
++    {
++        nv_printf(NV_DBG_WARNINGS,
++            "NVRM: user address passed to get_kern_phys_address: 0x%lx\n",
++            address);
++        return 0;
++    }
++#endif
++
++#if defined(NVCPU_IA64)
++    if (address > __IA64_UNCACHED_OFFSET)
++        return address - __IA64_UNCACHED_OFFSET;
++#endif
++
++    /* direct-mapped kernel address */
++    if ((address > PAGE_OFFSET) && (address < VMALLOC_START))
++        return __pa(address);
++
++    return _get_phys_address(address, 1);
++}
++
++unsigned long NV_API_CALL nv_get_user_phys_address(
++    unsigned long address
++)
++{
++    // make sure this address is not a kernel pointer
++    // IA64's memory layout is different from X86, at least in some cases.
++    // instead of fine-tuning it, let's just bail, since we're really just 
++    // trying to catch programming mistakes when debugging
++#if defined(DEBUG) && !defined(CONFIG_X86_4G) && !defined(NVCPU_IA64)
++    if (address >= PAGE_OFFSET)
++    {
++        nv_printf(NV_DBG_WARNINGS,
++            "NVRM: kernel address passed to get_user_phys_address: 0x%lx\n",
++            address);
++        return 0;
++    }
++#endif
++
++    return _get_phys_address(address, 0);
++}
++
++
++/* allocate memory for DMA push buffers */
++int NV_API_CALL nv_alloc_pages(
++    nv_state_t *nv,
++    void **pAddress,
++    unsigned int page_count,
++    unsigned int agp_memory,
++    unsigned int contiguous,
++    unsigned int cached,
++    unsigned int kernel,
++    unsigned int class,
++    void **priv_data
++)
++{
++    nv_alloc_t *at;
++    RM_STATUS rm_status = 0;
++    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++
++    nv_printf(NV_DBG_MEMINFO, "NVRM: VM: nv_alloc_pages: %d pages\n", page_count);
++    nv_printf(NV_DBG_MEMINFO, "NVRM: VM:    agp %d  contig %d  cached %d  kernel %d\n",
++        agp_memory, contiguous, cached, kernel);
++
++    page_count = RM_PAGES_TO_OS_PAGES(page_count);
++    at = nvos_create_alloc(nvl->dev, page_count);
++    if (at == NULL)
++        return RM_ERROR;
++
++    at->class = class;
++    at->flags = nv_alloc_init_flags(cached, agp_memory, contiguous, kernel);
++
++    if (agp_memory)
++    {
++        int offset;
++
++        if (!NV_AGP_ENABLED(nv))
++            goto failed;
++
++        /* allocate agp-able memory */
++        if (NV_OSAGP_ENABLED(nv))
++        {
++            /* agpgart will allocate all of the underlying memory */
++            rm_status = KernAllocAGPPages(nv, pAddress, page_count, priv_data, &offset);
++            if (rm_status)
++                goto failed;
++
++            at->priv_data = *priv_data;
++            nvl_add_alloc(nvl, at);
++        } else {
++            /* use nvidia's nvagp support */
++            if (nv_vm_malloc_pages(nv, at))
++                goto failed;
++
++            at->class = class;
++
++            // set our 'key' to the page_table. rm_alloc_agp_pages will call
++            // nv_translate_address below, which will look up pages using
++            // the value of *pAddress as a key, then index into the page_table
++            // once we're done with rm_alloc_agp_pages, we no longer need
++            // this, and the 'key' will be replaced below
++            *pAddress = at->page_table;
++            at->key_mapping = at->page_table;
++
++            /* the 'at' needs to be added before the alloc agp pages call */
++            nvl_add_alloc(nvl, at);
++            rm_status = rm_alloc_agp_pages(nv,
++                                        pAddress,
++                                        page_count,
++                                        class,
++                                        priv_data,
++                                        &offset);
++            if (rm_status)
++            {
++                nvl_remove_alloc(nvl, at);
++                NV_VM_UNLOCK_AND_FREE_PAGES(nv, NV_ATOMIC_READ(at->usage_count), at);
++                goto failed;
++            }
++            at->priv_data = *priv_data;
++        }
++        // return the physical address of the allocation for mmap
++        // in this case, 'physical address' is within the agp aperture
++        *pAddress = (void *)(NV_UINTPTR_T)(nv->agp.address + (offset << PAGE_SHIFT));
++    }
++    else 
++    {
++
++        if (nv_vm_malloc_pages(nv, at))
++            goto failed;
++
++        if (kernel)
++        {
++            *pAddress = (void *) at->page_table[0]->virt_addr;
++        }
++        else
++        {
++            /* must be page-aligned or mmap will fail
++             * so use the first page, which is page-aligned. this way, our 
++             * allocated page table does not need to be page-aligned
++             */
++            *pAddress = (void *) at->page_table[0]->phys_addr;
++        }
++
++        nvl_add_alloc(nvl, at);
++    }
++
++    at->key_mapping = *pAddress;
++    NV_ATOMIC_INC(at->usage_count);
++
++    return RM_OK;
++
++failed:
++    nvos_free_alloc(at);
++
++    return -1;
++}
++
++#define NV_FAILED_TO_FIND_AT(nv, addr) \
++    { \
++        nv_up(nvl->at_lock); \
++        nv_printf(NV_DBG_ERRORS, "NVRM: couldn't find alloc for 0x%p\n", addr); \
++        return -1; \
++    }
++
++int NV_API_CALL nv_free_pages(
++    nv_state_t *nv,
++    void **pAddress,
++    unsigned int page_count,
++    unsigned int agp_memory,
++    void *priv_data
++)
++{
++    int rmStatus = 0;
++    nv_alloc_t *at;
++    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++
++    page_count = RM_PAGES_TO_OS_PAGES(page_count);
++    nv_printf(NV_DBG_MEMINFO, "NVRM: VM: nv_free_pages: 0x%x 0x%x\n",
++        *pAddress, page_count);
++
++    if (agp_memory)
++    {
++        if (!NV_AGP_ENABLED(nv))
++            return -1;
++
++        /* only lock ldata while removing 'at' from the list */
++        nv_down(nvl->at_lock);
++        at = nvl_find_alloc(nvl, (unsigned long) *pAddress, NV_ALLOC_TYPE_AGP);
++        if (at == NULL)
++            NV_FAILED_TO_FIND_AT(nv, *pAddress);
++        if (at->num_pages != page_count)
++            NV_FAILED_TO_FIND_AT(nv, *pAddress);
++        nvl_remove_alloc(nvl, at);
++        nv_up(nvl->at_lock);
++
++        NV_ATOMIC_DEC(at->usage_count);
++
++        if (NV_OSAGP_ENABLED(nv))
++        {
++            rmStatus = KernFreeAGPPages(nv, pAddress, priv_data);
++        } else {
++            rmStatus = rm_free_agp_pages(nv, pAddress, priv_data);
++            if (rmStatus == RM_OK)
++            {
++                NV_VM_UNLOCK_AND_FREE_PAGES(nv, NV_ATOMIC_READ(at->usage_count), at);
++            }
++        }
++    } else {
++        /* only lock ldata while removing 'at' from the list */
++        nv_down(nvl->at_lock);
++        at = nvl_find_alloc(nvl, (unsigned long) *pAddress, NV_ALLOC_TYPE_PCI);
++        if (at == NULL)
++            NV_FAILED_TO_FIND_AT(nv, *pAddress);
++        if (at->num_pages != page_count)
++            NV_FAILED_TO_FIND_AT(nv, *pAddress);
++        nvl_remove_alloc(nvl, at);
++        nv_up(nvl->at_lock);
++
++        NV_ATOMIC_DEC(at->usage_count);
++
++        NV_VM_UNLOCK_AND_FREE_PAGES(nv, NV_ATOMIC_READ(at->usage_count), at);
++    }
++
++    if (NV_ATOMIC_READ(at->usage_count) == 0)
++        nvos_free_alloc(at);
++
++    return rmStatus;
++}
++
++
++static void nv_lock_init_locks
++( 
++    nv_state_t *nv
++)
++{
++    nv_linux_state_t *nvl;
++    nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++
++    spin_lock_init(&nvl->rm_lock);
++
++    sema_init(&nvl->ldata_lock, 1);
++    sema_init(&nvl->at_lock, 1);
++    NV_ATOMIC_SET(nvl->usage_count, 0);
++
++    nvl->rm_lock_cpu = -1;
++    nvl->rm_lock_count = 0;
++}
++
++void NV_API_CALL nv_lock_rm(
++    nv_state_t *nv
++)
++{
++    nv_linux_state_t *nvl;
++    int cpu;
++
++    nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++    cpu = get_cpu();
++
++    if (nvl->rm_lock_cpu == cpu)
++    {
++        nvl->rm_lock_count++;
++        put_cpu();
++        return;
++    }
++
++    put_cpu();
++    spin_unlock_wait(&nvl->rm_lock);
++    spin_lock_irq(&nvl->rm_lock);
++
++    nvl->rm_lock_cpu = smp_processor_id();
++    nvl->rm_lock_count = 1;
++}
++
++void NV_API_CALL nv_unlock_rm(
++    nv_state_t *nv
++)
++{
++    nv_linux_state_t *nvl;
++    nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++
++    if (--nvl->rm_lock_count)
++        return;
++
++    nvl->rm_lock_cpu = -1;
++    spin_unlock_irq(&nvl->rm_lock);
++}
++
++/*
++** post the event
++*/
++ 
++void NV_API_CALL nv_post_event(
++    nv_state_t *nv,
++    nv_event_t *event,
++    U032        handle,
++    U032        index
++)
++{
++    struct file *file = (struct file *) event->file;
++    nv_file_private_t *nvfp = NV_GET_NVFP(file);
++    unsigned long eflags;
++
++    nv_printf(NV_DBG_EVENTINFO, "NVRM: posting event on 0x%x:0x%x\n",
++        event, nvfp);
++
++    nv_lock_irq(nvfp->fp_lock, eflags);
++
++    if (nvfp->num_events == NV_EVENT_FIFO_SIZE)
++    {
++        wake_up_interruptible(&nvfp->waitqueue);
++        nv_unlock_irq(nvfp->fp_lock, eflags);
++        return;
++    }
++
++    // copy the event into the queue
++    nvfp->event_fifo[nvfp->put] = *event;
++
++    // set the handle for this event
++    nvfp->event_fifo[nvfp->put].hObject = handle;
++    nvfp->event_fifo[nvfp->put].index   = index;
++    
++    nvfp->num_events++;
++    nvfp->put++;
++    if (nvfp->put >= NV_EVENT_FIFO_SIZE)
++        nvfp->put = 0;
++
++    wake_up_interruptible(&nvfp->waitqueue);
++    nv_unlock_irq(nvfp->fp_lock, eflags);
++}
++
++int NV_API_CALL nv_get_event(
++    nv_state_t *nv,
++    void *void_file,
++    nv_event_t *event,
++    U032 *more_events
++)
++{
++    struct file *file = (struct file *) void_file;
++    nv_file_private_t *nvfp = NV_GET_NVFP(file);
++    unsigned long eflags;
++
++    nv_lock_irq(nvfp->fp_lock, eflags);
++    if (nvfp->num_events == 0)
++    {
++        nv_unlock_irq(nvfp->fp_lock, eflags);
++        return -1;
++    }
++
++    *event = nvfp->event_fifo[nvfp->get];
++    nvfp->num_events--;
++    nvfp->get++;
++    if (nvfp->get >= NV_EVENT_FIFO_SIZE)
++        nvfp->get = 0;
++
++    if (more_events)
++        *more_events = nvfp->num_events;
++
++    nv_printf(NV_DBG_EVENTINFO, "NVRM: returning event: 0x%x\n", event);
++    nv_printf(NV_DBG_EVENTINFO, "NVRM:     hParent: 0x%x\n", event->hParent);
++    nv_printf(NV_DBG_EVENTINFO, "NVRM:     hObject: 0x%x\n", event->hObject);
++    nv_printf(NV_DBG_EVENTINFO, "NVRM:     file:    0x%p\n", event->file);
++    nv_printf(NV_DBG_EVENTINFO, "NVRM:     fd:      %d\n", event->fd);
++    if (more_events)
++        nv_printf(NV_DBG_EVENTINFO, "NVRM: more events: %d\n", *more_events);
++
++    nv_unlock_irq(nvfp->fp_lock, eflags);
++
++    return 0;
++}
++
++
++int NV_API_CALL nv_agp_init(
++    nv_state_t *nv,
++    void **phys_start,
++    void **linear_start,
++    void *agp_limit,
++    U032 config         /* passed in from XF86Config file */
++)
++{
++    U032 status = 1;
++    static int old_error = 0;
++
++    if (NV_AGP_ENABLED(nv))
++        return -1;
++
++    if (config == NVOS_AGP_CONFIG_DISABLE_AGP)
++    {
++        nv->agp_config = NVOS_AGP_CONFIG_DISABLE_AGP;
++        nv->agp_status = NV_AGP_STATUS_DISABLED;
++        return 0;
++    }
++
++    nv_printf(NV_DBG_SETUP, "NVRM: nv_agp_init\n");
++
++    nv->agp_config = NVOS_AGP_CONFIG_DISABLE_AGP;
++    nv->agp_status = NV_AGP_STATUS_FAILED;
++
++    if (config & NVOS_AGP_CONFIG_OSAGP)
++    {
++        status = KernInitAGP(nv, phys_start, linear_start, agp_limit);
++
++        /* if enabling agpgart was successfull, register it,
++         * and check about overrides
++         */
++        if (status == 0)
++        {
++            nv->agp_config = NVOS_AGP_CONFIG_OSAGP;
++            nv->agp_status = NV_AGP_STATUS_ENABLED;
++
++            /* make sure we apply our overrides in this case */
++            rm_update_agp_config(nv);
++        }
++
++        if (status == 1 && !(config & NVOS_AGP_CONFIG_NVAGP) && !old_error)
++        {
++            nv_printf(NV_DBG_ERRORS,
++                "NVRM: unable to initialize the Linux AGPGART driver, please \n"
++                "NVRM: verify you configured your kernel to include support  \n"
++                "NVRM: for AGPGART (either statically linked, or as a kernel \n"
++                "NVRM: module). Please also make sure you selected support   \n"
++                "NVRM: for your AGP chipset.                                 \n");
++#if defined(KERNEL_2_6)
++            nv_printf(NV_DBG_ERRORS,
++                "NVRM:                                                       \n"
++                "NVRM: note that as of Linux 2.6 AGPGART, all chipset/vendor \n"
++                "NVRM: drivers are split into independent modules; make sure \n"
++                "NVRM: the correct one is loaded for your chipset.           \n");
++#endif
++            old_error = 1;
++        }
++
++        /* if agpgart is loaded, but we failed to initialize it,
++         * we'd better not attempt nvagp, or we're likely to lock
++         * the machine.
++         */
++        if (status < 0)
++            return status;
++    }
++
++    /* we're either explicitly not using agpgart,
++     * or trying to use agpgart failed
++     * make sure the user did not specify "use agpgart only"
++     */
++    if ( (!NV_AGP_ENABLED(nv)) && (config & NVOS_AGP_CONFIG_NVAGP) )
++    {
++        /* make sure the user does not have agpgart loaded */
++        if (inter_module_get("drm_agp")) {
++            inter_module_put("drm_agp");
++            nv_printf(NV_DBG_WARNINGS, "NVRM: not using NVAGP, AGPGART is loaded!!\n");
++        } else {
++#if defined(CONFIG_X86_64) && defined(CONFIG_GART_IOMMU)
++            nv_printf(NV_DBG_WARNINGS,
++                "NVRM: not using NVAGP, kernel was compiled with GART_IOMMU support!!\n");
++#else
++            status = rm_init_agp(nv);
++            if (status == RM_OK)
++            {
++                nv->agp_config = NVOS_AGP_CONFIG_NVAGP;
++                nv->agp_status = NV_AGP_STATUS_ENABLED;
++            }
++#endif
++        }
++    }
++
++    if (NV_AGP_ENABLED(nv))
++        old_error = 0; /* report new errors */
++
++    nv_printf(NV_DBG_SETUP, 
++        "NVRM: agp_init finished with status 0x%x and config %d\n",
++        status, nv->agp_config);
++
++    return status;
++}
++
++int NV_API_CALL nv_agp_teardown(
++    nv_state_t *nv
++)
++{
++    U032 status = 1;
++
++    nv_printf(NV_DBG_SETUP, "NVRM: nv_agp_teardown\n");
++
++    /* little sanity check won't hurt */
++    if (!NV_AGP_ENABLED(nv))
++        return -1;
++
++    if (NV_OSAGP_ENABLED(nv))
++        status = KernTeardownAGP(nv);
++    else if (NV_NVAGP_ENABLED(nv))
++        status = rm_teardown_agp(nv);
++
++    nv->agp_config = NVOS_AGP_CONFIG_DISABLE_AGP;
++    nv->agp_status = NV_AGP_STATUS_DISABLED;
++
++    nv_printf(NV_DBG_SETUP, "NVRM: teardown finished with status 0x%x\n", 
++        status);
++
++    return status;
++}
++
++int NV_API_CALL nv_translate_address(
++    nv_state_t *nv,
++    ULONG       base,
++    U032        index,
++    U032       *paddr
++)
++{
++    nv_alloc_t *at;
++    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++
++    /* find the 'at' */
++    at = nvl_find_alloc(nvl, base, NV_ALLOC_TYPE_AGP | NV_ALLOC_TYPE_PCI);
++    if (at == NULL)
++        return RM_ERROR;
++
++    if (index > at->num_pages)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: translate_address: ",
++            "at has inconsistent number of pages\n");
++        return RM_ERROR;
++    }
++
++    /* get the physical address of this page */
++    *paddr = (U032) ((NV_UINTPTR_T)at->page_table[index]->dma_addr);
++
++    return RM_OK;
++}
++
++
++int NV_API_CALL nv_int10h_call(
++    nv_state_t *nv,
++    U032 *eax,
++    U032 *ebx,
++    U032 *ecx,
++    U032 *edx,
++    void *buffer
++)
++{
++    return -1;
++}
++
++/* set a timer to go off every second */
++int NV_API_CALL nv_start_rc_timer(
++    nv_state_t *nv
++)
++{
++    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++
++    if (nv->rc_timer_enabled)
++        return -1;
++
++    nv_printf(NV_DBG_INFO, "NVRM: initializing rc timer\n");
++    init_timer(&nvl->rc_timer);
++    nvl->rc_timer.function = nv_kern_rc_timer;
++    nvl->rc_timer.data = (unsigned long) nv;
++    nv->rc_timer_enabled = 1;
++    mod_timer(&nvl->rc_timer, jiffies + HZ); /* set our timeout for 1 second */
++    nv_printf(NV_DBG_INFO, "NVRM: rc timer initialized\n");
++
++    return 0;
++}
++
++int NV_API_CALL nv_stop_rc_timer(
++    nv_state_t *nv
++)
++{
++    nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++
++    if (!nv->rc_timer_enabled)
++        return -1;
++
++    nv_printf(NV_DBG_INFO, "NVRM: stopping rc timer\n");
++    nv->rc_timer_enabled = 0;
++    del_timer(&nvl->rc_timer);
++    nv_printf(NV_DBG_INFO, "NVRM: rc timer stopped\n");
++
++    return 0;
++}
++
++/* make sure the pci_driver called probe for all of our devices.
++ * we've seen cases where rivafb claims the device first and our driver
++ * doesn't get called.
++ */
++static int
++nvos_count_devices(void)
++{
++    struct pci_dev *dev;
++    int count = 0;
++
++    dev = NV_PCI_GET_CLASS(PCI_CLASS_DISPLAY_VGA << 8, NULL);
++    while (dev)
++    {
++        if ((dev->vendor == 0x10de) && (dev->device >= 0x20))
++            count++;
++        dev = NV_PCI_GET_CLASS(PCI_CLASS_DISPLAY_VGA << 8, dev);
++    }
++    return count;
++}
++
++/* find nvidia devices and set initial state */
++int
++nv_kern_probe
++(
++    struct pci_dev *dev,
++    const struct pci_device_id *id_table
++)
++{
++    nv_state_t *nv;
++    nv_linux_state_t *nvl;
++
++    if ((dev->vendor != 0x10de) || (dev->device < 0x20) || 
++        (dev->class != (PCI_CLASS_DISPLAY_VGA << 8)))
++    {
++        return -1;
++    }
++
++    if (num_nv_devices == NV_MAX_DEVICES)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: maximum device number (%d) reached!\n", num_nv_devices);
++        return -1;
++    }
++
++    // enable io, mem, and bus-mastering in pci config space
++    if (pci_enable_device(dev) != 0)
++    {
++        nv_printf(NV_DBG_ERRORS,
++            "NVRM: pci_enable_device failed, aborting\n");
++        return -1;
++    }
++
++    // request ownership of our bars
++    // keeps other drivers from banging our registers.
++    // only do this for registers, as vesafb requests our framebuffer and will
++    // keep us from working properly
++    if (!request_mem_region(NV_PCI_RESOURCE_START(dev, 1),
++                            NV_PCI_RESOURCE_SIZE(dev, 1), "nvidia"))
++    {
++        nv_printf(NV_DBG_ERRORS,
++            "NVRM: request_mem_region failed for 0x%x:0x%x, aborting\n",
++             NV_PCI_RESOURCE_START(dev, 1), NV_PCI_RESOURCE_SIZE(dev, 1));
++        goto err_disable_dev;
++    }
++    pci_set_master(dev);
++
++    /* initialize bus-dependent config state */
++    nvl = &nv_linux_devices[num_nv_devices];
++    nv  = NV_STATE_PTR(nvl);
++
++    nvl->dev          = dev;
++    nv->vendor_id     = dev->vendor;
++    nv->device_id     = dev->device;
++    nv->os_state      = (void *) nvl;
++    nv->bus           = NV_PCI_BUS_NUMBER(dev);
++    nv->slot          = NV_PCI_SLOT_NUMBER(dev);
++
++    nv_lock_init_locks(nv);
++    
++
++    nv->bar.regs.address = NV_PCI_RESOURCE_START(dev, 1);
++    nv->bar.regs.size    = NV_PCI_RESOURCE_SIZE(dev, 1);
++
++    nv->bar.fb.address   = NV_PCI_RESOURCE_START(dev, 2);
++    nv->bar.fb.size      = NV_PCI_RESOURCE_SIZE(dev, 2);
++    
++    nv->interrupt_line = dev->irq;
++
++    /* check common error condition */
++    if (nv->interrupt_line == 0)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: Can't find an IRQ for your NVIDIA card!  \n");
++        nv_printf(NV_DBG_ERRORS, "NVRM: Please check your BIOS settings.         \n");
++        nv_printf(NV_DBG_ERRORS, "NVRM: [Plug & Play OS   ] should be set to NO  \n");
++        nv_printf(NV_DBG_ERRORS, "NVRM: [Assign IRQ to VGA] should be set to YES \n");
++        goto err_zero_dev;
++    }
++
++    /* sanity check the IO apertures */
++    if ( (nv->bar.regs.address == 0) || (nv->bar.regs.size == 0) ||
++         (nv->bar.fb.address   == 0) || (nv->bar.fb.size   == 0))
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: The IO regions for your NVIDIA card are invalid.\n");
++        nv_printf(NV_DBG_ERRORS, "NVRM: Your system BIOS may have misconfigured your graphics card.\n");
++
++        if ((nv->bar.regs.address == 0) || (nv->bar.regs.size == 0))
++        {
++            nv_printf(NV_DBG_ERRORS,
++                "NVRM: bar0 (registers) appears to be wrong: 0x%x 0x%x\n",
++                nv->bar.regs.address, nv->bar.regs.size);
++        }
++
++        if ((nv->bar.fb.address == 0) || (nv->bar.fb.size == 0))
++        {
++            nv_printf(NV_DBG_ERRORS,
++                "NVRM: bar1 (framebuffer) appears to be wrong: 0x%x 0x%x\n",
++                nv->bar.fb.address, nv->bar.fb.size);
++        }
++
++        goto err_zero_dev;
++    }
++
++
++#if defined(NV_BUILD_NV_PAT_SUPPORT)
++    if (nvos_find_pci_express_capability(nvl->dev))
++    {
++        __nv_enable_pat_support();
++    }
++#endif
++
++#if defined(NV_MAP_REGISTERS_EARLY)
++    nv->bar.regs.map = os_map_kernel_space(nv->bar.regs.address,
++                                           nv->bar.regs.size,
++                                           NV_MEMORY_UNCACHED);
++    nv->bar.regs.map_u = (nv_phwreg_t) nv->bar.regs.map;
++    if (nv->bar.regs.map == NULL)
++    {
++        nv_printf(NV_DBG_ERRORS, "NVRM: failed to map registers!!\n");
++        goto err_zero_dev;
++    }
++    nv->flags |= NV_FLAG_MAP_REGS_EARLY;
++#endif
++
++    nv_printf(NV_DBG_INFO, "NVRM: %02x:%02x.%x %04x:%04x - 0x%08x [size=%dM]\n",
++            nv->bus, nv->slot, PCI_FUNC(dev->devfn),
++            nv->vendor_id, nv->device_id, nv->bar.regs.address,
++            nv->bar.regs.size / (1024 * 1024));
++    nv_printf(NV_DBG_INFO, "NVRM: %02x:%02x.%x %04x:%04x - 0x%08x [size=%dM]\n",
++            nv->bus, nv->slot, PCI_FUNC(dev->devfn),
++            nv->vendor_id, nv->device_id, nv->bar.fb.address,
++            nv->bar.fb.size / (1024 * 1024));
++
++    num_nv_devices++;
++
++    return 0;
++
++err_zero_dev:
++    os_mem_set(nvl, 0, sizeof(nv_linux_state_t));
++    release_mem_region(NV_PCI_RESOURCE_START(dev, 1),
++                       NV_PCI_RESOURCE_SIZE(dev, 1));
++
++err_disable_dev:
++    NV_PCI_DISABLE_DEVICE(dev);
++    return -1;
++}
++
++int NV_API_CALL nv_no_incoherent_mappings
++(
++    void
++)
++{
++#ifdef NV_CHANGE_PAGE_ATTR_PRESENT
++    return 1;
++#else
++    return 0;
++#endif
++}
++
++#if defined(NV_PM_SUPPORT_ACPI)
++
++int
++nv_acpi_event
++(
++    struct pci_dev *dev, 
++    u32 state
++)
++{
++    nv_state_t *nv;
++    nv_linux_state_t *lnv = NULL;
++    int status = RM_OK, i;
++
++    nv_printf(NV_DBG_INFO, "NVRM: nv_acpi_event: %d\n", state);
++
++    for (i = 0; i < NV_MAX_DEVICES; i++)
++    {
++        if (nv_linux_devices[i].dev == dev)
++        {
++            lnv = &nv_linux_devices[i];
++            break;
++        }
++    }
++
++    if ((!lnv) || (lnv->dev != dev))
++    {
++        nv_printf(NV_DBG_WARNINGS, "NVRM: ACPI: invalid device!\n");
++        return -1;
++    }
++
++    nv = NV_STATE_PTR(lnv);
++    if (nv->pdev == NULL)
++    {
++        nv_printf(NV_DBG_WARNINGS, "NVRM: ACPI: device not initialized!\n");
++        return -1;
++    }
++
++    switch (state)
++    {
++        case PM_SUSPEND_MEM:
++            nv_printf(NV_DBG_INFO, "NVRM: ACPI: received suspend event\n");
++            status = rm_power_management(nv, 0, NV_PM_ACPI_STANDBY);
++            break;
++
++        case PM_SUSPEND_ON:
++            nv_printf(NV_DBG_INFO, "NVRM: ACPI: received resume event\n");
++            status = rm_power_management(nv, 0, NV_PM_ACPI_RESUME);
++            break;
++
++        default:
++            nv_printf(NV_DBG_WARNINGS, "NVRM: ACPI: unsupported event: %d\n", state);
++            return -1;
++    }
++
++    if (status != RM_OK)
++        nv_printf(NV_DBG_ERRORS, "NVRM: ACPI: failed event: %d\n", state);
++
++    return status;
++}
++
++int
++nv_kern_acpi_standby
++(
++    struct pci_dev *dev, 
++    u32 state
++)
++{
++    return nv_acpi_event(dev, state);
++}
++
++int
++nv_kern_acpi_resume
++(
++    struct pci_dev *dev
++)
++{
++    return nv_acpi_event(dev, PM_SUSPEND_ON);
++}
++
++#endif
+diff -ruN nvidia-kernel.orig/nv/os-agp.c nvidia-kernel/nv/os-agp.c
+--- nvidia-kernel.orig/nv/os-agp.c	2005-01-11 17:19:49.000000000 -0800
++++ nvidia-kernel/nv/os-agp.c	2005-02-18 15:08:12.957056670 -0800
+@@ -25,6 +25,13 @@
+ 
+ #ifdef AGPGART
+ 
++#if defined(KERNEL_2_6)
++typedef struct agp_kern_info agp_kern_info;
++typedef struct agp_memory agp_memory;
++#elif defined(KERNEL_2_4)
++const drm_agp_t *drm_agp_p; /* functions */
++#endif
++
+ typedef struct {
+     agp_memory *ptr;
+     int num_pages;
+@@ -45,7 +52,6 @@
+ 
+ agp_kern_info         agpinfo;
+ agp_gart              gart;
+-const drm_agp_t       *drm_agp_p;
+ 
+ #if defined(CONFIG_MTRR)
+ #define MTRR_DEL(gart) if ((gart).mtrr > 0) mtrr_del((gart).mtrr, 0, 0);
+@@ -53,6 +59,26 @@
+ #define MTRR_DEL(gart)
+ #endif
+ 
++#if defined(KERNEL_2_6)
++#define NV_AGPGART_BACKEND_ACQUIRE(o) agp_backend_acquire()
++#define NV_AGPGART_BACKEND_ENABLE(o,mode) agp_enable(mode)
++#define NV_AGPGART_BACKEND_RELEASE(o) agp_backend_release()
++#define NV_AGPGART_COPY_INFO(o,p) agp_copy_info(p)
++#define NV_AGPGART_ALLOCATE_MEMORY(o,count,type) agp_allocate_memory(count,type)
++#define NV_AGPGART_FREE_MEMORY(o,p) agp_free_memory(p)
++#define NV_AGPGART_BIND_MEMORY(o,p,offset) agp_bind_memory(p,offset)
++#define NV_AGPGART_UNBIND_MEMORY(o,p) agp_unbind_memory(p)
++#elif defined(KERNEL_2_4)
++#define NV_AGPGART_BACKEND_ACQUIRE(o) ({ (o)->acquire(); 0; })
++#define NV_AGPGART_BACKEND_ENABLE(o,mode) (o)->enable(mode)
++#define NV_AGPGART_BACKEND_RELEASE(o) ((o)->release())
++#define NV_AGPGART_COPY_INFO(o,p) ({ (o)->copy_info(p); 0; })
++#define NV_AGPGART_ALLOCATE_MEMORY(o,count,type) (o)->allocate_memory(count,type)
++#define NV_AGPGART_FREE_MEMORY(o,p) (o)->free_memory(p)
++#define NV_AGPGART_BIND_MEMORY(o,p,offset) (o)->bind_memory(p,offset)
++#define NV_AGPGART_UNBIND_MEMORY(o,p) (o)->unbind_memory(p)
++#endif
++
+ #endif /* AGPGART */
+ 
+ BOOL KernInitAGP(
+@@ -73,8 +99,10 @@
+ 
+     memset( (void *) &gart, 0, sizeof(agp_gart));
+ 
++#if defined(KERNEL_2_4)
+     if (!(drm_agp_p = inter_module_get_request("drm_agp", "agpgart")))
+         return 1;
++#endif
+ 
+     /* NOTE: from here down, return an error code of '-1'
+      * that indicates that agpgart is loaded, but we failed to use it
+@@ -82,11 +110,10 @@
+      * the memory controller.
+      */
+ 
+-    if (drm_agp_p->acquire())
++    if (NV_AGPGART_BACKEND_ACQUIRE(drm_agp_p))
+     {
+-        nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: backend in use\n");
+-        inter_module_put("drm_agp");
+-        return -1;
++        nv_printf(NV_DBG_INFO, "NVRM: AGPGART: no backend available\n");
++        goto bailout;
+     }
+ 
+     if (rm_read_registry_dword(nv, "NVreg", "ReqAGPRate", &agp_rate) == RM_ERROR)
+@@ -101,21 +128,12 @@
+         agp_fw = 1;
+     agp_fw &= 0x00000001;
+ 
+-#if defined(KERNEL_2_4)
+-    /*
+-     * The original Linux 2.4 AGP GART driver interface declared copy_info to
+-     * return nothing. This changed in Linux 2.5, which reports unsupported
+-     * chipsets via this function. If this Linux 2.4 kernels behaves the same
+-     * way, we have no way to know.
+-     */
+-    drm_agp_p->copy_info(&agpinfo);
+-#else
+-    if (drm_agp_p->copy_info(&agpinfo)) {
++    if (NV_AGPGART_COPY_INFO(drm_agp_p, &agpinfo))
++    {
+         nv_printf(NV_DBG_ERRORS,
+             "NVRM: AGPGART: kernel reports chipset as unsupported\n");
+         goto failed;
+     }
+-#endif
+ 
+ #ifdef CONFIG_MTRR
+     /*
+@@ -170,7 +188,7 @@
+     if (!(agp_rate & 0x00000004)) agpinfo.mode &= ~0x00000004;
+     if (!(agp_rate & 0x00000002)) agpinfo.mode &= ~0x00000002;
+     
+-    drm_agp_p->enable(agpinfo.mode);
++    NV_AGPGART_BACKEND_ENABLE(drm_agp_p, agpinfo.mode);
+ 
+     *ap_phys_base   = (void*) agpinfo.aper_base;
+     *ap_mapped_base = (void*) gart.aperture;
+@@ -182,8 +200,11 @@
+ 
+ failed:
+     MTRR_DEL(gart); /* checks gart.mtrr */
+-    drm_agp_p->release();
++    NV_AGPGART_BACKEND_RELEASE(drm_agp_p);
++bailout:
++#if defined(KERNEL_2_4)
+     inter_module_put("drm_agp");
++#endif
+ 
+     return -1;
+ 
+@@ -213,9 +234,10 @@
+         NV_IOUNMAP(gart.aperture, RM_PAGE_SIZE);
+     }
+ 
+-    drm_agp_p->release();
+-
++    NV_AGPGART_BACKEND_RELEASE(drm_agp_p);
++#if defined(KERNEL_2_4)
+     inter_module_put("drm_agp");
++#endif
+ 
+     if (rm_clear_agp_bitmap(nv, &bitmap))
+     {
+@@ -244,7 +266,6 @@
+     return RM_ERROR;
+ #else
+     agp_memory *ptr;
+-    int err;
+     agp_priv_data *data;
+     RM_STATUS status;
+ 
+@@ -262,7 +283,7 @@
+         return RM_ERROR;
+     }
+ 
+-    ptr = drm_agp_p->allocate_memory(PageCount, AGP_NORMAL_MEMORY);
++    ptr = NV_AGPGART_ALLOCATE_MEMORY(drm_agp_p, PageCount, AGP_NORMAL_MEMORY);
+     if (ptr == NULL)
+     {
+         *pAddress = (void*) 0;
+@@ -270,8 +291,7 @@
+         return RM_ERR_NO_FREE_MEM;
+     }
+     
+-    err = drm_agp_p->bind_memory(ptr, *Offset);
+-    if (err)
++    if (NV_AGPGART_BIND_MEMORY(drm_agp_p, ptr, *Offset))
+     {
+         // this happens a lot when the aperture itself fills up..
+         // not a big deal, so don't alarm people with an error message
+@@ -280,14 +300,11 @@
+         goto fail;
+     }
+ 
+-    /* return the agp aperture address */ 
+-    *pAddress = (void *) (agpinfo.aper_base + (*Offset << PAGE_SHIFT));
+-
+     status = os_alloc_mem((void **)&data, sizeof(agp_priv_data));
+     if (status != RM_OK)
+     {
+         nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: memory allocation failed\n");
+-        drm_agp_p->unbind_memory(ptr);
++        NV_AGPGART_UNBIND_MEMORY(drm_agp_p, ptr);
+         goto fail;
+     }
+ 
+@@ -302,7 +319,7 @@
+     return RM_OK;
+ 
+ fail:
+-    drm_agp_p->free_memory(ptr);
++    NV_AGPGART_FREE_MEMORY(drm_agp_p, ptr);
+     *pAddress = (void*) 0;
+ 
+     return RM_ERROR;
+@@ -342,7 +359,7 @@
+     {
+         nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: unable to remap %lu pages\n",
+             (unsigned long)agp_data->num_pages);
+-        drm_agp_p->unbind_memory(agp_data->ptr);
++        NV_AGPGART_UNBIND_MEMORY(drm_agp_p, agp_data->ptr);
+         goto fail;
+     }
+     
+@@ -441,8 +458,8 @@
+     {
+         size_t pages = ptr->page_count;
+ 
+-        drm_agp_p->unbind_memory(ptr);
+-        drm_agp_p->free_memory(ptr);
++        NV_AGPGART_UNBIND_MEMORY(drm_agp_p, ptr);
++        NV_AGPGART_FREE_MEMORY(drm_agp_p, ptr);
+ 
+         nv_printf(NV_DBG_INFO, "NVRM: AGPGART: freed %ld pages\n",
+             (unsigned long)pages);
+diff -ruN nvidia-kernel.orig/nv/os-interface.c nvidia-kernel/nv/os-interface.c
+--- nvidia-kernel.orig/nv/os-interface.c	2005-01-11 17:19:49.000000000 -0800
++++ nvidia-kernel/nv/os-interface.c	2005-02-18 15:07:56.308268009 -0800
+@@ -732,10 +732,17 @@
+ //
+ inline void NV_API_CALL out_string(const char *str)
+ {
++#if DEBUG
+     static int was_newline = 0;
+ 
+-    if (was_newline) printk("%d: %s", smp_processor_id(), str);
+-    else             printk("%s", str);
++    if (NV_NUM_CPUS() > 1 && was_newline)
++    {
++        printk("%d: %s", get_cpu(), str);
++        put_cpu();
++    }
++    else
++#endif
++        printk("%s", str);
+ 
+ #if DEBUG
+     if (NV_NUM_CPUS() > 1)
+@@ -866,7 +873,8 @@
+ )
+ {
+     struct pci_dev *dev;
+-    dev = NV_PCI_GET_SLOT(bus, PCI_DEVFN(slot, function));
++    unsigned int devfn = PCI_DEVFN(slot, function);
++    dev = NV_PCI_GET_SLOT(bus, devfn);
+     if (dev) {
+         if (vendor) *vendor = dev->vendor;
+         if (device) *device = dev->device;
