diff options
-rw-r--r-- | DRIVER_VERSION | 1 | ||||
-rw-r--r-- | Makefile | 376 | ||||
-rw-r--r-- | command-list.c | 10 | ||||
-rw-r--r-- | dist-files.mk | 3 | ||||
-rw-r--r-- | files.c | 2 | ||||
-rw-r--r-- | gen-manpage-opts.c | 12 | ||||
-rw-r--r-- | help-args.c | 8 | ||||
-rwxr-xr-x | libpci.a | bin | 28108 -> 0 bytes | |||
-rw-r--r-- | makefile.nvmk | 183 | ||||
-rw-r--r-- | nvgetopt.c | 231 | ||||
-rw-r--r-- | nvgetopt.h | 69 | ||||
-rw-r--r-- | nvidia-installer.1.m4 | 8 | ||||
-rw-r--r-- | nvidia-installer.c | 224 | ||||
-rw-r--r-- | option_table.h | 115 | ||||
-rwxr-xr-x | pci/config.h | 11 | ||||
-rwxr-xr-x | pci/header.h | 935 | ||||
-rw-r--r-- | pci/pci.h | 170 | ||||
-rwxr-xr-x | pci/types.h | 53 | ||||
-rw-r--r-- | public.mk | 310 | ||||
-rw-r--r-- | update.c | 14 | ||||
-rw-r--r-- | update.h | 6 | ||||
-rw-r--r-- | utils.mk | 293 | ||||
-rw-r--r-- | version.mk | 1 |
23 files changed, 968 insertions, 2067 deletions
diff --git a/DRIVER_VERSION b/DRIVER_VERSION deleted file mode 100644 index 29049f2..0000000 --- a/DRIVER_VERSION +++ /dev/null @@ -1 +0,0 @@ -195.36.24 @@ -2,18 +2,18 @@ # nvidia-installer: A tool for installing NVIDIA software packages on # Unix and Linux systems. # -# Copyright (C) 2003 NVIDIA Corporation +# Copyright (C) 2008 NVIDIA Corporation # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the: # @@ -25,161 +25,120 @@ # Makefile # -# default definitions; can be overwridden by users -ifndef CC - CC = gcc -endif -ifndef LD - LD = ld -endif +############################################################################## +# include common variables and functions +############################################################################## -ifndef HOST_CC - HOST_CC = $(CC) -endif +include utils.mk -ifndef HOST_LD - HOST_LD = $(LD) -endif +############################################################################## +# The calling Makefile may export any of the following variables; we +# assign default values if they are not exported by the caller +############################################################################## -ifndef CFLAGS - CFLAGS = -g -O -Wall -endif -SHELL = /bin/sh -INSTALL = install -m 755 +NCURSES_CFLAGS ?= +NCURSES_LDFLAGS ?= +PCI_CFLAGS ?= +PCI_LDFLAGS ?= -ifeq ($(NVDEBUG),1) - STRIP = true -else - ifndef STRIP - STRIP = strip - endif -endif +############################################################################## +# assign variables +############################################################################## -# default prefix -ifdef ROOT - prefix = $(ROOT)/usr -else - prefix = /usr/local -endif - -exec_prefix = $(prefix) -bindir = $(exec_prefix)/bin -mandir = $(exec_prefix)/share/man/man1 - -# Can be overwitten by users for cross-compiling -# get the os and architecture -ifndef INSTALLER_OS - INSTALLER_OS := $(shell uname) -endif - -ifndef INSTALLER_ARCH - INSTALLER_ARCH := $(shell uname -m) -endif - -# cook the architecture -INSTALLER_ARCH := $(subst i386,x86,$(INSTALLER_ARCH)) -INSTALLER_ARCH := $(subst i486,x86,$(INSTALLER_ARCH)) -INSTALLER_ARCH := $(subst i586,x86,$(INSTALLER_ARCH)) -INSTALLER_ARCH := $(subst i686,x86,$(INSTALLER_ARCH)) - - -NVIDIA_INSTALLER = nvidia-installer -MKPRECOMPILED = mkprecompiled -MAKESELF_HELP_SCRIPT = makeself-help-script +NVIDIA_INSTALLER = $(OUTPUTDIR)/nvidia-installer +MKPRECOMPILED = $(OUTPUTDIR)/mkprecompiled +MAKESELF_HELP_SCRIPT = $(OUTPUTDIR)/makeself-help-script NVIDIA_INSTALLER_PROGRAM_NAME = "nvidia-installer" -NVIDIA_INSTALLER_VERSION = "1.0.7" -NCURSES_UI = nvidia-installer-ncurses-ui.so -NCURSES_UI_C = g_$(NCURSES_UI:.so=.c) +NVIDIA_INSTALLER_VERSION := $(NVIDIA_VERSION) -TLS_TEST_C = g_tls_test.c -TLS_TEST_DSO_C = g_tls_test_dso.c -TLS_TEST = tls_test_$(INSTALLER_OS)-$(INSTALLER_ARCH) -TLS_TEST_DSO_SO = tls_test_dso_$(INSTALLER_OS)-$(INSTALLER_ARCH).so +NCURSES_UI_C = ncurses-ui.c +NCURSES_UI_SO = $(OUTPUTDIR)/nvidia-installer-ncurses-ui.so +NCURSES_UI_SO_C = $(OUTPUTDIR)/g_$(notdir $(NCURSES_UI_SO:.so=.c)) -TLS_TEST_32_C = g_tls_test_32.c -TLS_TEST_DSO_32_C = g_tls_test_dso_32.c -TLS_TEST_32 = tls_test_$(INSTALLER_OS)-x86 -TLS_TEST_DSO_SO_32 = tls_test_dso_$(INSTALLER_OS)-x86.so +TLS_TEST_C = $(OUTPUTDIR)/g_tls_test.c +TLS_TEST_DSO_C = $(OUTPUTDIR)/g_tls_test_dso.c +TLS_TEST = tls_test_$(TARGET_OS)-$(TARGET_ARCH) +TLS_TEST_DSO_SO = tls_test_dso_$(TARGET_OS)-$(TARGET_ARCH).so -RTLD_TEST_C = g_rtld_test.c -RTLD_TEST = rtld_test_$(INSTALLER_OS)-$(INSTALLER_ARCH) +TLS_TEST_32_C = $(OUTPUTDIR)/g_tls_test_32.c +TLS_TEST_DSO_32_C = $(OUTPUTDIR)/g_tls_test_dso_32.c +TLS_TEST_32 = tls_test_$(TARGET_OS)-x86 +TLS_TEST_DSO_SO_32 = tls_test_dso_$(TARGET_OS)-x86.so -RTLD_TEST_32_C = g_rtld_test_32.c -RTLD_TEST_32 = rtld_test_$(INSTALLER_OS)-x86 +RTLD_TEST_C = $(OUTPUTDIR)/g_rtld_test.c +RTLD_TEST = rtld_test_$(TARGET_OS)-$(TARGET_ARCH) -GEN_UI_ARRAY = ./gen-ui-array -CONFIG_H = config.h -STAMP_C = g_stamp.c +RTLD_TEST_32_C = $(OUTPUTDIR)/g_rtld_test_32.c +RTLD_TEST_32 = rtld_test_$(TARGET_OS)-x86 -MANPAGE = nvidia-installer.1 +GEN_UI_ARRAY = $(OUTPUTDIR)/gen-ui-array +CONFIG_H = $(OUTPUTDIR)/config.h -DRIVER_VERSION=$(shell cat DRIVER_VERSION) +MANPAGE = $(OUTPUTDIR)/nvidia-installer.1.gz +GEN_MANPAGE_OPTS = $(OUTPUTDIR)/gen-manpage-opts +OPTIONS_1_INC = $(OUTPUTDIR)/options.1.inc # Setup some architecture specific build options -ifeq ($(INSTALLER_OS)-$(INSTALLER_ARCH), Linux-x86_64) -TLS_MODEL=initial-exec -PIC=-fPIC -CFLAGS += -DNV_X86_64 -# Only Linux-x86_64 needs the tls_test_32 files -COMPAT_32_SRC = $(TLS_TEST_32_C) $(TLS_TEST_DSO_32_C) \ - $(RTLD_TEST_32_C) +ifeq ($(TARGET_OS)-$(TARGET_ARCH), Linux-x86_64) + TLS_MODEL = initial-exec + PIC = -fPIC + CFLAGS += -DNV_X86_64 + # Only Linux-x86_64 needs the tls_test_32 files + COMPAT_32_SRC = $(TLS_TEST_32_C) $(TLS_TEST_DSO_32_C) \ + $(RTLD_TEST_32_C) else -# So far all other platforms use local-exec -TLS_MODEL=local-exec -PIC= -# Non-Linux-x86_64 platforms do not include the tls_test_32 files -COMPAT_32_SRC = + # So far all other platforms use local-exec + TLS_MODEL = local-exec + PIC = + # Non-Linux-x86_64 platforms do not include the tls_test_32 files + COMPAT_32_SRC = endif -SRC = backup.c \ - command-list.c \ - crc.c \ - files.c \ - format.c \ - install-from-cwd.c \ - kernel.c \ - log.c \ - misc.c \ - nvidia-installer.c \ - precompiled.c \ - snarf-ftp.c \ - snarf-http.c \ - snarf.c \ - stream-ui.c \ - update.c \ - user-interface.c \ - help-args.c \ - string-utils.c \ - alloc-utils.c \ - sanity.c - -ALL_SRC = $(SRC) $(NCURSES_UI_C) $(TLS_TEST_C) $(TLS_TEST_DSO_C) \ +# include the list of source files; defines SRC +include dist-files.mk + +INSTALLER_SRC = $(SRC) $(NCURSES_UI_SO_C) $(TLS_TEST_C) $(TLS_TEST_DSO_C) \ $(RTLD_TEST_C) $(COMPAT_32_SRC) $(STAMP_C) -OBJS = $(ALL_SRC:.c=.o) +INSTALLER_OBJS = $(call BUILD_OBJECT_LIST,$(INSTALLER_SRC)) -ALL_CFLAGS = -I. $(CFLAGS) -imacros $(CONFIG_H) -ALL_LDFLAGS = -L. -ldl $(LDFLAGS) +CFLAGS += -I. -imacros $(CONFIG_H) -I $(OUTPUTDIR) +HOST_CFLAGS += -I. -imacros $(CONFIG_H) -I $(OUTPUTDIR) +LDFLAGS += -L. -ldl MKPRECOMPILED_SRC = crc.c mkprecompiled.c -MKPRECOMPILED_OBJS = $(MKPRECOMPILED_SRC:.c=.o) +MKPRECOMPILED_OBJS = $(call BUILD_OBJECT_LIST,$(MKPRECOMPILED_SRC)) + +MAKESELF_HELP_SCRIPT_SRC = makeself-help-script.c \ + help-args.c \ + format.c \ + string-utils.c \ + alloc-utils.c + +BUILD_MAKESELF_OBJECT_LIST = \ + $(patsubst %.o,%.makeself.o,$(call BUILD_OBJECT_LIST,$(1))) + +MAKESELF_HELP_SCRIPT_OBJS = \ + $(call BUILD_MAKESELF_OBJECT_LIST,$(MAKESELF_HELP_SCRIPT_SRC)) + +ALL_SRC = $(sort $(INSTALLER_SRC) $(NCURSES_UI_C) $(MKPRECOMPILED_SRC)) + +# define a quiet rule for GEN-UI-ARRAY +quiet_GEN_UI_ARRAY = GEN-UI-ARRAY $@ -MAKESELF_HELP_SCRIPT_SRC = makeself-help-script.c \ - help-args.c \ - format.c \ - string-utils.c \ - alloc-utils.c -MAKESELF_HELP_SCRIPT_OBJS = $(MAKESELF_HELP_SCRIPT_SRC:.c=.o) -# and now, the build rules: +############################################################################## +# build rules +############################################################################## -default: all +.PNONY: all install NVIDIA_INSTALLER_install MKPRECOMPILED_install \ + MANPAGE_install MAKESELF_HELP_SCRIPT_install clean clobber all: $(NVIDIA_INSTALLER) $(MKPRECOMPILED) $(MAKESELF_HELP_SCRIPT) $(MANPAGE) @@ -187,102 +146,116 @@ install: NVIDIA_INSTALLER_install MKPRECOMPILED_install MANPAGE_install \ MAKESELF_HELP_SCRIPT_install NVIDIA_INSTALLER_install: $(NVIDIA_INSTALLER) - $(STRIP) $< - $(INSTALL) $< $(bindir)/$< + $(MKDIR) $(bindir) + $(INSTALL) $(INSTALL_BIN_ARGS) $< $(bindir)/$(notdir $<) MKPRECOMPILED_install: $(MKPRECOMPILED) - $(INSTALL) $< $(bindir)/$< + $(MKDIR) $(bindir) + $(INSTALL) $(INSTALL_BIN_ARGS) $< $(bindir)/$(notdir $<) MAKESELF_HELP_SCRIPT_install: $(MAKESELF_HELP_SCRIPT) - $(INSTALL) $< $(bindir)/$< + $(MKDIR) $(bindir) + $(INSTALL) $(INSTALL_BIN_ARGS) $< $(bindir)/$(notdir $<) MANPAGE_install: $(MANPAGE) - mkdir -p $(mandir) - $(INSTALL) -m 644 $< $(mandir)/$< - gzip -9f $(mandir)/$(MANPAGE) + $(MKDIR) $(mandir) + $(INSTALL) $(INSTALL_DOC_ARGS) $< $(mandir)/$(notdir $<) -$(MKPRECOMPILED): $(CONFIG_H) $(MKPRECOMPILED_OBJS) - $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(MKPRECOMPILED_OBJS) -o $@ +$(MKPRECOMPILED): $(MKPRECOMPILED_OBJS) + $(call quiet_cmd,LINK) -o $@ \ + $(MKPRECOMPILED_OBJS) $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS) + $(call quiet_cmd,STRIP_CMD) $@ -$(MAKESELF_HELP_SCRIPT): $(CONFIG_H) $(MAKESELF_HELP_SCRIPT_OBJS) - $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(MAKESELF_HELP_SCRIPT_OBJS) -o $@ +$(MAKESELF_HELP_SCRIPT): $(MAKESELF_HELP_SCRIPT_OBJS) + $(call quiet_cmd,HOST_LINK) -o $@ \ + $(MAKESELF_HELP_SCRIPT_OBJS) $(HOST_CFLAGS) $(HOST_LDFLAGS) \ + $(HOST_BIN_LDFLAGS) + $(call quiet_cmd,STRIP_CMD) $@ -$(NVIDIA_INSTALLER): $(CONFIG_H) $(OBJS) - $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OBJS) -Wl,-Bstatic -lpci -Wl,-Bdynamic -o $@ - -$(NCURSES_UI_C): $(GEN_UI_ARRAY) $(NCURSES_UI) - $(GEN_UI_ARRAY) $(NCURSES_UI) ncurses_ui_array > $@ +$(NVIDIA_INSTALLER): $(INSTALLER_OBJS) + $(call quiet_cmd,LINK) -o $@ $(INSTALLER_OBJS) $(CFLAGS) $(LDFLAGS) \ + -Bstatic $(PCI_LDFLAGS) -lpci -Bdynamic $(BIN_LDFLAGS) + $(call quiet_cmd,STRIP_CMD) $@ $(GEN_UI_ARRAY): gen-ui-array.c $(CONFIG_H) - $(HOST_CC) $(ALL_CFLAGS) $< -o $@ + $(call quiet_cmd,HOST_CC) -o $@ $< $(HOST_CFLAGS) $(HOST_LDFLAGS) \ + $(HOST_BIN_LDFLAGS) + +$(NCURSES_UI_SO): $(call BUILD_OBJECT_LIST,ncurses-ui.c) + $(call quiet_cmd,LINK) -o $@ -shared $< \ + $(NCURSES_LDFLAGS) -lncurses \ + $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS) -$(NCURSES_UI): ncurses-ui.o - $(CC) -o $@ -shared ncurses-ui.o -lncurses +$(NCURSES_UI_SO_C): $(GEN_UI_ARRAY) $(NCURSES_UI_SO) + $(call quiet_cmd,GEN_UI_ARRAY) $(NCURSES_UI_SO) ncurses_ui_array > $@ $(TLS_TEST_C): $(GEN_UI_ARRAY) $(TLS_TEST) - $(GEN_UI_ARRAY) $(TLS_TEST) tls_test_array > $@ + $(call quiet_cmd,GEN_UI_ARRAY) $(TLS_TEST) tls_test_array > $@ $(TLS_TEST_DSO_C): $(GEN_UI_ARRAY) $(TLS_TEST_DSO_SO) - $(GEN_UI_ARRAY) $(TLS_TEST_DSO_SO) tls_test_dso_array > $@ + $(call quiet_cmd,GEN_UI_ARRAY) \ + $(TLS_TEST_DSO_SO) tls_test_dso_array > $@ $(TLS_TEST_32_C): $(GEN_UI_ARRAY) $(TLS_TEST_32) - $(GEN_UI_ARRAY) $(TLS_TEST_32) tls_test_array_32 > $@ + $(call quiet_cmd,GEN_UI_ARRAY) $(TLS_TEST_32) tls_test_array_32 > $@ $(TLS_TEST_DSO_32_C): $(GEN_UI_ARRAY) $(TLS_TEST_DSO_SO_32) - $(GEN_UI_ARRAY) $(TLS_TEST_DSO_SO_32) tls_test_dso_array_32 > $@ + $(call quiet_cmd,GEN_UI_ARRAY) \ + $(TLS_TEST_DSO_SO_32) tls_test_dso_array_32 > $@ $(RTLD_TEST_C): $(GEN_UI_ARRAY) $(RTLD_TEST) - $(GEN_UI_ARRAY) $(RTLD_TEST) rtld_test_array > $@ + $(call quiet_cmd,GEN_UI_ARRAY) $(RTLD_TEST) rtld_test_array > $@ $(RTLD_TEST_32_C): $(GEN_UI_ARRAY) $(RTLD_TEST_32) - $(GEN_UI_ARRAY) $(RTLD_TEST_32) rtld_test_array_32 > $@ + $(call quiet_cmd,GEN_UI_ARRAY) $(RTLD_TEST_32) rtld_test_array_32 > $@ + +# misc.c includes pci.h +$(call BUILD_OBJECT_LIST,misc.c): CFLAGS += $(PCI_CFLAGS) + +# ncurses-ui.c includes ncurses.h +$(call BUILD_OBJECT_LIST,ncurses-ui.c): CFLAGS += $(NCURSES_CFLAGS) -fPIC -ncurses-ui.o: ncurses-ui.c $(CONFIG_H) - $(CC) -c $(ALL_CFLAGS) $< -fPIC -o $@ +# define the rule to build each object file +$(foreach src,$(ALL_SRC),$(eval $(call DEFINE_OBJECT_RULE,CC,$(src)))) -%.o: %.c $(CONFIG_H) - $(CC) -c $(ALL_CFLAGS) $< -o $@ +# define a rule to build each makeself-help-script object file +$(foreach src,$(MAKESELF_HELP_SCRIPT_SRC),\ + $(eval $(call DEFINE_OBJECT_RULE_WITH_OBJECT_NAME,HOST_CC,$(src),\ + $(call BUILD_MAKESELF_OBJECT_LIST,$(src))))) -%.d: %.c - @set -e; $(CC) -MM $(CPPFLAGS) $< \ - | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \ - [ -s $@ ] || rm -f $@ +# define the rule to generate $(STAMP_C) +$(eval $(call DEFINE_STAMP_C_RULE, $(INSTALLER_OBJS),$(NVIDIA_INSTALLER_PROGRAM_NAME))) $(CONFIG_H): - @ rm -f $@ - @ echo "#define INSTALLER_OS \"$(INSTALLER_OS)\"" >> $@ - @ echo "#define INSTALLER_ARCH \"$(INSTALLER_ARCH)\"" >> $@ - @ echo -n "#define NVIDIA_INSTALLER_VERSION " >> $@ - @ echo "\"$(NVIDIA_INSTALLER_VERSION)\"" >> $@ - @ echo -n "#define PROGRAM_NAME " >> $@ - @ echo "\"$(NVIDIA_INSTALLER_PROGRAM_NAME)\"" >> $@ - -$(STAMP_C): $(filter-out $(STAMP_C:.c=.o), $(OBJS)) - @ rm -f $@ - @ echo -n "const char NV_ID[] = \"nvidia id: " >> $@ - @ echo -n "$(NVIDIA_INSTALLER_PROGRAM_NAME): " >> $@ - @ echo -n "version $(NVIDIA_INSTALLER_VERSION) " >> $@ - @ echo -n "($(shell whoami)@$(shell hostname)) " >> $@ - @ echo "$(shell date)\";" >> $@ - @ echo "const char *pNV_ID = NV_ID + 11;" >> $@ + @ $(RM) -f $@ + @ $(MKDIR) $(OUTPUTDIR) + @ $(ECHO) "#define INSTALLER_OS \"$(TARGET_OS)\"" >> $@ + @ $(ECHO) "#define INSTALLER_ARCH \"$(TARGET_ARCH)\"" >> $@ + @ $(ECHO) -n "#define NVIDIA_INSTALLER_VERSION " >> $@ + @ $(ECHO) "\"$(NVIDIA_INSTALLER_VERSION)\"" >> $@ + @ $(ECHO) -n "#define PROGRAM_NAME " >> $@ + @ $(ECHO) "\"$(NVIDIA_INSTALLER_PROGRAM_NAME)\"" >> $@ + +$(call BUILD_OBJECT_LIST,$(ALL_SRC)): $(CONFIG_H) +$(call BUILD_MAKESELF_OBJECT_LIST,$(MAKESELF_HELP_SCRIPT_SRC)): $(CONFIG_H) clean clobber: - rm -rf $(NVIDIA_INSTALLER) $(MKPRECOMPILED) $(MAKESELF_HELP_SCRIPT) \ - $(NCURSES_UI) $(NCURSES_UI_C) \ - $(TLS_TEST_C) $(TLS_TEST_DSO_C) $(RTLD_TEST_C) $(COMPAT_32_SRC) \ - $(GEN_UI_ARRAY) $(CONFIG_H) $(STAMP_C) *.o *~ *.d \ - $(MANPAGE) gen-manpage-opts options.1.inc + rm -rf $(OUTPUTDIR) + +############################################################################## # rule to rebuild tls_test and tls_test_dso; a precompiled tls_test # and tls_test_dso is distributed with nvidia_installer because they # require a recent toolchain to build. +############################################################################## rebuild_tls_test: tls_test.c gcc -Wall -O2 -fomit-frame-pointer -o $(TLS_TEST) -ldl $< strip $(TLS_TEST) rebuild_tls_test_dso: tls_test_dso.c - gcc -Wall -O2 $(PIC) -fomit-frame-pointer -c $< -ftls-model=$(TLS_MODEL) + gcc -Wall -O2 $(PIC) -fomit-frame-pointer -c $< \ + -ftls-model=$(TLS_MODEL) gcc -o $(TLS_TEST_DSO_SO) -shared tls_test_dso.o strip $(TLS_TEST_DSO_SO) @@ -305,35 +278,34 @@ rebuild_rtld_test: rtld_test.c rtld_test: rtld_test.c touch $@ -print_version: - @ echo $(NVIDIA_INSTALLER_VERSION) - -### Documentation +############################################################################## +# Documentation +############################################################################## AUTO_TEXT = ".\\\" WARNING: THIS FILE IS AUTO-GENERATED! Edit $< instead." doc: $(MANPAGE) -gen-manpage-opts.o: gen-manpage-opts.c $(CONFIG_H) - $(HOST_CC) $(ALL_CFLAGS) -c $< +$(eval $(call DEFINE_OBJECT_RULE,HOST_CC,gen-manpage-opts.c)) -gen-manpage-opts: gen-manpage-opts.o - $(HOST_CC) $(CFLAGS) $^ $(ALL_LDFLAGS) -o $@ +$(call BUILD_OBJECT_LIST,gen-manpage-opts.c): $(CONFIG_H) --include gen-manpage-opts.d +$(GEN_MANPAGE_OPTS): $(call BUILD_OBJECT_LIST,gen-manpage-opts.c) + $(call quiet_cmd,HOST_LINK) $< -o $@ \ + $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_BIN_LDFLAGS) -options.1.inc: gen-manpage-opts - ./$< > $@ +$(OPTIONS_1_INC): $(GEN_MANPAGE_OPTS) + @./$< > $@ -nvidia-installer.1: nvidia-installer.1.m4 options.1.inc DRIVER_VERSION - m4 -D__HEADER__=$(AUTO_TEXT) \ +$(MANPAGE): nvidia-installer.1.m4 $(OPTIONS_1_INC) + $(call quiet_cmd,M4) \ + -D__HEADER__=$(AUTO_TEXT) \ -D__VERSION__=$(NVIDIA_INSTALLER_VERSION) \ - -D__INSTALLER_OS__="$(INSTALLER_OS)" \ - -D__INSTALLER_ARCH__="$(INSTALLER_ARCH)" \ - -D__DRIVER_VERSION__="$(DRIVER_VERSION)" \ - $< > $@ - -### - --include $(SRC:.c=.d) + -D__DATE__="`$(DATE) +%F`" \ + -D__INSTALLER_OS__="$(TARGET_OS)" \ + -D__INSTALLER_ARCH__="$(TARGET_ARCH)" \ + -D__DRIVER_VERSION__="$(NVIDIA_VERSION)" \ + -D__OUTPUTDIR__=$(OUTPUTDIR) \ + -I $(OUTPUTDIR) \ + $< | $(GZIP_CMD) -9f > $@ diff --git a/command-list.c b/command-list.c index dcaeae2..a83908d 100644 --- a/command-list.c +++ b/command-list.c @@ -56,7 +56,7 @@ static void find_conflicting_xfree86_libraries(Options *, FileList *); static void find_conflicting_xfree86_libraries_fullpath(Options *op, - const char *, + char *, FileList *l); static void find_conflicting_opengl_libraries(Options *, @@ -565,7 +565,7 @@ static void find_conflicting_libraries(Options *op, FileList *l); static ConflictingFileInfo __xfree86_libs[] = { - { "libGLcore.", 10, /* strlen("libGLcore.") */ NULL }, + { "libnvidia-glcore.", 17, /* strlen("libnvidia-glcore.") */ NULL }, { "libGL.", 6, /* strlen("libGL.") */ NULL }, { "libGLwrapper.", 13, /* strlen("libGLwrapper.") */ NULL }, { "libglx.", 7, /* strlen("libglx.") */ "glxModuleData" }, @@ -605,17 +605,17 @@ static void find_conflicting_xfree86_libraries(Options *op, */ static void find_conflicting_xfree86_libraries_fullpath(Options *op, - const char *path, + char *path, FileList *l) { - find_conflicting_files(op, (char *) path, __xfree86_libs, l); + find_conflicting_files(op, path, __xfree86_libs, l); } /* find_conflicting_xfree86_libraries_fullpath() */ static ConflictingFileInfo __opengl_libs[] = { - { "libGLcore.", 10, /* strlen("libGLcore.") */ NULL }, + { "libnvidia-glcore.", 17, /* strlen("libnvidia-glcore.") */ NULL }, { "libGL.", 6, /* strlen("libGL.") */ NULL }, { "libnvidia-tls.", 14, /* strlen("libnvidia-tls.") */ NULL }, { "libGLwrapper.", 13, /* strlen("libGLwrapper.") */ NULL }, diff --git a/dist-files.mk b/dist-files.mk index fd63379..430ebf7 100644 --- a/dist-files.mk +++ b/dist-files.mk @@ -39,6 +39,7 @@ SRC += install-from-cwd.c SRC += kernel.c SRC += log.c SRC += misc.c +SRC += nvgetopt.c SRC += nvidia-installer.c SRC += precompiled.c SRC += snarf-ftp.c @@ -61,6 +62,7 @@ DIST_FILES += files.h DIST_FILES += format.h DIST_FILES += kernel.h DIST_FILES += misc.h +DIST_FILES += nvgetopt.h DIST_FILES += nvidia-installer-ui.h DIST_FILES += nvidia-installer.h DIST_FILES += option_table.h @@ -95,6 +97,7 @@ DIST_FILES += rtld_test.c DIST_FILES += nvidia-installer.1.m4 DIST_FILES += gen-manpage-opts.c +DIST_FILES += makeself-help-script.c DIST_FILES += gen-ui-array.c DIST_FILES += ncurses-ui.c @@ -1492,7 +1492,7 @@ int pack_precompiled_kernel_interface(Options *op, Package *p) /* build the mkprecompiled command */ - cmd = nvstrcat("./usr/bin/mkprecompiled --interface=", + cmd = nvstrcat("./mkprecompiled --interface=", p->kernel_module_build_directory, "/", PRECOMPILED_KERNEL_INTERFACE_FILENAME, " --output=", p->precompiled_kernel_interface_directory, diff --git a/gen-manpage-opts.c b/gen-manpage-opts.c index 440502e..c821a31 100644 --- a/gen-manpage-opts.c +++ b/gen-manpage-opts.c @@ -8,7 +8,7 @@ #include "nvidia-installer.h" #include "option_table.h" -static void print_option(const NVOption *o) +static void print_option(const NVGetoptOption *o) { char scratch[64], *s; int j, len; @@ -18,7 +18,7 @@ static void print_option(const NVOption *o) printf(".TP\n.BI "); /* Print the name of the option */ /* XXX We should backslashify the '-' characters in o->name. */ - if (o->flags & NVOPT_IS_BOOLEAN) { + if (o->flags & NVGETOPT_IS_BOOLEAN) { /* "\-\-name, \-\-no\-name */ printf("\"\\-\\-%s, \\-\\-no\\-%s", o->name, o->name); } else if (isalnum(o->val)) { @@ -29,7 +29,7 @@ static void print_option(const NVOption *o) printf("\"\\-\\-%s", o->name); } - if (o->flags & NVOPT_HAS_ARGUMENT) { + if (o->flags & NVGETOPT_HAS_ARGUMENT) { len = strlen(o->name); for (j = 0; j < len; j++) scratch[j] = toupper(o->name[j]); scratch[len] = '\0'; @@ -87,7 +87,7 @@ static void print_option(const NVOption *o) int main(int argc, char* argv[]) { int i; - const NVOption *o; + const NVGetoptOption *o; /* Print the "simple" options, i.e. the ones you get by running * nvidia-installer --help. @@ -96,7 +96,7 @@ int main(int argc, char* argv[]) for (i = 0; __options[i].name; i++) { o = &__options[i]; - if (!(o->flags & OPTION_HELP_ALWAYS)) + if (!(o->flags & NVGETOPT_HELP_ALWAYS)) continue; if (!o->description) @@ -110,7 +110,7 @@ int main(int argc, char* argv[]) for (i = 0; __options[i].name; i++) { o = &__options[i]; - if (o->flags & OPTION_HELP_ALWAYS) + if (o->flags & NVGETOPT_HELP_ALWAYS) continue; if (!o->description) diff --git a/help-args.c b/help-args.c index 15b92b2..08db884 100644 --- a/help-args.c +++ b/help-args.c @@ -72,7 +72,7 @@ void print_help_args_only(int args_only, int advanced) { int i, j, len; char *msg, *tmp, scratch[64]; - const NVOption *o; + const NVGetoptOption *o; /* * the args_only parameter is used by makeself.sh to get our @@ -90,12 +90,12 @@ void print_help_args_only(int args_only, int advanced) * not set, then skip this option */ - if (!advanced && !(o->flags & OPTION_HELP_ALWAYS)) continue; + if (!advanced && !(o->flags & NVGETOPT_HELP_ALWAYS)) continue; /* Skip options with no help text */ if (!o->description) continue; - if (o->flags & NVOPT_IS_BOOLEAN) { + if (o->flags & NVGETOPT_IS_BOOLEAN) { msg = nvstrcat("--", o->name, "/--no-", o->name, NULL); } else if (isalnum(o->val)) { sprintf(scratch, "%c", o->val); @@ -103,7 +103,7 @@ void print_help_args_only(int args_only, int advanced) } else { msg = nvstrcat("--", o->name, NULL); } - if (o->flags & NVOPT_HAS_ARGUMENT) { + if (o->flags & NVGETOPT_HAS_ARGUMENT) { len = strlen(o->name); for (j = 0; j < len; j++) scratch[j] = toupper(o->name[j]); scratch[len] = '\0'; diff --git a/libpci.a b/libpci.a Binary files differdeleted file mode 100755 index 0082fd1..0000000 --- a/libpci.a +++ /dev/null diff --git a/makefile.nvmk b/makefile.nvmk deleted file mode 100644 index 2a94e8c..0000000 --- a/makefile.nvmk +++ /dev/null @@ -1,183 +0,0 @@ -############################################################################## -# drivers/setup/linux/nvidia-installer/makefile.nvmk -############################################################################## - -############################################################################## -# Identify this module to nvCommon.nvmk so it can decide the build type -############################################################################## - -NV_MODULE_BUILD_TYPE_ALIASES = utils - -include $(NV_SOURCE)/drivers/common/build/nvCommon.nvmk - - -############################################################################## -# string to prepend in unix builds when executing rules in this gmake instance -############################################################################## - -export NV_MODULE_LOGGING_NAME = "nvidia-installer" - - -############################################################################## -# export the appropriate variables from nvmake to the gmake that we're -# going to invoke -############################################################################## - -$(eval $(EXPORT_VARIABLES_TO_PUBLIC_MAKEFILE)) - -_ncurses_dir = $(NV_TOOLS)/unix/targets/$(NV_TARGET_OS)-$(NV_TARGET_ARCH_UNIX_TOOLS)/ncurses-5.5 - -NCURSES_INCLUDE_DIR = $(_ncurses_dir)/include -NCURSES_LIB_DIR = $(_ncurses_dir)/lib - -export NCURSES_CFLAGS = -I$(NCURSES_INCLUDE_DIR) -export NCURSES_LDFLAGS = -L$(NCURSES_LIB_DIR) - -_pci_dir = $(NV_TOOLS)/unix/targets/$(NV_TARGET_OS)-$(NV_TARGET_ARCH_UNIX_TOOLS)/pciutils-2.2.1 - -PCI_INCLUDE_DIR = $(_pci_dir)/include -PCI_LIB_DIR = $(_pci_dir)/lib - -export PCI_CFLAGS = -I$(PCI_INCLUDE_DIR) -export PCI_LDFLAGS = -L$(PCI_LIB_DIR) - -export OUTPUTDIR - -export NV_AUTO_DEPEND -export NV_VERBOSE - -# for utils.mk -NV_MAKE_ARGS = -I $(NV_SOURCE)/drivers/setup/linux/common - - -############################################################################## -# check that all the directories that we exported above actually -# exist; trigger a warning if any of them don't exist -############################################################################## - -_extra_dirs += $(NCURSES_INCLUDE_DIR) -_extra_dirs += $(NCURSES_LIB_DIR) -_extra_dirs += $(PCI_INCLUDE_DIR) -_extra_dirs += $(PCI_LIB_DIR) - -build :: $(_extra_dirs) - -$(sort $(_extra_dirs)) : - @$(ECHO) WARNING: nvidia-installer extra directory does not exist: $@ - - -############################################################################## -# generate the legacy GPU header file -############################################################################## - -_nv_common_inc = $(NV_SOURCE)/drivers/common/inc -_nv_sdk_inc = $(NV_SOURCE)/sdk/nvidia/inc - -NV_NAME_H = $(_nv_common_inc)/nv_name.h -NV_CHIPFLAGS_H = $(_nv_common_inc)/nvChipFlags.h -NV_CHIPUTILS_H = $(_nv_common_inc)/nvChipUtils.h -NV_MISC_H = $(_nv_sdk_inc)/nvmisc.h - -NV_LEGACY_H = $(OUTPUTDIR)/nvLegacy.h - -NV_LEGACY_GENERATOR = $(OUTPUTDIR)/nvLegacyGenerator - -NV_LEGACY_GENERATOR_HEADER_DEPS = \ - $(NV_NAME_H) $(NV_CHIPFLAGS_H) $(NV_CHIPUTILS_H) $(NV_MISC_H) - -NV_LEGACY_GENERATOR_INCLUDE_CFLAGS = \ - $(addprefix -I,$(sort $(dir $(NV_LEGACY_GENERATOR_HEADER_DEPS)))) - -$(NV_LEGACY_GENERATOR): ../nvLegacy.c $(NV_LEGACY_GENERATOR_HEADER_DEPS) - $(call quiet_cmd,HOST_CC) $< -o $@ \ - $(NV_LEGACY_GENERATOR_INCLUDE_CFLAGS) $(HOST_LDFLAGS) $(HOST_BIN_LDFLAGS) - -$(NV_LEGACY_H): $(NV_LEGACY_GENERATOR) - ./$(NV_LEGACY_GENERATOR) > $@ - -OTHER_FILES_TO_REMOVE += $(NV_LEGACY_H) $(NV_LEGACY_GENERATOR) - - -############################################################################## -# define how to package the nvidia-installer source tarball -############################################################################## - -.PHONY: dist-tarball - -# include the list of nvidia-installer source files; defines DIST_FILES -include dist-files.mk - -NVIDIA_INSTALLER_DISTDIR_NO_OUTPUTDIR = nvidia-installer-$(NV_PACKAGE_FILENAME_VERSION_STRING) -NVIDIA_INSTALLER_DISTDIR = $(OUTPUTDIR)/$(NVIDIA_INSTALLER_DISTDIR_NO_OUTPUTDIR) -NVIDIA_INSTALLER_TARBALL_NO_OUTPUTDIR = $(NVIDIA_INSTALLER_DISTDIR_NO_OUTPUTDIR).tar.bz2 -NVIDIA_INSTALLER_TARBALL = $(NVIDIA_INSTALLER_DISTDIR).tar.bz2 - -ifeq ($(NV_VERBOSE),1) - _tar_verbose_arg = -v -else - _tar_verbose_arg = -endif - -# define rules to copy files from the source tree to -# $(NVIDIA_INSTALLER_DISTDIR) - -$(eval $(call ADD_FILE_TO_TARBALL_RULE, \ - public.mk, \ - $(NVIDIA_INSTALLER_DISTDIR)/Makefile, \ - $(NVIDIA_INSTALLER_TARBALL))) - -$(eval $(call ADD_FILE_TO_TARBALL_RULE, \ - $(OUTPUTDIR)/version.mk, \ - $(NVIDIA_INSTALLER_DISTDIR)/version.mk, \ - $(NVIDIA_INSTALLER_TARBALL))) - -$(eval $(call ADD_FILE_TO_TARBALL_RULE, \ - $(NV_SOURCE)/drivers/setup/linux/common/utils.mk, \ - $(NVIDIA_INSTALLER_DISTDIR)/utils.mk, \ - $(NVIDIA_INSTALLER_TARBALL))) - -$(eval $(call ADD_FILE_TO_TARBALL_RULE, \ - $(NV_LEGACY_H), \ - $(NVIDIA_INSTALLER_DISTDIR)/$(notdir $(NV_LEGACY_H)), \ - $(NVIDIA_INSTALLER_TARBALL))) - -$(foreach src, $(DIST_FILES), \ - $(eval $(call ADD_FILE_TO_TARBALL_RULE, \ - $(src), \ - $(NVIDIA_INSTALLER_DISTDIR)/$(src), \ - $(NVIDIA_INSTALLER_TARBALL)))) - -$(NVIDIA_INSTALLER_TARBALL): - @$(ECHO) "Generating $(OUTPUTDIR)/$(NVIDIA_INSTALLER_TARBALL)" - $(RM) $(OUTPUTDIR)/tar-file-list.txt - for i in $(patsubst $(OUTPUTDIR)/%,%,$(TARBALL_FILE_LIST_$@)); do \ - $(ECHO) $${i} >> $(OUTPUTDIR)/tar-file-list.txt; \ - done - cd $(OUTPUTDIR) && \ - PATH=/bin $(TAR) -c -j $(_tar_verbose_arg) -f \ - $(NVIDIA_INSTALLER_TARBALL_NO_OUTPUTDIR) \ - --files-from=tar-file-list.txt - $(RM) $(OUTPUTDIR)/tar-file-list.txt - -dist-tarball: $(NVIDIA_INSTALLER_TARBALL) - -OTHER_FILES_TO_REMOVE += $(NVIDIA_INSTALLER_DISTDIR) -OTHER_FILES_TO_REMOVE += $(NVIDIA_INSTALLER_TARBALL) - - -############################################################################## -# to actually build nvidia-settings, hand off control to the public makefile -############################################################################## - -$(eval $(DEFINE_VERSION_MK_RULE)) - -build:: $(OUTPUTDIR)/version.mk $(NV_LEGACY_H) - $(MAKE) $(NV_MAKE_ARGS) -f public.mk $@ - - -############################################################################## -# define the compiler and include the common rules -############################################################################## - -include $(NV_SOURCE)/drivers/common/build/gcc-4.1.1as2.nvmk -include $(NV_SOURCE)/drivers/common/build/nvCommonRules.nvmk diff --git a/nvgetopt.c b/nvgetopt.c new file mode 100644 index 0000000..efce012 --- /dev/null +++ b/nvgetopt.c @@ -0,0 +1,231 @@ +/* + * nvidia-installer: A tool for installing NVIDIA software packages on + * Unix and Linux systems. + * + * Copyright (C) 2010 NVIDIA Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the: + * + * Free Software Foundation, Inc. + * 59 Temple Place - Suite 330 + * Boston, MA 02111-1307, USA + * + * + * nvgetopt.c - portable getopt_long() replacement; removes the need + * for the stupid optstring argument. + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include "nvgetopt.h" + + +/* + * nvgetopt() - see the glibc getopt_long(3) manpage for usage + * description. Options can be prepended with "--" or "-". + * + * A global variable stores the current index into the argv array, so + * subsequent calls to nvgetopt() will advance through argv[]. + * + * On success, the matching NVGetoptOption.val is returned. + * + * On failure, an error is printed to stderr, and 0 is returned. + * + * When there are no more options to parse, -1 is returned. + */ + +int nvgetopt(int argc, char *argv[], const NVGetoptOption *options, + char **strval) +{ + char *c, *a, *arg, *name = NULL, *argument=NULL; + int i, found = NVGETOPT_FALSE, ret = 0; + const NVGetoptOption *o = NULL; + static int argv_index = 0; + + argv_index++; + + /* if no more options, return -1 */ + + if (argv_index >= argc) return -1; + + /* get the argument in question */ + + arg = strdup(argv[argv_index]); + + /* look for "--" or "-" */ + + if ((arg[0] == '-') && (arg[1] == '-')) { + name = arg + 2; + } else if (arg[0] == '-') { + name = arg + 1; + } else { + fprintf(stderr, "%s: invalid option: \"%s\"\n", argv[0], arg); + goto done; + } + + /* + * if there is an "=" in the string, then assign argument and zero + * out the equal sign so that name will match what is in the + * option table. + */ + + c = name; + while (*c) { + if (*c == '=') { argument = c + 1; *c = '\0'; break; } + c++; + } + + /* + * if the string is terminated after one character, interpret it + * as a short option. Otherwise, interpret it as a long option. + */ + + if (name[1] == '\0') { /* short option */ + for (i = 0; options[i].name; i++) { + if (options[i].val == name[0]) { + o = &options[i]; + break; + } + } + } else { /* long option */ + for (i = 0; options[i].name; i++) { + if (strcmp(options[i].name, name) == 0) { + o = &options[i]; + break; + } + } + } + + /* + * if we didn't find a match, maybe this is multiple short options + * stored together; is each character a short option? + */ + + if (!o) { + for (c = name; *c; c++) { + found = NVGETOPT_FALSE; + for (i = 0; options[i].name; i++) { + if (options[i].val == *c) { + found = NVGETOPT_TRUE; + break; + } + } + if (!found) break; + } + + if (found) { + + /* + * all characters individually are short options, so + * interpret them that way + */ + + for (i = 0; options[i].name; i++) { + if (options[i].val == name[0]) { + + /* + * don't allow options with arguments to be + * processed in this way + */ + + if (options[i].flags & NVGETOPT_HAS_ARGUMENT) break; + + /* + * remove the first short option from + * argv[argv_index] + */ + + a = argv[argv_index]; + if (a[0] == '-') a++; + if (a[0] == '-') a++; + if (a[0] == '+') a++; + + while(a[0]) { a[0] = a[1]; a++; } + + /* + * decrement argv_index so that we process this + * entry again + */ + + argv_index--; + + o = &options[i]; + break; + } + } + } + } + + /* if we didn't find an option, return */ + + if (!o) { + fprintf(stderr, "%s: unrecognized option: \"%s\"\n", argv[0], arg); + goto done; + } + + /* + * if the option takes an argument string, then we either + * need to use what was after the "=" in this argv[] entry, + * or we need to pull the next entry off of argv[] + */ + + if (o->flags & NVGETOPT_HAS_ARGUMENT) { + if (argument) { + if (!argument[0]) { + fprintf(stderr, "%s: option \"%s\" requires an " + "argument.\n", argv[0], arg); + goto done; + } + } else { + argv_index++; + if (argv_index >= argc) { + fprintf(stderr, "%s: option \"%s\" requires an " + "argument.\n", argv[0], arg); + goto done; + } + argument = argv[argv_index]; + } + + /* argument is now a valid string: parse it */ + + if ((o->flags & NVGETOPT_STRING_ARGUMENT) && (strval)) { + *strval = strdup(argument); + } else { + fprintf(stderr, "%s: error while assigning argument for " + "option \"%s\".\n", argv[0], arg); + goto done; + } + + } else { + + /* if we have an argument when we shouldn't; complain */ + + if (argument) { + fprintf(stderr, "%s: option \"%s\" does not take an argument, but " + "was given an argument of \"%s\".\n", + argv[0], arg, argument); + goto done; + } + } + + ret = o->val; + +done: + + free(arg); + return ret; + +} /* nvgetopt() */ diff --git a/nvgetopt.h b/nvgetopt.h new file mode 100644 index 0000000..d7c5f1b --- /dev/null +++ b/nvgetopt.h @@ -0,0 +1,69 @@ +/* + * nvidia-installer: A tool for installing/un-installing the + * NVIDIA Linux graphics driver. + * + * Copyright (C) 2004-2010 NVIDIA Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the: + * + * Free Software Foundation, Inc. + * 59 Temple Place - Suite 330 + * Boston, MA 02111-1307, USA + * + * + * nvgetopt.h + */ + +#ifndef __NVGETOPT_H__ +#define __NVGETOPT_H__ + +#define NVGETOPT_FALSE 0 +#define NVGETOPT_TRUE 1 + +/* + * indicates that the option is a boolean value; the presence of the + * option will be interpretted as a TRUE value; if the option is + * prepended with '--no-', the option will be interpretted as a FALSE + * value. On success, nvgetopt will return the parsed boolean value + * through 'boolval'. + */ + +#define NVGETOPT_IS_BOOLEAN 0x1 + + +/* + * indicates that the option takes an argument to be interpretted as a + * string; on success, nvgetopt will return the parsed string argument + * through 'strval'. + */ + +#define NVGETOPT_STRING_ARGUMENT 0x2 + + +#define NVGETOPT_HAS_ARGUMENT (NVGETOPT_STRING_ARGUMENT) + +#define NVGETOPT_HELP_ALWAYS 0x20 + +typedef struct { + const char *name; + int val; + unsigned int flags; + char *description; /* not used by nvgetopt() */ +} NVGetoptOption; + + +int nvgetopt(int argc, char *argv[], const NVGetoptOption *options, + char **strval); + +#endif /* __NVGETOPT_H__ */ diff --git a/nvidia-installer.1.m4 b/nvidia-installer.1.m4 index 21b55ac..61c4ed6 100644 --- a/nvidia-installer.1.m4 +++ b/nvidia-installer.1.m4 @@ -1,7 +1,7 @@ dnl This file is to be preprocessed by m4. changequote([[[, ]]])dnl define(__OPTIONS__, [[[include([[[options.1.inc]]])dnl]]])dnl -.\" Copyright (C) 2005-2009 NVIDIA Corporation. +.\" Copyright (C) 2005-2010 NVIDIA Corporation. .\" __HEADER__ .\" Define the URL macro and then load the URL package if it exists. @@ -9,7 +9,7 @@ __HEADER__ \\$2 \(laURL: \\$1 \(ra\\$3 .. .if \n[.g] .mso www.tmac -.TH nvidia\-installer 1 2009-01-09 "nvidia\-installer __VERSION__" +.TH nvidia\-installer 1 "__DATE__" "nvidia\-installer __VERSION__" .SH NAME nvidia\-installer \- install, upgrade, or uninstall the NVIDIA Accelerated Graphics Driver Set .SH SYNOPSIS @@ -24,7 +24,7 @@ is a tool for installing, updating, and uninstalling the NVIDIA __INSTALLER_OS__ When the driver is installed by running, for example: .sp .ti +5 -sh NVIDIA\-__INSTALLER_OS__\-__INSTALLER_ARCH__\-__DRIVER_VERSION__\-pkg1.run +sh NVIDIA\-__INSTALLER_OS__\-__INSTALLER_ARCH__\-__DRIVER_VERSION__\.run .sp The .run file unpacks itself and invokes the contained .B nvidia\-installer @@ -149,4 +149,4 @@ NVIDIA Corporation .BR nvidia-settings (1), .I /usr/share/doc/NVIDIA_GLX-1.0/README.txt .SH COPYRIGHT -Copyright \(co 2005-2009 NVIDIA Corporation. +Copyright \(co 2005-2010 NVIDIA Corporation. diff --git a/nvidia-installer.c b/nvidia-installer.c index ecd7c39..48912f8 100644 --- a/nvidia-installer.c +++ b/nvidia-installer.c @@ -2,18 +2,18 @@ * nvidia-installer: A tool for installing NVIDIA software packages on * Unix and Linux systems. * - * Copyright (C) 2003-2009 NVIDIA Corporation + * Copyright (C) 2003-2010 NVIDIA Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the: * @@ -75,7 +75,7 @@ static void print_version(void) "The NVIDIA Accelerated Graphics Driver Set for %s-%s.", INSTALLER_OS, INSTALLER_ARCH); fmtout(""); - fmtoutp(TAB, "Copyright (C) 2003 - 2009 NVIDIA Corporation."); + fmtoutp(TAB, "Copyright (C) 2003 - 2010 NVIDIA Corporation."); fmtout(""); } @@ -98,58 +98,21 @@ static void print_help(int advanced) /* - * parse_commandline() - malloc an Options structure, initialize it, - * and fill in any pertinent data from the commandline arguments; it - * is intended that this function do only minimal sanity checking -- - * just enough error trapping to ensure correct syntax of the - * commandline options. Validation of the actual data specified - * through the options is left for the functions that use this data. + * load_default_options - Allocate an Options structure + * and initialize it with default values. * - * XXX Would it be better to do more validation now? - * - * XXX this implementation uses getopt_long(), which isn't portable to - * non-glibc based systems... */ -Options *parse_commandline(int argc, char *argv[]) +static Options *load_default_options(void) { Options *op; - int c, option_index = 0; - char *program_name; - - const int num_opts = sizeof(__options) / sizeof(__options[0]) - 1; - /* Allocate space for the long options. */ - struct option *long_options = nvalloc(num_opts * sizeof(struct option)); - /* Allocate space for the short options: leave enough room for a letter and - * ':' for each option, plus the '\0'. */ - char *short_options = nvalloc(num_opts * 2 + 1); - char *pShort = short_options; - - /* Generate the table for getopt_long and the string for the short options. */ - for (c = 0; c < num_opts; c++) { - struct option* op = &long_options[c]; - const NVOption* o = &__options[c]; - - op->name = o->name; - op->has_arg = - (o->flags & NVOPT_HAS_ARGUMENT) ? - required_argument : no_argument; - op->flag = NULL; - op->val = o->val; - - if (isalnum(o->val)) { - *pShort++ = o->val; - - if (o->flags & NVOPT_HAS_ARGUMENT) - *pShort++ = ':'; - } - } - *pShort = '\0'; op = (Options *) nvalloc(sizeof(Options)); - + if (!op) { + return NULL; + } + /* statically initialized strings */ - op->proc_mount_point = DEFAULT_PROC_MOUNT_POINT; op->log_file_name = DEFAULT_LOG_FILE_NAME; op->ftp_site = DEFAULT_FTP_SITE; @@ -165,10 +128,30 @@ Options *parse_commandline(int argc, char *argv[]) op->sigwinch_workaround = TRUE; op->run_distro_scripts = TRUE; + return op; + +} /* load_default_options() */ + + + +/* + * parse_commandline() - Populate the Options structure with + * appropriate values, based on the arguments passed at the commandline. + * It is intended that this function does only minimal sanity checking -- + * just enough error trapping to ensure correct syntax of the + * commandline options. Validation of the actual data specified + * through the options is left for the functions that use this data. + */ + +static void parse_commandline(int argc, char *argv[], Options *op) +{ + int c, boolval; + char *strval = NULL, *program_name = NULL; + while (1) { - - c = getopt_long(argc, argv, short_options, - long_options, &option_index); + + c = nvgetopt(argc, argv, __options, &strval); + if (c == -1) break; @@ -187,7 +170,7 @@ Options *parse_commandline(int argc, char *argv[]) case 'n': op->no_precompiled_interface = TRUE; break; case 'c': op->no_ncurses_color = TRUE; break; case 'l': op->latest = TRUE; break; - case 'm': op->ftp_site = optarg; break; + case 'm': op->ftp_site = strval; break; case 'f': op->update = op->force_update = TRUE; break; case 'h': print_help(FALSE); exit(0); break; case 'A': print_help(TRUE); exit(0); break; @@ -204,86 +187,81 @@ Options *parse_commandline(int argc, char *argv[]) break; case 'k': - op->kernel_name = optarg; + op->kernel_name = strval; op->no_precompiled_interface = TRUE; op->ignore_cc_version_check = TRUE; break; case XFREE86_PREFIX_OPTION: case X_PREFIX_OPTION: - op->x_prefix = optarg; break; + op->x_prefix = strval; break; case X_LIBRARY_PATH_OPTION: - op->x_library_path = optarg; break; + op->x_library_path = strval; break; case X_MODULE_PATH_OPTION: - op->x_module_path = optarg; break; + op->x_module_path = strval; break; case OPENGL_PREFIX_OPTION: - op->opengl_prefix = optarg; break; + op->opengl_prefix = strval; break; case OPENGL_LIBDIR_OPTION: - op->opengl_libdir = optarg; break; + op->opengl_libdir = strval; break; #if defined(NV_X86_64) case COMPAT32_CHROOT_OPTION: - op->compat32_chroot = optarg; break; + op->compat32_chroot = strval; break; case COMPAT32_PREFIX_OPTION: - op->compat32_prefix = optarg; break; + op->compat32_prefix = strval; break; case COMPAT32_LIBDIR_OPTION: - op->compat32_libdir = optarg; break; + op->compat32_libdir = strval; break; #endif case DOCUMENTATION_PREFIX_OPTION: - op->documentation_prefix = optarg; break; + op->documentation_prefix = strval; break; case INSTALLER_PREFIX_OPTION: - op->installer_prefix = optarg; break; + op->installer_prefix = strval; break; case UTILITY_PREFIX_OPTION: - op->utility_prefix = optarg; break; + op->utility_prefix = strval; break; case UTILITY_LIBDIR_OPTION: - op->utility_libdir = optarg; break; + op->utility_libdir = strval; break; case KERNEL_SOURCE_PATH_OPTION: - op->kernel_source_path = optarg; break; + op->kernel_source_path = strval; break; case KERNEL_OUTPUT_PATH_OPTION: - op->kernel_output_path = optarg; break; + op->kernel_output_path = strval; break; case KERNEL_INCLUDE_PATH_OPTION: - op->kernel_include_path = optarg; break; + op->kernel_include_path = strval; break; case KERNEL_INSTALL_PATH_OPTION: - op->kernel_module_installation_path = optarg; break; + op->kernel_module_installation_path = strval; break; case UNINSTALL_OPTION: op->uninstall = TRUE; break; case PROC_MOUNT_POINT_OPTION: - op->proc_mount_point = optarg; break; + op->proc_mount_point = strval; break; case USER_INTERFACE_OPTION: - op->ui_str = optarg; break; + op->ui_str = strval; break; case LOG_FILE_NAME_OPTION: - op->log_file_name = optarg; break; + op->log_file_name = strval; break; case HELP_ARGS_ONLY_OPTION: print_help_args_only(TRUE, FALSE); exit(0); break; case TMPDIR_OPTION: - op->tmpdir = optarg; break; + op->tmpdir = strval; break; case NO_OPENGL_HEADERS_OPTION: op->opengl_headers = FALSE; break; case FORCE_TLS_OPTION: - if (strcasecmp(optarg, "new") == 0) + if (strcasecmp(strval, "new") == 0) op->which_tls = FORCE_NEW_TLS; - else if (strcasecmp(optarg, "classic") == 0) + else if (strcasecmp(strval, "classic") == 0) op->which_tls = FORCE_CLASSIC_TLS; else { - fmterr(""); - fmterr("Invalid parameter for '--force-tls'; please " - "run `%s --help` for usage information.", argv[0]); - fmterr(""); - exit(1); + fmterr("\n"); + fmterr("Invalid parameter for '--force-tls'"); + goto fail; } break; #if defined(NV_X86_64) case FORCE_TLS_COMPAT32_OPTION: - if (strcasecmp(optarg, "new") == 0) + if (strcasecmp(strval, "new") == 0) op->which_tls_compat32 = FORCE_NEW_TLS; - else if (strcasecmp(optarg, "classic") == 0) + else if (strcasecmp(strval, "classic") == 0) op->which_tls_compat32 = FORCE_CLASSIC_TLS; else { - fmterr(""); - fmterr("Invalid parameter for '--force-tls-compat32'; " - "please run `%s --help` for usage information.", - argv[0]); - fmterr(""); - exit(1); + fmterr("\n"); + fmterr("Invalid parameter for '--force-tls-compat32'"); + goto fail; } break; #endif @@ -297,7 +275,7 @@ Options *parse_commandline(int argc, char *argv[]) print_help_args_only(TRUE, TRUE); exit(0); break; case RPM_FILE_LIST_OPTION: - op->rpm_file_list = optarg; + op->rpm_file_list = strval; break; case NO_RUNLEVEL_CHECK_OPTION: op->no_runlevel_check = TRUE; @@ -306,10 +284,10 @@ Options *parse_commandline(int argc, char *argv[]) op->no_network = TRUE; break; case PRECOMPILED_KERNEL_INTERFACES_PATH_OPTION: - op->precompiled_kernel_interfaces_path = optarg; + op->precompiled_kernel_interfaces_path = strval; break; case PRECOMPILED_KERNEL_INTERFACES_URL_OPTION: - op->precompiled_kernel_interfaces_url = optarg; + op->precompiled_kernel_interfaces_url = strval; break; case NO_ABI_NOTE_OPTION: op->no_abi_note = TRUE; @@ -321,21 +299,18 @@ Options *parse_commandline(int argc, char *argv[]) op->no_recursion = TRUE; break; case FORCE_SELINUX_OPTION: - if (strcasecmp(optarg, "yes") == 0) + if (strcasecmp(strval, "yes") == 0) op->selinux_option = SELINUX_FORCE_YES; - else if (strcasecmp(optarg, "no") == 0) + else if (strcasecmp(strval, "no") == 0) op->selinux_option = SELINUX_FORCE_NO; - else if (strcasecmp(optarg, "default")) { - fmterr(""); - fmterr("Invalid parameter for '--force-selinux'; " - "please run `%s --help` for usage information.", - argv[0]); - fmterr(""); - exit(1); + else if (strcasecmp(strval, "default")) { + fmterr("\n"); + fmterr("Invalid parameter for '--force-selinux'"); + goto fail; } break; case SELINUX_CHCON_TYPE_OPTION: - op->selinux_chcon_type = optarg; break; + op->selinux_chcon_type = strval; break; case NO_SIGWINCH_WORKAROUND_OPTION: op->sigwinch_workaround = FALSE; break; @@ -354,11 +329,7 @@ Options *parse_commandline(int argc, char *argv[]) break; default: - fmterr(""); - fmterr("Invalid commandline, please run `%s --help` " - "for usage information.", argv[0]); - fmterr(""); - exit(1); + goto fail; } /* @@ -373,25 +344,11 @@ Options *parse_commandline(int argc, char *argv[]) op->update_arguments = append_update_arguments(op->update_arguments, - c, optarg, - long_options); + c, strval, __options); } - } - nvfree((void*)long_options); - nvfree((void*)short_options); - - if (optind < argc) { - fmterr(""); - fmterr("Unrecognized arguments:"); - while (optind < argc) - fmterrp(" ", argv[optind++]); - fmterr("Invalid commandline, please run `%s --help` for " - "usage information.", argv[0]); - fmterr(""); - exit(1); } - + /* * if the installer prefix was not specified, default it to the * utility prefix; this is done so that the installer prefix is @@ -411,9 +368,16 @@ Options *parse_commandline(int argc, char *argv[]) if (strcmp(basename(program_name), "nvidia-uninstall") == 0) op->uninstall = TRUE; free(program_name); - - return (op); + return; + + fail: + fmterr("\n"); + fmterr("Invalid commandline, please run `%s --help` " + "for usage information.", argv[0]); + fmterr("\n"); + nvfree((void*)op); + exit(1); } /* parse_commandline() */ @@ -429,10 +393,18 @@ int main(int argc, char *argv[]) /* Ensure created files get the permissions we expect */ umask(022); + + /* Load defaults */ + + op = load_default_options(); + if (!op) { + fprintf(stderr, "\nOut of memory error.\n\n"); + return 1; + } /* parse the commandline options */ - op = parse_commandline(argc, argv); + parse_commandline(argc, argv, op); /* init the log file */ @@ -520,6 +492,8 @@ int main(int argc, char *argv[]) ui_close(op); + nvfree((void*)op); + return (ret ? 0 : 1); } /* main() */ diff --git a/option_table.h b/option_table.h index 8463e49..7ad2e99 100644 --- a/option_table.h +++ b/option_table.h @@ -1,14 +1,34 @@ -#define NVOPT_HAS_ARGUMENT 0x1 -#define NVOPT_IS_BOOLEAN 0x2 - -#define OPTION_HELP_ALWAYS 0x8000 - -typedef struct { - const char *name; - int val; - unsigned int flags; - char *description; /* not used by nvgetopt() */ -} NVOption; +/* + * nvidia-installer: A tool for installing/un-installing the + * NVIDIA Linux graphics driver. + * + * Copyright (C) 2004-2010 NVIDIA Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + *? + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + *? + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the: + * + * Free Software Foundation, Inc. + * 59 Temple Place - Suite 330 + * Boston, MA 02111-1307, USA + * + * + * option_table.h + */ + +#ifndef __OPT_TABLE_H__ +#define __OPT_TABLE_H__ + +#include "nvgetopt.h" enum { XFREE86_PREFIX_OPTION = 1, @@ -57,31 +77,31 @@ enum { NO_DISTRO_SCRIPTS_OPTION }; -static const NVOption __options[] = { +static const NVGetoptOption __options[] = { /* These options are printed by "nvidia-installer --help" */ - { "accept-license", 'a', OPTION_HELP_ALWAYS, + { "accept-license", 'a', NVGETOPT_HELP_ALWAYS, "Bypass the display and prompting for acceptance of the " "NVIDIA Software License Agreement. By passing this option to " "nvidia-installer, you indicate that you have read and accept the " "License Agreement contained in the file 'LICENSE' (in the top " "level directory of the driver package)." }, - { "update", UPDATE_OPTION, OPTION_HELP_ALWAYS, + { "update", UPDATE_OPTION, NVGETOPT_HELP_ALWAYS, "Connect to the NVIDIA FTP server ' " DEFAULT_FTP_SITE " ' and determine the " "latest available driver version. If there is a more recent " "driver available, automatically download and install it. Any " "other options given on the commandline will be passed on to the " "downloaded driver package when installing it." }, - { "version", 'v', OPTION_HELP_ALWAYS, + { "version", 'v', NVGETOPT_HELP_ALWAYS, "Print the nvidia-installer version and exit." }, - { "help", 'h', OPTION_HELP_ALWAYS, + { "help", 'h', NVGETOPT_HELP_ALWAYS, "Print usage information for the common commandline options " "and exit." }, - { "advanced-options", 'A', OPTION_HELP_ALWAYS, + { "advanced-options", 'A', NVGETOPT_HELP_ALWAYS, "Print usage information for the common commandline options " "as well as the advanced options, and then exit." }, @@ -118,17 +138,17 @@ static const NVOption __options[] = { "printed, except for error messages to stderr. This option " "implies '--ui=none --no-questions --accept-license'." }, - { "x-prefix", X_PREFIX_OPTION, NVOPT_HAS_ARGUMENT, + { "x-prefix", X_PREFIX_OPTION, NVGETOPT_STRING_ARGUMENT, "The prefix under which the X components of the " "NVIDIA driver will be installed; the default is '" DEFAULT_X_PREFIX "' unless nvidia-installer detects that X.Org >= 7.0 is installed, " "in which case the default is '" XORG7_DEFAULT_X_PREFIX "'. Only " "under rare circumstances should this option be used." }, - { "xfree86-prefix", XFREE86_PREFIX_OPTION, NVOPT_HAS_ARGUMENT, + { "xfree86-prefix", XFREE86_PREFIX_OPTION, NVGETOPT_STRING_ARGUMENT, "This is a deprecated synonym for --x-prefix." }, - { "x-module-path", X_MODULE_PATH_OPTION, NVOPT_HAS_ARGUMENT, + { "x-module-path", X_MODULE_PATH_OPTION, NVGETOPT_STRING_ARGUMENT, "The path under which the NVIDIA X server modules will be installed. " "If this option is not specified, nvidia-installer uses the following " "search order and selects the first valid directory it finds: 1) " @@ -138,7 +158,7 @@ static const NVOption __options[] = { "than X.Org 7.0) or '" XORG7_DEFAULT_X_MODULEDIR "' (for X.Org 7.0 or " "later)." }, - { "x-library-path", X_LIBRARY_PATH_OPTION, NVOPT_HAS_ARGUMENT, + { "x-library-path", X_LIBRARY_PATH_OPTION, NVGETOPT_STRING_ARGUMENT, "The path under which the NVIDIA X libraries will be installed. " "If this option is not specified, nvidia-installer uses the following " "search order and selects the first valid directory it finds: 1) " @@ -148,14 +168,14 @@ static const NVOption __options[] = { DEFAULT_64BIT_LIBDIR "' or '" DEFAULT_LIBDIR "' on 64bit systems, " "depending on the installed Linux distribution." }, - { "opengl-prefix", OPENGL_PREFIX_OPTION, NVOPT_HAS_ARGUMENT, + { "opengl-prefix", OPENGL_PREFIX_OPTION, NVGETOPT_STRING_ARGUMENT, "The prefix under which the OpenGL components of the " "NVIDIA driver will be installed; the default is: '" DEFAULT_OPENGL_PREFIX "'. Only under rare circumstances should this option be used. " "The Linux OpenGL ABI (http://oss.sgi.com/projects/ogl-sample/ABI/) " "mandates this default value." }, - { "opengl-libdir", OPENGL_LIBDIR_OPTION, NVOPT_HAS_ARGUMENT, + { "opengl-libdir", OPENGL_LIBDIR_OPTION, NVGETOPT_STRING_ARGUMENT, "The path relative to the OpenGL library installation prefix under " "which the NVIDIA OpenGL components will be installed. The " "default is '" DEFAULT_LIBDIR "' on 32bit systems, and '" @@ -164,7 +184,7 @@ static const NVOption __options[] = { "circumstances should this option be used." }, #if defined(NV_X86_64) - { "compat32-chroot", COMPAT32_CHROOT_OPTION, NVOPT_HAS_ARGUMENT, + { "compat32-chroot", COMPAT32_CHROOT_OPTION, NVGETOPT_STRING_ARGUMENT, "The top-level prefix (chroot) relative to which the 32bit " "compatibility OpenGL libraries will be installed on Linux/x86-64 " "systems; this option is unset by default, the 32bit OpenGL " @@ -172,13 +192,13 @@ static const NVOption __options[] = { "path alone determine the target location. Only under very rare " "circumstances should this option be used." }, - { "compat32-prefix", COMPAT32_PREFIX_OPTION, NVOPT_HAS_ARGUMENT, + { "compat32-prefix", COMPAT32_PREFIX_OPTION, NVGETOPT_STRING_ARGUMENT, "The prefix under which the 32bit compatibility OpenGL components " "of the NVIDIA driver will be installed; the default is: '" DEFAULT_OPENGL_PREFIX "'. Only under rare circumstances should " "this option be used." }, - { "compat32-libdir", COMPAT32_LIBDIR_OPTION, NVOPT_HAS_ARGUMENT, + { "compat32-libdir", COMPAT32_LIBDIR_OPTION, NVGETOPT_STRING_ARGUMENT, "The path relative to the 32bit compatibility prefix under which the " "32bit compatibility OpenGL components of the NVIDIA driver will " "be installed. The default is '" DEFAULT_LIBDIR "' or '" @@ -187,36 +207,36 @@ static const NVOption __options[] = { "option be used." }, #endif /* NV_X86_64 */ - { "installer-prefix", INSTALLER_PREFIX_OPTION, NVOPT_HAS_ARGUMENT, + { "installer-prefix", INSTALLER_PREFIX_OPTION, NVGETOPT_STRING_ARGUMENT, "The prefix under which the installer binary will be " "installed; the default is: '" DEFAULT_UTILITY_PREFIX "'. Note: please " "use the '--utility-prefix' option instead." }, - { "utility-prefix", UTILITY_PREFIX_OPTION, NVOPT_HAS_ARGUMENT, + { "utility-prefix", UTILITY_PREFIX_OPTION, NVGETOPT_STRING_ARGUMENT, "The prefix under which the NVIDIA utilities (nvidia-installer, " "nvidia-settings, nvidia-xconfig, nvidia-bug-report.sh) and the NVIDIA " "utility libraries will be installed; the default is: '" DEFAULT_UTILITY_PREFIX "'." }, - { "utility-libdir", UTILITY_LIBDIR_OPTION, NVOPT_HAS_ARGUMENT, + { "utility-libdir", UTILITY_LIBDIR_OPTION, NVGETOPT_STRING_ARGUMENT, "The path relative to the utility installation prefix under which the " "NVIDIA utility libraries will be installed. The default is '" DEFAULT_LIBDIR "' on 32bit systems, and '" DEFAULT_64BIT_LIBDIR "' or '" DEFAULT_LIBDIR "' on 64bit " "systems, depending on the " "installed Linux distribution." }, - { "documentation-prefix", DOCUMENTATION_PREFIX_OPTION, NVOPT_HAS_ARGUMENT, + { "documentation-prefix", DOCUMENTATION_PREFIX_OPTION, NVGETOPT_STRING_ARGUMENT, "The prefix under which the documentation files for the NVIDIA " "driver will be installed. The default is: '" DEFAULT_DOCUMENTATION_PREFIX "'." }, - { "kernel-include-path", KERNEL_INCLUDE_PATH_OPTION, NVOPT_HAS_ARGUMENT, + { "kernel-include-path", KERNEL_INCLUDE_PATH_OPTION, NVGETOPT_STRING_ARGUMENT, "The directory containing the kernel include files that " "should be used when compiling the NVIDIA kernel module. " "This option is deprecated; please use '--kernel-source-path' " "instead." }, - { "kernel-source-path", KERNEL_SOURCE_PATH_OPTION, NVOPT_HAS_ARGUMENT, + { "kernel-source-path", KERNEL_SOURCE_PATH_OPTION, NVGETOPT_STRING_ARGUMENT, "The directory containing the kernel source files that " "should be used when compiling the NVIDIA kernel module. " "When not specified, the installer will use " @@ -224,20 +244,20 @@ static const NVOption __options[] = { "directory exists. Otherwise, it will use " "'/usr/src/linux'." }, - { "kernel-output-path", KERNEL_OUTPUT_PATH_OPTION, NVOPT_HAS_ARGUMENT, + { "kernel-output-path", KERNEL_OUTPUT_PATH_OPTION, NVGETOPT_STRING_ARGUMENT, "The directory containing any KBUILD output files if " "either one of the 'KBUILD_OUTPUT' or 'O' parameters were " "passed to KBUILD when building the kernel image/modules. " "When not specified, the installer will assume that no " "separate output directory was used." }, - { "kernel-install-path", KERNEL_INSTALL_PATH_OPTION, NVOPT_HAS_ARGUMENT, + { "kernel-install-path", KERNEL_INSTALL_PATH_OPTION, NVGETOPT_STRING_ARGUMENT, "The directory in which the NVIDIA kernel module should be " "installed. The default value is either '/lib/modules/`uname " "-r`/kernel/drivers/video' (if '/lib/modules/`uname -r`/kernel' " "exists) or '/lib/modules/`uname -r`/video'." }, - { "proc-mount-point", PROC_MOUNT_POINT_OPTION, NVOPT_HAS_ARGUMENT, + { "proc-mount-point", PROC_MOUNT_POINT_OPTION, NVGETOPT_STRING_ARGUMENT, "The mount point for the proc file system; if not " "specified, then this value defaults to '" DEFAULT_PROC_MOUNT_POINT "' (which is normally " @@ -247,18 +267,18 @@ static const NVOption __options[] = { "the currently running kernel. This option should only be needed " "in very rare circumstances." }, - { "log-file-name", LOG_FILE_NAME_OPTION, NVOPT_HAS_ARGUMENT, + { "log-file-name", LOG_FILE_NAME_OPTION, NVGETOPT_STRING_ARGUMENT, "File name of the installation log file (the default is: " "'" DEFAULT_LOG_FILE_NAME "')." }, - { "tmpdir", TMPDIR_OPTION, NVOPT_HAS_ARGUMENT, + { "tmpdir", TMPDIR_OPTION, NVGETOPT_STRING_ARGUMENT, "Use the specified directory as a temporary directory when " "downloading files from the NVIDIA ftp site; " "if not given, then the following list will be searched, and " "the first one that exists will be used: $TMPDIR, /tmp, ., " "$HOME." }, - { "ftp-mirror", 'm', NVOPT_HAS_ARGUMENT, + { "ftp-mirror", 'm', NVGETOPT_STRING_ARGUMENT, "Use the specified FTP mirror rather than the default ' " DEFAULT_FTP_SITE " ' when downloading driver updates." }, @@ -274,7 +294,7 @@ static const NVOption __options[] = { "thinks the latest driver is already installed; this option " "implies '--update'." }, - { "ui", USER_INTERFACE_OPTION, NVOPT_HAS_ARGUMENT, + { "ui", USER_INTERFACE_OPTION, NVGETOPT_STRING_ARGUMENT, "Specify what user interface to use, if available. " "Valid values for [UI] are 'ncurses' (the default) or 'none'. " "If the ncurses interface fails to initialize, or 'none' " @@ -289,7 +309,7 @@ static const NVOption __options[] = { "header files. This option disables installation of the NVIDIA " "OpenGL header files." }, - { "force-tls", FORCE_TLS_OPTION, NVOPT_HAS_ARGUMENT, + { "force-tls", FORCE_TLS_OPTION, NVGETOPT_STRING_ARGUMENT, "NVIDIA's OpenGL libraries are compiled with one of two " "different thread local storage (TLS) mechanisms: 'classic tls' " "which is used on systems with glibc 2.2 or older, and 'new tls' " @@ -300,13 +320,13 @@ static const NVOption __options[] = { "for [FORCE-TLS] are 'new' and 'classic'." }, #if defined(NV_X86_64) - { "force-tls-compat32", FORCE_TLS_COMPAT32_OPTION, NVOPT_HAS_ARGUMENT, + { "force-tls-compat32", FORCE_TLS_COMPAT32_OPTION, NVGETOPT_STRING_ARGUMENT, "This option forces the installer to install a specific " "32bit compatibility OpenGL TLS library; further details " "can be found in the description of the '--force-tls' option." }, #endif /* NV_X86_64 */ - { "kernel-name", 'k', NVOPT_HAS_ARGUMENT, + { "kernel-name", 'k', NVGETOPT_STRING_ARGUMENT, "Build and install the NVIDIA kernel module for the " "non-running kernel specified by [KERNEL-NAME] ([KERNEL-NAME] " "should be the output of `uname -r` when the target kernel is " @@ -379,12 +399,12 @@ static const NVOption __options[] = { "this option be used." }, { "precompiled-kernel-interfaces-path", - PRECOMPILED_KERNEL_INTERFACES_PATH_OPTION, NVOPT_HAS_ARGUMENT, + PRECOMPILED_KERNEL_INTERFACES_PATH_OPTION, NVGETOPT_STRING_ARGUMENT, "Before searching for a precompiled kernel interface in the " ".run file, search in the specified directory." }, { "precompiled-kernel-interfaces-url", - PRECOMPILED_KERNEL_INTERFACES_URL_OPTION, NVOPT_HAS_ARGUMENT, + PRECOMPILED_KERNEL_INTERFACES_URL_OPTION, NVGETOPT_STRING_ARGUMENT, "If no precompiled kernel interfaces are found within the driver package " "or provided on the file system by the Linux distribution, check the " "specified URL for updates. NVIDIA does not intend to provide updated " @@ -402,7 +422,7 @@ static const NVOption __options[] = { "'yes'. This is useful with the '--no-questions' or '--silent' " "options, which assume the default values for all questions." }, - { "force-selinux", FORCE_SELINUX_OPTION, NVOPT_HAS_ARGUMENT, + { "force-selinux", FORCE_SELINUX_OPTION, NVGETOPT_STRING_ARGUMENT, "Linux installations using SELinux (Security-Enhanced Linux) " "require that the security type of all shared libraries be set " "to 'shlib_t' or 'textrel_shlib_t', depending on the distribution. " @@ -417,7 +437,7 @@ static const NVOption __options[] = { "'no' (prevent setting of the security type), and 'default' " "(let nvidia-installer decide when to set the security type)." }, - { "selinux-chcon-type", SELINUX_CHCON_TYPE_OPTION, NVOPT_HAS_ARGUMENT, + { "selinux-chcon-type", SELINUX_CHCON_TYPE_OPTION, NVGETOPT_STRING_ARGUMENT, "When SELinux support is enabled, nvidia-installer will try to determine " "which chcon argument to use by first trying 'textrel_shlib_t', then " "'texrel_shlib_t', then 'shlib_t'. Use this option to override this " @@ -450,9 +470,10 @@ static const NVOption __options[] = { { "debug", 'd', 0, NULL }, { "help-args-only", HELP_ARGS_ONLY_OPTION, 0, NULL }, { "add-this-kernel", ADD_THIS_KERNEL_OPTION, 0, NULL }, - { "rpm-file-list", RPM_FILE_LIST_OPTION, NVOPT_HAS_ARGUMENT, NULL }, + { "rpm-file-list", RPM_FILE_LIST_OPTION, NVGETOPT_STRING_ARGUMENT, NULL }, { "no-rpms", NO_RPMS_OPTION, 0, NULL}, { "advanced-options-args-only", ADVANCED_OPTIONS_ARGS_ONLY_OPTION, 0, NULL }, { NULL, 0, 0, NULL }, }; +#endif /* __OPT_TABLE_H__ */ diff --git a/pci/config.h b/pci/config.h deleted file mode 100755 index d41f3ae..0000000 --- a/pci/config.h +++ /dev/null @@ -1,11 +0,0 @@ -#define PCI_ARCH_I386 -#define PCI_OS_LINUX -#define PCI_HAVE_PM_LINUX_SYSFS -#define PCI_HAVE_PM_LINUX_PROC -#define PCI_HAVE_LINUX_BYTEORDER_H -#define PCI_PATH_PROC_BUS_PCI "/proc/bus/pci" -#define PCI_PATH_SYS_BUS_PCI "/sys/bus/pci" -#define PCI_HAVE_PM_INTEL_CONF -#define PCI_HAVE_64BIT_ADDRESS -#define PCI_PATH_IDS "/usr/local/pciutils-2.2.1/share/pci.ids" -#define PCILIB_VERSION "2.2.1" diff --git a/pci/header.h b/pci/header.h deleted file mode 100755 index f064ab8..0000000 --- a/pci/header.h +++ /dev/null @@ -1,935 +0,0 @@ -/* - * The PCI Library -- PCI Header Structure (based on <linux/pci.h>) - * - * Copyright (c) 1997--2005 Martin Mares <mj@ucw.cz> - * - * Can be freely distributed and used under the terms of the GNU GPL. - */ - -/* - * Under PCI, each device has 256 bytes of configuration address space, - * of which the first 64 bytes are standardized as follows: - */ -#define PCI_VENDOR_ID 0x00 /* 16 bits */ -#define PCI_DEVICE_ID 0x02 /* 16 bits */ -#define PCI_COMMAND 0x04 /* 16 bits */ -#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ -#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ -#define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */ -#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */ -#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ -#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ -#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ -#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ -#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ -#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ - -#define PCI_STATUS 0x06 /* 16 bits */ -#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */ -#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */ -#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */ -#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */ -#define PCI_STATUS_PARITY 0x100 /* Detected parity error */ -#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ -#define PCI_STATUS_DEVSEL_FAST 0x000 -#define PCI_STATUS_DEVSEL_MEDIUM 0x200 -#define PCI_STATUS_DEVSEL_SLOW 0x400 -#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */ -#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */ -#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */ -#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */ -#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ - -#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 - revision */ -#define PCI_REVISION_ID 0x08 /* Revision ID */ -#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ -#define PCI_CLASS_DEVICE 0x0a /* Device class */ - -#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ -#define PCI_LATENCY_TIMER 0x0d /* 8 bits */ -#define PCI_HEADER_TYPE 0x0e /* 8 bits */ -#define PCI_HEADER_TYPE_NORMAL 0 -#define PCI_HEADER_TYPE_BRIDGE 1 -#define PCI_HEADER_TYPE_CARDBUS 2 - -#define PCI_BIST 0x0f /* 8 bits */ -#define PCI_BIST_CODE_MASK 0x0f /* Return result */ -#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ -#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ - -/* - * Base addresses specify locations in memory or I/O space. - * Decoded size can be determined by writing a value of - * 0xffffffff to the register, and reading it back. Only - * 1 bits are decoded. - */ -#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */ -#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */ -#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */ -#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */ -#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */ -#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */ -#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */ -#define PCI_BASE_ADDRESS_SPACE_IO 0x01 -#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00 -#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06 -#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */ -#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */ -#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */ -#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */ -#define PCI_BASE_ADDRESS_MEM_MASK (~(pciaddr_t)0x0f) -#define PCI_BASE_ADDRESS_IO_MASK (~(pciaddr_t)0x03) -/* bit 1 is reserved if address_space = 1 */ - -/* Header type 0 (normal devices) */ -#define PCI_CARDBUS_CIS 0x28 -#define PCI_SUBSYSTEM_VENDOR_ID 0x2c -#define PCI_SUBSYSTEM_ID 0x2e -#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */ -#define PCI_ROM_ADDRESS_ENABLE 0x01 -#define PCI_ROM_ADDRESS_MASK (~(pciaddr_t)0x7ff) - -#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */ - -/* 0x35-0x3b are reserved */ -#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */ -#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */ -#define PCI_MIN_GNT 0x3e /* 8 bits */ -#define PCI_MAX_LAT 0x3f /* 8 bits */ - -/* Header type 1 (PCI-to-PCI bridges) */ -#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */ -#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */ -#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */ -#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */ -#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */ -#define PCI_IO_LIMIT 0x1d -#define PCI_IO_RANGE_TYPE_MASK 0x0f /* I/O bridging type */ -#define PCI_IO_RANGE_TYPE_16 0x00 -#define PCI_IO_RANGE_TYPE_32 0x01 -#define PCI_IO_RANGE_MASK ~0x0f -#define PCI_SEC_STATUS 0x1e /* Secondary status register */ -#define PCI_MEMORY_BASE 0x20 /* Memory range behind */ -#define PCI_MEMORY_LIMIT 0x22 -#define PCI_MEMORY_RANGE_TYPE_MASK 0x0f -#define PCI_MEMORY_RANGE_MASK ~0x0f -#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */ -#define PCI_PREF_MEMORY_LIMIT 0x26 -#define PCI_PREF_RANGE_TYPE_MASK 0x0f -#define PCI_PREF_RANGE_TYPE_32 0x00 -#define PCI_PREF_RANGE_TYPE_64 0x01 -#define PCI_PREF_RANGE_MASK ~0x0f -#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */ -#define PCI_PREF_LIMIT_UPPER32 0x2c -#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */ -#define PCI_IO_LIMIT_UPPER16 0x32 -/* 0x34 same as for htype 0 */ -/* 0x35-0x3b is reserved */ -#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */ -/* 0x3c-0x3d are same as for htype 0 */ -#define PCI_BRIDGE_CONTROL 0x3e -#define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */ -#define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */ -#define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */ -#define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */ -#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */ -#define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */ -#define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */ - -/* Header type 2 (CardBus bridges) */ -/* 0x14-0x15 reserved */ -#define PCI_CB_SEC_STATUS 0x16 /* Secondary status */ -#define PCI_CB_PRIMARY_BUS 0x18 /* PCI bus number */ -#define PCI_CB_CARD_BUS 0x19 /* CardBus bus number */ -#define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */ -#define PCI_CB_LATENCY_TIMER 0x1b /* CardBus latency timer */ -#define PCI_CB_MEMORY_BASE_0 0x1c -#define PCI_CB_MEMORY_LIMIT_0 0x20 -#define PCI_CB_MEMORY_BASE_1 0x24 -#define PCI_CB_MEMORY_LIMIT_1 0x28 -#define PCI_CB_IO_BASE_0 0x2c -#define PCI_CB_IO_BASE_0_HI 0x2e -#define PCI_CB_IO_LIMIT_0 0x30 -#define PCI_CB_IO_LIMIT_0_HI 0x32 -#define PCI_CB_IO_BASE_1 0x34 -#define PCI_CB_IO_BASE_1_HI 0x36 -#define PCI_CB_IO_LIMIT_1 0x38 -#define PCI_CB_IO_LIMIT_1_HI 0x3a -#define PCI_CB_IO_RANGE_MASK ~0x03 -/* 0x3c-0x3d are same as for htype 0 */ -#define PCI_CB_BRIDGE_CONTROL 0x3e -#define PCI_CB_BRIDGE_CTL_PARITY 0x01 /* Similar to standard bridge control register */ -#define PCI_CB_BRIDGE_CTL_SERR 0x02 -#define PCI_CB_BRIDGE_CTL_ISA 0x04 -#define PCI_CB_BRIDGE_CTL_VGA 0x08 -#define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20 -#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */ -#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */ -#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 /* Prefetch enable for both memory regions */ -#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200 -#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400 -#define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40 -#define PCI_CB_SUBSYSTEM_ID 0x42 -#define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */ -/* 0x48-0x7f reserved */ - -/* Capability lists */ - -#define PCI_CAP_LIST_ID 0 /* Capability ID */ -#define PCI_CAP_ID_PM 0x01 /* Power Management */ -#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ -#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */ -#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */ -#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ -#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */ -#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */ -#define PCI_CAP_ID_HT 0x08 /* HyperTransport */ -#define PCI_CAP_ID_VNDR 0x09 /* Vendor specific */ -#define PCI_CAP_ID_DBG 0x0A /* Debug port */ -#define PCI_CAP_ID_CCRC 0x0B /* CompactPCI Central Resource Control */ -#define PCI_CAP_ID_AGP3 0x0E /* AGP 8x */ -#define PCI_CAP_ID_EXP 0x10 /* PCI Express */ -#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */ -#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */ -#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */ -#define PCI_CAP_SIZEOF 4 - -/* Capabilities residing in the PCI Express extended configuration space */ - -#define PCI_EXT_CAP_ID_AER 0x01 /* Advanced Error Reporting */ -#define PCI_EXT_CAP_ID_VC 0x02 /* Virtual Channel */ -#define PCI_EXT_CAP_ID_DSN 0x03 /* Device Serial Number */ -#define PCI_EXT_CAP_ID_PB 0x04 /* Power Budgeting */ - -/* Power Management Registers */ - -#define PCI_PM_CAP_VER_MASK 0x0007 /* Version (2=PM1.1) */ -#define PCI_PM_CAP_PME_CLOCK 0x0008 /* Clock required for PME generation */ -#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization required */ -#define PCI_PM_CAP_AUX_C_MASK 0x01c0 /* Maximum aux current required in D3cold */ -#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */ -#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */ -#define PCI_PM_CAP_PME_D0 0x0800 /* PME can be asserted from D0 */ -#define PCI_PM_CAP_PME_D1 0x1000 /* PME can be asserted from D1 */ -#define PCI_PM_CAP_PME_D2 0x2000 /* PME can be asserted from D2 */ -#define PCI_PM_CAP_PME_D3_HOT 0x4000 /* PME can be asserted from D3hot */ -#define PCI_PM_CAP_PME_D3_COLD 0x8000 /* PME can be asserted from D3cold */ -#define PCI_PM_CTRL 4 /* PM control and status register */ -#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */ -#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */ -#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* PM table data index */ -#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* PM table data scaling factor */ -#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */ -#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions */ -#define PCI_PM_PPB_B2_B3 0x40 /* If bridge enters D3hot, bus enters: 0=B3, 1=B2 */ -#define PCI_PM_BPCC_ENABLE 0x80 /* Secondary bus is power managed */ -#define PCI_PM_DATA_REGISTER 7 /* PM table contents read here */ -#define PCI_PM_SIZEOF 8 - -/* AGP registers */ - -#define PCI_AGP_VERSION 2 /* BCD version number */ -#define PCI_AGP_RFU 3 /* Rest of capability flags */ -#define PCI_AGP_STATUS 4 /* Status register */ -#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */ -#define PCI_AGP_STATUS_ISOCH 0x10000 /* Isochronous transactions supported */ -#define PCI_AGP_STATUS_ARQSZ_MASK 0xe000 /* log2(optimum async req size in bytes) - 4 */ -#define PCI_AGP_STATUS_CAL_MASK 0x1c00 /* Calibration cycle timing */ -#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */ -#define PCI_AGP_STATUS_ITA_COH 0x0100 /* In-aperture accesses always coherent */ -#define PCI_AGP_STATUS_GART64 0x0080 /* 64-bit GART entries supported */ -#define PCI_AGP_STATUS_HTRANS 0x0040 /* If 0, core logic can xlate host CPU accesses thru aperture */ -#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing cycles supported */ -#define PCI_AGP_STATUS_FW 0x0010 /* Fast write transfers supported */ -#define PCI_AGP_STATUS_AGP3 0x0008 /* AGP3 mode supported */ -#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported (RFU in AGP3 mode) */ -#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported (8x in AGP3 mode) */ -#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported (4x in AGP3 mode) */ -#define PCI_AGP_COMMAND 8 /* Control register */ -#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */ -#define PCI_AGP_COMMAND_ARQSZ_MASK 0xe000 /* log2(optimum async req size in bytes) - 4 */ -#define PCI_AGP_COMMAND_CAL_MASK 0x1c00 /* Calibration cycle timing */ -#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */ -#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */ -#define PCI_AGP_COMMAND_GART64 0x0080 /* 64-bit GART entries enabled */ -#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow generation of 64-bit addr cycles */ -#define PCI_AGP_COMMAND_FW 0x0010 /* Enable FW transfers */ -#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate (RFU in AGP3 mode) */ -#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate (8x in AGP3 mode) */ -#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate (4x in AGP3 mode) */ -#define PCI_AGP_SIZEOF 12 - -/* Slot Identification */ - -#define PCI_SID_ESR 2 /* Expansion Slot Register */ -#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */ -#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */ -#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */ - -/* Message Signalled Interrupts registers */ - -#define PCI_MSI_FLAGS 2 /* Various flags */ -#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */ -#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */ -#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */ -#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */ -#define PCI_MSI_RFU 3 /* Rest of capability flags */ -#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */ -#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */ -#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */ -#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */ - -/* PCI-X */ -#define PCI_PCIX_COMMAND 2 /* Command register offset */ -#define PCI_PCIX_COMMAND_DPERE 0x0001 /* Data Parity Error Recover Enable */ -#define PCI_PCIX_COMMAND_ERO 0x0002 /* Enable Relaxed Ordering */ -#define PCI_PCIX_COMMAND_MAX_MEM_READ_BYTE_COUNT 0x000c /* Maximum Memory Read Byte Count */ -#define PCI_PCIX_COMMAND_MAX_OUTSTANDING_SPLIT_TRANS 0x0070 -#define PCI_PCIX_COMMAND_RESERVED 0xf80 -#define PCI_PCIX_STATUS 4 /* Status register offset */ -#define PCI_PCIX_STATUS_FUNCTION 0x00000007 -#define PCI_PCIX_STATUS_DEVICE 0x000000f8 -#define PCI_PCIX_STATUS_BUS 0x0000ff00 -#define PCI_PCIX_STATUS_64BIT 0x00010000 -#define PCI_PCIX_STATUS_133MHZ 0x00020000 -#define PCI_PCIX_STATUS_SC_DISCARDED 0x00040000 /* Split Completion Discarded */ -#define PCI_PCIX_STATUS_UNEXPECTED_SC 0x00080000 /* Unexpected Split Completion */ -#define PCI_PCIX_STATUS_DEVICE_COMPLEXITY 0x00100000 /* 0 = simple device, 1 = bridge device */ -#define PCI_PCIX_STATUS_DESIGNED_MAX_MEM_READ_BYTE_COUNT 0x00600000 /* 0 = 512 bytes, 1 = 1024, 2 = 2048, 3 = 4096 */ -#define PCI_PCIX_STATUS_DESIGNED_MAX_OUTSTANDING_SPLIT_TRANS 0x03800000 -#define PCI_PCIX_STATUS_DESIGNED_MAX_CUMULATIVE_READ_SIZE 0x1c000000 -#define PCI_PCIX_STATUS_RCVD_SC_ERR_MESS 0x20000000 /* Received Split Completion Error Message */ -#define PCI_PCIX_STATUS_266MHZ 0x40000000 /* 266 MHz capable */ -#define PCI_PCIX_STATUS_533MHZ 0x80000000 /* 533 MHz capable */ -#define PCI_PCIX_SIZEOF 4 - -/* PCI-X Bridges */ -#define PCI_PCIX_BRIDGE_SEC_STATUS 2 /* Secondary bus status register offset */ -#define PCI_PCIX_BRIDGE_SEC_STATUS_64BIT 0x0001 -#define PCI_PCIX_BRIDGE_SEC_STATUS_133MHZ 0x0002 -#define PCI_PCIX_BRIDGE_SEC_STATUS_SC_DISCARDED 0x0004 /* Split Completion Discarded on secondary bus */ -#define PCI_PCIX_BRIDGE_SEC_STATUS_UNEXPECTED_SC 0x0008 /* Unexpected Split Completion on secondary bus */ -#define PCI_PCIX_BRIDGE_SEC_STATUS_SC_OVERRUN 0x0010 /* Split Completion Overrun on secondary bus */ -#define PCI_PCIX_BRIDGE_SEC_STATUS_SPLIT_REQUEST_DELAYED 0x0020 -#define PCI_PCIX_BRIDGE_SEC_STATUS_CLOCK_FREQ 0x01c0 -#define PCI_PCIX_BRIDGE_SEC_STATUS_RESERVED 0xfe00 -#define PCI_PCIX_BRIDGE_STATUS 4 /* Primary bus status register offset */ -#define PCI_PCIX_BRIDGE_STATUS_FUNCTION 0x00000007 -#define PCI_PCIX_BRIDGE_STATUS_DEVICE 0x000000f8 -#define PCI_PCIX_BRIDGE_STATUS_BUS 0x0000ff00 -#define PCI_PCIX_BRIDGE_STATUS_64BIT 0x00010000 -#define PCI_PCIX_BRIDGE_STATUS_133MHZ 0x00020000 -#define PCI_PCIX_BRIDGE_STATUS_SC_DISCARDED 0x00040000 /* Split Completion Discarded */ -#define PCI_PCIX_BRIDGE_STATUS_UNEXPECTED_SC 0x00080000 /* Unexpected Split Completion */ -#define PCI_PCIX_BRIDGE_STATUS_SC_OVERRUN 0x00100000 /* Split Completion Overrun */ -#define PCI_PCIX_BRIDGE_STATUS_SPLIT_REQUEST_DELAYED 0x00200000 -#define PCI_PCIX_BRIDGE_STATUS_RESERVED 0xffc00000 -#define PCI_PCIX_BRIDGE_UPSTREAM_SPLIT_TRANS_CTRL 8 /* Upstream Split Transaction Register offset */ -#define PCI_PCIX_BRIDGE_DOWNSTREAM_SPLIT_TRANS_CTRL 12 /* Downstream Split Transaction Register offset */ -#define PCI_PCIX_BRIDGE_STR_CAPACITY 0x0000ffff -#define PCI_PCIX_BRIDGE_STR_COMMITMENT_LIMIT 0xffff0000 -#define PCI_PCIX_BRIDGE_SIZEOF 12 - -/* HyperTransport (as of spec rev. 2.00) */ -#define PCI_HT_CMD 2 /* Command Register */ -#define PCI_HT_CMD_TYP_HI 0xe000 /* Capability Type high part */ -#define PCI_HT_CMD_TYP_HI_PRI 0x0000 /* Slave or Primary Interface */ -#define PCI_HT_CMD_TYP_HI_SEC 0x2000 /* Host or Secondary Interface */ -#define PCI_HT_CMD_TYP 0xf800 /* Capability Type */ -#define PCI_HT_CMD_TYP_SW 0x4000 /* Switch */ -#define PCI_HT_CMD_TYP_IDC 0x8000 /* Interrupt Discovery and Configuration */ -#define PCI_HT_CMD_TYP_RID 0x8800 /* Revision ID */ -#define PCI_HT_CMD_TYP_UIDC 0x9000 /* UnitID Clumping */ -#define PCI_HT_CMD_TYP_ECSA 0x9800 /* Extended Configuration Space Access */ -#define PCI_HT_CMD_TYP_AM 0xa000 /* Address Mapping */ -#define PCI_HT_CMD_TYP_MSIM 0xa800 /* MSI Mapping */ -#define PCI_HT_CMD_TYP_DR 0xb000 /* DirectRoute */ -#define PCI_HT_CMD_TYP_VCS 0xb800 /* VCSet */ -#define PCI_HT_CMD_TYP_RM 0xc000 /* Retry Mode */ -#define PCI_HT_CMD_TYP_X86 0xc800 /* X86 (reserved) */ - - /* Link Control Register */ -#define PCI_HT_LCTR_CFLE 0x0002 /* CRC Flood Enable */ -#define PCI_HT_LCTR_CST 0x0004 /* CRC Start Test */ -#define PCI_HT_LCTR_CFE 0x0008 /* CRC Force Error */ -#define PCI_HT_LCTR_LKFAIL 0x0010 /* Link Failure */ -#define PCI_HT_LCTR_INIT 0x0020 /* Initialization Complete */ -#define PCI_HT_LCTR_EOC 0x0040 /* End of Chain */ -#define PCI_HT_LCTR_TXO 0x0080 /* Transmitter Off */ -#define PCI_HT_LCTR_CRCERR 0x0f00 /* CRC Error */ -#define PCI_HT_LCTR_ISOCEN 0x1000 /* Isochronous Flow Control Enable */ -#define PCI_HT_LCTR_LSEN 0x2000 /* LDTSTOP# Tristate Enable */ -#define PCI_HT_LCTR_EXTCTL 0x4000 /* Extended CTL Time */ -#define PCI_HT_LCTR_64B 0x8000 /* 64-bit Addressing Enable */ - - /* Link Configuration Register */ -#define PCI_HT_LCNF_MLWI 0x0007 /* Max Link Width In */ -#define PCI_HT_LCNF_LW_8B 0x0 /* Link Width 8 bits */ -#define PCI_HT_LCNF_LW_16B 0x1 /* Link Width 16 bits */ -#define PCI_HT_LCNF_LW_32B 0x3 /* Link Width 32 bits */ -#define PCI_HT_LCNF_LW_2B 0x4 /* Link Width 2 bits */ -#define PCI_HT_LCNF_LW_4B 0x5 /* Link Width 4 bits */ -#define PCI_HT_LCNF_LW_NC 0x7 /* Link physically not connected */ -#define PCI_HT_LCNF_DFI 0x0008 /* Doubleword Flow Control In */ -#define PCI_HT_LCNF_MLWO 0x0070 /* Max Link Width Out */ -#define PCI_HT_LCNF_DFO 0x0080 /* Doubleword Flow Control Out */ -#define PCI_HT_LCNF_LWI 0x0700 /* Link Width In */ -#define PCI_HT_LCNF_DFIE 0x0800 /* Doubleword Flow Control In Enable */ -#define PCI_HT_LCNF_LWO 0x7000 /* Link Width Out */ -#define PCI_HT_LCNF_DFOE 0x8000 /* Doubleword Flow Control Out Enable */ - - /* Revision ID Register */ -#define PCI_HT_RID_MIN 0x1f /* Minor Revision */ -#define PCI_HT_RID_MAJ 0xe0 /* Major Revision */ - - /* Link Frequency/Error Register */ -#define PCI_HT_LFRER_FREQ 0x0f /* Transmitter Clock Frequency */ -#define PCI_HT_LFRER_200 0x00 /* 200MHz */ -#define PCI_HT_LFRER_300 0x01 /* 300MHz */ -#define PCI_HT_LFRER_400 0x02 /* 400MHz */ -#define PCI_HT_LFRER_500 0x03 /* 500MHz */ -#define PCI_HT_LFRER_600 0x04 /* 600MHz */ -#define PCI_HT_LFRER_800 0x05 /* 800MHz */ -#define PCI_HT_LFRER_1000 0x06 /* 1.0GHz */ -#define PCI_HT_LFRER_1200 0x07 /* 1.2GHz */ -#define PCI_HT_LFRER_1400 0x08 /* 1.4GHz */ -#define PCI_HT_LFRER_1600 0x09 /* 1.6GHz */ -#define PCI_HT_LFRER_VEND 0x0f /* Vendor-Specific */ -#define PCI_HT_LFRER_ERR 0xf0 /* Link Error */ -#define PCI_HT_LFRER_PROT 0x10 /* Protocol Error */ -#define PCI_HT_LFRER_OV 0x20 /* Overflow Error */ -#define PCI_HT_LFRER_EOC 0x40 /* End of Chain Error */ -#define PCI_HT_LFRER_CTLT 0x80 /* CTL Timeout */ - - /* Link Frequency Capability Register */ -#define PCI_HT_LFCAP_200 0x0001 /* 200MHz */ -#define PCI_HT_LFCAP_300 0x0002 /* 300MHz */ -#define PCI_HT_LFCAP_400 0x0004 /* 400MHz */ -#define PCI_HT_LFCAP_500 0x0008 /* 500MHz */ -#define PCI_HT_LFCAP_600 0x0010 /* 600MHz */ -#define PCI_HT_LFCAP_800 0x0020 /* 800MHz */ -#define PCI_HT_LFCAP_1000 0x0040 /* 1.0GHz */ -#define PCI_HT_LFCAP_1200 0x0080 /* 1.2GHz */ -#define PCI_HT_LFCAP_1400 0x0100 /* 1.4GHz */ -#define PCI_HT_LFCAP_1600 0x0200 /* 1.6GHz */ -#define PCI_HT_LFCAP_VEND 0x8000 /* Vendor-Specific */ - - /* Feature Register */ -#define PCI_HT_FTR_ISOCFC 0x0001 /* Isochronous Flow Control Mode */ -#define PCI_HT_FTR_LDTSTOP 0x0002 /* LDTSTOP# Supported */ -#define PCI_HT_FTR_CRCTM 0x0004 /* CRC Test Mode */ -#define PCI_HT_FTR_ECTLT 0x0008 /* Extended CTL Time Required */ -#define PCI_HT_FTR_64BA 0x0010 /* 64-bit Addressing */ -#define PCI_HT_FTR_UIDRD 0x0020 /* UnitID Reorder Disable */ - - /* Error Handling Register */ -#define PCI_HT_EH_PFLE 0x0001 /* Protocol Error Flood Enable */ -#define PCI_HT_EH_OFLE 0x0002 /* Overflow Error Flood Enable */ -#define PCI_HT_EH_PFE 0x0004 /* Protocol Error Fatal Enable */ -#define PCI_HT_EH_OFE 0x0008 /* Overflow Error Fatal Enable */ -#define PCI_HT_EH_EOCFE 0x0010 /* End of Chain Error Fatal Enable */ -#define PCI_HT_EH_RFE 0x0020 /* Response Error Fatal Enable */ -#define PCI_HT_EH_CRCFE 0x0040 /* CRC Error Fatal Enable */ -#define PCI_HT_EH_SERRFE 0x0080 /* System Error Fatal Enable (B */ -#define PCI_HT_EH_CF 0x0100 /* Chain Fail */ -#define PCI_HT_EH_RE 0x0200 /* Response Error */ -#define PCI_HT_EH_PNFE 0x0400 /* Protocol Error Nonfatal Enable */ -#define PCI_HT_EH_ONFE 0x0800 /* Overflow Error Nonfatal Enable */ -#define PCI_HT_EH_EOCNFE 0x1000 /* End of Chain Error Nonfatal Enable */ -#define PCI_HT_EH_RNFE 0x2000 /* Response Error Nonfatal Enable */ -#define PCI_HT_EH_CRCNFE 0x4000 /* CRC Error Nonfatal Enable */ -#define PCI_HT_EH_SERRNFE 0x8000 /* System Error Nonfatal Enable */ - -/* HyperTransport: Slave or Primary Interface */ -#define PCI_HT_PRI_CMD 2 /* Command Register */ -#define PCI_HT_PRI_CMD_BUID 0x001f /* Base UnitID */ -#define PCI_HT_PRI_CMD_UC 0x03e0 /* Unit Count */ -#define PCI_HT_PRI_CMD_MH 0x0400 /* Master Host */ -#define PCI_HT_PRI_CMD_DD 0x0800 /* Default Direction */ -#define PCI_HT_PRI_CMD_DUL 0x1000 /* Drop on Uninitialized Link */ - -#define PCI_HT_PRI_LCTR0 4 /* Link Control 0 Register */ -#define PCI_HT_PRI_LCNF0 6 /* Link Config 0 Register */ -#define PCI_HT_PRI_LCTR1 8 /* Link Control 1 Register */ -#define PCI_HT_PRI_LCNF1 10 /* Link Config 1 Register */ -#define PCI_HT_PRI_RID 12 /* Revision ID Register */ -#define PCI_HT_PRI_LFRER0 13 /* Link Frequency/Error 0 Register */ -#define PCI_HT_PRI_LFCAP0 14 /* Link Frequency Capability 0 Register */ -#define PCI_HT_PRI_FTR 16 /* Feature Register */ -#define PCI_HT_PRI_LFRER1 17 /* Link Frequency/Error 1 Register */ -#define PCI_HT_PRI_LFCAP1 18 /* Link Frequency Capability 1 Register */ -#define PCI_HT_PRI_ES 20 /* Enumeration Scratchpad Register */ -#define PCI_HT_PRI_EH 22 /* Error Handling Register */ -#define PCI_HT_PRI_MBU 24 /* Memory Base Upper Register */ -#define PCI_HT_PRI_MLU 25 /* Memory Limit Upper Register */ -#define PCI_HT_PRI_BN 26 /* Bus Number Register */ -#define PCI_HT_PRI_SIZEOF 28 - -/* HyperTransport: Host or Secondary Interface */ -#define PCI_HT_SEC_CMD 2 /* Command Register */ -#define PCI_HT_SEC_CMD_WR 0x0001 /* Warm Reset */ -#define PCI_HT_SEC_CMD_DE 0x0002 /* Double-Ended */ -#define PCI_HT_SEC_CMD_DN 0x0076 /* Device Number */ -#define PCI_HT_SEC_CMD_CS 0x0080 /* Chain Side */ -#define PCI_HT_SEC_CMD_HH 0x0100 /* Host Hide */ -#define PCI_HT_SEC_CMD_AS 0x0400 /* Act as Slave */ -#define PCI_HT_SEC_CMD_HIECE 0x0800 /* Host Inbound End of Chain Error */ -#define PCI_HT_SEC_CMD_DUL 0x1000 /* Drop on Uninitialized Link */ - -#define PCI_HT_SEC_LCTR 4 /* Link Control Register */ -#define PCI_HT_SEC_LCNF 6 /* Link Config Register */ -#define PCI_HT_SEC_RID 8 /* Revision ID Register */ -#define PCI_HT_SEC_LFRER 9 /* Link Frequency/Error Register */ -#define PCI_HT_SEC_LFCAP 10 /* Link Frequency Capability Register */ -#define PCI_HT_SEC_FTR 12 /* Feature Register */ -#define PCI_HT_SEC_FTR_EXTRS 0x0100 /* Extended Register Set */ -#define PCI_HT_SEC_FTR_UCNFE 0x0200 /* Upstream Configuration Enable */ -#define PCI_HT_SEC_ES 16 /* Enumeration Scratchpad Register */ -#define PCI_HT_SEC_EH 18 /* Error Handling Register */ -#define PCI_HT_SEC_MBU 20 /* Memory Base Upper Register */ -#define PCI_HT_SEC_MLU 21 /* Memory Limit Upper Register */ -#define PCI_HT_SEC_SIZEOF 24 - -/* HyperTransport: Switch */ -#define PCI_HT_SW_CMD 2 /* Switch Command Register */ -#define PCI_HT_SW_CMD_VIBERR 0x0080 /* VIB Error */ -#define PCI_HT_SW_CMD_VIBFL 0x0100 /* VIB Flood */ -#define PCI_HT_SW_CMD_VIBFT 0x0200 /* VIB Fatal */ -#define PCI_HT_SW_CMD_VIBNFT 0x0400 /* VIB Nonfatal */ -#define PCI_HT_SW_PMASK 4 /* Partition Mask Register */ -#define PCI_HT_SW_SWINF 8 /* Switch Info Register */ -#define PCI_HT_SW_SWINF_DP 0x0000001f /* Default Port */ -#define PCI_HT_SW_SWINF_EN 0x00000020 /* Enable Decode */ -#define PCI_HT_SW_SWINF_CR 0x00000040 /* Cold Reset */ -#define PCI_HT_SW_SWINF_PCIDX 0x00000f00 /* Performance Counter Index */ -#define PCI_HT_SW_SWINF_BLRIDX 0x0003f000 /* Base/Limit Range Index */ -#define PCI_HT_SW_SWINF_SBIDX 0x00002000 /* Secondary Base Range Index */ -#define PCI_HT_SW_SWINF_HP 0x00040000 /* Hot Plug */ -#define PCI_HT_SW_SWINF_HIDE 0x00080000 /* Hide Port */ -#define PCI_HT_SW_PCD 12 /* Performance Counter Data Register */ -#define PCI_HT_SW_BLRD 16 /* Base/Limit Range Data Register */ -#define PCI_HT_SW_SBD 20 /* Secondary Base Data Register */ -#define PCI_HT_SW_SIZEOF 24 - - /* Counter indices */ -#define PCI_HT_SW_PC_PCR 0x0 /* Posted Command Receive */ -#define PCI_HT_SW_PC_NPCR 0x1 /* Nonposted Command Receive */ -#define PCI_HT_SW_PC_RCR 0x2 /* Response Command Receive */ -#define PCI_HT_SW_PC_PDWR 0x3 /* Posted DW Receive */ -#define PCI_HT_SW_PC_NPDWR 0x4 /* Nonposted DW Receive */ -#define PCI_HT_SW_PC_RDWR 0x5 /* Response DW Receive */ -#define PCI_HT_SW_PC_PCT 0x6 /* Posted Command Transmit */ -#define PCI_HT_SW_PC_NPCT 0x7 /* Nonposted Command Transmit */ -#define PCI_HT_SW_PC_RCT 0x8 /* Response Command Transmit */ -#define PCI_HT_SW_PC_PDWT 0x9 /* Posted DW Transmit */ -#define PCI_HT_SW_PC_NPDWT 0xa /* Nonposted DW Transmit */ -#define PCI_HT_SW_PC_RDWT 0xb /* Response DW Transmit */ - - /* Base/Limit Range indices */ -#define PCI_HT_SW_BLR_BASE0_LO 0x0 /* Base 0[31:1], Enable */ -#define PCI_HT_SW_BLR_BASE0_HI 0x1 /* Base 0 Upper */ -#define PCI_HT_SW_BLR_LIM0_LO 0x2 /* Limit 0 Lower */ -#define PCI_HT_SW_BLR_LIM0_HI 0x3 /* Limit 0 Upper */ - - /* Secondary Base indices */ -#define PCI_HT_SW_SB_LO 0x0 /* Secondary Base[31:1], Enable */ -#define PCI_HT_SW_S0_HI 0x1 /* Secondary Base Upper */ - -/* HyperTransport: Interrupt Discovery and Configuration */ -#define PCI_HT_IDC_IDX 2 /* Index Register */ -#define PCI_HT_IDC_DATA 4 /* Data Register */ -#define PCI_HT_IDC_SIZEOF 8 - - /* Register indices */ -#define PCI_HT_IDC_IDX_LINT 0x01 /* Last Interrupt Register */ -#define PCI_HT_IDC_LINT 0x00ff0000 /* Last interrupt definition */ -#define PCI_HT_IDC_IDX_IDR 0x10 /* Interrupt Definition Registers */ - /* Low part (at index) */ -#define PCI_HT_IDC_IDR_MASK 0x10000001 /* Mask */ -#define PCI_HT_IDC_IDR_POL 0x10000002 /* Polarity */ -#define PCI_HT_IDC_IDR_II_2 0x1000001c /* IntrInfo[4:2]: Message Type */ -#define PCI_HT_IDC_IDR_II_5 0x10000020 /* IntrInfo[5]: Request EOI */ -#define PCI_HT_IDC_IDR_II_6 0x00ffffc0 /* IntrInfo[23:6] */ -#define PCI_HT_IDC_IDR_II_24 0xff000000 /* IntrInfo[31:24] */ - /* High part (at index + 1) */ -#define PCI_HT_IDC_IDR_II_32 0x00ffffff /* IntrInfo[55:32] */ -#define PCI_HT_IDC_IDR_PASSPW 0x40000000 /* PassPW setting for messages */ -#define PCI_HT_IDC_IDR_WEOI 0x80000000 /* Waiting for EOI */ - -/* HyperTransport: Revision ID */ -#define PCI_HT_RID_RID 2 /* Revision Register */ -#define PCI_HT_RID_SIZEOF 4 - -/* HyperTransport: UnitID Clumping */ -#define PCI_HT_UIDC_CS 4 /* Clumping Support Register */ -#define PCI_HT_UIDC_CE 8 /* Clumping Enable Register */ -#define PCI_HT_UIDC_SIZEOF 12 - -/* HyperTransport: Extended Configuration Space Access */ -#define PCI_HT_ECSA_ADDR 4 /* Configuration Address Register */ -#define PCI_HT_ECSA_ADDR_REG 0x00000ffc /* Register */ -#define PCI_HT_ECSA_ADDR_FUN 0x00007000 /* Function */ -#define PCI_HT_ECSA_ADDR_DEV 0x000f1000 /* Device */ -#define PCI_HT_ECSA_ADDR_BUS 0x0ff00000 /* Bus Number */ -#define PCI_HT_ECSA_ADDR_TYPE 0x10000000 /* Access Type */ -#define PCI_HT_ECSA_DATA 8 /* Configuration Data Register */ -#define PCI_HT_ECSA_SIZEOF 12 - -/* HyperTransport: Address Mapping */ -#define PCI_HT_AM_CMD 2 /* Command Register */ -#define PCI_HT_AM_CMD_NDMA 0x000f /* Number of DMA Mappings */ -#define PCI_HT_AM_CMD_IOSIZ 0x01f0 /* I/O Size */ -#define PCI_HT_AM_CMD_MT 0x0600 /* Map Type */ -#define PCI_HT_AM_CMD_MT_40B 0x0000 /* 40-bit */ -#define PCI_HT_AM_CMD_MT_64B 0x0200 /* 64-bit */ - - /* Window Control Register bits */ -#define PCI_HT_AM_SBW_CTR_COMP 0x1 /* Compat */ -#define PCI_HT_AM_SBW_CTR_NCOH 0x2 /* NonCoherent */ -#define PCI_HT_AM_SBW_CTR_ISOC 0x4 /* Isochronous */ -#define PCI_HT_AM_SBW_CTR_EN 0x8 /* Enable */ - -/* HyperTransport: 40-bit Address Mapping */ -#define PCI_HT_AM40_SBNPW 4 /* Secondary Bus Non-Prefetchable Window Register */ -#define PCI_HT_AM40_SBW_BASE 0x000fffff /* Window Base */ -#define PCI_HT_AM40_SBW_CTR 0xf0000000 /* Window Control */ -#define PCI_HT_AM40_SBPW 8 /* Secondary Bus Prefetchable Window Register */ -#define PCI_HT_AM40_DMA_PBASE0 12 /* DMA Window Primary Base 0 Register */ -#define PCI_HT_AM40_DMA_CTR0 15 /* DMA Window Control 0 Register */ -#define PCI_HT_AM40_DMA_CTR_CTR 0xf0 /* Window Control */ -#define PCI_HT_AM40_DMA_SLIM0 16 /* DMA Window Secondary Limit 0 Register */ -#define PCI_HT_AM40_DMA_SBASE0 18 /* DMA Window Secondary Base 0 Register */ -#define PCI_HT_AM40_SIZEOF 12 /* size is variable: 12 + 8 * NDMA */ - -/* HyperTransport: 64-bit Address Mapping */ -#define PCI_HT_AM64_IDX 4 /* Index Register */ -#define PCI_HT_AM64_DATA_LO 8 /* Data Lower Register */ -#define PCI_HT_AM64_DATA_HI 12 /* Data Upper Register */ -#define PCI_HT_AM64_SIZEOF 16 - - /* Register indices */ -#define PCI_HT_AM64_IDX_SBNPW 0x00 /* Secondary Bus Non-Prefetchable Window Register */ -#define PCI_HT_AM64_W_BASE_LO 0xfff00000 /* Window Base Lower */ -#define PCI_HT_AM64_W_CTR 0x0000000f /* Window Control */ -#define PCI_HT_AM64_IDX_SBPW 0x01 /* Secondary Bus Prefetchable Window Register */ -#define PCI_HT_AM64_IDX_PBNPW 0x02 /* Primary Bus Non-Prefetchable Window Register */ -#define PCI_HT_AM64_IDX_DMAPB0 0x04 /* DMA Window Primary Base 0 Register */ -#define PCI_HT_AM64_IDX_DMASB0 0x05 /* DMA Window Secondary Base 0 Register */ -#define PCI_HT_AM64_IDX_DMASL0 0x06 /* DMA Window Secondary Limit 0 Register */ - -/* HyperTransport: MSI Mapping */ -#define PCI_HT_MSIM_CMD 2 /* Command Register */ -#define PCI_HT_MSIM_CMD_EN 0x0001 /* Mapping Active */ -#define PCI_HT_MSIM_CMD_FIXD 0x0002 /* MSI Mapping Address Fixed */ -#define PCI_HT_MSIM_ADDR_LO 4 /* MSI Mapping Address Lower Register */ -#define PCI_HT_MSIM_ADDR_HI 8 /* MSI Mapping Address Upper Register */ -#define PCI_HT_MSIM_SIZEOF 12 - -/* HyperTransport: DirectRoute */ -#define PCI_HT_DR_CMD 2 /* Command Register */ -#define PCI_HT_DR_CMD_NDRS 0x000f /* Number of DirectRoute Spaces */ -#define PCI_HT_DR_CMD_IDX 0x01f0 /* Index */ -#define PCI_HT_DR_EN 4 /* Enable Vector Register */ -#define PCI_HT_DR_DATA 8 /* Data Register */ -#define PCI_HT_DR_SIZEOF 12 - - /* Register indices */ -#define PCI_HT_DR_IDX_BASE_LO 0x00 /* DirectRoute Base Lower Register */ -#define PCI_HT_DR_OTNRD 0x00000001 /* Opposite to Normal Request Direction */ -#define PCI_HT_DR_BL_LO 0xffffff00 /* Base/Limit Lower */ -#define PCI_HT_DR_IDX_BASE_HI 0x01 /* DirectRoute Base Upper Register */ -#define PCI_HT_DR_IDX_LIMIT_LO 0x02 /* DirectRoute Limit Lower Register */ -#define PCI_HT_DR_IDX_LIMIT_HI 0x03 /* DirectRoute Limit Upper Register */ - -/* HyperTransport: VCSet */ -#define PCI_HT_VCS_SUP 4 /* VCSets Supported Register */ -#define PCI_HT_VCS_L1EN 5 /* Link 1 VCSets Enabled Register */ -#define PCI_HT_VCS_L0EN 6 /* Link 0 VCSets Enabled Register */ -#define PCI_HT_VCS_SBD 8 /* Stream Bucket Depth Register */ -#define PCI_HT_VCS_SINT 9 /* Stream Interval Register */ -#define PCI_HT_VCS_SSUP 10 /* Number of Streaming VCs Supported Register */ -#define PCI_HT_VCS_SSUP_0 0x00 /* Streaming VC 0 */ -#define PCI_HT_VCS_SSUP_3 0x01 /* Streaming VCs 0-3 */ -#define PCI_HT_VCS_SSUP_15 0x02 /* Streaming VCs 0-15 */ -#define PCI_HT_VCS_NFCBD 12 /* Non-FC Bucket Depth Register */ -#define PCI_HT_VCS_NFCINT 13 /* Non-FC Bucket Interval Register */ -#define PCI_HT_VCS_SIZEOF 16 - -/* HyperTransport: Retry Mode */ -#define PCI_HT_RM_CTR0 4 /* Control 0 Register */ -#define PCI_HT_RM_CTR_LRETEN 0x01 /* Link Retry Enable */ -#define PCI_HT_RM_CTR_FSER 0x02 /* Force Single Error */ -#define PCI_HT_RM_CTR_ROLNEN 0x04 /* Rollover Nonfatal Enable */ -#define PCI_HT_RM_CTR_FSS 0x08 /* Force Single Stomp */ -#define PCI_HT_RM_CTR_RETNEN 0x10 /* Retry Nonfatal Enable */ -#define PCI_HT_RM_CTR_RETFEN 0x20 /* Retry Fatal Enable */ -#define PCI_HT_RM_CTR_AA 0xc0 /* Allowed Attempts */ -#define PCI_HT_RM_STS0 5 /* Status 0 Register */ -#define PCI_HT_RM_STS_RETSNT 0x01 /* Retry Sent */ -#define PCI_HT_RM_STS_CNTROL 0x02 /* Count Rollover */ -#define PCI_HT_RM_STS_SRCV 0x04 /* Stomp Received */ -#define PCI_HT_RM_CTR1 6 /* Control 1 Register */ -#define PCI_HT_RM_STS1 7 /* Status 1 Register */ -#define PCI_HT_RM_CNT0 8 /* Retry Count 0 Register */ -#define PCI_HT_RM_CNT1 10 /* Retry Count 1 Register */ -#define PCI_HT_RM_SIZEOF 12 - -/* PCI Express */ -#define PCI_EXP_FLAGS 0x2 /* Capabilities register */ -#define PCI_EXP_FLAGS_VERS 0x000f /* Capability version */ -#define PCI_EXP_FLAGS_TYPE 0x00f0 /* Device/Port type */ -#define PCI_EXP_TYPE_ENDPOINT 0x0 /* Express Endpoint */ -#define PCI_EXP_TYPE_LEG_END 0x1 /* Legacy Endpoint */ -#define PCI_EXP_TYPE_ROOT_PORT 0x4 /* Root Port */ -#define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */ -#define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */ -#define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */ -#define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */ -#define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */ -#define PCI_EXP_DEVCAP 0x4 /* Device capabilities */ -#define PCI_EXP_DEVCAP_PAYLOAD 0x07 /* Max_Payload_Size */ -#define PCI_EXP_DEVCAP_PHANTOM 0x18 /* Phantom functions */ -#define PCI_EXP_DEVCAP_EXT_TAG 0x20 /* Extended tags */ -#define PCI_EXP_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */ -#define PCI_EXP_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */ -#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */ -#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */ -#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */ -#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */ -#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */ -#define PCI_EXP_DEVCTL 0x8 /* Device Control */ -#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */ -#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */ -#define PCI_EXP_DEVCTL_FERE 0x0004 /* Fatal Error Reporting Enable */ -#define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */ -#define PCI_EXP_DEVCTL_RELAXED 0x0010 /* Enable Relaxed Ordering */ -#define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */ -#define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */ -#define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */ -#define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */ -#define PCI_EXP_DEVCTL_NOSNOOP 0x0800 /* Enable No Snoop */ -#define PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */ -#define PCI_EXP_DEVSTA 0xa /* Device Status */ -#define PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */ -#define PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */ -#define PCI_EXP_DEVSTA_FED 0x04 /* Fatal Error Detected */ -#define PCI_EXP_DEVSTA_URD 0x08 /* Unsupported Request Detected */ -#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */ -#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */ -#define PCI_EXP_LNKCAP 0xc /* Link Capabilities */ -#define PCI_EXP_LNKCAP_SPEED 0x0000f /* Maximum Link Speed */ -#define PCI_EXP_LNKCAP_WIDTH 0x003f0 /* Maximum Link Width */ -#define PCI_EXP_LNKCAP_ASPM 0x00c00 /* Active State Power Management */ -#define PCI_EXP_LNKCAP_L0S 0x07000 /* L0s Acceptable Latency */ -#define PCI_EXP_LNKCAP_L1 0x38000 /* L1 Acceptable Latency */ -#define PCI_EXP_LNKCAP_PORT 0xff000000 /* Port Number */ -#define PCI_EXP_LNKCTL 0x10 /* Link Control */ -#define PCI_EXP_LNKCTL_ASPM 0x0003 /* ASPM Control */ -#define PCI_EXP_LNKCTL_RCB 0x0008 /* Read Completion Boundary */ -#define PCI_EXP_LNKCTL_DISABLE 0x0010 /* Link Disable */ -#define PCI_EXP_LNKCTL_RETRAIN 0x0020 /* Retrain Link */ -#define PCI_EXP_LNKCTL_CLOCK 0x0040 /* Common Clock Configuration */ -#define PCI_EXP_LNKCTL_XSYNCH 0x0080 /* Extended Synch */ -#define PCI_EXP_LNKSTA 0x12 /* Link Status */ -#define PCI_EXP_LNKSTA_SPEED 0x000f /* Negotiated Link Speed */ -#define PCI_EXP_LNKSTA_WIDTH 0x03f0 /* Negotiated Link Width */ -#define PCI_EXP_LNKSTA_TR_ERR 0x0400 /* Training Error */ -#define PCI_EXP_LNKSTA_TRAIN 0x0800 /* Link Training */ -#define PCI_EXP_LNKSTA_SL_CLK 0x1000 /* Slot Clock Configuration */ -#define PCI_EXP_SLTCAP 0x14 /* Slot Capabilities */ -#define PCI_EXP_SLTCAP_ATNB 0x0001 /* Attention Button Present */ -#define PCI_EXP_SLTCAP_PWRC 0x0002 /* Power Controller Present */ -#define PCI_EXP_SLTCAP_MRL 0x0004 /* MRL Sensor Present */ -#define PCI_EXP_SLTCAP_ATNI 0x0008 /* Attention Indicator Present */ -#define PCI_EXP_SLTCAP_PWRI 0x0010 /* Power Indicator Present */ -#define PCI_EXP_SLTCAP_HPS 0x0020 /* Hot-Plug Surprise */ -#define PCI_EXP_SLTCAP_HPC 0x0040 /* Hot-Plug Capable */ -#define PCI_EXP_SLTCAP_PWR_VAL 0x00007f80 /* Slot Power Limit Value */ -#define PCI_EXP_SLTCAP_PWR_SCL 0x00018000 /* Slot Power Limit Scale */ -#define PCI_EXP_SLTCAP_PSN 0xfff80000 /* Physical Slot Number */ -#define PCI_EXP_SLTCTL 0x18 /* Slot Control */ -#define PCI_EXP_SLTCTL_ATNB 0x0001 /* Attention Button Pressed Enable */ -#define PCI_EXP_SLTCTL_PWRF 0x0002 /* Power Fault Detected Enable */ -#define PCI_EXP_SLTCTL_MRLS 0x0004 /* MRL Sensor Changed Enable */ -#define PCI_EXP_SLTCTL_PRSD 0x0008 /* Presence Detect Changed Enable */ -#define PCI_EXP_SLTCTL_CMDC 0x0010 /* Command Completed Interrupt Enable */ -#define PCI_EXP_SLTCTL_HPIE 0x0020 /* Hot-Plug Interrupt Enable */ -#define PCI_EXP_SLTCTL_ATNI 0x00C0 /* Attention Indicator Control */ -#define PCI_EXP_SLTCTL_PWRI 0x0300 /* Power Indicator Control */ -#define PCI_EXP_SLTCTL_PWRC 0x0400 /* Power Controller Control */ -#define PCI_EXP_SLTSTA 0x1a /* Slot Status */ -#define PCI_EXP_RTCTL 0x1c /* Root Control */ -#define PCI_EXP_RTCTL_SECEE 0x1 /* System Error on Correctable Error */ -#define PCI_EXP_RTCTL_SENFEE 0x1 /* System Error on Non-Fatal Error */ -#define PCI_EXP_RTCTL_SEFEE 0x1 /* System Error on Fatal Error */ -#define PCI_EXP_RTCTL_PMEIE 0x1 /* PME Interrupt Enable */ -#define PCI_EXP_RTSTA 0x20 /* Root Status */ - -/* MSI-X */ -#define PCI_MSIX_ENABLE 0x8000 -#define PCI_MSIX_MASK 0x4000 -#define PCI_MSIX_TABSIZE 0x03ff -#define PCI_MSIX_TABLE 4 -#define PCI_MSIX_PBA 8 -#define PCI_MSIX_BIR 0x7 - -/* Advanced Error Reporting */ -#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */ -#define PCI_ERR_UNC_TRAIN 0x00000001 /* Training */ -#define PCI_ERR_UNC_DLP 0x00000010 /* Data Link Protocol */ -#define PCI_ERR_UNC_POISON_TLP 0x00001000 /* Poisoned TLP */ -#define PCI_ERR_UNC_FCP 0x00002000 /* Flow Control Protocol */ -#define PCI_ERR_UNC_COMP_TIME 0x00004000 /* Completion Timeout */ -#define PCI_ERR_UNC_COMP_ABORT 0x00008000 /* Completer Abort */ -#define PCI_ERR_UNC_UNX_COMP 0x00010000 /* Unexpected Completion */ -#define PCI_ERR_UNC_RX_OVER 0x00020000 /* Receiver Overflow */ -#define PCI_ERR_UNC_MALF_TLP 0x00040000 /* Malformed TLP */ -#define PCI_ERR_UNC_ECRC 0x00080000 /* ECRC Error Status */ -#define PCI_ERR_UNC_UNSUP 0x00100000 /* Unsupported Request */ -#define PCI_ERR_UNCOR_MASK 8 /* Uncorrectable Error Mask */ - /* Same bits as above */ -#define PCI_ERR_UNCOR_SEVER 12 /* Uncorrectable Error Severity */ - /* Same bits as above */ -#define PCI_ERR_COR_STATUS 16 /* Correctable Error Status */ -#define PCI_ERR_COR_RCVR 0x00000001 /* Receiver Error Status */ -#define PCI_ERR_COR_BAD_TLP 0x00000040 /* Bad TLP Status */ -#define PCI_ERR_COR_BAD_DLLP 0x00000080 /* Bad DLLP Status */ -#define PCI_ERR_COR_REP_ROLL 0x00000100 /* REPLAY_NUM Rollover */ -#define PCI_ERR_COR_REP_TIMER 0x00001000 /* Replay Timer Timeout */ -#define PCI_ERR_COR_MASK 20 /* Correctable Error Mask */ - /* Same bits as above */ -#define PCI_ERR_CAP 24 /* Advanced Error Capabilities */ -#define PCI_ERR_CAP_FEP(x) ((x) & 31) /* First Error Pointer */ -#define PCI_ERR_CAP_ECRC_GENC 0x00000020 /* ECRC Generation Capable */ -#define PCI_ERR_CAP_ECRC_GENE 0x00000040 /* ECRC Generation Enable */ -#define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */ -#define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */ -#define PCI_ERR_HEADER_LOG 28 /* Header Log Register (16 bytes) */ -#define PCI_ERR_ROOT_COMMAND 44 /* Root Error Command */ -#define PCI_ERR_ROOT_STATUS 48 -#define PCI_ERR_ROOT_COR_SRC 52 -#define PCI_ERR_ROOT_SRC 54 - -/* Virtual Channel */ -#define PCI_VC_PORT_REG1 4 -#define PCI_VC_PORT_REG2 8 -#define PCI_VC_PORT_CTRL 12 -#define PCI_VC_PORT_STATUS 14 -#define PCI_VC_RES_CAP 16 -#define PCI_VC_RES_CTRL 20 -#define PCI_VC_RES_STATUS 26 - -/* Power Budgeting */ -#define PCI_PWR_DSR 4 /* Data Select Register */ -#define PCI_PWR_DATA 8 /* Data Register */ -#define PCI_PWR_DATA_BASE(x) ((x) & 0xff) /* Base Power */ -#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3) /* Data Scale */ -#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7) /* PM Sub State */ -#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */ -#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7) /* Type */ -#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7) /* Power Rail */ -#define PCI_PWR_CAP 12 /* Capability */ -#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */ - -/* - * The PCI interface treats multi-function devices as independent - * devices. The slot/function address of each device is encoded - * in a single byte as follows: - * - * 7:3 = slot - * 2:0 = function - */ -#define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) -#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) -#define PCI_FUNC(devfn) ((devfn) & 0x07) - -/* Device classes and subclasses */ - -#define PCI_CLASS_NOT_DEFINED 0x0000 -#define PCI_CLASS_NOT_DEFINED_VGA 0x0001 - -#define PCI_BASE_CLASS_STORAGE 0x01 -#define PCI_CLASS_STORAGE_SCSI 0x0100 -#define PCI_CLASS_STORAGE_IDE 0x0101 -#define PCI_CLASS_STORAGE_FLOPPY 0x0102 -#define PCI_CLASS_STORAGE_IPI 0x0103 -#define PCI_CLASS_STORAGE_RAID 0x0104 -#define PCI_CLASS_STORAGE_OTHER 0x0180 - -#define PCI_BASE_CLASS_NETWORK 0x02 -#define PCI_CLASS_NETWORK_ETHERNET 0x0200 -#define PCI_CLASS_NETWORK_TOKEN_RING 0x0201 -#define PCI_CLASS_NETWORK_FDDI 0x0202 -#define PCI_CLASS_NETWORK_ATM 0x0203 -#define PCI_CLASS_NETWORK_OTHER 0x0280 - -#define PCI_BASE_CLASS_DISPLAY 0x03 -#define PCI_CLASS_DISPLAY_VGA 0x0300 -#define PCI_CLASS_DISPLAY_XGA 0x0301 -#define PCI_CLASS_DISPLAY_OTHER 0x0380 - -#define PCI_BASE_CLASS_MULTIMEDIA 0x04 -#define PCI_CLASS_MULTIMEDIA_VIDEO 0x0400 -#define PCI_CLASS_MULTIMEDIA_AUDIO 0x0401 -#define PCI_CLASS_MULTIMEDIA_OTHER 0x0480 - -#define PCI_BASE_CLASS_MEMORY 0x05 -#define PCI_CLASS_MEMORY_RAM 0x0500 -#define PCI_CLASS_MEMORY_FLASH 0x0501 -#define PCI_CLASS_MEMORY_OTHER 0x0580 - -#define PCI_BASE_CLASS_BRIDGE 0x06 -#define PCI_CLASS_BRIDGE_HOST 0x0600 -#define PCI_CLASS_BRIDGE_ISA 0x0601 -#define PCI_CLASS_BRIDGE_EISA 0x0602 -#define PCI_CLASS_BRIDGE_MC 0x0603 -#define PCI_CLASS_BRIDGE_PCI 0x0604 -#define PCI_CLASS_BRIDGE_PCMCIA 0x0605 -#define PCI_CLASS_BRIDGE_NUBUS 0x0606 -#define PCI_CLASS_BRIDGE_CARDBUS 0x0607 -#define PCI_CLASS_BRIDGE_OTHER 0x0680 - -#define PCI_BASE_CLASS_COMMUNICATION 0x07 -#define PCI_CLASS_COMMUNICATION_SERIAL 0x0700 -#define PCI_CLASS_COMMUNICATION_PARALLEL 0x0701 -#define PCI_CLASS_COMMUNICATION_OTHER 0x0780 - -#define PCI_BASE_CLASS_SYSTEM 0x08 -#define PCI_CLASS_SYSTEM_PIC 0x0800 -#define PCI_CLASS_SYSTEM_DMA 0x0801 -#define PCI_CLASS_SYSTEM_TIMER 0x0802 -#define PCI_CLASS_SYSTEM_RTC 0x0803 -#define PCI_CLASS_SYSTEM_OTHER 0x0880 - -#define PCI_BASE_CLASS_INPUT 0x09 -#define PCI_CLASS_INPUT_KEYBOARD 0x0900 -#define PCI_CLASS_INPUT_PEN 0x0901 -#define PCI_CLASS_INPUT_MOUSE 0x0902 -#define PCI_CLASS_INPUT_OTHER 0x0980 - -#define PCI_BASE_CLASS_DOCKING 0x0a -#define PCI_CLASS_DOCKING_GENERIC 0x0a00 -#define PCI_CLASS_DOCKING_OTHER 0x0a01 - -#define PCI_BASE_CLASS_PROCESSOR 0x0b -#define PCI_CLASS_PROCESSOR_386 0x0b00 -#define PCI_CLASS_PROCESSOR_486 0x0b01 -#define PCI_CLASS_PROCESSOR_PENTIUM 0x0b02 -#define PCI_CLASS_PROCESSOR_ALPHA 0x0b10 -#define PCI_CLASS_PROCESSOR_POWERPC 0x0b20 -#define PCI_CLASS_PROCESSOR_CO 0x0b40 - -#define PCI_BASE_CLASS_SERIAL 0x0c -#define PCI_CLASS_SERIAL_FIREWIRE 0x0c00 -#define PCI_CLASS_SERIAL_ACCESS 0x0c01 -#define PCI_CLASS_SERIAL_SSA 0x0c02 -#define PCI_CLASS_SERIAL_USB 0x0c03 -#define PCI_CLASS_SERIAL_FIBER 0x0c04 - -#define PCI_CLASS_OTHERS 0xff - -/* Several ID's we need in the library */ - -#define PCI_VENDOR_ID_INTEL 0x8086 -#define PCI_VENDOR_ID_COMPAQ 0x0e11 diff --git a/pci/pci.h b/pci/pci.h deleted file mode 100644 index 5b551ba..0000000 --- a/pci/pci.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * The PCI Library - * - * Copyright (c) 1997--2005 Martin Mares <mj@ucw.cz> - * - * Can be freely distributed and used under the terms of the GNU GPL. - */ - -#ifndef _PCI_LIB_H -#define _PCI_LIB_H - -#include "config.h" -#include "header.h" -#include "types.h" - -#define PCI_LIB_VERSION 0x020200 - -/* - * PCI Access Structure - */ - -struct pci_methods; - -enum pci_access_type { - /* Known access methods, remember to update access.c as well */ - PCI_ACCESS_AUTO, /* Autodetection (params: none) */ - PCI_ACCESS_SYS_BUS_PCI, /* Linux /sys/bus/pci (params: path) */ - PCI_ACCESS_PROC_BUS_PCI, /* Linux /proc/bus/pci (params: path) */ - PCI_ACCESS_I386_TYPE1, /* i386 ports, type 1 (params: none) */ - PCI_ACCESS_I386_TYPE2, /* i386 ports, type 2 (params: none) */ - PCI_ACCESS_FBSD_DEVICE, /* FreeBSD /dev/pci (params: path) */ - PCI_ACCESS_AIX_DEVICE, /* /dev/pci0, /dev/bus0, etc. */ - PCI_ACCESS_NBSD_LIBPCI, /* NetBSD libpci */ - PCI_ACCESS_DUMP, /* Dump file (params: filename) */ - PCI_ACCESS_MAX -}; - -struct pci_access { - /* Options you can change: */ - unsigned int method; /* Access method */ - char *method_params[PCI_ACCESS_MAX]; /* Parameters for the methods */ - int writeable; /* Open in read/write mode */ - int buscentric; /* Bus-centric view of the world */ - char *id_file_name; /* Name of ID list file */ - int numeric_ids; /* Don't resolve device IDs to names */ - int debugging; /* Turn on debugging messages */ - - /* Functions you can override: */ - void (*error)(char *msg, ...); /* Write error message and quit */ - void (*warning)(char *msg, ...); /* Write a warning message */ - void (*debug)(char *msg, ...); /* Write a debugging message */ - - struct pci_dev *devices; /* Devices found on this bus */ - - /* Fields used internally: */ - struct pci_methods *methods; - struct id_entry **id_hash; /* names.c */ - struct id_bucket *current_id_bucket; - int fd; /* proc: fd */ - int fd_rw; /* proc: fd opened read-write */ - struct pci_dev *cached_dev; /* proc: device the fd is for */ - int fd_pos; /* proc: current position */ -}; - -/* Initialize PCI access */ -struct pci_access *pci_alloc(void); -void pci_init(struct pci_access *); -void pci_cleanup(struct pci_access *); - -/* Scanning of devices */ -void pci_scan_bus(struct pci_access *acc); -struct pci_dev *pci_get_dev(struct pci_access *acc, int domain, int bus, int dev, int func); /* Raw access to specified device */ -void pci_free_dev(struct pci_dev *); - -/* - * Devices - */ - -struct pci_dev { - struct pci_dev *next; /* Next device in the chain */ - u16 domain; /* PCI domain (host bridge) */ - u8 bus, dev, func; /* Bus inside domain, device and function */ - - /* These fields are set by pci_fill_info() */ - int known_fields; /* Set of info fields already known */ - u16 vendor_id, device_id; /* Identity of the device */ - int irq; /* IRQ number */ - pciaddr_t base_addr[6]; /* Base addresses */ - pciaddr_t size[6]; /* Region sizes */ - pciaddr_t rom_base_addr; /* Expansion ROM base address */ - pciaddr_t rom_size; /* Expansion ROM size */ - - /* Fields used internally: */ - struct pci_access *access; - struct pci_methods *methods; - u8 *cache; /* Cached config registers */ - int cache_len; - int hdrtype; /* Cached low 7 bits of header type, -1 if unknown */ - void *aux; /* Auxillary data */ -}; - -#define PCI_ADDR_IO_MASK (~(pciaddr_t) 0x3) -#define PCI_ADDR_MEM_MASK (~(pciaddr_t) 0xf) - -u8 pci_read_byte(struct pci_dev *, int pos); /* Access to configuration space */ -u16 pci_read_word(struct pci_dev *, int pos); -u32 pci_read_long(struct pci_dev *, int pos); -int pci_read_block(struct pci_dev *, int pos, u8 *buf, int len); -int pci_write_byte(struct pci_dev *, int pos, u8 data); -int pci_write_word(struct pci_dev *, int pos, u16 data); -int pci_write_long(struct pci_dev *, int pos, u32 data); -int pci_write_block(struct pci_dev *, int pos, u8 *buf, int len); - -int pci_fill_info(struct pci_dev *, int flags); /* Fill in device information */ - -#define PCI_FILL_IDENT 1 -#define PCI_FILL_IRQ 2 -#define PCI_FILL_BASES 4 -#define PCI_FILL_ROM_BASE 8 -#define PCI_FILL_SIZES 16 -#define PCI_FILL_RESCAN 0x10000 - -void pci_setup_cache(struct pci_dev *, u8 *cache, int len); - -/* - * Filters - */ - -struct pci_filter { - int domain, bus, slot, func; /* -1 = ANY */ - int vendor, device; -}; - -void pci_filter_init(struct pci_access *, struct pci_filter *); -char *pci_filter_parse_slot(struct pci_filter *, char *); -char *pci_filter_parse_id(struct pci_filter *, char *); -int pci_filter_match(struct pci_filter *, struct pci_dev *); - -/* - * Conversion of PCI ID's to names (according to the pci.ids file) - * - * Call pci_lookup_name() to identify different types of ID's: - * - * VENDOR (vendorID) -> vendor - * DEVICE (vendorID, deviceID) -> device - * VENDOR | DEVICE (vendorID, deviceID) -> combined vendor and device - * SUBSYSTEM | VENDOR (subvendorID) -> subsystem vendor - * SUBSYSTEM | DEVICE (vendorID, deviceID, subvendorID, subdevID) -> subsystem device - * SUBSYSTEM | VENDOR | DEVICE (vendorID, deviceID, subvendorID, subdevID) -> combined subsystem v+d - * SUBSYSTEM | ... (-1, -1, subvendorID, subdevID) -> generic subsystem - * CLASS (classID) -> class - * PROGIF (classID, progif) -> programming interface - */ - -char *pci_lookup_name(struct pci_access *a, char *buf, int size, int flags, ...); - -int pci_load_name_list(struct pci_access *a); /* Called automatically by pci_lookup_*() when needed; returns success */ -void pci_free_name_list(struct pci_access *a); /* Called automatically by pci_cleanup() */ - -enum pci_lookup_mode { - PCI_LOOKUP_VENDOR = 1, /* Vendor name (args: vendorID) */ - PCI_LOOKUP_DEVICE = 2, /* Device name (args: vendorID, deviceID) */ - PCI_LOOKUP_CLASS = 4, /* Device class (args: classID) */ - PCI_LOOKUP_SUBSYSTEM = 8, - PCI_LOOKUP_PROGIF = 16, /* Programming interface (args: classID, prog_if) */ - PCI_LOOKUP_NUMERIC = 0x10000, /* Want only formatted numbers; default if access->numeric_ids is set */ - PCI_LOOKUP_NO_NUMBERS = 0x20000 /* Return NULL if not found in the database; default is to print numerically */ -}; - -#endif diff --git a/pci/types.h b/pci/types.h deleted file mode 100755 index 4808f56..0000000 --- a/pci/types.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The PCI Library -- Types and Format Strings - * - * Copyright (c) 1997--2005 Martin Mares <mj@ucw.cz> - * - * Can be freely distributed and used under the terms of the GNU GPL. - */ - -#include <sys/types.h> - -#ifndef PCI_HAVE_Uxx_TYPES - -#ifdef PCI_OS_WINDOWS -typedef unsigned __int8 u8; -typedef unsigned __int16 u16; -typedef unsigned __int32 u32; -#else -typedef u_int8_t u8; -typedef u_int16_t u16; -typedef u_int32_t u32; -#endif - -#ifdef PCI_HAVE_64BIT_ADDRESS -#include <limits.h> -#if ULONG_MAX > 0xffffffff -typedef unsigned long u64; -#define PCI_U64_FMT "l" -#else -typedef unsigned long long u64; -#define PCI_U64_FMT "ll" -#endif -#endif - -#endif /* PCI_HAVE_Uxx_TYPES */ - -#ifdef PCI_HAVE_64BIT_ADDRESS -typedef u64 pciaddr_t; -#define PCIADDR_T_FMT "%08" PCI_U64_FMT "x" -#define PCIADDR_PORT_FMT "%04" PCI_U64_FMT "x" -#else -typedef u32 pciaddr_t; -#define PCIADDR_T_FMT "%08x" -#define PCIADDR_PORT_FMT "%04x" -#endif - -#ifdef PCI_ARCH_SPARC64 -/* On sparc64 Linux the kernel reports remapped port addresses and IRQ numbers */ -#undef PCIADDR_PORT_FMT -#define PCIADDR_PORT_FMT PCIADDR_T_FMT -#define PCIIRQ_FMT "%08x" -#else -#define PCIIRQ_FMT "%d" -#endif diff --git a/public.mk b/public.mk deleted file mode 100644 index 4a905b8..0000000 --- a/public.mk +++ /dev/null @@ -1,310 +0,0 @@ -# -# nvidia-installer: A tool for installing NVIDIA software packages on -# Unix and Linux systems. -# -# Copyright (C) 2008 NVIDIA Corporation -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the: -# -# Free Software Foundation, Inc. -# 59 Temple Place - Suite 330 -# Boston, MA 02111-1307, USA -# -# -# Makefile -# - - -############################################################################## -# include common variables and functions -############################################################################## - -include utils.mk - - -############################################################################## -# The calling Makefile may export any of the following variables; we -# assign default values if they are not exported by the caller -############################################################################## - - -NCURSES_CFLAGS ?= -NCURSES_LDFLAGS ?= -PCI_CFLAGS ?= -PCI_LDFLAGS ?= - - -############################################################################## -# assign variables -############################################################################## - -NVIDIA_INSTALLER = $(OUTPUTDIR)/nvidia-installer -MKPRECOMPILED = $(OUTPUTDIR)/mkprecompiled -MAKESELF_HELP_SCRIPT = $(OUTPUTDIR)/makeself-help-script - -NVIDIA_INSTALLER_PROGRAM_NAME = "nvidia-installer" - -NVIDIA_INSTALLER_VERSION := $(NVIDIA_VERSION) - -NCURSES_UI_C = ncurses-ui.c -NCURSES_UI_SO = $(OUTPUTDIR)/nvidia-installer-ncurses-ui.so -NCURSES_UI_SO_C = $(OUTPUTDIR)/g_$(notdir $(NCURSES_UI_SO:.so=.c)) - -TLS_TEST_C = $(OUTPUTDIR)/g_tls_test.c -TLS_TEST_DSO_C = $(OUTPUTDIR)/g_tls_test_dso.c -TLS_TEST = tls_test_$(TARGET_OS)-$(TARGET_ARCH) -TLS_TEST_DSO_SO = tls_test_dso_$(TARGET_OS)-$(TARGET_ARCH).so - -TLS_TEST_32_C = $(OUTPUTDIR)/g_tls_test_32.c -TLS_TEST_DSO_32_C = $(OUTPUTDIR)/g_tls_test_dso_32.c -TLS_TEST_32 = tls_test_$(TARGET_OS)-x86 -TLS_TEST_DSO_SO_32 = tls_test_dso_$(TARGET_OS)-x86.so - -RTLD_TEST_C = $(OUTPUTDIR)/g_rtld_test.c -RTLD_TEST = rtld_test_$(TARGET_OS)-$(TARGET_ARCH) - -RTLD_TEST_32_C = $(OUTPUTDIR)/g_rtld_test_32.c -RTLD_TEST_32 = rtld_test_$(TARGET_OS)-x86 - -GEN_UI_ARRAY = $(OUTPUTDIR)/gen-ui-array -CONFIG_H = $(OUTPUTDIR)/config.h - -MANPAGE = $(OUTPUTDIR)/nvidia-installer.1.gz -GEN_MANPAGE_OPTS = $(OUTPUTDIR)/gen-manpage-opts -OPTIONS_1_INC = $(OUTPUTDIR)/options.1.inc - -# Setup some architecture specific build options -ifeq ($(TARGET_OS)-$(TARGET_ARCH), Linux-x86_64) - TLS_MODEL = initial-exec - PIC = -fPIC - CFLAGS += -DNV_X86_64 - # Only Linux-x86_64 needs the tls_test_32 files - COMPAT_32_SRC = $(TLS_TEST_32_C) $(TLS_TEST_DSO_32_C) \ - $(RTLD_TEST_32_C) -else - # So far all other platforms use local-exec - TLS_MODEL = local-exec - PIC = - # Non-Linux-x86_64 platforms do not include the tls_test_32 files - COMPAT_32_SRC = -endif - -# include the list of source files; defines SRC -include dist-files.mk - -INSTALLER_SRC = $(SRC) $(NCURSES_UI_SO_C) $(TLS_TEST_C) $(TLS_TEST_DSO_C) \ - $(RTLD_TEST_C) $(COMPAT_32_SRC) $(STAMP_C) - -INSTALLER_OBJS = $(call BUILD_OBJECT_LIST,$(INSTALLER_SRC)) - -CFLAGS += -I. -imacros $(CONFIG_H) -I $(OUTPUTDIR) -HOST_CFLAGS += -I. -imacros $(CONFIG_H) -I $(OUTPUTDIR) -LDFLAGS += -L. -ldl - -MKPRECOMPILED_SRC = crc.c mkprecompiled.c -MKPRECOMPILED_OBJS = $(call BUILD_OBJECT_LIST,$(MKPRECOMPILED_SRC)) - -MAKESELF_HELP_SCRIPT_SRC = makeself-help-script.c \ - help-args.c \ - format.c \ - string-utils.c \ - alloc-utils.c - -BUILD_MAKESELF_OBJECT_LIST = \ - $(patsubst %.o,%.makeself.o,$(call BUILD_OBJECT_LIST,$(1))) - -MAKESELF_HELP_SCRIPT_OBJS = \ - $(call BUILD_MAKESELF_OBJECT_LIST,$(MAKESELF_HELP_SCRIPT_SRC)) - -ALL_SRC = $(sort $(INSTALLER_SRC) $(NCURSES_UI_C) $(MKPRECOMPILED_SRC)) - -# define a quiet rule for GEN-UI-ARRAY -quiet_GEN_UI_ARRAY = GEN-UI-ARRAY $@ - - -############################################################################## -# build rules -############################################################################## - -.PNONY: all install NVIDIA_INSTALLER_install MKPRECOMPILED_install \ - MANPAGE_install MAKESELF_HELP_SCRIPT_install clean clobber - -all: $(NVIDIA_INSTALLER) $(MKPRECOMPILED) $(MAKESELF_HELP_SCRIPT) $(MANPAGE) - -install: NVIDIA_INSTALLER_install MKPRECOMPILED_install MANPAGE_install \ - MAKESELF_HELP_SCRIPT_install - -NVIDIA_INSTALLER_install: $(NVIDIA_INSTALLER) - $(MKDIR) $(bindir) - $(INSTALL) $(INSTALL_BIN_ARGS) $< $(bindir)/$(notdir $<) - -MKPRECOMPILED_install: $(MKPRECOMPILED) - $(MKDIR) $(bindir) - $(INSTALL) $(INSTALL_BIN_ARGS) $< $(bindir)/$(notdir $<) - -MAKESELF_HELP_SCRIPT_install: $(MAKESELF_HELP_SCRIPT) - $(MKDIR) $(bindir) - $(INSTALL) $(INSTALL_BIN_ARGS) $< $(bindir)/$(notdir $<) - -MANPAGE_install: $(MANPAGE) - $(MKDIR) $(mandir) - $(INSTALL) $(INSTALL_DOC_ARGS) $< $(mandir)/$(notdir $<) - -$(MKPRECOMPILED): $(MKPRECOMPILED_OBJS) - $(call quiet_cmd,LINK) -o $@ \ - $(MKPRECOMPILED_OBJS) $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS) - $(STRIP_CMD) $@ - -$(MAKESELF_HELP_SCRIPT): $(MAKESELF_HELP_SCRIPT_OBJS) - $(call quiet_cmd,HOST_LINK) -o $@ \ - $(MAKESELF_HELP_SCRIPT_OBJS) $(HOST_CFLAGS) $(HOST_LDFLAGS) \ - $(HOST_BIN_LDFLAGS) - $(STRIP_CMD) $@ - -$(NVIDIA_INSTALLER): $(INSTALLER_OBJS) - $(call quiet_cmd,LINK) -o $@ $(INSTALLER_OBJS) $(CFLAGS) $(LDFLAGS) \ - -Bstatic $(PCI_LDFLAGS) -lpci -Bdynamic $(BIN_LDFLAGS) - $(STRIP_CMD) $@ - -$(GEN_UI_ARRAY): gen-ui-array.c $(CONFIG_H) - $(call quiet_cmd,HOST_CC) -o $@ $< $(HOST_CFLAGS) $(HOST_LDFLAGS) \ - $(HOST_BIN_LDFLAGS) - -$(NCURSES_UI_SO): $(call BUILD_OBJECT_LIST,ncurses-ui.c) - $(call quiet_cmd,LINK) -o $@ -shared $< \ - $(NCURSES_LDFLAGS) -lncurses \ - $(CFLAGS) $(LDFLAGS) $(BIN_LDFLAGS) - -$(NCURSES_UI_SO_C): $(GEN_UI_ARRAY) $(NCURSES_UI_SO) - $(call quiet_cmd,GEN_UI_ARRAY) $(NCURSES_UI_SO) ncurses_ui_array > $@ - -$(TLS_TEST_C): $(GEN_UI_ARRAY) $(TLS_TEST) - $(call quiet_cmd,GEN_UI_ARRAY) $(TLS_TEST) tls_test_array > $@ - -$(TLS_TEST_DSO_C): $(GEN_UI_ARRAY) $(TLS_TEST_DSO_SO) - $(call quiet_cmd,GEN_UI_ARRAY) \ - $(TLS_TEST_DSO_SO) tls_test_dso_array > $@ - -$(TLS_TEST_32_C): $(GEN_UI_ARRAY) $(TLS_TEST_32) - $(call quiet_cmd,GEN_UI_ARRAY) $(TLS_TEST_32) tls_test_array_32 > $@ - -$(TLS_TEST_DSO_32_C): $(GEN_UI_ARRAY) $(TLS_TEST_DSO_SO_32) - $(call quiet_cmd,GEN_UI_ARRAY) \ - $(TLS_TEST_DSO_SO_32) tls_test_dso_array_32 > $@ - -$(RTLD_TEST_C): $(GEN_UI_ARRAY) $(RTLD_TEST) - $(call quiet_cmd,GEN_UI_ARRAY) $(RTLD_TEST) rtld_test_array > $@ - -$(RTLD_TEST_32_C): $(GEN_UI_ARRAY) $(RTLD_TEST_32) - $(call quiet_cmd,GEN_UI_ARRAY) $(RTLD_TEST_32) rtld_test_array_32 > $@ - -# misc.c includes pci.h -$(call BUILD_OBJECT_LIST,misc.c): CFLAGS += $(PCI_CFLAGS) - -# ncurses-ui.c includes ncurses.h -$(call BUILD_OBJECT_LIST,ncurses-ui.c): CFLAGS += $(NCURSES_CFLAGS) -fPIC - -# define the rule to build each object file -$(foreach src,$(ALL_SRC),$(eval $(call DEFINE_OBJECT_RULE,CC,$(src)))) - -# define a rule to build each makeself-help-script object file -$(foreach src,$(MAKESELF_HELP_SCRIPT_SRC),\ - $(eval $(call DEFINE_OBJECT_RULE_WITH_OBJECT_NAME,HOST_CC,$(src),\ - $(call BUILD_MAKESELF_OBJECT_LIST,$(src))))) - -# define the rule to generate $(STAMP_C) -$(eval $(call DEFINE_STAMP_C_RULE, $(INSTALLER_OBJS), $(NVIDIA_INSTALLER_PROGRAM_NAME))) - -$(CONFIG_H): - @ $(RM) -f $@ - @ $(MKDIR) $(OUTPUTDIR) - @ $(ECHO) "#define INSTALLER_OS \"$(TARGET_OS)\"" >> $@ - @ $(ECHO) "#define INSTALLER_ARCH \"$(TARGET_ARCH)\"" >> $@ - @ $(ECHO) -n "#define NVIDIA_INSTALLER_VERSION " >> $@ - @ $(ECHO) "\"$(NVIDIA_INSTALLER_VERSION)\"" >> $@ - @ $(ECHO) -n "#define PROGRAM_NAME " >> $@ - @ $(ECHO) "\"$(NVIDIA_INSTALLER_PROGRAM_NAME)\"" >> $@ - -$(call BUILD_OBJECT_LIST,$(ALL_SRC)): $(CONFIG_H) -$(call BUILD_MAKESELF_OBJECT_LIST,$(MAKESELF_HELP_SCRIPT_SRC)): $(CONFIG_H) - -clean clobber: - rm -rf $(OUTPUTDIR) - - -############################################################################## -# rule to rebuild tls_test and tls_test_dso; a precompiled tls_test -# and tls_test_dso is distributed with nvidia_installer because they -# require a recent toolchain to build. -############################################################################## - -rebuild_tls_test: tls_test.c - gcc -Wall -O2 -fomit-frame-pointer -o $(TLS_TEST) -ldl $< - strip $(TLS_TEST) - -rebuild_tls_test_dso: tls_test_dso.c - gcc -Wall -O2 $(PIC) -fomit-frame-pointer -c $< \ - -ftls-model=$(TLS_MODEL) - gcc -o $(TLS_TEST_DSO_SO) -shared tls_test_dso.o - strip $(TLS_TEST_DSO_SO) - -# dummy rule to override implicit rule that builds tls_test from -# tls_test.c - -tls_test: tls_test.c - touch $@ - -# rule to rebuild rtld_test; a precompiled rtld_test is distributed with -# nvidia-installer to simplify x86-64 builds. - -rebuild_rtld_test: rtld_test.c - gcc -Wall -O2 -fomit-frame-pointer -o $(RTLD_TEST) -lGL $< - strip $(RTLD_TEST) - -# dummy rule to override implicit rule that builds dls_test from -# rtld_test.c - -rtld_test: rtld_test.c - touch $@ - - -############################################################################## -# Documentation -############################################################################## - -AUTO_TEXT = ".\\\" WARNING: THIS FILE IS AUTO-GENERATED! Edit $< instead." - -doc: $(MANPAGE) - -$(eval $(call DEFINE_OBJECT_RULE,HOST_CC,gen-manpage-opts.c)) - -$(call BUILD_OBJECT_LIST,gen-manpage-opts.c): $(CONFIG_H) - -$(GEN_MANPAGE_OPTS): $(call BUILD_OBJECT_LIST,gen-manpage-opts.c) - $(call quiet_cmd,HOST_LINK) $< -o $@ \ - $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_BIN_LDFLAGS) - -$(OPTIONS_1_INC): $(GEN_MANPAGE_OPTS) - @./$< > $@ - -$(MANPAGE): nvidia-installer.1.m4 $(OPTIONS_1_INC) - $(call quiet_cmd,M4) \ - -D__HEADER__=$(AUTO_TEXT) \ - -D__VERSION__=$(NVIDIA_INSTALLER_VERSION) \ - -D__TARGET_OS__="$(TARGET_OS)" \ - -D__TARGET_ARCH__="$(TARGET_ARCH)" \ - -D__DRIVER_VERSION__="$(NVIDIA_VERSION)" \ - -D__OUTPUTDIR__=$(OUTPUTDIR) \ - -I $(OUTPUTDIR) \ - $< | $(GZIP_CMD) -9f > $@ @@ -221,26 +221,28 @@ int report_latest_driver_version(Options *op) */ char *append_update_arguments(char *s, int c, const char *arg, - struct option l[]) + const NVGetoptOption *options) { char *t; int i = 0; - if (!s) s = nvstrcat(" ", NULL); + if (!s) { + s = nvstrcat(" ", NULL); + } do { - if (l[i].val == c) { - t = nvstrcat(s, " --", l[i].name, NULL); + if (options[i].val == c) { + t = nvstrcat(s, " --", options[i].name, NULL); nvfree(s); s = t; - if (l[i].has_arg) { + if (options[i].flags & NVGETOPT_HAS_ARGUMENT) { t = nvstrcat(s, "=", arg, NULL); nvfree(s); s = t; } return (s); } - } while (l[++i].name); + } while (options[++i].name); return s; @@ -27,14 +27,12 @@ #ifndef __NVIDIA_INSTALLER_UPDATE_H__ #define __NVIDIA_INSTALLER_UPDATE_H__ +#include "nvgetopt.h" #include "nvidia-installer.h" -#define _GNU_SOURCE /* XXX not portable */ -#include <getopt.h> - int update(Options *); int report_latest_driver_version(Options *); char *append_update_arguments(char *s, int c, const char *arg, - struct option l[]); + const NVGetoptOption *options); #endif /* __NVIDIA_INSTALLER_UPDATE_H__ */ diff --git a/utils.mk b/utils.mk new file mode 100644 index 0000000..f14772c --- /dev/null +++ b/utils.mk @@ -0,0 +1,293 @@ +# +# Copyright (C) 2008 NVIDIA Corporation +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the: +# +# Free Software Foundation, Inc. +# 59 Temple Place - Suite 330 +# Boston, MA 02111-1307, USA +# +# +# utils.mk: common Makefile fragment used by nvidia-xconfig, +# nvidia-installer, and nvidia-settings +# + + + +############################################################################## +# The calling Makefile (when building as part of the NVIDIA graphics +# driver) may export any of the following variables; we assign default +# values if they are not exported by the caller +############################################################################## + +CC ?= gcc +LD ?= ld +CFLAGS ?= -Wall -fno-strict-aliasing +CFLAGS += -O2 -fno-omit-frame-pointer +CC_ONLY_CFLAGS ?= +LDFLAGS ?= +BIN_LDFLAGS ?= + +HOST_CC ?= $(CC) +HOST_LD ?= $(LD) +HOST_CFLAGS ?= $(CFLAGS) +HOST_LDFLAGS ?= $(LDFLAGS) +HOST_BIN_LDFLAGS ?= + +ifeq ($(DEBUG),1) + STRIP_CMD ?= true + CFLAGS += -O0 -g +else + STRIP_CMD ?= strip +endif + +INSTALL ?= install +INSTALL_BIN_ARGS ?= -m 755 +INSTALL_DOC_ARGS ?= -m 644 + +M4 ?= m4 +SED ?= sed +M4 ?= m4 +ECHO ?= echo +PRINTF ?= printf +MKDIR ?= mkdir -p +RM ?= rm -f +TOUCH ?= touch +WHOAMI ?= whoami +HOSTNAME_CMD ?= hostname +DATE ?= date +GZIP_CMD ?= gzip + +NV_AUTO_DEPEND ?= 1 +NV_VERBOSE ?= 0 + +ifndef TARGET_OS + TARGET_OS := $(shell uname) +endif + +ifeq ($(TARGET_OS),Linux) + CFLAGS += -DNV_LINUX +endif + +ifeq ($(TARGET_OS),FreeBSD) + CFLAGS += -DNV_BSD +endif + +ifeq ($(TARGET_OS),SunOS) + CFLAGS += -DNV_SUNOS +endif + +ifndef TARGET_ARCH + TARGET_ARCH := $(shell uname -m) + TARGET_ARCH := $(subst i386,x86,$(TARGET_ARCH)) + TARGET_ARCH := $(subst i486,x86,$(TARGET_ARCH)) + TARGET_ARCH := $(subst i586,x86,$(TARGET_ARCH)) + TARGET_ARCH := $(subst i686,x86,$(TARGET_ARCH)) +endif + +OUTPUTDIR ?= _out/$(TARGET_OS)_$(TARGET_ARCH) + +NV_QUIET_COMMAND_REMOVED_TARGET_PREFIX ?= + +CFLAGS += $(CC_ONLY_CFLAGS) + + +############################################################################## +# define variables used when installing the open source utilities from +# the source tarball +############################################################################## + +prefix = /usr/local + +exec_prefix = $(prefix) +bindir = $(exec_prefix)/bin +mandir = $(exec_prefix)/share/man/man1 + + +############################################################################## +# default build rule, so that nothing here in utils.mk accidentally +# gets selected as the default rule +############################################################################## + +default build: all + + +############################################################################## +# get the definition of NVIDIA_VERSION from version.mk +# +# version.mk may be in one of two places: either in $(OUTPUTDIR) when +# building as part of the NVIDIA driver build, or directly in the +# source directory when building from the source tarball +############################################################################## + +include $(wildcard $(OUTPUTDIR)/version.mk version.mk) + + +############################################################################## +# to generate the dependency files, use the compiler's "-MM" option to +# generate output of the form "foo.o : foo.c foo.h"; then, use sed to +# wrap the prerequisites with $(wildcard ...); the wildcard function +# serves as an existence filter, so that files that are later removed +# from the build do not cause stale references. Also, "-MM" will +# cause the compiler to name the target as if it were in the current +# directory ("foo.o: "); use sed to rename the target in the output +# directory ("_out/Linux_x86/foo.o: ") so that the target actually +# applies to the object files produced in the build. +# +# Arguments: +# $(1): CC command (CC or HOST_CC) +# $(2): object filename +############################################################################## + +ifeq ($(NV_AUTO_DEPEND),1) + AUTO_DEP_CMD = && $($(1)) -MM $$(CFLAGS) $$< | $$(SED) \ + -e "s,: ,: $$$$\(wildcard ," \ + -e "s,\([^\\]\)$$$$,\1)," \ + -e "s;^$$(notdir $(2)): ;$(2): ;" \ + > $$(@:.o=.d) +else + AUTO_DEP_CMD = +endif + + +############################################################################## +# echo minimal compile information in the non-NV_VERBOSE case +# +# NV_MODULE_LOGGING_NAME can be set to prepend quiet build output with a +# label of which build component is being built +############################################################################## + +NV_MODULE_LOGGING_NAME ?= + +ifeq ($(NV_VERBOSE),0) + quiet_cmd = @$(PRINTF) \ + " $(if $(NV_MODULE_LOGGING_NAME),[ %-17.17s ]) $(quiet_$(1))\n" \ + "$(NV_MODULE_LOGGING_NAME)" && $($(1)) +else + quiet_cmd = $($(1)) +endif + +# define LINK and HOST_LINK to be the same as CC; this is so that, +# even though we use CC to link programs, we can have a different +# quiet rule that uses '$@' as it's arg, rather than '$<' +LINK = $(CC) +HOST_LINK = $(HOST_CC) + +# strip NV_QUIET_COMMAND_REMOVED_TARGET_PREFIX from the target string +define_quiet_cmd = $(1) $(patsubst $(NV_QUIET_COMMAND_REMOVED_TARGET_PREFIX)/%,%,$(2)) + +# define the quiet commands: +quiet_CC = $(call define_quiet_cmd,CC ,$<) +quiet_HOST_CC = $(call define_quiet_cmd,HOST_CC ,$<) +quiet_LINK = $(call define_quiet_cmd,LINK ,$@) +quiet_HOST_LINK = $(call define_quiet_cmd,HOST_LINK ,$@) +quiet_M4 = $(call define_quiet_cmd,M4 ,$<) +quiet_STRIP_CMD = $(call define_quiet_cmd,STRIP ,$@) + +############################################################################## +# Tell gmake to delete the target of a rule if it has changed and its +# commands exit with a nonzero exit status. +############################################################################## +.DELETE_ON_ERROR: + + +############################################################################## +# function to generate a list of object files from their corresponding +# source files; example usage: +# +# OBJS = $(call BUILD_OBJECT_LIST,$(SRC)) +############################################################################## + +BUILD_OBJECT_LIST = \ + $(addprefix $(OUTPUTDIR)/,$(notdir $(addsuffix .o,$(basename $(1))))) + + +############################################################################## +# function to generate a list of dependency files from their +# corresponding source files; example usage: +# +# DEPS = $(call BUILD_DEPENDENCY_LIST,$(SRC)) +############################################################################## + +BUILD_DEPENDENCY_LIST = \ + $(addprefix $(OUTPUTDIR)/,$(notdir $(addsuffix .d,$(basename $(1))))) + + +############################################################################## +# functions to define a rule to build an object file; the first +# argument is either CC or HOST_CC, the second argument is the source +# file to compile, and the third argument (_WITH_OBJECT_NAME-only) is +# the object filename to produce. Example usage: +# +# $(eval $(call DEFINE_OBJECT_RULE,CC,foo.c)) +# +# Note this also attempts to include the dependency file for this +# source file. +# +# The DEFINE_OBJECT_RULE is functionally equivalent to +# DEFINE_OBJECT_RULE_WITH_OBJECT_NAME, but infers the object file name +# from the source file name (this is normally what you want). +############################################################################## + +define DEFINE_OBJECT_RULE_WITH_OBJECT_NAME + $(3): $(2) + @$(MKDIR) $(OUTPUTDIR) + $$(call quiet_cmd,$(1)) -c $$< -o $$@ $$(CFLAGS) \ + $(call AUTO_DEP_CMD,$(1),$(3)) + + -include $$(call BUILD_DEPENDENCY_LIST,$(3)) + + # declare empty rule for generating dependency file; we generate the + # dependency files implicitly when compiling the source file (see + # AUTO_DEP_CMD above), so we don't want gmake to spend time searching + # for an explicit rule to generate the dependency file + $$(call BUILD_DEPENDENCY_LIST,$(3)): ; + +endef + +define DEFINE_OBJECT_RULE + $$(eval $$(call DEFINE_OBJECT_RULE_WITH_OBJECT_NAME,$(1),$(2),\ + $$(call BUILD_OBJECT_LIST,$(2)))) +endef + + +############################################################################## +# STAMP_C - this is a source file that is generated during the build +# to capture information about the build environment for the utility. +# +# The DEFINE_STAMP_C_RULE function is used to define the rule for +# generating STAMP_C. First argument is a list of dependencies for +# STAMP_C (g_stamp.o is filtered out of the list); second argument is +# the name of the program being built. +# +# The includer of utils.mk should add $(STAMP_C) to its list of source +# files +############################################################################## + +STAMP_C = $(OUTPUTDIR)/g_stamp.c + +define DEFINE_STAMP_C_RULE + + $$(STAMP_C): $$(filter-out \ + $$(call BUILD_OBJECT_LIST,$$(STAMP_C)),$(1)) \ + $$(wildcard version.mk $$(OUTPUTDIR)/version.mk) + @ $$(RM) $$@ + @ $$(PRINTF) "const char NV_ID[] = \"nvidia id: " >> $$@ + @ $$(PRINTF) "$(2): " >> $$@ + @ $$(PRINTF) "version $$(NVIDIA_VERSION) " >> $$@ + @ $$(PRINTF) "($$(shell $$(WHOAMI))@$$(shell $$(HOSTNAME_CMD))) " >> $$@ + @ $$(PRINTF) "$$(shell $(DATE))\";\n" >> $$@ + @ $$(PRINTF) "const char *pNV_ID = NV_ID + 11;\n" >> $$@ + +endef diff --git a/version.mk b/version.mk new file mode 100644 index 0000000..de85e42 --- /dev/null +++ b/version.mk @@ -0,0 +1 @@ +NVIDIA_VERSION = 256.25 |