Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 40057 | Differences between
and this patch

Collapse All | Expand All

(-)NVIDIA_kernel-1.0-4363/Makefile (-169 lines)
Lines 1-169 Link Here
1
# This Makefile is automatically generated; do not edit
2
#   Generated on 'builder3.nvidia.com' on Sat Apr 19 17:46:47 PDT 2003
3
4
LINUX_MODULE=nv-linux.o
5
DEFINES=-D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES -DNTRM -D_GNU_SOURCE -D_LOOSE_KERNEL_NAMES -D__KERNEL__ -DMODULE  -DNV_MAJOR_VERSION=1 -DNV_MINOR_VERSION=0 -DNV_PATCHLEVEL=4363  -DNV_UNIX   -DNV_LINUX   -DNV_INT64_OK   -DNVCPU_X86     
6
INCLUDES=-I.
7
8
OBJECTS=nv.o os-agp.o os-interface.o os-registry.o 
9
HEADERS=os-agp.h os-interface.h nv-linux.h nv-misc.h nv.h  rmretval.h nvtypes.h  $(VERSION_HDR)
10
11
CFLAGS=-Wall -Wimplicit -Wreturn-type -Wswitch -Wformat -Wchar-subscripts -Wparentheses -Wpointer-arith -Wcast-qual -Wno-multichar  -O -MD $(DEFINES) $(INCLUDES) -Wno-cast-qual
12
13
RESMAN_KERNEL_MODULE=nv-kernel.o
14
15
KERNDIR=/lib/modules/$(shell uname -r)
16
17
# check for newer paths. if found, use them, otherwise use old paths
18
# these wouldn't work with the gnu make included with rh6.2
19
# KERNINC=$(if -d $(KERNDIR)/build, $(KERNDIR)/build/include, /usr/src/linux/include)
20
# INSTALLDIR=$(if -d $(KERNDIR)/kernel, $(KERNDIR)/kernel/drivers/video, $(KERNDIR)/video)
21
22
# this is slightly more brain-dead, but works..
23
ifeq ($(shell if test -d $(KERNDIR)/build; then echo yes; fi),yes)
24
KERNINC=$(KERNDIR)/build/include
25
else
26
KERNINC=/usr/src/linux/include
27
endif
28
29
ifeq ($(shell if test -d $(KERNDIR)/kernel; then echo yes; fi),yes)
30
INSTALLDIR=$(KERNDIR)/kernel/drivers/video
31
else
32
INSTALLDIR=$(KERNDIR)/video
33
endif
34
35
ifeq ($(shell echo $(NVDEBUG)),1)
36
  ifeq ($(shell test -z $(RMDEBUG) && echo yes),yes)
37
    RMDEBUG=1
38
  endif
39
endif
40
41
ifeq ($(shell echo $(RMDEBUG)),1)
42
CFLAGS += -DDEBUG -g -fno-common
43
endif
44
45
# this is just plain wrong, get rid of it
46
BROKENDIR=$(KERNDIR)/kernel/video
47
48
INSTALL=$(shell which install)
49
50
# determine gcc versions used (kernel, nvidia.o)
51
module_cc:=$(shell $(CC) -v 2>&1 | tail -1)
52
version="^Linux version [^(]* (.*@.*) (\(.*\)) .*"
53
kernel_cc:=$(shell cat /proc/version | sed "s/"$(version)"/\1/")
54
55
module_cc:=$(shell echo "$(module_cc)" | cut -d ' ' -f 3)
56
kernel_cc:=$(shell echo "$(kernel_cc)" | cut -d ' ' -f 3)
57
58
# allow specification of alternate include file tree on command line and extra defines
59
ifdef SYSINCLUDE
60
INCLUDES += -I$(SYSINCLUDE)
61
else
62
INCLUDES += -I$(KERNINC)
63
endif
64
65
ifeq ($(shell sh conftest.sh remap_page_range $(INCLUDES)), 5)
66
  DEFINES += -DREMAP_PAGE_RANGE_5
67
endif
68
69
ifeq ($(shell sh conftest.sh remap_page_range $(INCLUDES)), 4)
70
  DEFINES += -DREMAP_PAGE_RANGE_4
71
endif
72
73
DEFINES+=$(EXTRA_DEFINES)
74
75
# allow build parameters to be passed in through the environment
76
ifdef BUILD_PARAMS
77
    DEFINES+=-D$(BUILD_PARAMS)
78
endif
79
80
VERSION_HDR=nv_compiler.h
81
82
all: install
83
84
install: package-install
85
86
package-install: nvidia.o rmmod-check
87
	@if [ `id -ur` != 0 ]; then \
88
		echo Please run \"make install\" as root.; \
89
	else \
90
		if [ -d $(BROKENDIR) ]; then \
91
			rm -f $(BROKENDIR)/NVdriver; \
92
			rmdir --ignore-fail-on-non-empty $(BROKENDIR); \
93
		fi && \
94
		mkdir -p $(INSTALLDIR) && \
95
		rm -f $(INSTALLDIR)/NVdriver && \
96
		$(INSTALL) -m 0664 -o root -g root nvidia.o $(INSTALLDIR)/nvidia.o$(O) && \
97
		/sbin/depmod -a && \
98
		/sbin/modprobe nvidia && \
99
		sh makedevices.sh && \
100
		echo "nvidia.o installed successfully."; \
101
	fi
102
103
RMMOD_ERROR=\
104
	echo ""; \
105
	echo "Unable to remove existing NVIDIA kernel module."; \
106
	echo "Please be sure you have exited X before attempting"; \
107
	echo "to install the NVIDIA kernel module."; \
108
	echo ""; \
109
	echo -en "\033[1;31m"; \
110
	echo -e  "*** Failed rmmod sanity check. Bailing out! ***"; \
111
	echo -en "\033[0m"; \
112
	exit 1;
113
114
rmmod-check:
115
	@if /sbin/lsmod | grep nvidia > /dev/null; then \
116
		if ! /sbin/rmmod nvidia > /dev/null; then $(RMMOD_ERROR) fi \
117
	fi; \
118
	if /sbin/lsmod | grep NVdriver > /dev/null; then \
119
		if ! /sbin/rmmod NVdriver > /dev/null; then $(RMMOD_ERROR) fi \
120
	fi
121
122
gcc-check:
123
	@if [ -z $(IGNORE_CC_MISMATCH) ]; then \
124
	 if [ $(kernel_cc) != $(module_cc) ]; then \
125
	echo "                                                           "; \
126
	echo "You appear to be compiling the NVIDIA kernel module with   "; \
127
	echo "a compiler different from the one that was used to compile "; \
128
	echo "the running kernel. This may be perfectly fine, but there  "; \
129
	echo "are cases where this can lead to unexpected behaviour and  "; \
130
	echo "system crashes.                                            "; \
131
	echo "                                                           "; \
132
	echo "If you know what you are doing and want to override this   "; \
133
	echo "check, you can do so by setting IGNORE_CC_MISMATCH.        "; \
134
	echo "                                                           "; \
135
	echo "In any other case, set the CC environment variable to the  "; \
136
	echo "name of the compiler that was used to compile the kernel.  "; \
137
	echo "                                                           "; \
138
	echo -en "\033[1;31m"; \
139
	echo -e  "*** Failed cc sanity check. Bailing out! ***"; \
140
	echo -en "\033[0m"; \
141
	exit 1; \
142
	 fi \
143
	fi
144
145
nvidia.o: gcc-check $(LINUX_MODULE) $(RESMAN_KERNEL_MODULE) 
146
	ld -r -o $@ $(LINUX_MODULE) $(RESMAN_KERNEL_MODULE)
147
148
$(VERSION_HDR): 
149
	echo \#define NV_COMPILER \"`$(CC) -v 2>&1 | tail -1`\" > $@
150
151
$(LINUX_MODULE): $(OBJECTS)
152
	ld -r -o $@ $(OBJECTS)
153
154
%.o: %.c $(HEADERS)
155
	$(CC) -c $(CFLAGS) $<
156
157
# debug tool to preprocess the file and leave .i to make it easier to untangle #defines
158
%.i: %.c
159
	$(CC) $(CFLAGS) -E $< > $@
160
161
%.s: %.c
162
	$(CC) $(CFLAGS) -S $< > $@
163
164
165
clean:
166
	$(RM) $(OBJECTS) $(LINUX_MODULE) $(VERSION_HDR) *.d NVdriver nvidia.o
167
168
169
-include $(OBJECTS:%.o=%.d)
(-)NVIDIA_kernel-1.0-4363/Makefile.kbuild (+249 lines)
Line 0 Link Here
1
#
2
# KBUILD Makefile for the NVIDIA Linux kernel module.
3
#
4
# The motivation for replacing the original Makefile is the hope that this
5
# version will simplify the build and installation process. In the past,
6
# many architectural and cosmetic changes to the Linux kernel have made it
7
# difficult to maintain compatibility or required duplication of logic.
8
#
9
# Linux 2.6 introduces numerous such changes, many of which impact modules.
10
# Relying on KBUILD, some aspects of the build system otherwise difficult
11
# to support (for example, module versioning) are abstracted away and dealt
12
# with elsewhere, making life significantly easier here.
13
#
14
# The new approach currently has its own share of problems, some of which
15
# are architectural difficulties with KBUILD, others minor annoyances. For
16
# this reason, an improved version of the NVIDIA Makefile is available to
17
# those experiencing difficulties.
18
#
19
# Please report any problems you may be experiencing with this experimental
20
# Makefile to either one (or, preferably, both) of us:
21
#
22
# Alistair J Strachan (alistair@devzero.co.uk) (first pass, enhancements)
23
# Christian Zander (zander@mail.minion.de) (enhancements)
24
#
25
26
all: install
27
install: package-install
28
29
#
30
# The NVIDIA kernel module base name and static file names. KBUILD will go
31
# ahead and append ".o" or ".ko" to form the final module name.
32
#
33
34
MODULE_NAME := nvidia
35
VERSION_HEADER := nv_compiler.h
36
37
#
38
# List of object files to link into NVIDIA kernel module; make sure KBUILD
39
# understands that we want a module.
40
#
41
42
RESMAN_CORE_OBJS := nv-kernel.o
43
RESMAN_GLUE_OBJS := nv.o os-agp.o os-interface.o os-registry.o
44
45
$(MODULE_NAME)-objs := $(RESMAN_CORE_OBJS) $(RESMAN_GLUE_OBJS)
46
47
#
48
# The precompiled kernel module build process requires a separation of the
49
# closed source and open source object files.
50
#
51
52
KERNEL_GLUE_NAME := nv-linux.o
53
KERNEL_GLUE_OBJS := $(RESMAN_GLUE_OBJS) $(MODULE_NAME).mod.o
54
55
#
56
# A bug in KBUILD 2.4 means that leaving obj-m set in top-level context
57
# will cause Rules.make to call pathdown.sh, which is wrong. So, we only
58
# set this conditional of a kernel-level instance.
59
#
60
61
ifdef TOPDIR
62
obj-m := $(MODULE_NAME).o
63
endif
64
65
#
66
# Include local source directory in $(CC)'s include path and set disable any
67
# warning types that are of little interest to us.
68
#
69
70
EXTRA_CFLAGS += -I$(src)
71
EXTRA_CFLAGS += -Wno-cast-qual -Wno-strict-prototypes
72
73
#
74
# We rely on these two definitions below; if they aren't set, we set them to
75
# reasonable defaults (Linux 2.4's KBUILD, and top-level passes will not set
76
# these).
77
#
78
79
src ?= .
80
obj ?= .
81
82
#
83
# Determine location of the Linux kernel source tree. Allow users to override
84
# the default (i.e. automatically determined) kernel source location with the
85
# SYSSRC directive; this new directive replaces NVIDIA's SYSINCLUDE.
86
#
87
88
KERNEL_UNAME := $(shell SYSSRC=$(SYSSRC) sh $(src)/conftest.sh get_uname)
89
MODULE_ROOT  := /lib/modules/$(KERNEL_UNAME)/kernel/drivers
90
91
ifdef SYSSRC
92
  KERNEL_SOURCES := $(SYSSRC)
93
  KERNEL_HEADERS := -I$(KERNEL_SOURCES)/include
94
else
95
  KERNEL_SOURCES := /lib/modules/$(KERNEL_UNAME)/build
96
  KERNEL_HEADERS := -I$(KERNEL_SOURCES)/include
97
endif
98
99
#
100
# Sets any internal variables left unset by KBUILD (e.g. this happens during
101
# a top-level run).
102
#
103
104
TOPDIR ?= $(KERNEL_SOURCES)
105
PATCHLEVEL ?= $(shell sh $(src)/conftest.sh kernel_patch_level $(TOPDIR))
106
107
#
108
# Linux 2.4 uses the .o module extension. Linux 2.6, however, uses the .ko
109
# module extension. Handle these gracefully.
110
#
111
112
ifeq ($(PATCHLEVEL), 4)
113
  MODULE_OBJECT := $(MODULE_NAME).o
114
else
115
  MODULE_OBJECT := $(MODULE_NAME).ko
116
endif
117
118
#
119
# NVIDIA specific CFLAGS and #define's. The remap_page_range check has become
120
# necessary with the introduction of the five argument version to Linux 2.4
121
# distribution kernels; this conflicting change cannot be detected at compile
122
# time.
123
#
124
125
EXTRA_CFLAGS += -D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES -DNTRM -D_GNU_SOURCE -D_LOOSE_KERNEL_NAMES -D__KERNEL__ -DMODULE  -DNV_MAJOR_VERSION=1 -DNV_MINOR_VERSION=0 -DNV_PATCHLEVEL=4363  -DNV_UNIX   -DNV_LINUX   -DNV_INT64_OK   -DNVCPU_X86
126
127
ifeq ($(shell echo $(NVDEBUG)),1)
128
  ifeq ($(shell test -z $(RMDEBUG) && echo yes),yes)
129
    RMDEBUG=1
130
  endif
131
endif
132
133
ifeq ($(shell echo $(RMDEBUG)),1)
134
  EXTRA_CFLAGS += -DDEBUG -g -fno-common
135
endif
136
137
ifeq ($(shell sh $(src)/conftest.sh remap_page_range $(KERNEL_HEADERS)), 5)
138
  EXTRA_CFLAGS += -DREMAP_PAGE_RANGE_5
139
endif
140
141
ifeq ($(shell sh $(src)/conftest.sh remap_page_range $(KERNEL_HEADERS)), 4)
142
  EXTRA_CFLAGS += -DREMAP_PAGE_RANGE_4
143
endif
144
145
#
146
# NVIDIA binary object file includes .common section.
147
#
148
149
EXTRA_LDFLAGS := -d
150
151
#
152
# Miscellaneous NVIDIA kernel module build support targets. They are needed
153
# to satisfy KBUILD requirements and to support NVIDIA specifics.
154
#
155
156
$(obj)/$(RESMAN_CORE_OBJS):
157
	cp $(src)/$(RESMAN_CORE_OBJS) $(obj)/$(RESMAN_CORE_OBJS)
158
159
$(obj)/$(VERSION_HEADER):
160
	echo \#define NV_COMPILER \"`$(CC) -v 2>&1 | tail -n 1`\" > $@
161
162
$(obj)/nv.o: $(obj)/$(VERSION_HEADER)
163
164
#
165
# More quirks for Linux 2.4 KBUILD, which doesn't link automatically.
166
#
167
168
ifeq ($(PATCHLEVEL), 4)
169
$(obj)/$(MODULE_NAME).o: $($(MODULE_NAME)-objs)
170
	$(LD) $(EXTRA_LDFLAGS) -r -o $@ $($(MODULE_NAME)-objs)
171
endif
172
173
#
174
# KBUILD build parameters.
175
#
176
177
KBUILD_PARAMS := -C $(KERNEL_SOURCES) SUBDIRS=$(PWD)
178
179
#
180
# NVIDIA sanity checks.
181
#
182
183
suser-sanity-check:
184
	@if ! sh conftest.sh suser_sanity_check nvidia; then \
185
	  exit 1; \
186
	fi
187
188
rmmod-sanity-check:
189
	@if ! sh conftest.sh rmmod_sanity_check nvidia; then \
190
	  exit 1; \
191
	fi
192
193
cc-sanity-check:
194
	 @if ! sh conftest.sh cc_sanity_check full_output $(CC); then \
195
	  exit 1; \
196
	fi
197
198
#
199
# Build the NVIDIA kernel module using Linux KBUILD. This target is used by
200
# the "package-install" target below.
201
#
202
203
module: cc-sanity-check
204
	@make CC=$(CC) $(KBUILD_PARAMS) modules
205
206
#
207
# Build the NVIDIA kernel module with KBUILD. Verify that the user posesses
208
# sufficient privileges. Rebuild the module dependency file.
209
#
210
211
module-install: suser-sanity-check module
212
	@mkdir -p $(MODULE_ROOT)/video; \
213
	install -m 0664 -o root -g root $(MODULE_OBJECT) $(MODULE_ROOT)/video; \
214
	PATH="$(PATH):/bin:/sbin" /sbin/depmod -ae;
215
216
#
217
# This target builds, then installs, then creates device nodes and inserts
218
# the module, if successful.
219
#
220
221
package-install: module-install rmmod-sanity-check
222
	@sh makedevices.sh; \
223
	PATH="$(PATH):/bin:/sbin" /sbin/modprobe $(MODULE_NAME)
224
225
#
226
# Build an object file suitable for further processing by the installer and
227
# inclusion as a precompiled kernel interface file.
228
#
229
230
$(KERNEL_GLUE_NAME): module
231
	@$(LD) $(EXTRA_LDFLAGS) -r -o $(KERNEL_GLUE_NAME) $(KERNEL_GLUE_OBJS)
232
233
#
234
# Support hack, KBUILD isn't prepared to clean up after external modules.
235
#
236
237
clean:
238
	@$(RM) -f $(RESMAN_GLUE_OBJS) $(KERNEL_GLUE_OBJS); \
239
	$(RM) -f built-in.o nv-linux.o *.d .*.{cmd,flags}; \
240
	$(RM) -f $(MODULE_NAME).{o,ko,mod.{o,c}} $(VERSION_HEADER) *~
241
242
#
243
# Linux 2.4 KBUILD requires the inclusion of Rules.make; Linux 2.6's KBUILD
244
# includes dependencies automatically.
245
#
246
247
ifeq ($(PATCHLEVEL), 4)
248
include $(KERNEL_SOURCES)/Rules.make
249
endif
(-)NVIDIA_kernel-1.0-4363/Makefile.nvidia (+154 lines)
Line 0 Link Here
1
# This Makefile is automatically generated; do not edit
2
#   Generated on 'builder3.nvidia.com' on Mon Mar 24 16:36:51 PST 2003
3
4
LINUX_MODULE=nv-linux.o
5
DEFINES=-D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES -DKBUILD_MODNAME="nvidia" -DNTRM -D_GNU_SOURCE -D_LOOSE_KERNEL_NAMES -D__KERNEL__ -DMODULE  -DNV_MAJOR_VERSION=1 -DNV_MINOR_VERSION=0 -DNV_PATCHLEVEL=4348  -DNV_UNIX   -DNV_LINUX   -DNV_INT64_OK   -DNVCPU_X86     
6
INCLUDES=-I.
7
8
OBJECTS=nv.o os-agp.o os-interface.o os-registry.o 
9
HEADERS=os-agp.h os-interface.h nv-linux.h nv-misc.h nv.h  rmretval.h nvtypes.h  $(VERSION_HDR)
10
11
CFLAGS=-Wall -Wimplicit -Wreturn-type -Wswitch -Wformat -Wchar-subscripts -Wparentheses -Wcast-qual -Wno-multichar  -O -MD $(DEFINES) $(INCLUDES) -Wno-cast-qual
12
13
RESMAN_KERNEL_MODULE=nv-kernel.o
14
15
KERNDIR=/lib/modules/$(shell uname -r)
16
17
# check for newer paths. if found, use them, otherwise use old paths
18
# these wouldn't work with the gnu make included with rh6.2
19
# KERNINC=$(if -d $(KERNDIR)/build, $(KERNDIR)/build/include, /usr/src/linux/include)
20
# INSTALLDIR=$(if -d $(KERNDIR)/kernel, $(KERNDIR)/kernel/drivers/video, $(KERNDIR)/video)
21
22
# this is slightly more brain-dead, but works..
23
ifeq ($(shell if test -d $(KERNDIR)/build; then echo yes; fi),yes)
24
KERNINC=$(KERNDIR)/build/include
25
else
26
KERNINC=/usr/src/linux/include
27
endif
28
29
ifeq ($(shell if test -d $(KERNDIR)/kernel; then echo yes; fi),yes)
30
INSTALLDIR=$(KERNDIR)/kernel/drivers/video
31
else
32
INSTALLDIR=$(KERNDIR)/video
33
endif
34
35
ifeq ($(shell echo $(NVDEBUG)),1)
36
  ifeq ($(shell test -z $(RMDEBUG) && echo yes),yes)
37
    RMDEBUG=1
38
  endif
39
endif
40
41
ifeq ($(shell echo $(RMDEBUG)),1)
42
CFLAGS += -DDEBUG -g -fno-common
43
endif
44
45
# this is just plain wrong, get rid of it
46
BROKENDIR=$(KERNDIR)/kernel/video
47
48
INSTALL=$(shell which install)
49
50
# allow specification of alternate include file tree on command line and extra defines
51
ifdef SYSINCLUDE
52
INCLUDES += -I$(SYSINCLUDE)
53
INCLUDES += -I$(SYSINCLUDE)/asm/mach-default
54
else
55
INCLUDES += -I$(KERNINC)
56
INCLUDES += -I$(KERNINC)/asm/mach-default
57
endif
58
59
ifeq ($(shell sh conftest.sh remap_page_range $(INCLUDES)), 5)
60
  DEFINES += -DREMAP_PAGE_RANGE_5
61
endif
62
63
ifeq ($(shell sh conftest.sh remap_page_range $(INCLUDES)), 4)
64
  DEFINES += -DREMAP_PAGE_RANGE_4
65
endif
66
67
DEFINES+=$(EXTRA_DEFINES)
68
69
# allow build parameters to be passed in through the environment
70
ifdef BUILD_PARAMS
71
    DEFINES+=-D$(BUILD_PARAMS)
72
endif
73
74
VERSION_HDR=nv_compiler.h
75
76
all: install
77
78
install: package-install
79
80
suser-sanity-check:
81
	@if ! sh conftest.sh suser_sanity_check; then \
82
	  echo; \
83
	  echo "You have insufficient privileges for this operation. Please "; \
84
	  echo "run \"make install\" as root!                               "; \
85
	  echo; \
86
	  exit 1; \
87
	fi
88
89
rmmod-sanity-check:
90
	@if ! sh conftest.sh rmmod_sanity_check nvidia; then \
91
	  echo; \
92
	  echo "Unable to unload the currently loaded NVIDIA kernel module! "; \
93
	  echo "Please be certain that you have exited X before attempting  "; \
94
	  echo "to install this version.                                    "; \
95
	  echo; \
96
	  exit 1; \
97
	fi
98
99
cc-sanity-check:
100
	@if ! sh conftest.sh cc_sanity_check $(CC); then \
101
	  echo; \
102
	  echo "You appear to be building the NVIDIA kernel module with a  "; \
103
	  echo "compiler different from the one that was used to build the "; \
104
	  echo "running kernel. This may be perfectly fine, but there are  "; \
105
	  echo "cases where this can lead to unexpected behaviour and      "; \
106
	  echo "system crashes.                                            "; \
107
	  echo; \
108
	  echo "If you know what you are doing and want to override this   "; \
109
	  echo "check, you can do so by setting IGNORE_CC_MISMATCH.        "; \
110
	  echo; \
111
	  echo "In any other case, set the CC environment variable to the  "; \
112
	  echo "name of the compiler that was used to build the kernel.    "; \
113
	  echo; \
114
	  exit 1; \
115
	fi
116
117
package-install: suser-sanity-check nvidia.o rmmod-sanity-check
118
	if [ -d $(BROKENDIR) ]; then \
119
		rm -f $(BROKENDIR)/NVdriver; \
120
		rmdir --ignore-fail-on-non-empty $(BROKENDIR); \
121
	fi && \
122
	mkdir -p $(INSTALLDIR) && \
123
	rm -f $(INSTALLDIR)/NVdriver && \
124
	$(INSTALL) -m 0664 -o root -g root nvidia.o $(INSTALLDIR)/nvidia.o$(O) && \
125
	/sbin/depmod -a && \
126
	/sbin/modprobe nvidia && \
127
	sh makedevices.sh && \
128
	echo "nvidia.o installed successfully."; \
129
130
nvidia.o: cc-sanity-check $(LINUX_MODULE) $(RESMAN_KERNEL_MODULE) 
131
	ld -d -r -o $@ $(LINUX_MODULE) $(RESMAN_KERNEL_MODULE)
132
133
$(VERSION_HDR): 
134
	echo \#define NV_COMPILER \"`$(CC) -v 2>&1 | tail -n 1`\" > $@
135
136
$(LINUX_MODULE): $(OBJECTS)
137
	ld -r -o $@ $(OBJECTS)
138
139
%.o: %.c $(HEADERS)
140
	$(CC) -c $(CFLAGS) $<
141
142
# debug tool to preprocess the file and leave .i to make it easier to untangle #defines
143
%.i: %.c
144
	$(CC) $(CFLAGS) -E $< > $@
145
146
%.s: %.c
147
	$(CC) $(CFLAGS) -S $< > $@
148
149
150
clean:
151
	$(RM) $(OBJECTS) $(LINUX_MODULE) $(VERSION_HDR) *.d NVdriver nvidia.o
152
153
154
-include $(OBJECTS:%.o=%.d)
(-)NVIDIA_kernel-1.0-4363/conftest.sh (+167 lines)
Lines 1-5 Link Here
1
#!/bin/bash
1
#!/bin/bash
2
2
3
# make sure we are in the directory containing this script
4
SCRIPTDIR=`dirname $0`
5
cd $SCRIPTDIR
6
7
PATH=$PATH:/bin:/sbin
8
3
case "$1" in
9
case "$1" in
4
    remap_page_range)
10
    remap_page_range)
5
        shift
11
        shift
Lines 37-41 Link Here
37
          exit 1
43
          exit 1
38
        fi
44
        fi
39
    ;;
45
    ;;
46
47
    cc_sanity_check)
48
        shift
49
        #
50
        # Verify that the same compiler is used for the kernel and kernel
51
        # module.
52
        #
53
        if test -n "$IGNORE_CC_MISMATCH" -o -n "$SYSSRC" -o -n "$SYSINCLUDE"; then
54
          #
55
          # The user chose to disable this test; this may or may not be
56
          # a wise decision...
57
          #
58
          exit 0
59
        fi
60
        
61
        # usage: conftest.sh [cc_sanity_check] [full_output|just_msg] [$(CC)]
62
63
        OUTPUT=$1
64
        shift
65
66
        rm -f gcc-version-check
67
        $* gcc-version-check.c -o gcc-version-check > /dev/null 2>&1
68
        if [ -f gcc-version-check ]; then
69
            PROC_VERSION=`cat /proc/version`
70
            MSG=`./gcc-version-check "$PROC_VERSION"`
71
            RET=$?
72
            rm -f gcc-version-check
73
        else
74
            MSG="Could not compile gcc-version-check.c"
75
            RET=1
76
        fi
77
78
        if [ "$RET" != "0" ]; then
79
            #
80
            # The gcc version check failed
81
            #
82
            
83
            if [ "$OUTPUT" = "full_output" ]; then
84
                echo "";
85
                echo "gcc-version-check failed:";
86
                echo "";
87
                echo "$MSG" | fmt -w 60
88
                echo "";
89
                echo "If you know what you are doing and want to override";
90
                echo "the gcc version check, you can do so by setting the";
91
                echo "IGNORE_CC_MISMATCH environment variable to \"1\".";
92
                echo "";
93
                echo "In any other case, set the CC environment variable";
94
                echo "to the name of the compiler that was used to compile";
95
                echo "the kernel.";
96
                echo ""
97
                echo -en "\033[1;31m";
98
                echo -e  "*** Failed cc sanity check. Bailing out! ***";
99
                echo -en "\033[0m";
100
                echo "";
101
            else
102
                echo "$MSG"
103
            fi
104
            exit 1;
105
        else
106
            exit 0
107
        fi
108
    ;;
109
110
    kernel_patch_level)
111
        shift
112
        #
113
        # Determine the kernel's major patch level; this is only done if we
114
        # aren't told by KBUILD.
115
        #
116
        echo $(cat "$1"/Makefile | grep "PATCHLEVEL =" | cut -d " " -f 3)
117
        exit 0
118
    ;;
119
120
    suser_sanity_check)
121
        shift
122
        #
123
        # Determine the caller's user id to determine if we have sufficient
124
        # privileges for the requested operation.
125
        #
126
        if test $(id -ur) != 0; then
127
          echo "";
128
          echo "Please run \"make install\" as root.";
129
          echo "";
130
          echo -en "\033[1;31m";
131
          echo -e  "*** Failed super-user sanity check. Bailing out! ***";
132
          echo -en "\033[0m";
133
          exit 1
134
        else
135
          exit 0
136
        fi
137
    ;;
138
139
    rmmod_sanity_check)
140
        shift
141
        #
142
        # Make sure that any currently loaded NVIDIA kernel module can be
143
        # unloaded.
144
        #
145
        if test -n "$SYSSRC" -o -n "$SYSINCLUDE"; then
146
          #
147
          # Don't attempt to remove the kernel module if we're not
148
          # building against the running kernel.
149
          #
150
          exit 0
151
        fi
152
153
        if lsmod | grep -q "$1"; then
154
          rmmod "$1" >& /dev/null
155
        fi
156
157
        if lsmod | grep -q "$1"; then
158
          #
159
          # The NVIDIA kernel module is still loaded, most likely because
160
          # it is busy.
161
          #
162
          echo "";
163
          echo "Unable to remove existing NVIDIA kernel module.";
164
          echo "Please be sure you have exited X before attempting";
165
          echo "to install the NVIDIA kernel module.";
166
          echo "";
167
          echo -en "\033[1;31m";
168
          echo -e  "*** Failed rmmod sanity check. Bailing out! ***";
169
          echo -en "\033[0m";
170
          exit 1
171
        else
172
          exit 0
173
        fi
174
    ;;
175
176
    get_uname)
177
        #
178
        # print UTS_RELEASE from the kernel sources that we are building
179
        # against; if an error occurs, give up and just return `uname -r`
180
        #
181
        shift
182
183
        if [ "$SYSSRC" ]; then
184
            KERNEL_INCLUDE=$SYSSRC/include
185
        elif [ "$SYSINCLUDE" ]; then
186
            KERNEL_INCLUDE=$SYSINCLUDE
187
        else
188
            KERNEL_INCLUDE="/lib/modules/`uname -r`/build/include"
189
        fi
190
191
        echo "#include \"linux/version.h\"
192
        int main() { printf(\"%s\n\", UTS_RELEASE); return 0; }" \
193
            > conftest.c
194
195
        gcc conftest.c -o conftest -nostdinc \
196
            -I $KERNEL_INCLUDE > /dev/null 2>&1
197
198
        if [ -f conftest ]; then
199
            ./conftest
200
            rm -f conftest conftest.c
201
            exit 0
202
        else
203
            uname -r
204
            exit 1
205
        fi
206
    ;;
40
esac
207
esac
41
208
(-)NVIDIA_kernel-1.0-4363/gcc-version-check.c (+200 lines)
Line 0 Link Here
1
#include <stdio.h>
2
#include <string.h>
3
#include <ctype.h>
4
5
/*
6
 * Check that the compiler used to compile this source file matches
7
 * the major and minor version of the compiler used to compile the
8
 * kernel specified on the commandline.
9
 *
10
 * The /proc/version string for the kernel in question is specified on
11
 * the commandline.
12
 *
13
 * Returns 0 if the major and minor versions match, and returns 1 if
14
 * they do not match.
15
 *
16
 * The program always prints one line of output to stdout, describing
17
 * why the return status was returned; this is so that the caller may
18
 * use that output when explaining what happened.
19
 *
20
 *
21
 * Some gcc version strings that have proven problematic for parsing
22
 * in the past:
23
 *
24
 *  gcc.real (GCC) 3.3 (Debian)
25
 *  gcc-Version 3.3 (Debian)
26
 *  gcc (GCC) 3.1.1 20020606 (Debian prerelease)
27
 */
28
29
30
31
#define STATE_BEFORE   0
32
#define STATE_IN_MAJOR 1
33
#define STATE_DOT      2
34
#define STATE_IN_MINOR 3
35
36
#define ctoi(c) (c - '0')
37
38
39
int main(int argc, char *argv[])
40
{
41
    char *str, *s, c;
42
    int gcc_major = __GNUC__;
43
    int gcc_minor = __GNUC_MINOR__;
44
    int major = 0;
45
    int minor = 0;
46
    int state;
47
    
48
    /*
49
     * must have exactly one argument: the kernel's proc version
50
     * string to check
51
     */
52
    
53
    if (argc != 2) {
54
        printf("No /proc/version string specified.\n");
55
        return 1;
56
    }
57
    
58
    /*
59
     * skip ahead in the /proc/version string to the first instance of
60
     * "(gcc"
61
     */
62
    
63
    str = argv[1];
64
    s = strstr(str, "(gcc");
65
    if (!s) {
66
        printf("The string \"(gcc\" was not found in the /proc/version "
67
               "string: \"%s\"; please report this error to "
68
               "linux-bugs@nvidia.com\n", str);
69
        return 1;
70
    }
71
    
72
    /*
73
     * Parser state machine: once we have found "gcc" in the
74
     * /proc/version string, scan for the next instances of "MMM.mmm";
75
     * in other words: we are looking for some number of digits (the
76
     * gcc major version number), followed by a dot, followed by some
77
     * number of digits (the gcc minor version number).
78
     */
79
80
    state = STATE_BEFORE;
81
82
    while(*s) {
83
        c = *s;
84
        switch (state) {
85
     
86
            /*
87
             * If we are in STATE_BEFORE and find a digit, then we
88
             * might have found the start of the major version number:
89
             * transition to STATE_IN_MAJOR and start recording
90
             * major.
91
             *
92
             * If we find a non-digit, then remain in STATE_BEFORE.
93
             */
94
       
95
        case STATE_BEFORE:
96
            if (isdigit(c)) {
97
                state = STATE_IN_MAJOR;
98
                major = ctoi(c);
99
            } else {
100
                state = STATE_BEFORE;
101
                major = minor = 0;
102
            }
103
            break;
104
            
105
            /*
106
             * If we are in STATE_IN_MAJOR and find a digit, then stay
107
             * in STATE_IN_MAJOR and continue to accumulate
108
             * major.
109
             *
110
             * If we find a dot, then transition to STATE_DOT.
111
             *
112
             * If we find anything else, then this was not really the
113
             * major version number: transition back to STATE_BEFORE
114
             * and clear out the major/minor variables.
115
             */
116
117
        case STATE_IN_MAJOR:
118
            if (isdigit(c)) {
119
                state = STATE_IN_MAJOR;
120
                major = (major * 10) + ctoi(c);
121
            } else if (c == '.') {
122
                state = STATE_DOT;
123
            } else {
124
                state = STATE_BEFORE;
125
                major = minor = 0;
126
            }
127
            break;
128
            
129
            /*
130
             * If we are in STATE_DOT and find a digit, then this is
131
             * the start of the minor version number: transition to
132
             * STATE_IN_MINOR, and start recording minor.
133
             *
134
             * If we find a non-digit, then this was not really the
135
             * version: transition back to STATE_BEFORE and clear out
136
             * the major/minor variables.
137
             */
138
            
139
        case STATE_DOT:
140
            if (isdigit(c)) {
141
                state = STATE_IN_MINOR;
142
                minor = ctoi(c);
143
            } else {
144
                state = STATE_BEFORE;
145
                major = minor = 0;
146
            }
147
            break;
148
            
149
            /*
150
             * If we are in STATE_IN_MINOR and find a digit, then stay
151
             * in STATE_IN_MINOR and continue to accumulate
152
             * minor.
153
             *
154
             * If we find a non-digit, then we are done.
155
             */
156
157
        case STATE_IN_MINOR:
158
            if (isdigit(c)) {
159
                state = STATE_IN_MINOR;
160
                minor = (minor * 10) + ctoi(c);
161
            } else {
162
                /* we are now done. */
163
                goto done;
164
            }
165
            break;
166
        }
167
        s++;
168
    }
169
170
 done:
171
172
    if (state == STATE_IN_MINOR) {
173
        if ((major == gcc_major) && (minor == gcc_minor)) {
174
            printf("The compiler used to compile the kernel matches the "
175
                   "current compiler (gcc %d.%d)\n", major, minor);
176
            return 0;
177
        } else if ((major == gcc_major) && (gcc_major > 2)) {
178
            printf("The compiler used to compile the kernel (gcc %d.%d) does "
179
                   "not exactly match the current compiler (gcc %d.%d), but "
180
                   "it is close enough.\n",
181
                   major, minor, gcc_major, gcc_minor);
182
            return 0;
183
        } else {
184
185
            printf("You appear to be compiling the NVIDIA kernel module with "
186
                   "a different compiler than the one that was used to "
187
                   "compile the running kernel.  This may be fine, "
188
                   "but there are cases where this can lead to instability.  "
189
                   "The compiler used to "
190
                   "compile the kernel was gcc %d.%d; the current "
191
                   "compiler is gcc %d.%d.\n",
192
                   major, minor, gcc_major, gcc_minor);
193
            return 1;
194
        }
195
    }
196
    
197
    printf("No gcc version found in /proc/version string: \"%s\"; please "
198
           "report this error to linux-bugs@nvidia.com\n", str);
199
    return 1;
200
}
(-)NVIDIA_kernel-1.0-4363/makedevices.sh (-38 / +43 lines)
Lines 1-56 Link Here
1
#!/bin/bash
1
#!/bin/sh
2
2
3
function error {
3
error() {
4
  echo "$(basename $0): fatal error, $1 failed"
4
  echo "$(basename $0): fatal error, $1 failed"
5
  exit 1
5
  exit 1
6
}
6
}
7
7
8
modconf=""
8
# create a temporary file
9
mktemp=`which mktemp || echo touch`
9
tmp=`(mktemp -q /tmp/nvidia.XXXXXX) 2> /dev/null` || tmp="/tmp/nvidia.$$"
10
tmp=`$mktemp -q /tmp/nvidia.XXXXXX` || error "mktemp"
11
12
paths=" /etc/modutils/aliases    \
13
        /etc/modules.conf        \
14
        /etc/conf.modules        "
15
10
16
for path in $paths; do
11
modconfs=" /etc/modutils/aliases    \
17
  test -f $path && modconf=$path
12
           /etc/modules.conf        \
13
           /etc/modprobe.d/aliases  \
14
           /etc/modprobe.conf       \
15
           /etc/conf.modules        "
16
17
#
18
# Pass the -p option to cp to preserve the permissions of $modconf and
19
# /etc/rc.d/rc.modules across the update. Update all relevant files
20
# including those eventually regenerated to avoid the need for awkward
21
# logic here.
22
#
23
for modconf in $modconfs; do
24
   if [ -f "$modconf" ]; then
25
     cp -p $modconf $tmp
26
     sed '/^alias.*\(NVdriver\|nvidia\)/d'  < $modconf   > $tmp
27
     if [ -c /dev/.devfsd ]; then
28
       echo "alias /dev/nvidia* nvidia" >> $tmp
29
     else
30
       if [ `uname -r | cut -d '.' -f 2` = 6 ]; then
31
           echo "alias	char-major-195*	nvidia" >> $tmp
32
       else
33
           echo "alias	char-major-195	nvidia" >> $tmp
34
       fi
35
     fi
36
     mv -f $tmp $modconf
37
     test -x /sbin/update-modules && /sbin/update-modules
38
   fi
18
done
39
done
19
40
20
if [ ! -z $modconf ]; then
41
if [ -f /etc/rc.d/rc.modules ]; then
21
   # Initialize the permissions on $tmp so that we don't change the
42
  cp -p /etc/rc.d/rc.modules $tmp
22
   # permissions of $modconf when we mv it into place
43
  sed '/.*\(NVdriver\|nvidia\).*/d' < /etc/rc.d/rc.modules > $tmp
23
   cp -p $modconf $tmp
44
  echo -e "\n/sbin/modprobe nvidia" >> $tmp
24
   sed '/^alias.*\(NVdriver\|nvidia\)/d'  < $modconf   > $tmp
45
  mv -f $tmp /etc/rc.d/rc.modules
25
   if [ -c /dev/.devfsd ]; then
26
     echo "alias /dev/nvidia*   nvidia" >> $tmp
27
   else
28
     echo "alias char-major-195 nvidia" >> $tmp
29
   fi
30
   mv -f $tmp $modconf
31
   test -x /sbin/update-modules && /sbin/update-modules
32
else
33
  if [ -f /etc/rc.d/rc.modules ]; then
34
    # Initialize the permissions on $tmp so that we don't change the
35
    # permissions of /etc/rc.d/rc.modules when we mv it into place
36
    cp -p /etc/rc.d/rc.modules $tmp
37
    sed '/.*\(NVdriver\|nvidia\).*/d' < /etc/rc.d/rc.modules > $tmp
38
    echo -e "\n/sbin/modprobe nvidia" >> $tmp
39
    mv -f $tmp /etc/rc.d/rc.modules
40
  fi
41
fi
46
fi
42
47
43
if [ ! -c /dev/.devfsd ]; then
48
if [ ! -c /dev/.devfsd ]; then
44
  for i in 0 1 2 3 4 5 6 7; do
49
  for i in 0 1 2 3 4 5 6 7; do
45
	node="/dev/nvidia$i"
50
      node="/dev/nvidia$i"
46
	rm -f $node
51
      rm -f $node
47
    mknod $node c 195 $i || error "mknod \"$node\""
52
      mknod $node c 195 $i || error "mknod \"$node\""
48
    chmod 0666 $node     || error "chmod \"$node\""
53
      chmod 0666 $node     || error "chmod \"$node\""
49
  done
54
  done
50
  node="/dev/nvidiactl"
55
  node="/dev/nvidiactl"
51
  rm -f $node        
56
  rm -f $node        
52
  mknod $node c 195 255  || error "mknod \"$node\""
57
  mknod $node c 195 255    || error "mknod \"$node\""
53
  chmod 0666 $node       || error "chmod \"$node\""
58
  chmod 0666 $node         || error "chmod \"$node\""
54
fi
59
fi
55
60
56
exit 0
61
exit 0
(-)NVIDIA_kernel-1.0-4363/nv-linux.h (-81 / +174 lines)
Lines 20-54 Link Here
20
#  define MODVERSIONS
20
#  define MODVERSIONS
21
#endif
21
#endif
22
22
23
#if defined (MODVERSIONS)
24
#include <linux/modversions.h>
25
#endif
26
27
#include <linux/kernel.h>
28
#include <linux/module.h>
29
#include <linux/version.h>
23
#include <linux/version.h>
30
24
31
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 12)
25
#if   LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)
32
#  error This driver does not support 2.2.11 or earlier kernels!
26
#  error This driver does not support 2.2.x kernels!
33
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)
34
#  define KERNEL_2_2
35
#  warning NVIDIA is considering dropping support for linux-2.2 
36
#  warning kernels. While end users are free to maintain their 
37
#  warning own patches, or stick with current drivers, our new 
38
#  warning drivers will not work "out of the box." If you are 
39
#  warning concerned about lack of support for 2.2 kernels, 
40
#  warning please let us know at linux-bugs@nvidia.com; we would
41
#  warning like to know how many users would be seriously 
42
#  warning impacted by this decision.
43
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
27
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
44
#  error This driver does not support 2.3.x development kernels!
28
#  error This driver does not support 2.3.x kernels!
45
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
29
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
46
#  define KERNEL_2_4
30
#  define KERNEL_2_4
47
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
31
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
48
#  error This driver does not support 2.5.x development kernels!
32
#  error This driver does not support 2.5.x kernels!
49
#  define KERNEL_2_5
33
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 7, 0)
34
#  define KERNEL_2_6
50
#else
35
#else
51
#  error This driver does not support 2.6.x or newer kernels!
36
#  error This driver does not support development kernels!
52
#endif
37
#endif
53
38
54
#if defined (__ia64)
39
#if defined (__ia64)
Lines 61-72 Link Here
61
#define __SMP__
46
#define __SMP__
62
#endif
47
#endif
63
48
49
#if defined (MODVERSIONS) && !defined (KERNEL_2_6)
50
#include <linux/modversions.h>
51
#endif
52
53
#include <linux/kernel.h>
54
#include <linux/module.h>
55
56
#include <linux/init.h>             /* module_init, module_exit         */
64
#include <linux/types.h>            /* pic_t, size_t, __u32, etc        */
57
#include <linux/types.h>            /* pic_t, size_t, __u32, etc        */
65
#include <linux/errno.h>            /* error codes                      */
58
#include <linux/errno.h>            /* error codes                      */
66
#include <linux/list.h>             /* circular linked list             */
59
#include <linux/list.h>             /* circular linked list             */
67
#include <linux/stddef.h>           /* NULL, offsetof                   */
60
#include <linux/stddef.h>           /* NULL, offsetof                   */
68
#include <linux/wait.h>             /* wait queues                      */
61
#include <linux/wait.h>             /* wait queues                      */
69
#include <linux/tqueue.h>           /* struct tq_struct                 */
70
62
71
#include <linux/slab.h>             /* kmalloc, kfree, etc              */
63
#include <linux/slab.h>             /* kmalloc, kfree, etc              */
72
#include <linux/vmalloc.h>          /* vmalloc, vfree, etc              */
64
#include <linux/vmalloc.h>          /* vmalloc, vfree, etc              */
Lines 74-82 Link Here
74
#include <linux/poll.h>             /* poll_wait                        */
66
#include <linux/poll.h>             /* poll_wait                        */
75
#include <linux/delay.h>            /* mdelay, udelay                   */
67
#include <linux/delay.h>            /* mdelay, udelay                   */
76
68
69
#ifdef KERNEL_2_6
70
#include <linux/sched.h>            /* suser(), capable() replacement   */
71
#include <linux/moduleparam.h>      /* module_param()                   */
72
#include <linux/smp_lock.h>         /* kernel_locked                    */
73
#include <asm/kmap_types.h>         /* page table entry lookup          */
74
#endif
75
77
#include <linux/pci.h>              /* pci_find_class, etc              */
76
#include <linux/pci.h>              /* pci_find_class, etc              */
78
#include <linux/wrapper.h>          /* mem_map_reserve                  */
77
#include <linux/interrupt.h>        /* tasklets, interrupt helpers      */
79
#include <linux/interrupt.h>        /* mark_bh, init_bh, remove_bh      */
80
#include <linux/timer.h>
78
#include <linux/timer.h>
81
79
82
#include <asm/system.h>             /* cli, sli, save_flags             */
80
#include <asm/system.h>             /* cli, sli, save_flags             */
Lines 85-98 Link Here
85
#include <asm/page.h>               /* PAGE_OFFSET                      */
83
#include <asm/page.h>               /* PAGE_OFFSET                      */
86
#include <asm/pgtable.h>            /* pte bit definitions              */
84
#include <asm/pgtable.h>            /* pte bit definitions              */
87
85
88
#if !defined (KERNEL_2_2)
89
#include <linux/spinlock.h>
86
#include <linux/spinlock.h>
90
#include <asm/semaphore.h>
87
#include <asm/semaphore.h>
91
#include <linux/highmem.h>
88
#include <linux/highmem.h>
92
#else
93
#include <asm/spinlock.h>
94
#include <asm/semaphore.h>
95
#endif
96
89
97
#ifdef CONFIG_PROC_FS
90
#ifdef CONFIG_PROC_FS
98
#include <linux/proc_fs.h>
91
#include <linux/proc_fs.h>
Lines 132-201 Link Here
132
        for (pos = (head)->next; pos != (head); pos = (pos)->next)
125
        for (pos = (head)->next; pos != (head); pos = (pos)->next)
133
#endif
126
#endif
134
127
135
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 18)
128
#define GET_MODULE_SYMBOL(mod,sym)      (const void *) inter_module_get(sym)
136
#define vmalloc_32 vmalloc
129
#define PUT_MODULE_SYMBOL(sym)          inter_module_put((char *) sym)
130
131
#ifdef KERNEL_2_6
132
# define NV_IS_SUSER()                  capable(CAP_SYS_ADMIN)
133
# define NV_PCI_DEVICE_NAME(x)          ((x)->pretty_name)
134
# define NV_CLI()                       local_irq_disable()
135
# define NV_SAVE_FLAGS(x)               local_save_flags(x)
136
# define NV_RESTORE_FLAGS(x)            local_irq_restore(x)
137
# define NV_MAY_SLEEP()                 (!in_interrupt() && !in_atomic())
138
# define NV_SMP_NUM_CPUS                num_online_cpus()
139
# define NV_MODULE_PARAMETER(x)         module_param(x, int, 0)
140
#else
141
# define NV_IS_SUSER()                  suser()
142
# define NV_PCI_DEVICE_NAME(x)          ((x)->name)
143
# define NV_CLI()                       __cli()
144
# define NV_SAVE_FLAGS(x)               __save_flags(x)
145
# define NV_RESTORE_FLAGS(x)            __restore_flags(x)
146
# define NV_MAY_SLEEP()                 (!in_interrupt())
147
# define NV_SMP_NUM_CPUS                smp_num_cpus
148
# define NV_MODULE_PARAMETER(x)         MODULE_PARM(x, "i")
137
#endif
149
#endif
138
150
139
#if !defined (KERNEL_2_2)
151
#define NV_DEVICE_NUMBER(x)             minor((x)->i_rdev)
140
#  define LINUX_VMA_OFFS(vma)           (((vma)->vm_pgoff) << PAGE_SHIFT)
152
#define NV_VMA_OFFSET(x)                (((x)->vm_pgoff) << PAGE_SHIFT)
141
#  define GET_MODULE_SYMBOL(mod,sym)	(const void *) inter_module_get(sym)
153
#define NV_VMA_PRIVATE(x)               ((x)->vm_private_data)
142
#  define PUT_MODULE_SYMBOL(sym)        inter_module_put((char *) sym)
154
#define NV_IS_CONTROL_DEVICE(x)         (minor((x)->i_rdev) == 255)
143
#  define GET_MAP_NR(phys_page)         virt_to_page(__va(phys_page))
155
    
144
#  define MEM_MAP_READ_COUNT(map_nr)    (atomic_read(&(map_nr)->count))
156
#ifndef minor
145
#  define MEM_MAP_INC_COUNT(map_nr)     (atomic_inc(&(map_nr)->count))
157
/*
146
#  define MEM_MAP_DEC_COUNT(map_nr)     (atomic_dec(&(map_nr)->count))
158
 * XXX Is this correct for all possible target kernels? We need this to
147
#  define GET_EVENT_QUEUE(nv)           ((struct __wait_queue_head *) ((nv)->event_queue))
159
 * support older 2.4 and some 2.6 kernels.
148
#  define VMA_PRIVATE(vma)              ((vma)->vm_private_data)
160
 */
149
#else
161
# define minor(x) MINOR(x)
150
#  define in_irq()                      (local_irq_count[smp_processor_id()])
151
#  define LINUX_VMA_OFFS(vma)           ((vma)->vm_offset)
152
#  define GET_MODULE_SYMBOL(mod, sym)   (void*) get_module_symbol((mod), (sym))
153
#  define PUT_MODULE_SYMBOL(sym)
154
#  define GET_MAP_NR(phys_page)         MAP_NR(__va(phys_page))
155
#  define MEM_MAP_READ_COUNT(map_nr)    (atomic_read(&mem_map[map_nr].count))
156
#  define MEM_MAP_INC_COUNT(map_nr)     (atomic_inc(&mem_map[map_nr].count))
157
#  define MEM_MAP_DEC_COUNT(map_nr)     (atomic_dec(&mem_map[map_nr].count))
158
#  define GET_EVENT_QUEUE(nv)           ((struct wait_queue **) &((nv)->event_queue))
159
#  define VMA_PRIVATE(vma)              ((void*)((vma)->vm_pte))
160
#endif
162
#endif
161
163
164
#ifndef KERNEL_2_6
165
#ifndef IRQ_HANDLED
166
  typedef void irqreturn_t;
167
#define IRQ_HANDLED
168
#endif  
169
#else
170
#ifdef AGPGART
171
  typedef struct agp_kern_info agp_kern_info;
172
  typedef struct agp_memory agp_memory;
173
#endif
174
  typedef void* devfs_handle_t;
175
#endif
176
177
#ifdef KERNEL_2_6
178
#define NV_DEVFS_REGISTER(_name, _minor)                            \
179
({                                                                  \
180
    devfs_handle_t __handle = NULL;                                 \
181
    devfs_mk_cdev(MKDEV(NV_MAJOR_DEVICE_NUMBER, _minor),            \
182
            S_IFCHR | S_IRUGO | S_IWUGO, _name);                    \
183
    __handle;                                                       \
184
})
185
186
#define NV_DEVFS_REMOVE_DEVICE(i) devfs_remove("nvidia%d", i)
187
#define NV_DEVFS_REMOVE_CONTROL() devfs_remove("nvidiactl")
188
#else
189
#define NV_DEVFS_REGISTER(_name, _minor)                            \
190
({                                                                  \
191
    devfs_handle_t __handle =                                       \
192
        devfs_register(NULL, _name, DEVFS_FL_DEFAULT,               \
193
                NV_MAJOR_DEVICE_NUMBER, _minor,                     \
194
                S_IFCHR | S_IRUGO | S_IWUGO, &nv_fops, NULL);       \
195
    __handle;                                                       \
196
 })
197
198
#define NV_DEVFS_REMOVE_DEVICE(i) devfs_unregister(nv_devfs_handles[i+1])
199
#define NV_DEVFS_REMOVE_CONTROL() devfs_unregister(nv_devfs_handles[0])
200
#endif
201
202
/*
203
 * Linux 2.5 introduced the five argument version of remap_page_range, all
204
 * relevant releases to date use it. This version was backported to 2.4 by
205
 * RedHat without means to identify the change, hence this hack.
206
 */
207
#ifdef KERNEL_2_6
208
#define NV_REMAP_PAGE_RANGE(a, b...) remap_page_range(vma, a, ## b)
209
#else
162
#if defined(REMAP_PAGE_RANGE_5)
210
#if defined(REMAP_PAGE_RANGE_5)
163
#define NV_REMAP_PAGE_RANGE(a, b...)    remap_page_range(vma, a, ## b)
211
#define NV_REMAP_PAGE_RANGE(a, b...) remap_page_range(vma, a, ## b)
164
#elif defined(REMAP_PAGE_RANGE_4)
212
#elif defined(REMAP_PAGE_RANGE_4)
165
#define NV_REMAP_PAGE_RANGE(a, b...)    remap_page_range(a, ## b)
213
#define NV_REMAP_PAGE_RANGE(a, b...) remap_page_range(a, ## b)
166
#else
214
#else
167
#error "Couldn't determine number of arguments expected by remap_page_range!"
215
#warning "conftest.sh failed, assuming old Linux 2.4 remap_page_range(4)!"
216
217
#define NV_REMAP_PAGE_RANGE(a, b...) remap_page_range(a, ## b)
168
#endif
218
#endif
219
#endif /* KERNEL_2_6 */
169
220
170
#if defined(pte_offset_atomic)
221
#if defined(pmd_offset_map)
171
#define NV_PTE_OFFSET(addres, pg_mid_dir, pte) \
222
#define NV_PMD_OFFSET(address, pgd, pmd) \
172
    { \
223
    { \
173
        pte_t *pte__ = pte_offset_atomic(pg_mid_dir, address); \
224
        pmd = pmd_offset_map(pgd, address); \
174
        pte = *pte__; \
225
    }
175
        pte_kunmap(pte__); \
226
#define NV_PMD_UNMAP(pmd) \
227
    { \
228
        pmd_unmap(pmd); \
176
    }
229
    }
177
#elif defined(pte_offset)
178
#define NV_PTE_OFFSET(addres, pg_mid_dir, pte) \
179
    pte = *pte_offset(pg_mid_dir, address)
180
#else
230
#else
181
#define NV_PTE_OFFSET(addres, pg_mid_dir, pte) \
231
#define NV_PMD_OFFSET(address, pgd, pmd) \
182
    { \
232
    { \
183
        pte_t *pte__ = pte_offset_map(pg_mid_dir, address); \
233
        pmd = pmd_offset(pgd, address); \
184
        pte = *pte__; \
185
        pte_unmap(pte__); \
186
    }
234
    }
235
#define NV_PMD_UNMAP(pmd)
187
#endif
236
#endif
188
237
189
#define NV_PAGE_ALIGN(addr)             ( ((addr) + PAGE_SIZE - 1) / PAGE_SIZE)
238
#define NV_PMD_PRESENT(pmd) \
190
#define NV_MASK_OFFSET(addr)            ( (addr) & (PAGE_SIZE - 1) )
239
    ({ \
240
        if (pmd) { \
241
            if (pmd_none(*pmd)) { \
242
                NV_PMD_UNMAP(pmd); pmd = NULL; \
243
            } \
244
        } pmd != NULL; \
245
    })
191
246
192
#ifndef MAXMEM  /* temporary define for 2.2 kernels */
247
#if defined (pte_offset_atomic)
193
#define MAXMEM  (-PAGE_OFFSET - (64 * 1024 * 1024))
248
#define NV_PTE_OFFSET(address, pmd, pte) \
249
    { \
250
        pte = pte_offset_atomic(pmd, address); \
251
        NV_PMD_UNMAP(pmd); \
252
    }
253
#define NV_PTE_UNMAP(pte) \
254
    { \
255
        pte_kunmap(pte); \
256
    }
257
#elif defined (pte_offset)
258
#define NV_PTE_OFFSET(address, pmd, pte) \
259
    { \
260
        pte = pte_offset(pmd, address); \
261
        NV_PMD_UNMAP(pmd); \
262
    }
263
#define NV_PTE_UNMAP(pte)
264
#else
265
#define NV_PTE_OFFSET(address, pmd, pte) \
266
    { \
267
        pte = pte_offset_map(pmd, address); \
268
        NV_PMD_UNMAP(pmd); \
269
    }
270
#define NV_PTE_UNMAP(pte) \
271
    { \
272
        pte_unmap(pte); \
273
    }
194
#endif
274
#endif
195
275
196
#ifndef NV01_ROOT
276
#define NV_PTE_PRESENT(pte) \
197
#define NV01_ROOT 0x00000000
277
    ({ \
198
#endif 
278
        if (pte) { \
279
            if (!pte_present(*pte)) { \
280
                NV_PTE_UNMAP(pte); pte = NULL; \
281
            } \
282
        } pte != NULL; \
283
    })
284
285
#define NV_PTE_VALUE(pte) \
286
    ({ \
287
        unsigned long __pte_value = pte_val(*pte); \
288
        NV_PTE_UNMAP(pte); \
289
        __pte_value; \
290
    })
291
292
#define NV_PAGE_ALIGN(addr)             ( ((addr) + PAGE_SIZE - 1) / PAGE_SIZE)
293
#define NV_MASK_OFFSET(addr)            ( (addr) & (PAGE_SIZE - 1) )
199
294
200
#if defined(NVCPU_IA64)
295
#if defined(NVCPU_IA64)
201
#define NV_GFP_HW (GFP_KERNEL | __GFP_DMA)
296
#define NV_GFP_HW (GFP_KERNEL | __GFP_DMA)
Lines 252-258 Link Here
252
static inline int NV_IRQL_IS_RAISED()
347
static inline int NV_IRQL_IS_RAISED()
253
    {
348
    {
254
        unsigned long int eflags;
349
        unsigned long int eflags;
255
        __save_flags(eflags);
350
        NV_SAVE_FLAGS(eflags);
256
        return !(eflags & NV_CPU_INTERRUPT_FLAGS_BIT);
351
        return !(eflags & NV_CPU_INTERRUPT_FLAGS_BIT);
257
    }
352
    }
258
 
353
 
Lines 310-325 Link Here
310
405
311
    nv_alloc_t *alloc_queue;
406
    nv_alloc_t *alloc_queue;
312
407
313
    // bottom half interrupt handler info; per device
408
    /* keep track of any pending bottom halfes */
314
    /* keep track of any pending bottom-halves */
409
    struct tasklet_struct tasklet;
315
    struct tq_struct *bh;
316
    atomic_t bh_count;
317
410
318
    U032 vblank_notifier;
411
    U032 vblank_notifier;
319
    U032 waiting_for_vblank;
412
    U032 waiting_for_vblank;
320
413
321
    /* queue for for NV's OS events */
414
    /* queue for for NV's OS events */
322
    void *event_queue;
415
    wait_queue_head_t waitqueue;
323
416
324
    /* get a timer callback every second */
417
    /* get a timer callback every second */
325
    struct timer_list rc_timer;
418
    struct timer_list rc_timer;
(-)NVIDIA_kernel-1.0-4363/nv-misc.h (+6 lines)
Lines 53-57 Link Here
53
53
54
typedef void *PHWINFO;
54
typedef void *PHWINFO;
55
55
56
/*
57
 * XXX: Make sure that arguments to and from the core resource
58
 * manager are passed and expected on the stack. Is this a good
59
 * place for this?
60
 */
61
#define NV_API_CALL __attribute__((regparm(0)))
56
62
57
#endif /* _NV_MISC_H_ */
63
#endif /* _NV_MISC_H_ */
(-)NVIDIA_kernel-1.0-4363/nv.c (-232 / +146 lines)
Lines 16-26 Link Here
16
#include "os-agp.h"
16
#include "os-agp.h"
17
17
18
18
19
MODULE_LICENSE("NVIDIA");
20
19
/*
21
/*
20
 * our global state; one per device
22
 * our global state; one per device
21
 */
23
 */
22
24
23
nv_linux_state_t nv_linux_devices[NV_MAX_DEVICES] = { { { 0 } } };
25
nv_linux_state_t nv_linux_devices[NV_MAX_DEVICES] = { { { 0 } } };
26
static int nv_num_devices;
24
27
25
#ifdef CONFIG_PM
28
#ifdef CONFIG_PM
26
/* XXX PM do we only need one, or one for each device? */
29
/* XXX PM do we only need one, or one for each device? */
Lines 36-62 Link Here
36
// keep track of opened clients and their process id so they
39
// keep track of opened clients and their process id so they
37
//   can be free'd up on abnormal close
40
//   can be free'd up on abnormal close
38
nv_client_t       nv_clients[NV_MAX_CLIENTS];
41
nv_client_t       nv_clients[NV_MAX_CLIENTS];
39
struct tq_struct  nv_bottom_halves[NV_MAX_CLIENTS];
40
42
41
#ifdef CONFIG_PROC_FS
43
#ifdef CONFIG_PROC_FS
42
struct proc_dir_entry *proc_nvidia;
44
struct proc_dir_entry *proc_nvidia;
43
#endif
45
#endif
44
46
45
#ifdef CONFIG_DEVFS_FS
47
#ifdef CONFIG_DEVFS_FS
46
devfs_handle_t  nv_dev_handle[NV_MAX_DEVICES];
48
devfs_handle_t nv_devfs_handles[NV_MAX_DEVICES+1];
47
devfs_handle_t  nv_ctl_handle;
48
#endif
49
#endif
49
50
50
/*
51
 * pick apart our minor device number
52
 * low 3 bits is NV device
53
 * if 255, then its the control device
54
 */
55
56
#define NV_DEVICE_NUMBER(_minor) ((_minor) & 0x0f)
57
#define NV_DEVICE_IS_CONTROL_DEVICE(_minor) \
58
             (((_minor) & 0xFF) == 0xFF)
59
60
// #define NV_DBG_MEM 1
51
// #define NV_DBG_MEM 1
61
#undef NV_DBG_MEM
52
#undef NV_DBG_MEM
62
53
Lines 107-116 Link Here
107
 *** EXPORTS to Linux Kernel
98
 *** EXPORTS to Linux Kernel
108
 ***/
99
 ***/
109
100
110
/* linux module interface functions (called by linux kernel) */
111
int           init_module(void);
112
void          cleanup_module(void);
113
114
/* nv_kern_ functions, interfaces used by linux kernel */
101
/* nv_kern_ functions, interfaces used by linux kernel */
115
void          nv_kern_vma_open(struct vm_area_struct *vma);
102
void          nv_kern_vma_open(struct vm_area_struct *vma);
116
void          nv_kern_vma_release(struct vm_area_struct *vma);
103
void          nv_kern_vma_release(struct vm_area_struct *vma);
Lines 120-127 Link Here
120
int           nv_kern_mmap(struct file *, struct vm_area_struct *);
107
int           nv_kern_mmap(struct file *, struct vm_area_struct *);
121
unsigned int  nv_kern_poll(struct file *, poll_table *);
108
unsigned int  nv_kern_poll(struct file *, poll_table *);
122
int           nv_kern_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
109
int           nv_kern_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
123
void          nv_kern_bh(void *);
110
void          nv_kern_isr_bh(unsigned long);
124
void          nv_kern_isr(int, void *, struct pt_regs *);
111
irqreturn_t   nv_kern_isr(int, void *, struct pt_regs *);
125
void          nv_kern_rc_timer(unsigned long);
112
void          nv_kern_rc_timer(unsigned long);
126
#ifdef CONFIG_PM
113
#ifdef CONFIG_PM
127
int           nv_kern_pm(struct pm_dev *dev, pm_request_t rqst, void *data);
114
int           nv_kern_pm(struct pm_dev *dev, pm_request_t rqst, void *data);
Lines 144-149 Link Here
144
/* character driver entry points */
131
/* character driver entry points */
145
132
146
static struct file_operations nv_fops = {
133
static struct file_operations nv_fops = {
134
    owner:          THIS_MODULE,
147
    poll:           nv_kern_poll,
135
    poll:           nv_kern_poll,
148
    ioctl:          nv_kern_ioctl,
136
    ioctl:          nv_kern_ioctl,
149
    mmap:           nv_kern_mmap,
137
    mmap:           nv_kern_mmap,
Lines 298-305 Link Here
298
    {
286
    {
299
        nv_printf(NV_DBG_MEMINFO, "  0x%x: count %d flags 0x%x\n", 
287
        nv_printf(NV_DBG_MEMINFO, "  0x%x: count %d flags 0x%x\n", 
300
            *page_ptr, 
288
            *page_ptr, 
301
            (GET_MAP_NR(*page_ptr))->count,
289
            (virt_to_page(__va(*page_ptr)))->count,
302
            (GET_MAP_NR(*page_ptr))->flags);
290
            (virt_to_page(__va(*page_ptr)))->flags);
303
        num_pages--;
291
        num_pages--;
304
        page_ptr++;
292
        page_ptr++;
305
    }
293
    }
Lines 370-376 Link Here
370
        phys_addr = virt_to_phys((void *) virt_addr);
358
        phys_addr = virt_to_phys((void *) virt_addr);
371
359
372
        /* lock the page for dma purposes */
360
        /* lock the page for dma purposes */
373
        mem_map_reserve(GET_MAP_NR(phys_addr));
361
        SetPageReserved(virt_to_page(__va(phys_addr)));
374
362
375
        *page_ptr++ = phys_addr;
363
        *page_ptr++ = phys_addr;
376
        pages_needed--;
364
        pages_needed--;
Lines 383-389 Link Here
383
    while (page_ptr != (unsigned long *) page_list)
371
    while (page_ptr != (unsigned long *) page_list)
384
    {
372
    {
385
        page_ptr--;
373
        page_ptr--;
386
        mem_map_unreserve(GET_MAP_NR(*page_ptr));
374
        ClearPageReserved(virt_to_page(__va(*page_ptr)));
387
        free_page((unsigned long) phys_to_virt(*page_ptr));
375
        free_page((unsigned long) phys_to_virt(*page_ptr));
388
    }
376
    }
389
377
Lines 403-409 Link Here
403
391
404
    while (pages_left)
392
    while (pages_left)
405
    {
393
    {
406
        mem_map_unreserve(GET_MAP_NR(*page_list));
394
        ClearPageReserved(virt_to_page(__va(*page_list)));
407
        page_list++;
395
        page_list++;
408
        pages_left--;
396
        pages_left--;
409
    }
397
    }
Lines 569-579 Link Here
569
    nv_linux_state_t *nvl;
557
    nv_linux_state_t *nvl;
570
    nv_linux_state_t *nv_max_devices;
558
    nv_linux_state_t *nv_max_devices;
571
559
572
#if defined (KERNEL_2_2)
573
    struct proc_dir_entry *proc_root_driver;
574
    proc_root_driver = create_proc_entry("driver", flags, &proc_root);
575
#endif
576
577
    proc_nvidia = create_proc_entry("nvidia", flags, proc_root_driver);
560
    proc_nvidia = create_proc_entry("nvidia", flags, proc_root_driver);
578
    proc_nvidia_cards = create_proc_entry("cards", flags, proc_nvidia);
561
    proc_nvidia_cards = create_proc_entry("cards", flags, proc_nvidia);
579
    proc_nvidia_agp = create_proc_entry("agp", flags, proc_nvidia);
562
    proc_nvidia_agp = create_proc_entry("agp", flags, proc_nvidia);
Lines 635-643 Link Here
635
{
618
{
636
#ifdef CONFIG_PROC_FS
619
#ifdef CONFIG_PROC_FS
637
    nvos_proc_remove_all(proc_nvidia);
620
    nvos_proc_remove_all(proc_nvidia);
638
#if defined (KERNEL_2_2)
639
    remove_proc_entry("driver", &proc_root);
640
#endif
641
#endif
621
#endif
642
}
622
}
643
623
Lines 726-796 Link Here
726
 *** EXPORTS to Linux Kernel
706
 *** EXPORTS to Linux Kernel
727
 ***/
707
 ***/
728
708
729
int init_module(void)
709
static int __init nvidia_init_module(void)
730
{
710
{
731
    nv_linux_state_t *nvl;
711
    int i, rc;
732
    int rc;
733
    int num_devices;
734
712
735
    memset(nv_linux_devices, 0, sizeof(nv_linux_devices));
713
    memset(nv_linux_devices, 0, sizeof(nv_linux_devices));
736
    num_devices = nvos_probe_devices();
714
    nv_num_devices = nvos_probe_devices();
737
715
738
    if (num_devices == 0) {
716
    if (nv_num_devices == 0) {
739
        nv_printf(NV_DBG_ERRORS, "nvidia: no NVIDIA graphics adapter found\n");
717
        nv_printf(NV_DBG_ERRORS, "nvidia: no NVIDIA graphics adapter found\n");
740
        return -ENODEV;
718
        return -ENODEV;
741
    }
719
    }
742
720
743
    nv_printf(NV_DBG_ERRORS, "nvidia: loading %s\n", pNVRM_ID);
721
    nv_printf(NV_DBG_ERRORS, "nvidia: loading %s\n", pNVRM_ID);
744
722
745
#ifdef CONFIG_DEVFS_FS
723
#if defined(CONFIG_DEVFS_FS) && !defined(KERNEL_2_6)
746
    rc = devfs_register_chrdev(nv_major, "nvidia", &nv_fops);
724
    rc = devfs_register_chrdev(nv_major, "nvidia", &nv_fops);
747
#else
725
#else
748
    rc = register_chrdev(nv_major, "nvidia", &nv_fops);
726
    rc = register_chrdev(nv_major, "nvidia", &nv_fops);
749
#endif
727
#endif
750
728
751
    if (rc < 0) {
729
    if (rc < 0) {
752
        nv_printf(NV_DBG_ERRORS, "init_module: register failed\n");
730
        nv_printf(NV_DBG_ERRORS, "nvidia_init_module: register failed\n");
753
        return rc;
731
        return rc;
754
    }
732
    }
755
733
756
#ifdef CONFIG_DEVFS_FS
734
#ifdef CONFIG_DEVFS_FS
757
    memset(nv_dev_handle, 0, sizeof(devfs_handle_t) * NV_MAX_DEVICES);
758
    do {
735
    do {
736
        /*
737
         * XXX This code isn't pretty, but neither is dealing with the
738
         * various Linux devfs implemenation(s). While Linux APIs are
739
         * known to be anything but stable and oftentimes anything but
740
         * well designed, the devfs interface has been more painful to
741
         * deal with than most other APIs.
742
         */
759
        char name[10];
743
        char name[10];
760
        int i;
761
744
762
        nv_ctl_handle = devfs_register(NULL, "nvidiactl",
745
        nv_devfs_handles[0] = NV_DEVFS_REGISTER("nvidiactl", 255);
763
                            DEVFS_FL_DEFAULT, nv_major, 255,
764
                            S_IFCHR | S_IRUGO | S_IWUGO,
765
                            &nv_fops, NULL);
766
746
767
        for (i = 0; i < num_devices; i++) {
747
        for (i = 0; i < nv_num_devices; i++) {
768
            sprintf(name, "nvidia%d", i);
748
            sprintf(name, "nvidia%d", i);
769
            nv_dev_handle[i] = devfs_register(NULL, name,
749
            nv_devfs_handles[i+1] = NV_DEVFS_REGISTER(name, i);
770
                                  DEVFS_FL_DEFAULT, nv_major, i,
771
                                  S_IFCHR | S_IRUGO | S_IWUGO,
772
                                  &nv_fops, NULL);
773
        }
750
        }
774
    } while(0);
751
    } while(0);
775
#endif
752
#endif
776
753
777
    nv_printf(NV_DBG_INFO, "init_module: major number %d\n", nv_major);
754
    nv_printf(NV_DBG_INFO, "nvidia_init_module: major number %d\n", nv_major);
778
755
779
    // init all the bottom half structures
756
    /* instantiate tasklets */
780
    for (nvl = nv_linux_devices; nvl < nv_linux_devices + NV_MAX_DEVICES; nvl++)
757
    for (i = 0; i < NV_MAX_DEVICES; i++) {
781
    {
758
        /*
782
        nvl->bh = &nv_bottom_halves[nvl - nv_linux_devices];
759
         * We keep one tasklet per card to avoid latency issues with more
783
        nvl->bh->routine = nv_kern_bh;
760
         * than one device; no two instances of a single tasklet are ever
784
        nvl->bh->data = (void *) nvl;
761
         * executed concurrently.
785
        nvl->bh->sync = 0;
762
         */
763
        atomic_set(&nv_linux_devices[i].tasklet.count, 1);
764
765
        /*
766
         * Initialize the event queue for this device. This only needs to
767
         * happen once for every device.
768
         */
769
        init_waitqueue_head(&nv_linux_devices[i].waitqueue);
786
    }
770
    }
787
771
788
    // init the nvidia control device
772
    // init the nvidia control device
789
    {
773
    {
790
        nv_state_t *nv_ctl = NV_STATE_PTR(&nv_ctl_device);
774
        nv_state_t *nv_ctl = NV_STATE_PTR(&nv_ctl_device);
791
        nv_ctl_device.event_queue = NULL;
792
        nv_ctl->os_state = (void *) &nv_ctl_device;
775
        nv_ctl->os_state = (void *) &nv_ctl_device;
793
        nv_lock_init_locks(nv_ctl);
776
        nv_lock_init_locks(nv_ctl);
777
        init_waitqueue_head(&nv_ctl_device.waitqueue);
794
    }
778
    }
795
779
796
#ifdef CONFIG_PM
780
#ifdef CONFIG_PM
Lines 815-828 Link Here
815
    /* create /proc/driver/nvidia */
799
    /* create /proc/driver/nvidia */
816
    nvos_proc_create();
800
    nvos_proc_create();
817
801
818
#if defined(DEBUG) && !defined(KERNEL_2_2)
802
#if defined(DEBUG)
819
    inter_module_register("nv_linux_devices", THIS_MODULE, nv_linux_devices);
803
    inter_module_register("nv_linux_devices", THIS_MODULE, nv_linux_devices);
820
#endif
804
#endif
821
805
822
    return 0;
806
    return 0;
823
807
824
 failed:
808
 failed:
825
#ifdef CONFIG_DEVFS_FS
809
#if defined(CONFIG_DEVFS_FS) && !defined(KERNEL_2_6)
826
    devfs_unregister_chrdev(nv_major, "nvidia");
810
    devfs_unregister_chrdev(nv_major, "nvidia");
827
#else
811
#else
828
    unregister_chrdev(nv_major, "nvidia");
812
    unregister_chrdev(nv_major, "nvidia");
Lines 830-847 Link Here
830
    return rc;
814
    return rc;
831
}
815
}
832
816
833
void cleanup_module(void)
817
static void __exit nvidia_exit_module(void)
834
{
818
{
835
    int rc;
836
    nv_linux_state_t *nvl;
819
    nv_linux_state_t *nvl;
837
    nv_linux_state_t *max_devices;
820
    nv_linux_state_t *max_devices;
821
    int rc;
838
822
839
    /* remove /proc/driver/nvidia */
823
    /* remove /proc/driver/nvidia */
840
    nvos_proc_remove();
824
    nvos_proc_remove();
841
825
842
    nv_printf(NV_DBG_INFO, "cleanup_module\n");
826
    nv_printf(NV_DBG_INFO, "nvidia_exit_module\n");
843
827
844
#if defined(DEBUG) && !defined(KERNEL_2_2)
828
#if defined(DEBUG)
845
    inter_module_unregister("nv_linux_devices");
829
    inter_module_unregister("nv_linux_devices");
846
#endif
830
#endif
847
831
Lines 866-898 Link Here
866
                continue;
850
                continue;
867
851
868
            nv_printf(NV_DBG_ERRORS,
852
            nv_printf(NV_DBG_ERRORS,
869
                    "still have vm que at cleanup_module(): 0x%x to 0x%x\n",
853
                    "still have vm que at nvidia_exit_module(): 0x%x to 0x%x\n",
870
                    nvl->alloc_queue->vma->vm_start,
854
                    nvl->alloc_queue->vma->vm_start,
871
                    nvl->alloc_queue->vma->vm_end);
855
                    nvl->alloc_queue->vma->vm_end);
872
        }
856
        }
873
    }
857
    }
874
858
875
#ifdef CONFIG_DEVFS_FS
859
#if defined(CONFIG_DEVFS_FS) && !defined(KERNEL_2_6)
876
    rc = devfs_unregister_chrdev(nv_major, "nvidia");
860
    rc = devfs_unregister_chrdev(nv_major, "nvidia");
877
#else
861
#else
878
    rc = unregister_chrdev(nv_major, "nvidia");
862
    rc = unregister_chrdev(nv_major, "nvidia");
879
#endif
863
#endif
880
864
881
    if (rc < 0) {
865
    if (rc < 0) {
882
        nv_printf(NV_DBG_ERRORS, "cleanup_module: unregister nv failed\n");
866
        nv_printf(NV_DBG_ERRORS, "nvidia_exit_module: unregister nv failed\n");
883
    }
867
    }
884
868
885
#ifdef CONFIG_DEVFS_FS
869
#ifdef CONFIG_DEVFS_FS
886
    do {
870
    do {
887
        int i;
871
        int i;
888
        for (i = 0; nv_dev_handle[i] != 0; i++) {
872
        NV_DEVFS_REMOVE_CONTROL();
889
            devfs_unregister(nv_dev_handle[i]);
873
        for (i = 0; i < nv_num_devices; i++)
890
        }
874
            NV_DEVFS_REMOVE_DEVICE(i);
891
    } while(0);
875
    } while (0);
892
    devfs_unregister(nv_ctl_handle);
893
#endif
876
#endif
894
}
877
}
895
878
879
module_init(nvidia_init_module);
880
module_exit(nvidia_exit_module);
896
881
897
/* this is only called when the vmas are duplicated.
882
/* this is only called when the vmas are duplicated.
898
 * this appears to only happen when the process is cloned to create
883
 * this appears to only happen when the process is cloned to create
Lines 906-916 Link Here
906
nv_kern_vma_open(struct vm_area_struct *vma)
891
nv_kern_vma_open(struct vm_area_struct *vma)
907
{
892
{
908
    nv_printf(NV_DBG_MEMINFO, "vma_open for 0x%x - 0x%x, offset 0x%x\n",
893
    nv_printf(NV_DBG_MEMINFO, "vma_open for 0x%x - 0x%x, offset 0x%x\n",
909
        vma->vm_start, vma->vm_end, LINUX_VMA_OFFS(vma));
894
        vma->vm_start, vma->vm_end, NV_VMA_OFFSET(vma));
910
895
911
    if (VMA_PRIVATE(vma))
896
    if (NV_VMA_PRIVATE(vma))
912
    {
897
    {
913
        nv_alloc_t *at = (nv_alloc_t *) VMA_PRIVATE(vma);
898
        nv_alloc_t *at = (nv_alloc_t *) NV_VMA_PRIVATE(vma);
914
        at->usage_count++;
899
        at->usage_count++;
915
900
916
        nv_printf(NV_DBG_MEMINFO, "  at 0x%x, usage count %d, page_table 0x%x\n",
901
        nv_printf(NV_DBG_MEMINFO, "  at 0x%x, usage count %d, page_table 0x%x\n",
Lines 918-925 Link Here
918
903
919
        nvos_list_page_count(at->page_table, at->num_pages);
904
        nvos_list_page_count(at->page_table, at->num_pages);
920
    }
905
    }
921
922
    MOD_INC_USE_COUNT;
923
}
906
}
924
907
925
908
Lines 927-937 Link Here
927
nv_kern_vma_release(struct vm_area_struct *vma)
910
nv_kern_vma_release(struct vm_area_struct *vma)
928
{
911
{
929
    nv_printf(NV_DBG_MEMINFO, "vma_release for 0x%x - 0x%x, offset 0x%x\n",
912
    nv_printf(NV_DBG_MEMINFO, "vma_release for 0x%x - 0x%x, offset 0x%x\n",
930
        vma->vm_start, vma->vm_end, LINUX_VMA_OFFS(vma));
913
        vma->vm_start, vma->vm_end, NV_VMA_OFFSET(vma));
931
914
932
    if (VMA_PRIVATE(vma))
915
    if (NV_VMA_PRIVATE(vma))
933
    {
916
    {
934
        nv_alloc_t *at = (nv_alloc_t *) VMA_PRIVATE(vma);
917
        nv_alloc_t *at = (nv_alloc_t *) NV_VMA_PRIVATE(vma);
935
918
936
        at->usage_count--;
919
        at->usage_count--;
937
920
Lines 949-983 Link Here
949
            if (at->page_table)
932
            if (at->page_table)
950
                nvos_unlock_pages(at->page_table, at->num_pages);
933
                nvos_unlock_pages(at->page_table, at->num_pages);
951
            nvos_free_alloc(at);
934
            nvos_free_alloc(at);
952
            VMA_PRIVATE(vma) = NULL;
935
            NV_VMA_PRIVATE(vma) = NULL;
953
        }
936
        }
954
    }
937
    }
955
956
    MOD_DEC_USE_COUNT;
957
}
938
}
958
939
959
940
960
/* at this point, this code just plain won't work with 2.2 kernels.
961
 * additionally, only ia64 & the 460GX need a nopage handler, and 2.2 doesn't
962
 * work on ia64 anyways. It's expected that at some point other agp chipsets
963
 * will work similar to the 460GX (AGP 3.0 spec), so pre-emptively make sure
964
 * this works on our standard ia32 driver.
965
 */
966
#if !defined(KERNEL_2_2)
967
968
/* AGP allocations under the 460GX are not mapped to the aperture
941
/* AGP allocations under the 460GX are not mapped to the aperture
969
 * addresses by the CPU.  This nopage handler will fault on CPU
942
 * addresses by the CPU.  This nopage handler will fault on CPU
970
 * accesses to AGP memory and map the address to the correct page.
943
 * accesses to AGP memory and map the address to the correct page.
971
 */
944
 */
972
struct page *nv_kern_vma_nopage(struct vm_area_struct *vma, unsigned long address, int write_access)
945
struct page *nv_kern_vma_nopage(struct vm_area_struct *vma, unsigned long address, int write_access)
973
{
946
{
947
#if defined(NVCPU_IA64) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 9))
974
    nv_alloc_t *at, *tmp;
948
    nv_alloc_t *at, *tmp;
975
    nv_linux_state_t *nvl;
949
    nv_linux_state_t *nvl;
976
    nv_state_t *nv;
950
    nv_state_t *nv;
977
    struct page *page_ptr;
951
    struct page *page_ptr;
978
    int rm_status, index;
952
    int rm_status, index;
979
953
980
    at = VMA_PRIVATE(vma);
954
    at = NV_VMA_PRIVATE(vma);
981
    if (at == NULL)
955
    if (at == NULL)
982
    {
956
    {
983
        nv_printf(NV_DBG_ERRORS, "NVRM: nopage handler called without an at: "
957
        nv_printf(NV_DBG_ERRORS, "NVRM: nopage handler called without an at: "
Lines 1016-1022 Link Here
1016
        // far again
990
        // far again
1017
        nv_printf(NV_DBG_ERRORS, "NVRM: nopage handler called on a freed"
991
        nv_printf(NV_DBG_ERRORS, "NVRM: nopage handler called on a freed"
1018
                  "address: vm_start 0x%x, at 0x%x\n", vma->vm_start, at);
992
                  "address: vm_start 0x%x, at 0x%x\n", vma->vm_start, at);
1019
        VMA_PRIVATE(vma) = NULL;
993
        NV_VMA_PRIVATE(vma) = NULL;
1020
        return NOPAGE_SIGBUS;
994
        return NOPAGE_SIGBUS;
1021
    }
995
    }
1022
996
Lines 1037-1054 Link Here
1037
    at->page_table[index] = (void *) ((page_ptr - mem_map) << PAGE_SHIFT);
1011
    at->page_table[index] = (void *) ((page_ptr - mem_map) << PAGE_SHIFT);
1038
1012
1039
    return page_ptr;
1013
    return page_ptr;
1040
}
1041
#endif
1014
#endif
1015
    return NOPAGE_SIGBUS;
1016
}
1042
1017
1043
struct vm_operations_struct nv_vm_ops = {
1018
struct vm_operations_struct nv_vm_ops = {
1044
    nv_kern_vma_open,
1019
    nv_kern_vma_open,
1045
    nv_kern_vma_release,  /* "close" */
1020
    nv_kern_vma_release,  /* "close" */
1046
#if !defined(KERNEL_2_2)
1047
    nv_kern_vma_nopage,
1021
    nv_kern_vma_nopage,
1048
#endif
1049
};
1022
};
1050
1023
1051
1052
/*
1024
/*
1053
** nv_kern_open
1025
** nv_kern_open
1054
**
1026
**
Lines 1076-1095 Link Here
1076
1048
1077
    /* for control device, just jump to its open routine */
1049
    /* for control device, just jump to its open routine */
1078
    /* after setting up the private data */
1050
    /* after setting up the private data */
1079
    if (NV_DEVICE_IS_CONTROL_DEVICE(inode->i_rdev))
1051
    if (NV_IS_CONTROL_DEVICE(inode))
1080
        return nv_kern_ctl_open(inode, file);
1052
        return nv_kern_ctl_open(inode, file);
1081
1053
1082
    /* what device are we talking about? */
1054
    /* what device are we talking about? */
1083
    devnum = NV_DEVICE_NUMBER(inode->i_rdev);
1055
    devnum = NV_DEVICE_NUMBER(inode);
1084
    if (devnum >= NV_MAX_DEVICES)
1056
    if (devnum >= NV_MAX_DEVICES)
1085
    {
1057
    {
1086
        rc = -ENODEV;
1058
        rc = -ENODEV;
1087
        goto failed;
1059
        goto failed;
1088
    }
1060
    }
1089
1061
1090
1091
    MOD_INC_USE_COUNT;
1092
1093
    nvl = &nv_linux_devices[devnum];
1062
    nvl = &nv_linux_devices[devnum];
1094
    nv = NV_STATE_PTR(nvl);
1063
    nv = NV_STATE_PTR(nvl);
1095
1064
Lines 1137-1152 Link Here
1137
            goto failed;
1106
            goto failed;
1138
        }
1107
        }
1139
1108
1140
#if !defined (KERNEL_2_2)
1109
        nvl->tasklet.func = nv_kern_isr_bh;
1141
        NV_KMALLOC(nvl->event_queue, sizeof(struct __wait_queue_head));
1110
        nvl->tasklet.data = (unsigned long) nv->pdev;
1142
        if (nvl->event_queue == NULL)
1111
        tasklet_enable(&nvl->tasklet);
1143
            goto failed;
1144
        memset(nvl->event_queue, 0, sizeof(struct __wait_queue_head));
1145
1146
        init_waitqueue_head(GET_EVENT_QUEUE(nvl));
1147
#else
1148
        nvl->event_queue = NULL;
1149
#endif
1150
1112
1151
        nv->flags |= NV_FLAG_OPEN;
1113
        nv->flags |= NV_FLAG_OPEN;
1152
    }
1114
    }
Lines 1157-1163 Link Here
1157
    return rc;
1119
    return rc;
1158
1120
1159
 failed:
1121
 failed:
1160
    MOD_DEC_USE_COUNT;
1161
    nv_unlock_ldata(nv);
1122
    nv_unlock_ldata(nv);
1162
    return rc;
1123
    return rc;
1163
}
1124
}
Lines 1179-1216 Link Here
1179
1140
1180
    /* for control device, just jump to its open routine */
1141
    /* for control device, just jump to its open routine */
1181
    /* after setting up the private data */
1142
    /* after setting up the private data */
1182
    if (NV_DEVICE_IS_CONTROL_DEVICE(inode->i_rdev))
1143
    if (NV_IS_CONTROL_DEVICE(inode))
1183
        return nv_kern_ctl_close(inode, file);
1144
        return nv_kern_ctl_close(inode, file);
1184
1145
1185
    nv_printf(NV_DBG_INFO, "nv_kern_close on device %d\n", NV_DEVICE_NUMBER(inode->i_rdev));
1146
    nv_printf(NV_DBG_INFO, "nv_kern_close on device %d\n", NV_DEVICE_NUMBER(inode));
1186
1147
1187
    rm_free_unused_clients(nv, current->pid, (void *) file);
1148
    rm_free_unused_clients(nv, current->pid, (void *) file);
1188
1149
1189
    nv_lock_ldata(nv);
1150
    nv_lock_ldata(nv);
1190
    if (--nv->usage_count == 0)
1151
    if (--nv->usage_count == 0)
1191
    {
1152
    {
1192
        int counter = 0;
1153
        /*
1193
1154
         * The usage count for this device has dropped to zero, it can be shut
1194
        /* turn off interrupts.
1155
         * down safely; disable its interrupts.
1195
        ** be careful to make sure any pending bottom half gets run
1156
         */
1196
        **  or disabled before calling rm_shutdown_adapter() since
1197
        **  it will free up the pdev.  This is hard to see on single
1198
        **  cpu systems, but easy on dual cpu :-)
1199
        */
1200
        rm_disable_adapter(nv);
1157
        rm_disable_adapter(nv);
1201
1158
1202
        /* give it a moment to allow any bottom half to run */
1159
        /*
1203
1160
         * Disable this device's tasklet to make sure that no bottom half will
1204
#define MAX_BH_TASKS 10
1161
         * run with undefined device state.
1205
        while (NV_ATOMIC_READ(nvl->bh_count) && (counter < MAX_BH_TASKS))
1162
         */
1206
        {
1163
        tasklet_disable(&nvl->tasklet);
1207
            current->state = TASK_INTERRUPTIBLE;
1208
            schedule_timeout(HZ/50);
1209
            counter++;
1210
        }
1211
1164
1212
        /* free the irq, which may block until any pending interrupts */
1165
        /*
1213
        /* are done being processed. */
1166
         * Free the IRQ, which may block until all pending interrupt processing
1167
         * has completed.
1168
         */
1214
        free_irq(nv->interrupt_line, (void *) nv);
1169
        free_irq(nv->interrupt_line, (void *) nv);
1215
1170
1216
        rm_shutdown_adapter(nv);
1171
        rm_shutdown_adapter(nv);
Lines 1230-1241 Link Here
1230
            }
1185
            }
1231
        }
1186
        }
1232
1187
1233
#if !defined (KERNEL_2_2)
1234
        /* this only needs to be freed on 2.4 and later kernels */
1235
        NV_KFREE(nvl->event_queue);
1236
        nvl->event_queue = NULL;
1237
#endif
1238
1239
        /* leave INIT flag alone so we don't reinit every time */
1188
        /* leave INIT flag alone so we don't reinit every time */
1240
        nv->flags &= ~(NV_FLAG_OPEN | NV_FLAG_WAITING);
1189
        nv->flags &= ~(NV_FLAG_OPEN | NV_FLAG_WAITING);
1241
    }
1190
    }
Lines 1246-1253 Link Here
1246
        NV_KFREE(file->private_data);
1195
        NV_KFREE(file->private_data);
1247
    file->private_data = (void *) 0;
1196
    file->private_data = (void *) 0;
1248
1197
1249
    MOD_DEC_USE_COUNT;
1250
1251
    return 0;
1198
    return 0;
1252
}
1199
}
1253
1200
Lines 1264-1273 Link Here
1264
    nv_printf(NV_DBG_INFO, "mmap([0x%lx-0x%lx] off=0x%lx)\n",
1211
    nv_printf(NV_DBG_INFO, "mmap([0x%lx-0x%lx] off=0x%lx)\n",
1265
        vma->vm_start,
1212
        vma->vm_start,
1266
        vma->vm_end,
1213
        vma->vm_end,
1267
        LINUX_VMA_OFFS(vma));
1214
        NV_VMA_OFFSET(vma));
1268
1215
1269
    // be a bit paranoid for now
1216
    // be a bit paranoid for now
1270
    if ((NV_MASK_OFFSET(LINUX_VMA_OFFS(vma))) ||
1217
    if ((NV_MASK_OFFSET(NV_VMA_OFFSET(vma))) ||
1271
        (NV_MASK_OFFSET(vma->vm_start)) ||
1218
        (NV_MASK_OFFSET(vma->vm_start)) ||
1272
        (NV_MASK_OFFSET(vma->vm_end)))
1219
        (NV_MASK_OFFSET(vma->vm_end)))
1273
    {
1220
    {
Lines 1285-1291 Link Here
1285
1232
1286
1233
1287
    /* NV reg space */
1234
    /* NV reg space */
1288
    if (IS_REG_OFFSET(nv, LINUX_VMA_OFFS(vma), vma->vm_end - vma->vm_start))
1235
    if (IS_REG_OFFSET(nv, NV_VMA_OFFSET(vma), vma->vm_end - vma->vm_start))
1289
    {
1236
    {
1290
        /* truncate to size of registers */
1237
        /* truncate to size of registers */
1291
        if (pages > nv->regs->size / PAGE_SIZE)
1238
        if (pages > nv->regs->size / PAGE_SIZE)
Lines 1293-1299 Link Here
1293
1240
1294
        vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
1241
        vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
1295
        if (NV_REMAP_PAGE_RANGE(vma->vm_start,
1242
        if (NV_REMAP_PAGE_RANGE(vma->vm_start,
1296
                             LINUX_VMA_OFFS(vma),
1243
                             NV_VMA_OFFSET(vma),
1297
                             vma->vm_end - vma->vm_start,
1244
                             vma->vm_end - vma->vm_start,
1298
                             vma->vm_page_prot))
1245
                             vma->vm_page_prot))
1299
            return -EAGAIN;
1246
            return -EAGAIN;
Lines 1303-1309 Link Here
1303
    }
1250
    }
1304
1251
1305
    /* NV fb space */
1252
    /* NV fb space */
1306
    else if (IS_FB_OFFSET(nv, LINUX_VMA_OFFS(vma), vma->vm_end - vma->vm_start))
1253
    else if (IS_FB_OFFSET(nv, NV_VMA_OFFSET(vma), vma->vm_end - vma->vm_start))
1307
    {
1254
    {
1308
1255
1309
        /* truncate to size of framebuffer */
1256
        /* truncate to size of framebuffer */
Lines 1312-1318 Link Here
1312
1259
1313
        vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
1260
        vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
1314
        if (NV_REMAP_PAGE_RANGE(vma->vm_start,
1261
        if (NV_REMAP_PAGE_RANGE(vma->vm_start,
1315
                             LINUX_VMA_OFFS(vma),
1262
                             NV_VMA_OFFSET(vma),
1316
                             vma->vm_end - vma->vm_start,
1263
                             vma->vm_end - vma->vm_start,
1317
                             vma->vm_page_prot))
1264
                             vma->vm_page_prot))
1318
            return -EAGAIN;
1265
            return -EAGAIN;
Lines 1322-1331 Link Here
1322
    }
1269
    }
1323
1270
1324
    /* AGP allocator */
1271
    /* AGP allocator */
1325
    else if (IS_AGP_OFFSET(nv, LINUX_VMA_OFFS(vma), vma->vm_end - vma->vm_start))
1272
    else if (IS_AGP_OFFSET(nv, NV_VMA_OFFSET(vma), vma->vm_end - vma->vm_start))
1326
    {
1273
    {
1327
        nv_lock_at(nv);
1274
        nv_lock_at(nv);
1328
        at = nvl_find_alloc(nvl, LINUX_VMA_OFFS(vma), NV_ALLOC_TYPE_AGP);
1275
        at = nvl_find_alloc(nvl, NV_VMA_OFFSET(vma), NV_ALLOC_TYPE_AGP);
1329
1276
1330
        if (at == NULL)
1277
        if (at == NULL)
1331
        {
1278
        {
Lines 1343-1349 Link Here
1343
        }
1290
        }
1344
1291
1345
        at->vma = vma;
1292
        at->vma = vma;
1346
        VMA_PRIVATE(vma) = at;
1293
        NV_VMA_PRIVATE(vma) = at;
1347
        at->usage_count++;
1294
        at->usage_count++;
1348
1295
1349
        if (NV_OSAGP_ENABLED(nv))
1296
        if (NV_OSAGP_ENABLED(nv))
Lines 1366-1378 Link Here
1366
    }
1313
    }
1367
1314
1368
    /* Magic allocator */
1315
    /* Magic allocator */
1369
    else // if (LINUX_VMA_OFFS(vma) == NV_MMAP_ALLOCATION_OFFSET)
1316
    else // if (NV_VMA_OFFSET(vma) == NV_MMAP_ALLOCATION_OFFSET)
1370
    {
1317
    {
1371
        unsigned long page = 0, pos, start;
1318
        unsigned long page = 0, pos, start;
1372
        int i = 0;
1319
        int i = 0;
1373
1320
1374
        nv_lock_at(nv);
1321
        nv_lock_at(nv);
1375
        at = nvl_find_alloc(nvl, LINUX_VMA_OFFS(vma), NV_ALLOC_TYPE_PCI);
1322
        at = nvl_find_alloc(nvl, NV_VMA_OFFSET(vma), NV_ALLOC_TYPE_PCI);
1376
1323
1377
        if (at == NULL)
1324
        if (at == NULL)
1378
        {
1325
        {
Lines 1390-1396 Link Here
1390
        }
1337
        }
1391
1338
1392
        at->vma = vma;
1339
        at->vma = vma;
1393
        VMA_PRIVATE(vma) = at;
1340
        NV_VMA_PRIVATE(vma) = at;
1394
        at->usage_count++;
1341
        at->usage_count++;
1395
1342
1396
        nv_printf(NV_DBG_INFO, "remapping %d system pages for at 0x%x\n", pages, at);
1343
        nv_printf(NV_DBG_INFO, "remapping %d system pages for at 0x%x\n", pages, at);
Lines 1412-1420 Link Here
1412
1359
1413
    vma->vm_file = file;
1360
    vma->vm_file = file;
1414
1361
1415
    /* just increment usage count, rather than calling vma_open */
1416
    MOD_INC_USE_COUNT;
1417
1418
    return 0;
1362
    return 0;
1419
}
1363
}
1420
1364
Lines 1439-1445 Link Here
1439
        return nv_kern_ctl_poll (file, wait);
1383
        return nv_kern_ctl_poll (file, wait);
1440
1384
1441
    // add us to the list
1385
    // add us to the list
1442
    poll_wait(file, GET_EVENT_QUEUE(nvl), wait);
1386
    poll_wait(file, &nvl->waitqueue, wait);
1443
1387
1444
    nv_lock_ldata(nv);
1388
    nv_lock_ldata(nv);
1445
1389
Lines 1519-1530 Link Here
1519
1463
1520
    switch (_IOC_NR(cmd))
1464
    switch (_IOC_NR(cmd))
1521
    {
1465
    {
1466
#if !defined(KERNEL_2_6)
1522
        /* debug tool; zap the module use count so we can unload driver */
1467
        /* debug tool; zap the module use count so we can unload driver */
1523
        /*             even if it is confused */
1468
        /*             even if it is confused */
1524
        case _IOC_NR(NV_IOCTL_MODULE_RESET):
1469
        case _IOC_NR(NV_IOCTL_MODULE_RESET):
1525
            atomic_set(&__this_module.uc.usecount, 1);
1470
            atomic_set(&__this_module.uc.usecount, 1);
1526
            break;
1471
            break;
1527
1472
#endif
1528
        /* pass out info about the card */
1473
        /* pass out info about the card */
1529
        case _IOC_NR(NV_IOCTL_CARD_INFO):
1474
        case _IOC_NR(NV_IOCTL_CARD_INFO):
1530
        {
1475
        {
Lines 1651-1657 Link Here
1651
 * driver receives an interrupt
1596
 * driver receives an interrupt
1652
 *    if someone waiting, then hand it off.
1597
 *    if someone waiting, then hand it off.
1653
 */
1598
 */
1654
void nv_kern_isr(
1599
irqreturn_t nv_kern_isr(
1655
    int   irq,
1600
    int   irq,
1656
    void *arg,
1601
    void *arg,
1657
    struct pt_regs *regs
1602
    struct pt_regs *regs
Lines 1664-1684 Link Here
1664
    rm_isr(nv->device_number, &need_to_run_bottom_half);
1609
    rm_isr(nv->device_number, &need_to_run_bottom_half);
1665
    if (need_to_run_bottom_half)
1610
    if (need_to_run_bottom_half)
1666
    {
1611
    {
1667
        NV_ATOMIC_INC(nvl->bh_count);
1612
        tasklet_schedule(&nvl->tasklet);
1668
        queue_task(nvl->bh, &tq_immediate);
1669
        mark_bh(IMMEDIATE_BH);
1670
    }
1613
    }
1614
1615
    return IRQ_HANDLED;
1671
}
1616
}
1672
1617
1673
void nv_kern_bh(
1618
void nv_kern_isr_bh(unsigned long data)
1674
    void *data
1675
)
1676
{
1619
{
1677
    nv_linux_state_t *nvl = (nv_linux_state_t *) data;
1620
    /*
1678
    nv_state_t *nv = NV_STATE_PTR(nvl);
1621
     * XXX: This level of indirection is necessary to work around
1679
1622
     * problems with Linux kernels using a non-standard calling
1680
    NV_ATOMIC_DEC(nvl->bh_count);
1623
     * convention, i.e. Arjan van de Ven's/RedHat's 2.6.0 kernels.
1681
    rm_isr_bh(nv->pdev);
1624
     */
1625
    rm_isr_bh((VOID *) data);
1682
}
1626
}
1683
1627
1684
void nv_kern_rc_timer(
1628
void nv_kern_rc_timer(
Lines 1760-1785 Link Here
1760
    /* save the nv away in file->private_data */
1704
    /* save the nv away in file->private_data */
1761
    NV_HIDE_IN_FILEP(file, nv);
1705
    NV_HIDE_IN_FILEP(file, nv);
1762
1706
1763
    MOD_INC_USE_COUNT;
1764
1765
    /* if this is the first time the control device has been opened,
1766
     * allocate the wait queue
1767
     */
1768
1769
    if (! nvl->event_queue) {
1770
1771
#if !defined (KERNEL_2_2)
1772
        NV_KMALLOC(nvl->event_queue, sizeof(struct __wait_queue_head));
1773
        if (nvl->event_queue == NULL)
1774
            return -ENOMEM;
1775
        memset(nvl->event_queue, 0, sizeof(struct __wait_queue_head));
1776
1777
        init_waitqueue_head(GET_EVENT_QUEUE(nvl));
1778
#else
1779
        nvl->event_queue = NULL;
1780
#endif
1781
    }
1782
1783
    nv->flags |= NV_FLAG_OPEN + NV_FLAG_CONTROL;
1707
    nv->flags |= NV_FLAG_OPEN + NV_FLAG_CONTROL;
1784
1708
1785
    /* turn off the hotkey occurred bit */
1709
    /* turn off the hotkey occurred bit */
Lines 1807-1821 Link Here
1807
1731
1808
    nv_lock_ldata(nv);
1732
    nv_lock_ldata(nv);
1809
    if (--nv->usage_count == 0)
1733
    if (--nv->usage_count == 0)
1810
    {
1811
#if !defined (KERNEL_2_2)
1812
        nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
1813
        /* this only needs to be freed on 2.4 and later kernels */
1814
        NV_KFREE(nvl->event_queue);
1815
        nvl->event_queue = 0;
1816
#endif
1817
        nv->flags = 0;
1734
        nv->flags = 0;
1818
    }
1819
    nv_unlock_ldata(nv);
1735
    nv_unlock_ldata(nv);
1820
1736
1821
    rm_free_unused_clients(nv, current->pid, (void *) file);
1737
    rm_free_unused_clients(nv, current->pid, (void *) file);
Lines 1825-1832 Link Here
1825
        NV_KFREE(file->private_data);
1741
        NV_KFREE(file->private_data);
1826
    file->private_data = (void *) 0;
1742
    file->private_data = (void *) 0;
1827
1743
1828
    MOD_DEC_USE_COUNT;
1829
1830
    return 0;
1744
    return 0;
1831
}
1745
}
1832
1746
Lines 1851-1857 Link Here
1851
    if (file->f_flags & O_NONBLOCK)
1765
    if (file->f_flags & O_NONBLOCK)
1852
        return -EAGAIN;
1766
        return -EAGAIN;
1853
1767
1854
    poll_wait(file, GET_EVENT_QUEUE(nvl), wait);
1768
    poll_wait(file, &nvl->waitqueue, wait);
1855
1769
1856
    nv_lock_ldata(nv);
1770
    nv_lock_ldata(nv);
1857
1771
Lines 1881-1887 Link Here
1881
    nv_ctl_device.nv_state.flags |= NV_FLAG_HOTKEY_OCCURRED;
1795
    nv_ctl_device.nv_state.flags |= NV_FLAG_HOTKEY_OCCURRED;
1882
    nv_unlock_ldata(&(nv_ctl_device.nv_state));
1796
    nv_unlock_ldata(&(nv_ctl_device.nv_state));
1883
1797
1884
    wake_up_interruptible(GET_EVENT_QUEUE(&nv_ctl_device));
1798
    wake_up_interruptible(&nv_ctl_device.waitqueue);
1885
}
1799
}
1886
1800
1887
int nv_kern_read_cardinfo(char *page, char **start, off_t off,
1801
int nv_kern_read_cardinfo(char *page, char **start, off_t off,
Lines 1960-1966 Link Here
1960
        len += sprintf(page+len, "Host Bridge: \t ");
1874
        len += sprintf(page+len, "Host Bridge: \t ");
1961
1875
1962
#if defined(CONFIG_PCI_NAMES)
1876
#if defined(CONFIG_PCI_NAMES)
1963
        len += sprintf(page+len, "%s\n", dev->name);
1877
        len += sprintf(page+len, "%s\n", NV_PCI_DEVICE_NAME(dev));
1964
#else
1878
#else
1965
        len += sprintf(page+len, "PCI device %04x:%04x\n",
1879
        len += sprintf(page+len, "PCI device %04x:%04x\n",
1966
                dev->vendor, dev->device);
1880
                dev->vendor, dev->device);
Lines 2088-2105 Link Here
2088
            {
2002
            {
2089
                unsigned long retaddr = (unsigned long) at->page_table[i];
2003
                unsigned long retaddr = (unsigned long) at->page_table[i];
2090
2004
2091
                if (retaddr <= MAXMEM)
2005
                /*
2092
                {
2006
                 * XXX This routine should be more straight-forward; as it
2093
                    return __va((retaddr + offset));
2007
                 * is, it returns a pointer into the kernel linear mapping if
2094
                }
2008
                 * the incoming address belongs to a vmalloc() allocation or
2095
   
2009
                 * the kernel logical mapping of the corresponding page if it
2096
                // if we've allocated via vmalloc on a highmem system, the 
2010
                 * was allocated with alloc_pages(); third case below.
2097
                // physical address may not be accessible via PAGE_OFFSET, 
2011
                 */
2098
                // that's ok, we have a simple linear pointer already.
2099
                if (at->flags & NV_ALLOC_TYPE_VMALLOC)
2012
                if (at->flags & NV_ALLOC_TYPE_VMALLOC)
2100
                {
2013
                {
2101
                    return (void *)((unsigned char *) at->key_mapping + (i << PAGE_SHIFT) + offset);
2014
                    return (void *)((unsigned char *) at->key_mapping + (i << PAGE_SHIFT) + offset);
2102
                }
2015
                }
2016
                else if (!(at->flags & NV_ALLOC_TYPE_CONTIG))
2017
                {
2018
                    return __va((retaddr + offset));
2019
                }
2103
2020
2104
                // ?? this may be a contiguous allocation, fall through
2021
                // ?? this may be a contiguous allocation, fall through
2105
                // to below? or should I just check at->flag here?
2022
                // to below? or should I just check at->flag here?
Lines 2169-2177 Link Here
2169
unsigned long
2086
unsigned long
2170
nv_get_phys_address(unsigned long address)
2087
nv_get_phys_address(unsigned long address)
2171
{
2088
{
2172
    pgd_t *pg_dir;
2089
    pgd_t *pgd;
2173
    pmd_t *pg_mid_dir;
2090
    pmd_t *pmd;
2174
    pte_t pte;
2091
    pte_t *pte; 
2175
2092
2176
#if defined(NVCPU_IA64)
2093
#if defined(NVCPU_IA64)
2177
    if (address > __IA64_UNCACHED_OFFSET)
2094
    if (address > __IA64_UNCACHED_OFFSET)
Lines 2184-2206 Link Here
2184
        return __pa(address);
2101
        return __pa(address);
2185
2102
2186
    if (address > VMALLOC_START)
2103
    if (address > VMALLOC_START)
2187
       pg_dir = pgd_offset_k(address);
2104
       pgd = pgd_offset_k(address);
2188
    else
2105
    else
2189
       pg_dir = pgd_offset(current->mm, address);
2106
       pgd = pgd_offset(current->mm, address);
2190
2107
2191
    if (pgd_none(*pg_dir))
2108
    if (!pgd || pgd_none(*pgd))
2192
        goto failed;
2109
        goto failed;
2193
2110
2194
    pg_mid_dir = pmd_offset(pg_dir, address);
2111
    NV_PMD_OFFSET(address, pgd, pmd);
2195
    if (pmd_none(*pg_mid_dir))
2112
 
2113
    if (!NV_PMD_PRESENT(pmd))
2196
        goto failed;
2114
        goto failed;
2197
2115
2198
    NV_PTE_OFFSET(address, pg_mid_dir, pte);
2116
    NV_PTE_OFFSET(address, pmd, pte);
2199
2117
2200
    if (!pte_present(pte))
2118
    if (!NV_PTE_PRESENT(pte))
2201
        goto failed;
2119
        goto failed;
2202
2120
 
2203
    return ((pte_val(pte) & KERN_PAGE_MASK) | NV_MASK_OFFSET(address));
2121
    return (NV_PTE_VALUE(pte) & KERN_PAGE_MASK) | NV_MASK_OFFSET(address);
2204
2122
2205
  failed:
2123
  failed:
2206
    return (unsigned long) NULL;
2124
    return (unsigned long) NULL;
Lines 2567-2573 Link Here
2567
2485
2568
    nvfp->any_fired_notifiers++;
2486
    nvfp->any_fired_notifiers++;
2569
2487
2570
    wake_up_interruptible(GET_EVENT_QUEUE(nvl));
2488
    wake_up_interruptible(&nvl->waitqueue);
2571
}
2489
}
2572
2490
2573
/*
2491
/*
Lines 2584-2590 Link Here
2584
    if (nvl->waiting_for_vblank)
2502
    if (nvl->waiting_for_vblank)
2585
        nvl->vblank_notifier++;
2503
        nvl->vblank_notifier++;
2586
2504
2587
    wake_up_interruptible(GET_EVENT_QUEUE(nvl));
2505
    wake_up_interruptible(&nvl->waitqueue);
2588
}
2506
}
2589
2507
2590
2508
Lines 2633-2644 Link Here
2633
    if ( (NV_AGP_DISABLED(nv)) && (config & NVOS_AGP_CONFIG_NVAGP) )
2551
    if ( (NV_AGP_DISABLED(nv)) && (config & NVOS_AGP_CONFIG_NVAGP) )
2634
    {
2552
    {
2635
        /* make sure the user does not have agpgart loaded */
2553
        /* make sure the user does not have agpgart loaded */
2636
#if !defined (KERNEL_2_2)
2637
        if (inter_module_get("drm_agp")) {
2554
        if (inter_module_get("drm_agp")) {
2638
            inter_module_put("drm_agp");
2555
            inter_module_put("drm_agp");
2639
#else
2640
        if (GET_MODULE_SYMBOL(0, __MODULE_STRING(agp_enable))) {
2641
#endif
2642
            nv_printf(NV_DBG_WARNINGS, "NVRM: not using NVAGP, AGPGART is loaded!!\n");
2556
            nv_printf(NV_DBG_WARNINGS, "NVRM: not using NVAGP, AGPGART is loaded!!\n");
2643
        } else
2557
        } else
2644
            status = rm_init_agp(nv);
2558
            status = rm_init_agp(nv);
(-)NVIDIA_kernel-1.0-4363/nv.h (-55 / +55 lines)
Lines 255-283 Link Here
255
 * ---------------------------------------------------------------------------
255
 * ---------------------------------------------------------------------------
256
 */
256
 */
257
257
258
VOID*  nv_find_kernel_mapping       (nv_state_t *, unsigned long); 
258
VOID*  NV_API_CALL  nv_find_kernel_mapping       (nv_state_t *, unsigned long); 
259
VOID*  nv_find_agp_kernel_mapping   (nv_state_t *, unsigned long); 
259
VOID*  NV_API_CALL  nv_find_agp_kernel_mapping   (nv_state_t *, unsigned long); 
260
ULONG  nv_get_phys_address          (ULONG);
260
ULONG  NV_API_CALL  nv_get_phys_address          (ULONG);
261
261
262
VOID   nv_lock_rm                   (nv_state_t *);
262
VOID   NV_API_CALL  nv_lock_rm                   (nv_state_t *);
263
VOID   nv_unlock_rm                 (nv_state_t *);
263
VOID   NV_API_CALL  nv_unlock_rm                 (nv_state_t *);
264
VOID   nv_lock_bh                   (nv_state_t *);
264
VOID   NV_API_CALL  nv_lock_bh                   (nv_state_t *);
265
VOID   nv_unlock_bh                 (nv_state_t *);
265
VOID   NV_API_CALL  nv_unlock_bh                 (nv_state_t *);
266
266
267
VOID   nv_post_event                (VOID *);
267
VOID   NV_API_CALL  nv_post_event                (VOID *);
268
VOID   nv_post_vblank               (nv_state_t *);
268
VOID   NV_API_CALL  nv_post_vblank               (nv_state_t *);
269
VOID   nv_set_hotkey_occurred_flag  (VOID);
269
VOID   NV_API_CALL  nv_set_hotkey_occurred_flag  (VOID);
270
S032   nv_int10h_call               (nv_state_t *, U032 *, U032 *, U032 *, U032 *, VOID *);
270
S032   NV_API_CALL  nv_int10h_call               (nv_state_t *, U032 *, U032 *, U032 *, U032 *, VOID *);
271
271
272
S032   nv_alloc_pages               (nv_state_t *, VOID **, U032, U032, U032, U032, U032, U032, VOID **);
272
S032   NV_API_CALL  nv_alloc_pages               (nv_state_t *, VOID **, U032, U032, U032, U032, U032, U032, VOID **);
273
S032   nv_free_pages                (nv_state_t *, VOID **, U032, U032, VOID **);
273
S032   NV_API_CALL  nv_free_pages                (nv_state_t *, VOID **, U032, U032, VOID **);
274
274
275
S032   nv_agp_init                  (nv_state_t *, VOID **, VOID **, VOID *, U032);
275
S032   NV_API_CALL  nv_agp_init                  (nv_state_t *, VOID **, VOID **, VOID *, U032);
276
S032   nv_agp_teardown              (nv_state_t *);
276
S032   NV_API_CALL  nv_agp_teardown              (nv_state_t *);
277
S032   nv_agp_translate_address     (nv_state_t *, VOID *, U032, U032 *);
277
S032   NV_API_CALL  nv_agp_translate_address     (nv_state_t *, VOID *, U032, U032 *);
278
278
279
S032   nv_start_rc_timer            (nv_state_t *);
279
S032   NV_API_CALL  nv_start_rc_timer            (nv_state_t *);
280
S032   nv_stop_rc_timer             (nv_state_t *);
280
S032   NV_API_CALL  nv_stop_rc_timer             (nv_state_t *);
281
281
282
282
283
/*
283
/*
Lines 288-328 Link Here
288
 * ---------------------------------------------------------------------------
288
 * ---------------------------------------------------------------------------
289
 */
289
 */
290
290
291
BOOL       rm_init_rm               (VOID);
291
BOOL       NV_API_CALL	rm_init_rm               (VOID);
292
BOOL       rm_shutdown_rm           (VOID);
292
BOOL       NV_API_CALL	rm_shutdown_rm           (VOID);
293
BOOL       rm_init_adapter          (nv_state_t *);
293
BOOL       NV_API_CALL	rm_init_adapter          (nv_state_t *);
294
BOOL       rm_disable_adapter       (nv_state_t *);
294
BOOL       NV_API_CALL	rm_disable_adapter       (nv_state_t *);
295
BOOL       rm_shutdown_adapter      (nv_state_t *);
295
BOOL       NV_API_CALL	rm_shutdown_adapter      (nv_state_t *);
296
BOOL       rm_ioctl                 (nv_state_t *, VOID *, U032, VOID *);
296
BOOL       NV_API_CALL	rm_ioctl                 (nv_state_t *, VOID *, U032, VOID *);
297
BOOL       rm_isr                   (U032, U032 *);
297
BOOL       NV_API_CALL	rm_isr                   (U032, U032 *);
298
VOID       rm_isr_bh                (VOID *);
298
VOID       NV_API_CALL	rm_isr_bh                (VOID *);
299
RM_STATUS  rm_power_management      (nv_state_t *, U032, U032);
299
RM_STATUS  NV_API_CALL	rm_power_management      (nv_state_t *, U032, U032);
300
U032       rm_get_vbios_version     (nv_state_t *, U032 *, U032 *, U032 *, U032 *, U032 *);
300
U032       NV_API_CALL	rm_get_vbios_version     (nv_state_t *, U032 *, U032 *, U032 *, U032 *, U032 *);
301
VOID       rm_free_unused_clients   (nv_state_t *, U032, VOID *);
301
VOID       NV_API_CALL	rm_free_unused_clients   (nv_state_t *, U032, VOID *);
302
302
303
VOID       rm_update_agp_config     (nv_state_t *);
303
VOID       NV_API_CALL	rm_update_agp_config     (nv_state_t *);
304
RM_STATUS  rm_init_agp              (nv_state_t *);
304
RM_STATUS  NV_API_CALL	rm_init_agp              (nv_state_t *);
305
RM_STATUS  rm_teardown_agp          (nv_state_t *);
305
RM_STATUS  NV_API_CALL	rm_teardown_agp          (nv_state_t *);
306
306
307
RM_STATUS  rm_alloc_agp_pages       (nv_state_t *, VOID **, U032, U032, VOID **, U032 *);
307
RM_STATUS  NV_API_CALL	rm_alloc_agp_pages       (nv_state_t *, VOID **, U032, U032, VOID **, U032 *);
308
RM_STATUS  rm_map_agp_pages         (nv_state_t *, VOID **, U032, VOID *);
308
RM_STATUS  NV_API_CALL	rm_map_agp_pages         (nv_state_t *, VOID **, U032, VOID *);
309
RM_STATUS  rm_free_agp_pages        (nv_state_t *, VOID **, VOID *);
309
RM_STATUS  NV_API_CALL	rm_free_agp_pages        (nv_state_t *, VOID **, VOID *);
310
310
311
RM_STATUS  rm_alloc_agp_bitmap      (nv_state_t *, U032, U032 *);
311
RM_STATUS  NV_API_CALL	rm_alloc_agp_bitmap      (nv_state_t *, U032, U032 *);
312
RM_STATUS  rm_free_agp_bitmap       (nv_state_t *, U032, U032);
312
RM_STATUS  NV_API_CALL	rm_free_agp_bitmap       (nv_state_t *, U032, U032);
313
RM_STATUS  rm_set_agp_bitmap        (nv_state_t *, VOID *);
313
RM_STATUS  NV_API_CALL	rm_set_agp_bitmap        (nv_state_t *, VOID *);
314
RM_STATUS  rm_clear_agp_bitmap      (nv_state_t *, VOID **);
314
RM_STATUS  NV_API_CALL	rm_clear_agp_bitmap      (nv_state_t *, VOID **);
315
315
316
RM_STATUS  rm_load_registry         (nv_parm_t *);
316
RM_STATUS  NV_API_CALL  rm_load_registry         (nv_parm_t *);
317
RM_STATUS  rm_read_registry_dword   (nv_state_t *, U008 *, U008 *, U032 *);
317
RM_STATUS  NV_API_CALL	rm_read_registry_dword   (nv_state_t *, U008 *, U008 *, U032 *);
318
RM_STATUS  rm_write_registry_dword  (nv_state_t *, U008 *, U008 *, U032);
318
RM_STATUS  NV_API_CALL	rm_write_registry_dword  (nv_state_t *, U008 *, U008 *, U032);
319
RM_STATUS  rm_read_registry_binary  (nv_state_t *, U008 *, U008 *, U008 *, U032 *);
319
RM_STATUS  NV_API_CALL	rm_read_registry_binary  (nv_state_t *, U008 *, U008 *, U008 *, U032 *);
320
RM_STATUS  rm_write_registry_binary (nv_state_t *, U008 *, U008 *, U008 *, U032);
320
RM_STATUS  NV_API_CALL	rm_write_registry_binary (nv_state_t *, U008 *, U008 *, U008 *, U032);
321
321
322
RM_STATUS  rm_run_rc_callback       (nv_state_t *);
322
RM_STATUS  NV_API_CALL	rm_run_rc_callback       (nv_state_t *);
323
RM_STATUS  rm_get_device_name       (U032, U032, U008*);
323
RM_STATUS  NV_API_CALL	rm_get_device_name       (U032, U032, U008*);
324
324
325
NvUI64     nv_rdtsc                 (VOID);
325
NvUI64     NV_API_CALL  nv_rdtsc                 (VOID);
326
326
327
#endif /* NVWATCH */
327
#endif /* NVWATCH */
328
328
(-)NVIDIA_kernel-1.0-4363/os-agp.c (-152 / +42 lines)
Lines 45-88 Link Here
45
    int  ready;
45
    int  ready;
46
} agp_gart;
46
} agp_gart;
47
47
48
typedef struct {
49
    int           (*backend_acquire)(void);
50
    void          (*backend_release)(void);
51
    void          (*copy_info)(agp_kern_info *);
52
    agp_memory *  (*allocate_memory)(size_t, unsigned int);
53
    void          (*free_memory)(agp_memory *);
54
    int           (*bind_memory)(agp_memory *, off_t);
55
    int           (*unbind_memory)(agp_memory *);
56
    void          (*enable)(unsigned int);
57
} agp_operations_struct;
58
59
agp_operations_struct agp_ops;
60
agp_kern_info         agpinfo;
48
agp_kern_info         agpinfo;
61
agp_gart              gart;
49
agp_gart              gart;
62
#if !defined (KERNEL_2_2)
63
const drm_agp_t       *drm_agp_p;
50
const drm_agp_t       *drm_agp_p;
64
#endif
65
66
#if defined (KERNEL_2_2)
67
    #define GET_AGPGART_SYMBOL(sym, sym_string)                     \
68
        sym = (void*) GET_MODULE_SYMBOL(0, sym_string);             \
69
        if (sym == NULL)                                            \
70
        {                                                           \
71
            nv_printf(NV_DBG_ERRORS,                                \
72
                "NVRM: AGPGART: unable to retrieve symbol %s\n",    \
73
                sym_string);                                        \
74
            return 1;                                               \
75
        }
76
77
    #define AGP_BACKEND_ACQUIRE_SYM   __MODULE_STRING(agp_backend_acquire)
78
    #define AGP_BACKEND_RELEASE_SYM   __MODULE_STRING(agp_backend_release)
79
    #define AGP_COPY_INFO_SYM         __MODULE_STRING(agp_copy_info)
80
    #define AGP_ALLOCATE_MEMORY_SYM   __MODULE_STRING(agp_allocate_memory)
81
    #define AGP_FREE_MEMORY_SYM       __MODULE_STRING(agp_free_memory)
82
    #define AGP_BIND_MEMORY_SYM       __MODULE_STRING(agp_bind_memory)
83
    #define AGP_UNBIND_MEMORY_SYM     __MODULE_STRING(agp_unbind_memory)
84
    #define AGP_ENABLE_SYM            __MODULE_STRING(agp_enable)
85
#endif
86
51
87
#if defined(CONFIG_MTRR)
52
#if defined(CONFIG_MTRR)
88
#define MTRR_DEL(gart) if ((gart).mtrr > 0) mtrr_del((gart).mtrr, 0, 0);
53
#define MTRR_DEL(gart) if ((gart).mtrr > 0) mtrr_del((gart).mtrr, 0, 0);
Lines 105-117 Link Here
105
    U032  agp_rate;
70
    U032  agp_rate;
106
    U032  agp_sba;
71
    U032  agp_sba;
107
    U032  agp_fw;
72
    U032  agp_fw;
108
    char* chipset;
109
    VOID *bitmap;
73
    VOID *bitmap;
110
    U032 bitmap_size;
74
    U032 bitmap_size;
111
75
112
    memset( (void *) &gart, 0, sizeof(agp_gart));
76
    memset( (void *) &gart, 0, sizeof(agp_gart));
113
77
114
#if !defined (KERNEL_2_2)
78
    /*
79
     * XXX The inter_module_* mechanism has been deprecated and replaced with
80
     * a different mechanism in Linux 2.5; it will go away eventually.
81
     * Also, the Linux 2.5 AGP GART driver is modularized, agpgart.o does not
82
     * include backend drivers.
83
     */
115
    if (!(drm_agp_p = inter_module_get_request("drm_agp", "agpgart")))
84
    if (!(drm_agp_p = inter_module_get_request("drm_agp", "agpgart")))
116
    {
85
    {
117
        nv_printf(NV_DBG_ERRORS,
86
        nv_printf(NV_DBG_ERRORS,
Lines 119-166 Link Here
119
        return 1;
88
        return 1;
120
    }
89
    }
121
    
90
    
122
    agp_ops.backend_acquire = drm_agp_p->acquire;
123
    agp_ops.backend_release = drm_agp_p->release;
124
    agp_ops.allocate_memory = drm_agp_p->allocate_memory;
125
    agp_ops.free_memory     = drm_agp_p->free_memory;
126
    agp_ops.bind_memory     = drm_agp_p->bind_memory;
127
    agp_ops.unbind_memory   = drm_agp_p->unbind_memory;
128
    agp_ops.enable          = drm_agp_p->enable;
129
130
    // looks like some newer kernels (for example mandrake 9.0's 2.4.19-16mdk)
131
    // have updated copy_info to return an integer value, and of course didn't
132
    // bother bumping the agpgart revision up. The return value is pretty 
133
    // harmless (backend_acquire would have already failed and caused us to
134
    // bail), so cast the function pointer to avoid compiler warnings.
135
    // we may need to revisit this in the future.
136
    agp_ops.copy_info       = (void (*)(agp_kern_info *)) drm_agp_p->copy_info;
137
138
#else
139
#if defined(CONFIG_KMOD)
140
    if ( request_module("agpgart") )
141
    {
142
        nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: not loading agpgart.o\n");
143
        return 1;
144
    }
145
#endif
146
147
    GET_AGPGART_SYMBOL(agp_ops.backend_acquire, AGP_BACKEND_ACQUIRE_SYM);
148
    GET_AGPGART_SYMBOL(agp_ops.backend_release, AGP_BACKEND_RELEASE_SYM);
149
    GET_AGPGART_SYMBOL(agp_ops.copy_info,       AGP_COPY_INFO_SYM);
150
    GET_AGPGART_SYMBOL(agp_ops.allocate_memory, AGP_ALLOCATE_MEMORY_SYM);
151
    GET_AGPGART_SYMBOL(agp_ops.free_memory,     AGP_FREE_MEMORY_SYM);
152
    GET_AGPGART_SYMBOL(agp_ops.bind_memory,     AGP_BIND_MEMORY_SYM);
153
    GET_AGPGART_SYMBOL(agp_ops.unbind_memory,   AGP_UNBIND_MEMORY_SYM);
154
    GET_AGPGART_SYMBOL(agp_ops.enable,          AGP_ENABLE_SYM);
155
#endif
156
157
    /* NOTE: from here down, return an error code of '-1'
91
    /* NOTE: from here down, return an error code of '-1'
158
     * that indicates that agpgart is loaded, but we failed to use it
92
     * that indicates that agpgart is loaded, but we failed to use it
159
     * in some way. This is so we don't try to use nvagp and lock up
93
     * in some way. This is so we don't try to use nvagp and lock up
160
     * the memory controller.
94
     * the memory controller.
161
     */
95
     */
162
96
163
    if ( (*(agp_ops.backend_acquire))() )
97
    if (drm_agp_p->acquire())
164
    {
98
    {
165
        nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: backend in use\n");
99
        nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: backend in use\n");
166
        return -1;
100
        return -1;
Lines 178-221 Link Here
178
        agp_fw = 1;
112
        agp_fw = 1;
179
    agp_fw &= 0x00000001;
113
    agp_fw &= 0x00000001;
180
    
114
    
181
    (*(agp_ops.copy_info))(&agpinfo);
115
#if defined(KERNEL_2_4)
182
116
    /*
183
    switch ( agpinfo.chipset )
117
     * The original Linux 2.4 AGP GART driver interface declared copy_info to
184
    {
118
     * return nothing. This changed in Linux 2.5, which reports unsupported
185
        case INTEL_GENERIC:    chipset = "Intel";            break;
119
     * chipsets via this function. If this Linux 2.4 kernels behaves the same
186
        case INTEL_LX:         chipset = "Intel 440LX";      break;
120
     * way, we have no way to know.
187
        case INTEL_BX:         chipset = "Intel 440BX";      break;
121
     */
188
        case INTEL_GX:         chipset = "Intel 440GX";      break;
122
    drm_agp_p->copy_info(&agpinfo);
189
        case INTEL_I810:       chipset = "Intel i810";       break;
123
#else
190
        case INTEL_I840:       chipset = "Intel i840";       break;
124
    if (drm_agp_p->copy_info(&agpinfo)) {
191
#if !defined (KERNEL_2_2)
125
        drm_agp_p->release();
192
        case INTEL_I815:       chipset = "Intel i815";       break;
126
        inter_module_put("drm_agp");
193
#if !defined(__rh_config_h__)
127
        return -1;
194
        case INTEL_I850:       chipset = "Intel i850";       break;
195
#endif
196
#endif
197
#if defined(NVCPU_IA64)
198
        case INTEL_460GX:      chipset = "Intel 460GX";      break;
199
#endif
200
        case VIA_GENERIC:      chipset = "VIA";              break;
201
        case VIA_VP3:          chipset = "VIA VP3";          break;
202
        case VIA_MVP3:         chipset = "VIA MVP3";         break;
203
        case VIA_MVP4:         chipset = "VIA MVP4";         break;
204
#if !defined (KERNEL_2_2)
205
        case VIA_APOLLO_KX133: chipset = "VIA Apollo KX133"; break;
206
        case VIA_APOLLO_KT133: chipset = "VIA Apollo KT133"; break;
207
#endif
208
        case VIA_APOLLO_PRO:   chipset = "VIA Apollo Pro";   break;
209
        case SIS_GENERIC:      chipset = "SiS";              break;
210
        case AMD_GENERIC:      chipset = "AMD";              break;
211
        case AMD_IRONGATE:     chipset = "AMD Irongate";     break;
212
        case ALI_M1541:        chipset = "ALi M1541";        break;
213
        case ALI_GENERIC:      chipset = "ALi";              break;
214
        case NOT_SUPPORTED:    chipset = "unsupported";      break;
215
        default:               chipset = "unknown";
216
    }
128
    }
217
129
#endif
218
    nv_printf(NV_DBG_SETUP, "NVRM: AGPGART: %s chipset\n", chipset);
219
130
220
#ifdef CONFIG_MTRR
131
#ifdef CONFIG_MTRR
221
    if ((gart.mtrr = mtrr_add(agpinfo.aper_base,
132
    if ((gart.mtrr = mtrr_add(agpinfo.aper_base,
Lines 229-235 Link Here
229
         */
140
         */
230
        nv_printf(NV_DBG_ERRORS, 
141
        nv_printf(NV_DBG_ERRORS, 
231
            "NVRM: AGPGART: unable to set MTRR write-combining\n");
142
            "NVRM: AGPGART: unable to set MTRR write-combining\n");
232
        (*(agp_ops.backend_release))();
143
        drm_agp_p->release();
144
        inter_module_put("drm_agp");
233
        return -1;
145
        return -1;
234
    }
146
    }
235
#endif
147
#endif
Lines 244-250 Link Here
244
    {
156
    {
245
        nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: unable to remap aperture\n");
157
        nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: unable to remap aperture\n");
246
        MTRR_DEL(gart);
158
        MTRR_DEL(gart);
247
        (*(agp_ops.backend_release))();
159
        drm_agp_p->release();
160
        inter_module_put("drm_agp");
248
        return -1;
161
        return -1;
249
    }
162
    }
250
163
Lines 255-261 Link Here
255
        nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: unable to allocate bitmap\n");
168
        nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: unable to allocate bitmap\n");
256
        iounmap(gart.aperture);
169
        iounmap(gart.aperture);
257
        MTRR_DEL(gart);
170
        MTRR_DEL(gart);
258
        (*(agp_ops.backend_release))();
171
        drm_agp_p->release();
172
        inter_module_put("drm_agp");
259
        return -1;
173
        return -1;
260
    }
174
    }
261
175
Lines 266-304 Link Here
266
        os_free_mem(bitmap);
180
        os_free_mem(bitmap);
267
        iounmap(gart.aperture);
181
        iounmap(gart.aperture);
268
        MTRR_DEL(gart);
182
        MTRR_DEL(gart);
269
        (*(agp_ops.backend_release))();
183
        drm_agp_p->release();
184
        inter_module_put("drm_agp");
270
        return -1;
185
        return -1;
271
    }
186
    }
272
187
273
    nv_printf(NV_DBG_SETUP,
274
        "NVRM: AGPGART: aperture: %ldM @ 0x%08lx\n",
275
        (unsigned long)agpinfo.aper_size,
276
        (unsigned long)agpinfo.aper_base);
277
278
    nv_printf(NV_DBG_SETUP, 
279
        "NVRM: AGPGART: aperture mapped from 0x%08lx to 0x%08lx\n",
280
        agpinfo.aper_base,
281
        (unsigned long) gart.aperture);
282
283
    if (!agp_sba) agpinfo.mode &= ~0x00000200;
188
    if (!agp_sba) agpinfo.mode &= ~0x00000200;
284
    if (!agp_fw)  agpinfo.mode &= ~0x00000010;
189
    if (!agp_fw)  agpinfo.mode &= ~0x00000010;
285
190
286
    if (!(agp_rate & 0x00000004)) agpinfo.mode &= ~0x00000004;
191
    if (!(agp_rate & 0x00000004)) agpinfo.mode &= ~0x00000004;
287
    if (!(agp_rate & 0x00000002)) agpinfo.mode &= ~0x00000002;
192
    if (!(agp_rate & 0x00000002)) agpinfo.mode &= ~0x00000002;
288
    
193
    
289
    (*(agp_ops.enable))(agpinfo.mode);
194
    drm_agp_p->enable(agpinfo.mode);
290
    
195
    
291
    if (agpinfo.mode & 0x00000200)
292
        nv_printf(NV_DBG_SETUP, "NVRM: AGPGART: backend supports sba\n");
293
    if (agpinfo.mode & 0x00000010)
294
        nv_printf(NV_DBG_SETUP, "NVRM: AGPGART: backend supports fw\n");
295
    if (agpinfo.mode & 0x00000004)
296
        nv_printf(NV_DBG_SETUP, "NVRM: AGPGART: mode 4x\n");
297
    else if (agpinfo.mode & 0x00000002)
298
        nv_printf(NV_DBG_SETUP, "NVRM: AGPGART: mode 2x\n");
299
    else if (agpinfo.mode & 0x00000001)
300
        nv_printf(NV_DBG_SETUP, "NVRM: AGPGART: mode 1x\n");
301
302
    *ap_phys_base   = (void*) agpinfo.aper_base;
196
    *ap_phys_base   = (void*) agpinfo.aper_base;
303
    *ap_mapped_base = (void*) gart.aperture;
197
    *ap_mapped_base = (void*) gart.aperture;
304
    *apsize         = (agpinfo.aper_size * 0x100000) - 1;
198
    *apsize         = (agpinfo.aper_size * 0x100000) - 1;
Lines 332-342 Link Here
332
        iounmap(gart.aperture);
226
        iounmap(gart.aperture);
333
    }
227
    }
334
228
335
    (*(agp_ops.backend_release))();
229
    drm_agp_p->release();
336
230
337
#if !defined (KERNEL_2_2)
231
    /*
232
     * XXX Same as above; the inter_module_* mechanism will go away at some
233
     * point, it has been deprecated in Linux 2.5.
234
     */
338
    inter_module_put("drm_agp");
235
    inter_module_put("drm_agp");
339
#endif
340
236
341
    if (rm_clear_agp_bitmap(nv, &bitmap))
237
    if (rm_clear_agp_bitmap(nv, &bitmap))
342
    {
238
    {
Lines 383-389 Link Here
383
        return RM_ERROR;
279
        return RM_ERROR;
384
    }
280
    }
385
281
386
    ptr = (*agp_ops.allocate_memory)(PageCount, AGP_NORMAL_MEMORY);
282
    ptr = drm_agp_p->allocate_memory(PageCount, AGP_NORMAL_MEMORY);
387
    if (ptr == NULL)
283
    if (ptr == NULL)
388
    {
284
    {
389
        *pAddress = (void*) 0;
285
        *pAddress = (void*) 0;
Lines 391-397 Link Here
391
        return RM_ERR_NO_FREE_MEM;
287
        return RM_ERR_NO_FREE_MEM;
392
    }
288
    }
393
    
289
    
394
    err = (*(agp_ops.bind_memory))(ptr, *Offset);
290
    err = drm_agp_p->bind_memory(ptr, *Offset);
395
    if (err)
291
    if (err)
396
    {
292
    {
397
        // this happens a lot when the aperture itself fills up..
293
        // this happens a lot when the aperture itself fills up..
Lines 408-414 Link Here
408
    if (status != RM_OK)
304
    if (status != RM_OK)
409
    {
305
    {
410
        nv_printf(NV_DBG_ERRORS, "NVRM: memory allocation failed\n");
306
        nv_printf(NV_DBG_ERRORS, "NVRM: memory allocation failed\n");
411
        (*(agp_ops.unbind_memory))(ptr);
307
        drm_agp_p->unbind_memory(ptr);
412
        goto fail;
308
        goto fail;
413
    }
309
    }
414
310
Lines 423-429 Link Here
423
    return RM_OK;
319
    return RM_OK;
424
320
425
fail:
321
fail:
426
    (*(agp_ops.free_memory))(ptr);
322
    drm_agp_p->free_memory(ptr);
427
    *pAddress = (void*) 0;
323
    *pAddress = (void*) 0;
428
324
429
    return RM_ERROR;
325
    return RM_ERROR;
Lines 462-468 Link Here
462
    {
358
    {
463
        nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: unable to remap %lu pages\n",
359
        nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: unable to remap %lu pages\n",
464
            (unsigned long)agp_data->num_pages);
360
            (unsigned long)agp_data->num_pages);
465
        (*(agp_ops.unbind_memory))(agp_data->ptr);
361
        drm_agp_p->unbind_memory(agp_data->ptr);
466
        goto fail;
362
        goto fail;
467
    }
363
    }
468
    
364
    
Lines 480-488 Link Here
480
#endif /* AGPGART */
376
#endif /* AGPGART */
481
}
377
}
482
378
483
484
#if !defined(KERNEL_2_2)
485
486
RM_STATUS 
379
RM_STATUS 
487
KernMapAGPNopage(
380
KernMapAGPNopage(
488
    VOID *address,
381
    VOID *address,
Lines 529-537 Link Here
529
#endif
422
#endif
530
}
423
}
531
424
532
#endif /* !defined(KERNEL_2_2) */
533
534
535
RM_STATUS KernFreeAGPPages(
425
RM_STATUS KernFreeAGPPages(
536
    nv_state_t *nv,
426
    nv_state_t *nv,
537
    VOID **pAddress,
427
    VOID **pAddress,
Lines 557-564 Link Here
557
    {
447
    {
558
        size_t pages = ptr->page_count;
448
        size_t pages = ptr->page_count;
559
449
560
        (*(agp_ops.unbind_memory))(ptr);
450
        drm_agp_p->unbind_memory(ptr);
561
        (*(agp_ops.free_memory))(ptr);
451
        drm_agp_p->free_memory(ptr);
562
452
563
        nv_printf(NV_DBG_INFO, "NVRM: AGPGART: freed %ld pages\n",
453
        nv_printf(NV_DBG_INFO, "NVRM: AGPGART: freed %ld pages\n",
564
            (unsigned long)pages);
454
            (unsigned long)pages);
(-)NVIDIA_kernel-1.0-4363/os-interface.c (-31 / +20 lines)
Lines 56-62 Link Here
56
    PHWINFO pDev
56
    PHWINFO pDev
57
)
57
)
58
{
58
{
59
    return suser();
59
    return NV_IS_SUSER();
60
}
60
}
61
61
62
U032 os_get_page_size(VOID)
62
U032 os_get_page_size(VOID)
Lines 209-214 Link Here
209
    U032 size
209
    U032 size
210
)
210
)
211
{
211
{
212
    /*
213
     * XXX This needs to be !NV_MAY_SLEEP() rather than in_interrupt(); that
214
     * requires quite a bit of locking to be rearranged, however, which is why
215
     * I'll leave it alone for now.
216
     */
212
    if (in_interrupt()) {
217
    if (in_interrupt()) {
213
        if (size <= KMALLOC_LIMIT) {
218
        if (size <= KMALLOC_LIMIT) {
214
            /*
219
            /*
Lines 286-292 Link Here
286
    *address = (void *) va;
291
    *address = (void *) va;
287
292
288
    for (i = 0; i < count; i++) {
293
    for (i = 0; i < count; i++) {
289
        mem_map_reserve(GET_MAP_NR(__pa((va))));
294
        SetPageReserved(virt_to_page(va));
290
        va += PAGE_SIZE;
295
        va += PAGE_SIZE;
291
    }
296
    }
292
297
Lines 310-316 Link Here
310
    unsigned long va = (unsigned long) address;
315
    unsigned long va = (unsigned long) address;
311
316
312
    for (i = 0; i < count; i++) {
317
    for (i = 0; i < count; i++) {
313
        mem_map_unreserve(GET_MAP_NR(__pa((va))));
318
        ClearPageReserved(virt_to_page(va));
314
        va += PAGE_SIZE;
319
        va += PAGE_SIZE;
315
    }
320
    }
316
321
Lines 416-422 Link Here
416
    if (in_irq() && MilliSeconds > NV_MAX_ISR_MDELAY)
421
    if (in_irq() && MilliSeconds > NV_MAX_ISR_MDELAY)
417
        return RM_ERROR;
422
        return RM_ERROR;
418
423
419
    if (in_interrupt()) 
424
    if (!NV_MAY_SLEEP()) 
420
    {
425
    {
421
        mdelay(MilliSeconds);
426
        mdelay(MilliSeconds);
422
        return RM_OK;
427
        return RM_OK;
Lines 514-521 Link Here
514
// The current debug display level (default to maximum debug level)
519
// The current debug display level (default to maximum debug level)
515
int cur_debuglevel = 0xaaaaaaaa;
520
int cur_debuglevel = 0xaaaaaaaa;
516
521
517
MODULE_PARM(silence_nvidia_output, "1i");
518
static int silence_nvidia_output = 0;
522
static int silence_nvidia_output = 0;
523
NV_MODULE_PARAMETER(silence_nvidia_output);
519
524
520
525
521
//
526
//
Lines 698-711 Link Here
698
703
699
ULONG os_cli(ULONG flags)
704
ULONG os_cli(ULONG flags)
700
{
705
{
701
    save_flags(flags);
706
    NV_SAVE_FLAGS(flags);
702
    cli();
707
    NV_CLI();
703
    return flags;
708
    return flags;
704
}
709
}
705
710
706
ULONG os_sti(ULONG flags)
711
ULONG os_sti(ULONG flags)
707
{
712
{
708
    restore_flags(flags);
713
    NV_RESTORE_FLAGS(flags);
709
    return flags;
714
    return flags;
710
}
715
}
711
716
Lines 838-853 Link Here
838
        vaddr = ioremap_nocache(start, size_bytes);
843
        vaddr = ioremap_nocache(start, size_bytes);
839
    }
844
    }
840
845
841
#if defined (KERNEL_2_2)
842
    if ((vaddr == NULL)) // && (mode == NV_MEMORY_DEFAULT))
843
    {
844
        unsigned long map_nr = MAP_NR(__va(start));
845
        if (map_nr < max_mapnr) {
846
            vaddr = __va(start);
847
        }
848
    }
849
#endif
850
851
#ifdef DEBUG
846
#ifdef DEBUG
852
    if (mode == NV_MEMORY_WRITECOMBINED) {
847
    if (mode == NV_MEMORY_WRITECOMBINED) {
853
        nv_printf(NV_DBG_ERRORS, 
848
        nv_printf(NV_DBG_ERRORS, 
Lines 868-883 Link Here
868
    U032 size_bytes
863
    U032 size_bytes
869
)
864
)
870
{
865
{
871
#if defined (KERNEL_2_2)
866
    iounmap(addr);
872
    if (MAP_NR(addr) < max_mapnr) {
873
        // if we didn't want the memory cached, this isn't necessary
874
        // but we shouldn't be in a timing critical piece of code.
875
        asm volatile("wbinvd":::"memory");
876
    } else 
877
#endif
878
    {
879
        iounmap(addr);
880
    }
881
}
867
}
882
868
883
VOID* os_map_user_space(
869
VOID* os_map_user_space(
Lines 981-987 Link Here
981
967
982
U032 os_get_cpu_count()
968
U032 os_get_cpu_count()
983
{
969
{
984
    return smp_num_cpus;
970
    return NV_SMP_NUM_CPUS;
985
}
971
}
986
972
987
973
Lines 1044-1055 Link Here
1044
    if (sgi_funcs.add_barrier == NULL)
1030
    if (sgi_funcs.add_barrier == NULL)
1045
    {
1031
    {
1046
#if defined(TESTING_SWAP)
1032
#if defined(TESTING_SWAP)
1047
#if !defined (KERNEL_2_2)
1033
        /*
1034
         * XXX The inter_module_* mechanism has been deprecated in Linux 2.5, a
1035
         * new mechanism is in place; this code will need to be updated at some
1036
         * point.
1037
         */
1048
        inter_module_register(ADD_BARRIER_FUNC,    THIS_MODULE, sgitest_add_barrier);
1038
        inter_module_register(ADD_BARRIER_FUNC,    THIS_MODULE, sgitest_add_barrier);
1049
        inter_module_register(REMOVE_BARRIER_FUNC, THIS_MODULE, sgitest_remove_barrier);
1039
        inter_module_register(REMOVE_BARRIER_FUNC, THIS_MODULE, sgitest_remove_barrier);
1050
        inter_module_register(SWAP_READY_FUNC,     THIS_MODULE, sgitest_swap_ready);
1040
        inter_module_register(SWAP_READY_FUNC,     THIS_MODULE, sgitest_swap_ready);
1051
#endif
1041
#endif
1052
#endif
1053
        sgi_funcs.add_barrier = GET_MODULE_SYMBOL(0, ADD_BARRIER_FUNC);
1042
        sgi_funcs.add_barrier = GET_MODULE_SYMBOL(0, ADD_BARRIER_FUNC);
1054
        sgi_funcs.remove_barrier = GET_MODULE_SYMBOL(0, REMOVE_BARRIER_FUNC);
1043
        sgi_funcs.remove_barrier = GET_MODULE_SYMBOL(0, REMOVE_BARRIER_FUNC);
1055
        sgi_funcs.swap_ready = GET_MODULE_SYMBOL(0, SWAP_READY_FUNC);
1044
        sgi_funcs.swap_ready = GET_MODULE_SYMBOL(0, SWAP_READY_FUNC);
(-)NVIDIA_kernel-1.0-4363/os-interface.h (-63 / +63 lines)
Lines 67-134 Link Here
67
 * ---------------------------------------------------------------------------
67
 * ---------------------------------------------------------------------------
68
 */
68
 */
69
69
70
U032        os_get_page_size            (VOID);
70
U032        NV_API_CALL  os_get_page_size            (VOID);
71
ULONG       os_get_page_mask            (VOID);
71
ULONG       NV_API_CALL  os_get_page_mask            (VOID);
72
RM_STATUS   os_alloc_mem                (VOID **, U032);
72
RM_STATUS   NV_API_CALL  os_alloc_mem                (VOID **, U032);
73
VOID        os_free_mem                 (VOID *);
73
VOID        NV_API_CALL  os_free_mem                 (VOID *);
74
RM_STATUS   os_alloc_contig_pages       (VOID **, U032);
74
RM_STATUS   NV_API_CALL  os_alloc_contig_pages       (VOID **, U032);
75
VOID        os_free_contig_pages        (VOID *, U032);
75
VOID        NV_API_CALL  os_free_contig_pages        (VOID *, U032);
76
RM_STATUS   os_get_current_time         (U032 *, U032 *);
76
RM_STATUS   NV_API_CALL  os_get_current_time         (U032 *, U032 *);
77
RM_STATUS   os_delay                    (U032);
77
RM_STATUS   NV_API_CALL  os_delay                    (U032);
78
RM_STATUS   os_delay_us                 (U032);
78
RM_STATUS   NV_API_CALL  os_delay_us                 (U032);
79
U032        os_get_cpu_frequency        (VOID);
79
U032        NV_API_CALL  os_get_cpu_frequency        (VOID);
80
RM_STATUS   os_get_current_process      (U032 *);
80
RM_STATUS   NV_API_CALL  os_get_current_process      (U032 *);
81
RM_STATUS   os_kill_process             (U032, U032);
81
RM_STATUS   NV_API_CALL  os_kill_process             (U032, U032);
82
U008*       os_string_copy              (U008 *, const U008 *);
82
U008*       NV_API_CALL  os_string_copy              (U008 *, const U008 *);
83
RM_STATUS   os_strncpy_from_user        (U008 *, const U008 *, U032);
83
RM_STATUS   NV_API_CALL  os_strncpy_from_user        (U008 *, const U008 *, U032);
84
S032        os_string_compare           (const U008 *, const U008 *);
84
S032        NV_API_CALL  os_string_compare           (const U008 *, const U008 *);
85
U032        os_string_length            (const U008 *);
85
U032        NV_API_CALL  os_string_length            (const U008 *);
86
U008*       os_mem_copy                 (U008 *, const U008 *, U032);
86
U008*       NV_API_CALL  os_mem_copy                 (U008 *, const U008 *, U032);
87
RM_STATUS   os_memcpy_from_user         (VOID *, const VOID *, U032);
87
RM_STATUS   NV_API_CALL  os_memcpy_from_user         (VOID *, const VOID *, U032);
88
RM_STATUS   os_memcpy_to_user           (void *, const VOID *, U032);
88
RM_STATUS   NV_API_CALL  os_memcpy_to_user           (void *, const VOID *, U032);
89
VOID*       os_mem_set                  (VOID *, U008, U032);
89
VOID*       NV_API_CALL  os_mem_set                  (VOID *, U008, U032);
90
S032        os_mem_cmp                  (const U008 *, const U008 *, U032);
90
S032        NV_API_CALL  os_mem_cmp                  (const U008 *, const U008 *, U032);
91
VOID*       os_pci_init_handle          (U008, U008, U008, U016 *, U016 *);
91
VOID*       NV_API_CALL  os_pci_init_handle          (U008, U008, U008, U016 *, U016 *);
92
U008        os_pci_read_byte            (VOID *, U008);
92
U008        NV_API_CALL  os_pci_read_byte            (VOID *, U008);
93
U016        os_pci_read_word            (VOID *, U008);
93
U016        NV_API_CALL  os_pci_read_word            (VOID *, U008);
94
U032        os_pci_read_dword           (VOID *, U008);
94
U032        NV_API_CALL  os_pci_read_dword           (VOID *, U008);
95
VOID        os_pci_write_byte           (VOID *, U008, U008);
95
VOID        NV_API_CALL  os_pci_write_byte           (VOID *, U008, U008);
96
VOID        os_pci_write_word           (VOID *, U008, U016);
96
VOID        NV_API_CALL  os_pci_write_word           (VOID *, U008, U016);
97
VOID        os_pci_write_dword          (VOID *, U008, U032);
97
VOID        NV_API_CALL  os_pci_write_dword          (VOID *, U008, U032);
98
VOID*       os_map_kernel_space         (U032, U032, U032);
98
VOID*       NV_API_CALL  os_map_kernel_space         (U032, U032, U032);
99
VOID        os_unmap_kernel_space       (VOID *, U032);
99
VOID        NV_API_CALL  os_unmap_kernel_space       (VOID *, U032);
100
VOID*       os_map_user_space           (VOID *, VOID **, U032, U032);
100
VOID*       NV_API_CALL  os_map_user_space           (VOID *, VOID **, U032, U032);
101
VOID        os_unmap_user_space         (VOID *, VOID *);
101
VOID        NV_API_CALL  os_unmap_user_space         (VOID *, VOID *);
102
VOID*       os_map_io_space             (U032, U032, VOID **, U032, U032);
102
VOID*       NV_API_CALL  os_map_io_space             (U032, U032, VOID **, U032, U032);
103
VOID        os_unmap_io_space           (VOID *, U032, VOID *, U032);
103
VOID        NV_API_CALL  os_unmap_io_space           (VOID *, U032, VOID *, U032);
104
RM_STATUS   os_flush_cpu_cache          (VOID);
104
RM_STATUS   NV_API_CALL  os_flush_cpu_cache          (VOID);
105
RM_STATUS   os_set_mem_range            (U032, U032, U032);
105
RM_STATUS   NV_API_CALL  os_set_mem_range            (U032, U032, U032);
106
RM_STATUS   os_unset_mem_range          (U032, U032);
106
RM_STATUS   NV_API_CALL  os_unset_mem_range          (U032, U032);
107
BOOL        os_pci_device_present       (U016, U016);
107
BOOL        NV_API_CALL  os_pci_device_present       (U016, U016);
108
U008        os_io_read_byte             (PHWINFO, U032);
108
U008        NV_API_CALL  os_io_read_byte             (PHWINFO, U032);
109
U016        os_io_read_word             (PHWINFO, U032);
109
U016        NV_API_CALL  os_io_read_word             (PHWINFO, U032);
110
U032        os_io_read_dword            (PHWINFO, U032);
110
U032        NV_API_CALL  os_io_read_dword            (PHWINFO, U032);
111
VOID        os_io_write_byte            (PHWINFO, U032, U008);
111
VOID        NV_API_CALL  os_io_write_byte            (PHWINFO, U032, U008);
112
VOID        os_io_write_word            (PHWINFO, U032, U016);
112
VOID        NV_API_CALL  os_io_write_word            (PHWINFO, U032, U016);
113
VOID        os_io_write_dword           (PHWINFO, U032, U032);
113
VOID        NV_API_CALL  os_io_write_dword           (PHWINFO, U032, U032);
114
ULONG       os_cli                      (ULONG);
114
ULONG       NV_API_CALL  os_cli                      (ULONG);
115
ULONG       os_sti                      (ULONG);
115
ULONG       NV_API_CALL  os_sti                      (ULONG);
116
VOID*       os_copy_in_ioctl_param      (VOID *, VOID *, U032);
116
VOID*       NV_API_CALL  os_copy_in_ioctl_param      (VOID *, VOID *, U032);
117
VOID*       os_copy_out_ioctl_param     (VOID *, VOID *, U032);
117
VOID*       NV_API_CALL  os_copy_out_ioctl_param     (VOID *, VOID *, U032);
118
VOID*       os_registry_lookup          (PHWINFO, U008 *, U008 *);
118
VOID*       NV_API_CALL  os_registry_lookup          (PHWINFO, U008 *, U008 *);
119
RM_STATUS   os_swap_barrier             (U032, VOID (*)(VOID *), VOID *);
119
RM_STATUS   NV_API_CALL  os_swap_barrier             (U032, VOID (*)(VOID *), VOID *);
120
RM_STATUS   os_init_swap_barrier        (U032);
120
RM_STATUS   NV_API_CALL  os_init_swap_barrier        (U032);
121
RM_STATUS   os_remove_swap_barrier      (U032);
121
RM_STATUS   NV_API_CALL  os_remove_swap_barrier      (U032);
122
BOOL        os_is_administrator         (PHWINFO);
122
BOOL        NV_API_CALL  os_is_administrator         (PHWINFO);
123
VOID        os_dbg_init                 (VOID);
123
VOID        NV_API_CALL  os_dbg_init                 (VOID);
124
VOID        os_dbg_breakpoint           (VOID);
124
VOID        NV_API_CALL  os_dbg_breakpoint           (VOID);
125
VOID        os_dbg_set_level            (U032);
125
VOID        NV_API_CALL  os_dbg_set_level            (U032);
126
U032        os_get_cpu_count            (VOID);
126
U032        NV_API_CALL  os_get_cpu_count            (VOID);
127
RM_STATUS   os_raise_smp_barrier        (VOID);
127
RM_STATUS   NV_API_CALL  os_raise_smp_barrier        (VOID);
128
RM_STATUS   os_clear_smp_barrier        (VOID);
128
RM_STATUS   NV_API_CALL  os_clear_smp_barrier        (VOID);
129
129
130
RM_STATUS   osRaiseSmpBarrier           (VOID);
130
RM_STATUS   NV_API_CALL  osRaiseSmpBarrier           (VOID);
131
RM_STATUS   osClearSmpBarrier           (VOID);
131
RM_STATUS   NV_API_CALL  osClearSmpBarrier           (VOID);
132
132
133
/*
133
/*
134
 * ---------------------------------------------------------------------------
134
 * ---------------------------------------------------------------------------
Lines 162-169 Link Here
162
#define NV_DBG_ERRORS     0x4
162
#define NV_DBG_ERRORS     0x4
163
163
164
164
165
inline void out_string(const char *str);
165
void    NV_API_CALL  out_string(const char *str);
166
int nv_printf(int debuglevel, const char *printf_format, ...);
166
int     NV_API_CALL  nv_printf(int debuglevel, const char *printf_format, ...);
167
167
168
168
169
#define NV_MEMORY_TYPE_SYSTEM       0
169
#define NV_MEMORY_TYPE_SYSTEM       0
(-)NVIDIA_kernel-1.0-4363/os-registry.c (-29 / +11 lines)
Lines 48-71 Link Here
48
 *   This could be changed to work on a per-device basis.
48
 *   This could be changed to work on a per-device basis.
49
 */
49
 */
50
50
51
/*
52
 * The 2nd argument to MODULE_PARM is used to verify parameters passed
53
 * to the module at load time. It should be a string in the following 
54
 * format:
55
 *
56
 *   	[min[-max]]{b,h,i,l,s}
57
 *
58
 * The MIN and MAX specifiers delimit the length of the array. If MAX
59
 * is omitted, it defaults to MIN; if both are omitted, the default is
60
 * 1. The final character is a type specifier.
61
 *
62
 *  b   byte
63
 *  h   short
64
 *  i   int
65
 *  l   long
66
 *  s   string
67
 */
68
69
/* 
51
/* 
70
 * Option: VideoMemoryTypeOverride
52
 * Option: VideoMemoryTypeOverride
71
 * 
53
 * 
Lines 92-98 Link Here
92
 */
74
 */
93
75
94
static int NVreg_VideoMemoryTypeOverride = 1;
76
static int NVreg_VideoMemoryTypeOverride = 1;
95
MODULE_PARM(NVreg_VideoMemoryTypeOverride, "i");
77
NV_MODULE_PARAMETER(NVreg_VideoMemoryTypeOverride);
96
78
97
/*
79
/*
98
 * Option: EnableVia4x
80
 * Option: EnableVia4x
Lines 111-117 Link Here
111
 */
93
 */
112
94
113
static int NVreg_EnableVia4x = 0;
95
static int NVreg_EnableVia4x = 0;
114
MODULE_PARM(NVreg_EnableVia4x, "i");
96
NV_MODULE_PARAMETER(NVreg_EnableVia4x);
115
97
116
/*
98
/*
117
 * Option: EnableALiAGP
99
 * Option: EnableALiAGP
Lines 134-140 Link Here
134
 */
116
 */
135
117
136
static int NVreg_EnableALiAGP = 0;
118
static int NVreg_EnableALiAGP = 0;
137
MODULE_PARM(NVreg_EnableALiAGP, "i");
119
NV_MODULE_PARAMETER(NVreg_EnableALiAGP);
138
120
139
/* 
121
/* 
140
 * Option: ReqAGPRate
122
 * Option: ReqAGPRate
Lines 164-170 Link Here
164
 */
146
 */
165
147
166
static int NVreg_ReqAGPRate = 7;
148
static int NVreg_ReqAGPRate = 7;
167
MODULE_PARM(NVreg_ReqAGPRate, "i");
149
NV_MODULE_PARAMETER(NVreg_ReqAGPRate);
168
150
169
/* 
151
/* 
170
 * Option: UpdateKernelAGP
152
 * Option: UpdateKernelAGP
Lines 193-199 Link Here
193
 */
175
 */
194
176
195
static int NVreg_UpdateKernelAGP = 1;
177
static int NVreg_UpdateKernelAGP = 1;
196
MODULE_PARM(NVreg_UpdateKernelAGP, "i");
178
NV_MODULE_PARAMETER(NVreg_UpdateKernelAGP);
197
179
198
/* 
180
/* 
199
 * Option: EnableAGPSBA
181
 * Option: EnableAGPSBA
Lines 226-232 Link Here
226
static int NVreg_EnableAGPSBA = 0;
208
static int NVreg_EnableAGPSBA = 0;
227
#endif
209
#endif
228
210
229
MODULE_PARM(NVreg_EnableAGPSBA, "i");
211
NV_MODULE_PARAMETER(NVreg_EnableAGPSBA);
230
212
231
/*
213
/*
232
 * Option: EnableAGPFW
214
 * Option: EnableAGPFW
Lines 250-256 Link Here
250
 */
232
 */
251
233
252
static int NVreg_EnableAGPFW = 0;
234
static int NVreg_EnableAGPFW = 0;
253
MODULE_PARM(NVreg_EnableAGPFW, "i");
235
NV_MODULE_PARAMETER(NVreg_EnableAGPFW);
254
236
255
/*
237
/*
256
 * Option: SoftEDIDs
238
 * Option: SoftEDIDs
Lines 269-275 Link Here
269
 */
251
 */
270
252
271
static int NVreg_SoftEDIDs = 1;
253
static int NVreg_SoftEDIDs = 1;
272
MODULE_PARM(NVreg_SoftEDIDs, "i");
254
NV_MODULE_PARAMETER(NVreg_SoftEDIDs);
273
255
274
/* 
256
/* 
275
 * Option: Mobile
257
 * Option: Mobile
Lines 293-306 Link Here
293
 */
275
 */
294
276
295
static int NVreg_Mobile = ~0;
277
static int NVreg_Mobile = ~0;
296
MODULE_PARM(NVreg_Mobile, "i");
278
NV_MODULE_PARAMETER(NVreg_Mobile);
297
279
298
280
299
static int NVreg_ResmanDebugLevel = ~0;
281
static int NVreg_ResmanDebugLevel = ~0;
300
MODULE_PARM(NVreg_ResmanDebugLevel, "i");
282
NV_MODULE_PARAMETER(NVreg_ResmanDebugLevel);
301
283
302
static int NVreg_FlatPanelMode = 0;
284
static int NVreg_FlatPanelMode = 0;
303
MODULE_PARM(NVreg_FlatPanelMode, "i");
285
NV_MODULE_PARAMETER(NVreg_FlatPanelMode);
304
286
305
/*
287
/*
306
 * You can enable any of the registry options disabled by default by
288
 * You can enable any of the registry options disabled by default by

Return to bug 40057