diff -u --recursive --new-file v2.4.0-test8/linux/CREDITS linux/CREDITS --- v2.4.0-test8/linux/CREDITS Fri Sep 8 13:27:11 2000 +++ linux/CREDITS Mon Sep 11 08:40:37 2000 @@ -1728,7 +1728,7 @@ S: Germany N: Mark W. McClelland -E: mmcclelland@delphi.com +E: mwm@i.am E: mark@alpha.dyndns.org W: http://alpha.dyndns.org/ov511/ D: OV511 driver diff -u --recursive --new-file v2.4.0-test8/linux/Documentation/Configure.help linux/Documentation/Configure.help --- v2.4.0-test8/linux/Documentation/Configure.help Fri Sep 8 13:27:11 2000 +++ linux/Documentation/Configure.help Sun Sep 17 09:48:04 2000 @@ -1088,22 +1088,25 @@ Support for PowerMac IDE devices (must also enable IDE) CONFIG_BLK_DEV_IDE_PMAC - No help for CONFIG_BLK_DEV_IDE_PMAC + This driver provides support for the built-in IDE controller on most + of the recent Apple Power Macintoshes and PowerBooks. + If unsure, say Y. PowerMac IDE DMA support CONFIG_BLK_DEV_IDEDMA_PMAC - No help for CONFIG_BLK_DEV_IDEDMA_PMAC + This option allows the driver for the built-in IDE controller on + Power Macintoshes and PowerBooks to use DMA (direct memory access) + to transfer data to and from memory. Saying Y is safe and improves + performance. Use DMA by default -CONFIG_IDEDMA_PMAC_AUTO - Prior to kernel version 2.1.112, Linux used to automatically use - DMA for IDE drives and chipsets which support it. Due to concerns - about a couple of cases where buggy hardware may have caused damage, - the default is now to NOT use DMA automatically. To revert to the - previous behaviour, say Y to this question. - - If you suspect your hardware is at all flakey, say N here. - Do NOT email the IDE kernel people regarding this issue! +CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO + This option allows the driver for the built-in IDE controller on + Power Macintoshes and PowerBooks to use DMA automatically, without + it having to be explicitly enabled. This option is provided because + of concerns about a couple of cases where using DMA on buggy PC + hardware may have caused damage. Saying Y should be safe on all + Apple machines. Macintosh Quadra/Powerbook IDE interface support CONFIG_BLK_DEV_MAC_IDE @@ -8276,6 +8279,11 @@ - SK-9844 (dual link 1000Base-SX) - SK-9821 (single link 1000Base-T) - SK-9822 (dual link 1000Base-T) + - SK-9861 (single link Volition connector) + - SK-9862 (dual link Volition connector) + The driver also supports the following adapters from Allied Telesyn: + - AT2970... + The dual link adapters support a link-failover feature. Read Documentation/networking/sk98lin.txt for information about optional driver parameters. @@ -9979,10 +9987,24 @@ The module will be called wmforce.o. If you want to compile it as a module, say M here and read Documentation/modules.txt. +Use input layer for ADB devices +CONFIG_INPUT_ADBHID + Say Y here if you want to have ADB (Apple Desktop Bus) HID devices + such as keyboards, mice, joysticks, or graphic tablets handled by the + input layer. If you say Y here, make sure to say Y to the + corresponding drivers "Keyboard support" (CONFIG_INPUT_KEYBDEV), + "Mouse Support" (CONFIG_INPUT_MOUSEDEV) and "Event interface support" + (CONFIG_INPUT_EVDEV) as well. + + If you say N here, you still have the option of using the old ADB + keyboard and mouse drivers. + + If unsure, say Y. + Keyboard support CONFIG_INPUT_KEYBDEV - Say Y here if you want your USB HID keyboard to be able to serve as - a system keyboard. + Say Y here if you want your USB HID keyboard (or an ADB keyboard + handled by the input layer) to be able to serve as a system keyboard. This driver is also available as a module ( = code which can be inserted in and removed from the running kernel whenever you want). @@ -9991,10 +10013,11 @@ Mouse support CONFIG_INPUT_MOUSEDEV - Say Y here if you want your USB HID mouse to be accessible as - char devices 13:32+ - /dev/input/mouseX and 13:63 - /dev/input/mice - as an emulated PS/2 mouse. That way, all user space programs will - be able to use your mouse. + Say Y here if you want your USB HID mouse (or ADB mouse handled by + the input layer) to be accessible as char devices 13:32+ - + /dev/input/mouseX and 13:63 - /dev/input/mice as an emulated ImPS/2 + mouse. That way, all user space programs will be able to use your + mouse. If unsure, say Y. @@ -10029,8 +10052,8 @@ Event interface support CONFIG_INPUT_EVDEV - Say Y here if you want your USB HID device events be accessible - under char device 13:64+ - /dev/inputX in a generic way. + Say Y here if you want your USB or ADB HID device events be accessible + under char device 13:64+ - /dev/input/eventX in a generic way. This is the future ... USB Scanner support @@ -15424,6 +15447,42 @@ You may also want to compile the dma sound driver as a module and have it autoloaded. The act of removing the module shuts down the sound hardware for more power savings. + +Mac-on-Linux support +CONFIG_MOL + This option enables low-level support for Mac-on-Linux. + MOL lets you run MacOS and Linux simultaneously. Please + visit for more information. + If unsure, say Y. + +ADB raw keycode support +CONFIG_MAC_ADBKEYCODES + This provides support for sending raw ADB keycodes to console + devices. This is the default up to 2.4.0, but in future this may be + phased out in favor of generic Linux keycodes. If you say Y here, you + can dynamically switch via the + /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes + sysctl and with the "keyboard_sends_linux_keycodes=" kernel argument. + + If unsure, say Y here. + +Mouse button 2+3 emulation support +CONFIG_MAC_EMUMOUSEBTN + This provides generic support for emulating the 2nd and 3rd mouse + button with keypresses. If you say Y here, the emulation is still + disabled by default. The emulation is controlled by these sysctl entries: + /proc/sys/dev/mac_hid/mouse_button_emulation + /proc/sys/dev/mac_hid/mouse_button2_keycode + /proc/sys/dev/mac_hid/mouse_button3_keycode + +Enhanced Real Time Clock Support +CONFIG_PPC_RTC + If you say Y here and create a character special file /dev/rtc with + major number 10 and minor number 135 using mknod ("man mknod"), you + will get access to the real time clock (or hardware clock) built + into your computer. + + If unsure, say Y here. Support for Open Firmware device tree in /proc CONFIG_PROC_DEVICETREE diff -u --recursive --new-file v2.4.0-test8/linux/Documentation/kbuild/00-INDEX linux/Documentation/kbuild/00-INDEX --- v2.4.0-test8/linux/Documentation/kbuild/00-INDEX Mon Feb 1 12:03:20 1999 +++ linux/Documentation/kbuild/00-INDEX Sun Sep 17 09:45:06 2000 @@ -6,3 +6,5 @@ - overview of kbuild commands config-language.txt - specification of Config Language, the language in Config.in files +makefiles.txt + - developer information for linux kernel makefiles diff -u --recursive --new-file v2.4.0-test8/linux/Documentation/kbuild/makefiles.txt linux/Documentation/kbuild/makefiles.txt --- v2.4.0-test8/linux/Documentation/kbuild/makefiles.txt Wed Dec 31 16:00:00 1969 +++ linux/Documentation/kbuild/makefiles.txt Sun Sep 17 09:45:06 2000 @@ -0,0 +1,1086 @@ +Linux Kernel Makefiles +16 August 2000 +Michael Elizabeth Chastain, + + + +=== Introduction + +This document describes the Linux kernel Makefiles. + +The Makefiles have five parts: + + Makefile: the top Makefile. + .config: the kernel configuration file. + arch/*/Makefile: the arch Makefiles. + Subdirectory Makefiles: there are about 300 of these. + Rules.make: the common rules for all subdirectory Makefiles. + +The top Makefile reads the .config file, which comes from the +kernel configuration process. + +The top Makefile is responsible for building two major products: vmlinux +(the resident kernel image) and modules (any module files). It builds +these targets by recursively descending into the subdirectories of the +kernel source tree. The list of subdirectories which are visited depends +upon the kernel configuration. + +The top Makefile textually includes an arch Makefile with the name +arch/$(ARCH)/Makefile. The arch Makefile supplies architecture-specific +information to the top Makefile. + +Each subdirectory has a Makefile which carries out the commands passed +down from above. The subdirectory Makefile uses information from the +.config file to construct various file lists, and then it textually +includes the common rules in Rules.make. + +Rules.make defines rules which are common to all the subdirectory +Makefiles. It has a public interface in the form of certain variable +lists. It then declares rules based on those lists. + + + +=== Who does what + +People have four different relationships with the kernel Makefiles. + +*Users* are people who build kernels. These people type commands such as +"make menuconfig" or "make bzImage". They usually do not read or edit +any kernel Makefiles (or any other source files). + +*Normal developers* are people who work on features such as device +drivers, file systems, and network protocols. These people need to +maintain the subdirectory Makefiles for the subsystem that they are +working on. In order to do this effectively, they need some overall +knowledge about the kernel Makefiles, plus detailed knowledge about the +public interface for Rules.make. + +*Arch developers* are people who work on an entire architecture, such +as sparc or ia64. Arch developers need to know about the arch Makefiles +as well as subdirectory Makefiles. + +*Kbuild developers* are people who work on the kernel build system itself. +These people need to know about all aspects of the kernel Makefiles. + +This document is aimed towards normal developers and arch developers. + + + +=== Makefile language + +The kernel Makefiles are designed to run with Gnu Make. The Makefiles +use only the documented features of Gnu Make, but they do use many +Gnu extensions. + +Gnu Make supports elementary list-processing functions. The kernel +Makefiles use a novel style of list building and manipulation with few +"if" statements. + +Gnu Make has two assignment operators, ":=" and "=". ":=" performs +immediate evaluation of the right-hand side and stores an actual string +into the left-hand side. "=" is like a formula definition; it stores the +right-hand side in an unevaluated form and then evaluates this form each +time the left-hand side is used. + +There are some cases where "=" is appropriate. Usually, though, ":=" +is the right choice. + +All of the examples in this document were drawn from actual kernel +sources. The examples have been reformatted (white space changed, lines +split), but are otherwise exactly the same. + + + +=== Variables passed down from the top + +The top Makefile exports the following variables: + + VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION + + These variables define the current kernel version. A few arch + Makefiles actually use these values directly; they should use + $(KERNELRELEASE) instead. + + $(VERSION), $(PATCHLEVEL), and $(SUBLEVEL) define the basic + three-part version number, such as "2", "4", and "0". These three + values are always numeric. + + $(EXTRAVERSION) defines an even tinier sublevel for pre-patches + or additional patches. It is usually some non-numeric string + such as "-pre4", and is often blank. + + KERNELRELEASE + + $(KERNELRELEASE) is a single string such as "2.4.0-pre4", suitable + for constructing installation directory names or showing in + version strings. Some arch Makefiles use it for this purpose. + + ARCH + + This variable defines the target architecture, such as "i386", + "arm", or "sparc". Many subdirectory Makefiles test $(ARCH) + to determine which files to compile. + + By default, the top Makefile sets $(ARCH) to be the same as the + host system system architecture. For a cross build, a user may + override the value of $(ARCH) on the command line: + + make ARCH=m68k ... + + TOPDIR, HPATH + + $(TOPDIR) is the path to the top of the kernel source tree. + Subdirectory Makefiles need this so that they can include + $(TOPDIR)/Rules.make. + + $(HPATH) is equal to $(TOPDIR)/include. A few arch Makefiles + need to use this to do special things using include files. + + SUBDIRS + + $(SUBDIRS) is a list of directories which the top Makefile + enters in order to build either vmlinux or modules. The actual + directories in $(SUBDIRS) depend on the kernel configuration. + The top Makefile defines this variable, and the arch Makefile + extends it. + + HEAD, CORE_FILES, NETWORKS, DRIVERS, LIBS + LINKFLAGS + + $(HEAD), $(CORE_FILES), $(NETWORKS), $(DRIVERS), and $(LIBS) + specify lists of object files and libraries to be linked into + vmlinux. + + The files in $(HEAD) are linked first in vmlinux. + + $(LINKFLAGS) specifies the flags to build vmlinux. + + The top Makefile and the arch Makefile jointly define these + variables. The top Makefile defines $(CORE_FILES), $(NETWORKS), + $(DRIVERS), and $(LIBS). The arch Makefile defines $(HEAD) + and $(LINKFLAGS), and extends $(CORE_FILES) and $(LIBS). + + Note: there are more names here than necessary. $(NETWORKS), + $(DRIVERS), and even $(LIBS) could be subsumed into $(CORE_FILES). + + CPP, CC, AS, LD, AR, NM, STRIP, OBJCOPY, OBJDUMP + CPPFLAGS, CFLAGS, CFLAGS_KERNEL, MODFLAGS, AFLAGS, LDFLAGS + PERL + GENKSYMS + + These variables specify the commands and flags that Rules.make + uses to build target files from source files. + + $(CFLAGS_KERNEL) contains extra C compiler flags used to compile + resident kernel code. + + $(MODFLAGS) contains extra C compiler flags used to compile code + for loadable kernel modules. In the future, this flag may be + renamed to the more regular name $(CFLAGS_MODULE). + + $(AFLAGS) contains assembler flags. + + $(GENKSYMS) contains the command used to generate kernel symbol + signatures when CONFIG_MODVERSIONS is enabled. The genksyms + command comes from the modutils package. + + CROSS_COMPILE + + This variable is a prefix path for other variables such as $(CC), + $(AS), and $(LD). The arch Makefiles sometimes use and set this + variable explicitly. Subdirectory Makefiles don't need to worry + about it. + + The user may override $(CROSS_COMPILE) on the command line if + desired. + + HOSTCC, HOSTCFLAGS + + These variables define the C compiler and C compiler flags to + be used for compiling host side programs. These are separate + variables because the target architecture can be different from + the host architecture. + + If your Makefile compiles and runs a program that is executed + during the course of building the kernel, then it should use + $(HOSTCC) and $(HOSTCFLAGS). + + For example, the subdirectory drivers/pci has a helper program + named gen-devlist.c. This program reads a list of PCI ID's and + generates C code in the output files classlist.h and devlist.h. + + Suppose that a user has an i386 computer and wants to build a + kernel for an ia64 machine. Then the user would use an ia64 + cross-compiler for most of the compilation, but would use a + native i386 host compiler to compile drivers/pci/gen-devlist.c. + + For another example, kbuild helper programs such as + scripts/mkdep.c and scripts/lxdialog/*.c are compiled with + $(HOSTCC) rather than $(CC). + + ROOT_DEV, SVGA_MODE, RAMDISK + + End users edit these variables to specify certain information + about the configuration of their kernel. These variables + are ancient! They are also specific to the i386 architecture. + They really should be replaced with CONFIG_* options. + + MAKEBOOT + + This variable is defined and used only inside the main arch + Makefiles. The top Makefile should not export it. + + INSTALL_PATH + + This variable defines a place for the arch Makefiles to install + the resident kernel image and System.map file. + + INSTALL_MOD_PATH, MODLIB + + $(INSTALL_MOD_PATH) specifies a prefix to $(MODLIB) for module + installation. This variable is not defined in the Makefile but + may be passed in by the user if desired. + + $(MODLIB) specifies the directory for module installation. + The top Makefile defines $(MODLIB) to + $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE). The user may + override this value on the command line if desired. + + CONFIG_SHELL + + This variable is private between Makefile and Rules.make. + Arch makefiles and subdirectory Makefiles should never use this. + + MODVERFILE + + An internal variable. This doesn't need to be exported, as it + is never used outside of the top Makefile. + + MAKE, MAKEFILES + + Some variables internal to Gnu Make. + + $(MAKEFILES) in particular is used to force the arch Makefiles + and subdirectory Makefiles to read $(TOPDIR)/.config without + including it explicitly. (This was an implementation hack and + could be fixed). + + + +=== The structure of an arch Makefile + +The top Makefile includes one arch Makefile file, arch/$(ARCH)/Makefile. +This section describes the functions of the arch Makefile. + +An arch Makefile extends some of the top Makefile's variables with +architecture-specific values. + + SUBDIRS + + The top Makefile defines $(SUBDIRS). The arch Makefile extends + $(SUBDIRS) with a list of architecture-specific directories. + + Example: + + # arch/alpha/Makefile + + SUBDIRS := $(SUBDIRS) arch/alpha/kernel arch/alpha/mm \ + arch/alpha/lib arch/alpha/math-emu + + This list may depend on the configuration: + + # arch/arm/Makefile + + ifeq ($(CONFIG_ARCH_ACORN),y) + SUBDIRS += drivers/acorn + ... + endif + + CPP, CC, AS, LD, AR, NM, STRIP, OBJCOPY, OBJDUMP + CPPFLAGS, CFLAGS, CFLAGS_KERNEL, MODFLAGS, AFLAGS, LDFLAGS + + The top Makefile defines these variables, and the arch Makefile + extends them. + + Many arch Makefiles dynamically run the target C compiler to + probe what options it supports: + + # arch/i386/Makefile + + # only work around strength reduction bug(s) on older gcc versions + CFLAGS += $(shell if ! $(CC) -march=i486 -S -o /dev/null \ + -xc /dev/null >/dev/null 2>&1; \ + then echo "-fno-strength-reduce"; fi) + + # prevent gcc from keeping the stack 16 byte aligned + CFLAGS += $(shell if $(CC) -mpreferred-stack-boundary=2 \ + -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ + then echo "-mpreferred-stack-boundary=2"; fi) + + And, of course, $(CFLAGS) can depend on the configuration: + + # arch/i386/Makefile + + ifdef CONFIG_M386 + CFLAGS += $(shell if $(CC) -march=i386 -S -o /dev/null \ + -xc /dev/null >/dev/null 2>&1; \ + then echo "-march=i386"; else echo "-m386"; fi) + endif + + ifdef CONFIG_M486 + CFLAGS += $(shell if $(CC) -march=i486 -S -o /dev/null \ + -xc /dev/null >/dev/null 2>&1; \ + then echo "-march=i486"; else echo "-m486"; fi) + endif + + ifdef CONFIG_M586 + CFLAGS += $(shell if $(CC) -march=i586 -S -o /dev/null \ + -xc /dev/null >/dev/null 2>&1; \ + then echo "-march=i586"; fi) + endif + + Some arch Makefiles redefine the compilation commands in order + to add architecture-specific flags: + + # arch/s390/Makefile + + LD=$(CROSS_COMPILE)ld -m elf_s390 + OBJCOPY=$(CROSS_COMPILE)objcopy -O binary -R .note -R .comment -S + +An arch Makefile co-operates with the top Makefile to define variables +which specify how to build the vmlinux file. Note that there is no +corresponding arch-specific section for modules; the module-building +machinery is all architecture-independent. + + HEAD, CORE_FILES, LIBS + LINKFLAGS + + The top Makefile defines the architecture-independent core of + thse variables, and the arch Makefile extends them. Note that the + arch Makefile defines (not just extends) $(HEAD) and $(LINKFLAGS). + + Example: + + # arch/m68k/Makefile + + ifndef CONFIG_SUN3 + LINKFLAGS = -T $(TOPDIR)/arch/m68k/vmlinux.lds + else + LINKFLAGS = -T $(TOPDIR)/arch/m68k/vmlinux-sun3.lds -N + endif + + ... + + ifndef CONFIG_SUN3 + HEAD := arch/m68k/kernel/head.o + else + HEAD := arch/m68k/kernel/sun3-head.o + endif + + SUBDIRS += arch/m68k/kernel arch/m68k/mm arch/m68k/lib + CORE_FILES := arch/m68k/kernel/kernel.o arch/m68k/mm/mm.o $(CORE_FILES) + LIBS += arch/m68k/lib/lib.a + +An arch Makefile specifies targets that take the vmlinux file, compress +it, wrap it in bootstrapping code, and copy the resulting files somewhere. +This includes various kinds of installation commands. + +These post-vmlinux targets are not standardized across different +architectures. Here is a list of these targets and the architectures +that support each of them (as of kernel version 2.4.0-test6-pre5): + + balo mips + bootimage alpha + bootpfile alpha, ia64 + bzImage i386, m68k + bzdisk i386 + bzlilo i386 + compressed i386, m68k, mips, mips64, sh + dasdfmt s390 + Image arm + image s390 + install arm, i386 + lilo m68k + msb alpha, ia64 + my-special-boot alpha, ia64 + orionboot mips + rawboot alpha + silo s390 + srmboot alpha + tftpboot.img sparc, sparc64 + vmlinux.64 mips64 + vmlinux.aout sparc64 + zImage arm, i386, m68k, mips, mips64, ppc, sh + zImage.initrd ppc + zdisk i386, mips, mips64, sh + zinstall arm + zlilo i386 + znetboot.initrd ppc + +An arch Makefile must define the following auxiliary targets. These +targets provide arch-specific actions for the corresponding targets +in the top Makefile: + + archclean clean + archdep dep + archmrproper mrproper + + + +=== The structure of a subdirectory Makefile + +A subdirectory Makefile has five sections. + +The first section is a comment header. Just write what you would +write if you were editing a C source file, but use "# ..." instead of +"/* ... */". Historically, many anonymous people have edited kernel +Makefiles without leaving any change histories in the header; comments +from them would have been valuable. + +The second section is a bunch of definitions that are the heart of the +subdirectory Makefile. These lines define the files to be built, any +special compilation options, and any subdirectories to be recursively +entered. The declarations in these lines depend heavily on the kernel +configuration variables (CONFIG_* symbols). + +In some Makefiles ("old-style Makefiles"), the second section looks +like this: + + # drivers/parport/Makefile + ifeq ($(CONFIG_PARPORT_PC),y) + LX_OBJS += parport_pc.o + else + ifeq ($(CONFIG_PARPORT_PC),m) + MX_OBJS += parport_pc.o + endif + endif + +In most Makefiles ("new-style Makefiles"), the second section looks +like this: + + # drivers/block/Makefile + obj-$(CONFIG_MAC_FLOPPY) += swim3.o + obj-$(CONFIG_BLK_DEV_FD) += floppy.o + obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o + obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o + +The new-style Makefiles are more compact and easier to get correct +for certain features (such as CONFIG_* options that enable more than +one file). If you have a choice, please write a new-style Makefile. + +The third section is an adapter section. In old-style Makefiles, this +third section is not present. In new-style Makefiles, the third section +contains boilerplate code which converts from new-style variables to +old-style variables. This is because Rules.make processes only the +old-style variables. + +The fourth section is the single line: + + include $(TOPDIR)/Rules.make + +The fifth section contains any special Makefile rules needed that are +not available through the common rules in Rules.make. + + + +=== Rules.make variables + +The public interface of Rules.make consists of the following variables: + + ALL_SUB_DIRS, SUB_DIRS, MOD_IN_SUB_DIRS, MOD_SUB_DIRS + + $(ALL_SUB_DIRS) is an unconditional list of *all* the + subdirectories in a given directory. This list should not depend + on the kernel configuration. + + $(SUB_DIRS) is a list of subdirectories which may contribute code + to vmlinux. This list may depend on the kernel configuration. + + $(MOD_SUB_DIRS) and $(MOD_IN_SUB_DIRS) are lists of subdirectories + which may build kernel modules. Both names have exactly the + same meaning. (In version 2.2 and earlier kernels, these + variables had different meanings -- hence the different names). + + For new code, $(MOD_SUB_DIRS) is recommended and $(MOD_IN_SUB_DIRS) + is deprecated. + + Example: + + # fs/Makefile + ALL_SUB_DIRS = coda minix ext2 fat msdos vfat proc isofs nfs \ + umsdos ntfs hpfs sysv smbfs ncpfs ufs efs affs \ + romfs autofs hfs lockd nfsd nls devpts devfs \ + adfs partitions qnx4 udf bfs cramfs openpromfs \ + autofs4 ramfs jffs + SUB_DIRS := + + ... + + ifeq ($(CONFIG_EXT2_FS),y) + SUB_DIRS += ext2 + else + ifeq ($(CONFIG_EXT2_FS),m) + MOD_SUB_DIRS += ext2 + endif + endif + + ifeq ($(CONFIG_CRAMFS),y) + SUB_DIRS += cramfs + else + ifeq ($(CONFIG_CRAMFS),m) + MOD_SUB_DIRS += cramfs + endif + endif + + Example: + + # drivers/net/Makefile + SUB_DIRS := + MOD_SUB_DIRS := + MOD_IN_SUB_DIRS := + ALL_SUB_DIRS := $(SUB_DIRS) fc hamradio irda pcmcia tokenring \ + wan sk98lin arcnet skfp tulip appletalk + + ... + + ifeq ($(CONFIG_IRDA),y) + SUB_DIRS += irda + MOD_IN_SUB_DIRS += irda + else + ifeq ($(CONFIG_IRDA),m) + MOD_IN_SUB_DIRS += irda + endif + endif + + ifeq ($(CONFIG_TR),y) + SUB_DIRS += tokenring + MOD_IN_SUB_DIRS += tokenring + else + ifeq ($(CONFIG_TR),m) + MOD_IN_SUB_DIRS += tokenring + endif + endif + + O_TARGET, O_OBJS, OX_OBJS + + The subdirectory Makefile specifies object files for vmlinux in + the lists $(O_OBJS) and $(OX_OBJS). These lists depend on the + kernel configuration. + + The "X" in "OX_OBJS" stands for "eXport". Files in $(OX_OBJS) + may use the EXPORT_SYMBOL macro to define public symbols which + loadable kernel modules can see. Files in $(O_OBJS) may not use + EXPORT_SYMBOL (and you will get a funky error message if you try). + + [Yes, it's kludgy to do this by hand. Yes, you can define all + your objects as $(OX_OBJS) whether they define symbols or not; + but then you will notice a lot of extra compiles when you edit + any source file. Blame CONFIG_MODVERSIONS for this.] + + Rules.make compiles all the $(O_OBJS) and $(OX_OBJS) files. + It then calls "$(LD) -r" to merge these files into one .o file + with the name $(O_TARGET). This $(O_TARGET) name also appears + in the top Makefile. + + The order of files in $(O_OBJS) and $(OX_OBJS) is significant. + All $(OX_OBJS) files come first, in the order listed, followed by + all $(O_OBJS) files, in the order listed. Duplicates in the lists + are allowed: the first instance will be linked into $(O_TARGET) + and succeeding instances will be ignored. (Note: Rules.make may + emit warning messages for duplicates, but this is harmless). + + Example: + + # arch/alpha/kernel/Makefile + O_TARGET := kernel.o + O_OBJS := entry.o traps.o process.o osf_sys.o irq.o \ + irq_alpha.o signal.o setup.o ptrace.o time.o \ + semaphore.o + OX_OBJS := alpha_ksyms.o + + ifdef CONFIG_SMP + O_OBJS += smp.o irq_smp.o + endif + + ifdef CONFIG_PCI + O_OBJS += pci.o pci_iommu.o + endif + + Even if a subdirectory Makefile has an $(O_TARGET), the .config + options still control whether or not its $(O_TARGET) goes into + vmlinux. See the $(M_OBJS) example below. + + + + L_TARGET, L_OBJS, LX_OBJS + + These names are similar to the O_* names. Once again, $(L_OBJS) + and $(LX_OBJS) specify object files for the resident kernel; + once again, the lists depend on the current configuration; and + once again, the files that call EXPORT_SYMBOL go on the "X" list. + + The difference is that "L" stands for "Library". After making + $(L_OBJS) and $(LX_OBJS), Rules.make uses the "$(AR) rcs" command + to put these files into an archive file (a library) with the + name $(L_TARGET). This name also appears in the top Makefile. + + Example: + + # arch/i386/lib/Makefile + L_TARGET = lib.a + L_OBJS = checksum.o old-checksum.o delay.o \ + usercopy.o getuser.o putuser.o iodebug.o + + ifdef CONFIG_X86_USE_3DNOW + L_OBJS += mmx.o + endif + + ifdef CONFIG_HAVE_DEC_LOCK + L_OBJS += dec_and_lock.o + endif + + The order of files in $(L_OBJS) and $(LX_OBJS) is not significant. + Duplicates in the lists are allowed. (Note: Rules.make may emit + warning messages for duplicates, but this is harmless). + + A subdirectory Makefile can specify either an $(O_TARGET), + an $(L_TARGET), or both. Here is a discussion of the differences. + + All of the files in an $(O_TARGET) are guaranteed to appear in + the resident vmlinux image. In an $(L_TARGET), only the files + that satisfy undefined symbol references from other files will + appear in vmlinux. + + In a conventional link process, the linker processes some + object files and creates a list of unresolved external symbols. + The linker then looks in a set of libraries to resolve these + symbols. Indeed, the Linux kernel used to be linked this way, + with the bulk of the code stored in libraries. + + But vmlinux contains two types of object files that cannot be + fetched out of libraries this way: + + (1) object files that are purely EXPORT_SYMBOL definitions + (2) object files that use module_init or __initcall initializers + (instead of an initialization routine called externally) + + These files contain autonomous initializer sections which provide + code and data without being explicitly called. If these files + were stored in $(L_TARGET) libraries, the linker would fail + to include them in vmlinux. Thus, most subdirectory Makefiles + specify an $(O_TARGET) and do not use $(L_TARGET). + + Other considerations: $(O_TARGET) leads to faster re-link times + during development activity, but $(L_TARGET) gives better error + messages for unresolved symbols. + + M_OBJS, MX_OBJS + + $(M_OBJS) and $(MX_OBJS) specify object files which are built + as loadable kernel modules. As usual, the "X" in $(MX_OBJS) + stands for "eXport"; source files that use EXPORT_SYMBOL must + appear on an $(MX_OBJS) list. + + A module may be built from one source file or several source + files. In the case of one source file, the subdirectory + Makefile simply adds the file to either $(M_OBJS) or $(MX_OBJS), + as appropriate. + + Example: + + # drivers/net/irda/Makefile + ifeq ($(CONFIG_IRTTY_SIR),y) + L_OBJS += irtty.o + else + ifeq ($(CONFIG_IRTTY_SIR),m) + M_OBJS += irtty.o + endif + endif + + ifeq ($(CONFIG_IRPORT_SIR),y) + LX_OBJS += irport.o + else + ifeq ($(CONFIG_IRPORT_SIR),m) + MX_OBJS += irport.o + endif + endif + + If a kernel module is built from several source files, there + are two ways to specify the set of source files. One way is to + build a single module for the entire subdirectory. This way is + popular in the file system and network protocol stacks. + + Example: + + # fs/ext2/Makefile + O_TARGET := ext2.o + O_OBJS := acl.o balloc.o bitmap.o dir.o file.o fsync.o \ + ialloc.o inode.o ioctl.o namei.o super.o symlink.o \ + truncate.o + M_OBJS := $(O_TARGET) + + In this example, the module name will be ext2.o. Because this + file has the same name has $(O_TARGET), Rules.make will use + the $(O_TARGET) rule to build ext2.o: it will run "$(LD) -r" + on the list of $(O_OBJS) files. + + Note that this subdirectory Makefile defines both an $(O_TARGET) + and an $(M_OBJS). The control code, up in fs/Makefile, will + select between these two. If CONFIG_EXT2_FS=y, then fs/Makefile + will build $(O_TARGET); and if CONFIG_EXT_FS=m, then fs/Makefile + will build $(M_OBJS) instead. (Yes, this is a little delicate + and a little confusing). + + MI_OBJS, MIX_OBJS + + Some kernel modules are composed of several object files + linked together, but do not include every object file in their + subdirectory. $(MI_OBJS) and $(MIX_OBJS) are for this case. + + "M" stands for Module. + "I" stands for Intermediate. + "X", as usual, stands for "eXport symbol". + + Example: + + # drivers/sound/Makefile + gus-objs := gus_card.o gus_midi.o gus_vol.o gus_wave.o ics2101.o + pas2-objs := pas2_card.o pas2_midi.o pas2_mixer.o pas2_pcm.o + sb-objs := sb_card.o + + gus.o: $(gus-objs) + $(LD) -r -o $@ $(gus-objs) + + pas2.o: $(pas2-objs) + $(LD) -r -o $@ $(pas2-objs) + + sb.o: $(sb-objs) + $(LD) -r -o $@ $(sb-objs) + + The kernel modules gus.o, pas2.o, and sb.o are the *composite + files*. The object files gus_card.o, gus_midi.o, gus_vol.o, + gus_wave.o, ics2101.o, pas2_card.o, pas2_midi.o, pas2_mixer.o, + pas2_pcm.o, and sb_card.o are *component files*. The component + files are also called *intermediate files*. + + In another part of drivers/sound/Makefile (not shown), all of + the component files are split out. For the resident drivers: + the component object files go onto $(O_OBJS) and $(OX_OBJS) + lists, depending on whether they export symbols or not; and the + composite files are never built. For the kernel modules: the + component object files go onto $(MI_OBJS) and $(MIX_OBJS); + the composite files go onto $(M_OBJS). + + The subdirectory Makefile must also specify the linking rule + for a multi-object-file module: + + # drivers/sound/Makefile + + gus.o: $(gus-objs) + $(LD) -r -o $@ $(gus-objs) + + pas2.o: $(pas2-objs) + $(LD) -r -o $@ $(pas2-objs) + + sb.o: $(sb-objs) + $(LD) -r -o $@ $(sb-objs) + + IGNORE_FLAGS_OBJS + + $(IGNORE_FLAGS_OBJS) is a list of object files which will not have + their flag dependencies automatically tracked. This is a hackish + feature, used to kludge around a problem in the implementation + of flag dependencies. (The problem is that flag dependencies + assume that a %.o file is built from a matching %.S or %.c file. + This is sometimes not true). + + EXTRA_CFLAGS, EXTRA_AFLAGS, EXTRA_LDFLAGS, EXTRA_ARFLAGS + + $(EXTRA_CFLAGS) specifies options for compiling C files with + $(CC). The options in this variable apply to all $(CC) commands + for files in the current directory. + + Example: + + # drivers/sound/emu10k1/Makefile + EXTRA_CFLAGS += -I. + ifdef DEBUG + EXTRA_CFLAGS += -DEMU10K1_DEBUG + endif + + $(EXTRA_CFLAGS) does not apply to subdirectories of the current + directory. Also, it does not apply to files compiled with + $(HOSTCC). + + This variable is necessary because the top Makefile owns the + variable $(CFLAGS) and uses it for compilation flags for the + entire tree. + + $(EXTRA_AFLAGS) is a similar string for per-directory options + when compiling assembly language source. + + Example: at the time of writing, there were no examples of + $(EXTRA_AFLAGS) in the kernel corpus. + + $(EXTRA_LDFLAGS) and $(EXTRA_ARFLAGS) are similar strings for + per-directory options to $(LD) and $(AR). + + Example: at the time of writing, there were no examples of + $(EXTRA_LDFLAGS) or $(EXTRA_ARFLAGS) in the kernel corpus. + + CFLAGS_$@, AFLAGS_$@ + + $(CFLAGS_$@) specifies per-file options for $(CC). The $@ + part has a literal value which specifies the file that it's for. + + Example: + + # drivers/scsi/Makefile + CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF + CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ \ + -DGDTH_STATISTICS + CFLAGS_seagate.o = -DARBITRATE -DPARITY -DSEAGATE_USE_ASM + + These three lines specify compilation flags for aha152x.o, + gdth.o, and seagate.o + + $(AFLAGS_$@) is a similar feature for source files in assembly + languages. + + Example: + + # arch/arm/kernel/Makefile + AFLAGS_head-armv.o := -DTEXTADDR=$(TEXTADDR) -traditional + AFLAGS_head-armo.o := -DTEXTADDR=$(TEXTADDR) -traditional + + Rules.make has a feature where an object file depends on the + value of $(CFLAGS_$@) that was used to compile it. (It also + depends on the values of $(CFLAGS) and $(EXTRA_CFLAGS)). Thus, + if you change the value of $(CFLAGS_$@) for a file, either by + editing the Makefile or overriding the value some other way, + Rules.make will do the right thing and re-compile your source + file with the new options. + + Note: because of a deficiency in Rules.make, assembly language + files do not have flag dependencies. If you edit $(AFLAGS_$@) + for such a file, you will have to remove the object file in order + to re-build from source. + + USE_STANDARD_AS_RULE + + This is a transition variable. If $(USE_STANDARD_AS_RULE) + is defined, then Rules.make will provide standard rules for + assembling %.S files into %.o files or %.s files (%.s files + are useful only to developers). + + If $(USE_STANDARD_AS_RULE) is not defined, then Rules.make + will not provide these standard rules. In this case, the + subdirectory Makefile must provide its own private rules for + assembling %.S files. + + In the past, all Makefiles provided private %.S rules. Newer + Makefiles should define USE_STANDARD_AS_RULE and use the standard + Rules.make rules. As soon as all the Makefiles across all + architectures have been converted to USE_STANDARD_AS_RULE, then + Rules.make can drop the conditional test on USE_STANDARD_AS_RULE. + After that, all the other Makefiles can drop the definition of + USE_STANDARD_AS_RULE. + + + +=== New-style variables + +The "new-style variables" are simpler and more powerful than the +"old-style variables". As a result, many subdirectory Makefiles shrank +more than 60%. This author hopes that, in time, all arch Makefiles and +subdirectory Makefiles will convert to the new style. + +Rules.make does not understand new-style variables. Thus, each new-style +Makefile has a section of boilerplate code that converts the new-style +variables into old-style variables. There is also some mixing, where +people define most variables using "new style" but then fall back to +"old style" for a few lines. + + obj-y obj-m obj-n obj- + + These variables replace $(O_OBJS), $(OX_OBJS), $(M_OBJS), + and $(MX_OBJS). + + Example: + + # drivers/block/Makefile + obj-$(CONFIG_MAC_FLOPPY) += swim3.o + obj-$(CONFIG_BLK_DEV_FD) += floppy.o + obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o + obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o + + Notice the use of $(CONFIG_...) substitutions on the left hand + side of an assignment operator. This gives Gnu Make the power + of associative indexing! Each of these assignments replaces + eight lines of code in an old-style Makefile. + + After executing all of the assignments, the subdirectory + Makefile has built up four lists: $(obj-y), $(obj-m), $(obj-n), + and $(obj-). + + $(obj-y) is a list of files to include in vmlinux. + $(obj-m) is a list of files to build as single-file modules. + $(obj-n) and $(obj-) are ignored. + + Each list may contain duplicates items; duplicates are + automatically removed later. Also, if a file appears in both + $(obj-y) and $(obj-m), it will automatically be removed from + the $(obj-m) list. + + Example: + + # drivers/net/Makefile + + ... + obj-$(CONFIG_OAKNET) += oaknet.o 8390.o + ... + obj-$(CONFIG_NE2K_PCI) += ne2k-pci.o 8390.o + ... + obj-$(CONFIG_STNIC) += stnic.o 8390.o + ... + obj-$(CONFIG_MAC8390) += daynaport.o 8390.o + ... + + In this example, four different drivers require the code in + 8390.o. If one or more of these four drivers are built into + vmlinux, then 8390.o will also be built into vmlinux, and will + *not* be built as a module -- even if another driver which needs + 8390.o is built as a module. (The modular driver is able to + use services of the 8390.o code in the resident vmlinux image). + + export-objs + + $(export-objs) is a list of all the files in the subdirectory + which potentially export symbols. The canonical way to construct + this list is: + + grep -l EXPORT_SYMBOL *.c + + (but watch out for sneaky files that call EXPORT_SYMBOL from an + included header file!) + + This is a potential list, independent of the kernel configuration. + All files that export symbols go into $(export-objs). The + boilerplate code then uses the $(export-objs) list to separate + the real file lists into $(*_OBJS) and $(*X_OBJS). + + Experience has shown that maintaining the proper X's in an + old-style Makefile is difficult and error-prone. Maintaining the + $(export-objs) list in a new-style Makefile is simpler and easier + to audit. + + list-multi + $(foo)-objs + + Some kernel modules are composed of multiple object files linked + together. $(list-multi) is a list of such kernel modules. + This is a static list; it does not depend on the configuration. + + For each kernel module in $(list-multi) there is another list + of all the object files which make up that module. For a kernel + module named foo.o, its object file list is foo-objs. + + Example: + + # drivers/scsi/Makefile + list-multi := scsi_mod.o sr_mod.o initio.o a100u2w.o + + ... + + scsi_mod-objs := hosts.o scsi.o scsi_ioctl.o constants.o \ + scsicam.o scsi_proc.o scsi_error.o \ + scsi_obsolete.o scsi_queue.o scsi_lib.o \ + scsi_merge.o scsi_dma.o scsi_scan.o \ + scsi_syms.o + sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o + initio-objs := ini9100u.o i91uscsi.o + a100u2w-objs := inia100.o i60uscsi.o + + The subdirectory Makefile puts the modules onto obj-* lists in + the usual configuration-dependent way: + + obj-$(CONFIG_SCSI) += scsi_mod.o + obj-$(CONFIG_BLK_DEV_SR) += sr_mod.o + obj-$(CONFIG_SCSI_INITIO) += initio.o + obj-$(CONFIG_SCSI_INIA100) += a100u2w.o + + Suppose that CONFIG_SCSI=y. Then vmlinux needs to link in all + 14 components of scsi_mod.o, so these components will go onto + $(O_OBJS) and $(OX_OBJS). The composite file scsi_mod.o will + never be created. The boilerplate conversion code produces this + result with a few lines of list processing commands. + + Suppose that CONFIG_BLK_DEV_SR=m. Then the 3 components + of sr_mod.o will linked together with "$(LD) -r" to make the + kernel module sr_mod.o, so these 3 components need to go onto + the $(MI_OBJS) and $(MIX_OBJS) lists; the composite file sr_mod.o + goes onto $(M_OBJS). The boilerplate conversion code takes care + of this, too. + + And suppose CONFIG_SCSI_INITIO=n. Then initio.o goes onto the + $(obj-n) list and that's the end of it. Its component files + are not compiled, and the composite file is not created. + + Finally, the subdirectory Makefile needs to define rules to + build each multi-object kernel module from its component list. + Example: + + # drivers/scsi/Makefile + + scsi_mod.o: $(scsi_mod-objs) + $(LD) -r -o $@ $(scsi_mod-objs) + + sr_mod.o: $(sr_mod-objs) + $(LD) -r -o $@ $(sr_mod-objs) + + initio.o: $(initio-objs) + $(LD) -r -o $@ $(initio-objs) + + a100u2w.o: $(a100u2w-objs) + $(LD) -r -o $@ $(a100u2w-objs) + + These rules are very regular; it would be nice for the boilerplate + code or Rules.make to synthesize these rules automatically. + But until that happens, the subdirectory Makefile needs to define + these rules explicitly. + + + +=== Compatibility with Linux Kernel 2.2 + +Most of the information in this document also applies to 2.2, although +there is no indication of which things have changed when. Here are some +hints for writing subdirectory Makefiles that are compatible with Linux +kernel 2.2. + +You can write either an old-style Makefile or a new-style Makefile +with a boilerplate adapter section. See the 2.2 version of +drivers/sound/Makefile for a copy of the boilerplate code. + +In 2.2, Rules.make makes a distinction between $(MOD_SUB_DIRS) +and $(MOD_IN_SUB_DIRS). If you have a single directory with no +subdirectories, this will not matter to you. If you have a whole +tree, then you need to know the difference between $(MOD_SUB_DIRS) +and $(MOD_IN_SUB_DIRS). For example code: $(MOD_SUB_DIRS) is used +extensively in fs/Makefile; $(MOD_IN_SUB_DIRS) is used extensively in +drivers/net/Makefile. + +If you are already using MOD_LIST_NAME, go ahead and keep using it. +If you don't already have a MOD_LIST_NAME, go ahead and keep not using +one; your module will be a 'misc' module in 2.2. + +Assembly language rules were a mess in 2.2. If you have assembly language +files, this author recommends that you write your own explicit rules +for each file by name. + + + +=== Credits + +Thanks to the members of the linux-kbuild mailing list for reviewing +drafts of this document, with particular thanks to Peter Samuelson. diff -u --recursive --new-file v2.4.0-test8/linux/Documentation/networking/8139too.txt linux/Documentation/networking/8139too.txt --- v2.4.0-test8/linux/Documentation/networking/8139too.txt Fri Sep 8 13:27:11 2000 +++ linux/Documentation/networking/8139too.txt Sun Sep 17 09:41:28 2000 @@ -1,6 +1,6 @@ "8139too" Fast Ethernet driver for Linux - Improved support for RTL-8139 Fast Ethernet adapters + Improved support for RTL-8139 10/100 Fast Ethernet adapters Copyright 2000 Jeff Garzik @@ -8,6 +8,7 @@ Architectures supported (all PCI platforms): x86, Alpha AXP, PowerPC, Sparc64 + Kernel versions supported: 2.4.x @@ -130,6 +131,8 @@ And thanks to every supporter free software. +(see top of 8139too.c for further credits and kudos) + Submitting Bug Reports @@ -156,38 +159,50 @@ 1) Work with Donald to merge fixes and updates into his driver. -2) 2.2.x COMPATIBILITY SUPPORT IS BROKEN. DO NOT USE IT. -It is included only for enterprising hackers willing to help fix it. +2) ethtool support -3) PPC platform has stability problems. +3) PPC platform has stability problems. (XXX: verify this is still true) 4) Sparc64 platform not tested at all. -5) Identify and fix "rx wedge" when ping flooded. (WIP) - -7) N-Way auto-negotiation is known to fail in some cases. This problem -also occurs in the rtl8139 driver in kernels 2.2.x/2.3.x. Solution: -Following technique in sunhme and sunbmac, use a kernel timer to -manually perform autonegotiation in case the network or card cannot do -it automatically. (patches welcome) - 8) Much improved command line / module parameter setup. (patches and suggestions welcome) (WIP) 9) Better documentation. (patches welcome) -10) (rtl8139-diag modified from Becker version, DONE) -User-mode (or maybe optional /proc) diagnostics program. - 11) RTL8139C support untested. -12) 10base-T support flaky or slow +12) 10base-T support flaky or slow (todo: verify this is still true) Change History -------------- + +Version 0.9.10 - September 12, 2000 + +* Never wrap an Rx packet (faster Rx interrupt handling) +* Clear all TxAborted conditions (bug fix) +* Correct copyright +* More credits +* Update NWay doc URL +* Clean up commonly used ifdef switches +* Reorg info displayed at bootup/modprobe time +* Remove some unneeded spinlocks +* Misc cosmetic code cleanup +* Always print interrupt status for abnormal interrupts +* Use RealTek-recommended FIFO and DMA burst settings (1024 bytes) + + +Version 0.9.9 - September 9, 2000 + +* Fix oops-able bug in Rx ring wrap calculation (David Ford) +* Use PIO instead of MMIO when USE_IO_OPS is defined +* Move Rx error handling out of Rx interrupt handler, resulting in + tighter Rx interrupt processing + + Version 0.9.8 - September 7, 2000 * Propagate request_irq error value (andrew morton) diff -u --recursive --new-file v2.4.0-test8/linux/Documentation/networking/sk98lin.txt linux/Documentation/networking/sk98lin.txt --- v2.4.0-test8/linux/Documentation/networking/sk98lin.txt Wed Aug 9 19:19:49 2000 +++ linux/Documentation/networking/sk98lin.txt Fri Sep 15 14:34:19 2000 @@ -1,9 +1,9 @@ -(C)Copyright 1999 SysKonnect. +(C)Copyright 1999-2000 SysKonnect. =========================================================================== -sk98lin.txt created 11-Nov-1999 +sk98lin.txt created 12-Sept-2000 -Readme File for sk98lin.o v3.04 +Readme File for sk98lin.o v3.05 SK-NET Gigabit Ethernet Adapter SK-98xx Driver for Linux This file contains @@ -372,6 +372,12 @@ (8) HISTORY =========== + +VERSION 3.05 (In-Kernel version) +Problems fixed: +- Failed for multiple adapters in kernel 2.4.0 +New features: +- New versions of several common modules VERSION 3.04 (In-Kernel version) Problems fixed: diff -u --recursive --new-file v2.4.0-test8/linux/Documentation/networking/vortex.txt linux/Documentation/networking/vortex.txt --- v2.4.0-test8/linux/Documentation/networking/vortex.txt Wed Aug 23 18:36:35 2000 +++ linux/Documentation/networking/vortex.txt Fri Sep 15 16:28:25 2000 @@ -166,8 +166,9 @@ Sets the time duration (in milliseconds) after which the kernel decides that the transmitter has become stuck and needs to be reset. - This is mainly for debugging purposes. The default value is 400 (0.4 - seconds). + This is mainly for debugging purposes, although it may be advantageous + to increase this value on LANs which have very high collision rates. + The default value is 400 (0.4 seconds). Additional resources -------------------- diff -u --recursive --new-file v2.4.0-test8/linux/Documentation/pci.txt linux/Documentation/pci.txt --- v2.4.0-test8/linux/Documentation/pci.txt Tue May 23 15:31:32 2000 +++ linux/Documentation/pci.txt Sun Sep 17 09:45:06 2000 @@ -188,6 +188,11 @@ list. pci_module_init() Inline helper function for ensuring correct pci_driver initialization and error handling. +pci_resource_start() Returns bus start address for a given PCI region +pci_resource_end() Returns bus end address for a given PCI region +pci_resource_len() Returns the byte length of a PCI region +pci_set_drvdata() Set private driver data pointer for a pci_dev +pci_get_drvdata() Return private driver data pointer for a pci_dev 7. Miscellaneous hints diff -u --recursive --new-file v2.4.0-test8/linux/MAINTAINERS linux/MAINTAINERS --- v2.4.0-test8/linux/MAINTAINERS Fri Sep 8 13:27:11 2000 +++ linux/MAINTAINERS Fri Sep 15 16:43:40 2000 @@ -1152,6 +1152,13 @@ L: linux-tulip@cesdis.gsfc.nasa.gov S: Maintained +TUN/TAP driver +P: Maxim Krasnyansky +M: maxk@qualcomm.com, max_mk@yahoo.com +L: vtun@office.satix.net +W: http://vtun.sourceforge.net/tun +S: Maintained + U14-34F SCSI DRIVER P: Dario Ballabio M: dario@milano.europe.dg.com @@ -1228,7 +1235,7 @@ USB OV511 DRIVER P: Mark McClelland -M: mmcclelland@delphi.com +M: mwm@i.am L: linux-usb-users@lists.sourceforge.net L: linux-usb-devel@lists.sourceforge.net W: http://alpha.dyndns.org/ov511/ diff -u --recursive --new-file v2.4.0-test8/linux/Makefile linux/Makefile --- v2.4.0-test8/linux/Makefile Fri Sep 8 13:27:11 2000 +++ linux/Makefile Sun Sep 17 09:48:04 2000 @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 4 SUBLEVEL = 0 -EXTRAVERSION = -test8 +EXTRAVERSION = -test9 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) @@ -161,7 +161,7 @@ DRIVERS-$(CONFIG_SBUS) += drivers/sbus/sbus.a DRIVERS-$(CONFIG_ZORRO) += drivers/zorro/zorro.a DRIVERS-$(CONFIG_FC4) += drivers/fc4/fc4.a -DRIVERS-$(CONFIG_PPC) += drivers/macintosh/macintosh.o +DRIVERS-$(CONFIG_ALL_PPC) += drivers/macintosh/macintosh.o DRIVERS-$(CONFIG_MAC) += drivers/macintosh/macintosh.o DRIVERS-$(CONFIG_ISAPNP) += drivers/pnp/pnp.o DRIVERS-$(CONFIG_SGI_IP22) += drivers/sgi/sgi.a @@ -174,7 +174,7 @@ DRIVERS-$(CONFIG_I2O) += drivers/i2o/i2o.o DRIVERS-$(CONFIG_IRDA) += drivers/net/irda/irda.o DRIVERS-$(CONFIG_I2C) += drivers/i2c/i2c.o -DRIVERS-$(CONFIG_PHONE) += drivers/telephony/telephony.a +DRIVERS-$(CONFIG_PHONE) += drivers/telephony/telephony.o DRIVERS-$(CONFIG_ACPI_INTERPRETER) += drivers/acpi/acpi.o DRIVERS += $(DRIVERS-y) diff -u --recursive --new-file v2.4.0-test8/linux/arch/alpha/kernel/time.c linux/arch/alpha/kernel/time.c --- v2.4.0-test8/linux/arch/alpha/kernel/time.c Wed Aug 23 18:36:36 2000 +++ linux/arch/alpha/kernel/time.c Mon Sep 11 08:39:47 2000 @@ -135,38 +135,6 @@ write_unlock(&xtime_lock); } -/* - * Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static inline unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ -} - void common_init_rtc(void) { diff -u --recursive --new-file v2.4.0-test8/linux/arch/arm/kernel/time.c linux/arch/arm/kernel/time.c --- v2.4.0-test8/linux/arch/arm/kernel/time.c Thu Jul 27 17:37:59 2000 +++ linux/arch/arm/kernel/time.c Mon Sep 11 08:39:47 2000 @@ -64,37 +64,6 @@ */ unsigned long (*gettimeoffset)(void) = dummy_gettimeoffset; -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -unsigned long -mktime(unsigned int year, unsigned int mon, unsigned int day, - unsigned int hour, unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ -} - /* * Handle kernel profile stuff... */ diff -u --recursive --new-file v2.4.0-test8/linux/arch/i386/kernel/acpi.c linux/arch/i386/kernel/acpi.c --- v2.4.0-test8/linux/arch/i386/kernel/acpi.c Thu Jul 27 17:37:59 2000 +++ linux/arch/i386/kernel/acpi.c Sun Sep 17 09:41:29 2000 @@ -21,6 +21,12 @@ /* * See http://www.geocities.com/SiliconValley/Hardware/3165/ * for the user-level ACPI stuff + * + * Changes: + * Arnaldo Carvalho de Melo - 2000/08/31 + * - check copy*user return + * - get rid of check_region + * - get rid of verify_area */ #include @@ -135,8 +141,7 @@ *len = 0; return 0; } - copy_to_user(buffer, str, size); - return 0; + return copy_to_user(buffer, str, size) ? -EFAULT : 0; } static void cx_statistics(unsigned int x, unsigned long time) @@ -1283,11 +1288,9 @@ */ static int acpi_claim(unsigned long start, unsigned long size) { - if (start && size) { - if (check_region(start, size)) + if (start && size) + if (!request_region(start, size, "acpi")) return -EBUSY; - request_region(start, size, "acpi"); - } return 0; } @@ -1391,7 +1394,8 @@ val = *(unsigned long*) ctl->data; size = sprintf(str, "0x%08lx\n", val); if (*len >= size) { - copy_to_user(buffer, str, size); + if (copy_to_user(buffer, str, size)) + return -EFAULT; *len = size; } else @@ -1404,7 +1408,8 @@ size = sizeof(str) - 1; if (size > *len) size = *len; - copy_from_user(str, buffer, size); + if (copy_from_user(str, buffer, size)) + return -EFAULT; str[size] = '\0'; val = simple_strtoul(str, &strend, 0); if (strend == str) @@ -1423,22 +1428,22 @@ size_t size, struct acpi_table_info *info) { + struct acpi_table hdr; + size_t table_size; + if (size < sizeof(struct acpi_table)) return -EINVAL; - else if (verify_area(VERIFY_READ, buffer, size)) + + if (copy_from_user(&hdr, buffer, sizeof(hdr))) return -EFAULT; - else { - struct acpi_table hdr; - size_t table_size; - copy_from_user(&hdr, buffer, sizeof(hdr)); - table_size = (size_t) hdr.length; - if (hdr.signature != info->expected_signature - || table_size < size - || (info->expected_size - && table_size != info->expected_size)) - return -EINVAL; - } + table_size = (size_t) hdr.length; + if (hdr.signature != info->expected_signature + || table_size < size + || (info->expected_size + && table_size != info->expected_size)) + return -EINVAL; + return 0; } @@ -1496,7 +1501,8 @@ error = acpi_verify_table(buffer, *len, info); if (error) return error; - copy_from_user(&hdr, buffer, sizeof(hdr)); + if (copy_from_user(&hdr, buffer, sizeof(hdr))) + return -EFAULT; table_size = (size_t) hdr.length; write_lock(&acpi_do_table_lock); @@ -1517,7 +1523,8 @@ error = -ENOMEM; } if (data) - copy_from_user(data, buffer, size); + if (copy_from_user(data, buffer, size)) + error = -EFAULT; write_unlock(&acpi_do_table_lock); } @@ -1565,7 +1572,8 @@ size = sprintf(str, "0x%08x\n", val); if (*len >= size) { - copy_to_user(buffer, str, size); + if (copy_to_user(buffer, str, size)) + return -EFAULT; *len = size; } else @@ -1580,7 +1588,8 @@ size = sizeof(str) - 1; if (size > *len) size = *len; - copy_from_user(str, buffer, size); + if (copy_from_user(str, buffer, size)) + return -EFAULT; str[size] = '\0'; val = (u32) simple_strtoul(str, &strend, 0); if (strend == str) @@ -1682,7 +1691,8 @@ pm1_status, gpe_status, event_state); - copy_to_user(buffer, str, size); + if (copy_to_user(buffer, str, size)) + return -EFAULT; *len = size; file->f_pos += size; diff -u --recursive --new-file v2.4.0-test8/linux/arch/i386/kernel/time.c linux/arch/i386/kernel/time.c --- v2.4.0-test8/linux/arch/i386/kernel/time.c Mon Jul 10 16:47:19 2000 +++ linux/arch/i386/kernel/time.c Mon Sep 11 08:39:47 2000 @@ -504,37 +504,6 @@ } -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static inline unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ -} - /* not static: needed by APM */ unsigned long get_cmos_time(void) { diff -u --recursive --new-file v2.4.0-test8/linux/arch/ia64/kernel/efi.c linux/arch/ia64/kernel/efi.c --- v2.4.0-test8/linux/arch/ia64/kernel/efi.c Wed Aug 23 18:36:36 2000 +++ linux/arch/ia64/kernel/efi.c Mon Sep 11 08:39:48 2000 @@ -98,37 +98,6 @@ efi_call_phys(__va(runtime->reset_system), status, data_size, __pa(data)); } -/* - * Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static inline unsigned long -mktime (unsigned int year, unsigned int mon, unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((((unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) - + year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ -} - void efi_gettimeofday (struct timeval *tv) { diff -u --recursive --new-file v2.4.0-test8/linux/arch/m68k/kernel/time.c linux/arch/m68k/kernel/time.c --- v2.4.0-test8/linux/arch/m68k/kernel/time.c Tue May 11 09:57:14 1999 +++ linux/arch/m68k/kernel/time.c Mon Sep 11 08:39:48 2000 @@ -102,37 +102,6 @@ #endif /* CONFIG_HEARTBEAT */ } -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static inline unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ -} - void time_init(void) { unsigned int year, mon, day, hour, min, sec; diff -u --recursive --new-file v2.4.0-test8/linux/arch/m68k/mac/misc.c linux/arch/m68k/mac/misc.c --- v2.4.0-test8/linux/arch/m68k/mac/misc.c Wed Feb 16 17:03:51 2000 +++ linux/arch/m68k/mac/misc.c Mon Sep 11 08:39:48 2000 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -497,37 +498,6 @@ sti(); printk ("Restart failed. Please restart manually.\n"); while(1); -} - -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ } /* diff -u --recursive --new-file v2.4.0-test8/linux/arch/mips/dec/time.c linux/arch/mips/dec/time.c --- v2.4.0-test8/linux/arch/mips/dec/time.c Fri Jul 14 12:12:05 2000 +++ linux/arch/mips/dec/time.c Mon Sep 11 08:39:48 2000 @@ -346,37 +346,6 @@ } } -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static inline unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long) (year / 4 - year / 100 + year / 400 + 367 * mon / 12 + day) + - year * 365 - 719499 - ) * 24 + hour /* now have hours */ - ) * 60 + min /* now have minutes */ - ) * 60 + sec; /* finally seconds */ -} - char cyclecounter_available; static inline void init_cycle_counter(void) diff -u --recursive --new-file v2.4.0-test8/linux/arch/mips/kernel/time.c linux/arch/mips/kernel/time.c --- v2.4.0-test8/linux/arch/mips/kernel/time.c Fri Jul 14 12:12:05 2000 +++ linux/arch/mips/kernel/time.c Mon Sep 11 08:39:48 2000 @@ -443,37 +443,6 @@ r4k_timer_interrupt (INDY_R4K_TIMER_IRQ, NULL, regs); } -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static inline unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ -} - char cyclecounter_available; static inline void init_cycle_counter(void) diff -u --recursive --new-file v2.4.0-test8/linux/arch/mips/sgi/kernel/indy_timer.c linux/arch/mips/sgi/kernel/indy_timer.c --- v2.4.0-test8/linux/arch/mips/sgi/kernel/indy_timer.c Tue May 23 15:31:33 2000 +++ linux/arch/mips/sgi/kernel/indy_timer.c Mon Sep 11 08:39:48 2000 @@ -151,37 +151,6 @@ return ct1 - ct0; } -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static inline unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ -} - static unsigned long __init get_indy_time(void) { struct indy_clock *clock = (struct indy_clock *)INDY_CLOCK_REGS; diff -u --recursive --new-file v2.4.0-test8/linux/arch/mips64/sgi-ip22/ip22-timer.c linux/arch/mips64/sgi-ip22/ip22-timer.c --- v2.4.0-test8/linux/arch/mips64/sgi-ip22/ip22-timer.c Tue May 23 15:31:33 2000 +++ linux/arch/mips64/sgi-ip22/ip22-timer.c Mon Sep 11 08:39:48 2000 @@ -151,37 +151,6 @@ return ct1 - ct0; } -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static inline unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ -} - static unsigned long __init get_indy_time(void) { struct indy_clock *clock = (struct indy_clock *)INDY_CLOCK_REGS; diff -u --recursive --new-file v2.4.0-test8/linux/arch/mips64/sgi-ip27/ip27-timer.c linux/arch/mips64/sgi-ip27/ip27-timer.c --- v2.4.0-test8/linux/arch/mips64/sgi-ip27/ip27-timer.c Fri Jul 14 12:12:05 2000 +++ linux/arch/mips64/sgi-ip27/ip27-timer.c Mon Sep 11 08:39:48 2000 @@ -219,37 +219,6 @@ #include #include -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static inline unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ -} - #define DEBUG_RTC static unsigned long __init get_m48t35_time(void) diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/8260_io/Config.in linux/arch/ppc/8260_io/Config.in --- v2.4.0-test8/linux/arch/ppc/8260_io/Config.in Thu May 11 15:30:06 2000 +++ linux/arch/ppc/8260_io/Config.in Sun Sep 17 09:48:05 2000 @@ -11,12 +11,15 @@ bool 'Ethernet on SCC2' CONFIG_SCC2_ENET fi fi - bool 'FCC Ethernet' CONFIG_FCC_ENET - if [ "$CONFIG_FCC_ENET" = "y" ]; then - bool 'Ethernet on FCC1' CONFIG_FCC1_ENET - if [ "$CONFIG_FCC1_ENET" != "y" ]; then - bool 'Ethernet on FCC2' CONFIG_FCC2_ENET - fi +# +# CONFIG_FEC_ENET is only used to get netdevices to call our init +# function. Any combination of FCC1,2,3 are supported. +# + bool 'FCC Ethernet' CONFIG_FEC_ENET + if [ "$CONFIG_FEC_ENET" = "y" ]; then + bool 'Ethernet on FCC1' CONFIG_FCC1_ENET + bool 'Ethernet on FCC2' CONFIG_FCC2_ENET + bool 'Ethernet on FCC3' CONFIG_FCC3_ENET fi endmenu fi diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/8260_io/Makefile linux/arch/ppc/8260_io/Makefile --- v2.4.0-test8/linux/arch/ppc/8260_io/Makefile Thu May 11 15:30:06 2000 +++ linux/arch/ppc/8260_io/Makefile Sun Sep 17 09:48:05 2000 @@ -10,8 +10,8 @@ O_TARGET := 8260_io.a O_OBJS = commproc.o uart.o -ifdef CONFIG_FCC_ENET -O_OBJS += fcc.o +ifdef CONFIG_FEC_ENET +O_OBJS += fcc_enet.o endif ifdef CONFIG_SCC_ENET O_OBJS += enet.o diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/8260_io/commproc.c linux/arch/ppc/8260_io/commproc.c --- v2.4.0-test8/linux/arch/ppc/8260_io/commproc.c Thu May 11 15:30:06 2000 +++ linux/arch/ppc/8260_io/commproc.c Sun Sep 17 09:48:05 2000 @@ -69,17 +69,27 @@ cpmp = (cpm8260_t *)commproc; } -/* Allocate some memory from the dual ported ram. We may want to - * enforce alignment restrictions, but right now everyone is a good - * citizen. +/* Allocate some memory from the dual ported ram. + * To help protocols with object alignment restrictions, we do that + * if they ask. */ uint -m8260_cpm_dpalloc(uint size) +m8260_cpm_dpalloc(uint size, uint align) { uint retloc; + uint align_mask, off; + uint savebase; - if ((dp_alloc_base + size) >= dp_alloc_top) + align_mask = align - 1; + savebase = dp_alloc_base; + + if ((off = (dp_alloc_base & align_mask)) != 0) + dp_alloc_base += (align - off); + + if ((dp_alloc_base + size) >= dp_alloc_top) { + dp_alloc_base = savebase; return(CPM_DP_NOSPACE); + } retloc = dp_alloc_base; dp_alloc_base += size; @@ -91,12 +101,22 @@ * UART "fifos" and the like. */ uint -m8260_cpm_hostalloc(uint size) +m8260_cpm_hostalloc(uint size, uint align) { uint retloc; + uint align_mask, off; + uint savebase; + + align_mask = align - 1; + savebase = host_buffer; + + if ((off = (host_buffer & align_mask)) != 0) + host_buffer += (align - off); - if ((host_buffer + size) >= host_end) + if ((host_buffer + size) >= host_end) { + host_buffer = savebase; return(0); + } retloc = host_buffer; host_buffer += size; diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/8260_io/enet.c linux/arch/ppc/8260_io/enet.c --- v2.4.0-test8/linux/arch/ppc/8260_io/enet.c Fri Jun 23 21:55:07 2000 +++ linux/arch/ppc/8260_io/enet.c Sun Sep 17 09:48:05 2000 @@ -466,8 +466,11 @@ cep->stats.rx_bytes += pkt_len; /* This does 16 byte alignment, much more than we need. - */ - skb = dev_alloc_skb(pkt_len); + * The packet length includes FCS, but we don't want to + * include that when passing upstream as it messes up + * bridging applications. + */ + skb = dev_alloc_skb(pkt_len-4); if (skb == NULL) { printk("%s: Memory squeeze, dropping packet.\n", dev->name); @@ -475,10 +478,10 @@ } else { skb->dev = dev; - skb_put(skb,pkt_len); /* Make room */ + skb_put(skb,pkt_len-4); /* Make room */ eth_copy_and_sum(skb, (unsigned char *)__va(bdp->cbd_bufaddr), - pkt_len, 0); + pkt_len-4, 0); skb->protocol=eth_type_trans(skb,dev); netif_rx(skb); } @@ -549,10 +552,10 @@ /* Log any net taps. */ printk("%s: Promiscuous mode enabled.\n", dev->name); - cep->sccp->scc_pmsr |= SCC_PMSR_PRO; + cep->sccp->scc_pmsr |= SCC_PSMR_PRO; } else { - cep->sccp->scc_pmsr &= ~SCC_PMSR_PRO; + cep->sccp->scc_pmsr &= ~SCC_PSMR_PRO; if (dev->flags & IFF_ALLMULTI) { /* Catch all multicast addresses, so set the @@ -678,11 +681,11 @@ * These are relative offsets in the DP ram address space. * Initialize base addresses for the buffer descriptors. */ - i = m8260_cpm_dpalloc(sizeof(cbd_t) * RX_RING_SIZE); + i = m8260_cpm_dpalloc(sizeof(cbd_t) * RX_RING_SIZE, 8); ep->sen_genscc.scc_rbase = i; cep->rx_bd_base = (cbd_t *)&immap->im_dprambase[i]; - i = m8260_cpm_dpalloc(sizeof(cbd_t) * TX_RING_SIZE); + i = m8260_cpm_dpalloc(sizeof(cbd_t) * TX_RING_SIZE, 8); ep->sen_genscc.scc_tbase = i; cep->tx_bd_base = (cbd_t *)&immap->im_dprambase[i]; @@ -816,7 +819,7 @@ /* Set processing mode. Use Ethernet CRC, catch broadcast, and * start frame search 22 bit times after RENA. */ - sccp->scc_pmsr = (SCC_PMSR_ENCRC | SCC_PMSR_NIB22); + sccp->scc_pmsr = (SCC_PSMR_ENCRC | SCC_PSMR_NIB22); /* It is now OK to enable the Ethernet transmitter. * Unfortunately, there are board implementation differences here. diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/8260_io/fcc_enet.c linux/arch/ppc/8260_io/fcc_enet.c --- v2.4.0-test8/linux/arch/ppc/8260_io/fcc_enet.c Wed Dec 31 16:00:00 1969 +++ linux/arch/ppc/8260_io/fcc_enet.c Sun Sep 17 09:48:05 2000 @@ -0,0 +1,1600 @@ +/* + * Fast Ethernet Controller (FCC) driver for Motorola MPC8260. + * Copyright (c) 2000 MontaVista Software, Inc. Dan Malek (dmalek@jlc.net) + * + * This version of the driver is a combination of the 8xx fec and + * 8260 SCC Ethernet drivers. People seem to be choosing common I/O + * configurations, so this driver will work on the EST8260 boards and + * others yet to be announced. + * + * Right now, I am very watseful with the buffers. I allocate memory + * pages and then divide them into 2K frame buffers. This way I know I + * have buffers large enough to hold one frame within one buffer descriptor. + * Once I get this working, I will use 64 or 128 byte CPM buffers, which + * will be much more memory efficient and will easily handle lots of + * small packets. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +/* The transmitter timeout + */ +#define TX_TIMEOUT (2*HZ) + +/* The number of Tx and Rx buffers. These are allocated from the page + * pool. The code may assume these are power of two, so it it best + * to keep them that size. + * We don't need to allocate pages for the transmitter. We just use + * the skbuffer directly. + */ +#define FCC_ENET_RX_PAGES 16 +#define FCC_ENET_RX_FRSIZE 2048 +#define FCC_ENET_RX_FRPPG (PAGE_SIZE / FCC_ENET_RX_FRSIZE) +#define RX_RING_SIZE (FCC_ENET_RX_FRPPG * FCC_ENET_RX_PAGES) +#define TX_RING_SIZE 16 /* Must be power of two */ +#define TX_RING_MOD_MASK 15 /* for this to work */ + +/* The FCC stores dest/src/type, data, and checksum for receive packets. + */ +#define PKT_MAXBUF_SIZE 1518 +#define PKT_MINBUF_SIZE 64 + +/* Maximum input DMA size. Must be a should(?) be a multiple of 4. +*/ +#define PKT_MAXDMA_SIZE 1520 + +/* Maximum input buffer size. Must be a multiple of 32. +*/ +#define PKT_MAXBLR_SIZE 1536 + +static int fcc_enet_open(struct net_device *dev); +static int fcc_enet_start_xmit(struct sk_buff *skb, struct net_device *dev); +static int fcc_enet_rx(struct net_device *dev); +static void fcc_enet_mii(struct net_device *dev); +static void fcc_enet_interrupt(int irq, void * dev_id, struct pt_regs * regs); +static int fcc_enet_close(struct net_device *dev); +static struct net_device_stats *fcc_enet_get_stats(struct net_device *dev); +static void set_multicast_list(struct net_device *dev); +static void restart_fcc(struct net_device *dev); + +/* These will be configurable for the FCC choice. + * Multiple ports can be configured. There is little choice among the + * I/O pins to the PHY, except the clocks. We will need some board + * dependent clock selection. + * Why in the hell did I put these inside #ifdef's? I dunno, maybe to + * help show what pins are used for each device. + */ + +/* I/O Pin assignment for FCC1. I don't yet know the best way to do this, + * but there is little variation among the choices. + */ +#define PA1_COL ((uint)0x00000001) +#define PA1_CRS ((uint)0x00000002) +#define PA1_TXER ((uint)0x00000004) +#define PA1_TXEN ((uint)0x00000008) +#define PA1_RXDV ((uint)0x00000010) +#define PA1_RXER ((uint)0x00000020) +#define PA1_TXDAT ((uint)0x00003c00) +#define PA1_RXDAT ((uint)0x0003c000) +#define PA1_PSORA0 (PA1_RXDAT | PA1_TXDAT) +#define PA1_PSORA1 (PA1_COL | PA1_CRS | PA1_TXER | PA1_TXEN | \ + PA1_RXDV | PA1_RXER) +#define PA1_DIRA0 (PA1_RXDAT | PA1_CRS | PA1_COL | PA1_RXER | PA1_RXDV) +#define PA1_DIRA1 (PA1_TXDAT | PA1_TXEN | PA1_TXER) + +/* CLK12 is receive, CLK11 is transmit. These are board specific. +*/ +#define PC_F1RXCLK ((uint)0x00000800) +#define PC_F1TXCLK ((uint)0x00000400) +#define CMX1_CLK_ROUTE ((uint)0x3e000000) +#define CMX1_CLK_MASK ((uint)0xff000000) + +/* I/O Pin assignment for FCC2. I don't yet know the best way to do this, + * but there is little variation among the choices. + */ +#define PB2_TXER ((uint)0x00000001) +#define PB2_RXDV ((uint)0x00000002) +#define PB2_TXEN ((uint)0x00000004) +#define PB2_RXER ((uint)0x00000008) +#define PB2_COL ((uint)0x00000010) +#define PB2_CRS ((uint)0x00000020) +#define PB2_TXDAT ((uint)0x000003c0) +#define PB2_RXDAT ((uint)0x00003c00) +#define PB2_PSORB0 (PB2_RXDAT | PB2_TXDAT | PB2_CRS | PB2_COL | \ + PB2_RXER | PB2_RXDV | PB2_TXER) +#define PB2_PSORB1 (PB2_TXEN) +#define PB2_DIRB0 (PB2_RXDAT | PB2_CRS | PB2_COL | PB2_RXER | PB2_RXDV) +#define PB2_DIRB1 (PB2_TXDAT | PB2_TXEN | PB2_TXER) + +/* CLK13 is receive, CLK14 is transmit. These are board dependent. +*/ +#define PC_F2RXCLK ((uint)0x00001000) +#define PC_F2TXCLK ((uint)0x00002000) +#define CMX2_CLK_ROUTE ((uint)0x00250000) +#define CMX2_CLK_MASK ((uint)0x00ff0000) + +/* I/O Pin assignment for FCC3. I don't yet know the best way to do this, + * but there is little variation among the choices. + */ +#define PB3_RXDV ((uint)0x00004000) +#define PB3_RXER ((uint)0x00008000) +#define PB3_TXER ((uint)0x00010000) +#define PB3_TXEN ((uint)0x00020000) +#define PB3_COL ((uint)0x00040000) +#define PB3_CRS ((uint)0x00080000) +#define PB3_TXDAT ((uint)0x0f000000) +#define PB3_RXDAT ((uint)0x00f00000) +#define PB3_PSORB0 (PB3_RXDAT | PB3_TXDAT | PB3_CRS | PB3_COL | \ + PB3_RXER | PB3_RXDV | PB3_TXER | PB3_TXEN) +#define PB3_PSORB1 (0) +#define PB3_DIRB0 (PB3_RXDAT | PB3_CRS | PB3_COL | PB3_RXER | PB3_RXDV) +#define PB3_DIRB1 (PB3_TXDAT | PB3_TXEN | PB3_TXER) + +/* CLK15 is receive, CLK16 is transmit. These are board dependent. +*/ +#define PC_F3RXCLK ((uint)0x00004000) +#define PC_F3TXCLK ((uint)0x00008000) +#define CMX3_CLK_ROUTE ((uint)0x00003700) +#define CMX3_CLK_MASK ((uint)0x0000ff00) + +/* MII status/control serial interface. +*/ +#define PC_MDIO ((uint)0x00400000) +#define PC_MDCK ((uint)0x00200000) + +/* A table of information for supporting FCCs. This does two things. + * First, we know how many FCCs we have and they are always externally + * numbered from zero. Second, it holds control register and I/O + * information that could be different among board designs. + */ +typedef struct fcc_info { + uint fc_fccnum; + uint fc_cpmblock; + uint fc_cpmpage; + uint fc_proff; + uint fc_interrupt; + uint fc_trxclocks; + uint fc_clockroute; + uint fc_clockmask; + uint fc_mdio; + uint fc_mdck; +} fcc_info_t; + +static fcc_info_t fcc_ports[] = { +#ifdef CONFIG_FCC1_ENET + { 0, CPM_CR_FCC1_SBLOCK, CPM_CR_FCC1_PAGE, PROFF_FCC1, SIU_INT_FCC1, + (PC_F1RXCLK | PC_F1TXCLK), CMX1_CLK_ROUTE, CMX1_CLK_MASK, + PC_MDIO, PC_MDCK }, +#endif +#ifdef CONFIG_FCC2_ENET + { 1, CPM_CR_FCC2_SBLOCK, CPM_CR_FCC2_PAGE, PROFF_FCC2, SIU_INT_FCC2, + (PC_F2RXCLK | PC_F2TXCLK), CMX2_CLK_ROUTE, CMX2_CLK_MASK, + PC_MDIO, PC_MDCK }, +#endif +#ifdef CONFIG_FCC3_ENET + { 2, CPM_CR_FCC3_SBLOCK, CPM_CR_FCC3_PAGE, PROFF_FCC3, SIU_INT_FCC3, + (PC_F3RXCLK | PC_F3TXCLK), CMX3_CLK_ROUTE, CMX3_CLK_MASK, + PC_MDIO, PC_MDCK }, +#endif +}; + +/* The FCC buffer descriptors track the ring buffers. The rx_bd_base and + * tx_bd_base always point to the base of the buffer descriptors. The + * cur_rx and cur_tx point to the currently available buffer. + * The dirty_tx tracks the current buffer that is being sent by the + * controller. The cur_tx and dirty_tx are equal under both completely + * empty and completely full conditions. The empty/ready indicator in + * the buffer descriptor determines the actual condition. + */ +struct fcc_enet_private { + /* The saved address of a sent-in-place packet/buffer, for skfree(). */ + struct sk_buff* tx_skbuff[TX_RING_SIZE]; + ushort skb_cur; + ushort skb_dirty; + + /* CPM dual port RAM relative addresses. + */ + cbd_t *rx_bd_base; /* Address of Rx and Tx buffers. */ + cbd_t *tx_bd_base; + cbd_t *cur_rx, *cur_tx; /* The next free ring entry */ + cbd_t *dirty_tx; /* The ring entries to be free()ed. */ + volatile fcc_t *fccp; + volatile fcc_enet_t *ep; + struct net_device_stats stats; + uint tx_full; + spinlock_t lock; + uint phy_address; + uint phy_type; + uint phy_duplex; + fcc_info_t *fip; +}; + +static void init_fcc_shutdown(fcc_info_t *fip, struct fcc_enet_private *cep, + volatile immap_t *immap); +static void init_fcc_startup(fcc_info_t *fip, struct net_device *dev); +static void init_fcc_ioports(fcc_info_t *fip, volatile iop8260_t *io, + volatile immap_t *immap); +static void init_fcc_param(fcc_info_t *fip, struct net_device *dev, + volatile immap_t *immap); + +/* MII processing. We keep this as simple as possible. Requests are + * placed on the list (if there is room). When the request is finished + * by the MII, an optional function may be called. + */ +typedef struct mii_list { + uint mii_regval; + void (*mii_func)(uint val, struct net_device *dev); + struct mii_list *mii_next; +} mii_list_t; + +#define NMII 20 +mii_list_t mii_cmds[NMII]; +mii_list_t *mii_free; +mii_list_t *mii_head; +mii_list_t *mii_tail; + +static int phyaddr; +static uint phytype; + +static int mii_queue(int request, void (*func)(uint, struct net_device *)); +static void mii_startup_cmds(void); +static uint mii_send_receive(fcc_info_t *fip, uint cmd); + +/* Make MII read/write commands for the FCC. +*/ + +#define mk_mii_phyaddr(ADDR) (0x60020000 | ((ADDR) << 23) | (2 << 18)) + +#define mk_mii_read(REG) (0x60020000 | ((phyaddr << 23) | \ + (REG & 0x1f) << 18)) + +#define mk_mii_write(REG, VAL) (0x50020000 | ((phyaddr << 23) | \ + (REG & 0x1f) << 18) | \ + (VAL & 0xffff)) + + +static int +fcc_enet_open(struct net_device *dev) +{ + netif_start_queue(dev); + return 0; /* Always succeed */ +} + +static int +fcc_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) +{ + struct fcc_enet_private *cep = (struct fcc_enet_private *)dev->priv; + volatile cbd_t *bdp; + + + /* Fill in a Tx ring entry */ + bdp = cep->cur_tx; + +#ifndef final_version + if (bdp->cbd_sc & BD_ENET_TX_READY) { + /* Ooops. All transmit buffers are full. Bail out. + * This should not happen, since cep->tx_full should be set. + */ + printk("%s: tx queue full!.\n", dev->name); + return 1; + } +#endif + + /* Clear all of the status flags. + */ + bdp->cbd_sc &= ~BD_ENET_TX_STATS; + + /* If the frame is short, tell CPM to pad it. + */ + if (skb->len <= ETH_ZLEN) + bdp->cbd_sc |= BD_ENET_TX_PAD; + else + bdp->cbd_sc &= ~BD_ENET_TX_PAD; + + /* Set buffer length and buffer pointer. + */ + bdp->cbd_datlen = skb->len; + bdp->cbd_bufaddr = __pa(skb->data); + + /* Save skb pointer. + */ + cep->tx_skbuff[cep->skb_cur] = skb; + + cep->stats.tx_bytes += skb->len; + cep->skb_cur = (cep->skb_cur+1) & TX_RING_MOD_MASK; + + spin_lock_irq(&cep->lock); + + /* Send it on its way. Tell CPM its ready, interrupt when done, + * its the last BD of the frame, and to put the CRC on the end. + */ + bdp->cbd_sc |= (BD_ENET_TX_READY | BD_ENET_TX_INTR | BD_ENET_TX_LAST | BD_ENET_TX_TC); + +#if 0 + /* Errata says don't do this. + */ + cep->fccp->fcc_ftodr = 0x8000; +#endif + dev->trans_start = jiffies; + + /* If this was the last BD in the ring, start at the beginning again. + */ + if (bdp->cbd_sc & BD_ENET_TX_WRAP) + bdp = cep->tx_bd_base; + else + bdp++; + + if (bdp->cbd_sc & BD_ENET_TX_READY) { + netif_stop_queue(dev); + cep->tx_full = 1; + } + + cep->cur_tx = (cbd_t *)bdp; + + spin_unlock_irq(&cep->lock); + + return 0; +} + + +static void +fcc_enet_timeout(struct net_device *dev) +{ + struct fcc_enet_private *cep = (struct fcc_enet_private *)dev->priv; + + printk("%s: transmit timed out.\n", dev->name); + cep->stats.tx_errors++; +#ifndef final_version + { + int i; + cbd_t *bdp; + printk(" Ring data dump: cur_tx %p%s cur_rx %p.\n", + cep->cur_tx, cep->tx_full ? " (full)" : "", + cep->cur_rx); + bdp = cep->tx_bd_base; + printk(" Tx @base %p :\n", bdp); + for (i = 0 ; i < TX_RING_SIZE; i++, bdp++) + printk("%04x %04x %08x\n", + bdp->cbd_sc, + bdp->cbd_datlen, + bdp->cbd_bufaddr); + bdp = cep->rx_bd_base; + printk(" Rx @base %p :\n", bdp); + for (i = 0 ; i < RX_RING_SIZE; i++, bdp++) + printk("%04x %04x %08x\n", + bdp->cbd_sc, + bdp->cbd_datlen, + bdp->cbd_bufaddr); + } +#endif + if (!cep->tx_full) + netif_wake_queue(dev); +} + +/* The interrupt handler. + */ +static void +fcc_enet_interrupt(int irq, void * dev_id, struct pt_regs * regs) +{ + struct net_device *dev = dev_id; + volatile struct fcc_enet_private *cep; + volatile cbd_t *bdp; + ushort int_events; + int must_restart; + + cep = (struct fcc_enet_private *)dev->priv; + + /* Get the interrupt events that caused us to be here. + */ + int_events = cep->fccp->fcc_fcce; + cep->fccp->fcc_fcce = int_events; + must_restart = 0; + + /* Handle receive event in its own function. + */ + if (int_events & FCC_ENET_RXF) + fcc_enet_rx(dev_id); + + /* Check for a transmit error. The manual is a little unclear + * about this, so the debug code until I get it figured out. It + * appears that if TXE is set, then TXB is not set. However, + * if carrier sense is lost during frame transmission, the TXE + * bit is set, "and continues the buffer transmission normally." + * I don't know if "normally" implies TXB is set when the buffer + * descriptor is closed.....trial and error :-). + */ + + /* Transmit OK, or non-fatal error. Update the buffer descriptors. + */ + if (int_events & (FCC_ENET_TXE | FCC_ENET_TXB)) { + spin_lock(&cep->lock); + bdp = cep->dirty_tx; + while ((bdp->cbd_sc&BD_ENET_TX_READY)==0) { + if ((bdp==cep->cur_tx) && (cep->tx_full == 0)) + break; + + if (bdp->cbd_sc & BD_ENET_TX_HB) /* No heartbeat */ + cep->stats.tx_heartbeat_errors++; + if (bdp->cbd_sc & BD_ENET_TX_LC) /* Late collision */ + cep->stats.tx_window_errors++; + if (bdp->cbd_sc & BD_ENET_TX_RL) /* Retrans limit */ + cep->stats.tx_aborted_errors++; + if (bdp->cbd_sc & BD_ENET_TX_UN) /* Underrun */ + cep->stats.tx_fifo_errors++; + if (bdp->cbd_sc & BD_ENET_TX_CSL) /* Carrier lost */ + cep->stats.tx_carrier_errors++; + + + /* No heartbeat or Lost carrier are not really bad errors. + * The others require a restart transmit command. + */ + if (bdp->cbd_sc & + (BD_ENET_TX_LC | BD_ENET_TX_RL | BD_ENET_TX_UN)) { + must_restart = 1; + cep->stats.tx_errors++; + } + + cep->stats.tx_packets++; + + /* Deferred means some collisions occurred during transmit, + * but we eventually sent the packet OK. + */ + if (bdp->cbd_sc & BD_ENET_TX_DEF) + cep->stats.collisions++; + + /* Free the sk buffer associated with this last transmit. + */ + dev_kfree_skb_irq(cep->tx_skbuff[cep->skb_dirty]); + cep->skb_dirty = (cep->skb_dirty + 1) & TX_RING_MOD_MASK; + + /* Update pointer to next buffer descriptor to be transmitted. + */ + if (bdp->cbd_sc & BD_ENET_TX_WRAP) + bdp = cep->tx_bd_base; + else + bdp++; + + /* I don't know if we can be held off from processing these + * interrupts for more than one frame time. I really hope + * not. In such a case, we would now want to check the + * currently available BD (cur_tx) and determine if any + * buffers between the dirty_tx and cur_tx have also been + * sent. We would want to process anything in between that + * does not have BD_ENET_TX_READY set. + */ + + /* Since we have freed up a buffer, the ring is no longer + * full. + */ + if (cep->tx_full) { + cep->tx_full = 0; + if (netif_queue_stopped(dev)) { + netif_wake_queue(dev); + } + } + + cep->dirty_tx = (cbd_t *)bdp; + } + + if (must_restart) { + volatile cpm8260_t *cp; + + /* Some transmit errors cause the transmitter to shut + * down. We now issue a restart transmit. Since the + * errors close the BD and update the pointers, the restart + * _should_ pick up without having to reset any of our + * pointers either. + */ + + cp = cpmp; + cp->cp_cpcr = + mk_cr_cmd(cep->fip->fc_cpmpage, cep->fip->fc_cpmblock, + 0x0c, CPM_CR_RESTART_TX) | CPM_CR_FLG; + while (cp->cp_cpcr & CPM_CR_FLG); + } + spin_unlock(&cep->lock); + } + + /* Check for receive busy, i.e. packets coming but no place to + * put them. + */ + if (int_events & FCC_ENET_BSY) { + cep->stats.rx_dropped++; + } + return; +} + +/* During a receive, the cur_rx points to the current incoming buffer. + * When we update through the ring, if the next incoming buffer has + * not been given to the system, we just set the empty indicator, + * effectively tossing the packet. + */ +static int +fcc_enet_rx(struct net_device *dev) +{ + struct fcc_enet_private *cep; + volatile cbd_t *bdp; + struct sk_buff *skb; + ushort pkt_len; + + cep = (struct fcc_enet_private *)dev->priv; + + /* First, grab all of the stats for the incoming packet. + * These get messed up if we get called due to a busy condition. + */ + bdp = cep->cur_rx; + +for (;;) { + if (bdp->cbd_sc & BD_ENET_RX_EMPTY) + break; + +#ifndef final_version + /* Since we have allocated space to hold a complete frame, both + * the first and last indicators should be set. + */ + if ((bdp->cbd_sc & (BD_ENET_RX_FIRST | BD_ENET_RX_LAST)) != + (BD_ENET_RX_FIRST | BD_ENET_RX_LAST)) + printk("CPM ENET: rcv is not first+last\n"); +#endif + + /* Frame too long or too short. + */ + if (bdp->cbd_sc & (BD_ENET_RX_LG | BD_ENET_RX_SH)) + cep->stats.rx_length_errors++; + if (bdp->cbd_sc & BD_ENET_RX_NO) /* Frame alignment */ + cep->stats.rx_frame_errors++; + if (bdp->cbd_sc & BD_ENET_RX_CR) /* CRC Error */ + cep->stats.rx_crc_errors++; + if (bdp->cbd_sc & BD_ENET_RX_OV) /* FIFO overrun */ + cep->stats.rx_crc_errors++; + + /* Report late collisions as a frame error. + * On this error, the BD is closed, but we don't know what we + * have in the buffer. So, just drop this frame on the floor. + */ + if (bdp->cbd_sc & BD_ENET_RX_CL) { + cep->stats.rx_frame_errors++; + } + else { + + /* Process the incoming frame. + */ + cep->stats.rx_packets++; + pkt_len = bdp->cbd_datlen; + cep->stats.rx_bytes += pkt_len; + + /* This does 16 byte alignment, much more than we need. + * The packet length includes FCS, but we don't want to + * include that when passing upstream as it messes up + * bridging applications. + */ + skb = dev_alloc_skb(pkt_len-4); + + if (skb == NULL) { + printk("%s: Memory squeeze, dropping packet.\n", dev->name); + cep->stats.rx_dropped++; + } + else { + skb->dev = dev; + skb_put(skb,pkt_len-4); /* Make room */ + eth_copy_and_sum(skb, + (unsigned char *)__va(bdp->cbd_bufaddr), + pkt_len-4, 0); + skb->protocol=eth_type_trans(skb,dev); + netif_rx(skb); + } + } + + /* Clear the status flags for this buffer. + */ + bdp->cbd_sc &= ~BD_ENET_RX_STATS; + + /* Mark the buffer empty. + */ + bdp->cbd_sc |= BD_ENET_RX_EMPTY; + + /* Update BD pointer to next entry. + */ + if (bdp->cbd_sc & BD_ENET_RX_WRAP) + bdp = cep->rx_bd_base; + else + bdp++; + + } + cep->cur_rx = (cbd_t *)bdp; + + return 0; +} + +static int +fcc_enet_close(struct net_device *dev) +{ + /* Don't know what to do yet. + */ + netif_stop_queue(dev); + + return 0; +} + +static struct net_device_stats *fcc_enet_get_stats(struct net_device *dev) +{ + struct fcc_enet_private *cep = (struct fcc_enet_private *)dev->priv; + + return &cep->stats; +} + +/* The MII is simulated from the 8xx FEC implementation. The FCC + * is not responsible for the MII control/status interface. + */ +static void +fcc_enet_mii(struct net_device *dev) +{ + struct fcc_enet_private *fep; + mii_list_t *mip; + uint mii_reg; + + fep = (struct fcc_enet_private *)dev->priv; +#if 0 + ep = &(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec); + mii_reg = ep->fec_mii_data; +#endif + + if ((mip = mii_head) == NULL) { + printk("MII and no head!\n"); + return; + } + + if (mip->mii_func != NULL) + (*(mip->mii_func))(mii_reg, dev); + + mii_head = mip->mii_next; + mip->mii_next = mii_free; + mii_free = mip; + +#if 0 + if ((mip = mii_head) != NULL) + ep->fec_mii_data = mip->mii_regval; +#endif +} + +static int +mii_queue(int regval, void (*func)(uint, struct net_device *)) +{ + unsigned long flags; + mii_list_t *mip; + int retval; + + retval = 0; + + save_flags(flags); + cli(); + + if ((mip = mii_free) != NULL) { + mii_free = mip->mii_next; + mip->mii_regval = regval; + mip->mii_func = func; + mip->mii_next = NULL; + if (mii_head) { + mii_tail->mii_next = mip; + mii_tail = mip; + } + else { + mii_head = mii_tail = mip; +#if 0 + (&(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec))->fec_mii_data = regval; +#endif + } + } + else { + retval = 1; + } + + restore_flags(flags); + + return(retval); +} + +static volatile uint full_duplex; + +static void +mii_status(uint mii_reg, struct net_device *dev) +{ + volatile uint prev_duplex; + + if (((mii_reg >> 18) & 0x1f) == 1) { + /* status register. + */ + printk("fec: "); + if (mii_reg & 0x0004) + printk("link up"); + else + printk("link down"); + + if (mii_reg & 0x0010) + printk(",remote fault"); + if (mii_reg & 0x0020) + printk(",auto complete"); + printk("\n"); + } + if (((mii_reg >> 18) & 0x1f) == 0x14) { + /* Extended chip status register. + */ + prev_duplex = full_duplex; + printk("fec: "); + if (mii_reg & 0x0800) + printk("100 Mbps"); + else + printk("10 Mbps"); + + if (mii_reg & 0x1000) { + printk(", Full-Duplex\n"); + full_duplex = 1; + } + else { + printk(", Half-Duplex\n"); + full_duplex = 0; + } +#if 0 + if (prev_duplex != full_duplex) + restart_fec(dev); +#endif + } + if (((mii_reg >> 18) & 0x1f) == 31) { + /* QS6612 PHY Control/Status. + * OK, now we have it all, so figure out what is going on. + */ + prev_duplex = full_duplex; + printk("fec: "); + + mii_reg = (mii_reg >> 2) & 7; + + if (mii_reg & 1) + printk("10 Mbps"); + else + printk("100 Mbps"); + + if (mii_reg > 4) { + printk(", Full-Duplex\n"); + full_duplex = 1; + } + else { + printk(", Half-Duplex\n"); + full_duplex = 0; + } + +#if 0 + if (prev_duplex != full_duplex) + restart_fec(dev); +#endif + } +} + +static uint phyno; + +static void +mii_discover_phy3(uint mii_reg, struct net_device *dev) +{ + phytype <<= 16; + phytype |= (mii_reg & 0xffff); + printk("fec: Phy @ 0x%x, type 0x%08x\n", phyno, phytype); + mii_startup_cmds(); +} + +static void +mii_discover_phy(uint mii_reg, struct net_device *dev) +{ + if (phyno < 32) { + if ((phytype = (mii_reg & 0xffff)) != 0xffff) { + phyaddr = phyno; + mii_queue(mk_mii_read(3), mii_discover_phy3); + } + else { + phyno++; + mii_queue(mk_mii_phyaddr(phyno), mii_discover_phy); + } + } + else { + printk("FEC: No PHY device found.\n"); + } +} + +static void +mii_discover_phy_poll(fcc_info_t *fip) +{ + uint rv; + int i; + + for (i=0; i<32; i++) { + rv = mii_send_receive(fip, mk_mii_phyaddr(i)); + if ((phytype = (rv & 0xffff)) != 0xffff) { + phyaddr = i; + rv = mii_send_receive(fip, mk_mii_read(3)); + phytype <<= 16; + phytype |= (rv & 0xffff); + printk("fec: Phy @ 0x%x, type 0x%08x\n", phyaddr, phytype); + } + } +} + +static void +mii_startup_cmds(void) +{ + +#if 1 + /* Level One PHY. + */ + + /* Read status registers to clear any pending interrupt. + */ + mii_queue(mk_mii_read(1), mii_status); + mii_queue(mk_mii_read(18), mii_status); + + /* Read extended chip status register. + */ + mii_queue(mk_mii_read(0x14), mii_status); + + /* Set default operation of 100-TX....for some reason + * some of these bits are set on power up, which is wrong. + */ + mii_queue(mk_mii_write(0x13, 0), NULL); + + /* Enable Link status change interrupts. + */ + mii_queue(mk_mii_write(0x11, 0x0002), NULL); + + /* Don't advertize Full duplex. + mii_queue(mk_mii_write(0x04, 0x0021), NULL); + */ +#endif + +} + +/* This supports the mii_link interrupt below. + * We should get called three times. Once for register 1, once for + * register 18, and once for register 20. + */ +static uint mii_saved_reg1; + +static void +mii_relink(uint mii_reg, struct net_device *dev) +{ + volatile uint prev_duplex; + unsigned long flags; + + if (((mii_reg >> 18) & 0x1f) == 1) { + /* Just save the status register and get out. + */ + mii_saved_reg1 = mii_reg; + return; + } + if (((mii_reg >> 18) & 0x1f) == 18) { + /* Not much here, but has to be read to clear the + * interrupt condition. + */ + if ((mii_reg & 0x8000) == 0) + printk("fec: re-link and no IRQ?\n"); + if ((mii_reg & 0x4000) == 0) + printk("fec: no PHY power?\n"); + } + if (((mii_reg >> 18) & 0x1f) == 20) { + /* Extended chip status register. + * OK, now we have it all, so figure out what is going on. + */ + prev_duplex = full_duplex; + printk("fec: "); + if (mii_saved_reg1 & 0x0004) + printk("link up"); + else + printk("link down"); + + if (mii_saved_reg1 & 0x0010) + printk(", remote fault"); + if (mii_saved_reg1 & 0x0020) + printk(", auto complete"); + + if (mii_reg & 0x0800) + printk(", 100 Mbps"); + else + printk(", 10 Mbps"); + + if (mii_reg & 0x1000) { + printk(", Full-Duplex\n"); + full_duplex = 1; + } + else { + printk(", Half-Duplex\n"); + full_duplex = 0; + } + if (prev_duplex != full_duplex) { + save_flags(flags); + cli(); +#if 0 + restart_fec(dev); +#endif + restore_flags(flags); + } + } + if (((mii_reg >> 18) & 0x1f) == 31) { + /* QS6612 PHY Control/Status. + * OK, now we have it all, so figure out what is going on. + */ + prev_duplex = full_duplex; + printk("fec: "); + if (mii_saved_reg1 & 0x0004) + printk("link up"); + else + printk("link down"); + + if (mii_saved_reg1 & 0x0010) + printk(", remote fault"); + if (mii_saved_reg1 & 0x0020) + printk(", auto complete"); + + mii_reg = (mii_reg >> 2) & 7; + + if (mii_reg & 1) + printk(", 10 Mbps"); + else + printk(", 100 Mbps"); + + if (mii_reg > 4) { + printk(", Full-Duplex\n"); + full_duplex = 1; + } + else { + printk(", Half-Duplex\n"); + full_duplex = 0; + } + +#if 0 + if (prev_duplex != full_duplex) { + save_flags(flags); + cli(); + restart_fec(dev); + restore_flags(flags); + } +#endif + } +} + +/* Set or clear the multicast filter for this adaptor. + * Skeleton taken from sunlance driver. + * The CPM Ethernet implementation allows Multicast as well as individual + * MAC address filtering. Some of the drivers check to make sure it is + * a group multicast address, and discard those that are not. I guess I + * will do the same for now, but just remove the test if you want + * individual filtering as well (do the upper net layers want or support + * this kind of feature?). + */ +static void +set_multicast_list(struct net_device *dev) +{ + struct fcc_enet_private *cep; + struct dev_mc_list *dmi; + u_char *mcptr, *tdptr; + volatile fcc_enet_t *ep; + int i, j; + + cep = (struct fcc_enet_private *)dev->priv; + +return; + /* Get pointer to FCC area in parameter RAM. + */ + ep = (fcc_enet_t *)dev->base_addr; + + if (dev->flags&IFF_PROMISC) { + + /* Log any net taps. */ + printk("%s: Promiscuous mode enabled.\n", dev->name); + cep->fccp->fcc_fpsmr |= FCC_PSMR_PRO; + } else { + + cep->fccp->fcc_fpsmr &= ~FCC_PSMR_PRO; + + if (dev->flags & IFF_ALLMULTI) { + /* Catch all multicast addresses, so set the + * filter to all 1's. + */ + ep->fen_gaddrh = 0xffffffff; + ep->fen_gaddrl = 0xffffffff; + } + else { + /* Clear filter and add the addresses in the list. + */ + ep->fen_gaddrh = 0; + ep->fen_gaddrl = 0; + + dmi = dev->mc_list; + + for (i=0; imc_count; i++) { + + /* Only support group multicast for now. + */ + if (!(dmi->dmi_addr[0] & 1)) + continue; + + /* The address in dmi_addr is LSB first, + * and taddr is MSB first. We have to + * copy bytes MSB first from dmi_addr. + */ + mcptr = (u_char *)dmi->dmi_addr + 5; + tdptr = (u_char *)&ep->fen_taddrh; + for (j=0; j<6; j++) + *tdptr++ = *mcptr--; + + /* Ask CPM to run CRC and set bit in + * filter mask. + */ + cpmp->cp_cpcr = mk_cr_cmd(cep->fip->fc_cpmpage, + cep->fip->fc_cpmblock, 0x0c, + CPM_CR_SET_GADDR) | CPM_CR_FLG; + udelay(10); + while (cpmp->cp_cpcr & CPM_CR_FLG); + } + } + } +} + +/* Initialize the CPM Ethernet on FCC. + */ +int __init fec_enet_init(void) +{ + struct net_device *dev; + struct fcc_enet_private *cep; + fcc_info_t *fip; + int i, np; + volatile immap_t *immap; + volatile iop8260_t *io; + + immap = (immap_t *)IMAP_ADDR; /* and to internal registers */ + io = &immap->im_ioport; + + np = sizeof(fcc_ports) / sizeof(fcc_info_t); + fip = fcc_ports; + + while (np-- > 0) { + + /* Allocate some private information. + */ + cep = (struct fcc_enet_private *) + kmalloc(sizeof(*cep), GFP_KERNEL); + __clear_user(cep,sizeof(*cep)); + spin_lock_init(&cep->lock); + cep->fip = fip; + + /* Create an Ethernet device instance. + */ + dev = init_etherdev(0, 0); + dev->priv = cep; + + init_fcc_shutdown(fip, cep, immap); + init_fcc_ioports(fip, io, immap); + init_fcc_param(fip, dev, immap); + + dev->base_addr = (unsigned long)(cep->ep); + + /* The CPM Ethernet specific entries in the device + * structure. + */ + dev->open = fcc_enet_open; + dev->hard_start_xmit = fcc_enet_start_xmit; + dev->tx_timeout = fcc_enet_timeout; + dev->watchdog_timeo = TX_TIMEOUT; + dev->stop = fcc_enet_close; + dev->get_stats = fcc_enet_get_stats; + dev->set_multicast_list = set_multicast_list; + + init_fcc_startup(fip, dev); + + printk("%s: FCC ENET Version 0.2, ", dev->name); + for (i=0; i<5; i++) + printk("%02x:", dev->dev_addr[i]); + printk("%02x\n", dev->dev_addr[5]); + + /* This is just a hack for now that works only on the EST + * board, or anything else that has MDIO/CK configured. + * It is mainly to test the MII software clocking. + */ + mii_discover_phy_poll(fip); + + fip++; + } + + return 0; +} + +/* Make sure the device is shut down during initialization. +*/ +static void __init +init_fcc_shutdown(fcc_info_t *fip, struct fcc_enet_private *cep, + volatile immap_t *immap) +{ + volatile fcc_enet_t *ep; + volatile fcc_t *fccp; + + /* Get pointer to FCC area in parameter RAM. + */ + ep = (fcc_enet_t *)(&immap->im_dprambase[fip->fc_proff]); + + /* And another to the FCC register area. + */ + fccp = (volatile fcc_t *)(&immap->im_fcc[fip->fc_fccnum]); + cep->fccp = fccp; /* Keep the pointers handy */ + cep->ep = ep; + + /* Disable receive and transmit in case someone left it running. + */ + fccp->fcc_gfmr &= ~(FCC_GFMR_ENR | FCC_GFMR_ENT); +} + +/* Initialize the I/O pins for the FCC Ethernet. +*/ +static void __init +init_fcc_ioports(fcc_info_t *fip, volatile iop8260_t *io, + volatile immap_t *immap) +{ + + /* FCC1 pins are on port A/C. FCC2/3 are port B/C. + */ + if (fip->fc_proff == PROFF_FCC1) { + /* Configure port A and C pins for FCC1 Ethernet. + */ + io->iop_pdira &= ~PA1_DIRA0; + io->iop_pdira |= PA1_DIRA1; + io->iop_psora &= ~PA1_PSORA0; + io->iop_psora |= PA1_PSORA1; + io->iop_ppara |= (PA1_DIRA0 | PA1_DIRA1); + } + if (fip->fc_proff == PROFF_FCC2) { + /* Configure port B and C pins for FCC Ethernet. + */ + io->iop_pdirb &= ~PB2_DIRB0; + io->iop_pdirb |= PB2_DIRB1; + io->iop_psorb &= ~PB2_PSORB0; + io->iop_psorb |= PB2_PSORB1; + io->iop_pparb |= (PB2_DIRB0 | PB2_DIRB1); + } + if (fip->fc_proff == PROFF_FCC3) { + /* Configure port B and C pins for FCC Ethernet. + */ + io->iop_pdirb &= ~PB3_DIRB0; + io->iop_pdirb |= PB3_DIRB1; + io->iop_psorb &= ~PB3_PSORB0; + io->iop_psorb |= PB3_PSORB1; + io->iop_pparb |= (PB3_DIRB0 | PB3_DIRB1); + } + + /* Port C has clocks...... + */ + io->iop_psorc &= ~(fip->fc_trxclocks); + io->iop_pdirc &= ~(fip->fc_trxclocks); + io->iop_pparc |= fip->fc_trxclocks; + + /* ....and the MII serial clock/data. + */ + io->iop_pdatc |= (fip->fc_mdio | fip->fc_mdck); + io->iop_podrc |= fip->fc_mdio; + io->iop_pdirc |= (fip->fc_mdio | fip->fc_mdck); + io->iop_pparc &= ~(fip->fc_mdio | fip->fc_mdck); + + /* Configure Serial Interface clock routing. + * First, clear all FCC bits to zero, + * then set the ones we want. + */ + immap->im_cpmux.cmx_fcr &= ~(fip->fc_clockmask); + immap->im_cpmux.cmx_fcr |= fip->fc_clockroute; +} + +static void __init +init_fcc_param(fcc_info_t *fip, struct net_device *dev, + volatile immap_t *immap) +{ + unsigned char *eap; + unsigned long mem_addr; + bd_t *bd; + int i, j; + struct fcc_enet_private *cep; + volatile fcc_enet_t *ep; + volatile cbd_t *bdp; + volatile cpm8260_t *cp; + + cep = (struct fcc_enet_private *)(dev->priv); + ep = cep->ep; + cp = cpmp; + + bd = (bd_t *)__res; + + /* Zero the whole thing.....I must have missed some individually. + * It works when I do this. + */ + memset((char *)ep, 0, sizeof(fcc_enet_t)); + + /* Allocate space for the buffer descriptors in the DP ram. + * These are relative offsets in the DP ram address space. + * Initialize base addresses for the buffer descriptors. + */ +#if 0 + /* I really want to do this, but for some reason it doesn't + * work with the data cache enabled, so I allocate from the + * main memory instead. + */ + i = m8260_cpm_dpalloc(sizeof(cbd_t) * RX_RING_SIZE, 8); + ep->fen_genfcc.fcc_rbase = (uint)&immap->im_dprambase[i]; + cep->rx_bd_base = (cbd_t *)&immap->im_dprambase[i]; + + i = m8260_cpm_dpalloc(sizeof(cbd_t) * TX_RING_SIZE, 8); + ep->fen_genfcc.fcc_tbase = (uint)&immap->im_dprambase[i]; + cep->tx_bd_base = (cbd_t *)&immap->im_dprambase[i]; +#else + cep->rx_bd_base = (cbd_t *)m8260_cpm_hostalloc(sizeof(cbd_t) * RX_RING_SIZE, 8); + ep->fen_genfcc.fcc_rbase = __pa(cep->rx_bd_base); + cep->tx_bd_base = (cbd_t *)m8260_cpm_hostalloc(sizeof(cbd_t) * TX_RING_SIZE, 8); + ep->fen_genfcc.fcc_tbase = __pa(cep->tx_bd_base); +#endif + + cep->dirty_tx = cep->cur_tx = cep->tx_bd_base; + cep->cur_rx = cep->rx_bd_base; + + ep->fen_genfcc.fcc_rstate = (CPMFCR_GBL | CPMFCR_EB) << 24; + ep->fen_genfcc.fcc_tstate = (CPMFCR_GBL | CPMFCR_EB) << 24; + + /* Set maximum bytes per receive buffer. + * It must be a multiple of 32. + */ + ep->fen_genfcc.fcc_mrblr = PKT_MAXBLR_SIZE; + + /* Allocate space in the reserved FCC area of DPRAM for the + * internal buffers. No one uses this space (yet), so we + * can do this. Later, we will add resource management for + * this area. + */ + mem_addr = CPM_FCC_SPECIAL_BASE + (fip->fc_fccnum * 128); + ep->fen_genfcc.fcc_riptr = mem_addr; + ep->fen_genfcc.fcc_tiptr = mem_addr+32; + ep->fen_padptr = mem_addr+64; + memset((char *)(&(immap->im_dprambase[(mem_addr+64)])), 0x88, 32); + + ep->fen_genfcc.fcc_rbptr = 0; + ep->fen_genfcc.fcc_tbptr = 0; + ep->fen_genfcc.fcc_rcrc = 0; + ep->fen_genfcc.fcc_tcrc = 0; + ep->fen_genfcc.fcc_res1 = 0; + ep->fen_genfcc.fcc_res2 = 0; + + ep->fen_camptr = 0; /* CAM isn't used in this driver */ + + /* Set CRC preset and mask. + */ + ep->fen_cmask = 0xdebb20e3; + ep->fen_cpres = 0xffffffff; + + ep->fen_crcec = 0; /* CRC Error counter */ + ep->fen_alec = 0; /* alignment error counter */ + ep->fen_disfc = 0; /* discard frame counter */ + ep->fen_retlim = 15; /* Retry limit threshold */ + ep->fen_pper = 0; /* Normal persistence */ + + /* Clear hash filter tables. + */ + ep->fen_gaddrh = 0; + ep->fen_gaddrl = 0; + ep->fen_iaddrh = 0; + ep->fen_iaddrl = 0; + + /* Clear the Out-of-sequence TxBD. + */ + ep->fen_tfcstat = 0; + ep->fen_tfclen = 0; + ep->fen_tfcptr = 0; + + ep->fen_mflr = PKT_MAXBUF_SIZE; /* maximum frame length register */ + ep->fen_minflr = PKT_MINBUF_SIZE; /* minimum frame length register */ + + /* Set Ethernet station address. + * + * This is supplied in the board information structure, so we + * copy that into the controller. + * So, far we have only been given one Ethernet address. We make + * it unique by setting a few bits in the upper byte of the + * non-static part of the address. + */ + eap = (unsigned char *)&(ep->fen_paddrh); + for (i=5; i>=0; i--) { + if (i == 3) { + dev->dev_addr[i] = bd->bi_enetaddr[i]; + dev->dev_addr[i] |= (1 << (7 - fip->fc_fccnum)); + *eap++ = dev->dev_addr[i]; + } + else { + *eap++ = dev->dev_addr[i] = bd->bi_enetaddr[i]; + } + } + + ep->fen_taddrh = 0; + ep->fen_taddrm = 0; + ep->fen_taddrl = 0; + + ep->fen_maxd1 = PKT_MAXDMA_SIZE; /* maximum DMA1 length */ + ep->fen_maxd2 = PKT_MAXDMA_SIZE; /* maximum DMA2 length */ + + /* Clear stat counters, in case we ever enable RMON. + */ + ep->fen_octc = 0; + ep->fen_colc = 0; + ep->fen_broc = 0; + ep->fen_mulc = 0; + ep->fen_uspc = 0; + ep->fen_frgc = 0; + ep->fen_ospc = 0; + ep->fen_jbrc = 0; + ep->fen_p64c = 0; + ep->fen_p65c = 0; + ep->fen_p128c = 0; + ep->fen_p256c = 0; + ep->fen_p512c = 0; + ep->fen_p1024c = 0; + + ep->fen_rfthr = 0; /* Suggested by manual */ + ep->fen_rfcnt = 0; + ep->fen_cftype = 0; + + /* Now allocate the host memory pages and initialize the + * buffer descriptors. + */ + bdp = cep->tx_bd_base; + for (i=0; icbd_sc = 0; + bdp->cbd_datlen = 0; + bdp->cbd_bufaddr = 0; + bdp++; + } + + /* Set the last buffer to wrap. + */ + bdp--; + bdp->cbd_sc |= BD_SC_WRAP; + + bdp = cep->rx_bd_base; + for (i=0; icbd_sc = BD_ENET_RX_EMPTY | BD_ENET_RX_INTR; + bdp->cbd_datlen = 0; + bdp->cbd_bufaddr = __pa(mem_addr); + mem_addr += FCC_ENET_RX_FRSIZE; + bdp++; + } + } + + /* Set the last buffer to wrap. + */ + bdp--; + bdp->cbd_sc |= BD_SC_WRAP; + + /* Let's re-initialize the channel now. We have to do it later + * than the manual describes because we have just now finished + * the BD initialization. + */ + cp->cp_cpcr = mk_cr_cmd(fip->fc_cpmpage, fip->fc_cpmblock, 0x0c, + CPM_CR_INIT_TRX) | CPM_CR_FLG; + while (cp->cp_cpcr & CPM_CR_FLG); + + cep->skb_cur = cep->skb_dirty = 0; +} + +/* Let 'er rip. +*/ +static void __init +init_fcc_startup(fcc_info_t *fip, struct net_device *dev) +{ + volatile fcc_t *fccp; + struct fcc_enet_private *cep; + + cep = (struct fcc_enet_private *)(dev->priv); + fccp = cep->fccp; + + fccp->fcc_fcce = 0xffff; /* Clear any pending events */ + + /* Enable interrupts for transmit error, complete frame + * received, and any transmit buffer we have also set the + * interrupt flag. + */ + fccp->fcc_fccm = (FCC_ENET_TXE | FCC_ENET_RXF | FCC_ENET_TXB); + + /* Install our interrupt handler. + */ + if (request_8xxirq(fip->fc_interrupt, fcc_enet_interrupt, 0, + "fenet", dev) < 0) + printk("Can't get FCC IRQ %d\n", fip->fc_interrupt); + + /* Set GFMR to enable Ethernet operating mode. + */ + fccp->fcc_gfmr = (FCC_GFMR_TCI | FCC_GFMR_MODE_ENET); + + /* Set sync/delimiters. + */ + fccp->fcc_fdsr = 0xd555; + + /* Set protocol specific processing mode for Ethernet. + * This has to be adjusted for Full Duplex operation after we can + * determine how to detect that. + */ + fccp->fcc_fpsmr = FCC_PSMR_ENCRC; + + /* And last, enable the transmit and receive processing. + */ + fccp->fcc_gfmr |= (FCC_GFMR_ENR | FCC_GFMR_ENT); +} + +/* MII command/status interface. + * I'm not going to describe all of the details. You can find the + * protocol definition in many other places, including the data sheet + * of most PHY parts. + * I wonder what "they" were thinking (maybe weren't) when they leave + * the I2C in the CPM but I have to toggle these bits...... + */ +static uint +mii_send_receive(fcc_info_t *fip, uint cmd) +{ + unsigned long flags; + uint retval; + int read_op, i; + volatile immap_t *immap; + volatile iop8260_t *io; + + immap = (immap_t *)IMAP_ADDR; + io = &immap->im_ioport; + + /* When we get here, both clock and data are high, outputs. + * Output is open drain. + * Data transitions on high->low clock, is valid on low->high clock. + * Spec says edge transitions no closer than 160 nSec, minimum clock + * cycle 400 nSec. I could only manage about 500 nSec edges with + * an XOR loop, so I won't worry about delays yet. + * I disable interrupts during bit flipping to ensure atomic + * updates of the registers. I do lots of interrupt disable/enable + * to ensure we don't hang out too long with interrupts disabled. + */ + + /* First, crank out 32 1-bits as preamble. + * This is 64 transitions to clock the bits, with clock/data + * left high. + */ + save_flags(flags); + cli(); + for (i=0; i<64; i++) { + io->iop_pdatc ^= fip->fc_mdck; + udelay(0); + } + restore_flags(flags); + + read_op = ((cmd & 0xf0000000) == 0x60000000); + + /* We return the command word on a write op, or the command portion + * plus the new data on a read op. This is what the 8xx FEC does, + * and it allows the functions to simply look at the returned value + * and know the PHY/register as well. + */ + if (read_op) + retval = cmd; + else + retval = (cmd >> 16); + + /* Clock out the first 16 MS bits of the command. + */ + save_flags(flags); + cli(); + for (i=0; i<16; i++) { + io->iop_pdatc &= ~(fip->fc_mdck); + if (cmd & 0x80000000) + io->iop_pdatc |= fip->fc_mdio; + else + io->iop_pdatc &= ~(fip->fc_mdio); + cmd <<= 1; + io->iop_pdatc |= fip->fc_mdck; + udelay(0); + } + + /* Do the turn-around. If read op, we make the IO and input. + * If write op, do the 1/0 thing. + */ + io->iop_pdatc &= ~(fip->fc_mdck); + if (read_op) + io->iop_pdirc &= ~(fip->fc_mdio); + else + io->iop_pdatc |= fip->fc_mdio; + io->iop_pdatc |= fip->fc_mdck; + + /* I do this mainly to get just a little delay. + */ + restore_flags(flags); + save_flags(flags); + cli(); + io->iop_pdatc &= ~(fip->fc_mdck); + io->iop_pdirc &= ~(fip->fc_mdio); + io->iop_pdatc |= fip->fc_mdck; + + restore_flags(flags); + save_flags(flags); + cli(); + + /* For read, clock in 16 bits. For write, clock out + * rest of command. + */ + if (read_op) { + io->iop_pdatc &= ~(fip->fc_mdck); + udelay(0); + for (i=0; i<16; i++) { + io->iop_pdatc |= fip->fc_mdck; + udelay(0); + retval <<= 1; + if (io->iop_pdatc & fip->fc_mdio) + retval |= 1; + io->iop_pdatc &= ~(fip->fc_mdck); + udelay(0); + } + } + else { + for (i=0; i<16; i++) { + io->iop_pdatc &= ~(fip->fc_mdck); + if (cmd & 0x80000000) + io->iop_pdatc |= fip->fc_mdio; + else + io->iop_pdatc &= ~(fip->fc_mdio); + cmd <<= 1; + io->iop_pdatc |= fip->fc_mdck; + udelay(0); + } + io->iop_pdatc &= ~(fip->fc_mdck); + } + restore_flags(flags); + + /* Some diagrams show two 1 bits for "idle". I don't know if + * this is really necessary or if it was just to indicate nothing + * is going to happen for a while. + * Make the data pin an output, set the data high, and clock it. + */ + save_flags(flags); + cli(); + io->iop_pdatc |= fip->fc_mdio; + io->iop_pdirc |= fip->fc_mdio; + for (i=0; i<3; i++) + io->iop_pdatc ^= fip->fc_mdck; + restore_flags(flags); + + /* We exit with the same conditions as entry. + */ + return(retval); +} diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/8260_io/uart.c linux/arch/ppc/8260_io/uart.c --- v2.4.0-test8/linux/arch/ppc/8260_io/uart.c Mon Jul 10 16:47:20 2000 +++ linux/arch/ppc/8260_io/uart.c Sun Sep 17 09:48:05 2000 @@ -977,8 +977,7 @@ } if (from_user) { - if (c != - copy_from_user(__va(bdp->cbd_bufaddr), buf, c)) { + if (copy_from_user(__va(bdp->cbd_bufaddr), buf, c)) { if (!ret) ret = -EFAULT; break; @@ -2396,10 +2395,10 @@ io->iop_pdird &= ~0x00800000; io->iop_psord &= ~0x00c00000; #if USE_SMC2 - io->iop_ppara |= 0x01800000; - io->iop_pdira |= 0x00800000; - io->iop_pdira &= ~0x01000000; - io->iop_psora &= ~0x01800000; + io->iop_ppara |= 0x00c00000; + io->iop_pdira |= 0x00400000; + io->iop_pdira &= ~0x00800000; + io->iop_psora &= ~0x00c00000; #endif /* Configure SCC2 and SCC3. Be careful about the fine print. @@ -2473,11 +2472,11 @@ * descriptors from dual port ram, and a character * buffer area from host mem. */ - dp_addr = m8260_cpm_dpalloc(sizeof(cbd_t) * RX_NUM_FIFO); + dp_addr = m8260_cpm_dpalloc(sizeof(cbd_t) * RX_NUM_FIFO, 8); /* Allocate space for FIFOs in the host memory. */ - mem_addr = m8260_cpm_hostalloc(RX_NUM_FIFO * RX_BUF_SIZE); + mem_addr = m8260_cpm_hostalloc(RX_NUM_FIFO * RX_BUF_SIZE, 1); /* Set the physical address of the host memory * buffers in the buffer descriptors, and the @@ -2506,11 +2505,11 @@ sup->scc_genscc.scc_rbase = dp_addr; } - dp_addr = m8260_cpm_dpalloc(sizeof(cbd_t) * TX_NUM_FIFO); + dp_addr = m8260_cpm_dpalloc(sizeof(cbd_t) * TX_NUM_FIFO, 8); /* Allocate space for FIFOs in the host memory. */ - mem_addr = m8260_cpm_hostalloc(TX_NUM_FIFO * TX_BUF_SIZE); + mem_addr = m8260_cpm_hostalloc(TX_NUM_FIFO * TX_BUF_SIZE, 1); /* Set the physical address of the host memory * buffers in the buffer descriptors, and the @@ -2716,11 +2715,11 @@ /* Allocate space for two buffer descriptors in the DP ram. */ - dp_addr = m8260_cpm_dpalloc(sizeof(cbd_t) * 2); + dp_addr = m8260_cpm_dpalloc(sizeof(cbd_t) * 2, 8); /* Allocate space for two 2 byte FIFOs in the host memory. */ - mem_addr = m8260_cpm_hostalloc(4); + mem_addr = m8260_cpm_hostalloc(4, 1); /* Set the physical address of the host memory buffers in * the buffer descriptors. diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/8xx_io/enet.c linux/arch/ppc/8xx_io/enet.c --- v2.4.0-test8/linux/arch/ppc/8xx_io/enet.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/8xx_io/enet.c Sun Sep 17 09:48:05 2000 @@ -484,8 +484,11 @@ cep->stats.rx_bytes += pkt_len; /* This does 16 byte alignment, much more than we need. - */ - skb = dev_alloc_skb(pkt_len); + * The packet length includes FCS, but we don't want to + * include that when passing upstream as it messes up + * bridging applications. + */ + skb = dev_alloc_skb(pkt_len-4); if (skb == NULL) { printk("%s: Memory squeeze, dropping packet.\n", dev->name); @@ -493,10 +496,10 @@ } else { skb->dev = dev; - skb_put(skb,pkt_len); /* Make room */ + skb_put(skb,pkt_len-4); /* Make room */ eth_copy_and_sum(skb, (unsigned char *)__va(bdp->cbd_bufaddr), - pkt_len, 0); + pkt_len-4, 0); skb->protocol=eth_type_trans(skb,dev); netif_rx(skb); } diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/8xx_io/fec.c linux/arch/ppc/8xx_io/fec.c --- v2.4.0-test8/linux/arch/ppc/8xx_io/fec.c Fri Jun 23 21:55:07 2000 +++ linux/arch/ppc/8xx_io/fec.c Sun Sep 17 09:48:06 2000 @@ -669,18 +669,21 @@ #endif /* This does 16 byte alignment, exactly what we need. + * The packet length includes FCS, but we don't want to + * include that when passing upstream as it messes up + * bridging applications. */ - skb = dev_alloc_skb(pkt_len); + skb = dev_alloc_skb(pkt_len-4); if (skb == NULL) { printk("%s: Memory squeeze, dropping packet.\n", dev->name); fep->stats.rx_dropped++; } else { skb->dev = dev; - skb_put(skb,pkt_len); /* Make room */ + skb_put(skb,pkt_len-4); /* Make room */ eth_copy_and_sum(skb, (unsigned char *)__va(bdp->cbd_bufaddr), - pkt_len, 0); + pkt_len-4, 0); skb->protocol=eth_type_trans(skb,dev); netif_rx(skb); } diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/amiga/time.c linux/arch/ppc/amiga/time.c --- v2.4.0-test8/linux/arch/ppc/amiga/time.c Sat Oct 9 11:47:50 1999 +++ linux/arch/ppc/amiga/time.c Mon Sep 11 08:39:48 2000 @@ -11,10 +11,6 @@ #include -static inline unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec); - unsigned long m68k_get_rtc_time(void) { unsigned int year, mon, day, hour, min, sec; @@ -36,38 +32,6 @@ return mach_set_clock_mmss (nowtime); return -1; } - -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static inline unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ -} - void apus_heartbeat (void) { diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/chrpboot/Makefile linux/arch/ppc/chrpboot/Makefile --- v2.4.0-test8/linux/arch/ppc/chrpboot/Makefile Fri Jun 23 21:55:07 2000 +++ linux/arch/ppc/chrpboot/Makefile Sun Sep 17 09:48:06 2000 @@ -67,11 +67,13 @@ zImage: $(OBJS) no_initrd.o addnote $(LD) $(LD_ARGS) -o $@ $(OBJS) no_initrd.o $(LIBS) - ./addnote $@ + cp $@ $@.rs6k + ./addnote $@.rs6k zImage.initrd: $(OBJS) initrd.o addnote $(LD) $(LD_ARGS) -o $@ $(OBJS) initrd.o $(LIBS) - ./addnote $@ + cp $@ $@.rs6k + ./addnote $@.rs6k else znetboot: diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/chrpboot/addnote.c linux/arch/ppc/chrpboot/addnote.c --- v2.4.0-test8/linux/arch/ppc/chrpboot/addnote.c Fri Jun 23 21:55:07 2000 +++ linux/arch/ppc/chrpboot/addnote.c Sun Sep 17 09:48:06 2000 @@ -22,12 +22,23 @@ #define N_DESCR 6 unsigned int descr[N_DESCR] = { +#if 1 + /* values for IBM RS/6000 machines */ 0xffffffff, /* real-mode = true */ 0x00c00000, /* real-base, i.e. where we expect OF to be */ 0xffffffff, /* real-size */ 0xffffffff, /* virt-base */ 0xffffffff, /* virt-size */ 0x4000, /* load-base */ +#else + /* values for longtrail CHRP */ + 0, /* real-mode = false */ + 0xffffffff, /* real-base */ + 0xffffffff, /* real-size */ + 0xffffffff, /* virt-base */ + 0xffffffff, /* virt-size */ + 0x00600000, /* load-base */ +#endif }; unsigned char buf[512]; @@ -63,7 +74,7 @@ unsigned char elf_magic[4] = { 0x7f, 'E', 'L', 'F' }; -main(int ac, char **av) +int main(int ac, char **av) { int fd, n, i; int ph, ps, np; diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/coffboot/Makefile linux/arch/ppc/coffboot/Makefile --- v2.4.0-test8/linux/arch/ppc/coffboot/Makefile Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/coffboot/Makefile Sun Sep 17 09:48:06 2000 @@ -8,7 +8,7 @@ CFLAGS = $(CPPFLAGS) -O -fno-builtin OBJCOPY_ARGS = -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment COFF_LD_ARGS = -e _start -T ld.script -Ttext 500000 -Tdata 510000 -Bstatic -CHRP_LD_ARGS = -Ttext 0x00400000 +CHRP_LD_ARGS = -Ttext 0x01000000 COFFOBJS = coffcrt0.o start.o coffmain.o misc.o string.o zlib.o image.o CHRPOBJS = crt0.o start.o chrpmain.o misc.o string.o zlib.o image.o diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/coffboot/chrpmain.c linux/arch/ppc/coffboot/chrpmain.c --- v2.4.0-test8/linux/arch/ppc/coffboot/chrpmain.c Thu Feb 10 17:11:04 2000 +++ linux/arch/ppc/coffboot/chrpmain.c Sun Sep 17 09:48:06 2000 @@ -22,13 +22,18 @@ #define get_16be(x) (*(unsigned short *)(x)) #define get_32be(x) (*(unsigned *)(x)) -#define RAM_START 0x00000000 -#define RAM_END (8<<20) +#define RAM_END (16 << 20) #define PROG_START 0x00010000 +#define PROG_SIZE 0x003f0000 + +#define SCRATCH_SIZE (128 << 10) char *avail_ram; -char *end_avail; +char *begin_avail, *end_avail; +char *avail_high; +unsigned int heap_use; +unsigned int heap_max; extern char _end[]; extern char image_data[]; @@ -60,29 +65,30 @@ im = image_data; len = image_len; /* claim 3MB starting at PROG_START */ - claim(PROG_START, 3 << 20, 0); + claim(PROG_START, PROG_SIZE, 0); dst = (void *) PROG_START; if (im[0] == 0x1f && im[1] == 0x8b) { - /* claim 512kB for scratch space */ - avail_ram = (char *) claim(0, 512 << 10, 0x10); - end_avail = avail_ram + (512 << 10); - printf("avail_ram = %x\n", avail_ram); + /* claim some memory for scratch space */ + avail_ram = (char *) claim(0, SCRATCH_SIZE, 0x10); + begin_avail = avail_high = avail_ram; + end_avail = avail_ram + SCRATCH_SIZE; + printf("heap at 0x%x\n", avail_ram); printf("gunzipping (0x%x <- 0x%x:0x%0x)...", dst, im, im+len); - gunzip(dst, 3 << 20, im, &len); + gunzip(dst, PROG_SIZE, im, &len); printf("done %u bytes\n", len); + printf("%u bytes of heap consumed, max in use %u\n", + avail_high - begin_avail, heap_max); } else { memmove(dst, im, len); } flush_cache(dst, len); - stop_imac_ethernet(); - stop_imac_usb(); make_bi_recs((unsigned long) dst + len); sa = (unsigned long)PROG_START; printf("start address = 0x%x\n", sa); - (*(void (*)())sa)(0, 0, prom, a1, a2); + (*(void (*)())sa)(a1, a2, prom); printf("returned?\n"); @@ -122,6 +128,7 @@ rec = (struct bi_record *)((unsigned long)rec + rec->size); } +#if 0 #define eieio() asm volatile("eieio"); void stop_imac_ethernet(void) @@ -172,14 +179,35 @@ *usb_ctrl = 0x01000000; /* cpu_to_le32(1) */ eieio(); } +#endif + +struct memchunk { + unsigned int size; + struct memchunk *next; +}; + +static struct memchunk *freechunks; void *zalloc(void *x, unsigned items, unsigned size) { - void *p = avail_ram; + void *p; + struct memchunk **mpp, *mp; size *= items; size = (size + 7) & -8; + heap_use += size; + if (heap_use > heap_max) + heap_max = heap_use; + for (mpp = &freechunks; (mp = *mpp) != 0; mpp = &mp->next) { + if (mp->size == size) { + *mpp = mp->next; + return mp; + } + } + p = avail_ram; avail_ram += size; + if (avail_ram > avail_high) + avail_high = avail_ram; if (avail_ram > end_avail) { printf("oops... out of memory\n"); pause(); @@ -189,6 +217,17 @@ void zfree(void *x, void *addr, unsigned nb) { + struct memchunk *mp = addr; + + nb = (nb + 7) & -8; + heap_use -= nb; + if (avail_ram == addr + nb) { + avail_ram = addr; + return; + } + mp->size = nb; + mp->next = freechunks; + freechunks = mp; } #define HEAD_CRC 2 diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/config.in linux/arch/ppc/config.in --- v2.4.0-test8/linux/arch/ppc/config.in Wed Aug 23 18:36:36 2000 +++ linux/arch/ppc/config.in Sun Sep 17 09:48:06 2000 @@ -88,11 +88,15 @@ if [ "$CONFIG_4xx" = "y" -o "$CONFIG_8xx" = "y" ]; then bool 'Math emulation' CONFIG_MATH_EMULATION fi + endmenu mainmenu_option next_comment comment 'General setup' +bool 'High memory support (experimental)' CONFIG_HIGHMEM +bool 'Mac-on-Linux support' CONFIG_MOL + define_bool CONFIG_ISA n define_bool CONFIG_SBUS n @@ -140,20 +144,6 @@ bool 'Backward compatibility mode for Xpmac' CONFIG_FB_COMPAT_XPMAC fi - bool 'Power management support for PowerBooks' CONFIG_PMAC_PBOOK - bool 'Support for PowerMac floppy' CONFIG_MAC_FLOPPY - tristate 'Support for PowerMac serial ports' CONFIG_MAC_SERIAL - if [ "$CONFIG_MAC_SERIAL" = "y" ]; then - bool ' Support for console on serial port' CONFIG_SERIAL_CONSOLE - fi - bool 'Apple Desktop Bus (ADB) support' CONFIG_ADB - if [ "$CONFIG_ADB" = "y" ]; then - bool ' Include CUDA ADB driver' CONFIG_ADB_CUDA - bool ' Include MacIO ADB driver' CONFIG_ADB_MACIO - bool ' Include PMU (Powerbook) ADB driver' CONFIG_ADB_PMU - bool 'Support for ADB keyboard' CONFIG_ADB_KEYBOARD - bool 'Support for ADB mouse' CONFIG_ADBMOUSE - fi tristate 'Support for /dev/rtc' CONFIG_PPC_RTC bool 'Support for Open Firmware device tree in /proc' CONFIG_PROC_DEVICETREE bool 'Support for early boot text console (BootX only)' CONFIG_BOOTX_TEXT @@ -192,7 +182,6 @@ source drivers/mtd/Config.in source drivers/pnp/Config.in source drivers/block/Config.in -#source drivers.new/Config.in if [ "$CONFIG_NET" = "y" ]; then source net/Config.in @@ -262,6 +251,43 @@ source drivers/video/Config.in endmenu +source drivers/input/Config.in + +mainmenu_option next_comment +comment 'Macintosh device drivers' + +if [ "$CONFIG_ALL_PPC" = "y" ]; then + # we want to change this to something like CONFIG_SYSCTRL_CUDA/PMU + bool 'Support for CUDA based PowerMacs' CONFIG_ADB_CUDA + bool 'Support for PMU based PowerMacs' CONFIG_ADB_PMU + if [ "$CONFIG_ADB_PMU" = "y" ]; then + bool ' Power management support for PowerBooks' CONFIG_PMAC_PBOOK + # made a separate option since backlight may end up beeing used + # on non-powerbook machines (but only on PMU based ones AFAIK) + bool ' Backlight control for LCD screens' CONFIG_PMAC_BACKLIGHT + fi + bool 'Support for PowerMac floppy' CONFIG_MAC_FLOPPY + tristate 'Support for PowerMac serial ports' CONFIG_MAC_SERIAL + if [ "$CONFIG_MAC_SERIAL" = "y" ]; then + bool ' Support for console on serial port' CONFIG_SERIAL_CONSOLE + fi + bool 'Apple Desktop Bus (ADB) support' CONFIG_ADB + if [ "$CONFIG_ADB" = "y" ]; then + bool ' Include MacIO (CHRP) ADB driver' CONFIG_ADB_MACIO + fi +fi +if [ "$CONFIG_ADB" = "y" ]; then + dep_bool ' Use input layer for ADB devices' CONFIG_INPUT_ADBHID $CONFIG_INPUT + if [ "$CONFIG_INPUT_ADBHID" = "y" ]; then + define_bool CONFIG_MAC_HID y + bool ' Support for ADB raw keycodes' CONFIG_MAC_ADBKEYCODES + bool ' Support for mouse button 2+3 emulation' CONFIG_MAC_EMUMOUSEBTN + else + bool ' Support for ADB keyboard (old driver)' CONFIG_ADB_KEYBOARD + fi +fi +endmenu + source drivers/char/Config.in source drivers/media/Config.in @@ -287,7 +313,6 @@ fi source drivers/usb/Config.in -source drivers/input/Config.in mainmenu_option next_comment comment 'Kernel hacking' diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/configs/common_defconfig linux/arch/ppc/configs/common_defconfig --- v2.4.0-test8/linux/arch/ppc/configs/common_defconfig Fri Jun 23 21:55:07 2000 +++ linux/arch/ppc/configs/common_defconfig Sun Sep 17 09:48:06 2000 @@ -1,5 +1,5 @@ # -# Automatically generated by make menuconfig: don't edit +# Automatically generated make config: don't edit # # CONFIG_UID16 is not set @@ -9,12 +9,20 @@ CONFIG_EXPERIMENTAL=y # +# Loadable module support +# +CONFIG_MODULES=y +CONFIG_MODVERSIONS=y +CONFIG_KMOD=y + +# # Platform support # CONFIG_PPC=y CONFIG_6xx=y # CONFIG_4xx is not set -# CONFIG_PPC64BRIDGE is not set +# CONFIG_POWER3 is not set +# CONFIG_POWER4 is not set # CONFIG_8260 is not set # CONFIG_8xx is not set CONFIG_ALL_PPC=y @@ -25,15 +33,9 @@ CONFIG_ALTIVEC=y # -# Loadable module support -# -CONFIG_MODULES=y -CONFIG_MODVERSIONS=y -CONFIG_KMOD=y - -# # General setup # +# CONFIG_HIGHMEM is not set # CONFIG_ISA is not set # CONFIG_SBUS is not set CONFIG_PCI=y @@ -44,8 +46,8 @@ CONFIG_KCORE_ELF=y CONFIG_BINFMT_ELF=y CONFIG_KERNEL_ELF=y -# CONFIG_BINFMT_MISC is not set -# CONFIG_PCI_NAMES is not set +CONFIG_BINFMT_MISC=m +CONFIG_PCI_NAMES=y # CONFIG_HOTPLUG is not set # CONFIG_PCMCIA is not set @@ -57,21 +59,18 @@ CONFIG_FB=y CONFIG_FB_COMPAT_XPMAC=y CONFIG_PMAC_PBOOK=y -CONFIG_MAC_FLOPPY=y -CONFIG_MAC_SERIAL=y -# CONFIG_SERIAL_CONSOLE is not set -CONFIG_ADB=y -CONFIG_ADB_CUDA=y -CONFIG_ADB_MACIO=y -CONFIG_ADB_PMU=y -CONFIG_ADB_KEYBOARD=y -CONFIG_ADBMOUSE=y +CONFIG_PPC_RTC=y CONFIG_PROC_DEVICETREE=y CONFIG_BOOTX_TEXT=y # CONFIG_MOTOROLA_HOTSWAP is not set # CONFIG_CMDLINE_BOOL is not set # +# Memory Technology Devices (MTD) +# +# CONFIG_MTD is not set + +# # Plug and Play configuration # # CONFIG_PNP is not set @@ -90,8 +89,11 @@ # CONFIG_BLK_DEV_LVM is not set # CONFIG_BLK_DEV_MD is not set # CONFIG_MD_LINEAR is not set -# CONFIG_MD_STRIPED is not set +# CONFIG_MD_RAID0 is not set +# CONFIG_MD_RAID1 is not set +# CONFIG_MD_RAID5 is not set CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_SIZE=4096 CONFIG_BLK_DEV_INITRD=y # @@ -109,22 +111,24 @@ CONFIG_IP_MULTICAST=y # CONFIG_IP_ADVANCED_ROUTER is not set # CONFIG_IP_PNP is not set -# CONFIG_IP_ROUTER is not set # CONFIG_NET_IPIP is not set # CONFIG_NET_IPGRE is not set # CONFIG_IP_MROUTE is not set -CONFIG_IP_ALIAS=y +# CONFIG_INET_ECN is not set CONFIG_SYN_COOKIES=y -CONFIG_SKB_LARGE=y # CONFIG_IPV6 is not set # CONFIG_KHTTPD is not set # CONFIG_ATM is not set + +# +# +# # CONFIG_IPX is not set CONFIG_ATALK=m # CONFIG_DECNET is not set +# CONFIG_BRIDGE is not set # CONFIG_X25 is not set # CONFIG_LAPB is not set -# CONFIG_BRIDGE is not set # CONFIG_LLC is not set # CONFIG_ECONET is not set # CONFIG_WAN_ROUTER is not set @@ -145,26 +149,42 @@ # IDE, ATA and ATAPI Block devices # CONFIG_BLK_DEV_IDE=y + +# +# Please see Documentation/ide.txt for help/info on IDE drives +# # CONFIG_BLK_DEV_HD_IDE is not set # CONFIG_BLK_DEV_HD is not set CONFIG_BLK_DEV_IDEDISK=y # CONFIG_IDEDISK_MULTI_MODE is not set +# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set +# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set +# CONFIG_BLK_DEV_IDEDISK_IBM is not set +# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set +# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set +# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set +# CONFIG_BLK_DEV_IDEDISK_WD is not set +# CONFIG_BLK_DEV_COMMERIAL is not set +# CONFIG_BLK_DEV_TIVO is not set # CONFIG_BLK_DEV_IDECS is not set CONFIG_BLK_DEV_IDECD=y # CONFIG_BLK_DEV_IDETAPE is not set -# CONFIG_BLK_DEV_IDEFLOPPY is not set +CONFIG_BLK_DEV_IDEFLOPPY=y CONFIG_BLK_DEV_IDESCSI=y + +# +# IDE chipset support/bugfixes +# # CONFIG_BLK_DEV_CMD640 is not set # CONFIG_BLK_DEV_CMD640_ENHANCED is not set # CONFIG_BLK_DEV_ISAPNP is not set # CONFIG_BLK_DEV_RZ1000 is not set CONFIG_BLK_DEV_IDEPCI=y -# CONFIG_IDEPCI_SHARE_IRQ is not set +CONFIG_IDEPCI_SHARE_IRQ=y CONFIG_BLK_DEV_IDEDMA_PCI=y # CONFIG_BLK_DEV_OFFBOARD is not set CONFIG_IDEDMA_PCI_AUTO=y CONFIG_BLK_DEV_IDEDMA=y -CONFIG_IDEDMA_PCI_EXPERIMENTAL=y # CONFIG_IDEDMA_PCI_WIP is not set # CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set # CONFIG_BLK_DEV_AEC62XX is not set @@ -173,37 +193,40 @@ # CONFIG_WDC_ALI15X3 is not set # CONFIG_BLK_DEV_AMD7409 is not set # CONFIG_AMD7409_OVERRIDE is not set -# CONFIG_BLK_DEV_CMD64X is not set -# CONFIG_CMD64X_RAID is not set +CONFIG_BLK_DEV_CMD64X=y # CONFIG_BLK_DEV_CY82C693 is not set # CONFIG_BLK_DEV_CS5530 is not set # CONFIG_BLK_DEV_HPT34X is not set # CONFIG_HPT34X_AUTODMA is not set # CONFIG_BLK_DEV_HPT366 is not set -# CONFIG_HPT366_FIP is not set -# CONFIG_HPT366_MODE3 is not set # CONFIG_BLK_DEV_NS87415 is not set # CONFIG_BLK_DEV_OPTI621 is not set # CONFIG_BLK_DEV_PDC202XX is not set # CONFIG_PDC202XX_BURST is not set -# CONFIG_PDC202XX_MASTER is not set # CONFIG_BLK_DEV_SIS5513 is not set # CONFIG_BLK_DEV_TRM290 is not set # CONFIG_BLK_DEV_VIA82CXXX is not set # CONFIG_VIA82CXXX_TUNING is not set -# CONFIG_BLK_DEV_SL82C105 is not set +CONFIG_BLK_DEV_SL82C105=y CONFIG_BLK_DEV_IDE_PMAC=y CONFIG_BLK_DEV_IDEDMA_PMAC=y -CONFIG_IDEDMA_PMAC_AUTO=y +CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y CONFIG_BLK_DEV_IDEDMA=y +CONFIG_BLK_DEV_IDEPCI=y # CONFIG_IDE_CHIPSETS is not set CONFIG_IDEDMA_AUTO=y +# CONFIG_IDEDMA_IVB is not set +# CONFIG_DMA_NONPCI is not set CONFIG_BLK_DEV_IDE_MODES=y # # SCSI support # CONFIG_SCSI=y + +# +# SCSI support type (disk, tape, CD-ROM) +# CONFIG_BLK_DEV_SD=y CONFIG_SD_EXTRA_DEVS=40 CONFIG_CHR_DEV_ST=y @@ -211,6 +234,10 @@ CONFIG_BLK_DEV_SR_VENDOR=y CONFIG_SR_EXTRA_DEVS=2 CONFIG_CHR_DEV_SG=y + +# +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs +# # CONFIG_SCSI_DEBUG_QUEUES is not set # CONFIG_SCSI_MULTI_LUN is not set CONFIG_SCSI_CONSTANTS=y @@ -296,6 +323,7 @@ # CONFIG_DUMMY is not set # CONFIG_BONDING is not set # CONFIG_EQUALIZER is not set +# CONFIG_TUN is not set # CONFIG_ETHERTAP is not set # CONFIG_NET_SB1000 is not set @@ -327,8 +355,9 @@ # CONFIG_DM9102 is not set # CONFIG_EEPRO100 is not set # CONFIG_LNE390 is not set -# CONFIG_NE3210 is not set +# CONFIG_NATSEMI is not set # CONFIG_NE2K_PCI is not set +# CONFIG_NE3210 is not set # CONFIG_RTL8129 is not set # CONFIG_8139TOO is not set # CONFIG_SIS900 is not set @@ -347,11 +376,13 @@ # CONFIG_FDDI is not set # CONFIG_HIPPI is not set CONFIG_PPP=y -# CONFIG_PPP_MULTILINK is not set -# CONFIG_PPP_ASYNC is not set +CONFIG_PPP_MULTILINK=y +CONFIG_PPP_FILTER=y +CONFIG_PPP_ASYNC=y # CONFIG_PPP_SYNC_TTY is not set -# CONFIG_PPP_DEFLATE is not set +CONFIG_PPP_DEFLATE=y # CONFIG_PPP_BSDCOMP is not set +# CONFIG_PPPOE is not set # CONFIG_SLIP is not set # @@ -404,12 +435,13 @@ # CONFIG_FB_RIVA is not set # CONFIG_FB_CLGEN is not set # CONFIG_FB_PM2 is not set +# CONFIG_FB_CYBER2000 is not set CONFIG_FB_OF=y CONFIG_FB_CONTROL=y CONFIG_FB_PLATINUM=y CONFIG_FB_VALKYRIE=y -CONFIG_FB_IMSTT=y CONFIG_FB_CT65550=y +CONFIG_FB_IMSTT=y # CONFIG_FB_S3TRIO is not set # CONFIG_FB_VGA16 is not set CONFIG_FB_MATROX=y @@ -420,6 +452,7 @@ CONFIG_FB_ATY=y CONFIG_FB_ATY128=y CONFIG_FB_3DFX=y +# CONFIG_FB_SIS is not set # CONFIG_FB_VIRTUAL is not set # CONFIG_FBCON_ADVANCED is not set CONFIG_FBCON_CFB8=y @@ -437,6 +470,32 @@ # CONFIG_FONT_ACORN_8x8 is not set # +# Input core support +# +CONFIG_INPUT=y +CONFIG_INPUT_KEYBDEV=y +CONFIG_INPUT_MOUSEDEV=y +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 +# CONFIG_INPUT_JOYDEV is not set +CONFIG_INPUT_EVDEV=y + +# +# Macintosh device drivers +# +CONFIG_MAC_FLOPPY=y +CONFIG_MAC_SERIAL=y +# CONFIG_SERIAL_CONSOLE is not set +CONFIG_ADB=y +CONFIG_ADB_CUDA=y +CONFIG_ADB_MACIO=y +CONFIG_ADB_PMU=y +CONFIG_INPUT_ADBHID=y +CONFIG_MAC_HID=y +CONFIG_MAC_ADBKEYCODES=y +CONFIG_MAC_EMUMOUSEBTN=y + +# # Character devices # CONFIG_VT=y @@ -459,7 +518,6 @@ # CONFIG_ATIXL_BUSMOUSE is not set # CONFIG_LOGIBUSMOUSE is not set # CONFIG_MS_BUSMOUSE is not set -CONFIG_ADBMOUSE=y CONFIG_MOUSE=y CONFIG_PSMOUSE=y # CONFIG_82C710_MOUSE is not set @@ -469,19 +527,19 @@ # Joysticks # # CONFIG_JOYSTICK is not set + +# +# Input core support is needed for joysticks +# # CONFIG_QIC02_TAPE is not set # # Watchdog Cards # # CONFIG_WATCHDOG is not set +# CONFIG_INTEL_RNG is not set CONFIG_NVRAM=y # CONFIG_RTC is not set - -# -# Video For Linux -# -# CONFIG_VIDEO_DEV is not set # CONFIG_DTLK is not set # CONFIG_R3964 is not set # CONFIG_APPLICOM is not set @@ -490,26 +548,31 @@ # Ftape, the floppy tape device driver # # CONFIG_FTAPE is not set -# CONFIG_DRM is not set -# CONFIG_DRM_TDFX is not set # CONFIG_AGP is not set +# CONFIG_DRM is not set + +# +# Multimedia devices +# +# CONFIG_VIDEO_DEV is not set # # File systems # # CONFIG_QUOTA is not set CONFIG_AUTOFS_FS=y -# CONFIG_AUTOFS4_FS is not set +CONFIG_AUTOFS4_FS=y # CONFIG_ADFS_FS is not set # CONFIG_ADFS_FS_RW is not set # CONFIG_AFFS_FS is not set -CONFIG_HFS_FS=y +# CONFIG_HFS_FS is not set # CONFIG_BFS_FS is not set CONFIG_FAT_FS=y CONFIG_MSDOS_FS=y # CONFIG_UMSDOS_FS is not set CONFIG_VFAT_FS=y # CONFIG_EFS_FS is not set +# CONFIG_JFFS_FS is not set # CONFIG_CRAMFS is not set # CONFIG_RAMFS is not set CONFIG_ISO9660_FS=y @@ -519,7 +582,8 @@ # CONFIG_NTFS_RW is not set # CONFIG_HPFS_FS is not set CONFIG_PROC_FS=y -# CONFIG_DEVFS_FS is not set +CONFIG_DEVFS_FS=y +# CONFIG_DEVFS_MOUNT is not set # CONFIG_DEVFS_DEBUG is not set CONFIG_DEVPTS_FS=y # CONFIG_QNX4FS_FS is not set @@ -571,12 +635,14 @@ # CONFIG_SOLARIS_X86_PARTITION is not set # CONFIG_UNIXWARE_DISKLABEL is not set # CONFIG_SGI_PARTITION is not set +# CONFIG_ULTRIX_PARTITION is not set # CONFIG_SUN_PARTITION is not set CONFIG_NLS=y # # Native Language Support # +CONFIG_NLS_DEFAULT="iso8859-1" # CONFIG_NLS_CODEPAGE_437 is not set # CONFIG_NLS_CODEPAGE_737 is not set # CONFIG_NLS_CODEPAGE_775 is not set @@ -593,6 +659,10 @@ # CONFIG_NLS_CODEPAGE_866 is not set # CONFIG_NLS_CODEPAGE_869 is not set # CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_CODEPAGE_932 is not set +# CONFIG_NLS_CODEPAGE_936 is not set +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_950 is not set # CONFIG_NLS_ISO8859_1 is not set # CONFIG_NLS_ISO8859_2 is not set # CONFIG_NLS_ISO8859_3 is not set @@ -605,6 +675,7 @@ # CONFIG_NLS_ISO8859_14 is not set # CONFIG_NLS_ISO8859_15 is not set # CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_UTF8 is not set # # Sound @@ -614,6 +685,7 @@ CONFIG_DMASOUND=y # CONFIG_SOUND_CMPCI is not set # CONFIG_SOUND_EMU10K1 is not set +# CONFIG_SOUND_FUSION is not set # CONFIG_SOUND_ES1370 is not set # CONFIG_SOUND_ES1371 is not set # CONFIG_SOUND_ESSSOLO1 is not set @@ -622,6 +694,7 @@ # CONFIG_SOUND_TRIDENT is not set # CONFIG_SOUND_MSNDCLAS is not set # CONFIG_SOUND_MSNDPIN is not set +# CONFIG_SOUND_VIA82CXXX is not set CONFIG_SOUND_OSS=y # CONFIG_SOUND_TRACEINIT is not set # CONFIG_SOUND_DMAP is not set @@ -647,24 +720,39 @@ # CONFIG_SOUND_AWE32_SYNTH is not set # CONFIG_SOUND_WAVEFRONT is not set # CONFIG_SOUND_MAUI is not set -# CONFIG_SOUND_VIA82CXXX is not set # CONFIG_SOUND_YM3812 is not set # CONFIG_SOUND_OPL3SA1 is not set # CONFIG_SOUND_OPL3SA2 is not set +# CONFIG_SOUND_YMPCI is not set # CONFIG_SOUND_UART6850 is not set # CONFIG_SOUND_AEDSP16 is not set +# CONFIG_SOUND_TVMIXER is not set # # USB support # CONFIG_USB=y CONFIG_USB_DEBUG=y -# CONFIG_USB_DEVICEFS is not set + +# +# Miscellaneous USB options +# +CONFIG_USB_DEVICEFS=y +# CONFIG_USB_BANDWIDTH is not set + +# +# USB Controllers +# # CONFIG_USB_UHCI is not set # CONFIG_USB_UHCI_ALT is not set CONFIG_USB_OHCI=y + +# +# USB Devices +# # CONFIG_USB_PRINTER is not set # CONFIG_USB_SCANNER is not set +# CONFIG_USB_MICROTEK is not set # CONFIG_USB_AUDIO is not set # CONFIG_USB_ACM is not set # CONFIG_USB_SERIAL is not set @@ -679,15 +767,13 @@ # CONFIG_USB_PEGASUS is not set # CONFIG_USB_RIO500 is not set # CONFIG_USB_DSBR is not set +# CONFIG_USB_BLUETOOTH is not set + +# +# USB Human Interface Devices (HID) +# CONFIG_USB_HID=y # CONFIG_USB_WACOM is not set -# CONFIG_USB_WMFORCE is not set -CONFIG_INPUT_KEYBDEV=y -CONFIG_INPUT_MOUSEDEV=y -CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 -CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 -# CONFIG_INPUT_JOYDEV is not set -# CONFIG_INPUT_EVDEV is not set # # Kernel hacking @@ -695,4 +781,3 @@ CONFIG_MAGIC_SYSRQ=y # CONFIG_KGDB is not set CONFIG_XMON=y - diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/configs/est8260_defconfig linux/arch/ppc/configs/est8260_defconfig --- v2.4.0-test8/linux/arch/ppc/configs/est8260_defconfig Fri Jun 23 21:55:07 2000 +++ linux/arch/ppc/configs/est8260_defconfig Sun Sep 17 09:48:06 2000 @@ -9,12 +9,18 @@ CONFIG_EXPERIMENTAL=y # +# Loadable module support +# +# CONFIG_MODULES is not set + +# # Platform support # CONFIG_PPC=y # CONFIG_6xx is not set # CONFIG_4xx is not set -# CONFIG_PPC64BRIDGE is not set +# CONFIG_POWER3 is not set +# CONFIG_POWER4 is not set CONFIG_8260=y # CONFIG_8xx is not set CONFIG_6xx=y @@ -29,13 +35,9 @@ CONFIG_MACH_SPECIFIC=y # -# Loadable module support -# -# CONFIG_MODULES is not set - -# # General setup # +# CONFIG_HIGHMEM is not set # CONFIG_ISA is not set # CONFIG_SBUS is not set # CONFIG_PCI is not set @@ -56,15 +58,17 @@ # CONFIG_PARPORT is not set # CONFIG_VGA_CONSOLE is not set # CONFIG_FB is not set -# CONFIG_PMAC_PBOOK is not set -# CONFIG_MAC_FLOPPY is not set -# CONFIG_MAC_SERIAL is not set -# CONFIG_ADB is not set +# CONFIG_PPC_RTC is not set # CONFIG_PROC_DEVICETREE is not set # CONFIG_BOOTX_TEXT is not set # CONFIG_MOTOROLA_HOTSWAP is not set # +# Memory Technology Devices (MTD) +# +# CONFIG_MTD is not set + +# # Plug and Play configuration # # CONFIG_PNP is not set @@ -84,8 +88,10 @@ # CONFIG_BLK_DEV_MD is not set # CONFIG_MD_LINEAR is not set # CONFIG_MD_RAID0 is not set -# CONFIG_RAID15_DANGEROUS is not set +# CONFIG_MD_RAID1 is not set +# CONFIG_MD_RAID5 is not set CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_SIZE=4096 CONFIG_BLK_DEV_INITRD=y # @@ -105,17 +111,11 @@ CONFIG_IP_PNP=y CONFIG_IP_PNP_BOOTP=y # CONFIG_IP_PNP_RARP is not set -# CONFIG_IP_ROUTER is not set # CONFIG_NET_IPIP is not set # CONFIG_NET_IPGRE is not set # CONFIG_IP_MROUTE is not set -CONFIG_IP_ALIAS=y +# CONFIG_INET_ECN is not set CONFIG_SYN_COOKIES=y - -# -# (it is safe to leave these untouched) -# -CONFIG_SKB_LARGE=y # CONFIG_IPV6 is not set # CONFIG_KHTTPD is not set # CONFIG_ATM is not set @@ -126,9 +126,9 @@ # CONFIG_IPX is not set # CONFIG_ATALK is not set # CONFIG_DECNET is not set +# CONFIG_BRIDGE is not set # CONFIG_X25 is not set # CONFIG_LAPB is not set -# CONFIG_BRIDGE is not set # CONFIG_LLC is not set # CONFIG_ECONET is not set # CONFIG_WAN_ROUTER is not set @@ -164,6 +164,7 @@ # CONFIG_DUMMY is not set # CONFIG_BONDING is not set # CONFIG_EQUALIZER is not set +# CONFIG_TUN is not set # CONFIG_ETHERTAP is not set # CONFIG_NET_SB1000 is not set @@ -245,6 +246,15 @@ # CONFIG_FB is not set # +# Input core support +# +# CONFIG_INPUT is not set + +# +# Macintosh device drivers +# + +# # Character devices # # CONFIG_VT is not set @@ -269,19 +279,19 @@ # Joysticks # # CONFIG_JOYSTICK is not set + +# +# Input core support is needed for joysticks +# # CONFIG_QIC02_TAPE is not set # # Watchdog Cards # # CONFIG_WATCHDOG is not set +# CONFIG_INTEL_RNG is not set # CONFIG_NVRAM is not set # CONFIG_RTC is not set - -# -# Video For Linux -# -# CONFIG_VIDEO_DEV is not set # CONFIG_DTLK is not set # CONFIG_R3964 is not set # CONFIG_APPLICOM is not set @@ -290,9 +300,13 @@ # Ftape, the floppy tape device driver # # CONFIG_FTAPE is not set -# CONFIG_DRM is not set -# CONFIG_DRM_TDFX is not set # CONFIG_AGP is not set +# CONFIG_DRM is not set + +# +# Multimedia devices +# +# CONFIG_VIDEO_DEV is not set # # File systems @@ -310,6 +324,7 @@ # CONFIG_UMSDOS_FS is not set # CONFIG_VFAT_FS is not set # CONFIG_EFS_FS is not set +# CONFIG_JFFS_FS is not set # CONFIG_CRAMFS is not set # CONFIG_RAMFS is not set # CONFIG_ISO9660_FS is not set @@ -369,6 +384,7 @@ # CONFIG_MAC_PARTITION is not set # CONFIG_MSDOS_PARTITION is not set # CONFIG_SGI_PARTITION is not set +# CONFIG_ULTRIX_PARTITION is not set # CONFIG_SUN_PARTITION is not set # CONFIG_NLS is not set @@ -382,7 +398,7 @@ # CONFIG_SCC_ENET=y CONFIG_SCC1_ENET=y -# CONFIG_FCC_ENET is not set +# CONFIG_FEC_ENET is not set # # USB support diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/configs/gemini_defconfig linux/arch/ppc/configs/gemini_defconfig --- v2.4.0-test8/linux/arch/ppc/configs/gemini_defconfig Fri Jun 23 21:55:07 2000 +++ linux/arch/ppc/configs/gemini_defconfig Sun Sep 17 09:48:06 2000 @@ -14,14 +14,12 @@ CONFIG_PPC=y CONFIG_6xx=y # CONFIG_4xx is not set -# CONFIG_PPC64BRIDGE is not set -# CONFIG_82xx is not set +# CONFIG_PPC64 is not set +# CONFIG_8260 is not set # CONFIG_8xx is not set -# CONFIG_PMAC is not set -# CONFIG_PREP is not set -# CONFIG_CHRP is not set # CONFIG_ALL_PPC is not set CONFIG_GEMINI=y +# CONFIG_EST8260 is not set # CONFIG_APUS is not set # CONFIG_SMP is not set CONFIG_ALTIVEC=y @@ -37,7 +35,8 @@ # # General setup # -# CONFIG_PCI is not set +# CONFIG_ISA is not set +# CONFIG_SBUS is not set CONFIG_PCI=y CONFIG_NET=y CONFIG_SYSCTL=y @@ -47,8 +46,12 @@ CONFIG_BINFMT_ELF=y CONFIG_KERNEL_ELF=y # CONFIG_BINFMT_MISC is not set -# CONFIG_PCI_NAMES is not set # CONFIG_HOTPLUG is not set +# CONFIG_PCMCIA is not set + +# +# Parallel port support +# # CONFIG_PARPORT is not set # CONFIG_VGA_CONSOLE is not set # CONFIG_FB is not set @@ -57,7 +60,6 @@ # CONFIG_MAC_SERIAL is not set # CONFIG_ADB is not set # CONFIG_PROC_DEVICETREE is not set -# CONFIG_TOTALMP is not set # CONFIG_BOOTX_TEXT is not set # CONFIG_MOTOROLA_HOTSWAP is not set @@ -70,22 +72,16 @@ # Block devices # # CONFIG_BLK_DEV_FD is not set -# CONFIG_BLK_DEV_IDE is not set # -# Please see Documentation/ide.txt for help/info on IDE drives +# Additional Block Devices # -# CONFIG_BLK_DEV_HD_ONLY is not set -# CONFIG_BLK_CPQ_DA is not set # CONFIG_BLK_DEV_LOOP is not set # CONFIG_BLK_DEV_NBD is not set +# CONFIG_BLK_DEV_LVM is not set # CONFIG_BLK_DEV_MD is not set +# CONFIG_RAID15_DANGEROUS is not set # CONFIG_BLK_DEV_RAM is not set -# CONFIG_BLK_DEV_XD is not set -# CONFIG_BLK_DEV_DAC960 is not set -# CONFIG_PARIDE is not set -# CONFIG_BLK_DEV_IDE_MODES is not set -# CONFIG_BLK_DEV_HD is not set # # Networking options @@ -138,6 +134,13 @@ # CONFIG_NET_SCHED is not set # +# ATA/IDE/MFM/RLL support +# +# CONFIG_IDE is not set +# CONFIG_BLK_DEV_IDE_MODES is not set +# CONFIG_BLK_DEV_HD is not set + +# # SCSI support # CONFIG_SCSI=y @@ -148,7 +151,6 @@ CONFIG_BLK_DEV_SD=y CONFIG_SD_EXTRA_DEVS=40 # CONFIG_CHR_DEV_ST is not set -CONFIG_ST_EXTRA_DEVS=2 CONFIG_BLK_DEV_SR=y CONFIG_BLK_DEV_SR_VENDOR=y CONFIG_SR_EXTRA_DEVS=2 @@ -171,7 +173,6 @@ # CONFIG_SCSI_AHA1542 is not set # CONFIG_SCSI_AHA1740 is not set # CONFIG_SCSI_AIC7XXX is not set -# CONFIG_SCSI_IPS is not set # CONFIG_SCSI_ADVANSYS is not set # CONFIG_SCSI_IN2000 is not set # CONFIG_SCSI_AM53C974 is not set @@ -184,43 +185,22 @@ # CONFIG_SCSI_FUTURE_DOMAIN is not set # CONFIG_SCSI_GDTH is not set # CONFIG_SCSI_GENERIC_NCR5380 is not set -# CONFIG_SCSI_INITIO is not set -# CONFIG_SCSI_INIA100 is not set # CONFIG_SCSI_NCR53C406A is not set # CONFIG_SCSI_SYM53C416 is not set # CONFIG_SCSI_SIM710 is not set -# CONFIG_SCSI_NCR53C7xx is not set -# CONFIG_SCSI_NCR53C8XX is not set -CONFIG_SCSI_SYM53C8XX=y -CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8 -CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32 -CONFIG_SCSI_NCR53C8XX_SYNC=20 -# CONFIG_SCSI_NCR53C8XX_PROFILE is not set -# CONFIG_SCSI_NCR53C8XX_IOMAPPED is not set -# CONFIG_SCSI_NCR53C8XX_PQS_PDS is not set -# CONFIG_SCSI_NCR53C8XX_SYMBIOS_COMPAT is not set +# CONFIG_SCSI_NCR53C7xx_sync is not set +# CONFIG_SCSI_NCR53C7xx_FAST is not set +# CONFIG_SCSI_NCR53C7xx_DISCONNECT is not set # CONFIG_SCSI_PAS16 is not set # CONFIG_SCSI_PCI2000 is not set # CONFIG_SCSI_PCI2220I is not set # CONFIG_SCSI_PSI240I is not set # CONFIG_SCSI_QLOGIC_FAS is not set -# CONFIG_SCSI_QLOGIC_ISP is not set -# CONFIG_SCSI_QLOGIC_FC is not set -# CONFIG_SCSI_QLOGIC_1280 is not set -# CONFIG_SCSI_SEAGATE is not set -# CONFIG_SCSI_DC390T is not set # CONFIG_SCSI_T128 is not set # CONFIG_SCSI_U14_34F is not set -# CONFIG_SCSI_ULTRASTOR is not set # CONFIG_SCSI_DEBUG is not set # CONFIG_SCSI_MESH is not set # CONFIG_SCSI_MAC53C94 is not set -# CONFIG_BLK_DEV_3W_XXXX_RAID is not set - -# -# IEEE 1394 (FireWire) support -# -# CONFIG_IEEE1394 is not set # # Network device support @@ -232,6 +212,7 @@ # # CONFIG_ARCNET is not set # CONFIG_DUMMY is not set +# CONFIG_BONDING is not set # CONFIG_EQUALIZER is not set # CONFIG_ETHERTAP is not set # CONFIG_NET_SB1000 is not set @@ -249,12 +230,10 @@ # CONFIG_LANCE is not set # CONFIG_NET_VENDOR_SMC is not set # CONFIG_NET_VENDOR_RACAL is not set -# CONFIG_RTL8139 is not set -# CONFIG_DM9102 is not set # CONFIG_AT1700 is not set # CONFIG_DEPCA is not set # CONFIG_NET_ISA is not set -# CONFIG_NET_EISA is not set +# CONFIG_NET_PCI is not set # CONFIG_NET_POCKET is not set # @@ -274,7 +253,7 @@ # CONFIG_NET_RADIO is not set # -# Token Ring driver support +# Token Ring devices # # CONFIG_TR is not set # CONFIG_NET_FC is not set @@ -292,6 +271,11 @@ # CONFIG_HAMRADIO is not set # +# IrDA (infrared) support +# +# CONFIG_IRDA is not set + +# # ISDN subsystem # # CONFIG_ISDN is not set @@ -361,12 +345,7 @@ # CONFIG_AGP is not set # -# USB support -# -# CONFIG_USB is not set - -# -# Filesystems +# File systems # # CONFIG_QUOTA is not set # CONFIG_AUTOFS_FS is not set @@ -378,12 +357,14 @@ # CONFIG_FAT_FS is not set # CONFIG_EFS_FS is not set # CONFIG_CRAMFS is not set +# CONFIG_RAMFS is not set CONFIG_ISO9660_FS=y # CONFIG_JOLIET is not set # CONFIG_MINIX_FS is not set # CONFIG_NTFS_FS is not set # CONFIG_HPFS_FS is not set CONFIG_PROC_FS=y +# CONFIG_DEVFS_FS is not set CONFIG_DEVPTS_FS=y # CONFIG_QNX4FS_FS is not set # CONFIG_ROMFS_FS is not set @@ -397,6 +378,7 @@ # # CONFIG_CODA_FS is not set CONFIG_NFS_FS=y +# CONFIG_NFS_V3 is not set # CONFIG_NFSD is not set CONFIG_SUNRPC=y CONFIG_LOCKD=y @@ -414,6 +396,11 @@ # Sound # # CONFIG_SOUND is not set + +# +# USB support +# +# CONFIG_USB is not set # # Kernel hacking diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/configs/rpxcllf_defconfig linux/arch/ppc/configs/rpxcllf_defconfig --- v2.4.0-test8/linux/arch/ppc/configs/rpxcllf_defconfig Fri Jun 23 21:55:07 2000 +++ linux/arch/ppc/configs/rpxcllf_defconfig Sun Sep 17 09:48:06 2000 @@ -9,18 +9,27 @@ CONFIG_EXPERIMENTAL=y # +# Loadable module support +# +# CONFIG_MODULES is not set + +# # Platform support # CONFIG_PPC=y # CONFIG_6xx is not set # CONFIG_4xx is not set -# CONFIG_PPC64BRIDGE is not set +# CONFIG_POWER3 is not set +# CONFIG_POWER4 is not set # CONFIG_8260 is not set CONFIG_8xx=y CONFIG_SERIAL_CONSOLE=y # CONFIG_RPXLITE is not set CONFIG_RPXCLASSIC=y # CONFIG_BSEIP is not set +# CONFIG_TQM8xxL is not set +# CONFIG_TQM860L is not set +# CONFIG_TQM860 is not set # CONFIG_MBX is not set # CONFIG_WINCEPT is not set # CONFIG_ALL_PPC is not set @@ -29,13 +38,9 @@ CONFIG_MATH_EMULATION=y # -# Loadable module support -# -# CONFIG_MODULES is not set - -# # General setup # +# CONFIG_HIGHMEM is not set # CONFIG_ISA is not set # CONFIG_SBUS is not set # CONFIG_PCI is not set @@ -56,6 +61,11 @@ # CONFIG_PARPORT is not set # +# Memory Technology Devices (MTD) +# +# CONFIG_MTD is not set + +# # Plug and Play configuration # # CONFIG_PNP is not set @@ -75,8 +85,10 @@ # CONFIG_BLK_DEV_MD is not set # CONFIG_MD_LINEAR is not set # CONFIG_MD_RAID0 is not set -# CONFIG_RAID15_DANGEROUS is not set +# CONFIG_MD_RAID1 is not set +# CONFIG_MD_RAID5 is not set CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_SIZE=4096 CONFIG_BLK_DEV_INITRD=y # @@ -96,17 +108,11 @@ CONFIG_IP_PNP=y CONFIG_IP_PNP_BOOTP=y # CONFIG_IP_PNP_RARP is not set -# CONFIG_IP_ROUTER is not set # CONFIG_NET_IPIP is not set # CONFIG_NET_IPGRE is not set # CONFIG_IP_MROUTE is not set -CONFIG_IP_ALIAS=y +# CONFIG_INET_ECN is not set CONFIG_SYN_COOKIES=y - -# -# (it is safe to leave these untouched) -# -CONFIG_SKB_LARGE=y # CONFIG_IPV6 is not set # CONFIG_KHTTPD is not set # CONFIG_ATM is not set @@ -117,9 +123,9 @@ # CONFIG_IPX is not set # CONFIG_ATALK is not set # CONFIG_DECNET is not set +# CONFIG_BRIDGE is not set # CONFIG_X25 is not set # CONFIG_LAPB is not set -# CONFIG_BRIDGE is not set # CONFIG_LLC is not set # CONFIG_ECONET is not set # CONFIG_WAN_ROUTER is not set @@ -155,6 +161,7 @@ # CONFIG_DUMMY is not set # CONFIG_BONDING is not set # CONFIG_EQUALIZER is not set +# CONFIG_TUN is not set # CONFIG_ETHERTAP is not set # CONFIG_NET_SB1000 is not set @@ -236,6 +243,15 @@ # CONFIG_FB is not set # +# Input core support +# +# CONFIG_INPUT is not set + +# +# Macintosh device drivers +# + +# # Character devices # # CONFIG_VT is not set @@ -260,19 +276,19 @@ # Joysticks # # CONFIG_JOYSTICK is not set + +# +# Input core support is needed for joysticks +# # CONFIG_QIC02_TAPE is not set # # Watchdog Cards # # CONFIG_WATCHDOG is not set +# CONFIG_INTEL_RNG is not set # CONFIG_NVRAM is not set # CONFIG_RTC is not set - -# -# Video For Linux -# -# CONFIG_VIDEO_DEV is not set # CONFIG_DTLK is not set # CONFIG_R3964 is not set # CONFIG_APPLICOM is not set @@ -281,9 +297,13 @@ # Ftape, the floppy tape device driver # # CONFIG_FTAPE is not set -# CONFIG_DRM is not set -# CONFIG_DRM_TDFX is not set # CONFIG_AGP is not set +# CONFIG_DRM is not set + +# +# Multimedia devices +# +# CONFIG_VIDEO_DEV is not set # # File systems @@ -301,6 +321,7 @@ # CONFIG_UMSDOS_FS is not set # CONFIG_VFAT_FS is not set # CONFIG_EFS_FS is not set +# CONFIG_JFFS_FS is not set # CONFIG_CRAMFS is not set # CONFIG_RAMFS is not set # CONFIG_ISO9660_FS is not set @@ -360,6 +381,7 @@ # CONFIG_MAC_PARTITION is not set # CONFIG_MSDOS_PARTITION is not set # CONFIG_SGI_PARTITION is not set +# CONFIG_ULTRIX_PARTITION is not set # CONFIG_SUN_PARTITION is not set # CONFIG_NLS is not set @@ -374,7 +396,9 @@ CONFIG_SCC_ENET=y CONFIG_SCC1_ENET=y CONFIG_FEC_ENET=y +CONFIG_ENET_BIG_BUFFERS=y CONFIG_8xxSMC2=y +# CONFIG_8xx_ALTSMC2 is not set CONFIG_8xxSCC=y # diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/defconfig linux/arch/ppc/defconfig --- v2.4.0-test8/linux/arch/ppc/defconfig Fri Jun 23 21:55:07 2000 +++ linux/arch/ppc/defconfig Sun Sep 17 09:48:06 2000 @@ -1,5 +1,5 @@ # -# Automatically generated by make menuconfig: don't edit +# Automatically generated make config: don't edit # # CONFIG_UID16 is not set @@ -9,12 +9,20 @@ CONFIG_EXPERIMENTAL=y # +# Loadable module support +# +CONFIG_MODULES=y +CONFIG_MODVERSIONS=y +CONFIG_KMOD=y + +# # Platform support # CONFIG_PPC=y CONFIG_6xx=y # CONFIG_4xx is not set -# CONFIG_PPC64BRIDGE is not set +# CONFIG_POWER3 is not set +# CONFIG_POWER4 is not set # CONFIG_8260 is not set # CONFIG_8xx is not set CONFIG_ALL_PPC=y @@ -25,15 +33,9 @@ CONFIG_ALTIVEC=y # -# Loadable module support -# -CONFIG_MODULES=y -CONFIG_MODVERSIONS=y -CONFIG_KMOD=y - -# # General setup # +# CONFIG_HIGHMEM is not set # CONFIG_ISA is not set # CONFIG_SBUS is not set CONFIG_PCI=y @@ -44,8 +46,8 @@ CONFIG_KCORE_ELF=y CONFIG_BINFMT_ELF=y CONFIG_KERNEL_ELF=y -# CONFIG_BINFMT_MISC is not set -# CONFIG_PCI_NAMES is not set +CONFIG_BINFMT_MISC=m +CONFIG_PCI_NAMES=y # CONFIG_HOTPLUG is not set # CONFIG_PCMCIA is not set @@ -57,21 +59,18 @@ CONFIG_FB=y CONFIG_FB_COMPAT_XPMAC=y CONFIG_PMAC_PBOOK=y -CONFIG_MAC_FLOPPY=y -CONFIG_MAC_SERIAL=y -# CONFIG_SERIAL_CONSOLE is not set -CONFIG_ADB=y -CONFIG_ADB_CUDA=y -CONFIG_ADB_MACIO=y -CONFIG_ADB_PMU=y -CONFIG_ADB_KEYBOARD=y -CONFIG_ADBMOUSE=y +CONFIG_PPC_RTC=y CONFIG_PROC_DEVICETREE=y CONFIG_BOOTX_TEXT=y # CONFIG_MOTOROLA_HOTSWAP is not set # CONFIG_CMDLINE_BOOL is not set # +# Memory Technology Devices (MTD) +# +# CONFIG_MTD is not set + +# # Plug and Play configuration # # CONFIG_PNP is not set @@ -90,8 +89,11 @@ # CONFIG_BLK_DEV_LVM is not set # CONFIG_BLK_DEV_MD is not set # CONFIG_MD_LINEAR is not set -# CONFIG_MD_STRIPED is not set +# CONFIG_MD_RAID0 is not set +# CONFIG_MD_RAID1 is not set +# CONFIG_MD_RAID5 is not set CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_SIZE=4096 CONFIG_BLK_DEV_INITRD=y # @@ -109,22 +111,24 @@ CONFIG_IP_MULTICAST=y # CONFIG_IP_ADVANCED_ROUTER is not set # CONFIG_IP_PNP is not set -# CONFIG_IP_ROUTER is not set # CONFIG_NET_IPIP is not set # CONFIG_NET_IPGRE is not set # CONFIG_IP_MROUTE is not set -CONFIG_IP_ALIAS=y +# CONFIG_INET_ECN is not set CONFIG_SYN_COOKIES=y -CONFIG_SKB_LARGE=y # CONFIG_IPV6 is not set # CONFIG_KHTTPD is not set # CONFIG_ATM is not set + +# +# +# # CONFIG_IPX is not set CONFIG_ATALK=m # CONFIG_DECNET is not set +# CONFIG_BRIDGE is not set # CONFIG_X25 is not set # CONFIG_LAPB is not set -# CONFIG_BRIDGE is not set # CONFIG_LLC is not set # CONFIG_ECONET is not set # CONFIG_WAN_ROUTER is not set @@ -145,26 +149,42 @@ # IDE, ATA and ATAPI Block devices # CONFIG_BLK_DEV_IDE=y + +# +# Please see Documentation/ide.txt for help/info on IDE drives +# # CONFIG_BLK_DEV_HD_IDE is not set # CONFIG_BLK_DEV_HD is not set CONFIG_BLK_DEV_IDEDISK=y # CONFIG_IDEDISK_MULTI_MODE is not set +# CONFIG_BLK_DEV_IDEDISK_VENDOR is not set +# CONFIG_BLK_DEV_IDEDISK_FUJITSU is not set +# CONFIG_BLK_DEV_IDEDISK_IBM is not set +# CONFIG_BLK_DEV_IDEDISK_MAXTOR is not set +# CONFIG_BLK_DEV_IDEDISK_QUANTUM is not set +# CONFIG_BLK_DEV_IDEDISK_SEAGATE is not set +# CONFIG_BLK_DEV_IDEDISK_WD is not set +# CONFIG_BLK_DEV_COMMERIAL is not set +# CONFIG_BLK_DEV_TIVO is not set # CONFIG_BLK_DEV_IDECS is not set CONFIG_BLK_DEV_IDECD=y # CONFIG_BLK_DEV_IDETAPE is not set -# CONFIG_BLK_DEV_IDEFLOPPY is not set +CONFIG_BLK_DEV_IDEFLOPPY=y CONFIG_BLK_DEV_IDESCSI=y + +# +# IDE chipset support/bugfixes +# # CONFIG_BLK_DEV_CMD640 is not set # CONFIG_BLK_DEV_CMD640_ENHANCED is not set # CONFIG_BLK_DEV_ISAPNP is not set # CONFIG_BLK_DEV_RZ1000 is not set CONFIG_BLK_DEV_IDEPCI=y -# CONFIG_IDEPCI_SHARE_IRQ is not set +CONFIG_IDEPCI_SHARE_IRQ=y CONFIG_BLK_DEV_IDEDMA_PCI=y # CONFIG_BLK_DEV_OFFBOARD is not set CONFIG_IDEDMA_PCI_AUTO=y CONFIG_BLK_DEV_IDEDMA=y -CONFIG_IDEDMA_PCI_EXPERIMENTAL=y # CONFIG_IDEDMA_PCI_WIP is not set # CONFIG_IDEDMA_NEW_DRIVE_LISTINGS is not set # CONFIG_BLK_DEV_AEC62XX is not set @@ -173,37 +193,40 @@ # CONFIG_WDC_ALI15X3 is not set # CONFIG_BLK_DEV_AMD7409 is not set # CONFIG_AMD7409_OVERRIDE is not set -# CONFIG_BLK_DEV_CMD64X is not set -# CONFIG_CMD64X_RAID is not set +CONFIG_BLK_DEV_CMD64X=y # CONFIG_BLK_DEV_CY82C693 is not set # CONFIG_BLK_DEV_CS5530 is not set # CONFIG_BLK_DEV_HPT34X is not set # CONFIG_HPT34X_AUTODMA is not set # CONFIG_BLK_DEV_HPT366 is not set -# CONFIG_HPT366_FIP is not set -# CONFIG_HPT366_MODE3 is not set # CONFIG_BLK_DEV_NS87415 is not set # CONFIG_BLK_DEV_OPTI621 is not set # CONFIG_BLK_DEV_PDC202XX is not set # CONFIG_PDC202XX_BURST is not set -# CONFIG_PDC202XX_MASTER is not set # CONFIG_BLK_DEV_SIS5513 is not set # CONFIG_BLK_DEV_TRM290 is not set # CONFIG_BLK_DEV_VIA82CXXX is not set # CONFIG_VIA82CXXX_TUNING is not set -# CONFIG_BLK_DEV_SL82C105 is not set +CONFIG_BLK_DEV_SL82C105=y CONFIG_BLK_DEV_IDE_PMAC=y CONFIG_BLK_DEV_IDEDMA_PMAC=y -CONFIG_IDEDMA_PMAC_AUTO=y +CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y CONFIG_BLK_DEV_IDEDMA=y +CONFIG_BLK_DEV_IDEPCI=y # CONFIG_IDE_CHIPSETS is not set CONFIG_IDEDMA_AUTO=y +# CONFIG_IDEDMA_IVB is not set +# CONFIG_DMA_NONPCI is not set CONFIG_BLK_DEV_IDE_MODES=y # # SCSI support # CONFIG_SCSI=y + +# +# SCSI support type (disk, tape, CD-ROM) +# CONFIG_BLK_DEV_SD=y CONFIG_SD_EXTRA_DEVS=40 CONFIG_CHR_DEV_ST=y @@ -211,6 +234,10 @@ CONFIG_BLK_DEV_SR_VENDOR=y CONFIG_SR_EXTRA_DEVS=2 CONFIG_CHR_DEV_SG=y + +# +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs +# # CONFIG_SCSI_DEBUG_QUEUES is not set # CONFIG_SCSI_MULTI_LUN is not set CONFIG_SCSI_CONSTANTS=y @@ -296,6 +323,7 @@ # CONFIG_DUMMY is not set # CONFIG_BONDING is not set # CONFIG_EQUALIZER is not set +# CONFIG_TUN is not set # CONFIG_ETHERTAP is not set # CONFIG_NET_SB1000 is not set @@ -327,8 +355,9 @@ # CONFIG_DM9102 is not set # CONFIG_EEPRO100 is not set # CONFIG_LNE390 is not set -# CONFIG_NE3210 is not set +# CONFIG_NATSEMI is not set # CONFIG_NE2K_PCI is not set +# CONFIG_NE3210 is not set # CONFIG_RTL8129 is not set # CONFIG_8139TOO is not set # CONFIG_SIS900 is not set @@ -347,11 +376,13 @@ # CONFIG_FDDI is not set # CONFIG_HIPPI is not set CONFIG_PPP=y -# CONFIG_PPP_MULTILINK is not set -# CONFIG_PPP_ASYNC is not set +CONFIG_PPP_MULTILINK=y +CONFIG_PPP_FILTER=y +CONFIG_PPP_ASYNC=y # CONFIG_PPP_SYNC_TTY is not set -# CONFIG_PPP_DEFLATE is not set +CONFIG_PPP_DEFLATE=y # CONFIG_PPP_BSDCOMP is not set +# CONFIG_PPPOE is not set # CONFIG_SLIP is not set # @@ -404,12 +435,13 @@ # CONFIG_FB_RIVA is not set # CONFIG_FB_CLGEN is not set # CONFIG_FB_PM2 is not set +# CONFIG_FB_CYBER2000 is not set CONFIG_FB_OF=y CONFIG_FB_CONTROL=y CONFIG_FB_PLATINUM=y CONFIG_FB_VALKYRIE=y -CONFIG_FB_IMSTT=y CONFIG_FB_CT65550=y +CONFIG_FB_IMSTT=y # CONFIG_FB_S3TRIO is not set # CONFIG_FB_VGA16 is not set CONFIG_FB_MATROX=y @@ -420,6 +452,7 @@ CONFIG_FB_ATY=y CONFIG_FB_ATY128=y CONFIG_FB_3DFX=y +# CONFIG_FB_SIS is not set # CONFIG_FB_VIRTUAL is not set # CONFIG_FBCON_ADVANCED is not set CONFIG_FBCON_CFB8=y @@ -437,6 +470,32 @@ # CONFIG_FONT_ACORN_8x8 is not set # +# Input core support +# +CONFIG_INPUT=y +CONFIG_INPUT_KEYBDEV=y +CONFIG_INPUT_MOUSEDEV=y +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 +# CONFIG_INPUT_JOYDEV is not set +CONFIG_INPUT_EVDEV=y + +# +# Macintosh device drivers +# +CONFIG_MAC_FLOPPY=y +CONFIG_MAC_SERIAL=y +# CONFIG_SERIAL_CONSOLE is not set +CONFIG_ADB=y +CONFIG_ADB_CUDA=y +CONFIG_ADB_MACIO=y +CONFIG_ADB_PMU=y +CONFIG_INPUT_ADBHID=y +CONFIG_MAC_HID=y +CONFIG_MAC_ADBKEYCODES=y +CONFIG_MAC_EMUMOUSEBTN=y + +# # Character devices # CONFIG_VT=y @@ -459,7 +518,6 @@ # CONFIG_ATIXL_BUSMOUSE is not set # CONFIG_LOGIBUSMOUSE is not set # CONFIG_MS_BUSMOUSE is not set -CONFIG_ADBMOUSE=y CONFIG_MOUSE=y CONFIG_PSMOUSE=y # CONFIG_82C710_MOUSE is not set @@ -469,19 +527,19 @@ # Joysticks # # CONFIG_JOYSTICK is not set + +# +# Input core support is needed for joysticks +# # CONFIG_QIC02_TAPE is not set # # Watchdog Cards # # CONFIG_WATCHDOG is not set +# CONFIG_INTEL_RNG is not set CONFIG_NVRAM=y # CONFIG_RTC is not set - -# -# Video For Linux -# -# CONFIG_VIDEO_DEV is not set # CONFIG_DTLK is not set # CONFIG_R3964 is not set # CONFIG_APPLICOM is not set @@ -490,26 +548,31 @@ # Ftape, the floppy tape device driver # # CONFIG_FTAPE is not set -# CONFIG_DRM is not set -# CONFIG_DRM_TDFX is not set # CONFIG_AGP is not set +# CONFIG_DRM is not set + +# +# Multimedia devices +# +# CONFIG_VIDEO_DEV is not set # # File systems # # CONFIG_QUOTA is not set CONFIG_AUTOFS_FS=y -# CONFIG_AUTOFS4_FS is not set +CONFIG_AUTOFS4_FS=y # CONFIG_ADFS_FS is not set # CONFIG_ADFS_FS_RW is not set # CONFIG_AFFS_FS is not set -CONFIG_HFS_FS=y +# CONFIG_HFS_FS is not set # CONFIG_BFS_FS is not set CONFIG_FAT_FS=y CONFIG_MSDOS_FS=y # CONFIG_UMSDOS_FS is not set CONFIG_VFAT_FS=y # CONFIG_EFS_FS is not set +# CONFIG_JFFS_FS is not set # CONFIG_CRAMFS is not set # CONFIG_RAMFS is not set CONFIG_ISO9660_FS=y @@ -519,7 +582,7 @@ # CONFIG_NTFS_RW is not set # CONFIG_HPFS_FS is not set CONFIG_PROC_FS=y -# CONFIG_DEVFS_FS is not set +CONFIG_DEVFS_FS=y # CONFIG_DEVFS_MOUNT is not set # CONFIG_DEVFS_DEBUG is not set CONFIG_DEVPTS_FS=y @@ -572,12 +635,14 @@ # CONFIG_SOLARIS_X86_PARTITION is not set # CONFIG_UNIXWARE_DISKLABEL is not set # CONFIG_SGI_PARTITION is not set +# CONFIG_ULTRIX_PARTITION is not set # CONFIG_SUN_PARTITION is not set CONFIG_NLS=y # # Native Language Support # +CONFIG_NLS_DEFAULT="iso8859-1" # CONFIG_NLS_CODEPAGE_437 is not set # CONFIG_NLS_CODEPAGE_737 is not set # CONFIG_NLS_CODEPAGE_775 is not set @@ -594,6 +659,10 @@ # CONFIG_NLS_CODEPAGE_866 is not set # CONFIG_NLS_CODEPAGE_869 is not set # CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_CODEPAGE_932 is not set +# CONFIG_NLS_CODEPAGE_936 is not set +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_950 is not set # CONFIG_NLS_ISO8859_1 is not set # CONFIG_NLS_ISO8859_2 is not set # CONFIG_NLS_ISO8859_3 is not set @@ -606,6 +675,7 @@ # CONFIG_NLS_ISO8859_14 is not set # CONFIG_NLS_ISO8859_15 is not set # CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_UTF8 is not set # # Sound @@ -615,6 +685,7 @@ CONFIG_DMASOUND=y # CONFIG_SOUND_CMPCI is not set # CONFIG_SOUND_EMU10K1 is not set +# CONFIG_SOUND_FUSION is not set # CONFIG_SOUND_ES1370 is not set # CONFIG_SOUND_ES1371 is not set # CONFIG_SOUND_ESSSOLO1 is not set @@ -623,6 +694,7 @@ # CONFIG_SOUND_TRIDENT is not set # CONFIG_SOUND_MSNDCLAS is not set # CONFIG_SOUND_MSNDPIN is not set +# CONFIG_SOUND_VIA82CXXX is not set CONFIG_SOUND_OSS=y # CONFIG_SOUND_TRACEINIT is not set # CONFIG_SOUND_DMAP is not set @@ -648,24 +720,39 @@ # CONFIG_SOUND_AWE32_SYNTH is not set # CONFIG_SOUND_WAVEFRONT is not set # CONFIG_SOUND_MAUI is not set -# CONFIG_SOUND_VIA82CXXX is not set # CONFIG_SOUND_YM3812 is not set # CONFIG_SOUND_OPL3SA1 is not set # CONFIG_SOUND_OPL3SA2 is not set +# CONFIG_SOUND_YMPCI is not set # CONFIG_SOUND_UART6850 is not set # CONFIG_SOUND_AEDSP16 is not set +# CONFIG_SOUND_TVMIXER is not set # # USB support # CONFIG_USB=y CONFIG_USB_DEBUG=y -# CONFIG_USB_DEVICEFS is not set + +# +# Miscellaneous USB options +# +CONFIG_USB_DEVICEFS=y +# CONFIG_USB_BANDWIDTH is not set + +# +# USB Controllers +# # CONFIG_USB_UHCI is not set # CONFIG_USB_UHCI_ALT is not set CONFIG_USB_OHCI=y + +# +# USB Devices +# # CONFIG_USB_PRINTER is not set # CONFIG_USB_SCANNER is not set +# CONFIG_USB_MICROTEK is not set # CONFIG_USB_AUDIO is not set # CONFIG_USB_ACM is not set # CONFIG_USB_SERIAL is not set @@ -680,15 +767,18 @@ # CONFIG_USB_PEGASUS is not set # CONFIG_USB_RIO500 is not set # CONFIG_USB_DSBR is not set +# CONFIG_USB_BLUETOOTH is not set + +# +# USB Human Interface Devices (HID) +# CONFIG_USB_HID=y # CONFIG_USB_WACOM is not set -# CONFIG_USB_WMFORCE is not set -CONFIG_INPUT_KEYBDEV=y -CONFIG_INPUT_MOUSEDEV=y -CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 -CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 -# CONFIG_INPUT_JOYDEV is not set -# CONFIG_INPUT_EVDEV is not set + +# +# Mac-on-Linux (MOL) support +# +# CONFIG_MOL is not set # # Kernel hacking diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/Makefile linux/arch/ppc/kernel/Makefile --- v2.4.0-test8/linux/arch/ppc/kernel/Makefile Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/Makefile Sun Sep 17 09:48:06 2000 @@ -99,8 +99,10 @@ ifeq ($(CONFIG_ALL_PPC),y) O_OBJS += pmac_pic.o pmac_setup.o pmac_time.o feature.o pmac_pci.o prom.o \ chrp_setup.o chrp_time.o chrp_pci.o open_pic.o indirect_pci.o \ - prep_pci.o i8259.o prep_nvram.o prep_time.o residual.o \ - pmac_backlight.o + prep_pci.o i8259.o prep_nvram.o prep_time.o residual.o + ifeq ($(CONFIG_PMAC_BACKLIGHT),y) + O_OBJS += pmac_backlight.o + endif OX_OBJS += prep_setup.o endif ifeq ($(CONFIG_GEMINI),y) diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/apus_setup.c linux/arch/ppc/kernel/apus_setup.c --- v2.4.0-test8/linux/arch/ppc/kernel/apus_setup.c Wed Apr 26 16:34:07 2000 +++ linux/arch/ppc/kernel/apus_setup.c Sun Sep 17 09:48:06 2000 @@ -304,7 +304,7 @@ void apus_calibrate_decr(void) { #ifdef CONFIG_APUS - int freq, divisor; + unsigned long freq; /* This algorithm for determining the bus speed was contributed by Ralph Schmidt. */ @@ -335,8 +335,8 @@ bus_speed = 60; freq = 15000000; } else if ((bus_speed >= 63) && (bus_speed < 69)) { - bus_speed = 66; - freq = 16500000; + bus_speed = 67; + freq = 16666667; } else { printk ("APUS: Unable to determine bus speed (%d). " "Defaulting to 50MHz", bus_speed); @@ -375,12 +375,10 @@ } - freq *= 60; /* try to make freq/1e6 an integer */ - divisor = 60; - printk("time_init: decrementer frequency = %d/%d\n", freq, divisor); - decrementer_count = freq / HZ / divisor; - count_period_num = divisor; - count_period_den = freq / 1000000; + printk("time_init: decrementer frequency = %lu.%.6lu MHz\n", + freq/1000000, freq%1000000); + tb_ticks_per_jiffy = freq / HZ; + tb_to_us = mulhwu_scale_factor(freq, 1000000); __bus_speed = bus_speed; __speed_test_failed = speed_test_failed; diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/chrp_pci.c linux/arch/ppc/kernel/chrp_pci.c --- v2.4.0-test8/linux/arch/ppc/kernel/chrp_pci.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/chrp_pci.c Sun Sep 17 09:48:06 2000 @@ -284,13 +284,38 @@ return 1; } +#ifdef CONFIG_POWER4 +static void +power4_fixup_dev(struct pci_dev *dev) +{ + int i; + unsigned long offset; + + for (i = 0; i < 6; ++i) { + if (dev->resource[i].start == 0) + continue; + offset = pci_address_offset(dev->bus->number, + dev->resource[i].flags); + if (offset) { + dev->resource[i].start += offset; + dev->resource[i].end += offset; + printk("device %x.%x[%d] now [%lx..%lx]\n", + dev->bus->number, dev->devfn, i, + dev->resource[i].start, + dev->resource[i].end); + } + /* zap the 2nd function of the winbond chip */ + if (dev->resource[i].flags & IORESOURCE_IO + && dev->bus->number == 0 && dev->devfn == 0x81) + dev->resource[i].flags &= ~IORESOURCE_IO; + } +} +#endif /* CONFIG_POWER4 */ + void __init chrp_pcibios_fixup(void) { struct pci_dev *dev; -#ifdef CONFIG_POWER4 - int i; -#endif int *brp; struct device_node *np; extern struct pci_ops generic_pci_ops; @@ -316,10 +341,8 @@ /* PCI interrupts are controlled by the OpenPIC */ pci_for_each_dev(dev) { np = find_pci_device_OFnode(dev->bus->number, dev->devfn); - if ( (np != 0) && (np->n_intrs > 0) && (np->intrs[0].line != 0)) + if ((np != 0) && (np->n_intrs > 0) && (np->intrs[0].line != 0)) dev->irq = np->intrs[0].line; - if ( dev->irq ) - dev->irq = openpic_to_irq( dev->irq ); /* these need to be absolute addrs for OF and Matrox FB -- Cort */ if ( dev->vendor == PCI_VENDOR_ID_MATROX ) { @@ -337,25 +360,7 @@ dev->devfn, PCI_VENDOR_ID, PCI_VENDOR_ID_AMD); } #ifdef CONFIG_POWER4 - for (i = 0; i < 6; ++i) { - unsigned long offset; - if (dev->resource[i].start == 0) - continue; - offset = pci_address_offset(dev->bus->number, - dev->resource[i].flags); - if (offset) { - dev->resource[i].start += offset; - dev->resource[i].end += offset; - printk("device %x.%x[%d] now [%lx..%lx]\n", - dev->bus->number, dev->devfn, i, - dev->resource[i].start, - dev->resource[i].end); - } - /* zap the 2nd function of the winbond chip */ - if (dev->resource[i].flags & IORESOURCE_IO - && dev->bus->number == 0 && dev->devfn == 0x81) - dev->resource[i].flags &= ~IORESOURCE_IO; - } + power4_fixup_dev(dev); #else if (dev->bus->number > 0 && python_busnr > 0) dev->resource[0].start += dev->bus->number*0x01000000; @@ -363,6 +368,40 @@ } } +static struct { + /* parent is iomem */ + struct resource ram, pci_mem, isa_mem, pci_io, pci_cfg, rom_exp, flash; + /* parent is isa_mem */ + struct resource nvram; +} gg2_resources = { + ram: { "RAM", 0x00000000, 0xbfffffff, IORESOURCE_MEM }, + pci_mem: { "GG2 PCI mem", 0xc0000000, 0xf6ffffff, IORESOURCE_MEM }, + isa_mem: { "GG2 ISA mem", 0xf7000000, 0xf7ffffff }, + pci_io: { "GG2 PCI I/O", 0xf8000000, 0xf8ffffff }, + pci_cfg: { "GG2 PCI cfg", 0xfec00000, 0xfec7ffff }, + rom_exp: { "ROM exp", 0xff000000, 0xff7fffff, }, + flash: { "Flash ROM", 0xfff80000, 0xffffffff }, + nvram: { "NVRAM", 0xf70e0000, 0xf70e7fff }, +}; + +static void __init gg2_pcibios_fixup(void) +{ + int i; + extern unsigned long *end_of_DRAM; + + chrp_pcibios_fixup(); + gg2_resources.ram.end = (unsigned long)end_of_DRAM-PAGE_OFFSET; + for (i = 0; i < 7; i++) + request_resource(&iomem_resource, + &((struct resource *)&gg2_resources)[i]); + request_resource(&gg2_resources.isa_mem, &gg2_resources.nvram); +} + +static void __init gg2_pcibios_fixup_bus(struct pci_bus *bus) +{ + bus->resource[1] = &gg2_resources.pci_mem; +} + decl_config_access_method(grackle); decl_config_access_method(indirect); decl_config_access_method(rtas); @@ -372,6 +411,7 @@ { struct device_node *py; + ppc_md.pcibios_fixup = chrp_pcibios_fixup; #ifdef CONFIG_POWER4 set_config_access_method(rtas); pci_dram_offset = 0; @@ -428,16 +468,17 @@ } else { + /* LongTrail */ pci_dram_offset = 0; isa_mem_base = 0xf7000000; isa_io_base = 0xf8000000; set_config_access_method(gg2); + ppc_md.pcibios_fixup = gg2_pcibios_fixup; + ppc_md.pcibios_fixup_bus = gg2_pcibios_fixup_bus; } } } #endif /* CONFIG_POWER4 */ - - ppc_md.pcibios_fixup = chrp_pcibios_fixup; } #ifdef CONFIG_PPC64BRIDGE diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/chrp_setup.c linux/arch/ppc/kernel/chrp_setup.c --- v2.4.0-test8/linux/arch/ppc/kernel/chrp_setup.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/chrp_setup.c Sun Sep 17 09:48:06 2000 @@ -62,11 +62,13 @@ unsigned long chrp_get_rtc_time(void); int chrp_set_rtc_time(unsigned long nowtime); void chrp_calibrate_decr(void); -void chrp_time_init(void); +long chrp_time_init(void); void chrp_setup_pci_ptrs(void); -extern void chrp_progress(char *, unsigned short); void chrp_event_scan(void); +void rtas_display_progress(char *, unsigned short); +void rtas_indicator_progress(char *, unsigned short); +void bootx_text_progress(char *, unsigned short); extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode); extern int pckbd_getkeycode(unsigned int scancode); @@ -91,6 +93,8 @@ extern unsigned long Hash_size, Hash_mask; extern int probingmem; extern unsigned long loops_per_sec; +extern int bootx_text_mapped; +static int max_width; unsigned long empty_zero_page[1024]; @@ -252,13 +256,6 @@ #endif ROOT_DEV = to_kdev_t(0x0802); /* sda2 (sda1 is for the kernel) */ printk("Boot arguments: %s\n", cmd_line); - - request_region(0x20,0x20,"pic1"); - request_region(0xa0,0x20,"pic2"); - request_region(0x00,0x20,"dma1"); - request_region(0x40,0x20,"timer"); - request_region(0x80,0x10,"dma page reg"); - request_region(0xc0,0x20,"dma2"); #ifndef CONFIG_PPC64BRIDGE /* PCI bridge config space access area - @@ -446,11 +443,43 @@ void __init chrp_init2(void) { +#if defined(CONFIG_VT) && defined(CONFIG_ADB_KEYBOARD) + struct device_node *kbd; +#endif #ifdef CONFIG_NVRAM pmac_nvram_init(); #endif + + request_region(0x20,0x20,"pic1"); + request_region(0xa0,0x20,"pic2"); + request_region(0x00,0x20,"dma1"); + request_region(0x40,0x20,"timer"); + request_region(0x80,0x10,"dma page reg"); + request_region(0xc0,0x20,"dma2"); + if (ppc_md.progress) ppc_md.progress(" Have fun! ", 0x7777); + +#if defined(CONFIG_VT) && defined(CONFIG_ADB_KEYBOARD) + /* see if there is a keyboard in the device tree + with a parent of type "adb" */ + for (kbd = find_devices("keyboard"); kbd; kbd = kbd->next) + if (kbd->parent && kbd->parent->type + && strcmp(kbd->parent->type, "adb") == 0) + break; + if (kbd) { + ppc_md.kbd_setkeycode = mackbd_setkeycode; + ppc_md.kbd_getkeycode = mackbd_getkeycode; + ppc_md.kbd_translate = mackbd_translate; + ppc_md.kbd_unexpected_up = mackbd_unexpected_up; + ppc_md.kbd_leds = mackbd_leds; + ppc_md.kbd_init_hw = mackbd_init_hw; +#ifdef CONFIG_MAGIC_SYSRQ + ppc_md.ppc_kbd_sysrq_xlate = mackbd_sysrq_xlate; + SYSRQ_KEY = 0x69; +#endif /* CONFIG_MAGIC_SYSRQ */ + } +#endif /* CONFIG_VT && CONFIG_ADB_KEYBOARD */ } #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) @@ -598,40 +627,40 @@ ppc_md.calibrate_decr = chrp_calibrate_decr; #ifdef CONFIG_VT -#ifdef CONFIG_MAC_KEYBOARD - if (adb_driver == NULL) - { -#endif /* CONFIG_MAC_KEYBOAD */ - ppc_md.kbd_setkeycode = pckbd_setkeycode; - ppc_md.kbd_getkeycode = pckbd_getkeycode; - ppc_md.kbd_translate = pckbd_translate; - ppc_md.kbd_unexpected_up = pckbd_unexpected_up; - ppc_md.kbd_leds = pckbd_leds; - ppc_md.kbd_init_hw = pckbd_init_hw; -#ifdef CONFIG_MAGIC_SYSRQ - ppc_md.ppc_kbd_sysrq_xlate = pckbd_sysrq_xlate; - SYSRQ_KEY = 0x54; -#endif /* CONFIG_MAGIC_SYSRQ */ -#ifdef CONFIG_MAC_KEYBOARD - } - else - { - ppc_md.kbd_setkeycode = mackbd_setkeycode; - ppc_md.kbd_getkeycode = mackbd_getkeycode; - ppc_md.kbd_translate = mackbd_translate; - ppc_md.kbd_unexpected_up = mackbd_unexpected_up; - ppc_md.kbd_leds = mackbd_leds; - ppc_md.kbd_init_hw = mackbd_init_hw; + /* these are adjusted in chrp_init2 if we have an ADB keyboard */ + ppc_md.kbd_setkeycode = pckbd_setkeycode; + ppc_md.kbd_getkeycode = pckbd_getkeycode; + ppc_md.kbd_translate = pckbd_translate; + ppc_md.kbd_unexpected_up = pckbd_unexpected_up; + ppc_md.kbd_leds = pckbd_leds; + ppc_md.kbd_init_hw = pckbd_init_hw; #ifdef CONFIG_MAGIC_SYSRQ - ppc_md.ppc_kbd_sysrq_xlate = mackbd_sysrq_xlate; - SYSRQ_KEY = 0x69; + ppc_md.ppc_kbd_sysrq_xlate = pckbd_sysrq_xlate; + SYSRQ_KEY = 0x54; #endif /* CONFIG_MAGIC_SYSRQ */ - } -#endif /* CONFIG_MAC_KEYBOARD */ #endif /* CONFIG_VT */ - if ( rtas_data ) - ppc_md.progress = chrp_progress; - + + if (rtas_data) { + struct device_node *rtas; + unsigned int *p; + + rtas = find_devices("rtas"); + if (rtas != NULL) { + if (get_property(rtas, "display-character", NULL)) { + ppc_md.progress = rtas_display_progress; + p = (unsigned int *) get_property + (rtas, "ibm,display-line-length", NULL); + if (p) + max_width = *p; + } else if (get_property(rtas, "set-indicator", NULL)) + ppc_md.progress = rtas_indicator_progress; + } + } +#ifdef CONFIG_BOOTX_TEXT + if (ppc_md.progress == NULL && bootx_text_mapped) + ppc_md.progress = bootx_text_progress; +#endif + #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) ppc_ide_md.insw = chrp_ide_insw; ppc_ide_md.outsw = chrp_ide_outsw; @@ -653,30 +682,13 @@ } void __chrp -chrp_progress(char *s, unsigned short hex) +rtas_display_progress(char *s, unsigned short hex) { - extern unsigned int rtas_data; - int max_width, width; - struct device_node *root; + int width; char *os = s; - unsigned long *p; - if ( (root = find_path_device("/rtas")) && - (p = (unsigned long *)get_property(root, - "ibm,display-line-length", - NULL)) ) - max_width = *p; - else - max_width = 0x10; - - if ( (_machine != _MACH_chrp) || !rtas_data ) - return; if ( call_rtas( "display-character", 1, 1, NULL, '\r' ) ) - { - /* assume no display-character RTAS method - use hex display */ - call_rtas("set-indicator", 3, 1, NULL, 6, 0, hex); return; - } width = max_width; while ( *os ) @@ -696,3 +708,17 @@ call_rtas( "display-character", 1, 1, NULL, ' ' ); } +void __chrp +rtas_indicator_progress(char *s, unsigned short hex) +{ + call_rtas("set-indicator", 3, 1, NULL, 6, 0, hex); +} + +#ifdef CONFIG_BOOTX_TEXT +void +bootx_text_progress(char *s, unsigned short hex) +{ + prom_print(s); + prom_print("\n"); +} +#endif /* CONFIG_BOOTX_TEXT */ diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/chrp_time.c linux/arch/ppc/kernel/chrp_time.c --- v2.4.0-test8/linux/arch/ppc/kernel/chrp_time.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/chrp_time.c Sun Sep 17 09:48:06 2000 @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -32,18 +33,20 @@ static int nvram_as0 = NVRAM_AS0; static int nvram_data = NVRAM_DATA; -void __init chrp_time_init(void) +long __init chrp_time_init(void) { struct device_node *rtcs; int base; rtcs = find_compatible_devices("rtc", "pnpPNP,b00"); if (rtcs == NULL || rtcs->addrs == NULL) - return; + return 0; base = rtcs->addrs[0].address; nvram_as1 = 0; nvram_as0 = base; nvram_data = base + 1; + + return 0; } int __chrp chrp_cmos_clock_read(int addr) @@ -115,28 +118,34 @@ unsigned long __chrp chrp_get_rtc_time(void) { unsigned int year, mon, day, hour, min, sec; - int i; + int uip, i; /* The Linux interpretation of the CMOS clock register contents: * When the Update-In-Progress (UIP) flag goes from 1 to 0, the * RTC registers show the second which has precisely just started. * Let's hope other operating systems interpret the RTC the same way. */ - /* read RTC exactly on falling edge of update flag */ - for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */ - if (chrp_cmos_clock_read(RTC_FREQ_SELECT) & RTC_UIP) - break; - for (i = 0 ; i < 1000000 ; i++) /* must try at least 2.228 ms */ - if (!(chrp_cmos_clock_read(RTC_FREQ_SELECT) & RTC_UIP)) - break; - do { /* Isn't this overkill ? UIP above should guarantee consistency */ + + /* Since the UIP flag is set for about 2.2 ms and the clock + * is typically written with a precision of 1 jiffy, trying + * to obtain a precision better than a few milliseconds is + * an illusion. Only consistency is interesting, this also + * allows to use the routine for /dev/rtc without a potential + * 1 second kernel busy loop triggered by any reader of /dev/rtc. + */ + + for ( i = 0; i<1000000; i++) { + uip = chrp_cmos_clock_read(RTC_FREQ_SELECT); sec = chrp_cmos_clock_read(RTC_SECONDS); min = chrp_cmos_clock_read(RTC_MINUTES); hour = chrp_cmos_clock_read(RTC_HOURS); day = chrp_cmos_clock_read(RTC_DAY_OF_MONTH); mon = chrp_cmos_clock_read(RTC_MONTH); year = chrp_cmos_clock_read(RTC_YEAR); - } while (sec != chrp_cmos_clock_read(RTC_SECONDS)); + uip |= chrp_cmos_clock_read(RTC_FREQ_SELECT); + if ((uip & RTC_UIP)==0) break; + } + if (!(chrp_cmos_clock_read(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { BCD_TO_BIN(sec); @@ -155,8 +164,7 @@ void __init chrp_calibrate_decr(void) { struct device_node *cpu; - int *fp, divisor; - unsigned long freq; + unsigned int freq, *fp; if (via_calibrate_decr()) return; @@ -168,15 +176,13 @@ freq = 16666000; /* hardcoded default */ cpu = find_type_devices("cpu"); if (cpu != 0) { - fp = (int *) get_property(cpu, "timebase-frequency", NULL); + fp = (unsigned int *) + get_property(cpu, "timebase-frequency", NULL); if (fp != 0) freq = *fp; } - freq *= 30; - divisor = 30; - printk("time_init: decrementer frequency = %lu/%d (%ld MHz)\n", freq, - divisor, (freq/divisor)>>20); - decrementer_count = freq / HZ / divisor; - count_period_num = divisor; - count_period_den = freq / 1000000; + printk("time_init: decrementer frequency = %u.%.6u MHz\n", + freq/1000000, freq%1000000); + tb_ticks_per_jiffy = freq / HZ; + tb_to_us = mulhwu_scale_factor(freq, 1000000); } diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/entry.S linux/arch/ppc/kernel/entry.S --- v2.4.0-test8/linux/arch/ppc/kernel/entry.S Wed Aug 9 19:19:49 2000 +++ linux/arch/ppc/kernel/entry.S Sun Sep 17 09:48:06 2000 @@ -30,6 +30,7 @@ #include #include #include +#include "mol.h" #undef SHOW_SYSCALLS #undef SHOW_SYSCALLS_TASK @@ -85,7 +86,7 @@ beq- 10f cmpi 0,r0,0x6666 /* Special case for 'sys_rt_sigreturn' */ beq- 16f - lwz r10,TASK_FLAGS(r2) + lwz r10,TASK_PTRACE(r2) andi. r10,r10,PT_TRACESYS bne- 50f cmpli 0,r0,NR_syscalls @@ -241,6 +242,13 @@ /* XXX it would be nice to find a SPRGx for this on 6xx,7xx too */ lwz r9,PGDIR(r4) /* cache the page table root */ tophys(r9,r9) /* convert to phys addr */ +#ifdef CONFIG_8xx_CPU6 + lis r6, cpu6_errata_word@h + ori r6, r6, cpu6_errata_word@l + li r5, 0x3980 + stw r5, 8(r6) + lwz r5, 8(r6) +#endif mtspr M_TWB,r9 /* Update MMU base address */ tlbia SYNC @@ -349,21 +357,18 @@ beq+ restore li r3,0 addi r4,r1,STACK_FRAME_OVERHEAD + MOL_HOOK_MMU(8,r8) bl do_signal .globl do_signal_ret do_signal_ret: -restore: - lwz r3,_CTR(r1) - lwz r0,_LINK(r1) - mtctr r3 - mtlr r0 +restore: lwz r3,_XER(r1) mtspr XER,r3 - REST_10GPRS(3, r1) - REST_10GPRS(13, r1) - REST_8GPRS(23, r1) - REST_GPR(31, r1) - + REST_10GPRS(9,r1) + REST_10GPRS(19,r1) + REST_2GPRS(29,r1) + REST_GPR(31,r1) + /* make sure we hard disable here, even if rtl is active, to protect * SRR[01] and SPRG2 -- Cort */ @@ -376,12 +381,28 @@ lwz r0,_MSR(r1) andi. r0,r0,MSR_PR beq+ 1f +#ifdef CONFIG_ALTIVEC + mfpvr r8 /* check if we are on a G4 */ + srwi r8,r8,16 + cmpwi r8,PVR_7400@h + bne 2f + lwz r0,THREAD+THREAD_VRSAVE(r2) + mtspr SPRN_VRSAVE,r0 /* if so, restore VRSAVE reg */ +2: +#endif /* CONFIG_ALTIVEC */ addi r0,r1,INT_FRAME_SIZE /* size of frame */ stw r0,THREAD+KSP(r2) /* save kernel stack pointer */ - tophys(r2,r1) - CLR_TOP32(r2) - mtspr SPRG2,r2 /* phys exception stack pointer */ + tophys(r8,r1) + CLR_TOP32(r8) + MOL_HOOK_MMU(9, r4) /* mod. r0,r2-r7, lr, ctr */ + mtspr SPRG2,r8 /* phys exception stack pointer */ 1: + lwz r3,_CTR(r1) + lwz r0,_LINK(r1) + mtctr r3 + mtlr r0 + REST_4GPRS(3, r1) + REST_2GPRS(7, r1) lwz r0,_MSR(r1) FIX_SRR1(r0,r2) mtspr SRR1,r0 diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/feature.c linux/arch/ppc/kernel/feature.c --- v2.4.0-test8/linux/arch/ppc/kernel/feature.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/feature.c Sun Sep 17 09:48:06 2000 @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include #include @@ -34,6 +36,20 @@ #define MAX_FEATURE_OFFSET 0x100 #define FREG(c,r) (&(((c)->reg)[(r)>>2])) +/* Keylargo reg. access. */ +#define KL_FCR(r) (keylargo_base + ((r) >> 2)) +#define KL_IN(r) (in_le32(KL_FCR(r))) +#define KL_OUT(r,v) (out_le32(KL_FCR(r), (v))) +#define KL_BIS(r,v) (KL_OUT((r), KL_IN(r) | (v))) +#define KL_BIC(r,v) (KL_OUT((r), KL_IN(r) & ~(v))) + +/* Uni-N reg. access. Note that Uni-N regs are big endian */ +#define UN_REG(r) (uninorth_base + ((r) >> 2)) +#define UN_IN(r) (in_be32(UN_REG(r))) +#define UN_OUT(r,v) (out_be32(UN_REG(r), (v))) +#define UN_BIS(r,v) (UN_OUT((r), UN_IN(r) | (v))) +#define UN_BIC(r,v) (UN_OUT((r), UN_IN(r) & ~(v))) + typedef struct feature_bit { int reg; /* reg. offset from mac-io base */ unsigned int polarity; /* 0 = normal, 1 = inverse */ @@ -74,11 +90,45 @@ {0x38,0,0}, /* FEATURE_Airport_reset */ }; -/* Those bits are from a PowerBook. It's possible that desktop machines - * based on heathrow need a different definition or some bits removed +/* Those bits concern heathrow-based desktop machines (Beige G3s). We have removed + * the SCC related bits and init them once. They have proven to occasionally cause + * problems with the desktop units. */ static fbit feature_bits_heathrow[] = { {0x38,0,0}, /* FEATURE_null */ + {0x38,0,0}, /* FEATURE_Serial_reset */ + {0x38,0,0}, /* FEATURE_Serial_enable */ + {0x38,0,0}, /* FEATURE_Serial_IO_A */ + {0x38,0,0}, /* FEATURE_Serial_IO_B */ + {0x38,0,HRW_SWIM_ENABLE}, /* FEATURE_SWIM3_enable */ + {0x38,0,HRW_MESH_ENABLE}, /* FEATURE_MESH_enable */ + {0x38,0,HRW_IDE0_ENABLE}, /* FEATURE_IDE0_enable */ + {0x38,1,HRW_IDE0_RESET_N}, /* FEATURE_IDE0_reset */ + {0x38,0,HRW_IOBUS_ENABLE}, /* FEATURE_IOBUS_enable */ + {0x38,1,0}, /* FEATURE_Mediabay_reset */ + {0x38,1,0}, /* FEATURE_Mediabay_power */ + {0x38,0,0}, /* FEATURE_Mediabay_PCI_enable */ + {0x38,0,HRW_BAY_IDE_ENABLE}, /* FEATURE_IDE1_enable */ + {0x38,1,HRW_IDE1_RESET_N}, /* FEATURE_IDE1_reset */ + {0x38,0,0}, /* FEATURE_Mediabay_floppy_enable */ + {0x38,0,HRW_BMAC_RESET}, /* FEATURE_BMac_reset */ + {0x38,0,HRW_BMAC_IO_ENABLE}, /* FEATURE_BMac_IO_enable */ + {0x38,1,0}, /* FEATURE_Modem_power */ + {0x38,0,HRW_SLOW_SCC_PCLK}, /* FEATURE_Slow_SCC_PCLK */ + {0x38,1,0}, /* FEATURE_Sound_Power */ + {0x38,0,0}, /* FEATURE_Sound_CLK_Enable */ + {0x38,0,0}, /* FEATURE_IDE2_enable */ + {0x38,0,0}, /* FEATURE_IDE2_reset */ + {0x38,0,0}, /* FEATURE_Mediabay_IDE_switch */ + {0x38,0,0}, /* FEATURE_Mediabay_content */ + {0x38,0,0}, /* FEATURE_Airport_reset */ +}; + +/* Those bits concern heathrow-based PowerBooks (wallstreet/mainstreet). + * Heathrow-based desktop macs (Beige G3s) are _not_ handled here + */ +static fbit feature_bits_wallstreet[] = { + {0x38,0,0}, /* FEATURE_null */ {0x38,0,HRW_RESET_SCC}, /* FEATURE_Serial_reset */ {0x38,0,HRW_SCC_ENABLE}, /* FEATURE_Serial_enable */ {0x38,0,HRW_SCCA_IO}, /* FEATURE_Serial_IO_A */ @@ -145,32 +195,32 @@ */ static fbit feature_bits_keylargo[] = { {0x38,0,0}, /* FEATURE_null */ - {0x38,0,0}, /* FEATURE_Serial_reset */ - {0x38,0,0x00000054}, /* FEATURE_Serial_enable */ - {0x38,0,0}, /* FEATURE_Serial_IO_A */ - {0x38,0,0}, /* FEATURE_Serial_IO_B */ + {0x38,0,KL0_SCC_RESET}, /* FEATURE_Serial_reset */ + {0x38,0,KL0_SERIAL_ENABLE}, /* FEATURE_Serial_enable */ + {0x38,0,KL0_SCC_A_INTF_ENABLE}, /* FEATURE_Serial_IO_A */ + {0x38,0,KL0_SCC_B_INTF_ENABLE}, /* FEATURE_Serial_IO_B */ {0x38,0,0}, /* FEATURE_SWIM3_enable */ {0x38,0,0}, /* FEATURE_MESH_enable */ {0x3c,0,0}, /* FEATURE_IDE0_enable */ - {0x3c,1,0x01000000}, /* FEATURE_IDE0_reset */ + {0x3c,1,KL1_EIDE0_RESET_N}, /* FEATURE_IDE0_reset */ {0x38,0,0}, /* FEATURE_IOBUS_enable */ {0x34,1,0x00000200}, /* FEATURE_Mediabay_reset */ {0x34,1,0x00000400}, /* FEATURE_Mediabay_power */ {0x38,0,0}, /* FEATURE_Mediabay_PCI_enable */ {0x3c,0,0x0}, /* FEATURE_IDE1_enable */ - {0x3c,1,0x08000000}, /* FEATURE_IDE1_reset */ + {0x3c,1,KL1_EIDE1_RESET_N}, /* FEATURE_IDE1_reset */ {0x38,0,0}, /* FEATURE_Mediabay_floppy_enable */ {0x38,0,0}, /* FEATURE_BMac_reset */ {0x38,0,0}, /* FEATURE_BMac_IO_enable */ - {0x40,1,0x02000000}, /* FEATURE_Modem_power */ + {0x40,1,KL2_MODEM_POWER_N}, /* FEATURE_Modem_power */ {0x38,0,0}, /* FEATURE_Slow_SCC_PCLK */ {0x38,0,0}, /* FEATURE_Sound_Power */ {0x38,0,0}, /* FEATURE_Sound_CLK_Enable */ {0x38,0,0}, /* FEATURE_IDE2_enable */ - {0x3c,1,0x40000000}, /* FEATURE_IDE2_reset */ - {0x34,0,0x00001000}, /* FEATURE_Mediabay_IDE_switch */ + {0x3c,1,KL1_UIDE_RESET_N}, /* FEATURE_IDE2_reset */ + {0x34,0,KL_MBCR_MBDEV_ENABLE}, /* FEATURE_Mediabay_IDE_switch */ {0x34,0,0x00000100}, /* FEATURE_Mediabay_content */ - {0x40,1,0x08000000}, /* FEATURE_Airport_reset */ + {0x40,1,KL2_AIRPORT_RESET_N}, /* FEATURE_Airport_reset */ }; /* definition of a feature controller object */ @@ -190,6 +240,8 @@ static void heathrow_prepare_for_sleep(struct feature_controller* ctrler); static void heathrow_wakeup(struct feature_controller* ctrler); +static void keylargo_init(void); +static void uninorth_init(void); static void core99_prepare_for_sleep(struct feature_controller* ctrler); static void core99_wake_up(struct feature_controller* ctrler); @@ -228,8 +280,15 @@ } } else if (device_is_compatible(np, "paddington")) { feature_add_controller(np, feature_bits_paddington); + } else if (machine_is_compatible("AAPL,PowerBook1998")) { + feature_add_controller(np, feature_bits_wallstreet); } else { - feature_add_controller(np, feature_bits_heathrow); + struct feature_controller* ctrler = + feature_add_controller(np, feature_bits_heathrow); + if (ctrler) + out_le32(FREG(ctrler,HEATHROW_FEATURE_REG), + in_le32(FREG(ctrler,HEATHROW_FEATURE_REG)) | HRW_DEFAULTS); + } np = np->next; } @@ -249,14 +308,17 @@ np = find_devices("uni-n"); if (np && np->n_addrs > 0) { uninorth_base = ioremap(np->addrs[0].address, 0x1000); - rev = (u32 *)get_property(np, "device-rev", NULL); - if (rev) - uninorth_rev = *rev; + uninorth_rev = in_be32(UN_REG(UNI_N_VERSION)); } if (uninorth_base && keylargo_base) printk("Uni-N revision: %d, KeyLargo revision: %d\n", uninorth_rev, keylargo_rev); + if (uninorth_base) + uninorth_init(); + if (keylargo_base) + keylargo_init(); + if (controller_count) printk(KERN_INFO "Registered %d feature controller(s)\n", controller_count); @@ -440,14 +502,21 @@ if (!uninorth_base) return; if (power) - out_le32(uninorth_base + 0x20/4, - in_le32(uninorth_base + 0x20/4) | 0x02000000); + UN_BIS(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_GMAC); else - out_le32(uninorth_base + 0x20/4, - in_le32(uninorth_base + 0x20/4) & ~0x02000000); + UN_BIC(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_GMAC); udelay(20); } +void +feature_set_gmac_phy_reset(struct device_node* device, int reset) +{ + if (!keylargo_base) + return; + out_8((volatile u8 *)KL_FCR(KL_GPIO_ETH_PHY_RESET), reset); + (void)in_8((volatile u8 *)KL_FCR(KL_GPIO_ETH_PHY_RESET)); +} + /* Pass the node of the correct controller, please */ void feature_set_usb_power(struct device_node* device, int power) @@ -460,6 +529,53 @@ { } +/* Initialize the Core99 UniNorth host bridge and memory controller + */ +static void +uninorth_init(void) +{ + struct device_node* gmac; + unsigned long actrl; + + /* Set the arbitrer QAck delay according to what Apple does + */ + actrl = in_be32(UN_REG(UNI_N_ARB_CTRL)) & ~UNI_N_ARB_CTRL_QACK_DELAY_MASK; + actrl |= ((uninorth_rev < 3) ? UNI_N_ARB_CTRL_QACK_DELAY105 : UNI_N_ARB_CTRL_QACK_DELAY) + << UNI_N_ARB_CTRL_QACK_DELAY_SHIFT; + UN_OUT(UNI_N_ARB_CTRL, actrl); + + /* + * Turns OFF the gmac clock. The gmac driver will turn + * it back ON when the interface is enabled. This save + * power on portables. + * + * Note: We could also try to turn OFF the PHY. Since this + * has to be done by both the gmac driver and this code, + * I'll probably end-up moving some of this out of the + * modular gmac driver into a non-modular stub containing + * some basic PHY management and power management stuffs + */ + gmac = find_devices("ethernet"); + + while(gmac) { + if (device_is_compatible(gmac, "gmac")) + break; + gmac = gmac->next; + } + if (gmac) + feature_set_gmac_power(gmac, 0); +} + +/* Initialize the Core99 KeyLargo ASIC. Currently, we just make sure + * OpenPIC is enabled + */ +static void +keylargo_init(void) +{ + KL_BIS(KEYLARGO_FCR2, KL2_MPIC_ENABLE); +} + +#ifdef CONFIG_PMAC_PBOOK void feature_prepare_for_sleep(void) { @@ -506,27 +622,28 @@ } } -static u32 save_fcr0; -//static u32 save_fcr1; -//static u32 save_fcr2; +static u32 save_fcr[5]; static u32 save_mbcr; static void heathrow_prepare_for_sleep(struct feature_controller* ctrler) { save_mbcr = in_le32(FREG(ctrler, 0x34)); - save_fcr0 = in_le32(FREG(ctrler, 0x38)); + save_fcr[0] = in_le32(FREG(ctrler, 0x38)); + save_fcr[1] = in_le32(FREG(ctrler, 0x3c)); - out_le32(FREG(ctrler, 0x38), save_fcr0 & ~HRW_IOBUS_ENABLE); + out_le32(FREG(ctrler, 0x38), save_fcr[0] & ~HRW_IOBUS_ENABLE); } static void heathrow_wakeup(struct feature_controller* ctrler) { - out_le32(FREG(ctrler, 0x38), save_fcr0); + out_le32(FREG(ctrler, 0x38), save_fcr[0]); + out_le32(FREG(ctrler, 0x3c), save_fcr[1]); out_le32(FREG(ctrler, 0x34), save_mbcr); - - out_le32(FREG(ctrler, 0x38), save_fcr0 | HRW_IOBUS_ENABLE); + mdelay(1); + out_le32(FREG(ctrler, 0x38), save_fcr[0] | HRW_IOBUS_ENABLE); + mdelay(1); } static void @@ -540,4 +657,4 @@ { /* Not yet implemented */ } - +#endif /* CONFIG_PMAC_PBOOK */ diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/gemini_setup.c linux/arch/ppc/kernel/gemini_setup.c --- v2.4.0-test8/linux/arch/ppc/kernel/gemini_setup.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/gemini_setup.c Sun Sep 17 09:48:06 2000 @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -335,7 +336,7 @@ #define gemini_rtc_write(val,x) (writeb((val),(GEMINI_RTC+(x)))) /* ensure that the RTC is up and running */ -void __init gemini_time_init(void) +long __init gemini_time_init(void) { unsigned char reg; @@ -346,6 +347,7 @@ gemini_rtc_write((reg & ~(M48T35_RTC_STOPPED)), M48T35_RTC_CONTROL); gemini_rtc_write((reg | M48T35_RTC_SET), M48T35_RTC_CONTROL); } + return 0; } #undef DEBUG_RTC diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/hashtable.S linux/arch/ppc/kernel/hashtable.S --- v2.4.0-test8/linux/arch/ppc/kernel/hashtable.S Fri Jun 23 21:55:07 2000 +++ linux/arch/ppc/kernel/hashtable.S Sun Sep 17 09:48:06 2000 @@ -27,6 +27,7 @@ #include #include #include +#include "mol.h" /* * Load a PTE into the hash table, if possible. @@ -593,6 +594,11 @@ * flush_hash_page(unsigned context, unsigned long va) */ _GLOBAL(flush_hash_page) +#ifdef CONFIG_MOL + mflr r10 + MOL_HOOK_MMU(10, r6) + mtlr r10 +#endif lis r6,Hash@ha lwz r6,Hash@l(r6) /* hash table base */ cmpwi 0,r6,0 /* hash table in use? */ diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/head.S linux/arch/ppc/kernel/head.S --- v2.4.0-test8/linux/arch/ppc/kernel/head.S Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/head.S Sun Sep 17 09:48:06 2000 @@ -31,6 +31,7 @@ #include #include #include +#include "mol.h" #ifdef CONFIG_APUS #include @@ -78,7 +79,7 @@ mtspr DBAT##n##L,RB; \ 1: #endif /* CONFIG_PPC64BRIDGE */ - + .text .globl _stext _stext: @@ -162,8 +163,8 @@ /* Switch MMU off, clear BATs and flush TLB. At this point, r3 contains * the physical address we are running at, returned by prom_init() */ -__after_prom_start: bl mmu_off +__after_mmu_off: bl clear_bats bl flush_tlbs #endif @@ -202,15 +203,7 @@ mr r26,r3 addis r4,r3,KERNELBASE@h /* current address of _start */ cmpwi 0,r4,0 /* are we already running at 0? */ - beq 2f /* assume it's OK if so */ - li r3,0 - mfmsr r0 - andi. r0,r0,MSR_DR /* MMU enabled? */ - beq relocate_kernel - lis r3,KERNELBASE@h /* if so, are we */ - cmpw 0,r4,r3 /* already running at KERNELBASE? */ bne relocate_kernel -2: #endif /* CONFIG_APUS */ /* * we now have the 1st 16M of ram mapped with the bats. @@ -300,6 +293,17 @@ .long hdlr; \ .long ret_from_except +#define STD_MOL_EXCEPTION(n, label, hdlr, hook) \ + . = n; \ +label: \ + EXCEPTION_PROLOG; \ + MOL_HOOK(hook); \ + addi r3,r1,STACK_FRAME_OVERHEAD; \ + li r20,MSR_KERNEL; \ + bl transfer_to_handler; \ + .long hdlr; \ + .long ret_from_except + /* System reset */ #ifdef CONFIG_SMP /* MVME/MTX and gemini start the secondary here */ #ifdef CONFIG_GEMINI @@ -324,6 +328,7 @@ DataAccess: EXCEPTION_PROLOG #endif /* CONFIG_PPC64BRIDGE */ + MOL_HOOK(0) mfspr r20,DSISR andis. r0,r20,0xa470 /* weird error? */ bne 1f /* if not, try to put a PTE */ @@ -366,6 +371,7 @@ InstructionAccess: EXCEPTION_PROLOG #endif /* CONFIG_PPC64BRIDGE */ + MOL_HOOK(1) andis. r0,r23,0x4000 /* no pte found? */ beq 1f /* if so, try to put a PTE */ mr r3,r22 /* into the hash table */ @@ -430,6 +436,7 @@ . = 0x700 ProgramCheck: EXCEPTION_PROLOG + MOL_HOOK(2) addi r3,r1,STACK_FRAME_OVERHEAD li r20,MSR_KERNEL rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ @@ -441,6 +448,7 @@ . = 0x800 FPUnavailable: EXCEPTION_PROLOG + MOL_HOOK_RESTORE(3) bne load_up_fpu /* if from user, just load it up */ li r20,MSR_KERNEL bl transfer_to_handler /* if from kernel, take a trap */ @@ -450,6 +458,7 @@ . = 0x900 Decrementer: EXCEPTION_PROLOG + MOL_HOOK(4) addi r3,r1,STACK_FRAME_OVERHEAD li r20,MSR_KERNEL bl transfer_to_handler @@ -473,12 +482,9 @@ .long ret_from_except /* Single step - not used on 601 */ - STD_EXCEPTION(0xd00, SingleStep, SingleStepException) - + STD_MOL_EXCEPTION(0xd00, SingleStep, SingleStepException, 5) STD_EXCEPTION(0xe00, Trap_0e, UnknownException) -#ifndef CONFIG_ALTIVEC - STD_EXCEPTION(0xf00, Trap_0f, UnknownException) -#else + /* * The Altivec unavailable trap is at 0x0f20. Foo. * We effectively remap it to 0x3000. @@ -493,15 +499,20 @@ .long ret_from_except . = 0xf20 +#ifdef CONFIG_ALTIVEC b AltiVecUnavailable -#endif /* CONFIG_ALTIVEC */ - +#endif +Trap_0f: + EXCEPTION_PROLOG + b trap_0f_cont + /* * Handle TLB miss for instruction on 603/603e. * Note: we get an alternate set of r0 - r3 to use automatically. */ . = 0x1000 InstructionTLBMiss: + MOL_HOOK_TLBMISS( 14 ) /* * r0: stored ctr * r1: linux style pte ( later becomes ppc hardware pte ) @@ -568,6 +579,7 @@ */ . = 0x1100 DataLoadTLBMiss: + MOL_HOOK_TLBMISS( 15 ) /* * r0: stored ctr * r1: linux style pte ( later becomes ppc hardware pte ) @@ -633,6 +645,7 @@ */ . = 0x1200 DataStoreTLBMiss: + MOL_HOOK_TLBMISS( 16 ) /* * r0: stored ctr * r1: linux style pte ( later becomes ppc hardware pte ) @@ -674,7 +687,7 @@ mtcrf 0x80,r3 rfi - STD_EXCEPTION(0x1300, Trap_13, InstructionBreakpoint) + STD_MOL_EXCEPTION(0x1300, Trap_13, InstructionBreakpoint, 11) STD_EXCEPTION(0x1400, SMI, SMIException) STD_EXCEPTION(0x1500, Trap_15, UnknownException) STD_EXCEPTION(0x1600, Trap_16, UnknownException) @@ -687,7 +700,7 @@ STD_EXCEPTION(0x1d00, Trap_1d, UnknownException) STD_EXCEPTION(0x1e00, Trap_1e, UnknownException) STD_EXCEPTION(0x1f00, Trap_1f, UnknownException) - STD_EXCEPTION(0x2000, RunMode, RunModeException) + STD_MOL_EXCEPTION(0x2000, RunMode, RunModeException, 5) STD_EXCEPTION(0x2100, Trap_21, UnknownException) STD_EXCEPTION(0x2200, Trap_22, UnknownException) STD_EXCEPTION(0x2300, Trap_23, UnknownException) @@ -709,16 +722,12 @@ #ifdef CONFIG_ALTIVEC AltiVecUnavailable: EXCEPTION_PROLOG + MOL_HOOK_RESTORE(12) bne load_up_altivec /* if from user, just load it up */ li r20,MSR_KERNEL bl transfer_to_handler /* if from kernel, take a trap */ .long KernelAltiVec .long ret_from_except - -/* here are the bits of trap 0xf00 which got displaced */ -Trap_0f: - EXCEPTION_PROLOG - b trap_0f_cont #endif /* CONFIG_ALTIVEC */ #ifdef CONFIG_PPC64BRIDGE @@ -753,6 +762,14 @@ beq 2f addi r24,r1,STACK_FRAME_OVERHEAD stw r24,PT_REGS(r23) +#ifdef CONFIG_ALTIVEC + mfpvr r24 /* check if we are on a G4 */ + srwi r24,r24,16 + cmpwi r24,PVR_7400@h + bne 2f + mfspr r22,SPRN_VRSAVE /* if so, save vrsave register value */ + stw r22,THREAD_VRSAVE(r23) +#endif /* CONFIG_ALTIVEC */ 2: addi r2,r23,-THREAD /* set r2 to current */ tovirt(r2,r2) mflr r23 @@ -771,6 +788,7 @@ lwz r24,0(r23) /* virtual address of handler */ lwz r23,4(r23) /* where to go when done */ FIX_SRR1(r20,r22) + MOL_HOOK(6) mtspr SRR0,r24 mtspr SRR1,r20 mtlr r23 @@ -981,6 +999,11 @@ .globl giveup_altivec giveup_altivec: +#ifdef CONFIG_MOL + mflr r4 + MOL_HOOK_MMU(13, r5) + mtlr r4 +#endif mfmsr r5 oris r5,r5,MSR_VEC@h SYNC @@ -1017,6 +1040,11 @@ */ .globl giveup_fpu giveup_fpu: +#ifdef CONFIG_MOL + mflr r4 + MOL_HOOK_MMU(7, r5) + mtlr r4 +#endif mfmsr r5 ori r5,r5,MSR_FP SYNC @@ -1048,19 +1076,10 @@ * the kernel image to physical address 0. */ relocate_kernel: -#if 0 /* Is this still needed ? I don't think so. It breaks new - * boot-with-mmu-off stuff - */ - lis r9,0x426f /* if booted from BootX, don't */ - addi r9,r9,0x6f58 /* translate source addr */ - cmpw r31,r9 /* (we have to on chrp) */ - beq 7f - rlwinm r4,r4,0,8,31 /* translate source address */ - add r4,r4,r3 /* to region mapped with BATs */ -#endif -7: addis r9,r26,klimit@ha /* fetch klimit */ + addis r9,r26,klimit@ha /* fetch klimit */ lwz r25,klimit@l(r9) addis r25,r25,-KERNELBASE@h + li r3,0 /* Destination base address */ li r6,0 /* Destination offset */ li r5,0x4000 /* # bytes of memory to copy */ bl copy_and_flush /* copy the first 0x4000 bytes */ @@ -1307,7 +1326,7 @@ mfspr r9,PVR rlwinm r9,r9,16,16,31 cmpi 0,r9,1 - beq 4f /* not needed for 601 */ + beq 6f /* not needed for 601 */ mfspr r11,HID0 andi. r0,r11,HID0_DCE ori r11,r11,HID0_ICE|HID0_DCE @@ -1323,26 +1342,33 @@ isync cmpi 0,r9,4 /* check for 604 */ cmpi 1,r9,9 /* or 604e */ - cmpi 2,r9,10 /* or mach5 */ + cmpi 2,r9,10 /* or mach5 / 604r */ cmpi 3,r9,8 /* check for 750 (G3) */ cmpi 4,r9,12 /* or 7400 (G4) */ cror 2,2,6 cror 2,2,10 bne 4f - ori r11,r11,HID0_SIED|HID0_BHTE /* for 604[e], enable */ + ori r11,r11,HID0_SIED|HID0_BHTE /* for 604[e|r], enable */ bne 2,5f - ori r11,r11,HID0_BTCD + ori r11,r11,HID0_BTCD /* superscalar exec & br history tbl */ b 5f 4: cror 14,14,18 bne 3,6f - /* We should add ABE here if we want to use Store Gathering - * and other nifty bridge features + /* for G3/G4: + * enable Store Gathering (SGE), Address Brodcast (ABE), + * Branch History Table (BHTE), Branch Target ICache (BTIC) */ - ori r11,r11,HID0_SGE|HID0_BHTE|HID0_BTIC /* for g3/g4, enable */ + ori r11,r11,HID0_SGE | HID0_ABE | HID0_BHTE | HID0_BTIC + oris r11,r11,HID0_DPM@h /* enable dynamic power mgmt */ + li r3,HID0_SPD + andc r11,r11,r3 /* clear SPD: enable speculative */ li r3,0 - mtspr ICTC,r3 -5: mtspr HID0,r11 /* superscalar exec & br history tbl */ + mtspr ICTC,r3 /* Instruction Cache Throttling off */ +5: isync + mtspr HID0,r11 + sync + isync 6: blr /* @@ -1548,12 +1574,11 @@ blr mmu_off: - addi r4, r3, __after_prom_start - _start + addi r4, r3, __after_mmu_off - _start mfmsr r3 andi. r0,r3,MSR_DR|MSR_IR /* MMU enabled? */ beqlr - ori r3,r3,MSR_DR|MSR_IR - xori r3,r3,MSR_DR|MSR_IR + andc r3,r3,r0 mtspr SRR0,r4 mtspr SRR1,r3 sync @@ -1617,23 +1642,19 @@ mflr r8 bl reloc_offset mtlr r8 - lis r8, disp_BATL@h - ori r8, r8, disp_BATL@l - add r8, r3, r8 - lwz r8, 0(r8) - lis r11, disp_BATU@h - ori r11, r11, disp_BATU@l - add r11, r3, r11 - lwz r11, 0(r11) - mtspr IBAT3L,r8 - mtspr IBAT3U,r11 + addis r8,r3,disp_BAT@ha + addi r8,r8,disp_BAT@l + lwz r11,0(r8) + lwz r8,4(r8) mfspr r9,PVR rlwinm r9,r9,16,16,31 /* r9 = 1 for 601, 4 for 604 */ cmpi 0,r9,1 beq 1f mtspr DBAT3L,r8 mtspr DBAT3U,r11 -1: + blr +1: mtspr IBAT3L,r8 + mtspr IBAT3U,r11 blr #endif /* !defined(CONFIG_APUS) && defined(CONFIG_BOOTX_TEXT) */ @@ -1649,17 +1670,42 @@ */ .globl m8260_gorom m8260_gorom: - li r5,MSR_KERNEL & ~(MSR_IR|MSR_DR) - lis r6,2f@h - addis r6,r6,-KERNELBASE@h - ori r6,r6,2f@l - mtspr SRR0,r6 - mtspr SRR1,r5 - rfi + mfmsr r0 + rlwinm r0,r0,0,17,15 /* clear MSR_EE in r0 */ + sync + mtmsr r0 + sync + mfspr r11, HID0 + lis r10, 0 + ori r10,r10,HID0_ICE|HID0_DCE + andc r11, r11, r10 + mtspr HID0, r11 + isync + li r5, MSR_ + lis r6,2f@h + addis r6,r6,-KERNELBASE@h + ori r6,r6,2f@l + mtspr SRR0,r6 + mtspr SRR1,r5 + isync + sync + rfi 2: - mtlr r4 - blr + mtlr r4 + blr +#endif + +#ifdef CONFIG_MOL +/* + * Mac-on-linux hook_table. Don't put this in the data section - + * the base address must be within the first 32KB of RAM. + */ + .globl mol_interface +mol_interface: + .long MOL_INTERFACE_VERSION + .fill 24,4,0 /* space for 24 hooks */ #endif + /* * We put a few things here that have to be page-aligned. diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/head_8xx.S linux/arch/ppc/kernel/head_8xx.S --- v2.4.0-test8/linux/arch/ppc/kernel/head_8xx.S Fri Jun 23 21:55:07 2000 +++ linux/arch/ppc/kernel/head_8xx.S Sun Sep 17 09:48:06 2000 @@ -874,6 +874,13 @@ lis r6, swapper_pg_dir@h tophys(r6,r6) ori r6, r6, swapper_pg_dir@l +#ifdef CONFIG_8xx_CPU6 + lis r4, cpu6_errata_word@h + ori r4, r4, cpu6_errata_word@l + li r3, 0x3980 + stw r3, 12(r4) + lwz r3, 12(r4) +#endif mtspr M_TWB, r6 lis r4,2f@h ori r4,r4,2f@l @@ -940,9 +947,23 @@ * ASID compare register with the new "context". */ _GLOBAL(set_context) +#ifdef CONFIG_8xx_CPU6 + lis r6, cpu6_errata_word@h + ori r6, r6, cpu6_errata_word@l + tophys (r4, r4) + li r7, 0x3980 + stw r7, 12(r6) + lwz r7, 12(r6) + mtspr M_TWB, r4 /* Update MMU base address */ + li r7, 0x3380 + stw r7, 12(r6) + lwz r7, 12(r6) + mtspr M_CASID, r3 /* Update context */ +#else mtspr M_CASID,r3 /* Update context */ tophys (r4, r4) mtspr M_TWB, r4 /* and pgd */ +#endif tlbia SYNC blr @@ -966,6 +987,24 @@ 2: mtlr r4 blr + +#ifdef CONFIG_8xx_CPU6 +/* It's here because it is unique to the 8xx. + * It is important we get called with interrupts disabled. I used to + * do that, but it appears that all code that calls this already had + * interrupt disabled. + */ + .globl set_dec_cpu6 +set_dec_cpu6: + lis r7, cpu6_errata_word@h + ori r7, r7, cpu6_errata_word@l + li r4, 0x2c00 + stw r4, 8(r7) + lwz r4, 8(r7) + mtspr 22, r3 /* Update Decrementer */ + SYNC + blr +#endif /* * We put a few things here that have to be page-aligned. @@ -990,4 +1029,10 @@ .globl cmd_line cmd_line: .space 512 + +#ifdef CONFIG_8xx_CPU6 + .globl cpu6_errata_word +cpu6_errata_word: + .space 16 +#endif diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/idle.c linux/arch/ppc/kernel/idle.c --- v2.4.0-test8/linux/arch/ppc/kernel/idle.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/idle.c Sun Sep 17 09:48:06 2000 @@ -286,6 +286,7 @@ case 6: /* 603e */ case 7: /* 603ev */ case 8: /* 750 */ + case 12: /* 7400 */ save_flags(msr); __cli(); if (!current->need_resched) { diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/irq.c linux/arch/ppc/kernel/irq.c --- v2.4.0-test8/linux/arch/ppc/kernel/irq.c Wed Aug 9 19:19:49 2000 +++ linux/arch/ppc/kernel/irq.c Sun Sep 17 09:48:06 2000 @@ -137,17 +137,21 @@ if (!handler) { /* Free */ - for (p = &irq_desc[irq].action; (action = *p) != NULL; p = &action->next) - { - /* Found it - now free it */ - save_flags(flags); - cli(); - *p = action->next; - restore_flags(flags); - irq_kfree(action); - return 0; - } - return -ENOENT; + p = &irq_desc[irq].action; + while ((action = *p) != NULL && action->dev_id != dev_id) + p = &action->next; + if (action == NULL) + return -ENOENT; + + /* Found it - now free it */ + save_flags(flags); + cli(); + *p = action->next; + if (irq_desc[irq].action == NULL) + disable_irq(irq); + restore_flags(flags); + irq_kfree(action); + return 0; } action = (struct irqaction *) @@ -300,7 +304,7 @@ } } -asmlinkage int do_IRQ(struct pt_regs *regs, int isfake) +int do_IRQ(struct pt_regs *regs, int isfake) { int cpu = smp_processor_id(); int irq; diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/m8260_setup.c linux/arch/ppc/kernel/m8260_setup.c --- v2.4.0-test8/linux/arch/ppc/kernel/m8260_setup.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/m8260_setup.c Sun Sep 17 09:48:07 2000 @@ -112,11 +112,10 @@ bd_t *binfo = (bd_t *)__res; int freq, divisor; - freq = (binfo->bi_intfreq * 1000000); - divisor = 16; - decrementer_count = freq / HZ / divisor; - count_period_num = divisor; - count_period_den = freq / 1000000; + freq = (binfo->bi_busfreq * 1000000); + divisor = 4; + tb_ticks_per_jiffy = freq / HZ / divisor; + tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000); } /* The 8260 has an internal 1-second timer update register that @@ -143,8 +142,20 @@ m8260_restart(char *cmd) { extern void m8260_gorom(bd_t *bi, uint addr); + uint startaddr; - m8260_gorom(NULL, 0xff000100); + /* Most boot roms have a warmstart as the second instruction + * of the reset vector. If that doesn't work for you, change this + * or the reboot program to send a proper address. + */ + startaddr = 0xff000104; + + if (cmd != NULL) { + if (!strncmp(cmd, "startaddr=", 10)) + startaddr = simple_strtoul(&cmd[10], NULL, 0); + } + + m8260_gorom((uint)__pa(__res), startaddr); } void diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/m8xx_setup.c linux/arch/ppc/kernel/m8xx_setup.c --- v2.4.0-test8/linux/arch/ppc/kernel/m8xx_setup.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/m8xx_setup.c Sun Sep 17 09:48:07 2000 @@ -135,6 +135,13 @@ machine_restart(NULL); } +/* A place holder for time base interrupts, if they are ever enabled. +*/ +void timebase_interrupt(int irq, void * dev, struct pt_regs * regs) +{ + printk("timebase_interrupt()\n"); +} + /* The decrementer counts at the system (internal) clock frequency divided by * sixteen, or external oscillator divided by four. We force the processor * to use system clock divided by sixteen. @@ -160,35 +167,14 @@ freq = fp*60; /* try to make freq/1e6 an integer */ divisor = 60; printk("time_init: decrementer frequency = %d/%d\n", freq, divisor); - decrementer_count = freq / HZ / divisor; - count_period_num = divisor; - count_period_den = freq / 1000000; -} + tb_ticks_per_jiffy = freq / HZ / divisor; + tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000); -/* A place holder for time base interrupts, if they are ever enabled. -*/ -void timebase_interrupt(int irq, void * dev, struct pt_regs * regs) -{ - printk("timebase_interrupt()\n"); -} - -/* The RTC on the MPC8xx is an internal register. - * We want to protect this during power down, so we need to unlock, - * modify, and re-lock. - */ -static int -m8xx_set_rtc_time(unsigned long time) -{ - ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_rtck = KAPWR_KEY; - ((volatile immap_t *)IMAP_ADDR)->im_sit.sit_rtc = time; - ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_rtck = ~KAPWR_KEY; - return(0); -} - -unsigned long __init -m8xx_get_rtc_time(void) -{ - /* First, unlock all of the registers we are going to modify. + /* Perform some more timer/timebase initialization. This used + * to be done elsewhere, but other changes caused it to get + * called more than once....that is a bad thing. + * + * First, unlock all of the registers we are going to modify. * To protect them from corruption during power down, registers * that are maintained by keep alive power are "locked". To * modify these registers we have to write the key value to @@ -219,9 +205,27 @@ ((volatile immap_t *)IMAP_ADDR)->im_sit.sit_tbscr = ((mk_int_int_mask(DEC_INTERRUPT) << 8) | (TBSCR_TBF | TBSCR_TBE)); + if (request_8xxirq(DEC_INTERRUPT, timebase_interrupt, 0, "tbint", NULL) != 0) panic("Could not allocate timer IRQ!"); +} + +/* The RTC on the MPC8xx is an internal register. + * We want to protect this during power down, so we need to unlock, + * modify, and re-lock. + */ +static int +m8xx_set_rtc_time(unsigned long time) +{ + ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_rtck = KAPWR_KEY; + ((volatile immap_t *)IMAP_ADDR)->im_sit.sit_rtc = time; + ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_rtck = ~KAPWR_KEY; + return(0); +} +unsigned long __init +m8xx_get_rtc_time(void) +{ /* Get time from the RTC. */ return((unsigned long)(((immap_t *)IMAP_ADDR)->im_sit.sit_rtc)); diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/misc.S linux/arch/ppc/kernel/misc.S --- v2.4.0-test8/linux/arch/ppc/kernel/misc.S Wed Aug 23 18:36:36 2000 +++ linux/arch/ppc/kernel/misc.S Sun Sep 17 09:48:07 2000 @@ -24,12 +24,15 @@ #if defined(CONFIG_4xx) || defined(CONFIG_8xx) #define CACHE_LINE_SIZE 16 #define LG_CACHE_LINE_SIZE 4 +#define MAX_COPY_PREFETCH 1 #elif !defined(CONFIG_PPC64BRIDGE) #define CACHE_LINE_SIZE 32 #define LG_CACHE_LINE_SIZE 5 +#define MAX_COPY_PREFETCH 4 #else #define CACHE_LINE_SIZE 128 #define LG_CACHE_LINE_SIZE 7 +#define MAX_COPY_PREFETCH 1 #endif /* CONFIG_4xx || CONFIG_8xx */ .text @@ -339,7 +342,15 @@ _GLOBAL(clear_page) li r0,4096/CACHE_LINE_SIZE mtctr r0 +#ifdef CONFIG_8xx + li r4, 0 +1: stw r4, 0(r3) + stw r4, 4(r3) + stw r4, 8(r3) + stw r4, 12(r3) +#else 1: dcbz 0,r3 +#endif addi r3,r3,CACHE_LINE_SIZE bdnz 1b blr @@ -361,12 +372,31 @@ stwu r9,16(r3) _GLOBAL(copy_page) - li r0,4096/CACHE_LINE_SIZE - mtctr r0 addi r3,r3,-4 addi r4,r4,-4 li r5,4 -1: dcbz r5,r3 + +#ifndef CONFIG_8xx +#if MAX_COPY_PREFETCH > 1 + li r0,MAX_COPY_PREFETCH + li r11,4 + mtctr r0 +11: dcbt r11,r4 + addi r11,r11,CACHE_LINE_SIZE + bdnz 11b +#else /* MAX_COPY_PREFETCH == 1 */ + dcbt r5,r4 + li r11,CACHE_LINE_SIZE+4 +#endif /* MAX_COPY_PREFETCH */ +#endif /* CONFIG_8xx */ + + li r0,4096/CACHE_LINE_SIZE + mtctr r0 +1: +#ifndef CONFIG_8xx + dcbt r11,r4 + dcbz r5,r3 +#endif COPY_16_BYTES #if CACHE_LINE_SIZE >= 32 COPY_16_BYTES @@ -484,7 +514,7 @@ stwcx. r5,0,r3 /* Update with new value */ bne- 10b /* Retry if "reservation" (i.e. lock) lost */ cntlzw r3,r5 - srwi r3,r3,5 + srwi r3,r3,5 blr #endif /* 0 */ _GLOBAL(atomic_clear_mask) @@ -629,48 +659,59 @@ blr /* - * Extended precision shifts + * Extended precision shifts. + * + * Updated to be valid for shift counts from 0 to 63 inclusive. + * -- Gabriel * * R3/R4 has 64 bit value * R5 has shift count * result in R3/R4 * - * ashrdi3: XXXYYY/ZZZAAA -> SSSXXX/YYYZZZ - * ashldi3: XXXYYY/ZZZAAA -> YYYZZZ/AAA000 - * lshrdi3: XXXYYY/ZZZAAA -> 000XXX/YYYZZZ + * ashrdi3: arithmetic right shift (sign propagation) + * lshrdi3: logical right shift + * ashldi3: left shift */ _GLOBAL(__ashrdi3) - li r6,32 - sub r6,r6,r5 - slw r7,r3,r6 /* isolate YYY */ - srw r4,r4,r5 /* isolate ZZZ */ - or r4,r4,r7 /* YYYZZZ */ - sraw r3,r3,r5 /* SSSXXX */ + subfic r6,r5,32 + srw r4,r4,r5 # LSW = count > 31 ? 0 : LSW >> count + addi r7,r5,32 # could be xori, or addi with -32 + slw r6,r3,r6 # t1 = count > 31 ? 0 : MSW << (32-count) + rlwinm r8,r7,0,32 # t3 = (count < 32) ? 32 : 0 + sraw r7,r3,r7 # t2 = MSW >> (count-32) + or r4,r4,r6 # LSW |= t1 + slw r7,r7,r8 # t2 = (count < 32) ? 0 : t2 + sraw r3,r3,r5 # MSW = MSW >> count + or r4,r4,r7 # LSW |= t2 blr _GLOBAL(__ashldi3) - li r6,32 - sub r6,r6,r5 - srw r7,r4,r6 /* isolate ZZZ */ - slw r4,r4,r5 /* AAA000 */ - slw r3,r3,r5 /* YYY--- */ - or r3,r3,r7 /* YYYZZZ */ + subfic r6,r5,32 + slw r3,r3,r5 # MSW = count > 31 ? 0 : MSW << count + addi r7,r5,32 # could be xori, or addi with -32 + srw r6,r4,r6 # t1 = count > 31 ? 0 : LSW >> (32-count) + slw r7,r4,r7 # t2 = count < 32 ? 0 : LSW << (count-32) + or r3,r3,r6 # MSW |= t1 + slw r4,r4,r5 # LSW = LSW << count + or r3,r3,r7 # MSW |= t2 blr _GLOBAL(__lshrdi3) - li r6,32 - sub r6,r6,r5 - slw r7,r3,r6 /* isolate YYY */ - srw r4,r4,r5 /* isolate ZZZ */ - or r4,r4,r7 /* YYYZZZ */ - srw r3,r3,r5 /* 000XXX */ + subfic r6,r5,32 + srw r4,r4,r5 # LSW = count > 31 ? 0 : LSW >> count + addi r7,r5,32 # could be xori, or addi with -32 + slw r6,r3,r6 # t1 = count > 31 ? 0 : MSW << (32-count) + srw r7,r3,r7 # t2 = count < 32 ? 0 : MSW >> (count-32) + or r4,r4,r6 # LSW |= t1 + srw r3,r3,r5 # MSW = MSW >> count + or r4,r4,r7 # LSW |= t2 blr _GLOBAL(abs) - cmpi 0,r3,0 - bge 10f - neg r3,r3 -10: blr + srawi r4,r3,31 + xor r3,r3,r4 + sub r3,r3,r4 + blr _GLOBAL(_get_SP) mr r3,r1 /* Close enough */ @@ -1217,6 +1258,6 @@ .long sys_pciconfig_iobase /* 200 */ .long sys_ni_syscall /* 201 - reserved - MacOnLinux - new */ .long sys_getdents64 /* 202 */ - .rept NR_syscalls-201 + .rept NR_syscalls-(.-sys_call_table)/4 .long sys_ni_syscall .endr diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/mol.h linux/arch/ppc/kernel/mol.h --- v2.4.0-test8/linux/arch/ppc/kernel/mol.h Wed Dec 31 16:00:00 1969 +++ linux/arch/ppc/kernel/mol.h Sun Sep 17 09:48:07 2000 @@ -0,0 +1,68 @@ +/* + * arch/ppc/kernel/mol.h + * + * + * + * Mac-on-Linux hook macros + * + * + * Copyright (C) 2000 Samuel Rydh (samuel@ibrium.se) + * + * 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 + * + */ + +#ifndef _PPC_KERNEL_MOL +#define _PPC_KERNEL_MOL + +#include + +#ifdef CONFIG_MOL +#define MOL_INTERFACE_VERSION 3 + +#define MOL_HOOK(hook_num) \ + lwz r0,(mol_interface + 4 * hook_num + 4)@l(0); \ + cmpwi cr1,r0,0; \ + beq+ cr1,777f; \ + mtctr r0; \ + bctrl; \ +777: lwz r0,GPR0(r21) + +#define MOL_HOOK_RESTORE(hook_num) \ + mfcr r2; \ + MOL_HOOK(hook_num); \ + mtcrf 0x80,r2; \ + lwz r2,_CTR(r21); \ + mtctr r2; \ + lwz r2,GPR2(r21) + +#define MOL_HOOK_MMU(hook_num, scr) \ + lis scr,(mol_interface + 4 * hook_num + 4)@ha; \ + lwz scr,(mol_interface + 4 * hook_num + 4)@l(scr); \ + cmpwi cr1,scr,0; \ + beq+ cr1,778f; \ + mtctr scr; \ + bctrl; \ +778: + +#define MOL_HOOK_TLBMISS(hook_num) \ + lwz r0,(mol_interface + 4 * hook_num + 4)@l(0); \ + cmpwi r0,0; \ + beq+ 779f; \ + mflr r3; \ + mtlr r0; \ + blrl; \ + mtlr r3; \ +779: + +#else +#define MOL_HOOK(num) +#define MOL_HOOK_RESTORE(num) +#define MOL_HOOK_MMU(num, scr) +#define MOL_HOOK_TLBMISS(num) +#endif + + +#endif /* _PPC_KERNEL_MOL */ diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/oak_setup.c linux/arch/ppc/kernel/oak_setup.c --- v2.4.0-test8/linux/arch/ppc/kernel/oak_setup.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/oak_setup.c Sun Sep 17 09:48:07 2000 @@ -231,10 +231,11 @@ /* * Document me. */ -void __init +long __init oak_time_init(void) { /* XXX - Implement me */ + return 0; } /* diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/open_pic.c linux/arch/ppc/kernel/open_pic.c --- v2.4.0-test8/linux/arch/ppc/kernel/open_pic.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/open_pic.c Sun Sep 17 09:48:07 2000 @@ -100,7 +100,7 @@ #ifdef CONFIG_SMP void openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *regs) { - smp_message_recv(cpl-OPENPIC_VEC_IPI); + smp_message_recv(cpl-OPENPIC_VEC_IPI, regs); } #endif /* CONFIG_SMP */ @@ -262,11 +262,11 @@ int j, pri; pri = strcmp(np->name, "programmer-switch") ? 2 : 7; for (j=0;jn_intrs;j++) { - openpic_initirq( np->intrs[j].line, - pri, - np->intrs[j].line, - 0, - np->intrs[j].sense); + openpic_initirq(np->intrs[j].line, + pri, + np->intrs[j].line, + 0, + np->intrs[j].sense); if (np->intrs[j].sense) irq_desc[np->intrs[j].line].status = IRQ_LEVEL; } diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/pci.c linux/arch/ppc/kernel/pci.c --- v2.4.0-test8/linux/arch/ppc/kernel/pci.c Thu Jul 27 17:37:59 2000 +++ linux/arch/ppc/kernel/pci.c Sun Sep 17 09:48:07 2000 @@ -25,7 +25,13 @@ #include "pci.h" -static void __init pcibios_claim_resources(struct list_head *); +#undef DEBUG + +#ifdef DEBUG +#define DBG(x...) printk(x) +#else +#define DBG(x...) +#endif unsigned long isa_io_base = 0; unsigned long isa_mem_base = 0; @@ -70,95 +76,297 @@ generic_pcibios_write_dword }; -void __init pcibios_init(void) -{ - printk("PCI: Probing PCI hardware\n"); - pci_scan_bus(0, &generic_pci_ops, NULL); - if (ppc_md.pcibios_fixup) - ppc_md.pcibios_fixup(); - pcibios_claim_resources(&pci_root_buses); -} -void __init -pcibios_fixup_pbus_ranges(struct pci_bus * bus, struct pbus_set_ranges_data * ranges) + +void pcibios_update_resource(struct pci_dev *dev, struct resource *root, + struct resource *res, int resource) { - ranges->io_start -= bus->resource[0]->start; - ranges->io_end -= bus->resource[0]->start; - ranges->mem_start -= bus->resource[1]->start; - ranges->mem_end -= bus->resource[1]->start; + u32 new, check; + int reg; + + new = res->start | (res->flags & PCI_REGION_FLAG_MASK); + if (resource < 6) { + reg = PCI_BASE_ADDRESS_0 + 4*resource; + } else if (resource == PCI_ROM_RESOURCE) { + res->flags |= PCI_ROM_ADDRESS_ENABLE; + reg = dev->rom_base_reg; + } else { + /* Somebody might have asked allocation of a non-standard resource */ + return; + } + + pci_write_config_dword(dev, reg, new); + pci_read_config_dword(dev, reg, &check); + if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) { + printk(KERN_ERR "PCI: Error while updating region " + "%s/%d (%08x != %08x)\n", dev->slot_name, resource, + new, check); + } } -unsigned long resource_fixup(struct pci_dev * dev, struct resource * res, - unsigned long start, unsigned long size) +/* + * We need to avoid collisions with `mirrored' VGA ports + * and other strange ISA hardware, so we always want the + * addresses to be allocated in the 0x000-0x0ff region + * modulo 0x400. + * + * Why? Because some silly external IO cards only decode + * the low 10 bits of the IO address. The 0x00-0xff region + * is reserved for motherboard devices that decode all 16 + * bits, so it's ok to allocate at, say, 0x2800-0x28ff, + * but we want to try to avoid allocating at 0x2900-0x2bff + * which might have be mirrored at 0x0100-0x03ff.. + */ +void +pcibios_align_resource(void *data, struct resource *res, unsigned long size) { - return start; + struct pci_dev *dev = data; + + if (res->flags & IORESOURCE_IO) { + unsigned long start = res->start; + + if (size > 0x100) { + printk(KERN_ERR "PCI: I/O Region %s/%d too large" + " (%ld bytes)\n", dev->slot_name, + dev->resource - res, size); + } + + if (start & 0x300) { + start = (start + 0x3ff) & ~0x3ff; + res->start = start; + } + } } -static void __init pcibios_claim_resources(struct list_head *bus_list) + +/* + * Handle resources of PCI devices. If the world were perfect, we could + * just allocate all the resource regions and do nothing more. It isn't. + * On the other hand, we cannot just re-allocate all devices, as it would + * require us to know lots of host bridge internals. So we attempt to + * keep as much of the original configuration as possible, but tweak it + * when it's found to be wrong. + * + * Known BIOS problems we have to work around: + * - I/O or memory regions not configured + * - regions configured, but not enabled in the command register + * - bogus I/O addresses above 64K used + * - expansion ROMs left enabled (this may sound harmless, but given + * the fact the PCI specs explicitly allow address decoders to be + * shared between expansion ROMs and other resource regions, it's + * at least dangerous) + * + * Our solution: + * (1) Allocate resources for all buses behind PCI-to-PCI bridges. + * This gives us fixed barriers on where we can allocate. + * (2) Allocate resources for all enabled devices. If there is + * a collision, just mark the resource as unallocated. Also + * disable expansion ROMs during this step. + * (3) Try to allocate resources for disabled devices. If the + * resources were assigned correctly, everything goes well, + * if they weren't, they won't disturb allocation of other + * resources. + * (4) Assign new addresses to resources which were either + * not configured at all or misconfigured. If explicitly + * requested by the user, configure expansion ROM address + * as well. + */ + +static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) { - struct list_head *ln, *dn; + struct list_head *ln; struct pci_bus *bus; struct pci_dev *dev; int idx; + struct resource *r, *pr; + /* Depth-First Search on bus tree */ for (ln=bus_list->next; ln != bus_list; ln=ln->next) { bus = pci_bus_b(ln); - for (dn=bus->devices.next; dn != &bus->devices; dn=dn->next) { - dev = pci_dev_b(dn); - for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) - { - struct resource *r = &dev->resource[idx]; - struct resource *pr; + if ((dev = bus->self)) { + for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) { + r = &dev->resource[idx]; if (!r->start) continue; pr = pci_find_parent_resource(dev, r); if (!pr || request_resource(pr, r) < 0) - { - printk(KERN_ERR "PCI: Address space collision on region %d of device %s\n", idx, dev->name); - /* We probably should disable the region, shouldn't we? */ + printk(KERN_ERR "PCI: Cannot allocate resource region %d of bridge %s\n", idx, dev->slot_name); + } + } + pcibios_allocate_bus_resources(&bus->children); + } +} + +static void __init pcibios_allocate_resources(int pass) +{ + struct pci_dev *dev; + int idx, disabled; + u16 command; + struct resource *r, *pr; + + pci_for_each_dev(dev) { + pci_read_config_word(dev, PCI_COMMAND, &command); + for(idx = 0; idx < 6; idx++) { + r = &dev->resource[idx]; + if (r->parent) /* Already allocated */ + continue; + if (!r->start) /* Address not assigned at all */ + continue; + if (r->end == 0xffffffff) { + /* LongTrail OF quirk: unassigned */ + DBG("PCI: Resource %08lx-%08lx was unassigned\n", r->start, r->end); + r->end -= r->start; + r->start = 0; + continue; + } + + if (r->flags & IORESOURCE_IO) + disabled = !(command & PCI_COMMAND_IO); + else + disabled = !(command & PCI_COMMAND_MEMORY); + if (pass == disabled) { + DBG("PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d)\n", + r->start, r->end, r->flags, disabled, pass); + pr = pci_find_parent_resource(dev, r); + if (!pr || request_resource(pr, r) < 0) { + printk(KERN_ERR "PCI: Cannot allocate resource region %d of device %s\n", idx, dev->slot_name); + /* We'll assign a new address later */ + r->end -= r->start; + r->start = 0; } } } - pcibios_claim_resources(&bus->children); + if (!pass) { + r = &dev->resource[PCI_ROM_RESOURCE]; + if (r->flags & PCI_ROM_ADDRESS_ENABLE) { + /* Turn the ROM off, leave the resource region, but keep it unregistered. */ + u32 reg; + DBG("PCI: Switching off ROM of %s\n", dev->slot_name); + r->flags &= ~PCI_ROM_ADDRESS_ENABLE; + pci_read_config_dword(dev, dev->rom_base_reg, ®); + pci_write_config_dword(dev, dev->rom_base_reg, reg & ~PCI_ROM_ADDRESS_ENABLE); + } + } } } -void __init pcibios_fixup_bus(struct pci_bus *bus) +static void __init pcibios_assign_resources(void) { - if ( ppc_md.pcibios_fixup_bus ) - ppc_md.pcibios_fixup_bus(bus); + struct pci_dev *dev; + int idx; + struct resource *r; + + pci_for_each_dev(dev) { + int class = dev->class >> 8; + + /* Don't touch classless devices and host bridges */ + if (!class || class == PCI_CLASS_BRIDGE_HOST) + continue; + + for(idx=0; idx<6; idx++) { + r = &dev->resource[idx]; + + /* + * Don't touch IDE controllers and I/O ports of video cards! + */ + if ((class == PCI_CLASS_STORAGE_IDE && idx < 4) || + (class == PCI_CLASS_DISPLAY_VGA && (r->flags & IORESOURCE_IO))) + continue; + + /* + * We shall assign a new address to this resource, either because + * the BIOS forgot to do so or because we have decided the old + * address was unusable for some reason. + */ + if (!r->start && r->end) + pci_assign_resource(dev, idx); + } + + if (0) { /* don't assign ROMs */ + r = &dev->resource[PCI_ROM_RESOURCE]; + r->end -= r->start; + r->start = 0; + if (r->end) + pci_assign_resource(dev, PCI_ROM_RESOURCE); + } + } } -char __init *pcibios_setup(char *str) + +int pcibios_enable_resources(struct pci_dev *dev) { - return str; + u16 cmd, old_cmd; + int idx; + struct resource *r; + + pci_read_config_word(dev, PCI_COMMAND, &cmd); + old_cmd = cmd; + for(idx=0; idx<6; idx++) { + r = &dev->resource[idx]; + if (!r->start && r->end) { + printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", dev->slot_name); + return -EINVAL; + } + if (r->flags & IORESOURCE_IO) + cmd |= PCI_COMMAND_IO; + if (r->flags & IORESOURCE_MEM) + cmd |= PCI_COMMAND_MEMORY; + } + if (dev->resource[PCI_ROM_RESOURCE].start) + cmd |= PCI_COMMAND_MEMORY; + if (cmd != old_cmd) { + printk("PCI: Enabling device %s (%04x -> %04x)\n", dev->slot_name, old_cmd, cmd); + pci_write_config_word(dev, PCI_COMMAND, cmd); + } + return 0; +} + + + +void __init pcibios_init(void) +{ + printk("PCI: Probing PCI hardware\n"); + pci_scan_bus(0, &generic_pci_ops, NULL); + if (ppc_md.pcibios_fixup) + ppc_md.pcibios_fixup(); + pcibios_allocate_bus_resources(&pci_root_buses); + pcibios_allocate_resources(0); + pcibios_allocate_resources(1); + pcibios_assign_resources(); } -/* the next two are stolen from the alpha port... */ void __init -pcibios_update_resource(struct pci_dev *dev, struct resource *root, - struct resource *res, int resource) +pcibios_fixup_pbus_ranges(struct pci_bus * bus, struct pbus_set_ranges_data * ranges) { - unsigned long where, size; - u32 reg; + ranges->io_start -= bus->resource[0]->start; + ranges->io_end -= bus->resource[0]->start; + ranges->mem_start -= bus->resource[1]->start; + ranges->mem_end -= bus->resource[1]->start; +} - where = PCI_BASE_ADDRESS_0 + (resource * 4); - size = res->end - res->start; - pci_read_config_dword(dev, where, ®); - reg = (reg & size) | (((u32)(res->start - root->start)) & ~size); - pci_write_config_dword(dev, where, reg); +unsigned long resource_fixup(struct pci_dev * dev, struct resource * res, + unsigned long start, unsigned long size) +{ + return start; } -void __init -pcibios_update_irq(struct pci_dev *dev, int irq) +void __init pcibios_fixup_bus(struct pci_bus *bus) { - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); - /* XXX FIXME - update OF device tree node interrupt property */ + if ( ppc_md.pcibios_fixup_bus ) + ppc_md.pcibios_fixup_bus(bus); } +char __init *pcibios_setup(char *str) +{ + return str; +} + +/* the next one is stolen from the alpha port... */ void __init -pcibios_align_resource(void *data, struct resource *res, unsigned long size) +pcibios_update_irq(struct pci_dev *dev, int irq) { + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); + /* XXX FIXME - update OF device tree node interrupt property */ } int pcibios_enable_device(struct pci_dev *dev) @@ -188,114 +396,26 @@ return 0; } -/* - * Those syscalls are derived from the Alpha versions, they - * allow userland apps to retreive the per-device iobase and - * mem-base. They also provide wrapper for userland to do - * config space accesses. - * The "host_number" returns the number of the Uni-N sub bridge - */ - -asmlinkage int -sys_pciconfig_read(unsigned long bus, unsigned long dfn, - unsigned long off, unsigned long len, - unsigned char *buf) -{ - unsigned char ubyte; - unsigned short ushort; - unsigned int uint; - long err = 0; - - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (!pcibios_present()) - return -ENOSYS; - - switch (len) { - case 1: - err = pcibios_read_config_byte(bus, dfn, off, &ubyte); - put_user(ubyte, buf); - break; - case 2: - err = pcibios_read_config_word(bus, dfn, off, &ushort); - put_user(ushort, (unsigned short *)buf); - break; - case 4: - err = pcibios_read_config_dword(bus, dfn, off, &uint); - put_user(uint, (unsigned int *)buf); - break; - default: - err = -EINVAL; - break; - } - return err; -} - -asmlinkage int -sys_pciconfig_write(unsigned long bus, unsigned long dfn, - unsigned long off, unsigned long len, - unsigned char *buf) -{ - unsigned char ubyte; - unsigned short ushort; - unsigned int uint; - long err = 0; - - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (!pcibios_present()) - return -ENOSYS; - - switch (len) { - case 1: - err = get_user(ubyte, buf); - if (err) - break; - err = pcibios_write_config_byte(bus, dfn, off, ubyte); - if (err != PCIBIOS_SUCCESSFUL) { - err = -EFAULT; - } - break; - case 2: - err = get_user(ushort, (unsigned short *)buf); - if (err) - break; - err = pcibios_write_config_word(bus, dfn, off, ushort); - if (err != PCIBIOS_SUCCESSFUL) { - err = -EFAULT; - } - break; - case 4: - err = get_user(uint, (unsigned int *)buf); - if (err) - break; - err = pcibios_write_config_dword(bus, dfn, off, uint); - if (err != PCIBIOS_SUCCESSFUL) { - err = -EFAULT; - } - break; - default: - err = -EINVAL; - break; - } - return err; -} - void * -pci_dev_io_base(unsigned char bus, unsigned char devfn) +pci_dev_io_base(unsigned char bus, unsigned char devfn, int physical) { - /* Defaults to old way */ - if (!ppc_md.pci_dev_io_base) - return pci_io_base(bus); - return ppc_md.pci_dev_io_base(bus, devfn); + if (!ppc_md.pci_dev_io_base) { + /* Please, someone fix this for non-pmac machines, we + * need either the virtual or physical PCI IO base + */ + return 0; + } + return ppc_md.pci_dev_io_base(bus, devfn, physical); } void * pci_dev_mem_base(unsigned char bus, unsigned char devfn) { /* Default memory base is 0 (1:1 mapping) */ - if (!ppc_md.pci_dev_mem_base) + if (!ppc_md.pci_dev_mem_base) { + /* Please, someone fix this for non-pmac machines.*/ return 0; + } return ppc_md.pci_dev_mem_base(bus, devfn); } @@ -318,15 +438,20 @@ asmlinkage long sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn) { + long result = -EOPNOTSUPP; + switch (which) { case IOBASE_BRIDGE_NUMBER: return (long)pci_dev_root_bridge(bus, devfn); case IOBASE_MEMORY: return (long)pci_dev_mem_base(bus, devfn); case IOBASE_IO: - return (long)pci_dev_io_base(bus, devfn); + result = (long)pci_dev_io_base(bus, devfn, 1); + if (result == 0) + result = -EOPNOTSUPP; + break; } - return -EOPNOTSUPP; + return result; } diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/pmac_backlight.c linux/arch/ppc/kernel/pmac_backlight.c --- v2.4.0-test8/linux/arch/ppc/kernel/pmac_backlight.c Thu Jul 27 17:37:59 2000 +++ linux/arch/ppc/kernel/pmac_backlight.c Sun Sep 17 09:48:07 2000 @@ -41,16 +41,16 @@ #ifdef CONFIG_ADB_PMU /* Special case for the old PowerBook since I can't test on it */ - if ((machine_is_compatible("AAPL,3400/2400") || machine_is_compatible("AAPL,3500") - || machine_is_compatible("AAPL,PowerBook1998") - || machine_is_compatible("AAPL,PowerBook1999")) - && !strcmp(type, "pmu")) + backlight_autosave = machine_is_compatible("AAPL,3400/2400") + || machine_is_compatible("AAPL,3500"); + if ((backlight_autosave + || machine_is_compatible("AAPL,PowerBook1998") + || machine_is_compatible("PowerBook1,1")) + && !strcmp(type, "pmu")) valid = 1; - else #endif - { - if (bk_node) - prop = get_property(bk_node, "backlight-control", NULL); + if (bk_node) { + prop = get_property(bk_node, "backlight-control", NULL); if (prop && !strncmp(prop, type, strlen(type))) valid = 1; } @@ -70,8 +70,6 @@ } #ifdef CONFIG_ADB_PMU - backlight_autosave = machine_is_compatible("AAPL,3400/2400") - || machine_is_compatible("AAPL,3500"); if (backlight_autosave) { struct adb_request req; pmu_request(&req, NULL, 2, 0xd9, 0); diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/pmac_nvram.c linux/arch/ppc/kernel/pmac_nvram.c --- v2.4.0-test8/linux/arch/ppc/kernel/pmac_nvram.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/pmac_nvram.c Sun Sep 17 09:48:07 2000 @@ -312,17 +312,18 @@ __openfirmware unsigned char nvram_read_byte(int addr) { - struct adb_request req; - switch (nvram_naddrs) { #ifdef CONFIG_ADB_PMU - case -1: + case -1: { + struct adb_request req; + if (pmu_request(&req, NULL, 3, PMU_READ_NVRAM, (addr >> 8) & 0xff, addr & 0xff)) break; while (!req.complete) pmu_poll(); return req.reply[1]; + } #endif case 1: if (is_core_99) @@ -339,17 +340,18 @@ __openfirmware void nvram_write_byte(unsigned char val, int addr) { - struct adb_request req; - switch (nvram_naddrs) { #ifdef CONFIG_ADB_PMU - case -1: + case -1: { + struct adb_request req; + if (pmu_request(&req, NULL, 4, PMU_WRITE_NVRAM, (addr >> 8) & 0xff, addr & 0xff, val)) break; while (!req.complete) pmu_poll(); break; + } #endif case 1: if (is_core_99) { diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/pmac_pci.c linux/arch/ppc/kernel/pmac_pci.c --- v2.4.0-test8/linux/arch/ppc/kernel/pmac_pci.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/pmac_pci.c Sun Sep 17 09:48:07 2000 @@ -35,6 +35,7 @@ volatile unsigned int* cfg_addr; volatile unsigned int* cfg_data; void* iobase; + unsigned long iobase_phys; }; static struct uninorth_data uninorth_bridges[3]; @@ -133,15 +134,20 @@ __pmac void * -pmac_pci_dev_io_base(unsigned char bus, unsigned char devfn) +pmac_pci_dev_io_base(unsigned char bus, unsigned char devfn, int physical) { - int bridge; - if (uninorth_count == 0) - return pci_io_base(bus); - bridge = pmac_pci_dev_root_bridge(bus, devfn); - if (bridge == -1) - return pci_io_base(bus); - return uninorth_bridges[bridge].iobase; + int bridge = -1; + if (uninorth_count != 0) + bridge = pmac_pci_dev_root_bridge(bus, devfn); + if (bridge == -1) { + struct bridge_data *bp; + + if (bus > max_bus || (bp = bridges[bus]) == 0) + return 0; + return physical ? (void *) bp->io_base_phys : bp->io_base; + } + return physical ? (void *) uninorth_bridges[bridge].iobase_phys + : uninorth_bridges[bridge].iobase; } __pmac @@ -649,7 +655,9 @@ uninorth_bridges[i].cfg_addr = ioremap(addr->address + 0x800000, 0x1000); uninorth_bridges[i].cfg_data = ioremap(addr->address + 0xc00000, 0x1000); uninorth_bridges[i].node = dev; - uninorth_bridges[i].iobase = (void *)addr->address; + uninorth_bridges[i].iobase_phys = addr->address; + /* is 0x10000 enough for io space ? */ + uninorth_bridges[i].iobase = (void *)ioremap(addr->address, 0x10000); /* XXX This is the bridge with the PCI expansion bus. This is also the * address of the bus that will receive type 1 config accesses and io * accesses. Appears to be correct for iMac DV and G4 Sawtooth too. @@ -667,14 +675,15 @@ if (device_is_compatible(dev, "uni-north")) { bp->cfg_addr = 0; bp->cfg_data = 0; - /* is 0x10000 enough for io space ? */ - bp->io_base = (void *)ioremap(addr->address, 0x10000); + bp->io_base = uninorth_bridges[uninorth_count-1].iobase; + bp->io_base_phys = uninorth_bridges[uninorth_count-1].iobase_phys; } else if (strcmp(dev->name, "pci") == 0) { /* XXX assume this is a mpc106 (grackle) */ bp->cfg_addr = (volatile unsigned int *) ioremap(0xfec00000, 0x1000); bp->cfg_data = (volatile unsigned char *) ioremap(0xfee00000, 0x1000); + bp->io_base_phys = 0xfe000000; bp->io_base = (void *) ioremap(0xfe000000, 0x20000); if (machine_is_compatible("AAPL,PowerBook1998")) grackle_set_loop_snoop(bp, 1); @@ -687,6 +696,7 @@ ioremap(addr->address + 0x800000, 0x1000); bp->cfg_data = (volatile unsigned char *) ioremap(addr->address + 0xc00000, 0x1000); + bp->io_base_phys = addr->address; bp->io_base = (void *) ioremap(addr->address, 0x10000); } if (isa_io_base == 0) diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/pmac_pic.c linux/arch/ppc/kernel/pmac_pic.c --- v2.4.0-test8/linux/arch/ppc/kernel/pmac_pic.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/pmac_pic.c Sun Sep 17 09:48:07 2000 @@ -204,17 +204,12 @@ unsigned long bits = 0; #ifdef CONFIG_SMP - void pmac_smp_message_recv(void); + void pmac_smp_message_recv(struct pt_regs *); /* IPI's are a hack on the powersurge -- Cort */ if ( smp_processor_id() != 0 ) { -#ifdef CONFIG_XMON - static int xmon_2nd; - if (xmon_2nd) - xmon(regs); -#endif - pmac_smp_message_recv(); + pmac_smp_message_recv(regs); return -2; /* ignore, already handled */ } #endif /* CONFIG_SMP */ diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/pmac_setup.c linux/arch/ppc/kernel/pmac_setup.c --- v2.4.0-test8/linux/arch/ppc/kernel/pmac_setup.c Thu Jul 27 17:37:59 2000 +++ linux/arch/ppc/kernel/pmac_setup.c Sun Sep 17 09:48:07 2000 @@ -68,7 +68,7 @@ #undef SHOW_GATWICK_IRQS -extern void pmac_time_init(void); +extern long pmac_time_init(void); extern unsigned long pmac_get_rtc_time(void); extern int pmac_set_rtc_time(unsigned long nowtime); extern void pmac_read_rtc_time(void); @@ -77,24 +77,29 @@ extern int mackbd_setkeycode(unsigned int scancode, unsigned int keycode); extern int mackbd_getkeycode(unsigned int scancode); -extern int mackbd_translate(unsigned char scancode, unsigned char *keycode, - char raw_mode); -extern char mackbd_unexpected_up(unsigned char keycode); +extern int mackbd_translate(unsigned char keycode, unsigned char *keycodep, + char raw_mode); +extern int mackbd_unexpected_up(unsigned char keycode); extern void mackbd_leds(unsigned char leds); -extern void mackbd_init_hw(void); +extern void __init mackbd_init_hw(void); +extern int mac_hid_kbd_translate(unsigned char scancode, unsigned char *keycode, + char raw_mode); +extern char mac_hid_kbd_unexpected_up(unsigned char keycode); +extern void mac_hid_init_hw(void); #ifdef CONFIG_MAGIC_SYSRQ -unsigned char mackbd_sysrq_xlate[128]; +extern unsigned char mac_hid_kbd_sysrq_xlate[128]; +extern unsigned char pckbd_sysrq_xlate[128]; +extern unsigned char mackbd_sysrq_xlate[128]; #endif /* CONFIG_MAGIC_SYSRQ */ extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode); extern int pckbd_getkeycode(unsigned int scancode); extern int pckbd_translate(unsigned char scancode, unsigned char *keycode, char raw_mode); extern char pckbd_unexpected_up(unsigned char keycode); -extern void pckbd_leds(unsigned char leds); -extern void pckbd_init_hw(void); +extern int keyboard_sends_linux_keycodes; extern void pmac_nvram_update(void); -extern void *pmac_pci_dev_io_base(unsigned char bus, unsigned char devfn); +extern void *pmac_pci_dev_io_base(unsigned char bus, unsigned char devfn, int physical); extern void *pmac_pci_dev_mem_base(unsigned char bus, unsigned char devfn); extern int pmac_pci_dev_root_bridge(unsigned char bus, unsigned char devfn); @@ -115,7 +120,6 @@ extern void zs_kgdb_hook(int tty_num); static void ohare_init(void); static void init_p2pbridge(void); -static void init_uninorth(void); #ifdef CONFIG_BOOTX_TEXT void pmac_progress(char *s, unsigned short hex); #endif @@ -276,7 +280,6 @@ pmac_find_bridges(); init_p2pbridge(); - init_uninorth(); /* Checks "l2cr-value" property in the registry */ if ( (_get_PVR() >> 16) == 8 || (_get_PVR() >> 16) == 12 ) { @@ -372,31 +375,6 @@ } } -static void __init -init_uninorth(void) -{ - /* - * Turns OFF the gmac clock. The gmac driver will turn - * it back ON when the interface is enabled. This save - * power on portables. - * - * Note: We could also try to turn OFF the PHY. Since this - * has to be done by both the gmac driver and this code, - * I'll probably end-up moving some of this out of the - * modular gmac driver into a non-modular stub containing - * some basic PHY management and power management stuffs - */ - struct device_node* gmac = find_devices("ethernet"); - - while(gmac) { - if (device_is_compatible(gmac, "gmac")) - break; - gmac = gmac->next; - } - if (gmac) - feature_set_gmac_power(gmac, 0); -} - extern char *bootpath; extern char *bootdevice; void *boot_host; @@ -404,14 +382,15 @@ int boot_part; kdev_t boot_dev; -extern void via_pmu_start(void); - void __init pmac_init2(void) { #ifdef CONFIG_ADB_PMU via_pmu_start(); #endif +#ifdef CONFIG_ADB_CUDA + via_cuda_start(); +#endif #ifdef CONFIG_PMAC_PBOOK media_bay_init(); #endif @@ -683,7 +662,26 @@ ppc_md.pci_dev_mem_base = pmac_pci_dev_mem_base; ppc_md.pci_dev_root_bridge = pmac_pci_dev_root_bridge; -#if defined(CONFIG_VT) && defined(CONFIG_ADB_KEYBOARD) +#ifdef CONFIG_VT +#ifdef CONFIG_INPUT_ADBHID + ppc_md.kbd_init_hw = mac_hid_init_hw; + ppc_md.kbd_translate = mac_hid_kbd_translate; + ppc_md.kbd_unexpected_up = mac_hid_kbd_unexpected_up; + ppc_md.kbd_setkeycode = 0; + ppc_md.kbd_getkeycode = 0; +#ifdef CONFIG_MAGIC_SYSRQ +#ifdef CONFIG_MAC_ADBKEYCODES + if (!keyboard_sends_linux_keycodes) { + ppc_md.ppc_kbd_sysrq_xlate = mac_hid_kbd_sysrq_xlate; + SYSRQ_KEY = 0x69; + } else +#endif /* CONFIG_MAC_ADBKEYCODES */ + { + ppc_md.ppc_kbd_sysrq_xlate = pckbd_sysrq_xlate; + SYSRQ_KEY = 0x54; + } +#endif /* CONFIG_MAGIC_SYSRQ */ +#elif defined(CONFIG_ADB_KEYBOARD) ppc_md.kbd_setkeycode = mackbd_setkeycode; ppc_md.kbd_getkeycode = mackbd_getkeycode; ppc_md.kbd_translate = mackbd_translate; @@ -691,10 +689,11 @@ ppc_md.kbd_leds = mackbd_leds; ppc_md.kbd_init_hw = mackbd_init_hw; #ifdef CONFIG_MAGIC_SYSRQ - ppc_md.ppc_kbd_sysrq_xlate = mackbd_sysrq_xlate; + ppc_md.ppc_kbd_sysrq_xlate = mackbd_sysrq_xlate; SYSRQ_KEY = 0x69; -#endif -#endif +#endif /* CONFIG_MAGIC_SYSRQ */ +#endif /* CONFIG_INPUT_ADBHID/CONFIG_ADB_KEYBOARD */ +#endif /* CONFIG_VT */ #if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC) ppc_ide_md.insw = pmac_ide_insw; diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/pmac_time.c linux/arch/ppc/kernel/pmac_time.c --- v2.4.0-test8/linux/arch/ppc/kernel/pmac_time.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/pmac_time.c Sun Sep 17 09:48:07 2000 @@ -25,7 +25,7 @@ #include #include #include - +#include #include #include @@ -58,7 +58,7 @@ extern struct timezone sys_tz; __init -void pmac_time_init(void) +long pmac_time_init(void) { #ifdef CONFIG_NVRAM s32 delta = 0; @@ -72,17 +72,18 @@ dst = ((pmac_xpram_read(PMAC_XPRAM_MACHINE_LOC + 0x8) & 0x80) != 0); printk("GMT Delta read from XPRAM: %d minutes, DST: %s\n", delta/60, dst ? "on" : "off"); - sys_tz.tz_minuteswest = -delta/60; - /* I _suppose_ this is 0:off, 1:on */ - sys_tz.tz_dsttime = dst; + return delta; +#else + return 0; #endif } __pmac unsigned long pmac_get_rtc_time(void) { -#ifdef CONFIG_ADB +#if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU) struct adb_request req; + unsigned long now; #endif /* Get the time from the RTC */ @@ -96,8 +97,9 @@ if (req.reply_len != 7) printk(KERN_ERR "pmac_get_rtc_time: got %d byte reply\n", req.reply_len); - return (req.reply[3] << 24) + (req.reply[4] << 16) - + (req.reply[5] << 8) + req.reply[6] - RTC_OFFSET; + now = (req.reply[3] << 24) + (req.reply[4] << 16) + + (req.reply[5] << 8) + req.reply[6]; + return now - RTC_OFFSET; #endif /* CONFIG_ADB_CUDA */ #ifdef CONFIG_ADB_PMU case SYS_CTRLER_PMU: @@ -108,21 +110,25 @@ if (req.reply_len != 5) printk(KERN_ERR "pmac_get_rtc_time: got %d byte reply\n", req.reply_len); - return (req.reply[1] << 24) + (req.reply[2] << 16) - + (req.reply[3] << 8) + req.reply[4] - RTC_OFFSET; + now = (req.reply[1] << 24) + (req.reply[2] << 16) + + (req.reply[3] << 8) + req.reply[4]; + return now - RTC_OFFSET; #endif /* CONFIG_ADB_PMU */ default: - return 0; } + return 0; } int pmac_set_rtc_time(unsigned long nowtime) { +#if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU) struct adb_request req; +#endif - nowtime += RTC_OFFSET - sys_tz.tz_minuteswest * 60; + nowtime += RTC_OFFSET; switch (sys_ctrler) { +#ifdef CONFIG_ADB_CUDA case SYS_CTRLER_CUDA: if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME, nowtime >> 24, nowtime >> 16, nowtime >> 8, nowtime) < 0) @@ -133,16 +139,19 @@ printk(KERN_ERR "pmac_set_rtc_time: got %d byte reply\n", req.reply_len); return 1; +#endif /* CONFIG_ADB_CUDA */ +#ifdef CONFIG_ADB_PMU case SYS_CTRLER_PMU: if (pmu_request(&req, NULL, 5, PMU_SET_RTC, nowtime >> 24, nowtime >> 16, nowtime >> 8, nowtime) < 0) return 0; while (!req.complete) pmu_poll(); - if (req.reply_len != 5) + if (req.reply_len != 0) printk(KERN_ERR "pmac_set_rtc_time: got %d byte reply\n", req.reply_len); return 1; +#endif /* CONFIG_ADB_PMU */ default: return 0; } @@ -186,12 +195,11 @@ ; dend = get_dec(); - decrementer_count = (dstart - dend) / 6; - count_period_num = 60; - count_period_den = decrementer_count * 6 * HZ / 100000; + tb_ticks_per_jiffy = (dstart - dend) / 6; + tb_to_us = mulhwu_scale_factor(dstart - dend, 60000); - printk(KERN_INFO "via_calibrate_decr: decrementer_count = %u (%u ticks)\n", - decrementer_count, dstart - dend); + printk(KERN_INFO "via_calibrate_decr: ticks per jiffy = %u (%u ticks)\n", + tb_ticks_per_jiffy, dstart - dend); return 1; } @@ -214,8 +222,11 @@ case PBOOK_WAKE: write_lock_irqsave(&xtime_lock, flags); xtime.tv_sec = pmac_get_rtc_time() + time_diff; + set_dec(tb_ticks_per_jiffy); + /* No currently-supported powerbook has a 601, + so use get_tbl, not native */ + last_jiffy_stamp(0) = tb_last_stamp = get_tbl(); xtime.tv_usec = 0; - set_dec(decrementer_count); last_rtc_update = xtime.tv_sec; write_unlock_irqrestore(&xtime_lock, flags); break; @@ -236,7 +247,7 @@ void __init pmac_calibrate_decr(void) { struct device_node *cpu; - int freq, *fp, divisor; + unsigned int freq, *fp; #ifdef CONFIG_PMAC_PBOOK pmu_register_sleep_notifier(&time_sleep_notifier); @@ -252,15 +263,13 @@ cpu = find_type_devices("cpu"); if (cpu == 0) panic("can't find cpu node in time_init"); - fp = (int *) get_property(cpu, "timebase-frequency", NULL); + fp = (unsigned int *) get_property(cpu, "timebase-frequency", NULL); if (fp == 0) panic("can't get cpu timebase frequency"); - freq = *fp * 60; /* try to make freq/1e6 an integer */ - divisor = 60; - printk("time_init: decrementer frequency = %d/%d\n", - freq, divisor); - decrementer_count = freq / HZ / divisor; - count_period_num = divisor; - count_period_den = freq / 1000000; + freq = *fp; + printk("time_init: decrementer frequency = %u.%.6u MHz\n", + freq/1000000, freq%1000000); + tb_ticks_per_jiffy = freq / HZ; + tb_to_us = mulhwu_scale_factor(freq, 1000000); } diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/ppc_ksyms.c linux/arch/ppc/kernel/ppc_ksyms.c --- v2.4.0-test8/linux/arch/ppc/kernel/ppc_ksyms.c Wed Aug 9 19:19:49 2000 +++ linux/arch/ppc/kernel/ppc_ksyms.c Sun Sep 17 09:48:07 2000 @@ -37,6 +37,7 @@ #include #include #include +#include #ifdef CONFIG_SMP #include #endif /* CONFIG_SMP */ @@ -184,6 +185,10 @@ EXPORT_SYMBOL(enable_kernel_fp); EXPORT_SYMBOL(flush_icache_range); EXPORT_SYMBOL(xchg_u32); +#ifdef CONFIG_ALTIVEC +EXPORT_SYMBOL(last_task_used_altivec); +EXPORT_SYMBOL(giveup_altivec); +#endif /* CONFIG_ALTIVEC */ #ifdef CONFIG_SMP EXPORT_SYMBOL(__global_cli); EXPORT_SYMBOL(__global_sti); @@ -204,26 +209,34 @@ EXPORT_SYMBOL(ppc_md); #ifdef CONFIG_ADB -/* - * This could be more fine-grained, but for now assume if we have - * ADB we have it all -- Cort - */ EXPORT_SYMBOL(adb_request); EXPORT_SYMBOL(adb_register); +EXPORT_SYMBOL(adb_unregister); +EXPORT_SYMBOL(adb_poll); +EXPORT_SYMBOL(adb_try_handler_change); +#endif /* CONFIG_ADB */ +#ifdef CONFIG_ADB_CUDA EXPORT_SYMBOL(cuda_request); EXPORT_SYMBOL(cuda_poll); +#endif /* CONFIG_ADB_CUDA */ #ifdef CONFIG_ADB_PMU EXPORT_SYMBOL(pmu_request); EXPORT_SYMBOL(pmu_poll); #endif /* CONFIG_ADB_PMU */ -#endif /* CONFIG_ADB */ #ifdef CONFIG_PMAC_PBOOK EXPORT_SYMBOL(pmu_register_sleep_notifier); EXPORT_SYMBOL(pmu_unregister_sleep_notifier); EXPORT_SYMBOL(pmu_enable_irled); -#endif CONFIG_PMAC_PBOOK +#endif /* CONFIG_PMAC_PBOOK */ +#ifdef CONFIG_PMAC_BACKLIGHT +EXPORT_SYMBOL(get_backlight_level); +EXPORT_SYMBOL(set_backlight_level); +#endif /* CONFIG_PMAC_BACKLIGHT */ #if defined(CONFIG_ALL_PPC) EXPORT_SYMBOL_NOVERS(sys_ctrler); +#ifndef CONFIG_MACH_SPECIFIC +EXPORT_SYMBOL_NOVERS(have_of); +#endif /* CONFIG_MACH_SPECIFIC */ EXPORT_SYMBOL(find_devices); EXPORT_SYMBOL(find_type_devices); EXPORT_SYMBOL(find_compatible_devices); @@ -253,10 +266,7 @@ EXPORT_SYMBOL(pmac_xpram_read); EXPORT_SYMBOL(pmac_xpram_write); #endif /* CONFIG_NVRAM */ -#ifdef CONFIG_PPC_RTC -EXPORT_SYMBOL(mktime); EXPORT_SYMBOL(to_tm); -#endif EXPORT_SYMBOL_NOVERS(__ashrdi3); EXPORT_SYMBOL_NOVERS(__ashldi3); @@ -280,7 +290,7 @@ EXPORT_SYMBOL(irq_desc); void ppc_irq_dispatch_handler(struct pt_regs *, int); EXPORT_SYMBOL(ppc_irq_dispatch_handler); -EXPORT_SYMBOL(decrementer_count); +EXPORT_SYMBOL(tb_ticks_per_jiffy); EXPORT_SYMBOL(get_wchan); EXPORT_SYMBOL(console_drivers); EXPORT_SYMBOL(console_lock); @@ -310,3 +320,17 @@ EXPORT_SYMBOL(next_mmu_context); EXPORT_SYMBOL(set_context); EXPORT_SYMBOL(mmu_context_overflow); + +#ifdef CONFIG_MOL +extern ulong mol_interface[]; +extern PTE *Hash; +extern unsigned long Hash_mask; +extern void (*ret_from_except)(void); +extern struct task_struct *last_task_used_altivec; +EXPORT_SYMBOL_NOVERS(mol_interface); +EXPORT_SYMBOL(Hash); +EXPORT_SYMBOL(Hash_mask); +EXPORT_SYMBOL(handle_mm_fault); +EXPORT_SYMBOL(last_task_used_math); +EXPORT_SYMBOL(ret_from_except); +#endif /* CONFIG_MOL */ diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/prep_setup.c linux/arch/ppc/kernel/prep_setup.c --- v2.4.0-test8/linux/arch/ppc/kernel/prep_setup.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/prep_setup.c Sun Sep 17 09:48:07 2000 @@ -365,14 +365,13 @@ */ void __init prep_res_calibrate_decr(void) { - int freq, divisor; + unsigned long freq, divisor=4; freq = res->VitalProductData.ProcessorBusHz; - divisor = 4; - printk("time_init: decrementer frequency = %d/%d\n", freq, divisor); - decrementer_count = freq / HZ / divisor; - count_period_num = divisor; - count_period_den = freq / 1000000; + printk("time_init: decrementer frequency = %lu.%.6lu MHz\n", + (freq/divisor)/1000000, (freq/divisor)%1000000); + tb_ticks_per_jiffy = freq / HZ / divisor; + tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000); } /* @@ -381,32 +380,30 @@ * but on prep we have to figure it out. * -- Cort */ -int calibrate_done = 0; -volatile int *done_ptr = &calibrate_done; +/* Done with 3 interrupts: the first one primes the cache and the + * 2 following ones measure the interval. The precision of the method + * is still doubtful due to the short interval sampled. + */ +static __initdata volatile int calibrate_steps = 3; +static __initdata unsigned tbstamp; void __init prep_calibrate_decr_handler(int irq, void *dev, struct pt_regs *regs) { - unsigned long freq, divisor; - static unsigned long t1 = 0, t2 = 0; - - if ( !t1 ) - t1 = get_dec(); - else if (!t2) - { - t2 = get_dec(); - t2 = t1-t2; /* decr's in 1/HZ */ - t2 = t2*HZ; /* # decrs in 1s - thus in Hz */ - freq = t2 * 60; /* try to make freq/1e6 an integer */ - divisor = 60; - printk("time_init: decrementer frequency = %lu/%lu (%luMHz)\n", - freq, divisor,t2>>20); - decrementer_count = freq / HZ / divisor; - count_period_num = divisor; - count_period_den = freq / 1000000; - *done_ptr = 1; + unsigned long t, freq; + int step=--calibrate_steps; + + t = get_tbl(); + if (step > 0) { + tbstamp = t; + } else { + freq = (t - tbstamp)*HZ; + printk("time_init: decrementer frequency = %lu.%.6lu MHz\n", + freq/1000000, freq%1000000); + tb_ticks_per_jiffy = freq / HZ; + tb_to_us = mulhwu_scale_factor(freq, 1000000); } } @@ -428,17 +425,43 @@ if (request_irq(0, prep_calibrate_decr_handler, 0, "timer", NULL) != 0) panic("Could not allocate timer IRQ!"); __sti(); - while ( ! *done_ptr ) /* nothing */; /* wait for calibrate */ + while ( calibrate_steps ) /* nothing */; /* wait for calibrate */ restore_flags(flags); free_irq( 0, NULL); } -/* We use the NVRAM RTC to time a second to calibrate the decrementer. */ +static long __init mk48t59_init(void) { + unsigned char tmp; + + tmp = ppc_md.nvram_read_val(MK48T59_RTC_CONTROLB); + if (tmp & MK48T59_RTC_CB_STOP) { + printk("Warning: RTC was stopped, date will be wrong.\n"); + ppc_md.nvram_write_val(MK48T59_RTC_CONTROLB, + tmp & ~MK48T59_RTC_CB_STOP); + /* Low frequency crystal oscillators may take a very long + * time to startup and stabilize. For now just ignore the + * the issue, but attempting to calibrate the decrementer + * from the RTC just after this wakeup is likely to be very + * inaccurate. Firmware should not allow to load + * the OS with the clock stopped anyway... + */ + } + /* Ensure that the clock registers are updated */ + tmp = ppc_md.nvram_read_val(MK48T59_RTC_CONTROLA); + tmp &= ~(MK48T59_RTC_CA_READ | MK48T59_RTC_CA_WRITE); + ppc_md.nvram_write_val(MK48T59_RTC_CONTROLA, tmp); + return 0; +} + +/* We use the NVRAM RTC to time a second to calibrate the decrementer, + * the RTC registers have just been set up in the right state by the + * preceding routine. + */ void __init mk48t59_calibrate_decr(void) { - unsigned long freq, divisor; - unsigned long t1, t2; + unsigned long freq; + unsigned long t1; unsigned char save_control; long i; unsigned char sec; @@ -458,29 +481,31 @@ /* Read the seconds value to see when it changes. */ sec = ppc_md.nvram_read_val(MK48T59_RTC_SECONDS); + /* Actually this is bad for precision, we should have a loop in + * which we only read the seconds counter. nvram_read_val writes + * the address bytes on every call and this takes a lot of time. + * Perhaps an nvram_wait_change method returning a time + * stamp with a loop count as parameter would be the solution. + */ for (i = 0 ; i < 1000000 ; i++) { /* may take up to 1 second... */ + t1 = get_tbl(); if (ppc_md.nvram_read_val(MK48T59_RTC_SECONDS) != sec) { break; } } - t1 = get_dec(); sec = ppc_md.nvram_read_val(MK48T59_RTC_SECONDS); for (i = 0 ; i < 1000000 ; i++) { /* Should take up 1 second... */ + freq = get_tbl()-t1; if (ppc_md.nvram_read_val(MK48T59_RTC_SECONDS) != sec) { break; } } - t2 = t1 - get_dec(); - - freq = t2 * 60; /* try to make freq/1e6 an integer */ - divisor = 60; - printk("time_init: decrementer frequency = %lu/%lu (%luMHz)\n", - freq, divisor,t2>>20); - decrementer_count = freq / HZ / divisor; - count_period_num = divisor; - count_period_den = freq / 1000000; + printk("time_init: decrementer frequency = %lu.%.6lu MHz\n", + freq/1000000, freq%1000000); + tb_ticks_per_jiffy = freq / HZ; + tb_to_us = mulhwu_scale_factor(freq, 1000000); } void __prep @@ -788,6 +813,7 @@ { ppc_md.set_rtc_time = mk48t59_set_rtc_time; ppc_md.get_rtc_time = mk48t59_get_rtc_time; + ppc_md.time_init = mk48t59_init; } else { @@ -808,6 +834,7 @@ ppc_md.set_rtc_time = mk48t59_set_rtc_time; ppc_md.get_rtc_time = mk48t59_get_rtc_time; ppc_md.calibrate_decr = mk48t59_calibrate_decr; + ppc_md.time_init = mk48t59_init; } #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/prep_time.c linux/arch/ppc/kernel/prep_time.c --- v2.4.0-test8/linux/arch/ppc/kernel/prep_time.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/prep_time.c Sun Sep 17 09:48:07 2000 @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -99,28 +100,34 @@ unsigned long mc146818_get_rtc_time(void) { unsigned int year, mon, day, hour, min, sec; - int i; + int uip, i; /* The Linux interpretation of the CMOS clock register contents: * When the Update-In-Progress (UIP) flag goes from 1 to 0, the * RTC registers show the second which has precisely just started. * Let's hope other operating systems interpret the RTC the same way. */ - /* read RTC exactly on falling edge of update flag */ - for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */ - if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) - break; - for (i = 0 ; i < 1000000 ; i++) /* must try at least 2.228 ms */ - if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)) - break; - do { /* Isn't this overkill ? UIP above should guarantee consistency */ + + /* Since the UIP flag is set for about 2.2 ms and the clock + * is typically written with a precision of 1 jiffy, trying + * to obtain a precision better than a few milliseconds is + * an illusion. Only consistency is interesting, this also + * allows to use the routine for /dev/rtc without a potential + * 1 second kernel busy loop triggered by any reader of /dev/rtc. + */ + + for ( i = 0; i<1000000; i++) { + uip = CMOS_READ(RTC_FREQ_SELECT); sec = CMOS_READ(RTC_SECONDS); min = CMOS_READ(RTC_MINUTES); hour = CMOS_READ(RTC_HOURS); day = CMOS_READ(RTC_DAY_OF_MONTH); mon = CMOS_READ(RTC_MONTH); year = CMOS_READ(RTC_YEAR); - } while (sec != CMOS_READ(RTC_SECONDS)); + uip |= CMOS_READ(RTC_FREQ_SELECT); + if ((uip & RTC_UIP)==0) break; + } + if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { @@ -177,28 +184,11 @@ { unsigned char save_control; unsigned int year, mon, day, hour, min, sec; - int i; - /* Make sure the time is not stopped. */ - save_control = ppc_md.nvram_read_val(MK48T59_RTC_CONTROLB); - - ppc_md.nvram_write_val(MK48T59_RTC_CONTROLA, - (save_control & (~MK48T59_RTC_CB_STOP))); - - /* Now make sure the read bit is off so the value will change. */ + /* Simple: freeze the clock, read it and allow updates again */ save_control = ppc_md.nvram_read_val(MK48T59_RTC_CONTROLA); save_control &= ~MK48T59_RTC_CA_READ; ppc_md.nvram_write_val(MK48T59_RTC_CONTROLA, save_control); - - /* Read the seconds value to see when it changes. */ - sec = ppc_md.nvram_read_val(MK48T59_RTC_SECONDS); - - /* Wait until the seconds value changes, then read the value. */ - for (i = 0 ; i < 1000000 ; i++) { /* may take up to 1 second... */ - if (ppc_md.nvram_read_val(MK48T59_RTC_SECONDS) != sec) { - break; - } - } /* Set the register to read the value. */ ppc_md.nvram_write_val(MK48T59_RTC_CONTROLA, diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/process.c linux/arch/ppc/kernel/process.c --- v2.4.0-test8/linux/arch/ppc/kernel/process.c Fri Sep 8 13:27:11 2000 +++ linux/arch/ppc/kernel/process.c Sun Sep 17 09:48:07 2000 @@ -234,7 +234,6 @@ prev->thread.vrsave ) giveup_altivec(prev); #endif /* CONFIG_ALTIVEC */ - prev->last_processor = prev->processor; current_set[smp_processor_id()] = new; #endif /* CONFIG_SMP */ /* Avoid the trap. On smp this this never happens since @@ -266,7 +265,7 @@ last_task_used_altivec); #ifdef CONFIG_SMP - printk(" CPU: %d last CPU: %d", current->processor,current->last_processor); + printk(" CPU: %d", current->processor); #endif /* CONFIG_SMP */ printk("\n"); @@ -379,9 +378,6 @@ childregs->msr &= ~MSR_VEC; #endif /* CONFIG_ALTIVEC */ -#ifdef CONFIG_SMP - p->last_processor = NO_PROC_ID; -#endif /* CONFIG_SMP */ return 0; } @@ -441,8 +437,8 @@ current->thread.fpscr = 0; } -asmlinkage int sys_clone(int p1, int p2, int p3, int p4, int p5, int p6, - struct pt_regs *regs) +int sys_clone(int p1, int p2, int p3, int p4, int p5, int p6, + struct pt_regs *regs) { unsigned long clone_flags = p1; int res; @@ -460,8 +456,8 @@ return res; } -asmlinkage int sys_fork(int p1, int p2, int p3, int p4, int p5, int p6, - struct pt_regs *regs) +int sys_fork(int p1, int p2, int p3, int p4, int p5, int p6, + struct pt_regs *regs) { int res; @@ -478,15 +474,15 @@ return res; } -asmlinkage int sys_vfork(int p1, int p2, int p3, int p4, int p5, int p6, - struct pt_regs *regs) +int sys_vfork(int p1, int p2, int p3, int p4, int p5, int p6, + struct pt_regs *regs) { return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->gpr[1], regs, 0); } -asmlinkage int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2, - unsigned long a3, unsigned long a4, unsigned long a5, - struct pt_regs *regs) +int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2, + unsigned long a3, unsigned long a4, unsigned long a5, + struct pt_regs *regs) { int error; char * filename; diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/prom.c linux/arch/ppc/kernel/prom.c --- v2.4.0-test8/linux/arch/ppc/kernel/prom.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/prom.c Sun Sep 17 09:48:07 2000 @@ -140,8 +140,7 @@ static long g_max_loc_X = 0; static long g_max_loc_Y = 0; -unsigned long disp_BATL = 0; -unsigned long disp_BATU = 0; +unsigned long disp_BAT[2] = {0, 0}; #define cmapsz (16*256) @@ -276,8 +275,7 @@ prom_drawstring(msg); #endif return; - } - + } for (p = msg; *p != 0; p = q) { for (q = p; *q != 0 && *q != '\n'; ++q) @@ -362,7 +360,7 @@ /* copy the holding pattern code to someplace safe (0) */ /* the holding pattern is now within the first 0x100 bytes of the kernel image -- paulus */ - memcpy((void *)0, KERNELBASE + offset, 0x100); + memcpy((void *)0, (void *)(KERNELBASE + offset), 0x100); flush_icache_range(0, 0x100); /* look for cpus */ @@ -556,6 +554,54 @@ } #endif /* CONFIG_PPC64BRIDGE */ +static __init void +prom_instantiate_rtas(void) +{ + ihandle prom_rtas; + unsigned int i; + struct prom_args prom_args; + unsigned long offset = reloc_offset(); + + prom_rtas = call_prom(RELOC("finddevice"), 1, 1, RELOC("/rtas")); + if (prom_rtas == (void *) -1) + return; + + RELOC(rtas_size) = 0; + call_prom(RELOC("getprop"), 4, 1, prom_rtas, + RELOC("rtas-size"), &RELOC(rtas_size), sizeof(rtas_size)); + prom_print(RELOC("instantiating rtas")); + if (RELOC(rtas_size) == 0) { + RELOC(rtas_data) = 0; + } else { + /* + * Ask OF for some space for RTAS. + * Actually OF has bugs so we just arbitrarily + * use memory at the 6MB point. + */ + RELOC(rtas_data) = 6 << 20; + prom_print(RELOC(" at ")); + prom_print_hex(RELOC(rtas_data)); + } + + prom_rtas = call_prom(RELOC("open"), 1, 1, RELOC("/rtas")); + prom_print(RELOC("...")); + prom_args.service = RELOC("call-method"); + prom_args.nargs = 3; + prom_args.nret = 2; + prom_args.args[0] = RELOC("instantiate-rtas"); + prom_args.args[1] = prom_rtas; + prom_args.args[2] = (void *) RELOC(rtas_data); + RELOC(prom)(&prom_args); + i = 0; + if (prom_args.args[3] == 0) + i = (unsigned int)prom_args.args[4]; + RELOC(rtas_entry) = i; + if ((RELOC(rtas_entry) == -1) || (RELOC(rtas_entry) == 0)) + prom_print(RELOC(" failed\n")); + else + prom_print(RELOC(" done\n")); +} + /* * We enter here early on, when the Open Firmware prom is still * handling exceptions and the MMU hash table for us. @@ -566,7 +612,7 @@ { int chrp = 0; unsigned long mem; - ihandle prom_rtas, prom_mmu, prom_op; + ihandle prom_mmu, prom_op; unsigned long offset = reloc_offset(); int l; char *p, *d; @@ -650,47 +696,7 @@ mem = ALIGN(mem + strlen(d) + 1); } - prom_rtas = call_prom(RELOC("finddevice"), 1, 1, RELOC("/rtas")); - if (prom_rtas != (void *) -1) { - int i, nargs; - struct prom_args prom_args; - - RELOC(rtas_size) = 0; - call_prom(RELOC("getprop"), 4, 1, prom_rtas, - RELOC("rtas-size"), &RELOC(rtas_size), sizeof(rtas_size)); - prom_print(RELOC("instantiating rtas")); - if (RELOC(rtas_size) == 0) { - RELOC(rtas_data) = 0; - } else { - /* - * Ask OF for some space for RTAS. - * Actually OF has bugs so we just arbitrarily - * use memory at the 6MB point. - */ - RELOC(rtas_data) = 6 << 20; - prom_print(RELOC(" at ")); - prom_print_hex(RELOC(rtas_data)); - } - prom_rtas = call_prom(RELOC("open"), 1, 1, RELOC("/rtas")); - prom_print(RELOC("...")); - nargs = 3; - prom_args.service = RELOC("call-method"); - prom_args.nargs = nargs; - prom_args.nret = 2; - prom_args.args[0] = RELOC("instantiate-rtas"); - prom_args.args[1] = prom_rtas; - prom_args.args[2] = (void *) RELOC(rtas_data); - RELOC(prom)(&prom_args); - if (prom_args.args[nargs] != 0) - i = 0; - else - i = (int)prom_args.args[nargs+1]; - RELOC(rtas_entry) = i; - if ((RELOC(rtas_entry) == -1) || (RELOC(rtas_entry) == 0)) - prom_print(RELOC(" failed\n")); - else - prom_print(RELOC(" done\n")); - } + prom_instantiate_rtas(); #ifdef CONFIG_PPC64BRIDGE /* @@ -737,7 +743,7 @@ /* We assume the phys. address size is 3 cells */ if (prom_args.args[nargs] != 0) - prom_print(RELOC(" (translate failed) ")); + prom_print(RELOC(" (translate failed)\n")); else phys = (unsigned long)prom_args.args[nargs+3]; } @@ -752,8 +758,6 @@ if (prom_version >= 3) { prom_print(RELOC("Calling quiesce ...\n")); call_prom(RELOC("quiesce"), 0, 0); - offset = reloc_offset(); - phys = offset + KERNELBASE; } #ifdef CONFIG_BOOTX_TEXT @@ -769,7 +773,9 @@ } #endif - prom_print(RELOC("returning from prom_init\n")); + prom_print(RELOC("returning ")); + prom_print_hex(phys); + prom_print(RELOC(" from prom_init\n")); RELOC(prom_stdout) = 0; return phys; } @@ -836,9 +842,8 @@ } /* Calc BAT values for mapping the display and store them - * in disp_BATH and disp_BATL. Those values are then used - * from head.S to map the display during identify_machine() - * and MMU_Init() + * in disp_BAT. Those values are then used from head.S to map + * the display during identify_machine() and MMU_Init() * * For now, the display is mapped in place (1:1). This should * be changed if the display physical address overlaps @@ -862,13 +867,13 @@ if ((_get_PVR() >> 16) != 1) { /* 603, 604, G3, G4, ... */ addr &= 0xFF000000UL; - RELOC(disp_BATU) = addr | (BL_16M<<2) | 2; - RELOC(disp_BATL) = addr | (_PAGE_NO_CACHE | _PAGE_GUARDED | BPP_RW); + RELOC(disp_BAT[0]) = addr | (BL_16M<<2) | 2; + RELOC(disp_BAT[1]) = addr | (_PAGE_NO_CACHE | _PAGE_GUARDED | BPP_RW); } else { /* 601 */ addr &= 0xFF800000UL; - RELOC(disp_BATU) = addr | (_PAGE_NO_CACHE | PP_RWXX) | 4; - RELOC(disp_BATL) = addr | BL_8M | 0x40; + RELOC(disp_BAT[0]) = addr | (_PAGE_NO_CACHE | PP_RWXX) | 4; + RELOC(disp_BAT[1]) = addr | BL_8M | 0x40; } bi->logicalDisplayBase = bi->dispDeviceBase; } @@ -1003,34 +1008,52 @@ unsigned address; boot_infos_t* bi; unsigned long offset = reloc_offset(); - - prom_print(RELOC("Initializing fake screen\n")); - - call_prom(RELOC("getprop"), 4, 1, dp, RELOC("width"), - &width, sizeof(width)); - call_prom(RELOC("getprop"), 4, 1, dp, RELOC("height"), - &height, sizeof(height)); - call_prom(RELOC("getprop"), 4, 1, dp, RELOC("depth"), - &depth, sizeof(depth)); + struct pci_reg_property addrs[8]; + int i, naddrs; + char name[32]; + char *getprop = RELOC("getprop"); + + prom_print(RELOC("Initializing fake screen: ")); + + memset(name, 0, sizeof(name)); + call_prom(getprop, 4, 1, dp, RELOC("name"), name, sizeof(name)); + name[sizeof(name)-1] = 0; + prom_print(name); + prom_print(RELOC("\n")); + call_prom(getprop, 4, 1, dp, RELOC("width"), &width, sizeof(width)); + call_prom(getprop, 4, 1, dp, RELOC("height"), &height, sizeof(height)); + call_prom(getprop, 4, 1, dp, RELOC("depth"), &depth, sizeof(depth)); pitch = width * ((depth + 7) / 8); - call_prom(RELOC("getprop"), 4, 1, dp, RELOC("linebytes"), + call_prom(getprop, 4, 1, dp, RELOC("linebytes"), &pitch, sizeof(pitch)); - address = 0; - if (pitch == 1) { - address = 0xfa000000; + if (pitch == 1) pitch = 0x1000; /* for strange IBM display */ - } - call_prom(RELOC("getprop"), 4, 1, dp, RELOC("address"), + address = 0; + call_prom(getprop, 4, 1, dp, RELOC("address"), &address, sizeof(address)); if (address == 0) { - prom_print(RELOC("Failed to get address\n")); - return; + /* look for an assigned address with a size of >= 1MB */ + naddrs = (int) call_prom(getprop, 4, 1, dp, + RELOC("assigned-addresses"), + addrs, sizeof(addrs)); + naddrs /= sizeof(struct pci_reg_property); + for (i = 0; i < naddrs; ++i) { + if (addrs[i].size_lo >= (1 << 20)) { + address = addrs[i].addr.a_lo; + /* use the BE aperture if possible */ + if (addrs[i].size_lo >= (16 << 20)) + address += (8 << 20); + break; + } + } + if (address == 0) { + prom_print(RELOC("Failed to get address\n")); + return; + } } -#if 0 /* kludge for valkyrie */ - if (strcmp(dp->name, "valkyrie") == 0) - address += 0x1000; -#endif + if (strcmp(name, RELOC("valkyrie")) == 0) + address += 0x1000; RELOC(disp_bi) = &fake_bi; bi = PTRRELOC((&fake_bi)); @@ -1334,11 +1357,19 @@ */ if (get_property(node, "interrupt-controller", &l)) { int i,j; + int cvt_irq; + + /* XXX on chrp, offset interrupt numbers for the + 8259 by 0, those for the openpic by 16 */ + cvt_irq = _machine == _MACH_chrp + && get_property(node, "interrupt-parent", NULL) == 0; np->intrs = (struct interrupt_info *) mem_start; np->n_intrs = ipsize / isize; mem_start += np->n_intrs * sizeof(struct interrupt_info); for (i = 0; i < np->n_intrs; ++i) { np->intrs[i].line = *interrupts++; + if (cvt_irq) + np->intrs[i].line = openpic_to_irq(np->intrs[i].line); np->intrs[i].sense = 0; if (isize > 1) np->intrs[i].sense = *interrupts++; @@ -2072,7 +2103,6 @@ * changes. */ -__init void map_bootx_text(void) { @@ -2083,7 +2113,10 @@ offset = ((unsigned long) disp_bi->dispDeviceBase) - base; size = disp_bi->dispDeviceRowBytes * disp_bi->dispDeviceRect[3] + offset + disp_bi->dispDeviceRect[0]; - disp_bi->logicalDisplayBase = ioremap(base, size) + offset; + disp_bi->logicalDisplayBase = ioremap(base, size); + if (disp_bi->logicalDisplayBase == 0) + return; + disp_bi->logicalDisplayBase += offset; bootx_text_mapped = 1; } @@ -2102,6 +2135,35 @@ return base; } +/* Adjust the display to a new resolution */ +void +bootx_update_display(unsigned long phys, int width, int height, + int depth, int pitch) +{ + if (disp_bi == 0) + return; + /* check it's the same frame buffer (within 16MB) */ + if ((phys ^ (unsigned long)disp_bi->dispDeviceBase) & 0xff000000) + return; + + disp_bi->dispDeviceBase = (__u8 *) phys; + disp_bi->dispDeviceRect[0] = 0; + disp_bi->dispDeviceRect[1] = 0; + disp_bi->dispDeviceRect[2] = width; + disp_bi->dispDeviceRect[3] = height; + disp_bi->dispDeviceDepth = depth; + disp_bi->dispDeviceRowBytes = pitch; + if (bootx_text_mapped) { + iounmap(disp_bi->logicalDisplayBase); + bootx_text_mapped = 0; + } + map_bootx_text(); + g_loc_X = 0; + g_loc_Y = 0; + g_max_loc_X = width / 8; + g_max_loc_Y = height / 16; +} + __pmac static void clearscreen(void) @@ -2162,6 +2224,9 @@ (bi->dispDeviceDepth >> 3)) >> 2; int i,j; +#ifdef CONFIG_ADB_PMU + pmu_suspend(); /* PMU will not shut us down ! */ +#endif for (i=0; i<(bi->dispDeviceRect[3] - bi->dispDeviceRect[1] - 16); i++) { unsigned long *src_ptr = src; @@ -2178,6 +2243,9 @@ *(dst_ptr++) = 0; dst += (bi->dispDeviceRowBytes >> 2); } +#ifdef CONFIG_ADB_PMU + pmu_resume(); /* PMU will not shut us down ! */ +#endif } #endif /* ndef NO_SCROLL */ diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/setup.c linux/arch/ppc/kernel/setup.c --- v2.4.0-test8/linux/arch/ppc/kernel/setup.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/setup.c Sun Sep 17 09:48:07 2000 @@ -35,6 +35,8 @@ #include #include #include +#include + #ifdef CONFIG_OAK #include "oak_setup.h" #endif /* CONFIG_OAK */ @@ -655,16 +657,18 @@ } /* Checks "l2cr=xxxx" command-line option */ -void ppc_setup_l2cr(char *str, int *ints) +int ppc_setup_l2cr(char *str) { if ( ((_get_PVR() >> 16) == 8) || ((_get_PVR() >> 16) == 12) ) { unsigned long val = simple_strtoul(str, NULL, 0); printk(KERN_INFO "l2cr set to %lx\n", val); - _set_L2CR(0); - _set_L2CR(val); + _set_L2CR(0); /* force invalidate by disable cache */ + _set_L2CR(val); /* and enable it */ } + return 1; } +__setup("l2cr=", ppc_setup_l2cr); void __init ppc_init(void) { @@ -683,6 +687,9 @@ extern char *klimit; extern void do_init_bootmem(void); + /* so udelay does something sensible, assume <= 1000 bogomips */ + loops_per_sec = 500000000; + #ifdef CONFIG_ALL_PPC feature_init(); #endif @@ -737,6 +744,7 @@ if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab); paging_init(); + sort_exception_table(); } void ppc_generic_ide_fix_driveid(struct hd_driveid *id) diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/signal.c linux/arch/ppc/kernel/signal.c --- v2.4.0-test8/linux/arch/ppc/kernel/signal.c Fri Sep 8 13:27:11 2000 +++ linux/arch/ppc/kernel/signal.c Sun Sep 17 09:48:07 2000 @@ -154,7 +154,7 @@ } -asmlinkage int +int sys_sigaltstack(const stack_t *uss, stack_t *uoss) { struct pt_regs *regs = (struct pt_regs *) &uss; @@ -232,7 +232,7 @@ * Each of these things must be a multiple of 16 bytes in size. * */ -asmlinkage int sys_rt_sigreturn(struct pt_regs *regs) +int sys_rt_sigreturn(struct pt_regs *regs) { struct rt_sigframe *rt_sf; struct sigcontext_struct sigctx; @@ -301,7 +301,6 @@ return ret; badframe: - lock_kernel(); do_exit(SIGSEGV); } @@ -351,7 +350,6 @@ printk("badframe in setup_rt_frame, regs=%p frame=%p newsp=%lx\n", regs, frame, newsp); #endif - lock_kernel(); do_exit(SIGSEGV); } @@ -418,7 +416,6 @@ return ret; badframe: - lock_kernel(); do_exit(SIGSEGV); } @@ -460,7 +457,6 @@ printk("badframe in setup_frame, regs=%p frame=%p newsp=%lx\n", regs, frame, newsp); #endif - lock_kernel(); do_exit(SIGSEGV); } @@ -541,7 +537,6 @@ regs, frame, *newspp); printk("sc=%p sig=%d ka=%p info=%p oldset=%p\n", sc, sig, ka, info, oldset); #endif - lock_kernel(); do_exit(SIGSEGV); } @@ -645,7 +640,6 @@ /* FALLTHRU */ default: - lock_kernel(); sigaddset(¤t->pending.signal, signr); recalc_sigpending(current); current->flags |= PF_SIGNALED; @@ -663,6 +657,7 @@ /* Whee! Actually deliver the signal. */ handle_signal(signr, ka, &info, oldset, regs, &newsp, frame); + break; } if (regs->trap == 0x0C00 /* System Call! */ && diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/smp.c linux/arch/ppc/kernel/smp.c --- v2.4.0-test8/linux/arch/ppc/kernel/smp.c Fri Sep 8 13:27:11 2000 +++ linux/arch/ppc/kernel/smp.c Sun Sep 17 09:48:07 2000 @@ -62,72 +62,62 @@ int start_secondary(void *); extern int cpu_idle(void *unused); u_int openpic_read(volatile u_int *addr); +void smp_call_function_interrupt(void); +void smp_message_pass(int target, int msg, unsigned long data, int wait); +/* register for interrupting the primary processor on the powersurge */ +/* N.B. this is actually the ethernet ROM! */ +#define PSURGE_PRI_INTR 0xf3019000 /* register for interrupting the secondary processor on the powersurge */ -#define PSURGE_INTR ((volatile unsigned *)0xf80000c0) +#define PSURGE_SEC_INTR 0xf80000c0 +/* register for storing the start address for the secondary processor */ +#define PSURGE_START 0xf2800000 +/* virtual addresses for the above */ +volatile u32 *psurge_pri_intr; +volatile u32 *psurge_sec_intr; +volatile u32 *psurge_start; + +/* Since OpenPIC has only 4 IPIs, we use slightly different message numbers. */ +#define PPC_MSG_CALL_FUNCTION 0 +#define PPC_MSG_RESCHEDULE 1 +#define PPC_MSG_INVALIDATE_TLB 2 +#define PPC_MSG_XMON_BREAK 3 + +static inline void set_tb(unsigned int upper, unsigned int lower) +{ + mtspr(SPRN_TBWU, upper); + mtspr(SPRN_TBWL, lower); +} void smp_local_timer_interrupt(struct pt_regs * regs) { int cpu = smp_processor_id(); - extern void update_one_process(struct task_struct *,unsigned long, - unsigned long,unsigned long,int); - if (!--prof_counter[cpu]) { - int user=0,system=0; - struct task_struct * p = current; - - /* - * After doing the above, we need to make like - * a normal interrupt - otherwise timer interrupts - * ignore the global interrupt lock, which is the - * WrongThing (tm) to do. - */ - - if (user_mode(regs)) - user=1; - else - system=1; - - if (p->pid) { - update_one_process(p, 1, user, system, cpu); - - p->counter -= 1; - if (p->counter <= 0) { - p->counter = 0; - current->need_resched = 1; - } - if (p->nice > 0) { - kstat.cpu_nice += user; - kstat.per_cpu_nice[cpu] += user; - } else { - kstat.cpu_user += user; - kstat.per_cpu_user[cpu] += user; - } - - kstat.cpu_system += system; - kstat.per_cpu_system[cpu] += system; - } + if (!--prof_counter[cpu]) { + update_process_times(user_mode(regs)); prof_counter[cpu]=prof_multiplier[cpu]; } } -void smp_message_recv(int msg) +void smp_message_recv(int msg, struct pt_regs *regs) { ipi_count++; - switch( msg ) - { - case MSG_STOP_CPU: - __cli(); - while (1) ; + switch( msg ) { + case PPC_MSG_CALL_FUNCTION: + smp_call_function_interrupt(); break; - case MSG_RESCHEDULE: + case PPC_MSG_RESCHEDULE: current->need_resched = 1; break; - case MSG_INVALIDATE_TLB: + case PPC_MSG_INVALIDATE_TLB: _tlbia(); - case 0xf0f0: /* pmac syncing time bases - just return */ break; +#ifdef CONFIG_XMON + case PPC_MSG_XMON_BREAK: + xmon(regs); + break; +#endif /* CONFIG_XMON */ default: printk("SMP %d: smp_message_recv(): unknown msg %d\n", smp_processor_id(), msg); @@ -142,25 +132,38 @@ * smp_message[]. * * This is because don't have several IPI's on the PowerSurge even though - * we do on the chrp. It would be nice to use actual IPI's such as with openpic - * rather than this. + * we do on the chrp. It would be nice to use actual IPI's such as with + * openpic rather than this. * -- Cort */ int pmac_smp_message[NR_CPUS]; -void pmac_smp_message_recv(void) +void pmac_smp_message_recv(struct pt_regs *regs) { - int msg = pmac_smp_message[smp_processor_id()]; - + int cpu = smp_processor_id(); + int msg; + /* clear interrupt */ - out_be32(PSURGE_INTR, ~0); - - /* make sure msg is for us */ - if ( msg == -1 ) return; + if (cpu == 1) + out_be32(psurge_sec_intr, ~0); + + if (smp_num_cpus < 2) + return; + + /* make sure there is a message there */ + msg = pmac_smp_message[cpu]; + if (msg == 0) + return; - smp_message_recv(msg); - /* reset message */ - pmac_smp_message[smp_processor_id()] = -1; + pmac_smp_message[cpu] = 0; + + smp_message_recv(msg - 1, regs); +} + +void +pmac_primary_intr(int irq, void *d, struct pt_regs *regs) +{ + pmac_smp_message_recv(regs); } /* @@ -171,7 +174,7 @@ void smp_send_tlb_invalidate(int cpu) { if ( (_get_PVR()>>16) == 8 ) - smp_message_pass(MSG_ALL_BUT_SELF, MSG_INVALIDATE_TLB, 0, 0); + smp_message_pass(MSG_ALL_BUT_SELF, PPC_MSG_INVALIDATE_TLB, 0, 0); } void smp_send_reschedule(int cpu) @@ -187,18 +190,135 @@ */ /* This is only used if `cpu' is running an idle task, so it will reschedule itself anyway... */ - smp_message_pass(cpu, MSG_RESCHEDULE, 0, 0); + smp_message_pass(cpu, PPC_MSG_RESCHEDULE, 0, 0); +} + +#ifdef CONFIG_XMON +void smp_send_xmon_break(int cpu) +{ + smp_message_pass(cpu, PPC_MSG_XMON_BREAK, 0, 0); +} +#endif /* CONFIG_XMON */ + +static void stop_this_cpu(void *dummy) +{ + __cli(); + while (1) + ; } void smp_send_stop(void) { - smp_message_pass(MSG_ALL_BUT_SELF, MSG_STOP_CPU, 0, 0); + smp_call_function(stop_this_cpu, NULL, 1, 0); + smp_num_cpus = 1; +} + +/* + * Structure and data for smp_call_function(). This is designed to minimise + * static memory requirements. It also looks cleaner. + * Stolen from the i386 version. + */ +static spinlock_t call_lock = SPIN_LOCK_UNLOCKED; + +static volatile struct call_data_struct { + void (*func) (void *info); + void *info; + atomic_t started; + atomic_t finished; + int wait; +} *call_data = NULL; + +/* + * this function sends a 'generic call function' IPI to all other CPUs + * in the system. + */ + +int smp_call_function (void (*func) (void *info), void *info, int nonatomic, + int wait) +/* + * [SUMMARY] Run a function on all other CPUs. + * The function to run. This must be fast and non-blocking. + * An arbitrary pointer to pass to the function. + * currently unused. + * If true, wait (atomically) until function has completed on other CPUs. + * [RETURNS] 0 on success, else a negative status code. Does not return until + * remote CPUs are nearly ready to execute <> or are or have executed. + * + * You must not call this function with disabled interrupts or from a + * hardware interrupt handler, you may call it from a bottom half handler. + */ +{ + struct call_data_struct data; + int ret = -1, cpus = smp_num_cpus-1; + int timeout; + + if (!cpus) + return 0; + + data.func = func; + data.info = info; + atomic_set(&data.started, 0); + data.wait = wait; + if (wait) + atomic_set(&data.finished, 0); + + spin_lock_bh(&call_lock); + call_data = &data; + /* Send a message to all other CPUs and wait for them to respond */ + smp_message_pass(MSG_ALL_BUT_SELF, PPC_MSG_CALL_FUNCTION, 0, 0); + + /* Wait for response */ + timeout = 1000000; + while (atomic_read(&data.started) != cpus) { + if (--timeout == 0) { + printk("smp_call_function on cpu %d: other cpus not responding (%d)\n", + smp_processor_id(), atomic_read(&data.started)); + goto out; + } + barrier(); + udelay(1); + } + + if (wait) { + timeout = 1000000; + while (atomic_read(&data.finished) != cpus) { + if (--timeout == 0) { + printk("smp_call_function on cpu %d: other cpus not finishing (%d/%d)\n", + smp_processor_id(), atomic_read(&data.finished), atomic_read(&data.started)); + goto out; + } + barrier(); + udelay(1); + } + } + ret = 0; + + out: + spin_unlock_bh(&call_lock); + return ret; +} + +void smp_call_function_interrupt(void) +{ + void (*func) (void *info) = call_data->func; + void *info = call_data->info; + int wait = call_data->wait; + + /* + * Notify initiating CPU that I've grabbed the data and am + * about to execute the function + */ + atomic_inc(&call_data->started); + /* + * At this point the info structure may be out of scope unless wait==1 + */ + (*func)(info); + if (wait) + atomic_inc(&call_data->finished); } void smp_message_pass(int target, int msg, unsigned long data, int wait) { - int i; - if ( !(_machine & (_MACH_Pmac|_MACH_chrp|_MACH_prep|_MACH_gemini)) ) return; @@ -212,31 +332,29 @@ * the recipient won't know the message was destined * for it. -- Cort */ - for ( i = 0; i <= smp_num_cpus ; i++ ) - pmac_smp_message[i] = -1; - switch( target ) - { - case MSG_ALL: - pmac_smp_message[smp_processor_id()] = msg; - /* fall through */ - case MSG_ALL_BUT_SELF: - for ( i = 0 ; i < smp_num_cpus ; i++ ) - if ( i != smp_processor_id () ) - pmac_smp_message[i] = msg; - break; - default: - pmac_smp_message[target] = msg; - break; + if (smp_processor_id() == 0) { + /* primary cpu */ + if (target == 1 || target == MSG_ALL_BUT_SELF + || target == MSG_ALL) { + pmac_smp_message[1] = msg + 1; + /* interrupt secondary processor */ + out_be32(psurge_sec_intr, ~0); + out_be32(psurge_sec_intr, 0); + } + } else { + /* secondary cpu */ + if (target == 0 || target == MSG_ALL_BUT_SELF + || target == MSG_ALL) { + pmac_smp_message[0] = msg + 1; + /* interrupt primary processor */ + in_be32(psurge_pri_intr); + } + } + if (target == smp_processor_id() || target == MSG_ALL) { + /* sending a message to ourself */ + /* XXX maybe we shouldn't do this if ints are off */ + smp_message_recv(msg, NULL); } - /* interrupt secondary processor */ - out_be32(PSURGE_INTR, ~0); - out_be32(PSURGE_INTR, 0); - /* - * Assume for now that the secondary doesn't send - * IPI's -- Cort - */ - /* interrupt primary */ - /**(volatile unsigned long *)(0xf3019000);*/ break; case _MACH_chrp: case _MACH_prep: @@ -261,7 +379,7 @@ #else /* CONFIG_POWER4 */ /* for now, only do reschedule messages since we only have one IPI */ - if (msg != MSG_RESCHEDULE) + if (msg != PPC_MSG_RESCHEDULE) break; for (i = 0; i < smp_num_cpus; ++i) { if (target == MSG_ALL || target == i @@ -319,7 +437,10 @@ { case _MACH_Pmac: /* assume powersurge board - 2 processors -- Cort */ - cpu_nr = 2; + cpu_nr = 2; + psurge_pri_intr = ioremap(PSURGE_PRI_INTR, 4); + psurge_sec_intr = ioremap(PSURGE_SEC_INTR, 4); + psurge_start = ioremap(PSURGE_START, 4); break; case _MACH_chrp: if (OpenPIC) @@ -370,13 +491,11 @@ { case _MACH_Pmac: /* setup entry point of secondary processor */ - *(volatile unsigned long *)(0xf2800000) = - (unsigned long)__secondary_start_psurge-KERNELBASE; - eieio(); + out_be32(psurge_start, __pa(__secondary_start_psurge)); /* interrupt secondary to begin executing code */ - out_be32(PSURGE_INTR, ~0); + out_be32(psurge_sec_intr, ~0); udelay(1); - out_be32(PSURGE_INTR, 0); + out_be32(psurge_sec_intr, 0); break; case _MACH_chrp: *(unsigned long *)KERNELBASE = i; @@ -399,9 +518,6 @@ if ( cpu_callin_map[i] ) { printk("Processor %d found.\n", i); - /* this sync's the decr's -- Cort */ - if ( _machine == _MACH_Pmac ) - set_dec(decrementer_count); smp_num_cpus++; } else { printk("Processor %d is stuck.\n", i); @@ -415,9 +531,25 @@ { /* reset the entry point so if we get another intr we won't * try to startup again */ - *(volatile unsigned long *)(0xf2800000) = 0x100; - /* send interrupt to other processors to start decr's on all cpus */ - smp_message_pass(1,0xf0f0, 0, 0); + out_be32(psurge_start, 0x100); + if (request_irq(30, pmac_primary_intr, 0, "primary IPI", 0)) + printk(KERN_ERR "Couldn't get primary IPI interrupt"); + /* + * The decrementers of both cpus are frozen at this point + * until we give the secondary cpu another interrupt. + * We set them both to decrementer_count and then send + * the interrupt. This should get the decrementers + * synchronized. + * -- paulus. + */ + set_dec(tb_ticks_per_jiffy); + if ((_get_PVR() >> 16) != 1) { + set_tb(0, 0); /* set timebase if not 601 */ + last_jiffy_stamp(0) = 0; + } + out_be32(psurge_sec_intr, ~0); + udelay(1); + out_be32(psurge_sec_intr, 0); } } @@ -447,8 +579,11 @@ void __init smp_callin(void) { smp_store_cpu_info(current->processor); - set_dec(decrementer_count); - + set_dec(tb_ticks_per_jiffy); + if (_machine == _MACH_Pmac && (_get_PVR() >> 16) != 1) { + set_tb(0, 0); /* set timebase if not 601 */ + last_jiffy_stamp(current->processor) = 0; + } init_idle(); cpu_callin_map[current->processor] = 1; diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/syscalls.c linux/arch/ppc/kernel/syscalls.c --- v2.4.0-test8/linux/arch/ppc/kernel/syscalls.c Thu Jul 27 17:37:59 2000 +++ linux/arch/ppc/kernel/syscalls.c Sun Sep 17 09:48:07 2000 @@ -45,7 +45,7 @@ { } -asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on) +int sys_ioperm(unsigned long from, unsigned long num, int on) { printk(KERN_ERR "sys_ioperm()\n"); return -EIO; @@ -74,7 +74,7 @@ * * This is really horribly ugly. */ -asmlinkage int +int sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth) { int version, ret; @@ -172,7 +172,7 @@ * sys_pipe() is the normal C calling standard for creating * a pipe. It's not the way unix traditionally does this, though. */ -asmlinkage int sys_pipe(int *fildes) +int sys_pipe(int *fildes) { int fd[2]; int error; @@ -185,19 +185,19 @@ return error; } -asmlinkage unsigned long sys_mmap(unsigned long addr, size_t len, - unsigned long prot, unsigned long flags, - unsigned long fd, off_t offset) +unsigned long sys_mmap(unsigned long addr, size_t len, + unsigned long prot, unsigned long flags, + unsigned long fd, off_t offset) { struct file * file = NULL; int ret = -EBADF; + flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); if (!(flags & MAP_ANONYMOUS)) { if (!(file = fget(fd))) goto out; } - flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); down(¤t->mm->mmap_sem); ret = do_mmap(file, addr, len, prot, flags, offset); up(¤t->mm->mmap_sem); @@ -207,7 +207,7 @@ return ret; } -extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +extern int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); /* * Due to some executables calling the wrong select we sometimes @@ -215,7 +215,7 @@ * (a single ptr to them all args passed) then calls * sys_select() with the appropriate args. -- Cort */ -asmlinkage int +int ppc_select(int n, fd_set *inp, fd_set *outp, fd_set *exp, struct timeval *tvp) { if ( (unsigned long)n >= 4096 ) @@ -232,14 +232,14 @@ return sys_select(n, inp, outp, exp, tvp); } -asmlinkage int sys_pause(void) +int sys_pause(void) { current->state = TASK_INTERRUPTIBLE; schedule(); return -ERESTARTNOHAND; } -asmlinkage int sys_uname(struct old_utsname * name) +int sys_uname(struct old_utsname * name) { int err = -EFAULT; @@ -250,7 +250,7 @@ return err; } -asmlinkage int sys_olduname(struct oldold_utsname * name) +int sys_olduname(struct oldold_utsname * name) { int error; diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/time.c linux/arch/ppc/kernel/time.c --- v2.4.0-test8/linux/arch/ppc/kernel/time.c Fri Jul 14 12:12:06 2000 +++ linux/arch/ppc/kernel/time.c Sun Sep 17 09:48:07 2000 @@ -6,6 +6,27 @@ * Paul Mackerras' version and mine for PReP and Pmac. * MPC8xx/MBX changes by Dan Malek (dmalek@jlc.net). * + * First round of bugfixes by Gabriel Paubert (paubert@iram.es) + * to make clock more stable (2.4.0-test5). The only thing + * that this code assumes is that the timebases have been synchronized + * by firmware on SMP and are never stopped (never do sleep + * on SMP then, nap and doze are OK). + * + * TODO (not necessarily in this file): + * - improve precision and reproducibility of timebase frequency + * measurement at boot time. + * - get rid of xtime_lock for gettimeofday (generic kernel problem + * to be implemented on all architectures for SMP scalability and + * eventually implementing gettimeofday without entering the kernel). + * - put all time/clock related variables in a single structure + * to minimize number of cache lines touched by gettimeofday() + * - for astronomical applications: add a new function to get + * non ambiguous timestamps even around leap seconds. This needs + * a new timestamp format and a good name. + * + * + * The following comment is partially obsolete (at least the long wait + * is no more a valid reason): * Since the MPC8xx has a programmable interrupt timer, I decided to * use that rather than the decrementer. Two reasons: 1.) the clock * frequency is low, causing 2.) a long wait in the timer interrupt @@ -49,18 +70,32 @@ void smp_local_timer_interrupt(struct pt_regs *); /* keep track of when we need to update the rtc */ -time_t last_rtc_update = 0; +time_t last_rtc_update; extern rwlock_t xtime_lock; /* The decrementer counts down by 128 every 128ns on a 601. */ #define DECREMENTER_COUNT_601 (1000000000 / HZ) -#define COUNT_PERIOD_NUM_601 1 -#define COUNT_PERIOD_DEN_601 1000 -unsigned decrementer_count; /* count value for 1e6/HZ microseconds */ -unsigned count_period_num; /* 1 decrementer count equals */ -unsigned count_period_den; /* count_period_num / count_period_den us */ -unsigned long last_tb; +unsigned tb_ticks_per_jiffy; +unsigned tb_to_us; +unsigned tb_last_stamp; + +extern unsigned long wall_jiffies; + +static long time_offset; + +/* Timer interrupt helper function */ +static inline int tb_delta(unsigned *jiffy_stamp) { + int delta; + if (__USE_RTC()) { + delta = get_rtcl(); + if (delta < *jiffy_stamp) *jiffy_stamp -= 1000000000; + delta -= *jiffy_stamp; + } else { + delta = get_tbl() - *jiffy_stamp; + } + return delta; +} /* * timer_interrupt - gets called when the decrementer overflows, @@ -69,88 +104,56 @@ */ int timer_interrupt(struct pt_regs * regs) { - int dval, d; -#if 0 - unsigned long flags; -#endif + int next_dec; unsigned long cpu = smp_processor_id(); - + unsigned jiffy_stamp = last_jiffy_stamp(cpu); + hardirq_enter(cpu); -#ifdef CONFIG_SMP - { - unsigned int loops = 100000000; - while (test_bit(0, &global_irq_lock)) { - if (smp_processor_id() == global_irq_holder) { - printk("uh oh, interrupt while we hold global irq lock!\n"); -#ifdef CONFIG_XMON - xmon(0); -#endif - break; - } - if (loops-- == 0) { - printk("do_IRQ waiting for irq lock (holder=%d)\n", global_irq_holder); -#ifdef CONFIG_XMON - xmon(0); -#endif - } - } - } -#endif /* CONFIG_SMP */ - dval = get_dec(); - /* - * Wait for the decrementer to change, then jump - * in and add decrementer_count to its value - * (quickly, before it changes again!) - */ - while ((d = get_dec()) == dval) - ; - asm volatile("mftb %0" : "=r" (last_tb) ); - /* - * Don't play catchup between the call to time_init() - * and sti() in init/main.c. - * - * This also means if we're delayed for > HZ - * we lose those ticks. If we're delayed for > HZ - * then we have something wrong anyway, though. - * - * -- Cort - */ - if ( d < (-1*decrementer_count) ) - d = 0; - set_dec(d + decrementer_count); - if ( !smp_processor_id() ) - { + do { + jiffy_stamp += tb_ticks_per_jiffy; + if (smp_processor_id()) continue; + /* We are in an interrupt, no need to save/restore flags */ + write_lock(&xtime_lock); + tb_last_stamp = jiffy_stamp; do_timer(regs); -#if 0 - /* -- BenH -- I'm removing this for now since it can cause various - * troubles with local-time RTCs. Now that we have a - * /dev/rtc that uses ppc_md.set_rtc_time() on mac, it - * should be possible to program the RTC from userland - * in all cases. - */ + /* - * update the rtc when needed + * update the rtc when needed, this should be performed on the + * right fraction of a second. Half or full second ? + * Full second works on mk48t59 clocks, others need testing. + * Note that this update is basically only used through + * the adjtimex system calls. Setting the HW clock in + * any other way is a /dev/rtc and userland business. + * This is still wrong by -0.5/+1.5 jiffies because of the + * timer interrupt resolution and possible delay, but here we + * hit a quantization limit which can only be solved by higher + * resolution timers and decoupling time management from timer + * interrupts. This is also wrong on the clocks + * which require being written at the half second boundary. + * We should have an rtc call that only sets the minutes and + * seconds like on Intel to avoid problems with non UTC clocks. */ - read_lock_irqsave(&xtime_lock, flags); - if ( (time_status & STA_UNSYNC) && - ((xtime.tv_sec > last_rtc_update + 60) || - (xtime.tv_sec < last_rtc_update)) ) - { - if (ppc_md.set_rtc_time(xtime.tv_sec) == 0) - last_rtc_update = xtime.tv_sec; + if ( (time_status & STA_UNSYNC) == 0 && + xtime.tv_sec - last_rtc_update >= 659 && + abs(xtime.tv_usec - (1000000-1000000/HZ)) < 500000/HZ && + jiffies - wall_jiffies == 1) { + if (ppc_md.set_rtc_time(xtime.tv_sec+1 + time_offset) == 0) + last_rtc_update = xtime.tv_sec+1; else - /* do it again in 60 s */ - last_rtc_update = xtime.tv_sec; + /* Try again one minute later */ + last_rtc_update += 60; } - read_unlock_irqrestore(&xtime_lock, flags); -#endif - } + write_unlock(&xtime_lock); + } while((next_dec = tb_ticks_per_jiffy - tb_delta(&jiffy_stamp)) < 0); + set_dec(next_dec); + last_jiffy_stamp(cpu) = jiffy_stamp; + #ifdef CONFIG_SMP smp_local_timer_interrupt(regs); #endif - if ( ppc_md.heartbeat && !ppc_md.heartbeat_count--) + if (ppc_md.heartbeat && !ppc_md.heartbeat_count--) ppc_md.heartbeat(); hardirq_exit(cpu); @@ -162,106 +165,138 @@ */ void do_gettimeofday(struct timeval *tv) { - unsigned long flags, diff; + unsigned long flags; + unsigned delta, lost_ticks, usec, sec; - save_flags(flags); - cli(); read_lock_irqsave(&xtime_lock, flags); - *tv = xtime; + sec = xtime.tv_sec; + usec = xtime.tv_usec; + delta = tb_ticks_since(tb_last_stamp); +#ifdef CONFIG_SMP + /* As long as timebases are not in sync, gettimeofday can only + * have jiffy resolution on SMP. + */ + if (_machine != _MACH_Pmac) + delta = 0; +#endif /* CONFIG_SMP */ + lost_ticks = jiffies - wall_jiffies; read_unlock_irqrestore(&xtime_lock, flags); - /* XXX we don't seem to have the decrementers synced properly yet */ -#ifndef CONFIG_SMP - asm volatile("mftb %0" : "=r" (diff) ); - diff -= last_tb; - tv->tv_usec += diff * count_period_num / count_period_den; - tv->tv_sec += tv->tv_usec / 1000000; - tv->tv_usec = tv->tv_usec % 1000000; -#endif - - restore_flags(flags); + + usec += mulhwu(tb_to_us, tb_ticks_per_jiffy * lost_ticks + delta); + while (usec > 1000000) { + sec++; + usec -= 1000000; + } + tv->tv_sec = sec; + tv->tv_usec = usec; } void do_settimeofday(struct timeval *tv) { unsigned long flags; - int frac_tick; - - last_rtc_update = 0; /* so the rtc gets updated soon */ - - frac_tick = tv->tv_usec % (1000000 / HZ); - save_flags(flags); - cli(); + int tb_delta, new_usec, new_sec; + write_lock_irqsave(&xtime_lock, flags); - xtime.tv_sec = tv->tv_sec; - xtime.tv_usec = tv->tv_usec - frac_tick; - write_unlock_irqrestore(&xtime_lock, flags); - set_dec(frac_tick * count_period_den / count_period_num); + /* Updating the RTC is not the job of this code. If the time is + * stepped under NTP, the RTC will be update after STA_UNSYNC + * is cleared. Tool like clock/hwclock either copy the RTC + * to the system time, in which case there is no point in writing + * to the RTC again, or write to the RTC but then they don't call + * settimeofday to perform this operation. Note also that + * we don't touch the decrementer since: + * a) it would lose timer interrupt synchronization on SMP + * (if it is working one day) + * b) it could make one jiffy spuriously shorter or longer + * which would introduce another source of uncertainty potentially + * harmful to relatively short timers. + */ + + /* This works perfectly on SMP only if the tb are in sync but + * guarantees an error < 1 jiffy even if they are off by eons, + * still reasonable when gettimeofday resolution is 1 jiffy. + */ + tb_delta = tb_ticks_since(last_jiffy_stamp(smp_processor_id())); + tb_delta += (jiffies - wall_jiffies) * tb_ticks_per_jiffy; + new_sec = tv->tv_sec; + new_usec = tv->tv_usec - mulhwu(tb_to_us, tb_delta); + while (new_usec <0) { + new_sec--; + new_usec += 1000000; + } + xtime.tv_usec = new_usec; + xtime.tv_sec = new_sec; + + /* In case of a large backwards jump in time with NTP, we want the + * clock to be updated as soon as the PLL is again in lock. + */ + last_rtc_update = new_sec - 658; + time_adjust = 0; /* stop active adjtime() */ time_status |= STA_UNSYNC; time_state = TIME_ERROR; /* p. 24, (a) */ time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; - restore_flags(flags); + write_unlock_irqrestore(&xtime_lock, flags); } void __init time_init(void) { + time_t sec, old_sec; + unsigned old_stamp, stamp, elapsed; + /* This function is only called on the boot processor */ unsigned long flags; + if (ppc_md.time_init != NULL) - { - ppc_md.time_init(); - } + time_offset = ppc_md.time_init(); - if ((_get_PVR() >> 16) == 1) { + if (__USE_RTC()) { /* 601 processor: dec counts down by 128 every 128ns */ - decrementer_count = DECREMENTER_COUNT_601; - count_period_num = COUNT_PERIOD_NUM_601; - count_period_den = COUNT_PERIOD_DEN_601; - } else if (!smp_processor_id()) { + tb_ticks_per_jiffy = DECREMENTER_COUNT_601; + /* mulhwu_scale_factor(1000000000, 1000000) is 0x418937 */ + tb_to_us = 0x418937; + } else { ppc_md.calibrate_decr(); } + /* Now that the decrementer is calibrated, it can be used in case the + * clock is stuck, but the fact that we have to handle the 601 + * makes things more complex. Repeatedly read the RTC until the + * next second boundary to try to achieve some precision... + */ + stamp = get_native_tbl(); + sec = ppc_md.get_rtc_time(); + elapsed = 0; + do { + old_stamp = stamp; + old_sec = sec; + stamp = get_native_tbl(); + if (__USE_RTC() && stamp < old_stamp) old_stamp -= 1000000000; + elapsed += stamp - old_stamp; + sec = ppc_md.get_rtc_time(); + } while ( sec == old_sec && elapsed < 2*HZ*tb_ticks_per_jiffy); + if (sec==old_sec) { + printk("Warning: real time clock seems stuck!\n"); + } write_lock_irqsave(&xtime_lock, flags); - xtime.tv_sec = ppc_md.get_rtc_time(); + xtime.tv_sec = sec; + last_jiffy_stamp(0) = tb_last_stamp = stamp; xtime.tv_usec = 0; + /* No update now, we just read the time from the RTC ! */ + last_rtc_update = xtime.tv_sec; write_unlock_irqrestore(&xtime_lock, flags); + /* Not exact, but the timer interrupt takes care of this */ + set_dec(tb_ticks_per_jiffy); - set_dec(decrementer_count); - /* allow setting the time right away */ - last_rtc_update = 0; -} - -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ + /* If platform provided a timezone (pmac), we correct the time + * using do_sys_settimeofday() which in turn calls warp_clock() + */ + if (time_offset) { + struct timezone tz; + tz.tz_minuteswest = -time_offset / 60; + tz.tz_dsttime = 0; + do_sys_settimeofday(NULL, &tz); + } } #define TICK_SIZE tick @@ -354,3 +389,31 @@ */ GregorianDay(tm); } + +/* Auxiliary function to compute scaling factors */ +/* Actually the choice of a timebase running at 1/4 the of the bus + * frequency giving resolution of a few tens of nanoseconds is quite nice. + * It makes this computation very precise (27-28 bits typically) which + * is optimistic considering the stability of most processor clock + * oscillators and the precision with which the timebase frequency + * is measured but does not harm. + */ +unsigned mulhwu_scale_factor(unsigned inscale, unsigned outscale) { + unsigned mlt=0, tmp, err; + /* No concern for performance, it's done once: use a stupid + * but safe and compact method to find the multiplier. + */ + for (tmp = 1U<<31; tmp != 0; tmp >>= 1) { + if (mulhwu(inscale, mlt|tmp) < outscale) mlt|=tmp; + } + /* We might still be off by 1 for the best approximation. + * A side effect of this is that if outscale is too large + * the returned value will be zero. + * Many corner cases have been checked and seem to work, + * some might have been forgotten in the test however. + */ + err = inscale*(mlt+1); + if (err <= inscale/2) mlt++; + return mlt; +} + diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/traps.c linux/arch/ppc/kernel/traps.c --- v2.4.0-test8/linux/arch/ppc/kernel/traps.c Tue May 23 15:31:34 2000 +++ linux/arch/ppc/kernel/traps.c Sun Sep 17 09:48:07 2000 @@ -87,45 +87,76 @@ void MachineCheckException(struct pt_regs *regs) { - if ( !user_mode(regs) ) - { -#if defined(CONFIG_8xx) && defined(CONFIG_PCI) - /* the qspan pci read routines can cause machine checks -- Cort */ - bad_page_fault(regs, regs->dar); +#ifdef CONFIG_ALL_PPC + unsigned long fixup; +#endif /* CONFIG_ALL_PPC */ + + if (user_mode(regs)) { + _exception(SIGSEGV, regs); return; + } + +#if defined(CONFIG_8xx) && defined(CONFIG_PCI) + /* the qspan pci read routines can cause machine checks -- Cort */ + bad_page_fault(regs, regs->dar); + return; #endif #if defined(CONFIG_XMON) || defined(CONFIG_KGDB) - if (debugger_fault_handler) { - debugger_fault_handler(regs); - return; - } + if (debugger_fault_handler) { + debugger_fault_handler(regs); + return; + } #endif - printk("Machine check in kernel mode.\n"); - printk("Caused by (from SRR1=%lx): ", regs->msr); - switch (regs->msr & 0xF0000) { - case 0x80000: - printk("Machine check signal\n"); - break; - case 0x40000: - printk("Transfer error ack signal\n"); - break; - case 0x20000: - printk("Data parity error signal\n"); - break; - case 0x10000: - printk("Address parity error signal\n"); - break; - default: - printk("Unknown values in msr\n"); + +#ifdef CONFIG_ALL_PPC + /* + * I/O accesses can cause machine checks on powermacs. + * Check if the NIP corresponds to the address of a sync + * instruction for which there is an entry in the exception + * table. + */ + if (regs->msr & (0x80000 | 0x40000) + && (fixup = search_exception_table(regs->nip)) != 0) { + /* + * Check that it's a sync instruction. + * As the address is in the exception table + * we should be able to read the instr there. + */ + if (*(unsigned int *)regs->nip == 0x7c0004ac) { + unsigned int lsi = ((unsigned int *)regs->nip)[-1]; + int rb = (lsi >> 11) & 0x1f; + printk(KERN_DEBUG "%s bad port %lx at %lx\n", + (lsi & 0x100)? "OUT to": "IN from", + regs->gpr[rb] - _IO_BASE, regs->nip); + regs->nip = fixup; + return; } - show_regs(regs); + } +#endif /* CONFIG_ALL_PPC */ + printk("Machine check in kernel mode.\n"); + printk("Caused by (from SRR1=%lx): ", regs->msr); + switch (regs->msr & 0xF0000) { + case 0x80000: + printk("Machine check signal\n"); + break; + case 0x40000: + printk("Transfer error ack signal\n"); + break; + case 0x20000: + printk("Data parity error signal\n"); + break; + case 0x10000: + printk("Address parity error signal\n"); + break; + default: + printk("Unknown values in msr\n"); + } + show_regs(regs); #if defined(CONFIG_XMON) || defined(CONFIG_KGDB) - debugger(regs); + debugger(regs); #endif - print_backtrace((unsigned long *)regs->gpr[1]); - panic("machine check"); - } - _exception(SIGSEGV, regs); + print_backtrace((unsigned long *)regs->gpr[1]); + panic("machine check"); } void @@ -166,6 +197,46 @@ _exception(SIGTRAP, regs); } +/* Illegal instruction emulation support. Originally written to + * provide the PVR to user applications using the mfspr rd, PVR. + * Return non-zero if we can't emulate, or EFAULT if the associated + * memory access caused an access fault. Return zero on success. + * + * There are a couple of ways to do this, either "decode" the instruction + * or directly match lots of bits. In this case, matching lots of + * bits is faster and easier. + * + */ +#define INST_MFSPR_PVR 0x7c1f42a6 +#define INST_MFSPR_PVR_MASK 0xfc1fffff + +static int +emulate_instruction(struct pt_regs *regs) +{ + uint instword; + uint rd; + uint retval; + + retval = EFAULT; + + if (!user_mode(regs)) + return retval; + + if (get_user(instword, (uint *)(regs->nip))) + return retval; + + /* Emulate the mfspr rD, PVR. + */ + if ((instword & INST_MFSPR_PVR_MASK) == INST_MFSPR_PVR) { + rd = (instword >> 21) & 0x1f; + regs->gpr[rd] = _get_PVR(); + retval = 0; + } + if (retval == 0) + regs->nip += 4; + return(retval); +} + void ProgramCheckException(struct pt_regs *regs) { @@ -193,7 +264,14 @@ #endif _exception(SIGTRAP, regs); } else { - _exception(SIGILL, regs); + /* Try to emulate it if we should. */ + int errcode; + if ((errcode = emulate_instruction(regs))) { + if (errcode == EFAULT) + _exception(SIGBUS, regs); + else + _exception(SIGILL, regs); + } } #endif } diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/walnut_setup.c linux/arch/ppc/kernel/walnut_setup.c --- v2.4.0-test8/linux/arch/ppc/kernel/walnut_setup.c Fri Jul 14 12:12:07 2000 +++ linux/arch/ppc/kernel/walnut_setup.c Sun Sep 17 09:48:07 2000 @@ -226,10 +226,11 @@ /* * Document me. */ -void __init +long __init walnut_time_init(void) { /* XXX - Implement me */ + return 0; } /* diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/kernel/xics.c linux/arch/ppc/kernel/xics.c --- v2.4.0-test8/linux/arch/ppc/kernel/xics.c Fri Jun 23 21:55:07 2000 +++ linux/arch/ppc/kernel/xics.c Sun Sep 17 09:48:07 2000 @@ -166,7 +166,7 @@ void xics_ipi_action(int irq, void *dev_id, struct pt_regs *regs) { qirr_info(smp_processor_id()) = 0xff; - smp_message_recv(MSG_RESCHEDULE); + smp_message_recv(MSG_RESCHEDULE, regs); } void xics_cause_IPI(int cpu) diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/lib/string.S linux/arch/ppc/lib/string.S --- v2.4.0-test8/linux/arch/ppc/lib/string.S Sun Feb 13 19:29:03 2000 +++ linux/arch/ppc/lib/string.S Sun Sep 17 09:48:07 2000 @@ -12,10 +12,70 @@ #include #include -CACHELINE_BYTES = 32 -LG_CACHELINE_BYTES = 5 -CACHELINE_MASK = 0x1f -CACHELINE_WORDS = 8 +#if defined(CONFIG_4xx) || defined(CONFIG_8xx) +#define CACHE_LINE_SIZE 16 +#define LG_CACHE_LINE_SIZE 4 +#define MAX_COPY_PREFETCH 1 +#elif !defined(CONFIG_PPC64BRIDGE) +#define CACHE_LINE_SIZE 32 +#define LG_CACHE_LINE_SIZE 5 +#define MAX_COPY_PREFETCH 4 +#else +#define CACHE_LINE_SIZE 128 +#define LG_CACHE_LINE_SIZE 7 +#define MAX_COPY_PREFETCH 1 +#endif /* CONFIG_4xx || CONFIG_8xx */ + +#define COPY_16_BYTES \ + lwz r7,4(r4); \ + lwz r8,8(r4); \ + lwz r9,12(r4); \ + lwzu r10,16(r4); \ + stw r7,4(r6); \ + stw r8,8(r6); \ + stw r9,12(r6); \ + stwu r10,16(r6) + +#define COPY_16_BYTES_WITHEX(n) \ +8 ## n ## 0: \ + lwz r7,4(r4); \ +8 ## n ## 1: \ + lwz r8,8(r4); \ +8 ## n ## 2: \ + lwz r9,12(r4); \ +8 ## n ## 3: \ + lwzu r10,16(r4); \ +8 ## n ## 4: \ + stw r7,4(r6); \ +8 ## n ## 5: \ + stw r8,8(r6); \ +8 ## n ## 6: \ + stw r9,12(r6); \ +8 ## n ## 7: \ + stwu r10,16(r6) + +#define COPY_16_BYTES_EXCODE(n) \ +9 ## n ## 0: \ + addi r5,r5,-(16 * n); \ + b 104f; \ +9 ## n ## 1: \ + addi r5,r5,-(16 * n); \ + b 105f; \ +.section __ex_table,"a"; \ + .align 2; \ + .long 8 ## n ## 0b,9 ## n ## 0b; \ + .long 8 ## n ## 1b,9 ## n ## 0b; \ + .long 8 ## n ## 2b,9 ## n ## 0b; \ + .long 8 ## n ## 3b,9 ## n ## 0b; \ + .long 8 ## n ## 4b,9 ## n ## 1b; \ + .long 8 ## n ## 5b,9 ## n ## 1b; \ + .long 8 ## n ## 6b,9 ## n ## 1b; \ + .long 8 ## n ## 7b,9 ## n ## 1b; \ +.text + +CACHELINE_BYTES = CACHE_LINE_SIZE +LG_CACHELINE_BYTES = LG_CACHE_LINE_SIZE +CACHELINE_MASK = (CACHE_LINE_SIZE-1) .globl strcpy strcpy: @@ -105,7 +165,14 @@ bdnz 4b 3: mtctr r9 li r7,4 +#if !defined(CONFIG_8xx) 10: dcbz r7,r6 +#else +10: stw r4, 4(r6) + stw r4, 8(r6) + stw r4, 12(r6) + stw r4, 16(r6) +#endif addi r6,r6,CACHELINE_BYTES bdnz 10b clrlwi r5,r8,32-LG_CACHELINE_BYTES @@ -202,23 +269,24 @@ li r11,4 mtctr r0 beq 63f -53: dcbz r11,r6 - lwz r7,4(r4) - lwz r8,8(r4) - lwz r9,12(r4) - lwzu r10,16(r4) - stw r7,4(r6) - stw r8,8(r6) - stw r9,12(r6) - stwu r10,16(r6) - lwz r7,4(r4) - lwz r8,8(r4) - lwz r9,12(r4) - lwzu r10,16(r4) - stw r7,4(r6) - stw r8,8(r6) - stw r9,12(r6) - stwu r10,16(r6) +53: +#if !defined(CONFIG_8xx) + dcbz r11,r6 +#endif + COPY_16_BYTES +#if CACHE_LINE_SIZE >= 32 + COPY_16_BYTES +#if CACHE_LINE_SIZE >= 64 + COPY_16_BYTES + COPY_16_BYTES +#if CACHE_LINE_SIZE >= 128 + COPY_16_BYTES + COPY_16_BYTES + COPY_16_BYTES + COPY_16_BYTES +#endif +#endif +#endif bdnz 53b 63: srwi. r0,r5,2 @@ -380,25 +448,59 @@ 58: srwi. r0,r5,LG_CACHELINE_BYTES /* # complete cachelines */ clrlwi r5,r5,32-LG_CACHELINE_BYTES li r11,4 - mtctr r0 beq 63f -53: dcbz r11,r6 -10: lwz r7,4(r4) -11: lwz r8,8(r4) -12: lwz r9,12(r4) -13: lwzu r10,16(r4) -14: stw r7,4(r6) -15: stw r8,8(r6) -16: stw r9,12(r6) -17: stwu r10,16(r6) -20: lwz r7,4(r4) -21: lwz r8,8(r4) -22: lwz r9,12(r4) -23: lwzu r10,16(r4) -24: stw r7,4(r6) -25: stw r8,8(r6) -26: stw r9,12(r6) -27: stwu r10,16(r6) + +#if !defined(CONFIG_8xx) + /* Here we decide how far ahead to prefetch the source */ +#if MAX_COPY_PREFETCH > 1 + /* Heuristically, for large transfers we prefetch + MAX_COPY_PREFETCH cachelines ahead. For small transfers + we prefetch 1 cacheline ahead. */ + cmpwi r0,MAX_COPY_PREFETCH + li r7,1 + li r3,4 + ble 111f + li r7,MAX_COPY_PREFETCH +111: mtctr r7 +112: dcbt r3,r4 + addi r3,r3,CACHELINE_BYTES + bdnz 112b +#else /* MAX_COPY_PREFETCH == 1 */ + li r3,CACHELINE_BYTES + 4 + dcbt r11,r4 +#endif /* MAX_COPY_PREFETCH */ +#endif /* CONFIG_8xx */ + + mtctr r0 +53: +#if !defined(CONFIG_8xx) + dcbt r3,r4 + dcbz r11,r6 +#endif +/* had to move these to keep extable in order */ + .section __ex_table,"a" + .align 2 + .long 70b,100f + .long 71b,101f + .long 72b,102f + .long 73b,103f + .long 53b,105f + .text +/* the main body of the cacheline loop */ + COPY_16_BYTES_WITHEX(0) +#if CACHE_LINE_SIZE >= 32 + COPY_16_BYTES_WITHEX(1) +#if CACHE_LINE_SIZE >= 64 + COPY_16_BYTES_WITHEX(2) + COPY_16_BYTES_WITHEX(3) +#if CACHE_LINE_SIZE >= 128 + COPY_16_BYTES_WITHEX(4) + COPY_16_BYTES_WITHEX(5) + COPY_16_BYTES_WITHEX(6) + COPY_16_BYTES_WITHEX(7) +#endif +#endif +#endif bdnz 53b 63: srwi. r0,r5,2 @@ -434,15 +536,31 @@ 103: li r4,1 91: li r3,2 b 99f -/* read fault in 2nd half of cacheline loop */ -106: addi r5,r5,-16 -/* read fault in 1st half of cacheline loop */ + +/* + * this stuff handles faults in the cacheline loop and branches to either + * 104f (if in read part) or 105f (if in write part), after updating r5 + */ + COPY_16_BYTES_EXCODE(0) +#if CACHE_LINE_SIZE >= 32 + COPY_16_BYTES_EXCODE(1) +#if CACHE_LINE_SIZE >= 64 + COPY_16_BYTES_EXCODE(2) + COPY_16_BYTES_EXCODE(3) +#if CACHE_LINE_SIZE >= 128 + COPY_16_BYTES_EXCODE(4) + COPY_16_BYTES_EXCODE(5) + COPY_16_BYTES_EXCODE(6) + COPY_16_BYTES_EXCODE(7) +#endif +#endif +#endif + +/* read fault in cacheline loop */ 104: li r4,0 b 92f -/* write fault in 2nd half of cacheline loop */ -107: addi r5,r5,-16 /* fault on dcbz (effectively a write fault) */ -/* or write fault in 1st half of cacheline loop */ +/* or write fault in cacheline loop */ 105: li r4,1 92: li r3,LG_CACHELINE_BYTES b 99f @@ -485,36 +603,15 @@ bdnz 114b 120: blr -.section __ex_table,"a" + .section __ex_table,"a" .align 2 - .long 70b,100b - .long 71b,101b - .long 72b,102b - .long 73b,103b - .long 53b,105b - .long 10b,104b - .long 11b,104b - .long 12b,104b - .long 13b,104b - .long 14b,105b - .long 15b,105b - .long 16b,105b - .long 17b,105b - .long 20b,106b - .long 21b,106b - .long 22b,106b - .long 23b,106b - .long 24b,107b - .long 25b,107b - .long 26b,107b - .long 27b,107b .long 30b,108b .long 31b,109b .long 40b,110b .long 41b,111b .long 112b,120b .long 114b,120b -.text + .text .globl __clear_user __clear_user: @@ -546,12 +643,13 @@ blr 99: li r3,-EFAULT blr -.section __ex_table,"a" + + .section __ex_table,"a" .align 2 .long 11b,99b .long 1b,99b .long 8b,99b -.text + .text .globl __strncpy_from_user __strncpy_from_user: @@ -570,10 +668,11 @@ blr 99: li r3,-EFAULT blr -.section __ex_table,"a" + + .section __ex_table,"a" .align 2 .long 1b,99b -.text + .text /* r3 = str, r4 = len (> 0), r5 = top (highest addr) */ .globl __strnlen_user @@ -596,6 +695,7 @@ blr 99: li r3,0 /* bad address, return 0 */ blr -.section __ex_table,"a" + + .section __ex_table,"a" .align 2 .long 1b,99b diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/mbxboot/misc.c linux/arch/ppc/mbxboot/misc.c --- v2.4.0-test8/linux/arch/ppc/mbxboot/misc.c Fri Jul 14 12:12:07 2000 +++ linux/arch/ppc/mbxboot/misc.c Sun Sep 17 09:48:07 2000 @@ -269,6 +269,11 @@ */ #ifdef CONFIG_MBX cmd_line = (char *)(load_addr - 0x10000); + + /* To be like everyone else, we need one too, although this + * board information is passed from the boot rom. + */ + bp->bi_baudrate = 9600; #else cmd_line = (char *)(0x200000); #endif diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/mm/extable.c linux/arch/ppc/mm/extable.c --- v2.4.0-test8/linux/arch/ppc/mm/extable.c Thu Nov 11 20:11:32 1999 +++ linux/arch/ppc/mm/extable.c Sun Sep 17 09:48:07 2000 @@ -7,8 +7,43 @@ #include #include -extern const struct exception_table_entry __start___ex_table[]; -extern const struct exception_table_entry __stop___ex_table[]; +extern struct exception_table_entry __start___ex_table[]; +extern struct exception_table_entry __stop___ex_table[]; + +/* + * The exception table needs to be sorted because we use the macros + * which put things into the exception table in a variety of segments + * such as the prep, pmac, chrp, etc. segments as well as the init + * segment and the main kernel text segment. + */ +static inline void +sort_ex_table(struct exception_table_entry *start, + struct exception_table_entry *finish) +{ + struct exception_table_entry el, *p, *q; + + /* insertion sort */ + for (p = start + 1; p < finish; ++p) { + /* start .. p-1 is sorted */ + if (p[0].insn < p[-1].insn) { + /* move element p down to its right place */ + el = *p; + q = p; + do { + /* el comes before q[-1], move q[-1] up one */ + q[0] = q[-1]; + --q; + } while (q > start && el.insn < q[-1].insn); + *q = el; + } + } +} + +void +sort_exception_table(void) +{ + sort_ex_table(__start___ex_table, __stop___ex_table); +} static inline unsigned long search_one_table(const struct exception_table_entry *first, @@ -36,25 +71,21 @@ { unsigned long ret; -#if 1 /*ndef CONFIG_MODULES*/ +#ifndef CONFIG_MODULES /* There is only the kernel to search. */ ret = search_one_table(__start___ex_table, __stop___ex_table-1, addr); if (ret) return ret; #else /* The kernel is the last "module" -- no need to treat it special. */ struct module *mp; - read_lock(&modlist_lock); for (mp = module_list; mp != NULL; mp = mp->next) { if (mp->ex_table_start == NULL) continue; ret = search_one_table(mp->ex_table_start, mp->ex_table_end - 1, addr); - if (ret) { - read_unlock(&modlist_lock); + if (ret) return ret; - } } - read_unlock(&modlist_lock); #endif return 0; diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/mm/fault.c linux/arch/ppc/mm/fault.c --- v2.4.0-test8/linux/arch/ppc/mm/fault.c Fri Jun 23 21:55:07 2000 +++ linux/arch/ppc/mm/fault.c Sun Sep 17 09:48:07 2000 @@ -67,7 +67,7 @@ #if defined(CONFIG_4xx) int is_write = error_code & ESR_DST; #else - int is_write = error_code & 0x02000000; + int is_write = 0; /* * Fortunately the bit assignments in SRR1 for an instruction @@ -77,6 +77,8 @@ */ if (regs->trap == 0x400) error_code &= 0x48200000; + else + is_write = error_code & 0x02000000; #endif /* CONFIG_4xx */ #if defined(CONFIG_XMON) || defined(CONFIG_KGDB) diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/mm/init.c linux/arch/ppc/mm/init.c --- v2.4.0-test8/linux/arch/ppc/mm/init.c Wed Aug 9 19:19:49 2000 +++ linux/arch/ppc/mm/init.c Sun Sep 17 09:48:07 2000 @@ -36,6 +36,7 @@ #include #include #include +#include #ifdef CONFIG_BLK_DEV_INITRD #include /* for initrd_* */ #endif @@ -69,15 +70,20 @@ #include "4xx_tlb.h" #endif +#define MAX_LOW_MEM (640 << 20) + #define PGTOKB(pages) (((pages) * PAGE_SIZE) >> 10) int prom_trashed; atomic_t next_mmu_context; unsigned long *end_of_DRAM; +unsigned long total_memory; +unsigned long total_lowmem; int mem_init_done; int init_bootmem_done; int boot_mapsize; unsigned long totalram_pages = 0; +unsigned long totalhigh_pages = 0; extern pgd_t swapper_pg_dir[]; extern char _start[], _end[]; extern char etext[], _stext[]; @@ -98,22 +104,26 @@ #ifndef CONFIG_SMP struct pgtable_cache_struct quicklists; #endif +#ifdef CONFIG_HIGHMEM +pte_t *kmap_pte; +pgprot_t kmap_prot; +#endif void MMU_init(void); static void *MMU_get_page(void); -unsigned long *prep_find_end_of_memory(void); -unsigned long *pmac_find_end_of_memory(void); -unsigned long *apus_find_end_of_memory(void); -unsigned long *gemini_find_end_of_memory(void); -extern unsigned long *find_end_of_memory(void); +unsigned long prep_find_end_of_memory(void); +unsigned long pmac_find_end_of_memory(void); +unsigned long apus_find_end_of_memory(void); +unsigned long gemini_find_end_of_memory(void); +extern unsigned long find_end_of_memory(void); #ifdef CONFIG_8xx -unsigned long *m8xx_find_end_of_memory(void); +unsigned long m8xx_find_end_of_memory(void); #endif /* CONFIG_8xx */ #ifdef CONFIG_4xx -unsigned long *oak_find_end_of_memory(void); +unsigned long oak_find_end_of_memory(void); #endif #ifdef CONFIG_8260 -unsigned long *m8260_find_end_of_memory(void); +unsigned long m8260_find_end_of_memory(void); #endif /* CONFIG_8260 */ static void mapin_ram(void); void map_page(unsigned long va, unsigned long pa, int flags); @@ -269,6 +279,7 @@ int i,free = 0,total = 0,reserved = 0; int shared = 0, cached = 0; struct task_struct *p; + int highmem = 0; printk("Mem-info:\n"); show_free_areas(); @@ -276,6 +287,8 @@ i = max_mapnr; while (i-- > 0) { total++; + if (PageHighMem(mem_map+i)) + highmem++; if (PageReserved(mem_map+i)) reserved++; else if (PageSwapCache(mem_map+i)) @@ -286,6 +299,7 @@ shared += atomic_read(&mem_map[i].count) - 1; } printk("%d pages of RAM\n",total); + printk("%d pages of HIGHMEM\n", highmem); printk("%d free pages\n",free); printk("%d reserved pages\n",reserved); printk("%d pages shared\n",shared); @@ -354,6 +368,8 @@ continue; val->sharedram += atomic_read(&mem_map[i].count) - 1; } + val->totalhigh = totalhigh_pages; + val->freehigh = nr_free_highpages(); val->mem_unit = PAGE_SIZE; } @@ -443,7 +459,8 @@ void iounmap(void *addr) { - /* XXX todo */ + if (addr > high_memory && (unsigned long) addr < ioremap_bot) + vfree((void *) (PAGE_MASK & (unsigned long) addr)); } unsigned long iopa(unsigned long addr) @@ -476,7 +493,7 @@ { pmd_t *pd, oldpd; pte_t *pg; - + /* Use upper 10 bits of VA to index the first level map */ pd = pmd_offset(pgd_offset_k(va), va); oldpd = *pd; @@ -516,6 +533,7 @@ flush_hash_segments(0xd, 0xffffff); #else __clear_user(Hash, Hash_size); + _tlbia(); #ifdef CONFIG_SMP smp_send_tlb_invalidate(0); #endif /* CONFIG_SMP */ @@ -610,6 +628,13 @@ } #endif /* CONFIG_8xx */ +void flush_page_to_ram(struct page *page) +{ + unsigned long vaddr = kmap(page); + __flush_page_to_ram(vaddr); + kunmap(page); +} + #if !defined(CONFIG_4xx) && !defined(CONFIG_8xx) static void get_mem_prop(char *, struct mem_pieces *); @@ -722,7 +747,7 @@ if (align && align < max_size) max_size = align; - tot = (unsigned long)end_of_DRAM - KERNELBASE; + tot = total_lowmem; for (bl = 128<<10; bl < max_size; bl <<= 1) { if (bl * 2 > tot) break; @@ -745,6 +770,8 @@ for (i = 0; i < phys_mem.n_regions; ++i) { v = (ulong)__va(phys_mem.regions[i].address); p = phys_mem.regions[i].address; + if (p >= total_lowmem) + break; for (s = 0; s < phys_mem.regions[i].size; s += PAGE_SIZE) { /* On the MPC8xx, we want the page shared so we * don't get ASID compares on kernel space. @@ -766,6 +793,8 @@ map_page(v, p, f); v += PAGE_SIZE; p += PAGE_SIZE; + if (p >= total_lowmem) + break; } } } @@ -788,77 +817,42 @@ return p; } -void __init free_initmem(void) +static void free_sec(unsigned long start, unsigned long end, const char *name) { - unsigned long a; - unsigned long num_freed_pages = 0, num_prep_pages = 0, - num_pmac_pages = 0, num_openfirmware_pages = 0, - num_apus_pages = 0, num_chrp_pages = 0; -#define FREESEC(START,END,CNT) do { \ - a = (unsigned long)(&START); \ - for (; a < (unsigned long)(&END); a += PAGE_SIZE) { \ - clear_bit(PG_reserved, &virt_to_page(a)->flags); \ - set_page_count(virt_to_page(a), 1); \ - free_page(a); \ - CNT++; \ - } \ -} while (0) - - FREESEC(__init_begin,__init_end,num_freed_pages); - switch (_machine) - { - case _MACH_Pmac: - FREESEC(__apus_begin,__apus_end,num_apus_pages); - FREESEC(__prep_begin,__prep_end,num_prep_pages); - FREESEC(__chrp_begin,__chrp_end,num_chrp_pages); - break; - case _MACH_chrp: - FREESEC(__apus_begin,__apus_end,num_apus_pages); - FREESEC(__pmac_begin,__pmac_end,num_pmac_pages); - FREESEC(__prep_begin,__prep_end,num_prep_pages); - break; - case _MACH_prep: - FREESEC(__apus_begin,__apus_end,num_apus_pages); - FREESEC(__pmac_begin,__pmac_end,num_pmac_pages); - FREESEC(__chrp_begin,__chrp_end,num_chrp_pages); - break; - case _MACH_mbx: - FREESEC(__apus_begin,__apus_end,num_apus_pages); - FREESEC(__pmac_begin,__pmac_end,num_pmac_pages); - FREESEC(__prep_begin,__prep_end,num_prep_pages); - FREESEC(__chrp_begin,__chrp_end,num_chrp_pages); - break; - case _MACH_apus: - FREESEC(__pmac_begin,__pmac_end,num_pmac_pages); - FREESEC(__prep_begin,__prep_end,num_prep_pages); - FREESEC(__chrp_begin,__chrp_end,num_chrp_pages); - break; - case _MACH_gemini: - FREESEC(__apus_begin,__apus_end,num_apus_pages); - FREESEC(__pmac_begin,__pmac_end,num_pmac_pages); - FREESEC(__prep_begin,__prep_end,num_prep_pages); - FREESEC(__chrp_begin,__chrp_end,num_chrp_pages); - break; - } + unsigned long cnt = 0; - if ( !have_of ) - FREESEC( __openfirmware_begin, __openfirmware_end, - num_openfirmware_pages ); - - printk ("Freeing unused kernel memory: %ldk init", - PGTOKB(num_freed_pages)); + while (start < end) { + clear_bit(PG_reserved, &virt_to_page(start)->flags); + set_page_count(virt_to_page(start), 1); + free_page(start); + cnt++; + start += PAGE_SIZE; + } + if (cnt) + printk(" %ldk %s", PGTOKB(cnt), name); +} - if ( num_prep_pages ) - printk(" %ldk prep", PGTOKB(num_prep_pages)); - if ( num_chrp_pages ) - printk(" %ldk chrp", PGTOKB(num_chrp_pages)); - if ( num_pmac_pages ) - printk(" %ldk pmac", PGTOKB(num_pmac_pages)); - if ( num_openfirmware_pages ) - printk(" %ldk open firmware", PGTOKB(num_openfirmware_pages)); - if ( num_apus_pages ) - printk(" %ldk apus", PGTOKB(num_apus_pages)); - printk("\n"); +void free_initmem(void) +{ +#define FREESEC(TYPE) \ + free_sec((unsigned long)(&__ ## TYPE ## _begin), \ + (unsigned long)(&__ ## TYPE ## _end), \ + #TYPE); + + printk ("Freeing unused kernel memory:"); + FREESEC(init); + if (_machine != _MACH_Pmac) + FREESEC(pmac); + if (_machine != _MACH_chrp) + FREESEC(chrp); + if (_machine != _MACH_prep) + FREESEC(prep); + if (_machine != _MACH_apus) + FREESEC(apus); + if (!have_of) + FREESEC(openfirmware); + printk("\n"); +#undef FREESEC } #ifdef CONFIG_BLK_DEV_INITRD @@ -909,7 +903,8 @@ * at KERNELBASE. */ - end_of_DRAM = oak_find_end_of_memory(); + total_memory = total_lowmem = oak_find_end_of_memory(); + end_of_DRAM = __va(total_memory); mapin_ram(); /* @@ -939,23 +934,33 @@ if ( ppc_md.progress ) ppc_md.progress("MMU:enter", 0x111); #ifndef CONFIG_8xx if (have_of) - end_of_DRAM = pmac_find_end_of_memory(); + total_memory = pmac_find_end_of_memory(); #ifdef CONFIG_APUS else if (_machine == _MACH_apus ) - end_of_DRAM = apus_find_end_of_memory(); + total_memory = apus_find_end_of_memory(); #endif #ifdef CONFIG_GEMINI else if ( _machine == _MACH_gemini ) - end_of_DRAM = gemini_find_end_of_memory(); + total_memory = gemini_find_end_of_memory(); #endif /* CONFIG_GEMINI */ #if defined(CONFIG_8260) else - end_of_DRAM = m8260_find_end_of_memory(); + total_memory = m8260_find_end_of_memory(); #else else /* prep */ - end_of_DRAM = prep_find_end_of_memory(); + total_memory = prep_find_end_of_memory(); #endif + total_lowmem = total_memory; +#ifdef CONFIG_HIGHMEM + if (total_lowmem > MAX_LOW_MEM) { + total_lowmem = MAX_LOW_MEM; + mem_pieces_remove(&phys_avail, total_lowmem, + total_memory - total_lowmem, 0); + } +#endif /* CONFIG_HIGHMEM */ + end_of_DRAM = __va(total_lowmem); + if ( ppc_md.progress ) ppc_md.progress("MMU:hash init", 0x300); hash_init(); #ifndef CONFIG_PPC64BRIDGE @@ -995,7 +1000,7 @@ #endif break; case _MACH_Pmac: - ioremap_base = 0xf8000000; + ioremap_base = 0xfe000000; break; case _MACH_apus: /* Map PPC exception vectors. */ @@ -1022,7 +1027,15 @@ #endif /* CONFIG_POWER4 */ #else /* CONFIG_8xx */ - end_of_DRAM = m8xx_find_end_of_memory(); + total_memory = total_lowmem = m8xx_find_end_of_memory(); +#ifdef CONFIG_HIGHMEM + if (total_lowmem > MAX_LOW_MEM) { + total_lowmem = MAX_LOW_MEM; + mem_pieces_remove(&phys_avail, total_lowmem, + total_memory - total_lowmem, 0); + } +#endif /* CONFIG_HIGHMEM */ + end_of_DRAM = __va(total_lowmem); /* Map in all of RAM starting at KERNELBASE */ mapin_ram(); @@ -1055,7 +1068,7 @@ if ( ppc_md.progress ) ppc_md.progress("MMU:exit", 0x211); #ifdef CONFIG_BOOTX_TEXT /* Must be done last, or ppc_md.progress will die */ - if (_machine == _MACH_Pmac) + if (_machine == _MACH_Pmac || _machine == _MACH_chrp) map_bootx_text(); #endif } @@ -1092,7 +1105,7 @@ start = PAGE_ALIGN(start); boot_mapsize = init_bootmem(start >> PAGE_SHIFT, - __pa(end_of_DRAM) >> PAGE_SHIFT); + total_lowmem >> PAGE_SHIFT); /* remove the bootmem bitmap from the available memory */ mem_pieces_remove(&phys_avail, start, boot_mapsize, 1); @@ -1105,47 +1118,6 @@ init_bootmem_done = 1; } -#if 0 -/* - * Find some memory for setup_arch to return. - * We use the largest chunk of available memory as the area - * that setup_arch returns, making sure that there are at - * least 32 pages unused before this for MMU_get_page to use. - */ -unsigned long __init find_available_memory(void) -{ - int i, rn; - unsigned long a, free; - unsigned long start, end; - - if (_machine == _MACH_mbx) { - /* Return the first, not the last region, because we - * may not yet have properly initialized the additonal - * memory DIMM. - */ - a = PAGE_ALIGN(phys_avail.regions[0].address); - avail_start = (unsigned long) __va(a); - return avail_start; - } - - rn = 0; - for (i = 1; i < phys_avail.n_regions; ++i) - if (phys_avail.regions[i].size > phys_avail.regions[rn].size) - rn = i; - free = 0; - for (i = 0; i < rn; ++i) { - start = phys_avail.regions[i].address; - end = start + phys_avail.regions[i].size; - free += (end & PAGE_MASK) - PAGE_ALIGN(start); - } - a = PAGE_ALIGN(phys_avail.regions[rn].address); - if (free < 32 * PAGE_SIZE) - a += 32 * PAGE_SIZE - free; - avail_start = (unsigned long) __va(a); - return avail_start; -} -#endif /* 0 */ - /* * paging_init() sets up the page tables - in fact we've already done this. */ @@ -1153,6 +1125,14 @@ { unsigned long zones_size[MAX_NR_ZONES], i; +#ifdef CONFIG_HIGHMEM + map_page(PKMAP_BASE, 0, 0); /* XXX gross */ + pkmap_page_table = pte_offset(pmd_offset(pgd_offset_k(PKMAP_BASE), PKMAP_BASE), PKMAP_BASE); + map_page(KMAP_FIX_BEGIN, 0, 0); /* XXX gross */ + kmap_pte = pte_offset(pmd_offset(pgd_offset_k(KMAP_FIX_BEGIN), KMAP_FIX_BEGIN), KMAP_FIX_BEGIN); + kmap_prot = PAGE_KERNEL; +#endif /* CONFIG_HIGHMEM */ + /* * Grab some memory for bad_page and bad_pagetable to use. */ @@ -1162,9 +1142,14 @@ /* * All pages are DMA-able so we put them all in the DMA zone. */ - zones_size[0] = ((unsigned long)end_of_DRAM - KERNELBASE) >> PAGE_SHIFT; + zones_size[ZONE_DMA] = total_lowmem >> PAGE_SHIFT; for (i = 1; i < MAX_NR_ZONES; i++) zones_size[i] = 0; + +#ifdef CONFIG_HIGHMEM + zones_size[ZONE_HIGHMEM] = (total_memory - total_lowmem) >> PAGE_SHIFT; +#endif /* CONFIG_HIGHMEM */ + free_area_init(zones_size); } @@ -1176,7 +1161,17 @@ int codepages = 0; int datapages = 0; int initpages = 0; +#ifdef CONFIG_HIGHMEM + unsigned long highmem_mapnr; + + highmem_mapnr = total_lowmem >> PAGE_SHIFT; + highmem_start_page = mem_map + highmem_mapnr; + max_mapnr = total_memory >> PAGE_SHIFT; + totalram_pages += max_mapnr - highmem_mapnr; +#else max_mapnr = max_low_pfn; +#endif /* CONFIG_HIGHMEM */ + high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); num_physpages = max_mapnr; /* RAM is assumed contiguous */ @@ -1217,11 +1212,28 @@ datapages++; } - printk("Memory: %luk available (%dk kernel code, %dk data, %dk init) [%08x,%08lx]\n", +#ifdef CONFIG_HIGHMEM + { + unsigned long pfn; + + for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) { + struct page *page = mem_map + pfn; + + ClearPageReserved(page); + set_bit(PG_highmem, &page->flags); + atomic_set(&page->count, 1); + __free_page(page); + totalhigh_pages++; + } + totalram_pages += totalhigh_pages; + } +#endif /* CONFIG_HIGHMEM */ + + printk("Memory: %luk available (%dk kernel code, %dk data, %dk init, %ldk highmem)\n", (unsigned long)nr_free_pages()<< (PAGE_SHIFT-10), codepages<< (PAGE_SHIFT-10), datapages<< (PAGE_SHIFT-10), initpages<< (PAGE_SHIFT-10), - PAGE_OFFSET, (unsigned long) end_of_DRAM); + (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10))); mem_init_done = 1; } @@ -1234,7 +1246,7 @@ * Our text, data, bss use something over 1MB, starting at 0. * Open Firmware may be using 1MB at the 4MB point. */ -unsigned long __init *pmac_find_end_of_memory(void) +unsigned long __init pmac_find_end_of_memory(void) { unsigned long a, total; unsigned long ram_limit = 0xe0000000 - KERNELBASE; @@ -1279,7 +1291,7 @@ set_phys_avail(&phys_mem); - return __va(total); + return total; } #endif /* CONFIG_ALL_PPC */ @@ -1290,7 +1302,7 @@ * this will likely stay separate from the pmac. * -- Cort */ -unsigned long __init *prep_find_end_of_memory(void) +unsigned long __init prep_find_end_of_memory(void) { unsigned long total; total = res->TotalMemory; @@ -1308,15 +1320,15 @@ mem_pieces_append(&phys_mem, 0, total); set_phys_avail(&phys_mem); - return (__va(total)); + return (total); } #endif /* defined(CONFIG_ALL_PPC) */ #if defined(CONFIG_GEMINI) -unsigned long __init *gemini_find_end_of_memory(void) +unsigned long __init gemini_find_end_of_memory(void) { - unsigned long total, *ret; + unsigned long total; unsigned char reg; reg = readb(GEMINI_MEMCFG); @@ -1327,9 +1339,8 @@ phys_mem.regions[0].size = total; phys_mem.n_regions = 1; - ret = __va(phys_mem.regions[0].size); set_phys_avail(&phys_mem); - return ret; + return phys_mem.regions[0].size; } #endif /* defined(CONFIG_GEMINI) */ @@ -1337,10 +1348,9 @@ /* * Same hack as 8xx. */ -unsigned long __init *m8260_find_end_of_memory(void) +unsigned long __init m8260_find_end_of_memory(void) { bd_t *binfo; - unsigned long *ret; extern unsigned char __res[]; binfo = (bd_t *)__res; @@ -1349,15 +1359,14 @@ phys_mem.regions[0].size = binfo->bi_memsize; phys_mem.n_regions = 1; - ret = __va(phys_mem.regions[0].size); set_phys_avail(&phys_mem); - return ret; + return phys_mem.regions[0].size; } #endif /* CONFIG_8260 */ #ifdef CONFIG_APUS #define HARDWARE_MAPPED_SIZE (512*1024) -unsigned long __init *apus_find_end_of_memory(void) +unsigned long __init apus_find_end_of_memory(void) { int shadow = 0; @@ -1421,7 +1430,7 @@ the PowerUP board. Other system memory is horrible slow in comparison. The user can use other memory for swapping using the z2ram device. */ - return __va(memory[0].addr + memory[0].size); + return memory[0].addr + memory[0].size; } #endif /* CONFIG_APUS */ @@ -1484,7 +1493,7 @@ /* Find some memory for the hash table. */ if ( Hash_size ) { Hash = mem_pieces_find(Hash_size, Hash_size); - /*__clear_user(Hash, Hash_size);*/ + cacheable_memzero(Hash, Hash_size); } else Hash = 0; #endif /* CONFIG_PPC64BRIDGE */ @@ -1544,10 +1553,9 @@ * functions in the image just to get prom_init, all we really need right * now is the initialization of the physical memory region. */ -unsigned long __init *m8xx_find_end_of_memory(void) +unsigned long __init m8xx_find_end_of_memory(void) { bd_t *binfo; - unsigned long *ret; extern unsigned char __res[]; binfo = (bd_t *)__res; @@ -1555,12 +1563,9 @@ phys_mem.regions[0].address = 0; phys_mem.regions[0].size = binfo->bi_memsize; phys_mem.n_regions = 1; - - ret = __va(phys_mem.regions[0].address+ - phys_mem.regions[0].size); set_phys_avail(&phys_mem); - return ret; + return phys_mem.regions[0].address + phys_mem.regions[0].size; } #endif /* !CONFIG_4xx && !CONFIG_8xx */ @@ -1569,7 +1574,7 @@ * Return the virtual address representing the top of physical RAM * on the Oak board. */ -unsigned long __init * +unsigned long __init oak_find_end_of_memory(void) { extern unsigned char __res[]; @@ -1580,12 +1585,9 @@ phys_mem.regions[0].address = 0; phys_mem.regions[0].size = bip->bi_memsize; phys_mem.n_regions = 1; - - ret = __va(phys_mem.regions[0].address + - phys_mem.regions[0].size); set_phys_avail(&phys_mem); - return (ret); + return (phys_mem.regions[0].address + phys_mem.regions[0].size); } #endif diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/xmon/start.c linux/arch/ppc/xmon/start.c --- v2.4.0-test8/linux/arch/ppc/xmon/start.c Fri Jun 23 21:55:08 2000 +++ linux/arch/ppc/xmon/start.c Sun Sep 17 09:48:07 2000 @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,12 @@ use_screen = 1; } #endif +#ifdef CONFIG_ADB_CUDA + if (!via_modem && disp_bi ) { + prom_drawstring("xmon uses screen and keyboard\n"); + use_screen = 1; + } +#endif #endif #ifdef CHRP_ESCC @@ -100,6 +107,10 @@ /* should already be mapped by the kernel boot */ sccc = (volatile unsigned char *) (isa_io_base + 0x3fd); sccd = (volatile unsigned char *) (isa_io_base + 0x3f8); + if (xmon_use_sccb) { + sccc -= 0x100; + sccd -= 0x100; + } TXRDY = 0x20; RXRDY = 1; } @@ -109,6 +120,19 @@ void xmon_init_scc(void); extern void pmu_poll(void); +extern void cuda_poll(void); + +static inline void do_poll_adb(void) +{ +#ifdef CONFIG_ADB_PMU + if (sys_ctrler == SYS_CTRLER_PMU) + pmu_poll(); +#endif /* CONFIG_ADB_PMU */ +#ifdef CONFIG_ADB_CUDA + if (sys_ctrler == SYS_CTRLER_CUDA) + cuda_poll(); +#endif /* CONFIG_ADB_CUDA */ +} int xmon_write(void *handle, void *ptr, int nb) @@ -128,12 +152,8 @@ xmon_init_scc(); ct = 0; for (i = 0; i < nb; ++i) { - while ((*sccc & TXRDY) == 0) { -#ifdef CONFIG_ADB_PMU - if (sys_ctrler == SYS_CTRLER_PMU) - pmu_poll(); -#endif /* CONFIG_ADB_PMU */ - } + while ((*sccc & TXRDY) == 0) + do_poll_adb(); c = p[i]; if (c == '\n' && !ct) { c = '\r'; @@ -189,9 +209,7 @@ prom_drawchar('\b'); t = 200000; } -#ifdef CONFIG_ADB_PMU - pmu_poll(); -#endif /* CONFIG_ADB_PMU */ + do_poll_adb(); } while (xmon_adb_keycode == -1); k = xmon_adb_keycode; if (on) @@ -230,14 +248,9 @@ xmon_init_scc(); for (i = 0; i < nb; ++i) { while ((*sccc & RXRDY) == 0) -#ifdef CONFIG_ADB_PMU - if (sys_ctrler == SYS_CTRLER_PMU) - pmu_poll(); -#else - ; -#endif /* CONFIG_ADB_PMU */ + do_poll_adb(); buf_access(); - *p++ = *sccd; + *p++ = *sccd; } return i; } @@ -246,10 +259,7 @@ xmon_read_poll(void) { if ((*sccc & RXRDY) == 0) { -#ifdef CONFIG_ADB_PMU - if (sys_ctrler == SYS_CTRLER_PMU) - pmu_poll(); -#endif /* CONFIG_ADB_PMU */ + do_poll_adb(); return -1; } buf_access(); @@ -490,4 +500,20 @@ } *p = 0; return str; +} + +void +xmon_enter(void) +{ +#ifdef CONFIG_ADB_PMU + pmu_suspend(); +#endif +} + +void +xmon_leave(void) +{ +#ifdef CONFIG_ADB_PMU + pmu_resume(); +#endif } diff -u --recursive --new-file v2.4.0-test8/linux/arch/ppc/xmon/xmon.c linux/arch/ppc/xmon/xmon.c --- v2.4.0-test8/linux/arch/ppc/xmon/xmon.c Fri Jul 14 12:12:07 2000 +++ linux/arch/ppc/xmon/xmon.c Sun Sep 17 09:48:07 2000 @@ -6,15 +6,23 @@ #include #include #include +#include #include #include #include +#include #include "nonstdio.h" #include "privinst.h" #define scanhex xmon_scanhex #define skipbl xmon_skipbl +#ifdef CONFIG_SMP +static unsigned long cpus_in_xmon = 0; +static unsigned long got_xmon = 0; +static volatile int take_xmon = -1; +#endif /* CONFIG_SMP */ + static unsigned adrs; static int size = 1; static unsigned ndump = 64; @@ -84,6 +92,9 @@ static struct bpt *at_breakpoint(unsigned pc); static void bpt_cmds(void); static void cacheflush(void); +#ifdef CONFIG_SMP +static void cpu_cmd(void); +#endif /* CONFIG_SMP */ #if 0 /* Makes compile with -Wall */ static char *pretty_print_addr(unsigned long addr); static char *lookup_name(unsigned long addr); @@ -96,8 +107,18 @@ extern int setjmp(u_int *); extern void longjmp(u_int *, int); +extern void xmon_enter(void); +extern void xmon_leave(void); + #define GETWORD(v) (((v)[0] << 24) + ((v)[1] << 16) + ((v)[2] << 8) + (v)[3]) +#define isxdigit(c) (('0' <= (c) && (c) <= '9') \ + || ('a' <= (c) && (c) <= 'f') \ + || ('A' <= (c) && (c) <= 'F')) +#define isalnum(c) (('0' <= (c) && (c) <= '9') \ + || ('a' <= (c) && (c) <= 'z') \ + || ('A' <= (c) && (c) <= 'Z')) + static char *help_string = "\ Commands:\n\ d dump bytes\n\ @@ -117,10 +138,12 @@ x exit monitor\n\ "; -static int xmon_trace; +static int xmon_trace[NR_CPUS]; #define SSTEP 1 /* stepping because of 's' command */ #define BRSTEP 2 /* stepping over breakpoint */ +static struct pt_regs *xmon_regs[NR_CPUS]; + void xmon(struct pt_regs *excp) { @@ -143,27 +166,52 @@ msr = get_msr(); set_msr(msr & ~0x8000); /* disable interrupts */ - remove_bpts(); + xmon_regs[smp_processor_id()] = excp; + xmon_enter(); excprint(excp); +#ifdef CONFIG_SMP + if (test_and_set_bit(smp_processor_id(), &cpus_in_xmon)) + for (;;) + ; + while (test_and_set_bit(0, &got_xmon)) { + if (take_xmon == smp_processor_id()) { + take_xmon = -1; + break; + } + } + /* + * XXX: breakpoints are removed while any cpu is in xmon + */ +#endif /* CONFIG_SMP */ + remove_bpts(); cmd = cmds(excp); if (cmd == 's') { - xmon_trace = SSTEP; + xmon_trace[smp_processor_id()] = SSTEP; excp->msr |= 0x400; } else if (at_breakpoint(excp->nip)) { - xmon_trace = BRSTEP; + xmon_trace[smp_processor_id()] = BRSTEP; excp->msr |= 0x400; } else { - xmon_trace = 0; + xmon_trace[smp_processor_id()] = 0; insert_bpts(); } + xmon_leave(); + xmon_regs[smp_processor_id()] = 0; +#ifdef CONFIG_SMP + clear_bit(0, &got_xmon); + clear_bit(smp_processor_id(), &cpus_in_xmon); +#endif /* CONFIG_SMP */ set_msr(msr); /* restore interrupt enable */ } void xmon_irq(int irq, void *d, struct pt_regs *regs) { + unsigned long flags; + save_flags(flags);cli(); printf("Keyboard interrupt\n"); xmon(regs); + restore_flags(flags); } int @@ -178,7 +226,7 @@ --bp->count; remove_bpts(); excprint(regs); - xmon_trace = BRSTEP; + xmon_trace[smp_processor_id()] = BRSTEP; regs->msr |= 0x400; } else { xmon(regs); @@ -189,10 +237,10 @@ int xmon_sstep(struct pt_regs *regs) { - if (!xmon_trace) + if (!xmon_trace[smp_processor_id()]) return 0; - if (xmon_trace == BRSTEP) { - xmon_trace = 0; + if (xmon_trace[smp_processor_id()] == BRSTEP) { + xmon_trace[smp_processor_id()] = 0; insert_bpts(); } else { xmon(regs); @@ -207,7 +255,7 @@ --dabr.count; remove_bpts(); excprint(regs); - xmon_trace = BRSTEP; + xmon_trace[smp_processor_id()] = BRSTEP; regs->msr |= 0x400; } else { dabr.instr = regs->nip; @@ -223,7 +271,7 @@ --iabr.count; remove_bpts(); excprint(regs); - xmon_trace = BRSTEP; + xmon_trace[smp_processor_id()] = BRSTEP; regs->msr |= 0x400; } else { xmon(regs); @@ -264,6 +312,7 @@ bp->address); bp->enabled = 0; } + store_inst((void *) bp->address); } #if !defined(CONFIG_8xx) && !defined(CONFIG_POWER4) if (dabr.enabled) @@ -293,6 +342,7 @@ && mwrite(bp->address, &bp->instr, 4) != 4) printf("Couldn't remove breakpoint at %x\n", bp->address); + store_inst((void *) bp->address); } } @@ -306,6 +356,9 @@ last_cmd = NULL; for(;;) { +#ifdef CONFIG_SMP + printf("%d:", smp_processor_id()); +#endif /* CONFIG_SMP */ printf("mon> "); fflush(stdout); flush_input(); @@ -383,12 +436,67 @@ case 'b': bpt_cmds(); break; - case 'c': + case 'C': csum(); break; +#ifdef CONFIG_SMP + case 'c': + cpu_cmd(); + break; +#endif /* CONFIG_SMP */ + } + } +} + +#ifdef CONFIG_SMP +static void cpu_cmd(void) +{ + unsigned cpu; + int timeout; + int cmd; + + cmd = inchar(); + if (cmd == 'i') { + /* interrupt other cpu(s) */ + cpu = MSG_ALL_BUT_SELF; + scanhex(&cpu); + smp_send_xmon_break(cpu); + return; + } + termch = cmd; + if (!scanhex(&cpu)) { + /* print cpus waiting or in xmon */ + printf("cpus stopped:"); + for (cpu = 0; cpu < NR_CPUS; ++cpu) { + if (test_bit(cpu, &cpus_in_xmon)) { + printf(" %d", cpu); + if (cpu == smp_processor_id()) + printf("*", cpu); + } + } + printf("\n"); + return; + } + /* try to switch to cpu specified */ + take_xmon = cpu; + timeout = 10000000; + while (take_xmon >= 0) { + if (--timeout == 0) { + /* yes there's a race here */ + take_xmon = -1; + printf("cpu %u didn't take control\n", cpu); + return; + } + } + /* now have to wait to be given control back */ + while (test_and_set_bit(0, &got_xmon)) { + if (take_xmon == smp_processor_id()) { + take_xmon = -1; + break; } } } +#endif /* CONFIG_SMP */ static unsigned short fcstab[256] = { 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, @@ -551,6 +659,8 @@ extern char lost_irq_ret, do_bottom_half_ret, do_signal_ret; extern char ret_from_except; + printf("backtrace:\n"); + if (excp != NULL) sp = excp->gpr[1]; else @@ -592,6 +702,9 @@ void excprint(struct pt_regs *fp) { +#ifdef CONFIG_SMP + printf("cpu %d: ", smp_processor_id()); +#endif /* CONFIG_SMP */ printf("vector: %x at pc = %x", fp->trap, fp->nip); printf(", lr = %x, msr = %x, sp = %x [%x]\n", @@ -1163,9 +1276,6 @@ return c; } -#define isxdigit(c) (('0' <= (c) && (c) <= '9') \ - || ('a' <= (c) && (c) <= 'f') \ - || ('A' <= (c) && (c) <= 'F')) void dump() { @@ -1402,6 +1512,16 @@ return c; } +#define N_PTREGS 44 +static char *regnames[N_PTREGS] = { + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", + "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", + "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", + "pc", "msr", "or3", "ctr", "lr", "xer", "ccr", "mq", + "trap", "dar", "dsisr", "res" +}; + int scanhex(vp) unsigned *vp; @@ -1410,6 +1530,36 @@ unsigned v; c = skipbl(); + if (c == '%') { + /* parse register name */ + char regname[8]; + int i; + + for (i = 0; i < sizeof(regname) - 1; ++i) { + c = inchar(); + if (!isalnum(c)) { + termch = c; + break; + } + regname[i] = c; + } + regname[i] = 0; + for (i = 0; i < N_PTREGS; ++i) { + if (strcmp(regnames[i], regname) == 0) { + unsigned *rp = (unsigned *) + xmon_regs[smp_processor_id()]; + if (rp == NULL) { + printf("regs not available\n"); + return 0; + } + *vp = rp[i]; + return 1; + } + } + printf("invalid register name '%%%s'\n", regname); + return 0; + } + d = hexdigit(c); if( d == EOF ){ termch = c; diff -u --recursive --new-file v2.4.0-test8/linux/arch/sh/kernel/time.c linux/arch/sh/kernel/time.c --- v2.4.0-test8/linux/arch/sh/kernel/time.c Wed Aug 9 19:19:49 2000 +++ linux/arch/sh/kernel/time.c Mon Sep 11 08:39:48 2000 @@ -274,37 +274,6 @@ write_unlock(&xtime_lock); } -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static inline unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ -} - static unsigned long get_rtc_time(void) { unsigned int sec, min, hr, wk, day, mon, yr, yr100; diff -u --recursive --new-file v2.4.0-test8/linux/arch/sparc/kernel/time.c linux/arch/sparc/kernel/time.c --- v2.4.0-test8/linux/arch/sparc/kernel/time.c Fri Jun 23 21:55:08 2000 +++ linux/arch/sparc/kernel/time.c Sun Sep 17 10:01:49 2000 @@ -1,4 +1,4 @@ -/* $Id: time.c,v 1.56 2000/06/13 22:51:28 anton Exp $ +/* $Id: time.c,v 1.57 2000/09/16 07:33:45 davem Exp $ * linux/arch/sparc/kernel/time.c * * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) @@ -147,37 +147,6 @@ last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */ } write_unlock(&xtime_lock); -} - -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static inline unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ } /* Kick start a stopped clock (procedure from the Sun NVRAM/hostid FAQ). */ diff -u --recursive --new-file v2.4.0-test8/linux/arch/sparc64/kernel/entry.S linux/arch/sparc64/kernel/entry.S --- v2.4.0-test8/linux/arch/sparc64/kernel/entry.S Fri Sep 8 13:27:11 2000 +++ linux/arch/sparc64/kernel/entry.S Fri Sep 8 17:55:17 2000 @@ -1,4 +1,4 @@ -/* $Id: entry.S,v 1.119 2000/09/06 00:45:01 davem Exp $ +/* $Id: entry.S,v 1.120 2000/09/08 13:58:12 jj Exp $ * arch/sparc64/kernel/entry.S: Sparc64 trap low-level entry points. * * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu) @@ -940,8 +940,8 @@ 1: b,pt %xcc, ret_sys_call ldx [%sp + STACK_BIAS + REGWIN_SZ + PT_V9_I0], %o0 -sparc_exit: rdpr %otherwin, %g1 - wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV), %pstate +sparc_exit: wrpr %g0, (PSTATE_RMO | PSTATE_PEF | PSTATE_PRIV), %pstate + rdpr %otherwin, %g1 rdpr %cansave, %g3 add %g3, %g1, %g3 wrpr %g3, 0x0, %cansave diff -u --recursive --new-file v2.4.0-test8/linux/arch/sparc64/kernel/sys_sparc32.c linux/arch/sparc64/kernel/sys_sparc32.c --- v2.4.0-test8/linux/arch/sparc64/kernel/sys_sparc32.c Wed Aug 23 18:36:36 2000 +++ linux/arch/sparc64/kernel/sys_sparc32.c Sun Sep 17 10:01:49 2000 @@ -1,4 +1,4 @@ -/* $Id: sys_sparc32.c,v 1.163 2000/08/22 10:09:10 jj Exp $ +/* $Id: sys_sparc32.c,v 1.164 2000/09/14 10:42:47 davem Exp $ * sys_sparc32.c: Conversion between 32bit and 64bit native syscalls. * * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) @@ -1621,7 +1621,7 @@ static void *do_ncp_super_data_conv(void *raw_data) { - struct ncp_mount_data *n = (struct ncp_mount_data *)raw_data; + struct ncp_mount_data news, *n = &news; struct ncp_mount_data32 *n32 = (struct ncp_mount_data32 *)raw_data; n->dir_mode = n32->dir_mode; @@ -1631,6 +1631,7 @@ memmove (n->mounted_vol, n32->mounted_vol, (sizeof (n32->mounted_vol) + 3 * sizeof (unsigned int))); n->wdog_pid = n32->wdog_pid; n->mounted_uid = low2highuid(n32->mounted_uid); + memcpy(raw_data, n, sizeof(struct ncp_mount_data)); return raw_data; } @@ -1645,7 +1646,7 @@ static void *do_smb_super_data_conv(void *raw_data) { - struct smb_mount_data *s = (struct smb_mount_data *)raw_data; + struct smb_mount_data news, *s = &news; struct smb_mount_data32 *s32 = (struct smb_mount_data32 *)raw_data; s->version = s32->version; @@ -1654,6 +1655,7 @@ s->gid = low2highgid(s32->gid); s->file_mode = s32->file_mode; s->dir_mode = s32->dir_mode; + memcpy(raw_data, s, sizeof(struct smb_mount_data)); return raw_data; } diff -u --recursive --new-file v2.4.0-test8/linux/arch/sparc64/kernel/time.c linux/arch/sparc64/kernel/time.c --- v2.4.0-test8/linux/arch/sparc64/kernel/time.c Fri Jul 14 12:12:08 2000 +++ linux/arch/sparc64/kernel/time.c Sun Sep 17 10:01:49 2000 @@ -1,4 +1,4 @@ -/* $Id: time.c,v 1.28 2000/07/11 02:21:12 davem Exp $ +/* $Id: time.c,v 1.29 2000/09/16 07:33:45 davem Exp $ * time.c: UltraSparc timer and TOD clock support. * * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) @@ -176,37 +176,6 @@ write_unlock(&xtime_lock); } #endif - -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. - * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 - * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. - * - * [For the Julian calendar (which was used in Russia before 1917, - * Britain & colonies before 1752, anywhere else before 1582, - * and is still in use by some communities) leave out the - * -year/100+year/400 terms, and add 10.] - * - * This algorithm was first published by Gauss (I think). - * - * WARNING: this function will overflow on 2106-02-07 06:28:16 on - * machines were long is 32-bit! (However, as time_t is signed, we - * will already get problems at other places on 2038-01-19 03:14:08) - */ -static inline unsigned long mktime(unsigned int year, unsigned int mon, - unsigned int day, unsigned int hour, - unsigned int min, unsigned int sec) -{ - if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ - mon += 12; /* Puts Feb last since it has leap day */ - year -= 1; - } - return ((( - (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) + - year*365 - 719499 - )*24 + hour /* now have hours */ - )*60 + min /* now have minutes */ - )*60 + sec; /* finally seconds */ -} /* Kick start a stopped clock (procedure from the Sun NVRAM/hostid FAQ). */ static void __init kick_start_clock(void) diff -u --recursive --new-file v2.4.0-test8/linux/arch/sparc64/lib/rwlock.S linux/arch/sparc64/lib/rwlock.S --- v2.4.0-test8/linux/arch/sparc64/lib/rwlock.S Sun Mar 19 18:35:30 2000 +++ linux/arch/sparc64/lib/rwlock.S Fri Sep 8 17:55:17 2000 @@ -1,4 +1,4 @@ -/* $Id: rwlock.S,v 1.3 2000/03/16 16:44:38 davem Exp $ +/* $Id: rwlock.S,v 1.4 2000/09/09 00:00:34 davem Exp $ * rwlocks.S: These things are too big to do inline. * * Copyright (C) 1999 David S. Miller (davem@redhat.com) @@ -30,54 +30,38 @@ cmp %g5, %g7 be,pt %xcc, 99b membar #StoreLoad | #StoreStore - b,a,pt %xcc, __read_unlock + ba,a,pt %xcc, __read_unlock __read_wait_for_writer: ldsw [%o0], %g5 brlz,pt %g5, __read_wait_for_writer membar #LoadLoad - b,a,pt %xcc, 4b -__write_wait_for_writer: - ldsw [%o0], %g5 - brlz,pt %g5, __write_wait_for_writer + ba,a,pt %xcc, 4b +__write_wait_for_any: + lduw [%o0], %g5 + brnz,pt %g5, __write_wait_for_any membar #LoadLoad - b,a,pt %xcc, 4f - - /* Similarly, 2 cache lines for non-contention write locks. */ + ba,a,pt %xcc, 4f .align 64 .globl __write_unlock __write_unlock: /* %o0 = lock_ptr */ - sethi %hi(0x80000000), %g2 -1: lduw [%o0], %g5 - andn %g5, %g2, %g7 - cas [%o0], %g5, %g7 - cmp %g5, %g7 - be,pt %icc, 99b - membar #StoreLoad | #StoreStore - b,a,pt %xcc, 1b + membar #LoadStore | #StoreStore + retl + stw %g0, [%o0] .globl __write_lock __write_lock: /* %o0 = lock_ptr */ sethi %hi(0x80000000), %g2 -1: ldsw [%o0], %g5 -4: brnz,pn %g5, 5f - or %g5, %g2, %g7 + +1: lduw [%o0], %g5 + brnz,pn %g5, __write_wait_for_any +4: or %g5, %g2, %g7 cas [%o0], %g5, %g7 + cmp %g5, %g7 be,pt %icc, 99b membar #StoreLoad | #StoreStore - - b,a,pt %xcc, 1b -5: brlz %g5, __write_wait_for_writer - or %g5, %g2, %g7 - cas [%o0], %g5, %g7 - cmp %g5, %g7 - bne,pn %icc, 5b -8: ldsw [%o0], %g5 - cmp %g5, %g2 - be,pn %icc, 99b - membar #LoadLoad - b,a,pt %xcc, 99b + ba,a,pt %xcc, 1b rwlock_impl_end: diff -u --recursive --new-file v2.4.0-test8/linux/arch/sparc64/mm/fault.c linux/arch/sparc64/mm/fault.c --- v2.4.0-test8/linux/arch/sparc64/mm/fault.c Wed Aug 23 18:36:36 2000 +++ linux/arch/sparc64/mm/fault.c Sun Sep 17 10:01:50 2000 @@ -1,4 +1,4 @@ -/* $Id: fault.c,v 1.50 2000/08/11 03:00:13 davem Exp $ +/* $Id: fault.c,v 1.51 2000/09/14 06:22:32 anton Exp $ * arch/sparc64/mm/fault.c: Page fault handlers for the 64-bit Sparc. * * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) @@ -145,7 +145,7 @@ if (!insn) { if (regs->tstate & TSTATE_PRIV) { - if (regs->tpc & 0x3) + if (!regs->tpc || (regs->tpc & 0x3)) goto cannot_handle; insn = *(unsigned int *)regs->tpc; } else { diff -u --recursive --new-file v2.4.0-test8/linux/arch/sparc64/mm/init.c linux/arch/sparc64/mm/init.c --- v2.4.0-test8/linux/arch/sparc64/mm/init.c Fri Sep 8 13:27:11 2000 +++ linux/arch/sparc64/mm/init.c Fri Sep 8 17:55:17 2000 @@ -1,4 +1,4 @@ -/* $Id: init.c,v 1.154 2000/08/09 00:00:15 davem Exp $ +/* $Id: init.c,v 1.155 2000/09/09 00:02:19 davem Exp $ * arch/sparc64/mm/init.c * * Copyright (C) 1996-1999 David S. Miller (davem@caip.rutgers.edu) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/Makefile linux/drivers/Makefile --- v2.4.0-test8/linux/drivers/Makefile Wed Aug 23 18:36:36 2000 +++ linux/drivers/Makefile Sun Sep 17 09:48:04 2000 @@ -63,7 +63,7 @@ MOD_SUB_DIRS += macintosh endif -ifdef CONFIG_PPC +ifdef CONFIG_ALL_PPC SUB_DIRS += macintosh MOD_SUB_DIRS += macintosh endif diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/Makefile linux/drivers/acpi/Makefile --- v2.4.0-test8/linux/drivers/acpi/Makefile Fri Jul 14 12:12:08 2000 +++ linux/drivers/acpi/Makefile Fri Sep 15 18:21:43 2000 @@ -2,7 +2,7 @@ # Makefile for the Linux ACPI interpreter # -SUB_DIRS := +SUB_DIRS := MOD_SUB_DIRS := $(SUB_DIRS) MOD_IN_SUB_DIRS := ALL_SUB_DIRS := $(SUB_DIRS) @@ -11,13 +11,22 @@ O_OBJS := M_OBJS := -ACPI_OBJS := driver.o ec.o cpu.o os.o sys.o tables.o -ACPI_OBJS += $(patsubst %.c,%.o,$(wildcard */*.c)) +export ACPI_CFLAGS +ACPI_CFLAGS := -D_LINUX -EXTRA_CFLAGS += -I./include -D_LINUX +EXTRA_CFLAGS += -I./include + +EXTRA_CFLAGS += $(ACPI_CFLAGS) # if the interpreter is used, it overrides arch/i386/kernel/acpi.c ifeq ($(CONFIG_ACPI_INTERPRETER),y) + + SUB_DIRS += common dispatcher events hardware\ + interpreter namespace parser resources tables + + ACPI_OBJS := $(patsubst %,%.o,$(SUB_DIRS)) + ACPI_OBJS += $(patsubst %.c,%.o,$(wildcard *.c)) + O_OBJS += $(ACPI_OBJS) endif diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/common/Makefile linux/drivers/acpi/common/Makefile --- v2.4.0-test8/linux/drivers/acpi/common/Makefile Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/common/Makefile Fri Sep 15 18:21:43 2000 @@ -0,0 +1,28 @@ +# +# Makefile for all Linux ACPI interpreter subdirectories +# + +SUB_DIRS := +MOD_SUB_DIRS := $(SUB_DIRS) +MOD_IN_SUB_DIRS := +ALL_SUB_DIRS := $(SUB_DIRS) + +O_TARGET := ../$(shell basename `pwd`).o +O_OBJS := +M_OBJS := + +ACPI_OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) + +EXTRA_CFLAGS += -I../include + +EXTRA_CFLAGS += $(ACPI_CFLAGS) + +# if the interpreter is used, it overrides arch/i386/kernel/acpi.c +ifeq ($(CONFIG_ACPI_INTERPRETER),y) + O_OBJS := $(ACPI_OBJS) +endif + +include $(TOPDIR)/Rules.make + +clean: + $(RM) *.o diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/common/cmalloc.c linux/drivers/acpi/common/cmalloc.c --- v2.4.0-test8/linux/drivers/acpi/common/cmalloc.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/common/cmalloc.c Fri Sep 15 14:30:29 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: cmalloc - local memory allocation routines + * $Revision: 73 $ * *****************************************************************************/ @@ -24,13 +25,13 @@ #include "acpi.h" -#include "parser.h" -#include "interp.h" -#include "namesp.h" -#include "globals.h" +#include "acparser.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acglobal.h" #define _COMPONENT MISCELLANEOUS - MODULE_NAME ("cmalloc"); + MODULE_NAME ("cmalloc") /***************************************************************************** @@ -52,8 +53,8 @@ _cm_allocate ( u32 size, u32 component, - ACPI_STRING module, - s32 line) + NATIVE_CHAR *module, + u32 line) { void *address = NULL; @@ -98,8 +99,8 @@ _cm_callocate ( u32 size, u32 component, - ACPI_STRING module, - s32 line) + NATIVE_CHAR *module, + u32 line) { void *address = NULL; @@ -146,8 +147,8 @@ _cm_free ( void *address, u32 component, - ACPI_STRING module, - s32 line) + NATIVE_CHAR *module, + u32 line) { if (NULL == address) { diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/common/cmclib.c linux/drivers/acpi/common/cmclib.c --- v2.4.0-test8/linux/drivers/acpi/common/cmclib.c Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/common/cmclib.c Fri Sep 15 14:30:29 2000 @@ -0,0 +1,821 @@ +/****************************************************************************** + * + * Module Name: cmclib - Local implementation of C library functions + * $Revision: 24 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + + +#include "acpi.h" +#include "acevents.h" +#include "achware.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "amlcode.h" + +/* + * These implementations of standard C Library routines can optionally be + * used if a C library is not available. In general, they are less efficient + * than an inline or assembly implementation + */ + +#define _COMPONENT MISCELLANEOUS + MODULE_NAME ("cmclib") + + +#ifdef _MSC_VER /* disable some level-4 warnings for VC++ */ +#pragma warning(disable:4706) /* warning C4706: assignment within conditional expression */ +#endif + +#ifndef ACPI_USE_SYSTEM_CLIBRARY + +/******************************************************************************* + * + * FUNCTION: strlen + * + * PARAMETERS: String - Null terminated string + * + * RETURN: Length + * + * DESCRIPTION: Returns the length of the input string + * + ******************************************************************************/ + + +NATIVE_UINT +acpi_cm_strlen ( + const NATIVE_CHAR *string) +{ + NATIVE_UINT length = 0; + + + /* Count the string until a null is encountered */ + + while (*string) { + length++; + string++; + } + + return (length); +} + + +/******************************************************************************* + * + * FUNCTION: strcpy + * + * PARAMETERS: Dst_string - Target of the copy + * Src_string - The source string to copy + * + * RETURN: Dst_string + * + * DESCRIPTION: Copy a null terminated string + * + ******************************************************************************/ + +NATIVE_CHAR * +acpi_cm_strcpy ( + NATIVE_CHAR *dst_string, + const NATIVE_CHAR *src_string) +{ + NATIVE_CHAR *string = dst_string; + + + /* Move bytes brute force */ + + while (*src_string) { + *string = *src_string; + + string++; + src_string++; + } + + /* Null terminate */ + + *string = 0; + + return (dst_string); +} + + +/******************************************************************************* + * + * FUNCTION: strncpy + * + * PARAMETERS: Dst_string - Target of the copy + * Src_string - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: Dst_string + * + * DESCRIPTION: Copy a null terminated string, with a maximum length + * + ******************************************************************************/ + +NATIVE_CHAR * +acpi_cm_strncpy ( + NATIVE_CHAR *dst_string, + const NATIVE_CHAR *src_string, + NATIVE_UINT count) +{ + NATIVE_CHAR *string = dst_string; + + + /* Copy the string */ + + for (string = dst_string; + count && (count--, (*string++ = *src_string++)); ) + {;} + + /* Pad with nulls if necessary */ + + while (count--) { + *string = 0; + string++; + } + + /* Return original pointer */ + + return (dst_string); +} + + +/******************************************************************************* + * + * FUNCTION: strcmp + * + * PARAMETERS: String1 - First string + * String2 - Second string + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings + * + ******************************************************************************/ + +u32 +acpi_cm_strcmp ( + const NATIVE_CHAR *string1, + const NATIVE_CHAR *string2) +{ + + + for ( ; (*string1 == *string2); string2++) { + if (!*string1++) { + return (0); + } + } + + + return ((unsigned char) *string1 - (unsigned char) *string2); +} + + +/******************************************************************************* + * + * FUNCTION: strncmp + * + * PARAMETERS: String1 - First string + * String2 - Second string + * Count - Maximum # of bytes to compare + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings, with a maximum length + * + ******************************************************************************/ + +u32 +acpi_cm_strncmp ( + const NATIVE_CHAR *string1, + const NATIVE_CHAR *string2, + NATIVE_UINT count) +{ + + + for ( ; count-- && (*string1 == *string2); string2++) { + if (!*string1++) { + return (0); + } + } + + return ((count == -1) ? 0 : ((unsigned char) *string1 - + (unsigned char) *string2)); +} + + +/******************************************************************************* + * + * FUNCTION: Strcat + * + * PARAMETERS: Dst_string - Target of the copy + * Src_string - The source string to copy + * + * RETURN: Dst_string + * + * DESCRIPTION: Append a null terminated string to a null terminated string + * + ******************************************************************************/ + +NATIVE_CHAR * +acpi_cm_strcat ( + NATIVE_CHAR *dst_string, + const NATIVE_CHAR *src_string) +{ + NATIVE_CHAR *string; + + + /* Find end of the destination string */ + + for (string = dst_string; *string++; ) { ; } + + /* Concatinate the string */ + + for (--string; (*string++ = *src_string++); ) { ; } + + return (dst_string); +} + + +/******************************************************************************* + * + * FUNCTION: strncat + * + * PARAMETERS: Dst_string - Target of the copy + * Src_string - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: Dst_string + * + * DESCRIPTION: Append a null terminated string to a null terminated string, + * with a maximum count. + * + ******************************************************************************/ + +NATIVE_CHAR * +acpi_cm_strncat ( + NATIVE_CHAR *dst_string, + const NATIVE_CHAR *src_string, + NATIVE_UINT count) +{ + NATIVE_CHAR *string; + + + if (count) { + /* Find end of the destination string */ + + for (string = dst_string; *string++; ) { ; } + + /* Concatinate the string */ + + for (--string; (*string++ = *src_string++) && --count; ) { ; } + + /* Null terminate if necessary */ + + if (!count) { + *string = 0; + } + } + + return (dst_string); +} + + +/******************************************************************************* + * + * FUNCTION: memcpy + * + * PARAMETERS: Dest - Target of the copy + * Src - Source buffer to copy + * Count - Number of bytes to copy + * + * RETURN: Dest + * + * DESCRIPTION: Copy arbitrary bytes of memory + * + ******************************************************************************/ + +void * +acpi_cm_memcpy ( + void *dest, + const void *src, + NATIVE_UINT count) +{ + NATIVE_CHAR *new = (NATIVE_CHAR *) dest; + NATIVE_CHAR *old = (NATIVE_CHAR *) src; + + + while (count) { + *new = *old; + new++; + old++; + count--; + } + + return (dest); +} + + +/******************************************************************************* + * + * FUNCTION: memset + * + * PARAMETERS: Dest - Buffer to set + * Value - Value to set each byte of memory + * Count - Number of bytes to set + * + * RETURN: Dest + * + * DESCRIPTION: Initialize a buffer to a known value. + * + ******************************************************************************/ + +void * +acpi_cm_memset ( + void *dest, + u32 value, + NATIVE_UINT count) +{ + NATIVE_CHAR *new = (NATIVE_CHAR *) dest; + + + while (count) { + *new = (char) value; + new++; + count--; + } + + return (dest); +} + + +#define NEGATIVE 1 +#define POSITIVE 0 + + +#define _XA 0x00 /* extra alphabetic - not supported */ +#define _XS 0x40 /* extra space */ +#define _BB 0x00 /* BEL, BS, etc. - not supported */ +#define _CN 0x20 /* CR, FF, HT, NL, VT */ +#define _DI 0x04 /* '0'-'9' */ +#define _LO 0x02 /* 'a'-'z' */ +#define _PU 0x10 /* punctuation */ +#define _SP 0x08 /* space */ +#define _UP 0x01 /* 'A'-'Z' */ +#define _XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ + +const u8 _ctype[257] = { + _CN, /* 0x0 0. */ + _CN, /* 0x1 1. */ + _CN, /* 0x2 2. */ + _CN, /* 0x3 3. */ + _CN, /* 0x4 4. */ + _CN, /* 0x5 5. */ + _CN, /* 0x6 6. */ + _CN, /* 0x7 7. */ + _CN, /* 0x8 8. */ + _CN|_SP, /* 0x9 9. */ + _CN|_SP, /* 0xA 10. */ + _CN|_SP, /* 0xB 11. */ + _CN|_SP, /* 0xC 12. */ + _CN|_SP, /* 0xD 13. */ + _CN, /* 0xE 14. */ + _CN, /* 0xF 15. */ + _CN, /* 0x10 16. */ + _CN, /* 0x11 17. */ + _CN, /* 0x12 18. */ + _CN, /* 0x13 19. */ + _CN, /* 0x14 20. */ + _CN, /* 0x15 21. */ + _CN, /* 0x16 22. */ + _CN, /* 0x17 23. */ + _CN, /* 0x18 24. */ + _CN, /* 0x19 25. */ + _CN, /* 0x1A 26. */ + _CN, /* 0x1B 27. */ + _CN, /* 0x1C 28. */ + _CN, /* 0x1D 29. */ + _CN, /* 0x1E 30. */ + _CN, /* 0x1F 31. */ + _XS|_SP, /* 0x20 32. ' ' */ + _PU, /* 0x21 33. '!' */ + _PU, /* 0x22 34. '"' */ + _PU, /* 0x23 35. '#' */ + _PU, /* 0x24 36. '$' */ + _PU, /* 0x25 37. '%' */ + _PU, /* 0x26 38. '&' */ + _PU, /* 0x27 39. ''' */ + _PU, /* 0x28 40. '(' */ + _PU, /* 0x29 41. ')' */ + _PU, /* 0x2A 42. '*' */ + _PU, /* 0x2B 43. '+' */ + _PU, /* 0x2C 44. ',' */ + _PU, /* 0x2D 45. '-' */ + _PU, /* 0x2E 46. '.' */ + _PU, /* 0x2F 47. '/' */ + _XD|_DI, /* 0x30 48. '0' */ + _XD|_DI, /* 0x31 49. '1' */ + _XD|_DI, /* 0x32 50. '2' */ + _XD|_DI, /* 0x33 51. '3' */ + _XD|_DI, /* 0x34 52. '4' */ + _XD|_DI, /* 0x35 53. '5' */ + _XD|_DI, /* 0x36 54. '6' */ + _XD|_DI, /* 0x37 55. '7' */ + _XD|_DI, /* 0x38 56. '8' */ + _XD|_DI, /* 0x39 57. '9' */ + _PU, /* 0x3A 58. ':' */ + _PU, /* 0x3B 59. ';' */ + _PU, /* 0x3C 60. '<' */ + _PU, /* 0x3D 61. '=' */ + _PU, /* 0x3E 62. '>' */ + _PU, /* 0x3F 63. '?' */ + _PU, /* 0x40 64. '@' */ + _XD|_UP, /* 0x41 65. 'A' */ + _XD|_UP, /* 0x42 66. 'B' */ + _XD|_UP, /* 0x43 67. 'C' */ + _XD|_UP, /* 0x44 68. 'D' */ + _XD|_UP, /* 0x45 69. 'E' */ + _XD|_UP, /* 0x46 70. 'F' */ + _UP, /* 0x47 71. 'G' */ + _UP, /* 0x48 72. 'H' */ + _UP, /* 0x49 73. 'I' */ + _UP, /* 0x4A 74. 'J' */ + _UP, /* 0x4B 75. 'K' */ + _UP, /* 0x4C 76. 'L' */ + _UP, /* 0x4D 77. 'M' */ + _UP, /* 0x4E 78. 'N' */ + _UP, /* 0x4F 79. 'O' */ + _UP, /* 0x50 80. 'P' */ + _UP, /* 0x51 81. 'Q' */ + _UP, /* 0x52 82. 'R' */ + _UP, /* 0x53 83. 'S' */ + _UP, /* 0x54 84. 'T' */ + _UP, /* 0x55 85. 'U' */ + _UP, /* 0x56 86. 'V' */ + _UP, /* 0x57 87. 'W' */ + _UP, /* 0x58 88. 'X' */ + _UP, /* 0x59 89. 'Y' */ + _UP, /* 0x5A 90. 'Z' */ + _PU, /* 0x5B 91. '[' */ + _PU, /* 0x5C 92. '\' */ + _PU, /* 0x5D 93. ']' */ + _PU, /* 0x5E 94. '^' */ + _PU, /* 0x5F 95. '_' */ + _PU, /* 0x60 96. '`' */ + _XD|_LO, /* 0x61 97. 'a' */ + _XD|_LO, /* 0x62 98. 'b' */ + _XD|_LO, /* 0x63 99. 'c' */ + _XD|_LO, /* 0x64 100. 'd' */ + _XD|_LO, /* 0x65 101. 'e' */ + _XD|_LO, /* 0x66 102. 'f' */ + _LO, /* 0x67 103. 'g' */ + _LO, /* 0x68 104. 'h' */ + _LO, /* 0x69 105. 'i' */ + _LO, /* 0x6A 106. 'j' */ + _LO, /* 0x6B 107. 'k' */ + _LO, /* 0x6C 108. 'l' */ + _LO, /* 0x6D 109. 'm' */ + _LO, /* 0x6E 110. 'n' */ + _LO, /* 0x6F 111. 'o' */ + _LO, /* 0x70 112. 'p' */ + _LO, /* 0x71 113. 'q' */ + _LO, /* 0x72 114. 'r' */ + _LO, /* 0x73 115. 's' */ + _LO, /* 0x74 116. 't' */ + _LO, /* 0x75 117. 'u' */ + _LO, /* 0x76 118. 'v' */ + _LO, /* 0x77 119. 'w' */ + _LO, /* 0x78 120. 'x' */ + _LO, /* 0x79 121. 'y' */ + _LO, /* 0x7A 122. 'z' */ + _PU, /* 0x7B 123. '{' */ + _PU, /* 0x7C 124. '|' */ + _PU, /* 0x7D 125. '}' */ + _PU, /* 0x7E 126. '~' */ + _CN, /* 0x7F 127. */ + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80 to 0x8F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90 to 0x9F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xA0 to 0xAF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xB0 to 0xBF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xC0 to 0xCF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xD0 to 0xDF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xE0 to 0xEF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xF0 to 0x100 */ +}; + +#define IS_UPPER(c) (_ctype[(unsigned char)(c)] & (_UP)) +#define IS_LOWER(c) (_ctype[(unsigned char)(c)] & (_LO)) +#define IS_DIGIT(c) (_ctype[(unsigned char)(c)] & (_DI)) +#define IS_SPACE(c) (_ctype[(unsigned char)(c)] & (_SP)) + + +/******************************************************************************* + * + * FUNCTION: Acpi_cm_to_upper + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: Convert character to uppercase + * + ******************************************************************************/ + +u32 +acpi_cm_to_upper ( + u32 c) +{ + + return (IS_LOWER(c) ? ((c)-0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_cm_to_lower + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: Convert character to lowercase + * + ******************************************************************************/ + +u32 +acpi_cm_to_lower ( + u32 c) +{ + + return (IS_UPPER(c) ? ((c)+0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: strupr + * + * PARAMETERS: Src_string - The source string to convert to + * + * RETURN: Src_string + * + * DESCRIPTION: Convert string to uppercase + * + ******************************************************************************/ + +NATIVE_CHAR * +acpi_cm_strupr ( + NATIVE_CHAR *src_string) +{ + NATIVE_CHAR *string; + + + /* Walk entire string, uppercasing the letters */ + + for (string = src_string; *string; ) { + *string = (char) acpi_cm_to_upper (*string); + string++; + } + + + return (src_string); +} + + +/******************************************************************************* + * + * FUNCTION: strstr + * + * PARAMETERS: String1 - + * String2 + * + * RETURN: + * + * DESCRIPTION: Checks if String2 occurs in String1. This is not really a + * full implementation of strstr, only sufficient for command + * matching + * + ******************************************************************************/ + +NATIVE_CHAR * +acpi_cm_strstr ( + NATIVE_CHAR *string1, + NATIVE_CHAR *string2) +{ + NATIVE_CHAR *string; + + + if (acpi_cm_strlen (string2) > acpi_cm_strlen (string1)) { + return (NULL); + } + + /* Walk entire string, uppercasing the letters */ + + for (string = string1; *string2; ) { + if (*string2 != *string) { + return (NULL); + } + + string2++; + string++; + } + + + return (string1); +} + + +/******************************************************************************* + * + * FUNCTION: strtoul + * + * PARAMETERS: String - Null terminated string + * Terminater - Where a pointer to the terminating byte is returned + * Base - Radix of the string + * + * RETURN: Converted value + * + * DESCRIPTION: Convert a string into an unsigned value. + * + ******************************************************************************/ + +u32 +acpi_cm_strtoul ( + const NATIVE_CHAR *string, + NATIVE_CHAR **terminator, + u32 base) +{ + u32 converted = 0; + u32 index; + u32 sign; + const NATIVE_CHAR *string_start; + u32 return_value = 0; + ACPI_STATUS status = AE_OK; + + + /* + * Save the value of the pointer to the buffer's first + * character, save the current errno value, and then + * skip over any white space in the buffer: + */ + string_start = string; + while (IS_SPACE (*string) || *string == '\t') { + ++string; + } + + /* + * The buffer may contain an optional plus or minus sign. + * If it does, then skip over it but remember what is was: + */ + if (*string == '-') { + sign = NEGATIVE; + ++string; + } + + else if (*string == '+') { + ++string; + sign = POSITIVE; + } + + else { + sign = POSITIVE; + } + + /* + * If the input parameter Base is zero, then we need to + * determine if it is octal, decimal, or hexadecimal: + */ + if (base == 0) { + if (*string == '0') { + if (acpi_cm_to_lower (*(++string)) == 'x') { + base = 16; + ++string; + } + + else { + base = 8; + } + } + + else { + base = 10; + } + } + + else if (base < 2 || base > 36) { + /* + * The specified Base parameter is not in the domain of + * this function: + */ + goto done; + } + + /* + * For octal and hexadecimal bases, skip over the leading + * 0 or 0x, if they are present. + */ + if (base == 8 && *string == '0') { + string++; + } + + if (base == 16 && + *string == '0' && + acpi_cm_to_lower (*(++string)) == 'x') + { + string++; + } + + + /* + * Main loop: convert the string to an unsigned long: + */ + while (*string) { + if (IS_DIGIT (*string)) { + index = *string - '0'; + } + + else { + index = acpi_cm_to_upper (*string); + if (IS_UPPER (index)) { + index = index - 'A' + 10; + } + + else { + goto done; + } + } + + if (index >= base) { + goto done; + } + + /* + * Check to see if value is out of range: + */ + + if (return_value > ((ACPI_UINT32_MAX - (u32) index) / + (u32) base)) + { + status = AE_ERROR; + return_value = 0L; /* reset */ + } + + else { + return_value *= base; + return_value += index; + converted = 1; + } + + ++string; + } + +done: + /* + * If appropriate, update the caller's pointer to the next + * unconverted character in the buffer. + */ + if (terminator) { + if (converted == 0 && return_value == 0L && string != NULL) { + *terminator = (NATIVE_CHAR *) string_start; + } + + else { + *terminator = (NATIVE_CHAR *) string; + } + } + + if (status == AE_ERROR) { + return_value = ACPI_UINT32_MAX; + } + + /* + * If a minus sign was present, then "the conversion is negated": + */ + if (sign == NEGATIVE) { + return_value = (ACPI_UINT32_MAX - return_value) + 1; + } + + return (return_value); +} + +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ + diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/common/cmcopy.c linux/drivers/acpi/common/cmcopy.c --- v2.4.0-test8/linux/drivers/acpi/common/cmcopy.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/common/cmcopy.c Fri Sep 15 14:30:29 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: cmcopy - Internal to external object translation utilities + * $Revision: 56 $ * *****************************************************************************/ @@ -24,17 +25,17 @@ #include "acpi.h" -#include "interp.h" -#include "namesp.h" +#include "acinterp.h" +#include "acnamesp.h" #define _COMPONENT MISCELLANEOUS - MODULE_NAME ("cmcopy"); + MODULE_NAME ("cmcopy") typedef struct search_st { - ACPI_OBJECT_INTERNAL *internal_obj; + ACPI_OPERAND_OBJECT *internal_obj; u32 index; ACPI_OBJECT *external_obj; @@ -64,13 +65,13 @@ ACPI_STATUS acpi_cm_build_external_simple_object ( - ACPI_OBJECT_INTERNAL *internal_obj, + ACPI_OPERAND_OBJECT *internal_obj, ACPI_OBJECT *external_obj, u8 *data_space, u32 *buffer_space_used) { u32 length = 0; - char *source_ptr = NULL; + u8 *source_ptr = NULL; /* @@ -103,8 +104,8 @@ length = internal_obj->string.length; external_obj->string.length = internal_obj->string.length; - external_obj->string.pointer = (char *) data_space; - source_ptr = internal_obj->string.pointer; + external_obj->string.pointer = (NATIVE_CHAR *) data_space; + source_ptr = (u8 *) internal_obj->string.pointer; break; @@ -113,7 +114,7 @@ length = internal_obj->buffer.length; external_obj->buffer.length = internal_obj->buffer.length; external_obj->buffer.pointer = data_space; - source_ptr = (char *) internal_obj->buffer.pointer; + source_ptr = (u8 *) internal_obj->buffer.pointer; break; @@ -132,7 +133,7 @@ */ external_obj->type = ACPI_TYPE_ANY; - external_obj->reference.handle = internal_obj->reference.nte; + external_obj->reference.handle = internal_obj->reference.node; break; @@ -142,10 +143,10 @@ internal_obj->processor.proc_id; external_obj->processor.pblk_address = - internal_obj->processor.pblk_address; + internal_obj->processor.address; external_obj->processor.pblk_length = - internal_obj->processor.pblk_length; + internal_obj->processor.length; break; case ACPI_TYPE_POWER: @@ -200,7 +201,7 @@ ACPI_STATUS acpi_cm_build_external_package_object ( - ACPI_OBJECT_INTERNAL *internal_obj, + ACPI_OPERAND_OBJECT *internal_obj, u8 *buffer, u32 *space_used) { @@ -211,7 +212,7 @@ u32 length = 0; u32 this_index; u32 object_space; - ACPI_OBJECT_INTERNAL *this_internal_obj; + ACPI_OPERAND_OBJECT *this_internal_obj; ACPI_OBJECT *this_external_obj; PKG_SEARCH_INFO *level_ptr; @@ -256,7 +257,7 @@ while (1) { this_index = level_ptr->index; this_internal_obj = - (ACPI_OBJECT_INTERNAL *) + (ACPI_OPERAND_OBJECT *) level_ptr->internal_obj->package.elements[this_index]; this_external_obj = (ACPI_OBJECT *) @@ -264,10 +265,11 @@ /* - * Check for 1) Null object -- OK, this can happen if package + * Check for + * 1) Null object -- OK, this can happen if package * element is never initialized - * 2) Not an internal object - can be an NTE instead - * 3) Any internal object other than a package. + * 2) Not an internal object - can be Node instead + * 3) Any internal object other than a package. * * The more complex package case is handled later */ @@ -367,8 +369,6 @@ level_ptr->index = 0; } } - - return (AE_OK); } @@ -388,7 +388,7 @@ ACPI_STATUS acpi_cm_build_external_object ( - ACPI_OBJECT_INTERNAL *internal_obj, + ACPI_OPERAND_OBJECT *internal_obj, ACPI_BUFFER *ret_buffer) { ACPI_STATUS status; @@ -446,7 +446,7 @@ ACPI_STATUS acpi_cm_build_internal_simple_object ( ACPI_OBJECT *external_obj, - ACPI_OBJECT_INTERNAL *internal_obj) + ACPI_OPERAND_OBJECT *internal_obj) { @@ -508,18 +508,17 @@ ACPI_STATUS acpi_cm_build_internal_package_object ( - ACPI_OBJECT_INTERNAL *internal_obj, + ACPI_OPERAND_OBJECT *internal_obj, u8 *buffer, u32 *space_used) { u8 *free_space; ACPI_OBJECT *external_obj; u32 current_depth = 0; - ACPI_STATUS status = AE_OK; u32 length = 0; u32 this_index; u32 object_space = 0; - ACPI_OBJECT_INTERNAL *this_internal_obj; + ACPI_OPERAND_OBJECT *this_internal_obj; ACPI_OBJECT *this_external_obj; PKG_SEARCH_INFO *level_ptr; @@ -562,7 +561,7 @@ while (1) { this_index = level_ptr->index; - this_internal_obj = (ACPI_OBJECT_INTERNAL *) + this_internal_obj = (ACPI_OPERAND_OBJECT *) &level_ptr->internal_obj->package.elements[this_index]; this_external_obj = (ACPI_OBJECT *) @@ -605,17 +604,6 @@ } /* if object is a package */ else { -/* Status = Acpi_cm_build_simple_object(This_internal_obj, - This_external_obj, Free_space, - &Object_space); -*/ - if (status != AE_OK) { - /* - * Failure get out - */ - return (status); - } - free_space += object_space; length += object_space; @@ -651,13 +639,6 @@ } } /* else object is NOT a package */ } /* while (1) */ - - - /* - * We'll never get here, but the compiler whines about - * return value - */ - return (AE_OK); } @@ -677,7 +658,7 @@ ACPI_STATUS acpi_cm_build_internal_object ( ACPI_OBJECT *external_obj, - ACPI_OBJECT_INTERNAL *internal_obj) + ACPI_OPERAND_OBJECT *internal_obj) { ACPI_STATUS status; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/common/cmdebug.c linux/drivers/acpi/common/cmdebug.c --- v2.4.0-test8/linux/drivers/acpi/common/cmdebug.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/common/cmdebug.c Fri Sep 15 14:30:29 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: cmdebug - Debug print routines + * $Revision: 60 $ * *****************************************************************************/ @@ -27,7 +27,7 @@ #include "acpi.h" #define _COMPONENT MISCELLANEOUS - MODULE_NAME ("cmdebug"); + MODULE_NAME ("cmdebug") /***************************************************************************** @@ -41,16 +41,16 @@ ****************************************************************************/ -s32 +u32 get_debug_level (void) { - return acpi_dbg_level; + return (acpi_dbg_level); } void set_debug_level ( - s32 new_debug_level) + u32 new_debug_level) { acpi_dbg_level = new_debug_level; @@ -75,10 +75,10 @@ void function_trace ( - char *module_name, - s32 line_number, - s32 component_id, - char *function_name) + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name) { acpi_gbl_nesting_level++; @@ -109,10 +109,10 @@ void function_trace_ptr ( - char *module_name, - s32 line_number, - s32 component_id, - char *function_name, + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name, void *pointer) { @@ -142,11 +142,11 @@ void function_trace_str ( - char *module_name, - s32 line_number, - s32 component_id, - char *function_name, - char *string) + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name, + NATIVE_CHAR *string) { acpi_gbl_nesting_level++; @@ -175,16 +175,16 @@ void function_trace_u32 ( - char *module_name, - s32 line_number, - s32 component_id, - char *function_name, + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name, u32 integer) { acpi_gbl_nesting_level++; debug_print (module_name, line_number, component_id, TRACE_FUNCTIONS, - " %2.2ld Entered Function: %s, 0x%l_x\n", + " %2.2ld Entered Function: %s, 0x%lX\n", acpi_gbl_nesting_level, function_name, integer); } @@ -207,10 +207,10 @@ void function_exit ( - char *module_name, - s32 line_number, - s32 component_id, - char *function_name) + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name) { debug_print (module_name, line_number, component_id, TRACE_FUNCTIONS, @@ -240,30 +240,19 @@ void function_status_exit ( - char *module_name, - s32 line_number, - s32 component_id, - char *function_name, + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name, ACPI_STATUS status) { - if (status > ACPI_MAX_STATUS) { - debug_print (module_name, line_number, component_id, - TRACE_FUNCTIONS, - " %2.2ld Exiting Function: %s, [Unknown Status] 0x%X\n", - acpi_gbl_nesting_level, - function_name, - status); - } - - else { - debug_print (module_name, line_number, component_id, - TRACE_FUNCTIONS, - " %2.2ld Exiting Function: %s, %s\n", - acpi_gbl_nesting_level, - function_name, - acpi_cm_format_exception (status)); - } + debug_print (module_name, line_number, component_id, + TRACE_FUNCTIONS, + " %2.2ld Exiting Function: %s, %s\n", + acpi_gbl_nesting_level, + function_name, + acpi_cm_format_exception (status)); acpi_gbl_nesting_level--; } @@ -288,10 +277,10 @@ void function_value_exit ( - char *module_name, - s32 line_number, - s32 component_id, - char *function_name, + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name, NATIVE_UINT value) { @@ -322,11 +311,11 @@ void function_ptr_exit ( - char *module_name, - s32 line_number, - s32 component_id, - char *function_name, - char *ptr) + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name, + u8 *ptr) { debug_print (module_name, line_number, component_id, TRACE_FUNCTIONS, @@ -357,11 +346,11 @@ void debug_print ( - char *module_name, - s32 line_number, - s32 component_id, - s32 print_level, - char *format, + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + u32 print_level, + NATIVE_CHAR *format, ...) { va_list args; @@ -397,8 +386,8 @@ void debug_print_prefix ( - char *module_name, - s32 line_number) + NATIVE_CHAR *module_name, + u32 line_number) { @@ -421,7 +410,7 @@ void debug_print_raw ( - char *format, + NATIVE_CHAR *format, ...) { va_list args; @@ -451,10 +440,10 @@ void acpi_cm_dump_buffer ( - char *buffer, + u8 *buffer, u32 count, u32 display, - s32 component_id) + u32 component_id) { u32 i = 0; u32 j; @@ -477,7 +466,7 @@ while (i < count) { /* Print current offset */ - acpi_os_printf ("%05_x ", i); + acpi_os_printf ("%05X ", i); /* Print 16 hex chars */ @@ -488,7 +477,7 @@ return; } - /* Make sure that the char doesn't get sign-extended! */ + /* Make sure that the s8 doesn't get sign-extended! */ switch (display) { @@ -496,7 +485,7 @@ default: - acpi_os_printf ("%02_x ", + acpi_os_printf ("%02X ", *((u8 *) &buffer[i + j])); j += 1; break; @@ -506,7 +495,7 @@ MOVE_UNALIGNED16_TO_32 (&temp32, &buffer[i + j]); - acpi_os_printf ("%04_x ", temp32); + acpi_os_printf ("%04X ", temp32); j += 2; break; @@ -515,7 +504,7 @@ MOVE_UNALIGNED32_TO_32 (&temp32, &buffer[i + j]); - acpi_os_printf ("%08_x ", temp32); + acpi_os_printf ("%08X ", temp32); j += 4; break; @@ -524,11 +513,11 @@ MOVE_UNALIGNED32_TO_32 (&temp32, &buffer[i + j]); - acpi_os_printf ("%08_x", temp32); + acpi_os_printf ("%08X", temp32); MOVE_UNALIGNED32_TO_32 (&temp32, &buffer[i + j + 4]); - acpi_os_printf ("%08_x ", temp32); + acpi_os_printf ("%08X ", temp32); j += 8; break; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/common/cmdelete.c linux/drivers/acpi/common/cmdelete.c --- v2.4.0-test8/linux/drivers/acpi/common/cmdelete.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/common/cmdelete.c Fri Sep 15 14:30:29 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: cmdelete - object deletion and reference count utilities + * $Revision: 53 $ * *****************************************************************************/ @@ -25,13 +25,13 @@ #include "acpi.h" -#include "interp.h" -#include "namesp.h" -#include "tables.h" -#include "parser.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acparser.h" #define _COMPONENT MISCELLANEOUS - MODULE_NAME ("cmdelete"); + MODULE_NAME ("cmdelete") /****************************************************************************** @@ -49,7 +49,7 @@ void acpi_cm_delete_internal_obj ( - ACPI_OBJECT_INTERNAL *object) + ACPI_OPERAND_OBJECT *object) { void *obj_pointer = NULL; @@ -110,14 +110,7 @@ case ACPI_TYPE_METHOD: - /* Delete parse tree if it exists */ - - if (object->method.parser_op) { - acpi_ps_delete_parse_tree (object->method.parser_op); - object->method.parser_op = NULL; - } - - /* Delete semaphore if it exists */ + /* Delete the method semaphore if it exists */ if (object->method.semaphore) { acpi_os_delete_semaphore (object->method.semaphore); @@ -146,7 +139,7 @@ /* Only delete the object if it was dynamically allocated */ - if (!(object->common.flags & AO_STATIC_ALLOCATION)) { + if (!(object->common.flags & AOPOBJ_STATIC_ALLOCATION)) { acpi_cm_delete_object_desc (object); } @@ -170,9 +163,9 @@ ACPI_STATUS acpi_cm_delete_internal_object_list ( - ACPI_OBJECT_INTERNAL **obj_list) + ACPI_OPERAND_OBJECT **obj_list) { - ACPI_OBJECT_INTERNAL **internal_obj; + ACPI_OPERAND_OBJECT **internal_obj; /* Walk the null-terminated internal list */ @@ -220,8 +213,8 @@ void acpi_cm_update_ref_count ( - ACPI_OBJECT_INTERNAL *object, - s32 action) + ACPI_OPERAND_OBJECT *object, + u32 action) { u16 count; u16 new_count; @@ -308,23 +301,23 @@ * DESCRIPTION: Increment the object reference count * * Object references are incremented when: - * 1) An object is added as a value in an Name Table Entry (NTE) + * 1) An object is attached to a Node (namespace object) * 2) An object is copied (all subobjects must be incremented) * * Object references are decremented when: - * 1) An object is removed from an NTE + * 1) An object is detached from an Node * ******************************************************************************/ ACPI_STATUS acpi_cm_update_object_reference ( - ACPI_OBJECT_INTERNAL *object, + ACPI_OPERAND_OBJECT *object, u16 action) { ACPI_STATUS status; u32 i; - ACPI_OBJECT_INTERNAL *next; - ACPI_OBJECT_INTERNAL *new; + ACPI_OPERAND_OBJECT *next; + ACPI_OPERAND_OBJECT *new; ACPI_GENERIC_STATE *state_list = NULL; ACPI_GENERIC_STATE *state; @@ -381,9 +374,9 @@ /* Must walk list of address handlers */ - next = object->addr_handler.link; + next = object->addr_handler.next; while (next) { - new = next->addr_handler.link; + new = next->addr_handler.next; acpi_cm_update_ref_count (next, action); next = new; @@ -512,7 +505,7 @@ void acpi_cm_add_reference ( - ACPI_OBJECT_INTERNAL *object) + ACPI_OPERAND_OBJECT *object) { @@ -549,7 +542,7 @@ void acpi_cm_remove_reference ( - ACPI_OBJECT_INTERNAL *object) + ACPI_OPERAND_OBJECT *object) { diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/common/cmeval.c linux/drivers/acpi/common/cmeval.c --- v2.4.0-test8/linux/drivers/acpi/common/cmeval.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/common/cmeval.c Fri Sep 15 14:30:29 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: cmeval - Object evaluation + * $Revision: 14 $ * *****************************************************************************/ @@ -25,19 +25,19 @@ #include "acpi.h" -#include "namesp.h" -#include "interp.h" +#include "acnamesp.h" +#include "acinterp.h" #define _COMPONENT MISCELLANEOUS - MODULE_NAME ("cmeval"); + MODULE_NAME ("cmeval") /**************************************************************************** * * FUNCTION: Acpi_cm_evaluate_numeric_object * - * PARAMETERS: Acpi_device - NTE for the device + * PARAMETERS: Device_node - Node for the device * *Address - Where the value is returned * * RETURN: Status @@ -51,17 +51,17 @@ ACPI_STATUS acpi_cm_evaluate_numeric_object ( - char *object_name, - ACPI_NAMED_OBJECT *acpi_device, + NATIVE_CHAR *object_name, + ACPI_NAMESPACE_NODE *device_node, u32 *address) { - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; ACPI_STATUS status; /* Execute the method */ - status = acpi_ns_evaluate_relative (acpi_device, object_name, NULL, &obj_desc); + status = acpi_ns_evaluate_relative (device_node, object_name, NULL, &obj_desc); if (ACPI_FAILURE (status)) { return (status); @@ -99,7 +99,7 @@ * * FUNCTION: Acpi_cm_execute_HID * - * PARAMETERS: Acpi_device - NTE for the device + * PARAMETERS: Device_node - Node for the device * *Hid - Where the HID is returned * * RETURN: Status @@ -113,16 +113,16 @@ ACPI_STATUS acpi_cm_execute_HID ( - ACPI_NAMED_OBJECT *acpi_device, + ACPI_NAMESPACE_NODE *device_node, DEVICE_ID *hid) { - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; ACPI_STATUS status; /* Execute the method */ - status = acpi_ns_evaluate_relative (acpi_device, + status = acpi_ns_evaluate_relative (device_node, METHOD_NAME__HID, NULL, &obj_desc); if (ACPI_FAILURE (status)) { @@ -176,7 +176,7 @@ * * FUNCTION: Acpi_cm_execute_UID * - * PARAMETERS: Acpi_device - NTE for the device + * PARAMETERS: Device_node - Node for the device * *Uid - Where the UID is returned * * RETURN: Status @@ -190,16 +190,16 @@ ACPI_STATUS acpi_cm_execute_UID ( - ACPI_NAMED_OBJECT *acpi_device, + ACPI_NAMESPACE_NODE *device_node, DEVICE_ID *uid) { - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; ACPI_STATUS status; /* Execute the method */ - status = acpi_ns_evaluate_relative (acpi_device, + status = acpi_ns_evaluate_relative (device_node, METHOD_NAME__UID, NULL, &obj_desc); if (ACPI_FAILURE (status)) { @@ -251,7 +251,7 @@ * * FUNCTION: Acpi_cm_execute_STA * - * PARAMETERS: Acpi_device - NTE for the device + * PARAMETERS: Device_node - Node for the device * *Flags - Where the status flags are returned * * RETURN: Status @@ -265,16 +265,16 @@ ACPI_STATUS acpi_cm_execute_STA ( - ACPI_NAMED_OBJECT *acpi_device, + ACPI_NAMESPACE_NODE *device_node, u32 *flags) { - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; ACPI_STATUS status; /* Execute the method */ - status = acpi_ns_evaluate_relative (acpi_device, + status = acpi_ns_evaluate_relative (device_node, METHOD_NAME__STA, NULL, &obj_desc); if (ACPI_FAILURE (status)) { diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/common/cmglobal.c linux/drivers/acpi/common/cmglobal.c --- v2.4.0-test8/linux/drivers/acpi/common/cmglobal.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/common/cmglobal.c Fri Sep 15 14:30:29 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: cmglobal - Global variables for the ACPI subsystem + * $Revision: 99 $ * *****************************************************************************/ @@ -26,13 +26,13 @@ #define DEFINE_ACPI_GLOBALS #include "acpi.h" -#include "events.h" -#include "namesp.h" -#include "interp.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" #define _COMPONENT MISCELLANEOUS - MODULE_NAME ("cmglobal"); + MODULE_NAME ("cmglobal") /****************************************************************************** @@ -126,31 +126,25 @@ NSP_NEWSCOPE | NSP_LOCAL, /* 13 Thermal */ NSP_NORMAL, /* 14 Buffer_field */ NSP_NORMAL, /* 15 Ddb_handle */ - NSP_NORMAL, /* 16 reserved */ - NSP_NORMAL, /* 17 reserved */ - NSP_NORMAL, /* 18 reserved */ - NSP_NORMAL, /* 19 reserved */ - NSP_NORMAL, /* 20 reserved */ - NSP_NORMAL, /* 21 reserved */ - NSP_NORMAL, /* 22 reserved */ - NSP_NORMAL, /* 23 reserved */ - NSP_NORMAL, /* 24 reserved */ - NSP_NORMAL, /* 25 Def_field */ - NSP_NORMAL, /* 26 Bank_field */ - NSP_NORMAL, /* 27 Index_field */ - NSP_NORMAL, /* 28 Def_field_defn */ - NSP_NORMAL, /* 29 Bank_field_defn */ - NSP_NORMAL, /* 30 Index_field_defn */ - NSP_NORMAL, /* 31 If */ - NSP_NORMAL, /* 32 Else */ - NSP_NORMAL, /* 33 While */ - NSP_NEWSCOPE, /* 34 Scope */ - NSP_LOCAL, /* 35 Def_any */ - NSP_NORMAL, /* 36 Reference */ - NSP_NORMAL, /* 37 Alias */ - NSP_NORMAL, /* 38 Notify */ - NSP_NORMAL, /* 39 Address Handler */ - NSP_NORMAL /* 40 Invalid */ + NSP_NORMAL, /* 16 Debug Object */ + NSP_NORMAL, /* 17 Def_field */ + NSP_NORMAL, /* 18 Bank_field */ + NSP_NORMAL, /* 19 Index_field */ + NSP_NORMAL, /* 20 Reference */ + NSP_NORMAL, /* 21 Alias */ + NSP_NORMAL, /* 22 Notify */ + NSP_NORMAL, /* 23 Address Handler */ + NSP_NORMAL, /* 24 Def_field_defn */ + NSP_NORMAL, /* 25 Bank_field_defn */ + NSP_NORMAL, /* 26 Index_field_defn */ + NSP_NORMAL, /* 27 If */ + NSP_NORMAL, /* 28 Else */ + NSP_NORMAL, /* 29 While */ + NSP_NEWSCOPE, /* 30 Scope */ + NSP_LOCAL, /* 31 Def_any */ + NSP_NORMAL, /* 32 Method Arg */ + NSP_NORMAL, /* 33 Method Local */ + NSP_NORMAL /* 34 Invalid */ }; @@ -204,11 +198,11 @@ if ((type < INTERNAL_TYPE_BEGIN) || (type > INTERNAL_TYPE_MAX)) { - return FALSE; + return (FALSE); } } - return TRUE; + return (TRUE); } @@ -224,16 +218,60 @@ * ****************************************************************************/ -char * +NATIVE_CHAR * acpi_cm_format_exception ( ACPI_STATUS status) { + NATIVE_CHAR *exception = "UNKNOWN_STATUS"; + ACPI_STATUS sub_status; + + + sub_status = (status & ~AE_CODE_MASK); + - if (status > ACPI_MAX_STATUS) { - return "UNKNOWN_STATUS"; + switch (status & AE_CODE_MASK) + { + case AE_CODE_ENVIRONMENTAL: + + if (sub_status <= AE_CODE_ENV_MAX) { + exception = acpi_gbl_exception_names_env [sub_status]; + } + break; + + case AE_CODE_PROGRAMMER: + + if (sub_status <= AE_CODE_PGM_MAX) { + exception = acpi_gbl_exception_names_pgm [sub_status -1]; + } + break; + + case AE_CODE_ACPI_TABLES: + + if (sub_status <= AE_CODE_TBL_MAX) { + exception = acpi_gbl_exception_names_tbl [sub_status -1]; + } + break; + + case AE_CODE_AML: + + if (sub_status <= AE_CODE_AML_MAX) { + exception = acpi_gbl_exception_names_aml [sub_status -1]; + } + break; + + case AE_CODE_CONTROL: + + if (sub_status <= AE_CODE_CTRL_MAX) { + exception = acpi_gbl_exception_names_ctrl [sub_status -1]; + } + break; + + default: + break; } - return (acpi_gbl_exception_names [status]); + + return (exception); } @@ -389,6 +427,11 @@ acpi_gbl_parse_cache_requests = 0; acpi_gbl_parse_cache_hits = 0; + acpi_gbl_ext_parse_cache = NULL; + acpi_gbl_ext_parse_cache_depth = 0; + acpi_gbl_ext_parse_cache_requests = 0; + acpi_gbl_ext_parse_cache_hits = 0; + acpi_gbl_object_cache = NULL; acpi_gbl_object_cache_depth = 0; acpi_gbl_object_cache_requests = 0; @@ -402,7 +445,7 @@ /* Interpreter */ acpi_gbl_buf_seq = 0; - acpi_gbl_named_object_err = FALSE; + acpi_gbl_node_err = FALSE; /* Parser */ @@ -418,18 +461,15 @@ /* Namespace */ - acpi_gbl_root_name_table.next_table = NULL; - acpi_gbl_root_name_table.parent_entry = NULL; - acpi_gbl_root_name_table.parent_table = NULL; - - acpi_gbl_root_object = acpi_gbl_root_name_table.entries; - - acpi_gbl_root_object->name = ACPI_ROOT_NAME; - acpi_gbl_root_object->data_type = ACPI_DESC_TYPE_NAMED; - acpi_gbl_root_object->type = ACPI_TYPE_ANY; - acpi_gbl_root_object->this_index = 0; - acpi_gbl_root_object->child_table = NULL; - acpi_gbl_root_object->object = NULL; + acpi_gbl_root_node = NULL; + + acpi_gbl_root_node_struct.name = ACPI_ROOT_NAME; + acpi_gbl_root_node_struct.data_type = ACPI_DESC_TYPE_NAMED; + acpi_gbl_root_node_struct.type = ACPI_TYPE_ANY; + acpi_gbl_root_node_struct.child = NULL; + acpi_gbl_root_node_struct.peer = NULL; + acpi_gbl_root_node_struct.object = NULL; + acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST; /* Memory allocation metrics - compiled out in non-debug mode. */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/common/cminit.c linux/drivers/acpi/common/cminit.c --- v2.4.0-test8/linux/drivers/acpi/common/cminit.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/common/cminit.c Fri Sep 15 14:30:29 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: cminit - Common ACPI subsystem initialization + * $Revision: 79 $ * *****************************************************************************/ @@ -25,14 +25,14 @@ #include "acpi.h" -#include "hardware.h" -#include "namesp.h" -#include "events.h" -#include "parser.h" -#include "dispatch.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" +#include "acparser.h" +#include "acdispat.h" #define _COMPONENT MISCELLANEOUS - MODULE_NAME ("cminit"); + MODULE_NAME ("cminit") /******************************************************************************* @@ -52,7 +52,7 @@ void acpi_cm_facp_register_error ( - char *register_name, + NATIVE_CHAR *register_name, u32 value) { @@ -77,7 +77,7 @@ acpi_cm_hardware_initialize (void) { ACPI_STATUS status = AE_OK; - s32 index; + u32 index; /* Are we running on the actual hardware */ @@ -351,8 +351,9 @@ acpi_ps_delete_parse_cache (); /* Debug only - display leftover memory allocation, if any */ - +#ifdef ENABLE_DEBUGGER acpi_cm_dump_current_allocations (ACPI_UINT32_MAX, NULL); +#endif BREAKPOINT3; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/common/cmobject.c linux/drivers/acpi/common/cmobject.c --- v2.4.0-test8/linux/drivers/acpi/common/cmobject.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/common/cmobject.c Fri Sep 15 14:30:29 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: cmobject - ACPI object create/delete/size/cache routines + * $Revision: 27 $ * *****************************************************************************/ @@ -25,14 +25,14 @@ #include "acpi.h" -#include "interp.h" -#include "namesp.h" -#include "tables.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" #include "amlcode.h" #define _COMPONENT MISCELLANEOUS - MODULE_NAME ("cmobject"); + MODULE_NAME ("cmobject") /****************************************************************************** @@ -57,14 +57,14 @@ * ******************************************************************************/ -ACPI_OBJECT_INTERNAL * +ACPI_OPERAND_OBJECT * _cm_create_internal_object ( - char *module_name, - s32 line_number, - s32 component_id, + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, OBJECT_TYPE_INTERNAL type) { - ACPI_OBJECT_INTERNAL *object; + ACPI_OPERAND_OBJECT *object; /* Allocate the raw object descriptor */ @@ -79,7 +79,6 @@ /* Save the object type in the object descriptor */ object->common.type = type; - object->common.size = (u8) sizeof (ACPI_OBJECT_INTERNAL); /* Init the reference count */ @@ -88,10 +87,6 @@ /* Any per-type initialization should go here */ - /* Memory allocation metrics - compiled out in non debug mode. */ - - INCREMENT_OBJECT_METRICS (sizeof (ACPI_OBJECT_INTERNAL)); - return (object); } @@ -102,7 +97,7 @@ * * PARAMETERS: Operand - Object to be validated * - * RETURN: Validate a pointer to be an ACPI_OBJECT_INTERNAL + * RETURN: Validate a pointer to be an ACPI_OPERAND_OBJECT * *****************************************************************************/ @@ -114,13 +109,13 @@ /* Check for a null pointer */ if (!object) { - return FALSE; + return (FALSE); } /* Check for a pointer within one of the ACPI tables */ if (acpi_tb_system_table_pointer (object)) { - return FALSE; + return (FALSE); } /* Check the descriptor type field */ @@ -131,13 +126,13 @@ - return FALSE; + return (FALSE); } - /* The object appears to be a valid ACPI_OBJECT_INTERNAL */ + /* The object appears to be a valid ACPI_OPERAND_OBJECT */ - return TRUE; + return (TRUE); } @@ -159,11 +154,11 @@ void * _cm_allocate_object_desc ( - char *module_name, - s32 line_number, - s32 component_id) + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id) { - ACPI_OBJECT_INTERNAL *object; + ACPI_OPERAND_OBJECT *object; acpi_cm_acquire_mutex (ACPI_MTX_CACHES); @@ -176,8 +171,8 @@ /* There is an object available, use it */ object = acpi_gbl_object_cache; - acpi_gbl_object_cache = object->common.next; - object->common.next = NULL; + acpi_gbl_object_cache = object->cache.next; + object->cache.next = NULL; acpi_gbl_object_cache_hits++; acpi_gbl_object_cache_depth--; @@ -192,9 +187,8 @@ /* Attempt to allocate new descriptor */ - object = _cm_callocate (sizeof (ACPI_OBJECT_INTERNAL), component_id, + object = _cm_callocate (sizeof (ACPI_OPERAND_OBJECT), component_id, module_name, line_number); - if (!object) { /* Allocation failed */ @@ -203,6 +197,10 @@ return (NULL); } + + /* Memory allocation metrics - compiled out in non debug mode. */ + + INCREMENT_OBJECT_METRICS (sizeof (ACPI_OPERAND_OBJECT)); } /* Mark the descriptor type */ @@ -227,19 +225,19 @@ void acpi_cm_delete_object_desc ( - ACPI_OBJECT_INTERNAL *object) + ACPI_OPERAND_OBJECT *object) { - /* Object must be an ACPI_OBJECT_INTERNAL */ + /* Make sure that the object isn't already in the cache */ - if (object->common.data_type != ACPI_DESC_TYPE_INTERNAL) { + if (object->common.data_type == (ACPI_DESC_TYPE_INTERNAL | ACPI_CACHED_OBJECT)) { return; } - /* Make sure that the object isn't already in the cache */ + /* Object must be an ACPI_OPERAND_OBJECT */ - if (object->common.next) { + if (object->common.data_type != ACPI_DESC_TYPE_INTERNAL) { return; } @@ -251,7 +249,7 @@ * Memory allocation metrics. Call the macro here since we only * care about dynamically allocated objects. */ - DECREMENT_OBJECT_METRICS (acpi_gbl_object_cache->common.size); + DECREMENT_OBJECT_METRICS (sizeof (ACPI_OPERAND_OBJECT)); acpi_cm_free (object); return; @@ -261,17 +259,18 @@ /* Clear the entire object. This is important! */ - MEMSET (object, 0, sizeof (ACPI_OBJECT_INTERNAL)); - object->common.data_type = ACPI_DESC_TYPE_INTERNAL; + MEMSET (object, 0, sizeof (ACPI_OPERAND_OBJECT)); + object->common.data_type = ACPI_DESC_TYPE_INTERNAL | ACPI_CACHED_OBJECT; /* Put the object at the head of the global cache list */ - object->common.next = acpi_gbl_object_cache; + object->cache.next = acpi_gbl_object_cache; acpi_gbl_object_cache = object; acpi_gbl_object_cache_depth++; acpi_cm_release_mutex (ACPI_MTX_CACHES); + return; } @@ -292,7 +291,7 @@ acpi_cm_delete_object_cache ( void) { - ACPI_OBJECT_INTERNAL *next; + ACPI_OPERAND_OBJECT *next; /* Traverse the global cache list */ @@ -300,17 +299,18 @@ while (acpi_gbl_object_cache) { /* Delete one cached state object */ - next = acpi_gbl_object_cache->common.next; - acpi_gbl_object_cache->common.next = NULL; + next = acpi_gbl_object_cache->cache.next; + acpi_gbl_object_cache->cache.next = NULL; /* * Memory allocation metrics. Call the macro here since we only * care about dynamically allocated objects. */ - DECREMENT_OBJECT_METRICS (acpi_gbl_object_cache->common.size); + DECREMENT_OBJECT_METRICS (sizeof (ACPI_OPERAND_OBJECT)); acpi_cm_free (acpi_gbl_object_cache); acpi_gbl_object_cache = next; + acpi_gbl_object_cache_depth--; } return; @@ -333,7 +333,7 @@ void acpi_cm_init_static_object ( - ACPI_OBJECT_INTERNAL *obj_desc) + ACPI_OPERAND_OBJECT *obj_desc) { @@ -345,12 +345,12 @@ /* * Clear the entire descriptor */ - MEMSET ((void *) obj_desc, 0, sizeof (ACPI_OBJECT_INTERNAL)); + MEMSET ((void *) obj_desc, 0, sizeof (ACPI_OPERAND_OBJECT)); /* * Initialize the header fields - * 1) This is an ACPI_OBJECT_INTERNAL descriptor + * 1) This is an ACPI_OPERAND_OBJECT descriptor * 2) The size is the full object (worst case) * 3) The flags field indicates static allocation * 4) Reference count starts at one (not really necessary since the @@ -358,8 +358,7 @@ */ obj_desc->common.data_type = ACPI_DESC_TYPE_INTERNAL; - obj_desc->common.size = sizeof (ACPI_OBJECT_INTERNAL); - obj_desc->common.flags = AO_STATIC_ALLOCATION; + obj_desc->common.flags = AOPOBJ_STATIC_ALLOCATION; obj_desc->common.reference_count = 1; return; @@ -385,7 +384,7 @@ ACPI_STATUS acpi_cm_get_simple_object_size ( - ACPI_OBJECT_INTERNAL *internal_obj, + ACPI_OPERAND_OBJECT *internal_obj, u32 *obj_length) { u32 length; @@ -405,7 +404,7 @@ length = sizeof (ACPI_OBJECT); if (VALID_DESCRIPTOR_TYPE (internal_obj, ACPI_DESC_TYPE_NAMED)) { - /* Object is an NTE (reference), just return the length */ + /* Object is a named object (reference), just return the length */ *obj_length = (u32) ROUND_UP_TO_NATIVE_WORD (length); return (status); @@ -495,13 +494,13 @@ ACPI_STATUS acpi_cm_get_package_object_size ( - ACPI_OBJECT_INTERNAL *internal_obj, + ACPI_OPERAND_OBJECT *internal_obj, u32 *obj_length) { - ACPI_OBJECT_INTERNAL *this_internal_obj; - ACPI_OBJECT_INTERNAL *parent_obj[MAX_PACKAGE_DEPTH] = { 0,0,0,0,0 }; - ACPI_OBJECT_INTERNAL *this_parent; + ACPI_OPERAND_OBJECT *this_internal_obj; + ACPI_OPERAND_OBJECT *parent_obj[MAX_PACKAGE_DEPTH] = { 0,0,0,0,0 }; + ACPI_OPERAND_OBJECT *this_parent; u32 this_index; u32 index[MAX_PACKAGE_DEPTH] = { 0,0,0,0,0 }; u32 length = 0; @@ -537,7 +536,7 @@ status = acpi_cm_get_simple_object_size (this_internal_obj, &object_space); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { return (status); } @@ -603,8 +602,6 @@ } } } - - return (AE_OK); } @@ -624,7 +621,7 @@ ACPI_STATUS acpi_cm_get_object_size( - ACPI_OBJECT_INTERNAL *internal_obj, + ACPI_OPERAND_OBJECT *internal_obj, u32 *obj_length) { ACPI_STATUS status; @@ -642,7 +639,7 @@ acpi_cm_get_simple_object_size (internal_obj, obj_length); } - return status; + return (status); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/common/cmutils.c linux/drivers/acpi/common/cmutils.c --- v2.4.0-test8/linux/drivers/acpi/common/cmutils.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/common/cmutils.c Fri Sep 15 14:30:29 2000 @@ -1,8 +1,9 @@ -/****************************************************************************** +/******************************************************************************* * * Module Name: cmutils - common utility procedures + * $Revision: 18 $ * - *****************************************************************************/ + ******************************************************************************/ /* * Copyright (C) 2000 R. Byron Moore @@ -24,19 +25,19 @@ #include "acpi.h" -#include "events.h" -#include "hardware.h" -#include "namesp.h" -#include "interp.h" +#include "acevents.h" +#include "achware.h" +#include "acnamesp.h" +#include "acinterp.h" #include "amlcode.h" -#include "debugger.h" +#include "acdebug.h" #define _COMPONENT MISCELLANEOUS - MODULE_NAME ("cmutils"); + MODULE_NAME ("cmutils") -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_valid_acpi_name * @@ -49,13 +50,13 @@ * 2) numeric * 3) underscore * - ****************************************************************************/ + ******************************************************************************/ u8 acpi_cm_valid_acpi_name ( u32 name) { - char *name_ptr = (char *) &name; + NATIVE_CHAR *name_ptr = (NATIVE_CHAR *) &name; u32 i; @@ -64,16 +65,16 @@ (name_ptr[i] >= 'A' && name_ptr[i] <= 'Z') || (name_ptr[i] >= '0' && name_ptr[i] <= '9'))) { - return FALSE; + return (FALSE); } } - return TRUE; + return (TRUE); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_valid_acpi_character * @@ -83,11 +84,11 @@ * * DESCRIPTION: Check for a printable character * - ****************************************************************************/ + ******************************************************************************/ u8 acpi_cm_valid_acpi_character ( - char character) + NATIVE_CHAR character) { return ((u8) ((character == '_') || @@ -96,7 +97,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_mutex_initialize * @@ -106,7 +107,7 @@ * * DESCRIPTION: Create the system mutex objects. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_cm_mutex_initialize ( @@ -130,7 +131,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_mutex_terminate * @@ -140,7 +141,7 @@ * * DESCRIPTION: Delete all of the system mutex objects. * - ****************************************************************************/ + ******************************************************************************/ void acpi_cm_mutex_terminate ( @@ -160,7 +161,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_create_mutex * @@ -170,7 +171,7 @@ * * DESCRIPTION: Create a mutex object. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_cm_create_mutex ( @@ -195,7 +196,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_delete_mutex * @@ -205,7 +206,7 @@ * * DESCRIPTION: Delete a mutex object. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_cm_delete_mutex ( @@ -228,7 +229,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_acquire_mutex * @@ -238,7 +239,7 @@ * * DESCRIPTION: Acquire a mutex object. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_cm_acquire_mutex ( @@ -252,9 +253,8 @@ } - status = - acpi_os_wait_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex, - 1, WAIT_FOREVER); + status = acpi_os_wait_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex, + 1, WAIT_FOREVER); if (ACPI_SUCCESS (status)) { acpi_gbl_acpi_mutex_info[mutex_id].locked = TRUE; @@ -265,7 +265,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_release_mutex * @@ -275,7 +275,7 @@ * * DESCRIPTION: Release a mutex object. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_cm_release_mutex ( @@ -291,14 +291,14 @@ acpi_gbl_acpi_mutex_info[mutex_id].locked = FALSE; /* Mark before unlocking */ - status = - acpi_os_signal_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex, 1); + status = acpi_os_signal_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex, 1); + return (status); } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_create_update_state_and_push * @@ -314,7 +314,7 @@ ACPI_STATUS acpi_cm_create_update_state_and_push ( - ACPI_OBJECT_INTERNAL *object, + ACPI_OPERAND_OBJECT *object, u16 action, ACPI_GENERIC_STATE **state_list) { @@ -324,21 +324,21 @@ /* Ignore null objects; these are expected */ if (!object) { - return AE_OK; + return (AE_OK); } state = acpi_cm_create_update_state (object, action); if (!state) { - return AE_NO_MEMORY; + return (AE_NO_MEMORY); } acpi_cm_push_generic_state (state_list, state); - return AE_OK; + return (AE_OK); } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_push_generic_state * @@ -365,7 +365,7 @@ } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_pop_generic_state * @@ -397,7 +397,7 @@ } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_create_generic_state * @@ -433,6 +433,7 @@ acpi_gbl_generic_state_cache_depth--; acpi_cm_release_mutex (ACPI_MTX_CACHES); + } else { @@ -446,18 +447,23 @@ /* Initialize */ if (state) { + /* Always zero out the object before init */ + + MEMSET (state, 0, sizeof (ACPI_GENERIC_STATE)); + state->common.data_type = ACPI_DESC_TYPE_STATE; } - return state; + return (state); } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_create_update_state * - * PARAMETERS: Object - Initial Object to be installed in the state + * PARAMETERS: Object - Initial Object to be installed in the + * state * Action - Update action to be performed * * RETURN: Status @@ -470,7 +476,7 @@ ACPI_GENERIC_STATE * acpi_cm_create_update_state ( - ACPI_OBJECT_INTERNAL *object, + ACPI_OPERAND_OBJECT *object, u16 action) { ACPI_GENERIC_STATE *state; @@ -480,7 +486,7 @@ state = acpi_cm_create_generic_state (); if (!state) { - return NULL; + return (NULL); } /* Init fields specific to the update struct */ @@ -492,7 +498,7 @@ } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_create_control_state * @@ -516,7 +522,7 @@ state = acpi_cm_create_generic_state (); if (!state) { - return NULL; + return (NULL); } @@ -528,7 +534,7 @@ } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_delete_generic_state * @@ -575,7 +581,7 @@ } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_cm_delete_generic_state_cache * @@ -603,13 +609,14 @@ next = acpi_gbl_generic_state_cache->common.next; acpi_cm_free (acpi_gbl_generic_state_cache); acpi_gbl_generic_state_cache = next; + acpi_gbl_generic_state_cache_depth--; } return; } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: _Report_error * @@ -622,14 +629,14 @@ * * DESCRIPTION: Print error message from KD table * - ****************************************************************************/ + ******************************************************************************/ void _report_error ( - char *module_name, - s32 line_number, - s32 component_id, - char *message) + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *message) { debug_print (module_name, line_number, component_id, ACPI_ERROR, @@ -638,7 +645,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: _Report_warning * @@ -651,14 +658,14 @@ * * DESCRIPTION: Print warning message from KD table * - ****************************************************************************/ + ******************************************************************************/ void _report_warning ( - char *module_name, - s32 line_number, - s32 component_id, - char *message) + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *message) { debug_print (module_name, line_number, component_id, ACPI_WARN, @@ -667,35 +674,7 @@ } -/***************************************************************************** - * - * FUNCTION: _Report_success - * - * PARAMETERS: Module_name - Caller's module name (for error output) - * Line_number - Caller's line number (for error output) - * Component_id - Caller's component ID (for error output) - * Message - Error message to use on failure - * - * RETURN: None - * - * DESCRIPTION: Print warning message from KD table - * - ****************************************************************************/ - -void -_report_success ( - char *module_name, - s32 line_number, - s32 component_id, - char *message) -{ - - debug_print (module_name, line_number, component_id, ACPI_OK, - "*** Success: %s\n", message); -} - - -/***************************************************************************** +/******************************************************************************* * * FUNCTION: _Report_info * @@ -708,14 +687,14 @@ * * DESCRIPTION: Print information message from KD table * - ****************************************************************************/ + ******************************************************************************/ void _report_info ( - char *module_name, - s32 line_number, - s32 component_id, - char *message) + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *message) { debug_print (module_name, line_number, component_id, ACPI_INFO, diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/common/cmxface.c linux/drivers/acpi/common/cmxface.c --- v2.4.0-test8/linux/drivers/acpi/common/cmxface.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/common/cmxface.c Fri Sep 15 14:30:29 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: cmxface - External interfaces for "global" ACPI functions + * $Revision: 43 $ * *****************************************************************************/ @@ -24,16 +25,16 @@ #include "acpi.h" -#include "events.h" -#include "hardware.h" -#include "namesp.h" -#include "interp.h" +#include "acevents.h" +#include "achware.h" +#include "acnamesp.h" +#include "acinterp.h" #include "amlcode.h" -#include "debugger.h" +#include "acdebug.h" #define _COMPONENT MISCELLANEOUS - MODULE_NAME ("cmxface"); + MODULE_NAME ("cmxface") /******************************************************************************* @@ -77,6 +78,8 @@ /* If configured, initialize the AML debugger */ + DEBUGGER_EXEC (acpi_db_initialize ()); + return (status); } @@ -100,7 +103,9 @@ /* Terminate the AML Debuger if present */ acpi_gbl_db_terminate_threads = TRUE; - acpi_cm_release_mutex (ACPI_MTX_DEBUG_CMD_READY); + + /* TBD: [Investigate] This is no longer needed?*/ +/* Acpi_cm_release_mutex (ACPI_MTX_DEBUG_CMD_READY); */ /* Shutdown and free all resources */ @@ -224,7 +229,7 @@ ACPI_BUFFER *out_buffer) { u32 length; - char *formatted_exception; + NATIVE_CHAR *formatted_exception; /* @@ -237,14 +242,7 @@ } - /* Exception must be within range */ - - if (exception > ACPI_MAX_STATUS) { - return (AE_BAD_PARAMETER); - } - - - /* Convert the exception code */ + /* Convert the exception code (Handles bad exception codes) */ formatted_exception = acpi_cm_format_exception (exception); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/cpu.c linux/drivers/acpi/cpu.c --- v2.4.0-test8/linux/drivers/acpi/cpu.c Fri Jul 14 12:12:08 2000 +++ linux/drivers/acpi/cpu.c Fri Sep 15 14:30:29 2000 @@ -25,6 +25,9 @@ #include "acpi.h" #include "driver.h" +#define _COMPONENT OS_DEPENDENT + MODULE_NAME ("cpu") + unsigned long acpi_c2_exit_latency = ACPI_INFINITE; unsigned long acpi_c3_exit_latency = ACPI_INFINITE; unsigned long acpi_c2_enter_latency = ACPI_INFINITE; @@ -33,6 +36,7 @@ static unsigned long acpi_pblk = ACPI_INVALID; static int acpi_c2_tested = 0; static int acpi_c3_tested = 0; +static int acpi_max_c_state = 1; /* * Clear busmaster activity flag @@ -101,10 +105,14 @@ /* * start from the previous sleep level.. */ - if (sleep_level == 1) + if (sleep_level == 1 + || acpi_max_c_state < 2) goto sleep1; - if (sleep_level == 2) + + if (sleep_level == 2 + || acpi_max_c_state < 3) goto sleep2; + sleep3: sleep_level = 3; if (!acpi_c3_tested) { @@ -193,7 +201,8 @@ acpi_clear_bm_activity(facp); continue; } - if (time > acpi_c3_enter_latency) + if (time > acpi_c3_enter_latency + && acpi_max_c_state >= 3) goto sleep3; } @@ -210,7 +219,8 @@ time = TIME_BEGIN(pm_tmr); safe_halt(); time = TIME_END(pm_tmr, time); - if (time > acpi_c2_enter_latency) + if (time > acpi_c2_enter_latency + && acpi_max_c_state >= 2) goto sleep2; } @@ -260,12 +270,19 @@ return AE_OK; if (lat[2].latency < MAX_CX_STATE_LATENCY) { - printk(KERN_INFO "ACPI: C2 supported\n"); + printk(KERN_INFO "ACPI: C2"); acpi_c2_exit_latency = lat[2].latency; - } - if (lat[3].latency < MAX_CX_STATE_LATENCY) { - printk(KERN_INFO "ACPI: C3 supported\n"); - acpi_c3_exit_latency = lat[3].latency; + acpi_max_c_state = 2; + + if (lat[3].latency < MAX_CX_STATE_LATENCY) { + printk(", C3 supported\n"); + acpi_c3_exit_latency = lat[3].latency; + acpi_max_c_state = 3; + } + else { + printk(" supported\n"); + } + } memset(throttle, 0, sizeof(throttle)); @@ -291,7 +308,7 @@ { acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, - ACPI_INT32_MAX, + ACPI_UINT32_MAX, acpi_find_cpu, NULL, NULL); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/dispatcher/Makefile linux/drivers/acpi/dispatcher/Makefile --- v2.4.0-test8/linux/drivers/acpi/dispatcher/Makefile Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/dispatcher/Makefile Fri Sep 15 18:21:43 2000 @@ -0,0 +1,28 @@ +# +# Makefile for all Linux ACPI interpreter subdirectories +# + +SUB_DIRS := +MOD_SUB_DIRS := $(SUB_DIRS) +MOD_IN_SUB_DIRS := +ALL_SUB_DIRS := $(SUB_DIRS) + +O_TARGET := ../$(shell basename `pwd`).o +O_OBJS := +M_OBJS := + +ACPI_OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) + +EXTRA_CFLAGS += -I../include + +EXTRA_CFLAGS += $(ACPI_CFLAGS) + +# if the interpreter is used, it overrides arch/i386/kernel/acpi.c +ifeq ($(CONFIG_ACPI_INTERPRETER),y) + O_OBJS := $(ACPI_OBJS) +endif + +include $(TOPDIR)/Rules.make + +clean: + $(RM) *.o diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/dispatcher/dsfield.c linux/drivers/acpi/dispatcher/dsfield.c --- v2.4.0-test8/linux/drivers/acpi/dispatcher/dsfield.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/dispatcher/dsfield.c Fri Sep 15 14:30:29 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: dsfield - Dispatcher field routines + * $Revision: 29 $ * *****************************************************************************/ @@ -26,13 +26,13 @@ #include "acpi.h" #include "amlcode.h" -#include "dispatch.h" -#include "interp.h" -#include "namesp.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" #define _COMPONENT DISPATCHER - MODULE_NAME ("dsfield"); + MODULE_NAME ("dsfield") /* @@ -46,28 +46,28 @@ #define FIELD_UPDATE_RULE_MASK 0x60 -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_create_field * * PARAMETERS: Op - Op containing the Field definition and args - * Region - NTE for the containing Operation Region + * Region_node - Object for the containing Operation Region * * RETURN: Status * * DESCRIPTION: Create a new field in the specified operation region * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_create_field ( - ACPI_GENERIC_OP *op, - ACPI_HANDLE region, + ACPI_PARSE_OBJECT *op, + ACPI_NAMESPACE_NODE *region_node, ACPI_WALK_STATE *walk_state) { ACPI_STATUS status = AE_AML_ERROR; - ACPI_GENERIC_OP *arg; - ACPI_NAMED_OBJECT *entry; + ACPI_PARSE_OBJECT *arg; + ACPI_NAMESPACE_NODE *node; u8 field_flags; u8 access_attribute = 0; u32 field_bit_position = 0; @@ -76,6 +76,16 @@ /* First arg is the name of the parent Op_region */ arg = op->value.arg; + if (!region_node) { + status = acpi_ns_lookup (walk_state->scope_info, arg->value.name, + ACPI_TYPE_REGION, IMODE_EXECUTE, + NS_SEARCH_PARENT, walk_state, + ®ion_node); + + if (ACPI_FAILURE (status)) { + return (status); + } + } /* Second arg is the field flags */ @@ -111,32 +121,29 @@ case AML_NAMEDFIELD_OP: status = acpi_ns_lookup (walk_state->scope_info, - (char *) &((ACPI_NAMED_OP *)arg)->name, + (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)arg)->name, INTERNAL_TYPE_DEF_FIELD, IMODE_LOAD_PASS1, NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &entry); + NULL, &node); if (ACPI_FAILURE (status)) { return (status); } /* - * Initialize an object for the new NTE that is on + * Initialize an object for the new Node that is on * the object stack */ - status = acpi_aml_prep_def_field_value (entry, region, - field_flags, - access_attribute, - field_bit_position, - arg->value.size); + status = acpi_aml_prep_def_field_value (node, region_node, field_flags, + access_attribute, field_bit_position, arg->value.size); if (ACPI_FAILURE (status)) { return (status); } - /* Keep track of bit position for the *next* field */ + /* Keep track of bit position for *next* field */ field_bit_position += arg->value.size; break; @@ -149,29 +156,29 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_create_bank_field * * PARAMETERS: Op - Op containing the Field definition and args - * Region - NTE for the containing Operation Region + * Region_node - Object for the containing Operation Region * * RETURN: Status * * DESCRIPTION: Create a new bank field in the specified operation region * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_create_bank_field ( - ACPI_GENERIC_OP *op, - ACPI_HANDLE region, + ACPI_PARSE_OBJECT *op, + ACPI_NAMESPACE_NODE *region_node, ACPI_WALK_STATE *walk_state) { ACPI_STATUS status = AE_AML_ERROR; - ACPI_GENERIC_OP *arg; - ACPI_NAMED_OBJECT *bank_reg; - ACPI_NAMED_OBJECT *entry; + ACPI_PARSE_OBJECT *arg; + ACPI_NAMESPACE_NODE *register_node; + ACPI_NAMESPACE_NODE *node; u32 bank_value; u8 field_flags; u8 access_attribute = 0; @@ -181,8 +188,18 @@ /* First arg is the name of the parent Op_region */ arg = op->value.arg; + if (!region_node) { + status = acpi_ns_lookup (walk_state->scope_info, arg->value.name, + ACPI_TYPE_REGION, IMODE_EXECUTE, + NS_SEARCH_PARENT, walk_state, + ®ion_node); + + if (ACPI_FAILURE (status)) { + return (status); + } + } - /* Socond arg is the Bank Register */ + /* Second arg is the Bank Register */ arg = arg->next; @@ -190,7 +207,7 @@ INTERNAL_TYPE_BANK_FIELD_DEFN, IMODE_LOAD_PASS1, NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &bank_reg); + NULL, ®ister_node); if (ACPI_FAILURE (status)) { return (status); @@ -236,27 +253,24 @@ case AML_NAMEDFIELD_OP: status = acpi_ns_lookup (walk_state->scope_info, - (char *) &((ACPI_NAMED_OP *)arg)->name, + (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)arg)->name, INTERNAL_TYPE_DEF_FIELD, IMODE_LOAD_PASS1, NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &entry); + NULL, &node); if (ACPI_FAILURE (status)) { return (status); } /* - * Initialize an object for the new NTE that is on + * Initialize an object for the new Node that is on * the object stack */ - status = acpi_aml_prep_bank_field_value (entry, region, - bank_reg, bank_value, - field_flags, - access_attribute, - field_bit_position, - arg->value.size); + status = acpi_aml_prep_bank_field_value (node, region_node, register_node, + bank_value, field_flags, access_attribute, + field_bit_position, arg->value.size); if (ACPI_FAILURE (status)) { return (status); @@ -276,30 +290,30 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_create_index_field * * PARAMETERS: Op - Op containing the Field definition and args - * Region - NTE for the containing Operation Region + * Region_node - Object for the containing Operation Region * * RETURN: Status * * DESCRIPTION: Create a new index field in the specified operation region * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_create_index_field ( - ACPI_GENERIC_OP *op, - ACPI_HANDLE region, + ACPI_PARSE_OBJECT *op, + ACPI_HANDLE region_node, ACPI_WALK_STATE *walk_state) { ACPI_STATUS status; - ACPI_GENERIC_OP *arg; - ACPI_NAMED_OBJECT *entry; - ACPI_NAMED_OBJECT *index_reg; - ACPI_NAMED_OBJECT *data_reg; + ACPI_PARSE_OBJECT *arg; + ACPI_NAMESPACE_NODE *node; + ACPI_NAMESPACE_NODE *index_register_node; + ACPI_NAMESPACE_NODE *data_register_node; u8 field_flags; u8 access_attribute = 0; u32 field_bit_position = 0; @@ -312,7 +326,7 @@ status = acpi_ns_lookup (walk_state->scope_info, arg->value.string, ACPI_TYPE_ANY, IMODE_LOAD_PASS1, NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &index_reg); + NULL, &index_register_node); if (ACPI_FAILURE (status)) { return (status); @@ -326,7 +340,7 @@ INTERNAL_TYPE_INDEX_FIELD_DEFN, IMODE_LOAD_PASS1, NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &data_reg); + NULL, &data_register_node); if (ACPI_FAILURE (status)) { return (status); @@ -368,26 +382,24 @@ case AML_NAMEDFIELD_OP: status = acpi_ns_lookup (walk_state->scope_info, - (char *) &((ACPI_NAMED_OP *)arg)->name, + (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)arg)->name, INTERNAL_TYPE_INDEX_FIELD, IMODE_LOAD_PASS1, NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &entry); + NULL, &node); if (ACPI_FAILURE (status)) { return (status); } /* - * Initialize an object for the new NTE that is on + * Initialize an object for the new Node that is on * the object stack */ - status = acpi_aml_prep_index_field_value (entry, index_reg, - data_reg, field_flags, - access_attribute, - field_bit_position, - arg->value.size); + status = acpi_aml_prep_index_field_value (node, index_register_node, data_register_node, + field_flags, access_attribute, + field_bit_position, arg->value.size); if (ACPI_FAILURE (status)) { return (status); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/dispatcher/dsmethod.c linux/drivers/acpi/dispatcher/dsmethod.c --- v2.4.0-test8/linux/drivers/acpi/dispatcher/dsmethod.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/dispatcher/dsmethod.c Fri Sep 15 14:30:29 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: dsmethod - Parser/Interpreter interface - control method parsing + * $Revision: 52 $ * *****************************************************************************/ @@ -25,24 +25,24 @@ #include "acpi.h" -#include "parser.h" +#include "acparser.h" #include "amlcode.h" -#include "dispatch.h" -#include "interp.h" -#include "namesp.h" -#include "tables.h" -#include "debugger.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acdebug.h" #define _COMPONENT DISPATCHER - MODULE_NAME ("dsmethod"); + MODULE_NAME ("dsmethod") /******************************************************************************* * * FUNCTION: Acpi_ds_parse_method * - * PARAMETERS: Obj_handle - NTE of the method + * PARAMETERS: Obj_handle - Node of the method * Level - Current nesting level * Context - Points to a method counter * Return_value - Not used @@ -61,9 +61,9 @@ ACPI_HANDLE obj_handle) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_GENERIC_OP *op; - ACPI_NAMED_OBJECT *entry; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_PARSE_OBJECT *op; + ACPI_NAMESPACE_NODE *node; ACPI_OWNER_ID owner_id; @@ -74,10 +74,10 @@ } - /* Extract the method object from the method NTE */ + /* Extract the method object from the method Node */ - entry = (ACPI_NAMED_OBJECT*) obj_handle; - obj_desc = entry->object; + node = (ACPI_NAMESPACE_NODE *) obj_handle; + obj_desc = node->object; if (!obj_desc) { return (AE_NULL_OBJECT); } @@ -87,8 +87,7 @@ if ((obj_desc->method.concurrency != INFINITE_CONCURRENCY) && (!obj_desc->method.semaphore)) { - status = acpi_os_create_semaphore (1, - obj_desc->method.concurrency, + status = acpi_os_create_semaphore (1,obj_desc->method.concurrency, &obj_desc->method.semaphore); if (ACPI_FAILURE (status)) { return (status); @@ -105,17 +104,17 @@ return (AE_NO_MEMORY); } - /* Init new op with the method name and pointer back to the NTE */ + /* Init new op with the method name and pointer back to the Node */ - acpi_ps_set_name (op, entry->name); - op->acpi_named_object = entry; + acpi_ps_set_name (op, node->name); + op->node = node; /* - * Parse the method, creating a parse tree. + * Parse the method, first pass * - * The parse also includes a first pass load of the - * namespace where newly declared named objects are + * The first pass load is + * where newly declared named objects are * added into the namespace. Actual evaluation of * the named objects (what would be called a "second * pass") happens during the actual execution of the @@ -124,7 +123,10 @@ */ status = acpi_ps_parse_aml (op, obj_desc->method.pcode, - obj_desc->method.pcode_length, 0); + obj_desc->method.pcode_length, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + node, NULL, NULL, + acpi_ds_load1_begin_op, acpi_ds_load1_end_op); if (ACPI_FAILURE (status)) { return (status); @@ -133,11 +135,13 @@ /* Get a new Owner_id for objects created by this method */ owner_id = acpi_cm_allocate_owner_id (OWNER_TYPE_METHOD); + obj_desc->method.owning_id = owner_id; /* Install the parsed tree in the method object */ + /* TBD: [Restructure] Obsolete field? */ + + acpi_ps_delete_parse_tree (op); - obj_desc->method.parser_op = op; - obj_desc->method.owning_id = owner_id; return (status); } @@ -147,7 +151,7 @@ * * FUNCTION: Acpi_ds_begin_method_execution * - * PARAMETERS: Method_entry - NTE of the method + * PARAMETERS: Method_node - Node of the method * Obj_desc - The method object * * RETURN: Status @@ -162,38 +166,31 @@ ACPI_STATUS acpi_ds_begin_method_execution ( - ACPI_NAMED_OBJECT *method_entry, - ACPI_OBJECT_INTERNAL *obj_desc) + ACPI_NAMESPACE_NODE *method_node, + ACPI_OPERAND_OBJECT *obj_desc) { ACPI_STATUS status = AE_OK; - if (!method_entry) { + if (!method_node) { return (AE_NULL_ENTRY); } - obj_desc = acpi_ns_get_attached_object (method_entry); + obj_desc = acpi_ns_get_attached_object (method_node); if (!obj_desc) { return (AE_NULL_OBJECT); } + /* - * Lock the parser while we check for and possibly parse the - * control method + * If there is a concurrency limit on this method, we need to + * obtain a unit from the method semaphore. This releases the + * interpreter if we block */ - acpi_cm_acquire_mutex (ACPI_MTX_PARSER); - - - /* If method is not parsed at this time, we must parse it first */ - - if (!obj_desc->method.parser_op) { - - status = acpi_ds_parse_method (method_entry); - if (ACPI_FAILURE (status)) { - acpi_cm_release_mutex (ACPI_MTX_PARSER); - return (status); - } + if (obj_desc->method.semaphore) { + status = acpi_aml_system_wait_semaphore (obj_desc->method.semaphore, + WAIT_FOREVER); } @@ -204,29 +201,10 @@ * the last thread completes execution of the method */ - ((ACPI_DEFERRED_OP *) obj_desc->method.parser_op)->thread_count++; - - /* - * Parsing is complete, we can unlock the parser. Parse tree - * cannot be deleted at least until this thread completes. - */ - - acpi_cm_release_mutex (ACPI_MTX_PARSER); - - /* - * If there is a concurrency limit on this method, we need to - * obtain a unit from the method semaphore. This releases the - * interpreter if we block - */ - - if (obj_desc->method.semaphore) { - status = acpi_aml_system_wait_semaphore (obj_desc->method.semaphore, - WAIT_FOREVER); - } + obj_desc->method.thread_count++; return (status); - } @@ -247,61 +225,76 @@ acpi_ds_call_control_method ( ACPI_WALK_LIST *walk_list, ACPI_WALK_STATE *this_walk_state, - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT *op) { ACPI_STATUS status; - ACPI_DEFERRED_OP *method; - ACPI_NAMED_OBJECT *method_entry; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_NAMESPACE_NODE *method_node; + ACPI_OPERAND_OBJECT *obj_desc; ACPI_WALK_STATE *next_walk_state; + ACPI_PARSE_STATE *parser_state; u32 i; /* - * Prev_op points to the METHOD_CALL Op. - * Get the NTE entry (in the METHOD_CALL->NAME Op) and the - * corresponding METHOD Op + * Get the namespace entry for the control method we are about to call */ - method_entry = (this_walk_state->prev_op->value.arg)->acpi_named_object; - if (!method_entry) { + method_node = this_walk_state->method_call_node; + if (!method_node) { return (AE_NULL_ENTRY); } - obj_desc = acpi_ns_get_attached_object (method_entry); + obj_desc = acpi_ns_get_attached_object (method_node); if (!obj_desc) { return (AE_NULL_OBJECT); } - /* Parse method if necessary, wait on concurrency semaphore */ - status = acpi_ds_begin_method_execution (method_entry, obj_desc); + /* Init for new method, wait on concurrency semaphore */ + + status = acpi_ds_begin_method_execution (method_node, obj_desc); if (ACPI_FAILURE (status)) { return (status); } - /* Save the (current) Op for when this walk is restarted */ - this_walk_state->method_call_op = this_walk_state->prev_op; - this_walk_state->prev_op = op; - method = obj_desc->method.parser_op; + /* Create and initialize a new parser state */ + + parser_state = acpi_ps_create_state (obj_desc->method.pcode, + obj_desc->method.pcode_length); + if (!parser_state) { + return (AE_NO_MEMORY); + } + + acpi_ps_init_scope (parser_state, NULL); + parser_state->start_node = method_node; + /* Create a new state for the preempting walk */ next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, - (ACPI_GENERIC_OP *) method, - obj_desc, walk_list); + NULL, obj_desc, walk_list); if (!next_walk_state) { + /* TBD: delete parser state */ + return (AE_NO_MEMORY); } + next_walk_state->walk_type = WALK_METHOD; + next_walk_state->method_node = method_node; + next_walk_state->parser_state = parser_state; + next_walk_state->parse_flags = this_walk_state->parse_flags; + next_walk_state->descending_callback = this_walk_state->descending_callback; + next_walk_state->ascending_callback = this_walk_state->ascending_callback; + /* The Next_op of the Next_walk will be the beginning of the method */ + /* TBD: [Restructure] -- obsolete? */ - next_walk_state->next_op = (ACPI_GENERIC_OP *) method; + next_walk_state->next_op = NULL; /* Open a new scope */ - status = acpi_ds_scope_stack_push (method_entry->child_table, + status = acpi_ds_scope_stack_push (method_node, ACPI_TYPE_METHOD, next_walk_state); if (ACPI_FAILURE (status)) { goto cleanup; @@ -316,11 +309,28 @@ */ status = acpi_ds_method_data_init_args (&this_walk_state->operands[0], - this_walk_state->num_operands); + this_walk_state->num_operands, + next_walk_state); if (ACPI_FAILURE (status)) { goto cleanup; } + + /* Create and init a Root Node */ + + op = acpi_ps_alloc_op (AML_SCOPE_OP); + if (!op) { + return (AE_NO_MEMORY); + } + + status = acpi_ps_parse_aml (op, obj_desc->method.pcode, + obj_desc->method.pcode_length, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + method_node, NULL, NULL, + acpi_ds_load1_begin_op, acpi_ds_load1_end_op); + acpi_ps_delete_parse_tree (op); + + /* * Delete the operands on the previous walkstate operand stack * (they were copied to new objects) @@ -328,6 +338,7 @@ for (i = 0; i < obj_desc->method.param_count; i++) { acpi_cm_remove_reference (this_walk_state->operands [i]); + this_walk_state->operands [i] = NULL; } /* Clear the operand stack */ @@ -364,30 +375,33 @@ ACPI_STATUS acpi_ds_restart_control_method ( ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL *return_desc) + ACPI_OPERAND_OBJECT *return_desc) { ACPI_STATUS status; if (return_desc) { - /* - * Get the return value (if any) from the previous method. - * NULL if no return value - */ + if (walk_state->return_used) { + /* + * Get the return value (if any) from the previous method. + * NULL if no return value + */ + + status = acpi_ds_result_stack_push (return_desc, walk_state); + if (ACPI_FAILURE (status)) { + acpi_cm_remove_reference (return_desc); + return (status); + } + } - status = acpi_ds_result_stack_push (return_desc, walk_state); - if (ACPI_FAILURE (status)) { + else { + /* + * Delete the return value if it will not be used by the + * calling method + */ acpi_cm_remove_reference (return_desc); - return (status); } - /* - * Delete the return value if it will not be used by the - * calling method - */ - - acpi_ds_delete_result_if_not_used (walk_state->method_call_op, - return_desc, walk_state); } @@ -414,9 +428,8 @@ ACPI_WALK_STATE *walk_state) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_DEFERRED_OP *op; - ACPI_NAMED_OBJECT *method_entry; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_NAMESPACE_NODE *method_node; /* The method object should be stored in the walk state */ @@ -438,66 +451,41 @@ acpi_cm_acquire_mutex (ACPI_MTX_PARSER); - /* - * The root of the method parse tree should be stored - * in the method object - */ - - op = obj_desc->method.parser_op; - if (!op) { - goto unlock_and_exit; - } /* Signal completion of the execution of this method if necessary */ if (walk_state->method_desc->method.semaphore) { status = acpi_os_signal_semaphore ( - walk_state->method_desc->method.semaphore, 1); + walk_state->method_desc->method.semaphore, 1); } /* Decrement the thread count on the method parse tree */ - op->thread_count--; - if (!op->thread_count) { + walk_state->method_desc->method.thread_count--; + if (!walk_state->method_desc->method.thread_count) { /* * There are no more threads executing this method. Perform * additional cleanup. * - * The method NTE is stored in the method Op + * The method Node is stored in the walk state */ - method_entry = op->acpi_named_object; - + method_node = walk_state->method_node; /* * Delete any namespace entries created immediately underneath * the method */ acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - if (method_entry->child_table) { - acpi_ns_delete_namespace_subtree (method_entry); + if (method_node->child) { + acpi_ns_delete_namespace_subtree (method_node); } /* * Delete any namespace entries created anywhere else within * the namespace */ - - acpi_ns_delete_namespace_by_owner ( - walk_state->method_desc->method.owning_id); - + acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owning_id); acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - - /* - * Delete the method's parse tree if asked to - */ - if (acpi_gbl_when_to_parse_methods & METHOD_DELETE_AT_COMPLETION) { - acpi_ps_delete_parse_tree ( - walk_state->method_desc->method.parser_op); - - walk_state->method_desc->method.parser_op = NULL; - } } - -unlock_and_exit: acpi_cm_release_mutex (ACPI_MTX_PARSER); return (AE_OK); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/dispatcher/dsmthdat.c linux/drivers/acpi/dispatcher/dsmthdat.c --- v2.4.0-test8/linux/drivers/acpi/dispatcher/dsmthdat.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/dispatcher/dsmthdat.c Fri Sep 15 14:30:29 2000 @@ -1,9 +1,9 @@ - -/****************************************************************************** +/******************************************************************************* * * Module Name: dsmthdat - control method arguments and local variables + * $Revision: 34 $ * - *****************************************************************************/ + ******************************************************************************/ /* * Copyright (C) 2000 R. Byron Moore @@ -25,18 +25,18 @@ #include "acpi.h" -#include "parser.h" -#include "dispatch.h" -#include "interp.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" +#include "acnamesp.h" #define _COMPONENT DISPATCHER - MODULE_NAME ("dsmthdat"); + MODULE_NAME ("dsmthdat") -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_init * @@ -49,7 +49,7 @@ * This allows Ref_of and De_ref_of to work properly for these * special data types. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_method_data_init ( @@ -62,8 +62,8 @@ * Walk_state fields are initialized to zero by the * Acpi_cm_callocate(). * - * An NTE is assigned to each argument and local so - * that Ref_of() can return a pointer to the NTE. + * An Node is assigned to each argument and local so + * that Ref_of() can return a pointer to the Node. */ /* Init the method arguments */ @@ -72,10 +72,9 @@ MOVE_UNALIGNED32_TO_32 (&walk_state->arguments[i].name, NAMEOF_ARG_NTE); - walk_state->arguments[i].name |= (i << 24); - walk_state->arguments[i].data_type = ACPI_DESC_TYPE_NAMED; - walk_state->arguments[i].type = - INTERNAL_TYPE_METHOD_ARGUMENT; + walk_state->arguments[i].name |= (i << 24); + walk_state->arguments[i].data_type = ACPI_DESC_TYPE_NAMED; + walk_state->arguments[i].type = INTERNAL_TYPE_METHOD_ARGUMENT; } /* Init the method locals */ @@ -84,18 +83,16 @@ MOVE_UNALIGNED32_TO_32 (&walk_state->local_variables[i].name, NAMEOF_LOCAL_NTE); - walk_state->local_variables[i].name |= (i << 24); + walk_state->local_variables[i].name |= (i << 24); walk_state->local_variables[i].data_type = ACPI_DESC_TYPE_NAMED; - walk_state->local_variables[i].type = - INTERNAL_TYPE_METHOD_LOCAL_VAR; + walk_state->local_variables[i].type = INTERNAL_TYPE_METHOD_LOCAL_VAR; } - return (AE_OK); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_delete_all * @@ -106,14 +103,14 @@ * DESCRIPTION: Delete method locals and arguments. Arguments are only * deleted if this method was called from another method. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_method_data_delete_all ( ACPI_WALK_STATE *walk_state) { u32 index; - ACPI_OBJECT_INTERNAL *object; + ACPI_OPERAND_OBJECT *object; /* Delete the locals */ @@ -122,8 +119,11 @@ object = walk_state->local_variables[index].object; if (object) { /* Remove first */ + walk_state->local_variables[index].object = NULL; + /* Was given a ref when stored */ + acpi_cm_remove_reference (object); } } @@ -135,8 +135,11 @@ object = walk_state->arguments[index].object; if (object) { /* Remove first */ + walk_state->arguments[index].object = NULL; + /* Was given a ref when stored */ + acpi_cm_remove_reference (object); } } @@ -145,7 +148,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_init_args * @@ -155,12 +158,13 @@ * * DESCRIPTION: Initialize arguments for a method * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_method_data_init_args ( - ACPI_OBJECT_INTERNAL **params, - u32 max_param_count) + ACPI_OPERAND_OBJECT **params, + u32 max_param_count, + ACPI_WALK_STATE *walk_state) { ACPI_STATUS status; u32 mindex; @@ -183,9 +187,8 @@ * Set the current method argument to the * Params[Pindex++] argument object descriptor */ - status = acpi_ds_method_data_set_value (MTH_TYPE_ARG, - mindex, - params[pindex]); + status = acpi_ds_method_data_set_value (MTH_TYPE_ARG, mindex, + params[pindex], walk_state); if (ACPI_FAILURE (status)) { break; } @@ -202,7 +205,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_get_entry * @@ -215,18 +218,16 @@ * * DESCRIPTION: Get the address of the stack entry given by Type:Index * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_method_data_get_entry ( u32 type, u32 index, - ACPI_OBJECT_INTERNAL ***entry) + ACPI_WALK_STATE *walk_state, + ACPI_OPERAND_OBJECT ***entry) { - ACPI_WALK_STATE *walk_state; - - walk_state = acpi_ds_get_current_walk_state (acpi_gbl_current_walk_list); /* * Get the requested object. @@ -243,7 +244,7 @@ } *entry = - (ACPI_OBJECT_INTERNAL **) &walk_state->local_variables[index].object; + (ACPI_OPERAND_OBJECT **) &walk_state->local_variables[index].object; break; @@ -254,7 +255,7 @@ } *entry = - (ACPI_OBJECT_INTERNAL **) &walk_state->arguments[index].object; + (ACPI_OPERAND_OBJECT **) &walk_state->arguments[index].object; break; @@ -267,7 +268,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_set_entry * @@ -279,21 +280,22 @@ * * DESCRIPTION: Insert an object onto the method stack at entry Type:Index. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_method_data_set_entry ( u32 type, u32 index, - ACPI_OBJECT_INTERNAL *object) + ACPI_OPERAND_OBJECT *object, + ACPI_WALK_STATE *walk_state) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL **entry; + ACPI_OPERAND_OBJECT **entry; /* Get a pointer to the stack entry to set */ - status = acpi_ds_method_data_get_entry (type, index, &entry); + status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry); if (ACPI_FAILURE (status)) { return (status); } @@ -310,7 +312,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_get_type * @@ -321,21 +323,22 @@ * RETURN: Data type of selected Arg or Local * Used only in Exec_monadic2()/Type_op. * - ****************************************************************************/ + ******************************************************************************/ OBJECT_TYPE_INTERNAL acpi_ds_method_data_get_type ( u32 type, - u32 index) + u32 index, + ACPI_WALK_STATE *walk_state) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL **entry; - ACPI_OBJECT_INTERNAL *object; + ACPI_OPERAND_OBJECT **entry; + ACPI_OPERAND_OBJECT *object; /* Get a pointer to the requested stack entry */ - status = acpi_ds_method_data_get_entry (type, index, &entry); + status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry); if (ACPI_FAILURE (status)) { return ((ACPI_TYPE_NOT_FOUND)); } @@ -355,7 +358,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_get_nte * @@ -363,20 +366,17 @@ * Index - Which local_var or argument whose type * to get * - * RETURN: Get the NTE associated with a local or arg. + * RETURN: Get the Node associated with a local or arg. * - ****************************************************************************/ + ******************************************************************************/ -ACPI_NAMED_OBJECT* +ACPI_NAMESPACE_NODE * acpi_ds_method_data_get_nte ( u32 type, - u32 index) + u32 index, + ACPI_WALK_STATE *walk_state) { - ACPI_NAMED_OBJECT *entry = NULL; - ACPI_WALK_STATE *walk_state; - - - walk_state = acpi_ds_get_current_walk_state (acpi_gbl_current_walk_list); + ACPI_NAMESPACE_NODE *node = NULL; switch (type) @@ -385,20 +385,20 @@ case MTH_TYPE_LOCAL: if (index > MTH_MAX_LOCAL) { - return (entry); + return (node); } - entry = &walk_state->local_variables[index]; + node = &walk_state->local_variables[index]; break; case MTH_TYPE_ARG: if (index > MTH_MAX_ARG) { - return (entry); + return (node); } - entry = &walk_state->arguments[index]; + node = &walk_state->arguments[index]; break; @@ -407,11 +407,11 @@ } - return (entry); + return (node); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_get_value * @@ -426,17 +426,18 @@ * at the current top of the method stack. * Used only in Acpi_aml_resolve_to_value(). * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_method_data_get_value ( u32 type, u32 index, - ACPI_OBJECT_INTERNAL **dest_desc) + ACPI_WALK_STATE *walk_state, + ACPI_OPERAND_OBJECT **dest_desc) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL **entry; - ACPI_OBJECT_INTERNAL *object; + ACPI_OPERAND_OBJECT **entry; + ACPI_OPERAND_OBJECT *object; /* Validate the object descriptor */ @@ -448,7 +449,7 @@ /* Get a pointer to the requested method stack entry */ - status = acpi_ds_method_data_get_entry (type, index, &entry); + status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry); if (ACPI_FAILURE (status)) { return (status); } @@ -494,7 +495,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_delete_value * @@ -506,21 +507,22 @@ * DESCRIPTION: Delete the entry at Type:Index on the method stack. Inserts * a null into the stack slot after the object is deleted. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_method_data_delete_value ( u32 type, - u32 index) + u32 index, + ACPI_WALK_STATE *walk_state) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL **entry; - ACPI_OBJECT_INTERNAL *object; + ACPI_OPERAND_OBJECT **entry; + ACPI_OPERAND_OBJECT *object; /* Get a pointer to the requested entry */ - status = acpi_ds_method_data_get_entry (type, index, &entry); + status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry); if (ACPI_FAILURE (status)) { return (status); } @@ -532,7 +534,7 @@ /* * Undefine the Arg or Local by setting its descriptor * pointer to NULL. Locals/Args can contain both - * ACPI_OBJECT_INTERNALS and ACPI_NAMED_OBJECTs + * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs */ *entry = NULL; @@ -554,7 +556,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_method_data_set_value * @@ -573,16 +575,17 @@ * as the new value for the Arg or Local and the reference count * is incremented. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_method_data_set_value ( u32 type, u32 index, - ACPI_OBJECT_INTERNAL *src_desc) + ACPI_OPERAND_OBJECT *src_desc, + ACPI_WALK_STATE *walk_state) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL **entry; + ACPI_OPERAND_OBJECT **entry; /* Parameter validation */ @@ -594,7 +597,7 @@ /* Get a pointer to the requested method stack entry */ - status = acpi_ds_method_data_get_entry (type, index, &entry); + status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry); if (ACPI_FAILURE (status)) { goto cleanup; } @@ -614,7 +617,7 @@ if (*entry) { /* * Check for an indirect store if an argument - * contains an object reference (stored as an NTE). + * contains an object reference (stored as an Node). * We don't allow this automatic dereferencing for * locals, since a store to a local should overwrite * anything there, including an object reference. @@ -632,16 +635,16 @@ if ((type == MTH_TYPE_ARG) && (VALID_DESCRIPTOR_TYPE (*entry, ACPI_DESC_TYPE_NAMED))) { - /* Detach an existing object from the NTE */ + /* Detach an existing object from the Node */ - acpi_ns_detach_object (*entry); + acpi_ns_detach_object ((ACPI_NAMESPACE_NODE *) *entry); /* - * Store this object into the NTE + * Store this object into the Node * (do the indirect store) */ - status = acpi_ns_attach_object (*entry, src_desc, + status = acpi_ns_attach_object ((ACPI_NAMESPACE_NODE *) *entry, src_desc, src_desc->common.type); return (status); } @@ -652,7 +655,7 @@ * before storing the new one */ - acpi_ds_method_data_delete_value (type, index); + acpi_ds_method_data_delete_value (type, index, walk_state); } @@ -663,7 +666,7 @@ * (increments the object reference count by one) */ - status = acpi_ds_method_data_set_entry (type, index, src_desc); + status = acpi_ds_method_data_set_entry (type, index, src_desc, walk_state); if (ACPI_FAILURE (status)) { goto cleanup; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/dispatcher/dsobject.c linux/drivers/acpi/dispatcher/dsobject.c --- v2.4.0-test8/linux/drivers/acpi/dispatcher/dsobject.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/dispatcher/dsobject.c Fri Sep 15 14:30:29 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: dsobject - Dispatcher object management routines + * $Revision: 43 $ * *****************************************************************************/ @@ -25,21 +25,21 @@ #include "acpi.h" -#include "parser.h" +#include "acparser.h" #include "amlcode.h" -#include "dispatch.h" -#include "interp.h" -#include "namesp.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" #define _COMPONENT DISPATCHER - MODULE_NAME ("dsobject"); + MODULE_NAME ("dsobject") /******************************************************************************* * * FUNCTION: Acpi_ds_init_one_object * - * PARAMETERS: Obj_handle - NTE of the object + * PARAMETERS: Obj_handle - Node * Level - Current nesting level * Context - Points to a init info struct * Return_value - Not used @@ -64,7 +64,6 @@ { OBJECT_TYPE_INTERNAL type; ACPI_STATUS status; - ACPI_OBJECT_INTERNAL *obj_desc; INIT_WALK_INFO *info = (INIT_WALK_INFO *) context; @@ -73,10 +72,10 @@ * was just loaded */ - if (((ACPI_NAMED_OBJECT*) obj_handle)->owner_id != + if (((ACPI_NAMESPACE_NODE *) obj_handle)->owner_id != info->table_desc->table_id) { - return AE_OK; + return (AE_OK); } @@ -119,12 +118,7 @@ */ if (acpi_gbl_when_to_parse_methods != METHOD_PARSE_AT_INIT) { - acpi_ns_delete_namespace_subtree (obj_handle); - - obj_desc = ((ACPI_NAMED_OBJECT*)obj_handle)->object; - acpi_ps_delete_parse_tree (obj_desc->method.parser_op); - obj_desc->method.parser_op = NULL; } break; @@ -149,15 +143,15 @@ * * RETURN: Status * - * DESCRIPTION: Walk the entire namespace and perform any necessary initialization - * on the objects found therein + * DESCRIPTION: Walk the entire namespace and perform any necessary + * initialization on the objects found therein * ******************************************************************************/ ACPI_STATUS acpi_ds_initialize_objects ( ACPI_TABLE_DESC *table_desc, - ACPI_NAMED_OBJECT *start_entry) + ACPI_NAMESPACE_NODE *start_node) { ACPI_STATUS status; INIT_WALK_INFO info; @@ -170,8 +164,8 @@ /* Walk entire namespace from the supplied root */ - status = acpi_walk_namespace (ACPI_TYPE_ANY, start_entry, - ACPI_INT32_MAX, acpi_ds_init_one_object, + status = acpi_walk_namespace (ACPI_TYPE_ANY, start_node, + ACPI_UINT32_MAX, acpi_ds_init_one_object, &info, NULL); return (AE_OK); @@ -197,28 +191,28 @@ ACPI_STATUS acpi_ds_init_object_from_op ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op, + ACPI_PARSE_OBJECT *op, u16 opcode, - ACPI_OBJECT_INTERNAL *obj_desc) + ACPI_OPERAND_OBJECT **obj_desc) { ACPI_STATUS status; - ACPI_GENERIC_OP *arg; - ACPI_BYTELIST_OP *byte_list; - ACPI_OBJECT_INTERNAL *arg_desc; - ACPI_OP_INFO *op_info; + ACPI_PARSE_OBJECT *arg; + ACPI_PARSE2_OBJECT *byte_list; + ACPI_OPERAND_OBJECT *arg_desc; + ACPI_OPCODE_INFO *op_info; op_info = acpi_ps_get_opcode_info (opcode); - if (!op_info) { + if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { /* Unknown opcode */ - return AE_TYPE; + return (AE_TYPE); } /* Get and prepare the first argument */ - switch (obj_desc->common.type) + switch ((*obj_desc)->common.type) { case ACPI_TYPE_BUFFER: @@ -230,31 +224,31 @@ /* Resolve the object (could be an arg or local) */ - status = acpi_aml_resolve_to_value (&arg_desc); + status = acpi_aml_resolve_to_value (&arg_desc, walk_state); if (ACPI_FAILURE (status)) { acpi_cm_remove_reference (arg_desc); - return status; + return (status); } /* We are expecting a number */ if (arg_desc->common.type != ACPI_TYPE_NUMBER) { acpi_cm_remove_reference (arg_desc); - return AE_TYPE; + return (AE_TYPE); } /* Get the value, delete the internal object */ - obj_desc->buffer.length = arg_desc->number.value; + (*obj_desc)->buffer.length = arg_desc->number.value; acpi_cm_remove_reference (arg_desc); /* Allocate the buffer */ - obj_desc->buffer.pointer = - acpi_cm_callocate (obj_desc->buffer.length); + (*obj_desc)->buffer.pointer = + acpi_cm_callocate ((*obj_desc)->buffer.length); - if (!obj_desc->buffer.pointer) { - return AE_NO_MEMORY; + if (!(*obj_desc)->buffer.pointer) { + return (AE_NO_MEMORY); } /* @@ -265,27 +259,42 @@ /* skip first arg */ arg = op->value.arg; - byte_list = (ACPI_BYTELIST_OP *) arg->next; + byte_list = (ACPI_PARSE2_OBJECT *) arg->next; if (byte_list) { if (byte_list->opcode != AML_BYTELIST_OP) { - return AE_TYPE; + return (AE_TYPE); } - MEMCPY (obj_desc->buffer.pointer, byte_list->data, - obj_desc->buffer.length); + MEMCPY ((*obj_desc)->buffer.pointer, byte_list->data, + (*obj_desc)->buffer.length); } break; + case ACPI_TYPE_PACKAGE: + + /* + * When called, an internal package object has already + * been built and is pointed to by *Obj_desc. + * Acpi_ds_build_internal_object build another internal + * package object, so remove reference to the original + * so that it is deleted. Error checking is done + * within the remove reference function. + */ + acpi_cm_remove_reference(*obj_desc); + + status = acpi_ds_build_internal_object (walk_state, op, obj_desc); + break; + case ACPI_TYPE_NUMBER: - obj_desc->number.value = op->value.integer; + (*obj_desc)->number.value = op->value.integer; break; case ACPI_TYPE_STRING: - obj_desc->string.pointer = op->value.string; - obj_desc->string.length = STRLEN (op->value.string); + (*obj_desc)->string.pointer = op->value.string; + (*obj_desc)->string.length = STRLEN (op->value.string); break; @@ -295,33 +304,33 @@ case INTERNAL_TYPE_REFERENCE: - switch (op_info->flags & OP_INFO_TYPE) + switch (ACPI_GET_OP_CLASS (op_info)) { case OPTYPE_LOCAL_VARIABLE: /* Split the opcode into a base opcode + offset */ - obj_desc->reference.op_code = AML_LOCAL_OP; - obj_desc->reference.offset = opcode - AML_LOCAL_OP; + (*obj_desc)->reference.op_code = AML_LOCAL_OP; + (*obj_desc)->reference.offset = opcode - AML_LOCAL_OP; break; case OPTYPE_METHOD_ARGUMENT: /* Split the opcode into a base opcode + offset */ - obj_desc->reference.op_code = AML_ARG_OP; - obj_desc->reference.offset = opcode - AML_ARG_OP; + (*obj_desc)->reference.op_code = AML_ARG_OP; + (*obj_desc)->reference.offset = opcode - AML_ARG_OP; break; default: /* Constants, Literals, etc.. */ if (op->opcode == AML_NAMEPATH_OP) { - /* Nte was saved in Op */ + /* Node was saved in Op */ - obj_desc->reference.nte = op->acpi_named_object; + (*obj_desc)->reference.node = op->node; } - obj_desc->reference.op_code = opcode; + (*obj_desc)->reference.op_code = opcode; break; } @@ -333,7 +342,7 @@ break; } - return AE_OK; + return (AE_OK); } @@ -354,10 +363,10 @@ ACPI_STATUS acpi_ds_build_internal_simple_obj ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op, - ACPI_OBJECT_INTERNAL **obj_desc_ptr) + ACPI_PARSE_OBJECT *op, + ACPI_OPERAND_OBJECT **obj_desc_ptr) { - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; OBJECT_TYPE_INTERNAL type; ACPI_STATUS status; @@ -369,13 +378,13 @@ * Otherwise, go ahead and look it up now */ - if (!op->acpi_named_object) { + if (!op->node) { status = acpi_ns_lookup (walk_state->scope_info, op->value.string, ACPI_TYPE_ANY, IMODE_EXECUTE, NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, NULL, - (ACPI_NAMED_OBJECT**)&(op->acpi_named_object)); + (ACPI_NAMESPACE_NODE **)&(op->node)); if (ACPI_FAILURE (status)) { return (status); @@ -403,7 +412,7 @@ } status = acpi_ds_init_object_from_op (walk_state, op, - op->opcode, obj_desc); + op->opcode, &obj_desc); if (ACPI_FAILURE (status)) { acpi_cm_remove_reference (obj_desc); @@ -433,11 +442,11 @@ ACPI_STATUS acpi_ds_build_internal_package_obj ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op, - ACPI_OBJECT_INTERNAL **obj_desc_ptr) + ACPI_PARSE_OBJECT *op, + ACPI_OPERAND_OBJECT **obj_desc_ptr) { - ACPI_GENERIC_OP *arg; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_PARSE_OBJECT *arg; + ACPI_OPERAND_OBJECT *obj_desc; ACPI_STATUS status = AE_OK; @@ -466,7 +475,7 @@ REPORT_ERROR ("Ds_build_internal_package_obj: Package vector allocation failure"); - acpi_cm_free (obj_desc); + acpi_cm_delete_object_desc (obj_desc); return (AE_NO_MEMORY); } @@ -514,8 +523,8 @@ ACPI_STATUS acpi_ds_build_internal_object ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op, - ACPI_OBJECT_INTERNAL **obj_desc_ptr) + ACPI_PARSE_OBJECT *op, + ACPI_OPERAND_OBJECT **obj_desc_ptr) { ACPI_STATUS status; @@ -536,7 +545,7 @@ /***************************************************************************** * - * FUNCTION: Acpi_ds_create_named_object + * FUNCTION: Acpi_ds_create_node * * PARAMETERS: Op - Parser object to be translated * Obj_desc_ptr - Where the ACPI internal object is returned @@ -548,13 +557,13 @@ ****************************************************************************/ ACPI_STATUS -acpi_ds_create_named_object ( +acpi_ds_create_node ( ACPI_WALK_STATE *walk_state, - ACPI_NAMED_OBJECT *entry, - ACPI_GENERIC_OP *op) + ACPI_NAMESPACE_NODE *node, + ACPI_PARSE_OBJECT *op) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; if (!op->value.arg) { @@ -575,12 +584,12 @@ /* Re-type the object according to it's argument */ - entry->type = obj_desc->common.type; + node->type = obj_desc->common.type; /* Init obj */ - status = acpi_ns_attach_object ((ACPI_HANDLE) entry, obj_desc, - (u8) entry->type); + status = acpi_ns_attach_object ((ACPI_HANDLE) node, obj_desc, + (u8) node->type); if (ACPI_FAILURE (status)) { goto cleanup; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/dispatcher/dsopcode.c linux/drivers/acpi/dispatcher/dsopcode.c --- v2.4.0-test8/linux/drivers/acpi/dispatcher/dsopcode.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/dispatcher/dsopcode.c Fri Sep 15 14:30:29 2000 @@ -1,8 +1,8 @@ - /****************************************************************************** * - * Module Name: dsopcode - Dispatcher Op Region support - * and handling of "control" opcodes + * Module Name: dsopcode - Dispatcher Op Region support and handling of + * "control" opcodes + * $Revision: 17 $ * *****************************************************************************/ @@ -26,16 +26,16 @@ #include "acpi.h" -#include "parser.h" +#include "acparser.h" #include "amlcode.h" -#include "dispatch.h" -#include "interp.h" -#include "namesp.h" -#include "events.h" -#include "tables.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" +#include "actables.h" #define _COMPONENT DISPATCHER - MODULE_NAME ("dsopcode"); + MODULE_NAME ("dsopcode") /***************************************************************************** @@ -53,23 +53,23 @@ ACPI_STATUS acpi_ds_get_region_arguments ( - ACPI_OBJECT_INTERNAL *rgn_desc) + ACPI_OPERAND_OBJECT *rgn_desc) { - ACPI_OBJECT_INTERNAL *method_desc; - ACPI_NAMED_OBJECT *entry; - ACPI_GENERIC_OP *op; - ACPI_GENERIC_OP *region_op; + ACPI_OPERAND_OBJECT *method_desc; + ACPI_NAMESPACE_NODE *node; + ACPI_PARSE_OBJECT *op; + ACPI_PARSE_OBJECT *region_op; ACPI_STATUS status; ACPI_TABLE_DESC *table_desc; - if (rgn_desc->region.region_flags & REGION_AGRUMENT_DATA_VALID) { + if (rgn_desc->region.flags & AOPOBJ_DATA_VALID) { return (AE_OK); } method_desc = rgn_desc->region.method; - entry = rgn_desc->region.nte; + node = rgn_desc->region.node; /* @@ -77,18 +77,18 @@ * Op_region tree */ - op = acpi_ps_alloc_op (AML_REGION_OP); + op = acpi_ps_alloc_op (AML_SCOPE_OP); if (!op) { - return AE_NO_MEMORY; + return (AE_NO_MEMORY); } - /* Save the NTE for use in Acpi_ps_parse_aml */ + /* Save the Node for use in Acpi_ps_parse_aml */ - op->acpi_named_object = acpi_ns_get_parent_entry (entry); + op->node = acpi_ns_get_parent_object (node); /* Get a handle to the parent ACPI table */ - status = acpi_tb_handle_to_object (entry->owner_id, &table_desc); + status = acpi_tb_handle_to_object (node->owner_id, &table_desc); if (ACPI_FAILURE (status)) { return (status); } @@ -96,20 +96,44 @@ /* Parse the entire Op_region declaration, creating a parse tree */ status = acpi_ps_parse_aml (op, method_desc->method.pcode, - method_desc->method.pcode_length, 0); - if (ACPI_SUCCESS (status)) { - /* Get and init the actual Region_op created above */ - - region_op = op->value.arg; - region_op->acpi_named_object = entry; - - /* Acpi_evaluate the address and length arguments for the Op_region */ - - acpi_ps_walk_parsed_aml (region_op, region_op, NULL, NULL, NULL, - NULL, table_desc->table_id, - acpi_ds_exec_begin_op, acpi_ds_exec_end_op); + method_desc->method.pcode_length, 0, + NULL, NULL, NULL, acpi_ds_load1_begin_op, acpi_ds_load1_end_op); + + if (ACPI_FAILURE (status)) { + acpi_ps_delete_parse_tree (op); + return (status); } + + /* Get and init the actual Region_op created above */ + +/* Region_op = Op->Value.Arg; + Op->Node = Node;*/ + + + region_op = op->value.arg; + region_op->node = node; + acpi_ps_delete_parse_tree (op); + + /* Acpi_evaluate the address and length arguments for the Op_region */ + + op = acpi_ps_alloc_op (AML_SCOPE_OP); + if (!op) { + return (AE_NO_MEMORY); + } + + op->node = acpi_ns_get_parent_object (node); + + status = acpi_ps_parse_aml (op, method_desc->method.pcode, + method_desc->method.pcode_length, + ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE, + NULL /*Method_desc*/, NULL, NULL, + acpi_ds_exec_begin_op, acpi_ds_exec_end_op); +/* + Acpi_ps_walk_parsed_aml (Region_op, Region_op, NULL, NULL, NULL, + NULL, Table_desc->Table_id, + Acpi_ds_exec_begin_op, Acpi_ds_exec_end_op); +*/ /* All done with the parse tree, delete it */ acpi_ps_delete_parse_tree (op); @@ -134,7 +158,7 @@ acpi_ds_initialize_region ( ACPI_HANDLE obj_handle) { - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; ACPI_STATUS status; @@ -144,7 +168,7 @@ status = acpi_ev_initialize_region (obj_desc, FALSE); - return status; + return (status); } @@ -164,20 +188,20 @@ ACPI_STATUS acpi_ds_eval_region_operands ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT *op) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL *region_desc; - ACPI_NAMED_OBJECT *entry; - ACPI_GENERIC_OP *next_op; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_OPERAND_OBJECT *region_desc; + ACPI_NAMESPACE_NODE *node; + ACPI_PARSE_OBJECT *next_op; /* * This is where we evaluate the address and length fields of the Op_region declaration */ - entry = op->acpi_named_object; + node = op->node; /* Next_op points to the op that holds the Space_iD */ next_op = op->value.arg; @@ -192,7 +216,7 @@ return (status); } - region_desc = acpi_ns_get_attached_object (entry); + region_desc = acpi_ns_get_attached_object (node); if (!region_desc) { return (AE_NOT_EXIST); } @@ -216,7 +240,7 @@ /* Now the address and length are valid for this opregion */ - region_desc->region.region_flags |= REGION_AGRUMENT_DATA_VALID; + region_desc->region.flags |= AOPOBJ_DATA_VALID; return (status); } @@ -239,7 +263,7 @@ ACPI_STATUS acpi_ds_exec_begin_control_op ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT *op) { ACPI_STATUS status = AE_OK; ACPI_GENERIC_STATE *control_state; @@ -263,6 +287,14 @@ } acpi_cm_push_generic_state (&walk_state->control_state, control_state); + + /* + * Save a pointer to the predicate for multiple executions + * of a loop + */ + walk_state->control_state->control.aml_predicate_start = + walk_state->parser_state->aml - 1; + /*Acpi_ps_pkg_length_encoding_size (GET8 (Walk_state->Parser_state->Aml));*/ break; @@ -287,7 +319,7 @@ break; } - return status; + return (status); } @@ -309,7 +341,7 @@ ACPI_STATUS acpi_ds_exec_end_control_op ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT *op) { ACPI_STATUS status = AE_OK; ACPI_GENERIC_STATE *control_state; @@ -350,16 +382,18 @@ if (walk_state->control_state->common.value) { /* Predicate was true, go back and evaluate it again! */ - status = AE_CTRL_TRUE; + status = AE_CTRL_PENDING; } - else { +/* else {*/ /* Pop this control state and free it */ control_state = acpi_cm_pop_generic_state (&walk_state->control_state); + + walk_state->aml_last_while = control_state->control.aml_predicate_start; acpi_cm_delete_generic_state (control_state); - } +/* }*/ break; @@ -367,44 +401,62 @@ case AML_RETURN_OP: - /* One optional operand -- the return value */ - + /* + * One optional operand -- the return value + * It can be either an immediate operand or a result that + * has been bubbled up the tree + */ if (op->value.arg) { + /* Return statement has an immediate operand */ + status = acpi_ds_create_operands (walk_state, op->value.arg); if (ACPI_FAILURE (status)) { - return status; + return (status); } /* - * TBD: [Restructure] Just check for NULL arg - * to signify no return value??? - */ - - /* * If value being returned is a Reference (such as * an arg or local), resolve it now because it may * cease to exist at the end of the method. */ - status = acpi_aml_resolve_to_value (&walk_state->operands [0]); + status = acpi_aml_resolve_to_value (&walk_state->operands [0], walk_state); if (ACPI_FAILURE (status)) { - return status; + return (status); } /* * Get the return value and save as the last result - * value - * This is the only place where Walk_state->Return_desc + * value. This is the only place where Walk_state->Return_desc * is set to anything other than zero! */ walk_state->return_desc = walk_state->operands[0]; } + else if (walk_state->num_results > 0) { + /* + * The return value has come from a previous calculation. + * + * If value being returned is a Reference (such as + * an arg or local), resolve it now because it may + * cease to exist at the end of the method. + */ + + status = acpi_aml_resolve_to_value (&walk_state->results [0], walk_state); + if (ACPI_FAILURE (status)) { + return (status); + } + + walk_state->return_desc = walk_state->results [0]; + } + else { /* No return operand */ - acpi_cm_remove_reference (walk_state->operands [0]); + if (walk_state->num_operands) { + acpi_cm_remove_reference (walk_state->operands [0]); + } walk_state->operands [0] = NULL; walk_state->num_operands = 0; @@ -417,7 +469,7 @@ break; - case AML_NOOP_CODE: + case AML_NOOP_OP: /* Just do nothing! */ break; @@ -459,6 +511,6 @@ } - return status; + return (status); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/dispatcher/dsutils.c linux/drivers/acpi/dispatcher/dsutils.c --- v2.4.0-test8/linux/drivers/acpi/dispatcher/dsutils.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/dispatcher/dsutils.c Fri Sep 15 14:30:29 2000 @@ -1,9 +1,9 @@ - -/****************************************************************************** +/******************************************************************************* * * Module Name: dsutils - Dispatcher utilities + * $Revision: 44 $ * - *****************************************************************************/ + ******************************************************************************/ /* * Copyright (C) 2000 R. Byron Moore @@ -25,20 +25,20 @@ #include "acpi.h" -#include "parser.h" +#include "acparser.h" #include "amlcode.h" -#include "dispatch.h" -#include "interp.h" -#include "namesp.h" -#include "debugger.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdebug.h" #define _COMPONENT PARSER - MODULE_NAME ("dsutils"); + MODULE_NAME ("dsutils") -/***************************************************************************** +/******************************************************************************* * - * FUNCTION: Acpi_ds_delete_result_if_not_used + * FUNCTION: Acpi_ds_is_result_used * * PARAMETERS: Op * Result_obj @@ -46,52 +46,32 @@ * * RETURN: Status * - * DESCRIPTION: Used after interpretation of an opcode. If there is an internal - * result descriptor, check if the parent opcode will actually use - * this result. If not, delete the result now so that it will - * not become orphaned. + * DESCRIPTION: Check if a result object will be used by the parent * - ****************************************************************************/ + ******************************************************************************/ -void -acpi_ds_delete_result_if_not_used ( - ACPI_GENERIC_OP *op, - ACPI_OBJECT_INTERNAL *result_obj, - ACPI_WALK_STATE *walk_state) +u8 +acpi_ds_is_result_used ( + ACPI_PARSE_OBJECT *op) { - ACPI_OP_INFO *parent_info; - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_STATUS status; + ACPI_OPCODE_INFO *parent_info; + + /* Must have both an Op and a Result Object */ if (!op) { - return; + return (TRUE); } - if (!result_obj) { - return; - } + /* + * If there is no parent, the result can't possibly be used! + * (An executing method typically has no parent, since each + * method is parsed separately) However, a method that is + * invoked from another method has a parent. + */ if (!op->parent) { - /* - * If there is no parent, the result can't possibly be used! - * (An executing method typically has no parent, since each - * method is parsed separately - */ - - /* - * Must pop the result stack (Obj_desc should be equal - * to Result_obj) - */ - - status = acpi_ds_result_stack_pop (&obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - return; - } - - acpi_cm_remove_reference (result_obj); - - return; + return (FALSE); } @@ -100,15 +80,15 @@ */ parent_info = acpi_ps_get_opcode_info (op->parent->opcode); - if (!parent_info) { - return; + if (ACPI_GET_OP_TYPE (parent_info) != ACPI_OP_TYPE_OPCODE) { + return (FALSE); } /* Never delete the return value associated with a return opcode */ if (op->parent->opcode == AML_RETURN_OP) { - return; + return (TRUE); } @@ -119,26 +99,15 @@ * as an operand later. */ - switch (parent_info->flags & OP_INFO_TYPE) + switch (ACPI_GET_OP_CLASS (parent_info)) { /* - * In these cases, the parent will never use the return object, - * so delete it here and now. + * In these cases, the parent will never use the return object */ case OPTYPE_CONTROL: /* IF, ELSE, WHILE only */ case OPTYPE_NAMED_OBJECT: /* Scope, method, etc. */ - /* - * Must pop the result stack (Obj_desc should be equal - * to Result_obj) - */ - - status = acpi_ds_result_stack_pop (&obj_desc, walk_state); - if (ACPI_FAILURE (status)) { - return; - } - - acpi_cm_remove_reference (result_obj); + return (FALSE); break; /* @@ -149,11 +118,63 @@ break; } + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_ds_delete_result_if_not_used + * + * PARAMETERS: Op + * Result_obj + * Walk_state + * + * RETURN: Status + * + * DESCRIPTION: Used after interpretation of an opcode. If there is an internal + * result descriptor, check if the parent opcode will actually use + * this result. If not, delete the result now so that it will + * not become orphaned. + * + ******************************************************************************/ + +void +acpi_ds_delete_result_if_not_used ( + ACPI_PARSE_OBJECT *op, + ACPI_OPERAND_OBJECT *result_obj, + ACPI_WALK_STATE *walk_state) +{ + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_STATUS status; + + + if (!op) { + return; + } + + if (!result_obj) { + return; + } + + + if (!acpi_ds_is_result_used (op)) { + /* + * Must pop the result stack (Obj_desc should be equal + * to Result_obj) + */ + + status = acpi_ds_result_stack_pop (&obj_desc, walk_state); + if (ACPI_SUCCESS (status)) { + acpi_cm_remove_reference (result_obj); + } + } + return; } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_create_operand * @@ -167,19 +188,19 @@ * looking up a name or entering a new name into the internal * namespace. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_create_operand ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *arg) + ACPI_PARSE_OBJECT *arg) { ACPI_STATUS status = AE_OK; - char *name_string; + NATIVE_CHAR *name_string; u32 name_length; OBJECT_TYPE_INTERNAL data_type; - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_GENERIC_OP *parent_op; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_PARSE_OBJECT *parent_op; u16 opcode; u32 flags; OPERATING_MODE interpreter_mode; @@ -214,7 +235,7 @@ */ parent_op = arg->parent; - if ((acpi_ps_is_named_object_op (parent_op->opcode)) && + if ((acpi_ps_is_node_op (parent_op->opcode)) && (parent_op->opcode != AML_METHODCALL_OP) && (parent_op->opcode != AML_NAMEPATH_OP)) { @@ -233,7 +254,7 @@ ACPI_TYPE_ANY, interpreter_mode, NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, walk_state, - (ACPI_NAMED_OBJECT**) &obj_desc); + (ACPI_NAMESPACE_NODE **) &obj_desc); /* Free the namestring created above */ @@ -252,7 +273,7 @@ * indicate this to the interpreter, set the * object to the root */ - obj_desc = (ACPI_OBJECT_INTERNAL *) acpi_gbl_root_object; + obj_desc = (ACPI_OPERAND_OBJECT *) acpi_gbl_root_node; status = AE_OK; } @@ -277,6 +298,7 @@ if (ACPI_FAILURE (status)) { return (status); } + DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state)); } @@ -311,6 +333,8 @@ } if (flags & OP_HAS_RETURN_VALUE) { + DEBUGGER_EXEC (acpi_db_display_argument_object (walk_state->operands [walk_state->num_operands - 1], walk_state)); + /* * Use value that was already previously returned * by the evaluation of this argument @@ -338,9 +362,9 @@ /* Initialize the new object */ status = acpi_ds_init_object_from_op (walk_state, arg, - opcode, obj_desc); + opcode, &obj_desc); if (ACPI_FAILURE (status)) { - acpi_cm_free (obj_desc); + acpi_cm_delete_object_desc (obj_desc); return (status); } } @@ -352,13 +376,14 @@ return (status); } + DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state)); } return (AE_OK); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_create_operands * @@ -370,15 +395,15 @@ * namespace objects and place those argument object on the object * stack in preparation for evaluation by the interpreter. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_create_operands ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *first_arg) + ACPI_PARSE_OBJECT *first_arg) { ACPI_STATUS status = AE_OK; - ACPI_GENERIC_OP *arg; + ACPI_PARSE_OBJECT *arg; u32 args_pushed = 0; @@ -416,7 +441,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_resolve_operands * @@ -428,7 +453,7 @@ * arguments to a control method invocation (a call from one * method to another.) * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ds_resolve_operands ( @@ -449,7 +474,7 @@ */ for (i = 0; i < walk_state->num_operands; i++) { - status = acpi_aml_resolve_to_value (&walk_state->operands[i]); + status = acpi_aml_resolve_to_value (&walk_state->operands[i], walk_state); if (ACPI_FAILURE (status)) { break; } @@ -459,7 +484,7 @@ } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_map_opcode_to_data_type * @@ -472,7 +497,7 @@ * if any. If the opcode returns a value as part of the * intepreter execution, a flag is returned in Out_flags. * - ****************************************************************************/ + ******************************************************************************/ OBJECT_TYPE_INTERNAL acpi_ds_map_opcode_to_data_type ( @@ -480,18 +505,18 @@ u32 *out_flags) { OBJECT_TYPE_INTERNAL data_type = INTERNAL_TYPE_INVALID; - ACPI_OP_INFO *op_info; + ACPI_OPCODE_INFO *op_info; u32 flags = 0; op_info = acpi_ps_get_opcode_info (opcode); - if (!op_info) { + if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { /* Unknown opcode */ - return data_type; + return (data_type); } - switch (op_info->flags & OP_INFO_TYPE) + switch (ACPI_GET_OP_CLASS (op_info)) { case OPTYPE_LITERAL: @@ -552,6 +577,7 @@ case OPTYPE_DYADIC2_s: case OPTYPE_INDEX: case OPTYPE_MATCH: + case OPTYPE_RETURN: flags = OP_HAS_RETURN_VALUE; data_type = ACPI_TYPE_ANY; @@ -592,11 +618,11 @@ *out_flags = flags; } - return data_type; + return (data_type); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ds_map_named_opcode_to_data_type * @@ -607,7 +633,7 @@ * DESCRIPTION: Convert a raw Named AML opcode to the associated data type. * Named opcodes are a subsystem of the AML opcodes. * - ****************************************************************************/ + ******************************************************************************/ OBJECT_TYPE_INTERNAL acpi_ds_map_named_opcode_to_data_type ( @@ -688,7 +714,7 @@ } - return data_type; + return (data_type); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/dispatcher/dswexec.c linux/drivers/acpi/dispatcher/dswexec.c --- v2.4.0-test8/linux/drivers/acpi/dispatcher/dswexec.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/dispatcher/dswexec.c Fri Sep 15 14:30:29 2000 @@ -1,7 +1,8 @@ /****************************************************************************** * * Module Name: dswexec - Dispatcher method execution callbacks; - * Dispatch to interpreter. + * dispatch to interpreter. + * $Revision: 42 $ * *****************************************************************************/ @@ -25,16 +26,16 @@ #include "acpi.h" -#include "parser.h" +#include "acparser.h" #include "amlcode.h" -#include "dispatch.h" -#include "interp.h" -#include "namesp.h" -#include "debugger.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdebug.h" #define _COMPONENT DISPATCHER - MODULE_NAME ("dswexec"); + MODULE_NAME ("dswexec") /***************************************************************************** @@ -55,14 +56,29 @@ ACPI_STATUS acpi_ds_exec_begin_op ( + u16 opcode, + ACPI_PARSE_OBJECT *op, ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT **out_op) { - ACPI_OP_INFO *op_info; + ACPI_OPCODE_INFO *op_info; ACPI_STATUS status = AE_OK; + if (!op) { + status = acpi_ds_load2_begin_op (opcode, NULL, walk_state, out_op); + if (ACPI_FAILURE (status)) { + return (status); + } + + op = *out_op; + } + if (op == walk_state->origin) { + if (out_op) { + *out_op = op; + } + return (AE_OK); } @@ -97,7 +113,7 @@ * Handle the opcode based upon the opcode type */ - switch (op_info->flags & OP_INFO_TYPE) + switch (ACPI_GET_OP_CLASS (op_info)) { case OPTYPE_CONTROL: @@ -107,7 +123,7 @@ case OPTYPE_NAMED_OBJECT: - if (walk_state->origin->opcode == AML_METHOD_OP) { + if (walk_state->walk_type == WALK_METHOD) { /* * Found a named object declaration during method * execution; we must enter this object into the @@ -116,7 +132,7 @@ * of this method. */ - status = acpi_ds_load2_begin_op (walk_state, op); + status = acpi_ds_load2_begin_op (op->opcode, op, walk_state, NULL); } break; @@ -150,17 +166,17 @@ ACPI_STATUS acpi_ds_exec_end_op ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT *op) { ACPI_STATUS status = AE_OK; u16 opcode; u8 optype; - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_GENERIC_OP *next_op; - ACPI_NAMED_OBJECT *entry; - ACPI_GENERIC_OP *first_arg; - ACPI_OBJECT_INTERNAL *result_obj = NULL; - ACPI_OP_INFO *op_info; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_PARSE_OBJECT *next_op; + ACPI_NAMESPACE_NODE *node; + ACPI_PARSE_OBJECT *first_arg; + ACPI_OPERAND_OBJECT *result_obj = NULL; + ACPI_OPCODE_INFO *op_info; u32 operand_index; @@ -168,11 +184,11 @@ op_info = acpi_ps_get_opcode_info (op->opcode); - if (!op_info) { + if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { return (AE_NOT_IMPLEMENTED); } - optype = (u8) (op_info->flags & OP_INFO_TYPE); + optype = (u8) ACPI_GET_OP_CLASS (op_info); first_arg = op->value.arg; /* Init the walk state */ @@ -183,6 +199,9 @@ /* Call debugger for single step support (DEBUG build only) */ + DEBUGGER_EXEC (status = acpi_db_single_step (walk_state, op, optype)); + DEBUGGER_EXEC (if (ACPI_FAILURE (status)) {return (status);}); + /* Decode the opcode */ @@ -220,6 +239,7 @@ case OPTYPE_CREATE_FIELD: case OPTYPE_FATAL: + status = acpi_ds_create_operands (walk_state, first_arg); if (ACPI_FAILURE (status)) { goto cleanup; @@ -376,12 +396,12 @@ case OPTYPE_METHOD_CALL: /* - * (AML_METHODCALL) Op->Value->Arg->Acpi_named_object contains - * the method NTE pointer + * (AML_METHODCALL) Op->Value->Arg->Node contains + * the method Node pointer */ /* Next_op points to the op that holds the method name */ next_op = first_arg; - entry = next_op->acpi_named_object; + node = next_op->node; /* Next_op points to first argument op */ next_op = next_op->next; @@ -410,7 +430,7 @@ /* Open new scope on the scope stack */ /* - Status = Acpi_ns_scope_stack_push_entry (Entry); + Status = Acpi_ns_scope_stack_push_entry (Node); if (ACPI_FAILURE (Status)) { break; } @@ -419,7 +439,7 @@ /* Tell the walk loop to preempt this running method and execute the new method */ - status = AE_CTRL_PENDING; + status = AE_CTRL_TRANSFER; /* Return now; we don't want to disturb anything, especially the operand count! */ @@ -431,14 +451,20 @@ case OPTYPE_NAMED_OBJECT: - if ((walk_state->origin->opcode == AML_METHOD_OP) && - (walk_state->origin != op)) + status = acpi_ds_load2_end_op (walk_state, op); + if (ACPI_FAILURE (status)) { + break; + } +/* + if ((Walk_state->Origin->Opcode == AML_METHOD_OP) && + (Walk_state->Origin != Op)) { - status = acpi_ds_load2_end_op (walk_state, op); - if (ACPI_FAILURE (status)) { + Status = Acpi_ds_load2_end_op (Walk_state, Op); + if (ACPI_FAILURE (Status)) { break; } } +*/ switch (op->opcode) { @@ -504,7 +530,7 @@ goto cleanup; } - status = acpi_aml_resolve_to_value (&walk_state->operands [0]); + status = acpi_aml_resolve_to_value (&walk_state->operands [0], walk_state); if (ACPI_FAILURE (status)) { goto cleanup; } @@ -537,6 +563,8 @@ /* Break to debugger to display result */ + DEBUGGER_EXEC (acpi_db_display_result_object (obj_desc, walk_state)); + /* Delete the predicate result object (we know that we don't need it anymore) and cleanup the stack */ @@ -551,6 +579,8 @@ if (result_obj) { /* Break to debugger to display result */ + + DEBUGGER_EXEC (acpi_db_display_result_object (result_obj, walk_state)); /* * Delete the result op if and only if: diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/dispatcher/dswload.c linux/drivers/acpi/dispatcher/dswload.c --- v2.4.0-test8/linux/drivers/acpi/dispatcher/dswload.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/dispatcher/dswload.c Fri Sep 15 14:30:29 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: dswload - Dispatcher namespace load callbacks + * $Revision: 19 $ * *****************************************************************************/ @@ -25,16 +25,16 @@ #include "acpi.h" -#include "parser.h" +#include "acparser.h" #include "amlcode.h" -#include "dispatch.h" -#include "interp.h" -#include "namesp.h" -#include "events.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" #define _COMPONENT DISPATCHER - MODULE_NAME ("dswload"); + MODULE_NAME ("dswload") /***************************************************************************** @@ -53,61 +53,75 @@ ACPI_STATUS acpi_ds_load1_begin_op ( + u16 opcode, + ACPI_PARSE_OBJECT *op, ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT **out_op) { - ACPI_NAMED_OBJECT *new_entry; + ACPI_NAMESPACE_NODE *node; ACPI_STATUS status; OBJECT_TYPE_INTERNAL data_type; + NATIVE_CHAR *path; /* We are only interested in opcodes that have an associated name */ - if (!acpi_ps_is_named_op (op->opcode)) { - return AE_OK; + if (!acpi_ps_is_named_op (opcode)) { + *out_op = op; + return (AE_OK); } /* Check if this object has already been installed in the namespace */ - if (op->acpi_named_object) { - return AE_OK; + if (op && op->node) { + *out_op = op; + return (AE_OK); } + path = acpi_ps_get_next_namestring (walk_state->parser_state); + /* Map the raw opcode into an internal object type */ - data_type = acpi_ds_map_named_opcode_to_data_type (op->opcode); + data_type = acpi_ds_map_named_opcode_to_data_type (opcode); - /* Attempt to type a NAME opcode by examining the argument */ - /* TBD: [Investigate] is this the right place to do this? */ + /* + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that involve + * arguments to the opcode must be created as we go back up the parse tree later. + */ + status = acpi_ns_lookup (walk_state->scope_info, path, + data_type, IMODE_LOAD_PASS1, + NS_NO_UPSEARCH, walk_state, &(node)); - if (op->opcode == AML_NAME_OP) { - if (op->value.arg) { + if (ACPI_FAILURE (status)) { + return (status); + } - data_type = acpi_ds_map_opcode_to_data_type ((op->value.arg)->opcode, - NULL); + if (!op) { + /* Create a new op */ + + op = acpi_ps_alloc_op (opcode); + if (!op) { + return (AE_NO_MEMORY); } } + /* Initialize */ + + ((ACPI_PARSE2_OBJECT *)op)->name = node->name; /* - * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that involve - * arguments to the opcode must be created as we go back up the parse tree later. + * Put the Node in the "op" object that the parser uses, so we + * can get it again quickly when this scope is closed */ - status = acpi_ns_lookup (walk_state->scope_info, - (char *) &((ACPI_NAMED_OP *)op)->name, - data_type, IMODE_LOAD_PASS1, - NS_NO_UPSEARCH, walk_state, &(new_entry)); + op->node = node; - if (ACPI_SUCCESS (status)) { - /* - * Put the NTE in the "op" object that the parser uses, so we - * can get it again quickly when this scope is closed - */ - op->acpi_named_object = new_entry; - } + + acpi_ps_append_arg (acpi_ps_get_parent_scope (walk_state->parser_state), op); + + *out_op = op; return (status); } @@ -131,7 +145,7 @@ ACPI_STATUS acpi_ds_load1_end_op ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT *op) { OBJECT_TYPE_INTERNAL data_type; @@ -139,20 +153,26 @@ /* We are only interested in opcodes that have an associated name */ if (!acpi_ps_is_named_op (op->opcode)) { - return AE_OK; + return (AE_OK); } - /* TBD: [Investigate] can this be removed? */ - if (op->opcode == AML_SCOPE_OP) { - if (((ACPI_NAMED_OP *)op)->name == -1) { - return AE_OK; + /* Get the type to determine if we should pop the scope */ + + data_type = acpi_ds_map_named_opcode_to_data_type (op->opcode); + + if (op->opcode == AML_NAME_OP) { + /* For Name opcode, check the argument */ + + if (op->value.arg) { + data_type = acpi_ds_map_opcode_to_data_type ( + (op->value.arg)->opcode, NULL); + ((ACPI_NAMESPACE_NODE *)op->node)->type = + (u8) data_type; } } - data_type = acpi_ds_map_named_opcode_to_data_type (op->opcode); - /* Pop the scope stack */ if (acpi_ns_opens_scope (data_type)) { @@ -160,7 +180,7 @@ acpi_ds_scope_stack_pop (walk_state); } - return AE_OK; + return (AE_OK); } @@ -181,60 +201,74 @@ ACPI_STATUS acpi_ds_load2_begin_op ( + u16 opcode, + ACPI_PARSE_OBJECT *op, ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT **out_op) { - ACPI_NAMED_OBJECT *new_entry; + ACPI_NAMESPACE_NODE *node; ACPI_STATUS status; OBJECT_TYPE_INTERNAL data_type; - char *buffer_ptr; + NATIVE_CHAR *buffer_ptr; void *original = NULL; /* We only care about Namespace opcodes here */ - if (!acpi_ps_is_namespace_op (op->opcode) && - op->opcode != AML_NAMEPATH_OP) + if (!acpi_ps_is_namespace_op (opcode) && + opcode != AML_NAMEPATH_OP) { - return AE_OK; + return (AE_OK); } - /* - * Get the name we are going to enter or lookup in the namespace - */ - if (op->opcode == AML_NAMEPATH_OP) { - /* For Namepath op , get the path string */ + /* Temp! same code as in psparse */ + + if (!acpi_ps_is_named_op (opcode)) { + return (AE_OK); + } + + if (op) { + /* + * Get the name we are going to enter or lookup in the namespace + */ + if (opcode == AML_NAMEPATH_OP) { + /* For Namepath op, get the path string */ + + buffer_ptr = op->value.string; + if (!buffer_ptr) { + /* No name, just exit */ + + return (AE_OK); + } + } - buffer_ptr = op->value.string; - if (!buffer_ptr) { - /* No name, just exit */ + else { + /* Get name from the op */ - return AE_OK; + buffer_ptr = (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)op)->name; } } else { - /* Get name from the op */ - - buffer_ptr = (char *) &((ACPI_NAMED_OP *)op)->name; + buffer_ptr = acpi_ps_get_next_namestring (walk_state->parser_state); } /* Map the raw opcode into an internal object type */ - data_type = acpi_ds_map_named_opcode_to_data_type (op->opcode); + data_type = acpi_ds_map_named_opcode_to_data_type (opcode); - if (op->opcode == AML_DEF_FIELD_OP || - op->opcode == AML_BANK_FIELD_OP || - op->opcode == AML_INDEX_FIELD_OP) + if (opcode == AML_DEF_FIELD_OP || + opcode == AML_BANK_FIELD_OP || + opcode == AML_INDEX_FIELD_OP) { - new_entry = NULL; + node = NULL; status = AE_OK; } - else if (op->opcode == AML_NAMEPATH_OP) { + else if (opcode == AML_NAMEPATH_OP) { /* * The Name_path is an object reference to an existing object. Don't enter the * name into the namespace, but look it up for use later @@ -242,16 +276,16 @@ status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, data_type, IMODE_EXECUTE, NS_SEARCH_PARENT, walk_state, - &(new_entry)); + &(node)); } else { - if (op->acpi_named_object) { - original = op->acpi_named_object; - new_entry = op->acpi_named_object; + if (op && op->node) { + original = op->node; + node = op->node; if (acpi_ns_opens_scope (data_type)) { - status = acpi_ds_scope_stack_push (new_entry->child_table, + status = acpi_ds_scope_stack_push (node, data_type, walk_state); if (ACPI_FAILURE (status)) { @@ -259,7 +293,7 @@ } } - return AE_OK; + return (AE_OK); } /* @@ -270,15 +304,30 @@ status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, data_type, IMODE_EXECUTE, NS_NO_UPSEARCH, walk_state, - &(new_entry)); + &(node)); } if (ACPI_SUCCESS (status)) { + if (!op) { + /* Create a new op */ + + op = acpi_ps_alloc_op (opcode); + if (!op) { + return (AE_NO_MEMORY); + } + + /* Initialize */ + + ((ACPI_PARSE2_OBJECT *)op)->name = node->name; + *out_op = op; + } + + /* - * Put the NTE in the "op" object that the parser uses, so we + * Put the Node in the "op" object that the parser uses, so we * can get it again quickly when this scope is closed */ - op->acpi_named_object = new_entry; + op->node = node; } @@ -305,22 +354,22 @@ ACPI_STATUS acpi_ds_load2_end_op ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT *op) { ACPI_STATUS status = AE_OK; OBJECT_TYPE_INTERNAL data_type; - ACPI_NAMED_OBJECT *entry; - ACPI_GENERIC_OP *arg; - ACPI_NAMED_OBJECT *new_entry; + ACPI_NAMESPACE_NODE *node; + ACPI_PARSE_OBJECT *arg; + ACPI_NAMESPACE_NODE *new_node; if (!acpi_ps_is_namespace_object_op (op->opcode)) { - return AE_OK; + return (AE_OK); } if (op->opcode == AML_SCOPE_OP) { - if (((ACPI_NAMED_OP *)op)->name == -1) { - return AE_OK; + if (((ACPI_PARSE2_OBJECT *)op)->name == -1) { + return (AE_OK); } } @@ -328,17 +377,17 @@ data_type = acpi_ds_map_named_opcode_to_data_type (op->opcode); /* - * Get the NTE/name from the earlier lookup + * Get the Node/name from the earlier lookup * (It was saved in the *op structure) */ - entry = op->acpi_named_object; + node = op->node; /* - * Put the NTE on the object stack (Contains the ACPI Name of + * Put the Node on the object stack (Contains the ACPI Name of * this object) */ - walk_state->operands[0] = (void *) entry; + walk_state->operands[0] = (void *) node; walk_state->num_operands = 1; /* Pop the scope stack */ @@ -409,29 +458,38 @@ INTERNAL_TYPE_DEF_ANY, IMODE_LOAD_PASS1, NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - walk_state, &(new_entry)); + walk_state, &(new_node)); if (ACPI_SUCCESS (status)) { - /* We could put the returned object (NTE) on the object stack for later, but + /* We could put the returned object (Node) on the object stack for later, but * for now, we will put it in the "op" object that the parser uses, so we * can get it again at the end of this scope */ - op->acpi_named_object = new_entry; - } + op->node = new_node; + /* + * If this is NOT a control method, we need to evaluate this opcode now. + */ + + /* THIS WON"T WORK. Must execute all operands like Add(). => Must do an execute pass + if (!Walk_state->Method_desc) { + Status = Acpi_ds_exec_end_op (Walk_state, Op); + } + */ + } break; case AML_METHODCALL_OP: /* - * Lookup the method name and save the NTE + * Lookup the method name and save the Node */ status = acpi_ns_lookup (walk_state->scope_info, arg->value.string, ACPI_TYPE_ANY, IMODE_LOAD_PASS2, NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, - walk_state, &(new_entry)); + walk_state, &(new_node)); if (ACPI_SUCCESS (status)) { @@ -440,11 +498,11 @@ /* TBD: [Restructure] Make sure that what we found is indeed a method! */ /* We didn't search for a method on purpose, to see if the name would resolve! */ - /* We could put the returned object (NTE) on the object stack for later, but + /* We could put the returned object (Node) on the object stack for later, but * for now, we will put it in the "op" object that the parser uses, so we * can get it again at the end of this scope */ - op->acpi_named_object = new_entry; + op->node = new_node; } @@ -455,7 +513,7 @@ /* Nothing to do other than enter object into namespace */ - status = acpi_aml_exec_create_processor (op, (ACPI_HANDLE) entry); + status = acpi_aml_exec_create_processor (op, (ACPI_HANDLE) node); if (ACPI_FAILURE (status)) { goto cleanup; } @@ -467,7 +525,7 @@ /* Nothing to do other than enter object into namespace */ - status = acpi_aml_exec_create_power_resource (op, (ACPI_HANDLE) entry); + status = acpi_aml_exec_create_power_resource (op, (ACPI_HANDLE) node); if (ACPI_FAILURE (status)) { goto cleanup; } @@ -487,7 +545,7 @@ arg = op->value.arg; status = acpi_ds_create_field (op, - (ACPI_HANDLE) arg->acpi_named_object, + arg->node, walk_state); break; @@ -497,7 +555,7 @@ arg = op->value.arg; status = acpi_ds_create_index_field (op, - (ACPI_HANDLE) arg->acpi_named_object, + (ACPI_HANDLE) arg->node, walk_state); break; @@ -506,7 +564,7 @@ arg = op->value.arg; status = acpi_ds_create_bank_field (op, - (ACPI_HANDLE) arg->acpi_named_object, + arg->node, walk_state); break; @@ -516,10 +574,10 @@ */ case AML_METHOD_OP: - if (!entry->object) { - status = acpi_aml_exec_create_method (((ACPI_DEFERRED_OP *) op)->body, - ((ACPI_DEFERRED_OP *) op)->body_length, - arg->value.integer, (ACPI_HANDLE) entry); + if (!node->object) { + status = acpi_aml_exec_create_method (((ACPI_PARSE2_OBJECT *) op)->data, + ((ACPI_PARSE2_OBJECT *) op)->length, + arg->value.integer, (ACPI_HANDLE) node); } break; @@ -549,14 +607,18 @@ case AML_REGION_OP: + if (node->object) { + break; + } + /* * The Op_region is not fully parsed at this time. Only valid argument is the Space_id. * (We must save the address of the AML of the address and length operands) */ - status = acpi_aml_exec_create_region (((ACPI_DEFERRED_OP *) op)->body, - ((ACPI_DEFERRED_OP *) op)->body_length, + status = acpi_aml_exec_create_region (((ACPI_PARSE2_OBJECT *) op)->data, + ((ACPI_PARSE2_OBJECT *) op)->length, arg->value.integer, walk_state); break; @@ -577,7 +639,7 @@ case AML_NAME_OP: - status = acpi_ds_create_named_object (walk_state, entry, op); + status = acpi_ds_create_node (walk_state, node, op); break; @@ -593,7 +655,9 @@ cleanup: - /* Remove the NTE pushed at the very beginning */ + + /* Remove the Node pushed at the very beginning */ + acpi_ds_obj_stack_pop (1, walk_state); return (status); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/dispatcher/dswscope.c linux/drivers/acpi/dispatcher/dswscope.c --- v2.4.0-test8/linux/drivers/acpi/dispatcher/dswscope.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/dispatcher/dswscope.c Fri Sep 15 14:30:29 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: dswscope - Scope stack manipulation + * $Revision: 38 $ * *****************************************************************************/ @@ -25,12 +25,12 @@ #include "acpi.h" -#include "interp.h" -#include "dispatch.h" +#include "acinterp.h" +#include "acdispat.h" #define _COMPONENT NAMESPACE - MODULE_NAME ("dswscope"); + MODULE_NAME ("dswscope") #define STACK_POP(head) head @@ -69,24 +69,24 @@ * * FUNCTION: Acpi_ds_scope_stack_push * - * PARAMETERS: *New_scope, - Name to be made current - * Type, - Type of frame being pushed + * PARAMETERS: *Node, - Name to be made current + * Type, - Type of frame being pushed * * DESCRIPTION: Push the current scope on the scope stack, and make the - * passed nte current. + * passed Node current. * ***************************************************************************/ ACPI_STATUS acpi_ds_scope_stack_push ( - ACPI_NAME_TABLE *new_scope, + ACPI_NAMESPACE_NODE *node, OBJECT_TYPE_INTERNAL type, ACPI_WALK_STATE *walk_state) { ACPI_GENERIC_STATE *scope_info; - if (!new_scope) { + if (!node) { /* invalid scope */ REPORT_ERROR ("Ds_scope_stack_push: null scope passed"); @@ -109,7 +109,7 @@ /* Init new scope object */ - scope_info->scope.name_table = new_scope; + scope_info->scope.node = node; scope_info->common.value = (u16) type; /* Push new scope object onto stack */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/dispatcher/dswstate.c linux/drivers/acpi/dispatcher/dswstate.c --- v2.4.0-test8/linux/drivers/acpi/dispatcher/dswstate.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/dispatcher/dswstate.c Fri Sep 15 14:30:29 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: dswstate - Dispatcher parse tree walk management routines + * $Revision: 31 $ * *****************************************************************************/ @@ -25,13 +26,13 @@ #include "acpi.h" #include "amlcode.h" -#include "parser.h" -#include "dispatch.h" -#include "namesp.h" -#include "interp.h" +#include "acparser.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acinterp.h" #define _COMPONENT DISPATCHER - MODULE_NAME ("dswstate"); + MODULE_NAME ("dswstate") /******************************************************************************* @@ -55,7 +56,7 @@ walk_state->num_results = 0; walk_state->current_result = 0; - return AE_OK; + return (AE_OK); } @@ -80,13 +81,13 @@ if (walk_state->num_results >= OBJ_NUM_OPERANDS) { - return AE_STACK_OVERFLOW; + return (AE_STACK_OVERFLOW); } walk_state->results [walk_state->num_results] = object; walk_state->num_results++; - return AE_OK; + return (AE_OK); } @@ -106,7 +107,7 @@ ACPI_STATUS acpi_ds_result_stack_pop ( - ACPI_OBJECT_INTERNAL **object, + ACPI_OPERAND_OBJECT **object, ACPI_WALK_STATE *walk_state) { @@ -114,7 +115,7 @@ /* Check for stack underflow */ if (walk_state->num_results == 0) { - return AE_AML_NO_OPERAND; + return (AE_AML_NO_OPERAND); } @@ -125,13 +126,13 @@ /* Check for a valid result object */ if (!walk_state->results [walk_state->num_results]) { - return AE_AML_NO_OPERAND; + return (AE_AML_NO_OPERAND); } *object = walk_state->results [walk_state->num_results]; walk_state->results [walk_state->num_results] = NULL; - return AE_OK; + return (AE_OK); } @@ -191,7 +192,7 @@ /* Check for stack overflow */ if (walk_state->num_operands >= OBJ_NUM_OPERANDS) { - return AE_STACK_OVERFLOW; + return (AE_STACK_OVERFLOW); } /* Put the object onto the stack */ @@ -199,7 +200,7 @@ walk_state->operands [walk_state->num_operands] = object; walk_state->num_operands++; - return AE_OK; + return (AE_OK); } @@ -219,7 +220,7 @@ ACPI_STATUS acpi_ds_obj_stack_pop_object ( - ACPI_OBJECT_INTERNAL **object, + ACPI_OPERAND_OBJECT **object, ACPI_WALK_STATE *walk_state) { @@ -227,7 +228,7 @@ /* Check for stack underflow */ if (walk_state->num_operands == 0) { - return AE_AML_NO_OPERAND; + return (AE_AML_NO_OPERAND); } @@ -238,7 +239,7 @@ /* Check for a valid operand */ if (!walk_state->operands [walk_state->num_operands]) { - return AE_AML_NO_OPERAND; + return (AE_AML_NO_OPERAND); } /* Get operand and set stack entry to null */ @@ -246,7 +247,7 @@ *object = walk_state->operands [walk_state->num_operands]; walk_state->operands [walk_state->num_operands] = NULL; - return AE_OK; + return (AE_OK); } @@ -276,7 +277,7 @@ /* Check for stack underflow */ if (walk_state->num_operands == 0) { - return AE_STACK_UNDERFLOW; + return (AE_STACK_UNDERFLOW); } /* Just set the stack entry to null */ @@ -285,7 +286,7 @@ walk_state->operands [walk_state->num_operands] = NULL; } - return AE_OK; + return (AE_OK); } @@ -309,14 +310,14 @@ ACPI_WALK_STATE *walk_state) { u32 i; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; for (i = 0; i < pop_count; i++) { /* Check for stack underflow */ if (walk_state->num_operands == 0) { - return AE_STACK_UNDERFLOW; + return (AE_STACK_UNDERFLOW); } /* Pop the stack and delete an object if present in this stack entry */ @@ -329,7 +330,7 @@ } } - return AE_OK; + return (AE_OK); } @@ -393,10 +394,10 @@ { if (!walk_list) { - return NULL; + return (NULL); } - return walk_list->walk_state; + return (walk_list->walk_state); } @@ -483,8 +484,8 @@ ACPI_WALK_STATE * acpi_ds_create_walk_state ( ACPI_OWNER_ID owner_id, - ACPI_GENERIC_OP *origin, - ACPI_OBJECT_INTERNAL *mth_desc, + ACPI_PARSE_OBJECT *origin, + ACPI_OPERAND_OBJECT *mth_desc, ACPI_WALK_LIST *walk_list) { ACPI_WALK_STATE *walk_state; @@ -511,6 +512,7 @@ /* The cache is empty, create a new object */ /* Avoid deadlock with Acpi_cm_callocate */ + acpi_cm_release_mutex (ACPI_MTX_CACHES); walk_state = acpi_cm_callocate (sizeof (ACPI_WALK_STATE)); @@ -640,6 +642,7 @@ next = acpi_gbl_walk_state_cache->next; acpi_cm_free (acpi_gbl_walk_state_cache); acpi_gbl_walk_state_cache = next; + acpi_gbl_walk_state_cache_depth--; } return; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/driver.c linux/drivers/acpi/driver.c --- v2.4.0-test8/linux/drivers/acpi/driver.c Fri Jul 14 12:12:08 2000 +++ linux/drivers/acpi/driver.c Fri Sep 15 14:30:30 2000 @@ -32,6 +32,9 @@ #include "acpi.h" #include "driver.h" +#define _COMPONENT OS_DEPENDENT + MODULE_NAME ("driver") + struct acpi_run_entry { void (*callback)(void*); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/ec.c linux/drivers/acpi/ec.c --- v2.4.0-test8/linux/drivers/acpi/ec.c Fri Jul 14 12:12:08 2000 +++ linux/drivers/acpi/ec.c Fri Sep 15 14:30:30 2000 @@ -1,21 +1,21 @@ /* - * ec.c - Embedded controller support + * ec.c - Embedded controller support * - * Copyright (C) 2000 Andrew Henroid + * Copyright (C) 2000 Andrew Henroid * - * 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 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. + * 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 + * 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 */ #include @@ -28,28 +28,28 @@ #include "acpi.h" #include "driver.h" -enum -{ - ACPI_EC_HID = 0x090cd041, -}; +#define _COMPONENT OS_DEPENDENT + MODULE_NAME ("ec") + +#define ACPI_EC_HID "PNP0A09" enum { - ACPI_EC_SMI = 0x40, - ACPI_EC_SCI = 0x20, - ACPI_EC_BURST = 0x10, - ACPI_EC_CMD = 0x08, - ACPI_EC_IBF = 0x02, - ACPI_EC_OBF = 0x01 + ACPI_EC_SMI = 0x40, + ACPI_EC_SCI = 0x20, + ACPI_EC_BURST = 0x10, + ACPI_EC_CMD = 0x08, + ACPI_EC_IBF = 0x02, + ACPI_EC_OBF = 0x01 }; enum { - ACPI_EC_READ = 0x80, - ACPI_EC_WRITE = 0x81, - ACPI_EC_BURST_ENABLE = 0x82, - ACPI_EC_BURST_DISABLE = 0x83, - ACPI_EC_QUERY = 0x84, + ACPI_EC_READ = 0x80, + ACPI_EC_WRITE = 0x81, + ACPI_EC_BURST_ENABLE = 0x82, + ACPI_EC_BURST_DISABLE = 0x83, + ACPI_EC_QUERY = 0x84, }; @@ -74,9 +74,9 @@ static void acpi_ec_wait_control(void) { - udelay(1); - while(inb(acpi_ec_status) & ACPI_EC_IBF) - udelay(10); + udelay(1); + while(inb(acpi_ec_status) & ACPI_EC_IBF) + udelay(10); } /* @@ -88,12 +88,12 @@ if (!acpi_ec_data || !acpi_ec_status) return -1; - outb(ACPI_EC_READ, acpi_ec_status); - acpi_ec_wait_control(); - outb(addr, acpi_ec_data); - acpi_ec_wait_control(); - interruptible_sleep_on(&acpi_ec_wait); - *value = inb(acpi_ec_data); + outb(ACPI_EC_READ, acpi_ec_status); + acpi_ec_wait_control(); + outb(addr, acpi_ec_data); + acpi_ec_wait_control(); + interruptible_sleep_on(&acpi_ec_wait); + *value = inb(acpi_ec_data); return 0; } @@ -107,33 +107,32 @@ if (!acpi_ec_data || !acpi_ec_status) return -1; - outb(ACPI_EC_WRITE, acpi_ec_status); - acpi_ec_wait_control(); - outb(addr, acpi_ec_data); - acpi_ec_wait_control(); - outb(value, acpi_ec_data); - acpi_ec_wait_control(); - interruptible_sleep_on(&acpi_ec_wait); + outb(ACPI_EC_WRITE, acpi_ec_status); + acpi_ec_wait_control(); + outb(addr, acpi_ec_data); + acpi_ec_wait_control(); + outb(value, acpi_ec_data); + acpi_ec_wait_control(); + interruptible_sleep_on(&acpi_ec_wait); return 0; } /* - * Get processor information + * Get Embedded Controller information */ static ACPI_STATUS acpi_find_ec(ACPI_HANDLE handle, u32 level, void *ctx, void **value) { - ACPI_BUFFER buf; + ACPI_DEVICE_INFO dev_info; ACPI_OBJECT obj; + ACPI_BUFFER buf; RESOURCE *res; int gpe; - buf.length = sizeof(obj); - buf.pointer = &obj; - if (!ACPI_SUCCESS(acpi_evaluate_object(handle, "_HID", NULL, &buf)) - || obj.type != ACPI_TYPE_NUMBER - || obj.number.value != ACPI_EC_HID) + if (!ACPI_SUCCESS(acpi_get_object_info(handle, &dev_info)) + || !(dev_info.valid & ACPI_VALID_HID) + || 0 != STRCMP(dev_info.hardware_id, ACPI_EC_HID)) return AE_OK; buf.length = 0; @@ -160,20 +159,23 @@ buf.length = sizeof(obj); buf.pointer = &obj; if (!ACPI_SUCCESS(acpi_evaluate_object(handle, "_GPE", NULL, &buf)) - || obj.type != ACPI_TYPE_NUMBER) + || obj.type != ACPI_TYPE_NUMBER) return AE_OK; gpe = (int) obj.number.value; printk(KERN_INFO "ACPI: found EC @ (0x%02x,0x%02x,%d)\n", - acpi_ec_data, acpi_ec_status, gpe); + acpi_ec_data, acpi_ec_status, gpe); if (!ACPI_SUCCESS(acpi_install_gpe_handler( gpe, (ACPI_EVENT_LEVEL_TRIGGERED | ACPI_EVENT_EDGE_TRIGGERED), acpi_ec_gpe, - NULL))) + NULL))) { + + DEBUG_PRINT(ACPI_ERROR, ("Could not install GPE handler for EC.\n")); return AE_OK; + } return AE_OK; } @@ -182,10 +184,10 @@ acpi_ec_init(void) { acpi_walk_namespace(ACPI_TYPE_DEVICE, - ACPI_ROOT_OBJECT, - ACPI_INT32_MAX, - acpi_find_ec, - NULL, - NULL); + ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, + acpi_find_ec, + NULL, + NULL); return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/events/Makefile linux/drivers/acpi/events/Makefile --- v2.4.0-test8/linux/drivers/acpi/events/Makefile Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/events/Makefile Fri Sep 15 18:21:43 2000 @@ -0,0 +1,28 @@ +# +# Makefile for all Linux ACPI interpreter subdirectories +# + +SUB_DIRS := +MOD_SUB_DIRS := $(SUB_DIRS) +MOD_IN_SUB_DIRS := +ALL_SUB_DIRS := $(SUB_DIRS) + +O_TARGET := ../$(shell basename `pwd`).o +O_OBJS := +M_OBJS := + +ACPI_OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) + +EXTRA_CFLAGS += -I../include + +EXTRA_CFLAGS += $(ACPI_CFLAGS) + +# if the interpreter is used, it overrides arch/i386/kernel/acpi.c +ifeq ($(CONFIG_ACPI_INTERPRETER),y) + O_OBJS := $(ACPI_OBJS) +endif + +include $(TOPDIR)/Rules.make + +clean: + $(RM) *.o diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/events/evevent.c linux/drivers/acpi/events/evevent.c --- v2.4.0-test8/linux/drivers/acpi/events/evevent.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/events/evevent.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ * * Module Name: evevent - Fixed and General Purpose Acpi_event * handling and dispatch + * $Revision: 13 $ * *****************************************************************************/ @@ -24,13 +25,13 @@ */ #include "acpi.h" -#include "hardware.h" -#include "events.h" -#include "namesp.h" -#include "common.h" +#include "achware.h" +#include "acevents.h" +#include "acnamesp.h" +#include "accommon.h" #define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evevent"); + MODULE_NAME ("evevent") /****************************************************************************** @@ -68,7 +69,7 @@ acpi_hw_register_access (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_RTC + TMR_EN, 0); - return AE_OK; + return (AE_OK); } @@ -140,7 +141,7 @@ int_status |= acpi_ev_fixed_event_dispatch (ACPI_EVENT_SLEEP_BUTTON); } - return int_status; + return (int_status); } @@ -163,7 +164,7 @@ { /* Clear the status bit */ - acpi_hw_register_access (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, (s32)TMR_STS + + acpi_hw_register_access (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, TMR_STS + event, 1); /* @@ -175,13 +176,13 @@ TMR_EN + event, 0); REPORT_ERROR("No installed handler for fixed event."); - return INTERRUPT_NOT_HANDLED; + return (INTERRUPT_NOT_HANDLED); } /* Invoke the handler */ - return (acpi_gbl_fixed_event_handlers[event].handler)( - acpi_gbl_fixed_event_handlers[event].context); + return ((acpi_gbl_fixed_event_handlers[event].handler)( + acpi_gbl_fixed_event_handlers[event].context)); } @@ -216,6 +217,11 @@ gpe1_register_count = (u16) DIV_2 (acpi_gbl_FACP->gpe1_blk_len); acpi_gbl_gpe_register_count = gpe0register_count + gpe1_register_count; + if (!acpi_gbl_gpe_register_count) { + REPORT_WARNING ("No GPEs defined in the FACP"); + return (AE_OK); + } + /* * Allocate the Gpe information block */ @@ -341,17 +347,17 @@ void **return_value) { u32 gpe_number; - char name[ACPI_NAME_SIZE + 1]; + NATIVE_CHAR name[ACPI_NAME_SIZE + 1]; u8 type; /* Extract the name from the object and convert to a string */ - MOVE_UNALIGNED32_TO_32 (name, &((ACPI_NAMED_OBJECT*) obj_handle)->name); + MOVE_UNALIGNED32_TO_32 (name, &((ACPI_NAMESPACE_NODE *) obj_handle)->name); name[ACPI_NAME_SIZE] = 0; /* - * Edge/Level determination is based on the 2nd char of the method name + * Edge/Level determination is based on the 2nd s8 of the method name */ if (name[1] == 'L') { type = ACPI_EVENT_LEVEL_TRIGGERED; @@ -362,7 +368,7 @@ else { /* Unknown method type, just ignore it! */ - return AE_OK; + return (AE_OK); } /* Convert the last two characters of the name to the Gpe Number */ @@ -371,7 +377,7 @@ if (gpe_number == ACPI_UINT32_MAX) { /* Conversion failed; invalid method, just ignore it */ - return AE_OK; + return (AE_OK); } /* Ensure that we have a valid GPE number */ @@ -379,7 +385,7 @@ if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) { /* Not valid, all we can do here is ignore it */ - return AE_OK; + return (AE_OK); } /* @@ -397,7 +403,7 @@ acpi_hw_enable_gpe (gpe_number); - return AE_OK; + return (AE_OK); } @@ -431,7 +437,7 @@ /* Traverse the namespace under \_GPE to find all methods there */ status = acpi_walk_namespace (ACPI_TYPE_METHOD, acpi_gbl_gpe_obj_handle, - ACPI_INT32_MAX, acpi_ev_save_method_info, + ACPI_UINT32_MAX, acpi_ev_save_method_info, NULL, NULL); return (status); @@ -523,7 +529,7 @@ } } - return int_status; + return (int_status); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/events/evmisc.c linux/drivers/acpi/events/evmisc.c --- v2.4.0-test8/linux/drivers/acpi/events/evmisc.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/events/evmisc.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ * * Module Name: evmisc - ACPI device notification handler dispatch * and ACPI Global Lock support + * $Revision: 13 $ * *****************************************************************************/ @@ -24,13 +25,13 @@ */ #include "acpi.h" -#include "events.h" -#include "namesp.h" -#include "interp.h" -#include "hardware.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "achware.h" #define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evmisc"); + MODULE_NAME ("evmisc") /************************************************************************** @@ -51,8 +52,8 @@ ACPI_HANDLE device, u32 notify_value) { - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL *handler_obj; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_OPERAND_OBJECT *handler_obj; NOTIFY_HANDLER handler; @@ -108,7 +109,7 @@ /* - * Get the notify object which must be attached to the device NTE + * Get the notify object which must be attached to the device Node */ obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) device); @@ -211,7 +212,7 @@ context); } - return INTERRUPT_HANDLED; + return (INTERRUPT_HANDLED); } @@ -349,7 +350,7 @@ */ if (pending) { acpi_hw_register_access (ACPI_WRITE, ACPI_MTX_LOCK, - (s32)PM1_CONTROL | GBL_RLS, 1); + PM1_CONTROL | GBL_RLS, 1); } } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/events/evregion.c linux/drivers/acpi/events/evregion.c --- v2.4.0-test8/linux/drivers/acpi/events/evregion.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/events/evregion.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: evregion - ACPI Address_space / Op_region handler dispatch + * $Revision: 76 $ * *****************************************************************************/ @@ -24,13 +25,13 @@ #include "acpi.h" -#include "events.h" -#include "namesp.h" -#include "interp.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" #include "amlcode.h" #define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evregion"); + MODULE_NAME ("evregion") #define PCI_ROOT_HID_STRING "PNP0A03" @@ -56,23 +57,23 @@ void *context, void **return_value) { - ACPI_NAMED_OBJECT *entry; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_NAMESPACE_NODE *node; + ACPI_OPERAND_OBJECT *obj_desc; ACPI_STATUS status; - entry = (ACPI_NAMED_OBJECT*) obj_handle; - obj_desc = ((ACPI_NAMED_OBJECT*)obj_handle)->object; + node = (ACPI_NAMESPACE_NODE *) obj_handle; + obj_desc = ((ACPI_NAMESPACE_NODE *) obj_handle)->object; /* * We are looking for all valid _HID objects. */ - if (STRNCMP ((char *)&entry->name, METHOD_NAME__HID, ACPI_NAME_SIZE) || + if (STRNCMP ((NATIVE_CHAR *) &node->name, METHOD_NAME__HID, ACPI_NAME_SIZE) || (!obj_desc)) { - return AE_OK; + return (AE_OK); } @@ -87,7 +88,7 @@ case ACPI_TYPE_NUMBER: if (obj_desc->number.value != PCI_ROOT_HID_VALUE) { - return AE_OK; + return (AE_OK); } break; @@ -97,14 +98,14 @@ if (STRNCMP (obj_desc->string.pointer, PCI_ROOT_HID_STRING, sizeof (PCI_ROOT_HID_STRING))) { - return AE_OK; + return (AE_OK); } break; default: - return AE_OK; + return (AE_OK); } @@ -114,11 +115,11 @@ * handler for this PCI device. */ - status = acpi_install_address_space_handler (acpi_ns_get_parent_entry (entry), + status = acpi_install_address_space_handler (acpi_ns_get_parent_object (node), ADDRESS_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL); - return AE_OK; + return (AE_OK); } @@ -142,7 +143,90 @@ acpi_ns_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, FALSE, acpi_ev_find_one_pci_root_bus, NULL, NULL); - return AE_OK; + return (AE_OK); +} + +/****************************************************************************** + * + * FUNCTION: Acpi_ev_init_one_device + * + * PARAMETERS: The usual "I'm a namespace callback" stuff + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: This is called once per device soon after ACPI is enabled + * to initialize each device. It determines if the device is + * present, and if so, calls _INI. + * + *****************************************************************************/ + +ACPI_STATUS +acpi_ev_init_one_device ( + ACPI_HANDLE obj_handle, + u32 nesting_level, + void *context, + void **return_value) +{ + ACPI_STATUS status; + ACPI_OPERAND_OBJECT *ret_obj; + + + /* + * Run _STA to determine if we can run _INI on the device. + */ + status = acpi_ns_evaluate_relative(obj_handle, "_STA", NULL, &ret_obj); + if (AE_NOT_FOUND == status) { + /* No _STA means device is present */ + } + else if (ACPI_FAILURE (status)) { + return (status); + } + else if (ret_obj) { + if (ACPI_TYPE_NUMBER != ret_obj->common.type) { + status = AE_AML_OPERAND_TYPE; + goto cleanup; + } + + /* + * if _STA "present" bit not set, we're done. + */ + if (!(ret_obj->number.value & 1)) { + goto cleanup; + } + } + + /* + * The device is present. Run _INI. + */ + + status = acpi_ns_evaluate_relative(obj_handle, "_INI", NULL, NULL); + +cleanup: + + acpi_cm_remove_reference (ret_obj); + return (status); +} + +/****************************************************************************** + * + * FUNCTION: Acpi_ev_init_devices + * + * PARAMETERS: None + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: This initializes all ACPI devices. + * + *****************************************************************************/ + +ACPI_STATUS +acpi_ev_init_devices ( + void) +{ + acpi_ns_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + FALSE, acpi_ev_init_one_device, NULL, NULL); + + return (AE_OK); } @@ -172,28 +256,20 @@ * associated with the address space. For these we use the root. */ - status = acpi_install_address_space_handler (acpi_gbl_root_object, + status = acpi_install_address_space_handler (acpi_gbl_root_node, ADDRESS_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL); if (ACPI_FAILURE (status)) { return (status); } - status = acpi_install_address_space_handler (acpi_gbl_root_object, + status = acpi_install_address_space_handler (acpi_gbl_root_node, ADDRESS_SPACE_SYSTEM_IO, ACPI_DEFAULT_HANDLER, NULL, NULL); if (ACPI_FAILURE (status)) { return (status); } - /* - * Install PCI config space handler for all PCI root bridges. A PCI root - * bridge is found by searching for devices containing a HID with the value - * EISAID("PNP0A03") - */ - - acpi_ev_find_pci_root_buses (); - return (AE_OK); } @@ -216,12 +292,12 @@ ACPI_STATUS acpi_ev_execute_reg_method ( - ACPI_OBJECT_INTERNAL *region_obj, + ACPI_OPERAND_OBJECT *region_obj, u32 function) { - ACPI_OBJECT_INTERNAL *params[3]; - ACPI_OBJECT_INTERNAL space_iD_obj; - ACPI_OBJECT_INTERNAL function_obj; + ACPI_OPERAND_OBJECT *params[3]; + ACPI_OPERAND_OBJECT space_iD_obj; + ACPI_OPERAND_OBJECT function_obj; ACPI_STATUS status; @@ -286,7 +362,7 @@ ACPI_STATUS acpi_ev_address_space_dispatch ( - ACPI_OBJECT_INTERNAL *region_obj, + ACPI_OPERAND_OBJECT *region_obj, u32 function, u32 address, u32 bit_width, @@ -295,8 +371,8 @@ ACPI_STATUS status; ADDRESS_SPACE_HANDLER handler; ADDRESS_SPACE_SETUP region_setup; - ACPI_OBJECT_INTERNAL *handler_desc; - void *region_context; + ACPI_OPERAND_OBJECT *handler_desc; + void *region_context = NULL; /* @@ -312,7 +388,7 @@ * It may be the case that the region has never been initialized * Some types of regions require special init code */ - if (!(region_obj->region.region_flags & REGION_INITIALIZED)) { + if (!(region_obj->region.flags & AOPOBJ_INITIALIZED)) { /* * This region has not been initialized yet, do it */ @@ -346,9 +422,10 @@ } /* - * Save the returned context for use in all accesses to the region + * Save the returned context for use in all accesses to + * this particular region. */ - handler_desc->addr_handler.context = region_context; + region_obj->region.region_context = region_context; } /* @@ -369,7 +446,8 @@ * Invoke the handler. */ status = handler (function, address, bit_width, value, - handler_desc->addr_handler.context); + handler_desc->addr_handler.context, + region_obj->region.region_context); if (!(handler_desc->addr_handler.flags & ADDR_HANDLER_DEFAULT_INSTALLED)) { @@ -398,13 +476,13 @@ void acpi_ev_disassociate_region_from_handler( - ACPI_OBJECT_INTERNAL *region_obj) + ACPI_OPERAND_OBJECT *region_obj) { - ACPI_OBJECT_INTERNAL *handler_obj; - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL **last_obj_ptr; + ACPI_OPERAND_OBJECT *handler_obj; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_OPERAND_OBJECT **last_obj_ptr; ADDRESS_SPACE_SETUP region_setup; - void *region_context; + void *region_context = region_obj->region.region_context; ACPI_STATUS status; @@ -436,7 +514,8 @@ /* * This is it, remove it from the handler's list */ - *last_obj_ptr = obj_desc->region.link; + *last_obj_ptr = obj_desc->region.next; + obj_desc->region.next = NULL; /* Must clear field */ /* * Now stop region accesses by executing the _REG method @@ -452,12 +531,6 @@ ®ion_context); /* - * Save the returned context (It is the original context - * passed into Install) - */ - handler_obj->addr_handler.context = region_context; - - /* * Init routine may fail, Just ignore errors */ @@ -482,8 +555,8 @@ /* * Move through the linked list of handlers */ - last_obj_ptr = &obj_desc->region.link; - obj_desc = obj_desc->region.link; + last_obj_ptr = &obj_desc->region.next; + obj_desc = obj_desc->region.next; } /* @@ -508,9 +581,10 @@ ******************************************************************************/ ACPI_STATUS -acpi_ev_associate_region_and_handler( - ACPI_OBJECT_INTERNAL *handler_obj, - ACPI_OBJECT_INTERNAL *region_obj) +acpi_ev_associate_region_and_handler ( + ACPI_OPERAND_OBJECT *handler_obj, + ACPI_OPERAND_OBJECT *region_obj, + u8 acpi_ns_is_locked) { ACPI_STATUS status; @@ -522,7 +596,7 @@ * Link this region to the front of the handler's list */ - region_obj->region.link = handler_obj->addr_handler.region_list; + region_obj->region.next = handler_obj->addr_handler.region_list; handler_obj->addr_handler.region_list = region_obj; /* @@ -539,9 +613,15 @@ /* * Last thing, tell all users that this region is usable */ - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); + if (acpi_ns_is_locked) { + acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); + } + status = acpi_ev_execute_reg_method (region_obj, 1); - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); + + if (acpi_ns_is_locked) { + acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); + } return (status); } @@ -551,7 +631,7 @@ * * FUNCTION: Acpi_ev_addr_handler_helper * - * PARAMETERS: Handle - Entry to be dumped + * PARAMETERS: Handle - Node to be dumped * Level - Nesting level of the handle * Context - Passed into Acpi_ns_walk_namespace * @@ -573,14 +653,14 @@ void *context, void **return_value) { - ACPI_OBJECT_INTERNAL *handler_obj; - ACPI_OBJECT_INTERNAL *tmp_obj; - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_NAMED_OBJECT *obj_entry; + ACPI_OPERAND_OBJECT *handler_obj; + ACPI_OPERAND_OBJECT *tmp_obj; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_NAMESPACE_NODE *node; ACPI_STATUS status; - handler_obj = (ACPI_OBJECT_INTERNAL *) context; + handler_obj = (ACPI_OPERAND_OBJECT *) context; /* Parameter validation */ @@ -590,8 +670,8 @@ /* Convert and validate the device handle */ - obj_entry = acpi_ns_convert_handle_to_entry (obj_handle); - if (!obj_entry) { + node = acpi_ns_convert_handle_to_entry (obj_handle); + if (!node) { return (AE_BAD_PARAMETER); } @@ -600,16 +680,16 @@ * that can have address handlers */ - if ((obj_entry->type != ACPI_TYPE_DEVICE) && - (obj_entry->type != ACPI_TYPE_REGION) && - (obj_entry != acpi_gbl_root_object)) + if ((node->type != ACPI_TYPE_DEVICE) && + (node->type != ACPI_TYPE_REGION) && + (node != acpi_gbl_root_node)) { return (AE_OK); } /* Check for an existing internal object */ - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) obj_entry); + obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) node); if (!obj_desc) { /* * The object DNE, we don't care about it @@ -647,7 +727,7 @@ /* * Move through the linked list of handlers */ - tmp_obj = tmp_obj->addr_handler.link; + tmp_obj = tmp_obj->addr_handler.next; } /* @@ -682,7 +762,7 @@ /* * Then connect the region to the new handler */ - status = acpi_ev_associate_region_and_handler (handler_obj, obj_desc); + status = acpi_ev_associate_region_and_handler (handler_obj, obj_desc, FALSE); return (status); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/events/evrgnini.c linux/drivers/acpi/events/evrgnini.c --- v2.4.0-test8/linux/drivers/acpi/events/evrgnini.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/events/evrgnini.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: evrgnini- ACPI Address_space / Op_region init + * $Revision: 22 $ * *****************************************************************************/ @@ -24,13 +25,13 @@ #include "acpi.h" -#include "events.h" -#include "namesp.h" -#include "interp.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" #include "amlcode.h" #define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evrgnini"); + MODULE_NAME ("evrgnini") /***************************************************************************** @@ -40,8 +41,8 @@ * PARAMETERS: Region_obj - region we are interested in * Function - start or stop * Handler_context - Address space handler context - * Returned context - context to be used with each call to the - * handler for this region + * Region_context - Region specific context + * * RETURN: Status * * DESCRIPTION: Do any prep work for region handling, a nop for now @@ -53,21 +54,17 @@ ACPI_HANDLE handle, u32 function, void *handler_context, - void **return_context) + void **region_context) { - MEM_HANDLER_CONTEXT *mem_context; - ACPI_OBJECT_INTERNAL *region_obj = (ACPI_OBJECT_INTERNAL *) handle; + ACPI_OPERAND_OBJECT *region_obj = (ACPI_OPERAND_OBJECT *) handle; if (function == ACPI_REGION_DEACTIVATE) { - region_obj->region.region_flags &= ~(REGION_INITIALIZED); - - *return_context = NULL; - if (handler_context) { - mem_context = handler_context; - *return_context = mem_context->handler_context; + region_obj->region.flags &= ~(AOPOBJ_INITIALIZED); - acpi_cm_free (mem_context); + if (*region_context) { + acpi_cm_free (*region_context); + *region_context = NULL; } return (AE_OK); } @@ -75,17 +72,15 @@ /* Activate. Create a new context */ - mem_context = acpi_cm_callocate (sizeof (MEM_HANDLER_CONTEXT)); - if (!mem_context) { + *region_context = acpi_cm_callocate (sizeof (MEM_HANDLER_CONTEXT)); + if (!(*region_context)) { return (AE_NO_MEMORY); } /* Init. (Mapping fields are all set to zeros above) */ - mem_context->handler_context = handler_context; - region_obj->region.region_flags |= REGION_INITIALIZED; + region_obj->region.flags |= AOPOBJ_INITIALIZED; - *return_context = mem_context; return (AE_OK); } @@ -97,8 +92,8 @@ * PARAMETERS: Region_obj - region we are interested in * Function - start or stop * Handler_context - Address space handler context - * Returned context - context to be used with each call to the - * handler for this region + * Region_context - Region specific context + * * RETURN: Status * * DESCRIPTION: Do any prep work for region handling @@ -110,21 +105,18 @@ ACPI_HANDLE handle, u32 function, void *handler_context, - void **return_context) + void **region_context) { - ACPI_OBJECT_INTERNAL *region_obj = (ACPI_OBJECT_INTERNAL *) handle; - + ACPI_OPERAND_OBJECT *region_obj = (ACPI_OPERAND_OBJECT *) handle; if (function == ACPI_REGION_DEACTIVATE) { - region_obj->region.region_flags &= ~(REGION_INITIALIZED); - *return_context = handler_context; - return (AE_OK); + *region_context = NULL; + region_obj->region.flags &= ~(AOPOBJ_INITIALIZED); + } + else { + *region_context = handler_context; + region_obj->region.flags |= AOPOBJ_INITIALIZED; } - - /* Activate the region */ - - region_obj->region.region_flags |= REGION_INITIALIZED; - *return_context = handler_context; return (AE_OK); } @@ -137,8 +129,8 @@ * PARAMETERS: Region_obj - region we are interested in * Function - start or stop * Handler_context - Address space handler context - * Returned context - context to be used with each call to the - * handler for this region + * Region_context - Region specific context + * * RETURN: Status * * DESCRIPTION: Do any prep work for region handling @@ -152,14 +144,14 @@ ACPI_HANDLE handle, u32 function, void *handler_context, - void **return_context) + void **region_context) { ACPI_STATUS status = AE_OK; u32 temp; - PCI_HANDLER_CONTEXT *pci_context; - ACPI_OBJECT_INTERNAL *handler_obj; - ACPI_NAMED_OBJECT *search_scope; - ACPI_OBJECT_INTERNAL *region_obj = (ACPI_OBJECT_INTERNAL *) handle; + PCI_HANDLER_CONTEXT *pci_context = *region_context; + ACPI_OPERAND_OBJECT *handler_obj; + ACPI_NAMESPACE_NODE *node; + ACPI_OPERAND_OBJECT *region_obj = (ACPI_OPERAND_OBJECT *) handle; handler_obj = region_obj->region.addr_handler; @@ -173,14 +165,11 @@ } if (function == ACPI_REGION_DEACTIVATE) { - region_obj->region.region_flags &= ~(REGION_INITIALIZED); - - *return_context = NULL; - if (handler_context) { - pci_context = handler_context; - *return_context = pci_context->handler_context; + region_obj->region.flags &= ~(AOPOBJ_INITIALIZED); + if (pci_context) { acpi_cm_free (pci_context); + *region_context = NULL; } return (status); @@ -189,7 +178,7 @@ /* Create a new context */ - pci_context = acpi_cm_allocate (sizeof(PCI_HANDLER_CONTEXT)); + pci_context = acpi_cm_callocate (sizeof(PCI_HANDLER_CONTEXT)); if (!pci_context) { return (AE_NO_MEMORY); } @@ -203,16 +192,16 @@ * First get device and function numbers from the _ADR object * in the parent's scope. */ - ACPI_ASSERT(region_obj->region.nte); + ACPI_ASSERT(region_obj->region.node); - search_scope = acpi_ns_get_parent_entry (region_obj->region.nte); + node = acpi_ns_get_parent_object (region_obj->region.node); acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); /* Acpi_evaluate the _ADR object */ - status = acpi_cm_evaluate_numeric_object (METHOD_NAME__ADR, search_scope, &temp); + status = acpi_cm_evaluate_numeric_object (METHOD_NAME__ADR, node, &temp); /* * The default is zero, since the allocation above zeroed the data, just * do nothing on failures. @@ -232,9 +221,9 @@ * This is the device the handler has been registered to handle. */ - search_scope = handler_obj->addr_handler.nte; + node = handler_obj->addr_handler.node; - status = acpi_cm_evaluate_numeric_object (METHOD_NAME__SEG, search_scope, &temp); + status = acpi_cm_evaluate_numeric_object (METHOD_NAME__SEG, node, &temp); if (ACPI_SUCCESS (status)) { /* * Got it.. @@ -242,7 +231,7 @@ pci_context->seg = temp; } - status = acpi_cm_evaluate_numeric_object (METHOD_NAME__BBN, search_scope, &temp); + status = acpi_cm_evaluate_numeric_object (METHOD_NAME__BBN, node, &temp); if (ACPI_SUCCESS (status)) { /* * Got it.. @@ -250,11 +239,12 @@ pci_context->bus = temp; } + *region_context = pci_context; + acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - *return_context = pci_context; + region_obj->region.flags |= AOPOBJ_INITIALIZED; - region_obj->region.region_flags |= REGION_INITIALIZED; return (AE_OK); } @@ -266,8 +256,8 @@ * PARAMETERS: Region_obj - region we are interested in * Function - start or stop * Handler_context - Address space handler context - * Returned context - context to be used with each call to the - * handler for this region + * Region_context - Region specific context + * * RETURN: Status * * DESCRIPTION: Do any prep work for region handling @@ -279,18 +269,18 @@ ACPI_HANDLE handle, u32 function, void *handler_context, - void **return_context) + void **region_context) { - ACPI_OBJECT_INTERNAL *region_obj = (ACPI_OBJECT_INTERNAL *) handle; + ACPI_OPERAND_OBJECT *region_obj = (ACPI_OPERAND_OBJECT *) handle; if (function == ACPI_REGION_DEACTIVATE) { - region_obj->region.region_flags &= ~(REGION_INITIALIZED); - *return_context = NULL; + *region_context = NULL; + region_obj->region.flags &= ~(AOPOBJ_INITIALIZED); } else { - region_obj->region.region_flags |= REGION_INITIALIZED; - *return_context = handler_context; + *region_context = handler_context; + region_obj->region.flags |= AOPOBJ_INITIALIZED; } return (AE_OK); @@ -320,15 +310,15 @@ ACPI_STATUS acpi_ev_initialize_region ( - ACPI_OBJECT_INTERNAL *region_obj, + ACPI_OPERAND_OBJECT *region_obj, u8 acpi_ns_locked) { - ACPI_OBJECT_INTERNAL *handler_obj; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *handler_obj; + ACPI_OPERAND_OBJECT *obj_desc; u32 space_id; - ACPI_NAMED_OBJECT *entry; /* Namespace Object */ + ACPI_NAMESPACE_NODE *node; ACPI_STATUS status; - ACPI_NAMED_OBJECT *reg_entry; + ACPI_NAMESPACE_NODE *method_node; ACPI_NAME *reg_name_ptr = (ACPI_NAME *) METHOD_NAME__REG; @@ -336,44 +326,44 @@ return (AE_BAD_PARAMETER); } - ACPI_ASSERT(region_obj->region.nte); + ACPI_ASSERT(region_obj->region.node); - entry = acpi_ns_get_parent_entry (region_obj->region.nte); + node = acpi_ns_get_parent_object (region_obj->region.node); space_id = region_obj->region.space_id; region_obj->region.addr_handler = NULL; region_obj->region.REGmethod = NULL; - region_obj->region.region_flags = INITIAL_REGION_FLAGS; + region_obj->region.flags &= ~(AOPOBJ_INITIALIZED); /* * Find any "_REG" associated with this region definition */ - status = acpi_ns_search_one_scope (*reg_name_ptr, entry->child_table, - ACPI_TYPE_METHOD, ®_entry, NULL); - if (status == AE_OK) { + status = acpi_ns_search_node (*reg_name_ptr, node, + ACPI_TYPE_METHOD, &method_node); + if (ACPI_SUCCESS (status)) { /* * The _REG method is optional and there can be only one per region * definition. This will be executed when the handler is attached * or removed */ - region_obj->region.REGmethod = reg_entry; + region_obj->region.REGmethod = method_node; } /* - * The following loop depends upon the root nte having no parent - * ie: Acpi_gbl_Root_object->Parent_entry being set to NULL + * The following loop depends upon the root Node having no parent + * ie: Acpi_gbl_Root_node->Parent_entry being set to NULL */ - while (entry) { + while (node) { /* * Check to see if a handler exists */ handler_obj = NULL; - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) entry); + obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) node); if (obj_desc) { /* * can only be a handler if the object exists */ - switch (entry->type) + switch (node->type) { case ACPI_TYPE_DEVICE: @@ -400,11 +390,11 @@ /* * Found it! Now update the region and the handler */ - acpi_ev_associate_region_and_handler(handler_obj, region_obj); + acpi_ev_associate_region_and_handler (handler_obj, region_obj, acpi_ns_locked); return (AE_OK); } - handler_obj = handler_obj->addr_handler.link; + handler_obj = handler_obj->addr_handler.next; } /* while handlerobj */ } @@ -413,9 +403,9 @@ * This one does not have the handler we need * Pop up one level */ - entry = acpi_ns_get_parent_entry (entry); + node = acpi_ns_get_parent_object (node); - } /* while Entry != ROOT */ + } /* while Node != ROOT */ /* * If we get here, there is no handler for this region diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/events/evsci.c linux/drivers/acpi/events/evsci.c --- v2.4.0-test8/linux/drivers/acpi/events/evsci.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/events/evsci.c Fri Sep 15 14:30:30 2000 @@ -1,9 +1,10 @@ -/****************************************************************************** +/******************************************************************************* * * Module Name: evsci - System Control Interrupt configuration and * legacy to ACPI mode state transition functions + * $Revision: 59 $ * - *****************************************************************************/ + ******************************************************************************/ /* * Copyright (C) 2000 R. Byron Moore @@ -24,27 +25,26 @@ */ #include "acpi.h" -#include "namesp.h" -#include "hardware.h" -#include "events.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" #define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evsci"); + MODULE_NAME ("evsci") /* - * Elements correspond to counts for - * TMR, NOT_USED, GBL, PWR_BTN, SLP_BTN, RTC, - * and GENERAL respectively. These counts - * are modified by the ACPI interrupt handler... - * Note that GENERAL should probably be split out - * into one element for each bit in the GPE - * registers + * Elements correspond to counts for TMR, NOT_USED, GBL, PWR_BTN, SLP_BTN, RTC, + * and GENERAL respectively. These counts are modified by the ACPI interrupt + * handler. + * + * TBD: [Investigate] Note that GENERAL should probably be split out into + * one element for each bit in the GPE registers */ -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ev_sci_handler * @@ -61,16 +61,16 @@ u32 acpi_ev_sci_handler (void *context) { - u32 interrupt_handled = INTERRUPT_NOT_HANDLED; + u32 interrupt_handled = INTERRUPT_NOT_HANDLED; + /* - * ACPI Enabled? - * ------------- * Make sure that ACPI is enabled by checking SCI_EN. Note that we are * required to treat the SCI interrupt as sharable, level, active low. */ - if (!acpi_hw_register_access (ACPI_READ, ACPI_MTX_DO_NOT_LOCK, (s32)SCI_EN)) { - REPORT_ERROR ("Received and SCI but ACPI is not enabled."); + if (!acpi_hw_register_access (ACPI_READ, ACPI_MTX_DO_NOT_LOCK, SCI_EN)) { + /* ACPI is not enabled; this interrupt cannot be for us */ + return (INTERRUPT_NOT_HANDLED); } @@ -107,12 +107,12 @@ u32 acpi_ev_install_sci_handler (void) { - u32 except = AE_OK; + u32 except = AE_OK; + - except = acpi_os_install_interrupt_handler ( - (u32) acpi_gbl_FACP->sci_int, - acpi_ev_sci_handler, - NULL); + except = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FACP->sci_int, + acpi_ev_sci_handler, + NULL); return (except); } @@ -163,24 +163,21 @@ #endif - acpi_os_remove_interrupt_handler ( - (u32) acpi_gbl_FACP->sci_int, - acpi_ev_sci_handler); + acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FACP->sci_int, + acpi_ev_sci_handler); return (AE_OK); } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ev_sci_count * - * PARAMETERS: char * Event_name name (fully qualified name from namespace - * or one of the fixed event names defined above) - * of the event to check if it's generated an SCI. + * PARAMETERS: Event Event that generated an SCI. * - * RETURN: Number of SCI's for requested event since last time i_sci_occured() - * was called for this event. + * RETURN: Number of SCI's for requested event since last time + * Sci_occured() was called for this event. * * DESCRIPTION: Checks to see if SCI has been generated from requested source * since the last time this function was called. @@ -188,7 +185,7 @@ ******************************************************************************/ -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ev_restore_acpi_state * @@ -203,7 +200,7 @@ void acpi_ev_restore_acpi_state (void) { - s32 index; + u32 index; /* Restore the state of the chipset enable bits. */ @@ -283,6 +280,7 @@ void acpi_ev_terminate (void) { + /* * Free global tables, etc. diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/events/evxface.c linux/drivers/acpi/events/evxface.c --- v2.4.0-test8/linux/drivers/acpi/events/evxface.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/events/evxface.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: evxface - External interfaces for ACPI events + * $Revision: 88 $ * *****************************************************************************/ @@ -24,14 +25,14 @@ #include "acpi.h" -#include "hardware.h" -#include "namesp.h" -#include "events.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" #include "amlcode.h" -#include "interp.h" +#include "acinterp.h" #define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evxface"); + MODULE_NAME ("evxface") /****************************************************************************** @@ -172,9 +173,9 @@ NOTIFY_HANDLER handler, void *context) { - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL *notify_obj; - ACPI_NAMED_OBJECT *obj_entry; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_OPERAND_OBJECT *notify_obj; + ACPI_NAMESPACE_NODE *device_node; ACPI_STATUS status = AE_OK; @@ -190,8 +191,8 @@ acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - obj_entry = acpi_ns_convert_handle_to_entry (device); - if (!obj_entry) { + device_node = acpi_ns_convert_handle_to_entry (device); + if (!device_node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } @@ -217,13 +218,13 @@ } if (handler_type == ACPI_SYSTEM_NOTIFY) { - acpi_gbl_sys_notify.nte = obj_entry; + acpi_gbl_sys_notify.node = device_node; acpi_gbl_sys_notify.handler = handler; acpi_gbl_sys_notify.context = context; } else { - acpi_gbl_drv_notify.nte = obj_entry; + acpi_gbl_drv_notify.node = device_node; acpi_gbl_drv_notify.handler = handler; acpi_gbl_drv_notify.context = context; } @@ -239,10 +240,10 @@ * These are the ONLY objects that can receive ACPI notifications */ - if ((obj_entry->type != ACPI_TYPE_DEVICE) && - (obj_entry->type != ACPI_TYPE_PROCESSOR) && - (obj_entry->type != ACPI_TYPE_POWER) && - (obj_entry->type != ACPI_TYPE_THERMAL)) + if ((device_node->type != ACPI_TYPE_DEVICE) && + (device_node->type != ACPI_TYPE_PROCESSOR) && + (device_node->type != ACPI_TYPE_POWER) && + (device_node->type != ACPI_TYPE_THERMAL)) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -250,7 +251,7 @@ /* Check for an existing internal object */ - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) obj_entry); + obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) device_node); if (obj_desc) { /* * The object exists. @@ -270,15 +271,15 @@ else { /* Create a new object */ - obj_desc = acpi_cm_create_internal_object (obj_entry->type); + obj_desc = acpi_cm_create_internal_object (device_node->type); if (!obj_desc) { status = AE_NO_MEMORY; goto unlock_and_exit; } - /* Attach new object to the NTE */ + /* Attach new object to the Node */ - status = acpi_ns_attach_object (device, obj_desc, (u8) obj_entry->type); + status = acpi_ns_attach_object (device, obj_desc, (u8) device_node->type); if (ACPI_FAILURE (status)) { goto unlock_and_exit; @@ -296,7 +297,7 @@ goto unlock_and_exit; } - notify_obj->notify_handler.nte = obj_entry; + notify_obj->notify_handler.node = device_node; notify_obj->notify_handler.handler = handler; notify_obj->notify_handler.context = context; @@ -337,9 +338,9 @@ u32 handler_type, NOTIFY_HANDLER handler) { - ACPI_OBJECT_INTERNAL *notify_obj; - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_NAMED_OBJECT *obj_entry; + ACPI_OPERAND_OBJECT *notify_obj; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_NAMESPACE_NODE *device_node; ACPI_STATUS status = AE_OK; @@ -355,8 +356,8 @@ /* Convert and validate the device handle */ - obj_entry = acpi_ns_convert_handle_to_entry (device); - if (!obj_entry) { + device_node = acpi_ns_convert_handle_to_entry (device); + if (!device_node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } @@ -365,10 +366,10 @@ * These are the ONLY objects that can receive ACPI notifications */ - if ((obj_entry->type != ACPI_TYPE_DEVICE) && - (obj_entry->type != ACPI_TYPE_PROCESSOR) && - (obj_entry->type != ACPI_TYPE_POWER) && - (obj_entry->type != ACPI_TYPE_THERMAL)) + if ((device_node->type != ACPI_TYPE_DEVICE) && + (device_node->type != ACPI_TYPE_PROCESSOR) && + (device_node->type != ACPI_TYPE_POWER) && + (device_node->type != ACPI_TYPE_THERMAL)) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -376,7 +377,7 @@ /* Check for an existing internal object */ - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) obj_entry); + obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) device_node); if (!obj_desc) { status = AE_NOT_EXIST; goto unlock_and_exit; @@ -573,7 +574,7 @@ acpi_aml_exit_interpreter (); *out_handle = 0; - return status; + return (status); } @@ -598,7 +599,7 @@ /* TBD: [Restructure] Validate handle */ acpi_ev_release_global_lock (); - return AE_OK; + return (AE_OK); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/events/evxfevnt.c linux/drivers/acpi/events/evxfevnt.c --- v2.4.0-test8/linux/drivers/acpi/events/evxfevnt.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/events/evxfevnt.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable + * $Revision: 19 $ * *****************************************************************************/ @@ -24,16 +25,24 @@ #include "acpi.h" -#include "hardware.h" -#include "namesp.h" -#include "events.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" #include "amlcode.h" -#include "interp.h" +#include "acinterp.h" #define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evxfevnt"); + MODULE_NAME ("evxfevnt") +ACPI_STATUS +acpi_ev_find_pci_root_buses ( + void); + +ACPI_STATUS +acpi_ev_init_devices ( + void); + /************************************************************************** * * FUNCTION: Acpi_enable @@ -60,12 +69,27 @@ return (AE_NO_ACPI_TABLES); } + /* Init the hardware */ + + /* + * With the advent of a 3-pass parser, we need to be + * prepared to execute on initialized HW before the + * namespace has completed its load. + */ + + status = acpi_cm_hardware_initialize (); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Make sure the BIOS supports ACPI mode */ if (SYS_MODE_LEGACY == acpi_hw_get_mode_capabilities()) { return (AE_ERROR); } + acpi_gbl_original_mode = acpi_hw_get_mode(); /* @@ -74,24 +98,28 @@ * before handers are installed. */ - if (ACPI_FAILURE (acpi_ev_fixed_event_initialize ())) { - return (AE_ERROR); + status = acpi_ev_fixed_event_initialize (); + if (ACPI_FAILURE (status)) { + return (status); } - if (ACPI_FAILURE (acpi_ev_gpe_initialize())) { - return (AE_ERROR); + status = acpi_ev_gpe_initialize (); + if (ACPI_FAILURE (status)) { + return (status); } /* Install the SCI handler */ - if (ACPI_FAILURE (acpi_ev_install_sci_handler ())) { - return (AE_ERROR); + status = acpi_ev_install_sci_handler (); + if (ACPI_FAILURE (status)) { + return (status); } /* Transition to ACPI mode */ - if (AE_OK != acpi_hw_set_mode (SYS_MODE_ACPI)) { - return (AE_ERROR); + status = acpi_hw_set_mode (SYS_MODE_ACPI); + if (ACPI_FAILURE (status)) { + return (status); } /* Install handlers for control method GPE handlers (_Lxx, _Exx) */ @@ -100,6 +128,26 @@ status = acpi_ev_init_global_lock_handler (); + /* + * Perform additional initialization that may cause control methods + * to be executed + * + * It may be wise to move this code to a new interface + */ + + + /* + * Install PCI config space handler for all PCI root bridges. A PCI root + * bridge is found by searching for devices containing a HID with the value + * EISAID("PNP0A03") + */ + + acpi_ev_find_pci_root_buses (); + + /* Call _INI on all devices */ + + acpi_ev_init_devices (); + return (status); } @@ -120,12 +168,14 @@ ACPI_STATUS acpi_disable (void) { + ACPI_STATUS status; /* Restore original mode */ - if (AE_OK != acpi_hw_set_mode (acpi_gbl_original_mode)) { - return (AE_ERROR); + status = acpi_hw_set_mode (acpi_gbl_original_mode); + if (ACPI_FAILURE (status)) { + return (status); } /* Unload the SCI interrupt handler */ @@ -133,7 +183,7 @@ acpi_ev_remove_sci_handler (); acpi_ev_restore_acpi_state (); - return (AE_OK); + return (status); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/events/evxfregn.c linux/drivers/acpi/events/evxfregn.c --- v2.4.0-test8/linux/drivers/acpi/events/evxfregn.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/events/evxfregn.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ * * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and * Address Spaces. + * $Revision: 20 $ * *****************************************************************************/ @@ -25,14 +26,14 @@ #include "acpi.h" -#include "hardware.h" -#include "namesp.h" -#include "events.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" #include "amlcode.h" -#include "interp.h" +#include "acinterp.h" #define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evxfregn"); + MODULE_NAME ("evxfregn") /****************************************************************************** @@ -59,9 +60,9 @@ ADDRESS_SPACE_SETUP setup, void *context) { - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL *handler_obj; - ACPI_NAMED_OBJECT *obj_entry; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_OPERAND_OBJECT *handler_obj; + ACPI_NAMESPACE_NODE *node; ACPI_STATUS status = AE_OK; OBJECT_TYPE_INTERNAL type; u16 flags = 0; @@ -80,8 +81,8 @@ /* Convert and validate the device handle */ - obj_entry = acpi_ns_convert_handle_to_entry (device); - if (!obj_entry) { + node = acpi_ns_convert_handle_to_entry (device); + if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } @@ -92,10 +93,10 @@ * get placed. */ - if ((obj_entry->type != ACPI_TYPE_DEVICE) && - (obj_entry->type != ACPI_TYPE_PROCESSOR) && - (obj_entry->type != ACPI_TYPE_THERMAL) && - (obj_entry != acpi_gbl_root_object)) + if ((node->type != ACPI_TYPE_DEVICE) && + (node->type != ACPI_TYPE_PROCESSOR) && + (node->type != ACPI_TYPE_THERMAL) && + (node != acpi_gbl_root_node)) { status = AE_BAD_PARAMETER; goto unlock_and_exit; @@ -139,7 +140,7 @@ * Check for an existing internal object */ - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) obj_entry); + obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) node); if (obj_desc) { /* * The object exists. @@ -162,19 +163,19 @@ /* * Move through the linked list of handlers */ - handler_obj = handler_obj->addr_handler.link; + handler_obj = handler_obj->addr_handler.next; } } else { /* Obj_desc does not exist, create one */ - if (obj_entry->type == ACPI_TYPE_ANY) { + if (node->type == ACPI_TYPE_ANY) { type = ACPI_TYPE_DEVICE; } else { - type = obj_entry->type; + type = node->type; } obj_desc = acpi_cm_create_internal_object (type); @@ -187,19 +188,13 @@ obj_desc->common.type = (u8) type; - /* Attach the new object to the NTE */ + /* Attach the new object to the Node */ status = acpi_ns_attach_object (device, obj_desc, (u8) type); if (ACPI_FAILURE (status)) { acpi_cm_remove_reference (obj_desc); goto unlock_and_exit; } - - /* TBD: [Investigate] Will this always be of type DEVICE? */ - - if (type == ACPI_TYPE_DEVICE) { - obj_desc->device.handle = device; - } } /* @@ -215,11 +210,11 @@ goto unlock_and_exit; } - handler_obj->addr_handler.space_id = (u16) space_id; + handler_obj->addr_handler.space_id = (u8) space_id; handler_obj->addr_handler.hflags = flags; - handler_obj->addr_handler.link = obj_desc->device.addr_handler; + handler_obj->addr_handler.next = obj_desc->device.addr_handler; handler_obj->addr_handler.region_list = NULL; - handler_obj->addr_handler.nte = obj_entry; + handler_obj->addr_handler.node = node; handler_obj->addr_handler.handler = handler; handler_obj->addr_handler.context = context; handler_obj->addr_handler.setup = setup; @@ -237,7 +232,7 @@ * of the branch */ status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, device, - ACPI_INT32_MAX, NS_WALK_NO_UNLOCK, + ACPI_UINT32_MAX, NS_WALK_UNLOCK, acpi_ev_addr_handler_helper, handler_obj, NULL); @@ -276,11 +271,11 @@ ACPI_ADDRESS_SPACE_TYPE space_id, ADDRESS_SPACE_HANDLER handler) { - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL *handler_obj; - ACPI_OBJECT_INTERNAL *region_obj; - ACPI_OBJECT_INTERNAL **last_obj_ptr; - ACPI_NAMED_OBJECT *obj_entry; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_OPERAND_OBJECT *handler_obj; + ACPI_OPERAND_OBJECT *region_obj; + ACPI_OPERAND_OBJECT **last_obj_ptr; + ACPI_NAMESPACE_NODE *node; ACPI_STATUS status = AE_OK; @@ -297,8 +292,8 @@ /* Convert and validate the device handle */ - obj_entry = acpi_ns_convert_handle_to_entry (device); - if (!obj_entry) { + node = acpi_ns_convert_handle_to_entry (device); + if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } @@ -306,7 +301,7 @@ /* Make sure the internal object exists */ - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) obj_entry); + obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) node); if (!obj_desc) { /* * The object DNE. @@ -356,7 +351,7 @@ /* * Remove this Handler object from the list */ - *last_obj_ptr = handler_obj->addr_handler.link; + *last_obj_ptr = handler_obj->addr_handler.next; /* * Now we can delete the handler object @@ -370,8 +365,8 @@ /* * Move through the linked list of handlers */ - last_obj_ptr = &handler_obj->addr_handler.link; - handler_obj = handler_obj->addr_handler.link; + last_obj_ptr = &handler_obj->addr_handler.next; + handler_obj = handler_obj->addr_handler.next; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/hardware/Makefile linux/drivers/acpi/hardware/Makefile --- v2.4.0-test8/linux/drivers/acpi/hardware/Makefile Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/hardware/Makefile Fri Sep 15 18:21:43 2000 @@ -0,0 +1,28 @@ +# +# Makefile for all Linux ACPI interpreter subdirectories +# + +SUB_DIRS := +MOD_SUB_DIRS := $(SUB_DIRS) +MOD_IN_SUB_DIRS := +ALL_SUB_DIRS := $(SUB_DIRS) + +O_TARGET := ../$(shell basename `pwd`).o +O_OBJS := +M_OBJS := + +ACPI_OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) + +EXTRA_CFLAGS += -I../include + +EXTRA_CFLAGS += $(ACPI_CFLAGS) + +# if the interpreter is used, it overrides arch/i386/kernel/acpi.c +ifeq ($(CONFIG_ACPI_INTERPRETER),y) + O_OBJS := $(ACPI_OBJS) +endif + +include $(TOPDIR)/Rules.make + +clean: + $(RM) *.o diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/hardware/hwacpi.c linux/drivers/acpi/hardware/hwacpi.c --- v2.4.0-test8/linux/drivers/acpi/hardware/hwacpi.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/hardware/hwacpi.c Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: hwacpi - ACPI hardware functions - mode and timer + * $Revision: 22 $ * *****************************************************************************/ @@ -25,11 +25,11 @@ #include "acpi.h" -#include "hardware.h" +#include "achware.h" #define _COMPONENT HARDWARE - MODULE_NAME ("hwacpi"); + MODULE_NAME ("hwacpi") /****************************************************************************** @@ -95,7 +95,7 @@ { - if (acpi_hw_register_access (ACPI_READ, ACPI_MTX_LOCK, (s32)SCI_EN)) { + if (acpi_hw_register_access (ACPI_READ, ACPI_MTX_LOCK, SCI_EN)) { return (SYS_MODE_ACPI); } else { diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/hardware/hwcpu32.c linux/drivers/acpi/hardware/hwcpu32.c --- v2.4.0-test8/linux/drivers/acpi/hardware/hwcpu32.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/hardware/hwcpu32.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Name: hwcpu32.c - CPU support for IA32 (Throttling, Cx_states) + * $Revision: 33 $ * *****************************************************************************/ @@ -23,11 +24,11 @@ */ #include "acpi.h" -#include "namesp.h" -#include "hardware.h" +#include "acnamesp.h" +#include "achware.h" #define _COMPONENT HARDWARE - MODULE_NAME ("Hwcpu32"); + MODULE_NAME ("Hwcpu32") #define BIT_4 0x10 /* TBD: [investigate] is this correct? */ @@ -82,7 +83,7 @@ *pm_timer_ticks = timer; } - return AE_OK; + return (AE_OK); } @@ -108,7 +109,7 @@ if (!pblk_address || !pm_timer_ticks) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } /* @@ -146,7 +147,7 @@ */ enable (); - return AE_OK; + return (AE_OK); } @@ -175,7 +176,7 @@ if (!pblk_address || !pm_timer_ticks) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } /* @@ -186,14 +187,14 @@ * eventually cause a demotion to C2 */ if (1 == (bus_master_status = - acpi_hw_register_access (ACPI_READ, ACPI_MTX_LOCK, (s32)BM_STS))) + acpi_hw_register_access (ACPI_READ, ACPI_MTX_LOCK, BM_STS))) { /* * Clear the BM_STS bit by setting it. */ - acpi_hw_register_access (ACPI_WRITE, ACPI_MTX_LOCK, (s32)BM_STS, 1); + acpi_hw_register_access (ACPI_WRITE, ACPI_MTX_LOCK, BM_STS, 1); *pm_timer_ticks = 0; - return AE_OK; + return (AE_OK); } /* @@ -253,7 +254,7 @@ */ enable(); - return AE_OK; + return (AE_OK); } @@ -277,7 +278,7 @@ { if (!acpi_hw_cx_handlers[acpi_hw_active_cx_state]) { - return AE_SUPPORT; + return (AE_SUPPORT); } return (acpi_hw_cx_handlers[acpi_hw_active_cx_state] (pblk_address, pm_timer_ticks)); @@ -305,11 +306,11 @@ * ---------------- */ if ((cx_state < 1) || (cx_state > 3)) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } if (!acpi_hw_cx_handlers[cx_state]) { - return AE_SUPPORT; + return (AE_SUPPORT); } /* @@ -318,7 +319,7 @@ * We only care when moving from one state to another... */ if (acpi_hw_active_cx_state == cx_state) { - return AE_OK; + return (AE_OK); } /* @@ -331,7 +332,7 @@ switch (cx_state) { case 3: - acpi_hw_register_access (ACPI_WRITE, ACPI_MTX_LOCK, (s32)BM_RLD, 1); + acpi_hw_register_access (ACPI_WRITE, ACPI_MTX_LOCK, BM_RLD, 1); break; } @@ -345,7 +346,7 @@ switch (acpi_hw_active_cx_state) { case 3: - acpi_hw_register_access (ACPI_WRITE, ACPI_MTX_LOCK, (s32)BM_RLD, 0); + acpi_hw_register_access (ACPI_WRITE, ACPI_MTX_LOCK, BM_RLD, 0); break; } @@ -355,7 +356,7 @@ */ acpi_hw_active_cx_state = cx_state; - return AE_OK; + return (AE_OK); } @@ -526,7 +527,7 @@ result = result * x; } - return result; + return (result); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/hardware/hwgpe.c linux/drivers/acpi/hardware/hwgpe.c --- v2.4.0-test8/linux/drivers/acpi/hardware/hwgpe.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/hardware/hwgpe.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: hwgpe - Low level GPE enable/disable/clear functions + * $Revision: 22 $ * *****************************************************************************/ @@ -23,12 +24,12 @@ */ #include "acpi.h" -#include "hardware.h" -#include "namesp.h" -#include "events.h" +#include "achware.h" +#include "acnamesp.h" +#include "acevents.h" #define _COMPONENT HARDWARE - MODULE_NAME ("hwgpe"); + MODULE_NAME ("hwgpe") u8 decode_to8bit [8] = {1,2,4,8,16,32,64,128}; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/hardware/hwregs.c linux/drivers/acpi/hardware/hwregs.c --- v2.4.0-test8/linux/drivers/acpi/hardware/hwregs.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/hardware/hwregs.c Fri Sep 15 14:30:30 2000 @@ -1,10 +1,11 @@ -/****************************************************************************** +/******************************************************************************* * * Module Name: hwregs - Read/write access functions for the various ACPI * control and status registers. + * $Revision: 67 $ * - *****************************************************************************/ + ******************************************************************************/ /* * Copyright (C) 2000 R. Byron Moore @@ -26,20 +27,20 @@ #include "acpi.h" -#include "hardware.h" -#include "namesp.h" +#include "achware.h" +#include "acnamesp.h" #define _COMPONENT HARDWARE - MODULE_NAME ("hwregs"); + MODULE_NAME ("hwregs") /* This matches the #defines in actypes.h. */ -ACPI_STRING sleep_state_table[] = {"\\_S0_","\\_S1_","\\_S2_","\\_S3_", +NATIVE_CHAR *sleep_state_table[] = {"\\_S0_","\\_S1_","\\_S2_","\\_S3_", "\\_S4_","\\_S4_b","\\_S5_"}; -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_hw_get_bit_shift * @@ -52,11 +53,11 @@ * ******************************************************************************/ -s32 +u32 acpi_hw_get_bit_shift ( u32 mask) { - s32 shift; + u32 shift; for (shift = 0; ((mask >> shift) & 1) == 0; shift++) { ; } @@ -65,7 +66,7 @@ } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_hw_clear_acpi_status * @@ -116,7 +117,7 @@ } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_hw_obtain_sleep_type_register_data * @@ -129,8 +130,7 @@ * DESCRIPTION: Acpi_hw_obtain_sleep_type_register_data() obtains the SLP_TYP and * SLP_TYPb values for the sleep state requested. * - - ***************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_hw_obtain_sleep_type_register_data ( @@ -139,7 +139,7 @@ u8 *slp_typ_b) { ACPI_STATUS status = AE_OK; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; /* @@ -157,45 +157,64 @@ */ status = acpi_ns_evaluate_by_name (sleep_state_table[sleep_state], NULL, &obj_desc); - if (AE_OK == status) { - if (obj_desc) { - /* - * We got something, now ensure it is correct. The object must - * be a package and must have at least 2 numeric values as the - * two elements - */ + if (ACPI_FAILURE (status)) { + return (status); + } - if ((obj_desc->common.type != ACPI_TYPE_PACKAGE) || - ((obj_desc->package.elements[0])->common.type != - ACPI_TYPE_NUMBER) || - ((obj_desc->package.elements[1])->common.type != - ACPI_TYPE_NUMBER)) - { - /* Invalid _Sx_ package type or value */ + if (!obj_desc) { + REPORT_ERROR ("Missing Sleep State object"); + return (AE_NOT_EXIST); + } - REPORT_ERROR ("Object type returned from interpreter differs from expected value"); - status = AE_ERROR; - } - else { - /* - * Valid _Sx_ package size, type, and value - */ - *slp_typ_a = - (u8) (obj_desc->package.elements[0])->number.value; + /* + * We got something, now ensure it is correct. The object must + * be a package and must have at least 2 numeric values as the + * two elements + */ - *slp_typ_b = - (u8) (obj_desc->package.elements[1])->number.value; - } + if (obj_desc->common.type != ACPI_TYPE_PACKAGE) { + /* Must be a package */ - acpi_cm_remove_reference (obj_desc); - } + REPORT_ERROR ("Sleep State object is not of type Package"); + status = AE_ERROR; + } + + else if (obj_desc->package.count < 2) { + /* Must have at least two elements */ + + REPORT_ERROR ("Sleep State package does not have at least two elements"); + status = AE_ERROR; + } + + else if (((obj_desc->package.elements[0])->common.type != + ACPI_TYPE_NUMBER) || + ((obj_desc->package.elements[1])->common.type != + ACPI_TYPE_NUMBER)) + { + /* Must have two */ + + REPORT_ERROR ("Sleep State package elements are not both of type Number"); + status = AE_ERROR; } + else { + /* + * Valid _Sx_ package size, type, and value + */ + *slp_typ_a = (u8) (obj_desc->package.elements[0])->number.value; + + *slp_typ_b = (u8) (obj_desc->package.elements[1])->number.value; + } + + + + acpi_cm_remove_reference (obj_desc); + return (status); } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_hw_register_access * @@ -229,7 +248,7 @@ va_list marker; va_start (marker, register_id); - value = va_arg (marker, s32); + value = va_arg (marker, u32); va_end (marker); } @@ -407,7 +426,7 @@ register_value = (u32) acpi_os_in16 (acpi_gbl_FACP->pm1a_cnt_blk); } - if (acpi_gbl_FACP->pm1b_cnt_blk && register_id != (s32) SLP_TYPE_A) { + if (acpi_gbl_FACP->pm1b_cnt_blk && register_id != (u32) SLP_TYPE_A) { register_value |= (u32) acpi_os_in16 (acpi_gbl_FACP->pm1b_cnt_blk); } @@ -469,7 +488,7 @@ } } - if (acpi_gbl_FACP->pm1b_cnt_blk && register_id != (s32) SLP_TYPE_A) { + if (acpi_gbl_FACP->pm1b_cnt_blk && register_id != (u32) SLP_TYPE_A) { acpi_os_out16 (acpi_gbl_FACP->pm1b_cnt_blk, (u16) register_value); } } @@ -551,13 +570,17 @@ mask = (((u32) register_id) & BIT_IN_REGISTER_MASK); mask = 1 << (mask-1); - /* The base address of the GPE 0 Register Block */ - /* Plus 1/2 the length of the GPE 0 Register Block */ - /* The enable register is the register following the Status Register */ - /* and each register is defined as 1/2 of the total Register Block */ - - /* This sets the bit within Enable_bit that needs to be written to */ - /* the register indicated in Mask to a 1, all others are 0 */ + /* + * The base address of the GPE 0 Register Block + * Plus 1/2 the length of the GPE 0 Register Block + * The enable register is the register following the Status Register + * and each register is defined as 1/2 of the total Register Block + */ + + /* + * This sets the bit within Enable_bit that needs to be written to + * the register indicated in Mask to a 1, all others are 0 + */ if (mask > LOW_BYTE) { /* Shift the value 1 byte to the right and add 1 to the register */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/hardware/hwxface.c linux/drivers/acpi/hardware/hwxface.c --- v2.4.0-test8/linux/drivers/acpi/hardware/hwxface.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/hardware/hwxface.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ /****************************************************************************** * * Name: hwxface.c - Hardware access external interfaces + * $Revision: 31 $ * *****************************************************************************/ @@ -24,11 +25,11 @@ */ #include "acpi.h" -#include "namesp.h" -#include "hardware.h" +#include "acnamesp.h" +#include "achware.h" #define _COMPONENT HARDWARE - MODULE_NAME ("hwxface"); + MODULE_NAME ("hwxface") /****************************************************************************** @@ -68,10 +69,9 @@ NATIVE_UINT num_throttle_states; NATIVE_UINT buffer_space_needed; NATIVE_UINT i; - u8 duty_offset; - u8 duty_width; - ACPI_NAMED_OBJECT *cpu_entry; - ACPI_OBJECT_INTERNAL *cpu_obj; + u8 duty_width = 0; + ACPI_NAMESPACE_NODE *cpu_node; + ACPI_OPERAND_OBJECT *cpu_obj; ACPI_CPU_THROTTLING_STATE *state_ptr; @@ -86,8 +86,8 @@ * Convert and validate the device handle */ - cpu_entry = acpi_ns_convert_handle_to_entry (processor_handle); - if (!cpu_entry) { + cpu_node = acpi_ns_convert_handle_to_entry (processor_handle); + if (!cpu_node) { return (AE_BAD_PARAMETER); } @@ -95,23 +95,27 @@ * Check for an existing internal object */ - cpu_obj = acpi_ns_get_attached_object ((ACPI_HANDLE) cpu_entry); + cpu_obj = acpi_ns_get_attached_object ((ACPI_HANDLE) cpu_node); if (!cpu_obj) { return (AE_NOT_FOUND); } - duty_offset = acpi_gbl_FACP->duty_offset; +#ifndef _IA64 + /* + * No Duty fields in IA64 tables + */ duty_width = acpi_gbl_FACP->duty_width; +#endif /* * P0 must always have a P_BLK all others may be null - * in either case, we can't thottle a processor that has no P_BLK + * in either case, we can't throttle a processor that has no P_BLK * * Also if no Duty width, one state and it is 100% * */ - if (!cpu_obj->processor.pblk_length || !duty_width || - (0xFFFF < cpu_obj->processor.pblk_address)) + if (!cpu_obj->processor.length || !duty_width || + (0xFFFF < cpu_obj->processor.address)) { /* * Acpi_even though we can't throttle, we still have one state (100%) @@ -169,30 +173,35 @@ ACPI_HANDLE processor_handle, u32 *throttle_state) { - ACPI_NAMED_OBJECT *cpu_entry; - ACPI_OBJECT_INTERNAL *cpu_obj; + ACPI_NAMESPACE_NODE *cpu_node; + ACPI_OPERAND_OBJECT *cpu_obj; u32 num_throttle_states; u32 duty_cycle; - u8 duty_offset; - u8 duty_width; + u8 duty_offset = 0; + u8 duty_width = 0; /* Convert and validate the device handle */ - cpu_entry = acpi_ns_convert_handle_to_entry (processor_handle); - if (!cpu_entry || !throttle_state) { + cpu_node = acpi_ns_convert_handle_to_entry (processor_handle); + if (!cpu_node || !throttle_state) { return (AE_BAD_PARAMETER); } /* Check for an existing internal object */ - cpu_obj = acpi_ns_get_attached_object ((ACPI_HANDLE) cpu_entry); + cpu_obj = acpi_ns_get_attached_object ((ACPI_HANDLE) cpu_node); if (!cpu_obj) { return (AE_NOT_FOUND); } +#ifndef _IA64 + /* + * No Duty fields in IA64 tables + */ duty_offset = acpi_gbl_FACP->duty_offset; duty_width = acpi_gbl_FACP->duty_width; +#endif /* * Must have a valid P_BLK P0 must have a P_BLK all others may be null @@ -201,8 +210,8 @@ * * also, if Duty_width is zero there are no additional states */ - if (!cpu_obj->processor.pblk_length || !duty_width || - (0xFFFF < cpu_obj->processor.pblk_address)) + if (!cpu_obj->processor.length || !duty_width || + (0xFFFF < cpu_obj->processor.address)) { *throttle_state = 0; return(AE_OK); @@ -214,7 +223,7 @@ * Get the current duty cycle value. */ duty_cycle = acpi_hw_get_duty_cycle (duty_offset, - cpu_obj->processor.pblk_address, + cpu_obj->processor.address, num_throttle_states); /* @@ -251,8 +260,8 @@ ACPI_HANDLE processor_handle, u32 throttle_state) { - ACPI_NAMED_OBJECT *cpu_entry; - ACPI_OBJECT_INTERNAL *cpu_obj; + ACPI_NAMESPACE_NODE *cpu_node; + ACPI_OPERAND_OBJECT *cpu_obj; u32 num_throttle_states = 0; u8 duty_offset = 0; u8 duty_width = 0; @@ -261,20 +270,25 @@ /* Convert and validate the device handle */ - cpu_entry = acpi_ns_convert_handle_to_entry (processor_handle); - if (!cpu_entry) { + cpu_node = acpi_ns_convert_handle_to_entry (processor_handle); + if (!cpu_node) { return (AE_BAD_PARAMETER); } /* Check for an existing internal object */ - cpu_obj = acpi_ns_get_attached_object ((ACPI_HANDLE) cpu_entry); + cpu_obj = acpi_ns_get_attached_object ((ACPI_HANDLE) cpu_node); if (!cpu_obj) { return (AE_NOT_FOUND); } +#ifndef _IA64 + /* + * No Duty fields in IA64 tables + */ duty_offset = acpi_gbl_FACP->duty_offset; duty_width = acpi_gbl_FACP->duty_width; +#endif /* * Must have a valid P_BLK P0 must have a P_BLK all others may be null @@ -283,8 +297,8 @@ * * also, if Duty_width is zero there are no additional states */ - if (!cpu_obj->processor.pblk_length || !duty_width || - (0xFFFF < cpu_obj->processor.pblk_address)) + if (!cpu_obj->processor.length || !duty_width || + (0xFFFF < cpu_obj->processor.address)) { /* * If caller wants to set the state to the only state we handle @@ -312,19 +326,19 @@ /* * Turn off throttling (don't muck with the h/w while throttling). */ - acpi_hw_disable_throttling (cpu_obj->processor.pblk_address); + acpi_hw_disable_throttling (cpu_obj->processor.address); /* * Program the throttling state. */ acpi_hw_program_duty_cycle (duty_offset, duty_cycle, - cpu_obj->processor.pblk_address, num_throttle_states); + cpu_obj->processor.address, num_throttle_states); /* * Only enable throttling for non-zero states (0 - 100%) */ if (throttle_state) { - acpi_hw_enable_throttling (cpu_obj->processor.pblk_address); + acpi_hw_enable_throttling (cpu_obj->processor.address); } return(AE_OK); @@ -438,9 +452,9 @@ ACPI_HANDLE processor_handle, u32 *pm_timer_ticks) { - ACPI_NAMED_OBJECT *cpu_entry = NULL; - ACPI_OBJECT_INTERNAL *cpu_obj = NULL; - ACPI_IO_ADDRESS pblk_address = 0; + ACPI_NAMESPACE_NODE *cpu_node = NULL; + ACPI_OPERAND_OBJECT *cpu_obj = NULL; + ACPI_IO_ADDRESS address = 0; /* @@ -449,31 +463,31 @@ /* Convert and validate the device handle */ - cpu_entry = acpi_ns_convert_handle_to_entry (processor_handle); - if (!cpu_entry) { - return AE_BAD_PARAMETER; + cpu_node = acpi_ns_convert_handle_to_entry (processor_handle); + if (!cpu_node) { + return (AE_BAD_PARAMETER); } /* Check for an existing internal object */ - cpu_obj = acpi_ns_get_attached_object ((ACPI_HANDLE) cpu_entry); + cpu_obj = acpi_ns_get_attached_object ((ACPI_HANDLE) cpu_node); if (!cpu_obj) { - return AE_NOT_FOUND; + return (AE_NOT_FOUND); } /* Get the processor register block (P_BLK) address */ - pblk_address = cpu_obj->processor.pblk_address; - if (!cpu_obj->processor.pblk_length) { + address = cpu_obj->processor.address; + if (!cpu_obj->processor.length) { /* Ensure a NULL addresss (note that P_BLK isn't required for C1) */ - pblk_address = 0; + address = 0; } /* * Enter the currently active Cx sleep state. */ - return acpi_hw_enter_cx (pblk_address, pm_timer_ticks); + return (acpi_hw_enter_cx (address, pm_timer_ticks)); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/accommon.h linux/drivers/acpi/include/accommon.h --- v2.4.0-test8/linux/drivers/acpi/include/accommon.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/accommon.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,661 @@ +/****************************************************************************** + * + * Name: accommon.h -- prototypes for the common (subsystem-wide) procedures + * $Revision: 74 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + +#ifndef _ACCOMMON_H +#define _ACCOMMON_H + + +#define REF_INCREMENT (u16) 0 +#define REF_DECREMENT (u16) 1 +#define REF_FORCE_DELETE (u16) 2 + +/* Acpi_cm_dump_buffer */ + +#define DB_BYTE_DISPLAY 1 +#define DB_WORD_DISPLAY 2 +#define DB_DWORD_DISPLAY 4 +#define DB_QWORD_DISPLAY 8 + + +/* Global initialization interfaces */ + +void +acpi_cm_init_globals ( + ACPI_INIT_DATA *init_data); + +void +acpi_cm_terminate ( + void); + + +/* + * Acpi_cm_init - miscellaneous initialization and shutdown + */ + +ACPI_STATUS +acpi_cm_hardware_initialize ( + void); + +ACPI_STATUS +acpi_cm_subsystem_shutdown ( + void); + +/* + * Acpi_cm_global - Global data structures and procedures + */ + +NATIVE_CHAR * +acpi_cm_get_mutex_name ( + u32 mutex_id); + +NATIVE_CHAR * +acpi_cm_get_type_name ( + u32 type); + +u8 +acpi_cm_valid_object_type ( + u32 type); + +ACPI_OWNER_ID +acpi_cm_allocate_owner_id ( + u32 id_type); + + +/* + * Acpi_cm_clib - Local implementations of C library functions + */ + +NATIVE_UINT +acpi_cm_strlen ( + const NATIVE_CHAR *string); + +NATIVE_CHAR * +acpi_cm_strcpy ( + NATIVE_CHAR *dst_string, + const NATIVE_CHAR *src_string); + +NATIVE_CHAR * +acpi_cm_strncpy ( + NATIVE_CHAR *dst_string, + const NATIVE_CHAR *src_string, + NATIVE_UINT count); + +u32 +acpi_cm_strncmp ( + const NATIVE_CHAR *string1, + const NATIVE_CHAR *string2, + NATIVE_UINT count); + +u32 +acpi_cm_strcmp ( + const NATIVE_CHAR *string1, + const NATIVE_CHAR *string2); + +NATIVE_CHAR * +acpi_cm_strcat ( + NATIVE_CHAR *dst_string, + const NATIVE_CHAR *src_string); + +NATIVE_CHAR * +acpi_cm_strncat ( + NATIVE_CHAR *dst_string, + const NATIVE_CHAR *src_string, + NATIVE_UINT count); + +u32 +acpi_cm_strtoul ( + const NATIVE_CHAR *string, + NATIVE_CHAR **terminator, + u32 base); + +NATIVE_CHAR * +acpi_cm_strstr ( + NATIVE_CHAR *string1, + NATIVE_CHAR *string2); + +NATIVE_CHAR * +acpi_cm_strupr ( + NATIVE_CHAR *src_string); + +void * +acpi_cm_memcpy ( + void *dest, + const void *src, + NATIVE_UINT count); + +void * +acpi_cm_memset ( + void *dest, + u32 value, + NATIVE_UINT count); + +u32 +acpi_cm_to_upper ( + u32 c); + +u32 +acpi_cm_to_lower ( + u32 c); + + +/* + * Acpi_cm_copy - Object construction and conversion interfaces + */ + +ACPI_STATUS +acpi_cm_build_simple_object( + ACPI_OPERAND_OBJECT *obj, + ACPI_OBJECT *user_obj, + u8 *data_space, + u32 *buffer_space_used); + +ACPI_STATUS +acpi_cm_build_package_object ( + ACPI_OPERAND_OBJECT *obj, + u8 *buffer, + u32 *space_used); + +ACPI_STATUS +acpi_cm_build_external_object ( + ACPI_OPERAND_OBJECT *obj, + ACPI_BUFFER *ret_buffer); + +ACPI_STATUS +acpi_cm_build_internal_simple_object( + ACPI_OBJECT *user_obj, + ACPI_OPERAND_OBJECT *obj); + +ACPI_STATUS +acpi_cm_build_internal_object ( + ACPI_OBJECT *obj, + ACPI_OPERAND_OBJECT *internal_obj); + +ACPI_STATUS +acpi_cm_copy_internal_simple_object ( + ACPI_OPERAND_OBJECT *source_obj, + ACPI_OPERAND_OBJECT *dest_obj); + +ACPI_STATUS +acpi_cm_build_copy_internal_package_object ( + ACPI_OPERAND_OBJECT *source_obj, + ACPI_OPERAND_OBJECT *dest_obj); + + +/* + * Acpi_cm_create - Object creation + */ + +ACPI_STATUS +acpi_cm_update_object_reference ( + ACPI_OPERAND_OBJECT *object, + u16 action); + +ACPI_OPERAND_OBJECT * +_cm_create_internal_object ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + OBJECT_TYPE_INTERNAL type); + + +/* + * Acpi_cm_debug - Debug interfaces + */ + +u32 +get_debug_level ( + void); + +void +set_debug_level ( + u32 level); + +void +function_trace ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name); + +void +function_trace_ptr ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name, + void *pointer); + +void +function_trace_u32 ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name, + u32 integer); + +void +function_trace_str ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name, + NATIVE_CHAR *string); + +void +function_exit ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name); + +void +function_status_exit ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name, + ACPI_STATUS status); + +void +function_value_exit ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name, + NATIVE_UINT value); + +void +function_ptr_exit ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *function_name, + u8 *ptr); + +void +debug_print_prefix ( + NATIVE_CHAR *module_name, + u32 line_number); + +void +debug_print ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + u32 print_level, + NATIVE_CHAR *format, ...); + +void +debug_print_raw ( + NATIVE_CHAR *format, ...); + +void +_report_info ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *message); + +void +_report_error ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *message); + +void +_report_warning ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id, + NATIVE_CHAR *message); + +void +acpi_cm_dump_buffer ( + u8 *buffer, + u32 count, + u32 display, + u32 component_id); + + +/* + * Acpi_cm_delete - Object deletion + */ + +void +acpi_cm_delete_internal_obj ( + ACPI_OPERAND_OBJECT *object); + +void +acpi_cm_delete_internal_package_object ( + ACPI_OPERAND_OBJECT *object); + +void +acpi_cm_delete_internal_simple_object ( + ACPI_OPERAND_OBJECT *object); + +ACPI_STATUS +acpi_cm_delete_internal_object_list ( + ACPI_OPERAND_OBJECT **obj_list); + + +/* + * Acpi_cm_eval - object evaluation + */ + +/* Method name strings */ + +#define METHOD_NAME__HID "_HID" +#define METHOD_NAME__UID "_UID" +#define METHOD_NAME__ADR "_ADR" +#define METHOD_NAME__STA "_STA" +#define METHOD_NAME__REG "_REG" +#define METHOD_NAME__SEG "_SEG" +#define METHOD_NAME__BBN "_BBN" + + +ACPI_STATUS +acpi_cm_evaluate_numeric_object ( + NATIVE_CHAR *method_name, + ACPI_NAMESPACE_NODE *device_node, + u32 *address); + +ACPI_STATUS +acpi_cm_execute_HID ( + ACPI_NAMESPACE_NODE *device_node, + DEVICE_ID *hid); + +ACPI_STATUS +acpi_cm_execute_STA ( + ACPI_NAMESPACE_NODE *device_node, + u32 *status_flags); + +ACPI_STATUS +acpi_cm_execute_UID ( + ACPI_NAMESPACE_NODE *device_node, + DEVICE_ID *uid); + + +/* + * Acpi_cm_error - exception interfaces + */ + +NATIVE_CHAR * +acpi_cm_format_exception ( + ACPI_STATUS status); + + +/* + * Acpi_cm_mutex - mutual exclusion interfaces + */ + +ACPI_STATUS +acpi_cm_mutex_initialize ( + void); + +void +acpi_cm_mutex_terminate ( + void); + +ACPI_STATUS +acpi_cm_create_mutex ( + ACPI_MUTEX_HANDLE mutex_id); + +ACPI_STATUS +acpi_cm_delete_mutex ( + ACPI_MUTEX_HANDLE mutex_id); + +ACPI_STATUS +acpi_cm_acquire_mutex ( + ACPI_MUTEX_HANDLE mutex_id); + +ACPI_STATUS +acpi_cm_release_mutex ( + ACPI_MUTEX_HANDLE mutex_id); + + +/* + * Acpi_cm_object - internal object create/delete/cache routines + */ + +void * +_cm_allocate_object_desc ( + NATIVE_CHAR *module_name, + u32 line_number, + u32 component_id); + +#define acpi_cm_create_internal_object(t) _cm_create_internal_object(_THIS_MODULE,__LINE__,_COMPONENT,t) +#define acpi_cm_allocate_object_desc() _cm_allocate_object_desc(_THIS_MODULE,__LINE__,_COMPONENT) + +void +acpi_cm_delete_object_desc ( + ACPI_OPERAND_OBJECT *object); + +u8 +acpi_cm_valid_internal_object ( + void *object); + + +/* + * Acpi_cm_ref_cnt - Object reference count management + */ + +void +acpi_cm_add_reference ( + ACPI_OPERAND_OBJECT *object); + +void +acpi_cm_remove_reference ( + ACPI_OPERAND_OBJECT *object); + +/* + * Acpi_cm_size - Object size routines + */ + +ACPI_STATUS +acpi_cm_get_simple_object_size ( + ACPI_OPERAND_OBJECT *obj, + u32 *obj_length); + +ACPI_STATUS +acpi_cm_get_package_object_size ( + ACPI_OPERAND_OBJECT *obj, + u32 *obj_length); + +ACPI_STATUS +acpi_cm_get_object_size( + ACPI_OPERAND_OBJECT *obj, + u32 *obj_length); + + +/* + * Acpi_cm_state - Generic state creation/cache routines + */ + +void +acpi_cm_push_generic_state ( + ACPI_GENERIC_STATE **list_head, + ACPI_GENERIC_STATE *state); + +ACPI_GENERIC_STATE * +acpi_cm_pop_generic_state ( + ACPI_GENERIC_STATE **list_head); + + +ACPI_GENERIC_STATE * +acpi_cm_create_generic_state ( + void); + +ACPI_GENERIC_STATE * +acpi_cm_create_update_state ( + ACPI_OPERAND_OBJECT *object, + u16 action); + +ACPI_STATUS +acpi_cm_create_update_state_and_push ( + ACPI_OPERAND_OBJECT *object, + u16 action, + ACPI_GENERIC_STATE **state_list); + +ACPI_GENERIC_STATE * +acpi_cm_create_control_state ( + void); + +void +acpi_cm_delete_generic_state ( + ACPI_GENERIC_STATE *state); + +void +acpi_cm_delete_generic_state_cache ( + void); + +void +acpi_cm_delete_object_cache ( + void); + +/* + * Acpi_cmutils + */ + +u8 +acpi_cm_valid_acpi_name ( + u32 name); + +u8 +acpi_cm_valid_acpi_character ( + NATIVE_CHAR character); + + +/* + * Memory allocation functions and related macros. + * Macros that expand to include filename and line number + */ + +void * +_cm_allocate ( + u32 size, + u32 component, + NATIVE_CHAR *module, + u32 line); + +void * +_cm_callocate ( + u32 size, + u32 component, + NATIVE_CHAR *module, + u32 line); + +void +_cm_free ( + void *address, + u32 component, + NATIVE_CHAR *module, + u32 line); + +void +acpi_cm_init_static_object ( + ACPI_OPERAND_OBJECT *obj_desc); + +#define acpi_cm_allocate(a) _cm_allocate(a,_COMPONENT,_THIS_MODULE,__LINE__) +#define acpi_cm_callocate(a) _cm_callocate(a, _COMPONENT,_THIS_MODULE,__LINE__) +#define acpi_cm_free(a) _cm_free(a,_COMPONENT,_THIS_MODULE,__LINE__) + +#ifndef ACPI_DEBUG + +#define acpi_cm_add_element_to_alloc_list(a,b,c,d,e,f) +#define acpi_cm_delete_element_from_alloc_list(a,b,c,d) +#define acpi_cm_dump_current_allocations(a,b) +#define acpi_cm_dump_allocation_info() + +#define DECREMENT_OBJECT_METRICS(a) +#define INCREMENT_OBJECT_METRICS(a) +#define INITIALIZE_ALLOCATION_METRICS() +#define DECREMENT_NAME_TABLE_METRICS(a) +#define INCREMENT_NAME_TABLE_METRICS(a) + +#else + +#define INITIALIZE_ALLOCATION_METRICS() \ + acpi_gbl_current_object_count = 0; \ + acpi_gbl_current_object_size = 0; \ + acpi_gbl_running_object_count = 0; \ + acpi_gbl_running_object_size = 0; \ + acpi_gbl_max_concurrent_object_count = 0; \ + acpi_gbl_max_concurrent_object_size = 0; \ + acpi_gbl_current_alloc_size = 0; \ + acpi_gbl_current_alloc_count = 0; \ + acpi_gbl_running_alloc_size = 0; \ + acpi_gbl_running_alloc_count = 0; \ + acpi_gbl_max_concurrent_alloc_size = 0; \ + acpi_gbl_max_concurrent_alloc_count = 0; \ + acpi_gbl_current_node_count = 0; \ + acpi_gbl_current_node_size = 0; \ + acpi_gbl_max_concurrent_node_count = 0 + + +#define DECREMENT_OBJECT_METRICS(a) \ + acpi_gbl_current_object_count--; \ + acpi_gbl_current_object_size -= a + +#define INCREMENT_OBJECT_METRICS(a) \ + acpi_gbl_current_object_count++; \ + acpi_gbl_running_object_count++; \ + if (acpi_gbl_max_concurrent_object_count < acpi_gbl_current_object_count) \ + { \ + acpi_gbl_max_concurrent_object_count = acpi_gbl_current_object_count; \ + } \ + acpi_gbl_running_object_size += a; \ + acpi_gbl_current_object_size += a; \ + if (acpi_gbl_max_concurrent_object_size < acpi_gbl_current_object_size) \ + { \ + acpi_gbl_max_concurrent_object_size = acpi_gbl_current_object_size; \ + } + +#define DECREMENT_NAME_TABLE_METRICS(a) \ + acpi_gbl_current_node_count--; \ + acpi_gbl_current_node_size -= (a) + +#define INCREMENT_NAME_TABLE_METRICS(a) \ + acpi_gbl_current_node_count++; \ + acpi_gbl_current_node_size+= (a); \ + if (acpi_gbl_max_concurrent_node_count < acpi_gbl_current_node_count) \ + { \ + acpi_gbl_max_concurrent_node_count = acpi_gbl_current_node_count; \ + } \ + + +void +acpi_cm_dump_allocation_info ( + void); + +void +acpi_cm_dump_current_allocations ( + u32 component, + NATIVE_CHAR *module); + +#endif + + +#endif /* _ACCOMMON_H */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acconfig.h linux/drivers/acpi/include/acconfig.h --- v2.4.0-test8/linux/drivers/acpi/include/acconfig.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/acconfig.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,186 @@ +/****************************************************************************** + * + * Name: acconfig.h - Global configuration constants + * $Revision: 42 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + +#ifndef _ACCONFIG_H +#define _ACCONFIG_H + + +/****************************************************************************** + * + * Compile-time options + * + *****************************************************************************/ + +/* + * ACPI_DEBUG - This switch enables all the debug facilities of the ACPI + * subsystem. This includes the DEBUG_PRINT output statements + * When disabled, all DEBUG_PRINT statements are compiled out. + * + * ACPI_APPLICATION - Use this switch if the subsystem is going to be run + * at the application level. + * + */ + + +/****************************************************************************** + * + * Subsystem Constants + * + *****************************************************************************/ + + +/* Version string */ + +#define ACPI_CA_VERSION __DATE__ + +/* Name of host operating system (returned by the _OS_ namespace object) */ + +#ifdef _LINUX +#define ACPI_OS_NAME "Linux" +#else +#define ACPI_OS_NAME "Intel ACPI/CA Core Subsystem" +#endif + + +/* + * How and when control methods will be parsed + * The default action is to parse all methods at table load time to verify them, but delete the parse trees + * to conserve memory. Methods are parsed just in time before execution and the parse tree is deleted + * when execution completes. + */ +#define METHOD_PARSE_AT_INIT 0x0 /* Parse at table init, never delete the method parse tree */ +#define METHOD_PARSE_JUST_IN_TIME 0x1 /* Parse only when a method is invoked */ +#define METHOD_DELETE_AT_COMPLETION 0x2 /* Delete parse tree on method completion */ + +/* Default parsing configuration */ + +#define METHOD_PARSE_CONFIGURATION (METHOD_PARSE_JUST_IN_TIME | METHOD_DELETE_AT_COMPLETION) + + +/* Maximum objects in the various object caches */ + +#define MAX_STATE_CACHE_DEPTH 64 /* State objects for stacks */ +#define MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ +#define MAX_EXTPARSE_CACHE_DEPTH 64 /* Parse tree objects */ +#define MAX_OBJECT_CACHE_DEPTH 64 /* Interpreter operand objects */ +#define MAX_WALK_CACHE_DEPTH 2 /* Objects for parse tree walks (method execution) */ + +/* + * Name_space Table size + * + * All tables are the same size to simplify the implementation. + * Tables may be extended by allocating additional tables that + * are in turn linked together to form a chain of tables. + */ + +#define NS_TABLE_SIZE 4 + +/* String size constants */ + +#define MAX_STRING_LENGTH 512 +#define PATHNAME_MAX 256 /* A full namespace pathname */ + + +/* Maximum count for a semaphore object */ + +#define MAX_SEMAPHORE_COUNT 256 + + +/* Max reference count (for debug only) */ + +#define MAX_REFERENCE_COUNT 0x200 + + +/* Size of cached memory mapping for system memory operation region */ + +#define SYSMEM_REGION_WINDOW_SIZE 4096 + + +/* + * Debugger threading model + * Use single threaded if the entire subsystem is contained in an application + * Use multiple threaded when the the subsystem is running in the kernel. + * + * By default the model is single threaded if ACPI_APPLICATION is set, + * multi-threaded if ACPI_APPLICATION is not set. + */ + +#define DEBUGGER_SINGLE_THREADED 0 +#define DEBUGGER_MULTI_THREADED 1 + +#ifdef ACPI_APPLICATION +#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED + +#else +#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED +#endif + + +/****************************************************************************** + * + * ACPI Specification constants (Do not change unless the specification changes) + * + *****************************************************************************/ + +/* + * Method info (in WALK_STATE), containing local variables and argumetns + */ + +#define MTH_NUM_LOCALS 8 +#define MTH_MAX_LOCAL 7 + +#define MTH_NUM_ARGS 7 +#define MTH_MAX_ARG 6 + +/* + * Operand Stack (in WALK_STATE), Must be large enough to contain MTH_MAX_ARG + */ + +#define OBJ_NUM_OPERANDS 8 +#define OBJ_MAX_OPERAND 7 + +/* Names within the namespace are 4 bytes long */ + +#define ACPI_NAME_SIZE 4 +#define PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 s8 for separator */ +#define PATH_SEPARATOR '.' + + +/* Constants used in searching for the RSDP in low memory */ + +#define LO_RSDP_WINDOW_BASE (void *) 0 +#define HI_RSDP_WINDOW_BASE (void *) 0xE0000 +#define LO_RSDP_WINDOW_SIZE 0x400 +#define HI_RSDP_WINDOW_SIZE 0x20000 +#define RSDP_SCAN_STEP 16 + + +/* Maximum nesting of package objects */ + +#define MAX_PACKAGE_DEPTH 16 + + +#endif /* _ACCONFIG_H */ + diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acdebug.h linux/drivers/acpi/include/acdebug.h --- v2.4.0-test8/linux/drivers/acpi/include/acdebug.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/acdebug.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,396 @@ +/****************************************************************************** + * + * Name: acdebug.h - ACPI/AML debugger + * $Revision: 35 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + +#ifndef __ACDEBUG_H__ +#define __ACDEBUG_H__ + + +#define DB_MAX_ARGS 8 /* Must be max method args + 1 */ + +#define DB_COMMAND_PROMPT '-' +#define DB_EXECUTE_PROMPT '%' + + +extern int optind; +extern NATIVE_CHAR *optarg; +extern u8 *aml_ptr; +extern u32 acpi_aml_length; + +extern u8 opt_tables; +extern u8 opt_disasm; +extern u8 opt_stats; +extern u8 opt_parse_jit; +extern u8 opt_verbose; + + +extern NATIVE_CHAR *args[DB_MAX_ARGS]; +extern NATIVE_CHAR line_buf[80]; +extern NATIVE_CHAR scope_buf[40]; +extern NATIVE_CHAR debug_filename[40]; +extern u8 output_to_file; +extern NATIVE_CHAR *buffer; +extern NATIVE_CHAR *filename; +extern NATIVE_CHAR *INDENT_STRING; +extern u8 acpi_gbl_db_output_flags; +extern u32 acpi_gbl_db_debug_level; +extern u32 acpi_gbl_db_console_debug_level; + +extern u32 num_names; +extern u32 num_methods; +extern u32 num_regions; +extern u32 num_packages; +extern u32 num_aliases; +extern u32 num_devices; +extern u32 num_field_defs; +extern u32 num_thermal_zones; +extern u32 num_nodes; +extern u32 num_grammar_elements; +extern u32 num_method_elements ; +extern u32 num_mutexes; +extern u32 num_power_resources; +extern u32 num_bank_fields ; +extern u32 num_index_fields; +extern u32 num_events; + +extern u32 size_of_parse_tree; +extern u32 size_of_method_trees; +extern u32 size_of_nTes; +extern u32 size_of_acpi_objects; + + +#define BUFFER_SIZE 4196 + +#define DB_REDIRECTABLE_OUTPUT 0x01 +#define DB_CONSOLE_OUTPUT 0x02 +#define DB_DUPLICATE_OUTPUT 0x03 + + +typedef struct command_info +{ + NATIVE_CHAR *name; /* Command Name */ + u8 min_args; /* Minimum arguments required */ + +} COMMAND_INFO; + + +typedef struct argument_info +{ + NATIVE_CHAR *name; /* Argument Name */ + +} ARGUMENT_INFO; + + +#define PARAM_LIST(pl) pl + +#define DBTEST_OUTPUT_LEVEL(lvl) if (opt_verbose) + +#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ + acpi_os_printf PARAM_LIST(fp);} + +#define EX_NO_SINGLE_STEP 1 +#define EX_SINGLE_STEP 2 + + +/* Prototypes */ + + +/* + * dbapi - external debugger interfaces + */ + +int +acpi_db_initialize ( + void); + +ACPI_STATUS +acpi_db_single_step ( + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *op, + u8 op_type); + + +/* + * dbcmds - debug commands and output routines + */ + + +void +acpi_db_display_table_info ( + NATIVE_CHAR *table_arg); + +void +acpi_db_unload_acpi_table ( + NATIVE_CHAR *table_arg, + NATIVE_CHAR *instance_arg); + +void +acpi_db_set_method_breakpoint ( + NATIVE_CHAR *location, + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *op); + +void +acpi_db_set_method_call_breakpoint ( + ACPI_PARSE_OBJECT *op); + +void +acpi_db_disassemble_aml ( + NATIVE_CHAR *statements, + ACPI_PARSE_OBJECT *op); + +void +acpi_db_dump_namespace ( + NATIVE_CHAR *start_arg, + NATIVE_CHAR *depth_arg); + +void +acpi_db_dump_namespace_by_owner ( + NATIVE_CHAR *owner_arg, + NATIVE_CHAR *depth_arg); + +void +acpi_db_send_notify ( + NATIVE_CHAR *name, + u32 value); + +void +acpi_db_set_method_data ( + NATIVE_CHAR *type_arg, + NATIVE_CHAR *index_arg, + NATIVE_CHAR *value_arg); + +ACPI_STATUS +acpi_db_display_objects ( + NATIVE_CHAR *obj_type_arg, + NATIVE_CHAR *display_count_arg); + +ACPI_STATUS +acpi_db_find_name_in_namespace ( + NATIVE_CHAR *name_arg); + +void +acpi_db_set_scope ( + NATIVE_CHAR *name); + +void +acpi_db_find_references ( + NATIVE_CHAR *object_arg); + + +/* + * dbdisasm - AML disassembler + */ + +void +acpi_db_display_op ( + ACPI_PARSE_OBJECT *origin, + u32 num_opcodes); + +void +acpi_db_display_namestring ( + NATIVE_CHAR *name); + +void +acpi_db_display_path ( + ACPI_PARSE_OBJECT *op); + +void +acpi_db_display_opcode ( + ACPI_PARSE_OBJECT *op); + + +/* + * dbdisply - debug display commands + */ + + +void +acpi_db_display_method_info ( + ACPI_PARSE_OBJECT *op); + +void +acpi_db_decode_and_display_object ( + NATIVE_CHAR *target, + NATIVE_CHAR *output_type); + +void +acpi_db_display_result_object ( + ACPI_OPERAND_OBJECT *obj_desc, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_db_display_all_methods ( + NATIVE_CHAR *display_count_arg); + +void +acpi_db_display_internal_object ( + ACPI_OPERAND_OBJECT *obj_desc, + ACPI_WALK_STATE *walk_state); + +void +acpi_db_display_arguments ( + void); + +void +acpi_db_display_locals ( + void); + +void +acpi_db_display_results ( + void); + +void +acpi_db_display_calling_tree ( + void); + +void +acpi_db_display_argument_object ( + ACPI_OPERAND_OBJECT *obj_desc, + ACPI_WALK_STATE *walk_state); + + +/* + * dbexec - debugger control method execution + */ + +void +acpi_db_execute ( + NATIVE_CHAR *name, + NATIVE_CHAR **args, + u32 flags); + +void +acpi_db_create_execution_threads ( + NATIVE_CHAR *num_threads_arg, + NATIVE_CHAR *num_loops_arg, + NATIVE_CHAR *method_name_arg); + + +/* + * dbfileio - Debugger file I/O commands + */ + +OBJECT_TYPE_INTERNAL +acpi_db_match_argument ( + NATIVE_CHAR *user_argument, + ARGUMENT_INFO *arguments); + + +void +acpi_db_close_debug_file ( + void); + +void +acpi_db_open_debug_file ( + NATIVE_CHAR *name); + +ACPI_STATUS +acpi_db_load_acpi_table ( + NATIVE_CHAR *filename); + + +/* + * dbhistry - debugger HISTORY command + */ + +void +acpi_db_add_to_history ( + NATIVE_CHAR *command_line); + +void +acpi_db_display_history (void); + +NATIVE_CHAR * +acpi_db_get_from_history ( + NATIVE_CHAR *command_num_arg); + + +/* + * dbinput - user front-end to the AML debugger + */ + +ACPI_STATUS +acpi_db_command_dispatch ( + NATIVE_CHAR *input_buffer, + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *op); + +void +acpi_db_execute_thread ( + void *context); + +ACPI_STATUS +acpi_db_user_commands ( + NATIVE_CHAR prompt, + ACPI_PARSE_OBJECT *op); + + +/* + * dbstats - Generation and display of ACPI table statistics + */ + +void +acpi_db_generate_statistics ( + ACPI_PARSE_OBJECT *root, + u8 is_method); + + +ACPI_STATUS +acpi_db_display_statistics ( + NATIVE_CHAR *type_arg); + + +/* + * dbutils - AML debugger utilities + */ + +void +acpi_db_set_output_destination ( + u32 where); + +void +acpi_db_dump_buffer ( + u32 address); + +void +acpi_db_dump_object ( + ACPI_OBJECT *obj_desc, + u32 level); + +void +acpi_db_prep_namestring ( + NATIVE_CHAR *name); + + +ACPI_STATUS +acpi_db_second_pass_parse ( + ACPI_PARSE_OBJECT *root); + +ACPI_NAMESPACE_NODE * +acpi_db_local_ns_lookup ( + NATIVE_CHAR *name); + + +#endif /* __ACDEBUG_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acdispat.h linux/drivers/acpi/include/acdispat.h --- v2.4.0-test8/linux/drivers/acpi/include/acdispat.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/acdispat.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,401 @@ +/****************************************************************************** + * + * Name: acdispat.h - dispatcher (parser to interpreter interface) + * $Revision: 29 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + + +#ifndef _ACDISPAT_H_ +#define _ACDISPAT_H_ + + +#define NAMEOF_LOCAL_NTE "__L0" +#define NAMEOF_ARG_NTE "__A0" + + +/* For Acpi_ds_method_data_set_value */ + +#define MTH_TYPE_LOCAL 0 +#define MTH_TYPE_ARG 1 + + +/* Common interfaces */ + +ACPI_STATUS +acpi_ds_obj_stack_push ( + void *object, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_obj_stack_pop ( + u32 pop_count, + ACPI_WALK_STATE *walk_state); + +void * +acpi_ds_obj_stack_get_value ( + u32 index, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_obj_stack_pop_object ( + ACPI_OPERAND_OBJECT **object, + ACPI_WALK_STATE *walk_state); + + +/* dsregion - Op region support */ + +ACPI_STATUS +acpi_ds_get_region_arguments ( + ACPI_OPERAND_OBJECT *rgn_desc); + + +/* dsctrl - Parser/Interpreter interface, control stack routines */ + + +ACPI_STATUS +acpi_ds_exec_begin_control_op ( + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *op); + +ACPI_STATUS +acpi_ds_exec_end_control_op ( + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *op); + + +/* dsexec - Parser/Interpreter interface, method execution callbacks */ + +ACPI_STATUS +acpi_ds_exec_begin_op ( + u16 opcode, + ACPI_PARSE_OBJECT *op, + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT **out_op); + +ACPI_STATUS +acpi_ds_exec_end_op ( + ACPI_WALK_STATE *state, + ACPI_PARSE_OBJECT *op); + + +/* dsfield - Parser/Interpreter interface for AML fields */ + + +ACPI_STATUS +acpi_ds_create_field ( + ACPI_PARSE_OBJECT *op, + ACPI_NAMESPACE_NODE *region_node, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_create_bank_field ( + ACPI_PARSE_OBJECT *op, + ACPI_NAMESPACE_NODE *region_node, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_create_index_field ( + ACPI_PARSE_OBJECT *op, + ACPI_HANDLE region_node, + ACPI_WALK_STATE *walk_state); + + +/* dsload - Parser/Interpreter interface, namespace load callbacks */ + +ACPI_STATUS +acpi_ds_load1_begin_op ( + u16 opcode, + ACPI_PARSE_OBJECT *op, + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT **out_op); + +ACPI_STATUS +acpi_ds_load1_end_op ( + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *op); + +ACPI_STATUS +acpi_ds_load2_begin_op ( + u16 opcode, + ACPI_PARSE_OBJECT *op, + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT **out_op); + +ACPI_STATUS +acpi_ds_load2_end_op ( + ACPI_WALK_STATE *state, + ACPI_PARSE_OBJECT *op); + + +/* dsmthdat - method data (locals/args) */ + + +ACPI_STATUS +acpi_ds_method_data_get_entry ( + u32 type, + u32 index, + ACPI_WALK_STATE *walk_state, + ACPI_OPERAND_OBJECT ***node); + +ACPI_STATUS +acpi_ds_method_data_delete_all ( + ACPI_WALK_STATE *walk_state); + +u8 +acpi_ds_is_method_value ( + ACPI_OPERAND_OBJECT *obj_desc); + +OBJECT_TYPE_INTERNAL +acpi_ds_method_data_get_type ( + u32 type, + u32 index, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_method_data_get_value ( + u32 type, + u32 index, + ACPI_WALK_STATE *walk_state, + ACPI_OPERAND_OBJECT **dest_desc); + +ACPI_STATUS +acpi_ds_method_data_set_value ( + u32 type, + u32 index, + ACPI_OPERAND_OBJECT *src_desc, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_method_data_delete_value ( + u32 type, + u32 index, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_method_data_init_args ( + ACPI_OPERAND_OBJECT **params, + u32 max_param_count, + ACPI_WALK_STATE *walk_state); + +ACPI_NAMESPACE_NODE * +acpi_ds_method_data_get_nte ( + u32 type, + u32 index, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_method_data_init ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_method_data_set_entry ( + u32 type, + u32 index, + ACPI_OPERAND_OBJECT *object, + ACPI_WALK_STATE *walk_state); + + +/* dsmethod - Parser/Interpreter interface - control method parsing */ + +ACPI_STATUS +acpi_ds_parse_method ( + ACPI_HANDLE obj_handle); + +ACPI_STATUS +acpi_ds_call_control_method ( + ACPI_WALK_LIST *walk_list, + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *op); + +ACPI_STATUS +acpi_ds_restart_control_method ( + ACPI_WALK_STATE *walk_state, + ACPI_OPERAND_OBJECT *return_desc); + +ACPI_STATUS +acpi_ds_terminate_control_method ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_begin_method_execution ( + ACPI_NAMESPACE_NODE *method_node, + ACPI_OPERAND_OBJECT *obj_desc); + + +/* dsobj - Parser/Interpreter interface - object initialization and conversion */ + +ACPI_STATUS +acpi_ds_init_one_object ( + ACPI_HANDLE obj_handle, + u32 level, + void *context, + void **return_value); + +ACPI_STATUS +acpi_ds_initialize_objects ( + ACPI_TABLE_DESC *table_desc, + ACPI_NAMESPACE_NODE *start_node); + +ACPI_STATUS +acpi_ds_build_internal_package_obj ( + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *op, + ACPI_OPERAND_OBJECT **obj_desc); + +ACPI_STATUS +acpi_ds_build_internal_object ( + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *op, + ACPI_OPERAND_OBJECT **obj_desc_ptr); + +ACPI_STATUS +acpi_ds_init_object_from_op ( + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *op, + u16 opcode, + ACPI_OPERAND_OBJECT **obj_desc); + +ACPI_STATUS +acpi_ds_create_node ( + ACPI_WALK_STATE *walk_state, + ACPI_NAMESPACE_NODE *node, + ACPI_PARSE_OBJECT *op); + + +/* dsregn - Parser/Interpreter interface - Op Region parsing */ + +ACPI_STATUS +acpi_ds_eval_region_operands ( + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *op); + +ACPI_STATUS +acpi_ds_initialize_region ( + ACPI_HANDLE obj_handle); + + +/* dsutils - Parser/Interpreter interface utility routines */ + +u8 +acpi_ds_is_result_used ( + ACPI_PARSE_OBJECT *op); + +void +acpi_ds_delete_result_if_not_used ( + ACPI_PARSE_OBJECT *op, + ACPI_OPERAND_OBJECT *result_obj, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_create_operand ( + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *arg); + +ACPI_STATUS +acpi_ds_create_operands ( + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *first_arg); + +ACPI_STATUS +acpi_ds_resolve_operands ( + ACPI_WALK_STATE *walk_state); + +OBJECT_TYPE_INTERNAL +acpi_ds_map_opcode_to_data_type ( + u16 opcode, + u32 *out_flags); + +OBJECT_TYPE_INTERNAL +acpi_ds_map_named_opcode_to_data_type ( + u16 opcode); + + +/* + * dswscope - Scope Stack manipulation + */ + +ACPI_STATUS +acpi_ds_scope_stack_push ( + ACPI_NAMESPACE_NODE *node, + OBJECT_TYPE_INTERNAL type, + ACPI_WALK_STATE *walk_state); + + +ACPI_STATUS +acpi_ds_scope_stack_pop ( + ACPI_WALK_STATE *walk_state); + +void +acpi_ds_scope_stack_clear ( + ACPI_WALK_STATE *walk_state); + + +/* Acpi_dswstate - parser WALK_STATE management routines */ + +ACPI_WALK_STATE * +acpi_ds_create_walk_state ( + ACPI_OWNER_ID owner_id, + ACPI_PARSE_OBJECT *origin, + ACPI_OPERAND_OBJECT *mth_desc, + ACPI_WALK_LIST *walk_list); + +ACPI_STATUS +acpi_ds_obj_stack_delete_all ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_obj_stack_pop_and_delete ( + u32 pop_count, + ACPI_WALK_STATE *walk_state); + +void +acpi_ds_delete_walk_state ( + ACPI_WALK_STATE *walk_state); + +ACPI_WALK_STATE * +acpi_ds_pop_walk_state ( + ACPI_WALK_LIST *walk_list); + +ACPI_STATUS +acpi_ds_result_stack_pop ( + ACPI_OPERAND_OBJECT **object, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_result_stack_push ( + void *object, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_result_stack_clear ( + ACPI_WALK_STATE *walk_state); + +ACPI_WALK_STATE * +acpi_ds_get_current_walk_state ( + ACPI_WALK_LIST *walk_list); + +void +acpi_ds_delete_walk_state_cache ( + void); + + +#endif /* _ACDISPAT_H_ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acenv.h linux/drivers/acpi/include/acenv.h --- v2.4.0-test8/linux/drivers/acpi/include/acenv.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/acenv.h Fri Sep 15 21:37:23 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Name: acenv.h - Generation environment specific items + * $Revision: 53 $ * *****************************************************************************/ @@ -75,10 +75,7 @@ #include #include #include - -/* Single threaded */ - -#define ACPI_APPLICATION +#include /* Use native Linux string library */ @@ -88,13 +85,27 @@ #define strtoul simple_strtoul +/* Linux clib doesn't to strupr, but we do. */ +char * +strupr(char *str); + +#else + +#ifdef _AED_EFI + +#include +#include +#include + #else + /* All other environments */ #define ACPI_USE_STANDARD_HEADERS #endif +#endif /****************************************************************************** @@ -117,6 +128,7 @@ #include #include #include +#include #endif /* ACPI_USE_STANDARD_HEADERS */ @@ -124,20 +136,20 @@ * We will be linking to the standard Clib functions */ -#define STRSTR(s1,s2) strstr((char *) (s1), (char *) (s2)) -#define STRUPR(s) strupr((char *) (s)) -#define STRLEN(s) strlen((char *) (s)) -#define STRCPY(d,s) strcpy((char *) (d), (char *) (s)) -#define STRNCPY(d,s,n) strncpy((char *) (d), (char *) (s), (n)) -#define STRNCMP(d,s,n) strncmp((char *) (d), (char *) (s), (n)) -#define STRCMP(d,s) strcmp((char *) (d), (char *) (s)) -#define STRCAT(d,s) strcat((char *) (d), (char *) (s)) -#define STRNCAT(d,s,n) strncat((char *) (d), (char *) (s), (n)) -#define STRTOUL(d,s,n) strtoul((char *) (d), (char **) (s), (n)) -#define MEMCPY(d,s,n) memcpy(d, s, (size_t) n) -#define MEMSET(d,s,n) memset(d, s, (size_t) n) -#define TOUPPER toupper -#define TOLOWER tolower +#define STRSTR(s1,s2) strstr((s1), (s2)) +#define STRUPR(s) strupr((s)) +#define STRLEN(s) strlen((s)) +#define STRCPY(d,s) strcpy((d), (s)) +#define STRNCPY(d,s,n) strncpy((d), (s), (n)) +#define STRNCMP(d,s,n) strncmp((d), (s), (n)) +#define STRCMP(d,s) strcmp((d), (s)) +#define STRCAT(d,s) strcat((d), (s)) +#define STRNCAT(d,s,n) strncat((d), (s), (n)) +#define STRTOUL(d,s,n) strtoul((d), (s), (n)) +#define MEMCPY(d,s,n) memcpy((d), (s), (n)) +#define MEMSET(d,s,n) memset((d), (s), (n)) +#define TOUPPER toupper +#define TOLOWER tolower /****************************************************************************** @@ -165,37 +177,35 @@ * Storage alignment properties */ -#define _AUPBND (sizeof(int) - 1) -#define _ADNBND (sizeof(int) - 1) +#define _AUPBND (sizeof(int) - 1) +#define _ADNBND (sizeof(int) - 1) /* * Variable argument list macro definitions */ -#define _bnd(X, bnd) (((sizeof(X)) + (bnd)) & (~(bnd))) -#define va_arg(ap, T) (*(T *)(((ap) += ((_bnd(T, _AUPBND))) \ - - (_bnd(T, _ADNBND))))) -#define va_end(ap) (void)0 -#define va_start(ap, A) (void) ((ap) = (((char *)&(A)) \ - + (_bnd(A, _AUPBND)))) +#define _bnd(X, bnd) (((sizeof(X)) + (bnd)) & (~(bnd))) +#define va_arg(ap, T) (*(T *)(((ap)+=((_bnd(T, _AUPBND)))-(_bnd(T,_ADNBND))))) +#define va_end(ap) (void)0 +#define va_start(ap, A) (void)((ap)=(((char*)&(A))+(_bnd(A,_AUPBND)))) #endif /* va_arg */ -#define STRSTR(s1,s2) acpi_cm_strstr ((char *) (s1), (char *) (s2)) -#define STRUPR(s) acpi_cm_strupr ((char *) (s)) -#define STRLEN(s) acpi_cm_strlen ((char *) (s)) -#define STRCPY(d,s) acpi_cm_strcpy ((char *) (d), (char *) (s)) -#define STRNCPY(d,s,n) acpi_cm_strncpy ((char *) (d), (char *) (s), (n)) -#define STRNCMP(d,s,n) acpi_cm_strncmp ((char *) (d), (char *) (s), (n)) -#define STRCMP(d,s) acpi_cm_strcmp ((char *) (d), (char *) (s)) -#define STRCAT(d,s) acpi_cm_strcat ((char *) (d), (char *) (s)) -#define STRNCAT(d,s,n) acpi_cm_strncat ((char *) (d), (char *) (s), (n)) -#define STRTOUL(d,s,n) acpi_cm_strtoul ((char *) (d), (char **) (s), (n)) -#define MEMCPY(d,s,n) acpi_cm_memcpy ((void *) (d), (const void *) (s), (n)) -#define MEMSET(d,v,n) acpi_cm_memset ((void *) (d), (v), (n)) -#define TOUPPER acpi_cm_to_upper -#define TOLOWER acpi_cm_to_lower +#define STRSTR(s1,s2) acpi_cm_strstr ((s1), (s2)) +#define STRUPR(s) acpi_cm_strupr ((s)) +#define STRLEN(s) acpi_cm_strlen ((s)) +#define STRCPY(d,s) acpi_cm_strcpy ((d), (s)) +#define STRNCPY(d,s,n) acpi_cm_strncpy ((d), (s), (n)) +#define STRNCMP(d,s,n) acpi_cm_strncmp ((d), (s), (n)) +#define STRCMP(d,s) acpi_cm_strcmp ((d), (s)) +#define STRCAT(d,s) acpi_cm_strcat ((d), (s)) +#define STRNCAT(d,s,n) acpi_cm_strncat ((d), (s), (n)) +#define STRTOUL(d,s,n) acpi_cm_strtoul ((d), (s),(n)) +#define MEMCPY(d,s,n) acpi_cm_memcpy ((d), (s), (n)) +#define MEMSET(d,v,n) acpi_cm_memset ((d), (v), (n)) +#define TOUPPER acpi_cm_to_upper +#define TOLOWER acpi_cm_to_lower #endif /* ACPI_USE_SYSTEM_CLIBRARY */ @@ -217,27 +227,90 @@ #ifdef __GNUC__ + #ifdef __ia64__ -#define _IA64 -#endif + +/* Single threaded */ +#define ACPI_APPLICATION #define ACPI_ASM_MACROS #define causeinterrupt(level) #define BREAKPOINT3 #define disable() __cli() #define enable() __sti() -#define halt() __asm__ __volatile__ ("sti; hlt":::"memory") #define wbinvd() +/*! [Begin] no source code translation */ +#include + +/* PAL_HALT[_LIGHT] */ +#define halt() ia64_pal_halt_light() + +/* PAL_HALT */ +#define safe_halt() ia64_pal_halt(1) + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + __asm__ volatile ("1: ld4 r29=%1\n" \ + ";;\n" \ + "mov ar.ccv=r29\n" \ + "mov r2=r29\n" \ + "shr.u r30=r29,1\n" \ + "and r29=-4,r29\n" \ + ";;\n" \ + "add r29=2,r29\n" \ + "and r30=1,r30\n" \ + ";;\n" \ + "add r29=r29,r30\n" \ + ";;\n" \ + "cmpxchg4.acq r30=%1,r29,ar.ccv\n" \ + ";;\n" \ + "cmp.eq p6,p7=r2,r30\n" \ + "(p7) br.dpnt.few 1b\n" \ + "cmp.gt p8,p9=3,r29\n" \ + ";;\n" \ + "(p8) mov %0=-1\n" \ + "(p9) mov %0=r0\n" \ + :"=r"(Acq):"m" __atomic_fool_gcc((GLptr)):"r2","r29","r30","memory"); \ + } while (0) + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + __asm__ volatile ("1: ld4 r29=%1\n" \ + ";;\n" \ + "mov ar.ccv=r29\n" \ + "mov r2=r29\n" \ + "and r29=-4,r29\n" \ + ";;\n" \ + "cmpxchg4.acq r30=%1,r29,ar.ccv\n" \ + ";;\n" \ + "cmp.eq p6,p7=r2,r30\n" \ + "(p7) br.dpnt.few 1b\n" \ + "and %0=1,r2\n" \ + ";;\n" \ + :"=r"(Acq):"m" __atomic_fool_gcc((GLptr)):"r2","r29","r30","memory"); \ + } while (0) +/*! [End] no source code translation !*/ + +#else /* DO IA32 */ + +#define ACPI_ASM_MACROS +#define causeinterrupt(level) +#define BREAKPOINT3 +#define disable() __cli() +#define enable() __sti() +#define halt() __asm__ __volatile__ ("sti; hlt":::"memory") +#define wbinvd() /*! [Begin] no source code translation * * A brief explanation as GNU inline assembly is a bit hairy * %0 is the output parameter in EAX ("=a") - * %1 and %2 are the input parameters in ECX ("c") and an immediate value ("i") respectively + * %1 and %2 are the input parameters in ECX ("c") + * and an immediate value ("i") respectively * All actual register references are preceded with "%%" as in "%%edx" * Immediate values in the assembly are preceded by "$" as in "$0x1" - * The final asm parameter is the non-output registers altered by the operation + * The final asm parameter are the operation altered non-output registers. */ #define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ do { \ @@ -267,12 +340,12 @@ } while(0) /*! [End] no source code translation !*/ +#endif /* IA 32 */ #endif /* __GNUC__ */ -#ifndef ACPI_ASM_MACROS - /* Unrecognized compiler, use defaults */ +#ifndef ACPI_ASM_MACROS #define ACPI_ASM_MACROS #define causeinterrupt(level) @@ -280,7 +353,6 @@ #define disable() #define enable() #define halt() - #define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq) #define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acevents.h linux/drivers/acpi/include/acevents.h --- v2.4.0-test8/linux/drivers/acpi/include/acevents.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/acevents.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,210 @@ +/****************************************************************************** + * + * Name: acevents.h - Event subcomponent prototypes and defines + * $Revision: 56 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + +#ifndef __ACEVENTS_H__ +#define __ACEVENTS_H__ + + +/* + * Acpi_evfixed - Fixed event handling + */ + +ACPI_STATUS +acpi_ev_fixed_event_initialize ( + void); + +u32 +acpi_ev_fixed_event_detect ( + void); + +u32 +acpi_ev_fixed_event_dispatch ( + u32 acpi_event); + + +/* + * Acpi_evglock - Global Lock support + */ + +ACPI_STATUS +acpi_ev_acquire_global_lock( + void); + +void +acpi_ev_release_global_lock( + void); + +ACPI_STATUS +acpi_ev_init_global_lock_handler ( + void); + + +/* + * Acpi_evgpe - GPE handling and dispatch + */ + +ACPI_STATUS +acpi_ev_gpe_initialize ( + void); + +ACPI_STATUS +acpi_ev_init_gpe_control_methods ( + void); + +u32 +acpi_ev_gpe_dispatch ( + u32 gpe_number); + +u32 +acpi_ev_gpe_detect ( + void); + + +/* + * Acpi_evnotify - Device Notify handling and dispatch + */ + +void +acpi_ev_notify_dispatch ( + ACPI_HANDLE device, + u32 notify_value); + + +/* + * Acpi_evregion - Address Space handling + */ + +ACPI_STATUS +acpi_ev_install_default_address_space_handlers ( + void); + +ACPI_STATUS +acpi_ev_address_space_dispatch ( + ACPI_OPERAND_OBJECT *region_obj, + u32 function, + u32 address, + u32 bit_width, + u32 *value); + + +ACPI_STATUS +acpi_ev_addr_handler_helper ( + ACPI_HANDLE obj_handle, + u32 level, + void *context, + void **return_value); + +void +acpi_ev_disassociate_region_from_handler( + ACPI_OPERAND_OBJECT *region_obj); + + +ACPI_STATUS +acpi_ev_associate_region_and_handler ( + ACPI_OPERAND_OBJECT *handler_obj, + ACPI_OPERAND_OBJECT *region_obj, + u8 acpi_ns_is_locked); + + +/* + * Acpi_evregini - Region initialization and setup + */ + +ACPI_STATUS +acpi_ev_system_memory_region_setup ( + ACPI_HANDLE handle, + u32 function, + void *handler_context, + void **region_context); + +ACPI_STATUS +acpi_ev_io_space_region_setup ( + ACPI_HANDLE handle, + u32 function, + void *handler_context, + void **region_context); + +ACPI_STATUS +acpi_ev_pci_config_region_setup ( + ACPI_HANDLE handle, + u32 function, + void *handler_context, + void **region_context); + +ACPI_STATUS +acpi_ev_default_region_setup ( + ACPI_HANDLE handle, + u32 function, + void *handler_context, + void **region_context); + +ACPI_STATUS +acpi_ev_initialize_region ( + ACPI_OPERAND_OBJECT *region_obj, + u8 acpi_ns_locked); + + +/* + * Evsci - SCI (System Control Interrupt) handling/dispatch + */ + +u32 +acpi_ev_install_sci_handler ( + void); + +ACPI_STATUS +acpi_ev_remove_sci_handler ( + void); + +u32 +acpi_ev_initialize_sCI ( + u32 program_sCI); + +void +acpi_ev_restore_acpi_state ( + void); + +void +acpi_ev_terminate ( + void); + + +/* Debug support */ + +#ifdef ACPI_DEBUG + +u32 +acpi_ev_sci_count ( + u32 acpi_event); + +#define DEBUG_INCREMENT_EVENT_COUNT(a) acpi_gbl_event_count[a]++; + +#else + +#define DEBUG_INCREMENT_EVENT_COUNT(a) +#endif + + +#endif /* __ACEVENTS_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acexcep.h linux/drivers/acpi/include/acexcep.h --- v2.4.0-test8/linux/drivers/acpi/include/acexcep.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/acexcep.h Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Name: acexcep.h - Exception codes returned by the ACPI subsystem + * $Revision: 35 $ * *****************************************************************************/ @@ -31,65 +31,105 @@ * Exceptions returned by external ACPI interfaces */ +#define AE_CODE_ENVIRONMENTAL 0x0000 +#define AE_CODE_PROGRAMMER 0x1000 +#define AE_CODE_ACPI_TABLES 0x2000 +#define AE_CODE_AML 0x3000 +#define AE_CODE_CONTROL 0x4000 +#define AE_CODE_MASK 0xF000 + + #define ACPI_SUCCESS(a) (!(a)) #define ACPI_FAILURE(a) (a) + #define AE_OK (ACPI_STATUS) 0x0000 -#define AE_CTRL_RETURN_VALUE (ACPI_STATUS) 0x0001 -#define AE_CTRL_PENDING (ACPI_STATUS) 0x0002 -#define AE_CTRL_TERMINATE (ACPI_STATUS) 0x0003 -#define AE_CTRL_TRUE (ACPI_STATUS) 0x0004 -#define AE_CTRL_FALSE (ACPI_STATUS) 0x0005 -#define AE_CTRL_DEPTH (ACPI_STATUS) 0x0006 -#define AE_CTRL_RESERVED (ACPI_STATUS) 0x0007 -#define AE_AML_ERROR (ACPI_STATUS) 0x0008 -#define AE_AML_PARSE (ACPI_STATUS) 0x0009 -#define AE_AML_BAD_OPCODE (ACPI_STATUS) 0x000A -#define AE_AML_NO_OPERAND (ACPI_STATUS) 0x000B -#define AE_AML_OPERAND_TYPE (ACPI_STATUS) 0x000C -#define AE_AML_OPERAND_VALUE (ACPI_STATUS) 0x000D -#define AE_AML_UNINITIALIZED_LOCAL (ACPI_STATUS) 0x000E -#define AE_AML_UNINITIALIZED_ARG (ACPI_STATUS) 0x000F -#define AE_AML_UNINITIALIZED_ELEMENT (ACPI_STATUS) 0x0010 -#define AE_AML_NUMERIC_OVERFLOW (ACPI_STATUS) 0x0011 -#define AE_AML_REGION_LIMIT (ACPI_STATUS) 0x0012 -#define AE_AML_BUFFER_LIMIT (ACPI_STATUS) 0x0013 -#define AE_AML_PACKAGE_LIMIT (ACPI_STATUS) 0x0014 -#define AE_AML_DIVIDE_BY_ZERO (ACPI_STATUS) 0x0015 -#define AE_AML_BAD_NAME (ACPI_STATUS) 0x0016 -#define AE_AML_NAME_NOT_FOUND (ACPI_STATUS) 0x0017 -#define AE_AML_INTERNAL (ACPI_STATUS) 0x0018 -#define AE_AML_RESERVED (ACPI_STATUS) 0x0019 -#define AE_ERROR (ACPI_STATUS) 0x001A -#define AE_NO_ACPI_TABLES (ACPI_STATUS) 0x001B -#define AE_NO_NAMESPACE (ACPI_STATUS) 0x001C -#define AE_NO_MEMORY (ACPI_STATUS) 0x001D -#define AE_BAD_SIGNATURE (ACPI_STATUS) 0x001E -#define AE_BAD_HEADER (ACPI_STATUS) 0x001F -#define AE_BAD_CHECKSUM (ACPI_STATUS) 0x0020 -#define AE_BAD_PARAMETER (ACPI_STATUS) 0x0021 -#define AE_BAD_CHARACTER (ACPI_STATUS) 0x0022 -#define AE_BAD_PATHNAME (ACPI_STATUS) 0x0023 -#define AE_BAD_DATA (ACPI_STATUS) 0x0024 -#define AE_BAD_ADDRESS (ACPI_STATUS) 0x0025 -#define AE_NOT_FOUND (ACPI_STATUS) 0x0026 -#define AE_NOT_EXIST (ACPI_STATUS) 0x0027 -#define AE_EXIST (ACPI_STATUS) 0x0028 -#define AE_TYPE (ACPI_STATUS) 0x0029 -#define AE_NULL_OBJECT (ACPI_STATUS) 0x002A -#define AE_NULL_ENTRY (ACPI_STATUS) 0x002B -#define AE_BUFFER_OVERFLOW (ACPI_STATUS) 0x002C -#define AE_STACK_OVERFLOW (ACPI_STATUS) 0x002D -#define AE_STACK_UNDERFLOW (ACPI_STATUS) 0x002E -#define AE_NOT_IMPLEMENTED (ACPI_STATUS) 0x002F -#define AE_VERSION_MISMATCH (ACPI_STATUS) 0x0030 -#define AE_SUPPORT (ACPI_STATUS) 0x0031 -#define AE_SHARE (ACPI_STATUS) 0x0032 -#define AE_LIMIT (ACPI_STATUS) 0x0033 -#define AE_TIME (ACPI_STATUS) 0x0034 -#define AE_UNKNOWN_STATUS (ACPI_STATUS) 0x0035 -#define ACPI_MAX_STATUS (ACPI_STATUS) 0x0035 -#define ACPI_NUM_STATUS (ACPI_STATUS) 0x0036 + +/* + * Environmental exceptions + */ +#define AE_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_ACPI_TABLES (ACPI_STATUS) (0x0002 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_NAMESPACE (ACPI_STATUS) (0x0003 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_MEMORY (ACPI_STATUS) (0x0004 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_FOUND (ACPI_STATUS) (0x0005 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_EXIST (ACPI_STATUS) (0x0006 | AE_CODE_ENVIRONMENTAL) +#define AE_EXIST (ACPI_STATUS) (0x0007 | AE_CODE_ENVIRONMENTAL) +#define AE_TYPE (ACPI_STATUS) (0x0008 | AE_CODE_ENVIRONMENTAL) +#define AE_NULL_OBJECT (ACPI_STATUS) (0x0009 | AE_CODE_ENVIRONMENTAL) +#define AE_NULL_ENTRY (ACPI_STATUS) (0x000A | AE_CODE_ENVIRONMENTAL) +#define AE_BUFFER_OVERFLOW (ACPI_STATUS) (0x000B | AE_CODE_ENVIRONMENTAL) +#define AE_STACK_OVERFLOW (ACPI_STATUS) (0x000C | AE_CODE_ENVIRONMENTAL) +#define AE_STACK_UNDERFLOW (ACPI_STATUS) (0x000D | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_IMPLEMENTED (ACPI_STATUS) (0x000E | AE_CODE_ENVIRONMENTAL) +#define AE_VERSION_MISMATCH (ACPI_STATUS) (0x000F | AE_CODE_ENVIRONMENTAL) +#define AE_SUPPORT (ACPI_STATUS) (0x0010 | AE_CODE_ENVIRONMENTAL) +#define AE_SHARE (ACPI_STATUS) (0x0011 | AE_CODE_ENVIRONMENTAL) +#define AE_LIMIT (ACPI_STATUS) (0x0012 | AE_CODE_ENVIRONMENTAL) +#define AE_TIME (ACPI_STATUS) (0x0013 | AE_CODE_ENVIRONMENTAL) +#define AE_UNKNOWN_STATUS (ACPI_STATUS) (0x0014 | AE_CODE_ENVIRONMENTAL) + +#define AE_CODE_ENV_MAX 0x0014 + +/* + * Programmer exceptions + */ +#define AE_BAD_PARAMETER (ACPI_STATUS) (0x0001 | AE_CODE_PROGRAMMER) +#define AE_BAD_CHARACTER (ACPI_STATUS) (0x0002 | AE_CODE_PROGRAMMER) +#define AE_BAD_PATHNAME (ACPI_STATUS) (0x0003 | AE_CODE_PROGRAMMER) +#define AE_BAD_DATA (ACPI_STATUS) (0x0004 | AE_CODE_PROGRAMMER) +#define AE_BAD_ADDRESS (ACPI_STATUS) (0x0005 | AE_CODE_PROGRAMMER) + +#define AE_CODE_PGM_MAX 0x0005 + + +/* + * Acpi table exceptions + */ +#define AE_BAD_SIGNATURE (ACPI_STATUS) (0x0001 | AE_CODE_ACPI_TABLES) +#define AE_BAD_HEADER (ACPI_STATUS) (0x0002 | AE_CODE_ACPI_TABLES) +#define AE_BAD_CHECKSUM (ACPI_STATUS) (0x0003 | AE_CODE_ACPI_TABLES) + +#define AE_CODE_TBL_MAX 0x0003 + + +/* + * AML exceptions. These are caused by problems with + * the actual AML byte stream + */ +#define AE_AML_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_AML) +#define AE_AML_PARSE (ACPI_STATUS) (0x0002 | AE_CODE_AML) +#define AE_AML_BAD_OPCODE (ACPI_STATUS) (0x0003 | AE_CODE_AML) +#define AE_AML_NO_OPERAND (ACPI_STATUS) (0x0004 | AE_CODE_AML) +#define AE_AML_OPERAND_TYPE (ACPI_STATUS) (0x0005 | AE_CODE_AML) +#define AE_AML_OPERAND_VALUE (ACPI_STATUS) (0x0006 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_LOCAL (ACPI_STATUS) (0x0007 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ARG (ACPI_STATUS) (0x0008 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ELEMENT (ACPI_STATUS) (0x0009 | AE_CODE_AML) +#define AE_AML_NUMERIC_OVERFLOW (ACPI_STATUS) (0x000A | AE_CODE_AML) +#define AE_AML_REGION_LIMIT (ACPI_STATUS) (0x000B | AE_CODE_AML) +#define AE_AML_BUFFER_LIMIT (ACPI_STATUS) (0x000C | AE_CODE_AML) +#define AE_AML_PACKAGE_LIMIT (ACPI_STATUS) (0x000D | AE_CODE_AML) +#define AE_AML_DIVIDE_BY_ZERO (ACPI_STATUS) (0x000E | AE_CODE_AML) +#define AE_AML_BAD_NAME (ACPI_STATUS) (0x000F | AE_CODE_AML) +#define AE_AML_NAME_NOT_FOUND (ACPI_STATUS) (0x0010 | AE_CODE_AML) +#define AE_AML_INTERNAL (ACPI_STATUS) (0x0011 | AE_CODE_AML) + +#define AE_CODE_AML_MAX 0x0011 + +/* + * Internal exceptions used for control + */ +#define AE_CTRL_RETURN_VALUE (ACPI_STATUS) (0x0001 | AE_CODE_CONTROL) +#define AE_CTRL_PENDING (ACPI_STATUS) (0x0002 | AE_CODE_CONTROL) +#define AE_CTRL_TERMINATE (ACPI_STATUS) (0x0003 | AE_CODE_CONTROL) +#define AE_CTRL_TRUE (ACPI_STATUS) (0x0004 | AE_CODE_CONTROL) +#define AE_CTRL_FALSE (ACPI_STATUS) (0x0005 | AE_CODE_CONTROL) +#define AE_CTRL_DEPTH (ACPI_STATUS) (0x0006 | AE_CODE_CONTROL) +#define AE_CTRL_END (ACPI_STATUS) (0x0007 | AE_CODE_CONTROL) +#define AE_CTRL_TRANSFER (ACPI_STATUS) (0x0008 | AE_CODE_CONTROL) + +#define AE_CODE_CTRL_MAX 0x0008 #ifdef DEFINE_ACPI_GLOBALS @@ -98,46 +138,13 @@ * String versions of the exception codes above * These strings must match the corresponding defines exactly */ -static char *acpi_gbl_exception_names[] = +static NATIVE_CHAR *acpi_gbl_exception_names_env[] = { "AE_OK", - "AE_CTRL_RETURN_VALUE", - "AE_CTRL_PENDING", - "AE_CTRL_TERMINATE", - "AE_CTRL_TRUE", - "AE_CTRL_FALSE", - "AE_CTRL_DEPTH", - "AE_CTRL_RESERVED", - "AE_AML_ERROR", - "AE_AML_PARSE", - "AE_AML_BAD_OPCODE", - "AE_AML_NO_OPERAND", - "AE_AML_OPERAND_TYPE", - "AE_AML_OPERAND_VALUE", - "AE_AML_UNINITIALIZED_LOCAL", - "AE_AML_UNINITIALIZED_ARG", - "AE_AML_UNINITIALIZED_ELEMENT", - "AE_AML_NUMERIC_OVERFLOW", - "AE_AML_REGION_LIMIT", - "AE_AML_BUFFER_LIMIT", - "AE_AML_PACKAGE_LIMIT", - "AE_AML_DIVIDE_BY_ZERO", - "AE_AML_BAD_NAME", - "AE_AML_NAME_NOT_FOUND", - "AE_AML_INTERNAL", - "AE_AML_RESERVED", "AE_ERROR", "AE_NO_ACPI_TABLES", "AE_NO_NAMESPACE", "AE_NO_MEMORY", - "AE_BAD_SIGNATURE", - "AE_BAD_HEADER", - "AE_BAD_CHECKSUM", - "AE_BAD_PARAMETER", - "AE_BAD_CHARACTER", - "AE_BAD_PATHNAME", - "AE_BAD_DATA", - "AE_BAD_ADDRESS", "AE_NOT_FOUND", "AE_NOT_EXIST", "AE_EXIST", @@ -153,8 +160,58 @@ "AE_SHARE", "AE_LIMIT", "AE_TIME", - "AE_UNKNOWN_STATUS" + "AE_UNKNOWN_STATUS", +}; + +static NATIVE_CHAR *acpi_gbl_exception_names_pgm[] = +{ + "AE_BAD_PARAMETER", + "AE_BAD_CHARACTER", + "AE_BAD_PATHNAME", + "AE_BAD_DATA", + "AE_BAD_ADDRESS", +}; + +static NATIVE_CHAR *acpi_gbl_exception_names_tbl[] = +{ + "AE_BAD_SIGNATURE", + "AE_BAD_HEADER", + "AE_BAD_CHECKSUM", +}; + +static NATIVE_CHAR *acpi_gbl_exception_names_aml[] = +{ + "AE_AML_ERROR", + "AE_AML_PARSE", + "AE_AML_BAD_OPCODE", + "AE_AML_NO_OPERAND", + "AE_AML_OPERAND_TYPE", + "AE_AML_OPERAND_VALUE", + "AE_AML_UNINITIALIZED_LOCAL", + "AE_AML_UNINITIALIZED_ARG", + "AE_AML_UNINITIALIZED_ELEMENT", + "AE_AML_NUMERIC_OVERFLOW", + "AE_AML_REGION_LIMIT", + "AE_AML_BUFFER_LIMIT", + "AE_AML_PACKAGE_LIMIT", + "AE_AML_DIVIDE_BY_ZERO", + "AE_AML_BAD_NAME", + "AE_AML_NAME_NOT_FOUND", + "AE_AML_INTERNAL", +}; + +static NATIVE_CHAR *acpi_gbl_exception_names_ctrl[] = +{ + "AE_CTRL_RETURN_VALUE", + "AE_CTRL_PENDING", + "AE_CTRL_TERMINATE", + "AE_CTRL_TRUE", + "AE_CTRL_FALSE", + "AE_CTRL_DEPTH", + "AE_CTRL_END", + "AE_CTRL_TRANSFER", }; + #endif /* DEFINE_ACPI_GLOBALS */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acglobal.h linux/drivers/acpi/include/acglobal.h --- v2.4.0-test8/linux/drivers/acpi/include/acglobal.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/acglobal.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,320 @@ +/****************************************************************************** + * + * Name: acglobal.h - Declarations for global variables + * $Revision: 84 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + +#ifndef __ACGLOBAL_H__ +#define __ACGLOBAL_H__ + + +/* + * Ensure that the globals are actually defined only once. + * + * The use of these defines allows a single list of globals (here) in order + * to simplify maintenance of the code. + */ +#ifdef DEFINE_ACPI_GLOBALS +#define ACPI_EXTERN +#else +#define ACPI_EXTERN extern +#endif + + +extern NATIVE_CHAR *msg_acpi_error_break; + +/***************************************************************************** + * + * Debug support + * + ****************************************************************************/ + +/* Runtime configuration of debug print levels */ + +extern u32 acpi_dbg_level; +extern u32 acpi_dbg_layer; + + +/* Procedure nesting level for debug output */ + +extern u32 acpi_gbl_nesting_level; + + +/***************************************************************************** + * + * ACPI Table globals + * + ****************************************************************************/ + +/* + * Table pointers. + * Although these pointers are somewhat redundant with the global Acpi_table, + * they are convenient because they are typed pointers. + * + * These tables are single-table only; meaning that there can be at most one + * of each in the system. Each global points to the actual table. + * + */ +ACPI_EXTERN ROOT_SYSTEM_DESCRIPTOR_POINTER *acpi_gbl_RSDP; +ACPI_EXTERN ROOT_SYSTEM_DESCRIPTION_TABLE *acpi_gbl_RSDT; +ACPI_EXTERN FIRMWARE_ACPI_CONTROL_STRUCTURE *acpi_gbl_FACS; +ACPI_EXTERN FIXED_ACPI_DESCRIPTION_TABLE *acpi_gbl_FACP; +ACPI_EXTERN APIC_TABLE *acpi_gbl_APIC; +ACPI_EXTERN ACPI_TABLE_HEADER *acpi_gbl_DSDT; +ACPI_EXTERN ACPI_TABLE_HEADER *acpi_gbl_SBST; +/* + * Since there may be multiple SSDTs and PSDTS, a single pointer is not + * sufficient; Therefore, there isn't one! + */ + + +/* + * ACPI Table info arrays + */ +extern ACPI_TABLE_DESC acpi_gbl_acpi_tables[NUM_ACPI_TABLES]; +extern ACPI_TABLE_SUPPORT acpi_gbl_acpi_table_data[NUM_ACPI_TABLES]; + +/* + * Predefined mutex objects. This array contains the + * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. + * (The table maps local handles to the real OS handles) + */ +ACPI_EXTERN ACPI_MUTEX_INFO acpi_gbl_acpi_mutex_info [NUM_MTX]; +extern ACPI_INIT_DATA acpi_gbl_acpi_init_data; + + +/***************************************************************************** + * + * Miscellaneous globals + * + ****************************************************************************/ + + +ACPI_EXTERN u8 *acpi_gbl_gpe0enable_register_save; +ACPI_EXTERN u8 *acpi_gbl_gpe1_enable_register_save; +ACPI_EXTERN ACPI_WALK_STATE *acpi_gbl_breakpoint_walk; +ACPI_EXTERN ACPI_GENERIC_STATE *acpi_gbl_generic_state_cache; +ACPI_EXTERN ACPI_PARSE_OBJECT *acpi_gbl_parse_cache; +ACPI_EXTERN ACPI_PARSE2_OBJECT *acpi_gbl_ext_parse_cache; +ACPI_EXTERN ACPI_OPERAND_OBJECT *acpi_gbl_object_cache; +ACPI_EXTERN ACPI_WALK_STATE *acpi_gbl_walk_state_cache; +ACPI_EXTERN ACPI_HANDLE acpi_gbl_global_lock_semaphore; + + +ACPI_EXTERN u32 acpi_gbl_global_lock_thread_count; +ACPI_EXTERN u32 acpi_gbl_restore_acpi_chipset; +ACPI_EXTERN u32 acpi_gbl_original_mode; +ACPI_EXTERN u32 acpi_gbl_edge_level_save; +ACPI_EXTERN u32 acpi_gbl_irq_enable_save; +ACPI_EXTERN u32 acpi_gbl_rsdp_original_location; + +ACPI_EXTERN u32 acpi_gbl_state_cache_requests; +ACPI_EXTERN u32 acpi_gbl_state_cache_hits; +ACPI_EXTERN u32 acpi_gbl_parse_cache_requests; +ACPI_EXTERN u32 acpi_gbl_parse_cache_hits; +ACPI_EXTERN u32 acpi_gbl_ext_parse_cache_requests; +ACPI_EXTERN u32 acpi_gbl_ext_parse_cache_hits; +ACPI_EXTERN u32 acpi_gbl_object_cache_requests; +ACPI_EXTERN u32 acpi_gbl_object_cache_hits; +ACPI_EXTERN u32 acpi_gbl_walk_state_cache_requests; +ACPI_EXTERN u32 acpi_gbl_walk_state_cache_hits; +ACPI_EXTERN u32 acpi_gbl_ns_lookup_count; +ACPI_EXTERN u32 acpi_gbl_ps_find_count; + + +ACPI_EXTERN u16 acpi_gbl_generic_state_cache_depth; +ACPI_EXTERN u16 acpi_gbl_parse_cache_depth; +ACPI_EXTERN u16 acpi_gbl_ext_parse_cache_depth; +ACPI_EXTERN u16 acpi_gbl_object_cache_depth; +ACPI_EXTERN u16 acpi_gbl_walk_state_cache_depth; +ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; +ACPI_EXTERN u16 acpi_gbl_next_table_owner_id; +ACPI_EXTERN u16 acpi_gbl_next_method_owner_id; + +ACPI_EXTERN u8 acpi_gbl_debugger_configuration; +ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; +ACPI_EXTERN u8 acpi_gbl_global_lock_set; /* TBD: [Restructure] OBSOLETE?? */ +ACPI_EXTERN u8 acpi_gbl_step_to_next_call; +ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present; + + +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER acpi_gbl_drv_notify; +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER acpi_gbl_sys_notify; + + +extern u8 acpi_gbl_shutdown; +extern u32 acpi_gbl_system_flags; +extern u32 acpi_gbl_startup_flags; + + +/***************************************************************************** + * + * Namespace globals + * + ****************************************************************************/ + +#define NUM_NS_TYPES INTERNAL_TYPE_INVALID+1 +#define NUM_PREDEFINED_NAMES 9 + + +ACPI_EXTERN ACPI_NAMESPACE_NODE acpi_gbl_root_node_struct; +ACPI_EXTERN ACPI_NAMESPACE_NODE *acpi_gbl_root_node; + +extern u8 acpi_gbl_ns_properties[NUM_NS_TYPES]; +extern PREDEFINED_NAMES acpi_gbl_pre_defined_names [NUM_PREDEFINED_NAMES]; + + +/* Used to detect memory leaks (DEBUG ONLY) */ + +#ifdef ACPI_DEBUG +ACPI_EXTERN ALLOCATION_INFO *acpi_gbl_head_alloc_ptr; +ACPI_EXTERN ALLOCATION_INFO *acpi_gbl_tail_alloc_ptr; +#endif + + +/***************************************************************************** + * + * Interpreter globals + * + ****************************************************************************/ + + +ACPI_EXTERN u32 acpi_gbl_when_to_parse_methods; +ACPI_EXTERN ACPI_WALK_LIST *acpi_gbl_current_walk_list; + +/* Base of AML block, and pointer to current location in it */ + +ACPI_EXTERN u8 *acpi_gbl_Pcode_base; +ACPI_EXTERN u8 *acpi_gbl_Pcode; + +/* + * Length of AML block, and remaining length of current package. + */ +ACPI_EXTERN u32 acpi_gbl_Pcode_block_len; +ACPI_EXTERN u32 acpi_gbl_Pcode_len; + +ACPI_EXTERN u32 acpi_gbl_buf_seq; /* Counts allocated Buffer descriptors */ +ACPI_EXTERN u32 acpi_gbl_node_err; /* Indicate if inc_error should be called */ + +/* + * Handle to the last method found - used during pass1 of load + */ +ACPI_EXTERN ACPI_HANDLE acpi_gbl_last_method; + +/* + * Table of Address Space handlers + */ + +ACPI_EXTERN ACPI_ADDRESS_SPACE_INFO acpi_gbl_address_spaces[ACPI_NUM_ADDRESS_SPACES]; + + +/* Control method single step flag */ + +ACPI_EXTERN u8 acpi_gbl_cm_single_step; + + +/***************************************************************************** + * + * Parser globals + * + ****************************************************************************/ + +ACPI_EXTERN ACPI_PARSE_OBJECT *acpi_gbl_parsed_namespace_root; + +extern ACPI_OPCODE_INFO acpi_gbl_aml_op_info[]; +extern u8 acpi_gbl_aml_op_info_index[256]; + + +/***************************************************************************** + * + * Hardware globals + * + ****************************************************************************/ + +extern ACPI_C_STATE_HANDLER acpi_hw_cx_handlers[MAX_CX_STATES]; +extern u32 acpi_hw_active_cx_state; + + +/***************************************************************************** + * + * Event globals + * + ****************************************************************************/ + +ACPI_EXTERN ACPI_FIXED_EVENT_INFO acpi_gbl_fixed_event_handlers[NUM_FIXED_EVENTS]; + +ACPI_EXTERN ACPI_HANDLE acpi_gbl_gpe_obj_handle; +ACPI_EXTERN u32 acpi_gbl_gpe_register_count; +ACPI_EXTERN ACPI_GPE_REGISTERS *acpi_gbl_gpe_registers; +ACPI_EXTERN ACPI_GPE_LEVEL_INFO *acpi_gbl_gpe_info; + +/* + * Gpe validation and translation table + * Indexed by the GPE number, returns GPE_INVALID if the GPE is not supported. + * Otherwise, returns a valid index into the global GPE table. + * + * This table is needed because the GPE numbers supported by block 1 do not + * have to be contiguous with the GPE numbers supported by block 0. + */ +ACPI_EXTERN u8 acpi_gbl_gpe_valid [NUM_GPE]; + +/* Acpi_event counter for debug only */ + +#ifdef ACPI_DEBUG +ACPI_EXTERN u32 acpi_gbl_event_count[NUM_FIXED_EVENTS]; +#endif + + +/***************************************************************************** + * + * Debugger globals + * + ****************************************************************************/ + +ACPI_EXTERN u8 acpi_gbl_method_executing; +ACPI_EXTERN u8 acpi_gbl_db_terminate_threads; + + +/* Memory allocation metrics - Debug Only! */ + +#ifdef ACPI_DEBUG + +ACPI_EXTERN u32 acpi_gbl_current_alloc_size; +ACPI_EXTERN u32 acpi_gbl_current_alloc_count; +ACPI_EXTERN u32 acpi_gbl_running_alloc_size; +ACPI_EXTERN u32 acpi_gbl_running_alloc_count; +ACPI_EXTERN u32 acpi_gbl_max_concurrent_alloc_size; +ACPI_EXTERN u32 acpi_gbl_max_concurrent_alloc_count; +ACPI_EXTERN u32 acpi_gbl_current_object_count; +ACPI_EXTERN u32 acpi_gbl_current_object_size; +ACPI_EXTERN u32 acpi_gbl_max_concurrent_object_count; +ACPI_EXTERN u32 acpi_gbl_max_concurrent_object_size; +ACPI_EXTERN u32 acpi_gbl_running_object_count; +ACPI_EXTERN u32 acpi_gbl_running_object_size; +ACPI_EXTERN u32 acpi_gbl_current_node_count; +ACPI_EXTERN u32 acpi_gbl_current_node_size; +ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count; + +#endif + + +#endif /* __ACGLOBAL_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/achware.h linux/drivers/acpi/include/achware.h --- v2.4.0-test8/linux/drivers/acpi/include/achware.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/achware.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,169 @@ +/****************************************************************************** + * + * Name: achware.h -- hardware specific interfaces + * $Revision: 41 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + +#ifndef __ACHWARE_H__ +#define __ACHWARE_H__ + + +/* Prototypes */ + + +ACPI_STATUS +acpi_hw_initialize( + void); + +ACPI_STATUS +acpi_hw_shutdown( + void); + +ACPI_STATUS +acpi_hw_initialize_system_info( + void); + +ACPI_STATUS +acpi_hw_set_mode ( + u32 mode); + +u32 +acpi_hw_get_mode ( + void); + +u32 +acpi_hw_get_mode_capabilities ( + void); + +/* Register I/O Prototypes */ + +u32 +acpi_hw_register_access ( + NATIVE_UINT read_write, + u8 use_lock, + u32 register_id, ... /* DWORD Value */); + +void +acpi_hw_clear_acpi_status ( + void); + + +/* GPE support */ + +void +acpi_hw_enable_gpe ( + u32 gpe_index); + +void +acpi_hw_disable_gpe ( + u32 gpe_index); + +void +acpi_hw_clear_gpe ( + u32 gpe_index); + +void +acpi_hw_get_gpe_status ( + u32 gpe_number, + ACPI_EVENT_STATUS *event_status); + +/* Sleep Prototypes */ + +ACPI_STATUS +acpi_hw_obtain_sleep_type_register_data ( + u8 sleep_state, + u8 *slp_typ_a, + u8 *slp_typ_b); + + +/* Cx State Prototypes */ + +ACPI_STATUS +acpi_hw_enter_c1( + ACPI_IO_ADDRESS pblk_address, + u32 *pm_timer_ticks); + +ACPI_STATUS +acpi_hw_enter_c2( + ACPI_IO_ADDRESS pblk_address, + u32 *pm_timer_ticks); + +ACPI_STATUS +acpi_hw_enter_c3( + ACPI_IO_ADDRESS pblk_address, + u32 *pm_timer_ticks); + +ACPI_STATUS +acpi_hw_enter_cx ( + ACPI_IO_ADDRESS pblk_address, + u32 *pm_timer_ticks); + +ACPI_STATUS +acpi_hw_set_cx ( + u32 cx_state); + +ACPI_STATUS +acpi_hw_get_cx_info ( + u32 cx_states[]); + + +/* Throttling Prototypes */ + +void +acpi_hw_enable_throttling ( + ACPI_IO_ADDRESS pblk_address); + +void +acpi_hw_disable_throttling ( + ACPI_IO_ADDRESS pblk_address); + +u32 +acpi_hw_get_duty_cycle ( + u8 duty_offset, + ACPI_IO_ADDRESS pblk_address, + u32 num_throttle_states); + +void +acpi_hw_program_duty_cycle ( + u8 duty_offset, + u32 duty_cycle, + ACPI_IO_ADDRESS pblk_address, + u32 num_throttle_states); + +NATIVE_UINT +acpi_hw_local_pow ( + NATIVE_UINT x, + NATIVE_UINT y); + + +/* ACPI Timer prototypes */ + +u32 +acpi_hw_pmt_ticks ( + void); + +u32 +acpi_hw_pmt_resolution ( + void); + + +#endif /* __ACHWARE_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acinterp.h linux/drivers/acpi/include/acinterp.h --- v2.4.0-test8/linux/drivers/acpi/include/acinterp.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/acinterp.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,526 @@ +/****************************************************************************** + * + * Name: acinterp.h - Interpreter subcomponent prototypes and defines + * $Revision: 79 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + +#ifndef __ACINTERP_H__ +#define __ACINTERP_H__ + + +#define WALK_OPERANDS &(walk_state->operands [walk_state->num_operands -1]) + + +/* Interpreter constants */ + +#define AML_END_OF_BLOCK -1 +#define PUSH_PKG_LENGTH 1 +#define DO_NOT_PUSH_PKG_LENGTH 0 + + +#define STACK_TOP 0 +#define STACK_BOTTOM (u32) -1 + +/* Constants for global "When_to_parse_methods" */ + +#define METHOD_PARSE_AT_INIT 0x0 +#define METHOD_PARSE_JUST_IN_TIME 0x1 +#define METHOD_DELETE_AT_COMPLETION 0x2 + + +ACPI_STATUS +acpi_aml_resolve_operands ( + u16 opcode, + ACPI_OPERAND_OBJECT **stack_ptr, + ACPI_WALK_STATE *walk_state); + + +/* + * amxface - External interpreter interfaces + */ + +ACPI_STATUS +acpi_aml_load_table ( + ACPI_TABLE_TYPE table_id); + +ACPI_STATUS +acpi_aml_execute_method ( + ACPI_NAMESPACE_NODE *method_node, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **return_obj_desc); + + +/* + * amfield - ACPI AML (p-code) execution - field manipulation + */ + + +ACPI_STATUS +acpi_aml_read_field ( + ACPI_OPERAND_OBJECT *obj_desc, + void *buffer, + u32 buffer_length, + u32 byte_length, + u32 datum_length, + u32 bit_granularity, + u32 byte_granularity); + +ACPI_STATUS +acpi_aml_write_field ( + ACPI_OPERAND_OBJECT *obj_desc, + void *buffer, + u32 buffer_length, + u32 byte_length, + u32 datum_length, + u32 bit_granularity, + u32 byte_granularity); + +ACPI_STATUS +acpi_aml_setup_field ( + ACPI_OPERAND_OBJECT *obj_desc, + ACPI_OPERAND_OBJECT *rgn_desc, + u32 field_bit_width); + +ACPI_STATUS +acpi_aml_read_field_data ( + ACPI_OPERAND_OBJECT *obj_desc, + u32 field_byte_offset, + u32 field_bit_width, + u32 *value); + +ACPI_STATUS +acpi_aml_access_named_field ( + u32 mode, + ACPI_HANDLE named_field, + void *buffer, + u32 length); + +/* + * ammisc - ACPI AML (p-code) execution - specific opcodes + */ + +ACPI_STATUS +acpi_aml_exec_create_field ( + u16 opcode, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_reconfiguration ( + u16 opcode, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_fatal ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_index ( + ACPI_WALK_STATE *walk_state, + ACPI_OPERAND_OBJECT **return_desc); + +ACPI_STATUS +acpi_aml_exec_match ( + ACPI_WALK_STATE *walk_state, + ACPI_OPERAND_OBJECT **return_desc); + +ACPI_STATUS +acpi_aml_exec_create_mutex ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_create_processor ( + ACPI_PARSE_OBJECT *op, + ACPI_HANDLE processor_nTE); + +ACPI_STATUS +acpi_aml_exec_create_power_resource ( + ACPI_PARSE_OBJECT *op, + ACPI_HANDLE processor_nTE); + +ACPI_STATUS +acpi_aml_exec_create_region ( + u8 *aml_ptr, + u32 acpi_aml_length, + u32 region_space, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_create_event ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_create_alias ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_create_method ( + u8 *aml_ptr, + u32 acpi_aml_length, + u32 method_flags, + ACPI_HANDLE method); + + +/* + * amprep - ACPI AML (p-code) execution - prep utilities + */ + +ACPI_STATUS +acpi_aml_prep_def_field_value ( + ACPI_NAMESPACE_NODE *node, + ACPI_HANDLE region, + u8 field_flags, + u8 field_attribute, + u32 field_position, + u32 field_length); + +ACPI_STATUS +acpi_aml_prep_bank_field_value ( + ACPI_NAMESPACE_NODE *node, + ACPI_HANDLE region, + ACPI_HANDLE bank_reg, + u32 bank_val, + u8 field_flags, + u8 field_attribute, + u32 field_position, + u32 field_length); + +ACPI_STATUS +acpi_aml_prep_index_field_value ( + ACPI_NAMESPACE_NODE *node, + ACPI_HANDLE index_reg, + ACPI_HANDLE data_reg, + u8 field_flags, + u8 field_attribute, + u32 field_position, + u32 field_length); + + +/* + * amsystem - Interface to OS services + */ + +u16 +acpi_aml_system_thread_id ( + void); + +ACPI_STATUS +acpi_aml_system_do_notify_op ( + ACPI_OPERAND_OBJECT *value, + ACPI_OPERAND_OBJECT *obj_desc); + +void +acpi_aml_system_do_suspend( + u32 time); + +void +acpi_aml_system_do_stall ( + u32 time); + +ACPI_STATUS +acpi_aml_system_acquire_mutex( + ACPI_OPERAND_OBJECT *time, + ACPI_OPERAND_OBJECT *obj_desc); + +ACPI_STATUS +acpi_aml_system_release_mutex( + ACPI_OPERAND_OBJECT *obj_desc); + +ACPI_STATUS +acpi_aml_system_signal_event( + ACPI_OPERAND_OBJECT *obj_desc); + +ACPI_STATUS +acpi_aml_system_wait_event( + ACPI_OPERAND_OBJECT *time, + ACPI_OPERAND_OBJECT *obj_desc); + +ACPI_STATUS +acpi_aml_system_reset_event( + ACPI_OPERAND_OBJECT *obj_desc); + +ACPI_STATUS +acpi_aml_system_wait_semaphore ( + ACPI_HANDLE semaphore, + u32 timeout); + + +/* + * ammonadic - ACPI AML (p-code) execution, monadic operators + */ + +ACPI_STATUS +acpi_aml_exec_monadic1 ( + u16 opcode, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_monadic2 ( + u16 opcode, + ACPI_WALK_STATE *walk_state, + ACPI_OPERAND_OBJECT **return_desc); + +ACPI_STATUS +acpi_aml_exec_monadic2_r ( + u16 opcode, + ACPI_WALK_STATE *walk_state, + ACPI_OPERAND_OBJECT **return_desc); + + +/* + * amdyadic - ACPI AML (p-code) execution, dyadic operators + */ + +ACPI_STATUS +acpi_aml_exec_dyadic1 ( + u16 opcode, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_dyadic2 ( + u16 opcode, + ACPI_WALK_STATE *walk_state, + ACPI_OPERAND_OBJECT **return_desc); + +ACPI_STATUS +acpi_aml_exec_dyadic2_r ( + u16 opcode, + ACPI_WALK_STATE *walk_state, + ACPI_OPERAND_OBJECT **return_desc); + +ACPI_STATUS +acpi_aml_exec_dyadic2_s ( + u16 opcode, + ACPI_WALK_STATE *walk_state, + ACPI_OPERAND_OBJECT **return_desc); + + +/* + * amresolv - Object resolution and get value functions + */ + +ACPI_STATUS +acpi_aml_resolve_to_value ( + ACPI_OPERAND_OBJECT **stack_ptr, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_resolve_node_to_value ( + ACPI_NAMESPACE_NODE **stack_ptr); + +ACPI_STATUS +acpi_aml_resolve_object_to_value ( + ACPI_OPERAND_OBJECT **stack_ptr, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_get_field_unit_value ( + ACPI_OPERAND_OBJECT *field_desc, + ACPI_OPERAND_OBJECT *result_desc); + + +/* + * amdump - Scanner debug output routines + */ + +void +acpi_aml_show_hex_value ( + u32 byte_count, + u8 *aml_ptr, + u32 lead_space); + + +ACPI_STATUS +acpi_aml_dump_operand ( + ACPI_OPERAND_OBJECT *entry_desc); + +void +acpi_aml_dump_operands ( + ACPI_OPERAND_OBJECT **operands, + OPERATING_MODE interpreter_mode, + NATIVE_CHAR *ident, + u32 num_levels, + NATIVE_CHAR *note, + NATIVE_CHAR *module_name, + u32 line_number); + +void +acpi_aml_dump_object_descriptor ( + ACPI_OPERAND_OBJECT *object, + u32 flags); + + +void +acpi_aml_dump_node ( + ACPI_NAMESPACE_NODE *node, + u32 flags); + + +/* + * amnames - interpreter/scanner name load/execute + */ + +NATIVE_CHAR * +acpi_aml_allocate_name_string ( + u32 prefix_count, + u32 num_name_segs); + +u32 +acpi_aml_good_char ( + u32 character); + +ACPI_STATUS +acpi_aml_exec_name_segment ( + u8 **in_aml_address, + NATIVE_CHAR *name_string); + +ACPI_STATUS +acpi_aml_get_name_string ( + OBJECT_TYPE_INTERNAL data_type, + u8 *in_aml_address, + NATIVE_CHAR **out_name_string, + u32 *out_name_length); + +ACPI_STATUS +acpi_aml_do_name ( + ACPI_OBJECT_TYPE data_type, + OPERATING_MODE load_exec_mode); + + +/* + * amstore - Object store support + */ + +ACPI_STATUS +acpi_aml_exec_store ( + ACPI_OPERAND_OBJECT *val_desc, + ACPI_OPERAND_OBJECT *dest_desc, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_store_object_to_object ( + ACPI_OPERAND_OBJECT *val_desc, + ACPI_OPERAND_OBJECT *dest_desc, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_store_object_to_node ( + ACPI_OPERAND_OBJECT *val_desc, + ACPI_NAMESPACE_NODE *node, + ACPI_WALK_STATE *walk_state); + + +/* + * amutils - interpreter/scanner utilities + */ + +void +acpi_aml_enter_interpreter ( + void); + +void +acpi_aml_exit_interpreter ( + void); + +u8 +acpi_aml_validate_object_type ( + ACPI_OBJECT_TYPE type); + +u8 +acpi_aml_acquire_global_lock ( + u32 rule); + +ACPI_STATUS +acpi_aml_release_global_lock ( + u8 locked); + +u32 +acpi_aml_buf_seq ( + void); + +u32 +acpi_aml_digits_needed ( + u32 value, + u32 base); + +ACPI_STATUS +acpi_aml_eisa_id_to_string ( + u32 numeric_id, + NATIVE_CHAR *out_string); + +ACPI_STATUS +acpi_aml_build_copy_internal_package_object ( + ACPI_OPERAND_OBJECT *source_obj, + ACPI_OPERAND_OBJECT *dest_obj, + ACPI_WALK_STATE *walk_state); + + +/* + * amregion - default Op_region handlers + */ + +ACPI_STATUS +acpi_aml_system_memory_space_handler ( + u32 function, + u32 address, + u32 bit_width, + u32 *value, + void *handler_context, + void *region_context); + +ACPI_STATUS +acpi_aml_system_io_space_handler ( + u32 function, + u32 address, + u32 bit_width, + u32 *value, + void *handler_context, + void *region_context); + +ACPI_STATUS +acpi_aml_pci_config_space_handler ( + u32 function, + u32 address, + u32 bit_width, + u32 *value, + void *handler_context, + void *region_context); + +ACPI_STATUS +acpi_aml_embedded_controller_space_handler ( + u32 function, + u32 address, + u32 bit_width, + u32 *value, + void *handler_context, + void *region_context); + +ACPI_STATUS +acpi_aml_sm_bus_space_handler ( + u32 function, + u32 address, + u32 bit_width, + u32 *value, + void *handler_context, + void *region_context); + + +#endif /* __INTERP_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/aclocal.h linux/drivers/acpi/include/aclocal.h --- v2.4.0-test8/linux/drivers/acpi/include/aclocal.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/aclocal.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,851 @@ +/****************************************************************************** + * + * Name: aclocal.h - Internal data types used across the ACPI subsystem + * $Revision: 77 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + +#ifndef __ACLOCAL_H__ +#define __ACLOCAL_H__ + + +#define WAIT_FOREVER ((u32) -1) + +typedef void* ACPI_MUTEX; +typedef u32 ACPI_MUTEX_HANDLE; + + +/* Object descriptor types */ + +#define ACPI_CACHED_OBJECT 0x11 /* ORed in when object is cached */ +#define ACPI_DESC_TYPE_STATE 0x22 +#define ACPI_DESC_TYPE_WALK 0x44 +#define ACPI_DESC_TYPE_PARSER 0x66 +#define ACPI_DESC_TYPE_INTERNAL 0x88 +#define ACPI_DESC_TYPE_NAMED 0xAA + + +/***************************************************************************** + * + * Mutex typedefs and structs + * + ****************************************************************************/ + + +/* + * Predefined handles for the mutex objects used within the subsystem + * All mutex objects are automatically created by Acpi_cm_mutex_initialize. + * NOTE: any changes here must be reflected in the Acpi_gbl_Mutex_names table also! + */ + +#define ACPI_MTX_HARDWARE 0 +#define ACPI_MTX_MEMORY 1 +#define ACPI_MTX_CACHES 2 +#define ACPI_MTX_TABLES 3 +#define ACPI_MTX_PARSER 4 +#define ACPI_MTX_DISPATCHER 5 +#define ACPI_MTX_INTERPRETER 6 +#define ACPI_MTX_EXECUTE 7 +#define ACPI_MTX_NAMESPACE 8 +#define ACPI_MTX_EVENTS 9 +#define ACPI_MTX_OP_REGIONS 10 +#define ACPI_MTX_DEBUG_CMD_READY 11 +#define ACPI_MTX_DEBUG_CMD_COMPLETE 12 + +#define MAX_MTX 12 +#define NUM_MTX MAX_MTX+1 + + +#ifdef ACPI_DEBUG +#ifdef DEFINE_ACPI_GLOBALS + +/* Names for the mutexes used in the subsystem */ + +static NATIVE_CHAR *acpi_gbl_mutex_names[] = +{ + "ACPI_MTX_Hardware", + "ACPI_MTX_Memory", + "ACPI_MTX_Caches", + "ACPI_MTX_Tables", + "ACPI_MTX_Parser", + "ACPI_MTX_Dispatcher", + "ACPI_MTX_Interpreter", + "ACPI_MTX_Execute", + "ACPI_MTX_Namespace", + "ACPI_MTX_Events", + "ACPI_MTX_Op_regions", + "ACPI_MTX_Debug_cmd_ready", + "ACPI_MTX_Debug_cmd_complete" +}; + +#endif +#endif + + +/* Table for the global mutexes */ + +typedef struct acpi_mutex_info +{ + ACPI_MUTEX mutex; + u32 use_count; + u8 locked; + +} ACPI_MUTEX_INFO; + + +/* Lock flag parameter for various interfaces */ + +#define ACPI_MTX_DO_NOT_LOCK 0 +#define ACPI_MTX_LOCK 1 + + +typedef u16 ACPI_OWNER_ID; +#define OWNER_TYPE_TABLE 0x0 +#define OWNER_TYPE_METHOD 0x1 +#define FIRST_METHOD_ID 0x0000 +#define FIRST_TABLE_ID 0x8000 + +/* TBD: [Restructure] get rid of the need for this! */ + +#define TABLE_ID_DSDT (ACPI_OWNER_ID) 0xD1D1 + +/***************************************************************************** + * + * Namespace typedefs and structs + * + ****************************************************************************/ + + +/* Operational modes of the AML interpreter/scanner */ + +typedef enum +{ + IMODE_LOAD_PASS1 = 0x01, + IMODE_LOAD_PASS2 = 0x02, + IMODE_EXECUTE = 0x0E + +} OPERATING_MODE; + + +/* + * The Node describes a named object that appears in the AML + * An Acpi_node is used to store Nodes. + * + * Data_type is used to differentiate between internal descriptors, and MUST + * be the first byte in this structure. + */ + +typedef struct acpi_node +{ + u8 data_type; + u8 type; /* Type associated with this name */ + u32 name; /* ACPI Name, always 4 chars per ACPI spec */ + u16 owner_id; + + + void *object; /* Pointer to attached ACPI object (optional) */ + struct acpi_node *child; /* first child */ + struct acpi_node *peer; /* Next peer*/ + u16 reference_count; /* Current count of references and children */ + u8 flags; + +} ACPI_NAMESPACE_NODE; + + +#define ENTRY_NOT_FOUND NULL + + +/* Node flags */ + +#define ANOBJ_AML_ATTACHMENT 0x1 +#define ANOBJ_END_OF_PEER_LIST 0x2 + + +/* + * ACPI Table Descriptor. One per ACPI table + */ +typedef struct acpi_table_desc +{ + struct acpi_table_desc *prev; + struct acpi_table_desc *next; + struct acpi_table_desc *installed_desc; + ACPI_TABLE_HEADER *pointer; + void *base_pointer; + u8 *aml_pointer; + u32 aml_length; + u32 length; + u32 count; + ACPI_OWNER_ID table_id; + u8 type; + u8 allocation; + u8 loaded_into_namespace; + +} ACPI_TABLE_DESC; + + +typedef struct +{ + NATIVE_CHAR *search_for; + ACPI_HANDLE *list; + u32 *count; + +} FIND_CONTEXT; + + +typedef struct +{ + ACPI_NAMESPACE_NODE *node; +} NS_SEARCH_DATA; + + +/* + * Predefined Namespace items + */ +#define ACPI_MAX_ADDRESS_SPACE 255 +#define ACPI_NUM_ADDRESS_SPACES 256 + + +typedef struct +{ + NATIVE_CHAR *name; + ACPI_OBJECT_TYPE type; + NATIVE_CHAR *val; + +} PREDEFINED_NAMES; + + +/***************************************************************************** + * + * Event typedefs and structs + * + ****************************************************************************/ + + +/* Status bits. */ + +#define ACPI_STATUS_PMTIMER 0x0001 +#define ACPI_STATUS_GLOBAL 0x0020 +#define ACPI_STATUS_POWER_BUTTON 0x0100 +#define ACPI_STATUS_SLEEP_BUTTON 0x0200 +#define ACPI_STATUS_RTC_ALARM 0x0400 + +/* Enable bits. */ + +#define ACPI_ENABLE_PMTIMER 0x0001 +#define ACPI_ENABLE_GLOBAL 0x0020 +#define ACPI_ENABLE_POWER_BUTTON 0x0100 +#define ACPI_ENABLE_SLEEP_BUTTON 0x0200 +#define ACPI_ENABLE_RTC_ALARM 0x0400 + + +/* + * Entry in the Address_space (AKA Operation Region) table + */ + +typedef struct +{ + ADDRESS_SPACE_HANDLER handler; + void *context; + +} ACPI_ADDRESS_SPACE_INFO; + + +/* Values and addresses of the GPE registers (both banks) */ + +typedef struct +{ + u8 status; /* Current value of status reg */ + u8 enable; /* Current value of enable reg */ + u16 status_addr; /* Address of status reg */ + u16 enable_addr; /* Address of enable reg */ + u8 gpe_base; /* Base GPE number */ + +} ACPI_GPE_REGISTERS; + + +#define ACPI_GPE_LEVEL_TRIGGERED 1 +#define ACPI_GPE_EDGE_TRIGGERED 2 + + +/* Information about each particular GPE level */ + +typedef struct +{ + u8 type; /* Level or Edge */ + + ACPI_HANDLE method_handle; /* Method handle for direct (fast) execution */ + GPE_HANDLER handler; /* Address of handler, if any */ + void *context; /* Context to be passed to handler */ + +} ACPI_GPE_LEVEL_INFO; + + +/* Information about each particular fixed event */ + +typedef struct +{ + FIXED_EVENT_HANDLER handler; /* Address of handler. */ + void *context; /* Context to be passed to handler */ + +} ACPI_FIXED_EVENT_INFO; + + +/* Information used during field processing */ + +typedef struct +{ + u8 skip_field; + u8 field_flag; + u32 pkg_length; + +} ACPI_FIELD_INFO; + + +/***************************************************************************** + * + * Generic "state" object for stacks + * + ****************************************************************************/ + + +#define CONTROL_NORMAL 0xC0 +#define CONTROL_CONDITIONAL_EXECUTING 0xC1 +#define CONTROL_PREDICATE_EXECUTING 0xC2 +#define CONTROL_PREDICATE_FALSE 0xC3 +#define CONTROL_PREDICATE_TRUE 0xC4 + + +/* Forward declaration */ +struct acpi_walk_state; +struct acpi_parse_obj ; + + +#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ + u8 data_type; /* To differentiate various internal objs */\ + u8 flags; \ + u16 value; \ + u16 state; \ + u16 acpi_eval; \ + void *next; \ + +typedef struct acpi_common_state +{ + ACPI_STATE_COMMON +} ACPI_COMMON_STATE; + + +/* + * Update state - used to traverse complex objects such as packages + */ +typedef struct acpi_update_state +{ + ACPI_STATE_COMMON + union acpi_operand_obj *object; + +} ACPI_UPDATE_STATE; + +/* + * Control state - one per if/else and while constructs. + * Allows nesting of these constructs + */ +typedef struct acpi_control_state +{ + ACPI_STATE_COMMON + struct acpi_parse_obj *predicate_op; + u8 *aml_predicate_start; /* Start of if/while predicate */ + +} ACPI_CONTROL_STATE; + + +/* + * Scope state - current scope during namespace lookups + */ + +typedef struct acpi_scope_state +{ + ACPI_STATE_COMMON + ACPI_NAMESPACE_NODE *node; + +} ACPI_SCOPE_STATE; + + +typedef struct acpi_pscope_state +{ + ACPI_STATE_COMMON + struct acpi_parse_obj *op; /* current op being parsed */ + u8 *arg_end; /* current argument end */ + u8 *pkg_end; /* current package end */ + u32 arg_list; /* next argument to parse */ + u32 arg_count; /* Number of fixed arguments */ + +} ACPI_PSCOPE_STATE; + + +typedef union acpi_gen_state +{ + ACPI_COMMON_STATE common; + ACPI_CONTROL_STATE control; + ACPI_UPDATE_STATE update; + ACPI_SCOPE_STATE scope; + ACPI_PSCOPE_STATE parse_scope; + +} ACPI_GENERIC_STATE; + + +typedef +ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) ( + u16 opcode, + struct acpi_parse_obj *op, + struct acpi_walk_state *walk_state, + struct acpi_parse_obj **out_op); + +typedef +ACPI_STATUS (*ACPI_PARSE_UPWARDS) ( + struct acpi_walk_state *walk_state, + struct acpi_parse_obj *op); + + +/***************************************************************************** + * + * Parser typedefs and structs + * + ****************************************************************************/ + + +#define ACPI_OP_CLASS_MASK 0x1F +#define ACPI_OP_ARGS_MASK 0x20 +#define ACPI_OP_TYPE_MASK 0xC0 + +#define ACPI_OP_TYPE_OPCODE 0x00 +#define ACPI_OP_TYPE_ASCII 0x40 +#define ACPI_OP_TYPE_PREFIX 0x80 +#define ACPI_OP_TYPE_UNKNOWN 0xC0 + +#define ACPI_GET_OP_CLASS(a) ((a)->flags & ACPI_OP_CLASS_MASK) +#define ACPI_GET_OP_ARGS(a) ((a)->flags & ACPI_OP_ARGS_MASK) +#define ACPI_GET_OP_TYPE(a) ((a)->flags & ACPI_OP_TYPE_MASK) + + +/* + * AML opcode, name, and argument layout + */ +typedef struct acpi_opcode_info +{ + u8 flags; /* Opcode type, Has_args flag */ + u32 parse_args; /* Grammar/Parse time arguments */ + u32 runtime_args; /* Interpret time arguments */ + + DEBUG_ONLY_MEMBERS ( + NATIVE_CHAR *name) /* op name (debug only) */ + +} ACPI_OPCODE_INFO; + + +typedef union acpi_parse_val +{ + u32 integer; /* integer constant */ + u32 size; /* bytelist or field size */ + NATIVE_CHAR *string; /* NULL terminated string */ + u8 *buffer; /* buffer or string */ + NATIVE_CHAR *name; /* NULL terminated string */ + struct acpi_parse_obj *arg; /* arguments and contained ops */ + +} ACPI_PARSE_VALUE; + + +#define ACPI_PARSE_COMMON \ + u8 data_type; /* To differentiate various internal objs */\ + u8 flags; /* Type of Op */\ + u16 opcode; /* AML opcode */\ + u32 aml_offset; /* offset of declaration in AML */\ + struct acpi_parse_obj *parent; /* parent op */\ + struct acpi_parse_obj *next; /* next op */\ + DEBUG_ONLY_MEMBERS (\ + NATIVE_CHAR op_name[16]) /* op name (debug only) */\ + /* NON-DEBUG members below: */\ + ACPI_NAMESPACE_NODE *node;/* for use by interpreter */\ + ACPI_PARSE_VALUE value; /* Value or args associated with the opcode */\ + + +/* + * generic operation (eg. If, While, Store) + */ +typedef struct acpi_parse_obj +{ + ACPI_PARSE_COMMON +} ACPI_PARSE_OBJECT; + + +/* + * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and Op_regions), + * and bytelists. + */ +typedef struct acpi_parse2_obj +{ + ACPI_PARSE_COMMON + u8 *data; /* AML body or bytelist data */ + u32 length; /* AML length */ + u32 name; /* 4-byte name or zero if no name */ + +} ACPI_PARSE2_OBJECT; + + +/* + * Parse state - one state per parser invocation and each control + * method. + */ + +typedef struct acpi_parse_state +{ + u8 *aml_start; /* first AML byte */ + u8 *aml; /* next AML byte */ + u8 *aml_end; /* (last + 1) AML byte */ + u8 *pkg_start; /* current package begin */ + u8 *pkg_end; /* current package end */ + ACPI_PARSE_OBJECT *start_op; /* root of parse tree */ + struct acpi_node *start_node; + ACPI_GENERIC_STATE *scope; /* current scope */ + struct acpi_parse_state *next; + +} ACPI_PARSE_STATE; + + +/***************************************************************************** + * + * Tree walking typedefs and structs + * + ****************************************************************************/ + + +/* + * Walk state - current state of a parse tree walk. Used for both a leisurely stroll through + * the tree (for whatever reason), and for control method execution. + */ + +#define NEXT_OP_DOWNWARD 1 +#define NEXT_OP_UPWARD 2 + +#define WALK_METHOD 1 +#define WALK_NON_METHOD 0 + +typedef struct acpi_walk_state +{ + u8 data_type; /* To differentiate various internal objs */\ + ACPI_OWNER_ID owner_id; /* Owner of objects created during the walk */ + u8 last_predicate; /* Result of last predicate */ + u8 next_op_info; /* Info about Next_op */ + u8 num_operands; /* Stack pointer for Operands[] array */ + u8 num_results; /* Stack pointer for Results[] array */ + u8 current_result; /* */ + + struct acpi_walk_state *next; /* Next Walk_state in list */ + ACPI_PARSE_OBJECT *origin; /* Start of walk */ + +/* TBD: Obsolete with removal of WALK procedure ? */ + ACPI_PARSE_OBJECT *prev_op; /* Last op that was processed */ + ACPI_PARSE_OBJECT *next_op; /* next op to be processed */ + + + ACPI_GENERIC_STATE *control_state; /* List of control states (nested IFs) */ + ACPI_GENERIC_STATE *scope_info; /* Stack of nested scopes */ + ACPI_PARSE_STATE *parser_state; /* Current state of parser */ + u8 *aml_last_while; + ACPI_PARSE_DOWNWARDS descending_callback; + ACPI_PARSE_UPWARDS ascending_callback; + + union acpi_operand_obj *return_desc; /* Return object, if any */ + union acpi_operand_obj *method_desc; /* Method descriptor if running a method */ + struct acpi_node *method_node; /* Method Node if running a method */ + ACPI_PARSE_OBJECT *method_call_op; /* Method_call Op if running a method */ + struct acpi_node *method_call_node; /* Called method Node*/ + union acpi_operand_obj *operands[OBJ_NUM_OPERANDS]; /* Operands passed to the interpreter */ + union acpi_operand_obj *results[OBJ_NUM_OPERANDS]; /* Accumulated results */ + struct acpi_node arguments[MTH_NUM_ARGS]; /* Control method arguments */ + struct acpi_node local_variables[MTH_NUM_LOCALS]; /* Control method locals */ + u32 parse_flags; + u8 walk_type; + u8 return_used; + u32 prev_arg_types; + + /* Debug support */ + + u32 method_breakpoint; + + +} ACPI_WALK_STATE; + + +/* + * Walk list - head of a tree of walk states. Multiple walk states are created when there + * are nested control methods executing. + */ +typedef struct acpi_walk_list +{ + + ACPI_WALK_STATE *walk_state; + +} ACPI_WALK_LIST; + + +/* Info used by Acpi_ps_init_objects */ + +typedef struct init_walk_info +{ + u32 method_count; + u32 op_region_count; + ACPI_TABLE_DESC *table_desc; + +} INIT_WALK_INFO; + + +/* TBD: [Restructure] Merge with struct above */ + +typedef struct acpi_walk_info +{ + u32 debug_level; + u32 owner_id; + +} ACPI_WALK_INFO; + + +/***************************************************************************** + * + * Hardware and PNP + * + ****************************************************************************/ + + +/* Sleep states */ + +#define SLWA_DEBUG_LEVEL 4 +#define GTS_CALL 0 +#define GTS_WAKE 1 + +/* Cx States */ + +#define MAX_CX_STATE_LATENCY 0xFFFFFFFF +#define MAX_CX_STATES 4 + +/* + * The #define's and enum below establish an abstract way of identifying what + * register block and register is to be accessed. Do not change any of the + * values as they are used in switch statements and offset calculations. + */ + +#define REGISTER_BLOCK_MASK 0xFF00 +#define BIT_IN_REGISTER_MASK 0x00FF +#define PM1_EVT 0x0100 +#define PM1_CONTROL 0x0200 +#define PM2_CONTROL 0x0300 +#define PM_TIMER 0x0400 +#define PROCESSOR_BLOCK 0x0500 +#define GPE0_STS_BLOCK 0x0600 +#define GPE0_EN_BLOCK 0x0700 +#define GPE1_STS_BLOCK 0x0800 +#define GPE1_EN_BLOCK 0x0900 + +enum +{ + /* PM1 status register ids */ + + TMR_STS = (PM1_EVT | 0x01), + BM_STS, + GBL_STS, + PWRBTN_STS, + SLPBTN_STS, + RTC_STS, + WAK_STS, + + /* PM1 enable register ids */ + + TMR_EN, + /* need to skip 1 enable number since there's no bus master enable register */ + GBL_EN = (PM1_EVT | 0x0A), + PWRBTN_EN, + SLPBTN_EN, + RTC_EN, + + /* PM1 control register ids */ + + SCI_EN = (PM1_CONTROL | 0x01), + BM_RLD, + GBL_RLS, + SLP_TYPE_A, + SLP_TYPE_B, + SLP_EN, + + /* PM2 control register ids */ + + ARB_DIS = (PM2_CONTROL | 0x01), + + /* PM Timer register ids */ + + TMR_VAL = (PM_TIMER | 0x01), + + GPE0_STS = (GPE0_STS_BLOCK | 0x01), + GPE0_EN = (GPE0_EN_BLOCK | 0x01), + + GPE1_STS = (GPE1_STS_BLOCK | 0x01), + GPE1_EN = (GPE0_EN_BLOCK | 0x01), + + /* Last register value is one less than LAST_REG */ + + LAST_REG +}; + + +#define TMR_STS_MASK 0x0001 +#define BM_STS_MASK 0x0010 +#define GBL_STS_MASK 0x0020 +#define PWRBTN_STS_MASK 0x0100 +#define SLPBTN_STS_MASK 0x0200 +#define RTC_STS_MASK 0x0400 +#define WAK_STS_MASK 0x8000 + +#define ALL_FIXED_STS_BITS (TMR_STS_MASK | BM_STS_MASK | GBL_STS_MASK | PWRBTN_STS_MASK | \ + SLPBTN_STS_MASK | RTC_STS_MASK | WAK_STS_MASK) + +#define TMR_EN_MASK 0x0001 +#define GBL_EN_MASK 0x0020 +#define PWRBTN_EN_MASK 0x0100 +#define SLPBTN_EN_MASK 0x0200 +#define RTC_EN_MASK 0x0400 + +#define SCI_EN_MASK 0x0001 +#define BM_RLD_MASK 0x0002 +#define GBL_RLS_MASK 0x0004 +#define SLP_TYPE_X_MASK 0x1C00 +#define SLP_EN_MASK 0x2000 + +#define ARB_DIS_MASK 0x0001 + +#define GPE0_STS_MASK +#define GPE0_EN_MASK + +#define GPE1_STS_MASK +#define GPE1_EN_MASK + + +#define ACPI_READ 1 +#define ACPI_WRITE 2 + +#define LOW_BYTE 0x00FF +#define ONE_BYTE 0x08 + +#ifndef SET + #define SET 1 +#endif +#ifndef CLEAR + #define CLEAR 0 +#endif + + +/* Plug and play */ + +/* Pnp and ACPI data */ + +#define VERSION_NO 0x01 +#define LOGICAL_DEVICE_ID 0x02 +#define COMPATIBLE_DEVICE_ID 0x03 +#define IRQ_FORMAT 0x04 +#define DMA_FORMAT 0x05 +#define START_DEPENDENT_TAG 0x06 +#define END_DEPENDENT_TAG 0x07 +#define IO_PORT_DESCRIPTOR 0x08 +#define FIXED_LOCATION_IO_DESCRIPTOR 0x09 +#define RESERVED_TYPE0 0x0A +#define RESERVED_TYPE1 0x0B +#define RESERVED_TYPE2 0x0C +#define RESERVED_TYPE3 0x0D +#define SMALL_VENDOR_DEFINED 0x0E +#define END_TAG 0x0F + +/* Pnp and ACPI data */ + +#define MEMORY_RANGE_24 0x81 +#define ISA_MEMORY_RANGE 0x81 +#define LARGE_VENDOR_DEFINED 0x84 +#define EISA_MEMORY_RANGE 0x85 +#define MEMORY_RANGE_32 0x85 +#define FIXED_EISA_MEMORY_RANGE 0x86 +#define FIXED_MEMORY_RANGE_32 0x86 + +/* ACPI only data */ + +#define DWORD_ADDRESS_SPACE 0x87 +#define WORD_ADDRESS_SPACE 0x88 +#define EXTENDED_IRQ 0x89 + +/* MUST HAVES */ + + +typedef enum +{ + DWORD_DEVICE_ID, + STRING_PTR_DEVICE_ID, + STRING_DEVICE_ID + +} DEVICE_ID_TYPE; + +typedef struct +{ + DEVICE_ID_TYPE type; + union + { + u32 number; + NATIVE_CHAR *string_ptr; + NATIVE_CHAR buffer[9]; + } data; + +} DEVICE_ID; + + +/***************************************************************************** + * + * Debug + * + ****************************************************************************/ + + +/* Entry for a memory allocation (debug only) */ + +#ifdef ACPI_DEBUG + +#define MEM_MALLOC 0 +#define MEM_CALLOC 1 +#define MAX_MODULE_NAME 16 + +typedef struct allocation_info +{ + struct allocation_info *previous; + struct allocation_info *next; + void *address; + u32 size; + u32 component; + u32 line; + NATIVE_CHAR module[MAX_MODULE_NAME]; + u8 alloc_type; + +} ALLOCATION_INFO; + +#endif + +#endif /* __ACLOCAL_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acmacros.h linux/drivers/acpi/include/acmacros.h --- v2.4.0-test8/linux/drivers/acpi/include/acmacros.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/acmacros.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,435 @@ +/****************************************************************************** + * + * Name: acmacros.h - C macros for the entire subsystem. + * $Revision: 48 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + +#ifndef __ACMACROS_H__ +#define __ACMACROS_H__ + +/* + * Data manipulation macros + */ + +#ifndef LOWORD +#define LOWORD(l) ((u16)(NATIVE_UINT)(l)) +#endif + +#ifndef HIWORD +#define HIWORD(l) ((u16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF)) +#endif + +#ifndef LOBYTE +#define LOBYTE(l) ((u8)(u16)(l)) +#endif + +#ifndef HIBYTE +#define HIBYTE(l) ((u8)((((u16)(l)) >> 8) & 0xFF)) +#endif + +#define BIT0(x) ((((x) & 0x01) > 0) ? 1 : 0) +#define BIT1(x) ((((x) & 0x02) > 0) ? 1 : 0) +#define BIT2(x) ((((x) & 0x04) > 0) ? 1 : 0) + +#define BIT3(x) ((((x) & 0x08) > 0) ? 1 : 0) +#define BIT4(x) ((((x) & 0x10) > 0) ? 1 : 0) +#define BIT5(x) ((((x) & 0x20) > 0) ? 1 : 0) +#define BIT6(x) ((((x) & 0x40) > 0) ? 1 : 0) +#define BIT7(x) ((((x) & 0x80) > 0) ? 1 : 0) + +#define LOW_BASE(w) ((u16) ((w) & 0x0000FFFF)) +#define MID_BASE(b) ((u8) (((b) & 0x00FF0000) >> 16)) +#define HI_BASE(b) ((u8) (((b) & 0xFF000000) >> 24)) +#define LOW_LIMIT(w) ((u16) ((w) & 0x0000FFFF)) +#define HI_LIMIT(b) ((u8) (((b) & 0x00FF0000) >> 16)) + + + /* + * Extract a byte of data using a pointer. Any more than a byte and we + * get into potential aligment issues -- see the STORE macros below + */ +#define GET8(addr) (*(u8*)(addr)) + + +/* + * Macros for moving data around to/from buffers that are possibly unaligned. + * If the hardware supports the transfer of unaligned data, just do the store. + * Otherwise, we have to move one byte at a time. + */ + +#ifdef _HW_ALIGNMENT_SUPPORT + +/* The hardware supports unaligned transfers, just do the move */ + +#define MOVE_UNALIGNED16_TO_16(d,s) *(u16*)(d) = *(u16*)(s) +#define MOVE_UNALIGNED32_TO_32(d,s) *(u32*)(d) = *(u32*)(s) +#define MOVE_UNALIGNED16_TO_32(d,s) *(u32*)(d) = *(u16*)(s) + +#else +/* + * The hardware does not support unaligned transfers. We must move the + * data one byte at a time. These macros work whether the source or + * the destination (or both) is/are unaligned. + */ + +#define MOVE_UNALIGNED16_TO_16(d,s) {((u8 *)(d))[0] = ((u8 *)(s))[0];\ + ((u8 *)(d))[1] = ((u8 *)(s))[1];} + +#define MOVE_UNALIGNED32_TO_32(d,s) {((u8 *)(d))[0] = ((u8 *)(s))[0];\ + ((u8 *)(d))[1] = ((u8 *)(s))[1];\ + ((u8 *)(d))[2] = ((u8 *)(s))[2];\ + ((u8 *)(d))[3] = ((u8 *)(s))[3];} + +#define MOVE_UNALIGNED16_TO_32(d,s) {(*(u32*)(d)) = 0; MOVE_UNALIGNED16_TO_16(d,s);} + +#endif + + +/* + * Fast power-of-two math macros for non-optimized compilers + */ + +#define _DIV(value,power_of2) ((u32) ((value) >> (power_of2))) +#define _MUL(value,power_of2) ((u32) ((value) << (power_of2))) +#define _MOD(value,divisor) ((u32) ((value) & ((divisor) -1))) + +#define DIV_2(a) _DIV(a,1) +#define MUL_2(a) _MUL(a,1) +#define MOD_2(a) _MOD(a,2) + +#define DIV_4(a) _DIV(a,2) +#define MUL_4(a) _MUL(a,2) +#define MOD_4(a) _MOD(a,4) + +#define DIV_8(a) _DIV(a,3) +#define MUL_8(a) _MUL(a,3) +#define MOD_8(a) _MOD(a,8) + +#define DIV_16(a) _DIV(a,4) +#define MUL_16(a) _MUL(a,4) +#define MOD_16(a) _MOD(a,16) + + +/* + * Rounding macros (Power of two boundaries only) + */ + +#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) +#define ROUND_UP(value,boundary) (((value) + ((boundary)-1)) & (~((boundary)-1))) + +#define ROUND_DOWN_TO_32_BITS(a) ROUND_DOWN(a,4) +#define ROUND_DOWN_TO_NATIVE_WORD(a) ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY) + +#define ROUND_UP_TO_32_bITS(a) ROUND_UP(a,4) +#define ROUND_UP_TO_NATIVE_WORD(a) ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY) + + +#ifdef DEBUG_ASSERT +#undef DEBUG_ASSERT +#endif + + +/* + * An ACPI_HANDLE (which is actually an ACPI_NAMESPACE_NODE *) can appear in some contexts, + * such as on ap_obj_stack, where a pointer to an ACPI_OPERAND_OBJECT can also + * appear. This macro is used to distinguish them. + * + * The Data_type field is the first field in both structures. + */ + +#define VALID_DESCRIPTOR_TYPE(d,t) (((ACPI_NAMESPACE_NODE *)d)->data_type == t) + + +/* Macro to test the object type */ + +#define IS_THIS_OBJECT_TYPE(d,t) (((ACPI_OPERAND_OBJECT *)d)->common.type == (u8)t) + +/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */ + +#define IS_SINGLE_TABLE(x) (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0) + +/* + * Macro to check if a pointer is within an ACPI table. + * Parameter (a) is the pointer to check. Parameter (b) must be defined + * as a pointer to an ACPI_TABLE_HEADER. (b+1) then points past the header, + * and ((u8 *)b+b->Length) points one byte past the end of the table. + */ + +#ifndef _IA16 +#define IS_IN_ACPI_TABLE(a,b) (((u8 *)(a) >= (u8 *)(b + 1)) &&\ + ((u8 *)(a) < ((u8 *)b + b->length))) + +#else +#define IS_IN_ACPI_TABLE(a,b) (_segment)(a) == (_segment)(b) &&\ + (((u8 *)(a) >= (u8 *)(b + 1)) &&\ + ((u8 *)(a) < ((u8 *)b + b->length))) +#endif + +/* + * Macros for the master AML opcode table + */ + +#ifdef ACPI_DEBUG +#define OP_INFO_ENTRY(flags,name,Pargs,Iargs) {flags,Pargs,Iargs,name} +#else +#define OP_INFO_ENTRY(flags,name,Pargs,Iargs) {flags,Pargs,Iargs} +#endif + +#define ARG_TYPE_WIDTH 5 +#define ARG_1(x) ((u32)(x)) +#define ARG_2(x) ((u32)(x) << (1 * ARG_TYPE_WIDTH)) +#define ARG_3(x) ((u32)(x) << (2 * ARG_TYPE_WIDTH)) +#define ARG_4(x) ((u32)(x) << (3 * ARG_TYPE_WIDTH)) +#define ARG_5(x) ((u32)(x) << (4 * ARG_TYPE_WIDTH)) +#define ARG_6(x) ((u32)(x) << (5 * ARG_TYPE_WIDTH)) + +#define ARGI_LIST1(a) (ARG_1(a)) +#define ARGI_LIST2(a,b) (ARG_1(b)|ARG_2(a)) +#define ARGI_LIST3(a,b,c) (ARG_1(c)|ARG_2(b)|ARG_3(a)) +#define ARGI_LIST4(a,b,c,d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a)) +#define ARGI_LIST5(a,b,c,d,e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a)) +#define ARGI_LIST6(a,b,c,d,e,f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a)) + +#define ARGP_LIST1(a) (ARG_1(a)) +#define ARGP_LIST2(a,b) (ARG_1(a)|ARG_2(b)) +#define ARGP_LIST3(a,b,c) (ARG_1(a)|ARG_2(b)|ARG_3(c)) +#define ARGP_LIST4(a,b,c,d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)) +#define ARGP_LIST5(a,b,c,d,e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)) +#define ARGP_LIST6(a,b,c,d,e,f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f)) + +#define GET_CURRENT_ARG_TYPE(list) (list & 0x1F) +#define INCREMENT_ARG_LIST(list) (list >>= ARG_TYPE_WIDTH) + + +/* + * Reporting macros that are never compiled out + */ + +/* + * Error reporting. These versions add callers module and line#. Since + * _THIS_MODULE gets compiled out when ACPI_DEBUG isn't defined, only + * use it in debug mode. + */ + +#ifdef ACPI_DEBUG + +#define REPORT_INFO(a) _report_info(_THIS_MODULE,__LINE__,_COMPONENT,a) +#define REPORT_ERROR(a) _report_error(_THIS_MODULE,__LINE__,_COMPONENT,a) +#define REPORT_WARNING(a) _report_warning(_THIS_MODULE,__LINE__,_COMPONENT,a) + +#else + +#define REPORT_INFO(a) _report_info("",__LINE__,_COMPONENT,a) +#define REPORT_ERROR(a) _report_error("",__LINE__,_COMPONENT,a) +#define REPORT_WARNING(a) _report_warning("",__LINE__,_COMPONENT,a) + +#endif + +/* Error reporting. These versions pass thru the module and line# */ + +#define _REPORT_INFO(a,b,c,d) _report_info(a,b,c,d) +#define _REPORT_ERROR(a,b,c,d) _report_error(a,b,c,d) +#define _REPORT_WARNING(a,b,c,d) _report_warning(a,b,c,d) + +/* Buffer dump macros */ + +#define DUMP_BUFFER(a,b) acpi_cm_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) + +/* + * Debug macros that are conditionally compiled + */ + +#ifdef ACPI_DEBUG + +#define MODULE_NAME(name) static char *_THIS_MODULE = name; + +/* + * Function entry tracing. + * The first parameter should be the procedure name as a quoted string. This is declared + * as a local string ("_Proc_name) so that it can be also used by the function exit macros below. + */ + +#define FUNCTION_TRACE(a) char * _proc_name = a;\ + function_trace(_THIS_MODULE,__LINE__,_COMPONENT,a) +#define FUNCTION_TRACE_PTR(a,b) char * _proc_name = a;\ + function_trace_ptr(_THIS_MODULE,__LINE__,_COMPONENT,a,(void *)b) +#define FUNCTION_TRACE_U32(a,b) char * _proc_name = a;\ + function_trace_u32(_THIS_MODULE,__LINE__,_COMPONENT,a,(u32)b) +#define FUNCTION_TRACE_STR(a,b) char * _proc_name = a;\ + function_trace_str(_THIS_MODULE,__LINE__,_COMPONENT,a,(NATIVE_CHAR *)b) +/* + * Function exit tracing. + * WARNING: These macros include a return statement. This is usually considered + * bad form, but having a separate exit macro is very ugly and difficult to maintain. + * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros + * so that "_Proc_name" is defined. + */ +#define return_VOID {function_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name);return;} +#define return_ACPI_STATUS(s) {function_status_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name,s);return(s);} +#define return_VALUE(s) {function_value_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name,(NATIVE_UINT)s);return(s);} +#define return_PTR(s) {function_ptr_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name,(u8 *)s);return(s);} + + +/* Conditional execution */ + +#define DEBUG_EXEC(a) a; +#define NORMAL_EXEC(a) + +#define DEBUG_DEFINE(a) a; +#define DEBUG_ONLY_MEMBERS(a) a; + + +/* Stack and buffer dumping */ + +#define DUMP_STACK_ENTRY(a) acpi_aml_dump_operand(a) +#define DUMP_OPERANDS(a,b,c,d,e) acpi_aml_dump_operands(a,b,c,d,e,_THIS_MODULE,__LINE__) + + +#define DUMP_ENTRY(a,b) acpi_ns_dump_entry (a,b) +#define DUMP_TABLES(a,b) acpi_ns_dump_tables(a,b) +#define DUMP_PATHNAME(a,b,c,d) acpi_ns_dump_pathname(a,b,c,d) +#define DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a) +#define BREAK_MSG(a) acpi_os_breakpoint (a) + +/* + * Generate INT3 on ACPI_ERROR (Debug only!) + */ + +#define ERROR_BREAK +#ifdef ERROR_BREAK +#define BREAK_ON_ERROR(lvl) if ((lvl)&ACPI_ERROR) acpi_os_breakpoint("Fatal error encountered\n") +#else +#define BREAK_ON_ERROR(lvl) +#endif + +/* + * Master debug print macros + * Print iff: + * 1) Debug print for the current component is enabled + * 2) Debug error level or trace level for the print statement is enabled + * + */ + +#define PARAM_LIST(pl) pl + +#define TEST_DEBUG_SWITCH(lvl) if (((lvl) & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer)) + +#define DEBUG_PRINT(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ + debug_print_prefix (_THIS_MODULE,__LINE__);\ + debug_print_raw PARAM_LIST(fp);\ + BREAK_ON_ERROR(lvl);} + +#define DEBUG_PRINT_RAW(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ + debug_print_raw PARAM_LIST(fp);} + + +/* Assert macros */ + +#define ACPI_ASSERT(exp) if(!(exp)) \ + acpi_os_dbg_assert(#exp, __FILE__, __LINE__, "Failed Assertion") + +#define DEBUG_ASSERT(msg, exp) if(!(exp)) \ + acpi_os_dbg_assert(#exp, __FILE__, __LINE__, msg) + + +#else +/* + * This is the non-debug case -- make everything go away, + * leaving no executable debug code! + */ + +#define MODULE_NAME(name) +#define _THIS_MODULE "" + +#define DEBUG_EXEC(a) +#define NORMAL_EXEC(a) a; + +#define DEBUG_DEFINE(a) +#define DEBUG_ONLY_MEMBERS(a) +#define FUNCTION_TRACE(a) +#define FUNCTION_TRACE_PTR(a,b) +#define FUNCTION_TRACE_U32(a,b) +#define FUNCTION_TRACE_STR(a,b) +#define FUNCTION_EXIT +#define FUNCTION_STATUS_EXIT(s) +#define FUNCTION_VALUE_EXIT(s) +#define DUMP_STACK_ENTRY(a) +#define DUMP_OPERANDS(a,b,c,d,e) +#define DUMP_ENTRY(a,b) +#define DUMP_TABLES(a,b) +#define DUMP_PATHNAME(a,b,c,d) +#define DUMP_RESOURCE_LIST(a) +#define DEBUG_PRINT(l,f) +#define DEBUG_PRINT_RAW(l,f) +#define BREAK_MSG(a) + +#define return_VOID return +#define return_ACPI_STATUS(s) return(s) +#define return_VALUE(s) return(s) +#define return_PTR(s) return(s) + +#define ACPI_ASSERT(exp) +#define DEBUG_ASSERT(msg, exp) + +#endif + +/* + * Some code only gets executed when the debugger is built in. + * Note that this is entirely independent of whether the + * DEBUG_PRINT stuff (set by ACPI_DEBUG) is on, or not. + */ +#ifdef ENABLE_DEBUGGER +#define DEBUGGER_EXEC(a) a; +#else +#define DEBUGGER_EXEC(a) +#endif + + +/* + * For 16-bit code, we want to shrink some things even though + * we are using ACPI_DEBUG to get the debug output + */ +#ifdef _IA16 +#undef DEBUG_ONLY_MEMBERS +#define DEBUG_ONLY_MEMBERS(a) +#undef OP_INFO_ENTRY +#define OP_INFO_ENTRY(opcode,flags,name,Pargs,Iargs) {opcode,flags,Pargs,Iargs} +#endif + + +#ifdef ACPI_DEBUG + +/* + * 1) Set name to blanks + * 2) Copy the object name + */ + +#define ADD_OBJECT_NAME(a,b) MEMSET (a->common.name, ' ', sizeof (a->common.name));\ + STRNCPY (a->common.name, acpi_gbl_ns_type_names[b], sizeof (a->common.name)) + +#else + +#define ADD_OBJECT_NAME(a,b) + +#endif + +#endif /* ACMACROS_H */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acnamesp.h linux/drivers/acpi/include/acnamesp.h --- v2.4.0-test8/linux/drivers/acpi/include/acnamesp.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/acnamesp.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,393 @@ +/****************************************************************************** + * + * Name: acnamesp.h - Namespace subcomponent prototypes and defines + * $Revision: 94 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + +#ifndef __ACNAMESP_H__ +#define __ACNAMESP_H__ + + +/* To search the entire name space, pass this as Search_base */ + +#define NS_ALL ((ACPI_HANDLE)0) + +/* + * Elements of Acpi_ns_properties are bit significant + * and should be one-to-one with values of ACPI_OBJECT_TYPE + */ +#define NSP_NORMAL 0 +#define NSP_NEWSCOPE 1 /* a definition of this type opens a name scope */ +#define NSP_LOCAL 2 /* suppress search of enclosing scopes */ + + +/* Definitions of the predefined namespace names */ + +#define ACPI_UNKNOWN_NAME (u32) 0x3F3F3F3F /* Unknown name is "????" */ +#define ACPI_ROOT_NAME (u32) 0x2F202020 /* Root name is "/ " */ +#define ACPI_SYS_BUS_NAME (u32) 0x5F53425F /* Sys bus name is "_SB_" */ + +#define NS_ROOT_PATH "/" +#define NS_SYSTEM_BUS "_SB_" + + +/* Flags for Acpi_ns_lookup, Acpi_ns_search_and_enter */ + +#define NS_NO_UPSEARCH 0 +#define NS_SEARCH_PARENT 0x01 +#define NS_DONT_OPEN_SCOPE 0x02 +#define NS_NO_PEER_SEARCH 0x04 + +#define NS_WALK_UNLOCK TRUE +#define NS_WALK_NO_UNLOCK FALSE + + +ACPI_STATUS +acpi_ns_walk_namespace ( + OBJECT_TYPE_INTERNAL type, + ACPI_HANDLE start_object, + u32 max_depth, + u8 unlock_before_callback, + WALK_CALLBACK user_function, + void *context, + void **return_value); + + +ACPI_NAMESPACE_NODE * +acpi_ns_get_next_object ( + OBJECT_TYPE_INTERNAL type, + ACPI_NAMESPACE_NODE *parent, + ACPI_NAMESPACE_NODE *child); + + +ACPI_STATUS +acpi_ns_delete_namespace_by_owner ( + u16 table_id); + + +/* Namespace loading - nsload */ + +ACPI_STATUS +acpi_ns_parse_table ( + ACPI_TABLE_DESC *table_desc, + ACPI_NAMESPACE_NODE *scope); + +ACPI_STATUS +acpi_ns_load_table ( + ACPI_TABLE_DESC *table_desc, + ACPI_NAMESPACE_NODE *node); + +ACPI_STATUS +acpi_ns_load_table_by_type ( + ACPI_TABLE_TYPE table_type); + + +/* + * Top-level namespace access - nsaccess + */ + + +ACPI_STATUS +acpi_ns_root_initialize ( + void); + +ACPI_STATUS +acpi_ns_lookup ( + ACPI_GENERIC_STATE *scope_info, + NATIVE_CHAR *name, + OBJECT_TYPE_INTERNAL type, + OPERATING_MODE interpreter_mode, + u32 flags, + ACPI_WALK_STATE *walk_state, + ACPI_NAMESPACE_NODE **ret_node); + + +/* + * Named object allocation/deallocation - nsalloc + */ + + +ACPI_NAMESPACE_NODE * +acpi_ns_create_node ( + u32 acpi_name); + +void +acpi_ns_delete_node ( + ACPI_NAMESPACE_NODE *node); + +ACPI_STATUS +acpi_ns_delete_namespace_subtree ( + ACPI_NAMESPACE_NODE *parent_handle); + +void +acpi_ns_detach_object ( + ACPI_NAMESPACE_NODE *node); + +void +acpi_ns_delete_children ( + ACPI_NAMESPACE_NODE *parent); + + +/* + * Namespace modification - nsmodify + */ + +ACPI_STATUS +acpi_ns_unload_namespace ( + ACPI_HANDLE handle); + +ACPI_STATUS +acpi_ns_delete_subtree ( + ACPI_HANDLE start_handle); + + +/* + * Namespace dump/print utilities - nsdump + */ + +void +acpi_ns_dump_tables ( + ACPI_HANDLE search_base, + u32 max_depth); + +void +acpi_ns_dump_entry ( + ACPI_HANDLE handle, + u32 debug_level); + +ACPI_STATUS +acpi_ns_dump_pathname ( + ACPI_HANDLE handle, + NATIVE_CHAR *msg, + u32 level, + u32 component); + +void +acpi_ns_dump_root_devices ( + void); + +void +acpi_ns_dump_objects ( + OBJECT_TYPE_INTERNAL type, + u32 max_depth, + u32 ownder_id, + ACPI_HANDLE start_handle); + + +/* + * Namespace evaluation functions - nseval + */ + +ACPI_STATUS +acpi_ns_evaluate_by_handle ( + ACPI_NAMESPACE_NODE *prefix_node, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **return_object); + +ACPI_STATUS +acpi_ns_evaluate_by_name ( + NATIVE_CHAR *pathname, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **return_object); + +ACPI_STATUS +acpi_ns_evaluate_relative ( + ACPI_NAMESPACE_NODE *prefix_node, + NATIVE_CHAR *pathname, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **return_object); + +ACPI_STATUS +acpi_ns_execute_control_method ( + ACPI_NAMESPACE_NODE *method_node, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **return_obj_desc); + +ACPI_STATUS +acpi_ns_get_object_value ( + ACPI_NAMESPACE_NODE *object_node, + ACPI_OPERAND_OBJECT **return_obj_desc); + + +/* + * Parent/Child/Peer utility functions - nsfamily + */ + +ACPI_NAME +acpi_ns_find_parent_name ( + ACPI_NAMESPACE_NODE *node_to_search); + +u8 +acpi_ns_exist_downstream_sibling ( + ACPI_NAMESPACE_NODE *this_node); + + +/* + * Scope manipulation - nsscope + */ + +u32 +acpi_ns_opens_scope ( + OBJECT_TYPE_INTERNAL type); + +NATIVE_CHAR * +acpi_ns_get_table_pathname ( + ACPI_NAMESPACE_NODE *node); + +NATIVE_CHAR * +acpi_ns_name_of_current_scope ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ns_handle_to_pathname ( + ACPI_HANDLE obj_handle, + u32 *buf_size, + NATIVE_CHAR *user_buffer); + +u8 +acpi_ns_pattern_match ( + ACPI_NAMESPACE_NODE *obj_node, + NATIVE_CHAR *search_for); + +ACPI_STATUS +acpi_ns_name_compare ( + ACPI_HANDLE obj_handle, + u32 level, + void *context, + void **return_value); + +ACPI_STATUS +acpi_ns_get_node ( + NATIVE_CHAR *pathname, + ACPI_NAMESPACE_NODE *in_prefix_node, + ACPI_NAMESPACE_NODE **out_node); + +/* + * Object management for NTEs - nsobject + */ + +ACPI_STATUS +acpi_ns_attach_object ( + ACPI_NAMESPACE_NODE *node, + ACPI_OPERAND_OBJECT *object, + OBJECT_TYPE_INTERNAL type); + + +void * +acpi_ns_compare_value ( + ACPI_HANDLE obj_handle, + u32 level, + void *obj_desc); + + +/* + * Namespace searching and entry - nssearch + */ + +ACPI_STATUS +acpi_ns_search_and_enter ( + u32 entry_name, + ACPI_WALK_STATE *walk_state, + ACPI_NAMESPACE_NODE *node, + OPERATING_MODE interpreter_mode, + OBJECT_TYPE_INTERNAL type, + u32 flags, + ACPI_NAMESPACE_NODE **ret_node); + +ACPI_STATUS +acpi_ns_search_node ( + u32 entry_name, + ACPI_NAMESPACE_NODE *node, + OBJECT_TYPE_INTERNAL type, + ACPI_NAMESPACE_NODE **ret_node); + +ACPI_NAMESPACE_NODE * +acpi_ns_create_node ( + u32 acpi_name); + +void +acpi_ns_install_node ( + ACPI_WALK_STATE *walk_state, + ACPI_NAMESPACE_NODE *parent_node, /* Parent */ + ACPI_NAMESPACE_NODE *node, /* New Child*/ + OBJECT_TYPE_INTERNAL type); + + +/* + * Utility functions - nsutils + */ + +u8 +acpi_ns_valid_root_prefix ( + NATIVE_CHAR prefix); + +u8 +acpi_ns_valid_path_separator ( + NATIVE_CHAR sep); + +OBJECT_TYPE_INTERNAL +acpi_ns_get_type ( + ACPI_HANDLE obj_handle); + +void * +acpi_ns_get_attached_object ( + ACPI_HANDLE obj_handle); + +u32 +acpi_ns_local ( + OBJECT_TYPE_INTERNAL type); + +ACPI_STATUS +acpi_ns_internalize_name ( + NATIVE_CHAR *dotted_name, + NATIVE_CHAR **converted_name); + +ACPI_STATUS +acpi_ns_externalize_name ( + u32 internal_name_length, + NATIVE_CHAR *internal_name, + u32 *converted_name_length, + NATIVE_CHAR **converted_name); + +ACPI_NAMESPACE_NODE * +acpi_ns_convert_handle_to_entry ( + ACPI_HANDLE handle); + +ACPI_HANDLE +acpi_ns_convert_entry_to_handle( + ACPI_NAMESPACE_NODE *node); + +void +acpi_ns_terminate ( + void); + +ACPI_NAMESPACE_NODE * +acpi_ns_get_parent_object ( + ACPI_NAMESPACE_NODE *node); + + +ACPI_NAMESPACE_NODE * +acpi_ns_get_next_valid_object ( + ACPI_NAMESPACE_NODE *node); + + +#endif /* __ACNAMESP_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acobject.h linux/drivers/acpi/include/acobject.h --- v2.4.0-test8/linux/drivers/acpi/include/acobject.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/acobject.h Fri Sep 15 14:30:30 2000 @@ -1,7 +1,8 @@ /****************************************************************************** * - * Name: acobject.h - Definition of ACPI_OBJECT_INTERNAL (Internal object only) + * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only) + * $Revision: 71 $ * *****************************************************************************/ @@ -26,17 +27,14 @@ #ifndef _ACOBJECT_H #define _ACOBJECT_H -#include "actypes.h" -#include "macros.h" -#include "internal.h" /* - * The ACPI_OBJECT_INTERNAL is used to pass AML operands from the dispatcher + * The ACPI_OPERAND_OBJECT is used to pass AML operands from the dispatcher * to the interpreter, and to keep track of the various handlers such as * address space handlers and notify handlers. The object is a constant * size in order to allow them to be cached and reused. * - * All variants of the ACPI_OBJECT_INTERNAL are defined with the same + * All variants of the ACPI_OPERAND_OBJECT are defined with the same * sequence of field types, with fields that are not used in a particular * variant being named "Reserved". This is not strictly necessary, but * may in some circumstances simplify understanding if these structures @@ -60,32 +58,31 @@ */ -#define ACPI_OBJECT_COMMON_HEADER /* Two 32-bit fields */\ - u8 data_type; /* To differentiate various internal objs */\ - u8 type; /* ACPI_OBJECT_TYPE */\ - u8 size; /* Size of entire descriptor */\ - u8 flags;\ - u16 reference_count; /* For object deletion management */\ - u16 acpi_cm_fill2;\ - union acpi_obj_internal *next; \ +#define ACPI_OBJECT_COMMON_HEADER /* Two 32-bit fields, one pointer, 8-bit flag */\ + u8 data_type; /* To differentiate various internal objs */\ + u8 type; /* ACPI_OBJECT_TYPE */\ + u16 reference_count; /* For object deletion management */\ + u8 flags; \ /* Defines for flag byte above */ -#define AO_STATIC_ALLOCATION 0x1 +#define AOPOBJ_STATIC_ALLOCATION 0x1 +#define AOPOBJ_DATA_VALID 0x2 +#define AOPOBJ_INITIALIZED 0x4 /* * Common bitfield for the field objects */ #define ACPI_COMMON_FIELD_INFO /* Three 32-bit values */\ - u32 offset; /* Byte offset within containing object */\ - u16 length; /* # of bits in buffer */ \ - u8 granularity;\ - u8 bit_offset; /* Bit offset within min read/write data unit */\ - u8 access; /* Access_type */\ - u8 lock_rule;\ - u8 update_rule;\ - u8 access_attribute; + u8 granularity;\ + u16 length; \ + u32 offset; /* Byte offset within containing object */\ + u8 bit_offset; /* Bit offset within min read/write data unit */\ + u8 access; /* Access_type */\ + u8 lock_rule;\ + u8 update_rule;\ + u8 access_attribute; /****************************************************************************** @@ -98,25 +95,23 @@ typedef struct /* COMMON */ { ACPI_OBJECT_COMMON_HEADER - UCHAR first_non_common_byte; } ACPI_OBJECT_COMMON; +typedef struct /* CACHE_LIST */ +{ + ACPI_OBJECT_COMMON_HEADER + union acpi_operand_obj *next; /* Link for object cache and internal lists*/ + +} ACPI_OBJECT_CACHE_LIST; + + typedef struct /* NUMBER - has value */ { ACPI_OBJECT_COMMON_HEADER - u32 value; - u32 reserved2; - u32 reserved3; - u32 reserved4; - - void *reserved_p1; - void *reserved_p2; - void *reserved_p3; - void *reserved_p4; - void *reserved_p5; + u32 value; } ACPI_OBJECT_NUMBER; @@ -125,16 +120,8 @@ { ACPI_OBJECT_COMMON_HEADER - u32 length; /* # of bytes in string, excluding trailing null */ - u32 reserved2; - u32 reserved3; - u32 reserved4; - - char *pointer; /* String value in AML stream or in allocated space */ - void *reserved_p2; - void *reserved_p3; - void *reserved_p4; - void *reserved_p5; + u32 length; + NATIVE_CHAR *pointer; /* String value in AML stream or in allocated space */ } ACPI_OBJECT_STRING; @@ -143,16 +130,10 @@ { ACPI_OBJECT_COMMON_HEADER - u32 length; /* # of bytes in buffer */ - u32 sequence; /* Sequential count of buffers created */ - u32 reserved3; - u32 reserved4; - - u8 *pointer; /* points to the buffer in allocated space */ - void *reserved_p2; - void *reserved_p3; - void *reserved_p4; - void *reserved_p5; + u32 length; + u32 sequence; /* Sequential count of buffers created */ + + u8 *pointer; /* points to the buffer in allocated space */ } ACPI_OBJECT_BUFFER; @@ -161,16 +142,10 @@ { ACPI_OBJECT_COMMON_HEADER - u32 count; /* # of elements in package */ - u32 reserved2; - u32 reserved3; - u32 reserved4; - - union acpi_obj_internal **elements; /* Array of pointers to Acpi_objects */ - union acpi_obj_internal **next_element; /* used only while initializing */ - void *reserved_p3; - void *reserved_p4; - void *reserved_p5; + u32 count; /* # of elements in package */ + + union acpi_operand_obj **elements; /* Array of pointers to Acpi_objects */ + union acpi_operand_obj **next_element; /* used only while initializing */ } ACPI_OBJECT_PACKAGE; @@ -180,13 +155,9 @@ ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO - u32 sequence; /* Container's sequence number */ + u32 sequence; /* Container's sequence number */ - union acpi_obj_internal *container; /* Containing object (Buffer) */ - void *reserved_p2; - void *reserved_p3; - void *reserved_p4; - void *reserved_p5; + union acpi_operand_obj *container; /* Containing object (Buffer) */ } ACPI_OBJECT_FIELD_UNIT; @@ -195,16 +166,9 @@ { ACPI_OBJECT_COMMON_HEADER - u32 reserved1; - u32 reserved2; - u32 reserved3; - u32 reserved4; - - ACPI_HANDLE handle; - union acpi_obj_internal *sys_handler; /* Handler for system notifies */ - union acpi_obj_internal *drv_handler; /* Handler for driver notifies */ - union acpi_obj_internal *addr_handler; /* Handler for Address space */ - void *reserved_p5; + union acpi_operand_obj *sys_handler; /* Handler for system notifies */ + union acpi_operand_obj *drv_handler; /* Handler for driver notifies */ + union acpi_operand_obj *addr_handler; /* Handler for Address space */ } ACPI_OBJECT_DEVICE; @@ -213,18 +177,7 @@ { ACPI_OBJECT_COMMON_HEADER - u16 lock_count; - u16 thread_id; - u16 signal_count; - u16 fill1; - u32 reserved3; - u32 reserved4; - - void *semaphore; - void *reserved_p2; - void *reserved_p3; - void *reserved_p4; - void *reserved_p5; + void *semaphore; } ACPI_OBJECT_EVENT; @@ -234,21 +187,17 @@ typedef struct /* METHOD */ { ACPI_OBJECT_COMMON_HEADER + u8 method_flags; + u8 param_count; + + u32 pcode_length; - u8 method_flags; - u8 param_count; - u8 concurrency; - u8 fill1; - u32 pcode_length; - u32 table_length; - ACPI_OWNER_ID owning_id; - u16 reserved4; - - u8 *pcode; - u8 *acpi_table; - void *parser_op; - void *semaphore; - void *reserved_p5; + void *semaphore; + u8 *pcode; + + u8 concurrency; + u8 thread_count; + ACPI_OWNER_ID owning_id; } ACPI_OBJECT_METHOD; @@ -256,45 +205,31 @@ typedef struct /* MUTEX */ { ACPI_OBJECT_COMMON_HEADER + u16 sync_level; - u16 lock_count; - u16 thread_id; - u16 sync_level; - u16 fill1; - u32 reserved3; - u32 reserved4; - - void *semaphore; - void *reserved_p2; - void *reserved_p3; - void *reserved_p4; - void *reserved_p5; + void *semaphore; } ACPI_OBJECT_MUTEX; -/* Flags for Region */ - -#define INITIAL_REGION_FLAGS 0x0000 /* value set when the region is created */ -#define REGION_AGRUMENT_DATA_VALID 0x0001 /* Addr/Len are set */ -#define REGION_INITIALIZED 0x0002 /* region init handler has been called */ - /* this includes _REG method, if any */ typedef struct /* REGION */ { ACPI_OBJECT_COMMON_HEADER - u16 space_id; - u16 region_flags; /* bits defined above */ - u32 address; - u32 length; - u32 reserved4; /* Region Specific data (PCI _ADR) */ - - union acpi_obj_internal *method; /* Associated control method */ - union acpi_obj_internal *addr_handler; /* Handler for system notifies */ - union acpi_obj_internal *link; /* Link in list of regions */ - /* list is owned by Addr_handler */ - ACPI_NAMED_OBJECT *REGmethod; /* _REG method for this region (if any) */ - ACPI_NAMED_OBJECT *nte; /* containing object */ + u8 space_id; + u32 length; + u32 address; + void *region_context; /* Region Specific data (Handler->Context + optional things like PCI _ADR) */ + + /* TBD: [Restructure] This field can go away when Pass3 is implemented */ + union acpi_operand_obj *method; /* Associated control method */ + + + union acpi_operand_obj *addr_handler; /* Handler for system notifies */ + ACPI_NAMESPACE_NODE *REGmethod; /* _REG method for this region (if any) */ + ACPI_NAMESPACE_NODE *node; /* containing object */ + union acpi_operand_obj *next; } ACPI_OBJECT_REGION; @@ -303,16 +238,11 @@ { ACPI_OBJECT_COMMON_HEADER - u32 system_level; - u32 resource_order; - u32 reserved3; - u32 reserved4; - - ACPI_HANDLE handle; - union acpi_obj_internal *sys_handler; /* Handler for system notifies */ - union acpi_obj_internal *drv_handler; /* Handler for driver notifies */ - void *reserved_p4; - void *reserved_p5; + u32 system_level; + u32 resource_order; + + union acpi_operand_obj *sys_handler; /* Handler for system notifies */ + union acpi_operand_obj *drv_handler; /* Handler for driver notifies */ } ACPI_OBJECT_POWER_RESOURCE; @@ -321,17 +251,13 @@ { ACPI_OBJECT_COMMON_HEADER - u32 proc_id; - ACPI_IO_ADDRESS pblk_address; - u16 fill1; - u32 pblk_length; - u32 reserved4; - - ACPI_HANDLE handle; - union acpi_obj_internal *sys_handler; /* Handler for system notifies */ - union acpi_obj_internal *drv_handler; /* Handler for driver notifies */ - union acpi_obj_internal *addr_handler; /* Handler for Address space */ - void *reserved_p5; + u32 proc_id; + u32 length; + ACPI_IO_ADDRESS address; + + union acpi_operand_obj *sys_handler; /* Handler for system notifies */ + union acpi_operand_obj *drv_handler; /* Handler for driver notifies */ + union acpi_operand_obj *addr_handler; /* Handler for Address space */ } ACPI_OBJECT_PROCESSOR; @@ -340,16 +266,9 @@ { ACPI_OBJECT_COMMON_HEADER - u32 reserved1; - u32 reserved2; - u32 reserved3; - u32 reserved4; - - ACPI_HANDLE handle; - union acpi_obj_internal *sys_handler; /* Handler for system notifies */ - union acpi_obj_internal *drv_handler; /* Handler for driver notifies */ - union acpi_obj_internal *addr_handler; /* Handler for Address space */ - void *reserved_p5; + union acpi_operand_obj *sys_handler; /* Handler for system notifies */ + union acpi_operand_obj *drv_handler; /* Handler for driver notifies */ + union acpi_operand_obj *addr_handler; /* Handler for Address space */ } ACPI_OBJECT_THERMAL_ZONE; @@ -358,18 +277,14 @@ * Internal types */ + typedef struct /* FIELD */ { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO - u32 reserved4; - union acpi_obj_internal *container; /* Containing object */ - void *reserved_p2; - void *reserved_p3; - void *reserved_p4; - void *reserved_p5; + union acpi_operand_obj *container; /* Containing object */ } ACPI_OBJECT_FIELD; @@ -379,13 +294,10 @@ ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO - u32 value; /* Value to store into Bank_select */ + u32 value; /* Value to store into Bank_select */ - ACPI_HANDLE bank_select; /* Bank select register */ - union acpi_obj_internal *container; /* Containing object */ - void *reserved_p3; - void *reserved_p4; - void *reserved_p5; + ACPI_HANDLE bank_select; /* Bank select register */ + union acpi_operand_obj *container; /* Containing object */ } ACPI_OBJECT_BANK_FIELD; @@ -399,13 +311,10 @@ ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO - u32 value; /* Value to store into Index register */ + u32 value; /* Value to store into Index register */ - ACPI_HANDLE index; /* Index register */ - ACPI_HANDLE data; /* Data register */ - void *reserved_p3; - void *reserved_p4; - void *reserved_p5; + ACPI_HANDLE index; /* Index register */ + ACPI_HANDLE data; /* Data register */ } ACPI_OBJECT_INDEX_FIELD; @@ -414,16 +323,9 @@ { ACPI_OBJECT_COMMON_HEADER - u32 reserved1; - u32 reserved2; - u32 reserved3; - u32 reserved4; - - ACPI_NAMED_OBJECT *nte; /* Parent device */ - NOTIFY_HANDLER handler; - void *context; - void *reserved_p4; - void *reserved_p5; + ACPI_NAMESPACE_NODE *node; /* Parent device */ + NOTIFY_HANDLER handler; + void *context; } ACPI_OBJECT_NOTIFY_HANDLER; @@ -432,19 +334,20 @@ #define ADDR_HANDLER_DEFAULT_INSTALLED 0x1 + typedef struct /* ADDRESS HANDLER */ { ACPI_OBJECT_COMMON_HEADER - u16 space_id; - u16 hflags; - ADDRESS_SPACE_HANDLER handler; - - ACPI_NAMED_OBJECT *nte; /* Parent device */ - void *context; - ADDRESS_SPACE_SETUP setup; - union acpi_obj_internal *link; /* Link to next handler on device */ - union acpi_obj_internal *region_list; /* regions using this handler */ + u8 space_id; + u16 hflags; + ADDRESS_SPACE_HANDLER handler; + + ACPI_NAMESPACE_NODE *node; /* Parent device */ + void *context; + ADDRESS_SPACE_SETUP setup; + union acpi_operand_obj *region_list; /* regions using this handler */ + union acpi_operand_obj *next; } ACPI_OBJECT_ADDR_HANDLER; @@ -458,31 +361,27 @@ { ACPI_OBJECT_COMMON_HEADER - u16 op_code; - u8 fill1; - u8 target_type; /* Used for Index_op */ - u32 offset; /* Used for Arg_op, Local_op, and Index_op */ - u32 reserved3; - u32 reserved4; - - void *object; /* Name_op=>HANDLE to obj, Index_op=>ACPI_OBJECT_INTERNAL */ - ACPI_NAMED_OBJECT *nte; - union acpi_obj_internal **where; - void *reserved_p4; - void *reserved_p5; + u8 target_type; /* Used for Index_op */ + u16 op_code; + u32 offset; /* Used for Arg_op, Local_op, and Index_op */ + + void *object; /* Name_op=>HANDLE to obj, Index_op=>ACPI_OPERAND_OBJECT */ + ACPI_NAMESPACE_NODE *node; + union acpi_operand_obj **where; } ACPI_OBJECT_REFERENCE; /****************************************************************************** * - * ACPI_OBJECT_INTERNAL Descriptor - a giant union of all of the above + * ACPI_OPERAND_OBJECT Descriptor - a giant union of all of the above * *****************************************************************************/ -typedef union acpi_obj_internal +typedef union acpi_operand_obj { ACPI_OBJECT_COMMON common; + ACPI_OBJECT_CACHE_LIST cache; ACPI_OBJECT_NUMBER number; ACPI_OBJECT_STRING string; ACPI_OBJECT_BUFFER buffer; @@ -503,6 +402,6 @@ ACPI_OBJECT_NOTIFY_HANDLER notify_handler; ACPI_OBJECT_ADDR_HANDLER addr_handler; -} ACPI_OBJECT_INTERNAL; +} ACPI_OPERAND_OBJECT; #endif /* _ACOBJECT_H */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acoutput.h linux/drivers/acpi/include/acoutput.h --- v2.4.0-test8/linux/drivers/acpi/include/acoutput.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/acoutput.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,124 @@ +/****************************************************************************** + * + * Name: acoutput.h -- debug output + * $Revision: 63 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + +#ifndef __ACOUTPUT_H__ +#define __ACOUTPUT_H__ + +/* + * Debug levels and component IDs. These are used to control the + * granularity of the output of the DEBUG_PRINT macro -- on a per- + * component basis and a per-exception-type basis. + */ + +/* Component IDs -- used in the global "Debug_layer" */ + +#define GLOBAL 0x00000001 +#define COMMON 0x00000002 +#define PARSER 0x00000004 +#define DISPATCHER 0x00000008 +#define INTERPRETER 0x00000010 +#define NAMESPACE 0x00000020 +#define RESOURCE_MANAGER 0x00000040 +#define TABLE_MANAGER 0x00000080 +#define EVENT_HANDLING 0x00000100 +#define HARDWARE 0x00000200 +#define MISCELLANEOUS 0x00000400 +#define OS_DEPENDENT 0x00000800 + +#define BUS_MANAGER 0x00001000 + +#define PROCESSOR_CONTROL 0x00002000 +#define SYSTEM_CONTROL 0x00004000 +#define THERMAL_CONTROL 0x00008000 +#define POWER_CONTROL 0x00010000 + +#define EMBEDDED_CONTROLLER 0x00020000 +#define BATTERY 0x00040000 + +#define DEBUGGER 0x00100000 +#define ALL_COMPONENTS 0x001FFFFF + + +/* Exception level -- used in the global "Debug_level" */ + +#define ACPI_OK 0x00000001 +#define ACPI_INFO 0x00000002 +#define ACPI_WARN 0x00000004 +#define ACPI_ERROR 0x00000008 +#define ACPI_FATAL 0x00000010 +#define ACPI_DEBUG_OBJECT 0x00000020 +#define ACPI_ALL 0x0000003F + + +/* Trace level -- also used in the global "Debug_level" */ + +#define TRACE_PARSE 0x00000100 +#define TRACE_DISPATCH 0x00000200 +#define TRACE_LOAD 0x00000400 +#define TRACE_EXEC 0x00000800 +#define TRACE_NAMES 0x00001000 +#define TRACE_OPREGION 0x00002000 +#define TRACE_BFIELD 0x00004000 +#define TRACE_TRASH 0x00008000 +#define TRACE_TABLES 0x00010000 +#define TRACE_FUNCTIONS 0x00020000 +#define TRACE_VALUES 0x00040000 +#define TRACE_OBJECTS 0x00080000 +#define TRACE_ALLOCATIONS 0x00100000 +#define TRACE_RESOURCES 0x00200000 +#define TRACE_IO 0x00400000 +#define TRACE_INTERRUPTS 0x00800000 +#define TRACE_USER_REQUESTS 0x01000000 +#define TRACE_PACKAGE 0x02000000 +#define TRACE_MUTEX 0x04000000 + +#define TRACE_ALL 0x0FFFFF00 + + +/* Exceptionally verbose output -- also used in the global "Debug_level" */ + +#define VERBOSE_AML_DISASSEMBLE 0x10000000 +#define VERBOSE_INFO 0x20000000 +#define VERBOSE_TABLES 0x40000000 +#define VERBOSE_EVENTS 0x80000000 + +#define VERBOSE_ALL 0x70000000 + + +/* Defaults for Debug_level, debug and normal */ + +#define DEBUG_DEFAULT (ACPI_OK | ACPI_WARN | ACPI_ERROR | ACPI_DEBUG_OBJECT | TRACE_TABLES | TRACE_IO) +#define NORMAL_DEFAULT (ACPI_OK | ACPI_WARN | ACPI_ERROR | ACPI_DEBUG_OBJECT) +#define DEBUG_ALL (VERBOSE_AML_DISASSEMBLE | TRACE_ALL | ACPI_ALL) + +/* Misc defines */ + +#define HEX 0x01 +#define ASCII 0x02 +#define FULL_ADDRESS 0x04 +#define CHARS_PER_LINE 16 /* used in Dump_buf function */ + + +#endif /* __ACOUTPUT_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acparser.h linux/drivers/acpi/include/acparser.h --- v2.4.0-test8/linux/drivers/acpi/include/acparser.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/acparser.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,345 @@ +/****************************************************************************** + * + * Module Name: acparser.h - AML Parser subcomponent prototypes and defines + * $Revision: 46 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + + +#ifndef __ACPARSER_H__ +#define __ACPARSER_H__ + + +#define OP_HAS_RETURN_VALUE 1 + +/* variable # arguments */ + +#define ACPI_VAR_ARGS ACPI_UINT32_MAX + +/* maximum virtual address */ + +#define ACPI_MAX_AML ((u8 *)(~0UL)) + + +#define ACPI_PARSE_DELETE_TREE 0x0001 +#define ACPI_PARSE_NO_TREE_DELETE 0x0000 +#define ACPI_PARSE_TREE_MASK 0x0001 + +#define ACPI_PARSE_LOAD_PASS1 0x0010 +#define ACPI_PARSE_LOAD_PASS2 0x0020 +#define ACPI_PARSE_EXECUTE 0x0030 +#define ACPI_PARSE_MODE_MASK 0x0030 + +/* psapi - Parser external interfaces */ + +ACPI_STATUS +acpi_psx_load_table ( + u8 *pcode_addr, + u32 pcode_length); + +ACPI_STATUS +acpi_psx_execute ( + ACPI_NAMESPACE_NODE *method_node, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **return_obj_desc); + + +u8 +acpi_ps_is_namespace_object_op ( + u16 opcode); +u8 +acpi_ps_is_namespace_op ( + u16 opcode); + + +/****************************************************************************** + * + * Parser interfaces + * + *****************************************************************************/ + + +/* psargs - Parse AML opcode arguments */ + +u8 * +acpi_ps_get_next_package_end ( + ACPI_PARSE_STATE *parser_state); + +u32 +acpi_ps_get_next_package_length ( + ACPI_PARSE_STATE *parser_state); + +NATIVE_CHAR * +acpi_ps_get_next_namestring ( + ACPI_PARSE_STATE *parser_state); + +void +acpi_ps_get_next_simple_arg ( + ACPI_PARSE_STATE *parser_state, + u32 arg_type, /* type of argument */ + ACPI_PARSE_OBJECT *arg); /* (OUT) argument data */ + +void +acpi_ps_get_next_namepath ( + ACPI_PARSE_STATE *parser_state, + ACPI_PARSE_OBJECT *arg, + u32 *arg_count, + u8 method_call); + +ACPI_PARSE_OBJECT * +acpi_ps_get_next_field ( + ACPI_PARSE_STATE *parser_state); + +ACPI_PARSE_OBJECT * +acpi_ps_get_next_arg ( + ACPI_PARSE_STATE *parser_state, + u32 arg_type, + u32 *arg_count); + + +/* psopcode - AML Opcode information */ + +ACPI_OPCODE_INFO * +acpi_ps_get_opcode_info ( + u16 opcode); + +NATIVE_CHAR * +acpi_ps_get_opcode_name ( + u16 opcode); + + +/* psparse - top level parsing routines */ + +ACPI_STATUS +acpi_ps_find_object ( + u16 opcode, + ACPI_PARSE_OBJECT *op, + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT **out_op); + +void +acpi_ps_delete_parse_tree ( + ACPI_PARSE_OBJECT *root); + +ACPI_STATUS +acpi_ps_parse_loop ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ps_parse_aml ( + ACPI_PARSE_OBJECT *start_scope, + u8 *aml, + u32 aml_size, + u32 parse_flags, + ACPI_NAMESPACE_NODE *method_node, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **caller_return_desc, + ACPI_PARSE_DOWNWARDS descending_callback, + ACPI_PARSE_UPWARDS ascending_callback); + +ACPI_STATUS +acpi_ps_parse_table ( + u8 *aml, + u32 aml_size, + ACPI_PARSE_DOWNWARDS descending_callback, + ACPI_PARSE_UPWARDS ascending_callback, + ACPI_PARSE_OBJECT **root_object); + +u16 +acpi_ps_peek_opcode ( + ACPI_PARSE_STATE *state); + + +/* psscope - Scope stack management routines */ + + +ACPI_STATUS +acpi_ps_init_scope ( + ACPI_PARSE_STATE *parser_state, + ACPI_PARSE_OBJECT *root); + +ACPI_PARSE_OBJECT * +acpi_ps_get_parent_scope ( + ACPI_PARSE_STATE *state); + +u8 +acpi_ps_has_completed_scope ( + ACPI_PARSE_STATE *parser_state); + +void +acpi_ps_pop_scope ( + ACPI_PARSE_STATE *parser_state, + ACPI_PARSE_OBJECT **op, + u32 *arg_list); + +ACPI_STATUS +acpi_ps_push_scope ( + ACPI_PARSE_STATE *parser_state, + ACPI_PARSE_OBJECT *op, + u32 remaining_args, + u32 arg_count); + +void +acpi_ps_cleanup_scope ( + ACPI_PARSE_STATE *state); + + +/* pstree - parse tree manipulation routines */ + +void +acpi_ps_append_arg( + ACPI_PARSE_OBJECT *op, + ACPI_PARSE_OBJECT *arg); + +ACPI_PARSE_OBJECT* +acpi_ps_find ( + ACPI_PARSE_OBJECT *scope, + NATIVE_CHAR *path, + u16 opcode, + u32 create); + +ACPI_PARSE_OBJECT * +acpi_ps_get_arg( + ACPI_PARSE_OBJECT *op, + u32 argn); + +ACPI_PARSE_OBJECT * +acpi_ps_get_child ( + ACPI_PARSE_OBJECT *op); + +ACPI_PARSE_OBJECT * +acpi_ps_get_depth_next ( + ACPI_PARSE_OBJECT *origin, + ACPI_PARSE_OBJECT *op); + + +/* pswalk - parse tree walk routines */ + +ACPI_STATUS +acpi_ps_walk_parsed_aml ( + ACPI_PARSE_OBJECT *start_op, + ACPI_PARSE_OBJECT *end_op, + ACPI_OPERAND_OBJECT *mth_desc, + ACPI_NAMESPACE_NODE *start_node, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **caller_return_desc, + ACPI_OWNER_ID owner_id, + ACPI_PARSE_DOWNWARDS descending_callback, + ACPI_PARSE_UPWARDS ascending_callback); + +ACPI_STATUS +acpi_ps_get_next_walk_op ( + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *op, + ACPI_PARSE_UPWARDS ascending_callback); + + +/* psutils - parser utilities */ + + +ACPI_PARSE_STATE * +acpi_ps_create_state ( + u8 *aml, + u32 aml_size); + +void +acpi_ps_init_op ( + ACPI_PARSE_OBJECT *op, + u16 opcode); + +ACPI_PARSE_OBJECT * +acpi_ps_alloc_op ( + u16 opcode); + +void +acpi_ps_free_op ( + ACPI_PARSE_OBJECT *op); + +void +acpi_ps_delete_parse_cache ( + void); + +u8 +acpi_ps_is_leading_char ( + u32 c); + +u8 +acpi_ps_is_prefix_char ( + u32 c); + +u8 +acpi_ps_is_named_op ( + u16 opcode); + +u8 +acpi_ps_is_node_op ( + u16 opcode); + +u8 +acpi_ps_is_deferred_op ( + u16 opcode); + +u8 +acpi_ps_is_bytelist_op( + u16 opcode); + +u8 +acpi_ps_is_field_op( + u16 opcode); + +u8 +acpi_ps_is_create_field_op ( + u16 opcode); + +ACPI_PARSE2_OBJECT* +acpi_ps_to_extended_op( + ACPI_PARSE_OBJECT *op); + +u32 +acpi_ps_get_name( + ACPI_PARSE_OBJECT *op); + +void +acpi_ps_set_name( + ACPI_PARSE_OBJECT *op, + u32 name); + + +/* psdump - display parser tree */ + +u32 +acpi_ps_sprint_path ( + NATIVE_CHAR *buffer_start, + u32 buffer_size, + ACPI_PARSE_OBJECT *op); + +u32 +acpi_ps_sprint_op ( + NATIVE_CHAR *buffer_start, + u32 buffer_size, + ACPI_PARSE_OBJECT *op); + +void +acpi_ps_show ( + ACPI_PARSE_OBJECT *op); + + +#endif /* __ACPARSER_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acpi.h linux/drivers/acpi/include/acpi.h --- v2.4.0-test8/linux/drivers/acpi/include/acpi.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/acpi.h Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Name: acpi.h - Master include file, Publics and external data. + * $Revision: 48 $ * *****************************************************************************/ @@ -31,20 +31,20 @@ * We put them here because we don't want to duplicate them * in the rest of the source code again and again. */ -#include "config.h" /* Configuration constants */ +#include "acconfig.h" /* Configuration constants */ #include "acenv.h" /* Target environment specific items */ #include "actypes.h" /* Fundamental data types */ #include "acexcep.h" /* Local exception codes */ -#include "macros.h" /* C macros */ -#include "actables.h" /* Acpi table definitions */ -#include "internal.h" /* Internal data types */ -#include "output.h" /* Error output and Debug macros */ +#include "acmacros.h" /* C macros */ +#include "actbl.h" /* Acpi table definitions */ +#include "aclocal.h" /* Internal data types */ +#include "acoutput.h" /* Error output and Debug macros */ #include "acpiosxf.h" /* Interfaces to the Acpi-to-OS layer*/ #include "acpixf.h" /* Acpi core external interfaces */ #include "acobject.h" /* Acpi internal object */ -#include "globals.h" /* All global variables */ -#include "hardware.h" /* Hardware defines and interfaces */ -#include "common.h" /* Common (global) interfaces */ +#include "acglobal.h" /* All global variables */ +#include "achware.h" /* Hardware defines and interfaces */ +#include "accommon.h" /* Common (global) interfaces */ #endif /* __ACPI_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acpiosxf.h linux/drivers/acpi/include/acpiosxf.h --- v2.4.0-test8/linux/drivers/acpi/include/acpiosxf.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/acpiosxf.h Fri Sep 15 14:30:30 2000 @@ -244,7 +244,7 @@ ACPI_STATUS acpi_os_breakpoint ( - char *message); + NATIVE_CHAR *message); u8 acpi_os_readable ( @@ -264,12 +264,12 @@ s32 acpi_os_printf ( - const char *format, + const NATIVE_CHAR *format, ...); s32 acpi_os_vprintf ( - const char *format, + const NATIVE_CHAR *format, va_list args); /* @@ -278,7 +278,7 @@ u32 acpi_os_get_line ( - char *buffer); + NATIVE_CHAR *buffer); /* @@ -290,7 +290,7 @@ void *failed_assertion, void *file_name, u32 line_number, - char *message); + NATIVE_CHAR *message); #endif /* __ACPIOSD_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acpixf.h linux/drivers/acpi/include/acpixf.h --- v2.4.0-test8/linux/drivers/acpi/include/acpixf.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/acpixf.h Fri Sep 15 14:30:30 2000 @@ -28,7 +28,7 @@ #define __ACXFACE_H__ #include "actypes.h" -#include "actables.h" +#include "actbl.h" /* * Global interfaces diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/acresrc.h linux/drivers/acpi/include/acresrc.h --- v2.4.0-test8/linux/drivers/acpi/include/acresrc.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/acresrc.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,304 @@ +/****************************************************************************** + * + * Name: acresrc.h - Resource Manager function prototypes + * $Revision: 20 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + +#ifndef __ACRESRC_H__ +#define __ACRESRC_H__ + + +/* + * Function prototypes called from Acpi* APIs + */ + +ACPI_STATUS +acpi_rs_get_prt_method_data ( + ACPI_HANDLE handle, + ACPI_BUFFER *ret_buffer); + + +ACPI_STATUS +acpi_rs_get_crs_method_data ( + ACPI_HANDLE handle, + ACPI_BUFFER *ret_buffer); + +ACPI_STATUS +acpi_rs_get_prs_method_data ( + ACPI_HANDLE handle, + ACPI_BUFFER *ret_buffer); + +ACPI_STATUS +acpi_rs_set_srs_method_data ( + ACPI_HANDLE handle, + ACPI_BUFFER *ret_buffer); + +ACPI_STATUS +acpi_rs_create_resource_list ( + ACPI_OPERAND_OBJECT *byte_stream_buffer, + u8 *output_buffer, + u32 *output_buffer_length); + +ACPI_STATUS +acpi_rs_create_byte_stream ( + RESOURCE *linked_list_buffer, + u8 *output_buffer, + u32 *output_buffer_length); + +ACPI_STATUS +acpi_rs_create_pci_routing_table ( + ACPI_OPERAND_OBJECT *method_return_object, + u8 *output_buffer, + u32 *output_buffer_length); + + +/* + *Function prototypes called from Acpi_rs_create*APIs + */ + +void +acpi_rs_dump_resource_list ( + RESOURCE *resource); + +void +acpi_rs_dump_irq_list ( + u8 *route_table); + +ACPI_STATUS +acpi_rs_get_byte_stream_start ( + u8 *byte_stream_buffer, + u8 **byte_stream_start, + u32 *size); + +ACPI_STATUS +acpi_rs_calculate_list_length ( + u8 *byte_stream_buffer, + u32 byte_stream_buffer_length, + u32 *size_needed); + +ACPI_STATUS +acpi_rs_calculate_byte_stream_length ( + RESOURCE *linked_list_buffer, + u32 *size_needed); + +ACPI_STATUS +acpi_rs_calculate_pci_routing_table_length ( + ACPI_OPERAND_OBJECT *package_object, + u32 *buffer_size_needed); + +ACPI_STATUS +acpi_rs_byte_stream_to_list ( + u8 *byte_stream_buffer, + u32 byte_stream_buffer_length, + u8 **output_buffer); + +ACPI_STATUS +acpi_rs_list_to_byte_stream ( + RESOURCE *linked_list, + u32 byte_stream_size_needed, + u8 **output_buffer); + +ACPI_STATUS +acpi_rs_io_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_fixed_io_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_io_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_fixed_io_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_irq_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_irq_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_dma_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_dma_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_address16_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_address16_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_address32_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_address32_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_start_dependent_functions_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_end_dependent_functions_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_start_dependent_functions_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_end_dependent_functions_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_memory24_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_memory24_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_memory32_range_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size +); + +ACPI_STATUS +acpi_rs_fixed_memory32_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_memory32_range_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_fixed_memory32_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_extended_irq_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_extended_irq_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_end_tag_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_end_tag_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_vendor_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_vendor_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + + +#endif /* __ACRESRC_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/actables.h linux/drivers/acpi/include/actables.h --- v2.4.0-test8/linux/drivers/acpi/include/actables.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/actables.h Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * - * Name: actables.h - Table data structures defined in ACPI specification + * Name: actables.h - ACPI table management + * $Revision: 20 $ * *****************************************************************************/ @@ -27,162 +27,139 @@ #define __ACTABLES_H__ -/* - * Values for description table header signatures - */ - -#define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */ -#define APIC_SIG "APIC" /* Multiple APIC Description Table */ -#define DSDT_SIG "DSDT" /* Differentiated System Description Table */ -#define FACP_SIG "FACP" /* Fixed ACPI Description Table */ -#define FACS_SIG "FACS" /* Firmware ACPI Control Structure */ -#define PSDT_SIG "PSDT" /* Persistent System Description Table */ -#define RSDT_SIG "RSDT" /* Root System Description Table */ -#define SSDT_SIG "SSDT" /* Secondary System Description Table */ -#define SBST_SIG "SBST" /* Smart Battery Specification Table */ -#define BOOT_SIG "BOOT" /* Boot table */ - - -#define GL_OWNED 0x02 /* Ownership of global lock is bit 1 */ +/* Used in Acpi_tb_map_acpi_table for size parameter if table header is to be used */ -/* values of Mapic.Model */ +#define SIZE_IN_HEADER 0 -#define DUAL_PIC 0 -#define MULTIPLE_APIC 1 -/* values of Type in APIC_HEADER */ - -#define APIC_PROC 0 -#define APIC_IO 1 +ACPI_STATUS +acpi_tb_handle_to_object ( + u16 table_id, + ACPI_TABLE_DESC **table_desc); /* - * Architecture-independent tables - * The architecture dependent tables are in separate files + * Acpi_tbfac - FACP, FACS utilities */ -typedef struct /* Root System Descriptor Pointer */ -{ - char signature [8]; /* contains "RSD PTR " */ - u8 checksum; /* to make sum of struct == 0 */ - char oem_id [6]; /* OEM identification */ - u8 reserved; /* reserved - must be zero */ - u32 rsdt_physical_address; /* physical address of RSDT */ - -} ROOT_SYSTEM_DESCRIPTOR_POINTER; +ACPI_STATUS +acpi_tb_get_table_facs ( + ACPI_TABLE_HEADER *buffer_ptr, + ACPI_TABLE_DESC *table_info); -typedef struct /* ACPI common table header */ -{ - char signature [4]; /* identifies type of table */ - u32 length; /* length of table, in bytes, - * including header */ - u8 revision; /* specification minor version # */ - u8 checksum; /* to make sum of entire table == 0 */ - char oem_id [6]; /* OEM identification */ - char oem_table_id [8]; /* OEM table identification */ - u32 oem_revision; /* OEM revision number */ - char asl_compiler_id [4]; /* ASL compiler vendor ID */ - u32 asl_compiler_revision; /* ASL compiler revision number */ +/* + * Acpi_tbget - Table "get" routines + */ -} ACPI_TABLE_HEADER; +ACPI_STATUS +acpi_tb_get_table_ptr ( + ACPI_TABLE_TYPE table_type, + u32 instance, + ACPI_TABLE_HEADER **table_ptr_loc); +ACPI_STATUS +acpi_tb_get_table ( + void *physical_address, + ACPI_TABLE_HEADER *buffer_ptr, + ACPI_TABLE_DESC *table_info); -typedef struct /* APIC Table */ -{ - ACPI_TABLE_HEADER header; /* table header */ - u32 local_apic_address; /* Physical address for accessing local APICs */ - u32 PCATcompat : 1; /* a one indicates system also has dual 8259s */ - u32 reserved1 : 31; -} APIC_TABLE; +/* + * Acpi_tbgetall - Get all firmware ACPI tables + */ +ACPI_STATUS +acpi_tb_get_all_tables ( + u32 number_of_tables, + ACPI_TABLE_HEADER *buffer_ptr); -typedef struct /* APIC Header */ -{ - u8 type; /* APIC type. Either APIC_PROC or APIC_IO */ - u8 length; /* Length of APIC structure */ -} APIC_HEADER; +/* + * Acpi_tbinstall - Table installation + */ +ACPI_STATUS +acpi_tb_install_table ( + ACPI_TABLE_HEADER *table_ptr, + ACPI_TABLE_DESC *table_info); -typedef struct /* Processor APIC */ -{ - APIC_HEADER header; - u8 processor_apic_id; /* ACPI processor id */ - u8 local_apic_id; /* processor's local APIC id */ - u32 processor_enabled: 1; /* Processor is usable if set */ - u32 reserved1 : 32; +ACPI_STATUS +acpi_tb_recognize_table ( + ACPI_TABLE_HEADER *table_ptr, + ACPI_TABLE_DESC *table_info); -} PROCESSOR_APIC; +ACPI_STATUS +acpi_tb_init_table_descriptor ( + ACPI_TABLE_TYPE table_type, + ACPI_TABLE_DESC *table_info); -typedef struct /* IO APIC */ -{ - APIC_HEADER header; - u8 io_apic_id; /* I/O APIC ID */ - u8 reserved; /* reserved - must be zero */ - u32 io_apic_address; /* APIC's physical address */ - u32 vector; /* interrupt vector index where INTI - * lines start */ -} IO_APIC; +/* + * Acpi_tbremove - Table removal and deletion + */ +void +acpi_tb_delete_acpi_tables ( + void); -/* -** IA64 TODO: Add SAPIC Tables -*/ +void +acpi_tb_delete_acpi_table ( + ACPI_TABLE_TYPE type); -/* -** IA64 TODO: Modify Smart Battery Description to comply with ACPI IA64 -** extensions. -*/ -typedef struct /* Smart Battery Description Table */ -{ - ACPI_TABLE_HEADER header; - u32 warning_level; - u32 low_level; - u32 critical_level; +ACPI_TABLE_DESC * +acpi_tb_delete_single_table ( + ACPI_TABLE_DESC *table_desc); -} SMART_BATTERY_DESCRIPTION_TABLE; +void +acpi_tb_free_acpi_tables_of_type ( + ACPI_TABLE_DESC *table_info); /* - * ACPI Table information. We save the table address, length, - * and type of memory allocation (mapped or allocated) for each - * table for 1) when we exit, and 2) if a new table is installed + * Acpi_tbrsd - RSDP, RSDT utilities */ -#define ACPI_MEM_NOT_ALLOCATED 0 -#define ACPI_MEM_ALLOCATED 1 -#define ACPI_MEM_MAPPED 2 - -#define ACPI_TABLE_SINGLE 0 -#define ACPI_TABLE_MULTIPLE 1 - - -/* Data about each known table type */ +ACPI_STATUS +acpi_tb_get_table_rsdt ( + u32 *number_of_tables); -typedef struct _acpi_table_support -{ - char *name; - char *signature; - u8 sig_length; - u8 flags; - u16 status; - void **global_ptr; +u8 * +acpi_tb_scan_memory_for_rsdp ( + u8 *start_address, + u32 length); -} ACPI_TABLE_SUPPORT; +ACPI_STATUS +acpi_tb_find_rsdp ( + ACPI_TABLE_DESC *table_info); /* - * Get the architecture-specific tables + * Acpi_tbutils - common table utilities */ -#ifdef IA64 -#include "actbl64.h" -#else -#include "actbl32.h" -#endif +u8 +acpi_tb_system_table_pointer ( + void *where); + +ACPI_STATUS +acpi_tb_map_acpi_table ( + void *physical_address, + u32 *size, + void **logical_address); + +ACPI_STATUS +acpi_tb_verify_table_checksum ( + ACPI_TABLE_HEADER *table_header); + +u8 +acpi_tb_checksum ( + void *buffer, + u32 length); + +ACPI_STATUS +acpi_tb_validate_table_header ( + ACPI_TABLE_HEADER *table_header); #endif /* __ACTABLES_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/actbl.h linux/drivers/acpi/include/actbl.h --- v2.4.0-test8/linux/drivers/acpi/include/actbl.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/include/actbl.h Fri Sep 15 14:30:30 2000 @@ -0,0 +1,190 @@ +/****************************************************************************** + * + * Name: actbl.h - Table data structures defined in ACPI specification + * $Revision: 34 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + +#ifndef __ACTBL_H__ +#define __ACTBL_H__ + + +/* + * Values for description table header signatures + */ + +#define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */ +#define APIC_SIG "APIC" /* Multiple APIC Description Table */ +#define DSDT_SIG "DSDT" /* Differentiated System Description Table */ +#define FACP_SIG "FACP" /* Fixed ACPI Description Table */ +#define FACS_SIG "FACS" /* Firmware ACPI Control Structure */ +#define PSDT_SIG "PSDT" /* Persistent System Description Table */ +#define RSDT_SIG "RSDT" /* Root System Description Table */ +#define SSDT_SIG "SSDT" /* Secondary System Description Table */ +#define SBST_SIG "SBST" /* Smart Battery Specification Table */ +#define BOOT_SIG "BOOT" /* Boot table */ + + +#define GL_OWNED 0x02 /* Ownership of global lock is bit 1 */ + +/* values of Mapic.Model */ + +#define DUAL_PIC 0 +#define MULTIPLE_APIC 1 + +/* values of Type in APIC_HEADER */ + +#define APIC_PROC 0 +#define APIC_IO 1 + + +/* + * Architecture-independent tables + * The architecture dependent tables are in separate files + */ + +typedef struct /* Root System Descriptor Pointer */ +{ + NATIVE_CHAR signature [8]; /* contains "RSD PTR " */ + u8 checksum; /* to make sum of struct == 0 */ + NATIVE_CHAR oem_id [6]; /* OEM identification */ + u8 reserved; /* reserved - must be zero */ + u32 rsdt_physical_address; /* physical address of RSDT */ + +} ROOT_SYSTEM_DESCRIPTOR_POINTER; + + +typedef struct /* ACPI common table header */ +{ + NATIVE_CHAR signature [4]; /* identifies type of table */ + u32 length; /* length of table, in bytes, + * including header */ + u8 revision; /* specification minor version # */ + u8 checksum; /* to make sum of entire table == 0 */ + NATIVE_CHAR oem_id [6]; /* OEM identification */ + NATIVE_CHAR oem_table_id [8]; /* OEM table identification */ + u32 oem_revision; /* OEM revision number */ + NATIVE_CHAR asl_compiler_id [4]; /* ASL compiler vendor ID */ + u32 asl_compiler_revision; /* ASL compiler revision number */ + +} ACPI_TABLE_HEADER; + + +typedef struct /* APIC Table */ +{ + ACPI_TABLE_HEADER header; /* table header */ + u32 local_apic_address; /* Physical address for accessing local APICs */ + u32 PCATcompat : 1; /* a one indicates system also has dual 8259s */ + u32 reserved1 : 31; + +} APIC_TABLE; + + +typedef struct /* APIC Header */ +{ + u8 type; /* APIC type. Either APIC_PROC or APIC_IO */ + u8 length; /* Length of APIC structure */ + +} APIC_HEADER; + + +typedef struct /* Processor APIC */ +{ + APIC_HEADER header; + u8 processor_apic_id; /* ACPI processor id */ + u8 local_apic_id; /* processor's local APIC id */ + u32 processor_enabled: 1; /* Processor is usable if set */ + u32 reserved1 : 32; + +} PROCESSOR_APIC; + + +typedef struct /* IO APIC */ +{ + APIC_HEADER header; + u8 io_apic_id; /* I/O APIC ID */ + u8 reserved; /* reserved - must be zero */ + u32 io_apic_address; /* APIC's physical address */ + u32 vector; /* interrupt vector index where INTI + * lines start */ +} IO_APIC; + + +/* +** IA64 TODO: Add SAPIC Tables +*/ + +/* +** IA64 TODO: Modify Smart Battery Description to comply with ACPI IA64 +** extensions. +*/ +typedef struct /* Smart Battery Description Table */ +{ + ACPI_TABLE_HEADER header; + u32 warning_level; + u32 low_level; + u32 critical_level; + +} SMART_BATTERY_DESCRIPTION_TABLE; + + +/* + * ACPI Table information. We save the table address, length, + * and type of memory allocation (mapped or allocated) for each + * table for 1) when we exit, and 2) if a new table is installed + */ + +#define ACPI_MEM_NOT_ALLOCATED 0 +#define ACPI_MEM_ALLOCATED 1 +#define ACPI_MEM_MAPPED 2 + +/* Definitions for the Flags bitfield member of ACPI_TABLE_SUPPORT */ + +#define ACPI_TABLE_SINGLE 0 +#define ACPI_TABLE_MULTIPLE 1 + + +/* Data about each known table type */ + +typedef struct _acpi_table_support +{ + NATIVE_CHAR *name; + NATIVE_CHAR *signature; + u8 sig_length; + u8 flags; + u16 status; + void **global_ptr; + +} ACPI_TABLE_SUPPORT; + + +/* + * Get the architecture-specific tables + */ + +#ifdef IA64 +#include "actbl64.h" +#else +#include "actbl32.h" +#endif + + +#endif /* __ACTBL_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/actbl32.h linux/drivers/acpi/include/actbl32.h --- v2.4.0-test8/linux/drivers/acpi/include/actbl32.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/actbl32.h Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Name: actbl32.h - ACPI tables specific to IA32 + * $Revision: 11 $ * *****************************************************************************/ @@ -40,7 +41,7 @@ typedef struct { - char signature[4]; /* signature "FACS" */ + NATIVE_CHAR signature[4]; /* signature "FACS" */ u32 length; /* length of structure, in bytes */ u32 hardware_signature; /* hardware configuration signature */ u32 firmware_waking_vector; /* ACPI OS waking vector */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/actbl64.h linux/drivers/acpi/include/actbl64.h --- v2.4.0-test8/linux/drivers/acpi/include/actbl64.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/actbl64.h Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Name: actbl64.h - ACPI tables specific to IA64 + * $Revision: 12 $ * *****************************************************************************/ @@ -45,7 +45,7 @@ typedef struct { - char signature[4]; /* signature "FACS" */ + NATIVE_CHAR signature[4]; /* signature "FACS" */ u32 length; /* length of structure, in bytes */ u32 hardware_signature; /* hardware configuration signature */ u32 reserved4; /* must be 0 */ @@ -65,7 +65,7 @@ ACPI_TABLE_HEADER header; /* table header */ u32 reserved_pad; /* IA64 alignment, must be 0 */ ACPI_TBLPTR firmware_ctrl; /* Physical address of FACS */ - ACPI_TBLPTR acpi_dsdt; /* Physical address of DSDT */ + ACPI_TBLPTR dsdt; /* Physical address of DSDT */ u8 model; /* System Interrupt Model */ u8 address_space; /* Address Space Bitmask */ u16 sci_int; /* System vector of SCI interrupt */ @@ -90,8 +90,8 @@ u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ u8 gpe1_base; /* offset in gpe model where gpe1 events start */ u8 reserved3; /* reserved */ - u16 Plvl2_lat; /* worst case HW latency to enter/exit C2 state */ - u16 Plvl3_lat; /* worst case HW latency to enter/exit C3 state */ + u16 plvl2_lat; /* worst case HW latency to enter/exit C2 state */ + u16 plvl3_lat; /* worst case HW latency to enter/exit C3 state */ u8 day_alrm; /* index to day-of-month alarm in RTC CMOS RAM */ u8 mon_alrm; /* index to month-of-year alarm in RTC CMOS RAM */ u8 century; /* index to century in RTC CMOS RAM */ @@ -99,11 +99,11 @@ u32 flush_cash : 1; /* PAL_FLUSH_CACHE is correctly supported */ u32 reserved5 : 1; /* reserved - must be zero */ u32 proc_c1 : 1; /* all processors support C1 state */ - u32 Plvl2_up : 1; /* C2 state works on MP system */ + u32 plvl2_up : 1; /* C2 state works on MP system */ u32 pwr_button : 1; /* Power button is handled as a generic feature */ u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ - u32 RTCS4 : 1; /* RTC wakeup stat not possible from S4 */ + u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ u32 tmr_val_ext : 1; /* tmr_val is 32 bits */ u32 dock_cap : 1; /* Supports Docking */ u32 reserved6 : 22; /* reserved - must be zero */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/actypes.h linux/drivers/acpi/include/actypes.h --- v2.4.0-test8/linux/drivers/acpi/include/actypes.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/actypes.h Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Name: actypes.h - Common data types for the entire ACPI subsystem + * $Revision: 131 $ * *****************************************************************************/ @@ -23,15 +23,18 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _ACTYPES_H -#define _ACTYPES_H +#ifndef __ACTYPES_H__ +#define __ACTYPES_H__ /*! [Begin] no source code translation (keep the typedefs) */ /* * Data types - Fixed across all compilation models * - * BOOLEAN Logical Boolean. 1 byte value containing a 0 for FALSE or a 1 for TRUE. Other values are undefined. + * BOOLEAN Logical Boolean. + * 1 byte value containing a 0 for FALSE or a 1 for TRUE. + * Other values are undefined. + * * INT8 8-bit (1 byte) signed value * UINT8 8-bit (1 byte) unsigned value * INT16 16-bit (2 byte) signed value @@ -45,14 +48,17 @@ * UCHAR Character. 1 byte unsigned value. */ +#ifdef __ia64__ +#define _IA64 +#endif + #ifdef _IA64 /* * 64-bit type definitions */ -typedef signed char INT8; typedef unsigned char UINT8; +typedef unsigned char BOOLEAN; typedef unsigned char UCHAR; -typedef short INT16; typedef unsigned short UINT16; typedef int INT32; typedef unsigned int UINT32; @@ -74,10 +80,9 @@ /* * 16-bit type definitions */ -typedef signed char INT8; typedef unsigned char UINT8; +typedef unsigned char BOOLEAN; typedef unsigned char UCHAR; -typedef int INT16; typedef unsigned int UINT16; typedef long INT32; typedef unsigned long UINT32; @@ -96,10 +101,9 @@ /* * 32-bit type definitions (default) */ -typedef signed char INT8; typedef unsigned char UINT8; +typedef unsigned char BOOLEAN; typedef unsigned char UCHAR; -typedef short INT16; typedef unsigned short UINT16; typedef int INT32; typedef unsigned int UINT32; @@ -113,19 +117,15 @@ #define ALIGNED_ADDRESS_BOUNDARY 0x00000004 #define _HW_ALIGNMENT_SUPPORT - #endif - - /* * Miscellaneous common types */ -typedef UINT8 BOOLEAN; typedef UINT32 UINT32_BIT; -typedef NATIVE_INT ACPI_PTRDIFF; -typedef NATIVE_UINT ACPI_SIZE; +typedef NATIVE_UINT ACPI_PTRDIFF; +typedef char NATIVE_CHAR; /* @@ -133,7 +133,6 @@ */ #define ACPI_UCHAR_MAX (UCHAR) 0xFF -#define ACPI_INT32_MAX (INT32) 0x7FFFFFFF #define ACPI_UINT32_MAX (UINT32) 0xFFFFFFFF @@ -141,14 +140,11 @@ /* * Types used only in translated source */ -typedef INT8 s8; -typedef INT16 s16; typedef INT32 s32; typedef UINT8 u8; typedef UINT16 u16; typedef UINT32 u32; #endif - /*! [End] no source code translation !*/ @@ -176,9 +172,9 @@ */ typedef u32 ACPI_STATUS; /* All ACPI Exceptions */ -typedef u32 ACPI_NAME; /* 4-char ACPI name */ +typedef u32 ACPI_NAME; /* 4-s8 ACPI name */ typedef char* ACPI_STRING; /* Null terminated ASCII string */ -typedef void* ACPI_HANDLE; /* Actually a ptr to an NTE */ +typedef void* ACPI_HANDLE; /* Actually a ptr to an Node */ /* @@ -223,10 +219,12 @@ /* * Types associated with names. The first group of - * values correspond to the definition of the ACPI Object_type operator (See the ACPI Spec). - * Therefore, only add to the first group if the spec changes! + * values correspond to the definition of the ACPI + * Object_type operator (See the ACPI Spec). Therefore, + * only add to the first group if the spec changes! * - * Types must be kept in sync with the Acpi_ns_properties and Acpi_ns_type_names arrays + * Types must be kept in sync with the Acpi_ns_properties + * and Acpi_ns_type_names arrays */ typedef u32 ACPI_OBJECT_TYPE; @@ -238,14 +236,14 @@ #define ACPI_TYPE_BUFFER 3 /* 0x03 */ #define ACPI_TYPE_PACKAGE 4 /* 0x04 Byte_const, multiple Data_term/Constant/Super_name */ #define ACPI_TYPE_FIELD_UNIT 5 /* 0x05 */ -#define ACPI_TYPE_DEVICE 6 /* 0x06 Name, multiple Named_object */ +#define ACPI_TYPE_DEVICE 6 /* 0x06 Name, multiple Node */ #define ACPI_TYPE_EVENT 7 /* 0x07 */ #define ACPI_TYPE_METHOD 8 /* 0x08 Name, Byte_const, multiple Code */ #define ACPI_TYPE_MUTEX 9 /* 0x09 */ #define ACPI_TYPE_REGION 10 /* 0x0A */ -#define ACPI_TYPE_POWER 11 /* 0x0B Name,Byte_const,Word_const,multi Named_object */ +#define ACPI_TYPE_POWER 11 /* 0x0B Name,Byte_const,Word_const,multi Node */ #define ACPI_TYPE_PROCESSOR 12 /* 0x0C Name,Byte_const,DWord_const,Byte_const,multi Nm_o */ -#define ACPI_TYPE_THERMAL 13 /* 0x0D Name, multiple Named_object */ +#define ACPI_TYPE_THERMAL 13 /* 0x0D Name, multiple Node */ #define ACPI_TYPE_BUFFER_FIELD 14 /* 0x0E */ #define ACPI_TYPE_DDB_HANDLE 15 /* 0x0F */ #define ACPI_TYPE_DEBUG_OBJECT 16 /* 0x10 */ @@ -254,32 +252,39 @@ /* * This section contains object types that do not relate to the ACPI Object_type operator. - * They are used for various internal purposes only. A numerical gap is provided in - * case additional "official" Object_types are added in the future. Also, values exceeding - * the largest official ACPI Object_type must not overlap with defined AML opcodes. - */ -#define INTERNAL_TYPE_BEGIN 25 -#define INTERNAL_TYPE_DEF_FIELD 25 /* 0x19 */ -#define INTERNAL_TYPE_BANK_FIELD 26 /* 0x1A */ -#define INTERNAL_TYPE_INDEX_FIELD 27 /* 0x1B */ -#define INTERNAL_TYPE_DEF_FIELD_DEFN 28 /* 0x1C Name, Byte_const, multiple Field_element */ -#define INTERNAL_TYPE_BANK_FIELD_DEFN 29 /* 0x1D 2 Name,DWord_const,Byte_const,multi Field_element */ -#define INTERNAL_TYPE_INDEX_FIELD_DEFN 30 /* 0x1E 2 Name, Byte_const, multiple Field_element */ -#define INTERNAL_TYPE_IF 31 /* 0x1F Op_code, multiple Code */ -#define INTERNAL_TYPE_ELSE 32 /* 0x20 multiple Code */ -#define INTERNAL_TYPE_WHILE 33 /* 0x21 Op_code, multiple Code */ -#define INTERNAL_TYPE_SCOPE 34 /* 0x22 Name, multiple Named_object */ -#define INTERNAL_TYPE_DEF_ANY 35 /* 0x23 type is Any, suppress search of enclosing scopes */ -#define INTERNAL_TYPE_REFERENCE 36 /* 0x24 Arg#, Local#, Name, Debug; used only in descriptors */ -#define INTERNAL_TYPE_ALIAS 37 /* 0x25 */ -#define INTERNAL_TYPE_NOTIFY 38 /* 0x26 */ -#define INTERNAL_TYPE_ADDRESS_HANDLER 39 /* 0x27 */ -#define INTERNAL_TYPE_METHOD_ARGUMENT 40 /* 0x28 */ -#define INTERNAL_TYPE_METHOD_LOCAL_VAR 41 /* 0x29 */ + * They are used for various internal purposes only. If new predefined ACPI_TYPEs are + * added (via the ACPI specification), these internal types must move upwards. + * Also, values exceeding the largest official ACPI Object_type must not overlap with + * defined AML opcodes. + */ +#define INTERNAL_TYPE_BEGIN 17 + +#define INTERNAL_TYPE_DEF_FIELD 17 /* 0x11 */ +#define INTERNAL_TYPE_BANK_FIELD 18 /* 0x12 */ +#define INTERNAL_TYPE_INDEX_FIELD 19 /* 0x13 */ +#define INTERNAL_TYPE_REFERENCE 20 /* 0x14 Arg#, Local#, Name, Debug; used only in descriptors */ +#define INTERNAL_TYPE_ALIAS 21 /* 0x15 */ +#define INTERNAL_TYPE_NOTIFY 22 /* 0x16 */ +#define INTERNAL_TYPE_ADDRESS_HANDLER 23 /* 0x17 */ + +#define INTERNAL_TYPE_NODE_MAX 23 + +/* These are pseudo-types because there are never any namespace nodes with these types */ + +#define INTERNAL_TYPE_DEF_FIELD_DEFN 24 /* 0x18 Name, Byte_const, multiple Field_element */ +#define INTERNAL_TYPE_BANK_FIELD_DEFN 25 /* 0x19 2 Name,DWord_const,Byte_const,multi Field_element */ +#define INTERNAL_TYPE_INDEX_FIELD_DEFN 26 /* 0x1A 2 Name, Byte_const, multiple Field_element */ +#define INTERNAL_TYPE_IF 27 /* 0x1B Op_code, multiple Code */ +#define INTERNAL_TYPE_ELSE 28 /* 0x1C multiple Code */ +#define INTERNAL_TYPE_WHILE 29 /* 0x1D Op_code, multiple Code */ +#define INTERNAL_TYPE_SCOPE 30 /* 0x1E Name, multiple Node */ +#define INTERNAL_TYPE_DEF_ANY 31 /* 0x1F type is Any, suppress search of enclosing scopes */ +#define INTERNAL_TYPE_METHOD_ARGUMENT 32 /* 0x20 */ +#define INTERNAL_TYPE_METHOD_LOCAL_VAR 33 /* 0x21 */ -#define INTERNAL_TYPE_MAX 41 +#define INTERNAL_TYPE_MAX 33 -#define INTERNAL_TYPE_INVALID 42 +#define INTERNAL_TYPE_INVALID 34 #define ACPI_TYPE_NOT_FOUND 0xFF /* @@ -375,7 +380,7 @@ { ACPI_OBJECT_TYPE type; u32 length; /* # of bytes in string, excluding trailing null */ - char *pointer; /* points to the string value */ + NATIVE_CHAR *pointer; /* points to the string value */ } string; struct @@ -551,7 +556,8 @@ u32 address, u32 bit_width, u32 *value, - void *context); + void *handler_context, + void *region_context); #define ACPI_DEFAULT_HANDLER ((ADDRESS_SPACE_HANDLER) NULL) @@ -561,7 +567,7 @@ ACPI_HANDLE region_handle, u32 function, void *handler_context, - void **return_context); + void **region_context); #define ACPI_REGION_ACTIVATE 0 #define ACPI_REGION_DEACTIVATE 1 @@ -589,13 +595,11 @@ #define ACPI_COMMON_OBJ_INFO \ - ACPI_OBJECT_TYPE type; /* ACPI object type */\ - ACPI_NAME name; /* ACPI object Name */\ - /*\ - * TBD: [Restructure] Do we want or need these next two??\ - */\ - ACPI_HANDLE parent; /* Parent object */\ - ACPI_HANDLE children; /* Linked list of children */\ + ACPI_OBJECT_TYPE type; /* ACPI object type */ \ + ACPI_NAME name; /* ACPI object Name */ \ + /* TBD: [Restructure] Do we want or need these next two??*/ \ + ACPI_HANDLE parent; /* Parent object */ \ + ACPI_HANDLE children; /* Linked list of children */ \ u32 valid /* ????? */ typedef struct @@ -611,8 +615,8 @@ /* * TBD: [Restructure]: a HID or a _UID can return either a number or a string */ - char hardware_id [9]; /* _HID value if any */ - char unique_id[9]; /* _UID value if any */ + NATIVE_CHAR hardware_id [9]; /* _HID value if any */ + NATIVE_CHAR unique_id[9]; /* _UID value if any */ u32 address; /* _ADR value if any */ u32 current_status; /* _STA value */ } ACPI_DEVICE_INFO; @@ -622,7 +626,6 @@ typedef struct { - void *handler_context; u32 seg; u32 bus; u32 dev_func; @@ -631,11 +634,9 @@ typedef struct { - void *handler_context; - char *mapped_physical_address; - char *mapped_logical_address; + u8 *mapped_physical_address; + u8 *mapped_logical_address; u32 mapped_length; - } MEM_HANDLER_CONTEXT; @@ -858,7 +859,7 @@ u32 address_length; u32 resource_source_index; u32 resource_source_string_length; - u8 resource_source[1]; + NATIVE_CHAR resource_source[1]; } ADDRESS16_RESOURCE; @@ -877,7 +878,7 @@ u32 address_length; u32 resource_source_index; u32 resource_source_string_length; - u8 resource_source[1]; + NATIVE_CHAR resource_source[1]; } ADDRESS32_RESOURCE; @@ -891,7 +892,7 @@ u32 interrupts[1]; u32 resource_source_index; u32 resource_source_string_length; - u8 resource_source[1]; + NATIVE_CHAR resource_source[1]; } EXTENDED_IRQ_RESOURCE; @@ -951,7 +952,7 @@ u32 address; u32 pin; u32 source_index; - u8 source[1]; + NATIVE_CHAR source[1]; } PRT_ENTRY; @@ -967,4 +968,4 @@ * END: Definitions for PCI Routing tables */ -#endif /* ACTYPES_H */ +#endif /* __ACTYPES_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/amlcode.h linux/drivers/acpi/include/amlcode.h --- v2.4.0-test8/linux/drivers/acpi/include/amlcode.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/amlcode.h Fri Sep 15 14:30:30 2000 @@ -1,9 +1,9 @@ - /****************************************************************************** * * Name: amlcode.h - Definitions for AML, as included in "definition blocks" * Declarations and definitions contained herein are derived * directly from the ACPI specification. + * $Revision: 39 $ * *****************************************************************************/ @@ -108,7 +108,7 @@ #define AML_IF_OP (u16) 0xa0 #define AML_ELSE_OP (u16) 0xa1 #define AML_WHILE_OP (u16) 0xa2 -#define AML_NOOP_CODE (u16) 0xa3 +#define AML_NOOP_OP (u16) 0xa3 #define AML_RETURN_OP (u16) 0xa4 #define AML_BREAK_OP (u16) 0xa5 #define AML_BREAK_POINT_OP (u16) 0xcc @@ -133,9 +133,9 @@ #define AML_WAIT_OP (u16) 0x5b25 #define AML_RESET_OP (u16) 0x5b26 #define AML_RELEASE_OP (u16) 0x5b27 -#define AML_FROM_BCDOP (u16) 0x5b28 -#define AML_TO_BCDOP (u16) 0x5b29 -#define AML_UN_LOAD_OP (u16) 0x5b2a +#define AML_FROM_BCD_OP (u16) 0x5b28 +#define AML_TO_BCD_OP (u16) 0x5b29 +#define AML_UNLOAD_OP (u16) 0x5b2a #define AML_REVISION_OP (u16) 0x5b30 #define AML_DEBUG_OP (u16) 0x5b31 #define AML_FATAL_OP (u16) 0x5b32 @@ -156,7 +156,11 @@ #define AML_LNOTEQUAL_OP (u16) 0x9293 -/* Internal opcodes */ +/* + * Internal opcodes + * Use only "Unknown" AML opcodes, don't attempt to use + * any valid ACPI ASCII values (A-Z, 0-9, '-') + */ #define AML_NAMEPATH_OP (u16) 0x002d #define AML_NAMEDFIELD_OP (u16) 0x0030 @@ -165,29 +169,7 @@ #define AML_BYTELIST_OP (u16) 0x0033 #define AML_STATICSTRING_OP (u16) 0x0034 #define AML_METHODCALL_OP (u16) 0x0035 - - -/* - * argument types - */ - -/* -#define AML_ASCIICHARLIST_ARG 'A' -#define AML_BYTEDATA_ARG 'b' -#define AML_BYTELIST_ARG 'B' -#define AML_DWORDDATA_ARG 'd' -#define AML_DATAOBJECT_ARG 'o' -#define AML_DATAOBJECTLIST_ARG 'O' -#define AML_FIELDLIST_ARG 'F' -#define AML_NAMESTRING_ARG 'n' -#define AML_OBJECTLIST_ARG 'P' -#define AML_PKGLENGTH_ARG 'p' -#define AML_SUPERNAME_ARG 's' -#define AML_TARGET_ARG 'l' -#define AML_TERMARG_ARG 't' -#define AML_TERMLIST_ARG 'T' -#define AML_WORDDATA_ARG 'w' -*/ +#define AML_RETURN_VALUE_OP (u16) 0x0036 #define ARG_NONE 0x0 @@ -229,7 +211,7 @@ #define ARGI_STRING 0x06 #define ARGI_BUFFER 0x07 #define ARGI_PACKAGE 0x08 -#define ARGI_DATAOBJECT 0x09 /* Buffer, string, package or NTE reference - Used only by Size_of operator*/ +#define ARGI_DATAOBJECT 0x09 /* Buffer, string, package or reference to a Node - Used only by Size_of operator*/ #define ARGI_COMPLEXOBJ 0x0A /* Buffer or package */ #define ARGI_MUTEX 0x0B #define ARGI_EVENT 0x0C @@ -291,8 +273,9 @@ #define OPTYPE_CONTROL 18 #define OPTYPE_RECONFIGURATION 19 #define OPTYPE_NAMED_OBJECT 20 +#define OPTYPE_RETURN 21 -#define OPTYPE_BOGUS 21 +#define OPTYPE_BOGUS 22 /* Comparison operation codes for Match_op operator */ @@ -375,13 +358,11 @@ extern u8 acpi_gbl_aml [NUM_OPCODES]; extern u16 acpi_gbl_pfx [NUM_OPCODES]; -extern char *acpi_gbl_short_ops [NUM_OPCODES]; -extern char *acpi_gbl_long_ops [NUM_OPCODES]; -extern char *acpi_gbl_region_types [NUM_REGION_TYPES]; -extern char *acpi_gbl_match_ops [NUM_MATCH_OPS]; -extern char *acpi_gbl_access_types [NUM_ACCESS_TYPES]; -extern char *acpi_gbl_update_rules [NUM_UPDATE_RULES]; -extern char *acpi_gbl_FEnames [NUM_FIELD_NAMES]; +extern NATIVE_CHAR *acpi_gbl_region_types [NUM_REGION_TYPES]; +extern NATIVE_CHAR *acpi_gbl_match_ops [NUM_MATCH_OPS]; +extern NATIVE_CHAR *acpi_gbl_access_types [NUM_ACCESS_TYPES]; +extern NATIVE_CHAR *acpi_gbl_update_rules [NUM_UPDATE_RULES]; +extern NATIVE_CHAR *acpi_gbl_FEnames [NUM_FIELD_NAMES]; /* @@ -392,7 +373,7 @@ /* Data used in keeping track of fields */ -char *acpi_gbl_FEnames[NUM_FIELD_NAMES] = +NATIVE_CHAR *acpi_gbl_FEnames[NUM_FIELD_NAMES] = { "skip", "?access?" @@ -401,7 +382,7 @@ /* Region type decoding */ -char *acpi_gbl_region_types[NUM_REGION_TYPES] = +NATIVE_CHAR *acpi_gbl_region_types[NUM_REGION_TYPES] = { "System_memory", "System_iO", @@ -411,7 +392,7 @@ }; -char *acpi_gbl_match_ops[NUM_MATCH_OPS] = +NATIVE_CHAR *acpi_gbl_match_ops[NUM_MATCH_OPS] = { "Error", "MTR", @@ -425,7 +406,7 @@ /* Access type decoding */ -char *acpi_gbl_access_types[NUM_ACCESS_TYPES] = +NATIVE_CHAR *acpi_gbl_access_types[NUM_ACCESS_TYPES] = { "Any_acc", "Byte_acc", @@ -439,7 +420,7 @@ /* Update rule decoding */ -char *acpi_gbl_update_rules[NUM_UPDATE_RULES] = +NATIVE_CHAR *acpi_gbl_update_rules[NUM_UPDATE_RULES] = { "Preserve", "Write_as_ones", diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/common.h linux/drivers/acpi/include/common.h --- v2.4.0-test8/linux/drivers/acpi/include/common.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/common.h Wed Dec 31 16:00:00 1969 @@ -1,650 +0,0 @@ - -/****************************************************************************** - * - * Name: common.h -- prototypes for the common (subsystem-wide) procedures - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - -#ifndef _COMMON_H -#define _COMMON_H - - -#define REF_INCREMENT (u16) 0 -#define REF_DECREMENT (u16) 1 -#define REF_FORCE_DELETE (u16) 2 - -/* Acpi_cm_dump_buffer */ - -#define DB_BYTE_DISPLAY 1 -#define DB_WORD_DISPLAY 2 -#define DB_DWORD_DISPLAY 4 -#define DB_QWORD_DISPLAY 8 - - -/* Global initialization interfaces */ - -void -acpi_cm_init_globals ( - ACPI_INIT_DATA *init_data); - -void -acpi_cm_terminate ( - void); - - -/* - * Acpi_cm_init - miscellaneous initialization and shutdown - */ - -ACPI_STATUS -acpi_cm_hardware_initialize ( - void); - -ACPI_STATUS -acpi_cm_subsystem_shutdown ( - void); - -/* - * Acpi_cm_global - Global data structures and procedures - */ - -char * -acpi_cm_get_mutex_name ( - u32 mutex_id); - -char * -acpi_cm_get_type_name ( - u32 type); - -u8 -acpi_cm_valid_object_type ( - u32 type); - -ACPI_OWNER_ID -acpi_cm_allocate_owner_id ( - u32 id_type); - - -/* - * Acpi_cm_clib - Local implementations of C library functions - */ - -ACPI_SIZE -acpi_cm_strlen ( - const char *string); - -char * -acpi_cm_strcpy ( - char *dst_string, - const char *src_string); - -char * -acpi_cm_strncpy ( - char *dst_string, - const char *src_string, - ACPI_SIZE count); - -u32 -acpi_cm_strncmp ( - const char *string1, - const char *string2, - ACPI_SIZE count); - -u32 -acpi_cm_strcmp ( - const char *string1, - const char *string2); - -char * -acpi_cm_strcat ( - char *dst_string, - const char *src_string); - -char * -acpi_cm_strncat ( - char *dst_string, - const char *src_string, - ACPI_SIZE count); - -u32 -acpi_cm_strtoul ( - const char *string, - char **terminator, - s32 base); - -char * -acpi_cm_strstr ( - char *string1, - char *string2); - -char * -acpi_cm_strupr ( - char *src_string); - -void * -acpi_cm_memcpy ( - void *dest, - const void *src, - ACPI_SIZE count); - -void * -acpi_cm_memset ( - void *dest, - s32 value, - ACPI_SIZE count); - -s32 -acpi_cm_to_upper ( - s32 c); - -s32 -acpi_cm_to_lower ( - s32 c); - - -/* - * Acpi_cm_copy - Object construction and conversion interfaces - */ - -ACPI_STATUS -acpi_cm_build_simple_object( - ACPI_OBJECT_INTERNAL *obj, - ACPI_OBJECT *user_obj, - char *data_space, - u32 *buffer_space_used); - -ACPI_STATUS -acpi_cm_build_package_object ( - ACPI_OBJECT_INTERNAL *obj, - char *buffer, - u32 *space_used); - -ACPI_STATUS -acpi_cm_build_external_object ( - ACPI_OBJECT_INTERNAL *obj, - ACPI_BUFFER *ret_buffer); - -ACPI_STATUS -acpi_cm_build_internal_simple_object( - ACPI_OBJECT *user_obj, - ACPI_OBJECT_INTERNAL *obj); - -ACPI_STATUS -acpi_cm_build_internal_object ( - ACPI_OBJECT *obj, - ACPI_OBJECT_INTERNAL *internal_obj); - -ACPI_STATUS -acpi_cm_copy_internal_simple_object ( - ACPI_OBJECT_INTERNAL *source_obj, - ACPI_OBJECT_INTERNAL *dest_obj); - -ACPI_STATUS -acpi_cm_build_copy_internal_package_object ( - ACPI_OBJECT_INTERNAL *source_obj, - ACPI_OBJECT_INTERNAL *dest_obj); - - -/* - * Acpi_cm_create - Object creation - */ - -ACPI_STATUS -acpi_cm_update_object_reference ( - ACPI_OBJECT_INTERNAL *object, - u16 action); - -ACPI_OBJECT_INTERNAL * -_cm_create_internal_object ( - char *module_name, - s32 line_number, - s32 component_id, - OBJECT_TYPE_INTERNAL type); - - -/* - * Acpi_cm_debug - Debug interfaces - */ - -s32 -get_debug_level ( - void); - -void -set_debug_level ( - s32 level); - -void -function_trace ( - ACPI_STRING module_name, - s32 line_number, - s32 component_id, - ACPI_STRING function_name); - -void -function_trace_ptr ( - ACPI_STRING module_name, - s32 line_number, - s32 component_id, - ACPI_STRING function_name, - void *pointer); - -void -function_trace_u32 ( - ACPI_STRING module_name, - s32 line_number, - s32 component_id, - ACPI_STRING function_name, - u32 integer); - -void -function_trace_str ( - ACPI_STRING module_name, - s32 line_number, - s32 component_id, - ACPI_STRING function_name, - char *string); - -void -function_exit ( - ACPI_STRING module_name, - s32 line_number, - s32 component_id, - ACPI_STRING function_name); - -void -function_status_exit ( - ACPI_STRING module_name, - s32 line_number, - s32 component_id, - ACPI_STRING function_name, - ACPI_STATUS status); - -void -function_value_exit ( - ACPI_STRING module_name, - s32 line_number, - s32 component_id, - ACPI_STRING function_name, - NATIVE_UINT value); - -void -function_ptr_exit ( - ACPI_STRING module_name, - s32 line_number, - s32 component_id, - ACPI_STRING function_name, - char *ptr); - -void -debug_print_prefix ( - ACPI_STRING module_name, - s32 line_number); - -void -debug_print ( - ACPI_STRING module_name, - s32 line_number, - s32 component_id, - s32 print_level, - char *format, ...); - -void -debug_print_raw ( - char *format, ...); - -void -_report_info ( - ACPI_STRING module_name, - s32 line_number, - s32 component_id, - ACPI_STRING message); - -void -_report_error ( - ACPI_STRING module_name, - s32 line_number, - s32 component_id, - ACPI_STRING message); - -void -_report_warning ( - ACPI_STRING module_name, - s32 line_number, - s32 component_id, - ACPI_STRING message); - -void -_report_success ( - ACPI_STRING module_name, - s32 line_number, - s32 component_id, - ACPI_STRING message); - -void -acpi_cm_dump_buffer ( - char *buffer, - u32 count, - u32 display, - s32 component_id); - - -/* - * Acpi_cm_delete - Object deletion - */ - -void -acpi_cm_delete_internal_obj ( - ACPI_OBJECT_INTERNAL *object); - -void -acpi_cm_delete_internal_package_object ( - ACPI_OBJECT_INTERNAL *object); - -void -acpi_cm_delete_internal_simple_object ( - ACPI_OBJECT_INTERNAL *object); - -ACPI_STATUS -acpi_cm_delete_internal_object_list ( - ACPI_OBJECT_INTERNAL **obj_list); - - -/* - * Acpi_cm_eval - object evaluation - */ - -/* Method name strings */ - -#define METHOD_NAME__HID "_HID" -#define METHOD_NAME__UID "_UID" -#define METHOD_NAME__ADR "_ADR" -#define METHOD_NAME__STA "_STA" -#define METHOD_NAME__REG "_REG" -#define METHOD_NAME__SEG "_SEG" -#define METHOD_NAME__BBN "_BBN" - - -ACPI_STATUS -acpi_cm_evaluate_numeric_object ( - char *method_name, - ACPI_NAMED_OBJECT *acpi_device, - u32 *address); - -ACPI_STATUS -acpi_cm_execute_HID ( - ACPI_NAMED_OBJECT *acpi_device, - DEVICE_ID *hid); - -ACPI_STATUS -acpi_cm_execute_STA ( - ACPI_NAMED_OBJECT *acpi_device, - u32 *status_flags); - -ACPI_STATUS -acpi_cm_execute_UID ( - ACPI_NAMED_OBJECT *acpi_device, - DEVICE_ID *uid); - - -/* - * Acpi_cm_error - exception interfaces - */ - -char * -acpi_cm_format_exception ( - ACPI_STATUS status); - - -/* - * Acpi_cm_mutex - mutual exclusion interfaces - */ - -ACPI_STATUS -acpi_cm_mutex_initialize ( - void); - -void -acpi_cm_mutex_terminate ( - void); - -ACPI_STATUS -acpi_cm_create_mutex ( - ACPI_MUTEX_HANDLE mutex_id); - -ACPI_STATUS -acpi_cm_delete_mutex ( - ACPI_MUTEX_HANDLE mutex_id); - -ACPI_STATUS -acpi_cm_acquire_mutex ( - ACPI_MUTEX_HANDLE mutex_id); - -ACPI_STATUS -acpi_cm_release_mutex ( - ACPI_MUTEX_HANDLE mutex_id); - - -/* - * Acpi_cm_object - internal object create/delete/cache routines - */ - -#define acpi_cm_create_internal_object(t) _cm_create_internal_object(_THIS_MODULE,__LINE__,_COMPONENT,t) -#define acpi_cm_allocate_object_desc() _cm_allocate_object_desc(_THIS_MODULE,__LINE__,_COMPONENT) - -void * -_cm_allocate_object_desc ( - char *module_name, - s32 line_number, - s32 component_id); - -void -acpi_cm_delete_object_desc ( - ACPI_OBJECT_INTERNAL *object); - -u8 -acpi_cm_valid_internal_object ( - void *object); - - -/* - * Acpi_cm_ref_cnt - Object reference count management - */ - -void -acpi_cm_add_reference ( - ACPI_OBJECT_INTERNAL *object); - -void -acpi_cm_remove_reference ( - ACPI_OBJECT_INTERNAL *object); - -/* - * Acpi_cm_size - Object size routines - */ - -ACPI_STATUS -acpi_cm_get_simple_object_size ( - ACPI_OBJECT_INTERNAL *obj, - u32 *obj_length); - -ACPI_STATUS -acpi_cm_get_package_object_size ( - ACPI_OBJECT_INTERNAL *obj, - u32 *obj_length); - -ACPI_STATUS -acpi_cm_get_object_size( - ACPI_OBJECT_INTERNAL *obj, - u32 *obj_length); - - -/* - * Acpi_cm_state - Generic state creation/cache routines - */ - -void -acpi_cm_push_generic_state ( - ACPI_GENERIC_STATE **list_head, - ACPI_GENERIC_STATE *state); - -ACPI_GENERIC_STATE * -acpi_cm_pop_generic_state ( - ACPI_GENERIC_STATE **list_head); - - -ACPI_GENERIC_STATE * -acpi_cm_create_generic_state ( - void); - -ACPI_GENERIC_STATE * -acpi_cm_create_update_state ( - ACPI_OBJECT_INTERNAL *object, - u16 action); - -ACPI_STATUS -acpi_cm_create_update_state_and_push ( - ACPI_OBJECT_INTERNAL *object, - u16 action, - ACPI_GENERIC_STATE **state_list); - -ACPI_GENERIC_STATE * -acpi_cm_create_control_state ( - void); - -void -acpi_cm_delete_generic_state ( - ACPI_GENERIC_STATE *state); - -void -acpi_cm_delete_generic_state_cache ( - void); - -void -acpi_cm_delete_object_cache ( - void); - -/* - * Acpi_cmutils - */ - -u8 -acpi_cm_valid_acpi_name ( - u32 name); - -u8 -acpi_cm_valid_acpi_character ( - char character); - - -/* - * Memory allocation functions and related macros. - * Macros that expand to include filename and line number - */ - -void * -_cm_allocate ( - u32 size, - u32 component, - ACPI_STRING module, - s32 line); - -void * -_cm_callocate ( - u32 size, - u32 component, - ACPI_STRING module, - s32 line); - -void -_cm_free ( - void *address, - u32 component, - ACPI_STRING module, - s32 line); - -void -acpi_cm_init_static_object ( - ACPI_OBJECT_INTERNAL *obj_desc); - -#define acpi_cm_allocate(a) _cm_allocate(a,_COMPONENT,_THIS_MODULE,__LINE__) -#define acpi_cm_callocate(a) _cm_callocate(a, _COMPONENT,_THIS_MODULE,__LINE__) -#define acpi_cm_free(a) _cm_free(a,_COMPONENT,_THIS_MODULE,__LINE__) - -#ifndef ACPI_DEBUG - -#define acpi_cm_add_element_to_alloc_list(a,b,c,d,e,f) -#define acpi_cm_delete_element_from_alloc_list(a,b,c,d) -#define acpi_cm_dump_current_allocations(a,b) -#define acpi_cm_dump_allocation_info() - -#define DECREMENT_OBJECT_METRICS(a) -#define INCREMENT_OBJECT_METRICS(a) -#define INITIALIZE_ALLOCATION_METRICS() - -#else - -#define INITIALIZE_ALLOCATION_METRICS() \ - acpi_gbl_current_object_count = 0; \ - acpi_gbl_current_object_size = 0; \ - acpi_gbl_running_object_count = 0; \ - acpi_gbl_running_object_size = 0; \ - acpi_gbl_max_concurrent_object_count = 0; \ - acpi_gbl_max_concurrent_object_size = 0; \ - acpi_gbl_current_alloc_size = 0; \ - acpi_gbl_current_alloc_count = 0; \ - acpi_gbl_running_alloc_size = 0; \ - acpi_gbl_running_alloc_count = 0; \ - acpi_gbl_max_concurrent_alloc_size = 0; \ - acpi_gbl_max_concurrent_alloc_count = 0 - -#define DECREMENT_OBJECT_METRICS(a) \ - acpi_gbl_current_object_count--; \ - acpi_gbl_current_object_size -= a - -#define INCREMENT_OBJECT_METRICS(a) \ - acpi_gbl_current_object_count++; \ - acpi_gbl_running_object_count++; \ - if (acpi_gbl_max_concurrent_object_count < acpi_gbl_current_object_count) \ - { \ - acpi_gbl_max_concurrent_object_count = acpi_gbl_current_object_count; \ - } \ - acpi_gbl_running_object_size += a; \ - acpi_gbl_current_object_size += a; \ - if (acpi_gbl_max_concurrent_object_size < acpi_gbl_current_object_size) \ - { \ - acpi_gbl_max_concurrent_object_size = acpi_gbl_current_object_size; \ - } - - -void -acpi_cm_dump_allocation_info ( - void); - -void -acpi_cm_dump_current_allocations ( - u32 component, - ACPI_STRING module); - -#endif - - -#endif /* _COMMON_H */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/config.h linux/drivers/acpi/include/config.h --- v2.4.0-test8/linux/drivers/acpi/include/config.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/config.h Wed Dec 31 16:00:00 1969 @@ -1,185 +0,0 @@ - -/****************************************************************************** - * - * Name: config.h - Global configuration constants - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - -#ifndef _CONFIG_H -#define _CONFIG_H - - -/****************************************************************************** - * - * Compile-time options - * - *****************************************************************************/ - -/* - * ACPI_DEBUG - This switch enables all the debug facilities of the ACPI - * subsystem. This includes the DEBUG_PRINT output statements - * When disabled, all DEBUG_PRINT statements are compiled out. - * - * ACPI_APPLICATION - Use this switch if the subsystem is going to be run - * at the application level. - * - */ - - -/****************************************************************************** - * - * Subsystem Constants - * - *****************************************************************************/ - - -/* Version string */ - -#define ACPI_CA_VERSION __DATE__ - -/* Name of host operating system (returned by the _OS_ namespace object) */ - -#ifdef _LINUX -#define ACPI_OS_NAME "Linux" -#else -#define ACPI_OS_NAME "Intel ACPI/CA Core Subsystem" -#endif - - -/* - * How and when control methods will be parsed - * The default action is to parse all methods at table load time to verify them, but delete the parse trees - * to conserve memory. Methods are parsed just in time before execution and the parse tree is deleted - * when execution completes. - */ -#define METHOD_PARSE_AT_INIT 0x0 /* Parse at table init, never delete the method parse tree */ -#define METHOD_PARSE_JUST_IN_TIME 0x1 /* Parse only when a method is invoked */ -#define METHOD_DELETE_AT_COMPLETION 0x2 /* Delete parse tree on method completion */ - -/* Default parsing configuration */ - -#define METHOD_PARSE_CONFIGURATION (METHOD_PARSE_JUST_IN_TIME | METHOD_DELETE_AT_COMPLETION) - - -/* Maximum objects in the various object caches */ - -#define MAX_STATE_CACHE_DEPTH 24 /* State objects for stacks */ -#define MAX_PARSE_CACHE_DEPTH 512 /* Parse tree objects */ -#define MAX_OBJECT_CACHE_DEPTH 32 /* Interpreter operand objects */ -#define MAX_WALK_CACHE_DEPTH 2 /* Objects for parse tree walks (method execution) */ - -/* - * Name_space Table size - * - * All tables are the same size to simplify the implementation. - * Tables may be extended by allocating additional tables that - * are in turn linked together to form a chain of tables. - */ - -#define NS_TABLE_SIZE 16 - -/* String size constants */ - -#define MAX_STRING_LENGTH 512 -#define PATHNAME_MAX 256 /* A full namespace pathname */ - - -/* Maximum count for a semaphore object */ - -#define MAX_SEMAPHORE_COUNT 256 - - -/* Max reference count (for debug only) */ - -#define MAX_REFERENCE_COUNT 0x200 - - -/* Size of cached memory mapping for system memory operation region */ - -#define SYSMEM_REGION_WINDOW_SIZE 4096 - - -/* - * Debugger threading model - * Use single threaded if the entire subsystem is contained in an application - * Use multiple threaded when the the subsystem is running in the kernel. - * - * By default the model is single threaded if ACPI_APPLICATION is set, - * multi-threaded if ACPI_APPLICATION is not set. - */ - -#define DEBUGGER_SINGLE_THREADED 0 -#define DEBUGGER_MULTI_THREADED 1 - -#ifdef ACPI_APPLICATION -#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED - -#else -#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED -#endif - - -/****************************************************************************** - * - * ACPI Specification constants (Do not change unless the specification changes) - * - *****************************************************************************/ - -/* - * Method info (in WALK_STATE), containing local variables and argumetns - */ - -#define MTH_NUM_LOCALS 8 -#define MTH_MAX_LOCAL 7 - -#define MTH_NUM_ARGS 7 -#define MTH_MAX_ARG 6 - -/* - * Operand Stack (in WALK_STATE), Must be large enough to contain MTH_MAX_ARG - */ - -#define OBJ_NUM_OPERANDS 8 -#define OBJ_MAX_OPERAND 7 - -/* Names within the namespace are 4 bytes long */ - -#define ACPI_NAME_SIZE 4 -#define PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ -#define PATH_SEPARATOR '.' - - -/* Constants used in searching for the RSDP in low memory */ - -#define LO_RSDP_WINDOW_BASE (void *) 0 -#define HI_RSDP_WINDOW_BASE (void *) 0xE0000 -#define LO_RSDP_WINDOW_SIZE 0x400 -#define HI_RSDP_WINDOW_SIZE 0x20000 -#define RSDP_SCAN_STEP 16 - - -/* Maximum nesting of package objects */ - -#define MAX_PACKAGE_DEPTH 16 - - -#endif /* _CONFIG_H */ - diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/debugger.h linux/drivers/acpi/include/debugger.h --- v2.4.0-test8/linux/drivers/acpi/include/debugger.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/debugger.h Wed Dec 31 16:00:00 1969 @@ -1,394 +0,0 @@ - -/****************************************************************************** - * - * Name: debugger.h - ACPI/AML debugger - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - -#ifndef __DEBUGGER_H__ -#define __DEBUGGER_H__ - - -#define DB_MAX_ARGS 8 /* Must be max method args + 1 */ - -#define DB_COMMAND_PROMPT '-' -#define DB_EXECUTE_PROMPT '%' - - -extern int optind; -extern char *optarg; -extern u8 *aml_ptr; -extern u32 acpi_aml_length; - -extern u8 opt_tables; -extern u8 opt_disasm; -extern u8 opt_stats; -extern u8 opt_parse_jit; -extern u8 opt_verbose; - - -extern char *args[DB_MAX_ARGS]; -extern char line_buf[80]; -extern char scope_buf[40]; -extern char debug_filename[40]; -extern u8 output_to_file; -extern char *buffer; -extern char *filename; -extern char *INDENT_STRING; -extern u32 acpi_gbl_method_breakpoint; -extern u8 acpi_gbl_db_output_flags; -extern u32 acpi_gbl_db_debug_level; -extern u32 acpi_gbl_db_console_debug_level; - -extern u32 num_names; -extern u32 num_methods; -extern u32 num_regions; -extern u32 num_packages; -extern u32 num_aliases; -extern u32 num_devices; -extern u32 num_field_defs; -extern u32 num_thermal_zones; -extern u32 num_named_objects; -extern u32 num_grammar_elements; -extern u32 num_method_elements ; -extern u32 num_mutexes; -extern u32 num_power_resources; -extern u32 num_bank_fields ; -extern u32 num_index_fields; -extern u32 num_events; - -extern u32 size_of_parse_tree; -extern u32 size_of_method_trees; -extern u32 size_of_nTes; -extern u32 size_of_acpi_objects; - - -#define BUFFER_SIZE 4196 - -#define DB_REDIRECTABLE_OUTPUT 0x01 -#define DB_CONSOLE_OUTPUT 0x02 -#define DB_DUPLICATE_OUTPUT 0x03 - - -typedef struct command_info -{ - char *name; /* Command Name */ - char min_args; /* Minimum arguments required */ - -} COMMAND_INFO; - - -typedef struct argument_info -{ - char *name; /* Argument Name */ - -} ARGUMENT_INFO; - - -#define PARAM_LIST(pl) pl - -#define DBTEST_OUTPUT_LEVEL(lvl) if (opt_verbose) - -#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ - acpi_os_printf PARAM_LIST(fp);} - -#define EX_NO_SINGLE_STEP 1 -#define EX_SINGLE_STEP 2 - - -/* Prototypes */ - - -/* - * dbapi - external debugger interfaces - */ - -int -acpi_db_initialize ( - void); - -ACPI_STATUS -acpi_db_single_step ( - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op, - u8 op_type); - - -/* - * dbcmds - debug commands and output routines - */ - - -void -acpi_db_display_table_info ( - char *table_arg); - -void -acpi_db_unload_acpi_table ( - char *table_arg, - char *instance_arg); - -void -acpi_db_set_method_breakpoint ( - char *location, - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op); - -void -acpi_db_set_method_call_breakpoint ( - ACPI_GENERIC_OP *op); - -void -acpi_db_disassemble_aml ( - char *statements, - ACPI_GENERIC_OP *op); - -void -acpi_db_dump_namespace ( - char *start_arg, - char *depth_arg); - -void -acpi_db_dump_namespace_by_owner ( - char *owner_arg, - char *depth_arg); - -void -acpi_db_send_notify ( - char *name, - u32 value); - -void -acpi_db_set_method_data ( - char *type_arg, - char *index_arg, - char *value_arg); - -ACPI_STATUS -acpi_db_display_objects ( - char *obj_type_arg, - char *display_count_arg); - -ACPI_STATUS -acpi_db_find_name_in_namespace ( - char *name_arg); - -void -acpi_db_set_scope ( - char *name); - -void -acpi_db_find_references ( - char *object_arg); - - -/* - * dbdisasm - AML disassembler - */ - -void -acpi_db_display_op ( - ACPI_GENERIC_OP *origin, - u32 num_opcodes); - -void -acpi_db_display_namestring ( - char *name); - -void -acpi_db_display_path ( - ACPI_GENERIC_OP *op); - -void -acpi_db_display_opcode ( - ACPI_GENERIC_OP *op); - - -/* - * dbdisply - debug display commands - */ - - -void -acpi_db_display_method_info ( - ACPI_GENERIC_OP *op); - -void -acpi_db_decode_and_display_object ( - char *target, - char *output_type); - -void -acpi_db_display_result_object ( - ACPI_OBJECT_INTERNAL *ret_desc); - -ACPI_STATUS -acpi_db_display_all_methods ( - char *display_count_arg); - -void -acpi_db_display_internal_object ( - ACPI_OBJECT_INTERNAL *obj_desc); - -void -acpi_db_display_arguments ( - void); - -void -acpi_db_display_locals ( - void); - -void -acpi_db_display_results ( - void); - -void -acpi_db_display_calling_tree ( - void); - -void -acpi_db_display_argument_object ( - ACPI_OBJECT_INTERNAL *obj_desc); - - -/* - * dbexec - debugger control method execution - */ - -void -acpi_db_execute ( - char *name, - char **args, - u32 flags); - -void -acpi_db_create_execution_threads ( - char *num_threads_arg, - char *num_loops_arg, - char *method_name_arg); - - -/* - * dbfileio - Debugger file I/O commands - */ - -OBJECT_TYPE_INTERNAL -acpi_db_match_argument ( - char *user_argument, - ARGUMENT_INFO *arguments); - - -void -acpi_db_close_debug_file ( - void); - -void -acpi_db_open_debug_file ( - char *name); - -ACPI_STATUS -acpi_db_load_acpi_table ( - char *filename); - - -/* - * dbhistry - debugger HISTORY command - */ - -void -acpi_db_add_to_history ( - char *command_line); - -void -acpi_db_display_history (void); - -char * -acpi_db_get_from_history ( - char *command_num_arg); - - -/* - * dbinput - user front-end to the AML debugger - */ - -ACPI_STATUS -acpi_db_command_dispatch ( - char *input_buffer, - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op); - -void -acpi_db_execute_thread ( - void *context); - -ACPI_STATUS -acpi_db_user_commands ( - char prompt, - ACPI_GENERIC_OP *op); - - -/* - * dbstats - Generation and display of ACPI table statistics - */ - -void -acpi_db_generate_statistics ( - ACPI_GENERIC_OP *root, - u8 is_method); - - -ACPI_STATUS -acpi_db_display_statistics ( - char *type_arg); - - -/* - * dbutils - AML debugger utilities - */ - -void -acpi_db_set_output_destination ( - s32 where); - -void -acpi_db_dump_buffer ( - u32 address); - -void -acpi_db_dump_object ( - ACPI_OBJECT *obj_desc, - u32 level); - -void -acpi_db_prep_namestring ( - char *name); - - -ACPI_STATUS -acpi_db_second_pass_parse ( - ACPI_GENERIC_OP *root); - -ACPI_NAMED_OBJECT* -acpi_db_local_ns_lookup ( - char *name); - - -#endif /* __DEBUGGER_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/dispatch.h linux/drivers/acpi/include/dispatch.h --- v2.4.0-test8/linux/drivers/acpi/include/dispatch.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/dispatch.h Wed Dec 31 16:00:00 1969 @@ -1,383 +0,0 @@ -/****************************************************************************** - * - * Module Name: dispatch.h - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - - -#ifndef _DISPATCH_H_ -#define _DISPATCH_H_ - - -#define NAMEOF_LOCAL_NTE "__L0" -#define NAMEOF_ARG_NTE "__A0" - - -/* For Acpi_ds_method_data_set_value */ - -#define MTH_TYPE_LOCAL 0 -#define MTH_TYPE_ARG 1 - - -/* Common interfaces */ - -ACPI_STATUS -acpi_ds_obj_stack_push ( - void *object, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_obj_stack_pop ( - u32 pop_count, - ACPI_WALK_STATE *walk_state); - -void * -acpi_ds_obj_stack_get_value ( - u32 index, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_obj_stack_pop_object ( - ACPI_OBJECT_INTERNAL **object, - ACPI_WALK_STATE *walk_state); - - -/* dsregion - Op region support */ - -ACPI_STATUS -acpi_ds_get_region_arguments ( - ACPI_OBJECT_INTERNAL *rgn_desc); - - -/* dsctrl - Parser/Interpreter interface, control stack routines */ - -/* -ACPI_CTRL_STATE * -Acpi_ds_create_control_state (void); - -void -Acpi_ds_push_control_state ( - ACPI_CTRL_STATE *Control_state, - ACPI_WALK_STATE *Walk_state); - -ACPI_CTRL_STATE * -Acpi_ds_pop_control_state ( - ACPI_WALK_STATE *Walk_state); -*/ - -ACPI_STATUS -acpi_ds_exec_begin_control_op ( - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op); - -ACPI_STATUS -acpi_ds_exec_end_control_op ( - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op); - - -/* dsexec - Parser/Interpreter interface, method execution callbacks */ - -ACPI_STATUS -acpi_ds_exec_begin_op ( - ACPI_WALK_STATE *state, - ACPI_GENERIC_OP *op); - -ACPI_STATUS -acpi_ds_exec_end_op ( - ACPI_WALK_STATE *state, - ACPI_GENERIC_OP *op); - - -/* dsfield - Parser/Interpreter interface for AML fields */ - - -ACPI_STATUS -acpi_ds_create_field ( - ACPI_GENERIC_OP *op, - ACPI_HANDLE region, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_create_bank_field ( - ACPI_GENERIC_OP *op, - ACPI_HANDLE region, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_create_index_field ( - ACPI_GENERIC_OP *op, - ACPI_HANDLE region, - ACPI_WALK_STATE *walk_state); - - -/* dsload - Parser/Interpreter interface, namespace load callbacks */ - -ACPI_STATUS -acpi_ds_load1_begin_op ( - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op); - -ACPI_STATUS -acpi_ds_load1_end_op ( - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op); - -ACPI_STATUS -acpi_ds_load2_begin_op ( - ACPI_WALK_STATE *state, - ACPI_GENERIC_OP *op); - -ACPI_STATUS -acpi_ds_load2_end_op ( - ACPI_WALK_STATE *state, - ACPI_GENERIC_OP *op); - - -/* dsmthdat - method data (locals/args) */ - - -ACPI_STATUS -acpi_ds_method_data_delete_all ( - ACPI_WALK_STATE *walk_state); - -u8 -acpi_ds_is_method_value ( - ACPI_OBJECT_INTERNAL *obj_desc); - -OBJECT_TYPE_INTERNAL -acpi_ds_method_data_get_type ( - u32 type, - u32 index); - -ACPI_STATUS -acpi_ds_method_data_get_value ( - u32 type, - u32 index, - ACPI_OBJECT_INTERNAL **obj_desc); - -ACPI_STATUS -acpi_ds_method_data_set_value ( - u32 type, - u32 index, - ACPI_OBJECT_INTERNAL *obj_desc); - -ACPI_STATUS -acpi_ds_method_data_delete_value ( - u32 type, - u32 index); - -ACPI_STATUS -acpi_ds_method_data_init_args ( - ACPI_OBJECT_INTERNAL **params, - u32 param_count); - -ACPI_NAMED_OBJECT* -acpi_ds_method_data_get_nte ( - u32 type, - u32 index); - -ACPI_STATUS -acpi_ds_method_data_init ( - ACPI_WALK_STATE *walk_state); - - -/* dsmethod - Parser/Interpreter interface - control method parsing */ - -ACPI_STATUS -acpi_ds_parse_method ( - ACPI_HANDLE obj_handle); - -ACPI_STATUS -acpi_ds_call_control_method ( - ACPI_WALK_LIST *walk_list, - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op); - -ACPI_STATUS -acpi_ds_restart_control_method ( - ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL *return_desc); - -ACPI_STATUS -acpi_ds_terminate_control_method ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_begin_method_execution ( - ACPI_NAMED_OBJECT *method_entry, - ACPI_OBJECT_INTERNAL *obj_desc); - - -/* dsobj - Parser/Interpreter interface - object initialization and conversion */ - -ACPI_STATUS -acpi_ds_init_one_object ( - ACPI_HANDLE obj_handle, - u32 level, - void *context, - void **return_value); - -ACPI_STATUS -acpi_ds_initialize_objects ( - ACPI_TABLE_DESC *table_desc, - ACPI_NAMED_OBJECT *start_entry); - -ACPI_STATUS -acpi_ds_build_internal_package_obj ( - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op, - ACPI_OBJECT_INTERNAL **obj_desc); - -ACPI_STATUS -acpi_ds_build_internal_object ( - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op, - ACPI_OBJECT_INTERNAL **obj_desc_ptr); - -ACPI_STATUS -acpi_ds_init_object_from_op ( - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op, - u16 opcode, - ACPI_OBJECT_INTERNAL *obj_desc); - -ACPI_STATUS -acpi_ds_create_named_object ( - ACPI_WALK_STATE *walk_state, - ACPI_NAMED_OBJECT *entry, - ACPI_GENERIC_OP *op); - - -/* dsregn - Parser/Interpreter interface - Op Region parsing */ - -ACPI_STATUS -acpi_ds_eval_region_operands ( - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op); - -ACPI_STATUS -acpi_ds_initialize_region ( - ACPI_HANDLE obj_handle); - - -/* dsutils - Parser/Interpreter interface utility routines */ - -void -acpi_ds_delete_result_if_not_used ( - ACPI_GENERIC_OP *op, - ACPI_OBJECT_INTERNAL *result_obj, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_create_operand ( - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *arg); - -ACPI_STATUS -acpi_ds_create_operands ( - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *first_arg); - -ACPI_STATUS -acpi_ds_resolve_operands ( - ACPI_WALK_STATE *walk_state); - -OBJECT_TYPE_INTERNAL -acpi_ds_map_opcode_to_data_type ( - u16 opcode, - u32 *out_flags); - -OBJECT_TYPE_INTERNAL -acpi_ds_map_named_opcode_to_data_type ( - u16 opcode); - - -/* - * dswscope - Scope Stack manipulation - */ - -ACPI_STATUS -acpi_ds_scope_stack_push ( - ACPI_NAME_TABLE *new_scope, - OBJECT_TYPE_INTERNAL type, - ACPI_WALK_STATE *walk_state); - - -ACPI_STATUS -acpi_ds_scope_stack_pop ( - ACPI_WALK_STATE *walk_state); - -void -acpi_ds_scope_stack_clear ( - ACPI_WALK_STATE *walk_state); - - -/* Acpi_dswstate - parser WALK_STATE management routines */ - -ACPI_WALK_STATE * -acpi_ds_create_walk_state ( - ACPI_OWNER_ID owner_id, - ACPI_GENERIC_OP *origin, - ACPI_OBJECT_INTERNAL *mth_desc, - ACPI_WALK_LIST *walk_list); - -ACPI_STATUS -acpi_ds_obj_stack_delete_all ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_obj_stack_pop_and_delete ( - u32 pop_count, - ACPI_WALK_STATE *walk_state); - -void -acpi_ds_delete_walk_state ( - ACPI_WALK_STATE *walk_state); - -ACPI_WALK_STATE * -acpi_ds_pop_walk_state ( - ACPI_WALK_LIST *walk_list); - -ACPI_STATUS -acpi_ds_result_stack_pop ( - ACPI_OBJECT_INTERNAL **object, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_result_stack_push ( - void *object, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ds_result_stack_clear ( - ACPI_WALK_STATE *walk_state); - -ACPI_WALK_STATE * -acpi_ds_get_current_walk_state ( - ACPI_WALK_LIST *walk_list); - -void -acpi_ds_delete_walk_state_cache ( - void); - - -#endif /* _DISPATCH_H_ */ \ No newline at end of file diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/events.h linux/drivers/acpi/include/events.h --- v2.4.0-test8/linux/drivers/acpi/include/events.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/events.h Wed Dec 31 16:00:00 1969 @@ -1,209 +0,0 @@ - -/****************************************************************************** - * - * Name: events.h - Acpi_event subcomponent prototypes and defines - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - -#ifndef __EVENTS_H__ -#define __EVENTS_H__ - - -/* - * Acpi_evfixed - Fixed event handling - */ - -ACPI_STATUS -acpi_ev_fixed_event_initialize ( - void); - -u32 -acpi_ev_fixed_event_detect ( - void); - -u32 -acpi_ev_fixed_event_dispatch ( - u32 acpi_event); - - -/* - * Acpi_evglock - Global Lock support - */ - -ACPI_STATUS -acpi_ev_acquire_global_lock( - void); - -void -acpi_ev_release_global_lock( - void); - -ACPI_STATUS -acpi_ev_init_global_lock_handler ( - void); - - -/* - * Acpi_evgpe - GPE handling and dispatch - */ - -ACPI_STATUS -acpi_ev_gpe_initialize ( - void); - -ACPI_STATUS -acpi_ev_init_gpe_control_methods ( - void); - -u32 -acpi_ev_gpe_dispatch ( - u32 gpe_number); - -u32 -acpi_ev_gpe_detect ( - void); - - -/* - * Acpi_evnotify - Device Notify handling and dispatch - */ - -void -acpi_ev_notify_dispatch ( - ACPI_HANDLE device, - u32 notify_value); - - -/* - * Acpi_evregion - Address Space handling - */ - -ACPI_STATUS -acpi_ev_install_default_address_space_handlers ( - void); - -ACPI_STATUS -acpi_ev_address_space_dispatch ( - ACPI_OBJECT_INTERNAL *region_obj, - u32 function, - u32 address, - u32 bit_width, - u32 *value); - - -ACPI_STATUS -acpi_ev_addr_handler_helper ( - ACPI_HANDLE obj_handle, - u32 level, - void *context, - void **return_value); - -void -acpi_ev_disassociate_region_from_handler( - ACPI_OBJECT_INTERNAL *region_obj); - - -ACPI_STATUS -acpi_ev_associate_region_and_handler( - ACPI_OBJECT_INTERNAL *handler_obj, - ACPI_OBJECT_INTERNAL *region_obj); - - -/* - * Acpi_evregini - Region initialization and setup - */ - -ACPI_STATUS -acpi_ev_system_memory_region_setup ( - ACPI_HANDLE handle, - u32 function, - void *handler_context, - void **return_context); - -ACPI_STATUS -acpi_ev_io_space_region_setup ( - ACPI_HANDLE handle, - u32 function, - void *handler_context, - void **return_context); - -ACPI_STATUS -acpi_ev_pci_config_region_setup ( - ACPI_HANDLE handle, - u32 function, - void *handler_context, - void **return_context); - -ACPI_STATUS -acpi_ev_default_region_setup ( - ACPI_HANDLE handle, - u32 function, - void *handler_context, - void **return_context); - -ACPI_STATUS -acpi_ev_initialize_region ( - ACPI_OBJECT_INTERNAL *region_obj, - u8 acpi_ns_locked); - - -/* - * Acpi_evsci - SCI (System Control Interrupt) handling/dispatch - */ - -u32 -acpi_ev_install_sci_handler ( - void); - -ACPI_STATUS -acpi_ev_remove_sci_handler ( - void); - -s32 -acpi_ev_initialize_sCI ( - s32 program_sCI); - -void -acpi_ev_restore_acpi_state ( - void); - -void -acpi_ev_terminate ( - void); - - -/* Debug support */ - -#ifdef ACPI_DEBUG - -s32 -acpi_ev_sci_count ( - u32 acpi_event); - -#define DEBUG_INCREMENT_EVENT_COUNT(a) acpi_gbl_event_count[a]++; - -#else - -#define DEBUG_INCREMENT_EVENT_COUNT(a) -#endif - - -#endif /* __EVENTS_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/globals.h linux/drivers/acpi/include/globals.h --- v2.4.0-test8/linux/drivers/acpi/include/globals.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/globals.h Wed Dec 31 16:00:00 1969 @@ -1,311 +0,0 @@ - -/****************************************************************************** - * - * Name: globals.h - Declarations for global variables - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - -#ifndef __GLOBALS_H__ -#define __GLOBALS_H__ - - -/* - * Ensure that the globals are actually defined only once - */ -#ifdef DEFINE_ACPI_GLOBALS -#define ACPI_EXTERN -#else -#define ACPI_EXTERN extern -#endif - - -extern char *msg_acpi_error_break; - -/***************************************************************************** - * - * Debug support - * - ****************************************************************************/ - -/* Runtime configuration of debug print levels */ - -extern u32 acpi_dbg_level; -extern u32 acpi_dbg_layer; - - -/* Procedure nesting level for debug output */ - -extern u32 acpi_gbl_nesting_level; - - -/***************************************************************************** - * - * ACPI Table globals - * - ****************************************************************************/ - -/* - * Table pointers. - * Although these pointers are somewhat redundant with the global Acpi_table, - * they are convenient because they are typed pointers. - * - * These tables are single-table only; meaning that there can be at most one - * of each in the system. Each global points to the actual table. - * - */ -ACPI_EXTERN ROOT_SYSTEM_DESCRIPTOR_POINTER *acpi_gbl_RSDP; -ACPI_EXTERN ROOT_SYSTEM_DESCRIPTION_TABLE *acpi_gbl_RSDT; -ACPI_EXTERN FIRMWARE_ACPI_CONTROL_STRUCTURE *acpi_gbl_FACS; -ACPI_EXTERN FIXED_ACPI_DESCRIPTION_TABLE *acpi_gbl_FACP; -ACPI_EXTERN APIC_TABLE *acpi_gbl_APIC; -ACPI_EXTERN ACPI_TABLE_HEADER *acpi_gbl_DSDT; -ACPI_EXTERN ACPI_TABLE_HEADER *acpi_gbl_SBST; -/* - * Since there may be multiple SSDTs and PSDTS, a single pointer is not - * sufficient; Therefore, there isn't one! - */ - - -/* - * ACPI Table info arrays - */ -extern ACPI_TABLE_DESC acpi_gbl_acpi_tables[NUM_ACPI_TABLES]; -extern ACPI_TABLE_SUPPORT acpi_gbl_acpi_table_data[NUM_ACPI_TABLES]; - -/* - * Predefined mutex objects. This array contains the - * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. - * (The table maps local handles to the real OS handles) - */ -ACPI_EXTERN ACPI_MUTEX_INFO acpi_gbl_acpi_mutex_info [NUM_MTX]; -extern ACPI_INIT_DATA acpi_gbl_acpi_init_data; - - -/***************************************************************************** - * - * Miscellaneous globals - * - ****************************************************************************/ - - -ACPI_EXTERN u8 *acpi_gbl_gpe0enable_register_save; -ACPI_EXTERN u8 *acpi_gbl_gpe1_enable_register_save; -ACPI_EXTERN ACPI_WALK_STATE *acpi_gbl_breakpoint_walk; -ACPI_EXTERN ACPI_GENERIC_STATE *acpi_gbl_generic_state_cache; -ACPI_EXTERN ACPI_GENERIC_OP *acpi_gbl_parse_cache; -ACPI_EXTERN ACPI_OBJECT_INTERNAL *acpi_gbl_object_cache; -ACPI_EXTERN ACPI_WALK_STATE *acpi_gbl_walk_state_cache; -ACPI_EXTERN ACPI_HANDLE acpi_gbl_global_lock_semaphore; - - -ACPI_EXTERN u32 acpi_gbl_global_lock_thread_count; -ACPI_EXTERN u32 acpi_gbl_restore_acpi_chipset; -ACPI_EXTERN u32 acpi_gbl_original_mode; -ACPI_EXTERN u32 acpi_gbl_edge_level_save; -ACPI_EXTERN u32 acpi_gbl_irq_enable_save; -ACPI_EXTERN u32 acpi_gbl_rsdp_original_location; - -ACPI_EXTERN u32 acpi_gbl_state_cache_requests; -ACPI_EXTERN u32 acpi_gbl_state_cache_hits; -ACPI_EXTERN u32 acpi_gbl_parse_cache_requests; -ACPI_EXTERN u32 acpi_gbl_parse_cache_hits; -ACPI_EXTERN u32 acpi_gbl_object_cache_requests; -ACPI_EXTERN u32 acpi_gbl_object_cache_hits; -ACPI_EXTERN u32 acpi_gbl_walk_state_cache_requests; -ACPI_EXTERN u32 acpi_gbl_walk_state_cache_hits; -ACPI_EXTERN u32 acpi_gbl_ns_lookup_count; -ACPI_EXTERN u32 acpi_gbl_ps_find_count; - - -ACPI_EXTERN u16 acpi_gbl_generic_state_cache_depth; -ACPI_EXTERN u16 acpi_gbl_parse_cache_depth; -ACPI_EXTERN u16 acpi_gbl_object_cache_depth; -ACPI_EXTERN u16 acpi_gbl_walk_state_cache_depth; -ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; -ACPI_EXTERN u16 acpi_gbl_next_table_owner_id; -ACPI_EXTERN u16 acpi_gbl_next_method_owner_id; - -ACPI_EXTERN u8 acpi_gbl_debugger_configuration; -ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; -ACPI_EXTERN u8 acpi_gbl_global_lock_set; /* TBD: [Restructure] OBSOLETE?? */ -ACPI_EXTERN u8 acpi_gbl_step_to_next_call; -ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present; - - -ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER acpi_gbl_drv_notify; -ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER acpi_gbl_sys_notify; - - -extern u8 acpi_gbl_shutdown; -extern u32 acpi_gbl_system_flags; -extern u32 acpi_gbl_startup_flags; - - -/***************************************************************************** - * - * Namespace globals - * - ****************************************************************************/ - -#define NUM_NS_TYPES INTERNAL_TYPE_INVALID+1 -#define NUM_PREDEFINED_NAMES 9 - - -ACPI_EXTERN ACPI_NAME_TABLE acpi_gbl_root_name_table; -ACPI_EXTERN ACPI_NAMED_OBJECT *acpi_gbl_root_object; - -extern u8 acpi_gbl_ns_properties[NUM_NS_TYPES]; -extern PREDEFINED_NAMES acpi_gbl_pre_defined_names [NUM_PREDEFINED_NAMES]; - - -/* Used to detect memory leaks (DEBUG ONLY) */ - -#ifdef ACPI_DEBUG -ACPI_EXTERN ALLOCATION_INFO *acpi_gbl_head_alloc_ptr; -ACPI_EXTERN ALLOCATION_INFO *acpi_gbl_tail_alloc_ptr; -#endif - - -/***************************************************************************** - * - * Interpreter globals - * - ****************************************************************************/ - - -ACPI_EXTERN u32 acpi_gbl_when_to_parse_methods; -ACPI_EXTERN ACPI_WALK_LIST *acpi_gbl_current_walk_list; - -/* Base of AML block, and pointer to current location in it */ - -ACPI_EXTERN u8 *acpi_gbl_Pcode_base; -ACPI_EXTERN u8 *acpi_gbl_Pcode; - -/* - * Length of AML block, and remaining length of current package. - */ -ACPI_EXTERN u32 acpi_gbl_Pcode_block_len; -ACPI_EXTERN u32 acpi_gbl_Pcode_len; - -ACPI_EXTERN u32 acpi_gbl_buf_seq; /* Counts allocated Buffer descriptors */ -ACPI_EXTERN s32 acpi_gbl_named_object_err; /* Indicate if inc_error should be called */ - -/* - * Handle to the last method found - used during pass1 of load - */ -ACPI_EXTERN ACPI_HANDLE acpi_gbl_last_method; - -/* - * Table of Address Space handlers - */ - -ACPI_EXTERN ACPI_ADDRESS_SPACE_INFO acpi_gbl_address_spaces[ACPI_NUM_ADDRESS_SPACES]; - - -/* Control method single step flag */ - -ACPI_EXTERN u8 acpi_gbl_cm_single_step; - - -/***************************************************************************** - * - * Parser globals - * - ****************************************************************************/ - -ACPI_EXTERN ACPI_GENERIC_OP *acpi_gbl_parsed_namespace_root; - -extern ACPI_OP_INFO acpi_gbl_aml_op_info[]; -extern u8 acpi_gbl_aml_op_info_index[256]; -extern char *acpi_gbl_parser_id; - - -/***************************************************************************** - * - * Hardware globals - * - ****************************************************************************/ - -extern ACPI_C_STATE_HANDLER acpi_hw_cx_handlers[MAX_CX_STATES]; -extern u32 acpi_hw_active_cx_state; - - -/***************************************************************************** - * - * Event globals - * - ****************************************************************************/ - -ACPI_EXTERN ACPI_FIXED_EVENT_INFO acpi_gbl_fixed_event_handlers[NUM_FIXED_EVENTS]; - -ACPI_EXTERN ACPI_HANDLE acpi_gbl_gpe_obj_handle; -ACPI_EXTERN u32 acpi_gbl_gpe_register_count; -ACPI_EXTERN ACPI_GPE_REGISTERS *acpi_gbl_gpe_registers; -ACPI_EXTERN ACPI_GPE_LEVEL_INFO *acpi_gbl_gpe_info; - -/* - * Gpe validation and translation table - * Indexed by the GPE number, returns GPE_INVALID if the GPE is not supported. - * Otherwise, returns a valid index into the global GPE table. - * - * This table is needed because the GPE numbers supported by block 1 do not - * have to be contiguous with the GPE numbers supported by block 0. - */ -ACPI_EXTERN u8 acpi_gbl_gpe_valid [NUM_GPE]; - -/* Acpi_event counter for debug only */ - -#ifdef ACPI_DEBUG -ACPI_EXTERN u32 acpi_gbl_event_count[NUM_FIXED_EVENTS]; -#endif - - -/***************************************************************************** - * - * Debugger globals - * - ****************************************************************************/ - -ACPI_EXTERN u8 acpi_gbl_method_executing; -ACPI_EXTERN u8 acpi_gbl_db_terminate_threads; - - -/* Memory allocation metrics - Debug Only! */ - -#ifdef ACPI_DEBUG - -ACPI_EXTERN u32 acpi_gbl_current_alloc_size; -ACPI_EXTERN u32 acpi_gbl_current_alloc_count; -ACPI_EXTERN u32 acpi_gbl_running_alloc_size; -ACPI_EXTERN u32 acpi_gbl_running_alloc_count; -ACPI_EXTERN u32 acpi_gbl_max_concurrent_alloc_size; -ACPI_EXTERN u32 acpi_gbl_max_concurrent_alloc_count; -ACPI_EXTERN u32 acpi_gbl_current_object_count; -ACPI_EXTERN u32 acpi_gbl_current_object_size; -ACPI_EXTERN u32 acpi_gbl_max_concurrent_object_count; -ACPI_EXTERN u32 acpi_gbl_max_concurrent_object_size; -ACPI_EXTERN u32 acpi_gbl_running_object_count; -ACPI_EXTERN u32 acpi_gbl_running_object_size; - -#endif - - -#endif /* __GLOBALS_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/hardware.h linux/drivers/acpi/include/hardware.h --- v2.4.0-test8/linux/drivers/acpi/include/hardware.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/hardware.h Wed Dec 31 16:00:00 1969 @@ -1,169 +0,0 @@ - -/****************************************************************************** - * - * Name: hardware.h -- hardware specific interfaces - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - -#ifndef __HARDWARE_H__ -#define __HARDWARE_H__ - - -/* Prototypes */ - - -ACPI_STATUS -acpi_hw_initialize( - void); - -ACPI_STATUS -acpi_hw_shutdown( - void); - -ACPI_STATUS -acpi_hw_initialize_system_info( - void); - -ACPI_STATUS -acpi_hw_set_mode ( - u32 mode); - -u32 -acpi_hw_get_mode ( - void); - -u32 -acpi_hw_get_mode_capabilities ( - void); - -/* Register I/O Prototypes */ - -u32 -acpi_hw_register_access ( - NATIVE_UINT read_write, - u8 use_lock, - u32 register_id, ... /* DWORD Value */); - -void -acpi_hw_clear_acpi_status ( - void); - - -/* GPE support */ - -void -acpi_hw_enable_gpe ( - u32 gpe_index); - -void -acpi_hw_disable_gpe ( - u32 gpe_index); - -void -acpi_hw_clear_gpe ( - u32 gpe_index); - -void -acpi_hw_get_gpe_status ( - u32 gpe_number, - ACPI_EVENT_STATUS *event_status); - -/* Sleep Prototypes */ - -ACPI_STATUS -acpi_hw_obtain_sleep_type_register_data ( - u8 sleep_state, - u8 *slp_typ_a, - u8 *slp_typ_b); - - -/* Cx State Prototypes */ - -ACPI_STATUS -acpi_hw_enter_c1( - ACPI_IO_ADDRESS pblk_address, - u32 *pm_timer_ticks); - -ACPI_STATUS -acpi_hw_enter_c2( - ACPI_IO_ADDRESS pblk_address, - u32 *pm_timer_ticks); - -ACPI_STATUS -acpi_hw_enter_c3( - ACPI_IO_ADDRESS pblk_address, - u32 *pm_timer_ticks); - -ACPI_STATUS -acpi_hw_enter_cx ( - ACPI_IO_ADDRESS pblk_address, - u32 *pm_timer_ticks); - -ACPI_STATUS -acpi_hw_set_cx ( - u32 cx_state); - -ACPI_STATUS -acpi_hw_get_cx_info ( - u32 cx_states[]); - - -/* Throttling Prototypes */ - -void -acpi_hw_enable_throttling ( - ACPI_IO_ADDRESS pblk_address); - -void -acpi_hw_disable_throttling ( - ACPI_IO_ADDRESS pblk_address); - -u32 -acpi_hw_get_duty_cycle ( - u8 duty_offset, - ACPI_IO_ADDRESS pblk_address, - u32 num_throttle_states); - -void -acpi_hw_program_duty_cycle ( - u8 duty_offset, - u32 duty_cycle, - ACPI_IO_ADDRESS pblk_address, - u32 num_throttle_states); - -NATIVE_UINT -acpi_hw_local_pow ( - NATIVE_UINT x, - NATIVE_UINT y); - - -/* ACPI Timer prototypes */ - -u32 -acpi_hw_pmt_ticks ( - void); - -u32 -acpi_hw_pmt_resolution ( - void); - - -#endif /* __HARDWARE_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/internal.h linux/drivers/acpi/include/internal.h --- v2.4.0-test8/linux/drivers/acpi/include/internal.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/internal.h Wed Dec 31 16:00:00 1969 @@ -1,850 +0,0 @@ - -/****************************************************************************** - * - * Name: internal.h - Internal data types used across the ACPI subsystem - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - -#ifndef _ACPI_INTERNAL_H -#define _ACPI_INTERNAL_H - -#include "config.h" - - -#define WAIT_FOREVER ((u32) -1) - -typedef void* ACPI_MUTEX; -typedef u32 ACPI_MUTEX_HANDLE; - - -/* Object descriptor types */ - -#define ACPI_DESC_TYPE_INTERNAL 0xAA -#define ACPI_DESC_TYPE_PARSER 0xBB -#define ACPI_DESC_TYPE_STATE 0xCC -#define ACPI_DESC_TYPE_WALK 0xDD -#define ACPI_DESC_TYPE_NAMED 0xEE - - -/***************************************************************************** - * - * Mutex typedefs and structs - * - ****************************************************************************/ - - -/* - * Predefined handles for the mutex objects used within the subsystem - * All mutex objects are automatically created by Acpi_cm_mutex_initialize. - * NOTE: any changes here must be reflected in the Acpi_gbl_Mutex_names table also! - */ - -#define ACPI_MTX_HARDWARE 0 -#define ACPI_MTX_MEMORY 1 -#define ACPI_MTX_CACHES 2 -#define ACPI_MTX_TABLES 3 -#define ACPI_MTX_PARSER 4 -#define ACPI_MTX_DISPATCHER 5 -#define ACPI_MTX_INTERPRETER 6 -#define ACPI_MTX_EXECUTE 7 -#define ACPI_MTX_NAMESPACE 8 -#define ACPI_MTX_EVENTS 9 -#define ACPI_MTX_OP_REGIONS 10 -#define ACPI_MTX_DEBUG_CMD_READY 11 -#define ACPI_MTX_DEBUG_CMD_COMPLETE 12 - -#define MAX_MTX 12 -#define NUM_MTX MAX_MTX+1 - - -#ifdef ACPI_DEBUG -#ifdef DEFINE_ACPI_GLOBALS - -/* Names for the mutexes used in the subsystem */ - -static char *acpi_gbl_mutex_names[] = -{ - "ACPI_MTX_Hardware", - "ACPI_MTX_Memory", - "ACPI_MTX_Caches", - "ACPI_MTX_Tables", - "ACPI_MTX_Parser", - "ACPI_MTX_Dispatcher", - "ACPI_MTX_Interpreter", - "ACPI_MTX_Execute", - "ACPI_MTX_Namespace", - "ACPI_MTX_Events", - "ACPI_MTX_Op_regions", - "ACPI_MTX_Debug_cmd_ready", - "ACPI_MTX_Debug_cmd_complete" -}; - -#endif -#endif - - -/* Table for the global mutexes */ - -typedef struct acpi_mutex_info -{ - ACPI_MUTEX mutex; - u32 use_count; - u8 locked; - -} ACPI_MUTEX_INFO; - - -/* Lock flag parameter for various interfaces */ - -#define ACPI_MTX_DO_NOT_LOCK 0 -#define ACPI_MTX_LOCK 1 - - -typedef u16 ACPI_OWNER_ID; -#define OWNER_TYPE_TABLE 0x0 -#define OWNER_TYPE_METHOD 0x1 -#define FIRST_METHOD_ID 0x0000 -#define FIRST_TABLE_ID 0x8000 - -/* TBD: [Restructure] get rid of the need for this! */ - -#define TABLE_ID_DSDT (ACPI_OWNER_ID) 0xD1D1 - -/***************************************************************************** - * - * Namespace typedefs and structs - * - ****************************************************************************/ - - -/* Operational modes of the AML interpreter/scanner */ - -typedef enum -{ - IMODE_LOAD_PASS1 = 0x01, - IMODE_LOAD_PASS2 = 0x02, - IMODE_EXECUTE = 0x0E - -} OPERATING_MODE; - - -/* - * The Acpi_named_object describes a named object that appears in the AML - * An Acpi_name_table is used to store Acpi_named_objects. - * - * Data_type is used to differentiate between internal descriptors, and MUST - * be the first byte in this structure. - */ - -typedef struct acpi_named_object -{ - u8 data_type; - u8 type; /* Type associated with this name */ - u8 this_index; /* Entry number */ - u8 flags; - u32 name; /* ACPI Name, always 4 chars per ACPI spec */ - - - void *object; /* Pointer to attached ACPI object (optional) */ - struct acpi_name_table *child_table; /* Scope owned by this name (optional) */ - ACPI_OWNER_ID owner_id; /* ID of owner - either an ACPI table or a method */ - u16 reference_count; /* Current count of references and children */ - -#ifdef _IA64 - u32 fill1; /* 64-bit alignment */ -#endif - -} ACPI_NAMED_OBJECT; - - -typedef struct acpi_name_table -{ - struct acpi_name_table *next_table; - struct acpi_name_table *parent_table; - ACPI_NAMED_OBJECT *parent_entry; - ACPI_NAMED_OBJECT entries[1]; - -} ACPI_NAME_TABLE; - - -#define ENTRY_NOT_FOUND NULL - - -/* NTE flags */ - -#define NTE_AML_ATTACHMENT 0x1 - - -/* - * ACPI Table Descriptor. One per ACPI table - */ -typedef struct acpi_table_desc -{ - struct acpi_table_desc *prev; - struct acpi_table_desc *next; - struct acpi_table_desc *installed_desc; - ACPI_TABLE_HEADER *pointer; - void *base_pointer; - u8 *aml_pointer; - u32 aml_length; - u32 length; - u32 count; - ACPI_OWNER_ID table_id; - u8 type; - u8 allocation; - u8 loaded_into_namespace; - -} ACPI_TABLE_DESC; - - -typedef struct -{ - char *search_for; - ACPI_HANDLE *list; - s32 *count; - -} FIND_CONTEXT; - - -typedef struct -{ - ACPI_NAME_TABLE *name_table; - u32 position; - u8 table_full; - -} NS_SEARCH_DATA; - - -/* - * Predefined Namespace items - */ -#define ACPI_MAX_ADDRESS_SPACE 255 -#define ACPI_NUM_ADDRESS_SPACES 256 - - -typedef struct -{ - char *name; - ACPI_OBJECT_TYPE type; - char *val; - -} PREDEFINED_NAMES; - - -/***************************************************************************** - * - * Event typedefs and structs - * - ****************************************************************************/ - - -/* Status bits. */ - -#define ACPI_STATUS_PMTIMER 0x0001 -#define ACPI_STATUS_GLOBAL 0x0020 -#define ACPI_STATUS_POWER_BUTTON 0x0100 -#define ACPI_STATUS_SLEEP_BUTTON 0x0200 -#define ACPI_STATUS_RTC_ALARM 0x0400 - -/* Enable bits. */ - -#define ACPI_ENABLE_PMTIMER 0x0001 -#define ACPI_ENABLE_GLOBAL 0x0020 -#define ACPI_ENABLE_POWER_BUTTON 0x0100 -#define ACPI_ENABLE_SLEEP_BUTTON 0x0200 -#define ACPI_ENABLE_RTC_ALARM 0x0400 - - -/* - * Entry in the Address_space (AKA Operation Region) table - */ - -typedef struct -{ - ADDRESS_SPACE_HANDLER handler; - void *context; - -} ACPI_ADDRESS_SPACE_INFO; - - -/* Values and addresses of the GPE registers (both banks) */ - -typedef struct -{ - u8 status; /* Current value of status reg */ - u8 enable; /* Current value of enable reg */ - u16 status_addr; /* Address of status reg */ - u16 enable_addr; /* Address of enable reg */ - u8 gpe_base; /* Base GPE number */ - -} ACPI_GPE_REGISTERS; - - -#define ACPI_GPE_LEVEL_TRIGGERED 1 -#define ACPI_GPE_EDGE_TRIGGERED 2 - - -/* Information about each particular GPE level */ - -typedef struct -{ - u8 type; /* Level or Edge */ - - ACPI_HANDLE method_handle; /* Method handle for direct (fast) execution */ - GPE_HANDLER handler; /* Address of handler, if any */ - void *context; /* Context to be passed to handler */ - -} ACPI_GPE_LEVEL_INFO; - - -/* Information about each particular fixed event */ - -typedef struct -{ - FIXED_EVENT_HANDLER handler; /* Address of handler. */ - void *context; /* Context to be passed to handler */ - -} ACPI_FIXED_EVENT_INFO; - - -/* Information used during field processing */ - -typedef struct -{ - u8 skip_field; - u8 field_flag; - u32 pkg_length; - -} ACPI_FIELD_INFO; - - -/***************************************************************************** - * - * Parser typedefs and structs - * - ****************************************************************************/ - - -#define OP_INFO_TYPE 0x1F -#define OP_INFO_HAS_ARGS 0x20 -#define OP_INFO_CHILD_LOCATION 0xC0 - -/* - * AML opcode, name, and argument layout - */ -typedef struct acpi_op_info -{ - u16 opcode; /* AML opcode */ - u8 flags; /* Opcode type, Has_args flag */ - u32 parse_args; /* Grammar/Parse time arguments */ - u32 runtime_args; /* Interpret time arguments */ - - DEBUG_ONLY_MEMBERS ( - char *name) /* op name (debug only) */ - -} ACPI_OP_INFO; - - -typedef union acpi_op_value -{ - u32 integer; /* integer constant */ - u32 size; /* bytelist or field size */ - char *string; /* NULL terminated string */ - u8 *buffer; /* buffer or string */ - char *name; /* NULL terminated string */ - struct acpi_generic_op *arg; /* arguments and contained ops */ - ACPI_NAMED_OBJECT *entry; /* entry in interpreter namespace tbl */ - -} ACPI_OP_VALUE; - - -#define ACPI_COMMON_OP \ - u8 data_type; /* To differentiate various internal objs */\ - u8 flags; /* Type of Op */\ - u16 opcode; /* AML opcode */\ - u32 aml_offset; /* offset of declaration in AML */\ - struct acpi_generic_op *parent; /* parent op */\ - struct acpi_generic_op *next; /* next op */\ - DEBUG_ONLY_MEMBERS (\ - char op_name[16]) /* op name (debug only) */\ - /* NON-DEBUG members below: */\ - void *acpi_named_object;/* for use by interpreter */\ - ACPI_OP_VALUE value; /* Value or args associated with the opcode */\ - - -/* - * generic operation (eg. If, While, Store) - */ -typedef struct acpi_generic_op -{ - ACPI_COMMON_OP -} ACPI_GENERIC_OP; - - -/* - * operation with a name (eg. Scope, Method, Name, Named_field, ...) - */ -typedef struct acpi_named_op -{ - ACPI_COMMON_OP - u32 name; /* 4-byte name or zero if no name */ - -} ACPI_NAMED_OP; - - -/* - * special operation for methods and regions (parsing must be deferred - * until a first pass parse is completed) - */ -typedef struct acpi_deferred_op -{ - ACPI_COMMON_OP - u32 name; /* 4-byte name or 0 if none */ - u32 body_length; /* AML body size */ - u8 *body; /* AML body */ - u16 thread_count; /* Count of threads currently executing a method */ - -} ACPI_DEFERRED_OP; - - -/* - * special operation for bytelists (Byte_list only) - */ -typedef struct acpi_bytelist_op -{ - ACPI_COMMON_OP - u8 *data; /* bytelist data */ - -} ACPI_BYTELIST_OP; - - -/* - * Parse state - one state per parser invocation and each control - * method. - */ - -typedef struct acpi_parse_state -{ - u8 *aml_start; /* first AML byte */ - u8 *aml; /* next AML byte */ - u8 *aml_end; /* (last + 1) AML byte */ - u8 *pkg_end; /* current package end */ - ACPI_GENERIC_OP *start_op; /* root of parse tree */ - struct acpi_parse_scope *scope; /* current scope */ - struct acpi_parse_scope *scope_avail; /* unused (extra) scope structs */ - struct acpi_parse_state *next; - -} ACPI_PARSE_STATE; - - -/* - * Parse scope - one per ACPI scope - */ - -typedef struct acpi_parse_scope -{ - ACPI_GENERIC_OP *op; /* current op being parsed */ - u8 *arg_end; /* current argument end */ - u8 *pkg_end; /* current package end */ - struct acpi_parse_scope *parent; /* parent scope */ - u32 arg_list; /* next argument to parse */ - u32 arg_count; /* Number of fixed arguments */ - -} ACPI_PARSE_SCOPE; - - -/***************************************************************************** - * - * Generic "state" object for stacks - * - ****************************************************************************/ - - -#define CONTROL_NORMAL 0xC0 -#define CONTROL_CONDITIONAL_EXECUTING 0xC1 -#define CONTROL_PREDICATE_EXECUTING 0xC2 -#define CONTROL_PREDICATE_FALSE 0xC3 -#define CONTROL_PREDICATE_TRUE 0xC4 - - -#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ - u8 data_type; /* To differentiate various internal objs */\ - u8 flags; \ - u16 value; \ - u16 state; \ - u16 acpi_eval; \ - void *next; \ - -typedef struct acpi_common_state -{ - ACPI_STATE_COMMON -} ACPI_COMMON_STATE; - - -/* - * Update state - used to traverse complex objects such as packages - */ -typedef struct acpi_update_state -{ - ACPI_STATE_COMMON - union acpi_obj_internal *object; - -} ACPI_UPDATE_STATE; - -/* - * Control state - one per if/else and while constructs. - * Allows nesting of these constructs - */ -typedef struct acpi_control_state -{ - ACPI_STATE_COMMON - ACPI_GENERIC_OP *predicate_op; /* Start of if/while predicate */ - -} ACPI_CONTROL_STATE; - - -/* - * Scope state - current scope during namespace lookups - */ - -typedef struct acpi_scope_state -{ - ACPI_STATE_COMMON - ACPI_NAME_TABLE *name_table; - -} ACPI_SCOPE_STATE; - - -typedef union acpi_gen_state -{ - ACPI_COMMON_STATE common; - ACPI_CONTROL_STATE control; - ACPI_UPDATE_STATE update; - ACPI_SCOPE_STATE scope; - -} ACPI_GENERIC_STATE; - - -/***************************************************************************** - * - * Tree walking typedefs and structs - * - ****************************************************************************/ - - -/* - * Walk state - current state of a parse tree walk. Used for both a leisurely stroll through - * the tree (for whatever reason), and for control method execution. - */ - -#define NEXT_OP_DOWNWARD 1 -#define NEXT_OP_UPWARD 2 - -typedef struct acpi_walk_state -{ - u8 data_type; /* To differentiate various internal objs */\ - ACPI_OWNER_ID owner_id; /* Owner of objects created during the walk */ - u8 last_predicate; /* Result of last predicate */ - u8 next_op_info; /* Info about Next_op */ - u8 num_operands; /* Stack pointer for Operands[] array */ - u8 num_results; /* Stack pointer for Results[] array */ - u8 current_result; /* */ - - struct acpi_walk_state *next; /* Next Walk_state in list */ - ACPI_GENERIC_OP *origin; /* Start of walk */ - ACPI_GENERIC_OP *prev_op; /* Last op that was processed */ - ACPI_GENERIC_OP *next_op; /* next op to be processed */ - ACPI_GENERIC_STATE *control_state; /* List of control states (nested IFs) */ - ACPI_GENERIC_STATE *scope_info; /* Stack of nested scopes */ - union acpi_obj_internal *return_desc; /* Return object, if any */ - union acpi_obj_internal *method_desc; /* Method descriptor if running a method */ - ACPI_GENERIC_OP *method_call_op; /* Method_call Op if running a method */ - union acpi_obj_internal *operands[OBJ_NUM_OPERANDS]; /* Operands passed to the interpreter */ - union acpi_obj_internal *results[OBJ_NUM_OPERANDS]; /* Accumulated results */ - struct acpi_named_object arguments[MTH_NUM_ARGS]; /* Control method arguments */ - struct acpi_named_object local_variables[MTH_NUM_LOCALS]; /* Control method locals */ - - -} ACPI_WALK_STATE; - - -/* - * Walk list - head of a tree of walk states. Multiple walk states are created when there - * are nested control methods executing. - */ -typedef struct acpi_walk_list -{ - - ACPI_WALK_STATE *walk_state; - -} ACPI_WALK_LIST; - - -typedef -ACPI_STATUS (*INTERPRETER_CALLBACK) ( - ACPI_WALK_STATE *state, - ACPI_GENERIC_OP *op); - - -/* Info used by Acpi_ps_init_objects */ - -typedef struct init_walk_info -{ - u32 method_count; - u32 op_region_count; - ACPI_TABLE_DESC *table_desc; - -} INIT_WALK_INFO; - - -/* TBD: [Restructure] Merge with struct above */ - -typedef struct acpi_walk_info -{ - u32 debug_level; - u32 owner_id; - -} ACPI_WALK_INFO; - - -/***************************************************************************** - * - * Hardware and PNP - * - ****************************************************************************/ - - -/* Sleep states */ - -#define SLWA_DEBUG_LEVEL 4 -#define GTS_CALL 0 -#define GTS_WAKE 1 - -/* Cx States */ - -#define MAX_CX_STATE_LATENCY 0xFFFFFFFF -#define MAX_CX_STATES 4 - -/* - * The #define's and enum below establish an abstract way of identifying what - * register block and register is to be accessed. Do not change any of the - * values as they are used in switch statements and offset calculations. - */ - -#define REGISTER_BLOCK_MASK 0xFF00 -#define BIT_IN_REGISTER_MASK 0x00FF -#define PM1_EVT 0x0100 -#define PM1_CONTROL 0x0200 -#define PM2_CONTROL 0x0300 -#define PM_TIMER 0x0400 -#define PROCESSOR_BLOCK 0x0500 -#define GPE0_STS_BLOCK 0x0600 -#define GPE0_EN_BLOCK 0x0700 -#define GPE1_STS_BLOCK 0x0800 -#define GPE1_EN_BLOCK 0x0900 - -enum -{ - /* PM1 status register ids */ - - TMR_STS = (PM1_EVT | 0x01), - BM_STS, - GBL_STS, - PWRBTN_STS, - SLPBTN_STS, - RTC_STS, - WAK_STS, - - /* PM1 enable register ids */ - - TMR_EN, - /* need to skip 1 enable number since there's no bus master enable register */ - GBL_EN = (PM1_EVT | 0x0A), - PWRBTN_EN, - SLPBTN_EN, - RTC_EN, - - /* PM1 control register ids */ - - SCI_EN = (PM1_CONTROL | 0x01), - BM_RLD, - GBL_RLS, - SLP_TYPE_A, - SLP_TYPE_B, - SLP_EN, - - /* PM2 control register ids */ - - ARB_DIS = (PM2_CONTROL | 0x01), - - /* PM Timer register ids */ - - TMR_VAL = (PM_TIMER | 0x01), - - GPE0_STS = (GPE0_STS_BLOCK | 0x01), - GPE0_EN = (GPE0_EN_BLOCK | 0x01), - - GPE1_STS = (GPE1_STS_BLOCK | 0x01), - GPE1_EN = (GPE0_EN_BLOCK | 0x01), - - /* Last register value is one less than LAST_REG */ - - LAST_REG -}; - - -#define TMR_STS_MASK 0x0001 -#define BM_STS_MASK 0x0010 -#define GBL_STS_MASK 0x0020 -#define PWRBTN_STS_MASK 0x0100 -#define SLPBTN_STS_MASK 0x0200 -#define RTC_STS_MASK 0x0400 -#define WAK_STS_MASK 0x8000 - -#define ALL_FIXED_STS_BITS (TMR_STS_MASK | BM_STS_MASK | GBL_STS_MASK | PWRBTN_STS_MASK | \ - SLPBTN_STS_MASK | RTC_STS_MASK | WAK_STS_MASK) - -#define TMR_EN_MASK 0x0001 -#define GBL_EN_MASK 0x0020 -#define PWRBTN_EN_MASK 0x0100 -#define SLPBTN_EN_MASK 0x0200 -#define RTC_EN_MASK 0x0400 - -#define SCI_EN_MASK 0x0001 -#define BM_RLD_MASK 0x0002 -#define GBL_RLS_MASK 0x0004 -#define SLP_TYPE_X_MASK 0x1C00 -#define SLP_EN_MASK 0x2000 - -#define ARB_DIS_MASK 0x0001 - -#define GPE0_STS_MASK -#define GPE0_EN_MASK - -#define GPE1_STS_MASK -#define GPE1_EN_MASK - - -#define ACPI_READ 1 -#define ACPI_WRITE 2 - -#define LOW_BYTE 0x00FF -#define ONE_BYTE 0x08 - -#ifndef SET - #define SET 1 -#endif -#ifndef CLEAR - #define CLEAR 0 -#endif - - -/* Plug and play */ - -/* Pnp and ACPI data */ - -#define VERSION_NO 0x01 -#define LOGICAL_DEVICE_ID 0x02 -#define COMPATIBLE_DEVICE_ID 0x03 -#define IRQ_FORMAT 0x04 -#define DMA_FORMAT 0x05 -#define START_DEPENDENT_TAG 0x06 -#define END_DEPENDENT_TAG 0x07 -#define IO_PORT_DESCRIPTOR 0x08 -#define FIXED_LOCATION_IO_DESCRIPTOR 0x09 -#define RESERVED_TYPE0 0x0A -#define RESERVED_TYPE1 0x0B -#define RESERVED_TYPE2 0x0C -#define RESERVED_TYPE3 0x0D -#define SMALL_VENDOR_DEFINED 0x0E -#define END_TAG 0x0F - -/* Pnp and ACPI data */ - -#define MEMORY_RANGE_24 0x81 -#define ISA_MEMORY_RANGE 0x81 -#define LARGE_VENDOR_DEFINED 0x84 -#define EISA_MEMORY_RANGE 0x85 -#define MEMORY_RANGE_32 0x85 -#define FIXED_EISA_MEMORY_RANGE 0x86 -#define FIXED_MEMORY_RANGE_32 0x86 - -/* ACPI only data */ - -#define DWORD_ADDRESS_SPACE 0x87 -#define WORD_ADDRESS_SPACE 0x88 -#define EXTENDED_IRQ 0x89 - -/* MUST HAVES */ - - -typedef enum -{ - DWORD_DEVICE_ID, - STRING_PTR_DEVICE_ID, - STRING_DEVICE_ID - -} DEVICE_ID_TYPE; - -typedef struct -{ - DEVICE_ID_TYPE type; - union - { - u32 number; - char *string_ptr; - char buffer[9]; - } data; - -} DEVICE_ID; - - -/***************************************************************************** - * - * Debug - * - ****************************************************************************/ - - -/* Entry for a memory allocation (debug only) */ - -#ifdef ACPI_DEBUG - -#define MEM_MALLOC 0 -#define MEM_CALLOC 1 -#define MAX_MODULE_NAME 16 - -typedef struct allocation_info -{ - struct allocation_info *previous; - struct allocation_info *next; - void *address; - u32 size; - u32 component; - u32 line; - char module[MAX_MODULE_NAME]; - u8 alloc_type; - -} ALLOCATION_INFO; - -#endif - -#endif diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/interp.h linux/drivers/acpi/include/interp.h --- v2.4.0-test8/linux/drivers/acpi/include/interp.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/interp.h Wed Dec 31 16:00:00 1969 @@ -1,660 +0,0 @@ - -/****************************************************************************** - * - * Name: interp.h - Interpreter subcomponent prototypes and defines - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - -#ifndef __INTERP_H__ -#define __INTERP_H__ - - -#include "actypes.h" -#include "acobject.h" - - -#define WALK_OPERANDS &(walk_state->operands [walk_state->num_operands -1]) - - -/* Interpreter constants */ - -#define AML_END_OF_BLOCK -1 -#define PUSH_PKG_LENGTH 1 -#define DO_NOT_PUSH_PKG_LENGTH 0 - - -#define STACK_TOP 0 -#define STACK_BOTTOM (u32) -1 - -/* Constants for global "When_to_parse_methods" */ - -#define METHOD_PARSE_AT_INIT 0x0 -#define METHOD_PARSE_JUST_IN_TIME 0x1 -#define METHOD_DELETE_AT_COMPLETION 0x2 - - -ACPI_STATUS -acpi_aml_resolve_operands ( - u16 opcode, - ACPI_OBJECT_INTERNAL **stack_ptr); - - -/* - * amxface - External interpreter interfaces - */ - -ACPI_STATUS -acpi_aml_load_table ( - ACPI_TABLE_TYPE table_id); - -ACPI_STATUS -acpi_aml_execute_method ( - ACPI_NAMED_OBJECT *method_entry, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **return_obj_desc); - - -/* - * amcopy - Interpreter object copy support - */ - -ACPI_STATUS -acpi_aml_build_copy_internal_package_object ( - ACPI_OBJECT_INTERNAL *source_obj, - ACPI_OBJECT_INTERNAL *dest_obj); - - -/* - * amfield - ACPI AML (p-code) execution - field manipulation - */ - - -ACPI_STATUS -acpi_aml_read_field ( - ACPI_OBJECT_INTERNAL *obj_desc, - void *buffer, - u32 buffer_length, - u32 byte_length, - u32 datum_length, - u32 bit_granularity, - u32 byte_granularity); - -ACPI_STATUS -acpi_aml_write_field ( - ACPI_OBJECT_INTERNAL *obj_desc, - void *buffer, - u32 buffer_length, - u32 byte_length, - u32 datum_length, - u32 bit_granularity, - u32 byte_granularity); - -ACPI_STATUS -acpi_aml_setup_field ( - ACPI_OBJECT_INTERNAL *obj_desc, - ACPI_OBJECT_INTERNAL *rgn_desc, - s32 field_bit_width); - -ACPI_STATUS -acpi_aml_read_field_data ( - ACPI_OBJECT_INTERNAL *obj_desc, - u32 field_byte_offset, - u32 field_bit_width, - u32 *value); - -ACPI_STATUS -acpi_aml_access_named_field ( - s32 mode, - ACPI_HANDLE named_field, - void *buffer, - u32 length); - -ACPI_STATUS -acpi_aml_set_named_field_value ( - ACPI_HANDLE named_field, - void *buffer, - u32 length); - -ACPI_STATUS -acpi_aml_get_named_field_value ( - ACPI_HANDLE named_field, - void *buffer, - u32 length); - - -/* - * ammisc - ACPI AML (p-code) execution - specific opcodes - */ - -ACPI_STATUS -acpi_aml_exec_create_field ( - u16 opcode, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_reconfiguration ( - u16 opcode, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_fatal ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_index ( - ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc); - -ACPI_STATUS -acpi_aml_exec_match ( - ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc); - -ACPI_STATUS -acpi_aml_exec_create_mutex ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_create_processor ( - ACPI_GENERIC_OP *op, - ACPI_HANDLE processor_nTE); - -ACPI_STATUS -acpi_aml_exec_create_power_resource ( - ACPI_GENERIC_OP *op, - ACPI_HANDLE processor_nTE); - -ACPI_STATUS -acpi_aml_exec_create_region ( - u8 *aml_ptr, - u32 acpi_aml_length, - u32 region_space, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_create_event ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_create_alias ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_create_method ( - u8 *aml_ptr, - u32 acpi_aml_length, - u32 method_flags, - ACPI_HANDLE method); - - -/* - * amprep - ACPI AML (p-code) execution - prep utilities - */ - -ACPI_STATUS -acpi_aml_prep_def_field_value ( - ACPI_NAMED_OBJECT *this_entry, - ACPI_HANDLE region, - u8 field_flags, - u8 field_attribute, - u32 field_position, - u32 field_length); - -ACPI_STATUS -acpi_aml_prep_bank_field_value ( - ACPI_NAMED_OBJECT *this_entry, - ACPI_HANDLE region, - ACPI_HANDLE bank_reg, - u32 bank_val, - u8 field_flags, - u8 field_attribute, - u32 field_position, - u32 field_length); - -ACPI_STATUS -acpi_aml_prep_index_field_value ( - ACPI_NAMED_OBJECT *this_entry, - ACPI_HANDLE index_reg, - ACPI_HANDLE data_reg, - u8 field_flags, - u8 field_attribute, - u32 field_position, - u32 field_length); - -ACPI_STATUS -acpi_aml_prep_operands ( - char *types, - ACPI_OBJECT_INTERNAL **stack_ptr); - - -/* - * iepstack - package stack utilities - */ - -/* -u32 -Acpi_aml_pkg_stack_level ( - void); - -void -Acpi_aml_clear_pkg_stack ( - void); - -ACPI_STATUS -Acpi_aml_pkg_push_length ( - u32 Length, - OPERATING_MODE Load_exec_mode); - -ACPI_STATUS -Acpi_aml_pkg_push_exec_length ( - u32 Length); - -ACPI_STATUS -Acpi_aml_pkg_push_exec ( - u8 *Code, - u32 Len); - -ACPI_STATUS -Acpi_aml_pkg_pop_length ( - s32 No_err_under, - OPERATING_MODE Load_exec_mode); - -ACPI_STATUS -Acpi_aml_pkg_pop_exec_length ( - void); - -ACPI_STATUS -Acpi_aml_pkg_pop_exec ( - void); - -*/ - -/* - * amsystem - Interface to OS services - */ - -u16 -acpi_aml_system_thread_id ( - void); - -ACPI_STATUS -acpi_aml_system_do_notify_op ( - ACPI_OBJECT_INTERNAL *value, - ACPI_OBJECT_INTERNAL *obj_desc); - -void -acpi_aml_system_do_suspend( - u32 time); - -void -acpi_aml_system_do_stall ( - u32 time); - -ACPI_STATUS -acpi_aml_system_acquire_mutex( - ACPI_OBJECT_INTERNAL *time, - ACPI_OBJECT_INTERNAL *obj_desc); - -ACPI_STATUS -acpi_aml_system_release_mutex( - ACPI_OBJECT_INTERNAL *obj_desc); - -ACPI_STATUS -acpi_aml_system_signal_event( - ACPI_OBJECT_INTERNAL *obj_desc); - -ACPI_STATUS -acpi_aml_system_wait_event( - ACPI_OBJECT_INTERNAL *time, - ACPI_OBJECT_INTERNAL *obj_desc); - -ACPI_STATUS -acpi_aml_system_reset_event( - ACPI_OBJECT_INTERNAL *obj_desc); - -ACPI_STATUS -acpi_aml_system_wait_semaphore ( - ACPI_HANDLE semaphore, - u32 timeout); - - -/* - * ammonadic - ACPI AML (p-code) execution, monadic operators - */ - -ACPI_STATUS -acpi_aml_exec_monadic1 ( - u16 opcode, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_monadic2 ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc); - -ACPI_STATUS -acpi_aml_exec_monadic2_r ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc); - - -/* - * amdyadic - ACPI AML (p-code) execution, dyadic operators - */ - -ACPI_STATUS -acpi_aml_exec_dyadic1 ( - u16 opcode, - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_aml_exec_dyadic2 ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc); - -ACPI_STATUS -acpi_aml_exec_dyadic2_r ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc); - -ACPI_STATUS -acpi_aml_exec_dyadic2_s ( - u16 opcode, - ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc); - - -/* - * amresolv - Object resolution and get value functions - */ - -ACPI_STATUS -acpi_aml_resolve_to_value ( - ACPI_OBJECT_INTERNAL **stack_ptr); - -ACPI_STATUS -acpi_aml_resolve_entry_to_value ( - ACPI_NAMED_OBJECT **stack_ptr); - -ACPI_STATUS -acpi_aml_resolve_object_to_value ( - ACPI_OBJECT_INTERNAL **stack_ptr); - -ACPI_STATUS -acpi_aml_get_field_unit_value ( - ACPI_OBJECT_INTERNAL *field_desc, - ACPI_OBJECT_INTERNAL *result_desc); - - -/* - * amcode - Scanner AML code manipulation routines - */ - -s32 -acpi_aml_avail ( - ACPI_SIZE n); - -s32 -acpi_aml_peek ( - void); - -s32 -acpi_aml_get_pcode_byte ( - u8 *pcode); - -u16 -acpi_aml_peek_op ( - void); - -u8 * -acpi_aml_consume_bytes ( - ACPI_SIZE bytes); - -ACPI_SIZE -acpi_aml_consume_stream_bytes ( - ACPI_SIZE bytes_to_get, - u8 *aml_buffer); - -void -acpi_aml_consume_package ( - OPERATING_MODE load_exec_mode); - -void -acpi_aml_set_pcode_input ( - u8 *base, - u32 length); - -ACPI_STATUS -acpi_aml_set_method ( - void *object); - -ACPI_STATUS -acpi_aml_prep_exec ( - u8 *pcode, - u32 pcode_length); - -ACPI_HANDLE -acpi_aml_get_pcode_handle ( - void); - -void -acpi_aml_get_current_location ( - ACPI_OBJECT_INTERNAL *method_desc); - -void -acpi_aml_set_current_location ( - ACPI_OBJECT_INTERNAL *method_desc); - - -/* - * amdump - Scanner debug output routines - */ - -void -acpi_aml_show_hex_value ( - s32 byte_count, - u8 *aml_ptr, - s32 lead_space); - -void -acpi_aml_dump_buffer ( - ACPI_SIZE length); - - -ACPI_STATUS -acpi_aml_dump_operand ( - ACPI_OBJECT_INTERNAL *entry_desc); - -void -acpi_aml_dump_operands ( - ACPI_OBJECT_INTERNAL **operands, - OPERATING_MODE interpreter_mode, - char *ident, - s32 num_levels, - char *note, - char *module_name, - s32 line_number); - -void -acpi_aml_dump_object_descriptor ( - ACPI_OBJECT_INTERNAL *object, - u32 flags); - - -void -acpi_aml_dump_acpi_named_object ( - ACPI_NAMED_OBJECT *entry, - u32 flags); - - -/* - * amnames - interpreter/scanner name load/execute - */ - -char * -acpi_aml_allocate_name_string ( - u32 prefix_count, - u32 num_name_segs); - -s32 -acpi_aml_good_char ( - s32 character); - -ACPI_STATUS -acpi_aml_exec_name_segment ( - u8 **in_aml_address, - char *name_string); - -ACPI_STATUS -acpi_aml_get_name_string ( - OBJECT_TYPE_INTERNAL data_type, - u8 *in_aml_address, - char **out_name_string, - u32 *out_name_length); - -u32 -acpi_aml_decode_package_length ( - u32 last_pkg_len); - - -ACPI_STATUS -acpi_aml_do_name ( - ACPI_OBJECT_TYPE data_type, - OPERATING_MODE load_exec_mode); - - -/* - * amstore - Object store support - */ - -ACPI_STATUS -acpi_aml_exec_store ( - ACPI_OBJECT_INTERNAL *op1, - ACPI_OBJECT_INTERNAL *res); - -ACPI_STATUS -acpi_aml_store_object_to_object ( - ACPI_OBJECT_INTERNAL *val_desc, - ACPI_OBJECT_INTERNAL *dest_desc); - -ACPI_STATUS -acpi_aml_store_object_to_nte ( - ACPI_OBJECT_INTERNAL *val_desc, - ACPI_NAMED_OBJECT *entry); - - -/* - * amutils - interpreter/scanner utilities - */ - -void -acpi_aml_enter_interpreter ( - void); - -void -acpi_aml_exit_interpreter ( - void); - -u8 -acpi_aml_validate_object_type ( - ACPI_OBJECT_TYPE type); - -u8 -acpi_aml_acquire_global_lock ( - u32 rule); - -ACPI_STATUS -acpi_aml_release_global_lock ( - u8 locked); - -void -acpi_aml_append_operand_diag( - char *name, - s32 line, - u16 op_code, - ACPI_OBJECT_INTERNAL **operands, - s32 Noperands); - -u32 -acpi_aml_buf_seq ( - void); - -s32 -acpi_aml_digits_needed ( - s32 value, - s32 base); - -ACPI_STATUS -acpi_aml_eisa_id_to_string ( - u32 numeric_id, - char *out_string); - - -/* - * amregion - default Op_region handlers - */ - -ACPI_STATUS -acpi_aml_system_memory_space_handler ( - u32 function, - u32 address, - u32 bit_width, - u32 *value, - void *context); - -ACPI_STATUS -acpi_aml_system_io_space_handler ( - u32 function, - u32 address, - u32 bit_width, - u32 *value, - void *context); - -ACPI_STATUS -acpi_aml_pci_config_space_handler ( - u32 function, - u32 address, - u32 bit_width, - u32 *value, - void *context); - -ACPI_STATUS -acpi_aml_embedded_controller_space_handler ( - u32 function, - u32 address, - u32 bit_width, - u32 *value, - void *context); - -ACPI_STATUS -acpi_aml_sm_bus_space_handler ( - u32 function, - u32 address, - u32 bit_width, - u32 *value, - void *context); - - -#endif /* __INTERP_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/macros.h linux/drivers/acpi/include/macros.h --- v2.4.0-test8/linux/drivers/acpi/include/macros.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/macros.h Wed Dec 31 16:00:00 1969 @@ -1,423 +0,0 @@ - -/****************************************************************************** - * - * Name: macros.h - C macros for the entire subsystem. - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - -#ifndef __MACROS_H__ -#define __MACROS_H__ - -/* - * Data manipulation macros - */ - -#ifndef LOWORD -#define LOWORD(l) ((u16)(NATIVE_UINT)(l)) -#endif - -#ifndef HIWORD -#define HIWORD(l) ((u16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF)) -#endif - -#ifndef LOBYTE -#define LOBYTE(l) ((u8)(u16)(l)) -#endif - -#ifndef HIBYTE -#define HIBYTE(l) ((u8)((((u16)(l)) >> 8) & 0xFF)) -#endif - -#define BIT0(x) ((((x) & 0x01) > 0) ? 1 : 0) -#define BIT1(x) ((((x) & 0x02) > 0) ? 1 : 0) -#define BIT2(x) ((((x) & 0x04) > 0) ? 1 : 0) - -#define BIT3(x) ((((x) & 0x08) > 0) ? 1 : 0) -#define BIT4(x) ((((x) & 0x10) > 0) ? 1 : 0) -#define BIT5(x) ((((x) & 0x20) > 0) ? 1 : 0) -#define BIT6(x) ((((x) & 0x40) > 0) ? 1 : 0) -#define BIT7(x) ((((x) & 0x80) > 0) ? 1 : 0) - -#define LOW_BASE(w) ((u16) ((w) & 0x0000FFFF)) -#define MID_BASE(b) ((u8) (((b) & 0x00FF0000) >> 16)) -#define HI_BASE(b) ((u8) (((b) & 0xFF000000) >> 24)) -#define LOW_LIMIT(w) ((u16) ((w) & 0x0000FFFF)) -#define HI_LIMIT(b) ((u8) (((b) & 0x00FF0000) >> 16)) - - - /* - * Extract a byte of data using a pointer. Any more than a byte and we - * get into potential aligment issues -- see the STORE macros below - */ -#define GET8(addr) (*(u8*)(addr)) - - -/* - * Macros for moving data around to/from buffers that are possibly unaligned. - * If the hardware supports the transfer of unaligned data, just do the store. - * Otherwise, we have to move one byte at a time. - */ - -#ifdef _HW_ALIGNMENT_SUPPORT - -/* The hardware supports unaligned transfers, just do the move */ - -#define MOVE_UNALIGNED16_TO_16(d,s) *(u16*)(d) = *(u16*)(s) -#define MOVE_UNALIGNED32_TO_32(d,s) *(u32*)(d) = *(u32*)(s) -#define MOVE_UNALIGNED16_TO_32(d,s) *(u32*)(d) = *(u16*)(s) - -#else -/* - * The hardware does not support unaligned transfers. We must move the - * data one byte at a time. These macros work whether the source or - * the destination (or both) is/are unaligned. - */ - -#define MOVE_UNALIGNED16_TO_16(d,s) {((char *)(d))[0] = ((char *)(s))[0];\ - ((char *)(d))[1] = ((char *)(s))[1];} - -#define MOVE_UNALIGNED32_TO_32(d,s) {((char *)(d))[0] = ((char *)(s))[0];\ - ((char *)(d))[1] = ((char *)(s))[1];\ - ((char *)(d))[2] = ((char *)(s))[2];\ - ((char *)(d))[3] = ((char *)(s))[3];} - -#define MOVE_UNALIGNED16_TO_32(d,s) {(*(u32*)(d)) = 0; MOVE_UNALIGNED16_TO_16(d,s);} - -#endif - - -/* - * Fast power-of-two math macros for non-optimized compilers - */ - -#define _DIV(value,power_of2) ((value) >> (power_of2)) -#define _MUL(value,power_of2) ((value) << (power_of2)) -#define _MOD(value,divisor) ((value) & ((divisor) -1)) - -#define DIV_2(a) _DIV(a,1) -#define MUL_2(a) _MUL(a,1) -#define MOD_2(a) _MOD(a,2) - -#define DIV_4(a) _DIV(a,2) -#define MUL_4(a) _MUL(a,2) -#define MOD_4(a) _MOD(a,4) - -#define DIV_8(a) _DIV(a,3) -#define MUL_8(a) _MUL(a,3) -#define MOD_8(a) _MOD(a,8) - -#define DIV_16(a) _DIV(a,4) -#define MUL_16(a) _MUL(a,4) -#define MOD_16(a) _MOD(a,16) - - -/* - * Rounding macros (Power of two boundaries only) - */ - -#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) -#define ROUND_UP(value,boundary) (((value) + ((boundary)-1)) & (~((boundary)-1))) - -#define ROUND_DOWN_TO_32_BITS(a) ROUND_DOWN(a,4) -#define ROUND_DOWN_TO_NATIVE_WORD(a) ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY) - -#define ROUND_UP_TO_32_bITS(a) ROUND_UP(a,4) -#define ROUND_UP_TO_NATIVE_WORD(a) ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY) - - -#ifdef DEBUG_ASSERT -#undef DEBUG_ASSERT -#endif - - -/* - * An ACPI_HANDLE (which is actually an ACPI_NAMED_OBJECT*) can appear in some contexts, - * such as on ap_obj_stack, where a pointer to an ACPI_OBJECT_INTERNAL can also - * appear. This macro is used to distinguish them. - * - * The Data_type field is the first field in both structures. - */ - -#define VALID_DESCRIPTOR_TYPE(d,t) (((ACPI_NAMED_OBJECT*)d)->data_type == t) - - -/* Macro to test the object type */ - -#define IS_THIS_OBJECT_TYPE(d,t) (((ACPI_OBJECT_INTERNAL *)d)->common.type == (u8)t) - - -/* - * Macro to check if a pointer is within an ACPI table. - * Parameter (a) is the pointer to check. Parameter (b) must be defined - * as a pointer to an ACPI_TABLE_HEADER. (b+1) then points past the header, - * and ((u8 *)b+b->Length) points one byte past the end of the table. - */ - -#ifndef _IA16 -#define IS_IN_ACPI_TABLE(a,b) (((u8 *)(a) >= (u8 *)(b + 1)) &&\ - ((u8 *)(a) < ((u8 *)b + b->length))) - -#else -#define IS_IN_ACPI_TABLE(a,b) (_segment)(a) == (_segment)(b) &&\ - (((u8 *)(a) >= (u8 *)(b + 1)) &&\ - ((u8 *)(a) < ((u8 *)b + b->length))) -#endif - -/* - * Macros for the master AML opcode table - */ - -#ifdef ACPI_DEBUG -#define OP_INFO_ENTRY(opcode,flags,name,Pargs,Iargs) {opcode,flags,Pargs,Iargs,name} -#else -#define OP_INFO_ENTRY(opcode,flags,name,Pargs,Iargs) {opcode,flags,Pargs,Iargs} -#endif - -#define ARG_TYPE_WIDTH 5 -#define ARG_1(x) ((u32)(x)) -#define ARG_2(x) ((u32)(x) << (1 * ARG_TYPE_WIDTH)) -#define ARG_3(x) ((u32)(x) << (2 * ARG_TYPE_WIDTH)) -#define ARG_4(x) ((u32)(x) << (3 * ARG_TYPE_WIDTH)) -#define ARG_5(x) ((u32)(x) << (4 * ARG_TYPE_WIDTH)) -#define ARG_6(x) ((u32)(x) << (5 * ARG_TYPE_WIDTH)) - -#define ARGI_LIST1(a) (ARG_1(a)) -#define ARGI_LIST2(a,b) (ARG_1(b)|ARG_2(a)) -#define ARGI_LIST3(a,b,c) (ARG_1(c)|ARG_2(b)|ARG_3(a)) -#define ARGI_LIST4(a,b,c,d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a)) -#define ARGI_LIST5(a,b,c,d,e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a)) -#define ARGI_LIST6(a,b,c,d,e,f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a)) - -#define ARGP_LIST1(a) (ARG_1(a)) -#define ARGP_LIST2(a,b) (ARG_1(a)|ARG_2(b)) -#define ARGP_LIST3(a,b,c) (ARG_1(a)|ARG_2(b)|ARG_3(c)) -#define ARGP_LIST4(a,b,c,d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)) -#define ARGP_LIST5(a,b,c,d,e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)) -#define ARGP_LIST6(a,b,c,d,e,f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f)) - -#define GET_CURRENT_ARG_TYPE(list) (list & 0x1F) -#define INCREMENT_ARG_LIST(list) (list >>= ARG_TYPE_WIDTH) - - -/* - * Reporting macros that are never compiled out - */ - -/* - * Error reporting. These versions add callers module and line#. Since - * _THIS_MODULE gets compiled out when ACPI_DEBUG isn't defined, only - * use it in debug mode. - */ - -#ifdef ACPI_DEBUG - -#define REPORT_INFO(a) _report_info(_THIS_MODULE,__LINE__,_COMPONENT,a) -#define REPORT_ERROR(a) _report_error(_THIS_MODULE,__LINE__,_COMPONENT,a) -#define REPORT_WARNING(a) _report_warning(_THIS_MODULE,__LINE__,_COMPONENT,a) -#define REPORT_SUCCESS(a) _report_success(_THIS_MODULE,__LINE__,_COMPONENT,a) - -#else - -#define REPORT_INFO(a) _report_info("",__LINE__,_COMPONENT,a) -#define REPORT_ERROR(a) _report_error("",__LINE__,_COMPONENT,a) -#define REPORT_WARNING(a) _report_warning("",__LINE__,_COMPONENT,a) -#define REPORT_SUCCESS(a) _report_success("",__LINE__,_COMPONENT,a) - -#endif - -/* Error reporting. These versions pass thru the module and line# */ - -#define _REPORT_INFO(a,b,c,d) _report_info(a,b,c,d) -#define _REPORT_ERROR(a,b,c,d) _report_error(a,b,c,d) -#define _REPORT_WARNING(a,b,c,d) _report_warning(a,b,c,d) - -/* Buffer dump macros */ - -#define DUMP_BUFFER(a,b) acpi_cm_dump_buffer((char *)a,b,DB_BYTE_DISPLAY,_COMPONENT) - -/* - * Debug macros that are conditionally compiled - */ - -#ifdef ACPI_DEBUG - -#define MODULE_NAME(name) static char *_THIS_MODULE = name - -/* - * Function entry tracing. - * The first parameter should be the procedure name as a quoted string. This is declared - * as a local string ("_Proc_name) so that it can be also used by the function exit macros below. - */ - -#define FUNCTION_TRACE(a) char * _proc_name = a;\ - function_trace(_THIS_MODULE,__LINE__,_COMPONENT,a) -#define FUNCTION_TRACE_PTR(a,b) char * _proc_name = a;\ - function_trace_ptr(_THIS_MODULE,__LINE__,_COMPONENT,a,(void *)b) -#define FUNCTION_TRACE_U32(a,b) char * _proc_name = a;\ - function_trace_u32(_THIS_MODULE,__LINE__,_COMPONENT,a,(u32)b) -#define FUNCTION_TRACE_STR(a,b) char * _proc_name = a;\ - function_trace_str(_THIS_MODULE,__LINE__,_COMPONENT,a,(char *)b) -/* - * Function exit tracing. - * WARNING: These macros include a return statement. This is usually considered - * bad form, but having a separate exit macro is very ugly and difficult to maintain. - * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros - * so that "_Proc_name" is defined. - */ -#define return_VOID {function_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name);return;} -#define return_ACPI_STATUS(s) {function_status_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name,s);return(s);} -#define return_VALUE(s) {function_value_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name,(NATIVE_UINT)s);return(s);} -#define return_PTR(s) {function_ptr_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name,(char *)s);return(s);} - - -/* Conditional execution */ - -#define DEBUG_EXEC(a) a; -#define NORMAL_EXEC(a) - -#define DEBUG_DEFINE(a) a; -#define DEBUG_ONLY_MEMBERS(a) a; - - -/* Stack and buffer dumping */ - -#define DUMP_STACK_ENTRY(a) acpi_aml_dump_operand(a) -#define DUMP_OPERANDS(a,b,c,d,e) acpi_aml_dump_operands(a,b,c,d,e,_THIS_MODULE,__LINE__) - - -#define DUMP_ENTRY(a,b) acpi_ns_dump_entry (a,b) -#define DUMP_TABLES(a,b) acpi_ns_dump_tables(a,b) -#define DUMP_PATHNAME(a,b,c,d) acpi_ns_dump_pathname(a,b,c,d) -#define BREAK_MSG(a) acpi_os_breakpoint (a) - -/* - * Generate INT3 on ACPI_ERROR (Debug only!) - */ - -#define ERROR_BREAK -#ifdef ERROR_BREAK -#define BREAK_ON_ERROR(lvl) if ((lvl)&ACPI_ERROR) acpi_os_breakpoint("Fatal error encountered\n") -#else -#define BREAK_ON_ERROR(lvl) -#endif - -/* - * Master debug print macros - * Print iff: - * 1) Debug print for the current component is enabled - * 2) Debug error level or trace level for the print statement is enabled - * - */ - -#define PARAM_LIST(pl) pl - -#define TEST_DEBUG_SWITCH(lvl) if (((lvl) & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer)) - -#define DEBUG_PRINT(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ - debug_print_prefix (_THIS_MODULE,__LINE__);\ - debug_print_raw PARAM_LIST(fp);\ - BREAK_ON_ERROR(lvl);} - -#define DEBUG_PRINT_RAW(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ - debug_print_raw PARAM_LIST(fp);} - - -/* Assert macros */ - -#define ACPI_ASSERT(exp) if(!(exp)) \ - acpi_os_dbg_assert(#exp, __FILE__, __LINE__, "Failed Assertion") - -#define DEBUG_ASSERT(msg, exp) if(!(exp)) \ - acpi_os_dbg_assert(#exp, __FILE__, __LINE__, msg) - - -#else -/* - * This is the non-debug case -- make everything go away, - * leaving no executable debug code! - */ - -#define MODULE_NAME(name) -#define _THIS_MODULE "" - -#define DEBUG_EXEC(a) -#define NORMAL_EXEC(a) a; - -#define DEBUG_DEFINE(a) -#define DEBUG_ONLY_MEMBERS(a) -#define FUNCTION_TRACE(a) -#define FUNCTION_TRACE_PTR(a,b) -#define FUNCTION_TRACE_U32(a,b) -#define FUNCTION_TRACE_STR(a,b) -#define FUNCTION_EXIT -#define FUNCTION_STATUS_EXIT(s) -#define FUNCTION_VALUE_EXIT(s) -#define DUMP_STACK_ENTRY(a) -#define DUMP_OPERANDS(a,b,c,d,e) -#define DUMP_ENTRY(a,b) -#define DUMP_TABLES(a,b) -#define DUMP_PATHNAME(a,b,c,d) -#define DEBUG_PRINT(l,f) -#define DEBUG_PRINT_RAW(l,f) -#define BREAK_MSG(a) - -#define return_VOID return -#define return_ACPI_STATUS(s) return(s) -#define return_VALUE(s) return(s) -#define return_PTR(s) return(s) - -#define ACPI_ASSERT(exp) -#define DEBUG_ASSERT(msg, exp) - -#endif - - -/* - * For 16-bit code, we want to shrink some things even though - * we are using ACPI_DEBUG to get the debug output - */ -#ifdef _IA16 -#undef DEBUG_ONLY_MEMBERS -#define DEBUG_ONLY_MEMBERS(a) -#undef OP_INFO_ENTRY -#define OP_INFO_ENTRY(opcode,flags,name,Pargs,Iargs) {opcode,flags,Pargs,Iargs} -#endif - - -#ifndef ACPI_DEBUG - -#define ADD_OBJECT_NAME(a,b) - -#else - - -/* - * 1) Set name to blanks - * 2) Copy the object name - */ - -#define ADD_OBJECT_NAME(a,b) MEMSET (a->common.name, ' ', sizeof (a->common.name));\ - STRNCPY (a->common.name, acpi_gbl_ns_type_names[b], sizeof (a->common.name)) - -#endif - - -#endif /* MACROS_H */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/namesp.h linux/drivers/acpi/include/namesp.h --- v2.4.0-test8/linux/drivers/acpi/include/namesp.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/namesp.h Wed Dec 31 16:00:00 1969 @@ -1,424 +0,0 @@ - -/****************************************************************************** - * - * Name: namesp.h - Namespace subcomponent prototypes and defines - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - -#ifndef __NAMESPACE_H__ -#define __NAMESPACE_H__ - -#include "actables.h" - - -/* To search the entire name space, pass this as Search_base */ - -#define NS_ALL ((ACPI_HANDLE)0) - -/* - * Elements of Acpi_ns_properties are bit significant - * and should be one-to-one with values of ACPI_OBJECT_TYPE - */ -#define NSP_NORMAL 0 -#define NSP_NEWSCOPE 1 /* a definition of this type opens a name scope */ -#define NSP_LOCAL 2 /* suppress search of enclosing scopes */ - - -/* Definitions of the predefined namespace names */ - -#define ACPI_UNKNOWN_NAME (u32) 0x3F3F3F3F /* Unknown name is "????" */ -#define ACPI_ROOT_NAME (u32) 0x2F202020 /* Root name is "/ " */ -#define ACPI_SYS_BUS_NAME (u32) 0x5F53425F /* Sys bus name is "_SB_" */ - -#define NS_ROOT_PATH "/" -#define NS_SYSTEM_BUS "_SB_" - - -/* Flags for Acpi_ns_lookup, Acpi_ns_search_and_enter */ - -#define NS_NO_UPSEARCH 0 -#define NS_SEARCH_PARENT 0x01 -#define NS_DONT_OPEN_SCOPE 0x02 -#define NS_NO_PEER_SEARCH 0x04 - -#define NS_WALK_UNLOCK TRUE -#define NS_WALK_NO_UNLOCK FALSE - - -ACPI_STATUS -acpi_ns_walk_namespace ( - OBJECT_TYPE_INTERNAL type, - ACPI_HANDLE start_object, - u32 max_depth, - u8 unlock_before_callback, - WALK_CALLBACK user_function, - void *context, - void **return_value); - - -ACPI_NAMED_OBJECT* -acpi_ns_get_next_object ( - OBJECT_TYPE_INTERNAL type, - ACPI_NAMED_OBJECT *parent, - ACPI_NAMED_OBJECT *child); - - -ACPI_STATUS -acpi_ns_delete_namespace_by_owner ( - u16 table_id); - -void -acpi_ns_free_table_entry ( - ACPI_NAMED_OBJECT *entry); - - -/* Namespace loading - nsload */ - -ACPI_STATUS -acpi_ns_parse_table ( - ACPI_TABLE_DESC *table_desc, - ACPI_NAME_TABLE *scope); - -ACPI_STATUS -acpi_ns_load_table ( - ACPI_TABLE_DESC *table_desc, - ACPI_NAMED_OBJECT *entry); - -ACPI_STATUS -acpi_ns_load_table_by_type ( - ACPI_TABLE_TYPE table_type); - - -/* - * Top-level namespace access - nsaccess - */ - - -ACPI_STATUS -acpi_ns_root_initialize ( - void); - -ACPI_STATUS -acpi_ns_lookup ( - ACPI_GENERIC_STATE *scope_info, - char *name, - OBJECT_TYPE_INTERNAL type, - OPERATING_MODE interpreter_mode, - u32 flags, - ACPI_WALK_STATE *walk_state, - ACPI_NAMED_OBJECT **ret_entry); - - -/* - * Table allocation/deallocation - nsalloc - */ - -ACPI_NAME_TABLE * -acpi_ns_allocate_name_table ( - u32 num_entries); - -ACPI_STATUS -acpi_ns_delete_namespace_subtree ( - ACPI_NAMED_OBJECT *parent_handle); - -void -acpi_ns_detach_object ( - ACPI_HANDLE object); - -void -acpi_ns_delete_name_table ( - ACPI_NAME_TABLE *name_table); - - -/* - * Namespace modification - nsmodify - */ - -ACPI_STATUS -acpi_ns_unload_namespace ( - ACPI_HANDLE handle); - -ACPI_STATUS -acpi_ns_delete_subtree ( - ACPI_HANDLE start_handle); - - -/* - * Namespace dump/print utilities - nsdump - */ - -void -acpi_ns_dump_tables ( - ACPI_HANDLE search_base, - s32 max_depth); - -void -acpi_ns_dump_entry ( - ACPI_HANDLE handle, - u32 debug_level); - -ACPI_STATUS -acpi_ns_dump_pathname ( - ACPI_HANDLE handle, - char *msg, - u32 level, - u32 component); - -void -acpi_ns_dump_root_devices ( - void); - -void -acpi_ns_dump_objects ( - OBJECT_TYPE_INTERNAL type, - u32 max_depth, - u32 ownder_id, - ACPI_HANDLE start_handle); - - -/* - * Namespace evaluation functions - nseval - */ - -ACPI_STATUS -acpi_ns_evaluate_by_handle ( - ACPI_NAMED_OBJECT *object_nte, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **return_object); - -ACPI_STATUS -acpi_ns_evaluate_by_name ( - char *pathname, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **return_object); - -ACPI_STATUS -acpi_ns_evaluate_relative ( - ACPI_NAMED_OBJECT *object_nte, - char *pathname, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **return_object); - -ACPI_STATUS -acpi_ns_execute_control_method ( - ACPI_NAMED_OBJECT *method_entry, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **return_obj_desc); - -ACPI_STATUS -acpi_ns_get_object_value ( - ACPI_NAMED_OBJECT *object_entry, - ACPI_OBJECT_INTERNAL **return_obj_desc); - - -/* - * Parent/Child/Peer utility functions - nsfamily - */ - -ACPI_NAME -acpi_ns_find_parent_name ( - ACPI_NAMED_OBJECT *entry_to_search); - -u8 -acpi_ns_exist_downstream_sibling ( - ACPI_NAMED_OBJECT *this_entry); - - -/* - * Scope manipulation - nsscope - */ - -s32 -acpi_ns_opens_scope ( - OBJECT_TYPE_INTERNAL type); - -char * -acpi_ns_name_of_scope ( - ACPI_NAME_TABLE *scope); - -char * -acpi_ns_name_of_current_scope ( - ACPI_WALK_STATE *walk_state); - -ACPI_STATUS -acpi_ns_handle_to_pathname ( - ACPI_HANDLE obj_handle, - u32 *buf_size, - char *user_buffer); - -u8 -acpi_ns_pattern_match ( - ACPI_NAMED_OBJECT *obj_entry, - char *search_for); - -ACPI_STATUS -acpi_ns_name_compare ( - ACPI_HANDLE obj_handle, - u32 level, - void *context, - void **return_value); - -void -acpi_ns_low_find_names ( - ACPI_NAMED_OBJECT *this_entry, - char *search_for, - s32 *count, - ACPI_HANDLE list[], - s32 max_depth); - -ACPI_HANDLE * -acpi_ns_find_names ( - char *search_for, - ACPI_HANDLE search_base, - s32 max_depth); - -ACPI_STATUS -acpi_ns_get_named_object ( - char *pathname, - ACPI_NAME_TABLE *in_scope, - ACPI_NAMED_OBJECT **out_nte); - -/* - * Object management for NTEs - nsobject - */ - -ACPI_STATUS -acpi_ns_attach_method ( - ACPI_HANDLE obj_handle, - u8 *pcode_addr, - u32 pcode_length); - -ACPI_STATUS -acpi_ns_attach_object ( - ACPI_HANDLE obj_handle, - ACPI_HANDLE value, - OBJECT_TYPE_INTERNAL type); - - -void * -acpi_ns_compare_value ( - ACPI_HANDLE obj_handle, - u32 level, - void *obj_desc); - -ACPI_HANDLE -acpi_ns_find_attached_object ( - ACPI_OBJECT_INTERNAL *obj_desc, - ACPI_HANDLE search_base, - s32 max_depth); - - -/* - * Namespace searching and entry - nssearch - */ - -ACPI_STATUS -acpi_ns_search_and_enter ( - u32 entry_name, - ACPI_WALK_STATE *walk_state, - ACPI_NAME_TABLE *name_table, - OPERATING_MODE interpreter_mode, - OBJECT_TYPE_INTERNAL type, - u32 flags, - ACPI_NAMED_OBJECT **ret_entry); - -void -acpi_ns_initialize_table ( - ACPI_NAME_TABLE *new_table, - ACPI_NAME_TABLE *parent_scope, - ACPI_NAMED_OBJECT *parent_entry); - -ACPI_STATUS -acpi_ns_search_one_scope ( - u32 entry_name, - ACPI_NAME_TABLE *name_table, - OBJECT_TYPE_INTERNAL type, - ACPI_NAMED_OBJECT **ret_entry, - NS_SEARCH_DATA *ret_info); - - -/* - * Utility functions - nsutils - */ - -u8 -acpi_ns_valid_root_prefix ( - char prefix); - -u8 -acpi_ns_valid_path_separator ( - char sep); - -OBJECT_TYPE_INTERNAL -acpi_ns_get_type ( - ACPI_HANDLE obj_handle); - -void * -acpi_ns_get_attached_object ( - ACPI_HANDLE obj_handle); - -s32 -acpi_ns_local ( - OBJECT_TYPE_INTERNAL type); - -ACPI_STATUS -acpi_ns_internalize_name ( - char *dotted_name, - char **converted_name); - -ACPI_STATUS -acpi_ns_externalize_name ( - u32 internal_name_length, - char *internal_name, - u32 *converted_name_length, - char **converted_name); - -s32 -is_ns_object ( - ACPI_OBJECT_INTERNAL *p_oD); - -s32 -acpi_ns_mark_nS( - void); - -ACPI_NAMED_OBJECT* -acpi_ns_convert_handle_to_entry ( - ACPI_HANDLE handle); - -ACPI_HANDLE -acpi_ns_convert_entry_to_handle( - ACPI_NAMED_OBJECT*nte); - -void -acpi_ns_terminate ( - void); - -ACPI_NAMED_OBJECT * -acpi_ns_get_parent_entry ( - ACPI_NAMED_OBJECT *this_entry); - - -ACPI_NAMED_OBJECT * -acpi_ns_get_next_valid_entry ( - ACPI_NAMED_OBJECT *this_entry); - - -#endif /* __NAMESPACE_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/output.h linux/drivers/acpi/include/output.h --- v2.4.0-test8/linux/drivers/acpi/include/output.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/output.h Wed Dec 31 16:00:00 1969 @@ -1,124 +0,0 @@ - -/****************************************************************************** - * - * Name: output.h -- debug output - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - -#ifndef _OUTPUT_H -#define _OUTPUT_H - -/* - * Debug levels and component IDs. These are used to control the - * granularity of the output of the DEBUG_PRINT macro -- on a per- - * component basis and a per-exception-type basis. - */ - -/* Component IDs -- used in the global "Debug_layer" */ - -#define GLOBAL 0x00000001 -#define COMMON 0x00000002 -#define PARSER 0x00000004 -#define DISPATCHER 0x00000008 -#define INTERPRETER 0x00000010 -#define NAMESPACE 0x00000020 -#define RESOURCE_MANAGER 0x00000040 -#define TABLE_MANAGER 0x00000080 -#define EVENT_HANDLING 0x00000100 -#define HARDWARE 0x00000200 -#define MISCELLANEOUS 0x00000400 -#define OS_DEPENDENT 0x00000800 - -#define BUS_MANAGER 0x00001000 - -#define PROCESSOR_CONTROL 0x00002000 -#define SYSTEM_CONTROL 0x00004000 -#define THERMAL_CONTROL 0x00008000 -#define POWER_CONTROL 0x00010000 - -#define EMBEDDED_CONTROLLER 0x00020000 -#define BATTERY 0x00040000 - -#define DEBUGGER 0x00100000 -#define ALL_COMPONENTS 0x001FFFFF - - -/* Exception level -- used in the global "Debug_level" */ - -#define ACPI_OK 0x00000001 -#define ACPI_INFO 0x00000002 -#define ACPI_WARN 0x00000004 -#define ACPI_ERROR 0x00000008 -#define ACPI_FATAL 0x00000010 -#define ACPI_DEBUG_OBJECT 0x00000020 -#define ACPI_ALL 0x0000003F - - -/* Trace level -- also used in the global "Debug_level" */ - -#define TRACE_PARSE 0x00000100 -#define TRACE_DISPATCH 0x00000200 -#define TRACE_LOAD 0x00000400 -#define TRACE_EXEC 0x00000800 -#define TRACE_NAMES 0x00001000 -#define TRACE_OPREGION 0x00002000 -#define TRACE_BFIELD 0x00004000 -#define TRACE_TRASH 0x00008000 -#define TRACE_TABLES 0x00010000 -#define TRACE_FUNCTIONS 0x00020000 -#define TRACE_VALUES 0x00040000 -#define TRACE_OBJECTS 0x00080000 -#define TRACE_ALLOCATIONS 0x00100000 -#define TRACE_RESOURCES 0x00200000 -#define TRACE_IO 0x00400000 -#define TRACE_INTERRUPTS 0x00800000 -#define TRACE_USER_REQUESTS 0x01000000 -#define TRACE_PACKAGE 0x02000000 -#define TRACE_MUTEX 0x04000000 - -#define TRACE_ALL 0x0FFFFF00 - - -/* Exceptionally verbose output -- also used in the global "Debug_level" */ - -#define VERBOSE_AML_DISASSEMBLE 0x10000000 -#define VERBOSE_INFO 0x20000000 -#define VERBOSE_TABLES 0x40000000 -#define VERBOSE_EVENTS 0x80000000 - -#define VERBOSE_ALL 0x70000000 - - -/* Defaults for Debug_level, debug and normal */ - -#define DEBUG_DEFAULT (ACPI_OK | ACPI_WARN | ACPI_ERROR | ACPI_DEBUG_OBJECT | TRACE_TABLES | TRACE_IO) -#define NORMAL_DEFAULT (ACPI_OK | ACPI_WARN | ACPI_ERROR | ACPI_DEBUG_OBJECT) -#define DEBUG_ALL (VERBOSE_AML_DISASSEMBLE | TRACE_ALL | ACPI_ALL) - -/* Misc defines */ - -#define HEX 0x01 -#define ASCII 0x02 -#define FULL_ADDRESS 0x04 -#define CHARS_PER_LINE 16 /* used in Dump_buf function */ - - -#endif /* _OUTPUT_H */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/parser.h linux/drivers/acpi/include/parser.h --- v2.4.0-test8/linux/drivers/acpi/include/parser.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/parser.h Wed Dec 31 16:00:00 1969 @@ -1,327 +0,0 @@ -/****************************************************************************** - * - * Module Name: parser.h - AML Parser subcomponent prototypes and defines - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - - -#ifndef _PARSER_H_ -#define _PARSER_H_ - - -#define OP_HAS_RETURN_VALUE 1 - -/* variable # arguments */ - -#define ACPI_VAR_ARGS ACPI_UINT32_MAX - -/* maximum virtual address */ - -#define ACPI_MAX_AML ((u8 *)(~0UL)) - - -#define PARSE_DELETE_TREE 1 - - -/* psapi - Parser external interfaces */ - -ACPI_STATUS -acpi_psx_load_table ( - u8 *pcode_addr, - s32 pcode_length); - -ACPI_STATUS -acpi_psx_execute ( - ACPI_NAMED_OBJECT *method_entry, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **return_obj_desc); - - -u8 -acpi_ps_is_namespace_object_op ( - u16 opcode); -u8 -acpi_ps_is_namespace_op ( - u16 opcode); - - -/****************************************************************************** - * - * Parser interfaces - * - *****************************************************************************/ - - -/* psargs - Parse AML opcode arguments */ - -u8 * -acpi_ps_get_next_package_end ( - ACPI_PARSE_STATE *parser_state); - -char * -acpi_ps_get_next_namestring ( - ACPI_PARSE_STATE *parser_state); - -void -acpi_ps_get_next_simple_arg ( - ACPI_PARSE_STATE *parser_state, - s32 arg_type, /* type of argument */ - ACPI_GENERIC_OP *arg); /* (OUT) argument data */ - -void -acpi_ps_get_next_namepath ( - ACPI_PARSE_STATE *parser_state, - ACPI_GENERIC_OP *arg, - u32 *arg_count, - u8 method_call); - -ACPI_GENERIC_OP * -acpi_ps_get_next_field ( - ACPI_PARSE_STATE *parser_state); - -ACPI_GENERIC_OP * -acpi_ps_get_next_arg ( - ACPI_PARSE_STATE *parser_state, - s32 arg_type, - u32 *arg_count); - - -/* psopcode - AML Opcode information */ - -ACPI_OP_INFO * -acpi_ps_get_opcode_info ( - u16 opcode); - -char * -acpi_ps_get_opcode_name ( - u16 opcode); - - -/* psparse - top level parsing routines */ - -void -acpi_ps_delete_parse_tree ( - ACPI_GENERIC_OP *root); - -ACPI_STATUS -acpi_ps_parse_loop ( - ACPI_PARSE_STATE *parser_state, - ACPI_WALK_STATE *walk_state, - u32 parse_flags); - - -ACPI_STATUS -acpi_ps_parse_aml ( - ACPI_GENERIC_OP *start_scope, - u8 *aml, - u32 acpi_aml_size, - u32 parse_flags); - -ACPI_STATUS -acpi_ps_parse_table ( - u8 *aml, - s32 aml_size, - INTERPRETER_CALLBACK descending_callback, - INTERPRETER_CALLBACK ascending_callback, - ACPI_GENERIC_OP **root_object); - -u16 -acpi_ps_peek_opcode ( - ACPI_PARSE_STATE *state); - - -/* psscope - Scope stack management routines */ - - -ACPI_STATUS -acpi_ps_init_scope ( - ACPI_PARSE_STATE *parser_state, - ACPI_GENERIC_OP *root); - -ACPI_GENERIC_OP * -acpi_ps_get_parent_scope ( - ACPI_PARSE_STATE *state); - -u8 -acpi_ps_has_completed_scope ( - ACPI_PARSE_STATE *parser_state); - -void -acpi_ps_pop_scope ( - ACPI_PARSE_STATE *parser_state, - ACPI_GENERIC_OP **op, - u32 *arg_list); - -ACPI_STATUS -acpi_ps_push_scope ( - ACPI_PARSE_STATE *parser_state, - ACPI_GENERIC_OP *op, - u32 remaining_args, - u32 arg_count); - -void -acpi_ps_cleanup_scope ( - ACPI_PARSE_STATE *state); - - -/* pstree - parse tree manipulation routines */ - -void -acpi_ps_append_arg( - ACPI_GENERIC_OP *op, - ACPI_GENERIC_OP *arg); - -ACPI_GENERIC_OP* -acpi_ps_find ( - ACPI_GENERIC_OP *scope, - char *path, - u16 opcode, - u32 create); - -ACPI_GENERIC_OP * -acpi_ps_get_arg( - ACPI_GENERIC_OP *op, - u32 argn); - -ACPI_GENERIC_OP * -acpi_ps_get_child ( - ACPI_GENERIC_OP *op); - -ACPI_GENERIC_OP * -acpi_ps_get_depth_next ( - ACPI_GENERIC_OP *origin, - ACPI_GENERIC_OP *op); - - -/* pswalk - parse tree walk routines */ - -ACPI_STATUS -acpi_ps_walk_parsed_aml ( - ACPI_GENERIC_OP *start_op, - ACPI_GENERIC_OP *end_op, - ACPI_OBJECT_INTERNAL *mth_desc, - ACPI_NAME_TABLE *start_scope, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **caller_return_desc, - ACPI_OWNER_ID owner_id, - INTERPRETER_CALLBACK descending_callback, - INTERPRETER_CALLBACK ascending_callback); - -ACPI_STATUS -acpi_ps_get_next_walk_op ( - ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op, - INTERPRETER_CALLBACK ascending_callback); - - -/* psutils - parser utilities */ - -void -acpi_ps_init_op ( - ACPI_GENERIC_OP *op, - u16 opcode); - -ACPI_GENERIC_OP * -acpi_ps_alloc_op ( - u16 opcode); - -void -acpi_ps_free_op ( - ACPI_GENERIC_OP *op); - -void -acpi_ps_delete_parse_cache ( - void); - -u8 -acpi_ps_is_leading_char ( - s32 c); - -u8 -acpi_ps_is_prefix_char ( - s32 c); - -u8 -acpi_ps_is_named_op ( - u16 opcode); - -u8 -acpi_ps_is_named_object_op ( - u16 opcode); - -u8 -acpi_ps_is_deferred_op ( - u16 opcode); - -u8 -acpi_ps_is_bytelist_op( - u16 opcode); - -u8 -acpi_ps_is_field_op( - u16 opcode); - -u8 -acpi_ps_is_create_field_op ( - u16 opcode); - -ACPI_NAMED_OP* -acpi_ps_to_named_op( - ACPI_GENERIC_OP *op); - -ACPI_DEFERRED_OP * -acpi_ps_to_deferred_op ( - ACPI_GENERIC_OP *op); - -ACPI_BYTELIST_OP* -acpi_ps_to_bytelist_op( - ACPI_GENERIC_OP *op); - -u32 -acpi_ps_get_name( - ACPI_GENERIC_OP *op); - -void -acpi_ps_set_name( - ACPI_GENERIC_OP *op, - u32 name); - - -/* psdump - display parser tree */ - -s32 -acpi_ps_sprint_path ( - char *buffer_start, - u32 buffer_size, - ACPI_GENERIC_OP *op); - -s32 -acpi_ps_sprint_op ( - char *buffer_start, - u32 buffer_size, - ACPI_GENERIC_OP *op); - -void -acpi_ps_show ( - ACPI_GENERIC_OP *op); - - -#endif /* _PARSER_H_ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/resource.h linux/drivers/acpi/include/resource.h --- v2.4.0-test8/linux/drivers/acpi/include/resource.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/resource.h Wed Dec 31 16:00:00 1969 @@ -1,300 +0,0 @@ -/****************************************************************************** - * - * Name: resource.h - Resource Manager function prototypes - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - -#ifndef __RESOURCE_H__ -#define __RESOURCE_H__ - -#include "actypes.h" -#include "acobject.h" - -/* - * Function prototypes called from Acpi* APIs - */ - -ACPI_STATUS -acpi_rs_get_prt_method_data ( - ACPI_HANDLE handle, - ACPI_BUFFER *ret_buffer); - - -ACPI_STATUS -acpi_rs_get_crs_method_data ( - ACPI_HANDLE handle, - ACPI_BUFFER *ret_buffer); - -ACPI_STATUS -acpi_rs_get_prs_method_data ( - ACPI_HANDLE handle, - ACPI_BUFFER *ret_buffer); - -ACPI_STATUS -acpi_rs_set_srs_method_data ( - ACPI_HANDLE handle, - ACPI_BUFFER *ret_buffer); - -ACPI_STATUS -acpi_rs_create_resource_list ( - ACPI_OBJECT_INTERNAL *byte_stream_buffer, - u8 *output_buffer, - u32 *output_buffer_length); - -ACPI_STATUS -acpi_rs_create_byte_stream ( - RESOURCE *linked_list_buffer, - u8 *output_buffer, - u32 *output_buffer_length); - -ACPI_STATUS -acpi_rs_create_pci_routing_table ( - ACPI_OBJECT_INTERNAL *method_return_object, - u8 *output_buffer, - u32 *output_buffer_length); - - -/* - *Function prototypes called from Acpi_rs_create*APIs - */ - -void -acpi_rs_dump_resource_list ( - RESOURCE *resource); - -void -acpi_rs_dump_irq_list ( - u8 *route_table); - -ACPI_STATUS -acpi_rs_get_byte_stream_start ( - u8 *byte_stream_buffer, - u8 **byte_stream_start, - u32 *size); - -ACPI_STATUS -acpi_rs_calculate_list_length ( - u8 *byte_stream_buffer, - u32 byte_stream_buffer_length, - u32 *size_needed); - -ACPI_STATUS -acpi_rs_calculate_byte_stream_length ( - RESOURCE *linked_list_buffer, - u32 *size_needed); - -ACPI_STATUS -acpi_rs_byte_stream_to_list ( - u8 *byte_stream_buffer, - u32 byte_stream_buffer_length, - u8 **output_buffer); - -ACPI_STATUS -acpi_rs_list_to_byte_stream ( - RESOURCE *linked_list, - u32 byte_stream_size_needed, - u8 **output_buffer); - -ACPI_STATUS -acpi_rs_io_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_fixed_io_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_io_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_fixed_io_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_irq_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_irq_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_dma_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_dma_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_address16_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_address16_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_address32_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_address32_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_start_dependent_functions_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_end_dependent_functions_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_start_dependent_functions_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_end_dependent_functions_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_memory24_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_memory24_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_memory32_range_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size -); - -ACPI_STATUS -acpi_rs_fixed_memory32_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_memory32_range_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_fixed_memory32_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_extended_irq_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_extended_irq_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_end_tag_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_end_tag_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - -ACPI_STATUS -acpi_rs_vendor_resource ( - u8 *byte_stream_buffer, - u32 *bytes_consumed, - u8 **output_buffer, - u32 *structure_size); - -ACPI_STATUS -acpi_rs_vendor_stream ( - RESOURCE *linked_list, - u8 **output_buffer, - u32 *bytes_consumed); - - -#endif /*__RESOURCE_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/include/tables.h linux/drivers/acpi/include/tables.h --- v2.4.0-test8/linux/drivers/acpi/include/tables.h Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/include/tables.h Wed Dec 31 16:00:00 1969 @@ -1,168 +0,0 @@ - -/****************************************************************************** - * - * Name: tables.h - ACPI table management - * - *****************************************************************************/ - -/* - * Copyright (C) 2000 R. Byron Moore - * - * 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 - */ - -#ifndef __TABLES_H__ -#define __TABLES_H__ - -#include "actypes.h" -#include "actables.h" - - -/* Used in Acpi_tb_map_acpi_table for size parameter if table header is to be used */ - -#define SIZE_IN_HEADER 0 - - -ACPI_STATUS -acpi_tb_handle_to_object ( - u16 table_id, - ACPI_TABLE_DESC **table_desc); - - -/* - * Acpi_tbfac - FACP, FACS utilities - */ - -ACPI_STATUS -acpi_tb_get_table_facs ( - char *buffer_ptr, - ACPI_TABLE_DESC *table_info); - - -/* - * Acpi_tbget - Table "get" routines - */ - -ACPI_STATUS -acpi_tb_get_table_ptr ( - ACPI_TABLE_TYPE table_type, - u32 instance, - ACPI_TABLE_HEADER **table_ptr_loc); - -ACPI_STATUS -acpi_tb_get_table ( - void *physical_address, - char *buffer_ptr, - ACPI_TABLE_DESC *table_info); - - -/* - * Acpi_tbgetall - Get all firmware ACPI tables - */ - -ACPI_STATUS -acpi_tb_get_all_tables ( - u32 number_of_tables, - char *buffer_ptr); - - -/* - * Acpi_tbinstall - Table installation - */ - -ACPI_STATUS -acpi_tb_install_table ( - char *table_ptr, - ACPI_TABLE_DESC *table_info); - -ACPI_STATUS -acpi_tb_recognize_table ( - char *table_ptr, - ACPI_TABLE_DESC *table_info); - -ACPI_STATUS -acpi_tb_init_table_descriptor ( - ACPI_TABLE_TYPE table_type, - ACPI_TABLE_DESC *table_info); - - -/* - * Acpi_tbremove - Table removal and deletion - */ - -void -acpi_tb_delete_acpi_tables ( - void); - -void -acpi_tb_delete_acpi_table ( - ACPI_TABLE_TYPE type); - -ACPI_TABLE_DESC * -acpi_tb_delete_single_table ( - ACPI_TABLE_DESC *table_desc); - -void -acpi_tb_free_acpi_tables_of_type ( - ACPI_TABLE_DESC *table_info); - - -/* - * Acpi_tbrsd - RSDP, RSDT utilities - */ - -ACPI_STATUS -acpi_tb_get_table_rsdt ( - u32 *number_of_tables); - -char * -acpi_tb_scan_memory_for_rsdp ( - char *start_address, - u32 length); - -ACPI_STATUS -acpi_tb_find_rsdp ( - ACPI_TABLE_DESC *table_info); - - -/* - * Acpi_tbutils - common table utilities - */ - -u8 -acpi_tb_system_table_pointer ( - void *where); - -ACPI_STATUS -acpi_tb_map_acpi_table ( - void *physical_address, - u32 *size, - void **logical_address); - -ACPI_STATUS -acpi_tb_verify_table_checksum ( - ACPI_TABLE_HEADER *table_header); - -u8 -acpi_tb_checksum ( - void *buffer, - u32 length); - -ACPI_STATUS -acpi_tb_validate_table_header ( - ACPI_TABLE_HEADER *table_header); - - -#endif /* __TABLES_H__ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/Makefile linux/drivers/acpi/interpreter/Makefile --- v2.4.0-test8/linux/drivers/acpi/interpreter/Makefile Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/interpreter/Makefile Fri Sep 15 18:21:44 2000 @@ -0,0 +1,28 @@ +# +# Makefile for all Linux ACPI interpreter subdirectories +# + +SUB_DIRS := +MOD_SUB_DIRS := $(SUB_DIRS) +MOD_IN_SUB_DIRS := +ALL_SUB_DIRS := $(SUB_DIRS) + +O_TARGET := ../$(shell basename `pwd`).o +O_OBJS := +M_OBJS := + +ACPI_OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) + +EXTRA_CFLAGS += -I../include + +EXTRA_CFLAGS += $(ACPI_CFLAGS) + +# if the interpreter is used, it overrides arch/i386/kernel/acpi.c +ifeq ($(CONFIG_ACPI_INTERPRETER),y) + O_OBJS := $(ACPI_OBJS) +endif + +include $(TOPDIR)/Rules.make + +clean: + $(RM) *.o diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amconfig.c linux/drivers/acpi/interpreter/amconfig.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amconfig.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amconfig.c Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: amconfig - Namespace reconfiguration (Load/Unload opcodes) + * $Revision: 23 $ * *****************************************************************************/ @@ -25,17 +25,17 @@ #include "acpi.h" -#include "parser.h" -#include "interp.h" +#include "acparser.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" -#include "events.h" -#include "tables.h" -#include "dispatch.h" +#include "acnamesp.h" +#include "acevents.h" +#include "actables.h" +#include "acdispat.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amconfig"); + MODULE_NAME ("amconfig") /***************************************************************************** @@ -53,13 +53,13 @@ ACPI_STATUS acpi_aml_exec_load_table ( - ACPI_OBJECT_INTERNAL *rgn_desc, + ACPI_OPERAND_OBJECT *rgn_desc, ACPI_HANDLE *ddb_handle) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL *table_desc = NULL; - char *table_ptr; - char *table_data_ptr; + ACPI_OPERAND_OBJECT *table_desc = NULL; + u8 *table_ptr; + u8 *table_data_ptr; ACPI_TABLE_HEADER table_header; ACPI_TABLE_DESC table_info; u32 i; @@ -73,7 +73,7 @@ table_header.length = 0; for (i = 0; i < sizeof (ACPI_TABLE_HEADER); i++) { status = acpi_ev_address_space_dispatch (rgn_desc, ADDRESS_SPACE_READ, - i, 8, (u32 *) ((char *) &table_header + i)); + i, 8, (u32 *) ((u8 *) &table_header + i)); if (ACPI_FAILURE (status)) { return (status); } @@ -184,16 +184,19 @@ ACPI_HANDLE ddb_handle) { ACPI_STATUS status = AE_NOT_IMPLEMENTED; - ACPI_OBJECT_INTERNAL *table_desc = (ACPI_OBJECT_INTERNAL *) ddb_handle; + ACPI_OPERAND_OBJECT *table_desc = (ACPI_OPERAND_OBJECT *) ddb_handle; ACPI_TABLE_DESC *table_info; /* Validate the handle */ - /* TBD: [Errors] Wasn't this done earlier? */ + /* Although the handle is partially validated in Acpi_aml_exec_reconfiguration(), + * when it calls Acpi_aml_resolve_operands(), the handle is more completely + * validated here. + */ if ((!ddb_handle) || (!VALID_DESCRIPTOR_TYPE (ddb_handle, ACPI_DESC_TYPE_INTERNAL)) || - (((ACPI_OBJECT_INTERNAL *)ddb_handle)->common.type != + (((ACPI_OPERAND_OBJECT *)ddb_handle)->common.type != INTERNAL_TYPE_REFERENCE)) { return (AE_BAD_PARAMETER); @@ -205,7 +208,7 @@ table_info = (ACPI_TABLE_DESC *) table_desc->reference.object; /* - * Delete the entire namespace under this table NTE + * Delete the entire namespace under this table Node * (Offset contains the Table_id) */ @@ -245,16 +248,16 @@ ACPI_WALK_STATE *walk_state) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL *region_desc = NULL; + ACPI_OPERAND_OBJECT *region_desc = NULL; ACPI_HANDLE *ddb_handle; /* Resolve the operands */ - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS); + status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); /* Get the table handle, common for both opcodes */ - status |= acpi_ds_obj_stack_pop_object ((ACPI_OBJECT_INTERNAL **) &ddb_handle, + status |= acpi_ds_obj_stack_pop_object ((ACPI_OPERAND_OBJECT **) &ddb_handle, walk_state); switch (opcode) @@ -265,22 +268,19 @@ /* Get the region or field descriptor */ status |= acpi_ds_obj_stack_pop_object (®ion_desc, walk_state); - if (status != AE_OK) { - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, opcode, - WALK_OPERANDS, 2); - goto cleanup2; + if (ACPI_FAILURE (status)) { + acpi_cm_remove_reference (region_desc); + return (status); } status = acpi_aml_exec_load_table (region_desc, ddb_handle); break; - case AML_UN_LOAD_OP: + case AML_UNLOAD_OP: - if (status != AE_OK) { - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, opcode, - WALK_OPERANDS, 1); - goto cleanup1; + if (ACPI_FAILURE (status)) { + return (status); } status = acpi_aml_exec_unload_table (ddb_handle); @@ -294,10 +294,6 @@ } -cleanup2: - acpi_cm_remove_reference (region_desc); - -cleanup1: return (status); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amcreate.c linux/drivers/acpi/interpreter/amcreate.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amcreate.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amcreate.c Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: amcreate - Named object creation + * $Revision: 44 $ * *****************************************************************************/ @@ -25,19 +25,19 @@ #include "acpi.h" -#include "parser.h" -#include "interp.h" +#include "acparser.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" -#include "events.h" -#include "dispatch.h" +#include "acnamesp.h" +#include "acevents.h" +#include "acdispat.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amcreate"); + MODULE_NAME ("amcreate") -/***************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_aml_exec_create_field * @@ -64,19 +64,19 @@ * Num_bits := Term_arg=>Integer * Source_buff := Term_arg=>Buffer * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_aml_exec_create_field ( u16 opcode, ACPI_WALK_STATE *walk_state) { - ACPI_OBJECT_INTERNAL *res_desc = NULL; - ACPI_OBJECT_INTERNAL *cnt_desc = NULL; - ACPI_OBJECT_INTERNAL *off_desc = NULL; - ACPI_OBJECT_INTERNAL *src_desc = NULL; - ACPI_OBJECT_INTERNAL *field_desc; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *res_desc = NULL; + ACPI_OPERAND_OBJECT *cnt_desc = NULL; + ACPI_OPERAND_OBJECT *off_desc = NULL; + ACPI_OPERAND_OBJECT *src_desc = NULL; + ACPI_OPERAND_OBJECT *field_desc; + ACPI_OPERAND_OBJECT *obj_desc; OBJECT_TYPE_INTERNAL res_type; ACPI_STATUS status; u32 num_operands = 3; @@ -88,7 +88,7 @@ /* Resolve the operands */ - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS); + status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); /* Get the operands */ @@ -101,11 +101,9 @@ status |= acpi_ds_obj_stack_pop_object (&off_desc, walk_state); status |= acpi_ds_obj_stack_pop_object (&src_desc, walk_state); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { /* Invalid parameters on object stack */ - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, opcode, - WALK_OPERANDS, 3); goto cleanup; } @@ -288,16 +286,17 @@ if (obj_desc) { /* * There is an existing object here; delete it and zero out the - * NTE + * object field within the Node */ acpi_cm_remove_reference (obj_desc); - acpi_ns_attach_object (res_desc, NULL, ACPI_TYPE_ANY); + acpi_ns_attach_object ((ACPI_NAMESPACE_NODE *) res_desc, NULL, + ACPI_TYPE_ANY); } /* Set the type to ANY (or the store below will fail) */ - ((ACPI_NAMED_OBJECT*) res_desc)->type = ACPI_TYPE_ANY; + ((ACPI_NAMESPACE_NODE *) res_desc)->type = ACPI_TYPE_ANY; break; @@ -310,7 +309,7 @@ /* Store constructed field descriptor in result location */ - status = acpi_aml_exec_store (field_desc, res_desc); + status = acpi_aml_exec_store (field_desc, res_desc, walk_state); /* * If the field descriptor was not physically stored (or if a failure @@ -358,39 +357,41 @@ acpi_aml_exec_create_alias ( ACPI_WALK_STATE *walk_state) { - ACPI_NAMED_OBJECT *src_entry; - ACPI_NAMED_OBJECT *alias_entry; + ACPI_NAMESPACE_NODE *source_node; + ACPI_NAMESPACE_NODE *alias_node; ACPI_STATUS status; /* Get the source/alias operands (both NTEs) */ - status = acpi_ds_obj_stack_pop_object ((ACPI_OBJECT_INTERNAL **) &src_entry, + status = acpi_ds_obj_stack_pop_object ((ACPI_OPERAND_OBJECT **) &source_node, walk_state); if (ACPI_FAILURE (status)) { return (status); } - /* Don't pop it, it gets popped later */ + /* + * Don't pop it, it gets removed in the calling routine + */ - alias_entry = acpi_ds_obj_stack_get_value (0, walk_state); + alias_node = acpi_ds_obj_stack_get_value (0, walk_state); /* Add an additional reference to the object */ - acpi_cm_add_reference (src_entry->object); + acpi_cm_add_reference (source_node->object); /* - * Attach the original source NTE to the new Alias NTE. + * Attach the original source Node to the new Alias Node. */ - status = acpi_ns_attach_object (alias_entry, src_entry->object, - src_entry->type); + status = acpi_ns_attach_object (alias_node, source_node->object, + source_node->type); /* * The new alias assumes the type of the source, but it points * to the same object. The reference count of the object has two * additional references to prevent deletion out from under either the - * source or the alias NTE + * source or the alias Node */ /* Since both operands are NTEs, we don't need to delete them */ @@ -416,7 +417,7 @@ ACPI_WALK_STATE *walk_state) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; BREAKPOINT3; @@ -438,7 +439,7 @@ goto cleanup; } - /* Attach object to the NTE */ + /* Attach object to the Node */ status = acpi_ns_attach_object (acpi_ds_obj_stack_get_value (0, walk_state), obj_desc, (u8) ACPI_TYPE_EVENT); @@ -473,8 +474,8 @@ ACPI_WALK_STATE *walk_state) { ACPI_STATUS status = AE_OK; - ACPI_OBJECT_INTERNAL *sync_desc; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *sync_desc; + ACPI_OPERAND_OBJECT *obj_desc; /* Get the operand */ @@ -546,22 +547,27 @@ ACPI_WALK_STATE *walk_state) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL *obj_desc_region; - ACPI_HANDLE *entry; + ACPI_OPERAND_OBJECT *obj_desc_region; + ACPI_NAMESPACE_NODE *node; if (region_space >= NUM_REGION_TYPES) { - /* TBD: [Errors] should this return an error, or should we just keep - * going? */ + /* TBD: [Future] In ACPI 2.0, valid region space + * includes types 0-6 (Adding CMOS and PCIBARTarget). + * Also, types 0x80-0xff are defined as "OEM Region + * Space handler" + * + * Should this return an error, or should we just keep + * going? How do we handle the OEM region handlers? + */ REPORT_WARNING ("Unable to decode the Region_space"); } - /* Get the NTE from the object stack */ - - entry = acpi_ds_obj_stack_get_value (0, walk_state); + /* Get the Node from the object stack */ + node = (ACPI_NAMESPACE_NODE *) acpi_ds_obj_stack_get_value (0, walk_state); /* Create the region descriptor */ @@ -583,10 +589,9 @@ /* Init the region from the operands */ - obj_desc_region->region.space_id = (u16) region_space; + obj_desc_region->region.space_id = (u8) region_space; obj_desc_region->region.address = 0; obj_desc_region->region.length = 0; - obj_desc_region->region.region_flags = 0; /* * Remember location in AML stream of address & length @@ -596,19 +601,38 @@ obj_desc_region->region.method->method.pcode_length = aml_length; - /* Install the new region object in the parent NTE */ + /* Install the new region object in the parent Node */ - obj_desc_region->region.nte = (ACPI_NAMED_OBJECT*) entry; + obj_desc_region->region.node = node; - status = acpi_ns_attach_object (entry, obj_desc_region, + status = acpi_ns_attach_object (node, obj_desc_region, (u8) ACPI_TYPE_REGION); + if (ACPI_FAILURE (status)) { goto cleanup; } + /* + * If we have a valid region, initialize it + * Namespace is NOT locked at this point. + */ + + status = acpi_ev_initialize_region (obj_desc_region, FALSE); + + if (ACPI_FAILURE (status)) { + /* + * If AE_NOT_EXIST is returned, it is not fatal + * because many regions get created before a handler + * is installed for said region. + */ + if (AE_NOT_EXIST == status) { + status = AE_OK; + } + } + cleanup: - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { /* Delete region object and method subobject */ if (obj_desc_region) { @@ -619,22 +643,6 @@ } } - - /* - * If we have a valid region, initialize it - */ - if (obj_desc_region) { - /* - * TBD: [Errors] Is there anything we can or could do when this - * fails? - * We need to do something useful with a failure. - */ - /* Namespace IS locked */ - - (void *) acpi_ev_initialize_region (obj_desc_region, TRUE); - - } - return (status); } @@ -645,7 +653,7 @@ * * PARAMETERS: Op - Op containing the Processor definition and * args - * Processor_nTE - NTE for the containing NTE + * Processor_nTE - Node for the containing Node * * RETURN: Status * @@ -655,12 +663,12 @@ ACPI_STATUS acpi_aml_exec_create_processor ( - ACPI_GENERIC_OP *op, + ACPI_PARSE_OBJECT *op, ACPI_HANDLE processor_nTE) { ACPI_STATUS status; - ACPI_GENERIC_OP *arg; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_PARSE_OBJECT *arg; + ACPI_OPERAND_OBJECT *obj_desc; obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_PROCESSOR); @@ -669,7 +677,7 @@ return (status); } - /* Install the new processor object in the parent NTE */ + /* Install the new processor object in the parent Node */ status = acpi_ns_attach_object (processor_nTE, obj_desc, (u8) ACPI_TYPE_PROCESSOR); @@ -700,7 +708,7 @@ /* Second arg is the PBlock Address */ - obj_desc->processor.pblk_address = (ACPI_IO_ADDRESS) arg->value.integer; + obj_desc->processor.address = (ACPI_IO_ADDRESS) arg->value.integer; /* Move to next arg and check existence */ @@ -712,7 +720,7 @@ /* Third arg is the PBlock Length */ - obj_desc->processor.pblk_length = (u8) arg->value.integer; + obj_desc->processor.length = (u8) arg->value.integer; return (AE_OK); } @@ -724,7 +732,7 @@ * * PARAMETERS: Op - Op containing the Power_resource definition * and args - * Power_res_nTE - NTE for the containing NTE + * Power_res_nTE - Node for the containing Node * * RETURN: Status * @@ -734,12 +742,12 @@ ACPI_STATUS acpi_aml_exec_create_power_resource ( - ACPI_GENERIC_OP *op, + ACPI_PARSE_OBJECT *op, ACPI_HANDLE power_res_nTE) { ACPI_STATUS status; - ACPI_GENERIC_OP *arg; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_PARSE_OBJECT *arg; + ACPI_OPERAND_OBJECT *obj_desc; obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_POWER); @@ -748,7 +756,7 @@ return (status); } - /* Install the new power resource object in the parent NTE */ + /* Install the new power resource object in the parent Node */ status = acpi_ns_attach_object (power_res_nTE, obj_desc, (u8) ACPI_TYPE_POWER); @@ -789,11 +797,14 @@ * * FUNCTION: Acpi_aml_exec_create_method * - * PARAMETERS: Interpreter_mode - Current running mode (load1/Load2/Exec) + * PARAMETERS: Aml_ptr - First byte of the method's AML + * Aml_length - AML byte count for this method + * Method_flags - AML method flag byte + * Method - Method Node * * RETURN: Status * - * DESCRIPTION: Create a new mutex object + * DESCRIPTION: Create a new method object * ****************************************************************************/ @@ -804,7 +815,7 @@ u32 method_flags, ACPI_HANDLE method) { - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; ACPI_STATUS status; @@ -830,9 +841,8 @@ METHOD_FLAGS_ARG_COUNT); /* - * Get the concurrency count - * If required, a semaphore will be created for this method when it is - * parsed. + * Get the concurrency count. If required, a semaphore will be + * created for this method when it is parsed. * * TBD: [Future] for APCI 2.0, there will be a Sync_level value, not * just a flag @@ -842,27 +852,16 @@ if (method_flags & METHOD_FLAGS_SERIALIZED) { obj_desc->method.concurrency = 1; } + else { obj_desc->method.concurrency = INFINITE_CONCURRENCY; } - /* Mark the Method as not parsed yet */ - - obj_desc->method.parser_op = NULL; - - /* - * Another +1 gets added when Acpi_psx_execute is called, - * no need for: Obj_desc->Method.Pcode++; - */ - - obj_desc->method.acpi_table = NULL; /* TBD: [Restructure] was (u8 *) Pcode_addr; */ - obj_desc->method.table_length = 0; /* TBD: [Restructure] needed? (u32) (Walk_state->aml_end - Pcode_addr); */ - - /* Attach the new object to the method NTE */ + /* Attach the new object to the method Node */ status = acpi_ns_attach_object (method, obj_desc, (u8) ACPI_TYPE_METHOD); if (ACPI_FAILURE (status)) { - acpi_cm_free (obj_desc); + acpi_cm_delete_object_desc (obj_desc); } return (status); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amdump.c linux/drivers/acpi/interpreter/amdump.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amdump.c Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/interpreter/amdump.c Fri Sep 15 14:30:30 2000 @@ -0,0 +1,41 @@ +/****************************************************************************** + * + * Module Name: amdump - Interpreter debug output routines + * $Revision: 90 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + + +#include "acpi.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "actables.h" + +#define _COMPONENT INTERPRETER + MODULE_NAME ("amdump") + + +/* + * The following routines are used for debug output only + */ + + diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amdyadic.c linux/drivers/acpi/interpreter/amdyadic.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amdyadic.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amdyadic.c Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: amdyadic - ACPI AML (p-code) execution for dyadic operators + * $Revision: 63 $ * *****************************************************************************/ @@ -25,16 +25,16 @@ #include "acpi.h" -#include "parser.h" -#include "namesp.h" -#include "interp.h" -#include "events.h" +#include "acparser.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "acevents.h" #include "amlcode.h" -#include "dispatch.h" +#include "acdispat.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amdyadic"); + MODULE_NAME ("amdyadic") /***************************************************************************** @@ -57,15 +57,15 @@ u16 opcode, ACPI_WALK_STATE *walk_state) { - ACPI_OBJECT_INTERNAL *obj_desc = NULL; - ACPI_OBJECT_INTERNAL *val_desc = NULL; - ACPI_NAMED_OBJECT *entry; + ACPI_OPERAND_OBJECT *obj_desc = NULL; + ACPI_OPERAND_OBJECT *val_desc = NULL; + ACPI_NAMESPACE_NODE *node; ACPI_STATUS status = AE_OK; /* Resolve all operands */ - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS); + status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); /* Get the operands */ status |= acpi_ds_obj_stack_pop_object (&val_desc, walk_state); @@ -73,8 +73,6 @@ if (ACPI_FAILURE (status)) { /* Invalid parameters on object stack */ - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, opcode, - WALK_OPERANDS, 2); goto cleanup; } @@ -88,15 +86,15 @@ case AML_NOTIFY_OP: - /* The Obj_desc is actually an NTE */ + /* The Obj_desc is actually an Node */ - entry = (ACPI_NAMED_OBJECT*) obj_desc; + node = (ACPI_NAMESPACE_NODE *) obj_desc; obj_desc = NULL; /* Object must be a device or thermal zone */ - if (entry && val_desc) { - switch (entry->type) + if (node && val_desc) { + switch (node->type) { case ACPI_TYPE_DEVICE: case ACPI_TYPE_THERMAL: @@ -108,7 +106,7 @@ /* Dispatch the notify to the appropriate handler */ - acpi_ev_notify_dispatch (entry, val_desc->number.value); + acpi_ev_notify_dispatch (node, val_desc->number.value); break; default: @@ -118,6 +116,8 @@ break; default: + + REPORT_ERROR ("Acpi_aml_exec_dyadic1: Unknown dyadic opcode"); status = AE_AML_BAD_OPCODE; } @@ -153,23 +153,23 @@ acpi_aml_exec_dyadic2_r ( u16 opcode, ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc) + ACPI_OPERAND_OBJECT **return_desc) { - ACPI_OBJECT_INTERNAL *obj_desc = NULL; - ACPI_OBJECT_INTERNAL *obj_desc2 = NULL; - ACPI_OBJECT_INTERNAL *res_desc = NULL; - ACPI_OBJECT_INTERNAL *res_desc2 = NULL; - ACPI_OBJECT_INTERNAL *ret_desc = NULL; - ACPI_OBJECT_INTERNAL *ret_desc2 = NULL; + ACPI_OPERAND_OBJECT *obj_desc = NULL; + ACPI_OPERAND_OBJECT *obj_desc2 = NULL; + ACPI_OPERAND_OBJECT *res_desc = NULL; + ACPI_OPERAND_OBJECT *res_desc2 = NULL; + ACPI_OPERAND_OBJECT *ret_desc = NULL; + ACPI_OPERAND_OBJECT *ret_desc2 = NULL; ACPI_STATUS status = AE_OK; u32 remainder; - s32 num_operands = 3; - char *new_buf; + u32 num_operands = 3; + NATIVE_CHAR *new_buf; /* Resolve all operands */ - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS); + status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); /* Get all operands */ if (AML_DIVIDE_OP == opcode) { @@ -180,10 +180,7 @@ status |= acpi_ds_obj_stack_pop_object (&res_desc, walk_state); status |= acpi_ds_obj_stack_pop_object (&obj_desc2, walk_state); status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (status != AE_OK) { - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, opcode, - &(walk_state->operands [walk_state->num_operands -1]), - num_operands); + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -368,9 +365,9 @@ goto cleanup; } - STRCPY (new_buf, (char *) obj_desc->string.pointer); + STRCPY (new_buf, obj_desc->string.pointer); STRCPY (new_buf + obj_desc->string.length, - (char *) obj_desc2->string.pointer); + obj_desc2->string.pointer); /* Point the return object to the new string */ @@ -391,16 +388,8 @@ new_buf = acpi_cm_allocate (obj_desc->buffer.length + obj_desc2->buffer.length); if (!new_buf) { - /* Only bail out if the buffer is small */ - - /* TBD: [Investigate] what is the point of this code? */ - - if (obj_desc->buffer.length + obj_desc2->buffer.length < 1024) { - REPORT_ERROR - ("Aml_exec_dyadic2_r/Concat_op: Buffer allocation failure"); - return (AE_NO_MEMORY); - } - + REPORT_ERROR + ("Aml_exec_dyadic2_r/Concat_op: Buffer allocation failure"); status = AE_NO_MEMORY; goto cleanup; } @@ -423,6 +412,7 @@ default: + REPORT_ERROR ("Acpi_aml_exec_dyadic2_r: Unknown dyadic opcode"); status = AE_AML_BAD_OPCODE; goto cleanup; } @@ -434,12 +424,13 @@ * descriptor (Res_desc). */ - if ((status = acpi_aml_exec_store (ret_desc, res_desc)) != AE_OK) { + status = acpi_aml_exec_store (ret_desc, res_desc, walk_state); + if (ACPI_FAILURE (status)) { goto cleanup; } if (AML_DIVIDE_OP == opcode) { - status = acpi_aml_exec_store (ret_desc2, res_desc2); + status = acpi_aml_exec_store (ret_desc2, res_desc2, walk_state); /* * Since the remainder is not returned, remove a reference to @@ -499,26 +490,24 @@ acpi_aml_exec_dyadic2_s ( u16 opcode, ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc) + ACPI_OPERAND_OBJECT **return_desc) { - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL *time_desc; - ACPI_OBJECT_INTERNAL *ret_desc = NULL; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_OPERAND_OBJECT *time_desc; + ACPI_OPERAND_OBJECT *ret_desc = NULL; ACPI_STATUS status; /* Resolve all operands */ - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS); + status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); /* Get all operands */ status |= acpi_ds_obj_stack_pop_object (&time_desc, walk_state); status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { /* Invalid parameters on object stack */ - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, opcode, - WALK_OPERANDS, 2); goto cleanup; } @@ -559,6 +548,7 @@ default: + REPORT_ERROR ("Acpi_aml_exec_dyadic2_s: Unknown dyadic synchronization opcode"); status = AE_AML_BAD_OPCODE; goto cleanup; } @@ -619,27 +609,25 @@ acpi_aml_exec_dyadic2 ( u16 opcode, ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc) + ACPI_OPERAND_OBJECT **return_desc) { - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL *obj_desc2; - ACPI_OBJECT_INTERNAL *ret_desc = NULL; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc2; + ACPI_OPERAND_OBJECT *ret_desc = NULL; ACPI_STATUS status; u8 lboolean; /* Resolve all operands */ - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS); + status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); /* Get all operands */ status |= acpi_ds_obj_stack_pop_object (&obj_desc2, walk_state); status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { /* Invalid parameters on object stack */ - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, opcode, - WALK_OPERANDS, 2); goto cleanup; } @@ -707,6 +695,7 @@ default: + REPORT_ERROR ("Acpi_aml_exec_dyadic2: Unknown dyadic opcode"); status = AE_AML_BAD_OPCODE; goto cleanup; break; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amfield.c linux/drivers/acpi/interpreter/amfield.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amfield.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amfield.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: amfield - ACPI AML (p-code) execution - field manipulation + * $Revision: 70 $ * *****************************************************************************/ @@ -24,16 +25,16 @@ #include "acpi.h" -#include "dispatch.h" -#include "interp.h" +#include "acdispat.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" -#include "hardware.h" -#include "events.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amfield"); + MODULE_NAME ("amfield") /******************************************************************************* @@ -67,12 +68,12 @@ ACPI_STATUS acpi_aml_setup_field ( - ACPI_OBJECT_INTERNAL *obj_desc, - ACPI_OBJECT_INTERNAL *rgn_desc, - s32 field_bit_width) + ACPI_OPERAND_OBJECT *obj_desc, + ACPI_OPERAND_OBJECT *rgn_desc, + u32 field_bit_width) { ACPI_STATUS status = AE_OK; - s32 field_byte_width; + u32 field_byte_width; /* Parameter validation */ @@ -87,6 +88,8 @@ /* + * TBD: [Future] Acpi 2.0 supports Qword fields + * * Init and validate Field width * Possible values are 1, 2, 4 */ @@ -105,7 +108,7 @@ * If the address and length have not been previously evaluated, * evaluate them and save the results. */ - if (!(rgn_desc->region.region_flags & REGION_AGRUMENT_DATA_VALID)) { + if (!(rgn_desc->region.flags & AOPOBJ_DATA_VALID)) { status = acpi_ds_get_region_arguments (rgn_desc); if (ACPI_FAILURE (status)) { @@ -113,12 +116,6 @@ } } - - /* - * If (offset rounded up to next multiple of field width) - * exceeds region length, indicate an error. - */ - if (rgn_desc->region.length < (obj_desc->field.offset & ~((u32) field_byte_width - 1)) + field_byte_width) @@ -152,12 +149,12 @@ ACPI_STATUS acpi_aml_access_named_field ( - s32 mode, + u32 mode, ACPI_HANDLE named_field, void *buffer, u32 buffer_length) { - ACPI_OBJECT_INTERNAL *obj_desc = NULL; + ACPI_OPERAND_OBJECT *obj_desc = NULL; ACPI_STATUS status = AE_OK; u8 locked = FALSE; u32 bit_granularity = 0; @@ -167,6 +164,11 @@ u32 byte_field_length; + /* Basic data checking */ + if ((!named_field) || (ACPI_READ == mode && !buffer)) { + return (AE_AML_INTERNAL); + } + /* Get the attached field object */ obj_desc = acpi_ns_get_attached_object (named_field); @@ -256,72 +258,6 @@ acpi_aml_release_global_lock (locked); - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_set_named_field_value - * - * PARAMETERS: Named_field - Handle for field to be set - * Buffer - Bytes to be stored - * Buffer_length - Number of bytes to be stored - * - * RETURN: Status - * - * DESCRIPTION: Store the given value into the field - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_set_named_field_value ( - ACPI_HANDLE named_field, - void *buffer, - u32 buffer_length) -{ - ACPI_STATUS status; - - - if (!named_field) { - return (AE_AML_INTERNAL); - } - - status = acpi_aml_access_named_field (ACPI_WRITE, named_field, buffer, - buffer_length); - return (status); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_get_named_field_value - * - * PARAMETERS: Named_field - Handle for field to be read - * *Buffer - Where to store value read from field - * Buffer_length - Max length to read - * - * RETURN: Status - * - * DESCRIPTION: Retrieve the value of the given field - * - ******************************************************************************/ - -ACPI_STATUS -acpi_aml_get_named_field_value ( - ACPI_HANDLE named_field, - void *buffer, - u32 buffer_length) -{ - ACPI_STATUS status; - - - if ((!named_field) || (!buffer)) { - return (AE_AML_INTERNAL); - } - - status = acpi_aml_access_named_field (ACPI_READ, named_field, buffer, - buffer_length); return (status); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amfldio.c linux/drivers/acpi/interpreter/amfldio.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amfldio.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amfldio.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: amfldio - Aml Field I/O + * $Revision: 26 $ * *****************************************************************************/ @@ -24,15 +25,15 @@ #include "acpi.h" -#include "interp.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" -#include "hardware.h" -#include "events.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amfldio"); + MODULE_NAME ("amfldio") /******************************************************************************* @@ -51,16 +52,16 @@ ACPI_STATUS acpi_aml_read_field_data ( - ACPI_OBJECT_INTERNAL *obj_desc, + ACPI_OPERAND_OBJECT *obj_desc, u32 field_byte_offset, u32 field_bit_width, u32 *value) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL *rgn_desc = NULL; + ACPI_OPERAND_OBJECT *rgn_desc = NULL; u32 address; u32 local_value = 0; - s32 field_byte_width; + u32 field_byte_width; /* Obj_desc is validated by callers */ @@ -72,7 +73,7 @@ field_byte_width = DIV_8 (field_bit_width); status = acpi_aml_setup_field (obj_desc, rgn_desc, field_bit_width); - if (AE_OK != status) { + if (ACPI_FAILURE (status)) { return (status); } @@ -84,17 +85,17 @@ /* - * Round offset down to next multiple of - * field width, add region base address and offset within the field + * Set offset to next multiple of field width, + * add region base address and offset within the field */ - address = rgn_desc->region.address + - (obj_desc->field.offset & ~((u32) field_byte_width - 1)) + + (obj_desc->field.offset * field_byte_width) + field_byte_offset; + /* Invoke the appropriate Address_space/Op_region handler */ status = acpi_ev_address_space_dispatch (rgn_desc, ADDRESS_SPACE_READ, @@ -122,7 +123,7 @@ ACPI_STATUS acpi_aml_read_field ( - ACPI_OBJECT_INTERNAL *obj_desc, + ACPI_OPERAND_OBJECT *obj_desc, void *buffer, u32 buffer_length, u32 byte_length, @@ -236,6 +237,7 @@ * field datum */ + if (obj_desc->field.bit_offset != 0) { merged_datum = (previous_raw_datum >> obj_desc->field.bit_offset) | @@ -247,10 +249,27 @@ } /* + * Prepare the merged datum for storing into the caller's + * buffer. It is possible to have a 32-bit buffer + * (Byte_granularity == 4), but a Obj_desc->Field.Length + * of 8 or 16, meaning that the upper bytes of merged data + * are undesired. This section fixes that. + */ + switch (obj_desc->field.length) + { + case 8: + merged_datum &= 0x000000FF; + break; + + case 16: + merged_datum &= 0x0000FFFF; + break; + } + + /* * Now store the datum in the caller's buffer, according to * the data type */ - switch (byte_granularity) { case 1: @@ -266,7 +285,6 @@ break; } - /* * Save the most recent datum since it contains bits of * the *next* field datum @@ -302,15 +320,15 @@ ACPI_STATUS acpi_aml_write_field_data ( - ACPI_OBJECT_INTERNAL *obj_desc, + ACPI_OPERAND_OBJECT *obj_desc, u32 field_byte_offset, u32 field_bit_width, u32 value) { ACPI_STATUS status = AE_OK; - ACPI_OBJECT_INTERNAL *rgn_desc = NULL; + ACPI_OPERAND_OBJECT *rgn_desc = NULL; u32 address; - s32 field_byte_width; + u32 field_byte_width; /* Obj_desc is validated by callers */ @@ -321,21 +339,21 @@ field_byte_width = DIV_8 (field_bit_width); status = acpi_aml_setup_field (obj_desc, rgn_desc, field_bit_width); - if (AE_OK != status) { + if (ACPI_FAILURE (status)) { return (status); } /* - * Round offset down to next multiple of - * field width, add region base address and offset within the field + * Set offset to next multiple of field width, + * add region base address and offset within the field */ - address = rgn_desc->region.address + - (obj_desc->field.offset & ~((u32) field_byte_width - 1)) + + (obj_desc->field.offset * field_byte_width) + field_byte_offset; + /* Invoke the appropriate Address_space/Op_region handler */ status = acpi_ev_address_space_dispatch (rgn_desc, ADDRESS_SPACE_WRITE, @@ -363,7 +381,7 @@ ACPI_STATUS acpi_aml_write_field_data_with_update_rule ( - ACPI_OBJECT_INTERNAL *obj_desc, + ACPI_OPERAND_OBJECT *obj_desc, u32 mask, u32 field_value, u32 this_field_byte_offset, @@ -426,7 +444,7 @@ bit_granularity, merged_value); } - return status; + return (status); } @@ -446,7 +464,7 @@ ACPI_STATUS acpi_aml_write_field ( - ACPI_OBJECT_INTERNAL *obj_desc, + ACPI_OPERAND_OBJECT *obj_desc, void *buffer, u32 buffer_length, u32 byte_length, @@ -638,7 +656,8 @@ field_value = (previous_raw_datum >> (bit_granularity - obj_desc->field.bit_offset)) & mask; - status = acpi_aml_write_field_data_with_update_rule (obj_desc, mask, field_value, this_field_byte_offset + 1, + status = acpi_aml_write_field_data_with_update_rule (obj_desc, mask, field_value, + this_field_byte_offset + byte_granularity, bit_granularity); if (ACPI_FAILURE (status)) { goto cleanup; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/ammisc.c linux/drivers/acpi/interpreter/ammisc.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/ammisc.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/ammisc.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ /****************************************************************************** * * Module Name: ammisc - ACPI AML (p-code) execution - specific opcodes + * $Revision: 67 $ * *****************************************************************************/ @@ -25,14 +26,14 @@ #include "acpi.h" -#include "parser.h" -#include "interp.h" +#include "acparser.h" +#include "acinterp.h" #include "amlcode.h" -#include "dispatch.h" +#include "acdispat.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("ammisc"); + MODULE_NAME ("ammisc") /******************************************************************************* @@ -58,25 +59,23 @@ acpi_aml_exec_fatal ( ACPI_WALK_STATE *walk_state) { - ACPI_OBJECT_INTERNAL *type_desc; - ACPI_OBJECT_INTERNAL *code_desc; - ACPI_OBJECT_INTERNAL *arg_desc; + ACPI_OPERAND_OBJECT *type_desc; + ACPI_OPERAND_OBJECT *code_desc; + ACPI_OPERAND_OBJECT *arg_desc; ACPI_STATUS status; /* Resolve operands */ - status = acpi_aml_resolve_operands (AML_FATAL_OP, WALK_OPERANDS); + status = acpi_aml_resolve_operands (AML_FATAL_OP, WALK_OPERANDS, walk_state); /* Get operands */ status |= acpi_ds_obj_stack_pop_object (&arg_desc, walk_state); status |= acpi_ds_obj_stack_pop_object (&code_desc, walk_state); status |= acpi_ds_obj_stack_pop_object (&type_desc, walk_state); - if (status != AE_OK) { - /* invalid parameters on object stack */ + if (ACPI_FAILURE (status)) { + /* Invalid parameters on object stack */ - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, - (u16) AML_FATAL_OP, WALK_OPERANDS, 3); goto cleanup; } @@ -130,30 +129,28 @@ ACPI_STATUS acpi_aml_exec_index ( ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc) + ACPI_OPERAND_OBJECT **return_desc) { - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL *idx_desc; - ACPI_OBJECT_INTERNAL *res_desc; - ACPI_OBJECT_INTERNAL *ret_desc = NULL; - ACPI_OBJECT_INTERNAL *tmp_desc; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_OPERAND_OBJECT *idx_desc; + ACPI_OPERAND_OBJECT *res_desc; + ACPI_OPERAND_OBJECT *ret_desc = NULL; + ACPI_OPERAND_OBJECT *tmp_desc; ACPI_STATUS status; /* Resolve operands */ /* First operand can be either a package or a buffer */ - status = acpi_aml_resolve_operands (AML_INDEX_OP, WALK_OPERANDS); + status = acpi_aml_resolve_operands (AML_INDEX_OP, WALK_OPERANDS, walk_state); /* Get all operands */ status |= acpi_ds_obj_stack_pop_object (&res_desc, walk_state); status |= acpi_ds_obj_stack_pop_object (&idx_desc, walk_state); status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { /* Invalid parameters on object stack */ - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, - (u16) AML_INDEX_OP, WALK_OPERANDS, 3); goto cleanup; } @@ -202,7 +199,7 @@ ret_desc->reference.target_type = tmp_desc->common.type; ret_desc->reference.object = tmp_desc; - status = acpi_aml_exec_store (ret_desc, res_desc); + status = acpi_aml_exec_store (ret_desc, res_desc, walk_state); ret_desc->reference.object = NULL; } @@ -228,7 +225,7 @@ ret_desc->reference.object = obj_desc; ret_desc->reference.offset = idx_desc->number.value; - status = acpi_aml_exec_store (ret_desc, res_desc); + status = acpi_aml_exec_store (ret_desc, res_desc, walk_state); } @@ -282,15 +279,15 @@ ACPI_STATUS acpi_aml_exec_match ( ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc) + ACPI_OPERAND_OBJECT **return_desc) { - ACPI_OBJECT_INTERNAL *pkg_desc; - ACPI_OBJECT_INTERNAL *op1_desc; - ACPI_OBJECT_INTERNAL *V1_desc; - ACPI_OBJECT_INTERNAL *op2_desc; - ACPI_OBJECT_INTERNAL *V2_desc; - ACPI_OBJECT_INTERNAL *start_desc; - ACPI_OBJECT_INTERNAL *ret_desc = NULL; + ACPI_OPERAND_OBJECT *pkg_desc; + ACPI_OPERAND_OBJECT *op1_desc; + ACPI_OPERAND_OBJECT *V1_desc; + ACPI_OPERAND_OBJECT *op2_desc; + ACPI_OPERAND_OBJECT *V2_desc; + ACPI_OPERAND_OBJECT *start_desc; + ACPI_OPERAND_OBJECT *ret_desc = NULL; ACPI_STATUS status; u32 index; u32 match_value = (u32) -1; @@ -298,7 +295,7 @@ /* Resolve all operands */ - status = acpi_aml_resolve_operands (AML_MATCH_OP, WALK_OPERANDS); + status = acpi_aml_resolve_operands (AML_MATCH_OP, WALK_OPERANDS, walk_state); /* Get all operands */ status |= acpi_ds_obj_stack_pop_object (&start_desc, walk_state); @@ -308,11 +305,9 @@ status |= acpi_ds_obj_stack_pop_object (&op1_desc, walk_state); status |= acpi_ds_obj_stack_pop_object (&pkg_desc, walk_state); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { /* Invalid parameters on object stack */ - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, - (u16) AML_MATCH_OP, WALK_OPERANDS, 6); goto cleanup; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/ammonad.c linux/drivers/acpi/interpreter/ammonad.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/ammonad.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/ammonad.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ /****************************************************************************** * * Module Name: ammonad - ACPI AML (p-code) execution for monadic operators + * $Revision: 79 $ * *****************************************************************************/ @@ -25,15 +26,15 @@ #include "acpi.h" -#include "parser.h" -#include "dispatch.h" -#include "interp.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" +#include "acnamesp.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("ammonad"); + MODULE_NAME ("ammonad") /******************************************************************************* @@ -52,8 +53,9 @@ ACPI_STATUS acpi_aml_get_object_reference ( - ACPI_OBJECT_INTERNAL *obj_desc, - ACPI_OBJECT_INTERNAL **ret_desc) + ACPI_OPERAND_OBJECT *obj_desc, + ACPI_OPERAND_OBJECT **ret_desc, + ACPI_WALK_STATE *walk_state) { ACPI_STATUS status = AE_OK; @@ -74,14 +76,14 @@ case AML_LOCAL_OP: *ret_desc = (void *) acpi_ds_method_data_get_nte (MTH_TYPE_LOCAL, - (obj_desc->reference.offset)); + (obj_desc->reference.offset), walk_state); break; case AML_ARG_OP: *ret_desc = (void *) acpi_ds_method_data_get_nte (MTH_TYPE_ARG, - (obj_desc->reference.offset)); + (obj_desc->reference.offset), walk_state); break; @@ -95,7 +97,7 @@ } else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) { - /* Must be a named object; Just return the NTE */ + /* Must be a named object; Just return the Node */ *ret_desc = obj_desc; } @@ -130,19 +132,17 @@ u16 opcode, ACPI_WALK_STATE *walk_state) { - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; ACPI_STATUS status; /* Resolve all operands */ - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS); + status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); /* Get all operands */ status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (status != AE_OK) { - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, - opcode, WALK_OPERANDS, 1); + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -196,6 +196,7 @@ default: + REPORT_ERROR ("Acpi_aml_exec_monadic1: Unknown monadic opcode"); status = AE_AML_BAD_OPCODE; break; @@ -229,30 +230,28 @@ acpi_aml_exec_monadic2_r ( u16 opcode, ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc) + ACPI_OPERAND_OBJECT **return_desc) { - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL *res_desc; - ACPI_OBJECT_INTERNAL *ret_desc = NULL; - ACPI_OBJECT_INTERNAL *ret_desc2 = NULL; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_OPERAND_OBJECT *res_desc; + ACPI_OPERAND_OBJECT *ret_desc = NULL; + ACPI_OPERAND_OBJECT *ret_desc2 = NULL; u32 res_val; ACPI_STATUS status; - s32 d0; - s32 d1; - s32 d2; - s32 d3; + u32 d0; + u32 d1; + u32 d2; + u32 d3; /* Resolve all operands */ - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS); + status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); /* Get all operands */ status |= acpi_ds_obj_stack_pop_object (&res_desc, walk_state); status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (status != AE_OK) { - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, - opcode, WALK_OPERANDS, 2); + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -264,8 +263,8 @@ case AML_BIT_NOT_OP: case AML_FIND_SET_LEFT_BIT_OP: case AML_FIND_SET_RIGHT_BIT_OP: - case AML_FROM_BCDOP: - case AML_TO_BCDOP: + case AML_FROM_BCD_OP: + case AML_TO_BCD_OP: case AML_COND_REF_OF_OP: ret_desc = acpi_cm_create_internal_object (ACPI_TYPE_NUMBER); @@ -293,7 +292,13 @@ case AML_FIND_SET_LEFT_BIT_OP: ret_desc->number.value = obj_desc->number.value; - for (res_val = 0; ret_desc->number.value && res_val < 33; ++res_val) { + + /* + * Acpi x1.94 spec, Chapter 16 describes Integer as a 32-bit + * little endian unsigned value, so this boundry condition + * is valid. + */ + for (res_val = 0; ret_desc->number.value && res_val < 32; ++res_val) { ret_desc->number.value >>= 1; } @@ -306,22 +311,29 @@ case AML_FIND_SET_RIGHT_BIT_OP: ret_desc->number.value = obj_desc->number.value; - for (res_val = 0; ret_desc->number.value && res_val < 33; ++res_val) { + + /* + * Acpi x1.94 spec, Chapter 16 describes Integer as a 32-bit + * little endian unsigned value, so this boundry condition + * is valid. + */ + for (res_val = 0; ret_desc->number.value && res_val < 32; ++res_val) { ret_desc->number.value <<= 1; } + /* Since returns must be 1-based, subtract from 33 */ ret_desc->number.value = res_val == 0 ? 0 : 33 - res_val; break; /* Def_from_bDC := From_bCDOp BCDValue Result */ - case AML_FROM_BCDOP: + case AML_FROM_BCD_OP: - d0 = (s32) (obj_desc->number.value & 15); - d1 = (s32) (obj_desc->number.value >> 4 & 15); - d2 = (s32) (obj_desc->number.value >> 8 & 15); - d3 = (s32) (obj_desc->number.value >> 12 & 15); + d0 = (u32) (obj_desc->number.value & 15); + d1 = (u32) (obj_desc->number.value >> 4 & 15); + d2 = (u32) (obj_desc->number.value >> 8 & 15); + d3 = (u32) (obj_desc->number.value >> 12 & 15); if (d0 > 9 || d1 > 9 || d2 > 9 || d3 > 9) { status = AE_AML_NUMERIC_OVERFLOW; @@ -334,7 +346,7 @@ /* Def_to_bDC := To_bCDOp Operand Result */ - case AML_TO_BCDOP: + case AML_TO_BCD_OP: if (obj_desc->number.value > 9999) { @@ -361,7 +373,7 @@ * (There are really two return values) */ - if ((ACPI_NAMED_OBJECT*) obj_desc == acpi_gbl_root_object) { + if ((ACPI_NAMESPACE_NODE *) obj_desc == acpi_gbl_root_node) { /* * This means that the object does not exist in the namespace, * return FALSE @@ -380,12 +392,12 @@ /* Get the object reference and store it */ - status = acpi_aml_get_object_reference (obj_desc, &ret_desc2); + status = acpi_aml_get_object_reference (obj_desc, &ret_desc2, walk_state); if (ACPI_FAILURE (status)) { goto cleanup; } - status = acpi_aml_exec_store (ret_desc2, res_desc); + status = acpi_aml_exec_store (ret_desc2, res_desc, walk_state); /* The object exists in the namespace, return TRUE */ @@ -406,7 +418,7 @@ * since the object itself may have been stored. */ - status = acpi_aml_exec_store (obj_desc, res_desc); + status = acpi_aml_exec_store (obj_desc, res_desc, walk_state); if (ACPI_FAILURE (status)) { /* On failure, just delete the Obj_desc */ @@ -454,12 +466,13 @@ default: + REPORT_ERROR ("Acpi_aml_exec_monadic2_r: Unknown monadic opcode"); status = AE_AML_BAD_OPCODE; goto cleanup; } - status = acpi_aml_exec_store (ret_desc, res_desc); + status = acpi_aml_exec_store (ret_desc, res_desc, walk_state); cleanup: @@ -502,25 +515,32 @@ acpi_aml_exec_monadic2 ( u16 opcode, ACPI_WALK_STATE *walk_state, - ACPI_OBJECT_INTERNAL **return_desc) + ACPI_OPERAND_OBJECT **return_desc) { - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL *tmp_desc; - ACPI_OBJECT_INTERNAL *ret_desc = NULL; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_OPERAND_OBJECT *tmp_desc; + ACPI_OPERAND_OBJECT *ret_desc = NULL; + ACPI_STATUS resolve_status; ACPI_STATUS status; u32 type; u32 value; - /* Resolve all operands */ + /* Attempt to resolve the operands */ - status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS); - /* Get all operands */ + resolve_status = acpi_aml_resolve_operands (opcode, WALK_OPERANDS, walk_state); + /* Always get all operands */ - status |= acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); - if (status != AE_OK) { - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, - opcode, WALK_OPERANDS, 1); + status = acpi_ds_obj_stack_pop_object (&obj_desc, walk_state); + + + /* Now we can check the status codes */ + + if (ACPI_FAILURE (resolve_status)) { + goto cleanup; + } + + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -553,7 +573,7 @@ /* * Since we are expecting an Reference on the top of the stack, it - * can be either an NTE or an internal object. + * can be either an Node or an internal object. * * TBD: [Future] This may be the prototype code for all cases where * an Reference is expected!! 10/99 @@ -586,10 +606,8 @@ * (This deletes the original Ret_desc) */ - status = acpi_aml_resolve_operands (AML_LNOT_OP, &ret_desc); - if (status != AE_OK) { - acpi_aml_append_operand_diag (_THIS_MODULE, __LINE__, - opcode, WALK_OPERANDS, 1); + status = acpi_aml_resolve_operands (AML_LNOT_OP, &ret_desc, walk_state); + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -604,7 +622,7 @@ /* Store the result back in the original descriptor */ - status = acpi_aml_exec_store (ret_desc, obj_desc); + status = acpi_aml_exec_store (ret_desc, obj_desc, walk_state); /* Objdesc was just deleted (because it is an Reference) */ @@ -662,19 +680,20 @@ case AML_LOCAL_OP: type = acpi_ds_method_data_get_type (MTH_TYPE_LOCAL, - (obj_desc->reference.offset)); + (obj_desc->reference.offset), walk_state); break; case AML_ARG_OP: type = acpi_ds_method_data_get_type (MTH_TYPE_ARG, - (obj_desc->reference.offset)); + (obj_desc->reference.offset), walk_state); break; default: + REPORT_ERROR ("Acpi_aml_exec_monadic2/Type_op:internal error: Unknown Reference subtype"); status = AE_AML_INTERNAL; goto cleanup; } @@ -682,8 +701,7 @@ else { /* - * Since we passed Acpi_aml_resolve_operands("l") and it's not a - * Reference, it must be a direct name pointer. + * It's not a Reference, so it must be a direct name pointer. */ type = acpi_ns_get_type ((ACPI_HANDLE) obj_desc); } @@ -764,7 +782,7 @@ case AML_REF_OF_OP: - status = acpi_aml_get_object_reference (obj_desc, &ret_desc); + status = acpi_aml_get_object_reference (obj_desc, &ret_desc, walk_state); if (ACPI_FAILURE (status)) { goto cleanup; } @@ -789,7 +807,7 @@ case AML_LOCAL_OP: acpi_ds_method_data_get_value (MTH_TYPE_LOCAL, - (obj_desc->reference.offset), &tmp_desc); + (obj_desc->reference.offset), walk_state, &tmp_desc); /* * Delete our reference to the input object and @@ -803,7 +821,7 @@ case AML_ARG_OP: acpi_ds_method_data_get_value (MTH_TYPE_ARG, - (obj_desc->reference.offset), &tmp_desc); + (obj_desc->reference.offset), walk_state, &tmp_desc); /* * Delete our reference to the input object and @@ -824,9 +842,9 @@ /* Obj_desc may have changed from the code above */ if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) { - /* Get the actual object from the NTE (This is the dereference) */ + /* Get the actual object from the Node (This is the dereference) */ - ret_desc = ((ACPI_NAMED_OBJECT*) obj_desc)->object; + ret_desc = ((ACPI_NAMESPACE_NODE *) obj_desc)->object; /* Returning a pointer to the object, add another reference! */ @@ -928,6 +946,7 @@ default: + REPORT_ERROR ("Acpi_aml_exec_monadic2: Internal error, unknown monadic opcode"); status = AE_AML_BAD_OPCODE; goto cleanup; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amnames.c linux/drivers/acpi/interpreter/amnames.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amnames.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amnames.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ /****************************************************************************** * * Module Name: amnames - interpreter/scanner name load/execute + * $Revision: 70 $ * *****************************************************************************/ @@ -25,12 +26,12 @@ #include "acpi.h" -#include "interp.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" +#include "acnamesp.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amnames"); + MODULE_NAME ("amnames") /* AML Package Length encodings */ @@ -57,13 +58,13 @@ * ******************************************************************************/ -char * +NATIVE_CHAR * acpi_aml_allocate_name_string ( u32 prefix_count, u32 num_name_segs) { - char *temp_ptr; - char *name_string; + NATIVE_CHAR *temp_ptr; + NATIVE_CHAR *name_string; u32 size_needed; @@ -87,7 +88,7 @@ * This buffer must be deleted by the caller! */ - name_string = acpi_cm_allocate ((ACPI_SIZE) size_needed); + name_string = acpi_cm_allocate (size_needed); if (!name_string) { REPORT_ERROR ("Aml_allocate_name_string: name allocation failure"); return (NULL); @@ -133,52 +134,6 @@ return (name_string); } - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_decode_package_length - * - * PARAMETERS: Last_pkg_len - latest value decoded by Do_pkg_length() for - * most recently examined package or field - * - * RETURN: Number of bytes contained in package length encoding - * - * DESCRIPTION: Decodes the Package Length. Upper 2 bits are are used to - * tell if type 1, 2, 3, or 4. - * 0x3F = Max 1 byte encoding, - * 0xFFF = Max 2 byte encoding, - * 0xFFFFF = Max 3 Byte encoding, - * 0xFFFFFFFFF = Max 4 Byte encoding. - * - ******************************************************************************/ - -u32 -acpi_aml_decode_package_length ( - u32 last_pkg_len) -{ - u32 num_bytes = 0; - - - if (last_pkg_len < ACPI_AML_PACKAGE_TYPE1) { - num_bytes = 1; - } - - else if (last_pkg_len < ACPI_AML_PACKAGE_TYPE2) { - num_bytes = 2; - } - - else if (last_pkg_len < ACPI_AML_PACKAGE_TYPE3) { - num_bytes = 3; - } - - else if (last_pkg_len < ACPI_AML_PACKAGE_TYPE4) { - num_bytes = 4; - } - - return (num_bytes); -} - - /******************************************************************************* * * FUNCTION: Acpi_aml_exec_name_segment @@ -194,12 +149,12 @@ ACPI_STATUS acpi_aml_exec_name_segment ( u8 **in_aml_address, - char *name_string) + NATIVE_CHAR *name_string) { u8 *aml_address = *in_aml_address; ACPI_STATUS status = AE_OK; - s32 index; - char char_buf[5]; + u32 index; + NATIVE_CHAR char_buf[5]; /* @@ -271,15 +226,16 @@ acpi_aml_get_name_string ( OBJECT_TYPE_INTERNAL data_type, u8 *in_aml_address, - char **out_name_string, + NATIVE_CHAR **out_name_string, u32 *out_name_length) { ACPI_STATUS status = AE_OK; u8 *aml_address = in_aml_address; - char *name_string = NULL; - s32 num_segments; - s32 prefix_count = 0; + NATIVE_CHAR *name_string = NULL; + u32 num_segments; + u32 prefix_count = 0; u8 prefix = 0; + u8 has_prefix = FALSE; if (INTERNAL_TYPE_DEF_FIELD == data_type || @@ -313,7 +269,8 @@ * Remember that we have a Root_prefix -- * see comment in Acpi_aml_allocate_name_string() */ - prefix_count = -1; + prefix_count = (u32) -1; + has_prefix = TRUE; break; @@ -327,7 +284,7 @@ ++prefix_count; } while (*aml_address == AML_PARENT_PREFIX); - + has_prefix = TRUE; break; @@ -351,9 +308,8 @@ break; } - /* Ensure Prefix_count != 0 to remember processing a prefix */ - - prefix_count += 2; + /* Indicate that we processed a prefix */ + has_prefix = TRUE; status = acpi_aml_exec_name_segment (&aml_address, name_string); if (ACPI_SUCCESS (status)) { @@ -375,9 +331,8 @@ break; } - /* Ensure Prefix_count != 0 to remember processing a prefix */ - - prefix_count += 2; + /* Indicate that we processed a prefix */ + has_prefix = TRUE; while (num_segments && (status = acpi_aml_exec_name_segment (&aml_address, name_string)) == AE_OK) @@ -422,7 +377,7 @@ } - if (AE_CTRL_PENDING == status && prefix_count != 0) { + if (AE_CTRL_PENDING == status && has_prefix) { /* Ran out of segments after processing a prefix */ REPORT_ERROR ("Ran out of segments after processing a prefix"); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amprep.c linux/drivers/acpi/interpreter/amprep.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amprep.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amprep.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ /****************************************************************************** * * Module Name: amprep - ACPI AML (p-code) execution - field prep utilities + * $Revision: 67 $ * *****************************************************************************/ @@ -25,14 +26,14 @@ #include "acpi.h" -#include "interp.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" -#include "parser.h" +#include "acnamesp.h" +#include "acparser.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amprep"); + MODULE_NAME ("amprep") /******************************************************************************* @@ -55,25 +56,25 @@ switch (access) { case ACCESS_ANY_ACC: - return 8; + return (8); break; case ACCESS_BYTE_ACC: - return 8; + return (8); break; case ACCESS_WORD_ACC: - return 16; + return (16); break; case ACCESS_DWORD_ACC: - return 32; + return (32); break; default: /* Invalid field access type */ - return 0; + return (0); } } @@ -98,7 +99,7 @@ ACPI_STATUS acpi_aml_prep_common_field_object ( - ACPI_OBJECT_INTERNAL *obj_desc, + ACPI_OPERAND_OBJECT *obj_desc, u8 field_flags, u8 field_attribute, u32 field_position, @@ -150,7 +151,7 @@ * * FUNCTION: Acpi_aml_prep_def_field_value * - * PARAMETERS: This_entry - Owning NTE + * PARAMETERS: Node - Owning Node * Region - Region in which field is being defined * Field_flags - Access, Lock_rule, or Update_rule. * The format of a Field_flag is described @@ -160,22 +161,22 @@ * * RETURN: Status * - * DESCRIPTION: Construct an ACPI_OBJECT_INTERNAL of type Def_field and - * connect it to the parent NTE. + * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type Def_field and + * connect it to the parent Node. * ******************************************************************************/ ACPI_STATUS acpi_aml_prep_def_field_value ( - ACPI_NAMED_OBJECT *this_entry, + ACPI_NAMESPACE_NODE *node, ACPI_HANDLE region, u8 field_flags, u8 field_attribute, u32 field_position, u32 field_length) { - ACPI_OBJECT_INTERNAL *obj_desc; - s32 type; + ACPI_OPERAND_OBJECT *obj_desc; + u32 type; ACPI_STATUS status; @@ -220,11 +221,11 @@ /* Debug info */ /* - * Store the constructed descriptor (Obj_desc) into the nte whose - * handle is on TOS, preserving the current type of that nte. + * Store the constructed descriptor (Obj_desc) into the Named_obj whose + * handle is on TOS, preserving the current type of that Named_obj. */ - status = acpi_ns_attach_object ((ACPI_HANDLE) this_entry, obj_desc, - (u8) acpi_ns_get_type ((ACPI_HANDLE) this_entry)); + status = acpi_ns_attach_object ((ACPI_HANDLE) node, obj_desc, + (u8) acpi_ns_get_type ((ACPI_HANDLE) node)); return (status); } @@ -234,7 +235,7 @@ * * FUNCTION: Acpi_aml_prep_bank_field_value * - * PARAMETERS: This_entry - Owning NTE + * PARAMETERS: Node - Owning Node * Region - Region in which field is being defined * Bank_reg - Bank selection register * Bank_val - Value to store in selection register @@ -244,14 +245,14 @@ * * RETURN: Status * - * DESCRIPTION: Construct an ACPI_OBJECT_INTERNAL of type Bank_field and - * connect it to the parent NTE. + * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type Bank_field and + * connect it to the parent Node. * ******************************************************************************/ ACPI_STATUS acpi_aml_prep_bank_field_value ( - ACPI_NAMED_OBJECT *this_entry, + ACPI_NAMESPACE_NODE *node, ACPI_HANDLE region, ACPI_HANDLE bank_reg, u32 bank_val, @@ -260,8 +261,8 @@ u32 field_position, u32 field_length) { - ACPI_OBJECT_INTERNAL *obj_desc; - s32 type; + ACPI_OPERAND_OBJECT *obj_desc; + u32 type; ACPI_STATUS status; @@ -308,11 +309,11 @@ /* Debug info */ /* - * Store the constructed descriptor (Obj_desc) into the nte whose - * handle is on TOS, preserving the current type of that nte. + * Store the constructed descriptor (Obj_desc) into the Named_obj whose + * handle is on TOS, preserving the current type of that Named_obj. */ - status = acpi_ns_attach_object ((ACPI_HANDLE) this_entry, obj_desc, - (u8) acpi_ns_get_type ((ACPI_HANDLE) this_entry)); + status = acpi_ns_attach_object ((ACPI_HANDLE) node, obj_desc, + (u8) acpi_ns_get_type ((ACPI_HANDLE) node)); return (status); } @@ -322,7 +323,7 @@ * * FUNCTION: Acpi_aml_prep_index_field_value * - * PARAMETERS: This_entry - Owning NTE + * PARAMETERS: Node - Owning Node * Index_reg - Index register * Data_reg - Data register * Field_flags - Access, Lock_rule, or Update_rule @@ -331,14 +332,14 @@ * * RETURN: Status * - * DESCRIPTION: Construct an ACPI_OBJECT_INTERNAL of type Index_field and - * connect it to the parent NTE. + * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type Index_field and + * connect it to the parent Node. * ******************************************************************************/ ACPI_STATUS acpi_aml_prep_index_field_value ( - ACPI_NAMED_OBJECT *this_entry, + ACPI_NAMESPACE_NODE *node, ACPI_HANDLE index_reg, ACPI_HANDLE data_reg, u8 field_flags, @@ -346,7 +347,7 @@ u32 field_position, u32 field_length) { - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; ACPI_STATUS status; @@ -381,11 +382,11 @@ /* Debug info */ /* - * Store the constructed descriptor (Obj_desc) into the nte whose - * handle is on TOS, preserving the current type of that nte. + * Store the constructed descriptor (Obj_desc) into the Named_obj whose + * handle is on TOS, preserving the current type of that Named_obj. */ - status = acpi_ns_attach_object ((ACPI_HANDLE) this_entry, obj_desc, - (u8) acpi_ns_get_type ((ACPI_HANDLE) this_entry)); + status = acpi_ns_attach_object ((ACPI_HANDLE) node, obj_desc, + (u8) acpi_ns_get_type ((ACPI_HANDLE) node)); return (status); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amregion.c linux/drivers/acpi/interpreter/amregion.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amregion.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amregion.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,8 @@ + /****************************************************************************** * * Module Name: amregion - ACPI default Op_region (address space) handlers + * $Revision: 35 $ * *****************************************************************************/ @@ -24,15 +26,15 @@ #include "acpi.h" -#include "interp.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" -#include "hardware.h" -#include "events.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amregion"); + MODULE_NAME ("amregion") /******************************************************************************* @@ -43,7 +45,9 @@ * Address - Where in the space to read or write * Bit_width - Field width in bits (8, 16, or 32) * Value - Pointer to in or out value - * Context - Context pointer + * Handler_context - Pointer to Handler's context + * Region_context - Pointer to context specific to the + * accessed region * * RETURN: Status * @@ -57,11 +61,12 @@ u32 address, /* TBD: [Future] Should this be A POINTER for 64-bit support? */ u32 bit_width, u32 *value, - void *context) + void *handler_context, + void *region_context) { ACPI_STATUS status = AE_OK; void *logical_addr_ptr = NULL; - MEM_HANDLER_CONTEXT *mem_info = context; + MEM_HANDLER_CONTEXT *mem_info = region_context; u32 length; @@ -93,8 +98,8 @@ * 2) Address beyond the current mapping? */ - if (((char *) address < mem_info->mapped_physical_address) || - (((char *) address + length) > + if (((u8 *) address < mem_info->mapped_physical_address) || + (((u8 *) address + length) > (mem_info->mapped_physical_address + mem_info->mapped_length))) { /* @@ -119,7 +124,7 @@ return (status); } - mem_info->mapped_physical_address = (char *) address; + mem_info->mapped_physical_address = (u8 *) address; mem_info->mapped_length = SYSMEM_REGION_WINDOW_SIZE; } @@ -130,7 +135,7 @@ */ logical_addr_ptr = mem_info->mapped_logical_address + - ((char *) address - mem_info->mapped_physical_address); + ((u8 *) address - mem_info->mapped_physical_address); /* Perform the memory read or write */ @@ -194,7 +199,9 @@ * Address - Where in the space to read or write * Bit_width - Field width in bits (8, 16, or 32) * Value - Pointer to in or out value - * Context - Context pointer + * Handler_context - Pointer to Handler's context + * Region_context - Pointer to context specific to the + * accessed region * * RETURN: Status * @@ -208,7 +215,8 @@ u32 address, u32 bit_width, u32 *value, - void *context) + void *handler_context, + void *region_context) { ACPI_STATUS status = AE_OK; @@ -283,7 +291,9 @@ * Address - Where in the space to read or write * Bit_width - Field width in bits (8, 16, or 32) * Value - Pointer to in or out value - * Context - Context pointer + * Handler_context - Pointer to Handler's context + * Region_context - Pointer to context specific to the + * accessed region * * RETURN: Status * @@ -297,7 +307,8 @@ u32 address, u32 bit_width, u32 *value, - void *context) + void *handler_context, + void *region_context) { ACPI_STATUS status = AE_OK; u32 pci_bus; @@ -321,7 +332,7 @@ * */ - PCIcontext = (PCI_HANDLER_CONTEXT *) context; + PCIcontext = (PCI_HANDLER_CONTEXT *) region_context; pci_bus = LOWORD(PCIcontext->seg) << 16; pci_bus |= LOWORD(PCIcontext->bus); @@ -365,7 +376,6 @@ case ADDRESS_SPACE_WRITE: - switch (bit_width) { diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amresnte.c linux/drivers/acpi/interpreter/amresnte.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amresnte.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amresnte.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ /****************************************************************************** * * Module Name: amresnte - AML Interpreter object resolution + * $Revision: 21 $ * *****************************************************************************/ @@ -26,32 +27,33 @@ #include "acpi.h" #include "amlcode.h" -#include "parser.h" -#include "dispatch.h" -#include "interp.h" -#include "namesp.h" -#include "tables.h" -#include "events.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acevents.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amresnte"); + MODULE_NAME ("amresnte") /******************************************************************************* * - * FUNCTION: Acpi_aml_resolve_entry_to_value + * FUNCTION: Acpi_aml_resolve_node_to_value * * PARAMETERS: Stack_ptr - Pointer to a location on a stack that contains - * a ptr to an NTE + * a pointer to an Node * * RETURN: Status * - * DESCRIPTION: Resolve a ACPI_NAMED_OBJECT(nte, A.K.A. a "direct name pointer") + * DESCRIPTION: Resolve a ACPI_NAMESPACE_NODE (Node, + * A.K.A. a "direct name pointer") * - * Note: for some of the data types, the pointer attached to the NTE can be - * either a pointer to an actual internal object or a pointer into the AML - * stream itself. These types are currently: + * Note: for some of the data types, the pointer attached to the Node + * can be either a pointer to an actual internal object or a pointer into the + * AML stream itself. These types are currently: * * ACPI_TYPE_NUMBER * ACPI_TYPE_STRING @@ -62,13 +64,13 @@ ******************************************************************************/ ACPI_STATUS -acpi_aml_resolve_entry_to_value ( - ACPI_NAMED_OBJECT **stack_ptr) +acpi_aml_resolve_node_to_value ( + ACPI_NAMESPACE_NODE **stack_ptr) { ACPI_STATUS status = AE_OK; - ACPI_OBJECT_INTERNAL *val_desc = NULL; - ACPI_OBJECT_INTERNAL *obj_desc = NULL; - ACPI_NAMED_OBJECT *stack_entry; + ACPI_OPERAND_OBJECT *val_desc = NULL; + ACPI_OPERAND_OBJECT *obj_desc = NULL; + ACPI_NAMESPACE_NODE *node; u8 *aml_pointer = NULL; OBJECT_TYPE_INTERNAL entry_type; u8 locked; @@ -78,20 +80,20 @@ OBJECT_TYPE_INTERNAL object_type; - stack_entry = *stack_ptr; + node = *stack_ptr; /* * The stack pointer is a "Direct name ptr", and points to a - * a ACPI_NAMED_OBJECT(nte). Get the pointer that is attached to - * the nte. + * a ACPI_NAMESPACE_NODE (Node). Get the pointer that is attached to + * the Node. */ - val_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) stack_entry); - entry_type = acpi_ns_get_type ((ACPI_HANDLE) stack_entry); + val_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) node); + entry_type = acpi_ns_get_type ((ACPI_HANDLE) node); /* - * The Val_desc attached to the NTE can be either: + * The Val_desc attached to the Node can be either: * 1) An internal ACPI object * 2) A pointer into the AML stream (into one of the ACPI system tables) */ @@ -105,7 +107,25 @@ /* - * Action is based on the type of the NTE, which indicates the type + * Several Entry_types do not require further processing, so + * we will return immediately + */ + /* Devices rarely have an attached object, return the Node + * and Method locals and arguments have a pseudo-Node + */ + if (entry_type == ACPI_TYPE_DEVICE || + entry_type == INTERNAL_TYPE_METHOD_ARGUMENT || + entry_type == INTERNAL_TYPE_METHOD_LOCAL_VAR) + { + return (AE_OK); + } + + if (!val_desc) { + return (AE_AML_NO_OPERAND); + } + + /* + * Action is based on the type of the Node, which indicates the type * of the attached object or pointer */ switch (entry_type) @@ -113,15 +133,6 @@ case ACPI_TYPE_PACKAGE: - /* - * Val_desc should point to either an ACPI_OBJECT_INTERNAL of - * type Package, or an initialization in the AML stream. - */ - if (!val_desc) { - return (AE_AML_NO_OPERAND); - } - - if (attached_aml_pointer) { /* * This means that the package initialization is not parsed @@ -132,7 +143,7 @@ /* Val_desc is an internal object in all cases by the time we get here */ - if (!val_desc || (ACPI_TYPE_PACKAGE != val_desc->common.type)) { + if (ACPI_TYPE_PACKAGE != val_desc->common.type) { return (AE_AML_OPERAND_TYPE); } @@ -145,10 +156,6 @@ case ACPI_TYPE_BUFFER: - if (!val_desc) { - return (AE_AML_NO_OPERAND); - } - if (attached_aml_pointer) { /* * This means that the buffer initialization is not parsed @@ -159,7 +166,7 @@ /* Val_desc is an internal object in all cases by the time we get here */ - if (!val_desc || (ACPI_TYPE_BUFFER != val_desc->common.type)) { + if (ACPI_TYPE_BUFFER != val_desc->common.type) { return (AE_AML_OPERAND_TYPE); } @@ -183,8 +190,8 @@ /* Init the internal object */ - obj_desc->string.pointer = (char *) aml_pointer; - obj_desc->string.length = STRLEN (aml_pointer); + obj_desc->string.pointer = (NATIVE_CHAR *) aml_pointer; + obj_desc->string.length = STRLEN (obj_desc->string.pointer); } else { @@ -203,11 +210,6 @@ case ACPI_TYPE_NUMBER: - if (!val_desc) { - return (AE_AML_NO_OPERAND); - } - - /* * An ACPI_TYPE_NUMBER can be either an object or an AML pointer */ @@ -279,7 +281,7 @@ else { /* - * The NTE has an attached internal object, make sure that it's a + * The Node has an attached internal object, make sure that it's a * number */ @@ -337,18 +339,21 @@ obj_desc->buffer.length = val_desc->field.length; - status = acpi_aml_get_named_field_value ((ACPI_HANDLE) stack_entry, - obj_desc->buffer.pointer, obj_desc->buffer.length); + status = acpi_aml_access_named_field (ACPI_READ, + (ACPI_HANDLE) node, + obj_desc->buffer.pointer, + obj_desc->buffer.length); - if (AE_OK != status) { + if (ACPI_FAILURE (status)) { return (status); } } else { - status = acpi_aml_get_named_field_value ((ACPI_HANDLE) stack_entry, + status = acpi_aml_access_named_field (ACPI_READ, + (ACPI_HANDLE) node, &temp_val, sizeof (temp_val)); - if (AE_OK != status) { + if (ACPI_FAILURE (status)) { return (status); } @@ -361,10 +366,6 @@ case INTERNAL_TYPE_BANK_FIELD: - if (!val_desc) { - return (AE_AML_NO_OPERAND); - } - if (attached_aml_pointer) { return (AE_AML_OPERAND_TYPE); } @@ -376,30 +377,30 @@ /* Get the global lock if needed */ - obj_desc = (ACPI_OBJECT_INTERNAL *) *stack_ptr; + obj_desc = (ACPI_OPERAND_OBJECT *) *stack_ptr; locked = acpi_aml_acquire_global_lock (obj_desc->field_unit.lock_rule); - { - /* Set Index value to select proper Data register */ - /* perform the update */ + /* Set Index value to select proper Data register */ + /* perform the update */ + + status = acpi_aml_access_named_field (ACPI_WRITE, + val_desc->bank_field.bank_select, + &val_desc->bank_field.value, + sizeof (val_desc->bank_field.value)); - status = acpi_aml_set_named_field_value (val_desc->bank_field.bank_select, - &val_desc->bank_field.value, - sizeof (val_desc->bank_field.value)); - } acpi_aml_release_global_lock (locked); - if (AE_OK != status) { + if (ACPI_FAILURE (status)) { return (status); } /* Read Data value */ - status = acpi_aml_get_named_field_value ( + status = acpi_aml_access_named_field (ACPI_READ, (ACPI_HANDLE) val_desc->bank_field.container, &temp_val, sizeof (temp_val)); - if (AE_OK != status) { + if (ACPI_FAILURE (status)) { return (status); } @@ -414,10 +415,6 @@ case INTERNAL_TYPE_INDEX_FIELD: - if (!val_desc) { - return (AE_AML_NO_OPERAND); - } - if (attached_aml_pointer) { return (AE_AML_OPERAND_TYPE); } @@ -430,25 +427,27 @@ /* Set Index value to select proper Data register */ /* Get the global lock if needed */ - obj_desc = (ACPI_OBJECT_INTERNAL *) *stack_ptr; + obj_desc = (ACPI_OPERAND_OBJECT *) *stack_ptr; locked = acpi_aml_acquire_global_lock (obj_desc->field_unit.lock_rule); - { - /* Perform the update */ - status = acpi_aml_set_named_field_value (val_desc->index_field.index, - &val_desc->index_field.value, - sizeof (val_desc->index_field.value)); - } + /* Perform the update */ + status = acpi_aml_access_named_field (ACPI_WRITE, + val_desc->index_field.index, + &val_desc->index_field.value, + sizeof (val_desc->index_field.value)); + acpi_aml_release_global_lock (locked); - if (AE_OK != status) { + if (ACPI_FAILURE (status)) { return (status); } /* Read Data value */ - status = acpi_aml_get_named_field_value (val_desc->index_field.data, &temp_val, sizeof (temp_val)); - if (AE_OK != status) { + status = acpi_aml_access_named_field (ACPI_READ, + val_desc->index_field.data, + &temp_val, sizeof (temp_val)); + if (ACPI_FAILURE (status)) { return (status); } @@ -463,10 +462,6 @@ case ACPI_TYPE_FIELD_UNIT: - if (!val_desc) { - return (AE_AML_NO_OPERAND); - } - if (attached_aml_pointer) { return (AE_AML_OPERAND_TYPE); } @@ -481,7 +476,8 @@ return (AE_NO_MEMORY); } - if ((status = acpi_aml_get_field_unit_value (val_desc, obj_desc)) != AE_OK) { + status = acpi_aml_get_field_unit_value (val_desc, obj_desc); + if (ACPI_FAILURE (status)) { acpi_cm_remove_reference (obj_desc); return (status); } @@ -490,7 +486,7 @@ /* - * For these objects, just return the object attached to the NTE + * For these objects, just return the object attached to the Node */ case ACPI_TYPE_MUTEX: @@ -502,32 +498,11 @@ case ACPI_TYPE_REGION: - /* There must be an object attached to this NTE */ - - if (!val_desc) { - return (AE_AML_INTERNAL); - } - /* Return an additional reference to the object */ obj_desc = val_desc; acpi_cm_add_reference (obj_desc); break; - - - /* Devices rarely have an attached object, return the NTE */ - - case ACPI_TYPE_DEVICE: - - - /* Method locals and arguments have a pseudo-NTE, just return it */ - - case INTERNAL_TYPE_METHOD_ARGUMENT: - case INTERNAL_TYPE_METHOD_LOCAL_VAR: - - return (AE_OK); - break; - /* TYPE_Any is untyped, and thus there is no object associated with it */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amresolv.c linux/drivers/acpi/interpreter/amresolv.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amresolv.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amresolv.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ /****************************************************************************** * * Module Name: amresolv - AML Interpreter object resolution + * $Revision: 74 $ * *****************************************************************************/ @@ -26,16 +27,16 @@ #include "acpi.h" #include "amlcode.h" -#include "parser.h" -#include "dispatch.h" -#include "interp.h" -#include "namesp.h" -#include "tables.h" -#include "events.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acevents.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amresolv"); + MODULE_NAME ("amresolv") /******************************************************************************* @@ -55,8 +56,8 @@ ACPI_STATUS acpi_aml_get_field_unit_value ( - ACPI_OBJECT_INTERNAL *field_desc, - ACPI_OBJECT_INTERNAL *result_desc) + ACPI_OPERAND_OBJECT *field_desc, + ACPI_OPERAND_OBJECT *result_desc) { ACPI_STATUS status = AE_OK; u32 mask; @@ -143,7 +144,7 @@ * FUNCTION: Acpi_aml_resolve_to_value * * PARAMETERS: **Stack_ptr - Points to entry on Obj_stack, which can - * be either an (ACPI_OBJECT_INTERNAL *) + * be either an (ACPI_OPERAND_OBJECT *) * or an ACPI_HANDLE. * * RETURN: Status @@ -154,7 +155,8 @@ ACPI_STATUS acpi_aml_resolve_to_value ( - ACPI_OBJECT_INTERNAL **stack_ptr) + ACPI_OPERAND_OBJECT **stack_ptr, + ACPI_WALK_STATE *walk_state) { ACPI_STATUS status = AE_OK; @@ -166,13 +168,13 @@ /* * The entity pointed to by the Stack_ptr can be either - * 1) A valid ACPI_OBJECT_INTERNAL, or - * 2) A ACPI_NAMED_OBJECT(nte) + * 1) A valid ACPI_OPERAND_OBJECT, or + * 2) A ACPI_NAMESPACE_NODE (Named_obj) */ if (VALID_DESCRIPTOR_TYPE (*stack_ptr, ACPI_DESC_TYPE_INTERNAL)) { - status = acpi_aml_resolve_object_to_value (stack_ptr); + status = acpi_aml_resolve_object_to_value (stack_ptr, walk_state); if (ACPI_FAILURE (status)) { return (status); } @@ -184,7 +186,7 @@ */ if (VALID_DESCRIPTOR_TYPE (*stack_ptr, ACPI_DESC_TYPE_NAMED)) { - status = acpi_aml_resolve_entry_to_value ((ACPI_NAMED_OBJECT**) stack_ptr); + status = acpi_aml_resolve_node_to_value ((ACPI_NAMESPACE_NODE **) stack_ptr); } @@ -208,19 +210,20 @@ ACPI_STATUS acpi_aml_resolve_object_to_value ( - ACPI_OBJECT_INTERNAL **stack_ptr) + ACPI_OPERAND_OBJECT **stack_ptr, + ACPI_WALK_STATE *walk_state) { - ACPI_OBJECT_INTERNAL *stack_desc; + ACPI_OPERAND_OBJECT *stack_desc; ACPI_STATUS status = AE_OK; ACPI_HANDLE temp_handle = NULL; - ACPI_OBJECT_INTERNAL *obj_desc = NULL; + ACPI_OPERAND_OBJECT *obj_desc = NULL; u32 index = 0; u16 opcode; stack_desc = *stack_ptr; - /* This is an ACPI_OBJECT_INTERNAL */ + /* This is an ACPI_OPERAND_OBJECT */ switch (stack_desc->common.type) { @@ -236,7 +239,7 @@ /* * Convert indirect name ptr to a direct name ptr. - * Then, Acpi_aml_resolve_entry_to_value can be used to get the value + * Then, Acpi_aml_resolve_node_to_value can be used to get the value */ temp_handle = stack_desc->reference.object; @@ -256,24 +259,26 @@ index = stack_desc->reference.offset; - /* Delete the Reference Object */ - - acpi_cm_remove_reference (stack_desc); - /* * Get the local from the method's state info - * Note: this increments the object reference count + * Note: this increments the local's object reference count */ status = acpi_ds_method_data_get_value (MTH_TYPE_LOCAL, index, - stack_ptr); + walk_state, &obj_desc); if (ACPI_FAILURE (status)) { return (status); } - stack_desc = *stack_ptr; + /* + * Now we can delete the original Reference Object and + * replace it with the resolve value + */ + + acpi_cm_remove_reference (stack_desc); + *stack_ptr = obj_desc; - if (ACPI_TYPE_NUMBER == stack_desc->common.type) { + if (ACPI_TYPE_NUMBER == obj_desc->common.type) { /* Value is a Number */ } @@ -285,9 +290,6 @@ index = stack_desc->reference.offset; - /* Delete the Reference Object*/ - - acpi_cm_remove_reference (stack_desc); /* * Get the argument from the method's state info @@ -295,14 +297,20 @@ */ status = acpi_ds_method_data_get_value (MTH_TYPE_ARG, index, - stack_ptr); + walk_state, &obj_desc); if (ACPI_FAILURE (status)) { return (status); } - stack_desc = *stack_ptr; + /* + * Now we can delete the original Reference Object and + * replace it with the resolve value + */ + + acpi_cm_remove_reference (stack_desc); + *stack_ptr = obj_desc; - if (ACPI_TYPE_NUMBER == stack_desc->common.type) { + if (ACPI_TYPE_NUMBER == obj_desc->common.type) { /* Value is a Number */ } @@ -392,7 +400,7 @@ } /* switch (Opcode) */ - if (AE_OK != status) { + if (ACPI_FAILURE (status)) { return (status); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amresop.c linux/drivers/acpi/interpreter/amresop.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amresop.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amresop.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ /****************************************************************************** * * Module Name: amresop - AML Interpreter operand/object resolution + * $Revision: 15 $ * *****************************************************************************/ @@ -26,16 +27,16 @@ #include "acpi.h" #include "amlcode.h" -#include "parser.h" -#include "dispatch.h" -#include "interp.h" -#include "namesp.h" -#include "tables.h" -#include "events.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acevents.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amresop"); + MODULE_NAME ("amresop") /******************************************************************************* @@ -60,19 +61,20 @@ ACPI_STATUS acpi_aml_resolve_operands ( u16 opcode, - ACPI_OBJECT_INTERNAL **stack_ptr) + ACPI_OPERAND_OBJECT **stack_ptr, + ACPI_WALK_STATE *walk_state) { - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; ACPI_STATUS status = AE_OK; u8 object_type; ACPI_HANDLE temp_handle; u32 arg_types; - ACPI_OP_INFO *op_info; + ACPI_OPCODE_INFO *op_info; u32 this_arg_type; op_info = acpi_ps_get_opcode_info (opcode); - if (!op_info) { + if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { return (AE_AML_BAD_OPCODE); } @@ -105,9 +107,9 @@ /* Decode the descriptor type */ if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_NAMED)) { - /* NTE */ + /* Node */ - object_type = ((ACPI_NAMED_OBJECT*) obj_desc)->type; + object_type = ((ACPI_NAMESPACE_NODE *) obj_desc)->type; } else if (VALID_DESCRIPTOR_TYPE (obj_desc, ACPI_DESC_TYPE_INTERNAL)) { @@ -128,7 +130,7 @@ */ op_info = acpi_ps_get_opcode_info (opcode); - if (!op_info) { + if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { return (AE_AML_BAD_OPCODE); } @@ -205,7 +207,8 @@ /* Need an operand of type ACPI_TYPE_NUMBER */ - if ((status = acpi_aml_resolve_to_value (stack_ptr)) != AE_OK) { + status = acpi_aml_resolve_to_value (stack_ptr, walk_state); + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -220,7 +223,8 @@ /* Need an operand of type ACPI_TYPE_STRING or ACPI_TYPE_BUFFER */ - if ((status = acpi_aml_resolve_to_value (stack_ptr)) != AE_OK) { + status = acpi_aml_resolve_to_value (stack_ptr, walk_state); + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -237,7 +241,8 @@ /* Need an operand of type ACPI_TYPE_BUFFER */ - if ((status = acpi_aml_resolve_to_value(stack_ptr)) != AE_OK) { + status = acpi_aml_resolve_to_value (stack_ptr, walk_state); + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -252,7 +257,8 @@ /* Need an operand of type ACPI_TYPE_MUTEX */ - if ((status = acpi_aml_resolve_to_value(stack_ptr)) != AE_OK) { + status = acpi_aml_resolve_to_value (stack_ptr, walk_state); + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -267,7 +273,8 @@ /* Need an operand of type ACPI_TYPE_EVENT */ - if ((status = acpi_aml_resolve_to_value(stack_ptr)) != AE_OK) { + status = acpi_aml_resolve_to_value (stack_ptr, walk_state); + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -282,7 +289,8 @@ /* Need an operand of type ACPI_TYPE_REGION */ - if ((status = acpi_aml_resolve_to_value(stack_ptr)) != AE_OK) { + status = acpi_aml_resolve_to_value (stack_ptr, walk_state); + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -308,7 +316,8 @@ /* Need an operand of type ACPI_TYPE_PACKAGE */ - if ((status = acpi_aml_resolve_to_value (stack_ptr)) != AE_OK) { + status = acpi_aml_resolve_to_value (stack_ptr, walk_state); + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -337,7 +346,8 @@ /* All others must be resolved */ - if ((status = acpi_aml_resolve_to_value (stack_ptr)) != AE_OK) { + status = acpi_aml_resolve_to_value (stack_ptr, walk_state); + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -352,15 +362,16 @@ * * The ACPI specification allows Size_of to return the size of * a Buffer, String or Package. However, the MS ACPI.SYS AML - * Interpreter also allows an NTE reference to return without + * Interpreter also allows an Node reference to return without * error with a size of 4. */ - if ((status = acpi_aml_resolve_to_value (stack_ptr)) != AE_OK) { + status = acpi_aml_resolve_to_value (stack_ptr, walk_state); + if (ACPI_FAILURE (status)) { goto cleanup; } - /* Need a buffer, string, package or NTE reference */ + /* Need a buffer, string, package or Node reference */ if (((*stack_ptr)->common.type != ACPI_TYPE_BUFFER) && ((*stack_ptr)->common.type != ACPI_TYPE_STRING) && @@ -372,10 +383,10 @@ } /* - * If this is a reference, only allow a reference to an NTE. + * If this is a reference, only allow a reference to an Node. */ if ((*stack_ptr)->common.type == INTERNAL_TYPE_REFERENCE) { - if (!(*stack_ptr)->reference.nte) { + if (!(*stack_ptr)->reference.node) { status = AE_AML_OPERAND_TYPE; goto cleanup; } @@ -386,7 +397,8 @@ case ARGI_COMPLEXOBJ: - if ((status = acpi_aml_resolve_to_value (stack_ptr)) != AE_OK) { + status = acpi_aml_resolve_to_value (stack_ptr, walk_state); + if (ACPI_FAILURE (status)) { goto cleanup; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amstore.c linux/drivers/acpi/interpreter/amstore.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amstore.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amstore.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ /****************************************************************************** * * Module Name: amstore - AML Interpreter object store support + * $Revision: 116 $ * *****************************************************************************/ @@ -25,16 +26,16 @@ #include "acpi.h" -#include "parser.h" -#include "dispatch.h" -#include "interp.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" -#include "tables.h" +#include "acnamesp.h" +#include "actables.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amstore"); + MODULE_NAME ("amstore") /******************************************************************************* @@ -43,7 +44,7 @@ * * PARAMETERS: *Val_desc - Value to be stored * *Dest_desc - Where to store it 0 Must be (ACPI_HANDLE) - * or an ACPI_OBJECT_INTERNAL of type + * or an ACPI_OPERAND_OBJECT of type * Reference; if the latter the descriptor * will be either reused or deleted. * @@ -58,13 +59,14 @@ ACPI_STATUS acpi_aml_exec_store ( - ACPI_OBJECT_INTERNAL *val_desc, - ACPI_OBJECT_INTERNAL *dest_desc) + ACPI_OPERAND_OBJECT *val_desc, + ACPI_OPERAND_OBJECT *dest_desc, + ACPI_WALK_STATE *walk_state) { ACPI_STATUS status = AE_OK; - ACPI_OBJECT_INTERNAL *delete_dest_desc = NULL; - ACPI_OBJECT_INTERNAL *tmp_desc; - ACPI_NAMED_OBJECT *entry = NULL; + ACPI_OPERAND_OBJECT *delete_dest_desc = NULL; + ACPI_OPERAND_OBJECT *tmp_desc; + ACPI_NAMESPACE_NODE *node = NULL; u8 value = 0; u32 length; u32 i; @@ -81,7 +83,7 @@ if (VALID_DESCRIPTOR_TYPE (dest_desc, ACPI_DESC_TYPE_NAMED)) { /* Dest is an ACPI_HANDLE, create a new object */ - entry = (ACPI_NAMED_OBJECT*) dest_desc; + node = (ACPI_NAMESPACE_NODE *) dest_desc; dest_desc = acpi_cm_create_internal_object (INTERNAL_TYPE_REFERENCE); if (!dest_desc) { /* Allocation failure */ @@ -92,7 +94,7 @@ /* Build a new Reference wrapper around the handle */ dest_desc->reference.op_code = AML_NAME_OP; - dest_desc->reference.object = entry; + dest_desc->reference.object = node; } @@ -115,7 +117,8 @@ * Storing into a Name */ delete_dest_desc = dest_desc; - status = acpi_aml_store_object_to_nte (val_desc, dest_desc->reference.object); + status = acpi_aml_store_object_to_node (val_desc, dest_desc->reference.object, + walk_state); break; /* Case Name_op */ @@ -182,7 +185,7 @@ */ if (ACPI_TYPE_PACKAGE == tmp_desc->common.type) { status = acpi_aml_build_copy_internal_package_object ( - val_desc, tmp_desc); + val_desc, tmp_desc, walk_state); if (ACPI_FAILURE (status)) { acpi_cm_remove_reference (tmp_desc); tmp_desc = NULL; @@ -206,7 +209,8 @@ * convert the contents of the source (Val_desc) and copy into * the destination (Tmp_desc) */ - status = acpi_aml_store_object_to_object(val_desc, tmp_desc); + status = acpi_aml_store_object_to_object (val_desc, tmp_desc, + walk_state); if (ACPI_FAILURE (status)) { /* * An error occurrered when copying the internal object @@ -299,7 +303,7 @@ /* * If we had an error, break out of this case statement. */ - if(AE_OK != status) { + if (ACPI_FAILURE (status)) { break; } @@ -315,7 +319,7 @@ case AML_ONES_OP: /* - * Storing to a constant is a no-op -- see spec sec 15.2.3.3.1. + * Storing to a constant is a no-op -- see ACPI Specification * Delete the result descriptor. */ @@ -326,7 +330,7 @@ case AML_LOCAL_OP: status = acpi_ds_method_data_set_value (MTH_TYPE_LOCAL, - (dest_desc->reference.offset), val_desc); + (dest_desc->reference.offset), val_desc, walk_state); delete_dest_desc = dest_desc; break; @@ -334,7 +338,7 @@ case AML_ARG_OP: status = acpi_ds_method_data_set_value (MTH_TYPE_ARG, - (dest_desc->reference.offset), val_desc); + (dest_desc->reference.offset), val_desc, walk_state); delete_dest_desc = dest_desc; break; @@ -343,7 +347,7 @@ /* * Storing to the Debug object causes the value stored to be - * displayed and otherwise has no effect -- see sec. 15.2.3.3.3. + * displayed and otherwise has no effect -- see ACPI Specification */ delete_dest_desc = dest_desc; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amstoren.c linux/drivers/acpi/interpreter/amstoren.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amstoren.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amstoren.c Fri Sep 15 14:30:30 2000 @@ -1,7 +1,9 @@ /****************************************************************************** * - * Module Name: amstoren - AML Interpreter object store support, store to NTE + * Module Name: amstoren - AML Interpreter object store support, + * Store to Node (namespace object) + * $Revision: 21 $ * *****************************************************************************/ @@ -25,24 +27,24 @@ #include "acpi.h" -#include "parser.h" -#include "dispatch.h" -#include "interp.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" -#include "tables.h" +#include "acnamesp.h" +#include "actables.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amstoren"); + MODULE_NAME ("amstoren") /******************************************************************************* * - * FUNCTION: Acpi_aml_store_object_to_nte + * FUNCTION: Acpi_aml_store_object_to_node * * PARAMETERS: *Val_desc - Value to be stored - * *Entry - Named object to recieve the value + * *Node - Named object to recieve the value * * RETURN: Status * @@ -65,9 +67,10 @@ ******************************************************************************/ ACPI_STATUS -acpi_aml_store_object_to_nte ( - ACPI_OBJECT_INTERNAL *val_desc, - ACPI_NAMED_OBJECT *entry) +acpi_aml_store_object_to_node ( + ACPI_OPERAND_OBJECT *val_desc, + ACPI_NAMESPACE_NODE *node, + ACPI_WALK_STATE *walk_state) { ACPI_STATUS status = AE_OK; u8 *buffer = NULL; @@ -76,16 +79,16 @@ u32 new_value; u8 locked = FALSE; u8 *location=NULL; - ACPI_OBJECT_INTERNAL *dest_desc; + ACPI_OPERAND_OBJECT *dest_desc; OBJECT_TYPE_INTERNAL destination_type = ACPI_TYPE_ANY; /* * Assuming the parameters are valid!!! */ - ACPI_ASSERT((entry) && (val_desc)); + ACPI_ASSERT((node) && (val_desc)); - destination_type = acpi_ns_get_type (entry); + destination_type = acpi_ns_get_type (node); /* * First ensure we have a value that can be stored in the target @@ -120,8 +123,8 @@ /* * Initially not a number, convert */ - status = acpi_aml_resolve_to_value (&val_desc); - if ((status == AE_OK) && + status = acpi_aml_resolve_to_value (&val_desc, walk_state); + if (ACPI_SUCCESS (status) && (val_desc->common.type != ACPI_TYPE_NUMBER)) { /* @@ -151,8 +154,8 @@ /* * Initially not a valid type, convert */ - status = acpi_aml_resolve_to_value (&val_desc); - if ((status == AE_OK) && + status = acpi_aml_resolve_to_value (&val_desc, walk_state); + if (ACPI_SUCCESS (status) && (val_desc->common.type != ACPI_TYPE_NUMBER) && (val_desc->common.type != ACPI_TYPE_BUFFER) && (val_desc->common.type != ACPI_TYPE_STRING)) @@ -184,7 +187,7 @@ * Val_desc reference count is incremented by Attach_object. */ - status = acpi_ns_attach_object (entry, val_desc, val_desc->common.type); + status = acpi_ns_attach_object (node, val_desc, val_desc->common.type); goto clean_up_and_bail_out; break; @@ -192,24 +195,24 @@ /* Exit now if failure above */ - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { goto clean_up_and_bail_out; } /* - * Get descriptor for object attached to NTE + * Get descriptor for object attached to Node */ - dest_desc = acpi_ns_get_attached_object (entry); + dest_desc = acpi_ns_get_attached_object (node); if (!dest_desc) { /* - * There is no existing object attached to this NTE + * There is no existing object attached to this Node */ status = AE_AML_INTERNAL; goto clean_up_and_bail_out; } /* - * Make sure the destination Object is the same as the NTE + * Make sure the destination Object is the same as the Node */ if (dest_desc->common.type != (u8) destination_type) { status = AE_AML_INTERNAL; @@ -237,15 +240,17 @@ * Perform the update (Set Bank Select) */ - status = acpi_aml_set_named_field_value (dest_desc->bank_field.bank_select, - &dest_desc->bank_field.value, - sizeof (dest_desc->bank_field.value)); - if (status == AE_OK) { + status = acpi_aml_access_named_field (ACPI_WRITE, + dest_desc->bank_field.bank_select, + &dest_desc->bank_field.value, + sizeof (dest_desc->bank_field.value)); + if (ACPI_SUCCESS (status)) { /* Set bank select successful, set data value */ - status = acpi_aml_set_named_field_value (dest_desc->bank_field.bank_select, - &val_desc->bank_field.value, - sizeof (val_desc->bank_field.value)); + status = acpi_aml_access_named_field (ACPI_WRITE, + dest_desc->bank_field.bank_select, + &val_desc->bank_field.value, + sizeof (val_desc->bank_field.value)); } break; @@ -280,7 +285,9 @@ break; } - status = acpi_aml_set_named_field_value (entry, buffer, length); + status = acpi_aml_access_named_field (ACPI_WRITE, + node, buffer, length); + break; /* Global Lock released below */ @@ -405,16 +412,18 @@ * perform the update (Set index) */ - status = acpi_aml_set_named_field_value (dest_desc->index_field.index, - &dest_desc->index_field.value, - sizeof (dest_desc->index_field.value)); + status = acpi_aml_access_named_field (ACPI_WRITE, + dest_desc->index_field.index, + &dest_desc->index_field.value, + sizeof (dest_desc->index_field.value)); - if (AE_OK == status) { + if (ACPI_SUCCESS (status)) { /* set index successful, next set Data value */ - status = acpi_aml_set_named_field_value (dest_desc->index_field.data, - &val_desc->number.value, - sizeof (val_desc->number.value)); + status = acpi_aml_access_named_field (ACPI_WRITE, + dest_desc->index_field.data, + &val_desc->number.value, + sizeof (val_desc->number.value)); } break; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amstorob.c linux/drivers/acpi/interpreter/amstorob.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amstorob.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amstorob.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ /****************************************************************************** * * Module Name: amstorob - AML Interpreter object store support, store to object + * $Revision: 16 $ * *****************************************************************************/ @@ -25,16 +26,16 @@ #include "acpi.h" -#include "parser.h" -#include "dispatch.h" -#include "interp.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" -#include "tables.h" +#include "acnamesp.h" +#include "actables.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amstorob"); + MODULE_NAME ("amstorob") /******************************************************************************* @@ -65,8 +66,9 @@ ACPI_STATUS acpi_aml_store_object_to_object ( - ACPI_OBJECT_INTERNAL *val_desc, - ACPI_OBJECT_INTERNAL *dest_desc) + ACPI_OPERAND_OBJECT *val_desc, + ACPI_OPERAND_OBJECT *dest_desc, + ACPI_WALK_STATE *walk_state) { ACPI_STATUS status = AE_OK; u8 *buffer = NULL; @@ -99,8 +101,8 @@ /* * Initially not a number, convert */ - status = acpi_aml_resolve_to_value (&val_desc); - if ((status == AE_OK) && + status = acpi_aml_resolve_to_value (&val_desc, walk_state); + if (ACPI_SUCCESS (status) && (val_desc->common.type != ACPI_TYPE_NUMBER)) { /* @@ -129,8 +131,8 @@ /* * Initially not a valid type, convert */ - status = acpi_aml_resolve_to_value (&val_desc); - if ((status == AE_OK) && + status = acpi_aml_resolve_to_value (&val_desc, walk_state); + if (ACPI_SUCCESS (status) && (val_desc->common.type != ACPI_TYPE_NUMBER) && (val_desc->common.type != ACPI_TYPE_BUFFER) && (val_desc->common.type != ACPI_TYPE_STRING)) @@ -155,7 +157,7 @@ /* Exit now if failure above */ - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { goto clean_up_and_bail_out; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amsystem.c linux/drivers/acpi/interpreter/amsystem.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amsystem.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amsystem.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ /****************************************************************************** * * Module Name: amsystem - Interface to OS services + * $Revision: 51 $ * *****************************************************************************/ @@ -25,13 +26,13 @@ #include "acpi.h" -#include "interp.h" -#include "namesp.h" -#include "hardware.h" -#include "events.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "achware.h" +#include "acevents.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amsystem"); + MODULE_NAME ("amsystem") /******************************************************************************* @@ -181,8 +182,8 @@ ACPI_STATUS acpi_aml_system_acquire_mutex ( - ACPI_OBJECT_INTERNAL *time_desc, - ACPI_OBJECT_INTERNAL *obj_desc) + ACPI_OPERAND_OBJECT *time_desc, + ACPI_OPERAND_OBJECT *obj_desc) { ACPI_STATUS status = AE_OK; @@ -223,7 +224,7 @@ ACPI_STATUS acpi_aml_system_release_mutex ( - ACPI_OBJECT_INTERNAL *obj_desc) + ACPI_OPERAND_OBJECT *obj_desc) { ACPI_STATUS status = AE_OK; @@ -260,7 +261,7 @@ ACPI_STATUS acpi_aml_system_signal_event ( - ACPI_OBJECT_INTERNAL *obj_desc) + ACPI_OPERAND_OBJECT *obj_desc) { ACPI_STATUS status = AE_OK; @@ -290,8 +291,8 @@ ACPI_STATUS acpi_aml_system_wait_event ( - ACPI_OBJECT_INTERNAL *time_desc, - ACPI_OBJECT_INTERNAL *obj_desc) + ACPI_OPERAND_OBJECT *time_desc, + ACPI_OPERAND_OBJECT *obj_desc) { ACPI_STATUS status = AE_OK; @@ -321,7 +322,7 @@ ACPI_STATUS acpi_aml_system_reset_event ( - ACPI_OBJECT_INTERNAL *obj_desc) + ACPI_OPERAND_OBJECT *obj_desc) { ACPI_STATUS status = AE_OK; void *temp_semaphore; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amutils.c linux/drivers/acpi/interpreter/amutils.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amutils.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amutils.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ /****************************************************************************** * * Module Name: amutils - interpreter/scanner utilities + * $Revision: 53 $ * *****************************************************************************/ @@ -25,21 +26,21 @@ #include "acpi.h" -#include "parser.h" -#include "interp.h" +#include "acparser.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" -#include "events.h" +#include "acnamesp.h" +#include "acevents.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amutils"); + MODULE_NAME ("amutils") typedef struct internal_search_st { - ACPI_OBJECT_INTERNAL *dest_obj; + ACPI_OPERAND_OBJECT *dest_obj; u32 index; - ACPI_OBJECT_INTERNAL *source_obj; + ACPI_OPERAND_OBJECT *source_obj; } INTERNAL_PKG_SEARCH_INFO; @@ -49,7 +50,7 @@ INTERNAL_PKG_SEARCH_INFO copy_level[MAX_PACKAGE_DEPTH]; -static char hex[] = +static NATIVE_CHAR hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; @@ -121,41 +122,10 @@ if ((type > ACPI_TYPE_MAX && type < INTERNAL_TYPE_BEGIN) || (type > INTERNAL_TYPE_MAX)) { - return FALSE; + return (FALSE); } - return TRUE; -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_aml_append_operand_diag - * - * PARAMETERS: *File_name - Name of source file - * Line_num - Line Number in file - * Op_code - Op_code being executed - * Num_operands - Number of operands Prep_stack tried to check - * - * DESCRIPTION: Print diagnostic information about operands. - * This function is intended to be called after Prep_stack - * has returned S_ERROR. - * - ******************************************************************************/ - -void -acpi_aml_append_operand_diag ( - char *file_name, - s32 line_num, - u16 op_code, - ACPI_OBJECT_INTERNAL **operands, - s32 num_operands) -{ - - /* - * This function outputs debug information only - */ - + return (TRUE); } @@ -178,7 +148,7 @@ acpi_aml_buf_seq (void) { - return ++acpi_gbl_buf_seq; + return (++acpi_gbl_buf_seq); } @@ -270,12 +240,12 @@ * ******************************************************************************/ -s32 +u32 acpi_aml_digits_needed ( - s32 val, - s32 base) + u32 val, + u32 base) { - s32 num_digits = 0; + u32 num_digits = 0; if (base < 1) { @@ -309,13 +279,13 @@ union { u32 value; - char bytes[4]; + u8 bytes[4]; } out; union { u32 value; - char bytes[4]; + u8 bytes[4]; } in; @@ -326,7 +296,7 @@ out.bytes[2] = in.bytes[1]; out.bytes[3] = in.bytes[0]; - return out.value; + return (out.value); } @@ -344,7 +314,7 @@ ACPI_STATUS acpi_aml_eisa_id_to_string ( u32 numeric_id, - char *out_string) + NATIVE_CHAR *out_string) { u32 id; @@ -361,7 +331,7 @@ out_string[6] = hex[id & 0xf]; out_string[7] = 0; - return AE_OK; + return (AE_OK); } @@ -381,16 +351,17 @@ ACPI_STATUS acpi_aml_build_copy_internal_package_object ( - ACPI_OBJECT_INTERNAL *source_obj, - ACPI_OBJECT_INTERNAL *dest_obj) + ACPI_OPERAND_OBJECT *source_obj, + ACPI_OPERAND_OBJECT *dest_obj, + ACPI_WALK_STATE *walk_state) { u32 current_depth = 0; ACPI_STATUS status = AE_OK; u32 length = 0; u32 this_index; u32 object_space = 0; - ACPI_OBJECT_INTERNAL *this_dest_obj; - ACPI_OBJECT_INTERNAL *this_source_obj; + ACPI_OPERAND_OBJECT *this_dest_obj; + ACPI_OPERAND_OBJECT *this_source_obj; INTERNAL_PKG_SEARCH_INFO *level_ptr; @@ -429,8 +400,8 @@ while (1) { this_index = level_ptr->index; - this_dest_obj = (ACPI_OBJECT_INTERNAL *) level_ptr->dest_obj->package.elements[this_index]; - this_source_obj = (ACPI_OBJECT_INTERNAL *) level_ptr->source_obj->package.elements[this_index]; + this_dest_obj = (ACPI_OPERAND_OBJECT *) level_ptr->dest_obj->package.elements[this_index]; + this_source_obj = (ACPI_OPERAND_OBJECT *) level_ptr->source_obj->package.elements[this_index]; if (IS_THIS_OBJECT_TYPE (this_source_obj, ACPI_TYPE_PACKAGE)) { /* @@ -458,7 +429,7 @@ * update the buffer length counter */ object_space = this_dest_obj->package.count * - sizeof (ACPI_OBJECT_INTERNAL); + sizeof (ACPI_OPERAND_OBJECT); length += object_space; current_depth++; level_ptr = ©_level[current_depth]; @@ -474,9 +445,9 @@ this_source_obj->common.type); level_ptr->dest_obj->package.elements[this_index] = this_dest_obj; - status = acpi_aml_store_object_to_object(this_source_obj, this_dest_obj); + status = acpi_aml_store_object_to_object(this_source_obj, this_dest_obj, walk_state); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { /* * Failure get out */ @@ -511,12 +482,6 @@ } } /* else object is NOT a package */ } /* while (1) */ - - - /* - * We'll never get here, but the compiler whines about return value - */ - return (AE_OK); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/interpreter/amxface.c linux/drivers/acpi/interpreter/amxface.c --- v2.4.0-test8/linux/drivers/acpi/interpreter/amxface.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/interpreter/amxface.c Fri Sep 15 14:30:30 2000 @@ -1,7 +1,8 @@ /****************************************************************************** * - * Module Name: ixface - External interpreter interfaces + * Module Name: amxface - External interpreter interfaces + * $Revision: 22 $ * *****************************************************************************/ @@ -25,11 +26,11 @@ #include "acpi.h" -#include "interp.h" +#include "acinterp.h" #define _COMPONENT INTERPRETER - MODULE_NAME ("amxface"); + MODULE_NAME ("amxface") /* @@ -48,8 +49,8 @@ #define DEFINE_AML_GLOBALS #include "amlcode.h" -#include "parser.h" -#include "namesp.h" +#include "acparser.h" +#include "acnamesp.h" /******************************************************************************* @@ -70,9 +71,9 @@ ACPI_STATUS acpi_aml_execute_method ( - ACPI_NAMED_OBJECT *method_entry, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **return_obj_desc) + ACPI_NAMESPACE_NODE *method_node, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **return_obj_desc) { ACPI_STATUS status; @@ -84,7 +85,7 @@ acpi_aml_enter_interpreter (); - status = acpi_psx_execute (method_entry, params, return_obj_desc); + status = acpi_psx_execute (method_node, params, return_obj_desc); acpi_aml_exit_interpreter (); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/namespace/Makefile linux/drivers/acpi/namespace/Makefile --- v2.4.0-test8/linux/drivers/acpi/namespace/Makefile Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/namespace/Makefile Fri Sep 15 18:21:44 2000 @@ -0,0 +1,28 @@ +# +# Makefile for all Linux ACPI interpreter subdirectories +# + +SUB_DIRS := +MOD_SUB_DIRS := $(SUB_DIRS) +MOD_IN_SUB_DIRS := +ALL_SUB_DIRS := $(SUB_DIRS) + +O_TARGET := ../$(shell basename `pwd`).o +O_OBJS := +M_OBJS := + +ACPI_OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) + +EXTRA_CFLAGS += -I../include + +EXTRA_CFLAGS += $(ACPI_CFLAGS) + +# if the interpreter is used, it overrides arch/i386/kernel/acpi.c +ifeq ($(CONFIG_ACPI_INTERPRETER),y) + O_OBJS := $(ACPI_OBJS) +endif + +include $(TOPDIR)/Rules.make + +clean: + $(RM) *.o diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/namespace/nsaccess.c linux/drivers/acpi/namespace/nsaccess.c --- v2.4.0-test8/linux/drivers/acpi/namespace/nsaccess.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/namespace/nsaccess.c Fri Sep 15 14:30:30 2000 @@ -1,9 +1,9 @@ - -/****************************************************************************** +/******************************************************************************* * * Module Name: nsaccess - Top-level functions for accessing ACPI namespace + * $Revision: 108 $ * - *****************************************************************************/ + ******************************************************************************/ /* * Copyright (C) 2000 R. Byron Moore @@ -26,59 +26,16 @@ #include "acpi.h" #include "amlcode.h" -#include "interp.h" -#include "namesp.h" -#include "dispatch.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdispat.h" #define _COMPONENT NAMESPACE - MODULE_NAME ("nsaccess"); + MODULE_NAME ("nsaccess") -/**************************************************************************** - * - * FUNCTION: Acpi_ns_root_create_scope - * - * PARAMETERS: Entry - NTE for which a scope will be created - * - * RETURN: Status - * - * DESCRIPTION: Create a scope table for the given name table entry - * - * MUTEX: Expects namespace to be locked - * - ***************************************************************************/ - -ACPI_STATUS -acpi_ns_root_create_scope ( - ACPI_NAMED_OBJECT *entry) -{ - - /* Allocate a scope table */ - - if (entry->child_table) { - return (AE_EXIST); - } - - entry->child_table = acpi_ns_allocate_name_table (NS_TABLE_SIZE); - if (!entry->child_table) { - /* root name table allocation failure */ - - REPORT_ERROR ("Root name table allocation failure"); - return (AE_NO_MEMORY); - } - - /* - * Init the scope first entry -- since it is the exemplar of - * the scope (Some fields are duplicated to new entries!) - */ - acpi_ns_initialize_table (entry->child_table, NULL, entry); - return (AE_OK); - -} - - -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_root_initialize * @@ -86,40 +43,41 @@ * * RETURN: Status * - * DESCRIPTION: Allocate and initialize the root name table + * DESCRIPTION: Allocate and initialize the default root named objects * * MUTEX: Locks namespace for entire execution * - ***************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ns_root_initialize (void) { ACPI_STATUS status = AE_OK; PREDEFINED_NAMES *init_val = NULL; - ACPI_NAMED_OBJECT *new_entry; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_NAMESPACE_NODE *new_node; + ACPI_OPERAND_OBJECT *obj_desc; acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); /* - * Root is initially NULL, so a non-NULL value indicates + * The global root ptr is initially NULL, so a non-NULL value indicates * that Acpi_ns_root_initialize() has already been called; just return. */ - if (acpi_gbl_root_object->child_table) { + if (acpi_gbl_root_node) { status = AE_OK; goto unlock_and_exit; } - /* Create the root scope */ + /* + * Tell the rest of the subsystem that the root is initialized + * (This is OK because the namespace is locked) + */ + + acpi_gbl_root_node = &acpi_gbl_root_node_struct; - status = acpi_ns_root_create_scope (acpi_gbl_root_object); - if (ACPI_FAILURE (status)) { - goto unlock_and_exit; - } /* Enter the pre-defined names in the name table */ @@ -127,25 +85,25 @@ status = acpi_ns_lookup (NULL, init_val->name, (OBJECT_TYPE_INTERNAL) init_val->type, IMODE_LOAD_PASS2, NS_NO_UPSEARCH, - NULL, &new_entry); + NULL, &new_node); + + if (ACPI_FAILURE (status) || + (!new_node)) /* - * if name entered successfully - * && its entry in Pre_defined_names[] specifies an - * initial value + * Name entered successfully. + * If entry in Pre_defined_names[] specifies an + * initial value, create the initial value. */ - if ((status == AE_OK) && - new_entry && init_val->val) - { + if (init_val->val) { /* * Entry requests an initial value, allocate a * descriptor for it. */ - obj_desc = - acpi_cm_create_internal_object ( - (OBJECT_TYPE_INTERNAL) init_val->type); + obj_desc = acpi_cm_create_internal_object ( + (OBJECT_TYPE_INTERNAL) init_val->type); if (!obj_desc) { status = AE_NO_MEMORY; @@ -164,23 +122,22 @@ case ACPI_TYPE_NUMBER: obj_desc->number.value = - (u32) STRTOUL (init_val->val, NULL, 10); + (u32) STRTOUL (init_val->val, NULL, 10); break; case ACPI_TYPE_STRING: obj_desc->string.length = - (u16) STRLEN (init_val->val); + (u16) STRLEN (init_val->val); /* * Allocate a buffer for the string. All * String.Pointers must be allocated buffers! * (makes deletion simpler) */ - obj_desc->string.pointer = - acpi_cm_allocate ((ACPI_SIZE) - (obj_desc->string.length + 1)); + obj_desc->string.pointer = acpi_cm_allocate ( + (obj_desc->string.length + 1)); if (!obj_desc->string.pointer) { REPORT_ERROR ("Initial value string" @@ -191,24 +148,22 @@ goto unlock_and_exit; } - STRCPY ((char *) obj_desc->string.pointer, - init_val->val); + STRCPY (obj_desc->string.pointer, init_val->val); break; case ACPI_TYPE_MUTEX: obj_desc->mutex.sync_level = - (u16) STRTOUL (init_val->val, NULL, 10); + (u16) STRTOUL (init_val->val, NULL, 10); if (STRCMP (init_val->name, "_GL_") == 0) { /* * Create a counting semaphore for the * global lock */ - status = - acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, - 1, &obj_desc->mutex.semaphore); + status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, + 1, &obj_desc->mutex.semaphore); if (ACPI_FAILURE (status)) { goto unlock_and_exit; @@ -218,8 +173,7 @@ * global lock, save it */ - acpi_gbl_global_lock_semaphore = - obj_desc->mutex.semaphore; + acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore; } else { @@ -232,11 +186,6 @@ goto unlock_and_exit; } } - - /* TBD: [Restructure] These fields may be obsolete */ - - obj_desc->mutex.lock_count = 0; - obj_desc->mutex.thread_id = 0; break; @@ -247,9 +196,9 @@ continue; } - /* Store pointer to value descriptor in nte */ + /* Store pointer to value descriptor in the Node */ - acpi_ns_attach_object (new_entry, obj_desc, + acpi_ns_attach_object (new_node, obj_desc, obj_desc->common.type); } } @@ -261,16 +210,19 @@ } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_lookup * - * PARAMETERS: Prefix_scope - Search scope if name is not fully qualified + * PARAMETERS: Prefix_node - Search scope if name is not fully qualified * Pathname - Search pathname, in internal format * (as represented in the AML stream) * Type - Type associated with name * Interpreter_mode - IMODE_LOAD_PASS2 => add name if not found - * Ret_entry - Where the new entry (NTE) is placed + * Flags - Flags describing the search restrictions + * Walk_state - Current state of the walk + * Return_node - Where the Node is placed (if found + * or created successfully) * * RETURN: Status * @@ -279,55 +231,42 @@ * * MUTEX: Assumes namespace is locked. * - ***************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ns_lookup ( ACPI_GENERIC_STATE *scope_info, - char *pathname, + NATIVE_CHAR *pathname, OBJECT_TYPE_INTERNAL type, OPERATING_MODE interpreter_mode, u32 flags, ACPI_WALK_STATE *walk_state, - ACPI_NAMED_OBJECT **ret_entry) + ACPI_NAMESPACE_NODE **return_node) { ACPI_STATUS status; - ACPI_NAME_TABLE *prefix_scope; - ACPI_NAME_TABLE *table_to_search = NULL; - ACPI_NAME_TABLE *scope_to_push = NULL; - ACPI_NAMED_OBJECT *this_entry = NULL; + ACPI_NAMESPACE_NODE *prefix_node; + ACPI_NAMESPACE_NODE *current_node = NULL; + ACPI_NAMESPACE_NODE *scope_to_push = NULL; + ACPI_NAMESPACE_NODE *this_node = NULL; u32 num_segments; ACPI_NAME simple_name; u8 null_name_path = FALSE; OBJECT_TYPE_INTERNAL type_to_check_for; OBJECT_TYPE_INTERNAL this_search_type; - if (!ret_entry) { + if (!return_node) { return (AE_BAD_PARAMETER); } acpi_gbl_ns_lookup_count++; - *ret_entry = ENTRY_NOT_FOUND; - if (!acpi_gbl_root_object->child_table) { - /* - * If the name space has not been initialized: - * - In Pass1 of Load mode, we need to initialize it - * before trying to define a name. - * - In Exec mode, there are no names to be found. - */ + *return_node = ENTRY_NOT_FOUND; - if (IMODE_LOAD_PASS1 == interpreter_mode) { - if ((status = acpi_ns_root_initialize ()) != AE_OK) { - return (status); - } - } - else { - return (AE_NOT_FOUND); - } - } + if (!acpi_gbl_root_node) { + return (AE_NO_NAMESPACE); + } /* * Get the prefix scope. @@ -335,12 +274,12 @@ */ if ((!scope_info) || - (!scope_info->scope.name_table)) + (!scope_info->scope.node)) { - prefix_scope = acpi_gbl_root_object->child_table; + prefix_node = acpi_gbl_root_node; } else { - prefix_scope = scope_info->scope.name_table; + prefix_node = scope_info->scope.node; } @@ -369,6 +308,8 @@ } + /* TBD: [Restructure] - Move the pathname stuff into a new procedure */ + /* Examine the name pointer */ if (!pathname) { @@ -376,7 +317,7 @@ null_name_path = TRUE; num_segments = 0; - this_entry = acpi_gbl_root_object; + this_node = acpi_gbl_root_node; } @@ -403,14 +344,16 @@ if (*pathname == AML_ROOT_PREFIX) { /* Pathname is fully qualified, look in root name table */ - table_to_search = acpi_gbl_root_object->child_table; + current_node = acpi_gbl_root_node; + /* point to segment part */ + pathname++; /* Direct reference to root, "\" */ if (!(*pathname)) { - this_entry = acpi_gbl_root_object; + this_node = acpi_gbl_root_node; goto check_for_new_scope_and_exit; } } @@ -418,7 +361,7 @@ else { /* Pathname is relative to current scope, start there */ - table_to_search = prefix_scope; + current_node = prefix_node; /* * Handle up-prefix (carat). More than one prefix @@ -426,23 +369,22 @@ */ while (*pathname == AML_PARENT_PREFIX) { - /* Point to segment part or next Parent_prefix */ pathname++; /* Backup to the parent's scope */ - table_to_search = table_to_search->parent_table; - if (!table_to_search) { + this_node = acpi_ns_get_parent_object (current_node); + if (!this_node) { /* Current scope has no parent scope */ - REPORT_ERROR ("Ns_lookup: Too many parent" - "prefixes or scope has no parent"); - + REPORT_ERROR ("Too many parent prefixes (^) - reached root"); return (AE_NOT_FOUND); } + + current_node = this_node; } } @@ -454,14 +396,18 @@ if (*pathname == AML_DUAL_NAME_PREFIX) { num_segments = 2; + /* point to first segment */ + pathname++; } else if (*pathname == AML_MULTI_NAME_PREFIX_OP) { - num_segments = (s32)* (u8 *) ++pathname; + num_segments = (u32)* (u8 *) ++pathname; + /* point to first segment */ + pathname++; } @@ -484,32 +430,32 @@ */ - while (num_segments-- && table_to_search) { + while (num_segments-- && current_node) { /* - * Search for the current segment in the table where - * it should be. - * Type is significant only at the last (topmost) level. + * Search for the current name segment under the current + * named object. The Type is significant only at the last (topmost) + * level. (We don't care about the types along the path, only + * the type of the final target object.) */ this_search_type = ACPI_TYPE_ANY; if (!num_segments) { this_search_type = type; } + /* Pluck and ACPI name from the front of the pathname */ + MOVE_UNALIGNED32_TO_32 (&simple_name, pathname); + + /* Try to find the ACPI name */ + status = acpi_ns_search_and_enter (simple_name, walk_state, - table_to_search, interpreter_mode, + current_node, interpreter_mode, this_search_type, flags, - &this_entry); + &this_node); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { if (status == AE_NOT_FOUND) { - /* Name not in ACPI namespace */ - - if (IMODE_LOAD_PASS1 == interpreter_mode || - IMODE_LOAD_PASS2 == interpreter_mode) - { - REPORT_ERROR ("Name table overflow"); - } + /* Name not found in ACPI namespace */ } @@ -518,92 +464,54 @@ /* - * If 1) last segment (Num_segments == 0) + * If 1) This is the last segment (Num_segments == 0) * 2) and looking for a specific type * (Not checking for TYPE_ANY) * 3) which is not a local type (TYPE_DEF_ANY) * 4) which is not a local type (TYPE_SCOPE) * 5) which is not a local type (TYPE_INDEX_FIELD_DEFN) - * 6) and type of entry is known (not TYPE_ANY) - * 7) and entry does not match request + * 6) and type of object is known (not TYPE_ANY) + * 7) and object does not match request * * Then we have a type mismatch. Just warn and ignore it. */ - if ((num_segments == 0) && - (type_to_check_for != ACPI_TYPE_ANY) && - (type_to_check_for != INTERNAL_TYPE_DEF_ANY) && - (type_to_check_for != INTERNAL_TYPE_SCOPE) && - (type_to_check_for != INTERNAL_TYPE_INDEX_FIELD_DEFN) && - (this_entry->type != ACPI_TYPE_ANY) && - (this_entry->type != type_to_check_for)) + if ((num_segments == 0) && + (type_to_check_for != ACPI_TYPE_ANY) && + (type_to_check_for != INTERNAL_TYPE_DEF_ANY) && + (type_to_check_for != INTERNAL_TYPE_SCOPE) && + (type_to_check_for != INTERNAL_TYPE_INDEX_FIELD_DEFN) && + (this_node->type != ACPI_TYPE_ANY) && + (this_node->type != type_to_check_for)) { - /* Complain about type mismatch */ + /* Complain about a type mismatch */ REPORT_WARNING ("Type mismatch"); } /* - * If last segment and not looking for a specific type, but type of - * found entry is known, use that type to see if it opens a scope. + * If this is the last name segment and we are not looking for a + * specific type, but the type of found object is known, use that type + * to see if it opens a scope. */ if ((0 == num_segments) && (ACPI_TYPE_ANY == type)) { - type = this_entry->type; + type = this_node->type; } if ((num_segments || acpi_ns_opens_scope (type)) && - (this_entry->child_table == NULL)) + (this_node->child == NULL)) { /* * More segments or the type implies enclosed scope, * and the next scope has not been allocated. */ - if ((IMODE_LOAD_PASS1 == interpreter_mode) || - (IMODE_LOAD_PASS2 == interpreter_mode)) - { - /* - * First or second pass load mode - * ==> locate the next scope - */ - - this_entry->child_table = - acpi_ns_allocate_name_table (NS_TABLE_SIZE); - - if (!this_entry->child_table) { - return (AE_NO_MEMORY); - } - } - - /* Now complain if there is no next scope */ - - if (this_entry->child_table == NULL) { - if (IMODE_LOAD_PASS1 == interpreter_mode || - IMODE_LOAD_PASS2 == interpreter_mode) - { - REPORT_ERROR ("Name Table allocation failure"); - return (AE_NOT_FOUND); - } - - return (AE_NOT_FOUND); - } - - - /* Scope table initialization */ - - if (IMODE_LOAD_PASS1 == interpreter_mode || - IMODE_LOAD_PASS2 == interpreter_mode) - { - /* Initialize the new table */ - - acpi_ns_initialize_table (this_entry->child_table, - table_to_search, - this_entry); - } } - table_to_search = this_entry->child_table; + current_node = this_node; + /* point to next name segment */ + pathname += ACPI_NAME_SIZE; } @@ -629,7 +537,7 @@ scope_to_push = NULL; } else { - scope_to_push = this_entry->child_table; + scope_to_push = this_node; } status = acpi_ds_scope_stack_push (scope_to_push, type, @@ -641,7 +549,7 @@ } } - *ret_entry = this_entry; + *return_node = this_node; return (AE_OK); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/namespace/nsalloc.c linux/drivers/acpi/namespace/nsalloc.c --- v2.4.0-test8/linux/drivers/acpi/namespace/nsalloc.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/namespace/nsalloc.c Fri Sep 15 14:30:30 2000 @@ -1,9 +1,9 @@ - -/****************************************************************************** +/******************************************************************************* * * Module Name: nsalloc - Namespace allocation and deletion utilities + * $Revision: 41 $ * - *****************************************************************************/ + ******************************************************************************/ /* * Copyright (C) 2000 R. Byron Moore @@ -25,46 +25,303 @@ #include "acpi.h" -#include "namesp.h" -#include "interp.h" +#include "acnamesp.h" +#include "acinterp.h" #define _COMPONENT NAMESPACE - MODULE_NAME ("nsalloc"); + MODULE_NAME ("nsalloc") + + +/******************************************************************************* + * + * FUNCTION: Acpi_ns_create_node + * + * PARAMETERS: + * + * RETURN: None + * + * DESCRIPTION: + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +acpi_ns_create_node ( + u32 acpi_name) +{ + ACPI_NAMESPACE_NODE *node; + + + node = acpi_cm_callocate (sizeof (ACPI_NAMESPACE_NODE)); + if (!node) { + return (NULL); + } + + INCREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); + + node->data_type = ACPI_DESC_TYPE_NAMED; + node->name = acpi_name; + node->reference_count = 1; + + return (node); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_ns_delete_node + * + * PARAMETERS: + * + * RETURN: None + * + * DESCRIPTION: + * + ******************************************************************************/ + +void +acpi_ns_delete_node ( + ACPI_NAMESPACE_NODE *node) +{ + ACPI_NAMESPACE_NODE *parent_node; + ACPI_NAMESPACE_NODE *prev_node; + ACPI_NAMESPACE_NODE *next_node; + + + parent_node = acpi_ns_get_parent_object (node); + + prev_node = NULL; + next_node = parent_node->child; + + while (next_node != node) { + prev_node = next_node; + next_node = prev_node->peer; + } + + if (prev_node) { + prev_node->peer = next_node->peer; + if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { + prev_node->flags |= ANOBJ_END_OF_PEER_LIST; + } + } + else { + parent_node->child = next_node->peer; + } + + + DECREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); + + /* + * Detach an object if there is one + */ + + if (node->object) { + acpi_ns_detach_object (node); + } + + acpi_cm_free (node); + + + return; +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_ns_install_node + * + * PARAMETERS: Walk_state - Current state of the walk + * Parent_node - The parent of the new Node + * Node - The new Node to install + * Type - ACPI object type of the new Node + * + * RETURN: None + * + * DESCRIPTION: Initialize a new entry within a namespace table. + * + ******************************************************************************/ + +void +acpi_ns_install_node ( + ACPI_WALK_STATE *walk_state, + ACPI_NAMESPACE_NODE *parent_node, /* Parent */ + ACPI_NAMESPACE_NODE *node, /* New Child*/ + OBJECT_TYPE_INTERNAL type) +{ + u16 owner_id = TABLE_ID_DSDT; + ACPI_NAMESPACE_NODE *child_node; + + + /* + * Get the owner ID from the Walk state + * The owner ID is used to track table deletion and + * deletion of objects created by methods + */ + if (walk_state) { + owner_id = walk_state->owner_id; + } + + + /* link the new entry into the parent and existing children */ + + /* TBD: Could be first, last, or alphabetic */ + + child_node = parent_node->child; + if (!child_node) { + parent_node->child = node; + } + + else { + while (!(child_node->flags & ANOBJ_END_OF_PEER_LIST)) { + child_node = child_node->peer; + } + + child_node->peer = node; + + /* Clear end-of-list flag */ + + child_node->flags &= ~ANOBJ_END_OF_PEER_LIST; + } + + /* Init the new entry */ + + node->owner_id = owner_id; + node->flags |= ANOBJ_END_OF_PEER_LIST; + node->peer = parent_node; + + + /* + * If adding a name with unknown type, or having to + * add the region in order to define fields in it, we + * have a forward reference. + */ + + if ((ACPI_TYPE_ANY == type) || + (INTERNAL_TYPE_DEF_FIELD_DEFN == type) || + (INTERNAL_TYPE_BANK_FIELD_DEFN == type)) + { + /* + * We don't want to abort here, however! + * We will fill in the actual type when the + * real definition is found later. + */ + + } + + /* + * The Def_field_defn and Bank_field_defn cases are actually + * looking up the Region in which the field will be defined + */ + + if ((INTERNAL_TYPE_DEF_FIELD_DEFN == type) || + (INTERNAL_TYPE_BANK_FIELD_DEFN == type)) + { + type = ACPI_TYPE_REGION; + } + + /* + * Scope, Def_any, and Index_field_defn are bogus "types" which do + * not actually have anything to do with the type of the name + * being looked up. Save any other value of Type as the type of + * the entry. + */ + + if ((type != INTERNAL_TYPE_SCOPE) && + (type != INTERNAL_TYPE_DEF_ANY) && + (type != INTERNAL_TYPE_INDEX_FIELD_DEFN)) + { + node->type = (u8) type; + } + + /* + * Increment the reference count(s) of all parents up to + * the root! + */ + + while ((node = acpi_ns_get_parent_object (node)) != NULL) { + node->reference_count++; + } + + return; +} -/**************************************************************************** +/******************************************************************************* * - * FUNCTION: Acpi_ns_allocate_name_table + * FUNCTION: Acpi_ns_delete_children * - * PARAMETERS: Nte_count - Count of NTEs to allocate + * PARAMETERS: Parent_node - Delete this objects children * - * RETURN: The address of the first nte in the array, or NULL + * RETURN: None. * - * DESCRIPTION: Allocate an array of nte, including prepended link space - * Array is set to all zeros via Acpi_os_callcate(). + * DESCRIPTION: Delete all children of the parent object. Deletes a + * "scope". * - ***************************************************************************/ + ******************************************************************************/ -ACPI_NAME_TABLE * -acpi_ns_allocate_name_table ( - u32 num_entries) +void +acpi_ns_delete_children ( + ACPI_NAMESPACE_NODE *parent_node) { - ACPI_NAME_TABLE *name_table = NULL; - ACPI_SIZE alloc_size; + ACPI_NAMESPACE_NODE *child_node; + ACPI_NAMESPACE_NODE *next_node; + u8 flags; + + + if (!parent_node) { + return; + } + + /* If no children, all done! */ + + child_node = parent_node->child; + if (!child_node) { + return; + } + + /* + * Deallocate all children at this level + */ + do + { + /* Get the things we need */ + + next_node = child_node->peer; + flags = child_node->flags; + + /* Grandchildren should have all been deleted already */ + + /* Now we can free this child object */ - alloc_size = sizeof (ACPI_NAME_TABLE) + ((num_entries - 1) * - sizeof (ACPI_NAMED_OBJECT)); + DECREMENT_NAME_TABLE_METRICS (sizeof (ACPI_NAMESPACE_NODE)); - name_table = acpi_cm_callocate (alloc_size); + /* + * Detach an object if there is one + */ + + if (child_node->object) { + acpi_ns_detach_object (child_node); + } + + acpi_cm_free (child_node); + + /* And move on to the next child in the list */ + + child_node = next_node; + } while (!(flags & ANOBJ_END_OF_PEER_LIST)); - return (name_table); + + /* Clear the parent's child pointer */ + + parent_node->child = NULL; + + return; } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_delete_namespace_subtree * @@ -72,22 +329,27 @@ * * RETURN: None. * - * DESCRIPTION: Delete a subtree of the namespace. This includes all objects stored - * within the subtree. Scope tables are deleted also + * DESCRIPTION: Delete a subtree of the namespace. This includes all objects + * stored within the subtree. Scope tables are deleted also * - ***************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ns_delete_namespace_subtree ( - ACPI_NAMED_OBJECT *parent_entry) + ACPI_NAMESPACE_NODE *parent_node) { - ACPI_NAMED_OBJECT *child_entry; + ACPI_NAMESPACE_NODE *child_node; + ACPI_OPERAND_OBJECT *obj_desc; u32 level; - ACPI_OBJECT_INTERNAL *obj_desc; - child_entry = 0; - level = 1; + if (!parent_node) { + return (AE_OK); + } + + + child_node = 0; + level = 1; /* * Traverse the tree of objects until we bubble back up @@ -100,53 +362,32 @@ * Null returned if not found */ - child_entry = acpi_ns_get_next_object (ACPI_TYPE_ANY, - parent_entry, - child_entry); - - if (child_entry) { + child_node = acpi_ns_get_next_object (ACPI_TYPE_ANY, parent_node, + child_node); + if (child_node) { /* * Found an object - delete the object within * the Value field */ - obj_desc = acpi_ns_get_attached_object (child_entry); + obj_desc = acpi_ns_get_attached_object (child_node); if (obj_desc) { - acpi_ns_detach_object (child_entry); + acpi_ns_detach_object (child_node); acpi_cm_remove_reference (obj_desc); } - /* - * Clear the NTE in case this scope is reused - * (e.g., a control method scope) - */ - - child_entry->type = ACPI_TYPE_ANY; - child_entry->name = 0; - /* Check if this object has any children */ - if (acpi_ns_get_next_object (ACPI_TYPE_ANY, child_entry, 0)) { + if (acpi_ns_get_next_object (ACPI_TYPE_ANY, child_node, 0)) { /* * There is at least one child of this object, * visit the object */ level++; - parent_entry = child_entry; - child_entry = 0; - } - - else { - /* - * There may be a name table even if there are - * no children - */ - - acpi_ns_delete_name_table (child_entry->child_table); - child_entry->child_table = NULL; - + parent_node = child_node; + child_node = 0; } } @@ -158,26 +399,18 @@ level--; /* - * Delete the scope (Name Table) associated with - * the parent object + * Now delete all of the children of this parent + * all at the same time. */ - /* Don't delete the top level scope, this allows - * the dynamic deletion of objects created underneath - * control methods! - */ - - if (level != 0) { - acpi_ns_delete_name_table (parent_entry->child_table); - parent_entry->child_table = NULL; - } + acpi_ns_delete_children (parent_node); /* New "last child" is this parent object */ - child_entry = parent_entry; + child_node = parent_node; /* Now we can move up the tree to the grandparent */ - parent_entry = acpi_ns_get_parent_entry (parent_entry); + parent_node = acpi_ns_get_parent_object (parent_node); } } @@ -186,70 +419,55 @@ } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_remove_reference * - * PARAMETERS: Entry - NTE whose reference count is to be decremented + * PARAMETERS: Node - Named object whose reference count is to be + * decremented * * RETURN: None. * - * DESCRIPTION: Remove an NTE reference. Decrements the reference count of - * all parent NTEs up to the root. Any NTE along the way that - * reaches zero references is freed. + * DESCRIPTION: Remove a Node reference. Decrements the reference count + * of all parent Nodes up to the root. Any object along + * the way that reaches zero references is freed. * - ***************************************************************************/ + ******************************************************************************/ void acpi_ns_remove_reference ( - ACPI_NAMED_OBJECT *entry) + ACPI_NAMESPACE_NODE *node) { - ACPI_NAMED_OBJECT *this_entry; - - - /* There may be a name table even if there are no children */ - - acpi_ns_delete_name_table (entry->child_table); - entry->child_table = NULL; + ACPI_NAMESPACE_NODE *next_node; /* - * Decrement the reference count(s) of all parents up to the root, - * And delete anything with zero remaining references. + * Decrement the reference count(s) of this object and all + * objects up to the root, Delete anything with zero remaining references. */ - this_entry = entry; - while (this_entry) { - /* Decrement the reference */ + next_node = node; + while (next_node) { + /* Decrement the reference count on this object*/ - this_entry->reference_count--; + next_node->reference_count--; - /* Delete entry if no more references */ - - if (!this_entry->reference_count) { - /* Delete the scope if present */ - - if (this_entry->child_table) { - acpi_ns_delete_name_table (this_entry->child_table); - this_entry->child_table = NULL; - } - - /* - * Mark the entry free - * (This doesn't deallocate anything) - */ + /* Delete the object if no more references */ - acpi_ns_free_table_entry (this_entry); + if (!next_node->reference_count) { + /* Delete all children and delete the object */ + acpi_ns_delete_children (next_node); + acpi_ns_delete_node (next_node); } /* Move up to parent */ - this_entry = acpi_ns_get_parent_entry (this_entry); + next_node = acpi_ns_get_parent_object (next_node); } } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_delete_namespace_by_owner * @@ -261,21 +479,21 @@ * specific ID. Used to delete entire ACPI tables. All * reference counts are updated. * - ***************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ns_delete_namespace_by_owner ( u16 owner_id) { - ACPI_NAMED_OBJECT *child_entry; + ACPI_NAMESPACE_NODE *child_node; u32 level; - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_NAMED_OBJECT *parent_entry; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_NAMESPACE_NODE *parent_node; - parent_entry = acpi_gbl_root_object; - child_entry = 0; - level = 1; + parent_node = acpi_gbl_root_node; + child_node = 0; + level = 1; /* * Traverse the tree of objects until we bubble back up @@ -288,124 +506,65 @@ * Null returned if not found */ - child_entry = acpi_ns_get_next_object (ACPI_TYPE_ANY, - parent_entry, - child_entry); + child_node = acpi_ns_get_next_object (ACPI_TYPE_ANY, parent_node, + child_node); - if (child_entry) { - if (child_entry->owner_id == owner_id) { + if (child_node) { + if (child_node->owner_id == owner_id) { /* * Found an object - delete the object within * the Value field */ - obj_desc = acpi_ns_get_attached_object (child_entry); + obj_desc = acpi_ns_get_attached_object (child_node); if (obj_desc) { - acpi_ns_detach_object (child_entry); + acpi_ns_detach_object (child_node); acpi_cm_remove_reference (obj_desc); } } /* Check if this object has any children */ - if (acpi_ns_get_next_object (ACPI_TYPE_ANY, child_entry, 0)) { + if (acpi_ns_get_next_object (ACPI_TYPE_ANY, child_node, 0)) { /* * There is at least one child of this object, * visit the object */ level++; - parent_entry = child_entry; - child_entry = 0; + parent_node = child_node; + child_node = 0; } - else if (child_entry->owner_id == owner_id) { - acpi_ns_remove_reference (child_entry); + else if (child_node->owner_id == owner_id) { + acpi_ns_remove_reference (child_node); } } else { /* - * No more children in this object. - * We will move up to the grandparent. + * No more children in this object. Move up to grandparent. */ level--; - /* - * Delete the scope (Name Table) associated with - * the parent object - */ - /* Don't delete the top level scope, this allows - * the dynamic deletion of objects created underneath - * control methods! - */ - - if (level != 0) { - if (parent_entry->owner_id == owner_id) { - acpi_ns_remove_reference (parent_entry); + if (parent_node->owner_id == owner_id) { + acpi_ns_remove_reference (parent_node); } } - /* New "last child" is this parent object */ - child_entry = parent_entry; + child_node = parent_node; /* Now we can move up the tree to the grandparent */ - parent_entry = acpi_ns_get_parent_entry (parent_entry); + parent_node = acpi_ns_get_parent_object (parent_node); } } return (AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_delete_name_table - * - * PARAMETERS: Scope - A handle to the scope to be deleted - * - * RETURN: None. - * - * DESCRIPTION: Delete a namespace Name Table with zero or - * more appendages. The table and all appendages are deleted. - * - ***************************************************************************/ - -void -acpi_ns_delete_name_table ( - ACPI_NAME_TABLE *name_table) -{ - ACPI_NAME_TABLE *this_table; - ACPI_NAME_TABLE *next_table; - - - if (!name_table) { - return; - } - - this_table = name_table; - - - /* - * Deallocate the name table and all appendages - */ - do - { - next_table = this_table->next_table; - - /* Now we can free the table */ - - acpi_cm_free (this_table); - this_table = next_table; - - } while (this_table); - - return; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/namespace/nsdump.c linux/drivers/acpi/namespace/nsdump.c --- v2.4.0-test8/linux/drivers/acpi/namespace/nsdump.c Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/namespace/nsdump.c Fri Sep 15 14:30:30 2000 @@ -0,0 +1,36 @@ +/****************************************************************************** + * + * Module Name: nsdump - table dumping routines for debug + * $Revision: 78 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + + +#include "acpi.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" + + +#define _COMPONENT NAMESPACE + MODULE_NAME ("nsdump") + + diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/namespace/nseval.c linux/drivers/acpi/namespace/nseval.c --- v2.4.0-test8/linux/drivers/acpi/namespace/nseval.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/namespace/nseval.c Fri Sep 15 14:30:30 2000 @@ -1,10 +1,10 @@ - -/****************************************************************************** +/******************************************************************************* * * Module Name: nseval - Object evaluation interfaces -- includes control * method lookup and execution. + * $Revision: 76 $ * - *****************************************************************************/ + ******************************************************************************/ /* * Copyright (C) 2000 R. Byron Moore @@ -27,20 +27,20 @@ #include "acpi.h" #include "amlcode.h" -#include "parser.h" -#include "interp.h" -#include "namesp.h" +#include "acparser.h" +#include "acinterp.h" +#include "acnamesp.h" #define _COMPONENT NAMESPACE - MODULE_NAME ("nseval"); + MODULE_NAME ("nseval") -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_evaluate_relative * - * PARAMETERS: Rel_obj_entry - NTE of the relative containing object + * PARAMETERS: Handle - The relative containing object * *Pathname - Name of method to execute, If NULL, the * handle is the object to execute * **Params - List of parameters to pass to the method, @@ -56,19 +56,19 @@ * * MUTEX: Locks Namespace * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ns_evaluate_relative ( - ACPI_NAMED_OBJECT *handle, - char *pathname, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **return_object) + ACPI_NAMESPACE_NODE *handle, + NATIVE_CHAR *pathname, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **return_object) { - ACPI_NAMED_OBJECT *rel_obj_entry; + ACPI_NAMESPACE_NODE *prefix_node; ACPI_STATUS status; - ACPI_NAMED_OBJECT *obj_entry = NULL; - char *internal_path = NULL; + ACPI_NAMESPACE_NODE *node = NULL; + NATIVE_CHAR *internal_path = NULL; ACPI_GENERIC_STATE scope_info; @@ -86,12 +86,12 @@ return (status); } - /* Get the prefix handle and NTE */ + /* Get the prefix handle and Node */ acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - rel_obj_entry = acpi_ns_convert_handle_to_entry (handle); - if (!rel_obj_entry) { + prefix_node = acpi_ns_convert_handle_to_entry (handle); + if (!prefix_node) { acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); status = AE_BAD_PARAMETER; goto cleanup; @@ -99,15 +99,14 @@ /* Lookup the name in the namespace */ - scope_info.scope.name_table = rel_obj_entry->child_table; + scope_info.scope.node = prefix_node->child; status = acpi_ns_lookup (&scope_info, internal_path, ACPI_TYPE_ANY, - IMODE_EXECUTE, - NS_NO_UPSEARCH, NULL, - &obj_entry); + IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, + &node); acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -116,7 +115,7 @@ * to evaluate it. */ - status = acpi_ns_evaluate_by_handle (obj_entry, params, return_object); + status = acpi_ns_evaluate_by_handle (node, params, return_object); cleanup: @@ -128,7 +127,7 @@ } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_evaluate_by_name * @@ -146,26 +145,24 @@ * * MUTEX: Locks Namespace * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ns_evaluate_by_name ( - char *pathname, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **return_object) + NATIVE_CHAR *pathname, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **return_object) { ACPI_STATUS status; - ACPI_NAMED_OBJECT *obj_entry = NULL; - char *internal_path = NULL; + ACPI_NAMESPACE_NODE *node = NULL; + NATIVE_CHAR *internal_path = NULL; /* Build an internal name string for the method */ - if (pathname[0] != '\\' || pathname[1] != '/') { - status = acpi_ns_internalize_name (pathname, &internal_path); - if (ACPI_FAILURE (status)) { - return (status); - } + status = acpi_ns_internalize_name (pathname, &internal_path); + if (ACPI_FAILURE (status)) { + return (status); } acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); @@ -173,13 +170,12 @@ /* Lookup the name in the namespace */ status = acpi_ns_lookup (NULL, internal_path, ACPI_TYPE_ANY, - IMODE_EXECUTE, - NS_NO_UPSEARCH, NULL, - &obj_entry); + IMODE_EXECUTE, NS_NO_UPSEARCH, NULL, + &node); acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { goto cleanup; } @@ -188,7 +184,7 @@ * to evaluate it. */ - status = acpi_ns_evaluate_by_handle (obj_entry, params, return_object); + status = acpi_ns_evaluate_by_handle (node, params, return_object); cleanup: @@ -203,16 +199,16 @@ } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_evaluate_by_handle * - * PARAMETERS: Obj_entry - NTE of method to execute - * *Return_object - Where to put method's return value (if - * any). If NULL, no value is returned. + * PARAMETERS: Handle - Method Node to execute * **Params - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. + * *Return_object - Where to put method's return value (if + * any). If NULL, no value is returned. * * RETURN: Status * @@ -220,22 +216,22 @@ * * MUTEX: Locks Namespace * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ns_evaluate_by_handle ( - ACPI_NAMED_OBJECT *handle, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **return_object) + ACPI_NAMESPACE_NODE *handle, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **return_object) { - ACPI_NAMED_OBJECT *obj_entry; + ACPI_NAMESPACE_NODE *node; ACPI_STATUS status; - ACPI_OBJECT_INTERNAL *local_return_object; + ACPI_OPERAND_OBJECT *local_return_object; /* Check if namespace has been initialized */ - if (!acpi_gbl_root_object->child_table) { + if (!acpi_gbl_root_node) { return (AE_NO_NAMESPACE); } @@ -251,12 +247,12 @@ *return_object = NULL; } - /* Get the prefix handle and NTE */ + /* Get the prefix handle and Node */ acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - obj_entry = acpi_ns_convert_handle_to_entry (handle); - if (!obj_entry) { + node = acpi_ns_convert_handle_to_entry (handle); + if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } @@ -271,14 +267,11 @@ * In both cases, the namespace is unlocked by the * Acpi_ns* procedure */ - - if (acpi_ns_get_type (obj_entry) == ACPI_TYPE_METHOD) { + if (acpi_ns_get_type (node) == ACPI_TYPE_METHOD) { /* * Case 1) We have an actual control method to execute */ - - status = acpi_ns_execute_control_method (obj_entry, - params, + status = acpi_ns_execute_control_method (node, params, &local_return_object); } @@ -287,9 +280,7 @@ * Case 2) Object is NOT a method, just return its * current value */ - - status = acpi_ns_get_object_value (obj_entry, - &local_return_object); + status = acpi_ns_get_object_value (node, &local_return_object); } @@ -297,7 +288,6 @@ * Check if there is a return value on the stack that must * be dealt with */ - if (status == AE_CTRL_RETURN_VALUE) { /* * If the Method returned a value and the caller @@ -305,13 +295,11 @@ * the returned value to the object descriptor provided * by the caller. */ - if (return_object) { /* * Valid return object, copy the pointer to * the returned object */ - *return_object = local_return_object; } @@ -327,7 +315,6 @@ * Namespace was unlocked by the handling Acpi_ns* function, * so we just return */ - return (status); @@ -338,14 +325,16 @@ } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_execute_control_method * - * PARAMETERS: Method_entry - The Nte of the object/method + * PARAMETERS: Method_node - The object/method * **Params - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. + * **Return_obj_desc - List of result objects to be returned + * from the method. * * RETURN: Status * @@ -353,36 +342,31 @@ * * MUTEX: Assumes namespace is locked * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ns_execute_control_method ( - ACPI_NAMED_OBJECT *method_entry, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **return_obj_desc) + ACPI_NAMESPACE_NODE *method_node, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **return_obj_desc) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; /* Verify that there is a method associated with this object */ - obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) method_entry); + obj_desc = acpi_ns_get_attached_object ((ACPI_HANDLE) method_node); if (!obj_desc) { return (AE_ERROR); } - /* - * Valid method, Set the current scope to that of the Method, - * and execute it. - */ - /* * Unlock the namespace before execution. This allows namespace access * via the external Acpi* interfaces while a method is being executed. * However, any namespace deletion must acquire both the namespace and - * interpter locks to ensure that no thread is using the portion of the + * interpreter locks to ensure that no thread is using the portion of the * namespace that is being deleted. */ @@ -391,17 +375,17 @@ /* * Excecute the method via the interpreter */ - status = acpi_aml_execute_method (method_entry, params, return_obj_desc); + status = acpi_aml_execute_method (method_node, params, return_obj_desc); return (status); } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_get_object_value * - * PARAMETERS: Object_entry - The Nte of the object + * PARAMETERS: Node - The object * * RETURN: Status * @@ -409,30 +393,29 @@ * * MUTEX: Assumes namespace is locked * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ns_get_object_value ( - ACPI_NAMED_OBJECT *object_entry, - ACPI_OBJECT_INTERNAL **return_obj_desc) + ACPI_NAMESPACE_NODE *node, + ACPI_OPERAND_OBJECT **return_obj_desc) { ACPI_STATUS status = AE_OK; - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL *val_desc; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_OPERAND_OBJECT *val_desc; /* * We take the value from certain objects directly */ - if ((object_entry->type == ACPI_TYPE_PROCESSOR) || - (object_entry->type == ACPI_TYPE_POWER)) + if ((node->type == ACPI_TYPE_PROCESSOR) || + (node->type == ACPI_TYPE_POWER)) { - /* * Create a Reference object to contain the object */ - obj_desc = acpi_cm_create_internal_object (object_entry->type); + obj_desc = acpi_cm_create_internal_object (node->type); if (!obj_desc) { status = AE_NO_MEMORY; goto unlock_and_exit; @@ -442,7 +425,7 @@ * Get the attached object */ - val_desc = acpi_ns_get_attached_object (object_entry); + val_desc = acpi_ns_get_attached_object (node); if (!val_desc) { status = AE_NULL_OBJECT; goto unlock_and_exit; @@ -452,10 +435,25 @@ * Just copy from the original to the return object */ - MEMCPY (&obj_desc->common.first_non_common_byte, - &val_desc->common.first_non_common_byte, - (sizeof(ACPI_OBJECT_COMMON) - - sizeof(obj_desc->common.first_non_common_byte))); + switch (node->type) + { + case ACPI_TYPE_PROCESSOR: + obj_desc->processor.proc_id = val_desc->processor.proc_id; + obj_desc->processor.address = val_desc->processor.address; + obj_desc->processor.sys_handler = val_desc->processor.sys_handler; + obj_desc->processor.drv_handler = val_desc->processor.drv_handler; + obj_desc->processor.addr_handler = val_desc->processor.addr_handler; + + break; + + case ACPI_TYPE_POWER: + obj_desc->power_resource.system_level = val_desc->power_resource.system_level; + obj_desc->power_resource.resource_order = val_desc->power_resource.resource_order; + obj_desc->power_resource.sys_handler = val_desc->power_resource.sys_handler; + obj_desc->power_resource.drv_handler = val_desc->power_resource.drv_handler; + + break; + } } @@ -475,15 +473,19 @@ /* Construct a descriptor pointing to the name */ obj_desc->reference.op_code = (u8) AML_NAME_OP; - obj_desc->reference.object = (void *) object_entry; + obj_desc->reference.object = (void *) node; /* * Use Acpi_aml_resolve_to_value() to get the associated value. * The call to Acpi_aml_resolve_to_value causes * Obj_desc (allocated above) to always be deleted. + * + * NOTE: we can get away with passing in NULL for a walk state + * because Obj_desc is guaranteed to not be a reference to either + * a method local or a method argument */ - status = acpi_aml_resolve_to_value (&obj_desc); + status = acpi_aml_resolve_to_value (&obj_desc, NULL); } /* @@ -491,7 +493,7 @@ * placed in Obj_desc. */ - if (status == AE_OK) { + if (ACPI_SUCCESS (status)) { status = AE_CTRL_RETURN_VALUE; *return_obj_desc = obj_desc; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/namespace/nsload.c linux/drivers/acpi/namespace/nsload.c --- v2.4.0-test8/linux/drivers/acpi/namespace/nsload.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/namespace/nsload.c Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: nsload - namespace loading/expanding/contracting procedures + * $Revision: 28 $ * *****************************************************************************/ @@ -25,16 +25,16 @@ #include "acpi.h" -#include "interp.h" -#include "namesp.h" +#include "acinterp.h" +#include "acnamesp.h" #include "amlcode.h" -#include "parser.h" -#include "dispatch.h" -#include "debugger.h" +#include "acparser.h" +#include "acdispat.h" +#include "acdebug.h" #define _COMPONENT NAMESPACE - MODULE_NAME ("nsload"); + MODULE_NAME ("nsload") /******************************************************************************* @@ -42,7 +42,7 @@ * FUNCTION: Acpi_ns_parse_table * * PARAMETERS: Table_desc - An ACPI table descriptor for table to parse - * Scope - Where to enter the table into the namespace + * Start_node - Where to enter the table into the namespace * * RETURN: Status * @@ -53,50 +53,85 @@ ACPI_STATUS acpi_ns_parse_table ( ACPI_TABLE_DESC *table_desc, - ACPI_NAME_TABLE *scope) + ACPI_NAMESPACE_NODE *start_node) { ACPI_STATUS status; - /* Create the root object */ + /* + * AML Parse, pass 1 + * + * In this pass, we load most of the namespace. Control methods + * are not parsed until later. A parse tree is not created. Instead, + * each Parser Op subtree is deleted when it is finished. This saves + * a great deal of memory, and allows a small cache of parse objects + * to service the entire parse. The second pass of the parse then + * performs another complete parse of the AML.. + */ + + /* Create and init a Root Node */ acpi_gbl_parsed_namespace_root = acpi_ps_alloc_op (AML_SCOPE_OP); if (!acpi_gbl_parsed_namespace_root) { return (AE_NO_MEMORY); } - /* Initialize the root object */ + ((ACPI_PARSE2_OBJECT *) acpi_gbl_parsed_namespace_root)->name = ACPI_ROOT_NAME; - ((ACPI_NAMED_OP *) acpi_gbl_parsed_namespace_root)->name = ACPI_ROOT_NAME; /* Pass 1: Parse everything except control method bodies */ status = acpi_ps_parse_aml (acpi_gbl_parsed_namespace_root, table_desc->aml_pointer, - table_desc->aml_length, 0); + table_desc->aml_length, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + NULL, NULL, NULL, + acpi_ds_load1_begin_op, + acpi_ds_load1_end_op); if (ACPI_FAILURE (status)) { return (status); } - -#ifndef PARSER_ONLY - status = acpi_ps_walk_parsed_aml (acpi_ps_get_child (acpi_gbl_parsed_namespace_root), - acpi_gbl_parsed_namespace_root, NULL, - scope, NULL, NULL, - table_desc->table_id, - acpi_ds_load2_begin_op, - acpi_ds_load2_end_op); + acpi_ps_delete_parse_tree (acpi_gbl_parsed_namespace_root); /* - * Now that the internal namespace has been constructed, we can delete the - * parsed namespace, since it is no longer needed + * AML Parse, pass 2 + * + * In this pass, we resolve forward references and other things + * that could not be completed during the first pass. + * Another complete parse of the AML is performed, but the + * overhead of this is compensated for by the fact that the + * parse objects are all cached. */ + /* Create and init a Root Node */ + + acpi_gbl_parsed_namespace_root = acpi_ps_alloc_op (AML_SCOPE_OP); + if (!acpi_gbl_parsed_namespace_root) { + return (AE_NO_MEMORY); + } + + ((ACPI_PARSE2_OBJECT *) acpi_gbl_parsed_namespace_root)->name = ACPI_ROOT_NAME; + + + /* Pass 2: Resolve forward references */ + + status = acpi_ps_parse_aml (acpi_gbl_parsed_namespace_root, + table_desc->aml_pointer, + table_desc->aml_length, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + NULL, NULL, NULL, + acpi_ds_load2_begin_op, + acpi_ds_load2_end_op); + + if (ACPI_FAILURE (status)) { + return (status); + } + acpi_ps_delete_parse_tree (acpi_gbl_parsed_namespace_root); acpi_gbl_parsed_namespace_root = NULL; -#endif return (status); @@ -120,7 +155,7 @@ ACPI_STATUS acpi_ns_load_table ( ACPI_TABLE_DESC *table_desc, - ACPI_NAMED_OBJECT *entry) + ACPI_NAMESPACE_NODE *node) { ACPI_STATUS status; @@ -146,7 +181,7 @@ */ acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - status = acpi_ns_parse_table (table_desc, entry->child_table); + status = acpi_ns_parse_table (table_desc, node->child); acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { @@ -160,7 +195,7 @@ * parse trees. */ - status = acpi_ds_initialize_objects (table_desc, entry); + status = acpi_ds_initialize_objects (table_desc, node); return (status); } @@ -222,7 +257,7 @@ /* Now load the single DSDT */ - status = acpi_ns_load_table (table_desc, acpi_gbl_root_object); + status = acpi_ns_load_table (table_desc, acpi_gbl_root_node); if (ACPI_SUCCESS (status)) { table_desc->loaded_into_namespace = TRUE; } @@ -247,7 +282,7 @@ if (!table_desc->loaded_into_namespace) { status = acpi_ns_load_table (table_desc, - acpi_gbl_root_object); + acpi_gbl_root_node); if (ACPI_FAILURE (status)) { break; } @@ -276,7 +311,7 @@ if (!table_desc->loaded_into_namespace) { status = acpi_ns_load_table (table_desc, - acpi_gbl_root_object); + acpi_gbl_root_node); if (ACPI_FAILURE (status)) { break; } @@ -306,52 +341,6 @@ /****************************************************************************** * - * FUNCTION: Acpi_ns_free_table_entry - * - * PARAMETERS: Entry - The entry to be deleted - * - * RETURNS None - * - * DESCRIPTION: Free an entry in a namespace table. Delete any objects contained - * in the entry, unlink the entry, then mark it unused. - * - ******************************************************************************/ - -void -acpi_ns_free_table_entry ( - ACPI_NAMED_OBJECT *entry) -{ - - if (!entry) { - return; - } - - /* - * Need to delete - * 1) The scope, if any - * 2) An attached object, if any - */ - - if (entry->child_table) { - acpi_cm_free (entry->child_table); - entry->child_table = NULL; - } - - if (entry->object) { - acpi_ns_detach_object (entry->object); - entry->object = NULL; - } - - /* Mark the entry unallocated */ - - entry->name = 0; - - return; -} - - -/****************************************************************************** - * * FUNCTION: Acpi_ns_delete_subtree * * PARAMETERS: Start_handle - Handle in namespace where search begins @@ -394,15 +383,6 @@ child_handle, &next_child_handle); - /* - * Regardless of the success or failure of the - * previous operation, we are done with the previous - * object (if there was one), and any children it - * may have had. So we can now safely delete it (and - * its scope, if any) - */ - - acpi_ns_free_table_entry (child_handle); child_handle = next_child_handle; @@ -432,6 +412,11 @@ * the object's parent */ level--; + + /* Delete all children now */ + + acpi_ns_delete_children (child_handle); + child_handle = parent_handle; acpi_get_parent (parent_handle, &parent_handle); } @@ -439,7 +424,7 @@ /* Now delete the starting object, and we are done */ - acpi_ns_free_table_entry ((ACPI_NAMED_OBJECT*) child_handle); + acpi_ns_delete_node (child_handle); return (AE_OK); @@ -469,7 +454,7 @@ /* Parameter validation */ - if (!acpi_gbl_root_object->child_table) { + if (!acpi_gbl_root_node) { return (AE_NO_NAMESPACE); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/namespace/nsnames.c linux/drivers/acpi/namespace/nsnames.c --- v2.4.0-test8/linux/drivers/acpi/namespace/nsnames.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/namespace/nsnames.c Fri Sep 15 14:30:30 2000 @@ -1,9 +1,9 @@ - -/****************************************************************************** +/******************************************************************************* * * Module Name: nsnames - Name manipulation and search + * $Revision: 48 $ * - *****************************************************************************/ + ******************************************************************************/ /* * Copyright (C) 2000 R. Byron Moore @@ -26,42 +26,40 @@ #include "acpi.h" #include "amlcode.h" -#include "interp.h" -#include "namesp.h" +#include "acinterp.h" +#include "acnamesp.h" #define _COMPONENT NAMESPACE - MODULE_NAME ("nsnames"); + MODULE_NAME ("nsnames") -/**************************************************************************** +/******************************************************************************* * - * FUNCTION: Acpi_ns_name_of_scope + * FUNCTION: Acpi_ns_get_table_pathname * - * PARAMETERS: Scope - Scope whose name is needed + * PARAMETERS: Node - Scope whose name is needed * * RETURN: Pointer to storage containing the fully qualified name of * the scope, in Label format (all segments strung together * with no separators) * - * DESCRIPTION: Used via Acpi_ns_name_of_current_scope() and Acpi_ns_last_fQN() - * for label generation in the interpreter, and for debug - * printing in Acpi_ns_search_table(). - * - ***************************************************************************/ - -char * -acpi_ns_name_of_scope ( - ACPI_NAME_TABLE *scope) + * DESCRIPTION: Used for debug printing in Acpi_ns_search_table(). + * + ******************************************************************************/ + +NATIVE_CHAR * +acpi_ns_get_table_pathname ( + ACPI_NAMESPACE_NODE *node) { - char *name_buffer; - ACPI_SIZE size; + NATIVE_CHAR *name_buffer; + u32 size; ACPI_NAME name; - ACPI_NAMED_OBJECT *entry_to_search; - ACPI_NAMED_OBJECT *parent_entry; + ACPI_NAMESPACE_NODE *child_node; + ACPI_NAMESPACE_NODE *parent_node; - if (!acpi_gbl_root_object->child_table || !scope) { + if (!acpi_gbl_root_node || !node) { /* * If the name space has not been initialized, * this function should not have been called. @@ -69,26 +67,26 @@ return (NULL); } - entry_to_search = scope->entries; + child_node = node->child; - /* Calculate required buffer size based on depth below root NT */ + /* Calculate required buffer size based on depth below root */ size = 1; - parent_entry = entry_to_search; - while (parent_entry) { - parent_entry = acpi_ns_get_parent_entry (parent_entry); - if (parent_entry) { + parent_node = child_node; + while (parent_node) { + parent_node = acpi_ns_get_parent_object (parent_node); + if (parent_node) { size += ACPI_NAME_SIZE; } } - /* Allocate the buffer */ + /* Allocate a buffer to be returned to caller */ name_buffer = acpi_cm_callocate (size + 1); if (!name_buffer) { - REPORT_ERROR ("Ns_name_of_scope: allocation failure"); + REPORT_ERROR ("Ns_get_table_pathname: allocation failure"); return (NULL); } @@ -97,15 +95,15 @@ name_buffer[size] = '\0'; while ((size > ACPI_NAME_SIZE) && - acpi_ns_get_parent_entry (entry_to_search)) + acpi_ns_get_parent_object (child_node)) { size -= ACPI_NAME_SIZE; - name = acpi_ns_find_parent_name (entry_to_search); + name = acpi_ns_find_parent_name (child_node); /* Put the name into the buffer */ MOVE_UNALIGNED32_TO_32 ((name_buffer + size), &name); - entry_to_search = acpi_ns_get_parent_entry (entry_to_search); + child_node = acpi_ns_get_parent_object (child_node); } name_buffer[--size] = AML_ROOT_PREFIX; @@ -115,69 +113,39 @@ } -/**************************************************************************** - * - * FUNCTION: Acpi_ns_name_of_current_scope - * - * PARAMETERS: none - * - * RETURN: pointer to storage containing the name of the current scope - * - ***************************************************************************/ - -char * -acpi_ns_name_of_current_scope ( - ACPI_WALK_STATE *walk_state) -{ - char *scope_name; - - - if (walk_state && walk_state->scope_info) { - scope_name = - acpi_ns_name_of_scope (walk_state->scope_info->scope.name_table); - - return (scope_name); - } - - REPORT_ERROR ("Current scope pointer is invalid"); - - return (NULL); -} - - -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_handle_to_pathname * - * PARAMETERS: Target_handle - Handle of nte whose name is to be found + * PARAMETERS: Target_handle - Handle of named object whose name is + * to be found * Buf_size - Size of the buffer provided * User_buffer - Where the pathname is returned * - * RETURN: Status, Buffer is filled with pathname if status == AE_OK + * RETURN: Status, Buffer is filled with pathname if status is AE_OK * * DESCRIPTION: Build and return a full namespace pathname * * MUTEX: Locks Namespace * - ***************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ns_handle_to_pathname ( ACPI_HANDLE target_handle, u32 *buf_size, - char *user_buffer) + NATIVE_CHAR *user_buffer) { ACPI_STATUS status = AE_OK; - ACPI_NAMED_OBJECT *entry_to_search = NULL; - ACPI_NAMED_OBJECT *temp = NULL; - ACPI_SIZE path_length = 0; - ACPI_SIZE size; + ACPI_NAMESPACE_NODE *node; + ACPI_NAMESPACE_NODE *next_node; + u32 path_length; + u32 size; u32 user_buf_size; ACPI_NAME name; - u8 namespace_was_locked; - if (!acpi_gbl_root_object->child_table || !target_handle) { + if (!acpi_gbl_root_node || !target_handle) { /* * If the name space has not been initialized, * this function should not have been called. @@ -186,13 +154,8 @@ return (AE_NO_NAMESPACE); } - namespace_was_locked = acpi_gbl_acpi_mutex_info[ACPI_MTX_NAMESPACE].locked; - if (!namespace_was_locked) { - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - } - - entry_to_search = acpi_ns_convert_handle_to_entry (target_handle); - if (!entry_to_search) { + node = acpi_ns_convert_handle_to_entry (target_handle); + if (!node) { return (AE_BAD_PARAMETER); } @@ -200,9 +163,9 @@ * Compute length of pathname as 5 * number of name segments. * Go back up the parent tree to the root */ - for (size = 0, temp = entry_to_search; - acpi_ns_get_parent_entry (temp); - temp = acpi_ns_get_parent_entry (temp)) + for (size = 0, next_node = node; + acpi_ns_get_parent_object (next_node); + next_node = acpi_ns_get_parent_object (next_node)) { size += PATH_SEGMENT_LENGTH; } @@ -217,7 +180,7 @@ if (path_length > user_buf_size) { status = AE_BUFFER_OVERFLOW; - goto unlock_and_exit; + goto exit; } /* Store null terminator */ @@ -228,19 +191,19 @@ /* Put the original ACPI name at the end of the path */ MOVE_UNALIGNED32_TO_32 ((user_buffer + size), - &entry_to_search->name); + &node->name); user_buffer[--size] = PATH_SEPARATOR; /* Build name backwards, putting "." between segments */ - while ((size > ACPI_NAME_SIZE) && entry_to_search) { + while ((size > ACPI_NAME_SIZE) && node) { size -= ACPI_NAME_SIZE; - name = acpi_ns_find_parent_name (entry_to_search); + name = acpi_ns_find_parent_name (node); MOVE_UNALIGNED32_TO_32 ((user_buffer + size), &name); user_buffer[--size] = PATH_SEPARATOR; - entry_to_search = acpi_ns_get_parent_entry (entry_to_search); + node = acpi_ns_get_parent_object (node); } /* @@ -250,254 +213,8 @@ user_buffer[size] = '\\'; - -unlock_and_exit: - - if (!namespace_was_locked) { - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - } - +exit: return (status); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_pattern_match - * - * PARAMETERS: Obj_entry - A namespace entry - * Search_for - Wildcard pattern string - * - * DESCRIPTION: Matches a namespace name against a wildcard pattern. Only - * a very simple pattern - 4 chars, either a valid char or a "?" - * to match any. - * - ***************************************************************************/ - -u8 -acpi_ns_pattern_match ( - ACPI_NAMED_OBJECT *obj_entry, - char *search_for) -{ - s32 i; - - - for (i = 0; i < ACPI_NAME_SIZE; i++) { - if (search_for[i] != '?' && - search_for[i] != ((char *) &obj_entry->name)[i]) - { - /* No match */ - - return FALSE; - } - } - - /* name matches pattern */ - - return TRUE; -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_name_compare - * - * PARAMETERS: Obj_handle - A namespace entry - * Level - Current nesting level - * Context - A FIND_CONTEXT structure - * - * DESCRIPTION: A User_function called by Acpi_ns_walk_namespace(). It performs - * a pattern match for Acpi_ns_low_find_names(), and updates the list - * and count as required. - * - ***************************************************************************/ - -ACPI_STATUS -acpi_ns_name_compare ( - ACPI_HANDLE obj_handle, - u32 level, - void *context, - void **return_value) -{ - FIND_CONTEXT *find = context; - - - /* Match, yes or no? */ - - if (acpi_ns_pattern_match ((ACPI_NAMED_OBJECT*) obj_handle, - find->search_for)) - { - /* Name matches pattern */ - - if (find->list) { - find->list[*(find->count)] = obj_handle; - } - - ++*(find->count); - } - - /* Don't terminate the walk */ - return AE_OK; -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_low_find_names - * - * PARAMETERS: *This_entry - Table to be searched - * *Search_for - Pattern to be found. - * 4 bytes, ? matches any character. - * *Count - Output count of matches found. - * Outermost caller should preset to 0 - * List[] - Output array of handles. If - * null, only the count is obtained. - * Max_depth - Maximum depth of search. Use - * INT_MAX for an effectively - * unlimited depth. - * - * DESCRIPTION: Low-level find name. - * Traverse the name space finding names which match a search - * pattern, and return an array of handles in List[]. - * - ***************************************************************************/ - -void -acpi_ns_low_find_names ( - ACPI_NAMED_OBJECT *this_entry, - char *search_for, - s32 *count, - ACPI_HANDLE list[], - s32 max_depth) -{ - FIND_CONTEXT find; - - - if (0 == max_depth || !this_entry || !search_for || !count) { - /* - * Zero requested depth, nothing to search, - * nothing to search for, or count pointer bad - */ - - return; - } - - /* Init the context structure used by compare routine */ - - find.list = list; - find.count = count; - find.search_for = search_for; - - /* Walk the namespace and find all matches */ - - acpi_ns_walk_namespace (ACPI_TYPE_ANY, (ACPI_HANDLE) this_entry, - max_depth, NS_WALK_NO_UNLOCK, - acpi_ns_name_compare, &find, NULL); - - if (list) { - /* null-terminate the output array */ - - list[*count] = (ACPI_HANDLE) 0; - } - - return; -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_find_names - - * - * PARAMETERS: *Search_for - pattern to be found. - * 4 bytes, ? matches any character. - * If NULL, "????" will be used. - * Start_handle - Root of subtree to be searched, or - * NS_ALL to search the entire namespace - * Max_depth - Maximum depth of search. Use INT_MAX - * for an effectively unlimited depth. - * - * DESCRIPTION: Traverse the name space finding names which match a search - * pattern, and return an array of handles. The end of the - * array is marked by the value (ACPI_HANDLE)0. A return value - * of (ACPI_HANDLE *)0 indicates that no matching names were - * found or that space for the list could not be allocated. - * if Start_handle is NS_ALL (null) search from the root, - * else it is a handle whose children are to be searched. - * - ***************************************************************************/ - -ACPI_HANDLE * -acpi_ns_find_names ( - char *search_for, - ACPI_HANDLE start_handle, - s32 max_depth) -{ - ACPI_HANDLE *list = NULL; - s32 count; - - - if (!acpi_gbl_root_object->child_table) { - /* - * If the name space has not been initialized, - * there surely are no matching names. - */ - return (NULL); - } - - if (NS_ALL == start_handle) { - /* base is root */ - - start_handle = acpi_gbl_root_object; - } - - else if (((ACPI_NAMED_OBJECT *) start_handle)->child_table) { - /* base has children to search */ - - start_handle = - ((ACPI_NAMED_OBJECT *) start_handle)->child_table->entries; - } - - else { - /* - * If base is not the root and has no children, - * there is nothing to search. - */ - return (NULL); - } - - if (!search_for) { - /* Search name not specified */ - - search_for = "????"; - } - - - /* Pass 1. Get required buffer size, don't try to build list */ - - count = 0; - acpi_ns_low_find_names (start_handle, search_for, &count, - NULL, max_depth); - - if (0 == count) { - return (NULL); - } - - /* Allow for trailing null */ - count++; - - list = acpi_cm_callocate (count * sizeof(ACPI_HANDLE)); - if (!list) { - REPORT_ERROR ("Ns_find_names: allocation failure"); - return (NULL); - } - - /* Pass 2. Fill buffer */ - - count = 0; - acpi_ns_low_find_names (start_handle, search_for, &count, list, max_depth); - - return (list); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/namespace/nsobject.c linux/drivers/acpi/namespace/nsobject.c --- v2.4.0-test8/linux/drivers/acpi/namespace/nsobject.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/namespace/nsobject.c Fri Sep 15 14:30:30 2000 @@ -1,10 +1,10 @@ - -/****************************************************************************** +/******************************************************************************* * * Module Name: nsobject - Utilities for objects attached to namespace - * table entries + * table entries + * $Revision: 44 $ * - *****************************************************************************/ + ******************************************************************************/ /* * Copyright (C) 2000 R. Byron Moore @@ -27,20 +27,20 @@ #include "acpi.h" #include "amlcode.h" -#include "namesp.h" -#include "interp.h" -#include "tables.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "actables.h" #define _COMPONENT NAMESPACE - MODULE_NAME ("nsobject"); + MODULE_NAME ("nsobject") -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_attach_object * - * PARAMETERS: Handle - Handle of nte + * PARAMETERS: Node - Parent Node * Object - Object to be attached * Type - Type of object, or ACPI_TYPE_ANY if not * known @@ -51,17 +51,16 @@ * * MUTEX: Assumes namespace is locked * - ***************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ns_attach_object ( - ACPI_HANDLE handle, - ACPI_HANDLE object, + ACPI_NAMESPACE_NODE *node, + ACPI_OPERAND_OBJECT *object, OBJECT_TYPE_INTERNAL type) { - ACPI_NAMED_OBJECT *this_entry = (ACPI_NAMED_OBJECT*) handle; - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL *previous_obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_OPERAND_OBJECT *previous_obj_desc; OBJECT_TYPE_INTERNAL obj_type = ACPI_TYPE_ANY; u8 flags; u16 opcode; @@ -71,17 +70,17 @@ * Parameter validation */ - if (!acpi_gbl_root_object->child_table) { + if (!acpi_gbl_root_node) { /* Name space not initialized */ REPORT_ERROR ("Ns_attach_object: Name space not initialized"); return (AE_NO_NAMESPACE); } - if (!handle) { + if (!node) { /* Invalid handle */ - REPORT_ERROR ("Ns_attach_object: Null name handle"); + REPORT_ERROR ("Ns_attach_object: Null Named_obj handle"); return (AE_BAD_PARAMETER); } @@ -93,7 +92,7 @@ return (AE_BAD_PARAMETER); } - if (!VALID_DESCRIPTOR_TYPE (handle, ACPI_DESC_TYPE_NAMED)) { + if (!VALID_DESCRIPTOR_TYPE (node, ACPI_DESC_TYPE_NAMED)) { /* Not a name handle */ REPORT_ERROR ("Ns_attach_object: Invalid handle"); @@ -102,15 +101,15 @@ /* Check if this object is already attached */ - if (this_entry->object == object) { + if (node->object == object) { return (AE_OK); } - /* Get the current flags field of the NTE */ + /* Get the current flags field of the Node */ - flags = this_entry->flags; - flags &= ~NTE_AML_ATTACHMENT; + flags = node->flags; + flags &= ~ANOBJ_AML_ATTACHMENT; /* If null object, we will just install it */ @@ -121,27 +120,27 @@ } /* - * If the object is an NTE with an attached object, + * If the object is an Node with an attached object, * we will use that (attached) object */ else if (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_NAMED) && - ((ACPI_NAMED_OBJECT*) object)->object) + ((ACPI_NAMESPACE_NODE *) object)->object) { /* * Value passed is a name handle and that name has a * non-null value. Use that name's value and type. */ - obj_desc = ((ACPI_NAMED_OBJECT*) object)->object; - obj_type = ((ACPI_NAMED_OBJECT*) object)->type; + obj_desc = ((ACPI_NAMESPACE_NODE *) object)->object; + obj_type = ((ACPI_NAMESPACE_NODE *) object)->type; /* * Copy appropriate flags */ - if (((ACPI_NAMED_OBJECT*) object)->flags & NTE_AML_ATTACHMENT) { - flags |= NTE_AML_ATTACHMENT; + if (((ACPI_NAMESPACE_NODE *) object)->flags & ANOBJ_AML_ATTACHMENT) { + flags |= ANOBJ_AML_ATTACHMENT; } } @@ -152,7 +151,7 @@ */ else { - obj_desc = (ACPI_OBJECT_INTERNAL *) object; + obj_desc = (ACPI_OPERAND_OBJECT *) object; /* If a valid type (non-ANY) was given, just use it */ @@ -173,10 +172,10 @@ else if (acpi_tb_system_table_pointer (object)) { /* * Object points into the AML stream. - * Set a flag bit in the NTE to indicate this + * Set a flag bit in the Node to indicate this */ - flags |= NTE_AML_ATTACHMENT; + flags |= ANOBJ_AML_ATTACHMENT; /* * The next byte (perhaps the next two bytes) @@ -263,13 +262,13 @@ /* Save the existing object (if any) for deletion later */ - previous_obj_desc = this_entry->object; + previous_obj_desc = node->object; /* Install the object and set the type, flags */ - this_entry->object = obj_desc; - this_entry->type = (u8) obj_type; - this_entry->flags = flags; + node->object = obj_desc; + node->type = (u8) obj_type; + node->flags |= flags; /* @@ -277,86 +276,12 @@ */ if (previous_obj_desc) { - /* One for the attach to the NTE */ - acpi_cm_remove_reference (previous_obj_desc); - /* Now delete */ - acpi_cm_remove_reference (previous_obj_desc); - } + /* One for the attach to the Node */ - return (AE_OK); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_attach_method - * - * PARAMETERS: Handle - Handle of nte to be set - * Offset - Value to be set - * Length - Length associated with value - * - * DESCRIPTION: Record the given offset and p-code length of the method - * whose handle is passed - * - * MUTEX: Assumes namespace is locked - * - ***************************************************************************/ - -ACPI_STATUS -acpi_ns_attach_method ( - ACPI_HANDLE handle, - u8 *pcode_addr, - u32 pcode_length) -{ - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_OBJECT_INTERNAL *previous_obj_desc; - ACPI_NAMED_OBJECT *this_entry = (ACPI_NAMED_OBJECT*) handle; - - - /* Parameter validation */ - - if (!acpi_gbl_root_object->child_table) { - /* Name space uninitialized */ - - REPORT_ERROR ("Ns_attach_method: name space uninitialized"); - return (AE_NO_NAMESPACE); - } - - if (!handle) { - /* Null name handle */ - - REPORT_ERROR ("Ns_attach_method: null name handle"); - return (AE_BAD_PARAMETER); - } - - - /* Allocate a method descriptor */ - - obj_desc = acpi_cm_create_internal_object (ACPI_TYPE_METHOD); - if (!obj_desc) { - /* Method allocation failure */ - - REPORT_ERROR ("Ns_attach_method: allocation failure"); - return (AE_NO_MEMORY); - } - - /* Init the method info */ - - obj_desc->method.pcode = pcode_addr; - obj_desc->method.pcode_length = pcode_length; - - /* Update reference count and install */ - - acpi_cm_add_reference (obj_desc); - - previous_obj_desc = this_entry->object; - this_entry->object = obj_desc; + acpi_cm_remove_reference (previous_obj_desc); + /* Now delete */ - /* - * Delete an existing object. Don't try to re-use in case it is shared - */ - if (previous_obj_desc) { acpi_cm_remove_reference (previous_obj_desc); } @@ -364,11 +289,11 @@ } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_detach_object * - * PARAMETERS: Object - An object whose Value will be deleted + * PARAMETERS: Node - An object whose Value will be deleted * * RETURN: None. * @@ -376,24 +301,23 @@ * Value is an allocated object, it is freed. Otherwise, the * field is simply cleared. * - ***************************************************************************/ + ******************************************************************************/ void acpi_ns_detach_object ( - ACPI_HANDLE object) + ACPI_NAMESPACE_NODE *node) { - ACPI_NAMED_OBJECT *entry = object; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; - obj_desc = entry->object; + obj_desc = node->object; if (!obj_desc) { return; } /* Clear the entry in all cases */ - entry->object = NULL; + node->object = NULL; /* Found a valid value */ @@ -412,16 +336,16 @@ } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_get_attached_object * - * PARAMETERS: Handle - Handle of nte to be examined + * PARAMETERS: Handle - Parent Node to be examined * - * RETURN: Current value of the object field from nte whose handle is - * passed + * RETURN: Current value of the object field from the Node whose + * handle is passed * - ***************************************************************************/ + ******************************************************************************/ void * acpi_ns_get_attached_object ( @@ -435,122 +359,7 @@ return (NULL); } - return (((ACPI_NAMED_OBJECT*) handle)->object); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_compare_object - * - * PARAMETERS: Obj_handle - A namespace entry - * Level - Current nesting level - * Obj_desc - The value to be compared - * - * DESCRIPTION: A User_function called by Acpi_ns_walk_namespace(). It performs - * a comparison for Acpi_ns_find_attached_object(). The comparison is against - * the value in the value field of the Obj_handle (an NTE). - * If a match is found, the handle is returned, which aborts - * Acpi_ns_walk_namespace. - * - ***************************************************************************/ - -ACPI_STATUS -acpi_ns_compare_object ( - ACPI_HANDLE obj_handle, - u32 level, - void *obj_desc, - void **return_value) -{ - - if (((ACPI_NAMED_OBJECT*) obj_handle)->object == obj_desc) { - if (return_value) { - *return_value = obj_handle; - } - - /* Stop the walk */ - return AE_CTRL_TERMINATE; - } - - /* Not found, continue the walk */ - return AE_OK; -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_find_attached_object - * - * PARAMETERS: *Obj_desc - Value to be found in ptr_val field. - * Start_handle - Root of subtree to be searched, or - * NS_ALL to search the entire namespace - * Max_depth - Maximum depth of search. Use INT_MAX - * for an effectively unlimited depth. - * - * DESCRIPTION: Traverse the name space until finding a name whose Value field - * matches the Obj_desc parameter, and return a handle to that - * name, or (ACPI_HANDLE)0 if none exists. - * if Start_handle is NS_ALL (null) search from the root, - * else it is a handle whose children are to be searched. - * - ***************************************************************************/ - -ACPI_HANDLE -acpi_ns_find_attached_object ( - ACPI_OBJECT_INTERNAL *obj_desc, - ACPI_HANDLE start_handle, - s32 max_depth) -{ - ACPI_HANDLE ret_object; - ACPI_STATUS status; - - - /* Parameter validation */ - - if (!obj_desc) { - return (NULL); - } - - if (0 == max_depth) { - return (NULL); - } - - if (!acpi_gbl_root_object->child_table) { - /* - * If the name space has not been initialized, - * there surely are no matching values. - */ - return (NULL); - } - - if (NS_ALL == start_handle) { - start_handle = acpi_gbl_root_object; - } - - else { - /* - * If base is not the root and has no children, - * there is nothing to search. - */ - return (NULL); - } - - - /* - * Walk namespace until a match is found. - * Either the matching object is returned, or NULL in case - * of no match. - */ - status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, start_handle, - max_depth, NS_WALK_NO_UNLOCK, - acpi_ns_compare_object, - obj_desc, &ret_object); - - if (ACPI_FAILURE (status)) { - ret_object = NULL; - } - - return (ret_object); + return (((ACPI_NAMESPACE_NODE *) handle)->object); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/namespace/nssearch.c linux/drivers/acpi/namespace/nssearch.c --- v2.4.0-test8/linux/drivers/acpi/namespace/nssearch.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/namespace/nssearch.c Fri Sep 15 14:30:30 2000 @@ -1,9 +1,9 @@ - -/****************************************************************************** +/******************************************************************************* * * Module Name: nssearch - Namespace search + * $Revision: 57 $ * - *****************************************************************************/ + ******************************************************************************/ /* * Copyright (C) 2000 R. Byron Moore @@ -26,192 +26,132 @@ #include "acpi.h" #include "amlcode.h" -#include "interp.h" -#include "namesp.h" +#include "acinterp.h" +#include "acnamesp.h" #define _COMPONENT NAMESPACE - MODULE_NAME ("nssearch"); + MODULE_NAME ("nssearch") -/**************************************************************************** +/******************************************************************************* * - * FUNCTION: Acpi_ns_search_one_scope + * FUNCTION: Acpi_ns_search_node * - * PARAMETERS: *Entry_name - Ascii ACPI name to search for - * *Name_table - Starting table where search will begin + * PARAMETERS: *Target_name - Ascii ACPI name to search for + * *Node - Starting table where search will begin * Type - Object type to match - * **Ret_entry - Where the matched NTE is returned - * *Ret_info - Where info about the search is returned + * **Return_node - Where the matched Named obj is returned * - * RETURN: Status and return information via NS_SEARCH_DATA + * RETURN: Status * * DESCRIPTION: Search a single namespace table. Performs a simple search, * does not add entries or search parents. * - ***************************************************************************/ + * + * Named object lists are built (and subsequently dumped) in the + * order in which the names are encountered during the namespace load; + * + * All namespace searching is linear in this implementation, but + * could be easily modified to support any improved search + * algorithm. However, the linear search was chosen for simplicity + * and because the trees are small and the other interpreter + * execution overhead is relatively high. + * + ******************************************************************************/ ACPI_STATUS -acpi_ns_search_one_scope ( - u32 entry_name, - ACPI_NAME_TABLE *name_table, +acpi_ns_search_node ( + u32 target_name, + ACPI_NAMESPACE_NODE *node, OBJECT_TYPE_INTERNAL type, - ACPI_NAMED_OBJECT **ret_entry, - NS_SEARCH_DATA *ret_info) + ACPI_NAMESPACE_NODE **return_node) { - u32 position; - ACPI_NAME_TABLE *this_table; - ACPI_NAME_TABLE *previous_table = name_table; - ACPI_NAMED_OBJECT *entries; - u8 table_full = TRUE; - ACPI_NAME_TABLE *table_with_empty_slots = NULL; - u32 empty_slot_position = 0; + ACPI_NAMESPACE_NODE *next_node; - /* - * Name tables are built (and subsequently dumped) in the - * order in which the names are encountered during the namespace load; - * - * All namespace searching will be linear; If a table overflows an - * additional segment will be allocated and added (chained). - * - * Start linear search at top of table - */ - position = 0; - this_table = name_table; - entries = this_table->entries; - - - /* Init return data */ - - if (ret_info) { - ret_info->name_table = this_table; - } - /* - * Search entire name table, including all linked appendages + * Search for name in this table, which is to say that we must search + * for the name among the children of this object */ - while (this_table) { - /* - * Search for name in table, starting at Position. Stop - * searching upon examining all entries in the table. - * - */ + next_node = node->child; + while (next_node) { + /* Check for match against the name */ - entries = this_table->entries; - while (position < NS_TABLE_SIZE) { - /* Check for a valid entry */ - - if (!entries[position].name) { - if (table_full) { - /* - * There is room in the table for more - * entries, if necessary - */ - - table_full = FALSE; - table_with_empty_slots = this_table; - empty_slot_position = position; - } - } - - /* Search for name in table */ + if (next_node->name == target_name) { + /* + * Found matching entry. Capture type if + * appropriate before returning the entry. + */ - else if (entries[position].name == entry_name) { - /* - * Found matching entry. Capture type if - * appropriate before returning the entry. - */ - - /* - * The Def_field_defn and Bank_field_defn cases - * are actually looking up the Region in which - * the field will be defined - */ - - if ((INTERNAL_TYPE_DEF_FIELD_DEFN == type) || - (INTERNAL_TYPE_BANK_FIELD_DEFN == type)) - { - type = ACPI_TYPE_REGION; - } - - /* - * Scope, Def_any, and Index_field_defn are bogus - * "types" which do not actually have anything - * to do with the type of the name being looked - * up. For any other value of Type, if the type - * stored in the entry is Any (i.e. unknown), - * save the actual type. - */ - - if (type != INTERNAL_TYPE_SCOPE && - type != INTERNAL_TYPE_DEF_ANY && - type != INTERNAL_TYPE_INDEX_FIELD_DEFN && - entries[position].type == ACPI_TYPE_ANY) - { - entries[position].type = (u8) type; - } + /* + * The Def_field_defn and Bank_field_defn cases + * are actually looking up the Region in which + * the field will be defined + */ - *ret_entry = &entries[position]; - return (AE_OK); + if ((INTERNAL_TYPE_DEF_FIELD_DEFN == type) || + (INTERNAL_TYPE_BANK_FIELD_DEFN == type)) + { + type = ACPI_TYPE_REGION; } + /* + * Scope, Def_any, and Index_field_defn are bogus + * "types" which do not actually have anything + * to do with the type of the name being looked + * up. For any other value of Type, if the type + * stored in the entry is Any (i.e. unknown), + * save the actual type. + */ - /* Didn't match name, move on to the next entry */ + if (type != INTERNAL_TYPE_SCOPE && + type != INTERNAL_TYPE_DEF_ANY && + type != INTERNAL_TYPE_INDEX_FIELD_DEFN && + next_node->type == ACPI_TYPE_ANY) + { + next_node->type = (u8) type; + } - position++; + *return_node = next_node; + return (AE_OK); } /* - * Just examined last slot in this table, move on - * to next appendate. - * All appendages, even to the root NT, contain - * NS_TABLE_SIZE entries. + * The last entry in the list points back to the parent, + * so a flag is used to indicate the end-of-list */ + if (next_node->flags & ANOBJ_END_OF_PEER_LIST) { + /* Searched entire list, we are done */ + + break; + } - previous_table = this_table; - this_table = this_table->next_table; + /* Didn't match name, move on to the next peer object */ - position = 0; + next_node = next_node->peer; } /* Searched entire table, not found */ - if (ret_info) { - /* - * Save info on if/where a slot is available - * (name was not found) - */ - - ret_info->table_full = table_full; - if (table_full) { - ret_info->name_table = previous_table; - } - - else { - ret_info->position = empty_slot_position; - ret_info->name_table = table_with_empty_slots; - } - } - return (AE_NOT_FOUND); } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_search_parent_tree * - * PARAMETERS: *Entry_name - Ascii ACPI name to search for - * *Name_table - Starting table where search will begin + * PARAMETERS: *Target_name - Ascii ACPI name to search for + * *Node - Starting table where search will begin * Type - Object type to match - * **Ret_entry - Where the matched NTE is returned + * **Return_node - Where the matched Named Obj is returned * * RETURN: Status * @@ -227,274 +167,79 @@ * indicates that the name is not found" (From ACPI Specification, * section 5.3) * - ***************************************************************************/ - + ******************************************************************************/ ACPI_STATUS acpi_ns_search_parent_tree ( - u32 entry_name, - ACPI_NAME_TABLE *name_table, + u32 target_name, + ACPI_NAMESPACE_NODE *node, OBJECT_TYPE_INTERNAL type, - ACPI_NAMED_OBJECT **ret_entry) + ACPI_NAMESPACE_NODE **return_node) { ACPI_STATUS status; - ACPI_NAMED_OBJECT *parent_entry; - ACPI_NAMED_OBJECT *entries; + ACPI_NAMESPACE_NODE *parent_node; - entries = name_table->entries; + parent_node = acpi_ns_get_parent_object (node); /* - * If no parent or type is "local", we won't be searching the - * parent tree. + * If there is no parent (at the root) or type is "local", we won't be + * searching the parent tree. */ - - if (!acpi_ns_local (type) && - name_table->parent_entry) + if ((acpi_ns_local (type)) || + (!parent_node)) { - parent_entry = name_table->parent_entry; - /* - * Search parents until found or we have backed up to - * the root - */ - - while (parent_entry) { - /* Search parent scope */ - /* TBD: [Investigate] Why ACPI_TYPE_ANY? */ - - status = acpi_ns_search_one_scope (entry_name, - parent_entry->child_table, - ACPI_TYPE_ANY, - ret_entry, NULL); - if (status == AE_OK) { - return (status); - } - - /* - * Not found here, go up another level - * (until we reach the root) - */ - - parent_entry = acpi_ns_get_parent_entry (parent_entry); - } - - /* Not found in parent tree */ - } - - - return (AE_NOT_FOUND); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_create_and_link_new_table - * - * PARAMETERS: *Name_table - The table that is to be "extended" by - * the creation of an appendage table. - * - * RETURN: Status - * - * DESCRIPTION: Allocate a new namespace table, initialize it, and link it - * into the parent table. - * - * NOTE: We are in the first or second pass load mode, want to - * add a new table entry, and the current table is full. - * - ***************************************************************************/ - -ACPI_STATUS -acpi_ns_create_and_link_new_table ( - ACPI_NAME_TABLE *name_table) -{ - ACPI_NAME_TABLE *new_table; - ACPI_NAMED_OBJECT *parent_entry; - ACPI_STATUS status = AE_OK; - - - /* Sanity check on the data structure */ - - if (name_table->next_table) { - /* We should never get here (an appendage already allocated) */ - - return (AE_AML_INTERNAL); - } - - - /* - * We can use the parent entries from the current table - * Since the parent information remains the same. - */ - parent_entry = name_table->parent_entry; - - - /* Allocate and chain an appendage to the filled table */ - - new_table = acpi_ns_allocate_name_table (NS_TABLE_SIZE); - if (!new_table) { - REPORT_ERROR ("Name Table appendage allocation failure"); - return (AE_NO_MEMORY); - } - /* - * Allocation successful. Init the new table. - */ - name_table->next_table = new_table; - acpi_ns_initialize_table (new_table, parent_entry->child_table, - parent_entry); - - return (status); -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_initialize_table - * - * PARAMETERS: New_table - The new table to be initialized - * Parent_table - The parent (owner) scope - * Parent_entry - The NTE for the parent - * - * RETURN: None - * - * DESCRIPTION: Initialize a new namespace table. Simple, but called - * from several places -- code should be kept in one place. - * - ***************************************************************************/ - -void -acpi_ns_initialize_table ( - ACPI_NAME_TABLE *new_table, - ACPI_NAME_TABLE *parent_table, - ACPI_NAMED_OBJECT *parent_entry) -{ - u8 i; - - - new_table->parent_entry = parent_entry; - new_table->parent_table = parent_table; - - - /* Init each named object entry in the table */ - - for (i = 0; i < NS_TABLE_SIZE; i++) { - new_table->entries[i].this_index = i; - new_table->entries[i].data_type = ACPI_DESC_TYPE_NAMED; + return (AE_NOT_FOUND); } -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_initialize_entry - * - * PARAMETERS: Name_table - The containing table for the new NTE - * Position - Position (index) of the new NTE in the table - * Entry_name - ACPI name of the new entry - * Type - ACPI object type of the new entry - * Previous_entry - Link back to the previous entry (can span - * multiple tables) - * - * RETURN: None - * - * DESCRIPTION: Initialize a new entry within a namespace table. - * - ***************************************************************************/ - -void -acpi_ns_initialize_entry ( - ACPI_WALK_STATE *walk_state, - ACPI_NAME_TABLE *name_table, - u32 position, - u32 entry_name, - OBJECT_TYPE_INTERNAL type) -{ - ACPI_NAMED_OBJECT *new_entry; - u16 owner_id = TABLE_ID_DSDT; - ACPI_NAMED_OBJECT *entries; + /* Search the parent tree */ /* - * Get the owner ID from the Walk state - * The owner ID is used to track table deletion and - * deletion of objects created by methods + * Search parents until found the target or we have backed up to + * the root */ - if (walk_state) { - owner_id = walk_state->owner_id; - } - - /* The new entry is given by two parameters */ - - entries = name_table->entries; - new_entry = &entries[position]; - - /* Init the new entry */ - new_entry->data_type = ACPI_DESC_TYPE_NAMED; - new_entry->name = entry_name; - new_entry->owner_id = owner_id; - new_entry->reference_count = 1; + while (parent_node) { + /* Search parent scope */ + /* TBD: [Investigate] Why ACPI_TYPE_ANY? */ + status = acpi_ns_search_node (target_name, parent_node, + ACPI_TYPE_ANY, return_node); - /* - * If adding a name with unknown type, or having to - * add the region in order to define fields in it, we - * have a forward reference. - */ + if (ACPI_SUCCESS (status)) { + return (status); + } - if ((ACPI_TYPE_ANY == type) || - (INTERNAL_TYPE_DEF_FIELD_DEFN == type) || - (INTERNAL_TYPE_BANK_FIELD_DEFN == type)) - { /* - * We don't want to abort here, however! - * We will fill in the actual type when the - * real definition is found later. + * Not found here, go up another level + * (until we reach the root) */ + parent_node = acpi_ns_get_parent_object (parent_node); } - /* - * The Def_field_defn and Bank_field_defn cases are actually - * looking up the Region in which the field will be defined - */ - - if ((INTERNAL_TYPE_DEF_FIELD_DEFN == type) || - (INTERNAL_TYPE_BANK_FIELD_DEFN == type)) - { - type = ACPI_TYPE_REGION; - } - /* - * Scope, Def_any, and Index_field_defn are bogus "types" which do - * not actually have anything to do with the type of the name - * being looked up. Save any other value of Type as the type of - * the entry. - */ + /* Not found in parent tree */ - if ((type != INTERNAL_TYPE_SCOPE) && - (type != INTERNAL_TYPE_DEF_ANY) && - (type != INTERNAL_TYPE_INDEX_FIELD_DEFN)) - { - new_entry->type = (u8) type; - } - - return; + return (AE_NOT_FOUND); } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_ns_search_and_enter * - * PARAMETERS: Entry_name - Ascii ACPI name to search for (4 chars) - * *Name_table - Starting table where search will begin - * Interpreter_mode - Add names only in MODE_Load_pass_x. Otherwise, - * search only. + * PARAMETERS: Target_name - Ascii ACPI name to search for (4 chars) + * Walk_state - Current state of the walk + * *Node - Starting table where search will begin + * Interpreter_mode - Add names only in MODE_Load_pass_x. + * Otherwise,search only. * Type - Object type to match - * **Ret_entry - Where the matched NTE is returned + * Flags - Flags describing the search restrictions + * **Return_node - Where the Node is returned * * RETURN: Status * @@ -506,51 +251,48 @@ * In IMODE_EXECUTE, search only. * In other modes, search and add if not found. * - ***************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_ns_search_and_enter ( - u32 entry_name, + u32 target_name, ACPI_WALK_STATE *walk_state, - ACPI_NAME_TABLE *name_table, + ACPI_NAMESPACE_NODE *node, OPERATING_MODE interpreter_mode, OBJECT_TYPE_INTERNAL type, u32 flags, - ACPI_NAMED_OBJECT **ret_entry) + ACPI_NAMESPACE_NODE **return_node) { - u32 position; /* position in table */ ACPI_STATUS status; - NS_SEARCH_DATA search_info; - ACPI_NAMED_OBJECT *entry; - ACPI_NAMED_OBJECT *entries; + ACPI_NAMESPACE_NODE *new_node; /* Parameter validation */ - if (!name_table || !entry_name || !ret_entry) { - REPORT_ERROR ("Ns_search_and_enter: bad parameter"); + if (!node || !target_name || !return_node) { + REPORT_ERROR ("Ns_search_and_enter: bad (null)parameter"); return (AE_BAD_PARAMETER); } /* Name must consist of printable characters */ - if (!acpi_cm_valid_acpi_name (entry_name)) { + if (!acpi_cm_valid_acpi_name (target_name)) { + REPORT_ERROR ("Ns_search_and_enter: Bad character in ACPI Name"); return (AE_BAD_CHARACTER); } /* Try to find the name in the table specified by the caller */ - *ret_entry = ENTRY_NOT_FOUND; - status = acpi_ns_search_one_scope (entry_name, name_table, - type, ret_entry, &search_info); + *return_node = ENTRY_NOT_FOUND; + status = acpi_ns_search_node (target_name, node, + type, return_node); if (status != AE_NOT_FOUND) { /* * Either found it or there was an error * -- finished either way */ - return (status); } @@ -573,10 +315,9 @@ * to ACPI specification */ - status = acpi_ns_search_parent_tree (entry_name, name_table, - type, ret_entry); - - if (status == AE_OK) { + status = acpi_ns_search_parent_tree (target_name, node, + type, return_node); + if (ACPI_SUCCESS (status)) { return (status); } } @@ -585,61 +326,22 @@ /* * In execute mode, just search, never add names. Exit now. */ - if (interpreter_mode == IMODE_EXECUTE) { return (AE_NOT_FOUND); } - /* - * Extract the pertinent info from the search result struct. - * Name_table and position might now point to an appendage - */ - name_table = search_info.name_table; - position = search_info.position; + /* Create the new named object */ - - /* - * This block handles the case where the existing table is full. - * we must allocate a new table before we can initialize a new entry - */ - - if (search_info.table_full) { - status = acpi_ns_create_and_link_new_table (name_table); - if (status != AE_OK) { - return (status); - } - - /* Point to the first slot in the new table */ - - name_table = name_table->next_table; - position = 0; + new_node = acpi_ns_create_node (target_name); + if (!new_node) { + return (AE_NO_MEMORY); } + /* Install the new object into the parent's list of children */ - /* - * There is room in the table (or we have just allocated a new one.) - * Initialize the new entry - */ - - acpi_ns_initialize_entry (walk_state, name_table, position, - entry_name, type); - - - entries = name_table->entries; - *ret_entry = &entries[position]; - entry = &entries[position]; - - /* - * Increment the reference count(s) of all parents up to - * the root! - */ - - while (acpi_ns_get_parent_entry (entry)) { - entry = acpi_ns_get_parent_entry (entry); - entry->reference_count++; - } - + acpi_ns_install_node (walk_state, node, new_node, type); + *return_node = new_node; return (AE_OK); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/namespace/nsutils.c linux/drivers/acpi/namespace/nsutils.c --- v2.4.0-test8/linux/drivers/acpi/namespace/nsutils.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/namespace/nsutils.c Fri Sep 15 14:30:30 2000 @@ -1,8 +1,8 @@ - /****************************************************************************** * * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing - * parents and siblings and Scope manipulation + * parents and siblings and Scope manipulation + * $Revision: 69 $ * *****************************************************************************/ @@ -26,13 +26,13 @@ #include "acpi.h" -#include "namesp.h" -#include "interp.h" +#include "acnamesp.h" +#include "acinterp.h" #include "amlcode.h" -#include "tables.h" +#include "actables.h" #define _COMPONENT NAMESPACE - MODULE_NAME ("nsutils"); + MODULE_NAME ("nsutils") /**************************************************************************** @@ -49,7 +49,7 @@ u8 acpi_ns_valid_root_prefix ( - char prefix) + NATIVE_CHAR prefix) { return ((u8) (prefix == '\\')); @@ -70,7 +70,7 @@ u8 acpi_ns_valid_path_separator ( - char sep) + NATIVE_CHAR sep) { return ((u8) (sep == '.')); @@ -81,9 +81,9 @@ * * FUNCTION: Acpi_ns_get_type * - * PARAMETERS: Handle - Handle of nte to be examined + * PARAMETERS: Handle - Parent Node to be examined * - * RETURN: Type field from nte whose handle is passed + * RETURN: Type field from Node whose handle is passed * ***************************************************************************/ @@ -93,13 +93,11 @@ { if (!handle) { - /* Handle invalid */ - REPORT_WARNING ("Ns_get_type: Null handle"); return (ACPI_TYPE_ANY); } - return (((ACPI_NAMED_OBJECT*) handle)->type); + return (((ACPI_NAMESPACE_NODE *) handle)->type); } @@ -114,19 +112,19 @@ * ***************************************************************************/ -s32 +u32 acpi_ns_local ( OBJECT_TYPE_INTERNAL type) { if (!acpi_cm_valid_object_type (type)) { - /* type code out of range */ + /* Type code out of range */ REPORT_WARNING ("Ns_local: Invalid Object Type"); return (NSP_NORMAL); } - return ((s32) acpi_gbl_ns_properties[type] & NSP_LOCAL); + return ((u32) acpi_gbl_ns_properties[type] & NSP_LOCAL); } @@ -147,12 +145,12 @@ ACPI_STATUS acpi_ns_internalize_name ( - char *external_name, - char **converted_name) + NATIVE_CHAR *external_name, + NATIVE_CHAR **converted_name) { - char *result = NULL; - char *internal_name; - ACPI_SIZE num_segments; + NATIVE_CHAR *result = NULL; + NATIVE_CHAR *internal_name; + u32 num_segments; u8 fully_qualified = FALSE; u32 i; @@ -235,7 +233,7 @@ } else { - /* Convert char to uppercase and save it */ + /* Convert s8 to uppercase and save it */ result[i] = (char) TOUPPER (*external_name); external_name++; @@ -273,166 +271,17 @@ /**************************************************************************** * - * FUNCTION: Acpi_ns_externalize_name - * - * PARAMETERS: *Internal_name - Internal representation of name - * **Converted_name - Where to return the resulting - * external representation of name - * - * RETURN: Status - * - * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) - * to its external form (e.g. "\_PR_.CPU0") - * - ****************************************************************************/ - -ACPI_STATUS -acpi_ns_externalize_name ( - u32 internal_name_length, - char *internal_name, - u32 *converted_name_length, - char **converted_name) -{ - u32 prefix_length = 0; - u32 names_index = 0; - u32 names_count = 0; - u32 i = 0; - u32 j = 0; - - if (internal_name_length < 0 || - !internal_name || - !converted_name_length || - !converted_name) - { - return (AE_BAD_PARAMETER); - } - - /* - * Check for a prefix (one '\' | one or more '^'). - */ - switch (internal_name[0]) - { - case '\\': - prefix_length = 1; - break; - - case '^': - for (i = 0; i < internal_name_length; i++) { - if (internal_name[i] != '^') { - prefix_length = i + 1; - } - } - - if (i == internal_name_length) { - prefix_length = i; - } - - break; - } - - /* - * Check for object names. Note that there could be 0-255 of these - * 4-byte elements. - */ - if (prefix_length < internal_name_length) { - switch (internal_name[prefix_length]) - { - - /* 4-byte names */ - - case AML_MULTI_NAME_PREFIX_OP: - names_index = prefix_length + 2; - names_count = (u32) internal_name[prefix_length + 1]; - break; - - - /* two 4-byte names */ - - case AML_DUAL_NAME_PREFIX: - names_index = prefix_length + 1; - names_count = 2; - break; - - - /* Null_name */ - - case 0: - names_index = 0; - names_count = 0; - break; - - - /* one 4-byte name */ - - default: - names_index = prefix_length; - names_count = 1; - break; - } - } - - /* - * Calculate the length of Converted_name, which equals the length - * of the prefix, length of all object names, length of any required - * punctuation ('.') between object names, plus the NULL terminator. - */ - *converted_name_length = prefix_length + (4 * names_count) + - ((names_count > 0) ? (names_count - 1) : 0) + 1; - - /* - * Check to see if we're still in bounds. If not, there's a problem - * with Internal_name (invalid format). - */ - if (*converted_name_length > internal_name_length) { - REPORT_ERROR ("Ns_externalize_name: Invalid internal name.\n"); - return (AE_BAD_PATHNAME); - } - - /* - * Build Converted_name... - */ - - (*converted_name) = acpi_cm_callocate (*converted_name_length); - if (!(*converted_name)) { - return (AE_NO_MEMORY); - } - - j = 0; - - for (i = 0; i < prefix_length; i++) { - (*converted_name)[j++] = internal_name[i]; - } - - if (names_count > 0) { - for (i = 0; i < names_count; i++) { - if (i > 0) { - (*converted_name)[j++] = '.'; - } - - (*converted_name)[j++] = internal_name[names_index++]; - (*converted_name)[j++] = internal_name[names_index++]; - (*converted_name)[j++] = internal_name[names_index++]; - (*converted_name)[j++] = internal_name[names_index++]; - } - } - - return (AE_OK); -} - - -/**************************************************************************** - * * FUNCTION: Acpi_ns_convert_handle_to_entry * - * PARAMETERS: Handle - Handle to be converted to an NTE + * PARAMETERS: Handle - Handle to be converted to an Node * * RETURN: A Name table entry pointer * - * DESCRIPTION: Convert a namespace handle to a real NTE + * DESCRIPTION: Convert a namespace handle to a real Node * ****************************************************************************/ -ACPI_NAMED_OBJECT* +ACPI_NAMESPACE_NODE * acpi_ns_convert_handle_to_entry ( ACPI_HANDLE handle) { @@ -444,21 +293,21 @@ */ if (!handle) { - return NULL; + return (NULL); } if (handle == ACPI_ROOT_OBJECT) { - return acpi_gbl_root_object; + return (acpi_gbl_root_node); } /* We can at least attempt to verify the handle */ if (!VALID_DESCRIPTOR_TYPE (handle, ACPI_DESC_TYPE_NAMED)) { - return NULL; + return (NULL); } - return (ACPI_NAMED_OBJECT*) handle; + return ((ACPI_NAMESPACE_NODE *) handle); } @@ -466,16 +315,17 @@ * * FUNCTION: Acpi_ns_convert_entry_to_handle * - * PARAMETERS: Nte - NTE to be converted to a Handle + * PARAMETERS: Node - Node to be converted to a Handle * * RETURN: An USER ACPI_HANDLE * - * DESCRIPTION: Convert a real NTE to a namespace handle + * DESCRIPTION: Convert a real Node to a namespace handle * ****************************************************************************/ ACPI_HANDLE -acpi_ns_convert_entry_to_handle(ACPI_NAMED_OBJECT*nte) +acpi_ns_convert_entry_to_handle ( + ACPI_NAMESPACE_NODE *node) { @@ -485,21 +335,21 @@ * and keep all pointers within this subsystem! */ - return (ACPI_HANDLE) nte; + return ((ACPI_HANDLE) node); /* --------------------------------------------------- - if (!Nte) { - return NULL; + if (!Node) { + return (NULL); } - if (Nte == Acpi_gbl_Root_object) { - return ACPI_ROOT_OBJECT; + if (Node == Acpi_gbl_Root_node) { + return (ACPI_ROOT_OBJECT); } - return (ACPI_HANDLE) Nte; + return ((ACPI_HANDLE) Node); ------------------------------------------------------*/ } @@ -519,11 +369,11 @@ void acpi_ns_terminate (void) { - ACPI_OBJECT_INTERNAL *obj_desc; - ACPI_NAMED_OBJECT *entry; + ACPI_OPERAND_OBJECT *obj_desc; + ACPI_NAMESPACE_NODE *this_node; - entry = acpi_gbl_root_object; + this_node = acpi_gbl_root_node; /* * 1) Free the entire namespace -- all objects, tables, and stacks @@ -533,22 +383,19 @@ * (additional table descriptors) */ - acpi_ns_delete_namespace_subtree (entry); + acpi_ns_delete_namespace_subtree (this_node); /* Detach any object(s) attached to the root */ - obj_desc = acpi_ns_get_attached_object (entry); + obj_desc = acpi_ns_get_attached_object (this_node); if (obj_desc) { - acpi_ns_detach_object (entry); + acpi_ns_detach_object (this_node); acpi_cm_remove_reference (obj_desc); } - acpi_ns_delete_name_table (entry->child_table); - entry->child_table = NULL; + acpi_ns_delete_children (this_node); - REPORT_SUCCESS ("Entire namespace and objects deleted"); - /* * 2) Now we can delete the ACPI tables */ @@ -570,7 +417,7 @@ * ***************************************************************************/ -s32 +u32 acpi_ns_opens_scope ( OBJECT_TYPE_INTERNAL type) { @@ -582,47 +429,46 @@ return (NSP_NORMAL); } - return (((s32) acpi_gbl_ns_properties[type]) & NSP_NEWSCOPE); + return (((u32) acpi_gbl_ns_properties[type]) & NSP_NEWSCOPE); } /**************************************************************************** * - * FUNCTION: Acpi_ns_get_named_object + * FUNCTION: Acpi_ns_get_node * * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The * \ (backslash) and ^ (carat) prefixes, and the * . (period) to separate segments are supported. - * In_scope - Root of subtree to be searched, or NS_ALL for the + * Start_node - Root of subtree to be searched, or NS_ALL for the * root of the name space. If Name is fully - * qualified (first char is '\'), the passed value + * qualified (first s8 is '\'), the passed value * of Scope will not be accessed. - * Out_nte - Where the Nte is returned + * Return_node - Where the Node is returned * * DESCRIPTION: Look up a name relative to a given scope and return the - * corresponding NTE. NOTE: Scope can be null. + * corresponding Node. NOTE: Scope can be null. * * MUTEX: Locks namespace * ***************************************************************************/ ACPI_STATUS -acpi_ns_get_named_object ( - char *pathname, - ACPI_NAME_TABLE *in_scope, - ACPI_NAMED_OBJECT **out_nte) +acpi_ns_get_node ( + NATIVE_CHAR *pathname, + ACPI_NAMESPACE_NODE *start_node, + ACPI_NAMESPACE_NODE **return_node) { ACPI_GENERIC_STATE scope_info; ACPI_STATUS status; - ACPI_NAMED_OBJECT *obj_entry = NULL; - char *internal_path = NULL; + NATIVE_CHAR *internal_path = NULL; - scope_info.scope.name_table = in_scope; + scope_info.scope.node = start_node; /* Ensure that the namespace has been initialized */ - if (!acpi_gbl_root_object->child_table) { + if (!acpi_gbl_root_node) { return (AE_NO_NAMESPACE); } @@ -643,13 +489,13 @@ /* NS_ALL means start from the root */ - if (NS_ALL == scope_info.scope.name_table) { - scope_info.scope.name_table = acpi_gbl_root_object->child_table; + if (NS_ALL == scope_info.scope.node) { + scope_info.scope.node = acpi_gbl_root_node; } else { - scope_info.scope.name_table = in_scope; - if (!scope_info.scope.name_table) { + scope_info.scope.node = start_node; + if (!scope_info.scope.node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } @@ -660,12 +506,8 @@ status = acpi_ns_lookup (&scope_info, internal_path, ACPI_TYPE_ANY, IMODE_EXECUTE, NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &obj_entry); - + NULL, return_node); - /* Return what was wanted - the NTE that matches the name */ - - *out_nte = obj_entry; unlock_and_exit: @@ -684,11 +526,11 @@ * * FUNCTION: Acpi_ns_find_parent_name * - * PARAMETERS: *Child_entry - nte whose name is to be found + * PARAMETERS: *Child_node - Named Obj whose name is to be found * * RETURN: The ACPI name * - * DESCRIPTION: Search for the given nte in its parent scope and return the + * DESCRIPTION: Search for the given obj in its parent scope and return the * name segment, or "????" if the parent name can't be found * (which "should not happen"). * @@ -696,18 +538,18 @@ ACPI_NAME acpi_ns_find_parent_name ( - ACPI_NAMED_OBJECT *child_entry) + ACPI_NAMESPACE_NODE *child_node) { - ACPI_NAMED_OBJECT *parent_entry; + ACPI_NAMESPACE_NODE *parent_node; - if (child_entry) { - /* Valid entry. Get the parent Nte */ + if (child_node) { + /* Valid entry. Get the parent Node */ - parent_entry = acpi_ns_get_parent_entry (child_entry); - if (parent_entry) { - if (parent_entry->name) { - return (parent_entry->name); + parent_node = acpi_ns_get_parent_object (child_node); + if (parent_node) { + if (parent_node->name) { + return (parent_node->name); } } @@ -717,92 +559,12 @@ return (ACPI_UNKNOWN_NAME); } -/**************************************************************************** - * - * FUNCTION: Acpi_ns_exist_downstream_sibling - * - * PARAMETERS: *This_entry - pointer to first nte to examine - * - * RETURN: TRUE if sibling is found, FALSE otherwise - * - * DESCRIPTION: Searches remainder of scope being processed to determine - * whether there is a downstream sibling to the current - * object. This function is used to determine what type of - * line drawing character to use when displaying namespace - * trees. - * - ***************************************************************************/ - -u8 -acpi_ns_exist_downstream_sibling ( - ACPI_NAMED_OBJECT *this_entry) -{ - - if (!this_entry) { - return FALSE; - } - - if (this_entry->name) { - return TRUE; - } - - -/* TBD: what did this really do? - if (This_entry->Next_entry) { - return TRUE; - } -*/ - return FALSE; -} - - -/**************************************************************************** - * - * FUNCTION: Acpi_ns_get_owner_table - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: - * - ***************************************************************************/ - - -ACPI_NAME_TABLE * -acpi_ns_get_owner_table ( - ACPI_NAMED_OBJECT *this_entry) -{ - - /* - * Given an entry in the Name_table->Entries field of a name table, - * we can create a pointer to the beginning of the table as follows: - * - * 1) Starting with the the pointer to the entry, - * 2) Subtract the entry index * size of each entry to get a - * pointer to Entries[0] - * 3) Subtract the size of NAME_TABLE structure to get a pointer - * to the start. - * - * This saves having to put a pointer in every entry that points - * back to the beginning of the table and/or a pointer back to - * the parent. - */ - - return (ACPI_NAME_TABLE *) ((char *) this_entry - - (this_entry->this_index * - sizeof (ACPI_NAMED_OBJECT)) - - (sizeof (ACPI_NAME_TABLE) - - sizeof (ACPI_NAMED_OBJECT))); - -} - /**************************************************************************** * - * FUNCTION: Acpi_ns_get_parent_entry + * FUNCTION: Acpi_ns_get_parent_object * - * PARAMETERS: This_entry - Current table entry + * PARAMETERS: Node - Current table entry * * RETURN: Parent entry of the given entry * @@ -811,76 +573,58 @@ ***************************************************************************/ -ACPI_NAMED_OBJECT * -acpi_ns_get_parent_entry ( - ACPI_NAMED_OBJECT *this_entry) +ACPI_NAMESPACE_NODE * +acpi_ns_get_parent_object ( + ACPI_NAMESPACE_NODE *node) { - ACPI_NAME_TABLE *name_table; - name_table = acpi_ns_get_owner_table (this_entry); - /* - * Now that we have a pointer to the name table, we can just pluck - * the parent + * Walk to the end of this peer list. + * The last entry is marked with a flag and the peer + * pointer is really a pointer back to the parent. + * This saves putting a parent back pointer in each and + * every named object! */ - return (name_table->parent_entry); + while (!(node->flags & ANOBJ_END_OF_PEER_LIST)) { + node = node->peer; + } + + + return (node->peer); } /**************************************************************************** * - * FUNCTION: Acpi_ns_get_next_valid_entry + * FUNCTION: Acpi_ns_get_next_valid_object * - * PARAMETERS: This_entry - Current table entry + * PARAMETERS: Node - Current table entry * * RETURN: Next valid object in the table. NULL if no more valid * objects * * DESCRIPTION: Find the next valid object within a name table. + * Useful for implementing NULL-end-of-list loops. * ***************************************************************************/ -ACPI_NAMED_OBJECT * -acpi_ns_get_next_valid_entry ( - ACPI_NAMED_OBJECT *this_entry) +ACPI_NAMESPACE_NODE * +acpi_ns_get_next_valid_object ( + ACPI_NAMESPACE_NODE *node) { - ACPI_NAME_TABLE *name_table; - u32 index; - - - index = this_entry->this_index + 1; - name_table = acpi_ns_get_owner_table (this_entry); - - - while (name_table) { - if (index >= NS_TABLE_SIZE) { - /* We are at the end of this table */ - name_table = name_table->next_table; - index = 0; - continue; - } - - - /* Is this a valid (occupied) slot? */ - - if (name_table->entries[index].name) { - /* Found a valid entry, all done */ + /* If we are at the end of this peer list, return NULL */ - return (&name_table->entries[index]); - } - - /* Go to the next slot */ - - index++; + if (node->flags & ANOBJ_END_OF_PEER_LIST) { + return NULL; } - /* No more valid entries in this name table */ + /* Otherwise just return the next peer */ - return NULL; + return (node->peer); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/namespace/nswalk.c linux/drivers/acpi/namespace/nswalk.c --- v2.4.0-test8/linux/drivers/acpi/namespace/nswalk.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/namespace/nswalk.c Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: nswalk - Functions for walking the APCI namespace + * $Revision: 17 $ * *****************************************************************************/ @@ -25,90 +25,85 @@ #include "acpi.h" -#include "interp.h" -#include "namesp.h" +#include "acinterp.h" +#include "acnamesp.h" #define _COMPONENT NAMESPACE - MODULE_NAME ("nswalk"); + MODULE_NAME ("nswalk") /**************************************************************************** * * FUNCTION: Acpi_get_next_object * - * PARAMETERS: Type - Type of object to be searched for - * Parent - Parent object whose children we are getting - * Last_child - Previous child that was found. - * The NEXT child will be returned - * Ret_handle - Where handle to the next object is placed - * - * RETURN: Status - * - * DESCRIPTION: Return the next peer object within the namespace. If Handle is - * valid, Scope is ignored. Otherwise, the first object within - * Scope is returned. + * PARAMETERS: Type - Type of object to be searched for + * Parent - Parent object whose children we are + * getting + * Last_child - Previous child that was found. + * The NEXT child will be returned + * + * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if + * none is found. + * + * DESCRIPTION: Return the next peer object within the namespace. If Handle + * is valid, Scope is ignored. Otherwise, the first object + * within Scope is returned. * - ******************************************************************************/ + ****************************************************************************/ -ACPI_NAMED_OBJECT* +ACPI_NAMESPACE_NODE * acpi_ns_get_next_object ( OBJECT_TYPE_INTERNAL type, - ACPI_NAMED_OBJECT *parent, - ACPI_NAMED_OBJECT *child) + ACPI_NAMESPACE_NODE *parent_node, + ACPI_NAMESPACE_NODE *child_node) { - ACPI_NAMED_OBJECT *this_entry = NULL; + ACPI_NAMESPACE_NODE *next_node = NULL; - if (!child) { + if (!child_node) { /* It's really the parent's _scope_ that we want */ - if (parent->child_table) { - this_entry = parent->child_table->entries; + if (parent_node->child) { + next_node = parent_node->child; } } else { /* Start search at the NEXT object */ - this_entry = acpi_ns_get_next_valid_entry (child); + next_node = acpi_ns_get_next_valid_object (child_node); } /* If any type is OK, we are done */ if (type == ACPI_TYPE_ANY) { - /* Make sure this is valid entry first */ - - if ((!this_entry) || - (!this_entry->name)) - { - return NULL; - } + /* Next_node is NULL if we are at the end-of-list */ - return (this_entry); + return (next_node); } /* Must search for the object -- but within this scope only */ - while (this_entry) { + while (next_node) { /* If type matches, we are done */ - if (this_entry->type == type) { - return (this_entry); + if (next_node->type == type) { + return (next_node); } /* Otherwise, move on to the next object */ - this_entry = acpi_ns_get_next_valid_entry (this_entry); + next_node = acpi_ns_get_next_valid_object (next_node); } /* Not found */ - return NULL; + return (NULL); } @@ -117,7 +112,7 @@ * FUNCTION: Acpi_ns_walk_namespace * * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for - * Start_object - Handle in namespace where search begins + * Start_node - Handle in namespace where search begins * Max_depth - Depth to which search is to reach * Unlock_before_callback- Whether to unlock the NS before invoking * the callback routine @@ -145,7 +140,7 @@ ACPI_STATUS acpi_ns_walk_namespace ( OBJECT_TYPE_INTERNAL type, - ACPI_HANDLE start_object, + ACPI_HANDLE start_node, u32 max_depth, u8 unlock_before_callback, WALK_CALLBACK user_function, @@ -153,25 +148,25 @@ void **return_value) { ACPI_STATUS status; - ACPI_NAMED_OBJECT *child_entry; - ACPI_NAMED_OBJECT *parent_entry; + ACPI_NAMESPACE_NODE *child_node; + ACPI_NAMESPACE_NODE *parent_node; OBJECT_TYPE_INTERNAL child_type; u32 level; - /* Special case for the namespace root object */ + /* Special case for the namespace Root Node */ - if (start_object == ACPI_ROOT_OBJECT) { - start_object = acpi_gbl_root_object; + if (start_node == ACPI_ROOT_OBJECT) { + start_node = acpi_gbl_root_node; } /* Null child means "get first object" */ - parent_entry = start_object; - child_entry = 0; - child_type = ACPI_TYPE_ANY; - level = 1; + parent_node = start_node; + child_node = 0; + child_type = ACPI_TYPE_ANY; + level = 1; /* * Traverse the tree of objects until we bubble back up to where we @@ -186,18 +181,18 @@ */ status = AE_OK; - child_entry = acpi_ns_get_next_object (ACPI_TYPE_ANY, - parent_entry, - child_entry); + child_node = acpi_ns_get_next_object (ACPI_TYPE_ANY, + parent_node, + child_node); - if (child_entry) { + if (child_node) { /* * Found an object, Get the type if we are not * searching for ANY */ if (type != ACPI_TYPE_ANY) { - child_type = child_entry->type; + child_type = child_node->type; } if (child_type == type) { @@ -210,7 +205,7 @@ acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); } - status = user_function (child_entry, level, + status = user_function (child_node, level, context, return_value); if (unlock_before_callback) { @@ -247,15 +242,15 @@ if ((level < max_depth) && (status != AE_CTRL_DEPTH)) { if (acpi_ns_get_next_object (ACPI_TYPE_ANY, - child_entry, 0)) + child_node, 0)) { /* * There is at least one child of this * object, visit the object */ level++; - parent_entry = child_entry; - child_entry = 0; + parent_node = child_node; + child_node = 0; } } } @@ -267,8 +262,8 @@ * the object's parent. */ level--; - child_entry = parent_entry; - parent_entry = acpi_ns_get_parent_entry (parent_entry); + child_node = parent_node; + parent_node = acpi_ns_get_parent_object (parent_node); } } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/namespace/nsxfname.c linux/drivers/acpi/namespace/nsxfname.c --- v2.4.0-test8/linux/drivers/acpi/namespace/nsxfname.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/namespace/nsxfname.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ * * Module Name: nsxfname - Public interfaces to the ACPI subsystem * ACPI Namespace oriented interfaces + * $Revision: 64 $ * *****************************************************************************/ @@ -25,16 +26,16 @@ #include "acpi.h" -#include "interp.h" -#include "namesp.h" +#include "acinterp.h" +#include "acnamesp.h" #include "amlcode.h" -#include "parser.h" -#include "dispatch.h" -#include "events.h" +#include "acparser.h" +#include "acdispat.h" +#include "acevents.h" #define _COMPONENT NAMESPACE - MODULE_NAME ("nsxfname"); + MODULE_NAME ("nsxfname") /****************************************************************************** @@ -64,21 +65,6 @@ } - /* Init the hardware */ - - /* - * TBD: [Restructure] Should this should be moved elsewhere, - * like Acpi_enable! ?? - */ - - /* we need to be able to call this interface repeatedly! */ - /* Does H/W require init before loading the namespace? */ - - status = acpi_cm_hardware_initialize (); - if (ACPI_FAILURE (status)) { - return (status); - } - /* * Load the namespace. The DSDT is required, * but the SSDT and PSDT tables are optional. @@ -131,24 +117,24 @@ ACPI_HANDLE *ret_handle) { ACPI_STATUS status; - ACPI_NAMED_OBJECT *this_entry; - ACPI_NAME_TABLE *scope = NULL; + ACPI_NAMESPACE_NODE *node; + ACPI_NAMESPACE_NODE *prefix_node = NULL; if (!ret_handle || !pathname) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } if (parent) { acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - this_entry = acpi_ns_convert_handle_to_entry (parent); - if (!this_entry) { + node = acpi_ns_convert_handle_to_entry (parent); + if (!node) { acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } - scope = this_entry->child_table; + prefix_node = node->child; acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); } @@ -156,17 +142,20 @@ /* TBD: [Investigate] Check for both forward and backslash?? */ if (STRCMP (pathname, NS_ROOT_PATH) == 0) { - *ret_handle = acpi_ns_convert_entry_to_handle (acpi_gbl_root_object); - return AE_OK; + *ret_handle = acpi_ns_convert_entry_to_handle (acpi_gbl_root_node); + return (AE_OK); } /* - * Find the Nte and convert to the user format + * Find the Node and convert to the user format */ - this_entry = NULL; - status = acpi_ns_get_named_object (pathname, scope, &this_entry); + node = NULL; + status = acpi_ns_get_node (pathname, prefix_node, &node); - *ret_handle = acpi_ns_convert_entry_to_handle (this_entry); + *ret_handle = NULL; + if(ACPI_SUCCESS(status)) { + *ret_handle = acpi_ns_convert_entry_to_handle (node); + } return (status); } @@ -195,13 +184,13 @@ ACPI_BUFFER *ret_path_ptr) { ACPI_STATUS status; - ACPI_NAMED_OBJECT *obj_entry; + ACPI_NAMESPACE_NODE *node; /* Buffer pointer must be valid always */ if (!ret_path_ptr || (name_type > ACPI_NAME_TYPE_MAX)) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } /* Allow length to be zero and ignore the pointer */ @@ -209,7 +198,7 @@ if ((ret_path_ptr->length) && (!ret_path_ptr->pointer)) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } if (name_type == ACPI_FULL_PATHNAME) { @@ -217,17 +206,17 @@ status = acpi_ns_handle_to_pathname (handle, &ret_path_ptr->length, ret_path_ptr->pointer); - return status; + return (status); } /* * Wants the single segment ACPI name. - * Validate handle and convert to an NTE + * Validate handle and convert to an Node */ acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - obj_entry = acpi_ns_convert_handle_to_entry (handle); - if (!obj_entry) { + node = acpi_ns_convert_handle_to_entry (handle); + if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } @@ -240,18 +229,18 @@ goto unlock_and_exit; } - /* Just copy the ACPI name from the NTE and zero terminate it */ + /* Just copy the ACPI name from the Node and zero terminate it */ - STRNCPY (ret_path_ptr->pointer, (char *) &obj_entry->name, + STRNCPY (ret_path_ptr->pointer, (NATIVE_CHAR *) &node->name, ACPI_NAME_SIZE); - ((char *) ret_path_ptr->pointer) [ACPI_NAME_SIZE] = 0; + ((NATIVE_CHAR *) ret_path_ptr->pointer) [ACPI_NAME_SIZE] = 0; status = AE_OK; unlock_and_exit: acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return status; + return (status); } @@ -279,27 +268,27 @@ ACPI_STATUS status; u32 device_status = 0; u32 address = 0; - ACPI_NAMED_OBJECT *device_entry; + ACPI_NAMESPACE_NODE *device_node; /* Parameter validation */ if (!device || !info) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); - device_entry = acpi_ns_convert_handle_to_entry (device); - if (!device_entry) { + device_node = acpi_ns_convert_handle_to_entry (device); + if (!device_node) { acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } - info->type = device_entry->type; - info->name = device_entry->name; - info->parent = - acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_entry (device_entry)); + info->type = device_node->type; + info->name = device_node->name; + info->parent = acpi_ns_convert_entry_to_handle ( + acpi_ns_get_parent_object (device_node)); acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); @@ -307,17 +296,17 @@ * If not a device, we are all done. */ if (info->type != ACPI_TYPE_DEVICE) { - return AE_OK; + return (AE_OK); } /* Get extra info for ACPI devices */ - info->valid = 0; + info->valid = 0; /* Execute the _HID method and save the result */ - status = acpi_cm_execute_HID (device_entry, &hid); + status = acpi_cm_execute_HID (device_node, &hid); if (ACPI_SUCCESS (status)) { if (hid.type == STRING_PTR_DEVICE_ID) { STRCPY (info->hardware_id, hid.data.string_ptr); @@ -331,7 +320,7 @@ /* Execute the _UID method and save the result */ - status = acpi_cm_execute_UID (device_entry, &uid); + status = acpi_cm_execute_UID (device_node, &uid); if (ACPI_SUCCESS (status)) { if (hid.type == STRING_PTR_DEVICE_ID) { STRCPY (info->unique_id, uid.data.string_ptr); @@ -348,7 +337,7 @@ * _STA is not always present */ - status = acpi_cm_execute_STA (device_entry, &device_status); + status = acpi_cm_execute_STA (device_node, &device_status); if (ACPI_SUCCESS (status)) { info->current_status = device_status; info->valid |= ACPI_VALID_STA; @@ -360,13 +349,13 @@ */ status = acpi_cm_evaluate_numeric_object (METHOD_NAME__ADR, - device_entry, &address); + device_node, &address); if (ACPI_SUCCESS (status)) { info->address = address; info->valid |= ACPI_VALID_ADR; } - return AE_OK; + return (AE_OK); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/namespace/nsxfobj.c linux/drivers/acpi/namespace/nsxfobj.c --- v2.4.0-test8/linux/drivers/acpi/namespace/nsxfobj.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/namespace/nsxfobj.c Fri Sep 15 14:30:30 2000 @@ -1,10 +1,10 @@ - -/****************************************************************************** +/******************************************************************************* * * Module Name: nsxfobj - Public interfaces to the ACPI subsystem * ACPI Object oriented interfaces + * $Revision: 65 $ * - *****************************************************************************/ + ******************************************************************************/ /* * Copyright (C) 2000 R. Byron Moore @@ -26,15 +26,15 @@ #include "acpi.h" -#include "interp.h" -#include "namesp.h" +#include "acinterp.h" +#include "acnamesp.h" #define _COMPONENT NAMESPACE - MODULE_NAME ("nsxfobj"); + MODULE_NAME ("nsxfobj") -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_evaluate_object * @@ -54,7 +54,7 @@ * parameters if necessary. One of "Handle" or "Pathname" must * be valid (non-null) * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_evaluate_object ( @@ -64,9 +64,9 @@ ACPI_BUFFER *return_buffer) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL **param_ptr = NULL; - ACPI_OBJECT_INTERNAL *return_obj = NULL; - ACPI_OBJECT_INTERNAL *object_ptr = NULL; + ACPI_OPERAND_OBJECT **param_ptr = NULL; + ACPI_OPERAND_OBJECT *return_obj = NULL; + ACPI_OPERAND_OBJECT *object_ptr = NULL; u32 buffer_space_needed; u32 user_buffer_length; u32 count; @@ -85,12 +85,11 @@ /* * Allocate a new parameter block for the internal objects * Add 1 to count to allow for null terminated internal list - * TBD: [Restructure] merge into single allocation! */ count = param_objects->count; param_length = (count + 1) * sizeof (void *); - object_length = count * sizeof (ACPI_OBJECT_INTERNAL); + object_length = count * sizeof (ACPI_OPERAND_OBJECT); param_ptr = acpi_cm_callocate (param_length + /* Parameter List part */ object_length); /* Actual objects */ @@ -98,7 +97,7 @@ return (AE_NO_MEMORY); } - object_ptr = (ACPI_OBJECT_INTERNAL *) ((u8 *) param_ptr + + object_ptr = (ACPI_OPERAND_OBJECT *) ((u8 *) param_ptr + param_length); /* @@ -169,18 +168,15 @@ * The null pathname case means the handle is for * the actual object to be evaluated */ - status = acpi_ns_evaluate_by_handle (handle, - param_ptr, - &return_obj); + status = acpi_ns_evaluate_by_handle (handle, param_ptr, &return_obj); } else { /* * Both a Handle and a relative Pathname */ - status = acpi_ns_evaluate_relative (handle, pathname, - param_ptr, - &return_obj); + status = acpi_ns_evaluate_relative (handle, pathname, param_ptr, + &return_obj); } } @@ -195,11 +191,9 @@ return_buffer->length = 0; if (return_obj) { - if (VALID_DESCRIPTOR_TYPE (return_obj, - ACPI_DESC_TYPE_NAMED)) - { + if (VALID_DESCRIPTOR_TYPE (return_obj, ACPI_DESC_TYPE_NAMED)) { /* - * If we got an NTE as a return object, + * If we got an Node as a return object, * this means the object we are evaluating * has nothing interesting to return (such * as a mutex, etc.) We return an error @@ -210,7 +204,7 @@ * types at a later date if necessary. */ status = AE_TYPE; - return_obj = NULL; /* No need to delete an NTE */ + return_obj = NULL; /* No need to delete an Node */ } if (ACPI_SUCCESS (status)) { @@ -241,9 +235,8 @@ /* * We have enough space for the object, build it */ - status = - acpi_cm_build_external_object (return_obj, - return_buffer); + status = acpi_cm_build_external_object (return_obj, + return_buffer); return_buffer->length = buffer_space_needed; } } @@ -276,7 +269,7 @@ } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_get_next_object * @@ -302,15 +295,15 @@ ACPI_HANDLE *ret_handle) { ACPI_STATUS status = AE_OK; - ACPI_NAMED_OBJECT *entry; - ACPI_NAMED_OBJECT *parent_entry = NULL; - ACPI_NAMED_OBJECT *child_entry = NULL; + ACPI_NAMESPACE_NODE *node; + ACPI_NAMESPACE_NODE *parent_node = NULL; + ACPI_NAMESPACE_NODE *child_node = NULL; /* Parameter validation */ if (type > ACPI_TYPE_MAX) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); @@ -320,8 +313,8 @@ if (!child) { /* Start search at the beginning of the specified scope */ - parent_entry = acpi_ns_convert_handle_to_entry (parent); - if (!parent_entry) { + parent_node = acpi_ns_convert_handle_to_entry (parent); + if (!parent_node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } @@ -332,8 +325,8 @@ else { /* Convert and validate the handle */ - child_entry = acpi_ns_convert_handle_to_entry (child); - if (!child_entry) { + child_node = acpi_ns_convert_handle_to_entry (child); + if (!child_node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } @@ -342,26 +335,26 @@ /* Internal function does the real work */ - entry = acpi_ns_get_next_object ((OBJECT_TYPE_INTERNAL) type, - parent_entry, child_entry); - if (!entry) { + node = acpi_ns_get_next_object ((OBJECT_TYPE_INTERNAL) type, + parent_node, child_node); + if (!node) { status = AE_NOT_FOUND; goto unlock_and_exit; } if (ret_handle) { - *ret_handle = acpi_ns_convert_entry_to_handle (entry); + *ret_handle = acpi_ns_convert_entry_to_handle (node); } unlock_and_exit: acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return status; + return (status); } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_get_type * @@ -379,44 +372,43 @@ ACPI_HANDLE handle, ACPI_OBJECT_TYPE *ret_type) { - ACPI_NAMED_OBJECT *object; + ACPI_NAMESPACE_NODE *node; /* Parameter Validation */ if (!ret_type) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } /* - * Special case for the predefined Root Object + * Special case for the predefined Root Node * (return type ANY) */ - if (handle == ACPI_ROOT_OBJECT) { *ret_type = ACPI_TYPE_ANY; - return AE_OK; + return (AE_OK); } acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); /* Convert and validate the handle */ - object = acpi_ns_convert_handle_to_entry (handle); - if (!object) { + node = acpi_ns_convert_handle_to_entry (handle); + if (!node) { acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } - *ret_type = object->type; + *ret_type = node->type; acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return AE_OK; + return (AE_OK); } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_get_parent * @@ -435,7 +427,7 @@ ACPI_HANDLE handle, ACPI_HANDLE *ret_handle) { - ACPI_NAMED_OBJECT *object; + ACPI_NAMESPACE_NODE *node; ACPI_STATUS status = AE_OK; @@ -443,13 +435,13 @@ if (!ret_handle) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } - /* Special case for the predefined Root Object (no parent) */ + /* Special case for the predefined Root Node (no parent) */ if (handle == ACPI_ROOT_OBJECT) { - return AE_NULL_ENTRY; + return (AE_NULL_ENTRY); } @@ -457,8 +449,8 @@ /* Convert and validate the handle */ - object = acpi_ns_convert_handle_to_entry (handle); - if (!object) { + node = acpi_ns_convert_handle_to_entry (handle); + if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } @@ -467,11 +459,11 @@ /* Get the parent entry */ *ret_handle = - acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_entry (object)); + acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_object (node)); /* Return exeption if parent is null */ - if (!acpi_ns_get_parent_entry (object)) { + if (!acpi_ns_get_parent_object (node)) { status = AE_NULL_ENTRY; } @@ -479,11 +471,11 @@ unlock_and_exit: acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); - return AE_OK; + return (status); } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: Acpi_walk_namespace * diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/os.c linux/drivers/acpi/os.c --- v2.4.0-test8/linux/drivers/acpi/os.c Fri Jul 14 12:12:08 2000 +++ linux/drivers/acpi/os.c Fri Sep 15 14:30:30 2000 @@ -29,6 +29,9 @@ #include "acpi.h" #include "driver.h" +#define _COMPONENT OS_DEPENDENT + MODULE_NAME ("os") + static int acpi_irq_irq = 0; static OSD_HANDLER acpi_irq_handler = NULL; static void *acpi_irq_context = NULL; @@ -61,7 +64,7 @@ } s32 -acpi_os_printf(const char *fmt,...) +acpi_os_printf(const NATIVE_CHAR *fmt,...) { s32 size; va_list args; @@ -72,11 +75,11 @@ } s32 -acpi_os_vprintf(const char *fmt, va_list args) +acpi_os_vprintf(const NATIVE_CHAR *fmt, va_list args) { static char buffer[512]; int size = vsprintf(buffer, fmt, args); - printk(KERN_DEBUG "ACPI: %s", buffer); + printk("%s", buffer); return size; } @@ -137,7 +140,7 @@ acpi_irq_context = context; if (request_irq(irq, acpi_irq, - SA_INTERRUPT | SA_SHIRQ, + SA_SHIRQ, "acpi", acpi_irq)) { printk(KERN_ERR "ACPI: SCI (IRQ%d) allocation failed\n", irq); @@ -338,7 +341,7 @@ } ACPI_STATUS -acpi_os_breakpoint(char *msg) +acpi_os_breakpoint(NATIVE_CHAR *msg) { acpi_os_printf("breakpoint: %s", msg); return AE_OK; @@ -351,13 +354,13 @@ } void -acpi_os_dbg_assert(void *failure, void *file, u32 line, char *msg) +acpi_os_dbg_assert(void *failure, void *file, u32 line, NATIVE_CHAR *msg) { acpi_os_printf("assert: %s", msg); } u32 -acpi_os_get_line(char *buffer) +acpi_os_get_line(NATIVE_CHAR *buffer) { return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/parser/Makefile linux/drivers/acpi/parser/Makefile --- v2.4.0-test8/linux/drivers/acpi/parser/Makefile Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/parser/Makefile Fri Sep 15 18:21:44 2000 @@ -0,0 +1,28 @@ +# +# Makefile for all Linux ACPI interpreter subdirectories +# + +SUB_DIRS := +MOD_SUB_DIRS := $(SUB_DIRS) +MOD_IN_SUB_DIRS := +ALL_SUB_DIRS := $(SUB_DIRS) + +O_TARGET := ../$(shell basename `pwd`).o +O_OBJS := +M_OBJS := + +ACPI_OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) + +EXTRA_CFLAGS += -I../include + +EXTRA_CFLAGS += $(ACPI_CFLAGS) + +# if the interpreter is used, it overrides arch/i386/kernel/acpi.c +ifeq ($(CONFIG_ACPI_INTERPRETER),y) + O_OBJS := $(ACPI_OBJS) +endif + +include $(TOPDIR)/Rules.make + +clean: + $(RM) *.o diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/parser/psargs.c linux/drivers/acpi/parser/psargs.c --- v2.4.0-test8/linux/drivers/acpi/parser/psargs.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/parser/psargs.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: psargs - Parse AML opcode arguments + * $Revision: 35 $ * *****************************************************************************/ @@ -24,12 +25,26 @@ #include "acpi.h" -#include "parser.h" +#include "acparser.h" #include "amlcode.h" -#include "namesp.h" +#include "acnamesp.h" #define _COMPONENT PARSER - MODULE_NAME ("psargs"); + MODULE_NAME ("psargs") + + +u32 +acpi_ps_pkg_length_encoding_size ( + u32 first_byte) +{ + + /* + * Bits 6-7 contain the number of bytes + * in the encoded package length (-1) + */ + + return ((first_byte >> 6) + 1); +} /******************************************************************************* @@ -46,14 +61,63 @@ ******************************************************************************/ u32 +xxx_acpi_ps_get_next_package_length ( + ACPI_PARSE_STATE *parser_state) +{ + u32 encoding_length; + u32 package_length = 0; + u8 *aml_ptr = parser_state->aml; + + + encoding_length = acpi_ps_pkg_length_encoding_size ((u32) GET8 (aml_ptr)); + + + switch (encoding_length) + { + case 1: /* 1-byte encoding (bits 0-5) */ + + package_length = ((u32) GET8 (aml_ptr) & 0x3f); + break; + + + case 2: /* 2-byte encoding (next byte + bits 0-3) */ + + package_length = ((((u32) GET8 (aml_ptr + 1)) << 4) | + (((u32) GET8 (aml_ptr)) & 0x0f)); + break; + + + case 3: /* 3-byte encoding (next 2 bytes + bits 0-3) */ + + package_length = ((((u32) GET8 (aml_ptr + 2)) << 12) | + (((u32) GET8 (aml_ptr + 1)) << 4) | + (((u32) GET8 (aml_ptr)) & 0x0f)); + break; + + + case 4: /* 4-byte encoding (next 3 bytes + bits 0-3) */ + + package_length = ((((u32) GET8 (aml_ptr + 3)) << 20) | + (((u32) GET8 (aml_ptr + 2)) << 12) | + (((u32) GET8 (aml_ptr + 1)) << 4) | + (((u32) GET8 (aml_ptr)) & 0x0f)); + break; + } + + parser_state->aml += encoding_length; + + return (package_length); +} + +u32 acpi_ps_get_next_package_length ( ACPI_PARSE_STATE *parser_state) { - s32 encoded_length; - s32 length = 0; + u32 encoded_length; + u32 length = 0; - encoded_length = (s32) GET8 (parser_state->aml); + encoded_length = (u32) GET8 (parser_state->aml); parser_state->aml++; @@ -137,13 +201,13 @@ * ******************************************************************************/ -char * +NATIVE_CHAR * acpi_ps_get_next_namestring ( ACPI_PARSE_STATE *parser_state) { - char *start = (char *) parser_state->aml; - char *end = (char *) parser_state->aml; - s32 length; + u8 *start = parser_state->aml; + u8 *end = parser_state->aml; + u32 length; /* Handle multiple prefix characters */ @@ -181,7 +245,7 @@ /* multiple name segments */ - length = (s32) GET8 (end + 1) * 4; + length = (u32) GET8 (end + 1) * 4; end += 2 + length; break; @@ -197,7 +261,7 @@ parser_state->aml = (u8*) end; - return (start); + return ((NATIVE_CHAR *) start); } @@ -228,14 +292,14 @@ void acpi_ps_get_next_namepath ( ACPI_PARSE_STATE *parser_state, - ACPI_GENERIC_OP *arg, + ACPI_PARSE_OBJECT *arg, u32 *arg_count, u8 method_call) { - char *path; - ACPI_GENERIC_OP *name; - ACPI_GENERIC_OP *op; - ACPI_GENERIC_OP *count; + NATIVE_CHAR *path; + ACPI_PARSE_OBJECT *name_op; + ACPI_PARSE_OBJECT *op; + ACPI_PARSE_OBJECT *count; path = acpi_ps_get_next_namestring (parser_state); @@ -270,18 +334,18 @@ count = acpi_ps_get_arg (op, 0); if (count && count->opcode == AML_BYTE_OP) { - name = acpi_ps_alloc_op (AML_NAMEPATH_OP); - if (name) { + name_op = acpi_ps_alloc_op (AML_NAMEPATH_OP); + if (name_op) { /* Change arg into a METHOD CALL and attach the name */ acpi_ps_init_op (arg, AML_METHODCALL_OP); - name->value.name = path; + name_op->value.name = path; - /* Point METHODCALL/NAME to the METHOD NTE */ + /* Point METHODCALL/NAME to the METHOD Node */ - name->acpi_named_object = op; - acpi_ps_append_arg (arg, name); + name_op->node = (ACPI_NAMESPACE_NODE *) op; + acpi_ps_append_arg (arg, name_op); *arg_count = count->value.integer & METHOD_FLAGS_ARG_COUNT; @@ -320,15 +384,15 @@ void acpi_ps_get_next_namepath ( ACPI_PARSE_STATE *parser_state, - ACPI_GENERIC_OP *arg, + ACPI_PARSE_OBJECT *arg, u32 *arg_count, u8 method_call) { - char *path; - ACPI_GENERIC_OP *name; + NATIVE_CHAR *path; + ACPI_PARSE_OBJECT *name_op; ACPI_STATUS status; - ACPI_NAMED_OBJECT *method = NULL; - ACPI_NAMED_OBJECT *entry; + ACPI_NAMESPACE_NODE *method_node = NULL; + ACPI_NAMESPACE_NODE *node; ACPI_GENERIC_STATE scope_info; @@ -346,10 +410,10 @@ /* * Lookup the name in the internal namespace */ - scope_info.scope.name_table = NULL; - entry = parser_state->start_op->acpi_named_object; - if (entry) { - scope_info.scope.name_table = entry->child_table; + scope_info.scope.node = NULL; + node = parser_state->start_node; + if (node) { + scope_info.scope.node = node; } /* @@ -361,24 +425,24 @@ status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY, IMODE_EXECUTE, NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, NULL, - &entry); + &node); if (ACPI_SUCCESS (status)) { - if (entry->type == ACPI_TYPE_METHOD) { - method = entry; - name = acpi_ps_alloc_op (AML_NAMEPATH_OP); - if (name) { + if (node->type == ACPI_TYPE_METHOD) { + method_node = node; + name_op = acpi_ps_alloc_op (AML_NAMEPATH_OP); + if (name_op) { /* Change arg into a METHOD CALL and attach name to it */ acpi_ps_init_op (arg, AML_METHODCALL_OP); - name->value.name = path; + name_op->value.name = path; - /* Point METHODCALL/NAME to the METHOD NTE */ + /* Point METHODCALL/NAME to the METHOD Node */ - name->acpi_named_object = method; - acpi_ps_append_arg (arg, name); + name_op->node = method_node; + acpi_ps_append_arg (arg, name_op); - *arg_count = ((ACPI_OBJECT_INTERNAL *) method->object)->method.param_count; + *arg_count = ((ACPI_OPERAND_OBJECT *) method_node->object)->method.param_count; } return; @@ -424,8 +488,8 @@ void acpi_ps_get_next_simple_arg ( ACPI_PARSE_STATE *parser_state, - s32 arg_type, - ACPI_GENERIC_OP *arg) + u32 arg_type, + ACPI_PARSE_OBJECT *arg) { @@ -498,13 +562,13 @@ * ******************************************************************************/ -ACPI_GENERIC_OP * +ACPI_PARSE_OBJECT * acpi_ps_get_next_field ( ACPI_PARSE_STATE *parser_state) { ACPI_PTRDIFF aml_offset = parser_state->aml - parser_state->aml_start; - ACPI_GENERIC_OP *field; + ACPI_PARSE_OBJECT *field; u16 opcode; u32 name; @@ -598,16 +662,16 @@ * ******************************************************************************/ -ACPI_GENERIC_OP * +ACPI_PARSE_OBJECT * acpi_ps_get_next_arg ( ACPI_PARSE_STATE *parser_state, - s32 arg_type, + u32 arg_type, u32 *arg_count) { - ACPI_GENERIC_OP *arg = NULL; - ACPI_GENERIC_OP *prev = NULL; - ACPI_GENERIC_OP *field; - s32 subop; + ACPI_PARSE_OBJECT *arg = NULL; + ACPI_PARSE_OBJECT *prev = NULL; + ACPI_PARSE_OBJECT *field; + u32 subop; switch (arg_type) @@ -675,7 +739,7 @@ /* fill in bytelist data */ arg->value.size = (parser_state->pkg_end - parser_state->aml); - acpi_ps_to_bytelist_op (arg)->data = parser_state->aml; + ((ACPI_PARSE2_OBJECT *) arg)->data = parser_state->aml; } /* skip to End of byte data */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/parser/psfind.c linux/drivers/acpi/parser/psfind.c --- v2.4.0-test8/linux/drivers/acpi/parser/psfind.c Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/parser/psfind.c Fri Sep 15 14:30:30 2000 @@ -0,0 +1,319 @@ + +/****************************************************************************** + * + * Module Name: psfind - Parse tree search routine + * $Revision: 16 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * 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 + */ + + +#include "acpi.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT PARSER + MODULE_NAME ("psfind") + + +/******************************************************************************* + * + * FUNCTION: Acpi_ps_get_parent + * + * PARAMETERS: Op - Get the parent of this Op + * + * RETURN: The Parent op. + * + * DESCRIPTION: Get op's parent + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +acpi_ps_get_parent ( + ACPI_PARSE_OBJECT *op) +{ + ACPI_PARSE_OBJECT *parent = op; + + + /* Traverse the tree upward (to root if necessary) */ + + while (parent) { + switch (parent->opcode) + { + case AML_SCOPE_OP: + case AML_PACKAGE_OP: + case AML_METHOD_OP: + case AML_DEVICE_OP: + case AML_POWER_RES_OP: + case AML_THERMAL_ZONE_OP: + + return (parent->parent); + } + + parent = parent->parent; + } + + return (parent); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_ps_find_name + * + * PARAMETERS: Scope - Scope to search + * Name - ACPI name to search for + * Opcode - Opcode to search for + * + * RETURN: Op containing the name + * + * DESCRIPTION: Find name segment from a list of acpi_ops. Searches a single + * scope, no more. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +acpi_ps_find_name ( + ACPI_PARSE_OBJECT *scope, + u32 name, + u32 opcode) +{ + ACPI_PARSE_OBJECT *op; + ACPI_PARSE_OBJECT *field; + + + /* search scope level for matching name segment */ + + op = acpi_ps_get_child (scope); + + while (op) { + + if (acpi_ps_is_field_op (op->opcode)) { + /* Field, search named fields */ + + field = acpi_ps_get_child (op); + while (field) { + if (acpi_ps_is_named_op (field->opcode) && + acpi_ps_get_name (field) == name && + (!opcode || field->opcode == opcode)) + { + return (field); + } + + field = field->next; + } + } + + else if (acpi_ps_is_create_field_op (op->opcode)) { + if (op->opcode == AML_CREATE_FIELD_OP) { + field = acpi_ps_get_arg (op, 3); + } + + else { + /* Create_xXXField, check name */ + + field = acpi_ps_get_arg (op, 2); + } + + if ((field) && + (field->value.string) && + (!STRNCMP (field->value.string, (char *) &name, ACPI_NAME_SIZE))) + { + return (op); + } + } + + else if ((acpi_ps_is_named_op (op->opcode)) && + (acpi_ps_get_name (op) == name) && + (!opcode || op->opcode == opcode)) + { + break; + } + + op = op->next; + } + + return (op); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_ps_find + * + * PARAMETERS: Scope - Where to begin the search + * Path - ACPI Path to the named object + * Opcode - Opcode associated with the object + * Create - if TRUE, create the object if not found. + * + * RETURN: Op if found, NULL otherwise. + * + * DESCRIPTION: Find object within scope + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +acpi_ps_find ( + ACPI_PARSE_OBJECT *scope, + NATIVE_CHAR *path, + u16 opcode, + u32 create) +{ + u32 seg_count; + u32 name; + u32 name_op; + ACPI_PARSE_OBJECT *op = NULL; + u8 unprefixed = TRUE; + + + if (!scope || !path) { + return (NULL); + } + + + acpi_gbl_ps_find_count++; + + + /* Handle all prefixes in the name path */ + + while (acpi_ps_is_prefix_char (GET8 (path))) { + switch (GET8 (path)) + { + + case '\\': + + /* Could just use a global for "root scope" here */ + + while (scope->parent) { + scope = scope->parent; + } + + /* get first object within the scope */ + /* TBD: [Investigate] OR - set next in root scope to point to the same value as arg */ + + /* Scope = Scope->Value.Arg; */ + + break; + + + case '^': + + /* Go up to the next valid scoping Op (method, scope, etc.) */ + + if (acpi_ps_get_parent (scope)) { + scope = acpi_ps_get_parent (scope); + } + + break; + } + + unprefixed = FALSE; + path++; + } + + /* get name segment count */ + + switch (GET8 (path)) + { + case '\0': + seg_count = 0; + + /* Null name case */ + + if (unprefixed) { + op = NULL; + } + else { + op = scope; + } + + + return (op); + break; + + case AML_DUAL_NAME_PREFIX: + seg_count = 2; + path++; + break; + + case AML_MULTI_NAME_PREFIX_OP: + seg_count = GET8 (path + 1); + path += 2; + break; + + default: + seg_count = 1; + break; + } + + /* match each name segment */ + + while (scope && seg_count) { + MOVE_UNALIGNED32_TO_32 (&name, path); + path += 4; + seg_count --; + + if (seg_count) { + name_op = 0; + } + else { + name_op = opcode; + } + + op = acpi_ps_find_name (scope, name, name_op); + + if (!op) { + if (create) { + /* Create a new Scope level */ + + if (seg_count) { + op = acpi_ps_alloc_op (AML_SCOPE_OP); + } + else { + op = acpi_ps_alloc_op (opcode); + } + + if (op) { + acpi_ps_set_name (op, name); + acpi_ps_append_arg (scope, op); + + } + } + + else if (unprefixed) { + /* Search higher scopes for unprefixed name */ + + while (!op && scope->parent) { + scope = scope->parent; + op = acpi_ps_find_name (scope, name, opcode); + + } + } + + } + + unprefixed = FALSE; + scope = op; + } + + return (op); +} + + diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/parser/psopcode.c linux/drivers/acpi/parser/psopcode.c --- v2.4.0-test8/linux/drivers/acpi/parser/psopcode.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/parser/psopcode.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: psopcode - Parser opcode information table + * $Revision: 20 $ * *****************************************************************************/ @@ -24,12 +25,32 @@ #include "acpi.h" -#include "parser.h" +#include "acparser.h" #include "amlcode.h" #define _COMPONENT PARSER - MODULE_NAME ("psopcode"); + MODULE_NAME ("psopcode") + + +u8 acpi_gbl_aml_short_op_info_index[]; +u8 acpi_gbl_aml_long_op_info_index[]; + +#define _UNK 0x6B +/* + * Reserved ASCII characters. Do not use any of these for + * internal opcodes, since they are used to differentiate + * name strings from AML opcodes + */ +#define _ASC 0x6C +#define _NAM 0x6C +#define _PFX 0x6D +#define _UNKNOWN_OPCODE 0x02 /* An example unknown opcode */ + +#define MAX_EXTENDED_OPCODE 0x87 +#define NUM_EXTENDED_OPCODE MAX_EXTENDED_OPCODE + 1 +#define MAX_INTERNAL_OPCODE +#define NUM_INTERNAL_OPCODE MAX_INTERNAL_OPCODE + 1 /******************************************************************************* @@ -41,27 +62,41 @@ * RETURN: A pointer to the info about the opcode. NULL if the opcode was * not found in the table. * - * DESCRIPTION: Find AML opcode description based on the opcode + * DESCRIPTION: Find AML opcode description based on the opcode. + * NOTE: This procedure must ALWAYS return a valid pointer! * ******************************************************************************/ -ACPI_OP_INFO * +ACPI_OPCODE_INFO * acpi_ps_get_opcode_info ( u16 opcode) { - ACPI_OP_INFO *op; - s32 hash; + ACPI_OPCODE_INFO *op_info; + u8 upper_opcode; + u8 lower_opcode; + + + /* Split the 16-bit opcode into separate bytes */ + + upper_opcode = (u8) (opcode >> 8); + lower_opcode = (u8) opcode; + + /* Default is "unknown opcode" */ + op_info = &acpi_gbl_aml_op_info [_UNK]; - /* compute hash/index into the Acpi_aml_op_index table */ - switch (opcode >> 8) + /* + * Detect normal 8-bit opcode or extended 16-bit opcode + */ + + switch (upper_opcode) { case 0: - /* Simple (8-bit) opcode */ + /* Simple (8-bit) opcode: 0-255, can't index beyond table */ - hash = opcode; + op_info = &acpi_gbl_aml_op_info [acpi_gbl_aml_short_op_info_index [lower_opcode]]; break; @@ -69,38 +104,29 @@ /* Extended (16-bit, prefix+opcode) opcode */ - hash = (opcode + AML_EXTOP_HASH_OFFSET) & 0xff; + if (lower_opcode <= MAX_EXTENDED_OPCODE) { + op_info = &acpi_gbl_aml_op_info [acpi_gbl_aml_long_op_info_index [lower_opcode]]; + } break; case AML_LNOT_OP: /* This case is for the bogus opcodes LNOTEQUAL, LLESSEQUAL, LGREATEREQUAL */ + /* TBD: [Investigate] remove this case? */ - hash = (opcode + AML_LNOT_HASH_OFFSET) & 0xff; break; default: - return NULL; + break; } /* Get the Op info pointer for this opcode */ - op = &acpi_gbl_aml_op_info [(s32) acpi_gbl_aml_op_info_index [hash]]; - - - /* If the returned opcode matches, we have a valid opcode */ - - if (op->opcode == opcode) { - return op; - } - - /* Otherwise, the opcode is an ASCII char or other non-opcode value */ - - return NULL; + return (op_info); } @@ -117,21 +143,19 @@ * ******************************************************************************/ -char * +NATIVE_CHAR * acpi_ps_get_opcode_name ( u16 opcode) { - ACPI_OP_INFO *op; + ACPI_OPCODE_INFO *op; op = acpi_ps_get_opcode_info (opcode); - if (!op) { - return "*ERROR*"; - } + /* Always guaranteed to return a valid pointer */ DEBUG_ONLY_MEMBERS (return op->name); - return "AE_NOT_CONFIGURED"; + return ("AE_NOT_CONFIGURED"); } @@ -153,7 +177,7 @@ * 6-7 (2 bits) = Reserved */ #define AML_NO_ARGS 0 -#define AML_HAS_ARGS OP_INFO_HAS_ARGS +#define AML_HAS_ARGS ACPI_OP_ARGS_MASK /* * All AML opcodes and the parse-time arguments for each. Used by the AML parser Each list is compressed @@ -225,7 +249,7 @@ #define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) #define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST) #define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) -#define ARGP_NOOP_CODE ARG_NONE +#define ARGP_NOOP_OP ARG_NONE #define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG) #define ARGP_BREAK_OP ARG_NONE #define ARGP_BREAK_POINT_OP ARG_NONE @@ -242,9 +266,9 @@ #define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) #define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME) #define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_FROM_BCDOP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TO_BCDOP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_UN_LOAD_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME) #define ARGP_REVISION_OP ARG_NONE #define ARGP_DEBUG_OP ARG_NONE #define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG) @@ -340,7 +364,7 @@ #define ARGI_IF_OP ARGI_INVALID_OPCODE #define ARGI_ELSE_OP ARGI_INVALID_OPCODE #define ARGI_WHILE_OP ARGI_INVALID_OPCODE -#define ARGI_NOOP_CODE ARG_NONE +#define ARGI_NOOP_OP ARG_NONE #define ARGI_RETURN_OP ARGI_INVALID_OPCODE #define ARGI_BREAK_OP ARG_NONE #define ARGI_BREAK_POINT_OP ARG_NONE @@ -357,9 +381,9 @@ #define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_NUMBER) #define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT) #define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX) -#define ARGI_FROM_BCDOP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) -#define ARGI_TO_BCDOP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) -#define ARGI_UN_LOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) +#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_NUMBER, ARGI_TARGETREF) +#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) #define ARGI_REVISION_OP ARG_NONE #define ARGI_DEBUG_OP ARG_NONE #define ARGI_FATAL_OP ARGI_LIST3 (ARGI_NUMBER, ARGI_NUMBER, ARGI_NUMBER) @@ -388,157 +412,156 @@ */ -ACPI_OP_INFO acpi_gbl_aml_op_info[] = +ACPI_OPCODE_INFO acpi_gbl_aml_op_info[] = { -/* Opcode Opcode Type Has Arguments? Child Name Parser Args Interpreter Args */ +/* Index Opcode Type Class Has Arguments? Name Parser Args Interpreter Args */ -/* 00 */ OP_INFO_ENTRY (AML_ZERO_OP, OPTYPE_CONSTANT| AML_NO_ARGS| 0, "Zero_op", ARGP_ZERO_OP, ARGI_ZERO_OP), -/* 01 */ OP_INFO_ENTRY (AML_ONE_OP, OPTYPE_CONSTANT| AML_NO_ARGS| 0, "One_op", ARGP_ONE_OP, ARGI_ONE_OP), -/* 02 */ OP_INFO_ENTRY (AML_ALIAS_OP, OPTYPE_NAMED_OBJECT| AML_HAS_ARGS| 0, "Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP), -/* 03 */ OP_INFO_ENTRY (AML_NAME_OP, OPTYPE_NAMED_OBJECT| AML_HAS_ARGS| 0, "Name", ARGP_NAME_OP, ARGI_NAME_OP), -/* 04 */ OP_INFO_ENTRY (AML_BYTE_OP, OPTYPE_LITERAL| AML_NO_ARGS| 0, "Byte_const", ARGP_BYTE_OP, ARGI_BYTE_OP), -/* 05 */ OP_INFO_ENTRY (AML_WORD_OP, OPTYPE_LITERAL| AML_NO_ARGS| 0, "Word_const", ARGP_WORD_OP, ARGI_WORD_OP), -/* 06 */ OP_INFO_ENTRY (AML_DWORD_OP, OPTYPE_LITERAL| AML_NO_ARGS| 0, "Dword_const", ARGP_DWORD_OP, ARGI_DWORD_OP), -/* 07 */ OP_INFO_ENTRY (AML_STRING_OP, OPTYPE_LITERAL| AML_NO_ARGS| 0, "String", ARGP_STRING_OP, ARGI_STRING_OP), -/* 08 */ OP_INFO_ENTRY (AML_SCOPE_OP, OPTYPE_NAMED_OBJECT| AML_HAS_ARGS| 0, "Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP), -/* 09 */ OP_INFO_ENTRY (AML_BUFFER_OP, OPTYPE_DATA_TERM| AML_HAS_ARGS| 0, "Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP), -/* 0A */ OP_INFO_ENTRY (AML_PACKAGE_OP, OPTYPE_DATA_TERM| AML_HAS_ARGS| 0, "Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP), -/* 0B */ OP_INFO_ENTRY (AML_METHOD_OP, OPTYPE_NAMED_OBJECT| AML_HAS_ARGS| 0, "Method", ARGP_METHOD_OP, ARGI_METHOD_OP), -/* 0C */ OP_INFO_ENTRY (AML_LOCAL0, OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS| 0, "Local0", ARGP_LOCAL0, ARGI_LOCAL0), -/* 0D */ OP_INFO_ENTRY (AML_LOCAL1, OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS| 0, "Local1", ARGP_LOCAL1, ARGI_LOCAL1), -/* 0E */ OP_INFO_ENTRY (AML_LOCAL2, OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS| 0, "Local2", ARGP_LOCAL2, ARGI_LOCAL2), -/* 0F */ OP_INFO_ENTRY (AML_LOCAL3, OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS| 0, "Local3", ARGP_LOCAL3, ARGI_LOCAL3), -/* 10 */ OP_INFO_ENTRY (AML_LOCAL4, OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS| 0, "Local4", ARGP_LOCAL4, ARGI_LOCAL4), -/* 11 */ OP_INFO_ENTRY (AML_LOCAL5, OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS| 0, "Local5", ARGP_LOCAL5, ARGI_LOCAL5), -/* 12 */ OP_INFO_ENTRY (AML_LOCAL6, OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS| 0, "Local6", ARGP_LOCAL6, ARGI_LOCAL6), -/* 13 */ OP_INFO_ENTRY (AML_LOCAL7, OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS| 0, "Local7", ARGP_LOCAL7, ARGI_LOCAL7), -/* 14 */ OP_INFO_ENTRY (AML_ARG0, OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS| 0, "Arg0", ARGP_ARG0, ARGI_ARG0), -/* 15 */ OP_INFO_ENTRY (AML_ARG1, OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS| 0, "Arg1", ARGP_ARG1, ARGI_ARG1), -/* 16 */ OP_INFO_ENTRY (AML_ARG2, OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS| 0, "Arg2", ARGP_ARG2, ARGI_ARG2), -/* 17 */ OP_INFO_ENTRY (AML_ARG3, OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS| 0, "Arg3", ARGP_ARG3, ARGI_ARG3), -/* 18 */ OP_INFO_ENTRY (AML_ARG4, OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS| 0, "Arg4", ARGP_ARG4, ARGI_ARG4), -/* 19 */ OP_INFO_ENTRY (AML_ARG5, OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS| 0, "Arg5", ARGP_ARG5, ARGI_ARG5), -/* 1_a */ OP_INFO_ENTRY (AML_ARG6, OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS| 0, "Arg6", ARGP_ARG6, ARGI_ARG6), -/* 1_b */ OP_INFO_ENTRY (AML_STORE_OP, OPTYPE_MONADIC2_r| AML_HAS_ARGS| 0, "Store", ARGP_STORE_OP, ARGI_STORE_OP), -/* 1_c */ OP_INFO_ENTRY (AML_REF_OF_OP, OPTYPE_MONADIC2| AML_HAS_ARGS| 0, "Ref_of", ARGP_REF_OF_OP, ARGI_REF_OF_OP), -/* 1_d */ OP_INFO_ENTRY (AML_ADD_OP, OPTYPE_DYADIC2_r| AML_HAS_ARGS| 0, "Add", ARGP_ADD_OP, ARGI_ADD_OP), -/* 1_e */ OP_INFO_ENTRY (AML_CONCAT_OP, OPTYPE_DYADIC2_r| AML_HAS_ARGS| 0, "Concat", ARGP_CONCAT_OP, ARGI_CONCAT_OP), -/* 1_f */ OP_INFO_ENTRY (AML_SUBTRACT_OP, OPTYPE_DYADIC2_r| AML_HAS_ARGS| 0, "Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP), -/* 20 */ OP_INFO_ENTRY (AML_INCREMENT_OP, OPTYPE_MONADIC2| AML_HAS_ARGS| 0, "Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP), -/* 21 */ OP_INFO_ENTRY (AML_DECREMENT_OP, OPTYPE_MONADIC2| AML_HAS_ARGS| 0, "Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP), -/* 22 */ OP_INFO_ENTRY (AML_MULTIPLY_OP, OPTYPE_DYADIC2_r| AML_HAS_ARGS| 0, "Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP), -/* 23 */ OP_INFO_ENTRY (AML_DIVIDE_OP, OPTYPE_DYADIC2_r| AML_HAS_ARGS| 0, "Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP), -/* 24 */ OP_INFO_ENTRY (AML_SHIFT_LEFT_OP, OPTYPE_DYADIC2_r| AML_HAS_ARGS| 0, "Shift_left", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP), -/* 25 */ OP_INFO_ENTRY (AML_SHIFT_RIGHT_OP, OPTYPE_DYADIC2_r| AML_HAS_ARGS| 0, "Shift_right", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP), -/* 26 */ OP_INFO_ENTRY (AML_BIT_AND_OP, OPTYPE_DYADIC2_r| AML_HAS_ARGS| 0, "And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP), -/* 27 */ OP_INFO_ENTRY (AML_BIT_NAND_OP, OPTYPE_DYADIC2_r| AML_HAS_ARGS| 0, "NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP), -/* 28 */ OP_INFO_ENTRY (AML_BIT_OR_OP, OPTYPE_DYADIC2_r| AML_HAS_ARGS| 0, "Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP), -/* 29 */ OP_INFO_ENTRY (AML_BIT_NOR_OP, OPTYPE_DYADIC2_r| AML_HAS_ARGS| 0, "NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP), -/* 2_a */ OP_INFO_ENTRY (AML_BIT_XOR_OP, OPTYPE_DYADIC2_r| AML_HAS_ARGS| 0, "XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP), -/* 2_b */ OP_INFO_ENTRY (AML_BIT_NOT_OP, OPTYPE_MONADIC2_r| AML_HAS_ARGS| 0, "Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP), -/* 2_c */ OP_INFO_ENTRY (AML_FIND_SET_LEFT_BIT_OP, OPTYPE_MONADIC2_r| AML_HAS_ARGS| 0, "Find_set_left_bit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP), -/* 2_d */ OP_INFO_ENTRY (AML_FIND_SET_RIGHT_BIT_OP, OPTYPE_MONADIC2_r| AML_HAS_ARGS| 0, "Find_set_right_bit", ARGP_FIND_SET_RIGHT_BIT_OP, ARGI_FIND_SET_RIGHT_BIT_OP), -/* 2_e */ OP_INFO_ENTRY (AML_DEREF_OF_OP, OPTYPE_MONADIC2| AML_HAS_ARGS| 0, "Deref_of", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP), -/* 2_f */ OP_INFO_ENTRY (AML_NOTIFY_OP, OPTYPE_DYADIC1| AML_HAS_ARGS| 0, "Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP), -/* 30 */ OP_INFO_ENTRY (AML_SIZE_OF_OP, OPTYPE_MONADIC2| AML_HAS_ARGS| 0, "Size_of", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP), -/* 31 */ OP_INFO_ENTRY (AML_INDEX_OP, OPTYPE_INDEX| AML_HAS_ARGS| 0, "Index", ARGP_INDEX_OP, ARGI_INDEX_OP), -/* 32 */ OP_INFO_ENTRY (AML_MATCH_OP, OPTYPE_MATCH| AML_HAS_ARGS| 0, "Match", ARGP_MATCH_OP, ARGI_MATCH_OP), -/* 33 */ OP_INFO_ENTRY (AML_DWORD_FIELD_OP, OPTYPE_CREATE_FIELD| AML_HAS_ARGS| 0, "Create_dWord_field", ARGP_DWORD_FIELD_OP, ARGI_DWORD_FIELD_OP), -/* 34 */ OP_INFO_ENTRY (AML_WORD_FIELD_OP, OPTYPE_CREATE_FIELD| AML_HAS_ARGS| 0, "Create_word_field", ARGP_WORD_FIELD_OP, ARGI_WORD_FIELD_OP), -/* 35 */ OP_INFO_ENTRY (AML_BYTE_FIELD_OP, OPTYPE_CREATE_FIELD| AML_HAS_ARGS| 0, "Create_byte_field", ARGP_BYTE_FIELD_OP, ARGI_BYTE_FIELD_OP), -/* 36 */ OP_INFO_ENTRY (AML_BIT_FIELD_OP, OPTYPE_CREATE_FIELD| AML_HAS_ARGS| 0, "Create_bit_field", ARGP_BIT_FIELD_OP, ARGI_BIT_FIELD_OP), -/* 37 */ OP_INFO_ENTRY (AML_TYPE_OP, OPTYPE_MONADIC2| AML_HAS_ARGS| 0, "Object_type", ARGP_TYPE_OP, ARGI_TYPE_OP), -/* 38 */ OP_INFO_ENTRY (AML_LAND_OP, OPTYPE_DYADIC2| AML_HAS_ARGS| 0, "LAnd", ARGP_LAND_OP, ARGI_LAND_OP), -/* 39 */ OP_INFO_ENTRY (AML_LOR_OP, OPTYPE_DYADIC2| AML_HAS_ARGS| 0, "LOr", ARGP_LOR_OP, ARGI_LOR_OP), -/* 3_a */ OP_INFO_ENTRY (AML_LNOT_OP, OPTYPE_MONADIC2| AML_HAS_ARGS| 0, "LNot", ARGP_LNOT_OP, ARGI_LNOT_OP), -/* 3_b */ OP_INFO_ENTRY (AML_LEQUAL_OP, OPTYPE_DYADIC2| AML_HAS_ARGS| 0, "LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP), -/* 3_c */ OP_INFO_ENTRY (AML_LGREATER_OP, OPTYPE_DYADIC2| AML_HAS_ARGS| 0, "LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP), -/* 3_d */ OP_INFO_ENTRY (AML_LLESS_OP, OPTYPE_DYADIC2| AML_HAS_ARGS| 0, "LLess", ARGP_LLESS_OP, ARGI_LLESS_OP), -/* 3_e */ OP_INFO_ENTRY (AML_IF_OP, OPTYPE_CONTROL| AML_HAS_ARGS| 0, "If", ARGP_IF_OP, ARGI_IF_OP), -/* 3_f */ OP_INFO_ENTRY (AML_ELSE_OP, OPTYPE_CONTROL| AML_HAS_ARGS| 0, "Else", ARGP_ELSE_OP, ARGI_ELSE_OP), -/* 40 */ OP_INFO_ENTRY (AML_WHILE_OP, OPTYPE_CONTROL| AML_HAS_ARGS| 0, "While", ARGP_WHILE_OP, ARGI_WHILE_OP), -/* 41 */ OP_INFO_ENTRY (AML_NOOP_CODE, OPTYPE_CONTROL| AML_NO_ARGS| 0, "Noop", ARGP_NOOP_CODE, ARGI_NOOP_CODE), -/* 42 */ OP_INFO_ENTRY (AML_RETURN_OP, OPTYPE_CONTROL| AML_HAS_ARGS| 0, "Return", ARGP_RETURN_OP, ARGI_RETURN_OP), -/* 43 */ OP_INFO_ENTRY (AML_BREAK_OP, OPTYPE_CONTROL| AML_NO_ARGS| 0, "Break", ARGP_BREAK_OP, ARGI_BREAK_OP), -/* 44 */ OP_INFO_ENTRY (AML_BREAK_POINT_OP, OPTYPE_CONTROL| AML_NO_ARGS| 0, "Break_point", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP), -/* 45 */ OP_INFO_ENTRY (AML_ONES_OP, OPTYPE_CONSTANT| AML_NO_ARGS| 0, "Ones_op", ARGP_ONES_OP, ARGI_ONES_OP), +/* 00 */ /* AML_ZERO_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Zero_op", ARGP_ZERO_OP, ARGI_ZERO_OP), +/* 01 */ /* AML_ONE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "One_op", ARGP_ONE_OP, ARGI_ONE_OP), +/* 02 */ /* AML_ALIAS_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP), +/* 03 */ /* AML_NAME_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Name", ARGP_NAME_OP, ARGI_NAME_OP), +/* 04 */ /* AML_BYTE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "Byte_const", ARGP_BYTE_OP, ARGI_BYTE_OP), +/* 05 */ /* AML_WORD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "Word_const", ARGP_WORD_OP, ARGI_WORD_OP), +/* 06 */ /* AML_DWORD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "Dword_const", ARGP_DWORD_OP, ARGI_DWORD_OP), +/* 07 */ /* AML_STRING_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "String", ARGP_STRING_OP, ARGI_STRING_OP), +/* 08 */ /* AML_SCOPE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP), +/* 09 */ /* AML_BUFFER_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DATA_TERM| AML_HAS_ARGS, "Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP), +/* 0A */ /* AML_PACKAGE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DATA_TERM| AML_HAS_ARGS, "Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP), +/* 0B */ /* AML_METHOD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Method", ARGP_METHOD_OP, ARGI_METHOD_OP), +/* 0C */ /* AML_LOCAL0 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local0", ARGP_LOCAL0, ARGI_LOCAL0), +/* 0D */ /* AML_LOCAL1 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local1", ARGP_LOCAL1, ARGI_LOCAL1), +/* 0E */ /* AML_LOCAL2 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local2", ARGP_LOCAL2, ARGI_LOCAL2), +/* 0F */ /* AML_LOCAL3 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local3", ARGP_LOCAL3, ARGI_LOCAL3), +/* 10 */ /* AML_LOCAL4 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local4", ARGP_LOCAL4, ARGI_LOCAL4), +/* 11 */ /* AML_LOCAL5 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local5", ARGP_LOCAL5, ARGI_LOCAL5), +/* 12 */ /* AML_LOCAL6 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local6", ARGP_LOCAL6, ARGI_LOCAL6), +/* 13 */ /* AML_LOCAL7 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LOCAL_VARIABLE| AML_NO_ARGS, "Local7", ARGP_LOCAL7, ARGI_LOCAL7), +/* 14 */ /* AML_ARG0 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg0", ARGP_ARG0, ARGI_ARG0), +/* 15 */ /* AML_ARG1 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg1", ARGP_ARG1, ARGI_ARG1), +/* 16 */ /* AML_ARG2 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg2", ARGP_ARG2, ARGI_ARG2), +/* 17 */ /* AML_ARG3 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg3", ARGP_ARG3, ARGI_ARG3), +/* 18 */ /* AML_ARG4 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg4", ARGP_ARG4, ARGI_ARG4), +/* 19 */ /* AML_ARG5 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg5", ARGP_ARG5, ARGI_ARG5), +/* 1_a */ /* AML_ARG6 */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_ARGUMENT| AML_NO_ARGS, "Arg6", ARGP_ARG6, ARGI_ARG6), +/* 1_b */ /* AML_STORE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Store", ARGP_STORE_OP, ARGI_STORE_OP), +/* 1_c */ /* AML_REF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Ref_of", ARGP_REF_OF_OP, ARGI_REF_OF_OP), +/* 1_d */ /* AML_ADD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Add", ARGP_ADD_OP, ARGI_ADD_OP), +/* 1_e */ /* AML_CONCAT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Concat", ARGP_CONCAT_OP, ARGI_CONCAT_OP), +/* 1_f */ /* AML_SUBTRACT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP), +/* 20 */ /* AML_INCREMENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP), +/* 21 */ /* AML_DECREMENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP), +/* 22 */ /* AML_MULTIPLY_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP), +/* 23 */ /* AML_DIVIDE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP), +/* 24 */ /* AML_SHIFT_LEFT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Shift_left", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP), +/* 25 */ /* AML_SHIFT_RIGHT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Shift_right", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP), +/* 26 */ /* AML_BIT_AND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP), +/* 27 */ /* AML_BIT_NAND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP), +/* 28 */ /* AML_BIT_OR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP), +/* 29 */ /* AML_BIT_NOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP), +/* 2_a */ /* AML_BIT_XOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_r| AML_HAS_ARGS, "XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP), +/* 2_b */ /* AML_BIT_NOT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP), +/* 2_c */ /* AML_FIND_SET_LEFT_BIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Find_set_left_bit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP), +/* 2_d */ /* AML_FIND_SET_RIGHT_BIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Find_set_right_bit", ARGP_FIND_SET_RIGHT_BIT_OP, ARGI_FIND_SET_RIGHT_BIT_OP), +/* 2_e */ /* AML_DEREF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Deref_of", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP), +/* 2_f */ /* AML_NOTIFY_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC1| AML_HAS_ARGS, "Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP), +/* 30 */ /* AML_SIZE_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Size_of", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP), +/* 31 */ /* AML_INDEX_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_INDEX| AML_HAS_ARGS, "Index", ARGP_INDEX_OP, ARGI_INDEX_OP), +/* 32 */ /* AML_MATCH_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MATCH| AML_HAS_ARGS, "Match", ARGP_MATCH_OP, ARGI_MATCH_OP), +/* 33 */ /* AML_DWORD_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "Create_dWord_field", ARGP_DWORD_FIELD_OP, ARGI_DWORD_FIELD_OP), +/* 34 */ /* AML_WORD_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "Create_word_field", ARGP_WORD_FIELD_OP, ARGI_WORD_FIELD_OP), +/* 35 */ /* AML_BYTE_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "Create_byte_field", ARGP_BYTE_FIELD_OP, ARGI_BYTE_FIELD_OP), +/* 36 */ /* AML_BIT_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "Create_bit_field", ARGP_BIT_FIELD_OP, ARGI_BIT_FIELD_OP), +/* 37 */ /* AML_TYPE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "Object_type", ARGP_TYPE_OP, ARGI_TYPE_OP), +/* 38 */ /* AML_LAND_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LAnd", ARGP_LAND_OP, ARGI_LAND_OP), +/* 39 */ /* AML_LOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LOr", ARGP_LOR_OP, ARGI_LOR_OP), +/* 3_a */ /* AML_LNOT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2| AML_HAS_ARGS, "LNot", ARGP_LNOT_OP, ARGI_LNOT_OP), +/* 3_b */ /* AML_LEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP), +/* 3_c */ /* AML_LGREATER_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP), +/* 3_d */ /* AML_LLESS_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2| AML_HAS_ARGS, "LLess", ARGP_LLESS_OP, ARGI_LLESS_OP), +/* 3_e */ /* AML_IF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "If", ARGP_IF_OP, ARGI_IF_OP), +/* 3_f */ /* AML_ELSE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "Else", ARGP_ELSE_OP, ARGI_ELSE_OP), +/* 40 */ /* AML_WHILE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "While", ARGP_WHILE_OP, ARGI_WHILE_OP), +/* 41 */ /* AML_NOOP_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "Noop", ARGP_NOOP_OP, ARGI_NOOP_OP), +/* 42 */ /* AML_RETURN_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_HAS_ARGS, "Return", ARGP_RETURN_OP, ARGI_RETURN_OP), +/* 43 */ /* AML_BREAK_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "Break", ARGP_BREAK_OP, ARGI_BREAK_OP), +/* 44 */ /* AML_BREAK_POINT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONTROL| AML_NO_ARGS, "Break_point", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP), +/* 45 */ /* AML_ONES_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Ones_op", ARGP_ONES_OP, ARGI_ONES_OP), /* Prefixed opcodes (Two-byte opcodes with a prefix op) */ -/* 46 */ OP_INFO_ENTRY (AML_MUTEX_OP, OPTYPE_NAMED_OBJECT| AML_HAS_ARGS| 0, "Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP), -/* 47 */ OP_INFO_ENTRY (AML_EVENT_OP, OPTYPE_NAMED_OBJECT| AML_NO_ARGS| 0, "Event", ARGP_EVENT_OP, ARGI_EVENT_OP), -/* 48 */ OP_INFO_ENTRY (AML_COND_REF_OF_OP, OPTYPE_MONADIC2_r| AML_HAS_ARGS| 0, "Cond_ref_of", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP), -/* 49 */ OP_INFO_ENTRY (AML_CREATE_FIELD_OP, OPTYPE_CREATE_FIELD| AML_HAS_ARGS| 0, "Create_field", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP), -/* 4_a */ OP_INFO_ENTRY (AML_LOAD_OP, OPTYPE_RECONFIGURATION| AML_HAS_ARGS| 0, "Load", ARGP_LOAD_OP, ARGI_LOAD_OP), -/* 4_b */ OP_INFO_ENTRY (AML_STALL_OP, OPTYPE_MONADIC1| AML_HAS_ARGS| 0, "Stall", ARGP_STALL_OP, ARGI_STALL_OP), -/* 4_c */ OP_INFO_ENTRY (AML_SLEEP_OP, OPTYPE_MONADIC1| AML_HAS_ARGS| 0, "Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP), -/* 4_d */ OP_INFO_ENTRY (AML_ACQUIRE_OP, OPTYPE_DYADIC2_s| AML_HAS_ARGS| 0, "Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP), -/* 4_e */ OP_INFO_ENTRY (AML_SIGNAL_OP, OPTYPE_MONADIC1| AML_HAS_ARGS| 0, "Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP), -/* 4_f */ OP_INFO_ENTRY (AML_WAIT_OP, OPTYPE_DYADIC2_s| AML_HAS_ARGS| 0, "Wait", ARGP_WAIT_OP, ARGI_WAIT_OP), -/* 50 */ OP_INFO_ENTRY (AML_RESET_OP, OPTYPE_MONADIC1| AML_HAS_ARGS| 0, "Reset", ARGP_RESET_OP, ARGI_RESET_OP), -/* 51 */ OP_INFO_ENTRY (AML_RELEASE_OP, OPTYPE_MONADIC1| AML_HAS_ARGS| 0, "Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP), -/* 52 */ OP_INFO_ENTRY (AML_FROM_BCDOP, OPTYPE_MONADIC2_r| AML_HAS_ARGS| 0, "From_bCD", ARGP_FROM_BCDOP, ARGI_FROM_BCDOP), -/* 53 */ OP_INFO_ENTRY (AML_TO_BCDOP, OPTYPE_MONADIC2_r| AML_HAS_ARGS| 0, "To_bCD", ARGP_TO_BCDOP, ARGI_TO_BCDOP), -/* 54 */ OP_INFO_ENTRY (AML_UN_LOAD_OP, OPTYPE_RECONFIGURATION| AML_HAS_ARGS| 0, "Unload", ARGP_UN_LOAD_OP, ARGI_UN_LOAD_OP), -/* 55 */ OP_INFO_ENTRY (AML_REVISION_OP, OPTYPE_CONSTANT| AML_NO_ARGS| 0, "Revision", ARGP_REVISION_OP, ARGI_REVISION_OP), -/* 56 */ OP_INFO_ENTRY (AML_DEBUG_OP, OPTYPE_CONSTANT| AML_NO_ARGS| 0, "Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP), -/* 57 */ OP_INFO_ENTRY (AML_FATAL_OP, OPTYPE_FATAL| AML_HAS_ARGS| 0, "Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP), -/* 58 */ OP_INFO_ENTRY (AML_REGION_OP, OPTYPE_NAMED_OBJECT| AML_HAS_ARGS| 0, "Op_region", ARGP_REGION_OP, ARGI_REGION_OP), -/* 59 */ OP_INFO_ENTRY (AML_DEF_FIELD_OP, OPTYPE_NAMED_OBJECT| AML_HAS_ARGS| 0, "Field", ARGP_DEF_FIELD_OP, ARGI_DEF_FIELD_OP), -/* 5_a */ OP_INFO_ENTRY (AML_DEVICE_OP, OPTYPE_NAMED_OBJECT| AML_HAS_ARGS| 0, "Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP), -/* 5_b */ OP_INFO_ENTRY (AML_PROCESSOR_OP, OPTYPE_NAMED_OBJECT| AML_HAS_ARGS| 0, "Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP), -/* 5_c */ OP_INFO_ENTRY (AML_POWER_RES_OP, OPTYPE_NAMED_OBJECT| AML_HAS_ARGS| 0, "Power_res", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP), -/* 5_d */ OP_INFO_ENTRY (AML_THERMAL_ZONE_OP, OPTYPE_NAMED_OBJECT| AML_HAS_ARGS| 0, "Thermal_zone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP), -/* 5_e */ OP_INFO_ENTRY (AML_INDEX_FIELD_OP, OPTYPE_NAMED_OBJECT| AML_HAS_ARGS| 0, "Index_field", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP), -/* 5_f */ OP_INFO_ENTRY (AML_BANK_FIELD_OP, OPTYPE_NAMED_OBJECT| AML_HAS_ARGS| 0, "Bank_field", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP), +/* 46 */ /* AML_MUTEX_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP), +/* 47 */ /* AML_EVENT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_NO_ARGS, "Event", ARGP_EVENT_OP, ARGI_EVENT_OP), +/* 48 */ /* AML_COND_REF_OF_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "Cond_ref_of", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP), +/* 49 */ /* AML_CREATE_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CREATE_FIELD| AML_HAS_ARGS, "Create_field", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP), +/* 4_a */ /* AML_LOAD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RECONFIGURATION| AML_HAS_ARGS, "Load", ARGP_LOAD_OP, ARGI_LOAD_OP), +/* 4_b */ /* AML_STALL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Stall", ARGP_STALL_OP, ARGI_STALL_OP), +/* 4_c */ /* AML_SLEEP_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP), +/* 4_d */ /* AML_ACQUIRE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_s| AML_HAS_ARGS, "Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP), +/* 4_e */ /* AML_SIGNAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP), +/* 4_f */ /* AML_WAIT_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_DYADIC2_s| AML_HAS_ARGS, "Wait", ARGP_WAIT_OP, ARGI_WAIT_OP), +/* 50 */ /* AML_RESET_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Reset", ARGP_RESET_OP, ARGI_RESET_OP), +/* 51 */ /* AML_RELEASE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC1| AML_HAS_ARGS, "Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP), +/* 52 */ /* AML_FROM_BCD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "From_bCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP), +/* 53 */ /* AML_TO_BCD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_MONADIC2_r| AML_HAS_ARGS, "To_bCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP), +/* 54 */ /* AML_UNLOAD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RECONFIGURATION| AML_HAS_ARGS, "Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP), +/* 55 */ /* AML_REVISION_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Revision", ARGP_REVISION_OP, ARGI_REVISION_OP), +/* 56 */ /* AML_DEBUG_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_CONSTANT| AML_NO_ARGS, "Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP), +/* 57 */ /* AML_FATAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_FATAL| AML_HAS_ARGS, "Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP), +/* 58 */ /* AML_REGION_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Op_region", ARGP_REGION_OP, ARGI_REGION_OP), +/* 59 */ /* AML_DEF_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Field", ARGP_DEF_FIELD_OP, ARGI_DEF_FIELD_OP), +/* 5_a */ /* AML_DEVICE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP), +/* 5_b */ /* AML_PROCESSOR_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP), +/* 5_c */ /* AML_POWER_RES_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Power_res", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP), +/* 5_d */ /* AML_THERMAL_ZONE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Thermal_zone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP), +/* 5_e */ /* AML_INDEX_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Index_field", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP), +/* 5_f */ /* AML_BANK_FIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_NAMED_OBJECT| AML_HAS_ARGS, "Bank_field", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP), /* Internal opcodes that map to invalid AML opcodes */ -/* 60 */ OP_INFO_ENTRY (AML_LNOTEQUAL_OP, OPTYPE_BOGUS| AML_HAS_ARGS| 0, "LNot_equal", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP), -/* 61 */ OP_INFO_ENTRY (AML_LLESSEQUAL_OP, OPTYPE_BOGUS| AML_HAS_ARGS| 0, "LLess_equal", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP), -/* 62 */ OP_INFO_ENTRY (AML_LGREATEREQUAL_OP, OPTYPE_BOGUS| AML_HAS_ARGS| 0, "LGreater_equal", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP), -/* 63 */ OP_INFO_ENTRY (AML_NAMEPATH_OP, OPTYPE_LITERAL| AML_NO_ARGS| 0, "Name_path", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP), -/* 64 */ OP_INFO_ENTRY (AML_METHODCALL_OP, OPTYPE_METHOD_CALL| AML_HAS_ARGS| 0, "Method_call", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP), -/* 65 */ OP_INFO_ENTRY (AML_BYTELIST_OP, OPTYPE_LITERAL| AML_NO_ARGS| 0, "Byte_list", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP), -/* 66 */ OP_INFO_ENTRY (AML_RESERVEDFIELD_OP, OPTYPE_BOGUS| AML_NO_ARGS| 0, "Reserved_field", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP), -/* 67 */ OP_INFO_ENTRY (AML_NAMEDFIELD_OP, OPTYPE_BOGUS| AML_NO_ARGS| 0, "Named_field", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP), -/* 68 */ OP_INFO_ENTRY (AML_ACCESSFIELD_OP, OPTYPE_BOGUS| AML_NO_ARGS| 0, "Access_field", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP), -/* 69 */ OP_INFO_ENTRY (AML_STATICSTRING_OP, OPTYPE_BOGUS| AML_NO_ARGS| 0, "Static_string", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP), -/* 6_a */ OP_INFO_ENTRY (0, OPTYPE_BOGUS| AML_HAS_ARGS| 0, "UNKNOWN_OP!", ARG_NONE, ARG_NONE), - OP_INFO_ENTRY (0, 0| AML_HAS_ARGS| 0, NULL, ARG_NONE, ARG_NONE) +/* 60 */ /* AML_LNOTEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LNot_equal", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP), +/* 61 */ /* AML_LLESSEQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LLess_equal", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP), +/* 62 */ /* AML_LGREATEREQUAL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_HAS_ARGS, "LGreater_equal", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP), +/* 63 */ /* AML_NAMEPATH_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "Name_path", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP), +/* 64 */ /* AML_METHODCALL_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_METHOD_CALL| AML_HAS_ARGS, "Method_call", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP), +/* 65 */ /* AML_BYTELIST_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_LITERAL| AML_NO_ARGS, "Byte_list", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP), +/* 66 */ /* AML_RESERVEDFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "Reserved_field", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP), +/* 67 */ /* AML_NAMEDFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "Named_field", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP), +/* 68 */ /* AML_ACCESSFIELD_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "Access_field", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP), +/* 69 */ /* AML_STATICSTRING_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_BOGUS| AML_NO_ARGS, "Static_string", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP), +/* 6_a */ /* AML_RETURN_VALUE_OP */ OP_INFO_ENTRY (ACPI_OP_TYPE_OPCODE | OPTYPE_RETURN| AML_HAS_ARGS, "[Return Value]", ARG_NONE, ARG_NONE), +/* 6_b */ /* UNKNOWN OPCODES */ OP_INFO_ENTRY (ACPI_OP_TYPE_UNKNOWN | OPTYPE_BOGUS| AML_HAS_ARGS, "UNKNOWN_OP!", ARG_NONE, ARG_NONE), +/* 6_c */ /* ASCII CHARACTERS */ OP_INFO_ENTRY (ACPI_OP_TYPE_ASCII | OPTYPE_BOGUS| AML_HAS_ARGS, "ASCII_ONLY!", ARG_NONE, ARG_NONE), +/* 6_d */ /* PREFIX CHARACTERS */ OP_INFO_ENTRY (ACPI_OP_TYPE_PREFIX | OPTYPE_BOGUS| AML_HAS_ARGS, "PREFIX_ONLY!", ARG_NONE, ARG_NONE), }; -#define _UNK 0x6A -#define _UNKNOWN_OPCODE 0x02 /* An example unknown opcode */ - /* * This table is directly indexed by the opcodes, and returns an * index into the table above */ -u8 acpi_gbl_aml_op_info_index[256] = +u8 acpi_gbl_aml_short_op_info_index[256] = { /* 0 1 2 3 4 5 6 7 */ /* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, /* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, _UNK, _UNK, -/* 0x10 */ 0x08, 0x09, 0x0a, _UNK, 0x0b, _UNK, _UNK, 0x46, -/* 0x18 */ 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x10 */ 0x08, 0x09, 0x0a, _UNK, 0x0b, _UNK, _UNK, _UNK, +/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x28 */ 0x48, 0x49, _UNK, _UNK, _UNK, 0x63, _UNK, _UNK, -/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x4a, 0x4b, -/* 0x38 */ 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, -/* 0x40 */ 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, 0x55, 0x56, -/* 0x48 */ 0x57, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, +/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, _UNK, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, /* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, /* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, /* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, /* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, /* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, _UNK, _UNK, 0x2f, 0x30, /* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, _UNK, -/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x58, 0x59, -/* 0x98 */ 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, _UNK, _UNK, +/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, _UNK, _UNK, +/* 0x98 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, /* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, @@ -552,3 +575,32 @@ /* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, }; + + +u8 acpi_gbl_aml_long_op_info_index[NUM_EXTENDED_OPCODE] = +{ +/* 0 1 2 3 4 5 6 7 */ +/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, +/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, +/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x30 */ 0x55, 0x56, 0x57, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, +}; + + +/* 0 1 2 3 4 5 6 7 */ +/* 0x00 */ + + diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/parser/psparse.c linux/drivers/acpi/parser/psparse.c --- v2.4.0-test8/linux/drivers/acpi/parser/psparse.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/parser/psparse.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: psparse - Parser top level AML parse routines + * $Revision: 51 $ * *****************************************************************************/ @@ -33,14 +34,14 @@ */ #include "acpi.h" -#include "parser.h" -#include "dispatch.h" +#include "acparser.h" +#include "acdispat.h" #include "amlcode.h" -#include "namesp.h" -#include "debugger.h" +#include "acnamesp.h" +#include "acdebug.h" #define _COMPONENT PARSER - MODULE_NAME ("psparse"); + MODULE_NAME ("psparse") u32 acpi_gbl_depth = 0; @@ -65,11 +66,11 @@ ACPI_STATUS acpi_ps_delete_completed_op ( ACPI_WALK_STATE *state, - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT *op) { acpi_ps_free_op (op); - return AE_OK; + return (AE_OK); } @@ -78,7 +79,7 @@ * * FUNCTION: Acpi_ps_delete_parse_tree * - * PARAMETERS: Root - Root of tree (or subtree) to delete + * PARAMETERS: Subtree_root - Root of tree (or subtree) to delete * * RETURN: None * @@ -88,33 +89,54 @@ void acpi_ps_delete_parse_tree ( - ACPI_GENERIC_OP *root) + ACPI_PARSE_OBJECT *subtree_root) { - ACPI_GENERIC_OP *op; - ACPI_WALK_STATE walk_state; + ACPI_WALK_STATE *walk_state; + ACPI_WALK_LIST walk_list; - walk_state.origin = root; - op = root; + if (!subtree_root) { + return; + } - /* TBD: [Restructure] hack for root case */ + /* Create and initialize a new walk list */ - if (op == acpi_gbl_parsed_namespace_root) { - op = acpi_ps_get_child (op); + walk_list.walk_state = NULL; + walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT, NULL, NULL, &walk_list); + if (!walk_state) { + return; } - /* Save root until last, so that we know when the tree has been walked */ + walk_state->parser_state = NULL; + walk_state->parse_flags = 0; + walk_state->descending_callback = NULL; + walk_state->ascending_callback = NULL; + - walk_state.next_op = op; - walk_state.next_op_info = NEXT_OP_DOWNWARD; + walk_state->origin = subtree_root; + walk_state->next_op = subtree_root; - while (walk_state.next_op) { - acpi_ps_get_next_walk_op (&walk_state, walk_state.next_op, + + /* Head downward in the tree */ + + walk_state->next_op_info = NEXT_OP_DOWNWARD; + + /* Visit all nodes in the subtree */ + + while (walk_state->next_op) { + acpi_ps_get_next_walk_op (walk_state, walk_state->next_op, acpi_ps_delete_completed_op); } + + /* We are done with this walk */ + + acpi_ds_delete_walk_state (walk_state); + + return; } #endif + /******************************************************************************* * * FUNCTION: Acpi_ps_peek_opcode @@ -135,12 +157,12 @@ /* Extended (2-byte) opcode if > 255 */ if (opcode > 0x00FF) { - return 2; + return (2); } /* Otherwise, just a single byte opcode */ - return 1; + return (1); } @@ -194,7 +216,7 @@ /* don't convert bare name to a namepath */ - return opcode; + return (opcode); } @@ -214,7 +236,7 @@ ACPI_PARSE_STATE * acpi_ps_create_state ( u8 *aml, - s32 aml_size) + u32 aml_size) { ACPI_PARSE_STATE *parser_state; @@ -257,88 +279,270 @@ ACPI_STATUS acpi_ps_find_object ( u16 opcode, - ACPI_PARSE_STATE *parser_state, + ACPI_PARSE_OBJECT *op, ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP **op) + ACPI_PARSE_OBJECT **out_op) { - char *path; + NATIVE_CHAR *path; + /* We are only interested in opcodes that have an associated name */ + + if (!acpi_ps_is_named_op (opcode)) { + *out_op = op; + return (AE_OK); + } + /* Find the name in the parse tree */ - path = acpi_ps_get_next_namestring (parser_state); + path = acpi_ps_get_next_namestring (walk_state->parser_state); - *op = acpi_ps_find (acpi_ps_get_parent_scope (parser_state), + *out_op = acpi_ps_find (acpi_ps_get_parent_scope (walk_state->parser_state), path, opcode, 1); - if (!(*op)) { - return AE_NOT_FOUND; + if (!(*out_op)) { + return (AE_NOT_FOUND); } - return AE_OK; + return (AE_OK); } + +#endif + + +/******************************************************************************* + * + * FUNCTION: Acpi_ps_complete_this_op + * + * PARAMETERS: Walk_state - Current State + * Op - Op to complete + * + * RETURN: TRUE if Op and subtree was deleted + * + * DESCRIPTION: Perform any cleanup at the completion of an Op. + * + ******************************************************************************/ + +u8 +acpi_ps_complete_this_op ( + ACPI_WALK_STATE *walk_state, + ACPI_PARSE_OBJECT *op) +{ +#ifndef PARSER_ONLY + ACPI_PARSE_OBJECT *prev; + ACPI_PARSE_OBJECT *next; + ACPI_OPCODE_INFO *op_info; + ACPI_OPCODE_INFO *parent_info; + u32 opcode_class; + ACPI_PARSE_OBJECT *replacement_op = NULL; + + + op_info = acpi_ps_get_opcode_info (op->opcode); + opcode_class = ACPI_GET_OP_CLASS (op_info); + + + /* Delete this op and the subtree below it if asked to */ + + if (((walk_state->parse_flags & ACPI_PARSE_TREE_MASK) == ACPI_PARSE_DELETE_TREE) && + (opcode_class != OPTYPE_CONSTANT) && + (opcode_class != OPTYPE_LITERAL) && + (opcode_class != OPTYPE_LOCAL_VARIABLE) && + (opcode_class != OPTYPE_METHOD_ARGUMENT) && + (opcode_class != OPTYPE_DATA_TERM) && + (op->opcode != AML_NAMEPATH_OP)) + { + /* Make sure that we only delete this subtree */ + + if (op->parent) { + /* + * Check if we need to replace the operator and its subtree + * with a return value op + */ + + parent_info = acpi_ps_get_opcode_info (op->parent->opcode); + + switch (ACPI_GET_OP_CLASS (parent_info)) + { + case OPTYPE_CONTROL: /* IF, ELSE, WHILE only */ + case OPTYPE_NAMED_OBJECT: /* Scope, method, etc. */ + break; + + default: + replacement_op = acpi_ps_alloc_op (AML_RETURN_VALUE_OP); + if (!replacement_op) { + return (FALSE); + } + } + + /* We must unlink this op from the parent tree */ + + prev = op->parent->value.arg; + if (prev == op) { + /* This op is the first in the list */ + + if (replacement_op) { + replacement_op->parent = op->parent; + replacement_op->value.arg = NULL; + op->parent->value.arg = replacement_op; + replacement_op->next = op->next; + } + else { + op->parent->value.arg = op->next; + } + } + + /* Search the parent list */ + + else while (prev) { + /* Traverse all siblings in the parent's argument list */ + + next = prev->next; + if (next == op) { + if (replacement_op) { + replacement_op->parent = op->parent; + replacement_op->value.arg = NULL; + prev->next = replacement_op; + replacement_op->next = op->next; + next = NULL; + } + else { + prev->next = op->next; + next = NULL; + } + } + + prev = next; + } + + } + + /* Now we can actually delete the subtree rooted at op */ + + acpi_ps_delete_parse_tree (op); + + return (TRUE); + } + + return (FALSE); + #else + return (FALSE); +#endif +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_ps_next_parse_state + * + * PARAMETERS: Parser_state - Current parser state object + * + * RETURN: + * + * DESCRIPTION: + * + ******************************************************************************/ + ACPI_STATUS -acpi_ps_find_object ( - u16 opcode, - ACPI_PARSE_STATE *parser_state, +acpi_ps_next_parse_state ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP **out_op) + ACPI_PARSE_OBJECT *op, + ACPI_STATUS callback_status) { - char *path; - ACPI_GENERIC_OP *op; - OBJECT_TYPE_INTERNAL data_type; - ACPI_STATUS status; - ACPI_NAMED_OBJECT *entry = NULL; + ACPI_PARSE_STATE *parser_state = walk_state->parser_state; + ACPI_STATUS status = AE_CTRL_PENDING; - /* - * The full parse tree has already been deleted -- therefore, we are parsing - * a control method. We can lookup the name in the namespace instead of - * the parse tree! - */ + switch (callback_status) + { + case AE_CTRL_TERMINATE: + /* + * A control method was terminated via a RETURN statement. + * The walk of this method is complete. + */ - path = acpi_ps_get_next_namestring (parser_state); + parser_state->aml = parser_state->aml_end; + status = AE_CTRL_TERMINATE; + break; - /* Map the raw opcode into an internal object type */ - data_type = acpi_ds_map_named_opcode_to_data_type (opcode); + case AE_CTRL_PENDING: - /* - * Enter the object into the namespace - * LOAD_PASS1 means Create if not found - */ + /* + * Predicate of a WHILE was true and the loop just completed an + * execution. Go back to the start of the loop and reevaluate the + * predicate. + */ +/* Walk_state->Control_state->Common.State = + CONTROL_PREDICATE_EXECUTING;*/ - status = acpi_ns_lookup (walk_state->scope_info, path, data_type, - IMODE_LOAD_PASS1, - NS_NO_UPSEARCH, walk_state, &entry); - if (ACPI_FAILURE (status)) { - return (status); - } + /* TBD: How to handle a break within a while. */ + /* This code attempts it */ - /* Create a new op */ + parser_state->aml = walk_state->aml_last_while; + break; - op = acpi_ps_alloc_op (opcode); - if (!op) { - return (AE_NO_MEMORY); - } - /* Initialize */ + case AE_CTRL_TRUE: + /* + * Predicate of an IF was true, and we are at the matching ELSE. + * Just close out this package + * + * Parser_state->Aml is modified by the package length procedure + */ + parser_state->aml = (parser_state->aml + + acpi_ps_get_next_package_length (parser_state)) -1; + break; + - ((ACPI_NAMED_OP *)op)->name = entry->name; - op->acpi_named_object = entry; + case AE_CTRL_FALSE: + /* + * Either an IF/WHILE Predicate was false or we encountered a BREAK + * opcode. In both cases, we do not execute the rest of the + * package; We simply close out the parent (finishing the walk of + * this branch of the tree) and continue execution at the parent + * level. + */ - acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op); + parser_state->aml = parser_state->scope->parse_scope.pkg_end; - *out_op = op; + /* In the case of a BREAK, just force a predicate (if any) to FALSE */ + walk_state->control_state->common.value = FALSE; + status = AE_CTRL_END; + break; - return (AE_OK); + + case AE_CTRL_TRANSFER: + + /* + * A method call (invocation) -- transfer control + */ + status = AE_CTRL_TRANSFER; + walk_state->prev_op = op; + walk_state->method_call_op = op; + walk_state->method_call_node = (op->value.arg)->node; + + /* Will return value (if any) be used by the caller? */ + + walk_state->return_used = acpi_ds_is_result_used (op); + break; + + + default: + status = callback_status; + if ((callback_status & AE_CODE_MASK) == AE_CODE_CONTROL) { + status = AE_OK; + } + break; + } + + + return (status); } -#endif /******************************************************************************* @@ -356,26 +560,27 @@ ACPI_STATUS acpi_ps_parse_loop ( - ACPI_PARSE_STATE *parser_state, - ACPI_WALK_STATE *walk_state, - u32 parse_flags) + ACPI_WALK_STATE *walk_state) { ACPI_STATUS status = AE_OK; - ACPI_GENERIC_OP *op = NULL; /* current op */ - ACPI_OP_INFO *op_info; - ACPI_GENERIC_OP *arg = NULL; - ACPI_DEFERRED_OP *deferred_op; + ACPI_PARSE_OBJECT *op = NULL; /* current op */ + ACPI_OPCODE_INFO *op_info; + ACPI_PARSE_OBJECT *arg = NULL; + ACPI_PARSE2_OBJECT *deferred_op; u32 arg_count; /* push for fixed or var args */ u32 arg_types = 0; ACPI_PTRDIFF aml_offset; u16 opcode; - ACPI_GENERIC_OP pre_op; + ACPI_PARSE_OBJECT pre_op; + ACPI_PARSE_STATE *parser_state; -#ifndef PARSER_ONLY - OBJECT_TYPE_INTERNAL data_type; -#endif + parser_state = walk_state->parser_state; + if (walk_state->prev_op) { + op = walk_state->prev_op; + arg_types = walk_state->prev_arg_types; + } /* * Iterative parsing loop, while there is more aml to process: @@ -384,9 +589,8 @@ if (!op) { /* Get the next opcode from the AML stream */ - aml_offset = parser_state->aml - parser_state->aml_start; - opcode = acpi_ps_peek_opcode (parser_state); - op_info = acpi_ps_get_opcode_info (opcode); + aml_offset = parser_state->aml - parser_state->aml_start; + opcode = acpi_ps_peek_opcode (parser_state); /* * First cut to determine what we have found: @@ -395,16 +599,19 @@ * 3) An unknown/invalid opcode */ - if (op_info) { + op_info = acpi_ps_get_opcode_info (opcode); + switch (ACPI_GET_OP_TYPE (op_info)) + { + case ACPI_OP_TYPE_OPCODE: + /* Found opcode info, this is a normal opcode */ parser_state->aml += acpi_ps_get_opcode_size (opcode); arg_types = op_info->parse_args; - } + break; - else if (acpi_ps_is_prefix_char (opcode) || - acpi_ps_is_leading_char (opcode)) - { + case ACPI_OP_TYPE_ASCII: + case ACPI_OP_TYPE_PREFIX: /* * Starts with a valid prefix or ASCII char, this is a name * string. Convert the bare name string to a namepath. @@ -412,9 +619,10 @@ opcode = AML_NAMEPATH_OP; arg_types = ARGP_NAMESTRING; - } + break; + + case ACPI_OP_TYPE_UNKNOWN: - else { /* The opcode is unrecognized. Just skip unknown opcodes */ parser_state->aml += acpi_ps_get_opcode_size (opcode); @@ -441,9 +649,24 @@ INCREMENT_ARG_LIST (arg_types); - status = acpi_ps_find_object (opcode, parser_state, walk_state, &op); - if (ACPI_FAILURE (status)) { - return (AE_NOT_FOUND); + if (walk_state->descending_callback != NULL) { + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + status = walk_state->descending_callback (opcode, NULL, walk_state, &op); + if (op == NULL) { + continue; + } + status = acpi_ps_next_parse_state (walk_state, op, status); + if (status == AE_CTRL_PENDING) { + status = AE_OK; + goto close_this_op; + } + + if (ACPI_FAILURE (status)) { + goto close_this_op; + } } acpi_ps_append_arg (op, pre_op.value.arg); @@ -451,7 +674,7 @@ if (op->opcode == AML_REGION_OP) { - deferred_op = acpi_ps_to_deferred_op (op); + deferred_op = acpi_ps_to_extended_op (op); if (deferred_op) { /* * Skip parsing of control method or opregion body, @@ -464,13 +687,15 @@ * Body_length is unknown until we parse the body */ - deferred_op->body = parser_state->aml - 6; - deferred_op->body_length = 0; + deferred_op->data = parser_state->aml - 6; + deferred_op->length = 0; } } } else { + + /* Not a named opcode, just allocate Op and append to parent */ op = acpi_ps_alloc_op (opcode); @@ -479,6 +704,23 @@ } acpi_ps_append_arg (acpi_ps_get_parent_scope (parser_state), op); + + if ((walk_state->descending_callback != NULL)) { + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + status = walk_state->descending_callback (opcode, op, walk_state, &op); + status = acpi_ps_next_parse_state (walk_state, op, status); + if (status == AE_CTRL_PENDING) { + status = AE_OK; + goto close_this_op; + } + + if (ACPI_FAILURE (status)) { + goto close_this_op; + } + } } op->aml_offset = aml_offset; @@ -532,7 +774,7 @@ /* For a method, save the length and address of the body */ if (op->opcode == AML_METHOD_OP) { - deferred_op = acpi_ps_to_deferred_op (op); + deferred_op = acpi_ps_to_extended_op (op); if (deferred_op) { /* * Skip parsing of control method or opregion body, @@ -540,8 +782,8 @@ * to parse them correctly. */ - deferred_op->body = parser_state->aml; - deferred_op->body_length = parser_state->pkg_end - + deferred_op->data = parser_state->aml; + deferred_op->length = parser_state->pkg_end - parser_state->aml; /* @@ -549,8 +791,8 @@ * parsing because the opregion is not a standalone * package (We don't know where the end is). */ - parser_state->aml = parser_state->pkg_end; - arg_count = 0; + parser_state->aml = parser_state->pkg_end; + arg_count = 0; } } @@ -567,7 +809,7 @@ } if (op->opcode == AML_REGION_OP) { - deferred_op = acpi_ps_to_deferred_op (op); + deferred_op = acpi_ps_to_extended_op (op); if (deferred_op) { /* * Skip parsing of control method or opregion body, @@ -578,46 +820,75 @@ * know the length. */ - deferred_op->body_length = parser_state->aml - - deferred_op->body; + deferred_op->length = parser_state->aml - + deferred_op->data; } } + } -#ifndef PARSER_ONLY - data_type = acpi_ds_map_named_opcode_to_data_type (op->opcode); + /* This op complete, notify the dispatcher */ - if (op->opcode == AML_NAME_OP) { - if (op->value.arg) { - data_type = acpi_ds_map_opcode_to_data_type ( - (op->value.arg)->opcode, NULL); - ((ACPI_NAMED_OBJECT*)op->acpi_named_object)->type = - (u8) data_type; - } + if (walk_state->ascending_callback != NULL) { + status = walk_state->ascending_callback (walk_state, op); + status = acpi_ps_next_parse_state (walk_state, op, status); + if (status == AE_CTRL_PENDING) { + status = AE_OK; + goto close_this_op; } + } - /* Pop the scope stack */ - if (acpi_ns_opens_scope (data_type)) { +close_this_op: - acpi_ds_scope_stack_pop (walk_state); - } -#endif + parser_state->scope->parse_scope.arg_count--; + + /* Close this Op (may result in parse subtree deletion) */ + + if (acpi_ps_complete_this_op (walk_state, op)) { + op = NULL; + } + + + if (status == AE_CTRL_END) { + acpi_ps_pop_scope (parser_state, &op, &arg_types); + status = walk_state->ascending_callback (walk_state, op); + status = acpi_ps_next_parse_state (walk_state, op, status); + acpi_ps_complete_this_op (walk_state, op); + op = NULL; + status = AE_OK; } + else if (ACPI_FAILURE (status)) { + if (op == NULL) { + acpi_ps_pop_scope (parser_state, &op, &arg_types); + } + walk_state->prev_op = op; + walk_state->prev_arg_types = arg_types; - parser_state->scope->arg_count--; + /* + * TEMP: + */ + if (status == AE_CTRL_TERMINATE) { + status = AE_OK; - /* Delete op if asked to */ + /* Clean up */ + do + { + if (op) { + acpi_ps_complete_this_op (walk_state, op); + } -#ifndef PARSER_ONLY - if (parse_flags & PARSE_DELETE_TREE) { - acpi_ps_delete_parse_tree (op); + acpi_ps_pop_scope (parser_state, &op, &arg_types); + } while (op); + } + return (status); } -#endif + /* This scope complete? */ + if (acpi_ps_has_completed_scope (parser_state)) { acpi_ps_pop_scope (parser_state, &op, &arg_types); } @@ -625,6 +896,7 @@ else { op = NULL; } + } else { @@ -637,6 +909,54 @@ } /* while Parser_state->Aml */ + /* + * Complete the last Op (if not completed), and clear the scope stack. + * It is easily possible to end an AML "package" with an unbounded number + * of open scopes (such as when several AML blocks are closed with + * sequential closing braces). We want to terminate each one cleanly. + */ + + do + { + if (op) { + if (walk_state->ascending_callback != NULL) { + status = walk_state->ascending_callback (walk_state, op); + status = acpi_ps_next_parse_state (walk_state, op, status); + if (status == AE_CTRL_PENDING) { + status = AE_OK; + goto close_this_op; + } + + if (status == AE_CTRL_TERMINATE) { + status = AE_OK; + + /* Clean up */ + do + { + if (op) { + acpi_ps_complete_this_op (walk_state, op); + } + + acpi_ps_pop_scope (parser_state, &op, &arg_types); + + } while (op); + + return (status); + } + + else if (ACPI_FAILURE (status)) { + acpi_ps_complete_this_op (walk_state, op); + return (status); + } + } + + acpi_ps_complete_this_op (walk_state, op); + } + + acpi_ps_pop_scope (parser_state, &op, &arg_types); + + } while (op); + return (status); } @@ -658,19 +978,28 @@ ACPI_STATUS acpi_ps_parse_aml ( - ACPI_GENERIC_OP *start_scope, + ACPI_PARSE_OBJECT *start_scope, u8 *aml, u32 aml_size, - u32 parse_flags) + u32 parse_flags, + ACPI_NAMESPACE_NODE *method_node, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **caller_return_desc, + ACPI_PARSE_DOWNWARDS descending_callback, + ACPI_PARSE_UPWARDS ascending_callback) { ACPI_STATUS status; ACPI_PARSE_STATE *parser_state; ACPI_WALK_STATE *walk_state; ACPI_WALK_LIST walk_list; - ACPI_NAMED_OBJECT *entry = NULL; + ACPI_NAMESPACE_NODE *node = NULL; + ACPI_WALK_LIST *prev_walk_list = acpi_gbl_current_walk_list; + ACPI_OPERAND_OBJECT *return_desc; + ACPI_OPERAND_OBJECT *mth_desc = NULL; + ACPI_NAMESPACE_NODE *start_node; - /* Initialize parser state and scope */ + /* Create and initialize a new parser state */ parser_state = acpi_ps_create_state (aml, aml_size); if (!parser_state) { @@ -679,36 +1008,166 @@ acpi_ps_init_scope (parser_state, start_scope); + if (method_node) { + mth_desc = acpi_ns_get_attached_object (method_node); + } - /* Initialize a new walk list */ + /* Create and initialize a new walk list */ walk_list.walk_state = NULL; - walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT, NULL, NULL, &walk_list); + walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT, parser_state->start_op, mth_desc, &walk_list); if (!walk_state) { status = AE_NO_MEMORY; goto cleanup; } + walk_state->method_node = method_node; + walk_state->parser_state = parser_state; + walk_state->parse_flags = parse_flags; + walk_state->descending_callback = descending_callback; + walk_state->ascending_callback = ascending_callback; + + /* TBD: [Restructure] TEMP until we pass Walk_state to the interpreter + */ + acpi_gbl_current_walk_list = &walk_list; + - /* Setup the current scope */ + if (method_node) { + start_node = method_node; + parser_state->start_node = method_node; + walk_state->walk_type = WALK_METHOD; - entry = parser_state->start_op->acpi_named_object; - if (entry) { - /* Push start scope on scope stack and make it current */ + if (start_node) { + /* Push start scope on scope stack and make it current */ + + status = acpi_ds_scope_stack_push (start_node, ACPI_TYPE_METHOD, walk_state); + if (ACPI_FAILURE (status)) { + return (status); + } - status = acpi_ds_scope_stack_push (entry->child_table, entry->type, - walk_state); - if (ACPI_FAILURE (status)) { - goto cleanup; } + /* Init arguments if this is a control method */ + /* TBD: [Restructure] add walkstate as a param */ + acpi_ds_method_data_init_args (params, MTH_NUM_ARGS, walk_state); } + else { + /* Setup the current scope */ - /* Create the parse tree */ + node = parser_state->start_op->node; + if (node) { + /* Push start scope on scope stack and make it current */ + + status = acpi_ds_scope_stack_push (node, node->type, + walk_state); + if (ACPI_FAILURE (status)) { + goto cleanup; + } + + } + } - status = acpi_ps_parse_loop (parser_state, walk_state, parse_flags); + + status = AE_OK; + + /* + * Execute the walk loop as long as there is a valid Walk State. This + * handles nested control method invocations without recursion. + */ + + while (walk_state) { + if (ACPI_SUCCESS (status)) { + status = acpi_ps_parse_loop (walk_state); + } + + if (status == AE_CTRL_TRANSFER) { + /* + * A method call was detected. + * Transfer control to the called control method + */ + + status = acpi_ds_call_control_method (&walk_list, walk_state, NULL); + + /* + * If the transfer to the new method method call worked, a new walk + * state was created -- get it + */ + + walk_state = acpi_ds_get_current_walk_state (&walk_list); + continue; + } + + else if (status == AE_CTRL_TERMINATE) { + status = AE_OK; + } + + /* We are done with this walk, move on to the parent if any */ + + + walk_state = acpi_ds_pop_walk_state (&walk_list); + + /* Extract return value before we delete Walk_state */ + + return_desc = walk_state->return_desc; + + /* Reset the current scope to the beginning of scope stack */ + + acpi_ds_scope_stack_clear (walk_state); + + /* + * If we just returned from the execution of a control method, + * there's lots of cleanup to do + */ + + if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) { + acpi_ds_terminate_control_method (walk_state); + } + + /* Delete this walk state and all linked control states */ + + acpi_ps_cleanup_scope (walk_state->parser_state); + acpi_cm_free (walk_state->parser_state); + acpi_ds_delete_walk_state (walk_state); + + /* Check if we have restarted a preempted walk */ + + walk_state = acpi_ds_get_current_walk_state (&walk_list); + if (walk_state && + ACPI_SUCCESS (status)) + { + /* There is another walk state, restart it */ + + /* + * If the method returned value is not used by the parent, + * The object is deleted + */ + + acpi_ds_restart_control_method (walk_state, return_desc); + } + + /* + * Just completed a 1st-level method, save the final internal return + * value (if any) + */ + + else if (caller_return_desc) { + *caller_return_desc = return_desc; /* NULL if no return value */ + } + + else if (return_desc) { + /* Caller doesn't want it, must delete it */ + + acpi_cm_remove_reference (return_desc); + } + } + + + /* Normal exit */ + + acpi_gbl_current_walk_list = prev_walk_list; + return (status); cleanup: @@ -719,6 +1178,7 @@ acpi_ps_cleanup_scope (parser_state); acpi_cm_free (parser_state); + acpi_gbl_current_walk_list = prev_walk_list; return (status); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/parser/psscope.c linux/drivers/acpi/parser/psscope.c --- v2.4.0-test8/linux/drivers/acpi/parser/psscope.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/parser/psscope.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: psscope - Parser scope stack management routines + * $Revision: 18 $ * *****************************************************************************/ @@ -24,10 +25,10 @@ #include "acpi.h" -#include "parser.h" +#include "acparser.h" #define _COMPONENT PARSER - MODULE_NAME ("psscope"); + MODULE_NAME ("psscope") /******************************************************************************* @@ -42,11 +43,11 @@ * ******************************************************************************/ -ACPI_GENERIC_OP * +ACPI_PARSE_OBJECT * acpi_ps_get_parent_scope ( ACPI_PARSE_STATE *parser_state) { - return parser_state->scope->op; + return (parser_state->scope->parse_scope.op); } @@ -68,8 +69,8 @@ acpi_ps_has_completed_scope ( ACPI_PARSE_STATE *parser_state) { - return (u8) ((parser_state->aml >= parser_state->scope->arg_end || - !parser_state->scope->arg_count)); + return ((u8) ((parser_state->aml >= parser_state->scope->parse_scope.arg_end || + !parser_state->scope->parse_scope.arg_count))); } @@ -78,7 +79,7 @@ * FUNCTION: Acpi_ps_init_scope * * PARAMETERS: Parser_state - Current parser state object - * Root - the root object of this new scope + * Root - the Root Node of this new scope * * RETURN: Status * @@ -89,24 +90,25 @@ ACPI_STATUS acpi_ps_init_scope ( ACPI_PARSE_STATE *parser_state, - ACPI_GENERIC_OP *root) + ACPI_PARSE_OBJECT *root_op) { - ACPI_PARSE_SCOPE *scope; + ACPI_GENERIC_STATE *scope; - scope = acpi_cm_callocate (sizeof (ACPI_PARSE_SCOPE)); + scope = acpi_cm_create_generic_state (); if (!scope) { - return AE_NO_MEMORY; + return (AE_NO_MEMORY); } - scope->op = root; - scope->arg_count = ACPI_VAR_ARGS; - scope->arg_end = parser_state->aml_end; - scope->pkg_end = parser_state->aml_end; - parser_state->scope = scope; - parser_state->start_op = root; + scope->parse_scope.op = root_op; + scope->parse_scope.arg_count = ACPI_VAR_ARGS; + scope->parse_scope.arg_end = parser_state->aml_end; + scope->parse_scope.pkg_end = parser_state->aml_end; - return AE_OK; + parser_state->scope = scope; + parser_state->start_op = root_op; + + return (AE_OK); } @@ -128,49 +130,39 @@ ACPI_STATUS acpi_ps_push_scope ( ACPI_PARSE_STATE *parser_state, - ACPI_GENERIC_OP *op, + ACPI_PARSE_OBJECT *op, u32 remaining_args, u32 arg_count) { - ACPI_PARSE_SCOPE *scope = parser_state->scope_avail; - + ACPI_GENERIC_STATE *scope; - if (scope) { - /* grabbed scope from available list */ - parser_state->scope_avail = scope->parent; + scope = acpi_cm_create_generic_state (); + if (!scope) { + return (AE_NO_MEMORY); } - else { - /* allocate scope from the heap */ - scope = (ACPI_PARSE_SCOPE*) acpi_cm_allocate (sizeof (ACPI_PARSE_SCOPE)); - if (!scope) { - return (AE_NO_MEMORY); - } - } + scope->parse_scope.op = op; + scope->parse_scope.arg_list = remaining_args; + scope->parse_scope.arg_count = arg_count; + scope->parse_scope.pkg_end = parser_state->pkg_end; - /* Always zero out the scope before init */ + /* Push onto scope stack */ - MEMSET (scope, 0, sizeof (*scope)); + acpi_cm_push_generic_state (&parser_state->scope, scope); - scope->op = op; - scope->arg_list = remaining_args; - scope->arg_count = arg_count; - scope->pkg_end = parser_state->pkg_end; - scope->parent = parser_state->scope; - parser_state->scope = scope; if (arg_count == ACPI_VAR_ARGS) { /* multiple arguments */ - scope->arg_end = parser_state->pkg_end; + scope->parse_scope.arg_end = parser_state->pkg_end; } else { /* single argument */ - scope->arg_end = ACPI_MAX_AML; + scope->parse_scope.arg_end = ACPI_MAX_AML; } return (AE_OK); @@ -195,24 +187,28 @@ void acpi_ps_pop_scope ( ACPI_PARSE_STATE *parser_state, - ACPI_GENERIC_OP **op, + ACPI_PARSE_OBJECT **op, u32 *arg_list) { - ACPI_PARSE_SCOPE *scope = parser_state->scope; + ACPI_GENERIC_STATE *scope = parser_state->scope; + + + /* + * Only pop the scope if there is in fact a next scope + */ + if (scope->common.next) { + scope = acpi_cm_pop_generic_state (&parser_state->scope); - if (scope->parent) { /* return to parsing previous op */ - *op = scope->op; - *arg_list = scope->arg_list; - parser_state->pkg_end = scope->pkg_end; - parser_state->scope = scope->parent; + *op = scope->parse_scope.op; + *arg_list = scope->parse_scope.arg_list; + parser_state->pkg_end = scope->parse_scope.pkg_end; - /* add scope to available list */ + /* All done with this scope state structure */ - scope->parent = parser_state->scope_avail; - parser_state->scope_avail = scope; + acpi_cm_delete_generic_state (scope); } else { @@ -222,6 +218,7 @@ *arg_list = 0; } + return; } @@ -243,27 +240,19 @@ acpi_ps_cleanup_scope ( ACPI_PARSE_STATE *parser_state) { - ACPI_PARSE_SCOPE *scope; + ACPI_GENERIC_STATE *scope; if (!parser_state) { return; } - /* destroy available list */ - - while (parser_state->scope_avail) { - scope = parser_state->scope_avail; - parser_state->scope_avail = scope->parent; - acpi_cm_free (scope); - } - /* destroy scope stack */ + /* Delete anything on the scope stack */ while (parser_state->scope) { - scope = parser_state->scope; - parser_state->scope = scope->parent; - acpi_cm_free (scope); + scope = acpi_cm_pop_generic_state (&parser_state->scope); + acpi_cm_delete_generic_state (scope); } return; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/parser/pstree.c linux/drivers/acpi/parser/pstree.c --- v2.4.0-test8/linux/drivers/acpi/parser/pstree.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/parser/pstree.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: pstree - Parser op tree manipulation/traversal/search + * $Revision: 23 $ * *****************************************************************************/ @@ -24,11 +25,11 @@ #include "acpi.h" -#include "parser.h" +#include "acparser.h" #include "amlcode.h" #define _COMPONENT PARSER - MODULE_NAME ("pstree"); + MODULE_NAME ("pstree") /******************************************************************************* @@ -44,30 +45,30 @@ * ******************************************************************************/ -ACPI_GENERIC_OP * +ACPI_PARSE_OBJECT * acpi_ps_get_arg ( - ACPI_GENERIC_OP *op, + ACPI_PARSE_OBJECT *op, u32 argn) { - ACPI_GENERIC_OP *arg = NULL; - ACPI_OP_INFO *op_info; + ACPI_PARSE_OBJECT *arg = NULL; + ACPI_OPCODE_INFO *op_info; /* Get the info structure for this opcode */ op_info = acpi_ps_get_opcode_info (op->opcode); - if (!op_info) { - /* Invalid opcode */ + if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { + /* Invalid opcode or ASCII character */ - return NULL; + return (NULL); } /* Check if this opcode requires argument sub-objects */ - if (!(op_info->flags & OP_INFO_HAS_ARGS)) { + if (!(ACPI_GET_OP_ARGS (op_info))) { /* Has no linked argument objects */ - return NULL; + return (NULL); } /* Get the requested argument object */ @@ -78,7 +79,7 @@ arg = arg->next; } - return arg; + return (arg); } @@ -97,11 +98,11 @@ void acpi_ps_append_arg ( - ACPI_GENERIC_OP *op, - ACPI_GENERIC_OP *arg) + ACPI_PARSE_OBJECT *op, + ACPI_PARSE_OBJECT *arg) { - ACPI_GENERIC_OP *prev_arg; - ACPI_OP_INFO *op_info; + ACPI_PARSE_OBJECT *prev_arg; + ACPI_OPCODE_INFO *op_info; if (!op) { @@ -111,7 +112,7 @@ /* Get the info structure for this opcode */ op_info = acpi_ps_get_opcode_info (op->opcode); - if (!op_info) { + if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) { /* Invalid opcode */ return; @@ -119,7 +120,7 @@ /* Check if this opcode requires argument sub-objects */ - if (!(op_info->flags & OP_INFO_HAS_ARGS)) { + if (!(ACPI_GET_OP_ARGS (op_info))) { /* Has no linked argument objects */ return; @@ -166,11 +167,11 @@ * ******************************************************************************/ -ACPI_GENERIC_OP * +ACPI_PARSE_OBJECT * acpi_ps_get_child ( - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT *op) { - ACPI_GENERIC_OP *child = NULL; + ACPI_PARSE_OBJECT *child = NULL; switch (op->opcode) @@ -211,7 +212,7 @@ } - return child; + return (child); } @@ -229,32 +230,32 @@ * ******************************************************************************/ -ACPI_GENERIC_OP * +ACPI_PARSE_OBJECT * acpi_ps_get_depth_next ( - ACPI_GENERIC_OP *origin, - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT *origin, + ACPI_PARSE_OBJECT *op) { - ACPI_GENERIC_OP *next = NULL; - ACPI_GENERIC_OP *parent; - ACPI_GENERIC_OP *arg; + ACPI_PARSE_OBJECT *next = NULL; + ACPI_PARSE_OBJECT *parent; + ACPI_PARSE_OBJECT *arg; if (!op) { - return NULL; + return (NULL); } /* look for an argument or child */ next = acpi_ps_get_arg (op, 0); if (next) { - return next; + return (next); } /* look for a sibling */ next = op->next; if (next) { - return next; + return (next); } /* look for a sibling of parent */ @@ -270,19 +271,19 @@ if (arg == origin) { /* reached parent of origin, end search */ - return NULL; + return (NULL); } if (parent->next) { /* found sibling of parent */ - return parent->next; + return (parent->next); } op = parent; parent = parent->parent; } - return next; + return (next); } @@ -300,10 +301,10 @@ * ******************************************************************************/ -ACPI_GENERIC_OP * +ACPI_PARSE_OBJECT * acpi_ps_fetch_prefix ( - ACPI_GENERIC_OP *scope, - char **path, + ACPI_PARSE_OBJECT *scope, + NATIVE_CHAR **path, u32 io) { u32 prefix = io ? GET8 (*path):**path; @@ -338,7 +339,7 @@ scope = acpi_ps_get_child (scope); } - return scope; + return (scope); } @@ -349,7 +350,7 @@ * PARAMETERS: Path - A string containing the name segment * io - Direction flag * - * RETURN: The 4-char ASCII ACPI Name as a u32 + * RETURN: The 4-s8 ASCII ACPI Name as a u32 * * DESCRIPTION: Fetch ACPI name segment (dot-delimited) * @@ -357,13 +358,13 @@ u32 acpi_ps_fetch_name ( - char **path, + NATIVE_CHAR **path, u32 io) { u32 name = 0; - char *nm; + NATIVE_CHAR *nm; u32 i; - char ch; + NATIVE_CHAR ch; if (io) { @@ -378,7 +379,7 @@ *path += 1; } - nm = (char*) &name; + nm = (NATIVE_CHAR *) &name; for (i = 0; i < 4; i++) { ch = **path; if (ch && ch != '.') { @@ -393,7 +394,7 @@ } } - return name; + return (name); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/parser/psutils.c linux/drivers/acpi/parser/psutils.c --- v2.4.0-test8/linux/drivers/acpi/parser/psutils.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/parser/psutils.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: psutils - Parser miscellaneous utilities (Parser only) + * $Revision: 29 $ * *****************************************************************************/ @@ -24,17 +25,18 @@ #include "acpi.h" -#include "parser.h" +#include "acparser.h" #include "amlcode.h" #define _COMPONENT PARSER - MODULE_NAME ("psutils"); + MODULE_NAME ("psutils") -#define PARSEOP_GENERIC 1 -#define PARSEOP_NAMED 2 -#define PARSEOP_DEFERRED 3 -#define PARSEOP_BYTELIST 4 +#define PARSEOP_GENERIC 0x01 +#define PARSEOP_NAMED 0x02 +#define PARSEOP_DEFERRED 0x03 +#define PARSEOP_BYTELIST 0x04 +#define PARSEOP_IN_CACHE 0x80 /******************************************************************************* @@ -53,21 +55,19 @@ void acpi_ps_init_op ( - ACPI_GENERIC_OP *op, + ACPI_PARSE_OBJECT *op, u16 opcode) { - ACPI_OP_INFO *aml_op; + ACPI_OPCODE_INFO *aml_op; op->data_type = ACPI_DESC_TYPE_PARSER; op->opcode = opcode; - aml_op = acpi_ps_get_opcode_info (opcode); - if (aml_op) { - DEBUG_ONLY_MEMBERS (STRNCPY (op->op_name, aml_op->name, - sizeof (op->op_name))); - } + + DEBUG_ONLY_MEMBERS (STRNCPY (op->op_name, aml_op->name, + sizeof (op->op_name))); } @@ -85,11 +85,11 @@ * ******************************************************************************/ -ACPI_GENERIC_OP* +ACPI_PARSE_OBJECT* acpi_ps_alloc_op ( u16 opcode) { - ACPI_GENERIC_OP *op = NULL; + ACPI_PARSE_OBJECT *op = NULL; u32 size; u8 flags; @@ -97,24 +97,27 @@ /* Allocate the minimum required size object */ if (acpi_ps_is_deferred_op (opcode)) { - size = sizeof (ACPI_DEFERRED_OP); + size = sizeof (ACPI_PARSE2_OBJECT); flags = PARSEOP_DEFERRED; } else if (acpi_ps_is_named_op (opcode)) { - size = sizeof (ACPI_NAMED_OP); + size = sizeof (ACPI_PARSE2_OBJECT); flags = PARSEOP_NAMED; } else if (acpi_ps_is_bytelist_op (opcode)) { - size = sizeof (ACPI_BYTELIST_OP); + size = sizeof (ACPI_PARSE2_OBJECT); flags = PARSEOP_BYTELIST; } else { - size = sizeof (ACPI_GENERIC_OP); + size = sizeof (ACPI_PARSE_OBJECT); flags = PARSEOP_GENERIC; + } + + if (size == sizeof (ACPI_PARSE_OBJECT)) { /* * The generic op is by far the most common (16 to 1), and therefore * the op cache is implemented with this type. @@ -133,13 +136,44 @@ op = acpi_gbl_parse_cache; acpi_gbl_parse_cache = op->next; + + /* Clear the previously used Op */ + + MEMSET (op, 0, sizeof (ACPI_PARSE_OBJECT)); + + } + acpi_cm_release_mutex (ACPI_MTX_CACHES); + } + + else { + /* + * The generic op is by far the most common (16 to 1), and therefore + * the op cache is implemented with this type. + * + * Check if there is an Op already available in the cache + */ + + acpi_cm_acquire_mutex (ACPI_MTX_CACHES); + acpi_gbl_ext_parse_cache_requests++; + if (acpi_gbl_ext_parse_cache) { + /* Extract an op from the front of the cache list */ + + acpi_gbl_ext_parse_cache_depth--; + acpi_gbl_ext_parse_cache_hits++; + + op = (ACPI_PARSE_OBJECT *) acpi_gbl_ext_parse_cache; + acpi_gbl_ext_parse_cache = (ACPI_PARSE2_OBJECT *) op->next; + + /* Clear the previously used Op */ - MEMSET (op, 0, sizeof (ACPI_GENERIC_OP)); + MEMSET (op, 0, sizeof (ACPI_PARSE2_OBJECT)); + } acpi_cm_release_mutex (ACPI_MTX_CACHES); } + /* Allocate a new Op if necessary */ if (!op) { @@ -152,7 +186,7 @@ op->flags = flags; } - return op; + return (op); } @@ -171,16 +205,22 @@ void acpi_ps_free_op ( - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT *op) { + if (op->flags == PARSEOP_GENERIC) { /* Is the cache full? */ if (acpi_gbl_parse_cache_depth < MAX_PARSE_CACHE_DEPTH) { /* Put a GENERIC_OP back into the cache */ + /* Clear the previously used Op */ + + MEMSET (op, 0, sizeof (ACPI_PARSE_OBJECT)); + op->flags = PARSEOP_IN_CACHE; + acpi_cm_acquire_mutex (ACPI_MTX_CACHES); acpi_gbl_parse_cache_depth++; @@ -192,6 +232,29 @@ } } + else { + /* Is the cache full? */ + + if (acpi_gbl_ext_parse_cache_depth < MAX_EXTPARSE_CACHE_DEPTH) { + /* Put a GENERIC_OP back into the cache */ + + /* Clear the previously used Op */ + + MEMSET (op, 0, sizeof (ACPI_PARSE2_OBJECT)); + op->flags = PARSEOP_IN_CACHE; + + acpi_cm_acquire_mutex (ACPI_MTX_CACHES); + acpi_gbl_ext_parse_cache_depth++; + + op->next = (ACPI_PARSE_OBJECT *) acpi_gbl_ext_parse_cache; + acpi_gbl_ext_parse_cache = (ACPI_PARSE2_OBJECT *) op; + + acpi_cm_release_mutex (ACPI_MTX_CACHES); + return; + } + } + + /* * Not a GENERIC OP, or the cache is full, just free the Op */ @@ -216,7 +279,7 @@ acpi_ps_delete_parse_cache ( void) { - ACPI_GENERIC_OP *next; + ACPI_PARSE_OBJECT *next; /* Traverse the global cache list */ @@ -227,6 +290,18 @@ next = acpi_gbl_parse_cache->next; acpi_cm_free (acpi_gbl_parse_cache); acpi_gbl_parse_cache = next; + acpi_gbl_parse_cache_depth--; + } + + /* Traverse the global cache list */ + + while (acpi_gbl_ext_parse_cache) { + /* Delete one cached state object */ + + next = acpi_gbl_ext_parse_cache->next; + acpi_cm_free (acpi_gbl_ext_parse_cache); + acpi_gbl_ext_parse_cache = (ACPI_PARSE2_OBJECT *) next; + acpi_gbl_ext_parse_cache_depth--; } return; @@ -253,7 +328,7 @@ u8 acpi_ps_is_leading_char ( - s32 c) + u32 c) { return ((u8) (c == '_' || (c >= 'A' && c <= 'Z'))); } @@ -264,7 +339,7 @@ */ u8 acpi_ps_is_prefix_char ( - s32 c) + u32 c) { return ((u8) (c == '\\' || c == '^')); } @@ -329,7 +404,7 @@ * TBD: [Restructure] Need a better way than this brute force approach! */ u8 -acpi_ps_is_named_object_op ( +acpi_ps_is_node_op ( u16 opcode) { return ((u8) @@ -433,38 +508,16 @@ /* - * Cast an acpi_op to an acpi_deferred_op if possible - */ -ACPI_DEFERRED_OP * -acpi_ps_to_deferred_op ( - ACPI_GENERIC_OP *op) -{ - return (acpi_ps_is_deferred_op (op->opcode) - ? ( (ACPI_DEFERRED_OP *) op) : NULL); -} - - -/* - * Cast an acpi_op to an acpi_named_op if possible + * Cast an acpi_op to an acpi_extended_op if possible */ -ACPI_NAMED_OP* -acpi_ps_to_named_op ( - ACPI_GENERIC_OP *op) -{ - return (acpi_ps_is_named_op (op->opcode) - ? ( (ACPI_NAMED_OP *) op) : NULL); -} - -/* - * Cast an acpi_op to an acpi_bytelist_op if possible - */ -ACPI_BYTELIST_OP* -acpi_ps_to_bytelist_op ( - ACPI_GENERIC_OP *op) +/* TBD: This is very inefficient, fix */ +ACPI_PARSE2_OBJECT * +acpi_ps_to_extended_op ( + ACPI_PARSE_OBJECT *op) { - return (acpi_ps_is_bytelist_op (op->opcode) - ? ( (ACPI_BYTELIST_OP*) op) : NULL); + return ((acpi_ps_is_deferred_op (op->opcode) || acpi_ps_is_named_op (op->opcode) || acpi_ps_is_bytelist_op (op->opcode)) + ? ( (ACPI_PARSE2_OBJECT *) op) : NULL); } @@ -473,9 +526,9 @@ */ u32 acpi_ps_get_name ( - ACPI_GENERIC_OP *op) + ACPI_PARSE_OBJECT *op) { - ACPI_NAMED_OP *named = acpi_ps_to_named_op (op); + ACPI_PARSE2_OBJECT *named = acpi_ps_to_extended_op (op); return (named ? named->name : 0); } @@ -486,10 +539,10 @@ */ void acpi_ps_set_name ( - ACPI_GENERIC_OP *op, + ACPI_PARSE_OBJECT *op, u32 name) { - ACPI_NAMED_OP *named = acpi_ps_to_named_op (op); + ACPI_PARSE2_OBJECT *named = acpi_ps_to_extended_op (op); if (named) { named->name = name; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/parser/pswalk.c linux/drivers/acpi/parser/pswalk.c --- v2.4.0-test8/linux/drivers/acpi/parser/pswalk.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/parser/pswalk.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: pswalk - Parser routines to walk parsed op tree(s) + * $Revision: 45 $ * *****************************************************************************/ @@ -25,13 +26,13 @@ #include "acpi.h" #include "amlcode.h" -#include "parser.h" -#include "dispatch.h" -#include "namesp.h" -#include "interp.h" +#include "acparser.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acinterp.h" #define _COMPONENT PARSER - MODULE_NAME ("pswalk"); + MODULE_NAME ("pswalk") /******************************************************************************* @@ -53,12 +54,12 @@ ACPI_STATUS acpi_ps_get_next_walk_op ( ACPI_WALK_STATE *walk_state, - ACPI_GENERIC_OP *op, - INTERPRETER_CALLBACK ascending_callback) + ACPI_PARSE_OBJECT *op, + ACPI_PARSE_UPWARDS ascending_callback) { - ACPI_GENERIC_OP *next; - ACPI_GENERIC_OP *parent; - ACPI_GENERIC_OP *grand_parent; + ACPI_PARSE_OBJECT *next; + ACPI_PARSE_OBJECT *parent; + ACPI_PARSE_OBJECT *grand_parent; ACPI_STATUS status; @@ -146,6 +147,18 @@ default: /* + * If we are back to the starting point, the walk is complete. + */ + if (op == walk_state->origin) { + /* Reached the point of origin, the walk is complete */ + + walk_state->prev_op = op; + walk_state->next_op = NULL; + + return (status); + } + + /* * Check for a sibling to the current op. A sibling means * we are still going "downward" in the tree. */ @@ -166,7 +179,7 @@ * No sibling, but check status. * Abort on error from callback routine */ - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { /* Next op will be the parent */ walk_state->prev_op = op; @@ -302,7 +315,7 @@ * No sibling, check for an error from closing the parent * (Also, AE_PENDING if a method call was encountered) */ - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { walk_state->prev_op = parent; walk_state->next_op = grand_parent; walk_state->next_op_info = NEXT_OP_UPWARD; @@ -347,13 +360,13 @@ ACPI_STATUS acpi_ps_walk_loop ( ACPI_WALK_LIST *walk_list, - ACPI_GENERIC_OP *start_op, - INTERPRETER_CALLBACK descending_callback, - INTERPRETER_CALLBACK ascending_callback) + ACPI_PARSE_OBJECT *start_op, + ACPI_PARSE_DOWNWARDS descending_callback, + ACPI_PARSE_UPWARDS ascending_callback) { ACPI_STATUS status = AE_OK; ACPI_WALK_STATE *walk_state; - ACPI_GENERIC_OP *op = start_op; + ACPI_PARSE_OBJECT *op = start_op; walk_state = acpi_ds_get_current_walk_state (walk_list); @@ -363,7 +376,7 @@ while (op) { if (walk_state->next_op_info != NEXT_OP_UPWARD) { - status = descending_callback (walk_state, op); + status = descending_callback (op->opcode, op, walk_state, NULL); } /* @@ -437,19 +450,19 @@ ACPI_STATUS acpi_ps_walk_parsed_aml ( - ACPI_GENERIC_OP *start_op, - ACPI_GENERIC_OP *end_op, - ACPI_OBJECT_INTERNAL *mth_desc, - ACPI_NAME_TABLE *start_scope, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **caller_return_desc, + ACPI_PARSE_OBJECT *start_op, + ACPI_PARSE_OBJECT *end_op, + ACPI_OPERAND_OBJECT *mth_desc, + ACPI_NAMESPACE_NODE *start_node, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **caller_return_desc, ACPI_OWNER_ID owner_id, - INTERPRETER_CALLBACK descending_callback, - INTERPRETER_CALLBACK ascending_callback) + ACPI_PARSE_DOWNWARDS descending_callback, + ACPI_PARSE_UPWARDS ascending_callback) { - ACPI_GENERIC_OP *op; + ACPI_PARSE_OBJECT *op; ACPI_WALK_STATE *walk_state; - ACPI_OBJECT_INTERNAL *return_desc; + ACPI_OPERAND_OBJECT *return_desc; ACPI_STATUS status; ACPI_WALK_LIST walk_list; ACPI_WALK_LIST *prev_walk_list; @@ -458,7 +471,7 @@ /* Parameter Validation */ if (!start_op || !end_op) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } /* Initialize a new walk list */ @@ -475,10 +488,10 @@ prev_walk_list = acpi_gbl_current_walk_list; acpi_gbl_current_walk_list = &walk_list; - if (start_scope) { + if (start_node) { /* Push start scope on scope stack and make it current */ - status = acpi_ds_scope_stack_push (start_scope, ACPI_TYPE_METHOD, walk_state); + status = acpi_ds_scope_stack_push (start_node, ACPI_TYPE_METHOD, walk_state); if (ACPI_FAILURE (status)) { return (status); } @@ -489,7 +502,7 @@ /* Init arguments if this is a control method */ /* TBD: [Restructure] add walkstate as a param */ - acpi_ds_method_data_init_args (params, MTH_NUM_ARGS); + acpi_ds_method_data_init_args (params, MTH_NUM_ARGS, walk_state); } op = start_op; @@ -502,7 +515,7 @@ */ while (walk_state) { - if (status == AE_OK) { + if (ACPI_SUCCESS (status)) { status = acpi_ps_walk_loop (&walk_list, op, descending_callback, ascending_callback); } @@ -526,9 +539,7 @@ * there's lots of cleanup to do */ - if (walk_state->method_desc && - walk_state->method_desc->method.parser_op) - { + if (walk_state->method_desc) { acpi_ds_terminate_control_method (walk_state); } @@ -540,7 +551,7 @@ walk_state = acpi_ds_get_current_walk_state (&walk_list); if (walk_state && - status == AE_OK) + ACPI_SUCCESS (status)) { /* There is another walk state, restart it */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/parser/psxface.c linux/drivers/acpi/parser/psxface.c --- v2.4.0-test8/linux/drivers/acpi/parser/psxface.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/parser/psxface.c Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: psxface - Parser external interfaces + * $Revision: 36 $ * *****************************************************************************/ @@ -25,18 +25,15 @@ #include "acpi.h" -#include "parser.h" -#include "dispatch.h" -#include "interp.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" #include "amlcode.h" -#include "namesp.h" +#include "acnamesp.h" #define _COMPONENT PARSER - MODULE_NAME ("psxface"); - - -char *acpi_gbl_parser_id = "Non-recursive AML Parser"; + MODULE_NAME ("psxface") /***************************************************************************** @@ -57,29 +54,30 @@ ACPI_STATUS acpi_psx_execute ( - ACPI_NAMED_OBJECT *method_entry, - ACPI_OBJECT_INTERNAL **params, - ACPI_OBJECT_INTERNAL **return_obj_desc) + ACPI_NAMESPACE_NODE *method_node, + ACPI_OPERAND_OBJECT **params, + ACPI_OPERAND_OBJECT **return_obj_desc) { ACPI_STATUS status; - ACPI_OBJECT_INTERNAL *obj_desc; + ACPI_OPERAND_OBJECT *obj_desc; u32 i; + ACPI_PARSE_OBJECT *op; - /* Validate the NTE and get the attached object */ + /* Validate the Node and get the attached object */ - if (!method_entry) { + if (!method_node) { return (AE_NULL_ENTRY); } - obj_desc = acpi_ns_get_attached_object (method_entry); + obj_desc = acpi_ns_get_attached_object (method_node); if (!obj_desc) { return (AE_NULL_OBJECT); } - /* Parse method if necessary, wait on concurrency semaphore */ + /* Init for new method, wait on concurrency semaphore */ - status = acpi_ds_begin_method_execution (method_entry, obj_desc); + status = acpi_ds_begin_method_execution (method_node, obj_desc); if (ACPI_FAILURE (status)) { return (status); } @@ -96,15 +94,40 @@ } /* - * Method is parsed and ready to execute - * The walk of the parse tree is where we actually execute the method + * Perform the first pass parse of the method to enter any + * named objects that it creates into the namespace */ - status = acpi_ps_walk_parsed_aml (obj_desc->method.parser_op, - obj_desc->method.parser_op, obj_desc, - method_entry->child_table, params, return_obj_desc, - obj_desc->method.owning_id, acpi_ds_exec_begin_op, - acpi_ds_exec_end_op); + /* Create and init a Root Node */ + + op = acpi_ps_alloc_op (AML_SCOPE_OP); + if (!op) { + return (AE_NO_MEMORY); + } + + status = acpi_ps_parse_aml (op, obj_desc->method.pcode, + obj_desc->method.pcode_length, + ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, + method_node, params, return_obj_desc, + acpi_ds_load1_begin_op, acpi_ds_load1_end_op); + acpi_ps_delete_parse_tree (op); + + /* Create and init a Root Node */ + + op = acpi_ps_alloc_op (AML_SCOPE_OP); + if (!op) { + return (AE_NO_MEMORY); + } + + /* + * The walk of the parse tree is where we actually execute the method + */ + status = acpi_ps_parse_aml (op, obj_desc->method.pcode, + obj_desc->method.pcode_length, + ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE, + method_node, params, return_obj_desc, + acpi_ds_exec_begin_op, acpi_ds_exec_end_op); + acpi_ps_delete_parse_tree (op); if (params) { /* Take away the extra reference that we gave the parameters above */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/resources/Makefile linux/drivers/acpi/resources/Makefile --- v2.4.0-test8/linux/drivers/acpi/resources/Makefile Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/resources/Makefile Fri Sep 15 18:21:44 2000 @@ -0,0 +1,28 @@ +# +# Makefile for all Linux ACPI interpreter subdirectories +# + +SUB_DIRS := +MOD_SUB_DIRS := $(SUB_DIRS) +MOD_IN_SUB_DIRS := +ALL_SUB_DIRS := $(SUB_DIRS) + +O_TARGET := ../$(shell basename `pwd`).o +O_OBJS := +M_OBJS := + +ACPI_OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) + +EXTRA_CFLAGS += -I../include + +EXTRA_CFLAGS += $(ACPI_CFLAGS) + +# if the interpreter is used, it overrides arch/i386/kernel/acpi.c +ifeq ($(CONFIG_ACPI_INTERPRETER),y) + O_OBJS := $(ACPI_OBJS) +endif + +include $(TOPDIR)/Rules.make + +clean: + $(RM) *.o diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/resources/rsaddr.c linux/drivers/acpi/resources/rsaddr.c --- v2.4.0-test8/linux/drivers/acpi/resources/rsaddr.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/resources/rsaddr.c Fri Sep 15 14:30:30 2000 @@ -4,6 +4,7 @@ * Acpi_rs_address16_stream * Acpi_rs_address32_resource * Acpi_rs_address32_stream + * $Revision: 9 $ * *****************************************************************************/ @@ -29,7 +30,7 @@ #include "acpi.h" #define _COMPONENT RESOURCE_MANAGER - MODULE_NAME ("rsaddr"); + MODULE_NAME ("rsaddr") /*************************************************************************** @@ -63,8 +64,8 @@ { u8 *buffer = byte_stream_buffer; RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; + u16 temp16; + u8 temp8; u32 index; u32 struct_size = sizeof(ADDRESS16_RESOURCE) + RESOURCE_LENGTH_NO_DATA; @@ -75,7 +76,7 @@ */ buffer += 1; - temp16 = *(u16 *)buffer; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); *bytes_consumed = temp16 + 3; @@ -91,7 +92,7 @@ /* Values 0-2 are valid */ if (temp8 > 2) { - return (AE_ERROR); + return (AE_AML_ERROR); } output_struct->data.address16.resource_type = temp8 & 0x03; @@ -235,6 +236,7 @@ */ temp8 = (u8) (index + 1); struct_size += ROUND_UP_TO_32_bITS (temp8); + output_struct->length = struct_size; } else { output_struct->data.address16.resource_source_index = 0x00; @@ -243,11 +245,6 @@ } /* - * Set the Length parameter - */ - output_struct->length = struct_size; - - /* * Return the final size of the structure */ *structure_size = struct_size; @@ -281,8 +278,8 @@ { u8 *buffer = *output_buffer; u8 *length_field; - u8 temp8 = 0; - u8 *temp_pointer = NULL; + u8 temp8; + NATIVE_CHAR *temp_pointer = NULL; u32 actual_bytes; @@ -389,7 +386,7 @@ *buffer = temp8; buffer += 1; - temp_pointer = buffer; + temp_pointer = (NATIVE_CHAR *) buffer; /* * Copy the string @@ -450,15 +447,21 @@ u8 **output_buffer, u32 *structure_size) { - u8 *buffer = byte_stream_buffer; - RESOURCE *output_struct = (RESOURCE *) * output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u32 struct_size = sizeof (ADDRESS32_RESOURCE) + - RESOURCE_LENGTH_NO_DATA; + u8 *buffer; + RESOURCE *output_struct; + u16 temp16; + u8 temp8; + u32 struct_size; u32 index; + buffer = byte_stream_buffer; + + output_struct = (RESOURCE *) *output_buffer; + + struct_size = sizeof (ADDRESS32_RESOURCE) + + RESOURCE_LENGTH_NO_DATA; + /* * Point past the Descriptor to get the number of bytes consumed */ @@ -477,7 +480,7 @@ /* Values 0-2 are valid */ if(temp8 > 2) { - return (AE_ERROR); + return (AE_AML_ERROR); } output_struct->data.address32.resource_type = temp8 & 0x03; @@ -661,11 +664,13 @@ u8 **output_buffer, u32 *bytes_consumed) { - u8 *buffer = *output_buffer; + u8 *buffer; u16 *length_field; - u8 temp8 = 0; - u8 *temp_pointer = NULL; + u8 temp8; + NATIVE_CHAR *temp_pointer; + + buffer = *output_buffer; /* * The descriptor field is static @@ -779,7 +784,7 @@ buffer += 1; - temp_pointer = buffer; + temp_pointer = (NATIVE_CHAR *) buffer; /* * Copy the string diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/resources/rscalc.c linux/drivers/acpi/resources/rscalc.c --- v2.4.0-test8/linux/drivers/acpi/resources/rscalc.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/resources/rscalc.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ * * Module Name: rscalc - Acpi_rs_calculate_byte_stream_length * Acpi_rs_calculate_list_length + * $Revision: 9 $ * *****************************************************************************/ @@ -27,7 +28,7 @@ #include "acpi.h" #define _COMPONENT RESOURCE_MANAGER - MODULE_NAME ("rscalc"); + MODULE_NAME ("rscalc") /*************************************************************************** @@ -51,9 +52,8 @@ RESOURCE *linked_list, u32 *size_needed) { - ACPI_STATUS status = AE_OK; u32 byte_stream_size_needed = 0; - u32 size_of_this_bit; + u32 segment_size; EXTENDED_IRQ_RESOURCE *ex_irq = NULL; u8 done = FALSE; @@ -64,7 +64,7 @@ * Init the variable that will hold the size to add to the * total. */ - size_of_this_bit = 0; + segment_size = 0; switch (linked_list->id) { @@ -76,7 +76,7 @@ * For an IRQ Resource, Byte 3, although optional, will * always be created - it holds IRQ information. */ - size_of_this_bit = 4; + segment_size = 4; break; case dma: @@ -86,7 +86,7 @@ /* * For this resource the size is static */ - size_of_this_bit = 3; + segment_size = 3; break; case start_dependent_functions: @@ -97,7 +97,7 @@ * For a Start_dependent_functions Resource, Byte 1, * although optional, will always be created. */ - size_of_this_bit = 2; + segment_size = 2; break; case end_dependent_functions: @@ -107,7 +107,7 @@ /* * For this resource the size is static */ - size_of_this_bit = 1; + segment_size = 1; break; case io: @@ -117,7 +117,7 @@ /* * For this resource the size is static */ - size_of_this_bit = 8; + segment_size = 8; break; case fixed_io: @@ -127,7 +127,7 @@ /* * For this resource the size is static */ - size_of_this_bit = 4; + segment_size = 4; break; case vendor_specific: @@ -141,12 +141,12 @@ * Resource data type. */ if(linked_list->data.vendor_specific.length > 7) { - size_of_this_bit = 3; + segment_size = 3; } else { - size_of_this_bit = 1; + segment_size = 1; } - size_of_this_bit += + segment_size += linked_list->data.vendor_specific.length; break; @@ -157,7 +157,7 @@ /* * For this resource the size is static */ - size_of_this_bit = 2; + segment_size = 2; done = TRUE; break; @@ -168,7 +168,7 @@ /* * For this resource the size is static */ - size_of_this_bit = 12; + segment_size = 12; break; case memory32: @@ -178,7 +178,7 @@ /* * For this resource the size is static */ - size_of_this_bit = 20; + segment_size = 20; break; case fixed_memory32: @@ -188,7 +188,7 @@ /* * For this resource the size is static */ - size_of_this_bit = 12; + segment_size = 12; break; case address16: @@ -201,10 +201,10 @@ * the Index + the length of the null terminated * string Resource Source + 1 for the null. */ - size_of_this_bit = 16; + segment_size = 16; if(NULL != linked_list->data.address16.resource_source) { - size_of_this_bit += (1 + + segment_size += (1 + linked_list->data.address16.resource_source_string_length); } break; @@ -219,10 +219,10 @@ * length of the null terminated string Resource Source + * 1 for the null. */ - size_of_this_bit = 26; + segment_size = 26; if(NULL != linked_list->data.address16.resource_source) { - size_of_this_bit += (1 + + segment_size += (1 + linked_list->data.address16.resource_source_string_length); } break; @@ -239,14 +239,14 @@ * Index + the length of the null terminated string * Resource Source + 1 for the null. */ - size_of_this_bit = 9; + segment_size = 9; - size_of_this_bit += + segment_size += (linked_list->data.extended_irq.number_of_interrupts - 1) * 4; if(NULL != ex_irq->resource_source) { - size_of_this_bit += (1 + + segment_size += (1 + linked_list->data.extended_irq.resource_source_string_length); } break; @@ -256,7 +256,7 @@ * If we get here, everything is out of sync, * so exit with an error */ - return (AE_ERROR); + return (AE_AML_ERROR); break; } /* switch (Linked_list->Id) */ @@ -264,7 +264,7 @@ /* * Update the total */ - byte_stream_size_needed += size_of_this_bit; + byte_stream_size_needed += segment_size; /* * Point to the next object @@ -278,7 +278,7 @@ */ *size_needed = byte_stream_size_needed; - return (status); + return (AE_OK); } /* Acpi_rs_calculate_byte_stream_length */ @@ -309,16 +309,16 @@ { u32 buffer_size = 0; u32 bytes_parsed = 0; - u8 resource_type = 0; - u32 structure_size = 0; - u32 bytes_consumed = 0; - u8 *buffer; u8 number_of_interrupts = 0; + u8 number_of_channels = 0; + u8 resource_type; + u32 structure_size; + u32 bytes_consumed; + u8 *buffer; u8 temp8; u16 temp16; u8 index; - u8 number_of_channels = 0; - u8 additional_bytes = 0; + u8 additional_bytes; while (bytes_parsed < byte_stream_buffer_length) { @@ -532,7 +532,7 @@ * If we get here, everything is out of sync, * so exit with an error */ - return (AE_ERROR); + return (AE_AML_ERROR); break; } } @@ -723,7 +723,7 @@ * If we get here, everything is out of sync, * so exit with an error */ - return (AE_ERROR); + return (AE_AML_ERROR); break; } /* switch */ @@ -752,3 +752,116 @@ } /* Acpi_rs_calculate_list_length */ +/*************************************************************************** + * FUNCTION: Acpi_rs_calculate_pci_routing_table_length + * + * PARAMETERS: + * Package_object - Pointer to the package object + * Buffer_size_needed - u32 pointer of the size buffer + * needed to properly return the + * parsed data + * + * RETURN: Status AE_OK + * + * DESCRIPTION: Given a package representing a PCI routing table, this + * calculates the size of the corresponding linked list of + * descriptions. + * + ***************************************************************************/ + +ACPI_STATUS +acpi_rs_calculate_pci_routing_table_length ( + ACPI_OPERAND_OBJECT *package_object, + u32 *buffer_size_needed) +{ + u32 number_of_elements; + u32 temp_size_needed; + ACPI_OPERAND_OBJECT **top_object_list; + u32 index; + + number_of_elements = package_object->package.count; + + /* + * Calculate the size of the return buffer. + * The base size is the number of elements * the sizes of the + * structures. Additional space for the strings is added below. + * The minus one is to subtract the size of the u8 Source[1] + * member because it is added below. + * + * NOTE: The Number_of_elements is incremented by one to add an end + * table structure that is essentially a structure of zeros. + */ + temp_size_needed = (number_of_elements + 1) * + (sizeof (PCI_ROUTING_TABLE) - 1); + + /* + * But each PRT_ENTRY structure has a pointer to a string and + * the size of that string must be found. + */ + top_object_list = package_object->package.elements; + + for (index = 0; index < number_of_elements; index++) { + ACPI_OPERAND_OBJECT *package_element; + ACPI_OPERAND_OBJECT **sub_object_list; + u8 name_found; + u32 table_index; + + /* + * Dereference the sub-package + */ + package_element = *top_object_list; + + /* + * The Sub_object_list will now point to an array of the + * four IRQ elements: Address, Pin, Source and Source_index + */ + sub_object_list = package_element->package.elements; + + /* + * Scan the Irq_table_elements for the Source Name String + */ + name_found = FALSE; + + for (table_index = 0; table_index < 4 && !name_found; table_index++) { + if (ACPI_TYPE_STRING == (*sub_object_list)->common.type) { + name_found = TRUE; + } + + else { + /* + * Look at the next element + */ + sub_object_list++; + } + } + + /* + * Was a String type found? + */ + if (TRUE == name_found) { + /* + * The length String.Length field includes the + * terminating NULL + */ + temp_size_needed += (*sub_object_list)->string.length; + temp_size_needed = ROUND_UP_TO_32_bITS (temp_size_needed); + } + + else { + /* + * If no name was found, then this is a NULL, which is + * translated as a u32 zero. + */ + temp_size_needed += sizeof(u32); + } + + /* + * Point to the next ACPI_OPERAND_OBJECT + */ + top_object_list++; + } + + *buffer_size_needed = temp_size_needed; + + return (AE_OK); +} \ No newline at end of file diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/resources/rscreate.c linux/drivers/acpi/resources/rscreate.c --- v2.4.0-test8/linux/drivers/acpi/resources/rscreate.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/resources/rscreate.c Fri Sep 15 14:30:30 2000 @@ -3,6 +3,7 @@ * Module Name: rscreate - Acpi_rs_create_resource_list * Acpi_rs_create_pci_routing_table * Acpi_rs_create_byte_stream + * $Revision: 16 $ * *****************************************************************************/ @@ -26,13 +27,14 @@ #include "acpi.h" -#include "resource.h" +#include "acresrc.h" #define _COMPONENT RESOURCE_MANAGER - MODULE_NAME ("rscreate"); + MODULE_NAME ("rscreate") -/*************************************************************************** +/******************************************************************************* + * * FUNCTION: Acpi_rs_create_resource_list * * PARAMETERS: @@ -40,53 +42,40 @@ * Output_buffer - Pointer to the user's buffer * Output_buffer_length - Pointer to the size of Output_buffer * - * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code - * If Output_buffer is not large enough, Output_buffer_length - * indicates how large Output_buffer should be, else it - * indicates how may u8 elements of Output_buffer are - * valid. + * RETURN: Status - AE_OK if okay, else a valid ACPI_STATUS code + * If Output_buffer is not large enough, Output_buffer_length + * indicates how large Output_buffer should be, else it + * indicates how may u8 elements of Output_buffer are valid. * * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method - * execution and parses the stream to create a linked list - * of device resources. + * execution and parses the stream to create a linked list + * of device resources. * - ***************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_rs_create_resource_list ( - ACPI_OBJECT_INTERNAL *byte_stream_buffer, + ACPI_OPERAND_OBJECT *byte_stream_buffer, u8 *output_buffer, u32 *output_buffer_length) { - ACPI_STATUS status = AE_UNKNOWN_STATUS; + ACPI_STATUS status; u8 *byte_stream_start = NULL; u32 list_size_needed = 0; u32 byte_stream_buffer_length = 0; /* - * Validate parameters: - * - * 1. If Byte_stream_buffer is NULL after we know that - * Byte_steam_length is not zero, or - * 2. If Output_buffer is NULL and Output_buffer_length - * is not zero - * - * Return an error + * Params already validated, so we don't re-validate here */ - if (!byte_stream_buffer || - (!output_buffer && 0 != *output_buffer_length)) - { - return (AE_BAD_PARAMETER); - } byte_stream_buffer_length = byte_stream_buffer->buffer.length; byte_stream_start = byte_stream_buffer->buffer.pointer; /* * Pass the Byte_stream_buffer into a module that can calculate - * the buffer size needed for the linked list + * the buffer size needed for the linked list */ status = acpi_rs_calculate_list_length (byte_stream_start, byte_stream_buffer_length, @@ -95,13 +84,13 @@ /* * Exit with the error passed back */ - if (AE_OK != status) { + if (ACPI_FAILURE (status)) { return (status); } /* * If the linked list will fit into the available buffer - * call to fill in the list + * call to fill in the list */ if (list_size_needed <= *output_buffer_length) { @@ -117,7 +106,7 @@ /* * Exit with the error passed back */ - if (AE_OK != status) { + if (ACPI_FAILURE (status)) { return (status); } @@ -134,138 +123,53 @@ } -/*************************************************************************** +/******************************************************************************* + * * FUNCTION: Acpi_rs_create_pci_routing_table * * PARAMETERS: - * Package_object - Pointer to an ACPI_OBJECT_INTERNAL + * Package_object - Pointer to an ACPI_OPERAND_OBJECT * package * Output_buffer - Pointer to the user's buffer * Output_buffer_length - Size of Output_buffer * * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. * If the Output_buffer is too small, the error will be - * AE_BUFFER_OVERFLOW and Output_buffer_length will point - * to the size buffer needed. + * AE_BUFFER_OVERFLOW and Output_buffer_length will point + * to the size buffer needed. * - * DESCRIPTION: Takes the ACPI_OBJECT_INTERNAL package and creates a - * linked list of PCI interrupt descriptions + * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a + * linked list of PCI interrupt descriptions * - ***************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_rs_create_pci_routing_table ( - ACPI_OBJECT_INTERNAL *package_object, + ACPI_OPERAND_OBJECT *package_object, u8 *output_buffer, u32 *output_buffer_length) { u8 *buffer = output_buffer; - ACPI_OBJECT_INTERNAL **top_object_list = NULL; - ACPI_OBJECT_INTERNAL **sub_object_list = NULL; - ACPI_OBJECT_INTERNAL *package_element = NULL; + ACPI_OPERAND_OBJECT **top_object_list = NULL; + ACPI_OPERAND_OBJECT **sub_object_list = NULL; + ACPI_OPERAND_OBJECT *package_element = NULL; u32 buffer_size_needed = 0; u32 number_of_elements = 0; u32 index = 0; - u8 table_index = 0; - u8 name_found = FALSE; PCI_ROUTING_TABLE *user_prt = NULL; + ACPI_STATUS status; /* - * Validate parameters: - * - * 1. If Method_return_object is NULL, or - * 2. If Output_buffer is NULL and Output_buffer_length is not zero - * - * Return an error + * Params already validated, so we don't re-validate here */ - if (!package_object || - (!output_buffer && 0 != *output_buffer_length)) - { - return (AE_BAD_PARAMETER); - } - /* - * Calculate the buffer size needed for the routing table. - */ - number_of_elements = package_object->package.count; - - /* - * Properly calculate the size of the return buffer. - * The base size is the number of elements * the sizes of the - * structures. Additional space for the strings is added below. - * The minus one is to subtract the size of the u8 Source[1] - * member because it is added below. - * NOTE: The Number_of_elements is incremented by one to add an end - * table structure that is essentially a structure of zeros. - */ - buffer_size_needed = (number_of_elements + 1) * - (sizeof (PCI_ROUTING_TABLE) - 1); - - /* - * But each PRT_ENTRY structure has a pointer to a string and - * the size of that string must be found. - */ - top_object_list = package_object->package.elements; - - for (index = 0; index < number_of_elements; index++) { - /* - * Dereference the sub-package - */ - package_element = *top_object_list; - - /* - * The Sub_object_list will now point to an array of the - * four IRQ elements: Address, Pin, Source and Source_index - */ - sub_object_list = package_element->package.elements; - - /* - * Scan the Irq_table_elements for the Source Name String - */ - name_found = FALSE; - - for (table_index = 0; table_index < 4 && !name_found; table_index++) { - if (ACPI_TYPE_STRING == (*sub_object_list)->common.type) { - name_found = TRUE; - } - - else { - /* - * Look at the next element - */ - sub_object_list++; - } - } - - /* - * Was a String type found? - */ - if (TRUE == name_found) { - /* - * The length String.Length field includes the - * terminating NULL - */ - buffer_size_needed += ((*sub_object_list)->string.length); - } - - else { - /* - * If no name was found, then this is a NULL, which is - * translated as a u32 zero. - */ - buffer_size_needed += sizeof(u32); - } - - /* - * Point to the next ACPI_OBJECT_INTERNAL - */ - top_object_list++; - } + status = acpi_rs_calculate_pci_routing_table_length(package_object, + &buffer_size_needed); /* * If the data will fit into the available buffer - * call to fill in the list + * call to fill in the list */ if (buffer_size_needed <= *output_buffer_length) { /* @@ -275,34 +179,32 @@ /* * Loop through the ACPI_INTERNAL_OBJECTS - Each object should - * contain a u32 Address, a u8 Pin, a Name and a u8 - * Source_index. + * contain a u32 Address, a u8 Pin, a Name and a u8 + * Source_index. */ top_object_list = package_object->package.elements; number_of_elements = package_object->package.count; - user_prt = (PCI_ROUTING_TABLE *)buffer; + user_prt = (PCI_ROUTING_TABLE *) buffer; for (index = 0; index < number_of_elements; index++) { /* * Point User_prt past this current structure * * NOTE: On the first iteration, User_prt->Length will - * be zero because we zero'ed out the return buffer - * earlier + * be zero because we cleared the return buffer earlier */ buffer += user_prt->length; - - user_prt = (PCI_ROUTING_TABLE *)buffer; + user_prt = (PCI_ROUTING_TABLE *) buffer; /* * Fill in the Length field with the information we - * have at this point. - * The minus one is to subtract the size of the - * u8 Source[1] member because it is added below. + * have at this point. + * The minus one is to subtract the size of the + * u8 Source[1] member because it is added below. */ - user_prt->length = (sizeof(PCI_ROUTING_TABLE) - 1); + user_prt->length = (sizeof (PCI_ROUTING_TABLE) - 1); /* * Dereference the sub-package @@ -311,8 +213,8 @@ /* * The Sub_object_list will now point to an array of - * the four IRQ elements: Address, Pin, Source and - * Source_index + * the four IRQ elements: Address, Pin, Source and + * Source_index */ sub_object_list = package_element->package.elements; @@ -348,27 +250,29 @@ sub_object_list++; if (ACPI_TYPE_STRING == (*sub_object_list)->common.type) { - STRCPY(user_prt->data.source, + STRCPY (user_prt->data.source, (*sub_object_list)->string.pointer); /* * Add to the Length field the length of the string */ user_prt->length += (*sub_object_list)->string.length; + user_prt->length = + ROUND_UP_TO_32_bITS (user_prt->length); } else { /* * If this is a number, then the Source Name - * is NULL, since the entire buffer was zeroed - * out, we can leave this alone. + * is NULL, since the entire buffer was zeroed + * out, we can leave this alone. */ if (ACPI_TYPE_NUMBER == (*sub_object_list)->common.type) { /* * Add to the Length field the length of - * the u32 NULL + * the u32 NULL */ - user_prt->length += sizeof(u32); + user_prt->length += sizeof (u32); } else { @@ -391,7 +295,7 @@ } /* - * Point to the next ACPI_OBJECT_INTERNAL + * Point to the next ACPI_OPERAND_OBJECT */ top_object_list++; } @@ -414,7 +318,8 @@ } -/*************************************************************************** +/******************************************************************************* + * * FUNCTION: Acpi_rs_create_byte_stream * * PARAMETERS: @@ -431,7 +336,7 @@ * creates a bytestream to be used as input for the * _SRS control method. * - ***************************************************************************/ + ******************************************************************************/ ACPI_STATUS acpi_rs_create_byte_stream ( @@ -439,27 +344,15 @@ u8 *output_buffer, u32 *output_buffer_length) { - ACPI_STATUS status = AE_UNKNOWN_STATUS; + ACPI_STATUS status; u32 byte_stream_size_needed = 0; /* - * Validate parameters: + * Params already validated, so we don't re-validate here * - * 1. If Linked_list_buffer is NULL, or - * 2. If Output_buffer is NULL and Output_buffer_length is not zero - * - * Return an error - */ - if (!linked_list_buffer || - (!output_buffer && 0 != *output_buffer_length)) - { - return (AE_BAD_PARAMETER); - } - - /* * Pass the Linked_list_buffer into a module that can calculate - * the buffer size needed for the byte stream. + * the buffer size needed for the byte stream. */ status = acpi_rs_calculate_byte_stream_length (linked_list_buffer, &byte_stream_size_needed); @@ -467,13 +360,13 @@ /* * Exit with the error passed back */ - if (AE_OK != status) { + if (ACPI_FAILURE (status)) { return (status); } /* * If the linked list will fit into the available buffer - * call to fill in the list + * call to fill in the list */ if (byte_stream_size_needed <= *output_buffer_length) { @@ -489,7 +382,7 @@ /* * Exit with the error passed back */ - if (AE_OK != status) { + if (ACPI_FAILURE (status)) { return (status); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/resources/rsdump.c linux/drivers/acpi/resources/rsdump.c --- v2.4.0-test8/linux/drivers/acpi/resources/rsdump.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/resources/rsdump.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: rsdump - Functions do dump out the resource structures. + * $Revision: 10 $ * *****************************************************************************/ @@ -26,7 +27,7 @@ #include "acpi.h" #define _COMPONENT RESOURCE_MANAGER - MODULE_NAME ("rsdump"); + MODULE_NAME ("rsdump") /****************************************************************************** @@ -120,7 +121,7 @@ break; } - acpi_os_printf ("\t\t%s_bus Master\n", + acpi_os_printf ("\t\t%sBus Master\n", BUS_MASTER == dma_data->bus_master ? "" : "Not a "); @@ -802,7 +803,7 @@ acpi_rs_dump_resource_list ( RESOURCE *resource) { - s8 count = 0; + u8 count = 0; u8 done = FALSE; @@ -902,7 +903,7 @@ u8 *route_table) { u8 *buffer = route_table; - s8 count = 0; + u8 count = 0; u8 done = FALSE; PCI_ROUTING_TABLE *prt_element; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/resources/rsio.c linux/drivers/acpi/resources/rsio.c --- v2.4.0-test8/linux/drivers/acpi/resources/rsio.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/resources/rsio.c Fri Sep 15 14:30:30 2000 @@ -6,6 +6,7 @@ * Acpi_rs_fixed_io_stream * Acpi_rs_dma_resource * Acpi_rs_dma_stream + * $Revision: 7 $ * *****************************************************************************/ @@ -31,7 +32,7 @@ #include "acpi.h" #define _COMPONENT RESOURCE_MANAGER - MODULE_NAME ("rsio"); + MODULE_NAME ("rsio") /*************************************************************************** @@ -90,7 +91,7 @@ * Check Min_base Address */ buffer += 1; - temp16 = *(u16 *)buffer; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); output_struct->data.io.min_base_address = temp16; @@ -98,7 +99,7 @@ * Check Max_base Address */ buffer += 2; - temp16 = *(u16 *)buffer; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); output_struct->data.io.max_base_address = temp16; @@ -255,7 +256,7 @@ */ temp16 = (u16) linked_list->data.io.min_base_address; - *(u16 *)buffer = temp16; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); buffer += 2; @@ -264,7 +265,7 @@ */ temp16 = (u16) linked_list->data.io.max_base_address; - *(u16 *)buffer = temp16; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); buffer += 2; @@ -336,7 +337,7 @@ */ temp16 = (u16) linked_list->data.fixed_io.base_address; - *(u16 *)buffer = temp16; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); buffer += 2; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/resources/rsirq.c linux/drivers/acpi/resources/rsirq.c --- v2.4.0-test8/linux/drivers/acpi/resources/rsirq.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/resources/rsirq.c Fri Sep 15 14:30:30 2000 @@ -4,6 +4,7 @@ * Acpi_rs_irq_stream * Acpi_rs_extended_irq_resource * Acpi_rs_extended_irq_stream + * $Revision: 8 $ * *****************************************************************************/ @@ -29,7 +30,7 @@ #include "acpi.h" #define _COMPONENT RESOURCE_MANAGER - MODULE_NAME ("rsirq"); + MODULE_NAME ("rsirq") /*************************************************************************** @@ -85,7 +86,7 @@ * Point to the 16-bits of Bytes 1 and 2 */ buffer += 1; - temp16 = *(u16 *)buffer; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); output_struct->data.irq.number_of_interrupts = 0; @@ -226,7 +227,7 @@ temp16 |= 0x1 << temp8; } - *(u16 *)buffer = temp16; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); buffer += 2; @@ -306,7 +307,7 @@ * Point past the Descriptor to get the number of bytes consumed */ buffer += 1; - temp16 = *(u16 *)buffer; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); *bytes_consumed = temp16 + 3; output_struct->id = extended_irq; @@ -476,7 +477,7 @@ u16 *length_field; u8 temp8 = 0; u8 index; - u8 *temp_pointer = NULL; + NATIVE_CHAR *temp_pointer = NULL; /* @@ -533,11 +534,10 @@ * Resource Source Index and Resource Source are optional */ if (0 != linked_list->data.extended_irq.resource_source_string_length) { - temp8 = (u8) linked_list->data.extended_irq.resource_source_index; - - *buffer = temp8; + *buffer = (u8) linked_list->data.extended_irq.resource_source_index; buffer += 1; - temp_pointer = buffer; + + temp_pointer = (NATIVE_CHAR *) buffer; /* * Copy the string diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/resources/rslist.c linux/drivers/acpi/resources/rslist.c --- v2.4.0-test8/linux/drivers/acpi/resources/rslist.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/resources/rslist.c Fri Sep 15 14:30:30 2000 @@ -2,6 +2,7 @@ * * Module Name: rslist - Acpi_rs_byte_stream_to_list * Acpi_list_to_byte_stream + * $Revision: 6 $ * *****************************************************************************/ @@ -25,10 +26,10 @@ #include "acpi.h" -#include "resource.h" +#include "acresrc.h" #define _COMPONENT RESOURCE_MANAGER - MODULE_NAME ("rslist"); + MODULE_NAME ("rslist") /*************************************************************************** @@ -53,7 +54,7 @@ u32 byte_stream_buffer_length, u8 **output_buffer) { - ACPI_STATUS status = AE_UNKNOWN_STATUS; + ACPI_STATUS status; u32 bytes_parsed = 0; u8 resource_type = 0; u32 bytes_consumed = 0; @@ -167,7 +168,7 @@ * If we get here, everything is out of sync, * so exit with an error */ - return (AE_ERROR); + return (AE_AML_ERROR); break; } } @@ -275,11 +276,11 @@ * If we get here, everything is out of sync, * so exit with an error */ - return (AE_ERROR); + return (AE_AML_ERROR); break; } /* switch */ - } /* if(Resource_type & 0x80) */ + } /* end else */ /* * Update the return value and counter @@ -296,14 +297,15 @@ */ *buffer += structure_size; - } /* while (Bytes_parsed < Byte_stream_buffer_length && - FALSE == End_tag_processed) */ + } /* end while */ /* * Check the reason for exiting the while loop */ - if (byte_stream_buffer_length != bytes_parsed || TRUE != end_tag_processed) { - return (AE_ERROR); + if (!(byte_stream_buffer_length == bytes_parsed) || + (TRUE != end_tag_processed)) + { + return (AE_AML_ERROR); } return (AE_OK); @@ -338,7 +340,7 @@ u32 byte_stream_size_needed, u8 **output_buffer) { - ACPI_STATUS status = AE_UNKNOWN_STATUS; + ACPI_STATUS status; u8 *buffer = *output_buffer; u32 bytes_consumed = 0; u8 done = FALSE; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/resources/rsmemory.c linux/drivers/acpi/resources/rsmemory.c --- v2.4.0-test8/linux/drivers/acpi/resources/rsmemory.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/resources/rsmemory.c Fri Sep 15 14:30:30 2000 @@ -6,6 +6,7 @@ * Acpi_rs_fixed_memory32_resource * Acpi_rs_memory32_range_stream * Acpi_rs_fixed_memory32_stream + * $Revision: 7 $ * *****************************************************************************/ @@ -31,7 +32,7 @@ #include "acpi.h" #define _COMPONENT RESOURCE_MANAGER - MODULE_NAME ("rsmemory"); + MODULE_NAME ("rsmemory") /*************************************************************************** @@ -76,7 +77,7 @@ */ buffer += 1; - temp16 = *(u16 *)buffer; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); buffer += 2; @@ -96,7 +97,7 @@ /* * Get Min_base_address (Bytes 4-5) */ - temp16 = *(u16 *)buffer; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); buffer += 2; @@ -105,7 +106,7 @@ /* * Get Max_base_address (Bytes 6-7) */ - temp16 = *(u16 *)buffer; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); buffer += 2; @@ -114,7 +115,7 @@ /* * Get Alignment (Bytes 8-9) */ - temp16 = *(u16 *)buffer; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); buffer += 2; @@ -123,7 +124,7 @@ /* * Get Range_length (Bytes 10-11) */ - temp16 = *(u16 *)buffer; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); output_struct->data.memory24.range_length = temp16; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/resources/rsmisc.c linux/drivers/acpi/resources/rsmisc.c --- v2.4.0-test8/linux/drivers/acpi/resources/rsmisc.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/resources/rsmisc.c Fri Sep 15 14:30:30 2000 @@ -8,6 +8,7 @@ * Acpi_rs_end_dependent_functions_resource * Acpi_rs_start_dependent_functions_stream * Acpi_rs_end_dependent_functions_stream + * $Revision: 7 $ * *****************************************************************************/ @@ -33,7 +34,7 @@ #include "acpi.h" #define _COMPONENT RESOURCE_MANAGER - MODULE_NAME ("rsmisc"); + MODULE_NAME ("rsmisc") /*************************************************************************** @@ -199,7 +200,7 @@ /* Dereference */ - temp16 = *(u16 *)buffer; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); /* Calculate bytes consumed */ @@ -304,7 +305,7 @@ temp16 = (u16) linked_list->data.vendor_specific.length; - *(u16 *)buffer = temp16; + MOVE_UNALIGNED16_TO_16 (&temp16, buffer); buffer += 2; } @@ -404,7 +405,7 @@ temp8 & 0x03; if (3 == output_struct->data.start_dependent_functions.compatibility_priority) { - return (AE_ERROR); + return (AE_AML_ERROR); } /* @@ -414,7 +415,7 @@ (temp8 >> 2) & 0x03; if (3 == output_struct->data.start_dependent_functions.performance_robustness) { - return (AE_ERROR); + return (AE_AML_ERROR); } } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/resources/rsutils.c linux/drivers/acpi/resources/rsutils.c --- v2.4.0-test8/linux/drivers/acpi/resources/rsutils.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/resources/rsutils.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: rsutils - Utilities for the resource manager + * $Revision: 10 $ * *****************************************************************************/ @@ -24,19 +25,19 @@ #include "acpi.h" -#include "namesp.h" -#include "resource.h" +#include "acnamesp.h" +#include "acresrc.h" #define _COMPONENT RESOURCE_MANAGER - MODULE_NAME ("rsutils"); + MODULE_NAME ("rsutils") /****************************************************************************** * * FUNCTION: Acpi_rs_get_prt_method_data * - * PARAMETERS: Device_handle - a handle to the containing object + * PARAMETERS: Handle - a handle to the containing object * Ret_buffer - a pointer to a buffer structure for the * results * @@ -55,28 +56,20 @@ ACPI_HANDLE handle, ACPI_BUFFER *ret_buffer) { - ACPI_OBJECT_INTERNAL *ret_obj; + ACPI_OPERAND_OBJECT *ret_obj; ACPI_STATUS status; - u32 buffer_space_needed = ret_buffer->length; + u32 buffer_space_needed; - /* - * Must have a valid handle and buffer, So we have to have a handle - * a return buffer structure and if there is a non-zero buffer length - * we also need a valid pointer in the buffer - */ - if ((!handle) || - (!ret_buffer) || - ((!ret_buffer->pointer) && (ret_buffer->length))) - { - return (AE_BAD_PARAMETER); - } + /* already validated params, so we won't repeat here */ + + buffer_space_needed = ret_buffer->length; /* * Execute the method, no parameters */ status = acpi_ns_evaluate_relative (handle, "_PRT", NULL, &ret_obj); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { return (status); } @@ -128,7 +121,7 @@ * * FUNCTION: Acpi_rs_get_crs_method_data * - * PARAMETERS: Device_handle - a handle to the containing object + * PARAMETERS: Handle - a handle to the containing object * Ret_buffer - a pointer to a buffer structure for the * results * @@ -147,28 +140,18 @@ ACPI_HANDLE handle, ACPI_BUFFER *ret_buffer) { - ACPI_OBJECT_INTERNAL *ret_obj; + ACPI_OPERAND_OBJECT *ret_obj; ACPI_STATUS status; u32 buffer_space_needed = ret_buffer->length; - /* - * Must have a valid handle and buffer, So we have to have a handle - * a return buffer structure and if there is a non-zero buffer length - * we also need a valid pointer in the buffer - */ - if ((!handle) || - (!ret_buffer) || - ((!ret_buffer->pointer) && (ret_buffer->length))) - { - return (AE_BAD_PARAMETER); - } + /* already validated params, so we won't repeat here */ /* * Execute the method, no parameters */ status = acpi_ns_evaluate_relative (handle, "_CRS", NULL, &ret_obj); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { return (status); } @@ -198,9 +181,7 @@ ret_buffer->pointer, &buffer_space_needed); - if (AE_OK == status) { - acpi_rs_dump_resource_list((RESOURCE *)ret_buffer->pointer); - } + /* * Tell the user how much of the buffer we have used or is needed @@ -223,7 +204,7 @@ * * FUNCTION: Acpi_rs_get_prs_method_data * - * PARAMETERS: Device_handle - a handle to the containing object + * PARAMETERS: Handle - a handle to the containing object * Ret_buffer - a pointer to a buffer structure for the * results * @@ -242,28 +223,18 @@ ACPI_HANDLE handle, ACPI_BUFFER *ret_buffer) { - ACPI_OBJECT_INTERNAL *ret_obj; + ACPI_OPERAND_OBJECT *ret_obj; ACPI_STATUS status; u32 buffer_space_needed = ret_buffer->length; - /* - * Must have a valid handle and buffer, So we have to have a handle - * a return buffer structure and if there is a non-zero buffer length - * we also need a valid pointer in the buffer - */ - if ((!handle) || - (!ret_buffer) || - ((!ret_buffer->pointer) && (ret_buffer->length))) - { - return (AE_BAD_PARAMETER); - } + /* already validated params, so we won't repeat here */ /* * Execute the method, no parameters */ status = acpi_ns_evaluate_relative (handle, "_PRS", NULL, &ret_obj); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { return (status); } @@ -314,9 +285,7 @@ * * FUNCTION: Acpi_rs_set_srs_method_data * - * PARAMETERS: Device_handle - a handle to the containing object - * *Method_name - Name of method to execute, If NULL, the - * handle is the object to execute + * PARAMETERS: Handle - a handle to the containing object * In_buffer - a pointer to a buffer structure of the * parameter * @@ -335,22 +304,13 @@ ACPI_HANDLE handle, ACPI_BUFFER *in_buffer) { - ACPI_OBJECT_INTERNAL *params[2]; - ACPI_OBJECT_INTERNAL param_obj; + ACPI_OPERAND_OBJECT *params[2]; + ACPI_OPERAND_OBJECT param_obj; ACPI_STATUS status; u8 *byte_stream = NULL; u32 buffer_size_needed = 0; - /* - * Must have a valid handle and buffer - */ - if ((!handle) || - (!in_buffer) || - (!in_buffer->pointer) || - (!in_buffer->length)) - { - return (AE_BAD_PARAMETER); - } + /* already validated params, so we won't repeat here */ /* * The In_buffer parameter will point to a linked list of @@ -390,12 +350,8 @@ byte_stream, &buffer_size_needed); - if(AE_OK != status) { - /* - * Failed the call - */ - acpi_cm_free (byte_stream); - return (status); + if (ACPI_FAILURE (status)) { + goto cleanup; } /* @@ -424,6 +380,9 @@ /* * Clean up and return the status from Acpi_ns_evaluate_relative */ + +cleanup: + acpi_cm_free (byte_stream); return (status); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/resources/rsxface.c linux/drivers/acpi/resources/rsxface.c --- v2.4.0-test8/linux/drivers/acpi/resources/rsxface.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/resources/rsxface.c Fri Sep 15 14:30:30 2000 @@ -1,6 +1,7 @@ /****************************************************************************** * * Module Name: rsxface - Public interfaces to the ACPI subsystem + * $Revision: 7 $ * *****************************************************************************/ @@ -24,12 +25,12 @@ #include "acpi.h" -#include "interp.h" -#include "namesp.h" -#include "resource.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acresrc.h" #define _COMPONENT RESOURCE_MANAGER - MODULE_NAME ("rsxface"); + MODULE_NAME ("rsxface") /****************************************************************************** @@ -37,19 +38,18 @@ * FUNCTION: Acpi_get_irq_routing_table * * PARAMETERS: Device_handle - a handle to the Bus device we are querying - * Out_buffer - a pointer to a buffer to receive the + * Ret_buffer - a pointer to a buffer to receive the * current resources for the device - * Buffer_length - the number of bytes available in the buffer * * RETURN: Status - the status of the call * * DESCRIPTION: This function is called to get the IRQ routing table for a * specific bus. The caller must first acquire a handle for the * desired bus. The routine table is placed in the buffer pointed - * to by the Out_buffer variable parameter. + * to by the Ret_buffer variable parameter. * * If the function fails an appropriate status will be returned - * and the value of Out_buffer is undefined. + * and the value of Ret_buffer is undefined. * * This function attempts to execute the _PRT method contained in * the object indicated by the passed Device_handle. @@ -64,6 +64,19 @@ ACPI_STATUS status; + /* + * Must have a valid handle and buffer, So we have to have a handle + * and a return buffer structure, and if there is a non-zero buffer length + * we also need a valid pointer in the buffer. If it's a zero buffer length, + * we'll be returning the needed buffer size, so keep going. + */ + if ((!device_handle) || + (!ret_buffer) || + ((!ret_buffer->pointer) && (ret_buffer->length))) + { + return (AE_BAD_PARAMETER); + } + status = acpi_rs_get_prt_method_data (device_handle, ret_buffer); return (status); @@ -76,19 +89,18 @@ * * PARAMETERS: Device_handle - a handle to the device object for the * device we are querying - * Out_buffer - a pointer to a buffer to receive the + * Ret_buffer - a pointer to a buffer to receive the * current resources for the device - * Buffer_length - the number of bytes available in the buffer * * RETURN: Status - the status of the call * * DESCRIPTION: This function is called to get the current resources for a * specific device. The caller must first acquire a handle for * the desired device. The resource data is placed in the buffer - * pointed to by the Out_buffer variable parameter. + * pointed to by the Ret_buffer variable parameter. * * If the function fails an appropriate status will be returned - * and the value of Out_buffer is undefined. + * and the value of Ret_buffer is undefined. * * This function attempts to execute the _CRS method contained in * the object indicated by the passed Device_handle. @@ -103,6 +115,19 @@ ACPI_STATUS status; + /* + * Must have a valid handle and buffer, So we have to have a handle + * and a return buffer structure, and if there is a non-zero buffer length + * we also need a valid pointer in the buffer. If it's a zero buffer length, + * we'll be returning the needed buffer size, so keep going. + */ + if ((!device_handle) || + (!ret_buffer) || + ((ret_buffer->length) && (!ret_buffer->pointer))) + { + return (AE_BAD_PARAMETER); + } + status = acpi_rs_get_crs_method_data (device_handle, ret_buffer); return (status); @@ -115,19 +140,18 @@ * * PARAMETERS: Device_handle - a handle to the device object for the * device we are querying - * Out_buffer - a pointer to a buffer to receive the + * Ret_buffer - a pointer to a buffer to receive the * resources for the device - * Buffer_length - the number of bytes available in the buffer - * + * * RETURN: Status - the status of the call * * DESCRIPTION: This function is called to get a list of the possible resources * for a specific device. The caller must first acquire a handle * for the desired device. The resource data is placed in the - * buffer pointed to by the Out_buffer variable. + * buffer pointed to by the Ret_buffer variable. * * If the function fails an appropriate status will be returned - * and the value of Out_buffer is undefined. + * and the value of Ret_buffer is undefined. * ******************************************************************************/ @@ -139,6 +163,19 @@ ACPI_STATUS status; + /* + * Must have a valid handle and buffer, So we have to have a handle + * and a return buffer structure, and if there is a non-zero buffer length + * we also need a valid pointer in the buffer. If it's a zero buffer length, + * we'll be returning the needed buffer size, so keep going. + */ + if ((!device_handle) || + (!ret_buffer) || + ((ret_buffer->length) && (!ret_buffer->pointer))) + { + return (AE_BAD_PARAMETER); + } + status = acpi_rs_get_prs_method_data (device_handle, ret_buffer); return (status); @@ -151,7 +188,7 @@ * * PARAMETERS: Device_handle - a handle to the device object for the * device we are changing the resources of - * Out_buffer - a pointer to a buffer containing the + * In_buffer - a pointer to a buffer containing the * resources to be set for the device * * RETURN: Status - the status of the call @@ -170,6 +207,17 @@ { ACPI_STATUS status; + + /* + * Must have a valid handle and buffer + */ + if ((!device_handle) || + (!in_buffer) || + (!in_buffer->pointer) || + (!in_buffer->length)) + { + return (AE_BAD_PARAMETER); + } status = acpi_rs_set_srs_method_data (device_handle, in_buffer); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/sys.c linux/drivers/acpi/sys.c --- v2.4.0-test8/linux/drivers/acpi/sys.c Fri Jul 14 12:12:08 2000 +++ linux/drivers/acpi/sys.c Fri Sep 15 14:30:30 2000 @@ -24,6 +24,9 @@ #include "acpi.h" #include "driver.h" +#define _COMPONENT OS_DEPENDENT + MODULE_NAME ("sys") + #define ACPI_SLP_TYP(typa, typb) (((int)(typa) << 8) | (int)(typb)) #define ACPI_SLP_TYPA(value) \ ((((value) >> 8) << ACPI_SLP_TYP_SHIFT) & ACPI_SLP_TYP_MASK) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/table.c linux/drivers/acpi/table.c --- v2.4.0-test8/linux/drivers/acpi/table.c Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/table.c Fri Sep 15 14:30:30 2000 @@ -0,0 +1,306 @@ +/* + * tables.c - ACPI tables, chipset, and errata handling + * + * Copyright (C) 2000 Andrew Henroid + * + * 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 + */ + +#include +#include +#include +#include +#include +#include "acpi.h" +#include "driver.h" + +#define _COMPONENT OS_DEPENDENT + MODULE_NAME ("tables") + +struct acpi_facp acpi_facp; + +#define ACPI_DUMMY_CHECKSUM 9 +#define ACPI_DUMMY_PBLK 51 + +static u8 acpi_dummy_dsdt[] = +{ + 0x44, 0x53, 0x44, 0x54, // "DSDT" + 0x38, 0x00, 0x00, 0x00, // length + 0x01, // revision + 0x00, // checksum + 0x4c, 0x49, 0x4e, 0x55, 0x58, 0x00, // "LINUX" + 0x44, 0x55, 0x4d, 0x4d, 0x59, 0x00, 0x00, 0x00, // "DUMMY" + 0x01, 0x00, 0x00, 0x00, // OEM rev + 0x4c, 0x4e, 0x55, 0x58, // "LNUX" + 0x01, 0x00, 0x00, 0x00, // creator rev + 0x10, // Scope + 0x13, // PkgLength + 0x5c, 0x5f, 0x50, 0x52, 0x5f, // \_PR_ + 0x5b, 0x83, // Processor + 0x0b, // PkgLength + 0x43, 0x50, 0x55, 0x30, // CPU0 + 0x00, // ID + 0x00, 0x00, 0x00, 0x00, // PBLK + 0x06 // PBLK size +}; + +/* + * Calculate and set ACPI table checksum + */ +static void +acpi_set_checksum(u8 *table, int size) +{ + int i, sum = 0; + for (i = 0; i < size; i++) + sum += (int) table[i]; + sum = (0x100 - ((sum - table[ACPI_DUMMY_CHECKSUM]) & 0xff)); + table[ACPI_DUMMY_CHECKSUM] = sum; +} + +/* + * Init PIIX4 device, create a fake FACP + */ +static int +acpi_init_piix4(struct pci_dev *dev) +{ + u32 base, pblk; + u16 cmd; + u8 pmregmisc; + + pci_read_config_word(dev, PCI_COMMAND, &cmd); + if (!(cmd & PCI_COMMAND_IO)) + return -ENODEV; + + pci_read_config_byte(dev, ACPI_PIIX4_PMREGMISC, &pmregmisc); + if (!(pmregmisc & ACPI_PIIX4_PMIOSE)) + return -ENODEV; + + base = pci_resource_start (dev, PCI_BRIDGE_RESOURCES); + if (!base) + return -ENODEV; + + printk(KERN_INFO "ACPI: found \"%s\" at 0x%04x\n", dev->name, base); + + memset(&acpi_facp, 0, sizeof(acpi_facp)); + acpi_facp.hdr.signature = ACPI_FACP_SIG; + acpi_facp.hdr.length = sizeof(acpi_facp); + acpi_facp.int_model = ACPI_PIIX4_INT_MODEL; + acpi_facp.sci_int = ACPI_PIIX4_SCI_INT; + acpi_facp.smi_cmd = ACPI_PIIX4_SMI_CMD; + acpi_facp.acpi_enable = ACPI_PIIX4_ACPI_ENABLE; + acpi_facp.acpi_disable = ACPI_PIIX4_ACPI_DISABLE; + acpi_facp.s4bios_req = ACPI_PIIX4_S4BIOS_REQ; + acpi_facp.pm1a_evt = base + ACPI_PIIX4_PM1_EVT; + acpi_facp.pm1a_cnt = base + ACPI_PIIX4_PM1_CNT; + acpi_facp.pm2_cnt = ACPI_PIIX4_PM2_CNT; + acpi_facp.pm_tmr = base + ACPI_PIIX4_PM_TMR; + acpi_facp.gpe0 = base + ACPI_PIIX4_GPE0; + acpi_facp.pm1_evt_len = ACPI_PIIX4_PM1_EVT_LEN; + acpi_facp.pm1_cnt_len = ACPI_PIIX4_PM1_CNT_LEN; + acpi_facp.pm2_cnt_len = ACPI_PIIX4_PM2_CNT_LEN; + acpi_facp.pm_tm_len = ACPI_PIIX4_PM_TM_LEN; + acpi_facp.gpe0_len = ACPI_PIIX4_GPE0_LEN; + acpi_facp.p_lvl2_lat = (__u16) ACPI_INFINITE_LAT; + acpi_facp.p_lvl3_lat = (__u16) ACPI_INFINITE_LAT; + + acpi_set_checksum((u8*) &acpi_facp, sizeof(acpi_facp)); + acpi_load_table((ACPI_TABLE_HEADER*) &acpi_facp); + + pblk = base + ACPI_PIIX4_P_BLK; + memcpy(acpi_dummy_dsdt + ACPI_DUMMY_PBLK, &pblk, sizeof(pblk)); + acpi_set_checksum(acpi_dummy_dsdt, sizeof(acpi_dummy_dsdt)); + acpi_load_table((ACPI_TABLE_HEADER*) acpi_dummy_dsdt); + + return 0; +} + +/* + * Init VIA ACPI device and create a fake FACP + */ +static int +acpi_init_via(struct pci_dev *dev) +{ + u32 base, pblk; + u8 tmp, irq; + + pci_read_config_byte(dev, 0x41, &tmp); + if (!(tmp & 0x80)) + return -ENODEV; + + base = pci_resource_start(dev, PCI_BRIDGE_RESOURCES); + if (!base) { + base = pci_resource_start(dev, PCI_BASE_ADDRESS_4); + if (!base) + return -ENODEV; + } + + pci_read_config_byte(dev, 0x42, &irq); + + printk(KERN_INFO "ACPI: found \"%s\" at 0x%04x\n", dev->name, base); + + memset(&acpi_facp, 0, sizeof(acpi_facp)); + acpi_facp.hdr.signature = ACPI_FACP_SIG; + acpi_facp.hdr.length = sizeof(acpi_facp); + acpi_facp.int_model = ACPI_VIA_INT_MODEL; + acpi_facp.sci_int = irq; + acpi_facp.smi_cmd = base + ACPI_VIA_SMI_CMD; + acpi_facp.acpi_enable = ACPI_VIA_ACPI_ENABLE; + acpi_facp.acpi_disable = ACPI_VIA_ACPI_DISABLE; + acpi_facp.pm1a_evt = base + ACPI_VIA_PM1_EVT; + acpi_facp.pm1a_cnt = base + ACPI_VIA_PM1_CNT; + acpi_facp.pm_tmr = base + ACPI_VIA_PM_TMR; + acpi_facp.gpe0 = base + ACPI_VIA_GPE0; + + acpi_facp.pm1_evt_len = ACPI_VIA_PM1_EVT_LEN; + acpi_facp.pm1_cnt_len = ACPI_VIA_PM1_CNT_LEN; + acpi_facp.pm_tm_len = ACPI_VIA_PM_TM_LEN; + acpi_facp.gpe0_len = ACPI_VIA_GPE0_LEN; + acpi_facp.p_lvl2_lat = (__u16) ACPI_INFINITE_LAT; + acpi_facp.p_lvl3_lat = (__u16) ACPI_INFINITE_LAT; + + acpi_facp.duty_offset = ACPI_VIA_DUTY_OFFSET; + acpi_facp.duty_width = ACPI_VIA_DUTY_WIDTH; + + acpi_facp.day_alarm = ACPI_VIA_DAY_ALARM; + acpi_facp.mon_alarm = ACPI_VIA_MON_ALARM; + acpi_facp.century = ACPI_VIA_CENTURY; + + acpi_set_checksum((u8*) &acpi_facp, sizeof(acpi_facp)); + acpi_load_table((ACPI_TABLE_HEADER*) &acpi_facp); + + pblk = base + ACPI_VIA_P_BLK; + memcpy(acpi_dummy_dsdt + ACPI_DUMMY_PBLK, &pblk, sizeof(pblk)); + acpi_set_checksum(acpi_dummy_dsdt, sizeof(acpi_dummy_dsdt)); + acpi_load_table((ACPI_TABLE_HEADER*) acpi_dummy_dsdt); + + return 0; +} + +typedef enum +{ + CH_UNKNOWN = 0, + CH_INTEL_PIIX4, + CH_VIA_586, + CH_VIA_686A, +} acpi_chip_t; + +/* indexed by value of each enum in acpi_chip_t */ +const static struct +{ + int (*chip_init)(struct pci_dev *dev); +} acpi_chip_info[] = +{ + {NULL,}, + {acpi_init_piix4}, + {acpi_init_via}, + {acpi_init_via}, +}; + +static struct pci_device_id acpi_pci_tbl[] = +{ + {0x8086, 0x7113, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_INTEL_PIIX4}, + {0x1106, 0x3040, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_VIA_586}, + {0x1106, 0x3057, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_VIA_686A}, + {0,} /* terminate list */ +}; + +static int +acpi_probe(struct pci_dev *dev, const struct pci_device_id *id) +{ + return acpi_chip_info[id->driver_data].chip_init(dev); +} + +static struct pci_driver acpi_driver = +{ + name: "acpi", + id_table: acpi_pci_tbl, + probe: acpi_probe, +}; +static int acpi_driver_registered = 0; + +/* + * Locate a known ACPI chipset + */ +static int +acpi_find_chipset(void) +{ + if (pci_register_driver(&acpi_driver) < 1) + return -ENODEV; + acpi_driver_registered = 1; + return 0; +} + +/* + * Fetch the FACP information + */ +static int +acpi_fetch_facp(void) +{ + ACPI_BUFFER buffer; + + memset(&acpi_facp, 0, sizeof(acpi_facp)); + buffer.pointer = &acpi_facp; + buffer.length = sizeof(acpi_facp); + if (!ACPI_SUCCESS(acpi_get_table(ACPI_TABLE_FACP, 1, &buffer))) { + printk(KERN_ERR "ACPI: missing FACP\n"); + return -ENODEV; + } + + if (acpi_facp.p_lvl2_lat + && acpi_facp.p_lvl2_lat <= ACPI_MAX_P_LVL2_LAT) { + acpi_c2_exit_latency + = ACPI_uS_TO_TMR_TICKS(acpi_facp.p_lvl2_lat); + acpi_c2_enter_latency + = ACPI_uS_TO_TMR_TICKS(ACPI_TMR_HZ / 1000); + } + if (acpi_facp.p_lvl3_lat + && acpi_facp.p_lvl3_lat <= ACPI_MAX_P_LVL3_LAT) { + acpi_c3_exit_latency + = ACPI_uS_TO_TMR_TICKS(acpi_facp.p_lvl3_lat); + acpi_c3_enter_latency + = ACPI_uS_TO_TMR_TICKS(acpi_facp.p_lvl3_lat * 5); + } + + return 0; +} + +/* + * Find and load ACPI tables + */ +int +acpi_load_tables(void) +{ + if (ACPI_SUCCESS(acpi_load_firmware_tables())) + { + printk(KERN_INFO "ACPI: support found\n"); + } + else if (acpi_find_chipset()) { + acpi_terminate(); + return -1; + } + + if (acpi_fetch_facp()) { + acpi_terminate(); + return -1; + } + + if (!ACPI_SUCCESS(acpi_load_namespace())) { + printk(KERN_ERR "ACPI: namespace load failed\n"); + acpi_terminate(); + return -1; + } + + return 0; +} diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/tables/Makefile linux/drivers/acpi/tables/Makefile --- v2.4.0-test8/linux/drivers/acpi/tables/Makefile Wed Dec 31 16:00:00 1969 +++ linux/drivers/acpi/tables/Makefile Fri Sep 15 18:21:44 2000 @@ -0,0 +1,28 @@ +# +# Makefile for all Linux ACPI interpreter subdirectories +# + +SUB_DIRS := +MOD_SUB_DIRS := $(SUB_DIRS) +MOD_IN_SUB_DIRS := +ALL_SUB_DIRS := $(SUB_DIRS) + +O_TARGET := ../$(shell basename `pwd`).o +O_OBJS := +M_OBJS := + +ACPI_OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) + +EXTRA_CFLAGS += -I../include + +EXTRA_CFLAGS += $(ACPI_CFLAGS) + +# if the interpreter is used, it overrides arch/i386/kernel/acpi.c +ifeq ($(CONFIG_ACPI_INTERPRETER),y) + O_OBJS := $(ACPI_OBJS) +endif + +include $(TOPDIR)/Rules.make + +clean: + $(RM) *.o diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/tables/tbget.c linux/drivers/acpi/tables/tbget.c --- v2.4.0-test8/linux/drivers/acpi/tables/tbget.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/tables/tbget.c Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: tbget - ACPI Table get* routines + * $Revision: 22 $ * *****************************************************************************/ @@ -25,12 +25,12 @@ #include "acpi.h" -#include "hardware.h" -#include "tables.h" +#include "achware.h" +#include "actables.h" #define _COMPONENT TABLE_MANAGER - MODULE_NAME ("tbget"); + MODULE_NAME ("tbget") /******************************************************************************* @@ -90,10 +90,15 @@ return (AE_NOT_EXIST); } - /* Walk the list to get the table */ - + /* Walk the list to get the desired table + * Since the if (Instance == 1) check above checked for the + * first table, setting Table_desc equal to the .Next member + * is actually pointing to the second table. Therefore, we + * need to walk from the 2nd table until we reach the Instance + * that the user is looking for and return its table pointer. + */ table_desc = acpi_gbl_acpi_tables[table_type].next; - for (i = 1; i < acpi_gbl_acpi_tables[table_type].count; i++) { + for (i = 2; i < instance; i++) { table_desc = table_desc->next; } @@ -110,8 +115,8 @@ * FUNCTION: Acpi_tb_get_table * * PARAMETERS: Physical_address - Physical address of table to retrieve - * *Buffer_ptr - If == NULL, read data from buffer - * rather than searching memory + * *Buffer_ptr - If Buffer_ptr is valid, read data from + * buffer rather than searching memory * *Table_info - Where the table info is returned * * RETURN: Status @@ -123,7 +128,7 @@ ACPI_STATUS acpi_tb_get_table ( void *physical_address, - char *buffer_ptr, + ACPI_TABLE_HEADER *buffer_ptr, ACPI_TABLE_DESC *table_info) { ACPI_TABLE_HEADER *table_header = NULL; @@ -143,7 +148,7 @@ * Getting data from a buffer, not BIOS tables */ - table_header = (ACPI_TABLE_HEADER *) buffer_ptr; + table_header = buffer_ptr; status = acpi_tb_validate_table_header (table_header); if (ACPI_FAILURE (status)) { /* Table failed verification, map all errors to BAD_DATA */ @@ -160,7 +165,7 @@ /* Copy the entire table (including header) to the local buffer */ - size = (ACPI_SIZE) table_header->length; + size = table_header->length; MEMCPY (full_table, buffer_ptr, size); /* Save allocation type */ @@ -216,7 +221,7 @@ ACPI_STATUS acpi_tb_get_all_tables ( u32 number_of_tables, - char *table_ptr) + ACPI_TABLE_HEADER *table_ptr) { ACPI_STATUS status = AE_OK; u32 index; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/tables/tbinstal.c linux/drivers/acpi/tables/tbinstal.c --- v2.4.0-test8/linux/drivers/acpi/tables/tbinstal.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/tables/tbinstal.c Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: tbinstal - ACPI table installation and removal + * $Revision: 29 $ * *****************************************************************************/ @@ -25,12 +25,12 @@ #include "acpi.h" -#include "hardware.h" -#include "tables.h" +#include "achware.h" +#include "actables.h" #define _COMPONENT TABLE_MANAGER - MODULE_NAME ("tbinstal"); + MODULE_NAME ("tbinstal") /******************************************************************************* @@ -50,11 +50,9 @@ ACPI_STATUS acpi_tb_install_table ( - char *table_ptr, + ACPI_TABLE_HEADER *table_ptr, ACPI_TABLE_DESC *table_info) { - ACPI_TABLE_TYPE table_type; - ACPI_TABLE_HEADER *table_header; ACPI_STATUS status; @@ -68,11 +66,6 @@ return (status); } - /* Table type is returned by Recognize_table */ - - table_type = table_info->type; - table_header = table_info->pointer; - /* Lock tables while installing */ acpi_cm_acquire_mutex (ACPI_MTX_TABLES); @@ -80,12 +73,9 @@ /* Install the table into the global data structure */ status = acpi_tb_init_table_descriptor (table_info->type, table_info); - if (ACPI_FAILURE (status)) { - return (status); - } acpi_cm_release_mutex (ACPI_MTX_TABLES); - return (AE_OK); + return (status); } @@ -112,7 +102,7 @@ ACPI_STATUS acpi_tb_recognize_table ( - char *table_ptr, + ACPI_TABLE_HEADER *table_ptr, ACPI_TABLE_DESC *table_info) { ACPI_TABLE_HEADER *table_header; @@ -215,9 +205,10 @@ * the table are allowed. This includes SSDT and PSDTs. */ - if (acpi_gbl_acpi_table_data[table_type].flags == ACPI_TABLE_SINGLE) { + if (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags)) { /* - * Only one table allowed, just update the list head + * Only one table allowed, and a table has alread been installed + * at this location, so return an error. */ if (list_head->pointer) { @@ -249,7 +240,7 @@ /* Update new entry */ table_desc->prev = list_head->prev; - table_desc->next = (ACPI_TABLE_DESC *) list_head; + table_desc->next = list_head; /* Update list head */ @@ -308,7 +299,7 @@ void acpi_tb_delete_acpi_tables (void) { - u32 i; + ACPI_TABLE_TYPE type; /* @@ -316,8 +307,8 @@ * Memory can either be mapped or allocated */ - for (i = 0; i < ACPI_TABLE_MAX; i++) { - acpi_tb_delete_acpi_table (i); + for (type = 0; type < ACPI_TABLE_MAX; type++) { + acpi_tb_delete_acpi_table (type); } } @@ -402,6 +393,46 @@ /******************************************************************************* * + * FUNCTION: Acpi_tb_free_acpi_tables_of_type + * + * PARAMETERS: Table_info - A table info struct + * + * RETURN: None. + * + * DESCRIPTION: Free the memory associated with an internal ACPI table + * Table mutex should be locked. + * + ******************************************************************************/ + +void +acpi_tb_free_acpi_tables_of_type ( + ACPI_TABLE_DESC *list_head) +{ + ACPI_TABLE_DESC *table_desc; + u32 count; + u32 i; + + + /* Get the head of the list */ + + table_desc = list_head; + count = list_head->count; + + /* + * Walk the entire list, deleting both the allocated tables + * and the table descriptors + */ + + for (i = 0; i < count; i++) { + table_desc = acpi_tb_delete_single_table (table_desc); + } + + return; +} + + +/******************************************************************************* + * * FUNCTION: Acpi_tb_delete_single_table * * PARAMETERS: Table_info - A table info struct @@ -488,46 +519,6 @@ return (next_desc); -} - - -/******************************************************************************* - * - * FUNCTION: Acpi_tb_free_acpi_tables_of_type - * - * PARAMETERS: Table_info - A table info struct - * - * RETURN: None. - * - * DESCRIPTION: Free the memory associated with an internal ACPI table - * Table mutex should be locked. - * - ******************************************************************************/ - -void -acpi_tb_free_acpi_tables_of_type ( - ACPI_TABLE_DESC *list_head) -{ - ACPI_TABLE_DESC *table_desc; - u32 count; - u32 i; - - - /* Get the head of the list */ - - table_desc = list_head; - count = list_head->count; - - /* - * Walk the entire list, deleting both the allocated tables - * and the table descriptors - */ - - for (i = 0; i < count; i++) { - table_desc = acpi_tb_delete_single_table (table_desc); - } - - return; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/tables/tbtable.c linux/drivers/acpi/tables/tbtable.c --- v2.4.0-test8/linux/drivers/acpi/tables/tbtable.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/tables/tbtable.c Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: tbtable - ACPI tables: FACP, FACS, and RSDP utilities + * $Revision: 24 $ * *****************************************************************************/ @@ -25,12 +25,12 @@ #include "acpi.h" -#include "hardware.h" -#include "tables.h" +#include "achware.h" +#include "actables.h" #define _COMPONENT TABLE_MANAGER - MODULE_NAME ("tbtable"); + MODULE_NAME ("tbtable") /******************************************************************************* @@ -38,7 +38,6 @@ * FUNCTION: Acpi_tb_get_table_rsdt * * PARAMETERS: Number_of_tables - Where the table count is placed - * Table_ptr - Input buffer pointer, optional * * RETURN: Status * @@ -85,15 +84,15 @@ REPORT_ERROR ("Invalid signature where RSDP indicates RSDT should be located"); } + REPORT_ERROR ("Unable to locate RSDT"); + + return (status); } /* Always delete the RSDP mapping */ acpi_tb_delete_acpi_table (ACPI_TABLE_RSDP); - if (ACPI_FAILURE (status)) { - return (status); - } /* Save the table pointers and allocation info */ @@ -109,10 +108,15 @@ status = acpi_tb_verify_table_checksum ((ACPI_TABLE_HEADER *) acpi_gbl_RSDT); - /* Determine the number of tables pointed to by the RSDT */ + /* + * Determine the number of tables pointed to by the RSDT. + * This is defined by the ACPI Specification to be the number of + * pointers contained within the RSDT. The size of the pointers + * is architecture-dependent. + */ - *number_of_tables = (s32) DIV_4 (acpi_gbl_RSDT->header.length - - sizeof (ACPI_TABLE_HEADER)); + *number_of_tables = ((acpi_gbl_RSDT->header.length - + sizeof (ACPI_TABLE_HEADER)) / sizeof (void *)); return (status); @@ -132,13 +136,13 @@ * ******************************************************************************/ -char * +u8 * acpi_tb_scan_memory_for_rsdp ( - char *start_address, + u8 *start_address, u32 length) { u32 offset; - char *mem_rover; + u8 *mem_rover; /* Search from given start addr for the requested length */ @@ -150,19 +154,19 @@ /* The signature and checksum must both be correct */ - if (STRNCMP (mem_rover, RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 && + if (STRNCMP ((NATIVE_CHAR *) mem_rover, RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 && acpi_tb_checksum (mem_rover, sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)) == 0) { /* If so, we have found the RSDP */ - return mem_rover; + return (mem_rover); } } /* Searched entire block, no RSDP was found */ - return NULL; + return (NULL); } @@ -189,8 +193,8 @@ acpi_tb_find_rsdp ( ACPI_TABLE_DESC *table_info) { - char *table_ptr; - char *mem_rover; + u8 *table_ptr; + u8 *mem_rover; ACPI_STATUS status = AE_OK; if (acpi_gbl_acpi_init_data.RSDP_physical_address) { @@ -214,9 +218,9 @@ * The signature and checksum must both be correct */ - if (STRNCMP (table_ptr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { + if (STRNCMP ((NATIVE_CHAR *) table_ptr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { /* Nope, BAD Signature */ - + acpi_os_unmap_memory (table_ptr, sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)); return (AE_BAD_SIGNATURE); } @@ -226,7 +230,7 @@ sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)) != 0) { /* Nope, BAD Checksum */ - + acpi_os_unmap_memory (table_ptr, sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)); return (AE_BAD_CHECKSUM); } @@ -309,12 +313,12 @@ } -/******************************************************************************* +/****************************************************************************** * * FUNCTION: Acpi_tb_get_table_facs * - * PARAMETERS: *Buffer_ptr - If == NULL, read data from buffer - * rather than searching memory + * PARAMETERS: *Buffer_ptr - If Buffer_ptr is valid, read data from + * buffer rather than searching memory * *Table_info - Where the table info is returned * * RETURN: Status @@ -324,11 +328,11 @@ * correctly initialized. The value of FACP->Firmware_ctrl * into a far pointer which is returned. * - ******************************************************************************/ + *****************************************************************************/ ACPI_STATUS acpi_tb_get_table_facs ( - char *buffer_ptr, + ACPI_TABLE_HEADER *buffer_ptr, ACPI_TABLE_DESC *table_info) { void *table_ptr = NULL; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/tables/tbutils.c linux/drivers/acpi/tables/tbutils.c --- v2.4.0-test8/linux/drivers/acpi/tables/tbutils.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/tables/tbutils.c Fri Sep 15 14:30:30 2000 @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: tbutils - Table manipulation utilities + * $Revision: 26 $ * *****************************************************************************/ @@ -25,23 +25,24 @@ #include "acpi.h" -#include "tables.h" -#include "interp.h" +#include "actables.h" +#include "acinterp.h" #define _COMPONENT TABLE_MANAGER - MODULE_NAME ("tbutils"); + MODULE_NAME ("tbutils") /******************************************************************************* * - * FUNCTION: Acpi_tb_system_table_pointer + * FUNCTION: Acpi_tb_handle_to_object * - * PARAMETERS: *Where - Pointer to be examined + * PARAMETERS: Table_id - Id for which the function is searching + * Table_desc - Pointer to return the matching table + * descriptor. * - * RETURN: TRUE if Where is within the AML stream (in one of the ACPI - * system tables such as the DSDT or an SSDT.) - * FALSE otherwise + * RETURN: Search the tables to find one with a matching Table_id and + * return a pointer to that table descriptor. * ******************************************************************************/ @@ -60,7 +61,7 @@ { if (list_head->table_id == table_id) { *table_desc = list_head; - return AE_OK; + return (AE_OK); } list_head = list_head->next; @@ -69,7 +70,7 @@ } - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } @@ -177,7 +178,7 @@ /* Verify that this is a valid address */ if (!acpi_os_readable (table_header, sizeof (ACPI_TABLE_HEADER))) { - return AE_BAD_ADDRESS; + return (AE_BAD_ADDRESS); } @@ -186,7 +187,7 @@ MOVE_UNALIGNED32_TO_32 (&signature, &table_header->signature); if (!acpi_cm_valid_acpi_name (signature)) { REPORT_WARNING ("Invalid table signature found"); - return AE_BAD_SIGNATURE; + return (AE_BAD_SIGNATURE); } @@ -194,10 +195,10 @@ if (table_header->length < sizeof (ACPI_TABLE_HEADER)) { REPORT_WARNING ("Invalid table header length found"); - return AE_BAD_HEADER; + return (AE_BAD_HEADER); } - return AE_OK; + return (AE_OK); } @@ -236,7 +237,7 @@ status = acpi_os_map_memory (physical_address, sizeof (ACPI_TABLE_HEADER), (void **) &table); if (ACPI_FAILURE (status)) { - return status; + return (status); } /* Extract the full table length before we delete the mapping */ @@ -257,7 +258,7 @@ /* Exit if header invalid */ if (ACPI_FAILURE (status)) { - return status; + return (status); } } @@ -266,13 +267,13 @@ status = acpi_os_map_memory (physical_address, table_size, (void **) &table); if (ACPI_FAILURE (status)) { - return status; + return (status); } *size = table_size; *logical_address = table; - return status; + return (status); } @@ -346,7 +347,7 @@ } } - return sum; + return (sum); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/tables/tbxface.c linux/drivers/acpi/tables/tbxface.c --- v2.4.0-test8/linux/drivers/acpi/tables/tbxface.c Mon Jul 10 16:47:21 2000 +++ linux/drivers/acpi/tables/tbxface.c Fri Sep 15 14:30:30 2000 @@ -1,8 +1,8 @@ - /****************************************************************************** * * Module Name: tbxface - Public interfaces to the ACPI subsystem * ACPI table oriented interfaces + * $Revision: 24 $ * *****************************************************************************/ @@ -26,13 +26,13 @@ #include "acpi.h" -#include "namesp.h" -#include "interp.h" -#include "tables.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "actables.h" #define _COMPONENT TABLE_MANAGER - MODULE_NAME ("tbxface"); + MODULE_NAME ("tbxface") /******************************************************************************* @@ -57,7 +57,7 @@ /* Get the RSDT first */ status = acpi_tb_get_table_rsdt (&number_of_tables); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { goto error_exit; } @@ -65,7 +65,7 @@ /* Now get the rest of the tables */ status = acpi_tb_get_all_tables (number_of_tables, NULL); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { goto error_exit; } @@ -105,12 +105,12 @@ if (!table_ptr) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } /* Copy the table to a local buffer */ - status = acpi_tb_get_table (NULL, ((char *) table_ptr), &table_info); + status = acpi_tb_get_table (NULL, table_ptr, &table_info); if (ACPI_FAILURE (status)) { return (status); } @@ -157,7 +157,12 @@ list_head = &acpi_gbl_acpi_tables[table_type]; do { - /* Delete the entire namespace under this table NTE */ + /* + * Delete all namespace entries owned by this table. Note that these + * entries can appear anywhere in the namespace by virtue of the AML + * "Scope" operator. Thus, we need to track ownership by an ID, not + * simply a position within the hierarchy + */ acpi_ns_delete_namespace_by_owner (list_head->table_id); @@ -205,8 +210,6 @@ ACPI_STATUS status; - status = AE_OK; - if ((instance == 0) || (table_type == ACPI_TABLE_RSDP) || (!out_table_header)) @@ -217,7 +220,7 @@ /* Check the table type and instance */ if ((table_type > ACPI_TABLE_MAX) || - (acpi_gbl_acpi_table_data[table_type].flags == ACPI_TABLE_SINGLE && + (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags) && instance > 1)) { return (AE_BAD_PARAMETER); @@ -227,7 +230,7 @@ /* Get a pointer to the entire table */ status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { return (status); } @@ -285,8 +288,6 @@ u32 ret_buf_len; - status = AE_OK; - /* * Must have a buffer */ @@ -301,7 +302,7 @@ /* Check the table type and instance */ if ((table_type > ACPI_TABLE_MAX) || - (acpi_gbl_acpi_table_data[table_type].flags == ACPI_TABLE_SINGLE && + (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags) && instance > 1)) { return (AE_BAD_PARAMETER); @@ -311,12 +312,13 @@ /* Get a pointer to the entire table */ status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { return (status); } /* - * The function will return a NULL pointer if the table is not loaded + * Acpi_tb_get_table_ptr will return a NULL pointer if the + * table is not loaded. */ if (tbl_ptr == NULL) { return (AE_NOT_EXIST); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/tables.c linux/drivers/acpi/tables.c --- v2.4.0-test8/linux/drivers/acpi/tables.c Fri Jul 14 12:12:08 2000 +++ linux/drivers/acpi/tables.c Wed Dec 31 16:00:00 1969 @@ -1,303 +0,0 @@ -/* - * tables.c - ACPI tables, chipset, and errata handling - * - * Copyright (C) 2000 Andrew Henroid - * - * 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 - */ - -#include -#include -#include -#include -#include -#include "acpi.h" -#include "driver.h" - -struct acpi_facp acpi_facp; - -#define ACPI_DUMMY_CHECKSUM 9 -#define ACPI_DUMMY_PBLK 51 - -static u8 acpi_dummy_dsdt[] = -{ - 0x44, 0x53, 0x44, 0x54, // "DSDT" - 0x38, 0x00, 0x00, 0x00, // length - 0x01, // revision - 0x00, // checksum - 0x4c, 0x49, 0x4e, 0x55, 0x58, 0x00, // "LINUX" - 0x44, 0x55, 0x4d, 0x4d, 0x59, 0x00, 0x00, 0x00, // "DUMMY" - 0x01, 0x00, 0x00, 0x00, // OEM rev - 0x4c, 0x4e, 0x55, 0x58, // "LNUX" - 0x01, 0x00, 0x00, 0x00, // creator rev - 0x10, // Scope - 0x13, // PkgLength - 0x5c, 0x5f, 0x50, 0x52, 0x5f, // \_PR_ - 0x5b, 0x83, // Processor - 0x0b, // PkgLength - 0x43, 0x50, 0x55, 0x30, // CPU0 - 0x00, // ID - 0x00, 0x00, 0x00, 0x00, // PBLK - 0x06 // PBLK size -}; - -/* - * Calculate and set ACPI table checksum - */ -static void -acpi_set_checksum(u8 *table, int size) -{ - int i, sum = 0; - for (i = 0; i < size; i++) - sum += (int) table[i]; - sum = (0x100 - ((sum - table[ACPI_DUMMY_CHECKSUM]) & 0xff)); - table[ACPI_DUMMY_CHECKSUM] = sum; -} - -/* - * Init PIIX4 device, create a fake FACP - */ -static int -acpi_init_piix4(struct pci_dev *dev) -{ - u32 base, pblk; - u16 cmd; - u8 pmregmisc; - - pci_read_config_word(dev, PCI_COMMAND, &cmd); - if (!(cmd & PCI_COMMAND_IO)) - return -ENODEV; - - pci_read_config_byte(dev, ACPI_PIIX4_PMREGMISC, &pmregmisc); - if (!(pmregmisc & ACPI_PIIX4_PMIOSE)) - return -ENODEV; - - base = pci_resource_start (dev, PCI_BRIDGE_RESOURCES); - if (!base) - return -ENODEV; - - printk(KERN_INFO "ACPI: found \"%s\" at 0x%04x\n", dev->name, base); - - memset(&acpi_facp, 0, sizeof(acpi_facp)); - acpi_facp.hdr.signature = ACPI_FACP_SIG; - acpi_facp.hdr.length = sizeof(acpi_facp); - acpi_facp.int_model = ACPI_PIIX4_INT_MODEL; - acpi_facp.sci_int = ACPI_PIIX4_SCI_INT; - acpi_facp.smi_cmd = ACPI_PIIX4_SMI_CMD; - acpi_facp.acpi_enable = ACPI_PIIX4_ACPI_ENABLE; - acpi_facp.acpi_disable = ACPI_PIIX4_ACPI_DISABLE; - acpi_facp.s4bios_req = ACPI_PIIX4_S4BIOS_REQ; - acpi_facp.pm1a_evt = base + ACPI_PIIX4_PM1_EVT; - acpi_facp.pm1a_cnt = base + ACPI_PIIX4_PM1_CNT; - acpi_facp.pm2_cnt = ACPI_PIIX4_PM2_CNT; - acpi_facp.pm_tmr = base + ACPI_PIIX4_PM_TMR; - acpi_facp.gpe0 = base + ACPI_PIIX4_GPE0; - acpi_facp.pm1_evt_len = ACPI_PIIX4_PM1_EVT_LEN; - acpi_facp.pm1_cnt_len = ACPI_PIIX4_PM1_CNT_LEN; - acpi_facp.pm2_cnt_len = ACPI_PIIX4_PM2_CNT_LEN; - acpi_facp.pm_tm_len = ACPI_PIIX4_PM_TM_LEN; - acpi_facp.gpe0_len = ACPI_PIIX4_GPE0_LEN; - acpi_facp.p_lvl2_lat = (__u16) ACPI_INFINITE_LAT; - acpi_facp.p_lvl3_lat = (__u16) ACPI_INFINITE_LAT; - - acpi_set_checksum((u8*) &acpi_facp, sizeof(acpi_facp)); - acpi_load_table((ACPI_TABLE_HEADER*) &acpi_facp); - - pblk = base + ACPI_PIIX4_P_BLK; - memcpy(acpi_dummy_dsdt + ACPI_DUMMY_PBLK, &pblk, sizeof(pblk)); - acpi_set_checksum(acpi_dummy_dsdt, sizeof(acpi_dummy_dsdt)); - acpi_load_table((ACPI_TABLE_HEADER*) acpi_dummy_dsdt); - - return 0; -} - -/* - * Init VIA ACPI device and create a fake FACP - */ -static int -acpi_init_via(struct pci_dev *dev) -{ - u32 base, pblk; - u8 tmp, irq; - - pci_read_config_byte(dev, 0x41, &tmp); - if (!(tmp & 0x80)) - return -ENODEV; - - base = pci_resource_start(dev, PCI_BRIDGE_RESOURCES); - if (!base) { - base = pci_resource_start(dev, PCI_BASE_ADDRESS_4); - if (!base) - return -ENODEV; - } - - pci_read_config_byte(dev, 0x42, &irq); - - printk(KERN_INFO "ACPI: found \"%s\" at 0x%04x\n", dev->name, base); - - memset(&acpi_facp, 0, sizeof(acpi_facp)); - acpi_facp.hdr.signature = ACPI_FACP_SIG; - acpi_facp.hdr.length = sizeof(acpi_facp); - acpi_facp.int_model = ACPI_VIA_INT_MODEL; - acpi_facp.sci_int = irq; - acpi_facp.smi_cmd = base + ACPI_VIA_SMI_CMD; - acpi_facp.acpi_enable = ACPI_VIA_ACPI_ENABLE; - acpi_facp.acpi_disable = ACPI_VIA_ACPI_DISABLE; - acpi_facp.pm1a_evt = base + ACPI_VIA_PM1_EVT; - acpi_facp.pm1a_cnt = base + ACPI_VIA_PM1_CNT; - acpi_facp.pm_tmr = base + ACPI_VIA_PM_TMR; - acpi_facp.gpe0 = base + ACPI_VIA_GPE0; - - acpi_facp.pm1_evt_len = ACPI_VIA_PM1_EVT_LEN; - acpi_facp.pm1_cnt_len = ACPI_VIA_PM1_CNT_LEN; - acpi_facp.pm_tm_len = ACPI_VIA_PM_TM_LEN; - acpi_facp.gpe0_len = ACPI_VIA_GPE0_LEN; - acpi_facp.p_lvl2_lat = (__u16) ACPI_INFINITE_LAT; - acpi_facp.p_lvl3_lat = (__u16) ACPI_INFINITE_LAT; - - acpi_facp.duty_offset = ACPI_VIA_DUTY_OFFSET; - acpi_facp.duty_width = ACPI_VIA_DUTY_WIDTH; - - acpi_facp.day_alarm = ACPI_VIA_DAY_ALARM; - acpi_facp.mon_alarm = ACPI_VIA_MON_ALARM; - acpi_facp.century = ACPI_VIA_CENTURY; - - acpi_set_checksum((u8*) &acpi_facp, sizeof(acpi_facp)); - acpi_load_table((ACPI_TABLE_HEADER*) &acpi_facp); - - pblk = base + ACPI_VIA_P_BLK; - memcpy(acpi_dummy_dsdt + ACPI_DUMMY_PBLK, &pblk, sizeof(pblk)); - acpi_set_checksum(acpi_dummy_dsdt, sizeof(acpi_dummy_dsdt)); - acpi_load_table((ACPI_TABLE_HEADER*) acpi_dummy_dsdt); - - return 0; -} - -typedef enum -{ - CH_UNKNOWN = 0, - CH_INTEL_PIIX4, - CH_VIA_586, - CH_VIA_686A, -} acpi_chip_t; - -/* indexed by value of each enum in acpi_chip_t */ -const static struct -{ - int (*chip_init)(struct pci_dev *dev); -} acpi_chip_info[] = -{ - {NULL,}, - {acpi_init_piix4}, - {acpi_init_via}, - {acpi_init_via}, -}; - -static struct pci_device_id acpi_pci_tbl[] = -{ - {0x8086, 0x7113, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_INTEL_PIIX4}, - {0x1106, 0x3040, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_VIA_586}, - {0x1106, 0x3057, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_VIA_686A}, - {0,} /* terminate list */ -}; - -static int -acpi_probe(struct pci_dev *dev, const struct pci_device_id *id) -{ - return acpi_chip_info[id->driver_data].chip_init(dev); -} - -static struct pci_driver acpi_driver = -{ - name: "acpi", - id_table: acpi_pci_tbl, - probe: acpi_probe, -}; -static int acpi_driver_registered = 0; - -/* - * Locate a known ACPI chipset - */ -static int -acpi_find_chipset(void) -{ - if (pci_register_driver(&acpi_driver) < 1) - return -ENODEV; - acpi_driver_registered = 1; - return 0; -} - -/* - * Fetch the FACP information - */ -static int -acpi_fetch_facp(void) -{ - ACPI_BUFFER buffer; - - memset(&acpi_facp, 0, sizeof(acpi_facp)); - buffer.pointer = &acpi_facp; - buffer.length = sizeof(acpi_facp); - if (!ACPI_SUCCESS(acpi_get_table(ACPI_TABLE_FACP, 1, &buffer))) { - printk(KERN_ERR "ACPI: missing FACP\n"); - return -ENODEV; - } - - if (acpi_facp.p_lvl2_lat - && acpi_facp.p_lvl2_lat <= ACPI_MAX_P_LVL2_LAT) { - acpi_c2_exit_latency - = ACPI_uS_TO_TMR_TICKS(acpi_facp.p_lvl2_lat); - acpi_c2_enter_latency - = ACPI_uS_TO_TMR_TICKS(ACPI_TMR_HZ / 1000); - } - if (acpi_facp.p_lvl3_lat - && acpi_facp.p_lvl3_lat <= ACPI_MAX_P_LVL3_LAT) { - acpi_c3_exit_latency - = ACPI_uS_TO_TMR_TICKS(acpi_facp.p_lvl3_lat); - acpi_c3_enter_latency - = ACPI_uS_TO_TMR_TICKS(acpi_facp.p_lvl3_lat * 5); - } - - return 0; -} - -/* - * Find and load ACPI tables - */ -int -acpi_load_tables(void) -{ - if (ACPI_SUCCESS(acpi_load_firmware_tables())) - { - printk(KERN_INFO "ACPI: support found\n"); - } - else if (acpi_find_chipset()) { - acpi_terminate(); - return -1; - } - - if (acpi_fetch_facp()) { - acpi_terminate(); - return -1; - } - - if (!ACPI_SUCCESS(acpi_load_namespace())) { - printk(KERN_ERR "ACPI: namespace load failed\n"); - acpi_terminate(); - return -1; - } - - return 0; -} diff -u --recursive --new-file v2.4.0-test8/linux/drivers/block/lvm-snap.c linux/drivers/block/lvm-snap.c --- v2.4.0-test8/linux/drivers/block/lvm-snap.c Wed Aug 9 19:19:50 2000 +++ linux/drivers/block/lvm-snap.c Sun Sep 17 09:51:57 2000 @@ -118,7 +118,8 @@ or error on this snapshot --> release it */ invalidate_buffers(lv_snap->lv_dev); - for (i = last_dev = 0; i < lv_snap->lv_remap_ptr; i++) { + last_dev = 0; + for (i = 0; i < lv_snap->lv_remap_ptr; i++) { if ( lv_snap->lv_block_exception[i].rdev_new != last_dev) { last_dev = lv_snap->lv_block_exception[i].rdev_new; invalidate_buffers(last_dev); @@ -199,8 +200,9 @@ lv_t * lv_snap) { const char * reason; - unsigned long org_start, snap_start, snap_phys_dev, virt_start, pe_off; + unsigned long org_start, snap_start, virt_start, pe_off; int idx = lv_snap->lv_remap_ptr, chunk_size = lv_snap->lv_chunk_size; + kdev_t snap_phys_dev; struct kiobuf * iobuf; unsigned long blocks[KIO_MAX_SECTORS]; int blksize_snap, blksize_org, min_blksize, max_blksize; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/block/lvm.c linux/drivers/block/lvm.c --- v2.4.0-test8/linux/drivers/block/lvm.c Fri Sep 8 13:27:11 2000 +++ linux/drivers/block/lvm.c Sun Sep 17 09:51:57 2000 @@ -250,7 +250,7 @@ static int lvm_do_pv_status(vg_t *, void *); static void lvm_geninit(struct gendisk *); #ifdef LVM_GET_INODE -static struct inode *lvm_get_inode(int); +static struct inode *lvm_get_inode(kdev_t); void lvm_clear_inode(struct inode *); #endif /* END Internal function prototypes */ @@ -486,9 +486,8 @@ loadtime = CURRENT_TIME; pe_lock_req.lock = UNLOCK_PE; - pe_lock_req.data.lv_dev = \ - pe_lock_req.data.pv_dev = \ - pe_lock_req.data.pv_offset = 0; + pe_lock_req.data.lv_dev = pe_lock_req.data.pv_dev = 0; + pe_lock_req.data.pv_offset = 0; /* Initialize VG pointers */ for (v = 0; v < ABS_MAX_VG; v++) vg[v] = NULL; @@ -1561,8 +1560,7 @@ case UNLOCK_PE: pe_lock_req.lock = UNLOCK_PE; - pe_lock_req.data.lv_dev = \ - pe_lock_req.data.pv_dev = \ + pe_lock_req.data.lv_dev = pe_lock_req.data.pv_dev = 0; pe_lock_req.data.pv_offset = 0; wake_up(&lvm_map_wait); break; @@ -2542,7 +2540,7 @@ * If you can convince Linus that it's worth changing - fine, then you'll need * to do blkdev_get()/blkdev_put(). Until then... */ -struct inode *lvm_get_inode(int dev) +struct inode *lvm_get_inode(kdev_t dev) { struct inode *inode_this = NULL; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/block/swim3.c linux/drivers/block/swim3.c --- v2.4.0-test8/linux/drivers/block/swim3.c Fri Jun 23 21:55:08 2000 +++ linux/drivers/block/swim3.c Sun Sep 17 09:48:05 2000 @@ -246,6 +246,13 @@ static int swim3_add_device(struct device_node *swims); int swim3_init(void); +#ifndef CONFIG_PMAC_PBOOK +static inline int check_media_bay(struct device_node *which_bay, int what) +{ + return 1; +} +#endif + static void swim3_select(struct floppy_state *fs, int sel) { volatile struct swim3 *sw = fs->swim3; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/cdrom/mcd.c linux/drivers/cdrom/mcd.c --- v2.4.0-test8/linux/drivers/cdrom/mcd.c Thu Jul 27 17:38:00 2000 +++ linux/drivers/cdrom/mcd.c Sun Sep 17 09:45:06 2000 @@ -275,7 +275,7 @@ static int statusCmd(void) { - int st, retry; + int st = -1, retry; for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++) { @@ -297,7 +297,7 @@ static int mcdPlay(struct mcd_Play_msf *arg) { - int retry, st; + int retry, st = -1; for (retry = 0; retry < MCD_RETRY_ATTEMPTS; retry++) { diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/Config.in linux/drivers/char/Config.in --- v2.4.0-test8/linux/drivers/char/Config.in Wed Aug 23 18:36:36 2000 +++ linux/drivers/char/Config.in Sun Sep 17 09:48:04 2000 @@ -90,8 +90,8 @@ dep_tristate ' ATIXL busmouse support' CONFIG_ATIXL_BUSMOUSE $CONFIG_BUSMOUSE dep_tristate ' Logitech busmouse support' CONFIG_LOGIBUSMOUSE $CONFIG_BUSMOUSE dep_tristate ' Microsoft busmouse support' CONFIG_MS_BUSMOUSE $CONFIG_BUSMOUSE - if [ "$CONFIG_ADB" = "y" ]; then - dep_tristate ' Apple Desktop Bus mouse support' CONFIG_ADBMOUSE $CONFIG_BUSMOUSE + if [ "$CONFIG_ADB" = "y" -a "$CONFIG_ADB_KEYBOARD" = "y" ]; then + dep_tristate ' Apple Desktop Bus mouse support (old driver)' CONFIG_ADBMOUSE $CONFIG_BUSMOUSE fi fi diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/drm/drmP.h linux/drivers/char/drm/drmP.h --- v2.4.0-test8/linux/drivers/char/drm/drmP.h Fri Sep 8 13:27:11 2000 +++ linux/drivers/char/drm/drmP.h Fri Sep 15 19:04:43 2000 @@ -33,6 +33,12 @@ #define _DRM_P_H_ #ifdef __KERNEL__ +#ifdef __alpha__ +/* add include of current.h so that "current" is defined + * before static inline funcs in wait.h. Doing this so we + * can build the DRM (part of PI DRI). 4/21/2000 S + B */ +#include +#endif /* __alpha__ */ #include #include #include @@ -47,6 +53,9 @@ #include #include /* For (un)lock_kernel */ #include +#ifdef __alpha__ +#include /* For pte_wrprotect */ +#endif #include #include #include @@ -147,6 +156,71 @@ #ifndef __HAVE_ARCH_CMPXCHG /* Include this here so that driver can be used with older kernels. */ +#if defined(__alpha__) +static __inline__ unsigned long +__cmpxchg_u32(volatile int *m, int old, int new) +{ + unsigned long prev, cmp; + + __asm__ __volatile__( + "1: ldl_l %0,%2\n" + " cmpeq %0,%3,%1\n" + " beq %1,2f\n" + " mov %4,%1\n" + " stl_c %1,%2\n" + " beq %1,3f\n" + "2: mb\n" + ".subsection 2\n" + "3: br 1b\n" + ".previous" + : "=&r"(prev), "=&r"(cmp), "=m"(*m) + : "r"((long) old), "r"(new), "m"(*m)); + + return prev; +} + +static __inline__ unsigned long +__cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new) +{ + unsigned long prev, cmp; + + __asm__ __volatile__( + "1: ldq_l %0,%2\n" + " cmpeq %0,%3,%1\n" + " beq %1,2f\n" + " mov %4,%1\n" + " stq_c %1,%2\n" + " beq %1,3f\n" + "2: mb\n" + ".subsection 2\n" + "3: br 1b\n" + ".previous" + : "=&r"(prev), "=&r"(cmp), "=m"(*m) + : "r"((long) old), "r"(new), "m"(*m)); + + return prev; +} + +static __inline__ unsigned long +__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) +{ + switch (size) { + case 4: + return __cmpxchg_u32(ptr, old, new); + case 8: + return __cmpxchg_u64(ptr, old, new); + } + return old; +} +#define cmpxchg(ptr,o,n) \ + ({ \ + __typeof__(*(ptr)) _o_ = (o); \ + __typeof__(*(ptr)) _n_ = (n); \ + (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \ + (unsigned long)_n_, sizeof(*(ptr))); \ + }) + +#elif __i386__ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) { @@ -177,6 +251,7 @@ #define cmpxchg(ptr,o,n) \ ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \ (unsigned long)(n),sizeof(*(ptr)))) +#endif /* i386 & alpha */ #endif /* Macros to make printk easier */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/drm/gamma_drv.c linux/drivers/char/drm/gamma_drv.c --- v2.4.0-test8/linux/drivers/char/drm/gamma_drv.c Fri Sep 8 13:27:11 2000 +++ linux/drivers/char/drm/gamma_drv.c Fri Sep 15 14:24:55 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -23,7 +23,7 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * * Authors: * Rickard E. (Rik) Faith * @@ -42,7 +42,7 @@ #define GAMMA_NAME "gamma" #define GAMMA_DESC "3dlabs GMX 2000" -#define GAMMA_DATE "20000719" +#define GAMMA_DATE "20000910" #define GAMMA_MAJOR 1 #define GAMMA_MINOR 0 #define GAMMA_PATCHLEVEL 0 @@ -87,7 +87,7 @@ [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { drm_mapbufs, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { drm_freebufs, 1, 0 }, - + [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { drm_addctx, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { drm_rmctx, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { drm_modctx, 1, 1 }, @@ -120,7 +120,7 @@ * passed via the boot-loader (e.g., LILO). It calls the insmod option * routine, drm_parse_options. */ - + static int __init gamma_options(char *str) { @@ -134,7 +134,7 @@ static int gamma_setup(drm_device_t *dev) { int i; - + atomic_set(&dev->ioctl_count, 0); atomic_set(&dev->vma_count, 0); dev->buf_use = 0; @@ -179,22 +179,22 @@ #endif dev->ctx_start = 0; dev->lck_start = 0; - + dev->buf_rp = dev->buf; dev->buf_wp = dev->buf; dev->buf_end = dev->buf + DRM_BSZ; dev->buf_async = NULL; init_waitqueue_head(&dev->buf_readers); init_waitqueue_head(&dev->buf_writers); - + DRM_DEBUG("\n"); - + /* The kernel's context could be created here, but is now created in drm_dma_enqueue. This is more resource-efficient for hardware that does not do DMA, but may mean that drm_select_queue fails between the time the interrupt is initialized and the time the queues are initialized. */ - + return 0; } @@ -209,15 +209,15 @@ DRM_DEBUG("\n"); if (dev->irq) gamma_irq_uninstall(dev); - + down(&dev->struct_sem); del_timer(&dev->timer); - + if (dev->devname) { drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); dev->devname = NULL; } - + if (dev->unique) { drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); dev->unique = NULL; @@ -231,7 +231,7 @@ } dev->magiclist[i].head = dev->magiclist[i].tail = NULL; } - + /* Clear vma list (only built for debugging) */ if (dev->vmalist) { for (vma = dev->vmalist; vma; vma = vma_next) { @@ -240,7 +240,7 @@ } dev->vmalist = NULL; } - + /* Clear map area and mtrr information */ if (dev->maplist) { for (i = 0; i < dev->map_count; i++) { @@ -278,7 +278,7 @@ dev->maplist = NULL; dev->map_count = 0; } - + if (dev->queuelist) { for (i = 0; i < dev->queue_count; i++) { drm_waitlist_destroy(&dev->queuelist[i]->waitlist); @@ -304,7 +304,7 @@ wake_up_interruptible(&dev->lock.lock_queue); } up(&dev->struct_sem); - + return 0; } @@ -349,7 +349,7 @@ memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); - + #ifdef MODULE drm_parse_options(gamma); #endif @@ -374,7 +374,7 @@ GAMMA_DATE, gamma_misc.minor, devices); - + return 0; } @@ -385,7 +385,7 @@ drm_device_t *dev = &gamma_device; DRM_DEBUG("\n"); - + drm_proc_cleanup(); if (misc_deregister(&gamma_misc)) { DRM_ERROR("Cannot unload module\n"); @@ -438,7 +438,7 @@ { drm_device_t *dev = &gamma_device; int retcode = 0; - + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_open_helper(inode, filp, dev))) { #if LINUX_VERSION_CODE < 0x020333 @@ -505,7 +505,7 @@ atomic_inc(&dev->ioctl_count); atomic_inc(&dev->total_ioctl); ++priv->ioctl_count; - + DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", current->pid, cmd, nr, dev->device, priv->authenticated); @@ -525,7 +525,7 @@ retcode = (func)(inode, filp, cmd, arg); } } - + atomic_dec(&dev->ioctl_count); return retcode; } @@ -540,7 +540,7 @@ if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) return -EFAULT; - + if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", current->pid, lock.context); @@ -565,7 +565,7 @@ atomic_inc(&dev->histo.lhld[drm_histogram_slot(get_cycles() - dev->lck_start)]); #endif - + unblock_all_signals(); return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/drm/i810_drv.c linux/drivers/char/drm/i810_drv.c --- v2.4.0-test8/linux/drivers/char/drm/i810_drv.c Fri Sep 8 13:27:11 2000 +++ linux/drivers/char/drm/i810_drv.c Fri Sep 15 14:24:55 2000 @@ -1,6 +1,6 @@ /* i810_drv.c -- I810 driver -*- linux-c -*- * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com - * + * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -35,7 +35,7 @@ #define I810_NAME "i810" #define I810_DESC "Intel I810" -#define I810_DATE "20000719" +#define I810_DATE "20000910" #define I810_MAJOR 1 #define I810_MINOR 1 #define I810_PATCHLEVEL 0 @@ -143,7 +143,7 @@ static int i810_setup(drm_device_t *dev) { int i; - + atomic_set(&dev->ioctl_count, 0); atomic_set(&dev->vma_count, 0); dev->buf_use = 0; @@ -188,22 +188,22 @@ #endif dev->ctx_start = 0; dev->lck_start = 0; - + dev->buf_rp = dev->buf; dev->buf_wp = dev->buf; dev->buf_end = dev->buf + DRM_BSZ; dev->buf_async = NULL; init_waitqueue_head(&dev->buf_readers); init_waitqueue_head(&dev->buf_writers); - + DRM_DEBUG("\n"); - + /* The kernel's context could be created here, but is now created in drm_dma_enqueue. This is more resource-efficient for hardware that does not do DMA, but may mean that drm_select_queue fails between the time the interrupt is initialized and the time the queues are initialized. */ - + return 0; } @@ -218,15 +218,15 @@ DRM_DEBUG("\n"); if (dev->irq) i810_irq_uninstall(dev); - + down(&dev->struct_sem); del_timer(&dev->timer); - + if (dev->devname) { drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); dev->devname = NULL; } - + if (dev->unique) { drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); dev->unique = NULL; @@ -244,7 +244,7 @@ if (dev->agp) { drm_agp_mem_t *entry; drm_agp_mem_t *nexte; - + /* Remove AGP resources, but leave dev->agp intact until r128_cleanup is called. */ for (entry = dev->agp->memory; entry; entry = nexte) { @@ -254,10 +254,10 @@ drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); } dev->agp->memory = NULL; - + if (dev->agp->acquired && drm_agp.release) (*drm_agp.release)(); - + dev->agp->acquired = 0; dev->agp->enabled = 0; } @@ -269,7 +269,7 @@ } dev->vmalist = NULL; } - + /* Clear map area and mtrr information */ if (dev->maplist) { for (i = 0; i < dev->map_count; i++) { @@ -305,7 +305,7 @@ dev->maplist = NULL; dev->map_count = 0; } - + if (dev->queuelist) { for (i = 0; i < dev->queue_count; i++) { drm_waitlist_destroy(&dev->queuelist[i]->waitlist); @@ -331,7 +331,7 @@ wake_up_interruptible(&dev->lock.lock_queue); } up(&dev->struct_sem); - + return 0; } @@ -348,7 +348,7 @@ memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); - + #ifdef MODULE drm_parse_options(i810); #endif @@ -402,7 +402,7 @@ drm_device_t *dev = &i810_device; DRM_DEBUG("\n"); - + drm_proc_cleanup(); if (misc_deregister(&i810_misc)) { DRM_ERROR("Cannot unload module\n"); @@ -461,7 +461,7 @@ { drm_device_t *dev = &i810_device; int retcode = 0; - + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_open_helper(inode, filp, dev))) { #if LINUX_VERSION_CODE < 0x020333 @@ -498,7 +498,7 @@ drm_lock_free(dev, &dev->lock.hw_lock->lock, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); - + /* FIXME: may require heavy-handed reset of hardware at this point, possibly processed via a callback to the X @@ -519,7 +519,7 @@ dev->lock.lock_time = jiffies; atomic_inc(&dev->total_locks); break; /* Got lock */ - } + } /* Contention */ atomic_inc(&dev->total_sleeps); current->state = TASK_INTERRUPTIBLE; @@ -545,7 +545,7 @@ if (priv->next) priv->next->prev = priv->prev; else dev->file_last = priv->prev; up(&dev->struct_sem); - + drm_free(priv, sizeof(*priv), DRM_MEM_FILES); #if LINUX_VERSION_CODE < 0x020333 MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */ @@ -585,7 +585,7 @@ atomic_inc(&dev->ioctl_count); atomic_inc(&dev->total_ioctl); ++priv->ioctl_count; - + DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", current->pid, cmd, nr, dev->device, priv->authenticated); @@ -605,7 +605,7 @@ retcode = (func)(inode, filp, cmd, arg); } } - + atomic_dec(&dev->ioctl_count); return retcode; } @@ -619,7 +619,7 @@ if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) return -EFAULT; - + if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", current->pid, lock.context); @@ -643,7 +643,7 @@ atomic_inc(&dev->histo.lhld[drm_histogram_slot(get_cycles() - dev->lck_start)]); #endif - + unblock_all_signals(); return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/drm/mga_dma.c linux/drivers/char/drm/mga_dma.c --- v2.4.0-test8/linux/drivers/char/drm/mga_dma.c Fri Sep 8 13:27:11 2000 +++ linux/drivers/char/drm/mga_dma.c Fri Sep 15 14:24:55 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -51,7 +51,7 @@ static unsigned long mga_alloc_page(drm_device_t *dev) { unsigned long address; - + DRM_DEBUG("%s\n", __FUNCTION__); address = __get_free_page(GFP_KERNEL); if(address == 0UL) { @@ -59,7 +59,7 @@ } atomic_inc(&virt_to_page(address)->count); set_bit(PG_locked, &virt_to_page(address)->flags); - + return address; } @@ -82,23 +82,6 @@ return; } -#ifdef __i386__ -void mga_flush_write_combine(void) -{ - int xchangeDummy; - DRM_DEBUG("%s\n", __FUNCTION__); - - __asm__ volatile(" push %%eax ; xchg %%eax, %0 ; pop %%eax" : : "m" (xchangeDummy)); - __asm__ volatile(" push %%eax ; push %%ebx ; push %%ecx ; push %%edx ;" - " movl $0,%%eax ; cpuid ; pop %%edx ; pop %%ecx ; pop %%ebx ;" - " pop %%eax" : /* no outputs */ : /* no inputs */ ); -} -#else -void mga_flush_write_combine(void) -{ -} -#endif - /* These are two age tags that will never be sent to * the hardware */ #define MGA_BUF_USED 0xffffffff @@ -119,7 +102,7 @@ if(dev_priv->head == NULL) return -ENOMEM; memset(dev_priv->head, 0, sizeof(drm_mga_freelist_t)); dev_priv->head->age = MGA_BUF_USED; - + for (i = 0; i < dma->buf_count; i++) { buf = dma->buflist[ i ]; buf_priv = buf->dev_private; @@ -139,7 +122,7 @@ buf_priv->dispatched = 0; dev_priv->head->next = item; } - + return 0; } @@ -157,7 +140,7 @@ item = item->next; drm_free(prev, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER); } - + dev_priv->head = dev_priv->tail = NULL; } @@ -173,15 +156,15 @@ DRM_DEBUG("%s\n", __FUNCTION__); end = jiffies + (HZ*3); while(1) { - if(!test_and_set_bit(MGA_IN_DISPATCH, + if(!test_and_set_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status)) { break; } if((signed)(end - jiffies) <= 0) { - DRM_ERROR("irqs: %d wanted %d\n", - atomic_read(&dev->total_irq), + DRM_ERROR("irqs: %d wanted %d\n", + atomic_read(&dev->total_irq), atomic_read(&dma->total_lost)); - DRM_ERROR("lockup\n"); + DRM_ERROR("lockup\n"); goto out_nolock; } for (i = 0 ; i < 2000 ; i++) mga_delay(); @@ -190,13 +173,13 @@ DRM_DEBUG("quiescent status : %x\n", MGA_READ(MGAREG_STATUS)); while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) { if((signed)(end - jiffies) <= 0) { - DRM_ERROR("irqs: %d wanted %d\n", - atomic_read(&dev->total_irq), + DRM_ERROR("irqs: %d wanted %d\n", + atomic_read(&dev->total_irq), atomic_read(&dma->total_lost)); - DRM_ERROR("lockup\n"); + DRM_ERROR("lockup\n"); goto out_status; } - for (i = 0 ; i < 2000 ; i++) mga_delay(); + for (i = 0 ; i < 2000 ; i++) mga_delay(); } sarea_priv->dirty |= MGA_DMA_FLUSH; @@ -220,13 +203,13 @@ } /* Least recently used : - * These operations are not atomic b/c they are protected by the + * These operations are not atomic b/c they are protected by the * hardware lock */ drm_buf_t *mga_freelist_get(drm_device_t *dev) { DECLARE_WAITQUEUE(entry, current); - drm_mga_private_t *dev_priv = + drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; drm_mga_freelist_t *prev; drm_mga_freelist_t *next; @@ -234,17 +217,17 @@ DRM_DEBUG("%s : tail->age : %d last_prim_age : %d\n", __FUNCTION__, dev_priv->tail->age, dev_priv->last_prim_age); - + if(failed >= 1000 && dev_priv->tail->age >= dev_priv->last_prim_age) { - DRM_DEBUG("I'm waiting on the freelist!!! %d\n", + DRM_DEBUG("I'm waiting on the freelist!!! %d\n", dev_priv->last_prim_age); set_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status); current->state = TASK_INTERRUPTIBLE; add_wait_queue(&dev_priv->buf_queue, &entry); for (;;) { mga_dma_schedule(dev, 0); - if(!test_bit(MGA_IN_GETBUF, - &dev_priv->dispatch_status)) + if(!test_bit(MGA_IN_GETBUF, + &dev_priv->dispatch_status)) break; atomic_inc(&dev->total_sleeps); schedule(); @@ -257,7 +240,7 @@ current->state = TASK_RUNNING; remove_wait_queue(&dev_priv->buf_queue, &entry); } - + if(dev_priv->tail->age < dev_priv->last_prim_age) { prev = dev_priv->tail->prev; next = dev_priv->tail; @@ -276,7 +259,7 @@ int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf) { - drm_mga_private_t *dev_priv = + drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; drm_mga_buf_priv_t *buf_priv = buf->dev_private; drm_mga_freelist_t *prev; @@ -307,7 +290,7 @@ next->prev = head; next->next = prev; } - + return 0; } @@ -319,41 +302,41 @@ int offset = init->reserved_map_agpstart; DRM_DEBUG("%s\n", __FUNCTION__); - dev_priv->primary_size = ((init->primary_size + PAGE_SIZE - 1) / + dev_priv->primary_size = ((init->primary_size + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE; size_of_buf = dev_priv->primary_size / MGA_NUM_PRIM_BUFS; dev_priv->warp_ucode_size = init->warp_ucode_size; - dev_priv->prim_bufs = drm_alloc(sizeof(drm_mga_prim_buf_t *) * - (MGA_NUM_PRIM_BUFS + 1), + dev_priv->prim_bufs = drm_alloc(sizeof(drm_mga_prim_buf_t *) * + (MGA_NUM_PRIM_BUFS + 1), DRM_MEM_DRIVER); if(dev_priv->prim_bufs == NULL) { DRM_ERROR("Unable to allocate memory for prim_buf\n"); return -ENOMEM; } - memset(dev_priv->prim_bufs, + memset(dev_priv->prim_bufs, 0, sizeof(drm_mga_prim_buf_t *) * (MGA_NUM_PRIM_BUFS + 1)); - + temp = init->warp_ucode_size + dev_priv->primary_size; temp = ((temp + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE; - - dev_priv->ioremap = drm_ioremap(dev->agp->base + offset, + + dev_priv->ioremap = drm_ioremap(dev->agp->base + offset, temp); if(dev_priv->ioremap == NULL) { DRM_DEBUG("Ioremap failed\n"); return -ENOMEM; } init_waitqueue_head(&dev_priv->wait_queue); - + for(i = 0; i < MGA_NUM_PRIM_BUFS; i++) { - prim_buffer = drm_alloc(sizeof(drm_mga_prim_buf_t), + prim_buffer = drm_alloc(sizeof(drm_mga_prim_buf_t), DRM_MEM_DRIVER); if(prim_buffer == NULL) return -ENOMEM; memset(prim_buffer, 0, sizeof(drm_mga_prim_buf_t)); prim_buffer->phys_head = offset + dev->agp->base; - prim_buffer->current_dma_ptr = - prim_buffer->head = - (u32 *) (dev_priv->ioremap + - offset - + prim_buffer->current_dma_ptr = + prim_buffer->head = + (u32 *) (dev_priv->ioremap + + offset - init->reserved_map_agpstart); prim_buffer->num_dwords = 0; prim_buffer->max_dwords = size_of_buf / sizeof(u32); @@ -365,11 +348,11 @@ dev_priv->prim_bufs[i] = prim_buffer; } dev_priv->current_prim_idx = 0; - dev_priv->next_prim = - dev_priv->last_prim = + dev_priv->next_prim = + dev_priv->last_prim = dev_priv->current_prim = dev_priv->prim_bufs[0]; - dev_priv->next_prim_age = 2; + dev_priv->next_prim_age = 2; dev_priv->last_prim_age = 1; set_bit(MGA_BUF_IN_USE, &dev_priv->current_prim->buffer_status); return 0; @@ -388,11 +371,11 @@ DRM_DEBUG("%s\n", __FUNCTION__); dev_priv->last_prim = prim; - + /* We never check for overflow, b/c there is always room */ PRIMPTR(prim); if(num_dwords <= 0) { - DRM_DEBUG("num_dwords == 0 when dispatched\n"); + DRM_ERROR("num_dwords == 0 when dispatched\n"); goto out_prim_wait; } PRIMOUTREG( MGAREG_DMAPAD, 0); @@ -403,17 +386,17 @@ end = jiffies + (HZ*3); if(sarea_priv->dirty & MGA_DMA_FLUSH) { - DRM_DEBUG("Dma top flush\n"); + DRM_DEBUG("Dma top flush\n"); while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) { if((signed)(end - jiffies) <= 0) { - DRM_ERROR("irqs: %d wanted %d\n", - atomic_read(&dev->total_irq), + DRM_ERROR("irqs: %d wanted %d\n", + atomic_read(&dev->total_irq), atomic_read(&dma->total_lost)); DRM_ERROR("lockup in fire primary " "(Dma Top Flush)\n"); goto out_prim_wait; } - + for (i = 0 ; i < 4096 ; i++) mga_delay(); } sarea_priv->dirty &= ~(MGA_DMA_FLUSH); @@ -421,14 +404,14 @@ DRM_DEBUG("Status wait\n"); while((MGA_READ(MGAREG_STATUS) & 0x00020001) != 0x00020000) { if((signed)(end - jiffies) <= 0) { - DRM_ERROR("irqs: %d wanted %d\n", - atomic_read(&dev->total_irq), + DRM_ERROR("irqs: %d wanted %d\n", + atomic_read(&dev->total_irq), atomic_read(&dma->total_lost)); DRM_ERROR("lockup in fire primary " "(Status Wait)\n"); goto out_prim_wait; } - + for (i = 0 ; i < 4096 ; i++) mga_delay(); } } @@ -439,9 +422,9 @@ MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp); prim->num_dwords = 0; sarea_priv->last_enqueue = prim->prim_age; - + next_idx = prim->idx + 1; - if(next_idx >= MGA_NUM_PRIM_BUFS) + if(next_idx >= MGA_NUM_PRIM_BUFS) next_idx = 0; dev_priv->next_prim = dev_priv->prim_bufs[next_idx]; @@ -464,28 +447,28 @@ drm_device_dma_t *dma = dev->dma; int next_prim_idx; int ret = 0; - + /* This needs to reset the primary buffer if available, * we should collect stats on how many times it bites * it's tail */ DRM_DEBUG("%s\n", __FUNCTION__); - + next_prim_idx = dev_priv->current_prim_idx + 1; if(next_prim_idx >= MGA_NUM_PRIM_BUFS) next_prim_idx = 0; prim_buffer = dev_priv->prim_bufs[next_prim_idx]; set_bit(MGA_IN_WAIT, &dev_priv->dispatch_status); - + /* In use is cleared in interrupt handler */ - + if(test_and_set_bit(MGA_BUF_IN_USE, &prim_buffer->buffer_status)) { add_wait_queue(&dev_priv->wait_queue, &entry); current->state = TASK_INTERRUPTIBLE; for (;;) { mga_dma_schedule(dev, 0); - if(!test_and_set_bit(MGA_BUF_IN_USE, - &prim_buffer->buffer_status)) + if(!test_and_set_bit(MGA_BUF_IN_USE, + &prim_buffer->buffer_status)) break; atomic_inc(&dev->total_sleeps); atomic_inc(&dma->total_missed_sched); @@ -547,9 +530,9 @@ atomic_inc(&dma->total_prio); return 1; } - + if(atomic_read(&dev_priv->pending_bufs) <= MGA_NUM_PRIM_BUFS - 1) { - if(test_bit(MGA_BUF_SWAP_PENDING, + if(test_bit(MGA_BUF_SWAP_PENDING, &dev_priv->next_prim->buffer_status)) { atomic_inc(&dma->total_dmas); return 1; @@ -585,16 +568,16 @@ retval = -EBUSY; goto sch_out_wakeup; } - + DRM_DEBUG("%s\n", __FUNCTION__); - if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) || + if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) || test_bit(MGA_IN_WAIT, &dev_priv->dispatch_status) || test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) { locked = 1; } - - if (!locked && + + if (!locked && !drm_lock_take(&dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) { atomic_inc(&dma->total_missed_lock); clear_bit(0, &dev->dma_flag); @@ -608,7 +591,7 @@ /* Fire dma buffer */ if(mga_decide_to_fire(dev)) { DRM_DEBUG("idx :%d\n", dev_priv->next_prim->idx); - clear_bit(MGA_BUF_FORCE_FIRE, + clear_bit(MGA_BUF_FORCE_FIRE, &dev_priv->next_prim->buffer_status); if(dev_priv->current_prim == dev_priv->next_prim) { /* Schedule overflow for a later time */ @@ -622,7 +605,7 @@ } else { DRM_DEBUG("I can't get the dispatch lock\n"); } - + if (!locked) { if (drm_lock_free(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) { @@ -644,8 +627,8 @@ DRM_DEBUG("Waking up buf queue\n"); wake_up_interruptible(&dev_priv->buf_queue); } else if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) { - DRM_DEBUG("Not waking buf_queue on %d %d\n", - atomic_read(&dev->total_irq), + DRM_DEBUG("Not waking buf_queue on %d %d\n", + atomic_read(&dev->total_irq), dev_priv->last_prim_age); } @@ -666,7 +649,7 @@ last_prim_buffer = dev_priv->last_prim; last_prim_buffer->num_dwords = 0; last_prim_buffer->sec_used = 0; - dev_priv->sarea_priv->last_dispatch = + dev_priv->sarea_priv->last_dispatch = dev_priv->last_prim_age = last_prim_buffer->prim_age; clear_bit(MGA_BUF_IN_USE, &last_prim_buffer->buffer_status); wake_up_interruptible(&dev_priv->wait_queue); @@ -688,12 +671,12 @@ DRM_DEBUG("%s\n", __FUNCTION__); if(dev->dev_private) { - drm_mga_private_t *dev_priv = + drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; - + if(dev_priv->ioremap) { - int temp = (dev_priv->warp_ucode_size + - dev_priv->primary_size + + int temp = (dev_priv->warp_ucode_size + + dev_priv->primary_size + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE; drm_ioremapfree((void *) dev_priv->ioremap, temp); @@ -714,7 +697,7 @@ } } drm_free(dev_priv->prim_bufs, sizeof(void *) * - (MGA_NUM_PRIM_BUFS + 1), + (MGA_NUM_PRIM_BUFS + 1), DRM_MEM_DRIVER); } if(dev_priv->head != NULL) { @@ -722,7 +705,7 @@ } - drm_free(dev->dev_private, sizeof(drm_mga_private_t), + drm_free(dev->dev_private, sizeof(drm_mga_private_t), DRM_MEM_DRIVER); dev->dev_private = NULL; } @@ -749,12 +732,12 @@ DRM_DEBUG("reserved_map or buffer_map are invalid\n"); return -EINVAL; } - + dev_priv->reserved_map_idx = init->reserved_map_idx; dev_priv->buffer_map_idx = init->buffer_map_idx; sarea_map = dev->maplist[0]; - dev_priv->sarea_priv = (drm_mga_sarea_t *) - ((u8 *)sarea_map->handle + + dev_priv->sarea_priv = (drm_mga_sarea_t *) + ((u8 *)sarea_map->handle + init->sarea_priv_offset); /* Scale primary size to the next page */ @@ -772,20 +755,21 @@ init_waitqueue_head(&dev_priv->flush_queue); init_waitqueue_head(&dev_priv->buf_queue); dev_priv->WarpPipe = 0xff000000; + dev_priv->vertexsize = 0; DRM_DEBUG("chipset: %d ucode_size: %d backOffset: %x depthOffset: %x\n", - dev_priv->chipset, dev_priv->warp_ucode_size, + dev_priv->chipset, dev_priv->warp_ucode_size, dev_priv->backOffset, dev_priv->depthOffset); DRM_DEBUG("cpp: %d sgram: %d stride: %d maccess: %x\n", - dev_priv->cpp, dev_priv->sgram, dev_priv->stride, + dev_priv->cpp, dev_priv->sgram, dev_priv->stride, dev_priv->mAccess); - - memcpy(&dev_priv->WarpIndex, &init->WarpIndex, + + memcpy(&dev_priv->WarpIndex, &init->WarpIndex, sizeof(drm_mga_warp_index_t) * MGA_MAX_WARP_PIPES); - for (i = 0 ; i < MGA_MAX_WARP_PIPES ; i++) + for (i = 0 ; i < MGA_MAX_WARP_PIPES ; i++) DRM_DEBUG("warp pipe %d: installed: %d phys: %lx size: %x\n", - i, + i, dev_priv->WarpIndex[i].installed, dev_priv->WarpIndex[i].phys_addr, dev_priv->WarpIndex[i].size); @@ -802,7 +786,7 @@ return -ENOMEM; } - dev_priv->status_page = + dev_priv->status_page = ioremap_nocache(virt_to_bus((void *)dev_priv->real_status_page), PAGE_SIZE); @@ -813,15 +797,15 @@ } /* Write status page when secend or softrap occurs */ - MGA_WRITE(MGAREG_PRIMPTR, + MGA_WRITE(MGAREG_PRIMPTR, virt_to_bus((void *)dev_priv->real_status_page) | 0x00000003); - + /* Private is now filled in, initialize the hardware */ { PRIMLOCALS; PRIMGETPTR( dev_priv ); - + PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DWGSYNC, 0x0100); @@ -829,13 +813,13 @@ /* Poll for the first buffer to insure that * the status register will be correct */ - + mga_flush_write_combine(); MGA_WRITE(MGAREG_PRIMADDRESS, phys_head | TT_GENERAL); - MGA_WRITE(MGAREG_PRIMEND, ((phys_head + num_dwords * 4) | + MGA_WRITE(MGAREG_PRIMEND, ((phys_head + num_dwords * 4) | PDEA_pagpxfer_enable)); - + while(MGA_READ(MGAREG_DWGSYNC) != 0x0100) ; } @@ -853,12 +837,12 @@ drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; drm_mga_init_t init; - + DRM_DEBUG("%s\n", __FUNCTION__); if (copy_from_user(&init, (drm_mga_init_t *)arg, sizeof(init))) return -EFAULT; - + switch(init.func) { case MGA_INIT_DMA: return mga_dma_initialize(dev, &init); @@ -874,7 +858,7 @@ int retcode; if (!irq) return -EINVAL; - + down(&dev->struct_sem); if (dev->irq) { up(&dev->struct_sem); @@ -882,7 +866,7 @@ } dev->irq = irq; up(&dev->struct_sem); - + DRM_DEBUG("install irq handler %d\n", irq); dev->context_flag = 0; @@ -923,7 +907,7 @@ irq = dev->irq; dev->irq = 0; up(&dev->struct_sem); - + if (!irq) return -EINVAL; DRM_DEBUG("remove irq handler %d\n", irq); MGA_WRITE(MGAREG_ICLEAR, 0x00000001); @@ -938,7 +922,7 @@ drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; drm_control_t ctl; - + if (copy_from_user(&ctl, (drm_control_t *)arg, sizeof(ctl))) return -EFAULT; @@ -965,21 +949,21 @@ if(dev_priv == NULL) { return 0; } - + if(dev_priv->next_prim->num_dwords != 0) { current->state = TASK_INTERRUPTIBLE; add_wait_queue(&dev_priv->flush_queue, &entry); set_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status); mga_dma_schedule(dev, 0); for (;;) { - if (!test_bit(MGA_IN_FLUSH, - &dev_priv->dispatch_status)) + if (!test_bit(MGA_IN_FLUSH, + &dev_priv->dispatch_status)) break; atomic_inc(&dev->total_sleeps); schedule(); if (signal_pending(current)) { ret = -EINTR; /* Can't restart */ - clear_bit(MGA_IN_FLUSH, + clear_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status); break; } @@ -1007,11 +991,11 @@ drm_buf_t *buf = dma->buflist[ i ]; drm_mga_buf_priv_t *buf_priv = buf->dev_private; - /* Only buffers that need to get reclaimed ever - * get set to free + /* Only buffers that need to get reclaimed ever + * get set to free */ if (buf->pid == pid && buf_priv) { - if(buf_priv->my_freelist->age == MGA_BUF_USED) + if(buf_priv->my_freelist->age == MGA_BUF_USED) buf_priv->my_freelist->age = MGA_BUF_FREE; } } @@ -1035,7 +1019,7 @@ current->pid, lock.context); return -EINVAL; } - + DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", lock.context, current->pid, dev->lock.hw_lock->lock, lock.flags); @@ -1043,7 +1027,7 @@ if (lock.context < 0) { return -EINVAL; } - + /* Only one queue: */ @@ -1062,7 +1046,7 @@ atomic_inc(&dev->total_locks); break; /* Got lock */ } - + /* Contention */ atomic_inc(&dev->total_sleeps); current->state = TASK_INTERRUPTIBLE; @@ -1075,7 +1059,7 @@ current->state = TASK_RUNNING; remove_wait_queue(&dev->lock.lock_queue, &entry); } - + if (!ret) { sigemptyset(&dev->sigmask); sigaddset(&dev->sigmask, SIGSTOP); @@ -1092,12 +1076,12 @@ mga_dma_quiescent(dev); } } - + DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); return ret; } - -int mga_flush_ioctl(struct inode *inode, struct file *filp, + +int mga_flush_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/drm/mga_drm.h linux/drivers/char/drm/mga_drm.h --- v2.4.0-test8/linux/drivers/char/drm/mga_drm.h Thu Jul 27 17:38:00 2000 +++ linux/drivers/char/drm/mga_drm.h Fri Sep 15 14:24:55 2000 @@ -73,17 +73,19 @@ /* 3d state excluding texture units: */ -#define MGA_CTXREG_DSTORG 0 /* validated */ -#define MGA_CTXREG_MACCESS 1 -#define MGA_CTXREG_PLNWT 2 -#define MGA_CTXREG_DWGCTL 3 -#define MGA_CTXREG_ALPHACTRL 4 -#define MGA_CTXREG_FOGCOLOR 5 -#define MGA_CTXREG_WFLAG 6 -#define MGA_CTXREG_TDUAL0 7 -#define MGA_CTXREG_TDUAL1 8 -#define MGA_CTXREG_FCOL 9 -#define MGA_CTX_SETUP_SIZE 10 +#define MGA_CTXREG_DSTORG 0 /* validated */ +#define MGA_CTXREG_MACCESS 1 +#define MGA_CTXREG_PLNWT 2 +#define MGA_CTXREG_DWGCTL 3 +#define MGA_CTXREG_ALPHACTRL 4 +#define MGA_CTXREG_FOGCOLOR 5 +#define MGA_CTXREG_WFLAG 6 +#define MGA_CTXREG_TDUAL0 7 +#define MGA_CTXREG_TDUAL1 8 +#define MGA_CTXREG_FCOL 9 +#define MGA_CTXREG_STENCIL 10 +#define MGA_CTXREG_STENCILCTL 11 +#define MGA_CTX_SETUP_SIZE 12 /* 2d state */ @@ -233,6 +235,7 @@ /* Mechanism to validate card state. */ int ctxOwner; + int vertexsize; } drm_mga_sarea_t; /* Device specific ioctls: @@ -241,6 +244,8 @@ unsigned int clear_color; unsigned int clear_depth; unsigned int flags; + unsigned int clear_depth_mask; + unsigned int clear_color_mask; } drm_mga_clear_t; typedef struct _drm_mga_swap { diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/drm/mga_drv.c linux/drivers/char/drm/mga_drv.c --- v2.4.0-test8/linux/drivers/char/drm/mga_drv.c Fri Sep 8 13:27:11 2000 +++ linux/drivers/char/drm/mga_drv.c Fri Sep 15 14:24:55 2000 @@ -1,6 +1,6 @@ /* mga_drv.c -- Matrox g200/g400 driver -*- linux-c -*- * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com - * + * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -35,9 +35,9 @@ #include "mga_drv.h" #define MGA_NAME "mga" -#define MGA_DESC "Matrox g200/g400" -#define MGA_DATE "20000719" -#define MGA_MAJOR 1 +#define MGA_DESC "Matrox G200/G400" +#define MGA_DATE "20000910" +#define MGA_MAJOR 2 #define MGA_MINOR 0 #define MGA_PATCHLEVEL 0 @@ -123,7 +123,7 @@ #endif MODULE_AUTHOR("VA Linux Systems, Inc."); -MODULE_DESCRIPTION("Matrox g200/g400"); +MODULE_DESCRIPTION("Matrox G200/G400"); MODULE_PARM(mga, "s"); #ifndef MODULE @@ -144,7 +144,7 @@ static int mga_setup(drm_device_t *dev) { int i; - + atomic_set(&dev->ioctl_count, 0); atomic_set(&dev->vma_count, 0); dev->buf_use = 0; @@ -187,22 +187,22 @@ dev->ctx_start = 0; dev->lck_start = 0; - + dev->buf_rp = dev->buf; dev->buf_wp = dev->buf; dev->buf_end = dev->buf + DRM_BSZ; dev->buf_async = NULL; init_waitqueue_head(&dev->buf_readers); init_waitqueue_head(&dev->buf_writers); - + DRM_DEBUG("\n"); - + /* The kernel's context could be created here, but is now created in drm_dma_enqueue. This is more resource-efficient for hardware that does not do DMA, but may mean that drm_select_queue fails between the time the interrupt is initialized and the time the queues are initialized. */ - + return 0; } @@ -217,15 +217,15 @@ DRM_DEBUG("\n"); if (dev->irq) mga_irq_uninstall(dev); - + down(&dev->struct_sem); del_timer(&dev->timer); - + if (dev->devname) { drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); dev->devname = NULL; } - + if (dev->unique) { drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); dev->unique = NULL; @@ -243,7 +243,7 @@ if (dev->agp) { drm_agp_mem_t *entry; drm_agp_mem_t *nexte; - + /* Remove AGP resources, but leave dev->agp intact until cleanup is called. */ for (entry = dev->agp->memory; entry; entry = nexte) { @@ -253,10 +253,10 @@ drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); } dev->agp->memory = NULL; - + if (dev->agp->acquired && drm_agp.release) (*drm_agp.release)(); - + dev->agp->acquired = 0; dev->agp->enabled = 0; } @@ -268,7 +268,7 @@ } dev->vmalist = NULL; } - + /* Clear map area and mtrr information */ if (dev->maplist) { for (i = 0; i < dev->map_count; i++) { @@ -304,7 +304,7 @@ dev->maplist = NULL; dev->map_count = 0; } - + if (dev->queuelist) { for (i = 0; i < dev->queue_count; i++) { drm_waitlist_destroy(&dev->queuelist[i]->waitlist); @@ -330,7 +330,7 @@ wake_up_interruptible(&dev->lock.lock_queue); } up(&dev->struct_sem); - + return 0; } @@ -347,7 +347,7 @@ memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); - + #ifdef MODULE drm_parse_options(mga); #endif @@ -407,7 +407,7 @@ drm_device_t *dev = &mga_device; DRM_DEBUG("\n"); - + drm_proc_cleanup(); if (misc_deregister(&mga_misc)) { DRM_ERROR("Cannot unload module\n"); @@ -419,7 +419,7 @@ #ifdef CONFIG_MTRR if(dev->agp && dev->agp->agp_mtrr) { int retval; - retval = mtrr_del(dev->agp->agp_mtrr, + retval = mtrr_del(dev->agp->agp_mtrr, dev->agp->agp_info.aper_base, dev->agp->agp_info.aper_size * 1024*1024); DRM_DEBUG("mtrr_del = %d\n", retval); @@ -477,7 +477,7 @@ { drm_device_t *dev = &mga_device; int retcode = 0; - + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_open_helper(inode, filp, dev))) { #if LINUX_VERSION_CODE < 0x020333 @@ -514,7 +514,7 @@ drm_lock_free(dev, &dev->lock.hw_lock->lock, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); - + /* FIXME: may require heavy-handed reset of hardware at this point, possibly processed via a callback to the X @@ -535,7 +535,7 @@ dev->lock.lock_time = jiffies; atomic_inc(&dev->total_locks); break; /* Got lock */ - } + } /* Contention */ atomic_inc(&dev->total_sleeps); current->state = TASK_INTERRUPTIBLE; @@ -561,7 +561,7 @@ if (priv->next) priv->next->prev = priv->prev; else dev->file_last = priv->prev; up(&dev->struct_sem); - + drm_free(priv, sizeof(*priv), DRM_MEM_FILES); #if LINUX_VERSION_CODE < 0x020333 MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */ @@ -602,7 +602,7 @@ atomic_inc(&dev->ioctl_count); atomic_inc(&dev->total_ioctl); ++priv->ioctl_count; - + DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", current->pid, cmd, nr, dev->device, priv->authenticated); @@ -622,7 +622,7 @@ retcode = (func)(inode, filp, cmd, arg); } } - + atomic_dec(&dev->ioctl_count); return retcode; } @@ -636,7 +636,7 @@ if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) return -EFAULT; - + if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", current->pid, lock.context); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/drm/mga_drv.h linux/drivers/char/drm/mga_drv.h --- v2.4.0-test8/linux/drivers/char/drm/mga_drv.h Fri Sep 8 13:27:11 2000 +++ linux/drivers/char/drm/mga_drv.h Fri Sep 15 14:24:55 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -82,6 +82,7 @@ int use_agp; drm_mga_warp_index_t WarpIndex[MGA_MAX_G400_PIPES]; unsigned int WarpPipe; + unsigned int vertexsize; atomic_t pending_bufs; void *status_page; unsigned long real_status_page; @@ -97,7 +98,7 @@ wait_queue_head_t wait_queue; /* Processes waiting until interrupt */ wait_queue_head_t buf_queue; /* Processes waiting for a free buf */ /* Some validated register values: - */ + */ u32 mAccess; } drm_mga_private_t; @@ -128,7 +129,6 @@ extern int mga_dma_cleanup(drm_device_t *dev); extern int mga_flush_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern void mga_flush_write_combine(void); extern unsigned int mga_create_sync_tag(drm_device_t *dev); extern drm_buf_t *mga_freelist_get(drm_device_t *dev); extern int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf); @@ -137,9 +137,9 @@ /* mga_bufs.c */ -extern int mga_addbufs(struct inode *inode, struct file *filp, +extern int mga_addbufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int mga_infobufs(struct inode *inode, struct file *filp, +extern int mga_infobufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int mga_markbufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); @@ -179,6 +179,7 @@ extern int mga_context_switch(drm_device_t *dev, int old, int new); extern int mga_context_switch_complete(drm_device_t *dev, int new); +#define mga_flush_write_combine() mb() typedef enum { TT_GENERAL, @@ -201,7 +202,7 @@ #define ISREG0(r) (r >= DWGREG0 && r <= DWGREG0_END) #define ADRINDEX0(r) (u8)((r - DWGREG0) >> 2) #define ADRINDEX1(r) (u8)(((r - DWGREG1) >> 2) | 0x80) -#define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r)) +#define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r)) #define MGA_VERBOSE 0 #define MGA_NUM_PRIM_BUFS 8 @@ -212,13 +213,12 @@ #define PRIM_OVERFLOW(dev, dev_priv, length) do { \ drm_mga_prim_buf_t *tmp_buf = \ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ - if( test_bit(MGA_BUF_NEEDS_OVERFLOW, \ - &tmp_buf->buffer_status)) { \ + if( test_bit(MGA_BUF_NEEDS_OVERFLOW, &tmp_buf->buffer_status)) { \ mga_advance_primary(dev); \ mga_dma_schedule(dev, 1); \ tmp_buf = dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ } else if( tmp_buf->max_dwords - tmp_buf->num_dwords < length || \ - tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \ + tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \ set_bit(MGA_BUF_FORCE_FIRE, &tmp_buf->buffer_status); \ mga_advance_primary(dev); \ mga_dma_schedule(dev, 1); \ @@ -295,7 +295,7 @@ num_dwords + 1 + outcount, ADRINDEX(reg), val); \ if( ++outcount == 4) { \ outcount = 0; \ - dma_ptr[0] = *(u32 *)tempIndex; \ + dma_ptr[0] = *(unsigned long *)tempIndex; \ dma_ptr+=5; \ num_dwords += 5; \ } \ @@ -396,8 +396,8 @@ #define DC_atype_zi 0x30 #define DC_atype_blk 0x40 #define DC_atype_i 0x70 -#define DC_linear_xy 0x0 -#define DC_linear_linear 0x80 +#define DC_linear_xy 0x0 +#define DC_linear_linear 0x80 #define DC_zmode_nozcmp 0x0 #define DC_zmode_ze 0x200 #define DC_zmode_zne 0x300 @@ -405,16 +405,16 @@ #define DC_zmode_zlte 0x500 #define DC_zmode_zgt 0x600 #define DC_zmode_zgte 0x700 -#define DC_solid_disable 0x0 -#define DC_solid_enable 0x800 -#define DC_arzero_disable 0x0 -#define DC_arzero_enable 0x1000 -#define DC_sgnzero_disable 0x0 -#define DC_sgnzero_enable 0x2000 -#define DC_shftzero_disable 0x0 -#define DC_shftzero_enable 0x4000 -#define DC_bop_SHIFT 16 -#define DC_trans_SHIFT 20 +#define DC_solid_disable 0x0 +#define DC_solid_enable 0x800 +#define DC_arzero_disable 0x0 +#define DC_arzero_enable 0x1000 +#define DC_sgnzero_disable 0x0 +#define DC_sgnzero_enable 0x2000 +#define DC_shftzero_disable 0x0 +#define DC_shftzero_enable 0x4000 +#define DC_bop_SHIFT 16 +#define DC_trans_SHIFT 20 #define DC_bltmod_bmonolef 0x0 #define DC_bltmod_bmonowf 0x8000000 #define DC_bltmod_bplan 0x2000000 @@ -423,21 +423,21 @@ #define DC_bltmod_bu32rgb 0xe000000 #define DC_bltmod_bu24bgr 0x16000000 #define DC_bltmod_bu24rgb 0x1e000000 -#define DC_pattern_disable 0x0 -#define DC_pattern_enable 0x20000000 -#define DC_transc_disable 0x0 -#define DC_transc_enable 0x40000000 -#define DC_clipdis_disable 0x0 -#define DC_clipdis_enable 0x80000000 +#define DC_pattern_disable 0x0 +#define DC_pattern_enable 0x20000000 +#define DC_transc_disable 0x0 +#define DC_transc_enable 0x40000000 +#define DC_clipdis_disable 0x0 +#define DC_clipdis_enable 0x80000000 -#define SETADD_mode_vertlist 0x0 +#define SETADD_mode_vertlist 0x0 #define MGA_CLEAR_CMD (DC_opcod_trap | DC_arzero_enable | \ DC_sgnzero_enable | DC_shftzero_enable | \ (0xC << DC_bop_SHIFT) | DC_clipdis_enable | \ DC_solid_enable | DC_transc_enable) - + #define MGA_COPY_CMD (DC_opcod_bitblt | DC_atype_rpl | DC_linear_xy | \ DC_solid_disable | DC_arzero_disable | \ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/drm/mga_state.c linux/drivers/char/drm/mga_state.c --- v2.4.0-test8/linux/drivers/char/drm/mga_state.c Fri Sep 8 13:27:11 2000 +++ linux/drivers/char/drm/mga_state.c Fri Sep 15 14:24:55 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -38,13 +38,13 @@ * change these values */ -#define MGAEMITCLIP_SIZE 10 -#define MGAEMITCTX_SIZE 15 -#define MGAG200EMITTEX_SIZE 20 -#define MGAG400EMITTEX0_SIZE 30 -#define MGAG400EMITTEX1_SIZE 25 -#define MGAG400EMITPIPE_SIZE 50 -#define MGAG200EMITPIPE_SIZE 15 +#define MGAEMITCLIP_SIZE 10 +#define MGAEMITCTX_SIZE 20 +#define MGAG200EMITTEX_SIZE 20 +#define MGAG400EMITTEX0_SIZE 30 +#define MGAG400EMITTEX1_SIZE 25 +#define MGAG400EMITPIPE_SIZE 55 +#define MGAG200EMITPIPE_SIZE 15 #define MAX_STATE_SIZE ((MGAEMITCLIP_SIZE * MGA_NR_SAREA_CLIPRECTS) + \ MGAEMITCTX_SIZE + MGAG400EMITTEX0_SIZE + \ @@ -89,7 +89,7 @@ PRIMLOCALS; DRM_DEBUG("%s\n", __FUNCTION__); - /* This takes a max of 15 dwords */ + /* This takes a max of 20 dwords */ PRIMGETPTR(dev_priv); PRIMOUTREG(MGAREG_DSTORG, regs[MGA_CTXREG_DSTORG]); @@ -107,6 +107,11 @@ PRIMOUTREG(MGAREG_TDUALSTAGE0, regs[MGA_CTXREG_TDUAL0]); PRIMOUTREG(MGAREG_TDUALSTAGE1, regs[MGA_CTXREG_TDUAL1]); PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]); + + PRIMOUTREG(MGAREG_STENCIL, regs[MGA_CTXREG_STENCIL]); + PRIMOUTREG(MGAREG_STENCILCTL, regs[MGA_CTXREG_STENCILCTL]); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); } else { PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]); PRIMOUTREG(MGAREG_DMAPAD, 0); @@ -151,11 +156,13 @@ PRIMADVANCE(dev_priv); } +#define TMC_dualtex_enable 0x80 + static void mgaG400EmitTex0(drm_mga_private_t * dev_priv) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->TexState[0]; - int multitex = sarea_priv->WarpPipe & MGA_T2; + int multitex = regs[MGA_TEXREG_CTL2] & TMC_dualtex_enable; PRIMLOCALS; DRM_DEBUG("%s\n", __FUNCTION__); @@ -183,7 +190,7 @@ PRIMOUTREG(0x2d00 + 61 * 4, 0); PRIMOUTREG(MGAREG_DMAPAD, 0); - if (!multitex) { + if (!multitex || 1) { PRIMOUTREG(0x2d00 + 52 * 4, 0x40); PRIMOUTREG(0x2d00 + 60 * 4, 0x40); PRIMOUTREG(MGAREG_DMAPAD, 0); @@ -200,10 +207,10 @@ #define TMC_map1_enable 0x80000000 -static void mgaG400EmitTex1(drm_mga_private_t * dev_priv) +static void mgaG400EmitTex1(drm_mga_private_t * dev_priv, int source ) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; - unsigned int *regs = sarea_priv->TexState[1]; + unsigned int *regs = sarea_priv->TexState[source]; PRIMLOCALS; DRM_DEBUG("%s\n", __FUNCTION__); @@ -245,6 +252,8 @@ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int pipe = sarea_priv->WarpPipe; float fParam = 12800.0f; + int multitex = (sarea_priv->TexState[0][MGA_TEXREG_CTL2] & + TMC_dualtex_enable); PRIMLOCALS; DRM_DEBUG("%s\n", __FUNCTION__); @@ -252,14 +261,36 @@ /* This takes 50 dwords */ - /* Establish vertex size. + /* Establish vertex size. */ PRIMOUTREG(MGAREG_WIADDR2, WIA_wmode_suspend); PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0); - if (pipe & MGA_T2) { + if (sarea_priv->vertexsize == 10) { + PRIMOUTREG(MGAREG_YDST, 0); + PRIMOUTREG(MGAREG_FXLEFT, 0); + PRIMOUTREG(MGAREG_FXRIGHT, 1); + PRIMOUTREG(MGAREG_DWGCTL, MGA_FLUSH_CMD); + + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 1); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DWGSYNC, 0x7000); + PRIMOUTREG(MGAREG_DMAPAD, 0); + + if (multitex) { + PRIMOUTREG(MGAREG_TEXCTL2, 0 | 0x00008000); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); + PRIMOUTREG(MGAREG_TEXCTL2, 0x80 | 0x00008000); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); + } else { + PRIMOUTREG(MGAREG_TEXCTL2, 0 | 0x00008000); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); + PRIMOUTREG(MGAREG_TEXCTL2, 0 | 0x00008000); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); + } + PRIMOUTREG(MGAREG_WVRTXSZ, 0x00001e09); PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0); @@ -270,23 +301,21 @@ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0); PRIMOUTREG(MGAREG_WACCEPTSEQ, 0x1e000000); } else { - if (dev_priv->WarpPipe & MGA_T2) { - /* Flush the WARP pipe */ - PRIMOUTREG(MGAREG_YDST, 0); - PRIMOUTREG(MGAREG_FXLEFT, 0); - PRIMOUTREG(MGAREG_FXRIGHT, 1); - PRIMOUTREG(MGAREG_DWGCTL, MGA_FLUSH_CMD); + /* Flush the WARP pipe */ + PRIMOUTREG(MGAREG_YDST, 0); + PRIMOUTREG(MGAREG_FXLEFT, 0); + PRIMOUTREG(MGAREG_FXRIGHT, 1); + PRIMOUTREG(MGAREG_DWGCTL, MGA_FLUSH_CMD); - PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 1); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DWGSYNC, 0x7000); - PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 1); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DWGSYNC, 0x7000); + PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_TEXCTL2, 0 | 0x00008000); - PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); - PRIMOUTREG(MGAREG_TEXCTL2, 0x80 | 0x00008000); - PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); - } + PRIMOUTREG(MGAREG_TEXCTL2, 0 | 0x00008000); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); + PRIMOUTREG(MGAREG_TEXCTL2, 0 | 0x00008000); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); PRIMOUTREG(MGAREG_WVRTXSZ, 0x00001807); PRIMOUTREG(MGAREG_DMAPAD, 0); @@ -314,13 +343,16 @@ PRIMOUTREG(0x2d00 + 52 * 4, 0x40); /* Tex stage 1 : w */ PRIMOUTREG(0x2d00 + 60 * 4, 0x40); /* Tex stage 1 : h */ - /* Dma pading required due to hw bug */ - PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); - PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); - PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); - PRIMOUTREG(MGAREG_WIADDR2, - (u32) (dev_priv->WarpIndex[pipe]. - phys_addr | WIA_wmode_start | WIA_wagp_agp)); + if (dev_priv->WarpPipe != pipe || 1) { + /* Dma pading required due to hw bug */ + PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); + PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); + PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); + PRIMOUTREG(MGAREG_WIADDR2, + (u32) (dev_priv->WarpIndex[pipe].phys_addr | + WIA_wmode_start | WIA_wagp_agp)); + } + PRIMADVANCE(dev_priv); } @@ -363,11 +395,20 @@ DRM_DEBUG("%s\n", __FUNCTION__); if (dev_priv->chipset == MGA_CARD_TYPE_G400) { - int multitex = sarea_priv->WarpPipe & MGA_T2; + int multitex = (sarea_priv->TexState[0][MGA_TEXREG_CTL2] & + TMC_dualtex_enable); - if (sarea_priv->WarpPipe != dev_priv->WarpPipe) { + dirty = ~0; + + if (dirty & MGA_UPLOAD_PIPE +/* && (sarea_priv->WarpPipe != dev_priv->WarpPipe || */ +/* sarea_priv->vertexsize != dev_priv->vertexsize) */ + ) + { mgaG400EmitPipe(dev_priv); dev_priv->WarpPipe = sarea_priv->WarpPipe; + dev_priv->vertexsize = sarea_priv->vertexsize; + sarea_priv->dirty &= ~MGA_UPLOAD_PIPE; } if (dirty & MGA_UPLOAD_CTX) { @@ -380,8 +421,11 @@ sarea_priv->dirty &= ~MGA_UPLOAD_TEX0; } - if ((dirty & MGA_UPLOAD_TEX1) && multitex) { - mgaG400EmitTex1(dev_priv); + if (dirty & MGA_UPLOAD_TEX1) { + if (multitex) + mgaG400EmitTex1(dev_priv, 1); + else + mgaG400EmitTex1(dev_priv, 0); sarea_priv->dirty &= ~MGA_UPLOAD_TEX1; } } else { @@ -552,12 +596,15 @@ if (buf->used) { /* WARNING: if you change any of the state functions verify - * these numbers (Overestimating this doesn't hurt). + * these numbers (Overestimating this doesn't hurt). */ buf_priv->dispatched = 1; PRIM_OVERFLOW(dev, dev_priv, (MAX_STATE_SIZE + (5 * MGA_NR_SAREA_CLIPRECTS))); mgaEmitState(dev_priv); + +/* length = dev_priv->vertexsize * 3 * 4; */ + do { if (i < sarea_priv->nbox) { DRM_DEBUG("idx %d Emit box %d/%d:" @@ -614,7 +661,7 @@ if (start != end) { /* WARNING: if you change any of the state functions verify - * these numbers (Overestimating this doesn't hurt). + * these numbers (Overestimating this doesn't hurt). */ buf_priv->dispatched = 1; PRIM_OVERFLOW(dev, dev_priv, @@ -644,6 +691,7 @@ SETADD_mode_vertlist)); PRIMOUTREG(MGAREG_SETUPEND, ((address + end) | use_agp)); +/* ((address + start + 12) | use_agp)); */ PRIMADVANCE(dev_priv); } while (++i < sarea_priv->nbox); } @@ -658,7 +706,9 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags, unsigned int clear_color, - unsigned int clear_zval) + unsigned int clear_zval, + unsigned int clear_colormask, + unsigned int clear_depthmask) { drm_mga_private_t *dev_priv = dev->dev_private; drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; @@ -687,7 +737,7 @@ if (flags & MGA_FRONT) { DRM_DEBUG("clear front\n"); PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_PLNWT, clear_colormask); PRIMOUTREG(MGAREG_YDSTLEN, (pbox[i].y1 << 16) | height); PRIMOUTREG(MGAREG_FXBNDRY, @@ -702,7 +752,7 @@ if (flags & MGA_BACK) { DRM_DEBUG("clear back\n"); PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_PLNWT, clear_colormask); PRIMOUTREG(MGAREG_YDSTLEN, (pbox[i].y1 << 16) | height); PRIMOUTREG(MGAREG_FXBNDRY, @@ -717,7 +767,7 @@ if (flags & MGA_DEPTH) { DRM_DEBUG("clear depth\n"); PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_PLNWT, clear_depthmask); PRIMOUTREG(MGAREG_YDSTLEN, (pbox[i].y1 << 16) | height); PRIMOUTREG(MGAREG_FXBNDRY, @@ -818,7 +868,10 @@ */ dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CTX; mga_dma_dispatch_clear(dev, clear.flags, - clear.clear_color, clear.clear_depth); + clear.clear_color, + clear.clear_depth, + clear.clear_color_mask, + clear.clear_depth_mask); PRIMUPDATE(dev_priv); mga_flush_write_combine(); mga_dma_schedule(dev, 1); @@ -1012,8 +1065,9 @@ break; buf->pid = current->pid; if (copy_to_user(&d->request_indices[i], - &buf->idx, sizeof(buf->idx)) || - copy_to_user(&d->request_sizes[i], + &buf->idx, sizeof(buf->idx))) + return -EFAULT; + if (copy_to_user(&d->request_sizes[i], &buf->total, sizeof(buf->total))) return -EFAULT; ++d->granted_count; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/drm/picker.c linux/drivers/char/drm/picker.c --- v2.4.0-test8/linux/drivers/char/drm/picker.c Wed Dec 31 16:00:00 1969 +++ linux/drivers/char/drm/picker.c Fri Sep 15 21:37:23 2000 @@ -0,0 +1,29 @@ +#include +#include + +#ifndef CONFIG_SMP +#define CONFIG_SMP 0 +#endif + +#ifndef CONFIG_MODVERSIONS +#define CONFIG_MODVERSIONS 0 +#endif + +#ifndef CONFIG_AGP_MODULE +#define CONFIG_AGP_MODULE 0 +#endif + +#ifndef CONFIG_AGP +#define CONFIG_AGP 0 +#endif + +#ifndef CONFIG_FB_SIS +#define CONFIG_FB_SIS 0 +#endif + +SMP = CONFIG_SMP +MODVERSIONS = CONFIG_MODVERSIONS +AGP = CONFIG_AGP +AGP_MODULE = CONFIG_AGP_MODULE +RELEASE = UTS_RELEASE +SIS = CONFIG_FB_SIS diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/drm/r128_dma.c linux/drivers/char/drm/r128_dma.c --- v2.4.0-test8/linux/drivers/char/drm/r128_dma.c Fri Sep 8 13:27:11 2000 +++ linux/drivers/char/drm/r128_dma.c Fri Sep 15 14:24:55 2000 @@ -68,30 +68,8 @@ return R128_READ(R128_CLOCK_CNTL_DATA); } -#ifdef __i386__ -static void r128_flush_write_combine(void) -{ - int xchangeDummy; +#define r128_flush_write_combine() mb() - __asm__ volatile("push %%eax ;" - "xchg %%eax, %0 ;" - "pop %%eax" : : "m" (xchangeDummy)); - __asm__ volatile("push %%eax ;" - "push %%ebx ;" - "push %%ecx ;" - "push %%edx ;" - "movl $0,%%eax ;" - "cpuid ;" - "pop %%edx ;" - "pop %%ecx ;" - "pop %%ebx ;" - "pop %%eax" : /* no outputs */ : /* no inputs */ ); -} -#else -static void r128_flush_write_combine(void) -{ -} -#endif static void r128_status(drm_device_t *dev) { diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/drm/r128_drv.c linux/drivers/char/drm/r128_drv.c --- v2.4.0-test8/linux/drivers/char/drm/r128_drv.c Fri Sep 8 13:27:11 2000 +++ linux/drivers/char/drm/r128_drv.c Fri Sep 15 14:24:55 2000 @@ -35,7 +35,7 @@ #define R128_NAME "r128" #define R128_DESC "ATI Rage 128" -#define R128_DATE "20000719" +#define R128_DATE "20000910" #define R128_MAJOR 1 #define R128_MINOR 0 #define R128_PATCHLEVEL 0 @@ -467,7 +467,7 @@ } spin_unlock(&dev->count_lock); } - + return retcode; } @@ -501,7 +501,7 @@ } spin_unlock(&dev->count_lock); } - + unlock_kernel(); return retcode; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/drm/tdfx_drv.c linux/drivers/char/drm/tdfx_drv.c --- v2.4.0-test8/linux/drivers/char/drm/tdfx_drv.c Fri Sep 8 13:27:11 2000 +++ linux/drivers/char/drm/tdfx_drv.c Fri Sep 15 14:24:55 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -23,7 +23,7 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * * Authors: * Rickard E. (Rik) Faith * Daryll Strauss @@ -36,7 +36,7 @@ #define TDFX_NAME "tdfx" #define TDFX_DESC "3dfx Banshee/Voodoo3+" -#define TDFX_DATE "20000719" +#define TDFX_DATE "20000910" #define TDFX_MAJOR 1 #define TDFX_MINOR 0 #define TDFX_PATCHLEVEL 0 @@ -76,7 +76,7 @@ [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 }, - + [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { tdfx_addctx, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { tdfx_rmctx, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { tdfx_modctx, 1, 1 }, @@ -128,7 +128,7 @@ static int tdfx_setup(drm_device_t *dev) { int i; - + atomic_set(&dev->ioctl_count, 0); atomic_set(&dev->vma_count, 0); dev->buf_use = 0; @@ -170,7 +170,7 @@ dev->ctx_start = 0; dev->lck_start = 0; - + dev->buf_rp = dev->buf; dev->buf_wp = dev->buf; dev->buf_end = dev->buf + DRM_BSZ; @@ -179,15 +179,15 @@ init_waitqueue_head(&dev->buf_writers); tdfx_res_ctx.handle=-1; - + DRM_DEBUG("\n"); - + /* The kernel's context could be created here, but is now created in drm_dma_enqueue. This is more resource-efficient for hardware that does not do DMA, but may mean that drm_select_queue fails between the time the interrupt is initialized and the time the queues are initialized. */ - + return 0; } @@ -203,12 +203,12 @@ down(&dev->struct_sem); del_timer(&dev->timer); - + if (dev->devname) { drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); dev->devname = NULL; } - + if (dev->unique) { drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); dev->unique = NULL; @@ -227,7 +227,7 @@ if (dev->agp) { drm_agp_mem_t *temp; drm_agp_mem_t *temp_next; - + temp = dev->agp->memory; while(temp != NULL) { temp_next = temp->next; @@ -246,7 +246,7 @@ } dev->vmalist = NULL; } - + /* Clear map area and mtrr information */ if (dev->maplist) { for (i = 0; i < dev->map_count; i++) { @@ -284,14 +284,14 @@ dev->maplist = NULL; dev->map_count = 0; } - + if (dev->lock.hw_lock) { dev->lock.hw_lock = NULL; /* SHM removed */ dev->lock.pid = 0; wake_up_interruptible(&dev->lock.lock_queue); } up(&dev->struct_sem); - + return 0; } @@ -308,7 +308,7 @@ memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); - + #ifdef MODULE drm_parse_options(tdfx); #endif @@ -340,7 +340,7 @@ TDFX_PATCHLEVEL, TDFX_DATE, tdfx_misc.minor); - + return 0; } @@ -351,7 +351,7 @@ drm_device_t *dev = &tdfx_device; DRM_DEBUG("\n"); - + drm_proc_cleanup(); if (misc_deregister(&tdfx_misc)) { DRM_ERROR("Cannot unload module\n"); @@ -412,7 +412,7 @@ { drm_device_t *dev = &tdfx_device; int retcode = 0; - + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_open_helper(inode, filp, dev))) { #if LINUX_VERSION_CODE < 0x020333 @@ -480,7 +480,7 @@ atomic_inc(&dev->ioctl_count); atomic_inc(&dev->total_ioctl); ++priv->ioctl_count; - + DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", current->pid, cmd, nr, dev->device, priv->authenticated); @@ -500,7 +500,7 @@ retcode = (func)(inode, filp, cmd, arg); } } - + atomic_dec(&dev->ioctl_count); return retcode; } @@ -538,7 +538,7 @@ if (lock.context < 0 || lock.context >= dev->queue_count) return -EINVAL; #endif - + if (!ret) { #if 0 if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) @@ -550,7 +550,7 @@ /* Can't take lock if we just had it and there is contention. */ DRM_DEBUG("%d (pid %d) delayed j=%d dev=%d jiffies=%d\n", - lock.context, current->pid, j, + lock.context, current->pid, j, dev->lock.lock_time, jiffies); current->state = TASK_INTERRUPTIBLE; current->policy |= SCHED_YIELD; @@ -573,7 +573,7 @@ atomic_inc(&dev->total_locks); break; /* Got lock */ } - + /* Contention */ atomic_inc(&dev->total_sleeps); current->state = TASK_INTERRUPTIBLE; @@ -648,7 +648,7 @@ #if DRM_DMA_HISTOGRAM atomic_inc(&dev->histo.lacq[drm_histogram_slot(get_cycles() - start)]); #endif - + return ret; } @@ -662,7 +662,7 @@ if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) return -EFAULT; - + if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", current->pid, lock.context); @@ -690,7 +690,7 @@ current->priority = DEF_PRIORITY; } #endif - + unblock_all_signals(); return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/mem.c linux/drivers/char/mem.c --- v2.4.0-test8/linux/drivers/char/mem.c Fri Jun 23 21:55:08 2000 +++ linux/drivers/char/mem.c Sun Sep 17 09:45:06 2000 @@ -55,9 +55,6 @@ #if defined(CONFIG_ADB) extern void adbdev_init(void); #endif -#ifdef CONFIG_PHONE -extern void telephony_init(void); -#endif static ssize_t do_write_mem(struct file * file, void *p, unsigned long realp, const char * buf, size_t count, loff_t *ppos) @@ -258,25 +255,27 @@ count -= read; } - kbuf = (char *)__get_free_page(GFP_KERNEL); - if (!kbuf) - return -ENOMEM; - while (count > 0) { - int len = count; - - if (len > PAGE_SIZE) - len = PAGE_SIZE; - len = vread(kbuf, (char *)p, len); - if (len && copy_to_user(buf, kbuf, len)) { - free_page((unsigned long)kbuf); - return -EFAULT; + if (count > 0) { + kbuf = (char *)__get_free_page(GFP_KERNEL); + if (!kbuf) + return -ENOMEM; + while (count > 0) { + int len = count; + + if (len > PAGE_SIZE) + len = PAGE_SIZE; + len = vread(kbuf, (char *)p, len); + if (len && copy_to_user(buf, kbuf, len)) { + free_page((unsigned long)kbuf); + return -EFAULT; + } + count -= len; + buf += len; + virtr += len; + p += len; } - count -= len; - buf += len; - virtr += len; - p += len; + free_page((unsigned long)kbuf); } - free_page((unsigned long)kbuf); *ppos = p; return virtr + read; } @@ -666,8 +665,5 @@ #ifdef CONFIG_VIDEO_DEV videodev_init(); #endif -#ifdef CONFIG_PHONE - telephony_init(); -#endif return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/nvram.c linux/drivers/char/nvram.c --- v2.4.0-test8/linux/drivers/char/nvram.c Fri Sep 8 13:27:11 2000 +++ linux/drivers/char/nvram.c Mon Sep 11 08:41:07 2000 @@ -109,7 +109,7 @@ extern spinlock_t rtc_lock; -static int nvram_open_cnt = 0; /* #times opened */ +static int nvram_open_cnt; /* #times opened */ static int nvram_open_mode; /* special open modes */ #define NVRAM_WRITE 1 /* opened for writing (exclusive) */ #define NVRAM_EXCL 2 /* opened with O_EXCL */ @@ -415,14 +415,29 @@ static int __init nvram_init(void) { + int ret; + /* First test whether the driver should init at all */ if (!CHECK_DRIVER_INIT()) return( -ENXIO ); - printk(KERN_INFO "Non-volatile memory driver v%s\n", NVRAM_VERSION ); - misc_register( &nvram_dev ); - create_proc_read_entry("driver/nvram",0,0,nvram_read_proc,NULL); - return( 0 ); + ret = misc_register( &nvram_dev ); + if (ret) { + printk(KERN_ERR "nvram: can't misc_register on minor=%d\n", NVRAM_MINOR); + goto out; + } + if (!create_proc_read_entry("driver/nvram",0,0,nvram_read_proc,NULL)) { + printk(KERN_ERR "nvram: can't create /proc/driver/nvram\n"); + ret = -ENOMEM; + goto outmisc; + } + ret = 0; + printk(KERN_INFO "Non-volatile memory driver v" NVRAM_VERSION "\n"); +out: + return( ret ); +outmisc: + misc_deregister( &nvram_dev ); + goto out; } static void __exit nvram_cleanup_module (void) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/wdt.c linux/drivers/char/wdt.c --- v2.4.0-test8/linux/drivers/char/wdt.c Thu Jul 27 17:38:00 2000 +++ linux/drivers/char/wdt.c Mon Sep 11 08:41:07 2000 @@ -26,6 +26,7 @@ * Alan Cox : Cleaned up copy/user stuff * Tim Hockin : Added insmod parameters, comment cleanup * Parameterized timeout + * Tigran Aivazian : Restructured wdt_init() to handle failures */ #include @@ -49,7 +50,7 @@ #include #include -static int wdt_is_open=0; +static int wdt_is_open; /* * You must set these - there is no sane way to probe for this board. @@ -495,18 +496,53 @@ int __init wdt_init(void) { - printk(KERN_INFO "WDT500/501-P driver 0.07 at %X (Interrupt %d)\n", io,irq); - if(request_irq(irq, wdt_interrupt, SA_INTERRUPT, "wdt501p", &wdt_miscdev)) - { - printk(KERN_ERR "IRQ %d is not free.\n", irq); - return -EIO; + int ret; + + ret = misc_register(&wdt_miscdev); + if (ret) { + printk(KERN_ERR "wdt: can't misc_register on minor=%d\n", WATCHDOG_MINOR); + goto out; } - misc_register(&wdt_miscdev); -#ifdef CONFIG_WDT_501 - misc_register(&temp_miscdev); -#endif - request_region(io, 8, "wdt501p"); - register_reboot_notifier(&wdt_notifier); - return 0; + ret = request_irq(irq, wdt_interrupt, SA_INTERRUPT, "wdt501p", NULL); + if(ret) { + printk(KERN_ERR "wdt: IRQ %d is not free.\n", irq); + goto outmisc; + } + if (!request_region(io, 8, "wdt501p")) { + printk(KERN_ERR "wdt: IO %X is not free.\n", io); + ret = -EBUSY; + goto outirq; + } + ret = register_reboot_notifier(&wdt_notifier); + if(ret) { + printk(KERN_ERR "wdt: can't register reboot notifier (err=%d)\n", ret); + goto outreg; + } + +#ifdef CONFIG_WDT_501 + ret = misc_register(&temp_miscdev); + if (ret) { + printk(KERN_ERR "wdt: can't misc_register (temp) on minor=%d\n", TEMP_MINOR); + goto outrbt; + } +#endif + + ret = 0; + printk(KERN_INFO "WDT500/501-P driver 0.07 at %X (Interrupt %d)\n", io, irq); +out: + return ret; + +#ifdef CONFIG_WDT_501 +outrbt: + unregister_reboot_notifier(&wdt_notifier); +#endif + +outreg: + release_region(io,8); +outirq: + free_irq(irq, NULL); +outmisc: + misc_deregister(&wdt_miscdev); + goto out; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/char/wdt_pci.c linux/drivers/char/wdt_pci.c --- v2.4.0-test8/linux/drivers/char/wdt_pci.c Fri Jul 14 12:12:09 2000 +++ linux/drivers/char/wdt_pci.c Mon Sep 11 08:41:07 2000 @@ -29,6 +29,7 @@ * JP Nollmann : Added support for PCI wdt501p * Alan Cox : Split ISA and PCI cards into two drivers * Jeff Garzik : PCI cleanups + * Tigran Aivazian : Restructured wdtpci_init_one() to handle failures */ #include @@ -70,7 +71,7 @@ #define PCI_DEVICE_ID_WDG_CSM 0x22c0 #endif -static int wdt_is_open=0; +static int wdt_is_open; /* * You must set these - there is no sane way to probe for this board. @@ -499,6 +500,7 @@ const struct pci_device_id *ent) { static int dev_count = 0; + int ret = -EIO; dev_count++; if (dev_count > 1) { @@ -513,33 +515,53 @@ "(Interrupt %d)\n", io, irq); if (pci_enable_device (dev)) - goto err_out; + goto out; if (request_region (io, 16, "wdt-pci") == NULL) { printk (KERN_ERR PFX "I/O %d is not free.\n", io); - goto err_out; + goto out; } if (request_irq (irq, wdtpci_interrupt, SA_INTERRUPT | SA_SHIRQ, "wdt-pci", &wdtpci_miscdev)) { printk (KERN_ERR PFX "IRQ %d is not free.\n", irq); - goto err_out_free_res; + goto out_reg; } - misc_register (&wdtpci_miscdev); + ret = misc_register (&wdtpci_miscdev); + if (ret) { + printk (KERN_ERR PFX "can't misc_register on minor=%d\n", WATCHDOG_MINOR); + goto out_irq; + } + ret = register_reboot_notifier (&wdtpci_notifier); + if (ret) { + printk (KERN_ERR PFX "can't misc_register on minor=%d\n", WATCHDOG_MINOR); + goto out_misc; + } #ifdef CONFIG_WDT_501 - misc_register (&temp_miscdev); + ret = misc_register (&temp_miscdev); + if (ret) { + printk (KERN_ERR PFX "can't misc_register (temp) on minor=%d\n", TEMP_MINOR); + goto out_rbt; + } #endif - register_reboot_notifier (&wdtpci_notifier); + ret = 0; +out: + return ret; - return 0; - -err_out_free_res: +#ifdef CONFIG_WDT_501 +out_rbt: + unregister_reboot_notifier(&wdtpci_notifier); +#endif +out_misc: + misc_deregister(&wdtpci_miscdev); +out_irq: + free_irq(irq, &wdtpci_miscdev); +out_reg: release_region (io, 16); -err_out: - return -EIO; + goto out; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/i2o/i2o_proc.c linux/drivers/i2o/i2o_proc.c --- v2.4.0-test8/linux/drivers/i2o/i2o_proc.c Wed Apr 26 16:34:07 2000 +++ linux/drivers/i2o/i2o_proc.c Sun Sep 17 09:45:06 2000 @@ -3319,7 +3319,7 @@ return 0; } -static int destroy_i2o_procfs(void) +static int __exit destroy_i2o_procfs(void) { struct i2o_controller *pctrl = NULL; int i; @@ -3342,10 +3342,6 @@ return 0; } -#ifdef MODULE -#define i2o_proc_init init_module -#endif - int __init i2o_proc_init(void) { if (i2o_install_handler(&i2o_proc_handler) < 0) @@ -3360,14 +3356,17 @@ return 0; } -#ifdef MODULE - MODULE_AUTHOR("Deepak Saxena"); MODULE_DESCRIPTION("I2O procfs Handler"); -void cleanup_module(void) +static void __exit i2o_proc_exit(void) { destroy_i2o_procfs(); i2o_remove_handler(&i2o_proc_handler); } + +#ifdef MODULE +module_init(i2o_proc_init); #endif +module_exit(i2o_proc_exit); + diff -u --recursive --new-file v2.4.0-test8/linux/drivers/ide/ide.c linux/drivers/ide/ide.c --- v2.4.0-test8/linux/drivers/ide/ide.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/ide/ide.c Mon Sep 11 08:42:57 2000 @@ -1082,7 +1082,7 @@ { byte *args = rq->buffer; if (args && rq->cmd == IDE_DRIVE_TASK) { - + byte sel; #ifdef DEBUG printk("%s: DRIVE_TASK_CMD data=x%02x cmd=0x%02x fr=0x%02x ns=0x%02x sc=0x%02x lcyl=0x%02x hcyl=0x%02x sel=0x%02x\n", drive->name, args[0], args[1], args[2], args[3], args[4], args[5], args[6]); @@ -1091,7 +1091,10 @@ OUT_BYTE(args[3], IDE_SECTOR_REG); OUT_BYTE(args[4], IDE_LCYL_REG); OUT_BYTE(args[5], IDE_HCYL_REG); - OUT_BYTE(args[6], IDE_SELECT_REG); + sel = (args[6] & ~0x10); + if (drive->select.b.unit) + sel |= 0x10; + OUT_BYTE(sel, IDE_SELECT_REG); ide_cmd(drive, args[0], args[2], &drive_cmd_intr); return ide_started; } else if (args) { diff -u --recursive --new-file v2.4.0-test8/linux/drivers/isdn/avmb1/capi.c linux/drivers/isdn/avmb1/capi.c --- v2.4.0-test8/linux/drivers/isdn/avmb1/capi.c Wed Aug 23 18:36:37 2000 +++ linux/drivers/isdn/avmb1/capi.c Sun Sep 17 09:45:05 2000 @@ -212,6 +212,7 @@ #include #include #include +#include #include "capiutil.h" #include "capicmd.h" #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE @@ -1930,7 +1931,7 @@ { "capi/capi20ncci", 0 , proc_capincci_read_proc }, }; -static void proc_init(void) +static void __init proc_init(void) { int nelem = sizeof(procfsentries)/sizeof(procfsentries[0]); int i; @@ -1942,7 +1943,7 @@ } } -static void proc_exit(void) +static void __exit proc_exit(void) { int nelem = sizeof(procfsentries)/sizeof(procfsentries[0]); int i; @@ -1981,7 +1982,7 @@ #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ } -static int alloc_init(void) +static int __init alloc_init(void) { capidev_cachep = kmem_cache_create("capi20_dev", sizeof(struct capidev), @@ -2052,10 +2053,6 @@ } } -#ifdef MODULE -#define capi_init init_module -#endif - static struct capi_interface_user cuser = { "capi20", lower_callback, @@ -2063,7 +2060,7 @@ static char rev[10]; -int capi_init(void) +int __init capi_init(void) { char *p; @@ -2152,8 +2149,7 @@ return 0; } -#ifdef MODULE -void cleanup_module(void) +static void __exit capi_exit(void) { #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE unsigned int j; @@ -2177,4 +2173,8 @@ printk(KERN_NOTICE "capi: Rev%s: unloaded\n", rev); } +#ifdef MODULE +module_init(capi_init); #endif +module_exit(capi_exit); + diff -u --recursive --new-file v2.4.0-test8/linux/drivers/isdn/avmb1/capidrv.c linux/drivers/isdn/avmb1/capidrv.c --- v2.4.0-test8/linux/drivers/isdn/avmb1/capidrv.c Wed Aug 23 18:36:37 2000 +++ linux/drivers/isdn/avmb1/capidrv.c Sun Sep 17 09:45:05 2000 @@ -200,6 +200,7 @@ #include #include #include +#include #include #include "capiutil.h" @@ -2436,7 +2437,7 @@ { "capi/capidrv", 0 , proc_capidrv_read_proc }, }; -static void proc_init(void) +static void __init proc_init(void) { int nelem = sizeof(procfsentries)/sizeof(procfsentries[0]); int i; @@ -2448,7 +2449,7 @@ } } -static void proc_exit(void) +static void __exit proc_exit(void) { int nelem = sizeof(procfsentries)/sizeof(procfsentries[0]); int i; @@ -2467,11 +2468,7 @@ lower_callback }; -#ifdef MODULE -#define capidrv_init init_module -#endif - -int capidrv_init(void) +int __init capidrv_init(void) { struct capi_register_params rparam; capi_profile profile; @@ -2531,8 +2528,7 @@ return 0; } -#ifdef MODULE -void cleanup_module(void) +static void __exit capidrv_exit(void) { char rev[10]; char *p; @@ -2554,4 +2550,8 @@ printk(KERN_NOTICE "capidrv: Rev%s: unloaded\n", rev); } +#ifdef MODULE +module_init(capidrv_init); #endif +module_exit(capidrv_exit); + diff -u --recursive --new-file v2.4.0-test8/linux/drivers/macintosh/Makefile linux/drivers/macintosh/Makefile --- v2.4.0-test8/linux/drivers/macintosh/Makefile Tue May 23 15:31:34 2000 +++ linux/drivers/macintosh/Makefile Sun Sep 17 09:48:05 2000 @@ -9,76 +9,67 @@ # parent makes.. # -SUB_DIRS := -MOD_SUB_DIRS := $(SUB_DIRS) +# Subdirs. -O_TARGET := macintosh.o -O_OBJS := -M_OBJS := +SUB_DIRS := +MOD_SUB_DIRS := $(SUB_DIRS) +MOD_IN_SUB_DIRS := $(SUB_DIRS) +ALL_SUB_DIRS := $(SUB_DIRS) -ifeq ($(CONFIG_PMAC_PBOOK),y) - O_OBJS += mediabay.o -else - ifeq ($(CONFIG_MAC_FLOPPY),y) - O_OBJS += mediabay.o - endif -endif +# The target object and module list name. -ifeq ($(CONFIG_MAC_SERIAL),y) - O_OBJS += macserial.o -else - ifeq ($(CONFIG_MAC_SERIAL),m) - M_OBJS += macserial.o - endif -endif +O_TARGET := macintosh.o +M_OBJS := +O_OBJS := +MOD_LIST_NAME := MACINTOSH_MODULES -ifeq ($(CONFIG_NVRAM),y) - O_OBJS += nvram.o -else - ifeq ($(CONFIG_NVRAM),m) - M_OBJS += nvram.o - endif -endif +# Objects that export symbols. -ifdef CONFIG_ADB - OX_OBJS := adb.o -endif +export-objs := adb.o rtc.o mac_hid.o -ifdef CONFIG_ADB_KEYBOARD - O_OBJS += mac_keyb.o -endif +# Object file lists. -ifdef CONFIG_ADB_MACII - O_OBJS += via-macii.o -endif +obj-y := +obj-m := +obj-n := +obj- := -ifdef CONFIG_ADB_MACIISI - O_OBJS += via-maciisi.o -endif +# Each configuration option enables a list of files. -ifdef CONFIG_ADB_CUDA - O_OBJS += via-cuda.o +ifeq ($(CONFIG_PMAC_PBOOK),y) + obj-y += mediabay.o endif -ifdef CONFIG_ADB_IOP - O_OBJS += adb-iop.o -endif +obj-$(CONFIG_MAC_SERIAL) += macserial.o +obj-$(CONFIG_NVRAM) += nvram.o +obj-$(CONFIG_MAC_HID) += mac_hid.o +obj-$(CONFIG_INPUT_ADBHID) += adbhid.o +obj-$(CONFIG_PPC_RTC) += rtc.o -ifdef CONFIG_ADB_PMU - O_OBJS += via-pmu.o -endif +obj-$(CONFIG_ADB_PMU) += via-pmu.o +obj-$(CONFIG_ADB_CUDA) += via-cuda.o -ifdef CONFIG_ADB_PMU68K - O_OBJS += via-pmu68k.o -endif +obj-$(CONFIG_ADB) += adb.o +obj-$(CONFIG_ADB_KEYBOARD) += mac_keyb.o +obj-$(CONFIG_ADB_MACII) += via-macii.o +obj-$(CONFIG_ADB_MACIISI) += via-maciisi.o +obj-$(CONFIG_ADB_IOP) += adb-iop.o +obj-$(CONFIG_ADB_PMU68K) += via-pmu68k.o +obj-$(CONFIG_ADB_MACIO) += macio-adb.o -ifdef CONFIG_ADB_MACIO - O_OBJS += macio-adb.o -endif +# Files that are both resident and modular: remove from modular. + +obj-m := $(filter-out $(obj-y), $(obj-m)) +int-m := $(filter-out $(int-y), $(int-m)) + +# Translate to Rules.make lists. + +O_OBJS := $(sort $(filter-out $(export-objs), $(obj-y))) +OX_OBJS := $(sort $(filter $(export-objs), $(obj-y))) +M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) +MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) + +# The global Rules.make. include $(TOPDIR)/Rules.make -# Integrated in mac_keyb.c -# mackeymap.map is retained for historical reasons -#mackeymap.c: mackeymap.map -# loadkeys --mktable mackeymap.map > mackeymap.c diff -u --recursive --new-file v2.4.0-test8/linux/drivers/macintosh/adb.c linux/drivers/macintosh/adb.c --- v2.4.0-test8/linux/drivers/macintosh/adb.c Fri Jul 14 12:12:10 2000 +++ linux/drivers/macintosh/adb.c Sun Sep 17 09:48:05 2000 @@ -393,6 +393,15 @@ return ids->nids; } +int +adb_unregister(int index) +{ + if (!adb_handler[index].handler) + return -ENODEV; + adb_handler[index].handler = 0; + return 0; +} + void adb_input(unsigned char *buf, int nb, struct pt_regs *regs, int autopoll) { diff -u --recursive --new-file v2.4.0-test8/linux/drivers/macintosh/adbhid.c linux/drivers/macintosh/adbhid.c --- v2.4.0-test8/linux/drivers/macintosh/adbhid.c Wed Dec 31 16:00:00 1969 +++ linux/drivers/macintosh/adbhid.c Sun Sep 17 09:48:05 2000 @@ -0,0 +1,875 @@ +/* + * drivers/input/adbhid.c + * + * ADB HID driver for Power Macintosh computers. + * + * Adapted from drivers/macintosh/mac_keyb.c by Franz Sirl + * (see that file for its authors and contributors). + * + * Copyright (C) 2000 Franz Sirl. + * + * Adapted to ADB changes and support for more devices by + * Benjamin Herrenschmidt. Adapted from code in MkLinux + * and reworked. + * + * Supported devices: + * + * - Standard 1 button mouse + * - All standard Apple Extended protocol (handler ID 4) + * - mouseman and trackman mice & trackballs + * - PowerBook Trackpad (default setup: enable tapping) + * - MicroSpeed mouse & trackball (needs testing) + * - CH Products Trackball Pro (needs testing) + * - Contour Design (Contour Mouse) + * - Hunter digital (NoHandsMouse) + * - Kensignton TurboMouse 5 (needs testing) + * - Mouse Systems A3 mice and trackballs + * - MacAlly 2-buttons mouse (needs testing) + * + * To do: + * + * Improve Kensington support. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#ifdef CONFIG_PMAC_BACKLIGHT +#include +#endif + +MODULE_AUTHOR("Franz Sirl "); + +#define KEYB_KEYREG 0 /* register # for key up/down data */ +#define KEYB_LEDREG 2 /* register # for leds on ADB keyboard */ +#define MOUSE_DATAREG 0 /* reg# for movement/button codes from mouse */ + +static int adb_message_handler(struct notifier_block *, unsigned long, void *); +static struct notifier_block adbhid_adb_notifier = { + notifier_call: adb_message_handler, +}; + +unsigned char adb_to_linux_keycodes[128] = { + 30, 31, 32, 33, 35, 34, 44, 45, 46, 47, 86, 48, 16, 17, 18, 19, + 21, 20, 2, 3, 4, 5, 7, 6, 13, 10, 8, 12, 9, 11, 27, 24, + 22, 26, 23, 25, 28, 38, 36, 40, 37, 39, 43, 51, 53, 49, 50, 52, + 15, 57, 41, 14, 96, 1, 29,125, 42, 58, 56,105,106,108,103, 0, + 0, 83, 0, 55, 0, 78, 0, 69, 0, 0, 0, 98, 96, 0, 74, 0, + 0,117, 82, 79, 80, 81, 75, 76, 77, 71, 0, 72, 73,183,181,124, + 63, 64, 65, 61, 66, 67,191, 87,190, 99, 0, 70, 0, 68,101, 88, + 0,119,110,102,104,111, 62,107, 60,109, 59, 54,100, 97,116,116 +}; + +struct adbhid { + struct input_dev input; + int id; + int default_id; + int original_handler_id; + int current_handler_id; + int mouse_kind; + unsigned char *keycode; + char name[64]; +}; + +static struct adbhid *adbhid[16] = { 0 }; + +static void adbhid_probe(void); + +static void adbhid_input_keycode(int, int, int); +static void leds_done(struct adb_request *); + +static void init_trackpad(int id); +static void init_trackball(int id); +static void init_turbomouse(int id); +static void init_microspeed(int id); +static void init_ms_a3(int id); + +static struct adb_ids keyboard_ids; +static struct adb_ids mouse_ids; +static struct adb_ids buttons_ids; + +/* Kind of keyboard, see Apple technote 1152 */ +#define ADB_KEYBOARD_UNKNOWN 0 +#define ADB_KEYBOARD_ANSI 0x0100 +#define ADB_KEYBOARD_ISO 0x0200 +#define ADB_KEYBOARD_JIS 0x0300 + +/* Kind of mouse */ +#define ADBMOUSE_STANDARD_100 0 /* Standard 100cpi mouse (handler 1) */ +#define ADBMOUSE_STANDARD_200 1 /* Standard 200cpi mouse (handler 2) */ +#define ADBMOUSE_EXTENDED 2 /* Apple Extended mouse (handler 4) */ +#define ADBMOUSE_TRACKBALL 3 /* TrackBall (handler 4) */ +#define ADBMOUSE_TRACKPAD 4 /* Apple's PowerBook trackpad (handler 4) */ +#define ADBMOUSE_TURBOMOUSE5 5 /* Turbomouse 5 (previously req. mousehack) */ +#define ADBMOUSE_MICROSPEED 6 /* Microspeed mouse (&trackball ?), MacPoint */ +#define ADBMOUSE_TRACKBALLPRO 7 /* Trackball Pro (special buttons) */ +#define ADBMOUSE_MS_A3 8 /* Mouse systems A3 trackball (handler 3) */ +#define ADBMOUSE_MACALLY2 9 /* MacAlly 2-button mouse */ + +static void +adbhid_keyboard_input(unsigned char *data, int nb, struct pt_regs *regs, int apoll) +{ + int id = (data[0] >> 4) & 0x0f; + + if (!adbhid[id]) { + printk(KERN_ERR "ADB HID on ID %d not yet registered, packet %#02x, %#02x, %#02x, %#02x\n", + id, data[0], data[1], data[2], data[3]); + return; + } + + /* first check this is from register 0 */ + if (nb != 3 || (data[0] & 3) != KEYB_KEYREG) + return; /* ignore it */ + kbd_pt_regs = regs; + adbhid_input_keycode(id, data[1], 0); + if (!(data[2] == 0xff || (data[2] == 0x7f && data[1] == 0x7f))) + adbhid_input_keycode(id, data[2], 0); +} + +static void +adbhid_input_keycode(int id, int keycode, int repeat) +{ + int up_flag; + + up_flag = (keycode & 0x80); + keycode &= 0x7f; + + switch (keycode) { + case 0x39: /* Generate down/up events for CapsLock everytime. */ + input_report_key(&adbhid[id]->input, KEY_CAPSLOCK, 1); + input_report_key(&adbhid[id]->input, KEY_CAPSLOCK, 0); + return; + case 0x3f: /* ignore Powerbook Fn key */ + return; + } + + if (adbhid[id]->keycode[keycode]) + input_report_key(&adbhid[id]->input, + adbhid[id]->keycode[keycode], !up_flag); + else + printk(KERN_INFO "Unhandled ADB key (scancode %#02x) %s.\n", keycode, + up_flag ? "released" : "pressed"); +} + +static void +adbhid_mouse_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll) +{ + int id = (data[0] >> 4) & 0x0f; + + if (!adbhid[id]) { + printk(KERN_ERR "ADB HID on ID %d not yet registered\n", id); + return; + } + + /* + Handler 1 -- 100cpi original Apple mouse protocol. + Handler 2 -- 200cpi original Apple mouse protocol. + + For Apple's standard one-button mouse protocol the data array will + contain the following values: + + BITS COMMENTS + data[0] = dddd 1100 ADB command: Talk, register 0, for device dddd. + data[1] = bxxx xxxx First button and x-axis motion. + data[2] = byyy yyyy Second button and y-axis motion. + + Handler 4 -- Apple Extended mouse protocol. + + For Apple's 3-button mouse protocol the data array will contain the + following values: + + BITS COMMENTS + data[0] = dddd 1100 ADB command: Talk, register 0, for device dddd. + data[1] = bxxx xxxx Left button and x-axis motion. + data[2] = byyy yyyy Second button and y-axis motion. + data[3] = byyy bxxx Third button and fourth button. Y is additional + high bits of y-axis motion. XY is additional + high bits of x-axis motion. + + MacAlly 2-button mouse protocol. + + For MacAlly 2-button mouse protocol the data array will contain the + following values: + + BITS COMMENTS + data[0] = dddd 1100 ADB command: Talk, register 0, for device dddd. + data[1] = bxxx xxxx Left button and x-axis motion. + data[2] = byyy yyyy Right button and y-axis motion. + data[3] = ???? ???? unknown + data[4] = ???? ???? unknown + + */ + + /* If it's a trackpad, we alias the second button to the first. + NOTE: Apple sends an ADB flush command to the trackpad when + the first (the real) button is released. We could do + this here using async flush requests. + */ + switch (adbhid[id]->mouse_kind) + { + case ADBMOUSE_TRACKPAD: + data[1] = (data[1] & 0x7f) | ((data[1] & data[2]) & 0x80); + data[2] = data[2] | 0x80; + break; + case ADBMOUSE_MICROSPEED: + data[1] = (data[1] & 0x7f) | ((data[3] & 0x01) << 7); + data[2] = (data[2] & 0x7f) | ((data[3] & 0x02) << 6); + data[3] = (data[3] & 0x77) | ((data[3] & 0x04) << 5) + | (data[3] & 0x08); + break; + case ADBMOUSE_TRACKBALLPRO: + data[1] = (data[1] & 0x7f) | (((data[3] & 0x04) << 5) + & ((data[3] & 0x08) << 4)); + data[2] = (data[2] & 0x7f) | ((data[3] & 0x01) << 7); + data[3] = (data[3] & 0x77) | ((data[3] & 0x02) << 6); + break; + case ADBMOUSE_MS_A3: + data[1] = (data[1] & 0x7f) | ((data[3] & 0x01) << 7); + data[2] = (data[2] & 0x7f) | ((data[3] & 0x02) << 6); + data[3] = ((data[3] & 0x04) << 5); + break; + case ADBMOUSE_MACALLY2: + data[3] = (data[2] & 0x80) ? 0x80 : 0x00; + data[2] |= 0x80; /* Right button is mapped as button 3 */ + nb=4; + break; + } + + input_report_key(&adbhid[id]->input, BTN_LEFT, !((data[1] >> 7) & 1)); + input_report_key(&adbhid[id]->input, BTN_MIDDLE, !((data[2] >> 7) & 1)); + + if (nb >= 4) + input_report_key(&adbhid[id]->input, BTN_RIGHT, !((data[3] >> 7) & 1)); + + input_report_rel(&adbhid[id]->input, REL_X, + ((data[2]&0x7f) < 64 ? (data[2]&0x7f) : (data[2]&0x7f)-128 )); + input_report_rel(&adbhid[id]->input, REL_Y, + ((data[1]&0x7f) < 64 ? (data[1]&0x7f) : (data[1]&0x7f)-128 )); +} + +static void +adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll) +{ + int id = (data[0] >> 4) & 0x0f; + + if (!adbhid[id]) { + printk(KERN_ERR "ADB HID on ID %d not yet registered\n", id); + return; + } + + switch (adbhid[id]->original_handler_id) { + default: + case 0x02: /* Adjustable keyboard button device */ + printk(KERN_INFO "Unhandled ADB_MISC event %02x, %02x, %02x, %02x\n", + data[0], data[1], data[2], data[3]); + break; + case 0x1f: /* Powerbook button device */ + { +#ifdef CONFIG_PMAC_BACKLIGHT + int backlight = get_backlight_level(); + + /* + * XXX: Where is the contrast control for the passive? + * -- Cort + */ + + switch (data[1]) { + case 0x8: /* mute */ + break; + + case 0x7: /* contrast decrease */ + break; + + case 0x6: /* contrast increase */ + break; + + case 0xa: /* brightness decrease */ + if (backlight < 0) + break; + if (backlight > BACKLIGHT_OFF) + set_backlight_level(backlight-1); + else + set_backlight_level(BACKLIGHT_OFF); + break; + + case 0x9: /* brightness increase */ + if (backlight < 0) + break; + if (backlight < BACKLIGHT_MAX) + set_backlight_level(backlight+1); + else + set_backlight_level(BACKLIGHT_MAX); + break; + } +#endif /* CONFIG_PMAC_BACKLIGHT */ + } + break; + } +} + +static struct adb_request led_request; +static int leds_pending[16]; +static int pending_devs[16]; +static int pending_led_start=0; +static int pending_led_end=0; + +static void real_leds(unsigned char leds, int device) +{ + if (led_request.complete) { + adb_request(&led_request, leds_done, 0, 3, + ADB_WRITEREG(device, KEYB_LEDREG), 0xff, + ~leds); + } else { + if (!(leds_pending[device] & 0x100)) { + pending_devs[pending_led_end] = device; + pending_led_end++; + pending_led_end = (pending_led_end < 16) ? pending_led_end : 0; + } + leds_pending[device] = leds | 0x100; + } +} + +/* + * Event callback from the input module. Events that change the state of + * the hardware are processed here. + */ +static int adbhid_kbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) +{ + struct adbhid *adbhid = dev->private; + unsigned char leds; + + switch (type) { + case EV_LED: + leds = (test_bit(LED_SCROLLL, dev->led) ? 4 : 0) + | (test_bit(LED_NUML, dev->led) ? 1 : 0) + | (test_bit(LED_CAPSL, dev->led) ? 2 : 0); + real_leds(leds, adbhid->id); + return 0; + } + + return -1; +} + +static void leds_done(struct adb_request *req) +{ + int leds,device; + + if (pending_led_start != pending_led_end) { + device = pending_devs[pending_led_start]; + leds = leds_pending[device] & 0xff; + leds_pending[device] = 0; + pending_led_start++; + pending_led_start = (pending_led_start < 16) ? pending_led_start : 0; + real_leds(leds,device); + } + +} + +static int +adb_message_handler(struct notifier_block *this, unsigned long code, void *x) +{ + unsigned long flags; + + switch (code) { + case ADB_MSG_PRE_RESET: + case ADB_MSG_POWERDOWN: + /* Stop the repeat timer. Autopoll is already off at this point */ + save_flags(flags); + cli(); + { + int i; + for (i = 1; i < 16; i++) { + if (adbhid[i]) + del_timer(&adbhid[i]->input.timer); + } + } + restore_flags(flags); + + /* Stop pending led requests */ + while(!led_request.complete) + adb_poll(); + break; + + case ADB_MSG_POST_RESET: + adbhid_probe(); + break; + } + return NOTIFY_DONE; +} + +static void +adbhid_input_register(int id, int default_id, int original_handler_id, + int current_handler_id, int mouse_kind) +{ + int i; + + if (adbhid[id]) { + printk(KERN_ERR "Trying to reregister ADB HID on ID %d\n", id); + return; + } + + if (!(adbhid[id] = kmalloc(sizeof(struct adbhid), GFP_KERNEL))) + return; + + memset(adbhid[id], 0, sizeof(struct adbhid)); + + adbhid[id]->id = default_id; + adbhid[id]->original_handler_id = original_handler_id; + adbhid[id]->current_handler_id = current_handler_id; + adbhid[id]->mouse_kind = mouse_kind; + adbhid[id]->input.private = adbhid[id]; + adbhid[id]->input.name = adbhid[id]->name; + adbhid[id]->input.idbus = BUS_ADB; + adbhid[id]->input.idvendor = 0x0001; + adbhid[id]->input.idproduct = (id << 12) | (default_id << 8) | original_handler_id; + adbhid[id]->input.idversion = 0x0100; + + switch (default_id) { + case ADB_KEYBOARD: + if (!(adbhid[id]->keycode = kmalloc(sizeof(adb_to_linux_keycodes), GFP_KERNEL))) { + kfree(adbhid[id]); + return; + } + + sprintf(adbhid[id]->name, "ADB keyboard on ID %d:%d.%02x", + id, default_id, original_handler_id); + + memcpy(adbhid[id]->keycode, adb_to_linux_keycodes, sizeof(adb_to_linux_keycodes)); + + printk(KERN_INFO "Detected ADB keyboard, type "); + switch (original_handler_id) { + default: + printk(".\n"); + adbhid[id]->input.idversion = ADB_KEYBOARD_UNKNOWN; + break; + + case 0x01: case 0x02: case 0x03: case 0x06: case 0x08: + case 0x0C: case 0x10: case 0x18: case 0x1B: case 0x1C: + case 0xC0: case 0xC3: case 0xC6: + printk("ANSI.\n"); + adbhid[id]->input.idversion = ADB_KEYBOARD_ANSI; + break; + + case 0x04: case 0x05: case 0x07: case 0x09: case 0x0D: + case 0x11: case 0x14: case 0x19: case 0x1D: case 0xC1: + case 0xC4: case 0xC7: + printk("ISO, swapping keys.\n"); + adbhid[id]->input.idversion = ADB_KEYBOARD_ISO; + i = adbhid[id]->keycode[10]; + adbhid[id]->keycode[10] = adbhid[id]->keycode[50]; + adbhid[id]->keycode[50] = i; + break; + + case 0x12: case 0x15: case 0x16: case 0x17: case 0x1A: + case 0x1E: case 0xC2: case 0xC5: case 0xC8: case 0xC9: + printk("JIS.\n"); + adbhid[id]->input.idversion = ADB_KEYBOARD_JIS; + break; + } + + for (i = 0; i < 128; i++) + if (adbhid[id]->keycode[i]) + set_bit(adbhid[id]->keycode[i], adbhid[id]->input.keybit); + + adbhid[id]->input.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); + adbhid[id]->input.ledbit[0] = BIT(LED_SCROLLL) | BIT(LED_CAPSL) | BIT(LED_NUML); + adbhid[id]->input.event = adbhid_kbd_event; + adbhid[id]->input.keycodemax = 127; + adbhid[id]->input.keycodesize = 1; + break; + + case ADB_MOUSE: + sprintf(adbhid[id]->name, "ADB mouse on ID %d:%d.%02x", + id, default_id, original_handler_id); + + adbhid[id]->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); + adbhid[id]->input.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); + adbhid[id]->input.relbit[0] = BIT(REL_X) | BIT(REL_Y); + break; + + case ADB_MISC: + switch (original_handler_id) { + case 0x02: /* Adjustable keyboard button device */ + sprintf(adbhid[id]->name, "ADB adjustable keyboard buttons on ID %d:%d.%02x", + id, default_id, original_handler_id); + break; + case 0x1f: /* Powerbook button device */ + sprintf(adbhid[id]->name, "ADB Powerbook buttons on ID %d:%d.%02x", + id, default_id, original_handler_id); + break; + } + if (adbhid[id]->name[0]) + break; + /* else fall through */ + + default: + printk(KERN_INFO "Trying to register unknown ADB device to input layer.\n"); + kfree(adbhid[id]); + return; + } + + adbhid[id]->input.keycode = adbhid[id]->keycode; + + input_register_device(&adbhid[id]->input); + + printk(KERN_INFO "input%d: ADB HID on ID %d:%d.%02x\n", + adbhid[id]->input.number, id, default_id, original_handler_id); + + if (default_id == ADB_KEYBOARD) { + /* HACK WARNING!! This should go away as soon there is an utility + * to control that for event devices. + */ + adbhid[id]->input.rep[REP_DELAY] = HZ/2; /* input layer default: HZ/4 */ + adbhid[id]->input.rep[REP_PERIOD] = HZ/15; /* input layer default: HZ/33 */ + } +} + +static void adbhid_input_unregister(int id) +{ + input_unregister_device(&adbhid[id]->input); + if (adbhid[id]->keycode) + kfree(adbhid[id]->keycode); + kfree(adbhid[id]); + adbhid[id] = 0; +} + + +static void +adbhid_probe(void) +{ + struct adb_request req; + int i, default_id, org_handler_id, cur_handler_id; + + for (i = 1; i < 16; i++) { + if (adbhid[i]) + adbhid_input_unregister(i); + } + + adb_register(ADB_MOUSE, 0, &mouse_ids, adbhid_mouse_input); + adb_register(ADB_KEYBOARD, 0, &keyboard_ids, adbhid_keyboard_input); + adb_register(ADB_MISC, 0, &buttons_ids, adbhid_buttons_input); + + for (i = 0; i < keyboard_ids.nids; i++) { + int id = keyboard_ids.id[i]; + + adb_get_infos(id, &default_id, &org_handler_id); + + /* turn off all leds */ + adb_request(&req, NULL, ADBREQ_SYNC, 3, + ADB_WRITEREG(id, KEYB_LEDREG), 0xff, 0xff); + + /* Enable full feature set of the keyboard + ->get it to send separate codes for left and right shift, + control, option keys */ +#if 0 /* handler 5 doesn't send separate codes for R modifiers */ + if (adb_try_handler_change(id, 5)) + printk("ADB keyboard at %d, handler set to 5\n", id); + else +#endif + if (adb_try_handler_change(id, 3)) + printk("ADB keyboard at %d, handler set to 3\n", id); + else + printk("ADB keyboard at %d, handler 1\n", id); + + adb_get_infos(id, &default_id, &cur_handler_id); + adbhid_input_register(id, default_id, org_handler_id, cur_handler_id, 0); + } + + for (i = 0; i < buttons_ids.nids; i++) { + int id = buttons_ids.id[i]; + + adb_get_infos(id, &default_id, &org_handler_id); + adbhid_input_register(id, default_id, org_handler_id, org_handler_id, 0); + } + + /* Try to switch all mice to handler 4, or 2 for three-button + mode and full resolution. */ + for (i = 0; i < mouse_ids.nids; i++) { + int id = mouse_ids.id[i]; + int mouse_kind; + + adb_get_infos(id, &default_id, &org_handler_id); + + if (adb_try_handler_change(id, 4)) { + printk("ADB mouse at %d, handler set to 4", id); + mouse_kind = ADBMOUSE_EXTENDED; + } + else if (adb_try_handler_change(id, 0x2F)) { + printk("ADB mouse at %d, handler set to 0x2F", id); + mouse_kind = ADBMOUSE_MICROSPEED; + } + else if (adb_try_handler_change(id, 0x42)) { + printk("ADB mouse at %d, handler set to 0x42", id); + mouse_kind = ADBMOUSE_TRACKBALLPRO; + } + else if (adb_try_handler_change(id, 0x66)) { + printk("ADB mouse at %d, handler set to 0x66", id); + mouse_kind = ADBMOUSE_MICROSPEED; + } + else if (adb_try_handler_change(id, 0x5F)) { + printk("ADB mouse at %d, handler set to 0x5F", id); + mouse_kind = ADBMOUSE_MICROSPEED; + } + else if (adb_try_handler_change(id, 3)) { + printk("ADB mouse at %d, handler set to 3", id); + mouse_kind = ADBMOUSE_MS_A3; + } + else if (adb_try_handler_change(id, 2)) { + printk("ADB mouse at %d, handler set to 2", id); + mouse_kind = ADBMOUSE_STANDARD_200; + } + else { + printk("ADB mouse at %d, handler 1", id); + mouse_kind = ADBMOUSE_STANDARD_100; + } + + if ((mouse_kind == ADBMOUSE_TRACKBALLPRO) + || (mouse_kind == ADBMOUSE_MICROSPEED)) { + init_microspeed(id); + } else if (mouse_kind == ADBMOUSE_MS_A3) { + init_ms_a3(id); + } else if (mouse_kind == ADBMOUSE_EXTENDED) { + /* + * Register 1 is usually used for device + * identification. Here, we try to identify + * a known device and call the appropriate + * init function. + */ + adb_request(&req, NULL, ADBREQ_SYNC | ADBREQ_REPLY, 1, + ADB_READREG(id, 1)); + + if ((req.reply_len) && + (req.reply[1] == 0x9a) && ((req.reply[2] == 0x21) + || (req.reply[2] == 0x20))) { + mouse_kind = ADBMOUSE_TRACKBALL; + init_trackball(id); + } + else if ((req.reply_len >= 4) && + (req.reply[1] == 0x74) && (req.reply[2] == 0x70) && + (req.reply[3] == 0x61) && (req.reply[4] == 0x64)) { + mouse_kind = ADBMOUSE_TRACKPAD; + init_trackpad(id); + } + else if ((req.reply_len >= 4) && + (req.reply[1] == 0x4b) && (req.reply[2] == 0x4d) && + (req.reply[3] == 0x4c) && (req.reply[4] == 0x31)) { + mouse_kind = ADBMOUSE_TURBOMOUSE5; + init_turbomouse(id); + } + else if ((req.reply_len == 9) && + (req.reply[1] == 0x4b) && (req.reply[2] == 0x4f) && + (req.reply[3] == 0x49) && (req.reply[4] == 0x54)) { + if (adb_try_handler_change(id, 0x42)) { + printk("\nADB MacAlly 2-button mouse at %d, handler set to 0x42", id); + mouse_kind = ADBMOUSE_MACALLY2; + } + } + } + printk("\n"); + + adb_get_infos(id, &default_id, &cur_handler_id); + adbhid_input_register(id, default_id, org_handler_id, + cur_handler_id, mouse_kind); + } +} + +static void +init_trackpad(int id) +{ + struct adb_request req; + unsigned char r1_buffer[8]; + + printk(" (trackpad)"); + + adb_request(&req, NULL, ADBREQ_SYNC | ADBREQ_REPLY, 1, + ADB_READREG(id,1)); + if (req.reply_len < 8) + printk("bad length for reg. 1\n"); + else + { + memcpy(r1_buffer, &req.reply[1], 8); + adb_request(&req, NULL, ADBREQ_SYNC, 9, + ADB_WRITEREG(id,1), + r1_buffer[0], + r1_buffer[1], + r1_buffer[2], + r1_buffer[3], + r1_buffer[4], + r1_buffer[5], + 0x0d, /*r1_buffer[6],*/ + r1_buffer[7]); + + adb_request(&req, NULL, ADBREQ_SYNC, 9, + ADB_WRITEREG(id,2), + 0x99, + 0x94, + 0x19, + 0xff, + 0xb2, + 0x8a, + 0x1b, + 0x50); + + adb_request(&req, NULL, ADBREQ_SYNC, 9, + ADB_WRITEREG(id,1), + r1_buffer[0], + r1_buffer[1], + r1_buffer[2], + r1_buffer[3], + r1_buffer[4], + r1_buffer[5], + 0x03, /*r1_buffer[6],*/ + r1_buffer[7]); + } +} + +static void +init_trackball(int id) +{ + struct adb_request req; + + printk(" (trackman/mouseman)"); + + adb_request(&req, NULL, ADBREQ_SYNC, 3, + ADB_WRITEREG(id,1), 00,0x81); + + adb_request(&req, NULL, ADBREQ_SYNC, 3, + ADB_WRITEREG(id,1), 01,0x81); + + adb_request(&req, NULL, ADBREQ_SYNC, 3, + ADB_WRITEREG(id,1), 02,0x81); + + adb_request(&req, NULL, ADBREQ_SYNC, 3, + ADB_WRITEREG(id,1), 03,0x38); + + adb_request(&req, NULL, ADBREQ_SYNC, 3, + ADB_WRITEREG(id,1), 00,0x81); + + adb_request(&req, NULL, ADBREQ_SYNC, 3, + ADB_WRITEREG(id,1), 01,0x81); + + adb_request(&req, NULL, ADBREQ_SYNC, 3, + ADB_WRITEREG(id,1), 02,0x81); + + adb_request(&req, NULL, ADBREQ_SYNC, 3, + ADB_WRITEREG(id,1), 03,0x38); +} + +static void +init_turbomouse(int id) +{ + struct adb_request req; + + printk(" (TurboMouse 5)"); + + adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id)); + + adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(3)); + + adb_request(&req, NULL, ADBREQ_SYNC, 9, + ADB_WRITEREG(3,2), + 0xe7, + 0x8c, + 0, + 0, + 0, + 0xff, + 0xff, + 0x94); + + adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(3)); + + adb_request(&req, NULL, ADBREQ_SYNC, 9, + ADB_WRITEREG(3,2), + 0xa5, + 0x14, + 0, + 0, + 0x69, + 0xff, + 0xff, + 0x27); +} + +static void +init_microspeed(int id) +{ + struct adb_request req; + + printk(" (Microspeed/MacPoint or compatible)"); + + adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id)); + + /* This will initialize mice using the Microspeed, MacPoint and + other compatible firmware. Bit 12 enables extended protocol. + + Register 1 Listen (4 Bytes) + 0 - 3 Button is mouse (set also for double clicking!!!) + 4 - 7 Button is locking (affects change speed also) + 8 - 11 Button changes speed + 12 1 = Extended mouse mode, 0 = normal mouse mode + 13 - 15 unused 0 + 16 - 23 normal speed + 24 - 31 changed speed + + Register 1 talk holds version and product identification information. + Register 1 Talk (4 Bytes): + 0 - 7 Product code + 8 - 23 undefined, reserved + 24 - 31 Version number + + Speed 0 is max. 1 to 255 set speed in increments of 1/256 of max. + */ + adb_request(&req, NULL, ADBREQ_SYNC, 5, + ADB_WRITEREG(id,1), + 0x20, /* alt speed = 0x20 (rather slow) */ + 0x00, /* norm speed = 0x00 (fastest) */ + 0x10, /* extended protocol, no speed change */ + 0x07); /* all buttons enabled as mouse buttons, no locking */ + + + adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id)); +} + +static void +init_ms_a3(int id) +{ + struct adb_request req; + + printk(" (Mouse Systems A3 Mouse, or compatible)"); + adb_request(&req, NULL, ADBREQ_SYNC, 3, + ADB_WRITEREG(id, 0x2), + 0x00, + 0x07); + + adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id)); +} + +static int __init adbhid_init(void) +{ + if ( (_machine != _MACH_chrp) && (_machine != _MACH_Pmac) ) + return 0; + + led_request.complete = 1; + + adbhid_probe(); + + notifier_chain_register(&adb_client_list, &adbhid_adb_notifier); + + return 0; +} + +static void __exit adbhid_exit(void) +{ +} + +module_init(adbhid_init); +module_exit(adbhid_exit); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/macintosh/mac_hid.c linux/drivers/macintosh/mac_hid.c --- v2.4.0-test8/linux/drivers/macintosh/mac_hid.c Wed Dec 31 16:00:00 1969 +++ linux/drivers/macintosh/mac_hid.c Sun Sep 17 09:48:05 2000 @@ -0,0 +1,492 @@ +/* + * drivers/macintosh/mac_hid.c + * + * HID support stuff for Macintosh computers. + * + * Copyright (C) 2000 Franz Sirl. + * + * Stuff inside CONFIG_MAC_ADBKEYCODES should go away during 2.5 when all + * major distributions are using the Linux keycodes. + * Stuff inside CONFIG_MAC_EMUMOUSEBTN should really be moved to userspace. + */ + +#include +#include +#include +#include +#include + +#ifdef CONFIG_MAC_ADBKEYCODES +#include +#include +#include +#endif + +#ifdef CONFIG_MAC_ADBKEYCODES +/* Simple translation table for the SysRq keys */ + +#ifdef CONFIG_MAGIC_SYSRQ +unsigned char mac_hid_kbd_sysrq_xlate[128] = + "asdfhgzxcv\000bqwer" /* 0x00 - 0x0f */ + "yt123465=97-80o]" /* 0x10 - 0x1f */ + "u[ip\rlj'k;\\,/nm." /* 0x20 - 0x2f */ + "\t `\177\000\033\000\000\000\000\000\000\000\000\000\000" + /* 0x30 - 0x3f */ + "\000\000\000*\000+\000\000\000\000\000/\r\000-\000" + /* 0x40 - 0x4f */ + "\000\0000123456789\000\000\000" /* 0x50 - 0x5f */ + "\205\206\207\203\210\211\000\213\000\215\000\000\000\000\000\212\000\214"; + /* 0x60 - 0x6f */ +extern unsigned char pckbd_sysrq_xlate[128]; +#endif + +static u_short macplain_map[NR_KEYS] = { + 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb68, 0xfb67, 0xfb7a, 0xfb78, + 0xfb63, 0xfb76, 0xf200, 0xfb62, 0xfb71, 0xfb77, 0xfb65, 0xfb72, + 0xfb79, 0xfb74, 0xf031, 0xf032, 0xf033, 0xf034, 0xf036, 0xf035, + 0xf03d, 0xf039, 0xf037, 0xf02d, 0xf038, 0xf030, 0xf05d, 0xfb6f, + 0xfb75, 0xf05b, 0xfb69, 0xfb70, 0xf201, 0xfb6c, 0xfb6a, 0xf027, + 0xfb6b, 0xf03b, 0xf05c, 0xf02c, 0xf02f, 0xfb6e, 0xfb6d, 0xf02e, + 0xf009, 0xf020, 0xf060, 0xf07f, 0xf200, 0xf01b, 0xf702, 0xf703, + 0xf700, 0xf207, 0xf701, 0xf601, 0xf602, 0xf600, 0xf603, 0xf200, + 0xf200, 0xf310, 0xf200, 0xf30c, 0xf200, 0xf30a, 0xf200, 0xf208, + 0xf200, 0xf200, 0xf200, 0xf30d, 0xf30e, 0xf200, 0xf30b, 0xf200, + 0xf200, 0xf200, 0xf300, 0xf301, 0xf302, 0xf303, 0xf304, 0xf305, + 0xf306, 0xf307, 0xf200, 0xf308, 0xf309, 0xf200, 0xf200, 0xf200, + 0xf104, 0xf105, 0xf106, 0xf102, 0xf107, 0xf108, 0xf200, 0xf10a, + 0xf200, 0xf10c, 0xf200, 0xf209, 0xf200, 0xf109, 0xf200, 0xf10b, + 0xf200, 0xf11d, 0xf115, 0xf114, 0xf118, 0xf116, 0xf103, 0xf117, + 0xf101, 0xf119, 0xf100, 0xf700, 0xf701, 0xf702, 0xf200, 0xf200, +}; + +static u_short macshift_map[NR_KEYS] = { + 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb48, 0xfb47, 0xfb5a, 0xfb58, + 0xfb43, 0xfb56, 0xf200, 0xfb42, 0xfb51, 0xfb57, 0xfb45, 0xfb52, + 0xfb59, 0xfb54, 0xf021, 0xf040, 0xf023, 0xf024, 0xf05e, 0xf025, + 0xf02b, 0xf028, 0xf026, 0xf05f, 0xf02a, 0xf029, 0xf07d, 0xfb4f, + 0xfb55, 0xf07b, 0xfb49, 0xfb50, 0xf201, 0xfb4c, 0xfb4a, 0xf022, + 0xfb4b, 0xf03a, 0xf07c, 0xf03c, 0xf03f, 0xfb4e, 0xfb4d, 0xf03e, + 0xf009, 0xf020, 0xf07e, 0xf07f, 0xf200, 0xf01b, 0xf702, 0xf703, + 0xf700, 0xf207, 0xf701, 0xf601, 0xf602, 0xf600, 0xf603, 0xf200, + 0xf200, 0xf310, 0xf200, 0xf30c, 0xf200, 0xf30a, 0xf200, 0xf208, + 0xf200, 0xf200, 0xf200, 0xf30d, 0xf30e, 0xf200, 0xf30b, 0xf200, + 0xf200, 0xf200, 0xf300, 0xf301, 0xf302, 0xf303, 0xf304, 0xf305, + 0xf306, 0xf307, 0xf200, 0xf308, 0xf309, 0xf200, 0xf200, 0xf200, + 0xf10e, 0xf10f, 0xf110, 0xf10c, 0xf111, 0xf112, 0xf200, 0xf10a, + 0xf200, 0xf10c, 0xf200, 0xf203, 0xf200, 0xf113, 0xf200, 0xf10b, + 0xf200, 0xf11d, 0xf115, 0xf114, 0xf20b, 0xf116, 0xf10d, 0xf117, + 0xf10b, 0xf20a, 0xf10a, 0xf700, 0xf701, 0xf702, 0xf200, 0xf200, +}; + +static u_short macaltgr_map[NR_KEYS] = { + 0xf914, 0xfb73, 0xf917, 0xf919, 0xfb68, 0xfb67, 0xfb7a, 0xfb78, + 0xf916, 0xfb76, 0xf200, 0xf915, 0xfb71, 0xfb77, 0xf918, 0xfb72, + 0xfb79, 0xfb74, 0xf200, 0xf040, 0xf200, 0xf024, 0xf200, 0xf200, + 0xf200, 0xf05d, 0xf07b, 0xf05c, 0xf05b, 0xf07d, 0xf07e, 0xfb6f, + 0xfb75, 0xf200, 0xfb69, 0xfb70, 0xf201, 0xfb6c, 0xfb6a, 0xf200, + 0xfb6b, 0xf200, 0xf200, 0xf200, 0xf200, 0xfb6e, 0xfb6d, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf702, 0xf703, + 0xf700, 0xf207, 0xf701, 0xf601, 0xf602, 0xf600, 0xf603, 0xf200, + 0xf200, 0xf310, 0xf200, 0xf30c, 0xf200, 0xf30a, 0xf200, 0xf208, + 0xf200, 0xf200, 0xf200, 0xf30d, 0xf30e, 0xf200, 0xf30b, 0xf200, + 0xf200, 0xf200, 0xf90a, 0xf90b, 0xf90c, 0xf90d, 0xf90e, 0xf90f, + 0xf910, 0xf911, 0xf200, 0xf912, 0xf913, 0xf200, 0xf200, 0xf200, + 0xf510, 0xf511, 0xf512, 0xf50e, 0xf513, 0xf514, 0xf200, 0xf516, + 0xf200, 0xf10c, 0xf200, 0xf202, 0xf200, 0xf515, 0xf200, 0xf517, + 0xf200, 0xf11d, 0xf115, 0xf114, 0xf118, 0xf116, 0xf50f, 0xf117, + 0xf50d, 0xf119, 0xf50c, 0xf700, 0xf701, 0xf702, 0xf200, 0xf200, +}; + +static u_short macctrl_map[NR_KEYS] = { + 0xf001, 0xf013, 0xf004, 0xf006, 0xf008, 0xf007, 0xf01a, 0xf018, + 0xf003, 0xf016, 0xf200, 0xf002, 0xf011, 0xf017, 0xf005, 0xf012, + 0xf019, 0xf014, 0xf200, 0xf000, 0xf01b, 0xf01c, 0xf01e, 0xf01d, + 0xf200, 0xf200, 0xf01f, 0xf01f, 0xf07f, 0xf200, 0xf01d, 0xf00f, + 0xf015, 0xf01b, 0xf009, 0xf010, 0xf201, 0xf00c, 0xf00a, 0xf007, + 0xf00b, 0xf200, 0xf01c, 0xf200, 0xf07f, 0xf00e, 0xf00d, 0xf20e, + 0xf200, 0xf000, 0xf000, 0xf008, 0xf200, 0xf200, 0xf702, 0xf703, + 0xf700, 0xf207, 0xf701, 0xf601, 0xf602, 0xf600, 0xf603, 0xf200, + 0xf200, 0xf310, 0xf200, 0xf30c, 0xf200, 0xf30a, 0xf200, 0xf208, + 0xf200, 0xf200, 0xf200, 0xf30d, 0xf30e, 0xf200, 0xf30b, 0xf200, + 0xf200, 0xf200, 0xf300, 0xf301, 0xf302, 0xf303, 0xf304, 0xf305, + 0xf306, 0xf307, 0xf200, 0xf308, 0xf309, 0xf200, 0xf200, 0xf200, + 0xf104, 0xf105, 0xf106, 0xf102, 0xf107, 0xf108, 0xf200, 0xf10a, + 0xf200, 0xf10c, 0xf200, 0xf204, 0xf200, 0xf109, 0xf200, 0xf10b, + 0xf200, 0xf11d, 0xf115, 0xf114, 0xf118, 0xf116, 0xf103, 0xf117, + 0xf101, 0xf119, 0xf100, 0xf700, 0xf701, 0xf702, 0xf200, 0xf200, +}; + +static u_short macshift_ctrl_map[NR_KEYS] = { + 0xf001, 0xf013, 0xf004, 0xf006, 0xf008, 0xf007, 0xf01a, 0xf018, + 0xf003, 0xf016, 0xf200, 0xf002, 0xf011, 0xf017, 0xf005, 0xf012, + 0xf019, 0xf014, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf200, 0xf200, 0xf00f, + 0xf015, 0xf200, 0xf009, 0xf010, 0xf201, 0xf00c, 0xf00a, 0xf200, + 0xf00b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf00e, 0xf00d, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf702, 0xf703, + 0xf700, 0xf207, 0xf701, 0xf601, 0xf602, 0xf600, 0xf603, 0xf200, + 0xf200, 0xf310, 0xf200, 0xf30c, 0xf200, 0xf30a, 0xf200, 0xf208, + 0xf200, 0xf200, 0xf200, 0xf30d, 0xf30e, 0xf200, 0xf30b, 0xf200, + 0xf200, 0xf200, 0xf300, 0xf301, 0xf302, 0xf303, 0xf304, 0xf305, + 0xf306, 0xf307, 0xf200, 0xf308, 0xf309, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf10c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf11d, 0xf115, 0xf114, 0xf118, 0xf116, 0xf200, 0xf117, + 0xf200, 0xf119, 0xf200, 0xf700, 0xf701, 0xf702, 0xf200, 0xf20c, +}; + +static u_short macalt_map[NR_KEYS] = { + 0xf861, 0xf873, 0xf864, 0xf866, 0xf868, 0xf867, 0xf87a, 0xf878, + 0xf863, 0xf876, 0xf200, 0xf862, 0xf871, 0xf877, 0xf865, 0xf872, + 0xf879, 0xf874, 0xf831, 0xf832, 0xf833, 0xf834, 0xf836, 0xf835, + 0xf83d, 0xf839, 0xf837, 0xf82d, 0xf838, 0xf830, 0xf85d, 0xf86f, + 0xf875, 0xf85b, 0xf869, 0xf870, 0xf80d, 0xf86c, 0xf86a, 0xf827, + 0xf86b, 0xf83b, 0xf85c, 0xf82c, 0xf82f, 0xf86e, 0xf86d, 0xf82e, + 0xf809, 0xf820, 0xf860, 0xf87f, 0xf200, 0xf81b, 0xf702, 0xf703, + 0xf700, 0xf207, 0xf701, 0xf210, 0xf211, 0xf600, 0xf603, 0xf200, + 0xf200, 0xf310, 0xf200, 0xf30c, 0xf200, 0xf30a, 0xf200, 0xf208, + 0xf200, 0xf200, 0xf200, 0xf30d, 0xf30e, 0xf200, 0xf30b, 0xf200, + 0xf200, 0xf200, 0xf900, 0xf901, 0xf902, 0xf903, 0xf904, 0xf905, + 0xf906, 0xf907, 0xf200, 0xf908, 0xf909, 0xf200, 0xf200, 0xf200, + 0xf504, 0xf505, 0xf506, 0xf502, 0xf507, 0xf508, 0xf200, 0xf50a, + 0xf200, 0xf10c, 0xf200, 0xf209, 0xf200, 0xf509, 0xf200, 0xf50b, + 0xf200, 0xf11d, 0xf115, 0xf114, 0xf118, 0xf116, 0xf503, 0xf117, + 0xf501, 0xf119, 0xf500, 0xf700, 0xf701, 0xf702, 0xf200, 0xf200, +}; + +static u_short macctrl_alt_map[NR_KEYS] = { + 0xf801, 0xf813, 0xf804, 0xf806, 0xf808, 0xf807, 0xf81a, 0xf818, + 0xf803, 0xf816, 0xf200, 0xf802, 0xf811, 0xf817, 0xf805, 0xf812, + 0xf819, 0xf814, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf80f, + 0xf815, 0xf200, 0xf809, 0xf810, 0xf201, 0xf80c, 0xf80a, 0xf200, + 0xf80b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf80e, 0xf80d, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf702, 0xf703, + 0xf700, 0xf207, 0xf701, 0xf601, 0xf602, 0xf600, 0xf603, 0xf200, + 0xf200, 0xf310, 0xf200, 0xf30c, 0xf200, 0xf30a, 0xf200, 0xf208, + 0xf200, 0xf200, 0xf200, 0xf30d, 0xf30e, 0xf200, 0xf30b, 0xf200, + 0xf200, 0xf200, 0xf300, 0xf301, 0xf302, 0xf303, 0xf304, 0xf305, + 0xf306, 0xf307, 0xf200, 0xf308, 0xf309, 0xf200, 0xf200, 0xf200, + 0xf504, 0xf505, 0xf506, 0xf502, 0xf507, 0xf508, 0xf200, 0xf50a, + 0xf200, 0xf10c, 0xf200, 0xf200, 0xf200, 0xf509, 0xf200, 0xf50b, + 0xf200, 0xf11d, 0xf115, 0xf114, 0xf118, 0xf116, 0xf503, 0xf117, + 0xf501, 0xf119, 0xf500, 0xf700, 0xf701, 0xf702, 0xf200, 0xf200, +}; + +static unsigned short *mac_key_maps_save[MAX_NR_KEYMAPS] = { + macplain_map, macshift_map, macaltgr_map, 0, + macctrl_map, macshift_ctrl_map, 0, 0, + macalt_map, 0, 0, 0, + macctrl_alt_map, 0 +}; + +static unsigned short *pc_key_maps_save[MAX_NR_KEYMAPS]; + +int mac_hid_kbd_translate(unsigned char keycode, unsigned char *keycodep, + char raw_mode); +static int mac_hid_sysctl_keycodes(ctl_table *ctl, int write, struct file * filp, + void *buffer, size_t *lenp); +char mac_hid_kbd_unexpected_up(unsigned char keycode); + +static int keyboard_lock_keycodes = 0; +int keyboard_sends_linux_keycodes = 0; +#else +int keyboard_sends_linux_keycodes = 1; +#endif + + +static unsigned char e0_keys[128] = { + 0, 0, 0, KEY_KPCOMMA, 0, KEY_INTL3, 0, 0, /* 0x00-0x07 */ + 0, 0, 0, 0, KEY_LANG1, KEY_LANG2, 0, 0, /* 0x08-0x0f */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10-0x17 */ + 0, 0, 0, 0, KEY_KPENTER, KEY_RIGHTCTRL, 0, 0, /* 0x18-0x1f */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20-0x27 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x28-0x2f */ + 0, 0, 0, 0, 0, KEY_KPSLASH, 0, KEY_SYSRQ, /* 0x30-0x37 */ + KEY_RIGHTALT, 0, 0, 0, 0, 0, 0, 0, /* 0x38-0x3f */ + 0, 0, 0, 0, 0, 0, 0, KEY_HOME, /* 0x40-0x47 */ + KEY_UP, KEY_PAGEUP, 0, KEY_LEFT, 0, KEY_RIGHT, 0, KEY_END, /* 0x48-0x4f */ + KEY_DOWN, KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, 0, 0, 0, 0, /* 0x50-0x57 */ + 0, 0, 0, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_COMPOSE, 0, 0, /* 0x58-0x5f */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */ + 0, 0, 0, 0, 0, 0, 0, KEY_MACRO, /* 0x68-0x6f */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77 */ + 0, 0, 0, 0, 0, 0, 0, 0 /* 0x78-0x7f */ +}; + +#ifdef CONFIG_MAC_EMUMOUSEBTN +static struct input_dev emumousebtn; +static void emumousebtn_input_register(void); +static int mouse_emulate_buttons = 0; +static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */ +static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */ +static int mouse_last_keycode = 0; +#endif + +extern void pckbd_init_hw(void); + +#if defined CONFIG_SYSCTL && (defined(CONFIG_MAC_ADBKEYCODES) || defined(CONFIG_MAC_EMUMOUSEBTN)) +/* file(s) in /proc/sys/dev/mac_hid */ +ctl_table mac_hid_files[] = +{ +#ifdef CONFIG_MAC_ADBKEYCODES + { + DEV_MAC_HID_KEYBOARD_SENDS_LINUX_KEYCODES, + "keyboard_sends_linux_keycodes", &keyboard_sends_linux_keycodes, sizeof(int), + 0644, NULL, &mac_hid_sysctl_keycodes + }, + { + DEV_MAC_HID_KEYBOARD_LOCK_KEYCODES, + "keyboard_lock_keycodes", &keyboard_lock_keycodes, sizeof(int), + 0644, NULL, &proc_dointvec + }, +#endif +#ifdef CONFIG_MAC_EMUMOUSEBTN + { + DEV_MAC_HID_MOUSE_BUTTON_EMULATION, + "mouse_button_emulation", &mouse_emulate_buttons, sizeof(int), + 0644, NULL, &proc_dointvec + }, + { + DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE, + "mouse_button2_keycode", &mouse_button2_keycode, sizeof(int), + 0644, NULL, &proc_dointvec + }, + { + DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE, + "mouse_button3_keycode", &mouse_button3_keycode, sizeof(int), + 0644, NULL, &proc_dointvec + }, +#endif + { 0 } +}; + +/* dir in /proc/sys/dev */ +ctl_table mac_hid_dir[] = +{ + { DEV_MAC_HID, "mac_hid", NULL, 0, 0555, mac_hid_files }, + { 0 } +}; + +/* /proc/sys/dev itself, in case that is not there yet */ +ctl_table mac_hid_root_dir[] = +{ + { CTL_DEV, "dev", NULL, 0, 0555, mac_hid_dir }, + { 0 } +}; + +static struct ctl_table_header *mac_hid_sysctl_header; + +#ifdef CONFIG_MAC_ADBKEYCODES +static +int mac_hid_sysctl_keycodes(ctl_table *ctl, int write, struct file * filp, + void *buffer, size_t *lenp) +{ + int val = keyboard_sends_linux_keycodes; + int ret = 0; + + if (!write + || (write && !keyboard_lock_keycodes)) + ret = proc_dointvec(ctl, write, filp, buffer, lenp); + + if (write + && keyboard_sends_linux_keycodes != val) { + if (!keyboard_sends_linux_keycodes) { +#ifdef CONFIG_MAGIC_SYSRQ + ppc_md.ppc_kbd_sysrq_xlate = mac_hid_kbd_sysrq_xlate; + SYSRQ_KEY = 0x69; +#endif + memcpy(pc_key_maps_save, key_maps, sizeof(key_maps)); + memcpy(key_maps, mac_key_maps_save, sizeof(key_maps)); + } else { +#ifdef CONFIG_MAGIC_SYSRQ + ppc_md.ppc_kbd_sysrq_xlate = pckbd_sysrq_xlate; + SYSRQ_KEY = 0x54; +#endif + memcpy(mac_key_maps_save, key_maps, sizeof(key_maps)); + memcpy(key_maps, pc_key_maps_save, sizeof(key_maps)); + } + } + + return ret; +} +#endif +#endif /* endif CONFIG_SYSCTL */ + +int mac_hid_kbd_translate(unsigned char scancode, unsigned char *keycode, + char raw_mode) +{ +#ifdef CONFIG_MAC_ADBKEYCODES + if (!keyboard_sends_linux_keycodes) { + if (!raw_mode) { + /* + * Convert R-shift/control/option to L version. + */ + switch (scancode) { + case 0x7b: scancode = 0x38; break; /* R-shift */ + case 0x7c: scancode = 0x3a; break; /* R-option */ + case 0x7d: scancode = 0x36; break; /* R-control */ + } + } + *keycode = scancode; + return 1; + } else +#endif + { + /* This code was copied from char/pc_keyb.c and will be + * superflous when the input layer is fully integrated. + * We don't need the high_keys handling, so this part + * has been removed. + */ + static int prev_scancode = 0; + + /* special prefix scancodes.. */ + if (scancode == 0xe0 || scancode == 0xe1) { + prev_scancode = scancode; + return 0; + } + + scancode &= 0x7f; + + if (prev_scancode) { + if (prev_scancode != 0xe0) { + if (prev_scancode == 0xe1 && scancode == 0x1d) { + prev_scancode = 0x100; + return 0; + } else if (prev_scancode == 0x100 && scancode == 0x45) { + *keycode = KEY_PAUSE; + prev_scancode = 0; + } else { + if (!raw_mode) + printk(KERN_INFO "keyboard: unknown e1 escape sequence\n"); + prev_scancode = 0; + return 0; + } + } else { + prev_scancode = 0; + if (scancode == 0x2a || scancode == 0x36) + return 0; + } + if (e0_keys[scancode]) + *keycode = e0_keys[scancode]; + else { + if (!raw_mode) + printk(KERN_INFO "keyboard: unknown scancode e0 %02x\n", + scancode); + return 0; + } + } else { + switch (scancode) { + case 91: scancode = KEY_LINEFEED; break; + case 92: scancode = KEY_KPEQUAL; break; + case 125: scancode = KEY_INTL1; break; + } + *keycode = scancode; + } + return 1; + } +} + +char mac_hid_kbd_unexpected_up(unsigned char keycode) +{ + if (keyboard_sends_linux_keycodes && keycode == KEY_F13) + return 0; + else + return 0x80; +} + +#ifdef CONFIG_MAC_ADBKEYCODES +int mac_hid_keyboard_sends_linux_keycodes(void) +{ + return keyboard_sends_linux_keycodes; +} + +static int __init mac_hid_setup(char *str) +{ + int ints[2]; + + str = get_options(str, ARRAY_SIZE(ints), ints); + if (ints[0] == 1) { + keyboard_sends_linux_keycodes = ints[1] != 0; + keyboard_lock_keycodes = 1; + } + return 1; +} + +__setup("keyboard_sends_linux_keycodes=", mac_hid_setup); + +#endif + +#ifdef CONFIG_MAC_EMUMOUSEBTN +int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down) +{ + switch (caller) { + case 1: + /* Called from keybdev.c */ + if (mouse_emulate_buttons + && (keycode == mouse_button2_keycode + || keycode == mouse_button3_keycode)) { + if (mouse_emulate_buttons == 1) { + input_report_key(&emumousebtn, + keycode == mouse_button2_keycode ? BTN_MIDDLE : BTN_RIGHT, + down); + return 1; + } + mouse_last_keycode = down ? keycode : 0; + } + break; + case 2: + /* Called from mousedev.c */ + if (mouse_emulate_buttons == 2 && keycode == 0) { + if (mouse_last_keycode == mouse_button2_keycode) + return 1; /* map to middle button */ + if (mouse_last_keycode == mouse_button3_keycode) + return 2; /* map to right button */ + } + return keycode; /* keep button */ + } + return 0; +} + +static void emumousebtn_input_register(void) +{ + emumousebtn.name = "Macintosh mouse button emulation"; + + emumousebtn.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); + emumousebtn.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); + emumousebtn.relbit[0] = BIT(REL_X) | BIT(REL_Y); + + emumousebtn.idbus = BUS_ADB; + emumousebtn.idvendor = 0x0001; + emumousebtn.idproduct = 0x0001; + emumousebtn.idversion = 0x0100; + + input_register_device(&emumousebtn); + + printk(KERN_INFO "input%d: Macintosh mouse button emulation\n", emumousebtn.number); +} +#endif + +void __init mac_hid_init_hw(void) +{ + +#ifdef CONFIG_MAC_ADBKEYCODES + memcpy(pc_key_maps_save, key_maps, sizeof(key_maps)); + + if (!keyboard_sends_linux_keycodes) + memcpy(key_maps, mac_key_maps_save, sizeof(key_maps)); +#endif + +#ifdef CONFIG_MAC_EMUMOUSEBTN + emumousebtn_input_register(); +#endif + +#if CONFIG_PPC + if (_machine != _MACH_Pmac) + pckbd_init_hw(); +#endif + +#if defined(CONFIG_SYSCTL) && (defined(CONFIG_MAC_ADBKEYCODES) || defined(CONFIG_MAC_EMUMOUSEBTN)) + mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir, 1); +#endif /* CONFIG_SYSCTL */ +} diff -u --recursive --new-file v2.4.0-test8/linux/drivers/macintosh/mac_keyb.c linux/drivers/macintosh/mac_keyb.c --- v2.4.0-test8/linux/drivers/macintosh/mac_keyb.c Fri Jun 23 21:55:09 2000 +++ linux/drivers/macintosh/mac_keyb.c Sun Sep 17 09:48:05 2000 @@ -51,6 +51,10 @@ #include #include +#ifdef CONFIG_PMAC_BACKLIGHT +#include +#endif + #define KEYB_KEYREG 0 /* register # for key up/down data */ #define KEYB_LEDREG 2 /* register # for leds on ADB keyboard */ #define MOUSE_DATAREG 0 /* reg# for movement/button codes from mouse */ @@ -585,68 +589,50 @@ } #endif /* CONFIG_ADBMOUSE */ -/* XXX Needs to get rid of this, see comments in pmu.c */ -extern int backlight_level; - static void buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll) { -#ifdef CONFIG_ADB_PMU +#ifdef CONFIG_PMAC_BACKLIGHT + int backlight = get_backlight_level(); + /* * XXX: Where is the contrast control for the passive? * -- Cort */ /* Ignore data from register other than 0 */ -#if 0 - if ((adb_hardware != ADB_VIAPMU) || (data[0] & 0x3) || (nb < 2)) -#else if ((data[0] & 0x3) || (nb < 2)) -#endif return; - switch (data[1]&0xf ) - { - /* mute */ - case 0x8: - /* down event */ - if ( data[1] == (data[1]&0xf) ) { - } - break; - /* contrast decrease */ - case 0x7: - /* down event */ - if ( data[1] == (data[1]&0xf) ) { - } - break; - /* contrast increase */ - case 0x6: - /* down event */ - if ( data[1] == (data[1]&0xf) ) { - } - break; - /* brightness decrease */ - case 0xa: - /* down event */ - if ( data[1] == (data[1]&0xf) ) { - if (backlight_level > 2) - pmu_set_brightness(backlight_level-2); - else - pmu_set_brightness(0); - } + switch (data[1]) { + case 0x8: /* mute */ + break; + + case 0x7: /* contrast decrease */ + break; + + case 0x6: /* contrast increase */ + break; + + case 0xa: /* brightness decrease */ + if (backlight < 0) break; - /* brightness increase */ - case 0x9: - /* down event */ - if ( data[1] == (data[1]&0xf) ) { - if (backlight_level < 0x1e) - pmu_set_brightness(backlight_level+2); - else - pmu_set_brightness(0x1f); - } + if (backlight > BACKLIGHT_OFF) + set_backlight_level(backlight-1); + else + set_backlight_level(BACKLIGHT_OFF); + break; + + case 0x9: /* brightness increase */ + if (backlight < 0) break; + if (backlight < BACKLIGHT_MAX) + set_backlight_level(backlight+1); + else + set_backlight_level(BACKLIGHT_MAX); + break; } -#endif /* CONFIG_ADB_PMU */ +#endif /* CONFIG_PMAC_BACKLIGHT */ } /* Map led flags as defined in kbd_kern.h to bits for Apple keyboard. */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/macintosh/macio-adb.c linux/drivers/macintosh/macio-adb.c --- v2.4.0-test8/linux/drivers/macintosh/macio-adb.c Sat Oct 9 11:47:50 1999 +++ linux/drivers/macintosh/macio-adb.c Sun Sep 17 09:48:05 2000 @@ -122,6 +122,8 @@ out_8(&adb->autopoll.r, APE); out_8(&adb->intr_enb.r, DFB | TAG); + printk("adb: mac-io driver 1.0 for unified ADB\n"); + return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/macintosh/macserial.c linux/drivers/macintosh/macserial.c --- v2.4.0-test8/linux/drivers/macintosh/macserial.c Tue May 23 15:31:34 2000 +++ linux/drivers/macintosh/macserial.c Sun Sep 17 09:48:05 2000 @@ -2291,7 +2291,7 @@ zss->irq = ch->intrs[0].line; zss->has_dma = 0; #if !defined(CONFIG_KGDB) && defined(SUPPORT_SERIAL_DMA) - if (ch->n_addrs == 3 && ch->n_intrs == 3) + if (ch->n_addrs >= 3 && ch->n_intrs == 3) zss->has_dma = 1; #endif zss->dma_initted = 0; @@ -2643,9 +2643,6 @@ * ------------------------------------------------------------ */ #ifdef CONFIG_SERIAL_CONSOLE -#ifdef CONFIG_SERIAL -#error Cannot build serial console with macserial and serial drivers -#endif /* * Print a string to the serial port trying not to disturb @@ -2719,7 +2716,7 @@ */ static int __init serial_console_setup(struct console *co, char *options) { - struct mac_serial *info = zs_soft + co->index; + struct mac_serial *info; int baud = 38400; int bits = 8; int parity = 'n'; @@ -2735,6 +2732,11 @@ if (zs_chain == 0) return -1; + /* Do we have the device asked for? */ + if (co->index >= zs_channels_found) + return -1; + info = zs_soft + co->index; + set_scc_power(info, 1); /* Reset the channel */ @@ -2904,7 +2906,7 @@ /* * Register console. */ -void __init serial_console_init(void) +void __init mac_scc_console_init(void) { register_console(&sercons); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/macintosh/mediabay.c linux/drivers/macintosh/mediabay.c --- v2.4.0-test8/linux/drivers/macintosh/mediabay.c Tue May 23 15:31:34 2000 +++ linux/drivers/macintosh/mediabay.c Sun Sep 17 09:48:05 2000 @@ -472,8 +472,11 @@ } else if (MB_IDE_READY(i)) { bay->timer = 0; bay->state = mb_up; - if (bay->cd_index < 0) + if (bay->cd_index < 0) { + pmu_suspend(); bay->cd_index = ide_register(bay->cd_base, 0, bay->cd_irq); + pmu_resume(); + } if (bay->cd_index == -1) { /* We eventually do a retry */ bay->cd_retry++; @@ -605,7 +608,9 @@ only if it did not change. Note those bozo timings, they seem to help the 3400 get it right. */ - mdelay(MB_STABLE_DELAY); + /* Force MB power to 0 */ + set_mb_power(i, 0); + mdelay(MB_POWER_DELAY); if (!bay->pismo) out_8(&bay->addr->contents, 0x70); mdelay(MB_STABLE_DELAY); @@ -615,7 +620,9 @@ bay->last_value = bay->content_id; bay->value_count = MS_TO_HZ(MB_STABLE_DELAY); bay->timer = MS_TO_HZ(MB_POWER_DELAY); +#ifdef CONFIG_BLK_DEV_IDE bay->cd_retry = 0; +#endif do { mdelay(1000/HZ); media_bay_step(i); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/macintosh/nvram.c linux/drivers/macintosh/nvram.c --- v2.4.0-test8/linux/drivers/macintosh/nvram.c Fri Jun 23 21:55:09 2000 +++ linux/drivers/macintosh/nvram.c Sun Sep 17 09:48:05 2000 @@ -14,6 +14,7 @@ #include #include #include +#include #define NVRAM_SIZE 8192 @@ -70,11 +71,36 @@ return p - buf; } +static int nvram_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + switch(cmd) { + case PMAC_NVRAM_GET_OFFSET: + { + int part, offset; + if (copy_from_user(&part,(void*)arg,sizeof(part))!=0) + return -EFAULT; + if (part < pmac_nvram_OF || part > pmac_nvram_NR) + return -EINVAL; + offset = pmac_get_partition(part); + if (copy_to_user((void*)arg,&offset,sizeof(offset))!=0) + return -EFAULT; + break; + } + + default: + return -EINVAL; + } + + return 0; +} + struct file_operations nvram_fops = { owner: THIS_MODULE, llseek: nvram_llseek, read: read_nvram, write: write_nvram, + ioctl: nvram_ioctl, }; static struct miscdevice nvram_dev = { diff -u --recursive --new-file v2.4.0-test8/linux/drivers/macintosh/rtc.c linux/drivers/macintosh/rtc.c --- v2.4.0-test8/linux/drivers/macintosh/rtc.c Wed Dec 31 16:00:00 1969 +++ linux/drivers/macintosh/rtc.c Sun Sep 17 09:48:05 2000 @@ -0,0 +1,158 @@ +/* + * Linux/PowerPC Real Time Clock Driver + * + * heavily based on: + * Linux/SPARC Real Time Clock Driver + * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu) + * + * This is a little driver that lets a user-level program access + * the PPC clocks chip. It is no use unless you + * use the modified clock utility. + * + * Get the modified clock utility from: + * ftp://vger.rutgers.edu/pub/linux/Sparc/userland/clock.c + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +static int rtc_busy = 0; + +/* Retrieve the current date and time from the real time clock. */ +void get_rtc_time(struct rtc_time *t) +{ + unsigned long nowtime; + + nowtime = (ppc_md.get_rtc_time)(); + + to_tm(nowtime, t); + + t->tm_year -= 1900; + t->tm_mon -= 1; + t->tm_wday -= 1; +} + +/* Set the current date and time in the real time clock. */ +void set_rtc_time(struct rtc_time *t) +{ + unsigned long nowtime; + + printk(KERN_INFO "rtc.c:set_rtc_time: %04d-%02d-%02d %02d:%02d:%02d.\n", t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); + + nowtime = mktime(t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); + + printk(KERN_INFO "rtc.c:set_rtc_time: set rtc time to %ld seconds.\n", nowtime); + + (ppc_md.set_rtc_time)(nowtime); +} + +static loff_t rtc_lseek(struct file *file, loff_t offset, int origin) +{ + return -ESPIPE; +} + +static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg) +{ + struct rtc_time rtc_tm; + + switch (cmd) + { + case RTC_RD_TIME: + if (ppc_md.get_rtc_time) + { + get_rtc_time(&rtc_tm); + + if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time))) + return -EFAULT; + + return 0; + } + else + return -EINVAL; + + case RTC_SET_TIME: + if (!capable(CAP_SYS_TIME)) + return -EPERM; + + if (ppc_md.set_rtc_time) + { + if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, sizeof(struct rtc_time))) + return -EFAULT; + + set_rtc_time(&rtc_tm); + + return 0; + } + else + return -EINVAL; + + default: + return -EINVAL; + } +} + +static int rtc_open(struct inode *inode, struct file *file) +{ + if (rtc_busy) + return -EBUSY; + + rtc_busy = 1; + + MOD_INC_USE_COUNT; + + return 0; +} + +static int rtc_release(struct inode *inode, struct file *file) +{ + MOD_DEC_USE_COUNT; + rtc_busy = 0; + return 0; +} + +static struct file_operations rtc_fops = { + owner: THIS_MODULE, + llseek: rtc_lseek, + ioctl: rtc_ioctl, + open: rtc_open, + release: rtc_release +}; + +static struct miscdevice rtc_dev = { RTC_MINOR, "rtc", &rtc_fops }; + +EXPORT_NO_SYMBOLS; + +static int __init rtc_init(void) +{ + int error; + + error = misc_register(&rtc_dev); + if (error) { + printk(KERN_ERR "rtc: unable to get misc minor\n"); + return error; + } + + return 0; +} + +static void __exit rtc_exit(void) +{ + misc_deregister(&rtc_dev); +} + +module_init(rtc_init); +module_exit(rtc_exit); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/macintosh/via-cuda.c linux/drivers/macintosh/via-cuda.c --- v2.4.0-test8/linux/drivers/macintosh/via-cuda.c Thu Nov 18 20:25:37 1999 +++ linux/drivers/macintosh/via-cuda.c Sun Sep 17 09:48:05 2000 @@ -94,39 +94,48 @@ #endif static int cuda_fully_inited = 0; +#ifdef CONFIG_ADB static int cuda_probe(void); static int cuda_init(void); +static int cuda_send_request(struct adb_request *req, int sync); +static int cuda_adb_autopoll(int devs); +static int cuda_reset_adb_bus(void); +#endif /* CONFIG_ADB */ + static int cuda_init_via(void); static void cuda_start(void); static void cuda_interrupt(int irq, void *arg, struct pt_regs *regs); static void cuda_input(unsigned char *buf, int nb, struct pt_regs *regs); -static int cuda_send_request(struct adb_request *req, int sync); -static int cuda_adb_autopoll(int devs); void cuda_poll(void); -static int cuda_reset_adb_bus(void); static int cuda_write(struct adb_request *req); int cuda_request(struct adb_request *req, void (*done)(struct adb_request *), int nbytes, ...); +#ifdef CONFIG_ADB struct adb_driver via_cuda_driver = { "CUDA", cuda_probe, cuda_init, cuda_send_request, - /*cuda_write,*/ cuda_adb_autopoll, cuda_poll, cuda_reset_adb_bus }; +#endif /* CONFIG_ADB */ #ifdef CONFIG_PPC -void -find_via_cuda() +int +find_via_cuda(void) { + int err; + struct adb_request req; + + if (vias != 0) + return 1; vias = find_devices("via-cuda"); if (vias == 0) - return; + return 0; if (vias->next != 0) printk(KERN_WARNING "Warning: only using 1st via-cuda\n"); @@ -146,15 +155,54 @@ printk(KERN_ERR "via-cuda: expecting 1 address (%d) and 1 interrupt (%d)\n", vias->n_addrs, vias->n_intrs); if (vias->n_addrs < 1 || vias->n_intrs < 1) - return; + return 0; } via = (volatile unsigned char *) ioremap(vias->addrs->address, 0x2000); cuda_state = idle; sys_ctrler = SYS_CTRLER_CUDA; + + err = cuda_init_via(); + if (err) { + printk(KERN_ERR "cuda_init_via() failed\n"); + via = NULL; + return 0; + } + + /* Clear and enable interrupts, but only on PPC. On 68K it's done */ + /* for us by the the main VIA driver in arch/m68k/mac/via.c */ + +#ifndef CONFIG_MAC + via[IFR] = 0x7f; eieio(); /* clear interrupts by writing 1s */ + via[IER] = IER_SET|SR_INT; eieio(); /* enable interrupt from SR */ +#endif + + /* enable autopoll */ + cuda_request(&req, NULL, 3, CUDA_PACKET, CUDA_AUTOPOLL, 1); + while (!req.complete) + cuda_poll(); + + return 1; } #endif /* CONFIG_PPC */ +int via_cuda_start(void) +{ + if (via == NULL) + return -ENODEV; + + if (request_irq(CUDA_IRQ, cuda_interrupt, 0, "ADB", cuda_interrupt)) { + printk(KERN_ERR "cuda_init: can't get irq %d\n", CUDA_IRQ); + return -EAGAIN; + } + + printk("Macintosh CUDA driver v0.5 for Unified ADB.\n"); + + cuda_fully_inited = 1; + return 0; +} + +#ifdef CONFIG_ADB static int cuda_probe() { @@ -172,46 +220,24 @@ static int cuda_init(void) { - int err; - if (via == NULL) return -ENODEV; - - err = cuda_init_via(); - if (err) { - printk(KERN_ERR "cuda_probe: init_via() failed\n"); - via = NULL; - return err; - } - - /* Clear and enable interrupts, but only on PPC. On 68K it's done */ - /* for us by the the main VIA driver in arch/m68k/mac/via.c */ - -#ifndef CONFIG_MAC - via[IFR] = 0x7f; eieio(); /* clear interrupts by writing 1s */ - via[IER] = IER_SET|SR_INT; eieio(); /* enable interrupt from SR */ +#ifndef CONFIG_PPC + return via_cuda_start(); #endif - - if (request_irq(CUDA_IRQ, cuda_interrupt, 0, "ADB", cuda_interrupt)) { - printk(KERN_ERR "cuda_init: can't get irq %d\n", CUDA_IRQ); - return -EAGAIN; - } - - printk("adb: CUDA driver v0.5 for Unified ADB.\n"); - - cuda_fully_inited = 1; return 0; } +#endif /* CONFIG_ADB */ -#define WAIT_FOR(cond, what) \ - do { \ - for (x = 1000; !(cond); --x) { \ - if (x == 0) { \ - printk("Timeout waiting for " what); \ - return -ENXIO; \ - } \ +#define WAIT_FOR(cond, what) \ + do { \ + for (x = 1000; !(cond); --x) { \ + if (x == 0) { \ + printk("Timeout waiting for " what "\n"); \ + return -ENXIO; \ + } \ udelay(100); \ - } \ + } \ } while (0) static int @@ -255,6 +281,7 @@ return 0; } +#ifdef CONFIG_ADB /* Send an ADB command */ static int cuda_send_request(struct adb_request *req, int sync) @@ -309,7 +336,7 @@ cuda_poll(); return 0; } - +#endif /* CONFIG_ADB */ /* Construct and send a cuda request */ int cuda_request(struct adb_request *req, void (*done)(struct adb_request *), @@ -534,7 +561,18 @@ switch (buf[0]) { case ADB_PACKET: +#ifdef CONFIG_XMON + if (nb == 5 && buf[2] == 0x2c) { + extern int xmon_wants_key, xmon_adb_keycode; + if (xmon_wants_key) { + xmon_adb_keycode = buf[3]; + return; + } + } +#endif /* CONFIG_XMON */ +#ifdef CONFIG_ADB adb_input(buf+2, nb-2, regs, buf[1] & 0x40); +#endif /* CONFIG_ADB */ break; default: diff -u --recursive --new-file v2.4.0-test8/linux/drivers/macintosh/via-pmu.c linux/drivers/macintosh/via-pmu.c --- v2.4.0-test8/linux/drivers/macintosh/via-pmu.c Fri Jul 14 12:12:10 2000 +++ linux/drivers/macintosh/via-pmu.c Sun Sep 17 09:48:05 2000 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -39,10 +40,16 @@ #include #include #include +#include #include #include #include -#include +#ifdef CONFIG_PMAC_BACKLIGHT +#include +#endif + +/* Some compile options */ +#undef SUSPEND_USES_PMU /* Misc minor number allocated for /dev/pmu */ #define PMU_MINOR 154 @@ -84,7 +91,7 @@ #define CB2_INT 0x08 #define CB1_INT 0x10 /* transition on CB1 input */ -static enum pmu_state { +static volatile enum pmu_state { idle, sending, intack, @@ -95,7 +102,7 @@ static struct adb_request *current_req; static struct adb_request *last_req; static struct adb_request *req_awaiting_reply; -static unsigned char interrupt_data[32]; +static unsigned char interrupt_data[256]; /* Made bigger: I've been told that might happen */ static unsigned char *reply_ptr; static int data_index; static int data_len; @@ -106,22 +113,27 @@ static struct device_node *vias; static int pmu_kind = PMU_UNKNOWN; static int pmu_fully_inited = 0; -static int pmu_has_adb, pmu_has_backlight; +static int pmu_has_adb; static unsigned char *gpio_reg = NULL; -static int gpio_irq; +static int gpio_irq = -1; +static volatile int pmu_suspended = 0; +static spinlock_t pmu_lock; int asleep; struct notifier_block *sleep_notifier_list; +#ifdef CONFIG_ADB static int pmu_probe(void); static int pmu_init(void); +static int pmu_send_request(struct adb_request *req, int sync); +static int pmu_adb_autopoll(int devs); +static int pmu_adb_reset_bus(void); +#endif /* CONFIG_ADB */ + static int init_pmu(void); static int pmu_queue_request(struct adb_request *req); static void pmu_start(void); static void via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs); -static int pmu_send_request(struct adb_request *req, int sync); -static int pmu_adb_autopoll(int devs); -static int pmu_adb_reset_bus(void); static void send_byte(int x); static void recv_byte(void); static void pmu_sr_intr(struct pt_regs *regs); @@ -130,20 +142,25 @@ struct pt_regs *regs); static void set_volume(int level); static void gpio1_interrupt(int irq, void *arg, struct pt_regs *regs); +#ifdef CONFIG_PMAC_BACKLIGHT +static int pmu_set_backlight_level(int level, void* data); +static int pmu_set_backlight_enable(int on, int level, void* data); +#endif /* CONFIG_PMAC_BACKLIGHT */ #ifdef CONFIG_PMAC_PBOOK static void pmu_pass_intr(unsigned char *data, int len); #endif +#ifdef CONFIG_ADB struct adb_driver via_pmu_driver = { "PMU", pmu_probe, pmu_init, pmu_send_request, - /*pmu_queue_request,*/ pmu_adb_autopoll, pmu_poll, pmu_adb_reset_bus }; +#endif /* CONFIG_ADB */ extern void low_sleep_handler(void); extern void sleep_save_intrs(int); @@ -206,6 +223,13 @@ "Core99" }; +#ifdef CONFIG_PMAC_BACKLIGHT +static struct backlight_controller pmu_backlight_controller = { + pmu_set_backlight_enable, + pmu_set_backlight_level +}; +#endif /* CONFIG_PMAC_BACKLIGHT */ + int __openfirmware find_via_pmu() { @@ -216,17 +240,6 @@ return 0; if (vias->next != 0) printk(KERN_WARNING "Warning: only using 1st via-pmu\n"); -#if 0 - { int i; - - printk("find_via_pmu: node = %p, addrs =", vias->node); - for (i = 0; i < vias->n_addrs; ++i) - printk(" %x(%x)", vias->addrs[i].address, vias->addrs[i].size); - printk(", intrs ="); - for (i = 0; i < vias->n_intrs; ++i) - printk(" %x", vias->intrs[i].line); - printk("\n"); } -#endif if (vias->n_addrs < 1 || vias->n_intrs < 1) { printk(KERN_ERR "via-pmu: %d addresses, %d interrupts!\n", @@ -235,8 +248,9 @@ return 0; } + spin_lock_init(&pmu_lock); + pmu_has_adb = 1; - pmu_has_backlight = 1; if (vias->parent->name && ((strcmp(vias->parent->name, "ohare") == 0) || device_is_compatible(vias->parent, "ohare"))) @@ -246,9 +260,18 @@ else if (device_is_compatible(vias->parent, "heathrow")) pmu_kind = PMU_HEATHROW_BASED; else if (device_is_compatible(vias->parent, "Keylargo")) { + struct device_node *gpio, *gpiop; + pmu_kind = PMU_KEYLARGO_BASED; pmu_has_adb = (find_type_devices("adb") != NULL); - pmu_has_backlight = (find_type_devices("backlight") != NULL); + + gpiop = find_devices("gpio"); + if (gpiop && gpiop->n_addrs) { + gpio_reg = ioremap(gpiop->addrs->address, 0x10); + gpio = find_devices("extint-gpio1"); + if (gpio && gpio->parent == gpiop && gpio->n_intrs) + gpio_irq = gpio->intrs[0].line; + } } else pmu_kind = PMU_UNKNOWN; @@ -266,10 +289,13 @@ printk(KERN_INFO "PMU driver initialized for %s\n", pbook_type[pmu_kind]); + sys_ctrler = SYS_CTRLER_PMU; + return 1; } +#ifdef CONFIG_ADB static int __openfirmware pmu_probe() { @@ -280,9 +306,10 @@ pmu_init(void) { if (vias == NULL) - return -ENXIO; + return -ENODEV; return 0; } +#endif /* CONFIG_ADB */ /* * We can't wait until pmu_init gets called, that happens too late. @@ -291,10 +318,10 @@ * turned us off. * This is called from arch/ppc/kernel/pmac_setup.c:pmac_init2(). */ -void via_pmu_start(void) +int via_pmu_start(void) { if (vias == NULL) - return; + return -ENODEV; bright_req_1.complete = 1; bright_req_2.complete = 1; @@ -304,24 +331,12 @@ (void *)0)) { printk(KERN_ERR "VIA-PMU: can't get irq %d\n", vias->intrs[0].line); - return; + return -EAGAIN; } - if (pmu_kind == PMU_KEYLARGO_BASED) { - struct device_node *gpio, *gpiop; - - gpiop = find_devices("gpio"); - if (gpiop && gpiop->n_addrs) { - gpio_reg = ioremap(gpiop->addrs->address, 0x10); - gpio = find_devices("extint-gpio1"); - if (gpio && gpio->parent == gpiop && gpio->n_intrs) { - gpio_irq = gpio->intrs[0].line; - if (request_irq(gpio_irq, gpio1_interrupt, 0, - "GPIO1/ADB", (void *)0)) - printk(KERN_ERR "pmu: can't get irq %d (GPIO1)\n", - gpio->intrs[0].line); - } - } + if (pmu_kind == PMU_KEYLARGO_BASED && gpio_irq != -1) { + if (request_irq(gpio_irq, gpio1_interrupt, 0, "GPIO1/ADB", (void *)0)) + printk(KERN_ERR "pmu: can't get irq %d (GPIO1)\n", gpio_irq); } /* Enable interrupts */ @@ -329,8 +344,24 @@ pmu_fully_inited = 1; +#ifdef CONFIG_PMAC_BACKLIGHT /* Enable backlight */ - pmu_enable_backlight(1); + register_backlight_controller(&pmu_backlight_controller, NULL, "pmu"); +#endif /* CONFIG_PMAC_BACKLIGHT */ + + /* Make sure PMU settle down before continuing. This is _very_ important + * since the IDE probe may shut interrupts down for quite a bit of time. If + * a PMU communication is pending while this happens, the PMU may timeout + * Not that on Core99 machines, the PMU keeps sending us environement + * messages, we should find a way to either fix IDE or make it call + * pmu_suspend() before masking interrupts. This can also happens while + * scolling with some fbdevs. + */ + do { + pmu_poll(); + } while (pmu_state != idle); + + return 0; } static int __openfirmware @@ -342,7 +373,7 @@ out_8(&via[B], via[B] | TREQ); /* negate TREQ */ out_8(&via[DIRB], (via[DIRB] | TREQ) & ~TACK); /* TACK in, TREQ out */ - pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xff); + pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xfc); timeout = 100000; while (!req.complete) { if (--timeout < 0) { @@ -367,6 +398,13 @@ udelay(10); } + /* Tell PMU we are ready. Which PMU support this ? */ + if (pmu_kind == PMU_KEYLARGO_BASED) { + pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2); + while (!req.complete) + pmu_poll(); + } + return 1; } @@ -376,6 +414,7 @@ return pmu_kind; } +#ifdef CONFIG_ADB /* Send an ADB command */ static int __openfirmware pmu_send_request(struct adb_request *req, int sync) @@ -513,6 +552,7 @@ return 0; } +#endif /* CONFIG_ADB */ /* Construct and send a pmu request */ int __openfirmware @@ -568,8 +608,8 @@ req->next = 0; req->sent = 0; req->complete = 0; - save_flags(flags); cli(); + spin_lock_irqsave(&pmu_lock, flags); if (current_req != 0) { last_req->next = req; last_req = req; @@ -579,11 +619,27 @@ if (pmu_state == idle) pmu_start(); } + spin_unlock_irqrestore(&pmu_lock, flags); - restore_flags(flags); return 0; } +static void __openfirmware +wait_for_ack(void) +{ + /* Sightly increased the delay, I had one occurence of the message + * reported + */ + int timeout = 4000; + while ((in_8(&via[B]) & TACK) == 0) { + if (--timeout < 0) { + printk(KERN_ERR "PMU not responding (!ack)\n"); + return; + } + udelay(10); + } +} + /* New PMU seems to be very sensitive to those timings, so we make sure * PCI is flushed immediately */ static void __openfirmware @@ -613,57 +669,126 @@ static void __openfirmware pmu_start() { - unsigned long flags; struct adb_request *req; /* assert pmu_state == idle */ /* get the packet to send */ - save_flags(flags); cli(); req = current_req; if (req == 0 || pmu_state != idle - || (req->reply_expected && req_awaiting_reply)) - goto out; + || (/*req->reply_expected && */req_awaiting_reply)) + return; pmu_state = sending; data_index = 1; data_len = pmu_data_len[req->data[0]][0]; + /* Sounds safer to make sure ACK is high before writing. This helped + * kill a problem with ADB and some iBooks + */ + wait_for_ack(); /* set the shift register to shift out and send a byte */ - ++disable_poll; send_byte(req->data[0]); - --disable_poll; - -out: - restore_flags(flags); } void __openfirmware pmu_poll() { - unsigned long flags; - + if (!via) + return; if (disable_poll) return; - save_flags(flags); - cli(); - if ((via[IFR] & (SR_INT | CB1_INT)) || - (gpio_reg && (in_8(gpio_reg + 0x9) & 0x02) == 0)) + /* Kicks ADB read when PMU is suspended */ + if (pmu_suspended) + adb_int_pending = 1; + do { + via_pmu_interrupt(0, 0, 0); + } while (pmu_suspended && (adb_int_pending || pmu_state != idle + || req_awaiting_reply)); +} + +/* This function loops until the PMU is idle and prevents it from + * anwsering to ADB interrupts. pmu_request can still be called. + * This is done to avoid spurrious shutdowns when we know we'll have + * interrupts switched off for a long time + */ +void __openfirmware +pmu_suspend(void) +{ + unsigned long flags; +#ifdef SUSPEND_USES_PMU + struct adb_request *req; +#endif + if (!via) + return; + + spin_lock_irqsave(&pmu_lock, flags); + pmu_suspended++; + if (pmu_suspended > 1) { + spin_unlock_irqrestore(&pmu_lock, flags); + return; + } + + do { + spin_unlock(&pmu_lock); via_pmu_interrupt(0, 0, 0); - restore_flags(flags); + spin_lock(&pmu_lock); + if (!adb_int_pending && pmu_state == idle && !req_awaiting_reply) { +#ifdef SUSPEND_USES_PMU + pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0); + spin_unlock_irqrestore(&pmu_lock, flags); + while(!req.complete) + pmu_poll(); +#else /* SUSPEND_USES_PMU */ + if (gpio_irq >= 0) + disable_irq(gpio_irq); + out_8(&via[IER], CB1_INT | IER_CLR); + spin_unlock_irqrestore(&pmu_lock, flags); +#endif /* SUSPEND_USES_PMU */ + break; + } + } while (1); +} + +void __openfirmware +pmu_resume(void) +{ + unsigned long flags; + + if (!via || (pmu_suspended < 1)) + return; + + spin_lock_irqsave(&pmu_lock, flags); + pmu_suspended--; + if (pmu_suspended > 0) { + spin_unlock_irqrestore(&pmu_lock, flags); + return; + } + adb_int_pending = 1; +#ifdef SUSPEND_USES_PMU + pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xfc); + spin_unlock_irqrestore(&pmu_lock, flags); + while(!req.complete) + pmu_poll(); +#else /* SUSPEND_USES_PMU */ + if (gpio_irq >= 0) + enable_irq(gpio_irq); + out_8(&via[IER], CB1_INT | IER_SET); + spin_unlock_irqrestore(&pmu_lock, flags); + pmu_poll(); +#endif /* SUSPEND_USES_PMU */ } static void __openfirmware via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs) { + unsigned long flags; int intr; int nloop = 0; - unsigned long flags; - /* Currently, we use brute-force cli() for syncing with GPIO - * interrupt. I'll make this smarter later, along with some - * spinlocks for SMP */ - save_flags(flags);cli(); + /* This is a bit brutal, we can probably do better */ + spin_lock_irqsave(&pmu_lock, flags); ++disable_poll; + while ((intr = in_8(&via[IFR])) != 0) { if (++nloop > 1000) { printk(KERN_DEBUG "PMU: stuck in intr loop, " @@ -681,25 +806,38 @@ out_8(&via[IFR], intr); } } - if (gpio_reg && (in_8(gpio_reg + 0x9) & 0x02) == 0) + /* This is not necessary except if synchronous ADB requests are done + * with interrupts off, which should not happen. Since I'm not sure + * this "wiring" will remain, I'm commenting it out for now. Please do + * not remove. -- BenH. + */ +#if 0 + if (gpio_reg && !pmu_suspended && (in_8(gpio_reg + 0x9) & 0x02) == 0) adb_int_pending = 1; +#endif if (pmu_state == idle) { if (adb_int_pending) { pmu_state = intack; + /* Sounds safer to make sure ACK is high before writing. + * This helped kill a problem with ADB and some iBooks + */ + wait_for_ack(); send_byte(PMU_INT_ACK); adb_int_pending = 0; } else if (current_req) { pmu_start(); } } + --disable_poll; - restore_flags(flags); + spin_unlock_irqrestore(&pmu_lock, flags); } static void __openfirmware gpio1_interrupt(int irq, void *arg, struct pt_regs *regs) { + adb_int_pending = 1; via_pmu_interrupt(0, 0, 0); } @@ -707,7 +845,7 @@ pmu_sr_intr(struct pt_regs *regs) { struct adb_request *req; - int bite, timeout; + int bite; if (via[B] & TREQ) { printk(KERN_ERR "PMU: spurious SR intr (%x)\n", via[B]); @@ -720,26 +858,16 @@ if (via[B] & TACK) { while ((in_8(&via[B]) & TACK) != 0) ; -#if 0 - printk(KERN_ERR "PMU: sr_intr but ack still high! (%x)\n", - via[B]); -#endif } /* reset TREQ and wait for TACK to go high */ out_8(&via[B], in_8(&via[B]) | TREQ); - timeout = 3200; - while ((in_8(&via[B]) & TACK) == 0) { - if (--timeout < 0) { - printk(KERN_ERR "PMU not responding (!ack)\n"); - return; - } - udelay(10); - } + wait_for_ack(); /* if reading grab the byte, and reset the interrupt */ if (pmu_state == reading || pmu_state == reading_intr) bite = in_8(&via[SR]); + out_8(&via[IFR], SR_INT); switch (pmu_state) { @@ -761,8 +889,11 @@ current_req = req->next; if (req->reply_expected) req_awaiting_reply = req; - else + else { + spin_unlock(&pmu_lock); pmu_done(req); + spin_lock(&pmu_lock); + } } else { pmu_state = reading; data_index = 0; @@ -795,12 +926,16 @@ } if (pmu_state == reading_intr) { + spin_unlock(&pmu_lock); pmu_handle_data(interrupt_data, data_index, regs); + spin_lock(&pmu_lock); } else { req = current_req; current_req = req->next; req->reply_len += data_index; + spin_unlock(&pmu_lock); pmu_done(req); + spin_lock(&pmu_lock); } pmu_state = idle; @@ -826,6 +961,7 @@ { asleep = 0; if (len < 1) { +// xmon_printk("empty ADB\n"); adb_int_pending = 0; return; } @@ -854,6 +990,7 @@ } } #endif /* CONFIG_XMON */ +#ifdef CONFIG_ADB /* * XXX On the [23]400 the PMU gives us an up * event for keycodes 0x74 or 0x75 when the PC @@ -864,10 +1001,13 @@ && data[1] == 0x2c && data[3] == 0xff && (data[2] & ~1) == 0xf4)) adb_input(data+1, len-1, regs, 1); +#endif /* CONFIG_ADB */ } } else if (data[0] == 0x08 && len == 3) { /* sound/brightness buttons pressed */ - pmu_set_brightness(data[1] >> 3); +#ifdef CONFIG_PMAC_BACKLIGHT + set_backlight_level(data[1] >> 4); +#endif set_volume(data[2]); } else { #ifdef CONFIG_PMAC_PBOOK @@ -876,53 +1016,23 @@ } } -int backlight_level = -1; -int backlight_enabled = 0; - -#define LEVEL_TO_BRIGHT(lev) ((lev) < 1? 0x7f: 0x4a - ((lev) << 1)) - -void __openfirmware -pmu_enable_backlight(int on) +#ifdef CONFIG_PMAC_BACKLIGHT +static int backlight_to_bright[] = { + 0x7f, 0x46, 0x42, 0x3e, 0x3a, 0x36, 0x32, 0x2e, + 0x2a, 0x26, 0x22, 0x1e, 0x1a, 0x16, 0x12, 0x0e +}; + +static int __openfirmware +pmu_set_backlight_enable(int on, int level, void* data) { struct adb_request req; + + if (vias == NULL) + return -ENODEV; - if ((vias == NULL) || !pmu_has_backlight) - return; - - /* first call: get current backlight value */ - if (on && backlight_level < 0) { - switch (pmu_kind) { - case PMU_OHARE_BASED: - pmu_request(&req, NULL, 2, 0xd9, 0); - while (!req.complete) - pmu_poll(); - backlight_level = req.reply[1] >> 3; - break; - case PMU_HEATHROW_BASED: - /* We cannot use nvram_read_byte here (not yet initialized) */ - pmu_request(&req, NULL, 3, PMU_READ_NVRAM, 0x14, 0xe); - while (!req.complete) - pmu_poll(); - backlight_level = req.reply[1]; - printk(KERN_DEBUG "pmu: nvram returned bright: %d\n", backlight_level); - break; - case PMU_PADDINGTON_BASED: - case PMU_KEYLARGO_BASED: - /* the G3 PB 1999 has a backlight node - and chrp-structured nvram */ - /* XXX should read macos's "blkt" property in nvram - for this node. For now this ensures that the - backlight doesn't go off as soon as linux boots. */ - backlight_level = 20; - break; - default: - backlight_enabled = 0; - return; - } - } if (on) { pmu_request(&req, NULL, 2, PMU_BACKLIGHT_BRIGHT, - LEVEL_TO_BRIGHT(backlight_level)); + backlight_to_bright[level]); while (!req.complete) pmu_poll(); } @@ -930,35 +1040,28 @@ PMU_POW_BACKLIGHT | (on ? PMU_POW_ON : PMU_POW_OFF)); while (!req.complete) pmu_poll(); - backlight_enabled = on; + + return 0; } -void __openfirmware -pmu_set_brightness(int level) +static int __openfirmware +pmu_set_backlight_level(int level, void* data) { - int bright; + if (vias == NULL) + return -ENODEV; - if ((vias == NULL) || !pmu_has_backlight) - return ; + if (!bright_req_1.complete) + return -EAGAIN; + pmu_request(&bright_req_1, NULL, 2, PMU_BACKLIGHT_BRIGHT, + backlight_to_bright[level]); + if (!bright_req_2.complete) + return -EAGAIN; + pmu_request(&bright_req_2, NULL, 2, PMU_POWER_CTRL, PMU_POW_BACKLIGHT + | (level > BACKLIGHT_OFF ? PMU_POW_ON : PMU_POW_OFF)); - backlight_level = level; - bright = LEVEL_TO_BRIGHT(level); - if (!backlight_enabled) - return; - if (bright_req_1.complete) - pmu_request(&bright_req_1, NULL, 2, PMU_BACKLIGHT_BRIGHT, - bright); - if (bright_req_2.complete) - pmu_request(&bright_req_2, NULL, 2, PMU_POWER_CTRL, - PMU_POW_BACKLIGHT | (bright < 0x7f ? PMU_POW_ON : PMU_POW_OFF)); - - /* XXX nvram address is hard-coded and looks ok on wallstreet, please - test on your machine. Note that newer MacOS system software may break - the nvram layout. */ - if ((pmu_kind == PMU_HEATHROW_BASED) && bright_req_3.complete) - pmu_request(&bright_req_3, NULL, 4, PMU_WRITE_NVRAM, - 0x14, 0xe, level); + return 0; } +#endif /* CONFIG_PMAC_BACKLIGHT */ void __openfirmware pmu_enable_irled(int on) @@ -967,6 +1070,8 @@ if (vias == NULL) return ; + if (pmu_kind == PMU_KEYLARGO_BASED) + return ; pmu_request(&req, NULL, 2, PMU_POWER_CTRL, PMU_POW_IRLED | (on ? PMU_POW_ON : PMU_POW_OFF)); @@ -1201,17 +1306,9 @@ { int ret; unsigned long save_l2cr; - unsigned long save_fcr; unsigned long wait; unsigned short pmcr1; - struct adb_request sleep_req; - struct device_node *macio; - unsigned long macio_base = 0; - - macio = find_devices("mac-io"); - if (macio != 0 && macio->n_addrs > 0) - macio_base = (unsigned long) - ioremap(macio->addrs[0].address, 0x40); + struct adb_request req; /* Notify device drivers */ ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT); @@ -1245,14 +1342,13 @@ /* Make sure the decrementer won't interrupt us */ asm volatile("mtdec %0" : : "r" (0x7fffffff)); + feature_prepare_for_sleep(); + /* For 750, save backside cache setting and disable it */ save_l2cr = _get_L2CR(); /* (returns 0 if not 750) */ if (save_l2cr) _set_L2CR(0); - if (macio_base != 0) - save_fcr = in_le32(FEATURE_CTRL(macio_base)); - if (current->thread.regs && (current->thread.regs->msr & MSR_FP) != 0) giveup_fpu(current); @@ -1263,17 +1359,14 @@ grackle_pcibios_write_config_word(0, 0, 0x70, pmcr1); /* Ask the PMU to put us to sleep */ - pmu_request(&sleep_req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T'); - while (!sleep_req.complete) + pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T'); + while (!req.complete) pmu_poll(); cli(); while (pmu_state != idle) pmu_poll(); - /* clear IOBUS enable */ - out_le32(FEATURE_CTRL(macio_base), save_fcr & ~HRW_IOBUS_ENABLE); - /* Call low-level ASM sleep handler */ low_sleep_handler(); @@ -1282,15 +1375,14 @@ pmcr1 &= ~(GRACKLE_PM|GRACKLE_DOZE|GRACKLE_SLEEP|GRACKLE_NAP); grackle_pcibios_write_config_word(0, 0, 0x70, pmcr1); - /* reenable IOBUS */ - out_le32(FEATURE_CTRL(macio_base), save_fcr | HRW_IOBUS_ENABLE); - /* Make sure the PMU is idle */ while (pmu_state != idle) pmu_poll(); sti(); + feature_wake_up(); + /* The PGD is only a placeholder until Dan finds a way to make * this work properly on the 8xx processors. It is only used on * 8xx processors, it is ignored here. @@ -1304,6 +1396,116 @@ /* reenable interrupts */ sleep_restore_intrs(); + /* Tell PMU we are ready */ + pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2); + while (!req.complete) + pmu_poll(); + + /* Notify drivers */ + mdelay(10); + broadcast_wake(); + + return 0; +} + +/* Not finished yet */ +int __openfirmware powerbook_sleep_Core99(void) +{ + int ret; + unsigned long save_l2cr; + unsigned long wait; + struct adb_request req; + + /* Notify device drivers */ + ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT); + if (ret != PBOOK_SLEEP_OK) { + printk("pmu: sleep rejected\n"); + return -EBUSY; + } + + /* Sync the disks. */ + /* XXX It would be nice to have some way to ensure that + * nobody is dirtying any new buffers while we wait. + * BenH: Moved to _after_ sleep request and changed video + * drivers to vmalloc() during sleep request. This way, all + * vmalloc's are done before actual sleep of block drivers */ + fsync_dev(0); + + /* Sleep can fail now. May not be very robust but useful for debugging */ + ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE); + if (ret != PBOOK_SLEEP_OK) { + printk("pmu: sleep failed\n"); + return -EBUSY; + } + + /* Give the disks a little time to actually finish writing */ + for (wait = jiffies + (HZ/4); time_before(jiffies, wait); ) + mb(); + + /* Tell PMU what events will wake us up */ + pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_CLR_WAKEUP_EVENTS, + 0xff, 0xff); + while (!req.complete) + pmu_poll(); + pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_SET_WAKEUP_EVENTS, + 0, PMU_PWR_WAKEUP_KEY | PMU_PWR_WAKEUP_LID_OPEN); + while (!req.complete) + pmu_poll(); + + /* Disable all interrupts except pmu */ + sleep_save_intrs(vias->intrs[0].line); + + /* Make sure the decrementer won't interrupt us */ + asm volatile("mtdec %0" : : "r" (0x7fffffff)); + + /* Save the state of PCI config space for some slots */ + pbook_pci_save(); + + feature_prepare_for_sleep(); + + /* For 750, save backside cache setting and disable it */ + save_l2cr = _get_L2CR(); /* (returns 0 if not 750) */ + if (save_l2cr) + _set_L2CR(0); + + if (current->thread.regs && (current->thread.regs->msr & MSR_FP) != 0) + giveup_fpu(current); + + /* Ask the PMU to put us to sleep */ + pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T'); + while (!req.complete) + mb(); + + cli(); + while (pmu_state != idle) + pmu_poll(); + + /* Call low-level ASM sleep handler */ + low_sleep_handler(); + + /* Make sure the PMU is idle */ + while (pmu_state != idle) + pmu_poll(); + + sti(); + + feature_wake_up(); + pbook_pci_restore(); + + set_context(current->mm->context, current->mm->pgd); + + /* Restore L2 cache */ + if (save_l2cr) + _set_L2CR(save_l2cr | 0x200000); /* set invalidate bit */ + + /* reenable interrupts */ + sleep_restore_intrs(); + + /* Tell PMU we are ready */ + pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2); + while (!req.complete) + pmu_poll(); + /* Notify drivers */ mdelay(10); broadcast_wake(); @@ -1557,7 +1759,6 @@ u_int cmd, u_long arg) { int error; - __u32 value; switch (cmd) { case PMU_IOC_SLEEP: @@ -1569,21 +1770,33 @@ case PMU_PADDINGTON_BASED: error = powerbook_sleep_G3(); break; +#if 0 /* Not ready yet */ + case PMU_KEYLARGO_BASED: + error = powerbook_sleep_Core99(); + break; +#endif default: error = -ENOSYS; } return error; +#ifdef CONFIG_PMAC_BACKLIGHT + /* Backlight should have its own device or go via + * the fbdev + */ case PMU_IOC_GET_BACKLIGHT: - if (!pmu_has_backlight) - return -ENOSYS; - return put_user(backlight_level, (__u32 *)arg); + error = get_backlight_level(); + if (error < 0) + return error; + return put_user(error, (__u32 *)arg); case PMU_IOC_SET_BACKLIGHT: - if (!pmu_has_backlight) - return -ENOSYS; + { + __u32 value; error = get_user(value, (__u32 *)arg); if (!error) - pmu_set_brightness(value); + error = set_backlight_level(value); return error; + } +#endif /* CONFIG_PMAC_BACKLIGHT */ case PMU_IOC_GET_MODEL: return put_user(pmu_kind, (__u32 *)arg); case PMU_IOC_HAS_ADB: diff -u --recursive --new-file v2.4.0-test8/linux/drivers/media/video/bttv-driver.c linux/drivers/media/video/bttv-driver.c --- v2.4.0-test8/linux/drivers/media/video/bttv-driver.c Wed Aug 23 18:36:37 2000 +++ linux/drivers/media/video/bttv-driver.c Sun Sep 17 09:45:06 2000 @@ -3027,11 +3027,11 @@ * Scan for a Bt848 card, request the irq and map the io memory */ -static void __devinit bttv_remove(struct pci_dev *pci_dev) +static void __devexit bttv_remove(struct pci_dev *pci_dev) { u8 command; int j; - struct bttv *btv = PCI_GET_DRIVER_DATA(pci_dev); + struct bttv *btv = pci_get_drvdata(pci_dev); /* unregister i2c_bus */ if (0 == btv->i2c_ok) @@ -3093,6 +3093,8 @@ btv->shutdown=1; wake_up(&btv->gpioq); + pci_set_drvdata(pci_dev, NULL); + return; } @@ -3198,7 +3200,7 @@ } } - PCI_SET_DRIVER_DATA(dev,btv); + pci_set_drvdata(dev,btv); if(init_bt848(btv) < 0) { bttv_remove(dev); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/media/video/bttv.h linux/drivers/media/video/bttv.h --- v2.4.0-test8/linux/drivers/media/video/bttv.h Wed Aug 23 18:36:37 2000 +++ linux/drivers/media/video/bttv.h Sun Sep 17 09:45:06 2000 @@ -23,11 +23,6 @@ #define BTTV_VERSION_CODE KERNEL_VERSION(0,7,38) -#ifndef PCI_GET_DRIVER_DATA -# define PCI_GET_DRIVER_DATA(pdev) ((pdev)->driver_data) -# define PCI_SET_DRIVER_DATA(pdev,data) (((pdev)->driver_data) = (data)) -#endif /* PCI_GET_DRIVER_DATA */ - #include #include #include diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/3c507.c linux/drivers/net/3c507.c --- v2.4.0-test8/linux/drivers/net/3c507.c Fri Jun 23 21:55:09 2000 +++ linux/drivers/net/3c507.c Sun Sep 17 09:41:28 2000 @@ -332,6 +332,7 @@ { static unsigned char init_ID_done = 0, version_printed = 0; int i, irq, irqval; + struct net_local *lp; if (init_ID_done == 0) { ushort lrs_state = 0xff; @@ -355,7 +356,7 @@ /* Allocate a new 'dev' if needed. */ if (dev == NULL) - dev = init_etherdev(0, sizeof(struct net_local)); + dev = init_etherdev(0, 0); if (net_debug && version_printed++ == 0) printk(version); @@ -417,10 +418,11 @@ printk(version); /* Initialize the device structure. */ - dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL); + lp = dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL); if (dev->priv == NULL) return -ENOMEM; memset(dev->priv, 0, sizeof(struct net_local)); + spin_lock_init(&lp->lock); dev->open = el16_open; dev->stop = el16_close; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/3c509.c linux/drivers/net/3c509.c --- v2.4.0-test8/linux/drivers/net/3c509.c Fri Jul 14 12:12:10 2000 +++ linux/drivers/net/3c509.c Sun Sep 17 09:41:28 2000 @@ -193,6 +193,7 @@ int el3_probe(struct net_device *dev) { + struct el3_private *lp; short lrs_state = 0xff, i; int ioaddr, irq, if_port; u16 phys_addr[3]; @@ -200,7 +201,7 @@ int mca_slot = -1; #ifdef __ISAPNP__ static int pnp_cards = 0; -#endif +#endif /* __ISAPNP__ */ /* First check all slots of the EISA bus. The next slot address to probe is kept in 'eisa_addr' to support multiple probe() calls. */ @@ -292,7 +293,7 @@ /* if we get here, we didn't find an MCA adapter */ return -ENODEV; } -#endif +#endif /* CONFIG_MCA */ #ifdef __ISAPNP__ if (nopnp == 1) @@ -330,7 +331,7 @@ } } no_pnp: -#endif +#endif /* __ISAPNP__ */ /* Select an open I/O location at 0x1*0 to do contention select. */ for ( ; id_port < 0x200; id_port += 0x10) { @@ -396,7 +397,7 @@ } } } -#endif +#endif /* __ISAPNP__ */ { unsigned int iobase = id_read_eeprom(8); @@ -466,9 +467,10 @@ return -ENOMEM; memset(dev->priv, 0, sizeof(struct el3_private)); - ((struct el3_private *)dev->priv)->mca_slot = mca_slot; - ((struct el3_private *)dev->priv)->next_dev = el3_root_dev; - ((struct el3_private *)dev->priv)->lock = (spinlock_t) SPIN_LOCK_UNLOCKED; + lp = dev->priv; + lp->mca_slot = mca_slot; + lp->next_dev = el3_root_dev; + spin_lock_init(&lp->lock); el3_root_dev = dev; if (el3_debug > 0) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/3c59x.c linux/drivers/net/3c59x.c --- v2.4.0-test8/linux/drivers/net/3c59x.c Wed Aug 23 18:36:37 2000 +++ linux/drivers/net/3c59x.c Fri Sep 15 16:28:25 2000 @@ -98,6 +98,18 @@ - Added INVERT_LED_PWR, used it. - Backed out the extra_reset stuff + LK1.1.9 2 Sep 2000 andrewm + - Backed out the tx_reset_resume flags. It was a no-op. + - In vortex_error, don't reset the Tx on txReclaim errors + - In vortex_error, don't reset the Tx on maxCollisions errors. + Hence backed out all the DownListPtr logic here. + - In vortex_error, give Tornado cards a partial TxReset on + maxCollisions (David Hinds). Defined MAX_COLLISION_RESET for this. + - Redid some driver flags and device names based on pcmcia_cs-3.1.20. + - Fixed a bug where, if vp->tx_full is set when the interface + is downed, it remains set when the interface is upped. Bad + things happen. + - See http://www.uow.edu.au/~andrewm/linux/#3c59x-2.3 for more details. - Also see Documentation/networking/vortex.txt */ @@ -183,7 +195,7 @@ #include static char version[] __devinitdata = -"3c59x.c:LK1.1.8 13 Aug 2000 Donald Becker and others. http://www.scyld.com/network/vortex.html " "$Revision: 1.102.2.25 $\n"; +"3c59x.c:LK1.1.9 2 Sep 2000 Donald Becker and others. http://www.scyld.com/network/vortex.html " "$Revision: 1.102.2.38 $\n"; MODULE_AUTHOR("Donald Becker "); MODULE_DESCRIPTION("3Com 3c59x/3c90x/3c575 series Vortex/Boomerang/Cyclone driver"); @@ -303,7 +315,7 @@ enum { IS_VORTEX=1, IS_BOOMERANG=2, IS_CYCLONE=4, IS_TORNADO=8, EEPROM_8BIT=0x10, /* AKPM: Uses 0x230 as the base bitmaps for EEPROM reads */ HAS_PWR_CTRL=0x20, HAS_MII=0x40, HAS_NWAY=0x80, HAS_CB_FNS=0x100, - INVERT_MII_PWR=0x200, INVERT_LED_PWR=0x400 }; + INVERT_MII_PWR=0x200, INVERT_LED_PWR=0x400, MAX_COLLISION_RESET=0x800 }; enum vortex_chips { @@ -415,14 +427,14 @@ {"3CCFE575BT Cyclone CardBus", PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_LED_PWR, 128, }, - {"3CCFE575CT Cyclone CardBus", - PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR, 128, }, + {"3CCFE575CT Tornado CardBus", + PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR|MAX_COLLISION_RESET, 128, }, {"3CCFE656 Cyclone CardBus", PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR|INVERT_LED_PWR, 128, }, {"3CCFEM656B Cyclone+Winmodem CardBus", PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR|INVERT_LED_PWR, 128, }, - {"3CCFE656C Tornado+Winmodem CardBus", /* From pcmcia-cs-3.1.5 */ - PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR, 128, }, + {"3CXFEM656C Tornado+Winmodem CardBus", /* From pcmcia-cs-3.1.5 */ + PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR|MAX_COLLISION_RESET, 128, }, {"3c450 HomePNA Tornado", /* AKPM: from Don's 0.99Q */ PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY, 128, }, @@ -652,7 +664,6 @@ open:1, must_free_region:1; /* Flag: if zero, Cardbus owns the I/O region */ int drv_flags; - int tx_reset_resume; /* Flag to retart timer after vortex_error handling */ u16 status_enable; u16 intr_enable; u16 available_media; /* From Wn3_Options. */ @@ -1369,6 +1380,7 @@ vortex_up(dev); vp->open = 1; + vp->tx_full = 0; return 0; out_free_irq: @@ -1570,7 +1582,7 @@ { struct vortex_private *vp = (struct vortex_private *)dev->priv; long ioaddr = dev->base_addr; - int do_tx_reset = 0; + int do_tx_reset = 0, reset_mask = 0; unsigned char tx_status = 0; if (vortex_debug > 2) { @@ -1589,10 +1601,14 @@ if (tx_status & 0x14) vp->stats.tx_fifo_errors++; if (tx_status & 0x38) vp->stats.tx_aborted_errors++; outb(0, ioaddr + TxStatus); - if (tx_status & 0x3a) /* TxReset after 16 collisions, despite what the manual says */ - do_tx_reset = 1; /* Also reset on reclaim errors */ - else /* Merely re-enable the transmitter. */ + if (tx_status & 0x30) { /* txJabber or txUnderrun */ + do_tx_reset = 1; + } else if ((tx_status & 0x08) && (vp->drv_flags & MAX_COLLISION_RESET)) { /* maxCollisions */ + do_tx_reset = 1; + reset_mask = 0x0108; /* Reset interface logic, but not download logic */ + } else { /* Merely re-enable the transmitter. */ outw(TxEnable, ioaddr + EL3_CMD); + } } if (status & RxEarly) { /* Rx early is unused. */ @@ -1644,40 +1660,11 @@ } } - /* - * Black magic. If we're resetting the transmitter, remember the current downlist - * pointer and restore it afterwards. We can't usr cur_tx because that could - * lag the actual hardware index. - */ if (do_tx_reset) { - if (vp->full_bus_master_tx) { - unsigned long old_down_list_ptr; - - wait_for_completion(dev, DownStall); - old_down_list_ptr = inl(ioaddr + DownListPtr); - wait_for_completion(dev, TxReset); - outw(TxEnable, ioaddr + EL3_CMD); - - /* Restart DMA if necessary */ - outl(old_down_list_ptr, ioaddr + DownListPtr); - if (vortex_debug > 2) - printk(KERN_DEBUG "reset DMA to 0x%08x\n", inl(ioaddr + DownListPtr)); - outw(DownUnstall, ioaddr + EL3_CMD); - - /* - * Here we make a single attempt to prevent a timeout by - * restarting the timer if we think that the ISR has a good - * chance of unjamming things. - */ - if (vp->tx_reset_resume == 0 && vp->tx_full) { - vp->tx_reset_resume = 1; - dev->trans_start = jiffies; - } - } else { - wait_for_completion(dev, TxReset); - outw(TxEnable, ioaddr + EL3_CMD); + wait_for_completion(dev, TxReset|reset_mask); + outw(TxEnable, ioaddr + EL3_CMD); + if (!vp->full_bus_master_tx) netif_wake_queue(dev); - } } } @@ -1785,7 +1772,6 @@ /* netif_start_queue (dev); */ /* AKPM: redundant? */ } outw(DownUnstall, ioaddr + EL3_CMD); - vp->tx_reset_resume = 0; spin_unlock_irqrestore(&vp->lock, flags); dev->trans_start = jiffies; return 0; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/8139too.c linux/drivers/net/8139too.c --- v2.4.0-test8/linux/drivers/net/8139too.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/net/8139too.c Sun Sep 17 09:41:28 2000 @@ -2,8 +2,37 @@ 8139too.c: A RealTek RTL-8139 Fast Ethernet driver for Linux. - Copyright 2000 Jeff Garzik - Originally: Written 1997-1999 by Donald Becker. + Maintained by Jeff Garzik + + Much code comes from Donald Becker's rtl8139.c driver, + versions 1.11 and older. This driver was originally based + on rtl8139.c version 1.07. Header of rtl8139.c version 1.11: + + ---------- + + Written 1997-2000 by Donald Becker. + This software may be used and distributed according to the + terms of the GNU General Public License (GPL), incorporated + herein by reference. Drivers based on or derived from this + code fall under the GPL and must retain the authorship, + copyright and license notice. This file is not a complete + program and may only be used when the entire operating + system is licensed under the GPL. + + This driver is for boards based on the RTL8129 and RTL8139 + PCI ethernet chips. + + The author may be reached as becker@scyld.com, or C/O Scyld + Computing Corporation 410 Severn Ave., Suite 210 Annapolis + MD 21403 + + Support and updates available at + http://www.scyld.com/network/rtl8139.html + + Twister-tuning table provided by Kinston + . + + ---------- This software may be used and distributed according to the terms of the GNU Public License, incorporated herein by reference. @@ -16,7 +45,7 @@ Tigran Aivazian - bug fixes, skbuff free cleanup Martin Mares - suggestions for PCI cleanup - + David S. Miller - PCI DMA and softnet updates Ernst Gill - fixes ported from BSD driver @@ -24,7 +53,22 @@ Daniel Kobras - identified specific locations of posted MMIO write bugginess - Gerard Sharp - bug fix + Gerard Sharp - bug fix, testing and feedback + + David Ford - Rx ring wrap fix + + Dan DeMaggio - swapped RTL8139 cards with me, and allowed me + to find and fix a crucial bug on older chipsets. + + Donald Becker/Chris Butterworth/Marcus Westergren - + Noticed various Rx packet size-related buglets. + + Santiago Garcia Mantinan - testing and feedback + + Jens David - 2.2.x kernel backports + + Martin Dennett - incredibly helpful insight on undocumented + features of the 8139 chips Submitting bug reports: @@ -73,7 +117,7 @@ IVb. References http://www.realtek.com.tw/cn/cn.html -http://cesdis.gsfc.nasa.gov/linux/misc/NWay.html +http://www.scyld.com/expert/NWay.html IVc. Errata @@ -97,25 +141,33 @@ #include -#define RTL8139_VERSION "0.9.8" +#define RTL8139_VERSION "0.9.10" #define RTL8139_MODULE_NAME "8139too" #define RTL8139_DRIVER_NAME RTL8139_MODULE_NAME " Fast Ethernet driver " RTL8139_VERSION #define PFX RTL8139_MODULE_NAME ": " -#undef RTL8139_DEBUG /* define to 1 to enable copious debugging info */ + +/* define to 1 to enable PIO instead of MMIO */ +#undef USE_IO_OPS + +/* define to 1 to enable copious debugging info */ +#undef RTL8139_DEBUG + +/* define to 1 to disable lightweight runtime debugging checks */ +#undef RTL8139_NDEBUG + #ifdef RTL8139_DEBUG /* note: prints function name for you */ -#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) +# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) #else -#define DPRINTK(fmt, args...) +# define DPRINTK(fmt, args...) #endif -#undef RTL8139_NDEBUG /* define to 1 to disable lightweight runtime checks */ #ifdef RTL8139_NDEBUG -#define assert(expr) +# define assert(expr) do {} while (0) #else -#define assert(expr) \ +# define assert(expr) \ if(!(expr)) { \ printk( "Assertion failed! %s,%s,%s,line=%d\n", \ #expr,__FILE__,__FUNCTION__,__LINE__); \ @@ -125,12 +177,6 @@ #define arraysize(x) (sizeof(x)/sizeof(*(x))) -#ifndef PCI_GET_DRIVER_DATA - #define PCI_GET_DRIVER_DATA(pdev) ((pdev)->driver_data) - #define PCI_SET_DRIVER_DATA(pdev,data) (((pdev)->driver_data) = (data)) -#endif /* PCI_GET_DRIVER_DATA */ - - /* A few user-configurable values. */ /* media options */ static int media[] = {-1, -1, -1, -1, -1, -1, -1, -1}; @@ -146,7 +192,8 @@ #define RX_BUF_LEN_IDX 2 /* 0==8K, 1==16K, 2==32K, 3==64K */ #define RX_BUF_LEN (8192 << RX_BUF_LEN_IDX) #define RX_BUF_PAD 16 -#define RX_BUF_TOT_LEN (RX_BUF_LEN + RX_BUF_PAD) +#define RX_BUF_WRAP_PAD 2048 /* spare padding to handle lack of packet wrap */ +#define RX_BUF_TOT_LEN (RX_BUF_LEN + RX_BUF_PAD + RX_BUF_WRAP_PAD) /* Number of Tx descriptor registers. */ #define NUM_TX_DESC 4 @@ -160,9 +207,9 @@ #define TX_FIFO_THRESH 256 /* In bytes, rounded down to 32 byte units. */ /* The following settings are log_2(bytes)-4: 0 == 16 bytes .. 6==1024, 7==end of packet. */ -#define RX_FIFO_THRESH 4 /* Rx buffer level before first PCI xfer. */ -#define RX_DMA_BURST 4 /* Maximum PCI burst, '7' is unlimited */ -#define TX_DMA_BURST 4 /* Maximum PCI burst, '4' is 256 */ +#define RX_FIFO_THRESH 6 /* Rx buffer level before first PCI xfer. */ +#define RX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */ +#define TX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */ /* Operational parameters that usually are not changed. */ @@ -321,6 +368,7 @@ TxLoopBack = (1 << 18) | (1 << 17), /* enable loopback test mode */ TxCRC = (1 << 16), /* DISABLE appending CRC to end of Tx packets */ TxClearAbt = (1 << 0), /* Clear abort (WO) */ + TxDMAShift = 8, /* DMA burst value (0-7) is shift this many bits */ TxVersionMask = 0x7C800000, /* mask out version bits 30-26, 23 */ }; @@ -341,7 +389,7 @@ /* Early Rx threshold, none or X/16 */ RxCfgEarlyRxNone = 0, RxCfgEarlyRxShift = 24, - + /* rx fifo threshold */ RxCfgFIFOShift = 13, RxCfgFIFONone = (7 << RxCfgFIFOShift), @@ -355,6 +403,9 @@ RxCfgRcv16K = (1 << 11), RxCfgRcv32K = (1 << 12), RxCfgRcv64K = (1 << 11) | (1 << 12), + + /* Disable packet wrap at end of Rx buffer */ + RxNoWrap = (1 << 7), }; @@ -411,17 +462,17 @@ 0x40, 0xf0fe0040, /* XXX copied from RTL8139A, verify */ }, - + { "RTL-8139 rev K", 0x60, - 0xf0fe0040, /* XXX copied from RTL8139A, verify */ + 0xf0fe0040, }, - + { "RTL-8139A", 0x70, 0xf0fe0040, }, - + { "RTL-8139B", 0x78, 0xf0fc0040 @@ -497,6 +548,32 @@ static void rtl8139_hw_start (struct net_device *dev); +#ifdef USE_IO_OPS + +#define RTL_R8(reg) inb (((unsigned long)ioaddr) + (reg)) +#define RTL_R16(reg) inw (((unsigned long)ioaddr) + (reg)) +#define RTL_R32(reg) inl (((unsigned long)ioaddr) + (reg)) +#define RTL_W8(reg, val8) outb ((val8), ((unsigned long)ioaddr) + (reg)) +#define RTL_W16(reg, val16) outw ((val16), ((unsigned long)ioaddr) + (reg)) +#define RTL_W32(reg, val32) outl ((val32), ((unsigned long)ioaddr) + (reg)) +#define RTL_W8_F RTL_W8 +#define RTL_W16_F RTL_W16 +#define RTL_W32_F RTL_W32 +#undef readb +#undef readw +#undef readl +#undef writeb +#undef writew +#undef writel +#define readb(addr) inb((unsigned long)(addr)) +#define readw(addr) inw((unsigned long)(addr)) +#define readl(addr) inl((unsigned long)(addr)) +#define writeb(val,addr) outb((val),(unsigned long)(addr)) +#define writew(val,addr) outw((val),(unsigned long)(addr)) +#define writel(val,addr) outl((val),(unsigned long)(addr)) + +#else + /* write MMIO register, with flush */ /* Flush avoids rtl8139 bug w/ posted MMIO writes */ #define RTL_W8_F(reg, val8) do { writeb ((val8), ioaddr + (reg)); readb (ioaddr + (reg)); } while (0) @@ -525,13 +602,17 @@ #define RTL_R16(reg) readw (ioaddr + (reg)) #define RTL_R32(reg) readl (ioaddr + (reg)) +#endif /* USE_IO_OPS */ -static const u16 rtl8139_intr_mask = + +static const u16 rtl8139_intr_mask = PCIErr | PCSTimeout | RxUnderrun | RxOverflow | RxFIFOOver | TxErr | TxOK | RxErr | RxOK; static const unsigned int rtl8139_rx_config = - RxCfgEarlyRxNone | RxCfgFIFONone | RxCfgRcv32K | RxCfgDMAUnlimited; + RxCfgEarlyRxNone | RxCfgRcv32K | RxNoWrap | + (RX_FIFO_THRESH << RxCfgFIFOShift) | + (RX_DMA_BURST << RxCfgDMAShift); static int __devinit rtl8139_init_board (struct pci_dev *pdev, @@ -577,7 +658,7 @@ /* set this immediately, we need to know before * we talk to the chip directly */ DPRINTK("PIO region size == 0x%02X\n", pio_len); - DPRINTK("MMIO region size == 0x%02X\n", mmio_len); + DPRINTK("MMIO region size == 0x%02lX\n", mmio_len); if (pio_len == RTL8139B_IO_SIZE) tp->chipset = CH_8139B; @@ -587,14 +668,14 @@ rc = -ENODEV; goto err_out; } - + /* make sure PCI base addr 1 is MMIO */ if (!(mmio_flags & IORESOURCE_MEM)) { printk (KERN_ERR PFX "region #1 not an MMIO resource, aborting\n"); rc = -ENODEV; goto err_out; } - + /* check for weird/broken PCI region reporting */ if ((pio_len != mmio_len) || (pio_len < RTL_MIN_IO_SIZE) || @@ -610,14 +691,14 @@ rc = -EBUSY; goto err_out; } - + /* make sure our MMIO region in PCI space is available */ if (!request_mem_region (mmio_start, mmio_len, dev->name)) { printk (KERN_ERR PFX "no mem resource available, aborting\n"); rc = -EBUSY; goto err_out_free_pio; } - + /* enable device (incl. PCI PM wakeup), and bus-mastering */ rc = pci_enable_device (pdev); if (rc) @@ -625,6 +706,9 @@ pci_set_master (pdev); +#ifdef USE_IO_OPS + ioaddr = (void *) pio_start; +#else /* ioremap MMIO region */ ioaddr = ioremap (mmio_start, mmio_len); if (ioaddr == NULL) { @@ -632,6 +716,7 @@ rc = -EIO; goto err_out_free_mmio; } +#endif /* USE_IO_OPS */ /* Soft reset the chip. */ RTL_W8 (ChipCmd, (RTL_R8 (ChipCmd) & ChipCmdClear) | CmdReset); @@ -653,12 +738,14 @@ RTL_W8 (Config1, 0); } +#ifndef USE_IO_OPS /* sanity checks -- ensure PIO and MMIO registers agree */ assert (inb (pio_start+Config0) == readb (ioaddr+Config0)); assert (inb (pio_start+Config1) == readb (ioaddr+Config1)); assert (inb (pio_start+TxConfig) == readb (ioaddr+TxConfig)); assert (inb (pio_start+RxConfig) == readb (ioaddr+RxConfig)); - +#endif /* !USE_IO_OPS */ + /* make sure chip thinks PIO and MMIO are enabled */ tmp8 = RTL_R8 (Config1); if ((tmp8 & Cfg1_PIO) == 0) { @@ -671,7 +758,7 @@ rc = -EIO; goto err_out_iounmap; } - + /* identify chip attached to board */ tmp = RTL_R8 (ChipVersion); for (i = arraysize (rtl_chip_info) - 1; i >= 0; i--) @@ -691,15 +778,17 @@ tmp, tp->chipset, rtl_chip_info[tp->chipset].name); - + DPRINTK ("EXIT, returning 0\n"); *ioaddr_out = ioaddr; *dev_out = dev; - return 0; + return 0; err_out_iounmap: assert (ioaddr > 0); +#ifndef USE_IO_OPS iounmap (ioaddr); +#endif /* !USE_IO_OPS */ err_out_free_mmio: release_mem_region (mmio_start, mmio_len); err_out_free_pio: @@ -720,14 +809,11 @@ int i, addr_len, option; void *ioaddr = NULL; static int board_idx = -1; - u8 tmp; - -#ifndef RTL8139_NDEBUG static int printed_version = 0; -#endif /* RTL8139_NDEBUG */ + u8 tmp; DPRINTK ("ENTER\n"); - + assert (pdev != NULL); assert (ent != NULL); @@ -743,9 +829,9 @@ DPRINTK ("EXIT, returning %d\n", i); return i; } - + tp = dev->priv; - + assert (ioaddr != NULL); assert (dev != NULL); assert (tp != NULL); @@ -766,7 +852,7 @@ dev->watchdog_timeo = TX_TIMEOUT; dev->irq = pdev->irq; - dev->base_addr = pci_resource_start (pdev, 1); + dev->base_addr = (unsigned long) ioaddr; /* dev->priv/tp zeroed and aligned in init_etherdev */ tp = dev->priv; @@ -779,24 +865,23 @@ tp->mmio_addr = ioaddr; tp->lock = SPIN_LOCK_UNLOCKED; - PCI_SET_DRIVER_DATA (pdev, dev); + pdev->driver_data = dev; tp->phys[0] = 32; - printk (KERN_INFO "%s: %s board found at 0x%lx, IRQ %d\n", - dev->name, board_info[ent->driver_data].name, - dev->base_addr, dev->irq); - - printk (KERN_INFO "%s: Chip is '%s'\n", - dev->name, - rtl_chip_info[tp->chipset].name); - - printk (KERN_INFO "%s: MAC address " - "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x.\n", + printk (KERN_INFO "%s: %s at 0x%lx, " + "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x, " + "IRQ %d\n", dev->name, + board_info[ent->driver_data].name, + dev->base_addr, dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], dev->dev_addr[3], - dev->dev_addr[4], dev->dev_addr[5]); + dev->dev_addr[4], dev->dev_addr[5], + dev->irq); + + printk (KERN_DEBUG "%s: Identified 8139 chip type '%s'\n", + dev->name, rtl_chip_info[tp->chipset].name); /* Put the chip into low-power mode. */ RTL_W8_F (Cfg9346, Cfg9346_Unlock); @@ -831,7 +916,7 @@ static void __devexit rtl8139_remove_one (struct pci_dev *pdev) { - struct net_device *dev = PCI_GET_DRIVER_DATA (pdev); + struct net_device *dev = pdev->driver_data; struct rtl8139_private *np; DPRINTK ("ENTER\n"); @@ -843,7 +928,10 @@ unregister_netdev (dev); +#ifndef USE_IO_OPS iounmap (np->mmio_addr); +#endif /* !USE_IO_OPS */ + release_region (pci_resource_start (pdev, 0), pci_resource_len (pdev, 0)); release_mem_region (pci_resource_start (pdev, 1), @@ -857,7 +945,9 @@ #endif /* RTL8139_NDEBUG */ kfree (dev); - + + pdev->driver_data = NULL; + DPRINTK ("EXIT\n"); } @@ -1094,9 +1184,9 @@ DPRINTK ("EXIT, returning -ENOMEM\n"); MOD_DEC_USE_COUNT; return -ENOMEM; - + } - + tp->full_duplex = tp->duplex_lock; tp->tx_flag = (TX_FIFO_THRESH << 11) & 0x003f0000; @@ -1131,7 +1221,7 @@ u8 tmp; DPRINTK ("ENTER\n"); - + /* Soft reset the chip. */ RTL_W8 (ChipCmd, (RTL_R8 (ChipCmd) & ChipCmdClear) | CmdReset); udelay (100); @@ -1154,7 +1244,7 @@ RTL_W32_F (RxConfig, i); /* Check this value: the documentation for IFG contradicts ifself. */ - RTL_W32 (TxConfig, (TX_DMA_BURST << 8)); + RTL_W32 (TxConfig, (TX_DMA_BURST << TxDMAShift)); /* unlock Config[01234] and BMCR register writes */ RTL_W8_F (Cfg9346, Cfg9346_Unlock); @@ -1175,9 +1265,9 @@ if (tp->chipset >= CH_8139B) { tmp = RTL_R8 (Config4) & ~(1<<2); /* chip will clear Rx FIFO overflow automatically */ - tmp |= (1<<7); + tmp |= (1<<7); RTL_W8 (Config4, tmp); - + /* disable magic packet scanning, which is enabled * when PM is enabled above (Config1) */ RTL_W8 (Config3, RTL_R8 (Config3) & ~(1<<5)); @@ -1334,15 +1424,13 @@ { struct net_device *dev = (struct net_device *) data; struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv; + void *ioaddr = tp->mmio_addr; int next_tick = 60 * HZ; int mii_reg5; - spin_lock_irq (&tp->lock); - mii_reg5 = mdio_read (dev, tp->phys[0], 5); if (!tp->duplex_lock && mii_reg5 != 0xffff) { - void *ioaddr = tp->mmio_addr; int duplex = (mii_reg5 & 0x0100) || (mii_reg5 & 0x01C0) == 0x0040; if (tp->full_duplex != duplex) { @@ -1371,8 +1459,6 @@ dev->name, RTL_R8 (Config0), RTL_R8 (Config1)); - spin_unlock_irq (&tp->lock); - tp->timer.expires = jiffies + next_tick; add_timer (&tp->timer); } @@ -1383,6 +1469,7 @@ struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv; void *ioaddr = tp->mmio_addr; int i; + unsigned long flags; DPRINTK ("%s: Transmit timeout, status %2.2x %4.4x " "media %2.2x.\n", dev->name, @@ -1390,25 +1477,20 @@ RTL_R16 (IntrStatus), RTL_R8 (MediaStatus)); - spin_lock_irq (&tp->lock); - /* Disable interrupts by clearing the interrupt mask. */ RTL_W16 (IntrMask, 0x0000); - spin_unlock_irq (&tp->lock); - /* Emit info to figure out what went wrong. */ - printk (KERN_DEBUG - "%s: Tx queue start entry %d dirty entry %d.\n", + printk (KERN_DEBUG "%s: Tx queue start entry %d dirty entry %d.\n", dev->name, atomic_read (&tp->cur_tx), atomic_read (&tp->dirty_tx)); for (i = 0; i < NUM_TX_DESC; i++) printk (KERN_DEBUG "%s: Tx descriptor %d is %8.8x.%s\n", dev->name, i, RTL_R32 (TxStatus0 + (i * 4)), - i == - atomic_read (&tp->dirty_tx) % NUM_TX_DESC ? " (queue head)" : ""); + i == atomic_read (&tp->dirty_tx) % NUM_TX_DESC ? + " (queue head)" : ""); - spin_lock_irq (&tp->lock); + spin_lock_irqsave (&tp->lock, flags); /* Stop a shared interrupt from scavenging while we are. */ atomic_set (&tp->cur_tx, 0); @@ -1418,7 +1500,8 @@ for (i = 0; i < NUM_TX_DESC; i++) { struct ring_info *rp = &tp->tx_info[i]; if (rp->mapping != 0) { - pci_unmap_single (tp->pci_dev, rp->mapping, rp->skb->len, PCI_DMA_TODEVICE); + pci_unmap_single (tp->pci_dev, rp->mapping, + rp->skb->len, PCI_DMA_TODEVICE); rp->mapping = 0; } if (rp->skb) { @@ -1427,9 +1510,10 @@ tp->stats.tx_dropped++; } } - - spin_unlock_irq (&tp->lock); + spin_unlock_irqrestore (&tp->lock, flags); + + /* ...and finally, reset everything */ rtl8139_hw_start (dev); } @@ -1444,18 +1528,17 @@ /* Calculate the next Tx descriptor entry. */ entry = atomic_read (&tp->cur_tx) % NUM_TX_DESC; + assert (tp->tx_info[entry].skb == NULL); + assert (tp->tx_info[entry].mapping == 0); + tp->tx_info[entry].skb = skb; - tp->tx_info[entry].mapping = 0; + /* tp->tx_info[entry].mapping = 0; */ memcpy (tp->tx_buf[entry], skb->data, skb->len); - spin_lock_irq (&tp->lock); - /* Note: the chip doesn't have auto-pad! */ RTL_W32 (TxStatus0 + (entry * sizeof(u32)), tp->tx_flag | (skb->len >= ETH_ZLEN ? skb->len : ETH_ZLEN)); - spin_unlock_irq (&tp->lock); - dev->trans_start = jiffies; atomic_inc (&tp->cur_tx); if ((atomic_read (&tp->cur_tx) - atomic_read (&tp->dirty_tx)) >= NUM_TX_DESC) @@ -1477,20 +1560,15 @@ assert (dev != NULL); assert (tp != NULL); assert (ioaddr != NULL); - - /* drop lock held in rtl8139_interrupt */ - spin_unlock (&tp->lock); - + dirty_tx = atomic_read (&tp->dirty_tx); while ((atomic_read (&tp->cur_tx) - dirty_tx) > 0) { int entry = dirty_tx % NUM_TX_DESC; int txstatus; - spin_lock (&tp->lock); - txstatus = RTL_R32 (TxStatus0 + (entry * 4)); - spin_unlock (&tp->lock); - + txstatus = RTL_R32 (TxStatus0 + (entry * sizeof (u32))); + if (!(txstatus & (TxStatOK | TxUnderrun | TxAborted))) break; /* It still hasn't been Txed */ @@ -1502,9 +1580,7 @@ tp->stats.tx_errors++; if (txstatus & TxAborted) { tp->stats.tx_aborted_errors++; - spin_lock (&tp->lock); - RTL_W32 (TxConfig, (TX_DMA_BURST << 8)); - spin_unlock (&tp->lock); + RTL_W32 (TxConfig, TxClearAbt | (TX_DMA_BURST << TxDMAShift)); } if (txstatus & TxCarrierLost) tp->stats.tx_carrier_errors++; @@ -1551,17 +1627,63 @@ #endif /* RTL8139_NDEBUG */ atomic_set (&tp->dirty_tx, dirty_tx); - - /* obtain lock need for rtl8139_interrupt */ - spin_lock (&tp->lock); +} + + +/* TODO: clean this up! Rx reset need not be this intensive */ +static void rtl8139_rx_err (u32 rx_status, struct net_device *dev, + struct rtl8139_private *tp, void *ioaddr) +{ + u8 tmp8; + int tmp_work = 1000; + + DPRINTK ("%s: Ethernet frame had errors, status %8.8x.\n", + dev->name, rx_status); + if (rx_status & RxTooLong) { + DPRINTK ("%s: Oversized Ethernet frame, status %4.4x!\n", + dev->name, rx_status); + /* A.C.: The chip hangs here. */ + } + tp->stats.rx_errors++; + if (rx_status & (RxBadSymbol | RxBadAlign)) + tp->stats.rx_frame_errors++; + if (rx_status & (RxRunt | RxTooLong)) + tp->stats.rx_length_errors++; + if (rx_status & RxCRCErr) + tp->stats.rx_crc_errors++; + /* Reset the receiver, based on RealTek recommendation. (Bug?) */ + tp->cur_rx = 0; + + /* disable receive */ + tmp8 = RTL_R8 (ChipCmd) & ChipCmdClear; + RTL_W8_F (ChipCmd, tmp8 | CmdTxEnb); + + /* A.C.: Reset the multicast list. */ + rtl8139_set_rx_mode (dev); + + /* XXX potentially temporary hack to + * restart hung receiver */ + while (--tmp_work > 0) { + tmp8 = RTL_R8 (ChipCmd); + if ((tmp8 & CmdRxEnb) && (tmp8 & CmdTxEnb)) + break; + RTL_W8_F (ChipCmd, + (tmp8 & ChipCmdClear) | CmdRxEnb | CmdTxEnb); + } + + /* G.S.: Re-enable receiver */ + /* XXX temporary hack to work around receiver hang */ + rtl8139_set_rx_mode (dev); + + if (tmp_work <= 0) + printk (KERN_WARNING PFX "tx/rx enable wait too long\n"); } /* The data sheet doesn't describe the Rx ring at all, so I'm guessing at the field alignments and semantics. */ static void rtl8139_rx_interrupt (struct net_device *dev, - struct rtl8139_private *tp, - void *ioaddr) + struct rtl8139_private *tp, void *ioaddr) { unsigned char *rx_ring; u16 cur_rx; @@ -1569,31 +1691,33 @@ assert (dev != NULL); assert (tp != NULL); assert (ioaddr != NULL); - + rx_ring = tp->rx_ring; cur_rx = tp->cur_rx; DPRINTK ("%s: In rtl8139_rx(), current %4.4x BufAddr %4.4x," - " free to %4.4x, Cmd %2.2x.\n", dev->name, cur_rx, - RTL_R16 (RxBufAddr), - RTL_R16 (RxBufPtr), - RTL_R8 (ChipCmd)); + " free to %4.4x, Cmd %2.2x.\n", dev->name, cur_rx, + RTL_R16 (RxBufAddr), + RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd)); while ((RTL_R8 (ChipCmd) & RxBufEmpty) == 0) { int ring_offset = cur_rx % RX_BUF_LEN; u32 rx_status = le32_to_cpu (*(u32 *) (rx_ring + ring_offset)); int rx_size = rx_status >> 16; + struct sk_buff *skb; + int pkt_size = rx_size - 4; DPRINTK ("%s: rtl8139_rx() status %4.4x, size %4.4x," - " cur %4.4x.\n", dev->name, rx_status, - rx_size, cur_rx); + " cur %4.4x.\n", dev->name, rx_status, + rx_size, cur_rx); #if RTL8139_DEBUG > 2 { - int i; - DPRINTK ("%s: Frame contents ", dev->name); - for (i = 0; i < 70; i++) - printk (" %2.2x", rx_ring[ring_offset + i]); - printk (".\n"); + int i; + DPRINTK ("%s: Frame contents ", dev->name); + for (i = 0; i < 70; i++) + printk (" %2.2x", + rx_ring[ring_offset + i]); + printk (".\n"); } #endif @@ -1609,128 +1733,68 @@ if (rx_size == 0xfff0) break; + /* if Rx err received, Rx process gets reset, so + * we abort any further Rx processing + */ if (rx_status & - (RxBadSymbol | RxRunt | RxTooLong | RxCRCErr | - RxBadAlign)) { - u8 tmp8; - int tmp_work = 1000; - - DPRINTK ("%s: Ethernet frame had errors," - " status %8.8x.\n", dev->name, - rx_status); - if (rx_status & RxTooLong) { - DPRINTK ("%s: Oversized Ethernet frame, status %4.4x!\n", - dev->name, rx_status); - /* A.C.: The chip hangs here. */ - } - tp->stats.rx_errors++; - if (rx_status & (RxBadSymbol | RxBadAlign)) - tp->stats.rx_frame_errors++; - if (rx_status & (RxRunt | RxTooLong)) - tp->stats.rx_length_errors++; - if (rx_status & RxCRCErr) - tp->stats.rx_crc_errors++; - /* Reset the receiver, based on RealTek recommendation. (Bug?) */ - tp->cur_rx = 0; - - /* disable receive */ - tmp8 = RTL_R8 (ChipCmd) & ChipCmdClear; - RTL_W8_F (ChipCmd, tmp8 | CmdTxEnb); - - /* A.C.: Reset the multicast list. */ - rtl8139_set_rx_mode (dev); - - /* XXX potentially temporary hack to - * restart hung receiver */ - while (--tmp_work > 0) { - tmp8 = RTL_R8 (ChipCmd); - if ((tmp8 & CmdRxEnb) && (tmp8 & CmdTxEnb)) - break; - RTL_W8_F (ChipCmd, (tmp8 & ChipCmdClear) | CmdRxEnb | CmdTxEnb); - } + (RxBadSymbol | RxRunt | RxTooLong | RxCRCErr | RxBadAlign)) { + rtl8139_rx_err (rx_status, dev, tp, ioaddr); + return; + } - /* G.S.: Re-enable receiver */ - /* XXX temporary hack to work around receiver hang */ - rtl8139_set_rx_mode (dev); + /* Malloc up new buffer, compatible with net-2e. */ + /* Omit the four octet CRC from the length. */ - if (tmp_work <= 0) - printk (KERN_WARNING PFX "tx/rx enable wait too long\n"); - } else { - /* Malloc up new buffer, compatible with net-2e. */ - /* Omit the four octet CRC from the length. */ - struct sk_buff *skb; - int pkt_size = rx_size - 4; - - skb = dev_alloc_skb (pkt_size + 2); - if (skb == NULL) { - printk (KERN_WARNING - "%s: Memory squeeze, dropping packet.\n", - dev->name); - /* We should check that some rx space is free. - If not, free one and mark stats->rx_dropped++. */ - tp->stats.rx_dropped++; - break; - } - skb->dev = dev; - skb_reserve (skb, 2); /* 16 byte align the IP fields. */ + /* TODO: consider allocating skb's outside of + * interrupt context, both to speed interrupt processing, + * and also to reduce the chances of having to + * drop packets here under memory pressure. + */ - if (ring_offset + rx_size + 4 > RX_BUF_LEN) { - int semi_count = - RX_BUF_LEN - ring_offset - 4; - /* This could presumably use two calls to copy_and_sum()? */ - memcpy (skb_put (skb, semi_count), - &rx_ring[ring_offset + 4], - semi_count); - memcpy (skb_put (skb, pkt_size - semi_count), - rx_ring, pkt_size - semi_count); -#ifdef RTL8139_DEBUG - { - int i; - printk (KERN_DEBUG "%s: Frame wrap @%d", - dev->name, semi_count); - for (i = 0; i < 16; i++) - printk (" %2.2x", rx_ring[i]); - printk ("\n"); - memset (rx_ring, 0xcc, 16); - } -#endif /* RTL8139_DEBUG */ - - } else { - eth_copy_and_sum (skb, - &rx_ring[ring_offset + 4], - pkt_size, 0); - skb_put (skb, pkt_size); - } - skb->protocol = eth_type_trans (skb, dev); - netif_rx (skb); - tp->stats.rx_bytes += pkt_size; - tp->stats.rx_packets++; + skb = dev_alloc_skb (pkt_size + 2); + if (skb == NULL) { + printk (KERN_WARNING + "%s: Memory squeeze, dropping packet.\n", + dev->name); + tp->stats.rx_dropped++; + break; } + skb->dev = dev; + skb_reserve (skb, 2); /* 16 byte align the IP fields. */ + + eth_copy_and_sum (skb, &rx_ring[ring_offset + 4], pkt_size, 0); + skb_put (skb, pkt_size); + + skb->protocol = eth_type_trans (skb, dev); + netif_rx (skb); + tp->stats.rx_bytes += pkt_size; + tp->stats.rx_packets++; cur_rx = (cur_rx + rx_size + 4 + 3) & ~3; RTL_W16_F (RxBufPtr, cur_rx - 16); } + DPRINTK ("%s: Done rtl8139_rx(), current %4.4x BufAddr %4.4x," - " free to %4.4x, Cmd %2.2x.\n", dev->name, cur_rx, - RTL_R16 (RxBufAddr), - RTL_R16 (RxBufPtr), - RTL_R8 (ChipCmd)); + " free to %4.4x, Cmd %2.2x.\n", dev->name, cur_rx, + RTL_R16 (RxBufAddr), + RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd)); + tp->cur_rx = cur_rx; } -static int rtl8139_weird_interrupt (struct net_device *dev, - struct rtl8139_private *tp, - void *ioaddr, - int status, int link_changed) -{ - DPRINTK ("%s: Abnormal interrupt, status %8.8x.\n", - dev->name, status); - +static void rtl8139_weird_interrupt (struct net_device *dev, + struct rtl8139_private *tp, + void *ioaddr, + int status, int link_changed) +{ + printk (KERN_DEBUG "%s: Abnormal interrupt, status %8.8x.\n", + dev->name, status); + assert (dev != NULL); assert (tp != NULL); assert (ioaddr != NULL); - + /* Update the error count. */ tp->stats.rx_missed_errors += RTL_R32 (RxMissed); RTL_W32 (RxMissed, 0); @@ -1768,8 +1832,6 @@ printk (KERN_ERR "%s: PCI Bus error %4.4x.\n", dev->name, pci_cmd_status); } - - return 0; } @@ -1785,14 +1847,14 @@ int status = 0, link_changed = 0; /* avoid bogus "uninit" warning */ spin_lock (&tp->lock); - + do { status = RTL_R16 (IntrStatus); /* h/w no longer present (hotplug?) or major error, bail */ if (status == 0xFFFF) break; - + /* Acknowledge all of the current interrupt sources ASAP, but an first get an additional status bit from CSCR. */ if (status & RxUnderrun) @@ -1854,7 +1916,7 @@ } spin_unlock (&tp->lock); - + DPRINTK ("%s: exiting interrupt, intr_status=%#4.4x.\n", dev->name, RTL_R16 (IntrStatus)); } @@ -1875,7 +1937,7 @@ dev->name, RTL_R16 (IntrStatus)); del_timer_sync (&tp->timer); - + spin_lock_irqsave (&tp->lock, flags); /* Disable interrupts by clearing the interrupt mask. */ @@ -1889,7 +1951,7 @@ RTL_W32 (RxMissed, 0); spin_unlock_irqrestore (&tp->lock, flags); - + /* snooze for a small bit */ if (current->need_resched) schedule (); @@ -2053,7 +2115,7 @@ set_bit (ether_crc (ETH_ALEN, mclist->dmi_addr) >> 26, mc_filter); } - + /* if called from irq handler, lock already acquired */ if (!in_irq ()) spin_lock_irq (&tp->lock); @@ -2074,13 +2136,13 @@ static void rtl8139_suspend (struct pci_dev *pdev) { - struct net_device *dev = PCI_GET_DRIVER_DATA (pdev); + struct net_device *dev = pdev->driver_data; struct rtl8139_private *tp = (struct rtl8139_private *) dev->priv; void *ioaddr = tp->mmio_addr; unsigned long flags; netif_device_detach (dev); - + spin_lock_irqsave (&tp->lock, flags); /* Disable interrupts, stop Tx and Rx. */ @@ -2097,7 +2159,7 @@ static void rtl8139_resume (struct pci_dev *pdev) { - struct net_device *dev = PCI_GET_DRIVER_DATA (pdev); + struct net_device *dev = pdev->driver_data; netif_device_attach (dev); rtl8139_hw_start (dev); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/Makefile linux/drivers/net/Makefile --- v2.4.0-test8/linux/drivers/net/Makefile Wed Aug 23 18:36:37 2000 +++ linux/drivers/net/Makefile Sun Sep 17 09:45:05 2000 @@ -304,7 +304,7 @@ MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) ifneq ($(ARCH),s390) -O_OBJS += auto_irq.o +OX_OBJS += auto_irq.o endif include $(TOPDIR)/Rules.make diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/acenic.c linux/drivers/net/acenic.c --- v2.4.0-test8/linux/drivers/net/acenic.c Wed Aug 9 19:19:50 2000 +++ linux/drivers/net/acenic.c Mon Sep 11 08:37:25 2000 @@ -712,7 +712,7 @@ return status; } - +#ifdef MODULE #if (LINUX_VERSION_CODE < 0x02032a) int init_module(void) { @@ -728,7 +728,7 @@ module_init(ace_module_init); module_exit(ace_module_cleanup); #endif - +#endif static void ace_free_descriptors(struct net_device *dev) { diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/arcnet/arcnet.c linux/drivers/net/arcnet/arcnet.c --- v2.4.0-test8/linux/drivers/net/arcnet/arcnet.c Mon Jul 10 16:47:23 2000 +++ linux/drivers/net/arcnet/arcnet.c Sun Sep 17 09:45:05 2000 @@ -155,9 +155,6 @@ #ifdef CONFIG_ARCNET_COM90xx com90xx_probe(NULL); #endif -#ifdef CONFIG_ARCNET_COM20020_PCI - com20020pci_probe_all(); -#endif #endif } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/arcnet/com20020-isa.c linux/drivers/net/arcnet/com20020-isa.c --- v2.4.0-test8/linux/drivers/net/arcnet/com20020-isa.c Tue May 23 15:31:35 2000 +++ linux/drivers/net/arcnet/com20020-isa.c Sun Sep 17 09:45:05 2000 @@ -205,7 +205,7 @@ case 6: /* Timeout */ lp->timeout = ints[6]; case 5: /* CKP value */ - lp->clock = ints[5]; + lp->clockp = ints[5]; case 4: /* Backplane flag */ lp->backplane = ints[4]; case 3: /* Node ID */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/arcnet/com20020-pci.c linux/drivers/net/arcnet/com20020-pci.c --- v2.4.0-test8/linux/drivers/net/arcnet/com20020-pci.c Tue May 23 15:31:35 2000 +++ linux/drivers/net/arcnet/com20020-pci.c Sun Sep 17 09:45:05 2000 @@ -148,7 +148,7 @@ remove: com20020pci_remove }; -int com20020pci_init(void) +static int __init com20020pci_init(void) { BUGLVL(D_NORMAL) printk(VERSION); #ifndef MODULE @@ -157,7 +157,7 @@ return pci_module_init(&com20020pci_driver); } -void com20020pci_cleanup(void) +static void __exit com20020pci_cleanup(void) { pci_unregister_driver(&com20020pci_driver); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/auto_irq.c linux/drivers/net/auto_irq.c --- v2.4.0-test8/linux/drivers/net/auto_irq.c Tue Feb 10 12:56:44 1998 +++ linux/drivers/net/auto_irq.c Sun Sep 17 09:45:05 2000 @@ -32,6 +32,7 @@ "auto_irq.c:v1.11 Donald Becker (becker@cesdis.gsfc.nasa.gov)"; #endif +#include #include #include #include @@ -53,6 +54,10 @@ BUSY_LOOP_UNTIL(delay) return probe_irq_off(irqs); } + +EXPORT_SYMBOL(autoirq_setup); +EXPORT_SYMBOL(autoirq_report); + /* * Local variables: diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/declance.c linux/drivers/net/declance.c --- v2.4.0-test8/linux/drivers/net/declance.c Tue May 23 15:31:35 2000 +++ linux/drivers/net/declance.c Sun Sep 17 09:41:29 2000 @@ -1030,6 +1030,7 @@ /* Make certain the data structures used by the LANCE are aligned. */ dev->priv = (void *) (((unsigned long) dev->priv + 7) & ~7); lp = (struct lance_private *) dev->priv; + spin_lock_init(&lp->lock); switch (type) { #ifdef CONFIG_TC @@ -1193,9 +1194,9 @@ lp->multicast_timer.function = &lance_set_multicast_retry; #ifdef MODULE - dev->ifindex = dev_new_index(); - lp->next_module = root_lance_dev; - root_lance_dev = lp; + dev->ifindex = dev_new_index(); + lp->next_module = root_lance_dev; + root_lance_dev = lp; #endif return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/eexpress.c linux/drivers/net/eexpress.c --- v2.4.0-test8/linux/drivers/net/eexpress.c Fri Jun 23 21:55:09 2000 +++ linux/drivers/net/eexpress.c Sun Sep 17 09:41:29 2000 @@ -1084,6 +1084,7 @@ return -ENOMEM; memset(dev->priv, 0, sizeof(struct net_local)); + spin_lock_init(&lp->lock); printk("(IRQ %d, %s connector, %d-bit bus", dev->irq, eexp_ifmap[dev->if_port], buswidth?8:16); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/epic100.c linux/drivers/net/epic100.c --- v2.4.0-test8/linux/drivers/net/epic100.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/net/epic100.c Sun Sep 10 13:21:13 2000 @@ -33,9 +33,9 @@ LK1.1.4 (jgarzik): * Merge becker test version 1.09 (5/29/2000) - LK1.1.5 (jgarzik): - * Fix locking - * Limit 83c175 probe to ethernet-class PCI devices + LK1.1.5: + * Fix locking (jgarzik) + * Limit 83c175 probe to ethernet-class PCI devices (rgooch) */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/gmac.c linux/drivers/net/gmac.c --- v2.4.0-test8/linux/drivers/net/gmac.c Wed Aug 9 19:19:50 2000 +++ linux/drivers/net/gmac.c Sun Sep 17 09:48:05 2000 @@ -9,10 +9,15 @@ * Changes: * Arnaldo Carvalho de Melo - 08/06/2000 * - check init_etherdev return in gmac_probe1 + * BenH - 03/09/2000 + * - Add support for new PHYs + * - Add some PowerBook sleep code * */ #include + +#include #include #include #include @@ -29,13 +34,19 @@ #include #include #include +#include +#ifdef CONFIG_PMAC_PBOOK +#include +#include +#include +#endif #include "gmac.h" #define DEBUG_PHY -/* Driver version 1.1, kernel 2.4.x */ -#define GMAC_VERSION "v1.1k4" +/* Driver version 1.2, kernel 2.4.x */ +#define GMAC_VERSION "v1.2k4" static unsigned char dummy_buf[RX_BUF_ALLOC_SIZE + RX_OFFSET + GMAC_BUFFER_ALIGN]; static struct net_device *gmacs = NULL; @@ -48,9 +59,12 @@ static void mii_interrupt(struct gmac *gm); static int mii_lookup_and_reset(struct gmac *gm); static void mii_setup_phy(struct gmac *gm); +static int mii_do_reset_phy(struct gmac *gm, int phy_addr); +static void mii_init_BCM5400(struct gmac *gm); static void gmac_set_power(struct gmac *gm, int power_up); static int gmac_powerup_and_reset(struct net_device *dev); +static void gmac_set_gigabit_mode(struct gmac *gm, int gigabit); static void gmac_set_duplex_mode(struct gmac *gm, int full_duplex); static void gmac_mac_init(struct gmac *gm, unsigned char *mac_addr); static void gmac_init_rings(struct gmac *gm, int from_irq); @@ -71,6 +85,13 @@ extern int pci_device_loc(struct device_node *dev, unsigned char *bus_ptr, unsigned char *devfn_ptr); +#ifdef CONFIG_PMAC_PBOOK +int gmac_sleep_notify(struct pmu_sleep_notifier *self, int when); +static struct pmu_sleep_notifier gmac_sleep_notifier = { + gmac_sleep_notify, SLEEP_LEVEL_NET, +}; +#endif + /* * Read via the mii interface from a PHY register */ @@ -161,6 +182,19 @@ * a timer and control the autoneg. process more closely. Also, we may * want to stop rx and tx side when the link is down. */ + +/* Link modes of the BCM5400 PHY */ +static int phy_BCM5400_link_table[8][3] = { + { 0, 0, 0 }, /* No link */ + { 0, 0, 0 }, /* 10BT Half Duplex */ + { 1, 0, 0 }, /* 10BT Full Duplex */ + { 0, 1, 0 }, /* 100BT Half Duplex */ + { 0, 1, 0 }, /* 100BT Half Duplex */ + { 1, 1, 0 }, /* 100BT Full Duplex*/ + { 1, 0, 1 }, /* 1000BT */ + { 1, 0, 1 }, /* 1000BT */ +}; + static void mii_interrupt(struct gmac *gm) { @@ -175,8 +209,9 @@ /* We read the Auxilliary Status Summary register */ phy_status = mii_read(gm, gm->phy_addr, MII_SR); if ((phy_status ^ gm->phy_status) & (MII_SR_ASSC | MII_SR_LKS)) { - int full_duplex; - int link_100; + int full_duplex = 0; + int link_100 = 0; + int gigabit = 0; #ifdef DEBUG_PHY printk("Link state change, phy_status: 0x%04x\n", phy_status); #endif @@ -188,8 +223,9 @@ else GM_BIC(GM_MAC_CTRL_CONFIG, GM_MAC_CTRL_CONF_SND_PAUSE_EN); - /* Link ? For now we handle only the 5201 PHY */ + /* Link ? Check for speed and duplex */ if ((phy_status & MII_SR_LKS) && (phy_status & MII_SR_ASSC)) { + int restart = 0; if (gm->phy_type == PHY_B5201) { int aux_stat = mii_read(gm, gm->phy_addr, MII_BCM5201_AUXCTLSTATUS); #ifdef DEBUG_PHY @@ -197,19 +233,41 @@ #endif full_duplex = ((aux_stat & MII_BCM5201_AUXCTLSTATUS_DUPLEX) != 0); link_100 = ((aux_stat & MII_BCM5201_AUXCTLSTATUS_SPEED) != 0); - } else { - full_duplex = 1; - link_100 = 1; + } else if (gm->phy_type == PHY_B5400) { + int aux_stat = mii_read(gm, gm->phy_addr, MII_BCM5400_AUXSTATUS); + int link = (aux_stat & MII_BCM5400_AUXSTATUS_LINKMODE_MASK) >> + MII_BCM5400_AUXSTATUS_LINKMODE_SHIFT; +#ifdef DEBUG_PHY + printk(" Link up ! BCM5400 aux_stat: 0x%04x (link mode: %d)\n", + aux_stat, link); +#endif + full_duplex = phy_BCM5400_link_table[link][0]; + link_100 = phy_BCM5400_link_table[link][1]; + gigabit = phy_BCM5400_link_table[link][2]; + } else if (gm->phy_type == PHY_LXT971) { + int stat2 = mii_read(gm, gm->phy_addr, MII_LXT971_STATUS2); +#ifdef DEBUG_PHY + printk(" Link up ! LXT971 stat2: 0x%04x\n", stat2); +#endif + full_duplex = ((stat2 & MII_LXT971_STATUS2_FULLDUPLEX) != 0); + link_100 = ((stat2 & MII_LXT971_STATUS2_SPEED) != 0); } #ifdef DEBUG_PHY printk(" full_duplex: %d, speed: %s\n", full_duplex, - link_100 ? "100" : "10"); + gigabit ? "1000" : (link_100 ? "100" : "10")); #endif + if (gigabit != gm->gigabit) { + gm->gigabit = gigabit; + gmac_set_gigabit_mode(gm, gm->gigabit); + restart = 1; + } if (full_duplex != gm->full_duplex) { gm->full_duplex = full_duplex; gmac_set_duplex_mode(gm, gm->full_duplex); - gmac_start_dma(gm); + restart = 1; } + if (restart) + gmac_start_dma(gm); } else if (!(phy_status & MII_SR_LKS)) { #ifdef DEBUG_PHY printk(" Link down !\n"); @@ -218,19 +276,73 @@ } } -/* - * Lookup for a PHY on the mii interface and reset it - */ +static int +mii_do_reset_phy(struct gmac *gm, int phy_addr) +{ + int mii_control, timeout; + + mii_control = mii_read(gm, phy_addr, MII_CR); + mii_write(gm, phy_addr, MII_CR, mii_control | MII_CR_RST); + mdelay(10); + for (timeout = 100; timeout > 0; --timeout) { + mii_control = mii_read(gm, phy_addr, MII_CR); + if (mii_control == -1) { + printk(KERN_ERR "%s PHY died after reset !\n", + gm->dev->name); + return 1; + } + if ((mii_control & MII_CR_RST) == 0) + break; + mdelay(10); + } + if (mii_control & MII_CR_RST) { + printk(KERN_ERR "%s PHY reset timeout !\n", gm->dev->name); + return 1; + } + mii_write(gm, phy_addr, MII_CR, mii_control & ~MII_CR_ISOL); + return 0; +} + +static void +mii_init_BCM5400(struct gmac *gm) +{ + int data; + + data = mii_read(gm, gm->phy_addr, MII_BCM5400_AUXCONTROL); + data |= MII_BCM5400_AUXCONTROL_PWR10BASET; + mii_write(gm, gm->phy_addr, MII_BCM5400_AUXCONTROL, data); + + data = mii_read(gm, gm->phy_addr, MII_BCM5400_GB_CONTROL); + data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP; + mii_write(gm, gm->phy_addr, MII_BCM5400_GB_CONTROL, data); + + mdelay(10); + mii_do_reset_phy(gm, 0x1f); + + data = mii_read(gm, 0x1f, MII_BCM5201_MULTIPHY); + data |= MII_BCM5201_MULTIPHY_SERIALMODE; + mii_write(gm, 0x1f, MII_BCM5201_MULTIPHY, data); + + data = mii_read(gm, gm->phy_addr, MII_BCM5400_AUXCONTROL); + data &= ~MII_BCM5400_AUXCONTROL_PWR10BASET; + mii_write(gm, gm->phy_addr, MII_BCM5400_AUXCONTROL, data); +} + static int mii_lookup_and_reset(struct gmac *gm) { - int i, timeout; - int mii_status, mii_control; + int i, mii_status, mii_control; - /* Find the PHY */ gm->phy_addr = -1; gm->phy_type = PHY_UNKNOWN; + + /* Hard reset the PHY */ + feature_set_gmac_phy_reset(gm->of_node, KL_GPIO_ETH_PHY_RESET_ASSERT); + mdelay(10); + feature_set_gmac_phy_reset(gm->of_node, KL_GPIO_ETH_PHY_RESET_RELEASE); + mdelay(10); + /* Find the PHY */ for(i=31; i>0; --i) { mii_control = mii_read(gm, i, MII_CR); mii_status = mii_read(gm, i, MII_SR); @@ -243,25 +355,9 @@ return 0; /* Reset it */ - mii_write(gm, gm->phy_addr, MII_CR, mii_control | MII_CR_RST); - mdelay(10); - for (timeout = 100; timeout > 0; --timeout) { - mii_control = mii_read(gm, gm->phy_addr, MII_CR); - if (mii_control == -1) { - printk(KERN_ERR "%s PHY died after reset !\n", - gm->dev->name); - goto fail; - } - if ((mii_control & MII_CR_RST) == 0) - break; - mdelay(10); - } - if (mii_control & MII_CR_RST) { - printk(KERN_ERR "%s PHY reset timeout !\n", gm->dev->name); + if (mii_do_reset_phy(gm, gm->phy_addr)) goto fail; - } - mii_write(gm, gm->phy_addr, MII_CR, mii_control & ~MII_CR_ISOL); - + /* Read the PHY ID */ gm->phy_id = (mii_read(gm, gm->phy_addr, MII_ID0) << 16) | mii_read(gm, gm->phy_addr, MII_ID1); @@ -270,10 +366,15 @@ #endif if ((gm->phy_id & MII_BCM5400_MASK) == MII_BCM5400_ID) { gm->phy_type = PHY_B5400; - printk(KERN_ERR "%s Warning ! Unsupported BCM5400 PHY !\n", + printk(KERN_ERR "%s Found Broadcom BCM5400 PHY (Gigabit)\n", gm->dev->name); + mii_init_BCM5400(gm); } else if ((gm->phy_id & MII_BCM5201_MASK) == MII_BCM5201_ID) { gm->phy_type = PHY_B5201; + printk(KERN_INFO "%s Found Broadcom BCM5201 PHY\n", gm->dev->name); + } else if ((gm->phy_id & MII_LXT971_MASK) == MII_LXT971_ID) { + gm->phy_type = PHY_LXT971; + printk(KERN_INFO "%s Found LevelOne LX971 PHY\n", gm->dev->name); } else { printk(KERN_ERR "%s: Warning ! Unknown PHY ID 0x%08x !\n", gm->dev->name, gm->phy_id); @@ -405,6 +506,22 @@ } } +/* Set the MAC gigabit mode. Side effect: stops Tx MAC */ +static void +gmac_set_gigabit_mode(struct gmac *gm, int gigabit) +{ + /* Stop Tx MAC */ + GM_BIC(GM_MAC_TX_CONFIG, GM_MAC_TX_CONF_ENABLE); + while(GM_IN(GM_MAC_TX_CONFIG) & GM_MAC_TX_CONF_ENABLE) + ; + + if (gigabit) { + GM_BIS(GM_MAC_XIF_CONFIG, GM_MAC_XIF_CONF_GMII_MODE); + } else { + GM_BIC(GM_MAC_XIF_CONFIG, GM_MAC_XIF_CONF_GMII_MODE); + } +} + /* * Initialize a bunch of registers to put the chip into a known * and hopefully happy state @@ -788,6 +905,65 @@ return 0; } +#ifdef CONFIG_PMAC_PBOOK +int +gmac_sleep_notify(struct pmu_sleep_notifier *self, int when) +{ + struct gmac *gm; + int i; + + /* XXX should handle more than one */ + if (gmacs == NULL) + return PBOOK_SLEEP_OK; + + gm = (struct gmac *) gmacs->priv; + if (!gm->opened) + return PBOOK_SLEEP_OK; + + switch (when) { + case PBOOK_SLEEP_REQUEST: + break; + case PBOOK_SLEEP_REJECT: + break; + case PBOOK_SLEEP_NOW: + disable_irq(gm->dev->irq); + netif_stop_queue(gm->dev); + gmac_stop_dma(gm); + mii_poll_stop(gm); + gmac_set_power(gm, 0); + for (i = 0; i < NRX; ++i) { + if (gm->rx_buff[i] != 0) { + dev_kfree_skb(gm->rx_buff[i]); + gm->rx_buff[i] = 0; + } + } + for (i = 0; i < NTX; ++i) { + if (gm->tx_buff[i] != 0) { + dev_kfree_skb(gm->tx_buff[i]); + gm->tx_buff[i] = 0; + } + } + break; + case PBOOK_WAKE: + /* see if this is enough */ + gmac_powerup_and_reset(gm->dev); + gm->full_duplex = 0; + gm->phy_status = 0; + mii_lookup_and_reset(gm); + mii_setup_phy(gm); + gmac_init_rings(gm, 0); + gmac_mac_init(gm, gm->dev->dev_addr); + gmac_set_multicast(gm->dev); + mii_interrupt(gm); + gmac_start_dma(gm); + netif_start_queue(gm->dev); + enable_irq(gm->dev->irq); + break; + } + return PBOOK_SLEEP_OK; +} +#endif /* CONFIG_PMAC_PBOOK */ + /* * Handle a transmit timeout */ @@ -1196,7 +1372,8 @@ ioremap(gmac->addrs[0].address, 0x10000); dev->irq = gmac->intrs[0].line; gm->dev = dev; - + gm->of_node = gmac; + if (pci_device_loc(gmac, &gm->pci_bus, &gm->pci_devfn)) { gm->pci_bus = gm->pci_devfn = 0xff; printk(KERN_ERR "Can't locate GMAC PCI entry\n"); @@ -1229,6 +1406,10 @@ gm->next_gmac = gmacs; gmacs = dev; + +#ifdef CONFIG_PMAC_PBOOK + pmu_register_sleep_notifier(&gmac_sleep_notifier); +#endif } MODULE_AUTHOR("Paul Mackerras/Ben Herrenschmidt"); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/gmac.h linux/drivers/net/gmac.h --- v2.4.0-test8/linux/drivers/net/gmac.h Thu Jul 27 17:38:00 2000 +++ linux/drivers/net/gmac.h Sun Sep 17 09:48:05 2000 @@ -730,8 +730,9 @@ */ /* Supported PHYs (phy_type field ) */ -#define PHY_B5400 5400 -#define PHY_B5201 5201 +#define PHY_B5400 0x5400 +#define PHY_B5201 0x5201 +#define PHY_LXT971 0x0971 #define PHY_UNKNOWN 0 /* Identification (for multi-PHY) */ @@ -745,6 +746,11 @@ #define MII_BCM5400_REV 0x01 #define MII_BCM5400_ID ((MII_BCM5400_OUI << 10) | (MII_BCM5400_MODEL << 4)) #define MII_BCM5400_MASK 0xfffffff0 +#define MII_LXT971_OUI 0x0004de +#define MII_LXT971_MODEL 0x0e +#define MII_LXT971_REV 0x00 +#define MII_LXT971_ID ((MII_LXT971_OUI << 10) | (MII_LXT971_MODEL << 4)) +#define MII_LXT971_MASK 0xfffffff0 /* BCM5201 AUX STATUS register */ #define MII_BCM5201_AUXCTLSTATUS 0x18 @@ -764,6 +770,26 @@ #define MII_BCM5201_MULTIPHY_SERIALMODE 0x0002 #define MII_BCM5201_MULTIPHY_SUPERISOLATE 0x0008 +/* MII BCM5400 1000-BASET Control register */ +#define MII_BCM5400_GB_CONTROL 0x09 +#define MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP 0x0200 + +/* MII BCM5400 AUXCONTROL register */ +#define MII_BCM5400_AUXCONTROL 0x18 +#define MII_BCM5400_AUXCONTROL_PWR10BASET 0x0004 + +/* MII BCM5400 AUXSTATUS register */ +#define MII_BCM5400_AUXSTATUS 0x19 +#define MII_BCM5400_AUXSTATUS_LINKMODE_MASK 0x0700 +#define MII_BCM5400_AUXSTATUS_LINKMODE_SHIFT 8 + +/* MII LXT971 STATUS2 register */ +#define MII_LXT971_STATUS2 0x11 +#define MII_LXT971_STATUS2_SPEED 0x4000 +#define MII_LXT971_STATUS2_LINK 0x0400 +#define MII_LXT971_STATUS2_FULLDUPLEX 0x0200 +#define MII_LXT971_STATUS2_AUTONEG_COMPLETE 0x0080 + /* @@ -845,6 +871,7 @@ int phy_type; int phy_status; /* Cached PHY status */ int full_duplex; /* Current set to full duplex */ + int gigabit; /* Current set to 1000BT */ struct net_device_stats stats; u8 pci_bus; u8 pci_devfn; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/hamradio/pi2.c linux/drivers/net/hamradio/pi2.c --- v2.4.0-test8/linux/drivers/net/hamradio/pi2.c Fri Jun 23 21:55:09 2000 +++ linux/drivers/net/hamradio/pi2.c Fri Sep 8 17:56:49 2000 @@ -1182,7 +1182,7 @@ } -int __init pi_init(void) +int __init pi2_init(void) { int *port; int ioaddr = 0; @@ -1658,7 +1658,7 @@ int init_module(void) { - return pi_init(); + return pi2_init(); } void cleanup_module(void) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/hamradio/pt.c linux/drivers/net/hamradio/pt.c --- v2.4.0-test8/linux/drivers/net/hamradio/pt.c Fri Jun 23 21:55:09 2000 +++ linux/drivers/net/hamradio/pt.c Fri Sep 8 17:56:49 2000 @@ -474,7 +474,7 @@ } /* chipset_init() */ -int __init pt_init(void) +int __init ptwin_init(void) { int *port; int ioaddr = 0; @@ -531,7 +531,7 @@ pt0b.irq = pt0a.irq; /* IRQ is shared */ return 0; -} /* pt_init() */ +} /* ptwin_init() */ /* * Probe for PT card. Also initialises the timers @@ -1758,7 +1758,7 @@ int init_module(void) { - return pt_init(); + return ptwin_init(); } void cleanup_module(void) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/irda/toshoboe.c linux/drivers/net/irda/toshoboe.c --- v2.4.0-test8/linux/drivers/net/irda/toshoboe.c Mon Mar 27 08:08:26 2000 +++ linux/drivers/net/irda/toshoboe.c Sun Sep 17 09:45:07 2000 @@ -900,7 +900,6 @@ static void toshoboe_wakeup (struct toshoboe_cb *self) { - struct net_device *dev = self->netdev; unsigned long flags; if (!self->stopped) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/lne390.c linux/drivers/net/lne390.c --- v2.4.0-test8/linux/drivers/net/lne390.c Fri Jun 23 21:55:09 2000 +++ linux/drivers/net/lne390.c Sun Sep 17 09:49:42 2000 @@ -26,10 +26,13 @@ You can try if you want more info, as I've never even seen one of these cards. :) + Arnaldo Carvalho de Melo - 2000/09/01 + - get rid of check_region + - no need to check if dev == NULL in lne390_probe1 */ static const char *version = - "lne390.c: Driver revision v0.99, 12/05/98\n"; + "lne390.c: Driver revision v0.99.1, 01/09/2000\n"; #include #include @@ -103,9 +106,16 @@ int __init lne390_probe(struct net_device *dev) { unsigned short ioaddr = dev->base_addr; + int ret; - if (ioaddr > 0x1ff) /* Check a single specified location. */ - return lne390_probe1(dev, ioaddr); + if (ioaddr > 0x1ff) { /* Check a single specified location. */ + if (!request_region(ioaddr, LNE390_IO_EXTENT, "lne390")) + return -EBUSY; + ret = lne390_probe1(dev, ioaddr); + if (ret) + release_region(ioaddr, LNE390_IO_EXTENT); + return ret; + } else if (ioaddr > 0) /* Don't probe at all. */ return -ENXIO; @@ -118,10 +128,11 @@ /* EISA spec allows for up to 16 slots, but 8 is typical. */ for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000) { - if (check_region(ioaddr , LNE390_IO_EXTENT)) + if (!request_region(ioaddr, LNE390_IO_EXTENT, "lne390")) continue; if (lne390_probe1(dev, ioaddr) == 0) return 0; + release_region(ioaddr, LNE390_IO_EXTENT); } return -ENODEV; @@ -129,7 +140,7 @@ int __init lne390_probe1(struct net_device *dev, int ioaddr) { - int i, revision; + int i, revision, ret; unsigned long eisa_id; if (inb_p(ioaddr + LNE390_ID_PORT) == 0xff) return -ENODEV; @@ -161,13 +172,6 @@ return -ENODEV; } #endif - - /* We should have a "dev" from Space.c or the static module table. */ - if (dev == NULL) { - printk("lne390.c: Passed a NULL device.\n"); - dev = init_etherdev(0, 0); - } - /* Allocate dev->priv and fill in 8390 specific dev fields. */ if (ethdev_init(dev)) { printk ("lne390.c: unable to allocate memory for dev->priv!\n"); @@ -225,20 +229,16 @@ printk(KERN_CRIT "lne390.c: Use EISA SCU to set card memory below 1MB,\n"); printk(KERN_CRIT "lne390.c: or to an address above 0x%lx.\n", virt_to_bus(high_memory)); printk(KERN_CRIT "lne390.c: Driver NOT installed.\n"); - free_irq(dev->irq, dev); - kfree(dev->priv); - dev->priv = NULL; - return -EINVAL; + ret = -EINVAL; + goto cleanup; } dev->mem_start = (unsigned long)ioremap(dev->mem_start, LNE390_STOP_PG*0x100); if (dev->mem_start == 0) { printk(KERN_ERR "lne390.c: Unable to remap card memory above 1MB !!\n"); printk(KERN_ERR "lne390.c: Try using EISA SCU to set memory below 1MB.\n"); printk(KERN_ERR "lne390.c: Driver NOT installed.\n"); - free_irq(dev->irq, dev); - kfree(dev->priv); - dev->priv = NULL; - return -EAGAIN; + ret = -EAGAIN; + goto cleanup; } ei_status.reg0 = 1; /* Use as remap flag */ printk("lne390.c: remapped %dkB card memory to virtual address %#lx\n", @@ -251,7 +251,6 @@ /* The 8390 offset is zero for the LNE390 */ dev->base_addr = ioaddr; - request_region(dev->base_addr, LNE390_IO_EXTENT, "lne390"); ei_status.name = "LNE390"; ei_status.tx_start_page = LNE390_START_PG; @@ -271,6 +270,11 @@ dev->stop = &lne390_close; NS8390_init(dev, 0); return 0; +cleanup: + free_irq(dev->irq, dev); + kfree(dev->priv); + dev->priv = NULL; + return ret; } /* diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/net_init.c linux/drivers/net/net_init.c --- v2.4.0-test8/linux/drivers/net/net_init.c Thu Jul 27 17:38:00 2000 +++ linux/drivers/net/net_init.c Sun Sep 17 09:41:29 2000 @@ -198,7 +198,7 @@ return(0); } -#endif +#endif /* CONFIG_FDDI */ #ifdef CONFIG_HIPPI @@ -256,7 +256,7 @@ return 0; } -#endif +#endif /* CONFIG_HIPPI */ void ether_setup(struct net_device *dev) { @@ -314,7 +314,7 @@ return; } -#endif +#endif /* CONFIG_FDDI */ #ifdef CONFIG_HIPPI void hippi_setup(struct net_device *dev) @@ -350,7 +350,7 @@ dev_init_buffers(dev); } -#endif +#endif /* CONFIG_HIPPI */ #if defined(CONFIG_ATALK) || defined(CONFIG_ATALK_MODULE) @@ -389,7 +389,7 @@ dev_init_buffers(dev); } -#endif +#endif /* CONFIG_ATALK || CONFIG_ATALK_MODULE */ int ether_config(struct net_device *dev, struct ifmap *map) { @@ -506,7 +506,7 @@ unregister_netdevice(dev); rtnl_unlock(); } -#endif +#endif /* CONFIG_TR */ #ifdef CONFIG_NET_FC @@ -555,10 +555,3 @@ #endif /* CONFIG_NET_FC */ -/* - * Local variables: - * compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c net_init.c" - * version-control: t - * kept-new-versions: 5 - * End: - */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/pcmcia/xircom_tulip_cb.c linux/drivers/net/pcmcia/xircom_tulip_cb.c --- v2.4.0-test8/linux/drivers/net/pcmcia/xircom_tulip_cb.c Wed Aug 23 18:36:38 2000 +++ linux/drivers/net/pcmcia/xircom_tulip_cb.c Sun Sep 17 09:41:29 2000 @@ -3034,10 +3034,7 @@ if (entry == TX_RING_SIZE-1) tx_flags |= DESC_RING_WRAP; /* Wrap ring. */ tp->tx_ring[entry].length = tx_flags; - if(tp->chip_id == X3201_3) - tp->tx_ring[entry].buffer1 = (virt_to_bus(tp->setup_frame) + 4); - else - tp->tx_ring[entry].buffer1 = virt_to_bus(tp->setup_frame); + tp->tx_ring[entry].buffer1 = virt_to_bus(tp->setup_frame); tp->tx_ring[entry].status = DescOwned; if (tp->cur_tx - tp->dirty_tx >= TX_RING_SIZE - 2) { tp->tx_full = 1; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/pppox.c linux/drivers/net/pppox.c --- v2.4.0-test8/linux/drivers/net/pppox.c Fri May 12 14:18:55 2000 +++ linux/drivers/net/pppox.c Sun Sep 17 09:41:29 2000 @@ -141,6 +141,8 @@ pppox_create }; +extern int pppoe_init (void); + #ifdef MODULE int init_module(void) #else @@ -154,9 +156,7 @@ if (err == 0) printk(KERN_INFO "Registered PPPoX v0.5\n"); -#ifdef CONFIG_PPPOE pppoe_init(); -#endif return err; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/rtl8129.c linux/drivers/net/rtl8129.c --- v2.4.0-test8/linux/drivers/net/rtl8129.c Fri Jul 14 12:12:11 2000 +++ linux/drivers/net/rtl8129.c Sun Sep 17 09:41:29 2000 @@ -406,6 +406,8 @@ printk(KERN_INFO "%s", version); dev = init_etherdev(NULL, 0); + if (dev == NULL) + goto out; printk(KERN_INFO "%s: %s at %#lx, IRQ %d, ", dev->name, pci_tbl[chip_idx].name, ioaddr, irq); @@ -427,13 +429,17 @@ printk("%2.2x.\n", dev->dev_addr[i]); /* We do a request_region() to register /proc/ioports info. */ - request_region(ioaddr, pci_tbl[chip_idx].io_size, dev->name); + if (!request_region(ioaddr, pci_tbl[chip_idx].io_size, dev->name)) + goto out_free_dev; dev->base_addr = ioaddr; dev->irq = irq; /* Some data structures must be quadword aligned. */ tp = kmalloc(sizeof(*tp), GFP_KERNEL | GFP_DMA); + if (tp == NULL) + goto out_release_region; + memset(tp, 0, sizeof(*tp)); dev->priv = tp; @@ -499,8 +505,15 @@ dev->get_stats = &rtl8129_get_stats; dev->set_multicast_list = &set_rx_mode; dev->do_ioctl = &mii_ioctl; - return dev; + +out_release_region: + release_region(ioaddr, pci_tbl[chip_idx].io_size); +out_free_dev: + unregister_netdev(dev); + kfree(dev); +out: + return NULL; } /* Serial EEPROM section. */ @@ -660,17 +673,18 @@ { struct rtl8129_private *tp = (struct rtl8129_private *)dev->priv; long ioaddr = dev->base_addr; - int i; + int i, retval; + + MOD_INC_USE_COUNT; /* Soft reset the chip. */ outb(CmdReset, ioaddr + ChipCmd); - if (request_irq(dev->irq, &rtl8129_interrupt, SA_SHIRQ, dev->name, dev)) { - return -EAGAIN; + if ((retval = request_irq(dev->irq, &rtl8129_interrupt, SA_SHIRQ, dev->name, dev))) { + MOD_DEC_USE_COUNT; + return retval; } - MOD_INC_USE_COUNT; - tp->tx_bufs = pci_alloc_consistent(tp->pdev, TX_BUF_SIZE * NUM_TX_DESC, &tp->tx_bufs_dma); @@ -690,6 +704,7 @@ if (rtl8129_debug > 0) printk(KERN_ERR "%s: Couldn't allocate a %d byte receive ring.\n", dev->name, RX_BUF_LEN); + MOD_DEC_USE_COUNT; return -ENOMEM; } rtl8129_init_ring(dev); @@ -1226,8 +1241,9 @@ /* Malloc up new buffer, compatible with net-2e. */ /* Omit the four octet CRC from the length. */ struct sk_buff *skb; + int pkt_size = rx_size - 4; - skb = dev_alloc_skb(rx_size + 2); + skb = dev_alloc_skb(pkt_size + 2); if (skb == NULL) { printk(KERN_WARNING"%s: Memory squeeze, deferring packet.\n", dev->name); @@ -1238,12 +1254,12 @@ } skb->dev = dev; skb_reserve(skb, 2); /* 16 byte align the IP fields. */ - if (ring_offset+rx_size+4 > RX_BUF_LEN) { + if (ring_offset+rx_size > RX_BUF_LEN) { int semi_count = RX_BUF_LEN - ring_offset - 4; memcpy(skb_put(skb, semi_count), &rx_ring[ring_offset + 4], semi_count); - memcpy(skb_put(skb, rx_size-semi_count), rx_ring, - rx_size-semi_count); + memcpy(skb_put(skb, pkt_size-semi_count), rx_ring, + pkt_size-semi_count); if (rtl8129_debug > 4) { int i; printk(KERN_DEBUG"%s: Frame wrap @%d", @@ -1256,17 +1272,17 @@ } else { #if 1 /* USE_IP_COPYSUM */ eth_copy_and_sum(skb, &rx_ring[ring_offset + 4], - rx_size, 0); - skb_put(skb, rx_size); + pkt_size, 0); + skb_put(skb, pkt_size); #else - memcpy(skb_put(skb, rx_size), &rx_ring[ring_offset + 4], - rx_size); + memcpy(skb_put(skb, pkt_size), &rx_ring[ring_offset + 4], + pkt_size); #endif } skb->protocol = eth_type_trans(skb, dev); netif_rx(skb); #if LINUX_VERSION_CODE > 0x20119 - tp->stats.rx_bytes += rx_size; + tp->stats.rx_bytes += pkt_size; #endif tp->stats.rx_packets++; } @@ -1292,6 +1308,8 @@ netif_stop_queue(dev); + del_timer_sync(&tp->timer); + if (rtl8129_debug > 1) printk(KERN_DEBUG"%s: Shutting down ethercard, status was 0x%4.4x.\n", dev->name, inw(ioaddr + IntrStatus)); @@ -1305,8 +1323,6 @@ /* Update the error counts. */ tp->stats.rx_missed_errors += inl(ioaddr + RxMissed); outl(0, ioaddr + RxMissed); - - del_timer(&tp->timer); free_irq(dev->irq, dev); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/setup.c linux/drivers/net/setup.c --- v2.4.0-test8/linux/drivers/net/setup.c Tue May 23 15:31:35 2000 +++ linux/drivers/net/setup.c Sun Sep 17 09:48:04 2000 @@ -22,6 +22,7 @@ extern int awc4500_365_probe(void); extern int arcnet_init(void); extern int scc_enet_init(void); +extern int fec_enet_init(void); extern int dlci_setup(void); extern int lapbeth_init(void); extern int sdla_setup(void); @@ -74,6 +75,9 @@ #endif #if defined(CONFIG_SCC_ENET) {scc_enet_init, 0}, +#endif +#if defined(CONFIG_FEC_ENET) + {fec_enet_init, 0}, #endif #if defined(CONFIG_COMX) {comx_init, 0}, diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/lm80.h linux/drivers/net/sk98lin/h/lm80.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/lm80.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/lm80.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: lm80.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.2 $ - * Date: $Date: 1999/03/12 13:26:51 $ + * Version: $Revision: 1.3 $ + * Date: $Date: 1999/11/22 13:41:19 $ * Purpose: Contains all defines for the LM80 Chip * (National Semiconductor). * @@ -27,6 +27,9 @@ * * History: * $Log: lm80.h,v $ + * Revision 1.3 1999/11/22 13:41:19 cgoos + * Changed license header to GPL. + * * Revision 1.2 1999/03/12 13:26:51 malthoff * remove __STDC__. * diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skaddr.h linux/drivers/net/sk98lin/h/skaddr.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skaddr.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skaddr.h Fri Sep 15 14:34:19 2000 @@ -2,15 +2,15 @@ * * Name: skaddr.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.19 $ - * Date: $Date: 1999/05/28 10:56:07 $ - * Purpose: Header file for Address Management (MC, UC, Prom) + * Version: $Revision: 1.23 $ + * Date: $Date: 2000/08/10 11:27:50 $ + * Purpose: Header file for Address Management (MC, UC, Prom). * ******************************************************************************/ /****************************************************************************** * - * (C)Copyright 1998,1999 SysKonnect, + * (C)Copyright 1998-2000 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * * This program is free software; you can redistribute it and/or modify @@ -27,6 +27,21 @@ * History: * * $Log: skaddr.h,v $ + * Revision 1.23 2000/08/10 11:27:50 rassmann + * Editorial changes. + * Preserving 32-bit alignment in structs for the adapter context. + * + * Revision 1.22 2000/08/07 11:10:40 rassmann + * Editorial changes. + * + * Revision 1.21 2000/05/04 09:39:59 rassmann + * Editorial changes. + * Corrected multicast address hashing. + * + * Revision 1.20 1999/11/22 13:46:14 cgoos + * Changed license header to GPL. + * Allowing overwrite for SK_ADDR_EQUAL. + * * Revision 1.19 1999/05/28 10:56:07 rassmann * Editorial changes. * @@ -115,32 +130,33 @@ #define __INC_SKADDR_H #ifdef __cplusplus -xxxx /* not supported yet - force error */ +#error C++ is not yet supported. extern "C" { #endif /* cplusplus */ /* defines ********************************************************************/ -#define SK_MAC_ADDR_LEN 6 /* Length of MAC address. */ -#define SK_MAX_ADDRS 14 /* #Addrs for exact match. */ +#define SK_MAC_ADDR_LEN 6 /* Length of MAC address. */ +#define SK_MAX_ADDRS 14 /* #Addrs for exact match. */ /* ----- Common return values ----- */ -#define SK_ADDR_SUCCESS 0 /* Function returned successfully. */ -#define SK_ADDR_ILLEGAL_PORT 100 /* Port number too high. */ -#define SK_ADDR_TOO_EARLY 101 /* Function called too early. */ +#define SK_ADDR_SUCCESS 0 /* Function returned successfully. */ +#define SK_ADDR_ILLEGAL_PORT 100 /* Port number too high. */ +#define SK_ADDR_TOO_EARLY 101 /* Function called too early. */ /* ----- Clear/Add flag bits ----- */ -#define SK_ADDR_PERMANENT 1 /* RLMT Address */ +#define SK_ADDR_PERMANENT 1 /* RLMT Address */ /* ----- Additional Clear flag bits ----- */ -#define SK_MC_SW_ONLY 2 /* Do not update HW when clearing. */ +#define SK_MC_SW_ONLY 2 /* Do not update HW when clearing. */ /* ----- Override flag bits ----- */ -#define SK_ADDR_VIRTUAL_ADDRESS 0 +#define SK_ADDR_LOGICAL_ADDRESS 0 +#define SK_ADDR_VIRTUAL_ADDRESS (SK_ADDR_LOGICAL_ADDRESS) /* old */ #define SK_ADDR_PHYSICAL_ADDRESS 1 /* ----- Override return values ----- */ @@ -151,7 +167,7 @@ /* ----- Partitioning of excact match table ----- */ -#define SK_ADDR_EXACT_MATCHES 16 /* #Exact match entries. */ +#define SK_ADDR_EXACT_MATCHES 16 /* #Exact match entries. */ #define SK_ADDR_FIRST_MATCH_RLMT 1 #define SK_ADDR_LAST_MATCH_RLMT 2 @@ -160,21 +176,21 @@ /* ----- SkAddrMcAdd/SkAddrMcUpdate return values ----- */ -#define SK_MC_FILTERING_EXACT 0 /* Exact filtering. */ -#define SK_MC_FILTERING_INEXACT 1 /* Inexact filtering. */ +#define SK_MC_FILTERING_EXACT 0 /* Exact filtering. */ +#define SK_MC_FILTERING_INEXACT 1 /* Inexact filtering. */ /* ----- Additional SkAddrMcAdd return values ----- */ -#define SK_MC_ILLEGAL_ADDRESS 2 /* Illegal address. */ -#define SK_MC_ILLEGAL_PORT 3 /* Illegal port (not the active one). */ -#define SK_MC_RLMT_OVERFLOW 4 /* Too many RLMT mc addresses. */ +#define SK_MC_ILLEGAL_ADDRESS 2 /* Illegal address. */ +#define SK_MC_ILLEGAL_PORT 3 /* Illegal port (not the active one). */ +#define SK_MC_RLMT_OVERFLOW 4 /* Too many RLMT mc addresses. */ /* Promiscuous mode bits ----- */ -#define SK_PROM_MODE_NONE 0 /* Normal receive. */ -#define SK_PROM_MODE_LLC 1 /* Receive all LLC frames. */ -#define SK_PROM_MODE_ALL_MC 2 /* Receive all multicast frames. */ -/* #define SK_PROM_MODE_NON_LLC 4 */ /* Receive all non-LLC frames. */ +#define SK_PROM_MODE_NONE 0 /* Normal receive. */ +#define SK_PROM_MODE_LLC 1 /* Receive all LLC frames. */ +#define SK_PROM_MODE_ALL_MC 2 /* Receive all multicast frames. */ +/* #define SK_PROM_MODE_NON_LLC 4 */ /* Receive all non-LLC frames. */ /* Macros */ @@ -192,7 +208,7 @@ *(SK_U32 *)&(((SK_U8 *)(A1))[2]) == *(SK_U32 *)&(((SK_U8 *)(A2))[2]) && \ *(SK_U32 *)&(((SK_U8 *)(A1))[0]) == *(SK_U32 *)&(((SK_U8 *)(A2))[0])) #endif /* SK_ADDR_DWORD_COMPARE */ -#endif /* SK_ADDR_EQUAL */ +#endif /* SK_ADDR_EQUAL */ /* typedefs *******************************************************************/ @@ -203,27 +219,28 @@ /* SK_FILTER is used to ensure alignment of the filter. */ typedef union s_InexactFilter { SK_U8 Bytes[8]; - SK_U64 Val; /* Dummy entry for alignment only. */ + SK_U64 Val; /* Dummy entry for alignment only. */ } SK_FILTER64; typedef struct s_AddrPort { /* ----- Public part (read-only) ----- */ - SK_MAC_ADDR PermanentMacAddress; /* Physical MAC Address. */ - SK_MAC_ADDR CurrentMacAddress; /* Physical MAC Address. */ - int PromMode; /* Promiscuous Mode. */ + SK_MAC_ADDR CurrentMacAddress; /* Current physical MAC Address. */ + SK_MAC_ADDR PermanentMacAddress; /* Permanent physical MAC Address. */ + int PromMode; /* Promiscuous Mode. */ /* ----- Private part ----- */ + SK_MAC_ADDR PreviousMacAddress; /* Prev. phys. MAC Address. */ SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */ - SK_MAC_ADDR PreviousMacAddress; /* Prev. phys. MAC Address. */ + SK_U8 Align01; SK_U32 FirstExactMatchRlmt; SK_U32 NextExactMatchRlmt; SK_U32 FirstExactMatchDrv; SK_U32 NextExactMatchDrv; SK_MAC_ADDR Exact[SK_ADDR_EXACT_MATCHES]; - SK_FILTER64 InexactFilter; /* For 64-bit hash register. */ + SK_FILTER64 InexactFilter; /* For 64-bit hash register. */ } SK_ADDR_PORT; typedef struct s_Addr { @@ -232,22 +249,21 @@ SK_ADDR_PORT Port[SK_MAX_MACS]; SK_MAC_ADDR PermanentMacAddress; /* Logical MAC Address. */ - SK_MAC_ADDR CurrentMacAddress; /* Logical MAC Address. */ + SK_MAC_ADDR CurrentMacAddress; /* Logical MAC Address. */ /* ----- Private part ----- */ -#if 0 - SK_BOOL Initialized; /* Flag: Addr module is initialized. */ -#endif /* 0 */ + SK_U32 ActivePort; /* View of module ADDR. */ SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */ - SK_U32 ActivePort; /* Vie of module ADDR. */ + SK_U8 Align01; + SK_U16 Align02; } SK_ADDR; /* function prototypes ********************************************************/ #ifndef SK_KR_PROTO -/* Functions provided by SkRlmt */ +/* Functions provided by SkAddr */ /* ANSI/C++ compliant function prototypes */ @@ -297,7 +313,7 @@ /* Non-ANSI/C++ compliant function prototypes */ -xxxx /* not supported yet - force error */ +#error KR-style prototypes are not yet provided. #endif /* defined(SK_KR_PROTO)) */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skcsum.h linux/drivers/net/sk98lin/h/skcsum.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skcsum.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skcsum.h Fri Sep 15 14:34:19 2000 @@ -1,9 +1,9 @@ /****************************************************************************** * * Name: skcsum.h - * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.2 $ - * Date: $Date: 1998/09/04 12:16:34 $ + * Project: GEnesis - SysKonnect SK-NET Gigabit Ethernet (SK-98xx) + * Version: $Revision: 1.7 $ + * Date: $Date: 2000/06/29 13:17:05 $ * Purpose: Store/verify Internet checksum in send/receive packets. * ******************************************************************************/ @@ -27,6 +27,25 @@ * History: * * $Log: skcsum.h,v $ + * Revision 1.7 2000/06/29 13:17:05 rassmann + * Corrected reception of a packet with UDP checksum == 0 (which means there + * is no UDP checksum). + * + * Revision 1.6 2000/02/28 12:33:44 cgoos + * Changed C++ style comments to C style. + * + * Revision 1.5 2000/02/21 12:10:05 cgoos + * Fixed license comment. + * + * Revision 1.4 2000/02/21 11:08:37 cgoos + * Merged changes back into common source. + * + * Revision 1.1 1999/07/26 14:47:49 mkarl + * changed from common source to windows specific source + * added return SKCS_STATUS_IP_CSUM_ERROR_UDP and + * SKCS_STATUS_IP_CSUM_ERROR_TCP to pass the NidsTester + * changes for Tx csum offload + * * Revision 1.2 1998/09/04 12:16:34 mhaveman * Checked in for Stephan to allow compilation. * -Added definition SK_CSUM_EVENT_CLEAR_PROTO_STATS to clear statistic @@ -98,24 +117,32 @@ * * SKCS_STATUS_UNKNOWN_IP_VERSION - Not an IP v4 frame. * SKCS_STATUS_IP_CSUM_ERROR - IP checksum error. + * SKCS_STATUS_IP_CSUM_ERROR_TCP - IP checksum error in TCP frame. + * SKCS_STATUS_IP_CSUM_ERROR_UDP - IP checksum error in UDP frame * SKCS_STATUS_IP_FRAGMENT - IP fragment (IP checksum ok). * SKCS_STATUS_IP_CSUM_OK - IP checksum ok (not a TCP or UDP frame). * SKCS_STATUS_TCP_CSUM_ERROR - TCP checksum error (IP checksum ok). * SKCS_STATUS_UDP_CSUM_ERROR - UDP checksum error (IP checksum ok). * SKCS_STATUS_TCP_CSUM_OK - IP and TCP checksum ok. * SKCS_STATUS_UDP_CSUM_OK - IP and UDP checksum ok. + * SKCS_STATUS_IP_CSUM_OK_NO_UDP - IP checksum OK and no UDP checksum. */ #ifndef SKCS_OVERWRITE_STATUS /* User overwrite? */ #define SKCS_STATUS int /* Define status type. */ #define SKCS_STATUS_UNKNOWN_IP_VERSION 1 -#define SKCS_STATUS_IP_CSUM_ERROR 2 -#define SKCS_STATUS_IP_FRAGMENT 3 -#define SKCS_STATUS_IP_CSUM_OK 4 -#define SKCS_STATUS_TCP_CSUM_ERROR 5 -#define SKCS_STATUS_UDP_CSUM_ERROR 6 -#define SKCS_STATUS_TCP_CSUM_OK 7 -#define SKCS_STATUS_UDP_CSUM_OK 8 +#define SKCS_STATUS_IP_CSUM_ERROR 2 +#define SKCS_STATUS_IP_FRAGMENT 3 +#define SKCS_STATUS_IP_CSUM_OK 4 +#define SKCS_STATUS_TCP_CSUM_ERROR 5 +#define SKCS_STATUS_UDP_CSUM_ERROR 6 +#define SKCS_STATUS_TCP_CSUM_OK 7 +#define SKCS_STATUS_UDP_CSUM_OK 8 +/* needed for Microsoft */ +#define SKCS_STATUS_IP_CSUM_ERROR_UDP 9 +#define SKCS_STATUS_IP_CSUM_ERROR_TCP 10 +/* UDP checksum may be omitted */ +#define SKCS_STATUS_IP_CSUM_OK_NO_UDP 11 #endif /* !SKCS_OVERWRITE_STATUS */ /* Clear protocol statistics event. */ @@ -158,7 +185,7 @@ SK_U64 RxUnableCts; /* Unable to verify receive checksum. */ SK_U64 RxErrCts; /* Receive checksum error. */ SK_U64 TxOkCts; /* Transmit checksum ok. */ - SK_U64 TxUnableCts; /* Unable to verify transmit checksum. */ + SK_U64 TxUnableCts; /* Unable to calculate checksum in hw. */ } SKCS_PROTO_STATS; /* @@ -167,6 +194,9 @@ typedef struct s_Csum { /* Enabled receive SK_PROTO_XXX bit flags. */ unsigned ReceiveFlags; +#ifdef TX_CSUM + unsigned TransmitFlags; +#endif /* TX_CSUM */ /* The protocol statistics structure; one per supported protocol. */ SKCS_PROTO_STATS ProtoStats[SKCS_NUM_PROTOCOLS]; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skdebug.h linux/drivers/net/sk98lin/h/skdebug.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skdebug.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skdebug.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skdebug.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.9 $ - * Date: $Date: 1999/09/14 14:02:43 $ + * Version: $Revision: 1.10 $ + * Date: $Date: 1999/11/22 13:47:40 $ * Purpose: SK specific DEBUG support * ******************************************************************************/ @@ -26,6 +26,9 @@ * * History: * $Log: skdebug.h,v $ + * Revision 1.10 1999/11/22 13:47:40 cgoos + * Changed license header to GPL. + * * Revision 1.9 1999/09/14 14:02:43 rwahl * Added SK_DBGMOD_PECP. * diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skdrv1st.h linux/drivers/net/sk98lin/h/skdrv1st.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skdrv1st.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skdrv1st.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skdrv1st.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.6 $ - * Date: $Date: 1999/07/27 08:03:33 $ + * Version: $Revision: 1.8 $ + * Date: $Date: 2000/02/21 12:19:18 $ * Purpose: First header file for driver and all other modules * ******************************************************************************/ @@ -27,6 +27,15 @@ * History: * * $Log: skdrv1st.h,v $ + * Revision 1.8 2000/02/21 12:19:18 cgoos + * Added default for SK_DEBUG_CHKMOD/_CHKCAT + * + * Revision 1.7 1999/11/22 13:50:00 cgoos + * Changed license header to GPL. + * Added overwrite for several functions. + * Removed linux 2.0.x definitions. + * Removed PCI vendor ID definition (now in kernel). + * * Revision 1.6 1999/07/27 08:03:33 cgoos * Changed SK_IN/OUT macros to readX/writeX instead of memory * accesses (necessary for ALPHA). @@ -175,6 +184,12 @@ #ifdef DEBUG #define SK_DBG_PRINTF printk +#ifndef SK_DEBUG_CHKMOD +#define SK_DEBUG_CHKMOD 0 +#endif +#ifndef SK_DEBUG_CHKCAT +#define SK_DEBUG_CHKCAT 0 +#endif /* those come from the makefile */ #define SK_DBG_CHKMOD(pAC) (SK_DEBUG_CHKMOD) #define SK_DBG_CHKCAT(pAC) (SK_DEBUG_CHKCAT) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skerror.h linux/drivers/net/sk98lin/h/skerror.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skerror.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skerror.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skerror.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.3 $ - * Date: $Date: 1999/09/14 14:04:42 $ + * Version: $Revision: 1.4 $ + * Date: $Date: 1999/11/22 13:51:59 $ * Purpose: SK specific Error log support * ******************************************************************************/ @@ -26,6 +26,9 @@ * * History: * $Log: skerror.h,v $ + * Revision 1.4 1999/11/22 13:51:59 cgoos + * Changed license header to GPL. + * * Revision 1.3 1999/09/14 14:04:42 rwahl * Added error base SK_ERRBASE_PECP. * Changed error base for driver. diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skgedrv.h linux/drivers/net/sk98lin/h/skgedrv.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skgedrv.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skgedrv.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skgedrv.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.3 $ - * Date: $Date: 1998/12/01 13:31:39 $ + * Version: $Revision: 1.4 $ + * Date: $Date: 1999/11/22 13:52:46 $ * Purpose: Interface with the driver * ******************************************************************************/ @@ -27,6 +27,9 @@ * History: * * $Log: skgedrv.h,v $ + * Revision 1.4 1999/11/22 13:52:46 cgoos + * Changed license header to GPL. + * * Revision 1.3 1998/12/01 13:31:39 cgoos * SWITCH INTERN Event added. * diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skgehw.h linux/drivers/net/sk98lin/h/skgehw.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skgehw.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skgehw.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skgehw.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.33 $ - * Date: $Date: 1999/08/27 11:17:10 $ + * Version: $Revision: 1.35 $ + * Date: $Date: 2000/05/19 10:17:13 $ * Purpose: Defines and Macros for the Gigabit Ethernet Adapter Product * Family * @@ -27,6 +27,12 @@ * * History: * $Log: skgehw.h,v $ + * Revision 1.35 2000/05/19 10:17:13 cgoos + * Added inactivity check in PHY_READ (in DEBUG mode only). + * + * Revision 1.34 1999/11/22 13:53:40 cgoos + * Changed license header to GPL. + * * Revision 1.33 1999/08/27 11:17:10 malthoff * It's more savely to put bracket around marco parameters. * Brackets added for PHY_READ and PHY_WRITE. @@ -1627,19 +1633,44 @@ * written. * * usage: PHY_READ(IoC, pPort, MAC_1, PHY_CTRL, Value); + * Warning: a PHY_READ on an uninitialized PHY (PHY still in reset) never + * comes back. This is checked in DEBUG mode. */ +#ifndef DEBUG +#define PHY_READ(IoC, pPort, Mac, PhyReg, pVal) { \ + SK_U16 Mmu; \ + \ + XM_OUT16((IoC),(Mac), XM_PHY_ADDR, (PhyReg)|(pPort)->PhyAddr); \ + XM_IN16((IoC), (Mac), XM_PHY_DATA, (pVal)); \ + if ((pPort)->PhyType != SK_PHY_XMAC) { \ + do { \ + XM_IN16((IoC), (Mac), XM_MMU_CMD, &Mmu); \ + } while ((Mmu & XM_MMU_PHY_RDY) == 0); \ + XM_IN16((IoC), (Mac), XM_PHY_DATA, (pVal)); \ + } \ +} +#else #define PHY_READ(IoC, pPort, Mac, PhyReg, pVal) { \ SK_U16 Mmu; \ + int __i = 0; \ \ XM_OUT16((IoC),(Mac), XM_PHY_ADDR, (PhyReg)|(pPort)->PhyAddr); \ XM_IN16((IoC), (Mac), XM_PHY_DATA, (pVal)); \ if ((pPort)->PhyType != SK_PHY_XMAC) { \ do { \ XM_IN16((IoC), (Mac), XM_MMU_CMD, &Mmu); \ + __i++; \ + if (__i > 10000) { \ + SK_DBG_PRINTF("*****************************\n"); \ + SK_DBG_PRINTF("PHY_READ on uninitialized PHY\n"); \ + SK_DBG_PRINTF("*****************************\n"); \ + break; \ + } \ } while ((Mmu & XM_MMU_PHY_RDY) == 0); \ XM_IN16((IoC), (Mac), XM_PHY_DATA, (pVal)); \ } \ } +#endif #define PHY_WRITE(IoC, pPort, Mac, PhyReg, Val) { \ SK_U16 Mmu; \ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skgehwt.h linux/drivers/net/sk98lin/h/skgehwt.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skgehwt.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skgehwt.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skhwt.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.4 $ - * Date: $Date: 1998/08/19 09:50:58 $ + * Version: $Revision: 1.5 $ + * Date: $Date: 1999/11/22 13:54:24 $ * Purpose: Defines for the hardware timer functions * ******************************************************************************/ @@ -27,6 +27,9 @@ * History: * * $Log: skgehwt.h,v $ + * Revision 1.5 1999/11/22 13:54:24 cgoos + * Changed license header to GPL. + * * Revision 1.4 1998/08/19 09:50:58 gklug * fix: remove struct keyword from c-code (see CCC) add typedefs * diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skgei2c.h linux/drivers/net/sk98lin/h/skgei2c.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skgei2c.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skgei2c.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skgei2c.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.16 $ - * Date: $Date: 1999/11/12 08:24:10 $ + * Version: $Revision: 1.17 $ + * Date: $Date: 1999/11/22 13:55:25 $ * Purpose: Special genesis defines for I2C * (taken from Monalisa (taken from Concentrator)) * @@ -28,6 +28,9 @@ * History: * * $Log: skgei2c.h,v $ + * Revision 1.17 1999/11/22 13:55:25 cgoos + * Changed license header to GPL. + * * Revision 1.16 1999/11/12 08:24:10 malthoff * Change voltage warning and error limits * (warning +-5%, error +-10%). diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skgeinit.h linux/drivers/net/sk98lin/h/skgeinit.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skgeinit.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skgeinit.h Fri Sep 15 14:34:19 2000 @@ -2,15 +2,15 @@ * * Name: skgeinit.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.44 $ - * Date: $Date: 1999/10/26 07:34:15 $ + * Version: $Revision: 1.46 $ + * Date: $Date: 2000/08/10 11:28:00 $ * Purpose: Structures and prototypes for the GE Init Module * ******************************************************************************/ /****************************************************************************** * - * (C)Copyright 1998,1999 SysKonnect, + * (C)Copyright 1998-2000 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * * This program is free software; you can redistribute it and/or modify @@ -27,6 +27,13 @@ * History: * * $Log: skgeinit.h,v $ + * Revision 1.46 2000/08/10 11:28:00 rassmann + * Editorial changes. + * Preserving 32-bit alignment in structs for the adapter context. + * + * Revision 1.45 1999/11/22 13:56:19 cgoos + * Changed license header to GPL. + * * Revision 1.44 1999/10/26 07:34:15 malthoff * The define SK_LNK_ON has been lost in v1.41. * @@ -443,61 +450,63 @@ SK_TIMER PWaTimer; /* Workaround Timer */ #endif SK_U64 PPrevShorts; /* Previous short Counter checking */ - SK_U64 PPrevRx; /* Previous RxOk Counter checking */ - SK_U64 PPrevFcs; /* Previous FCS Error Counter checking */ - SK_U64 PRxLim; /* Previous RxOk Counter checking */ - int PLinkResCt; /* Link Restart Counter */ - int PAutoNegTimeOut;/* AutoNegotiation timeout current value */ - int PRxQSize; /* Port Rx Queue Size in kB */ - int PXSQSize; /* Port Synchronous Transmit Queue Size in kB */ - int PXAQSize; /* Port Asynchronous Transmit Queue Size in kB*/ + SK_U64 PPrevRx; /* Previous RxOk Counter checking */ + SK_U64 PPrevFcs; /* Previous FCS Error Counter checking */ + SK_U64 PRxLim; /* Previous RxOk Counter checking */ + int PLinkResCt; /* Link Restart Counter */ + int PAutoNegTimeOut;/* AutoNegotiation timeout current value */ + int PRxQSize; /* Port Rx Queue Size in kB */ + int PXSQSize; /* Port Synchronous Transmit Queue Size in kB */ + int PXAQSize; /* Port Asynchronous Transmit Queue Size in kB*/ SK_U32 PRxQRamStart; /* Receive Queue RAM Buffer Start Address */ - SK_U32 PRxQRamEnd; /* Receive Queue RAM Buffer End Address */ + SK_U32 PRxQRamEnd; /* Receive Queue RAM Buffer End Address */ SK_U32 PXsQRamStart; /* Sync Tx Queue RAM Buffer Start Address */ - SK_U32 PXsQRamEnd; /* Sync Tx Queue RAM Buffer End Address */ + SK_U32 PXsQRamEnd; /* Sync Tx Queue RAM Buffer End Address */ SK_U32 PXaQRamStart; /* Async Tx Queue RAM Buffer Start Address */ - SK_U32 PXaQRamEnd; /* Async Tx Queue RAM Buffer End Address */ - int PRxQOff; /* Rx Queue Address Offset */ - int PXsQOff; /* Synchronous Tx Queue Address Offset */ - int PXaQOff; /* Asynchronous Tx Queue Address Offset */ - SK_U16 PRxCmd; /* Port Receive Command Configuration Value */ - SK_U16 PIsave; /* Saved Interrupt status word */ - SK_U16 PSsave; /* Saved PHY status word */ - SK_BOOL PHWLinkUp; /* The hardware Link is up (wireing) */ - SK_BOOL PState; /* Is port initialized ? */ + SK_U32 PXaQRamEnd; /* Async Tx Queue RAM Buffer End Address */ + int PRxQOff; /* Rx Queue Address Offset */ + int PXsQOff; /* Synchronous Tx Queue Address Offset */ + int PXaQOff; /* Asynchronous Tx Queue Address Offset */ + SK_U16 PRxCmd; /* Port Receive Command Configuration Value */ + SK_U16 PIsave; /* Saved Interrupt status word */ + SK_U16 PSsave; /* Saved PHY status word */ + SK_BOOL PHWLinkUp; /* The hardware Link is up (wireing) */ + SK_BOOL PState; /* Is port initialized ? */ SK_BOOL PLinkBroken; /* Is Link broken ? */ - SK_BOOL PCheckPar; /* Do we check for parity errors ? */ - SK_U8 PLinkCap; /* Link Capabilities */ + SK_BOOL PCheckPar; /* Do we check for parity errors ? */ + SK_U8 PLinkCap; /* Link Capabilities */ SK_U8 PLinkModeConf; /* Link Mode configured */ - SK_U8 PLinkMode; /* Link Mode currently used */ - SK_U8 PLinkModeStatus; /* Link Mode Status */ + SK_U8 PLinkMode; /* Link Mode currently used */ + SK_U8 PLinkModeStatus;/* Link Mode Status */ SK_U8 PFlowCtrlCap; /* Flow Control Capabilities */ SK_U8 PFlowCtrlMode; /* Flow Control Mode */ - SK_U8 PFlowCtrlStatus; /* Flow Control Status */ - SK_U8 PMSCap; /* Master/Slave Capabilities */ - SK_U8 PMSMode; /* Master/Slave Mode */ - SK_U8 PMSStatus; /* Master/Slave Status */ + SK_U8 PFlowCtrlStatus;/* Flow Control Status */ + SK_U8 PMSCap; /* Master/Slave Capabilities */ + SK_U8 PMSMode; /* Master/Slave Mode */ + SK_U8 PMSStatus; /* Master/Slave Status */ SK_U8 PAutoNegFail; /* Autonegotiation fail flag */ SK_U8 PLipaAutoNeg; /* Autonegotiation possible with Link Partner */ + SK_U16 PhyAddr; /* MDIO/MDC PHY address */ int PhyType; /* PHY used on this port */ - SK_U16 PhyAddr; /* MDIO/MDC PHY address */ } SK_GEPORT; /* * Gigabit Ethernet Initalization Struct - * (has to be included in the adapter context + * (has to be included in the adapter context) */ typedef struct s_GeInit { - int GIMacsFound; /* Number of MACs found on this adapter */ - int GIPciHwRev; /* PCI HW Revision Number */ - SK_U32 GIRamOffs; /* RAM Address Offset for addr calculation */ - int GIRamSize; /* The RAM size of the adapter in kB */ - int GIHstClkFact; /* Host Clock Factor (62.5 / HstClk * 100) */ - int GIPortUsage; /* driver port usage: SK_RED_LINK/SK_MUL_LINK */ - SK_U32 GIPollTimerVal; /* Descriptor Poll Timer Init Val in clk ticks*/ - int GILevel; /* Initialization Level Completed */ - SK_BOOL GIAnyPortAct; /* Is True if one or more port is initialized */ - SK_GEPORT GP[SK_MAX_MACS]; /* Port Dependent Information */ + int GIMacsFound; /* Number of MACs found on this adapter */ + int GIPciHwRev; /* PCI HW Revision Number */ + SK_U32 GIRamOffs; /* RAM Address Offset for addr calculation */ + int GIRamSize; /* The RAM size of the adapter in kB */ + int GIHstClkFact; /* Host Clock Factor (62.5 / HstClk * 100) */ + int GIPortUsage; /* driver port usage: SK_RED_LINK/SK_MUL_LINK */ + SK_U32 GIPollTimerVal; /* Descriptor Poll Timer Init Val in clk ticks*/ + int GILevel; /* Initialization Level Completed */ + SK_GEPORT GP[SK_MAX_MACS];/* Port Dependent Information */ + SK_BOOL GIAnyPortAct; /* Is True if one or more port is initialized */ + SK_U8 Align01; + SK_U16 Align02; } SK_GEINIT; /* diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skgepnm2.h linux/drivers/net/sk98lin/h/skgepnm2.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skgepnm2.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skgepnm2.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skgepnm2.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.24 $ - * Date: $Date: 1999/04/13 15:11:11 $ + * Version: $Revision: 1.28 $ + * Date: $Date: 2000/08/03 15:12:48 $ * Purpose: Defines for Private Network Management Interface * ****************************************************************************/ @@ -27,6 +27,20 @@ * History: * * $Log: skgepnm2.h,v $ + * Revision 1.28 2000/08/03 15:12:48 rwahl + * - Additional comment for MAC statistic data structure. + * + * Revision 1.27 2000/08/01 16:10:18 rwahl + * - Added mac statistic data structure for StatRxLongFrame counter. + * + * Revision 1.26 2000/03/31 13:51:34 rwahl + * Added SK_UPTR cast to offset calculation for PNMI struct fields; + * missing cast caused compiler warnings by Win64 compiler. + * + * Revision 1.25 1999/11/22 13:57:41 cgoos + * Changed license header to GPL. + * Allowing overwrite for SK_PNMI_STORE/_READ defines. + * * Revision 1.24 1999/04/13 15:11:11 mhaveman * Changed copyright. * @@ -203,6 +217,8 @@ /* * MAC statistic data structures + * Only for the first 64 counters: the number relates to the bit in the + * XMAC overflow status register */ #define SK_PNMI_HTX 0 #define SK_PNMI_HTX_OCTET 1 @@ -274,6 +290,8 @@ #define SK_PNMI_HTX_SYNC 64 #define SK_PNMI_HTX_SYNC_OCTET 65 +#define SK_PNMI_HRX_LONGFRAMES 66 + #define SK_PNMI_MAX_IDX (SK_PNMI_CNT_NO) /* @@ -288,25 +306,25 @@ /* * SK_PNMI_STRUCT_DATA copy offset evaluation macros */ -#define SK_PNMI_OFF(e) ((SK_U32)&(((SK_PNMI_STRUCT_DATA *)0)->e)) -#define SK_PNMI_MAI_OFF(e) ((SK_U32)&(((SK_PNMI_STRUCT_DATA *)0)->e)) -#define SK_PNMI_VPD_OFF(e) ((SK_U32)&(((SK_PNMI_VPD *)0)->e)) -#define SK_PNMI_SEN_OFF(e) ((SK_U32)&(((SK_PNMI_SENSOR *)0)->e)) -#define SK_PNMI_CHK_OFF(e) ((SK_U32)&(((SK_PNMI_CHECKSUM *)0)->e)) -#define SK_PNMI_STA_OFF(e) ((SK_U32)&(((SK_PNMI_STAT *)0)->e)) -#define SK_PNMI_CNF_OFF(e) ((SK_U32)&(((SK_PNMI_CONF *)0)->e)) -#define SK_PNMI_RLM_OFF(e) ((SK_U32)&(((SK_PNMI_RLMT *)0)->e)) -#define SK_PNMI_MON_OFF(e) ((SK_U32)&(((SK_PNMI_RLMT_MONITOR *)0)->e)) -#define SK_PNMI_TRP_OFF(e) ((SK_U32)&(((SK_PNMI_TRAP *)0)->e)) +#define SK_PNMI_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_STRUCT_DATA *)0)->e)) +#define SK_PNMI_MAI_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_STRUCT_DATA *)0)->e)) +#define SK_PNMI_VPD_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_VPD *)0)->e)) +#define SK_PNMI_SEN_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_SENSOR *)0)->e)) +#define SK_PNMI_CHK_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_CHECKSUM *)0)->e)) +#define SK_PNMI_STA_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_STAT *)0)->e)) +#define SK_PNMI_CNF_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_CONF *)0)->e)) +#define SK_PNMI_RLM_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_RLMT *)0)->e)) +#define SK_PNMI_MON_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_RLMT_MONITOR *)0)->e)) +#define SK_PNMI_TRP_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_TRAP *)0)->e)) #define SK_PNMI_SET_STAT(b,s,o) {SK_U32 Val32; char *pVal; \ Val32 = (s); \ - pVal = (char *)(b) + ((SK_U32) \ + pVal = (char *)(b) + ((SK_U32)(SK_UPTR) \ &(((SK_PNMI_STRUCT_DATA *)0)-> \ ReturnStatus.ErrorStatus)); \ SK_PNMI_STORE_U32(pVal, Val32); \ Val32 = (o); \ - pVal = (char *)(b) + ((SK_U32) \ + pVal = (char *)(b) + ((SK_U32)(SK_UPTR) \ &(((SK_PNMI_STRUCT_DATA *)0)-> \ ReturnStatus.ErrorOffset)); \ SK_PNMI_STORE_U32(pVal, Val32);} diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skgepnmi.h linux/drivers/net/sk98lin/h/skgepnmi.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skgepnmi.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skgepnmi.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skgepnmi.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.37 $ - * Date: $Date: 1999/09/14 14:25:32 $ + * Version: $Revision: 1.44 $ + * Date: $Date: 2000/09/07 07:35:27 $ * Purpose: Defines for Private Network Management Interface * ****************************************************************************/ @@ -27,6 +27,34 @@ * History: * * $Log: skgepnmi.h,v $ + * Revision 1.44 2000/09/07 07:35:27 rwahl + * - removed NDIS counter specific data type. + * - fixed spelling for OID_SKGE_RLMT_PORT_PREFERRED. + * + * Revision 1.43 2000/08/04 11:41:08 rwahl + * - Fixed compiler warning (port is always >= 0) for macros + * SK_PNMI_CNT_RX_LONGFRAMES & SK_PNMI_CNT_SYNC_OCTETS + * + * Revision 1.42 2000/08/03 15:14:07 rwahl + * - Corrected error in driver macros addressing a physical port. + * + * Revision 1.41 2000/08/01 16:22:29 rwahl + * - Changed MDB version to 3.1. + * - Added definitions for StatRxLongFrames counter. + * - Added macro to be used by driver to count long frames received. + * - Added directive to control width (default = 32bit) of NDIS statistic + * counters (SK_NDIS_64BIT_CTR). + * + * Revision 1.40 2000/03/31 13:51:34 rwahl + * Added SK_UPTR cast to offset calculation for PNMI struct fields; + * missing cast caused compiler warnings by Win64 compiler. + * + * Revision 1.39 1999/12/06 10:09:47 rwahl + * Added new error log message. + * + * Revision 1.38 1999/11/22 13:57:55 cgoos + * Changed license header to GPL. + * * Revision 1.37 1999/09/14 14:25:32 rwahl * Set MDB version for 1000Base-T (sensors, Master/Slave) changes. * @@ -164,7 +192,7 @@ /* * Management Database Version */ -#define SK_PNMI_MDB_VERSION 0x00030000 /* 3.0 */ +#define SK_PNMI_MDB_VERSION 0x00030001 /* 3.1 */ /* @@ -383,6 +411,7 @@ #define OID_SKGE_STAT_RX_511 0xFF020154 #define OID_SKGE_STAT_RX_1023 0xFF020155 #define OID_SKGE_STAT_RX_MAX 0xFF020156 +#define OID_SKGE_STAT_RX_LONGFRAMES 0xFF020157 #define OID_SKGE_PHYS_CUR_ADDR 0xFF010120 #define OID_SKGE_PHYS_FAC_ADDR 0xFF010121 @@ -405,7 +434,7 @@ #define OID_SKGE_RLMT_MODE 0xFF010140 #define OID_SKGE_RLMT_PORT_NUMBER 0xFF010141 #define OID_SKGE_RLMT_PORT_ACTIVE 0xFF010142 -#define OID_SKGE_RLMT_PORT_PREFERED 0xFF010143 +#define OID_SKGE_RLMT_PORT_PREFERRED 0xFF010143 #define OID_SKGE_RLMT_CHANGE_CTS 0xFF020160 #define OID_SKGE_RLMT_CHANGE_TIME 0xFF020161 #define OID_SKGE_RLMT_CHANGE_ESTIM 0xFF020162 @@ -559,6 +588,8 @@ #define SK_PNMI_ERR050MSG "MacUpdate: Cannot update statistic counter" #define SK_PNMI_ERR051 (SK_ERRBASE_PNMI + 51) #define SK_PNMI_ERR051MSG "SkPnmiEvent: Port switch suspicious" +#define SK_PNMI_ERR052 (SK_ERRBASE_PNMI + 52) +#define SK_PNMI_ERR052MSG "MacPrivateConf: SK_HWEV_SET_ROLE returned not 0" /* * Management counter macros called by the driver @@ -592,9 +623,16 @@ #define SK_PNMI_CNT_SYNC_OCTETS(pAC,p,v) \ { \ - if (((p) >= 0) && ((p) < SK_MAX_MACS)) { \ - ((pAC)->Pnmi.StatSyncCts[p])++; \ - (pAC)->Pnmi.StatSyncOctetsCts[p] += (SK_U64)(v); \ + if ((p) < SK_MAX_MACS) { \ + ((pAC)->Pnmi.Port[p].StatSyncCts)++; \ + (pAC)->Pnmi.Port[p].StatSyncOctetsCts += (SK_U64)(v); \ + } \ + } + +#define SK_PNMI_CNT_RX_LONGFRAMES(pAC,p) \ + { \ + if ((p) < SK_MAX_MACS) { \ + ((pAC)->Pnmi.Port[p].StatRxLongFrameCts)++; \ } \ } @@ -687,6 +725,7 @@ SK_U64 StatRxBroadcastOkCts; SK_U64 StatRxMulticastOkCts; SK_U64 StatRxUnicastOkCts; + SK_U64 StatRxLongFramesCts; SK_U64 StatRxPauseMacCtrlCts; SK_U64 StatRxMacCtrlCts; SK_U64 StatRxPauseMacCtrlErrorCts; @@ -809,8 +848,9 @@ } SK_PNMI_STRUCT_DATA; #define SK_PNMI_STRUCT_SIZE (sizeof(SK_PNMI_STRUCT_DATA)) -#define SK_PNMI_MIN_STRUCT_SIZE ((unsigned int)&(((SK_PNMI_STRUCT_DATA *)0)->\ - VpdFreeBytes)) /* +#define SK_PNMI_MIN_STRUCT_SIZE ((unsigned int)(SK_UPTR)\ + &(((SK_PNMI_STRUCT_DATA *)0)->VpdFreeBytes)) + /* * ReturnStatus field * must be located * before VpdFreeBytes @@ -822,7 +862,7 @@ #define SK_PNMI_MAX_PROTOS 3 #define SK_PNMI_SCNT_NOT 64 -#define SK_PNMI_CNT_NO 66 +#define SK_PNMI_CNT_NO 67 /* * Estimate data structure @@ -843,6 +883,7 @@ SK_U64 CounterOffset[SK_PNMI_CNT_NO]; SK_U64 StatSyncCts; SK_U64 StatSyncOctetsCts; + SK_U64 StatRxLongFrameCts; SK_BOOL ActiveFlag; } SK_PNMI_PORT; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skgesirq.h linux/drivers/net/sk98lin/h/skgesirq.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skgesirq.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skgesirq.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skgesirq.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.18 $ - * Date: $Date: 1999/05/19 07:32:59 $ + * Version: $Revision: 1.20 $ + * Date: $Date: 1999/12/06 10:00:44 $ * Purpose: SK specific Gigabit Ethernet special IRQ functions * ******************************************************************************/ @@ -26,6 +26,12 @@ * * History: * $Log: skgesirq.h,v $ + * Revision 1.20 1999/12/06 10:00:44 cgoos + * Added SET event for role. + * + * Revision 1.19 1999/11/22 13:58:26 cgoos + * Changed license header to GPL. + * * Revision 1.18 1999/05/19 07:32:59 cgoos * Changes for 1000Base-T. * @@ -99,6 +105,7 @@ #define SK_HWEV_UPDATE_STAT 5 /* Update Statistics by PNMI */ #define SK_HWEV_SET_LMODE 6 /* Set Link Mode by PNMI */ #define SK_HWEV_SET_FLOWMODE 7 /* Set Flow Control Mode by PNMI */ +#define SK_HWEV_SET_ROLE 8 /* Set Master/Slave (Role) by PNMI */ #define SK_WA_ACT_TIME (5000000L) /* 5 sec */ #define SK_WA_INA_TIME (100000L) /* 100 msec */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/ski2c.h linux/drivers/net/sk98lin/h/ski2c.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/ski2c.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/ski2c.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: ski2c.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.27 $ - * Date: $Date: 1999/05/20 09:23:10 $ + * Version: $Revision: 1.29 $ + * Date: $Date: 2000/08/03 14:28:17 $ * Purpose: Defines to access Voltage and Temperature Sensor * (taken from Monalisa (taken from Concentrator)) * @@ -28,6 +28,13 @@ * History: * * $Log: ski2c.h,v $ + * Revision 1.29 2000/08/03 14:28:17 rassmann + * - Added function to wait for I2C being ready before resetting the board. + * - Replaced one duplicate "out of range" message with correct one. + * + * Revision 1.28 1999/11/22 13:55:46 cgoos + * Changed license header to GPL. + * * Revision 1.27 1999/05/20 09:23:10 cgoos * Changes for 1000Base-T (Fan sensors). * @@ -254,9 +261,9 @@ extern int SkI2cReadSensor(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen); #ifndef SK_DIAG -extern int SkI2cEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, - SK_EVPARA Para); +extern int SkI2cEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Para); extern int SkI2cInit(SK_AC *pAC, SK_IOC IoC, int Level); +extern void SkI2cWaitIrq(SK_AC *pAC, SK_IOC IoC); extern void SkI2cIsr(SK_AC *pAC, SK_IOC IoC); #endif diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skqueue.h linux/drivers/net/sk98lin/h/skqueue.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skqueue.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skqueue.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skqueue.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.12 $ - * Date: $Date: 1998/09/08 08:48:01 $ + * Version: $Revision: 1.13 $ + * Date: $Date: 1999/11/22 13:59:05 $ * Purpose: Defines for the Event queue * ******************************************************************************/ @@ -27,6 +27,9 @@ * History: * * $Log: skqueue.h,v $ + * Revision 1.13 1999/11/22 13:59:05 cgoos + * Changed license header to GPL. + * * Revision 1.12 1998/09/08 08:48:01 gklug * add: init level handling * diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skrlmt.h linux/drivers/net/sk98lin/h/skrlmt.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skrlmt.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skrlmt.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skrlmt.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.26 $ - * Date: $Date: 1999/10/04 14:01:19 $ + * Version: $Revision: 1.27 $ + * Date: $Date: 1999/11/22 13:59:56 $ * Purpose: Header file for Redundant Link ManagemenT. * ******************************************************************************/ @@ -27,6 +27,9 @@ * History: * * $Log: skrlmt.h,v $ + * Revision 1.27 1999/11/22 13:59:56 cgoos + * Changed license header to GPL. + * * Revision 1.26 1999/10/04 14:01:19 rassmann * Corrected reaction to reception of BPDU frames. * Added parameter descriptions to "For Readme" section skrlmt.txt. diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/sktimer.h linux/drivers/net/sk98lin/h/sktimer.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/sktimer.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/sktimer.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: sktimer.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.8 $ - * Date: $Date: 1998/09/08 08:48:02 $ + * Version: $Revision: 1.9 $ + * Date: $Date: 1999/11/22 14:00:29 $ * Purpose: Defines for the timer functions * ******************************************************************************/ @@ -27,6 +27,9 @@ * History: * * $Log: sktimer.h,v $ + * Revision 1.9 1999/11/22 14:00:29 cgoos + * Changed license header to GPL. + * * Revision 1.8 1998/09/08 08:48:02 gklug * add: init level handling * diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/sktypes.h linux/drivers/net/sk98lin/h/sktypes.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/sktypes.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/sktypes.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: sktypes.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.1 $ - * Date: $Date: 1999/02/16 07:41:40 $ + * Version: $Revision: 1.2 $ + * Date: $Date: 1999/11/22 14:01:58 $ * Purpose: Define data types for Linux * ******************************************************************************/ @@ -27,6 +27,10 @@ * History: * * $Log: sktypes.h,v $ + * Revision 1.2 1999/11/22 14:01:58 cgoos + * Changed license header to GPL. + * Now using Linux' fixed size types instead of standard types. + * * Revision 1.1 1999/02/16 07:41:40 cgoos * First version. * diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/skvpd.h linux/drivers/net/sk98lin/h/skvpd.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/skvpd.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/skvpd.h Fri Sep 15 14:34:19 2000 @@ -2,15 +2,15 @@ * * Name: skvpd.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.8 $ - * Date: $Date: 1999/03/11 14:26:40 $ + * Version: $Revision: 1.10 $ + * Date: $Date: 2000/08/10 11:29:07 $ * Purpose: Defines and Macros for VPD handling * ******************************************************************************/ /****************************************************************************** * - * (C)Copyright 1998,1999 SysKonnect, + * (C)Copyright 1998-2000 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * * This program is free software; you can redistribute it and/or modify @@ -27,6 +27,15 @@ * History: * * $Log: skvpd.h,v $ + * Revision 1.10 2000/08/10 11:29:07 rassmann + * Editorial changes. + * Preserving 32-bit alignment in structs for the adapter context. + * Removed unused function VpdWriteDword() (#if 0). + * Made VpdReadKeyword() available for SKDIAG only. + * + * Revision 1.9 1999/11/22 14:02:27 cgoos + * Changed license header to GPL. + * * Revision 1.8 1999/03/11 14:26:40 malthoff * Replace __STDC__ with SK_KR_PROTO. * @@ -112,40 +121,42 @@ /* VPD status */ /* bit 7..1 reserved */ -#define VPD_VALID (1<<0) /* VPD data buffer, vpd_free_ro, */ - /* and vpd_free_rw valid */ +#define VPD_VALID (1<<0) /* VPD data buffer, vpd_free_ro, */ + /* and vpd_free_rw valid */ /* * VPD structs */ typedef struct s_vpd_status { - unsigned short vpd_status ; /* VPD status, description see above */ - int vpd_free_ro ; /* unused bytes in read only area */ - int vpd_free_rw ; /* bytes available in read/write area */ + unsigned short Align01; /* Alignment */ + unsigned short vpd_status; /* VPD status, description see above */ + int vpd_free_ro; /* unused bytes in read only area */ + int vpd_free_rw; /* bytes available in read/write area */ } SK_VPD_STATUS; typedef struct s_vpd { - SK_VPD_STATUS v ; /* VPD status structure */ - char vpd_buf[VPD_SIZE] ; /* VPD buffer */ + SK_VPD_STATUS v; /* VPD status structure */ + char vpd_buf[VPD_SIZE]; /* VPD buffer */ } SK_VPD; typedef struct s_vpd_para { - unsigned int p_len ; /* parameter length */ - char *p_val ; /* points to the value */ + unsigned int p_len; /* parameter length */ + char *p_val; /* points to the value */ } SK_VPD_PARA; /* * structure of Large Resource Type Identifiers */ -/* was removed, because of alignment problems */ + +/* was removed because of alignment problems */ /* * sturcture of VPD keywords */ typedef struct s_vpd_key { - char p_key[2] ; /* 2 bytes ID string */ - unsigned char p_len ; /* 1 byte length */ - char p_val ; /* start of the value string */ + char p_key[2]; /* 2 bytes ID string */ + unsigned char p_len; /* 1 byte length */ + char p_val; /* start of the value string */ } SK_VPD_KEY; @@ -169,39 +180,39 @@ #define VPD_IN32(pAC,IoC,Addr,pVal) SK_IN32(IoC,PCI_C(Addr),pVal) #endif /* VPD_DO_IO */ #else /* SKDIAG */ -#define VPD_OUT8(pAC,Ioc,Addr,Val) { \ +#define VPD_OUT8(pAC,Ioc,Addr,Val) { \ if ((pAC)->DgT.DgUseCfgCycle) \ - SkPciWriteCfgByte(pAC,Addr,Val) ; \ - else \ + SkPciWriteCfgByte(pAC,Addr,Val); \ + else \ SK_OUT8(pAC,PCI_C(Addr),Val); \ } -#define VPD_OUT16(pAC,Ioc,Addr,Val) { \ +#define VPD_OUT16(pAC,Ioc,Addr,Val) { \ if ((pAC)->DgT.DgUseCfgCycle) \ - SkPciWriteCfgWord(pAC,Addr,Val) ; \ + SkPciWriteCfgWord(pAC,Addr,Val); \ else \ SK_OUT16(pAC,PCI_C(Addr),Val); \ } -#define VPD_OUT32(pAC,Ioc,Addr,Val) { \ +#define VPD_OUT32(pAC,Ioc,Addr,Val) { \ if ((pAC)->DgT.DgUseCfgCycle) \ - SkPciWriteCfgDWord(pAC,Addr,Val) ; \ + SkPciWriteCfgDWord(pAC,Addr,Val); \ else \ SK_OUT32(pAC,PCI_C(Addr),Val); \ } -#define VPD_IN8(pAC,Ioc,Addr,pVal) { \ +#define VPD_IN8(pAC,Ioc,Addr,pVal) { \ if ((pAC)->DgT.DgUseCfgCycle) \ - SkPciReadCfgByte(pAC,Addr,pVal) ; \ + SkPciReadCfgByte(pAC,Addr,pVal); \ else \ SK_IN8(pAC,PCI_C(Addr),pVal); \ } -#define VPD_IN16(pAC,Ioc,Addr,pVal) { \ +#define VPD_IN16(pAC,Ioc,Addr,pVal) { \ if ((pAC)->DgT.DgUseCfgCycle) \ - SkPciReadCfgWord(pAC,Addr,pVal) ; \ + SkPciReadCfgWord(pAC,Addr,pVal); \ else \ SK_IN16(pAC,PCI_C(Addr),pVal); \ } -#define VPD_IN32(pAC,Ioc,Addr,pVal) { \ +#define VPD_IN32(pAC,Ioc,Addr,pVal) { \ if ((pAC)->DgT.DgUseCfgCycle) \ - SkPciReadCfgDWord(pAC,Addr,pVal) ; \ + SkPciReadCfgDWord(pAC,Addr,pVal); \ else \ SK_IN32(pAC,PCI_C(Addr),pVal); \ } @@ -210,50 +221,52 @@ /* function prototypes ********************************************************/ #ifndef SK_KR_PROTO +#ifdef SKDIAG extern SK_U32 VpdReadDWord( SK_AC *pAC, SK_IOC IoC, - int addr) ; + int addr); +#endif /* SKDIAG */ extern int VpdSetupPara( SK_AC *pAC, char *key, char *buf, - int len, - int type, - int op) ; + int len, + int type, + int op); extern SK_VPD_STATUS *VpdStat( SK_AC *pAC, - SK_IOC IoC) ; + SK_IOC IoC); extern int VpdKeys( SK_AC *pAC, SK_IOC IoC, char *buf, - int *len, - int *elements) ; + int *len, + int *elements); extern int VpdRead( SK_AC *pAC, SK_IOC IoC, char *key, char *buf, - int *len) ; + int *len); extern SK_BOOL VpdMayWrite( - char *key) ; + char *key); extern int VpdWrite( SK_AC *pAC, SK_IOC IoC, char *key, - char *buf) ; + char *buf); extern int VpdDelete( SK_AC *pAC, SK_IOC IoC, - char *key) ; + char *key); extern int VpdUpdate( SK_AC *pAC, @@ -262,34 +275,34 @@ extern void VpdErrLog( SK_AC *pAC, SK_IOC IoC, - char *msg) ; + char *msg); #ifdef SKDIAG extern int VpdReadBlock( SK_AC *pAC, SK_IOC IoC, char *buf, - int addr, - int len) ; + int addr, + int len); extern int VpdWriteBlock( SK_AC *pAC, SK_IOC IoC, char *buf, - int addr, - int len) ; + int addr, + int len); #endif /* SKDIAG */ #else /* SK_KR_PROTO */ -extern SK_U32 VpdReadDWord() ; -extern int VpdSetupPara() ; -extern SK_VPD_STATUS *VpdStat() ; -extern int VpdKeys() ; -extern int VpdRead() ; -extern SK_BOOL VpdMayWrite() ; -extern int VpdWrite() ; -extern int VpdDelete() ; -extern int VpdUpdate() ; -extern void VpdErrLog() ; +extern SK_U32 VpdReadDWord(); +extern int VpdSetupPara(); +extern SK_VPD_STATUS *VpdStat(); +extern int VpdKeys(); +extern int VpdRead(); +extern SK_BOOL VpdMayWrite(); +extern int VpdWrite(); +extern int VpdDelete(); +extern int VpdUpdate(); +extern void VpdErrLog(); #endif /* SK_KR_PROTO */ #endif /* __INC_SKVPD_H_ */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/h/xmac_ii.h linux/drivers/net/sk98lin/h/xmac_ii.h --- v2.4.0-test8/linux/drivers/net/sk98lin/h/xmac_ii.h Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/h/xmac_ii.h Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: xmac_ii.h * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.25 $ - * Date: $Date: 1999/08/12 19:19:38 $ + * Version: $Revision: 1.27 $ + * Date: $Date: 2000/05/17 11:00:46 $ * Purpose: Defines and Macros for XaQti's Gigabit Ethernet Controller * ******************************************************************************/ @@ -27,6 +27,12 @@ * History: * * $Log: xmac_ii.h,v $ + * Revision 1.27 2000/05/17 11:00:46 malthoff + * Add bit for enable/disable power management in BCOM chip. + * + * Revision 1.26 1999/11/22 14:03:00 cgoos + * Changed license header to GPL. + * * Revision 1.25 1999/08/12 19:19:38 malthoff * Add PHY_B_AC_TX_TST bit according to BCOM A1 errata sheet. * @@ -930,7 +936,9 @@ #define PHY_B_AC_TX_TST (1<<10) /* Bit 10: tx test bit, always 1 */ /* Bit 9.. 8: reserved */ #define PHY_B_AC_DIS_PRF (1<<7) /* Bit 7: dis part resp filter */ - /* Bit 6.. 4: reserved */ + /* Bit 6: reserved */ +#define PHY_B_AC_DIS_PM (1<<5) /* Bit 5: dis power management */ + /* Bit 4: reserved */ #define PHY_B_AC_DIAG (1<<3) /* Bit 3: Diagnostic Mode */ /* Bit 2.. 0: reserved */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/skaddr.c linux/drivers/net/sk98lin/skaddr.c --- v2.4.0-test8/linux/drivers/net/sk98lin/skaddr.c Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/skaddr.c Fri Sep 15 14:34:19 2000 @@ -2,19 +2,17 @@ * * Name: skaddr.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.33 $ - * Date: $Date: 1999/05/28 10:56:06 $ - * Purpose: Manage Addresses (Multicast and Unicast) and Promiscuous Mode + * Version: $Revision: 1.36 $ + * Date: $Date: 2000/08/07 11:10:39 $ + * Purpose: Manage Addresses (Multicast and Unicast) and Promiscuous Mode. * ******************************************************************************/ /****************************************************************************** * - * (C)Copyright 1998,1999 SysKonnect, + * (C)Copyright 1998-2000 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * - * See the file "skge.c" for further information. - * * 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 @@ -29,6 +27,16 @@ * History: * * $Log: skaddr.c,v $ + * Revision 1.36 2000/08/07 11:10:39 rassmann + * Editorial changes. + * + * Revision 1.35 2000/05/04 09:38:41 rassmann + * Editorial changes. + * Corrected multicast address hashing. + * + * Revision 1.34 1999/11/22 13:23:44 cgoos + * Changed license header to GPL. + * * Revision 1.33 1999/05/28 10:56:06 rassmann * Editorial changes. * @@ -164,13 +172,13 @@ #ifndef lint static const char SysKonnectFileId[] = - "@(#) $Id: skaddr.c,v 1.33 1999/05/28 10:56:06 rassmann Exp $ (C) SysKonnect."; + "@(#) $Id: skaddr.c,v 1.36 2000/08/07 11:10:39 rassmann Exp $ (C) SysKonnect."; #endif /* !defined(lint) */ #define __SKADDR_C #ifdef __cplusplus -xxxx /* not supported yet - force error */ +#error C++ is not yet supported. extern "C" { #endif /* cplusplus */ @@ -179,19 +187,9 @@ /* defines ********************************************************************/ -#define SK_ADDR_CHEAT YES /* Cheat. */ - -/* - * G32: - * POLY equ 04C11DB6h ; CRC polynominal term - * bit-reversed: 6DB88320 - */ #define CRC32_POLY 0xEDB88320UL /* CRC32-Poly - XMAC: Little Endian */ -#if 0 -#define CRC32_POLY 0x6DB88320UL /* CRC32-Poly - XMAC: Little Endian */ -#endif /* 0 */ -#define HASH_BITS 6 /* #bits in hash */ +#define HASH_BITS 6 /* #bits in hash */ #define SK_MC_BIT 0x01 /* Error numbers and messages. */ @@ -219,13 +217,6 @@ /* functions ******************************************************************/ -#if 0 -void SkAddrDummy(void) -{ - SkAddrInit(NULL, NULL, 0); -} /* SkAddrDummy */ -#endif /* 0 */ - /****************************************************************************** * * SkAddrInit - initialize data, set state to init @@ -236,7 +227,7 @@ * ============ * * This routine clears the multicast tables and resets promiscuous mode. - * Some entries are reserved for the "logical board address", the + * Some entries are reserved for the "logical MAC address", the * SK-RLMT multicast address, and the BPDU multicast address. * * @@ -263,12 +254,12 @@ int SkAddrInit( SK_AC *pAC, /* the adapter context */ SK_IOC IoC, /* I/O context */ -int Level) /* initialization level */ +int Level) /* initialization level */ { - int j; - SK_U32 i; - SK_U8 *InAddr; - SK_U16 *OutAddr; + int j; + SK_U32 i; + SK_U8 *InAddr; + SK_U16 *OutAddr; SK_ADDR_PORT *pAPort; switch (Level) { @@ -279,20 +270,15 @@ pAPort = &pAC->Addr.Port[i]; pAPort->PromMode = SK_PROM_MODE_NONE; - pAPort->FirstExactMatchRlmt = - SK_ADDR_FIRST_MATCH_RLMT; - pAPort->FirstExactMatchDrv = - SK_ADDR_FIRST_MATCH_DRV; - pAPort->NextExactMatchRlmt = - SK_ADDR_FIRST_MATCH_RLMT; - pAPort->NextExactMatchDrv = - SK_ADDR_FIRST_MATCH_DRV; + pAPort->FirstExactMatchRlmt = SK_ADDR_FIRST_MATCH_RLMT; + pAPort->FirstExactMatchDrv = SK_ADDR_FIRST_MATCH_DRV; + pAPort->NextExactMatchRlmt = SK_ADDR_FIRST_MATCH_RLMT; + pAPort->NextExactMatchDrv = SK_ADDR_FIRST_MATCH_DRV; #if 0 - /* Not here ... */ + /* Don't do this here ... */ /* Reset Promiscuous mode. */ - (void)SkAddrPromiscuousChange( pAC, IoC, @@ -325,8 +311,7 @@ } #endif /* DEBUG */ - /* Read permanent virtual address from Control Register File. */ - + /* Read permanent logical MAC address from Control Register File. */ for (j = 0; j < SK_MAC_ADDR_LEN; j++) { InAddr = (SK_U8 *)&pAC->Addr.PermanentMacAddress.a[j]; SK_IN8(IoC, B2_MAC_1 + j, InAddr); @@ -334,17 +319,15 @@ if (!pAC->Addr.CurrentMacAddressSet) { /* - * Set the current virtual MAC address + * Set the current logical MAC address * to the permanent one. */ - pAC->Addr.CurrentMacAddress = pAC->Addr.PermanentMacAddress; pAC->Addr.CurrentMacAddressSet = SK_TRUE; } - /* Set the current virtual MAC address. */ - + /* Set the current logical MAC address. */ pAC->Addr.Port[pAC->Addr.ActivePort].Exact[0] = pAC->Addr.CurrentMacAddress; @@ -354,27 +337,27 @@ SK_DBGMOD_ADDR, SK_DBGCAT_INIT, ("Permanent MAC Address: %02X %02X %02X %02X %02X %02X\n", - pAC->Addr.PermanentMacAddress.a[0], - pAC->Addr.PermanentMacAddress.a[1], - pAC->Addr.PermanentMacAddress.a[2], - pAC->Addr.PermanentMacAddress.a[3], - pAC->Addr.PermanentMacAddress.a[4], - pAC->Addr.PermanentMacAddress.a[5])) + pAC->Addr.PermanentMacAddress.a[0], + pAC->Addr.PermanentMacAddress.a[1], + pAC->Addr.PermanentMacAddress.a[2], + pAC->Addr.PermanentMacAddress.a[3], + pAC->Addr.PermanentMacAddress.a[4], + pAC->Addr.PermanentMacAddress.a[5])) SK_DBG_MSG( pAC, SK_DBGMOD_ADDR, SK_DBGCAT_INIT, - ("Virtual MAC Address: %02X %02X %02X %02X %02X %02X\n", - pAC->Addr.CurrentMacAddress.a[0], - pAC->Addr.CurrentMacAddress.a[1], - pAC->Addr.CurrentMacAddress.a[2], - pAC->Addr.CurrentMacAddress.a[3], - pAC->Addr.CurrentMacAddress.a[4], - pAC->Addr.CurrentMacAddress.a[5])) + ("Logical MAC Address: %02X %02X %02X %02X %02X %02X\n", + pAC->Addr.CurrentMacAddress.a[0], + pAC->Addr.CurrentMacAddress.a[1], + pAC->Addr.CurrentMacAddress.a[2], + pAC->Addr.CurrentMacAddress.a[3], + pAC->Addr.CurrentMacAddress.a[4], + pAC->Addr.CurrentMacAddress.a[5])) #endif /* DEBUG */ #if 0 - /* Not here ... */ + /* Don't do this here ... */ (void)SkAddrMcUpdate(pAC, IoC, pAC->Addr.ActivePort); #endif /* 0 */ @@ -386,10 +369,8 @@ * Read permanent port addresses from * Control Register File. */ - for (j = 0; j < SK_MAC_ADDR_LEN; j++) { - InAddr = (SK_U8 *) - &pAPort->PermanentMacAddress.a[j]; + InAddr = (SK_U8 *)&pAPort->PermanentMacAddress.a[j]; SK_IN8(IoC, B2_MAC_2 + 8 * i + j, InAddr); } @@ -399,16 +380,12 @@ * MAC address of this port to its permanent * MAC address. */ - - pAPort->CurrentMacAddress = - pAPort->PermanentMacAddress; - pAPort->PreviousMacAddress = - pAPort->PermanentMacAddress; + pAPort->CurrentMacAddress = pAPort->PermanentMacAddress; + pAPort->PreviousMacAddress = pAPort->PermanentMacAddress; pAPort->CurrentMacAddressSet = SK_TRUE; } /* Set port's current MAC addresses. */ - OutAddr = (SK_U16 *)&pAPort->CurrentMacAddress.a[0]; XM_OUTADDR(IoC, i, XM_SA, OutAddr); @@ -484,7 +461,7 @@ SK_AC *pAC, /* adapter context */ SK_IOC IoC, /* I/O context */ SK_U32 PortIdx, /* Index of affected port */ -int Flags) /* permanent/non-perm, sw-only */ +int Flags) /* permanent/non-perm, sw-only */ { int i; @@ -495,9 +472,7 @@ if (Flags & SK_ADDR_PERMANENT) { /* Clear RLMT multicast addresses. */ - - pAC->Addr.Port[PortIdx].NextExactMatchRlmt = - SK_ADDR_FIRST_MATCH_RLMT; + pAC->Addr.Port[PortIdx].NextExactMatchRlmt = SK_ADDR_FIRST_MATCH_RLMT; } else { /* not permanent => DRV */ @@ -509,8 +484,7 @@ /* Clear DRV multicast addresses. */ - pAC->Addr.Port[PortIdx].NextExactMatchDrv = - SK_ADDR_FIRST_MATCH_DRV; + pAC->Addr.Port[PortIdx].NextExactMatchDrv = SK_ADDR_FIRST_MATCH_DRV; } if (!(Flags & SK_MC_SW_ONLY)) { @@ -521,7 +495,7 @@ } /* SkAddrMcClear */ #ifndef SK_ADDR_CHEAT -// RA;:;: + /****************************************************************************** * * SkCrc32McHash - hash multicast address @@ -548,15 +522,13 @@ Crc = 0xFFFFFFFFUL; for (Idx = 0; Idx < SK_MAC_ADDR_LEN; Idx++) { - Data = *pMc++; + Data = *pMc++; for (Bit = 0; Bit < 8; Bit++, Data >>= 1) { - Crc = (Crc >> 1) ^ - (((Crc ^ Data) & 1) ? CRC32_POLY : 0); + Crc = (Crc >> 1) ^ (((Crc ^ Data) & 1) ? CRC32_POLY : 0); } } return (Crc & ((1 << HASH_BITS) - 1)); - } /* SkCrc32McHash */ #endif /* not SK_ADDR_CHEAT */ @@ -593,7 +565,7 @@ SK_IOC IoC, /* I/O context */ SK_U32 PortIdx, /* Port Index */ SK_MAC_ADDR *pMc, /* multicast address to be added */ -int Flags) /* permanent/non-permanent */ +int Flags) /* permanent/non-permanent */ { int i; SK_U8 Inexact; @@ -628,11 +600,9 @@ } /* Not PERMANENT => DRV */ - if (PortIdx != pAC->Addr.ActivePort) { /* Only RLMT is allowed to do this. */ - return (SK_MC_ILLEGAL_PORT); } @@ -647,41 +617,31 @@ if (pAC->Addr.Port[PortIdx].NextExactMatchDrv <= SK_ADDR_LAST_MATCH_DRV) { /* Set exact match entry. */ - pAC->Addr.Port[PortIdx].Exact[ pAC->Addr.Port[PortIdx].NextExactMatchDrv++] = *pMc; /* Clear InexactFilter. */ - for (i = 0; i < 8; i++) { - pAC->Addr.Port[PortIdx - ].InexactFilter.Bytes[i] = 0; + pAC->Addr.Port[PortIdx].InexactFilter.Bytes[i] = 0; } } else { if (!(pMc->a[0] & SK_MC_BIT)) { - /* * Hashing only possible with * multicast addresses. */ - return (SK_MC_ILLEGAL_ADDRESS); } #ifndef SK_ADDR_CHEAT /* Compute hash value of address. */ -RA;:;: untested - HashBit = SkCrc32McHash(&pMc->a[0]); + HashBit = 63 - SkCrc32McHash(&pMc->a[0]); /* Add bit to InexactFilter. */ - pAC->Addr.Port[PortIdx].InexactFilter.Bytes[HashBit / 8] |= 1 << (HashBit % 8); - #else /* SK_ADDR_CHEAT */ - /* Set all bits in InexactFilter. */ - for (i = 0; i < 8; i++) { pAC->Addr.Port[PortIdx].InexactFilter.Bytes[i] = 0xFF; } @@ -727,10 +687,10 @@ SK_IOC IoC, /* I/O context */ SK_U32 PortIdx) /* Port Index */ { - SK_U32 i; - SK_U8 Inexact; - SK_U16 *OutAddr; - SK_U16 LoMode; /* Lower 16 bits of XMAC Mode Reg. */ + SK_U32 i; + SK_U8 Inexact; + SK_U16 *OutAddr; + SK_U16 LoMode; /* Lower 16 bits of XMAC Mode Reg. */ SK_ADDR_PORT *pAPort; if (PortIdx >= (SK_U32)pAC->GIni.GIMacsFound) { @@ -753,18 +713,16 @@ ("Next0 on Port %d: %d\n", PortIdx, Next0[PortIdx])) #endif /* DEBUG */ - for (i = 0; /* Also program the virtual address. */ + for (i = 0; /* Also program the logical MAC address. */ i < pAPort->NextExactMatchRlmt; i++) { /* Set exact match address i on HW. */ - OutAddr = (SK_U16 *)&pAPort->Exact[i].a[0]; XM_OUTADDR(IoC, PortIdx, XM_EXM(i), OutAddr); } /* Clear other permanent exact match addresses on HW. */ - if (pAPort->NextExactMatchRlmt <= SK_ADDR_LAST_MATCH_RLMT) { SkXmClrExactAddr( pAC, @@ -774,17 +732,12 @@ SK_ADDR_LAST_MATCH_RLMT); } - for (i = pAPort->FirstExactMatchDrv; - i < pAPort->NextExactMatchDrv; - i++) { - + for (i = pAPort->FirstExactMatchDrv; i < pAPort->NextExactMatchDrv; i++) { OutAddr = (SK_U16 *)&pAPort->Exact[i].a[0]; XM_OUTADDR(IoC, PortIdx, XM_EXM(i), OutAddr); - } /* Clear other non-permanent exact match addresses on HW. */ - if (pAPort->NextExactMatchDrv <= SK_ADDR_LAST_MATCH_DRV) { SkXmClrExactAddr( pAC, @@ -794,67 +747,51 @@ SK_ADDR_LAST_MATCH_DRV); } - for (Inexact = 0xFF, i = 0; i < 8; i++) { - Inexact &= pAPort->InexactFilter.Bytes[i]; + for (Inexact = 0, i = 0; i < 8; i++) { + Inexact |= pAPort->InexactFilter.Bytes[i]; } - if (pAPort->PromMode & SK_PROM_MODE_ALL_MC) { + if (pAPort->PromMode & SK_PROM_MODE_ALL_MC) { /* Set all bits in 64-bit hash register. */ - XM_OUTHASH(IoC, PortIdx, XM_HSM, &OnesHash); /* Set bit 15 in mode register. */ - XM_IN16(IoC, PortIdx, XM_MODE, &LoMode); LoMode |= XM_MD_ENA_HSH; XM_OUT16(IoC, PortIdx, XM_MODE, LoMode); } - else if (Inexact != 0xFF) { - - /* Clear bit 15 in mode register. */ + else if (Inexact != 0) { + /* Set 64-bit hash register to InexactFilter. */ + XM_OUTHASH(IoC, PortIdx, XM_HSM, &pAPort->InexactFilter.Bytes[0]); + /* Set bit 15 in mode register. */ XM_IN16(IoC, PortIdx, XM_MODE, &LoMode); - LoMode &= ~XM_MD_ENA_HSH; + LoMode |= XM_MD_ENA_HSH; XM_OUT16(IoC, PortIdx, XM_MODE, LoMode); } else { - /* Set 64-bit hash register to InexactFilter. */ - - XM_OUTHASH( - IoC, - PortIdx, - XM_HSM, - &pAPort->InexactFilter.Bytes[0]); - - /* Set bit 15 in mode register. */ - + /* Clear bit 15 in mode register. */ XM_IN16(IoC, PortIdx, XM_MODE, &LoMode); - LoMode |= XM_MD_ENA_HSH; + LoMode &= ~XM_MD_ENA_HSH; XM_OUT16(IoC, PortIdx, XM_MODE, LoMode); } if (pAPort->PromMode != SK_PROM_MODE_NONE) { - (void)SkAddrPromiscuousChange( - pAC, - IoC, - PortIdx, - pAPort->PromMode); + (void)SkAddrPromiscuousChange(pAC, IoC, PortIdx, pAPort->PromMode); } /* Set port's current MAC address. */ - OutAddr = (SK_U16 *)&pAPort->CurrentMacAddress.a[0]; XM_OUTADDR(IoC, PortIdx, XM_SA, OutAddr); #ifdef DEBUG - for (i = 0; /* Also program the virtual address. */ + for (i = 0; /* Also program the logical MAC address. */ i < pAPort->NextExactMatchRlmt; i++) { SK_U8 InAddr8[6]; SK_U16 *InAddr; /* Get exact match address i from port PortIdx. */ - InAddr = (SK_U16 *)&InAddr8[0]; XM_INADDR(IoC, PortIdx, XM_EXM(i), InAddr); SK_DBG_MSG( @@ -880,10 +817,6 @@ #endif /* DEBUG */ /* Determine return value. */ - - for (Inexact = 0, i = 0; i < 8; i++) { - Inexact |= pAPort->InexactFilter.Bytes[i]; - } if (Inexact == 0 && pAPort->PromMode == 0) { return (SK_MC_FILTERING_EXACT); } @@ -915,7 +848,7 @@ SK_IOC IoC, /* I/O context */ SK_U32 PortIdx, /* Port Index */ SK_MAC_ADDR *pNewAddr, /* new MAC address */ -int Flags) /* logical/physical address */ +int Flags) /* logical/physical MAC address */ { SK_U32 i; SK_U16 *OutAddr; @@ -957,7 +890,7 @@ return (SK_ADDR_TOO_EARLY); } - if (Flags & SK_ADDR_PHYSICAL_ADDRESS) { /* Physical address. */ + if (Flags & SK_ADDR_PHYSICAL_ADDRESS) { /* Physical MAC address. */ if (SK_ADDR_EQUAL(pNewAddr->a, pAC->Addr.CurrentMacAddress.a)) { return (SK_ADDR_DUPLICATE_ADDRESS); } @@ -984,16 +917,14 @@ pAC->Addr.Port[PortIdx].CurrentMacAddress = *pNewAddr; /* Change port's address. */ - OutAddr = (SK_U16 *)pNewAddr; XM_OUTADDR(IoC, PortIdx, XM_SA, OutAddr); /* Report address change to RLMT. */ - Para.Para32[0] = PortIdx; SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_PORT_ADDR, Para); } - else { /* Logical Address. */ + else { /* Logical MAC address. */ if (SK_ADDR_EQUAL(pNewAddr->a, pAC->Addr.CurrentMacAddress.a)) { return (SK_ADDR_SUCCESS); } @@ -1019,27 +950,26 @@ SK_DBGMOD_ADDR, SK_DBGCAT_CTRL, ("Permanent MAC Address: %02X %02X %02X %02X %02X %02X\n", - pAC->Addr.PermanentMacAddress.a[0], - pAC->Addr.PermanentMacAddress.a[1], - pAC->Addr.PermanentMacAddress.a[2], - pAC->Addr.PermanentMacAddress.a[3], - pAC->Addr.PermanentMacAddress.a[4], - pAC->Addr.PermanentMacAddress.a[5])) + pAC->Addr.PermanentMacAddress.a[0], + pAC->Addr.PermanentMacAddress.a[1], + pAC->Addr.PermanentMacAddress.a[2], + pAC->Addr.PermanentMacAddress.a[3], + pAC->Addr.PermanentMacAddress.a[4], + pAC->Addr.PermanentMacAddress.a[5])) SK_DBG_MSG( pAC, SK_DBGMOD_ADDR, SK_DBGCAT_CTRL, - ("New Virtual MAC Address: %02X %02X %02X %02X %02X %02X\n", - pAC->Addr.CurrentMacAddress.a[0], - pAC->Addr.CurrentMacAddress.a[1], - pAC->Addr.CurrentMacAddress.a[2], - pAC->Addr.CurrentMacAddress.a[3], - pAC->Addr.CurrentMacAddress.a[4], - pAC->Addr.CurrentMacAddress.a[5])) + ("New logical MAC Address: %02X %02X %02X %02X %02X %02X\n", + pAC->Addr.CurrentMacAddress.a[0], + pAC->Addr.CurrentMacAddress.a[1], + pAC->Addr.CurrentMacAddress.a[2], + pAC->Addr.CurrentMacAddress.a[3], + pAC->Addr.CurrentMacAddress.a[4], + pAC->Addr.CurrentMacAddress.a[5])) #endif /* DEBUG */ /* Write address to first exact match entry of active port. */ - (void)SkAddrMcUpdate(pAC, IoC, PortIdx); } @@ -1066,25 +996,24 @@ * SK_ADDR_ILLEGAL_PORT */ int SkAddrPromiscuousChange( -SK_AC *pAC, /* adapter context */ -SK_IOC IoC, /* I/O context */ -SK_U32 PortIdx, /* port whose promiscuous mode changes */ -int NewPromMode) /* new promiscuous mode */ +SK_AC *pAC, /* adapter context */ +SK_IOC IoC, /* I/O context */ +SK_U32 PortIdx, /* port whose promiscuous mode changes */ +int NewPromMode) /* new promiscuous mode */ { - int i; + int i; SK_BOOL InexactModeBit; SK_U8 Inexact; SK_U8 HwInexact; SK_FILTER64 HwInexactFilter; SK_U16 LoMode; /* Lower 16 bits of XMAC Mode Register. */ - int CurPromMode = SK_PROM_MODE_NONE; + int CurPromMode = SK_PROM_MODE_NONE; if (PortIdx >= (SK_U32)pAC->GIni.GIMacsFound) { return (SK_ADDR_ILLEGAL_PORT); } /* Read CurPromMode from Hardware. */ - XM_IN16(IoC, PortIdx, XM_MODE, &LoMode); if (LoMode & XM_MD_ENA_PROM) { @@ -1095,18 +1024,15 @@ Inexact &= pAC->Addr.Port[PortIdx].InexactFilter.Bytes[i]; } if (Inexact == 0xFF) { - CurPromMode |= (pAC->Addr.Port[PortIdx].PromMode & - SK_PROM_MODE_ALL_MC); + CurPromMode |= (pAC->Addr.Port[PortIdx].PromMode & SK_PROM_MODE_ALL_MC); } else { /* Read InexactModeBit (bit 15 in mode register). */ - XM_IN16(IoC, PortIdx, XM_MODE, &LoMode); - - InexactModeBit = (LoMode & XM_MD_ENA_HSH) != 0; + + InexactModeBit = (LoMode & XM_MD_ENA_HSH) != 0; /* Read 64-bit hash register from HW. */ - XM_INHASH(IoC, PortIdx, XM_HSM, &HwInexactFilter.Bytes[0]); for (HwInexact = 0xFF, i = 0; i < 8; i++) { @@ -1126,43 +1052,34 @@ if ((NewPromMode & SK_PROM_MODE_ALL_MC) && !(CurPromMode & SK_PROM_MODE_ALL_MC)) { /* All MC. */ - /* Set all bits in 64-bit hash register. */ - XM_OUTHASH(IoC, PortIdx, XM_HSM, &OnesHash); /* Set bit 15 in mode register. */ - XM_IN16(IoC, PortIdx, XM_MODE, &LoMode); LoMode |= XM_MD_ENA_HSH; XM_OUT16(IoC, PortIdx, XM_MODE, LoMode); } else if ((CurPromMode & SK_PROM_MODE_ALL_MC) && !(NewPromMode & SK_PROM_MODE_ALL_MC)) { /* Norm MC. */ - for (Inexact = 0, i = 0; i < 8; i++) { - Inexact |= - pAC->Addr.Port[PortIdx].InexactFilter.Bytes[i]; + Inexact |= pAC->Addr.Port[PortIdx].InexactFilter.Bytes[i]; } if (Inexact == 0) { /* Clear bit 15 in mode register. */ - XM_IN16(IoC, PortIdx, XM_MODE, &LoMode); LoMode &= ~XM_MD_ENA_HSH; XM_OUT16(IoC, PortIdx, XM_MODE, LoMode); } else { /* Set 64-bit hash register to InexactFilter. */ - XM_OUTHASH( IoC, PortIdx, XM_HSM, - &pAC->Addr.Port[PortIdx - ].InexactFilter.Bytes[0]); + &pAC->Addr.Port[PortIdx].InexactFilter.Bytes[0]); /* Set bit 15 in mode register. */ - XM_IN16(IoC, PortIdx, XM_MODE, &LoMode); LoMode |= XM_MD_ENA_HSH; XM_OUT16(IoC, PortIdx, XM_MODE, LoMode); @@ -1171,29 +1088,27 @@ if ((NewPromMode & SK_PROM_MODE_LLC) && !(CurPromMode & SK_PROM_MODE_LLC)) { /* Prom. LLC */ - /* Set promiscuous bit in mode register. */ - XM_IN16(IoC, PortIdx, XM_MODE, &LoMode); + #if 0 /* Receive MAC frames. */ - LoMode |= XM_MD_RX_MCTRL; #endif /* 0 */ + LoMode |= XM_MD_ENA_PROM; XM_OUT16(IoC, PortIdx, XM_MODE, LoMode); } else if ((CurPromMode & SK_PROM_MODE_LLC) && !(NewPromMode & SK_PROM_MODE_LLC)) { /* Norm. LLC. */ - /* Clear promiscuous bit in mode register. */ - XM_IN16(IoC, PortIdx, XM_MODE, &LoMode); + #if 0 /* Don't receive MAC frames. */ - LoMode &= ~XM_MD_RX_MCTRL; #endif /* 0 */ + LoMode &= ~XM_MD_ENA_PROM; XM_OUT16(IoC, PortIdx, XM_MODE, LoMode); } @@ -1218,12 +1133,12 @@ * SK_ADDR_ILLEGAL_PORT */ int SkAddrSwap( -SK_AC *pAC, /* adapter context */ -SK_IOC IoC, /* I/O context */ +SK_AC *pAC, /* adapter context */ +SK_IOC IoC, /* I/O context */ SK_U32 FromPortIdx, /* Port1 Index */ -SK_U32 ToPortIdx) /* Port2 Index */ +SK_U32 ToPortIdx) /* Port2 Index */ { - int i; + int i; SK_U8 Byte; SK_MAC_ADDR MacAddr; SK_U32 DWord; @@ -1263,8 +1178,7 @@ } i = pAC->Addr.Port[FromPortIdx].PromMode; - pAC->Addr.Port[FromPortIdx].PromMode = - pAC->Addr.Port[ToPortIdx].PromMode; + pAC->Addr.Port[FromPortIdx].PromMode = pAC->Addr.Port[ToPortIdx].PromMode; pAC->Addr.Port[ToPortIdx].PromMode = i; DWord = pAC->Addr.Port[FromPortIdx].FirstExactMatchRlmt; @@ -1287,7 +1201,7 @@ pAC->Addr.Port[ToPortIdx].NextExactMatchDrv; pAC->Addr.Port[ToPortIdx].NextExactMatchDrv = DWord; - pAC->Addr.ActivePort = ToPortIdx; + pAC->Addr.ActivePort = ToPortIdx; (void)SkAddrMcUpdate(pAC, IoC, FromPortIdx); (void)SkAddrMcUpdate(pAC, IoC, ToPortIdx); @@ -1298,3 +1212,4 @@ #ifdef __cplusplus } #endif /* __cplusplus */ + diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/skcsum.c linux/drivers/net/sk98lin/skcsum.c --- v2.4.0-test8/linux/drivers/net/sk98lin/skcsum.c Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/skcsum.c Fri Sep 15 14:34:19 2000 @@ -2,19 +2,17 @@ * * Name: skcsum.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.3 $ - * Date: $Date: 1999/05/10 08:39:33 $ + * Version: $Revision: 1.7 $ + * Date: $Date: 2000/06/29 13:17:05 $ * Purpose: Store/verify Internet checksum in send/receive packets. * ******************************************************************************/ /****************************************************************************** * - * (C)Copyright 1998,1999 SysKonnect, + * (C)Copyright 1998-2000 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * - * See the file "skge.c" for further information. - * * 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 @@ -29,6 +27,23 @@ * History: * * $Log: skcsum.c,v $ + * Revision 1.7 2000/06/29 13:17:05 rassmann + * Corrected reception of a packet with UDP checksum == 0 (which means there + * is no UDP checksum). + * + * Revision 1.6 2000/02/21 12:35:10 cgoos + * Fixed license header comment. + * + * Revision 1.5 2000/02/21 11:05:19 cgoos + * Merged changes back to common source. + * Fixed rx path for BIG ENDIAN architecture. + * + * Revision 1.1 1999/07/26 15:28:12 mkarl + * added return SKCS_STATUS_IP_CSUM_ERROR_UDP and + * SKCS_STATUS_IP_CSUM_ERROR_TCP to pass the NidsTester + * changed from common source to windows specific source + * therefore restarting with v1.0 + * * Revision 1.3 1999/05/10 08:39:33 mkarl * prevent overflows in SKCS_HTON16 * fixed a bug in pseudo header checksum calculation @@ -48,7 +63,7 @@ #ifndef lint static const char SysKonnectFileId[] = "@(#)" - "$Id: skcsum.c,v 1.3 1999/05/10 08:39:33 mkarl Exp $" + "$Id: skcsum.c,v 1.7 2000/06/29 13:17:05 rassmann Exp $" " (C) SysKonnect."; #endif /* !lint */ @@ -94,13 +109,13 @@ /* defines ********************************************************************/ /* The size of an Ethernet MAC header. */ -#define SKCS_ETHERNET_MAC_HEADER_SIZE (6+6+2) +#define SKCS_ETHERNET_MAC_HEADER_SIZE (6+6+2) /* The size of the used topology's MAC header. */ #define SKCS_MAC_HEADER_SIZE SKCS_ETHERNET_MAC_HEADER_SIZE /* The size of the IP header without any option fields. */ -#define SKCS_IP_HEADER_SIZE 20 +#define SKCS_IP_HEADER_SIZE 20 /* * Field offsets within the IP header. @@ -110,23 +125,31 @@ #define SKCS_OFS_IP_HEADER_VERSION_AND_LENGTH 0 /* "Total Length". */ -#define SKCS_OFS_IP_TOTAL_LENGTH 2 +#define SKCS_OFS_IP_TOTAL_LENGTH 2 /* "Flags" "Fragment Offset". */ #define SKCS_OFS_IP_FLAGS_AND_FRAGMENT_OFFSET 6 /* "Next Level Protocol" identifier. */ -#define SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL 9 +#define SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL 9 /* Source IP address. */ -#define SKCS_OFS_IP_SOURCE_ADDRESS 12 +#define SKCS_OFS_IP_SOURCE_ADDRESS 12 /* Destination IP address. */ -#define SKCS_OFS_IP_DESTINATION_ADDRESS 16 +#define SKCS_OFS_IP_DESTINATION_ADDRESS 16 + + +/* + * Field offsets within the UDP header. + */ + +/* UDP checksum. */ +#define SKCS_OFS_UDP_CHECKSUM 6 /* IP "Next Level Protocol" identifiers (see RFC 790). */ -#define SKCS_PROTO_ID_TCP 6 /* Transport Control Protocol */ -#define SKCS_PROTO_ID_UDP 17 /* User Datagram Protocol */ +#define SKCS_PROTO_ID_TCP 6 /* Transport Control Protocol */ +#define SKCS_PROTO_ID_UDP 17 /* User Datagram Protocol */ /* IP "Don't Fragment" bit. */ #define SKCS_IP_DONT_FRAGMENT SKCS_HTON16(0x4000) @@ -224,8 +247,8 @@ * of the TCP or UDP pseudo header is returned here. */ void SkCsGetSendInfo( -SK_AC *pAc, /* Adapter context struct. */ -void *pIpHeader, /* IP header. */ +SK_AC *pAc, /* Adapter context struct. */ +void *pIpHeader, /* IP header. */ SKCS_PACKET_INFO *pPacketInfo) /* Packet information struct. */ { /* Internet Header Version found in IP header. */ @@ -397,7 +420,8 @@ SKCS_OC_ADD(pPacketInfo->PseudoHeaderChecksum, PseudoHeaderChecksum, 0); NextLevelProtoStats->TxOkCts++; /* Success. */ -} +} /* SkCsGetSendInfo */ + /****************************************************************************** * @@ -415,7 +439,8 @@ * pAc - Pointer to adapter context struct. * * pIpHeader - Pointer to IP header. Must be at least the length in bytes - * of the received IP header including any option fields. + * of the received IP header including any option fields. For UDP packets, + * 8 additional bytes are needed to access the UDP checksum. * * Note: The actual length of the IP header is stored in the lower four * bits of the first octet of the IP header as the number of 4-byte words, @@ -431,18 +456,20 @@ * Returns: * SKCS_STATUS_UNKNOWN_IP_VERSION - Not an IP v4 frame. * SKCS_STATUS_IP_CSUM_ERROR - IP checksum error. + * SKCS_STATUS_IP_CSUM_ERROR_TCP - IP checksum error in TCP frame. + * SKCS_STATUS_IP_CSUM_ERROR_UDP - IP checksum error in UDP frame * SKCS_STATUS_IP_FRAGMENT - IP fragment (IP checksum ok). * SKCS_STATUS_IP_CSUM_OK - IP checksum ok (not a TCP or UDP frame). * SKCS_STATUS_TCP_CSUM_ERROR - TCP checksum error (IP checksum ok). * SKCS_STATUS_UDP_CSUM_ERROR - UDP checksum error (IP checksum ok). * SKCS_STATUS_TCP_CSUM_OK - IP and TCP checksum ok. * SKCS_STATUS_UDP_CSUM_OK - IP and UDP checksum ok. + * SKCS_STATUS_IP_CSUM_OK_NO_UDP - IP checksum OK and no UDP checksum. * - * Note: The SKCS_STATUS_XXX values returned here are *not* defined by - * the CSUM module but must be defined in some header file by the module - * using CSUM. In this way, the calling module can assign return values - * for its own needs, e.g. by assigning bit flags to the individual - * protocols. + * Note: If SKCS_OVERWRITE_STATUS is defined, the SKCS_STATUS_XXX values + * returned here can be defined in some header file by the module using CSUM. + * In this way, the calling module can assign return values for its own needs, + * e.g. by assigning bit flags to the individual protocols. */ SKCS_STATUS SkCsGetReceiveInfo( SK_AC *pAc, /* Adapter context struct. */ @@ -544,30 +571,36 @@ /* Adjust the IP header and IP data checksums. */ - SKCS_OC_ADD(IpHeaderChecksum, - IpHeaderChecksum, IpOptionsChecksum); + SKCS_OC_ADD(IpHeaderChecksum, IpHeaderChecksum, IpOptionsChecksum); - SKCS_OC_SUB(IpDataChecksum, - IpDataChecksum, IpOptionsChecksum); + SKCS_OC_SUB(IpDataChecksum, IpDataChecksum, IpOptionsChecksum); } - /* Check if the IP header checksum is ok. */ /* - * NOTE: We must check the IP header checksum even if the caller does - * not want us to do so because we cannot do any further processing of - * the packet without a valid IP checksum. + * Check if the IP header checksum is ok. + * + * NOTE: We must check the IP header checksum even if the caller just wants + * us to check upper-layer checksums, because we cannot do any further + * processing of the packet without a valid IP checksum. */ + + /* Get the next level protocol identifier. */ + + NextLevelProtocol = *(SK_U8 *) + SKCS_IDX(pIpHeader, SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL); if (IpHeaderChecksum != 0xFFFF) { pAc->Csum.ProtoStats[SKCS_PROTO_STATS_IP].RxErrCts++; + /* the NDIS tester wants to know the upper level protocol too */ + if (NextLevelProtocol == SKCS_PROTO_ID_TCP) { + return(SKCS_STATUS_IP_CSUM_ERROR_TCP); + } + else if (NextLevelProtocol == SKCS_PROTO_ID_UDP) { + return(SKCS_STATUS_IP_CSUM_ERROR_UDP); + } return (SKCS_STATUS_IP_CSUM_ERROR); } - /* Get the next level protocol identifier. */ - - NextLevelProtocol = - *(SK_U8 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL); - /* * Check if this is a TCP or UDP frame and if we should calculate the * TCP/UDP pseudo header checksum. @@ -579,14 +612,12 @@ if ((pAc->Csum.ReceiveFlags & SKCS_PROTO_TCP) != 0 && NextLevelProtocol == SKCS_PROTO_ID_TCP) { /* TCP/IP frame. */ - NextLevelProtoStats = - &pAc->Csum.ProtoStats[SKCS_PROTO_STATS_TCP]; + NextLevelProtoStats = &pAc->Csum.ProtoStats[SKCS_PROTO_STATS_TCP]; } else if ((pAc->Csum.ReceiveFlags & SKCS_PROTO_UDP) != 0 && NextLevelProtocol == SKCS_PROTO_ID_UDP) { /* UDP/IP frame. */ - NextLevelProtoStats = - &pAc->Csum.ProtoStats[SKCS_PROTO_STATS_UDP]; + NextLevelProtoStats = &pAc->Csum.ProtoStats[SKCS_PROTO_STATS_UDP]; } else { /* @@ -615,6 +646,24 @@ } /* + * 08-May-2000 ra + * + * From RFC 768 (UDP) + * If the computed checksum is zero, it is transmitted as all ones (the + * equivalent in one's complement arithmetic). An all zero transmitted + * checksum value means that the transmitter generated no checksum (for + * debugging or for higher level protocols that don't care). + */ + + if (NextLevelProtocol == SKCS_PROTO_ID_UDP && + *(SK_U16*)SKCS_IDX(pIpHeader, IpHeaderLength + 6) == 0x0000) { + + NextLevelProtoStats->RxOkCts++; + + return (SKCS_STATUS_IP_CSUM_OK_NO_UDP); + } + + /* * Calculate the TCP/UDP checksum. */ @@ -639,7 +688,7 @@ SKCS_OFS_IP_DESTINATION_ADDRESS + 0) + (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_DESTINATION_ADDRESS + 2) + - (unsigned long) (NextLevelProtocol << 8) + + (unsigned long) SKCS_HTON16(NextLevelProtocol) + (unsigned long) SKCS_HTON16(IpDataLength) + /* Add the TCP/UDP header checksum. */ @@ -672,7 +721,8 @@ return (NextLevelProtocol == SKCS_PROTO_ID_TCP ? SKCS_STATUS_TCP_CSUM_ERROR : SKCS_STATUS_UDP_CSUM_ERROR); -} +} /* SkCsGetReceiveInfo */ + /****************************************************************************** * @@ -702,7 +752,7 @@ * Returns the two hardware checksum start offsets. */ void SkCsSetReceiveFlags( -SK_AC *pAc, /* Adapter context struct. */ +SK_AC *pAc, /* Adapter context struct. */ unsigned ReceiveFlags, /* New receive flags. */ unsigned *pChecksum1Offset, /* Offset for hardware checksum 1. */ unsigned *pChecksum2Offset) /* Offset for hardware checksum 2. */ @@ -719,9 +769,10 @@ * if there are any IP header options in the actual packet. */ *pChecksum2Offset = SKCS_MAC_HEADER_SIZE + SKCS_IP_HEADER_SIZE; -} +} /* SkCsSetReceiveFlags */ #ifndef SkCsCalculateChecksum + /****************************************************************************** * * SkCsCalculateChecksum - calculate checksum for specified data @@ -783,7 +834,8 @@ /* Note: All bits beyond the 16-bit limit are now zero. */ return ((unsigned) Checksum); -} +} /* SkCsCalculateChecksum */ + #endif /* SkCsCalculateChecksum */ /****************************************************************************** @@ -833,7 +885,7 @@ memset(&pAc->Csum.ProtoStats[0], 0, sizeof(pAc->Csum.ProtoStats)); } - else { /* Clear for individual protocol. */ + else { /* Clear for individual protocol. */ memset(&pAc->Csum.ProtoStats[ProtoIndex], 0, sizeof(pAc->Csum.ProtoStats[ProtoIndex])); } @@ -842,6 +894,6 @@ break; } return (0); /* Success. */ -} +} /* SkCsEvent */ #endif /* SK_USE_CSUM */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/skge.c linux/drivers/net/sk98lin/skge.c --- v2.4.0-test8/linux/drivers/net/sk98lin/skge.c Wed Aug 9 19:19:50 2000 +++ linux/drivers/net/sk98lin/skge.c Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skge.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.27 $ - * Date: $Date: 1999/11/25 09:06:28 $ + * Version: $Revision: 1.29 $ + * Date: $Date: 2000/02/21 13:31:56 $ * Purpose: The main driver source module * ******************************************************************************/ @@ -46,6 +46,25 @@ * History: * * $Log: skge.c,v $ + * Kernel 2.4.x specific: + * Revision 1.xx 2000/09/12 13:31:56 cgoos + * Fixed missign "dev=NULL in skge_probe. + * Added counting for jumbo frames (corrects error statistic). + * Removed VLAN tag check (enables VLAN support). + * + * Kernel 2.2.x specific: + * Revision 1.29 2000/02/21 13:31:56 cgoos + * Fixed "unused" warning for UltraSPARC change. + * + * Partially kernel 2.2.x specific: + * Revision 1.28 2000/02/21 10:32:36 cgoos + * Added fixes for UltraSPARC. + * Now printing RlmtMode and PrefPort setting at startup. + * Changed XmitFrame return value. + * Fixed rx checksum calculation for BIG ENDIAN systems. + * Fixed rx jumbo frames counted as ierrors. + * + * * Revision 1.27 1999/11/25 09:06:28 cgoos * Changed base_addr to unsigned long. * @@ -225,7 +244,7 @@ static const char SysKonnectFileId[] = "@(#)" __FILE__ " (C) SysKonnect."; static const char SysKonnectBuildNumber[] = - "@(#)SK-BUILD: 3.02 (19991111) PL: 01"; + "@(#)SK-BUILD: 3.05 (20000907) PL: 01"; #include #include @@ -235,10 +254,10 @@ /* defines ******************************************************************/ -#define BOOT_STRING "sk98lin: Network Device Driver v3.02\n" \ - "Copyright (C) 1999 SysKonnect" +#define BOOT_STRING "sk98lin: Network Device Driver v3.05\n" \ + "Copyright (C) 1999-2000 SysKonnect" -#define VER_STRING "3.02" +#define VER_STRING "3.05" /* for debuging on x86 only */ @@ -373,6 +392,8 @@ PCI_DEVICE_ID_SYSKONNECT_GE, pdev)) != NULL) { if (pci_enable_device(pdev)) continue; + + dev = NULL; dev = init_etherdev(dev, sizeof(SK_AC)); if (dev == NULL) { @@ -785,6 +806,14 @@ ProductStr(pAC); printk("%s: %s\n", dev->name, pAC->DeviceStr); + /* Print configuration settings */ + printk(" PrefPort:%c RlmtMode:%s\n", + 'A' + pAC->Rlmt.PrefPort, + (pAC->RlmtMode==0) ? "ChkLink" : + ((pAC->RlmtMode==1) ? "ChkLink" : + ((pAC->RlmtMode==3) ? "ChkOth" : + ((pAC->RlmtMode==7) ? "ChkSeg" : "Error")))); + SkGeYellowLED(pAC, pAC->IoBase, 1); /* @@ -1936,6 +1965,10 @@ } /* frame > SK_COPY_TRESHOLD */ FrameStat = pRxd->FrameStat; + if ((FrameStat & XMR_FS_LNG_ERR) != 0) { + /* jumbo frame, count to correct statistic */ + SK_PNMI_CNT_RX_LONGFRAMES(pAC, pRxPort->PortIndex); + } pRxd = pRxd->pNextRxd; pRxPort->pRxdRingHead = pRxd; pRxPort->RxdRingFree ++; @@ -1947,9 +1980,9 @@ pRxPort->RxdRingFree)); if ((Control & RX_CTRL_STAT_VALID) == RX_CTRL_STAT_VALID && - (FrameStat & - (XMR_FS_ANY_ERR | XMR_FS_1L_VLAN | XMR_FS_2L_VLAN)) - == 0) { + (FrameStat & XMR_FS_ANY_ERR) == 0) { + // was the following, changed to allow VLAN support + // (XMR_FS_ANY_ERR | XMR_FS_1L_VLAN | XMR_FS_2L_VLAN) SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_RX_PROGRESS,("V")); ForRlmt = SK_RLMT_RX_PROTOCOL; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/skgehwt.c linux/drivers/net/sk98lin/skgehwt.c --- v2.4.0-test8/linux/drivers/net/sk98lin/skgehwt.c Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/skgehwt.c Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skgehwt.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.12 $ - * Date: $Date: 1998/10/15 15:11:34 $ + * Version: $Revision: 1.13 $ + * Date: $Date: 1999/11/22 13:31:12 $ * Purpose: Hardware Timer. * ******************************************************************************/ @@ -13,8 +13,6 @@ * (C)Copyright 1998,1999 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * - * See the file "skge.c" for further information. - * * 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 @@ -29,6 +27,9 @@ * History: * * $Log: skgehwt.c,v $ + * Revision 1.13 1999/11/22 13:31:12 cgoos + * Changed license header to GPL. + * * Revision 1.12 1998/10/15 15:11:34 gklug * fix: ID_sccs to SysKonnectFileId * @@ -76,7 +77,7 @@ Event queue and dispatcher */ static const char SysKonnectFileId[] = - "$Header: /usr56/projects/ge/schedule/skgehwt.c,v 1.12 1998/10/15 15:11:34 gklug Exp $" ; + "$Header: /usr56/projects/ge/schedule/skgehwt.c,v 1.13 1999/11/22 13:31:12 cgoos Exp $" ; #include "h/skdrv1st.h" /* Driver Specific Definitions */ #include "h/skdrv2nd.h" /* Adapter Control- and Driver specific Def. */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/skgeinit.c linux/drivers/net/sk98lin/skgeinit.c --- v2.4.0-test8/linux/drivers/net/sk98lin/skgeinit.c Tue Nov 23 22:42:20 1999 +++ linux/drivers/net/sk98lin/skgeinit.c Fri Sep 15 14:34:19 2000 @@ -2,19 +2,17 @@ * * Name: skgeinit.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.54 $ - * Date: $Date: 1999/10/26 07:32:54 $ + * Version: $Revision: 1.57 $ + * Date: $Date: 2000/08/03 14:55:28 $ * Purpose: Contains functions to initialize the GE HW * ******************************************************************************/ /****************************************************************************** * - * (C)Copyright 1998,1999 SysKonnect, + * (C)Copyright 1998-2000 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * - * See the file "skge.c" for further information. - * * 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 @@ -29,6 +27,16 @@ * History: * * $Log: skgeinit.c,v $ + * Revision 1.57 2000/08/03 14:55:28 rassmann + * Waiting for I2C to be ready before de-initializing adapter + * (prevents sensors from hanging up). + * + * Revision 1.56 2000/07/27 12:16:48 gklug + * fix: Stop Port check of the STOP bit does now take 2/18 sec as wanted + * + * Revision 1.55 1999/11/22 13:32:26 cgoos + * Changed license header to GPL. + * * Revision 1.54 1999/10/26 07:32:54 malthoff * Initialize PHWLinkUp with SK_FALSE. Required for Diagnostics. * @@ -199,7 +207,7 @@ * DoInitRamQueue(), and SkGeCfgSync(). * Add coding for SkGeInitMacArb(), SkGeInitPktArb(), * SkGeInitMacFifo(), SkGeInitRamBufs(), - * SkGeInitRamIface(), and SkGeInitBmu(). + * SkGeInitRamIface(), and SkGeInitBmu(). * * Revision 1.11 1998/09/29 08:26:29 malthoff * bug fix: SkGeInit0() 'i' should be increment. @@ -275,7 +283,7 @@ /* local variables ************************************************************/ static const char SysKonnectFileId[] = - "@(#)$Id: skgeinit.c,v 1.54 1999/10/26 07:32:54 malthoff Exp $ (C) SK "; + "@(#)$Id: skgeinit.c,v 1.57 2000/08/03 14:55:28 rassmann Exp $ (C) SK "; struct s_QOffTab { int RxQOff; /* Receive Queue Address Offset */ @@ -283,7 +291,7 @@ int XaQOff; /* Async Tx Queue Address Offset */ }; static struct s_QOffTab QOffTab[] = { - { Q_R1, Q_XS1, Q_XA1 }, { Q_R2, Q_XS2, Q_XA2 } + {Q_R1, Q_XS1, Q_XA1}, {Q_R2, Q_XS2, Q_XA2} }; @@ -303,7 +311,7 @@ void SkGePollRxD( SK_AC *pAC, /* adapter context */ SK_IOC IoC, /* IO context */ -int Port, /* Port Index (MAC_1 + n) */ +int Port, /* Port Index (MAC_1 + n) */ SK_BOOL PollRxD) /* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */ { SK_GEPORT *pPrt; @@ -311,12 +319,13 @@ pPrt = &pAC->GIni.GP[Port]; if (PollRxD) { - SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff,Q_CSR), CSR_ENA_POL); + SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_ENA_POL); } else { - SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff,Q_CSR), CSR_DIS_POL); + SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_DIS_POL); } -} +} /* SkGePollRxD */ + /****************************************************************************** * @@ -334,7 +343,7 @@ void SkGePollTxD( SK_AC *pAC, /* adapter context */ SK_IOC IoC, /* IO context */ -int Port, /* Port Index (MAC_1 + n) */ +int Port, /* Port Index (MAC_1 + n) */ SK_BOOL PollTxD) /* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */ { SK_GEPORT *pPrt; @@ -350,12 +359,12 @@ } if (pPrt->PXSQSize != 0) { - SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff,Q_CSR), DWord); + SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), DWord); } if (pPrt->PXAQSize != 0) { - SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff,Q_CSR), DWord); + SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), DWord); } -} +} /* SkGePollTxD */ /****************************************************************************** @@ -374,17 +383,18 @@ void SkGeYellowLED( SK_AC *pAC, /* adapter context */ SK_IOC IoC, /* IO context */ -int State) /* yellow LED state, 0 = OFF, 0 != ON */ +int State) /* yellow LED state, 0 = OFF, 0 != ON */ { if (State == 0) { /* Switch yellow LED OFF */ - SK_OUT8(IoC, B0_LED, LED_STAT_OFF) ; + SK_OUT8(IoC, B0_LED, LED_STAT_OFF); } else { /* Switch yellow LED ON */ - SK_OUT8(IoC, B0_LED, LED_STAT_ON) ; + SK_OUT8(IoC, B0_LED, LED_STAT_ON); } -} +} /* SkGeYellowLED */ + /****************************************************************************** * @@ -398,7 +408,7 @@ * 'Led' must contain the address offset of the LEDs INI register. * * Usage: - * SkGeXmitLED(pAC, IoC, MR_ADDR(Port,TX_LED_INI), SK_LED_ENA); + * SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_ENA); * * Returns: * nothing @@ -406,31 +416,31 @@ void SkGeXmitLED( SK_AC *pAC, /* adapter context */ SK_IOC IoC, /* IO context */ -int Led, /* offset to the LED Init Value register */ -int Mode) /* Mode may be SK_LED_DIS, SK_LED_ENA, SK_LED_TST */ +int Led, /* offset to the LED Init Value register */ +int Mode) /* Mode may be SK_LED_DIS, SK_LED_ENA, SK_LED_TST */ { SK_U32 LedIni; switch (Mode) { case SK_LED_ENA: LedIni = SK_XMIT_DUR * (SK_U32)pAC->GIni.GIHstClkFact / 100; - SK_OUT32(IoC, Led+XMIT_LED_INI, LedIni); - SK_OUT8(IoC, Led+XMIT_LED_CTRL, LED_START); - break ; + SK_OUT32(IoC, Led + XMIT_LED_INI, LedIni); + SK_OUT8(IoC, Led + XMIT_LED_CTRL, LED_START); + break; case SK_LED_TST: - SK_OUT8(IoC, Led+XMIT_LED_TST, LED_T_ON); - SK_OUT32(IoC, Led+XMIT_LED_CNT, 100); - SK_OUT8(IoC, Led+XMIT_LED_CTRL, LED_START); - break ; + SK_OUT8(IoC, Led + XMIT_LED_TST, LED_T_ON); + SK_OUT32(IoC, Led + XMIT_LED_CNT, 100); + SK_OUT8(IoC, Led + XMIT_LED_CTRL, LED_START); + break; case SK_LED_DIS: default: /* * Do NOT stop the LED Timer here. The LED might be * in on state. But it needs to go off. */ - SK_OUT32(IoC, Led+XMIT_LED_CNT, 0); - SK_OUT8(IoC, Led+XMIT_LED_TST, LED_T_OFF); - break ; + SK_OUT32(IoC, Led + XMIT_LED_CNT, 0); + SK_OUT8(IoC, Led + XMIT_LED_TST, LED_T_OFF); + break; } /* @@ -440,7 +450,8 @@ * (Broadcom: It may be that PHY_B_PEC_EN_LTR has to be set.) * (In this case it has to be added here. But we will see. XXX) */ -} +} /* SkGeXmitLED */ + /****************************************************************************** * @@ -461,12 +472,12 @@ * 1: configuration error */ static int DoCalcAddr( -SK_AC *pAC, /* adapter context */ -SK_GEPORT *pPrt, /* port index */ -int QuSize, /* size of the queue to configure in kB */ -SK_U32 *StartVal, /* start value for address calculation */ -SK_U32 *QuStartAddr, /* start addr to calculate */ -SK_U32 *QuEndAddr) /* end address to calculate */ +SK_AC *pAC, /* adapter context */ +SK_GEPORT *pPrt, /* port index */ +int QuSize, /* size of the queue to configure in kB */ +SK_U32 *StartVal, /* start value for address calculation */ +SK_U32 *QuStartAddr, /* start addr to calculate */ +SK_U32 *QuEndAddr) /* end address to calculate */ { SK_U32 EndVal; SK_U32 NextStart; @@ -494,7 +505,7 @@ *StartVal = NextStart; return (Rtv); -} +} /* DoCalcAddr */ /****************************************************************************** @@ -521,8 +532,8 @@ * 1: Queue Size Configuration invalid */ static int SkGeCheckQSize( -SK_AC *pAC, /* adapter context */ -int Port) /* port index */ +SK_AC *pAC, /* adapter context */ +int Port) /* port index */ { SK_GEPORT *pPrt; int UsedMem; @@ -540,9 +551,7 @@ (pPrt->PXSQSize & QZ_UNITS) || (pPrt->PXAQSize & QZ_UNITS)) { - SK_ERR_LOG(pAC, SK_ERRCL_SW, - SKERR_HWI_E012, - SKERR_HWI_E012MSG); + SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E012, SKERR_HWI_E012MSG); Rtv = 1; goto CheckQSizeEnd; } @@ -550,9 +559,7 @@ UsedMem += pPrt->PRxQSize + pPrt->PXSQSize + pPrt->PXAQSize; if (i == Port && pPrt->PRxQSize < SK_MIN_RXQ_SIZE) { - SK_ERR_LOG(pAC, SK_ERRCL_SW, - SKERR_HWI_E011, - SKERR_HWI_E011MSG); + SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E011, SKERR_HWI_E011MSG); Rtv = 1; goto CheckQSizeEnd; } @@ -584,17 +591,15 @@ Rtv |= Rtv2; if (Rtv) { - SK_ERR_LOG(pAC, SK_ERRCL_SW, - SKERR_HWI_E013, - SKERR_HWI_E013MSG); + SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E013, SKERR_HWI_E013MSG); break; } } - CheckQSizeEnd: return (Rtv); -} +} /* SkGeCheckQSize */ + /****************************************************************************** * @@ -633,7 +638,8 @@ * There is not start or enable buttom to push, therefore * the MAC arbiter is configured and enabled now. */ -} +} /* SkGeInitMacArb */ + /****************************************************************************** * @@ -666,10 +672,11 @@ SK_OUT16(IoC, B3_PA_CTRL, PA_ENA_TO_TX1); } else { - SK_OUT16(IoC, B3_PA_CTRL,(PA_ENA_TO_TX1|PA_ENA_TO_TX2)); + SK_OUT16(IoC, B3_PA_CTRL,(PA_ENA_TO_TX1 | PA_ENA_TO_TX2)); } } -} +} /* SkGeInitPktArb */ + /****************************************************************************** * @@ -684,7 +691,7 @@ static void SkGeInitMacFifo( SK_AC *pAC, /* adapter context */ SK_IOC IoC, /* IO context */ -int Port) /* Port Index (MAC_1 + n) */ +int Port) /* Port Index (MAC_1 + n) */ { /* * For each FIFO: @@ -707,7 +714,8 @@ if (pAC->GIni.GIPortUsage == SK_JUMBO_LINK) { SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_ENA_FLUSH); } -} +} /* SkGeInitMacFifo */ + /****************************************************************************** * @@ -731,7 +739,7 @@ void SkGeLoadLnkSyncCnt( SK_AC *pAC, /* adapter context */ SK_IOC IoC, /* IO context */ -int Port, /* Port Index (MAC_1 + n) */ +int Port, /* Port Index (MAC_1 + n) */ SK_U32 CntVal) /* Counter value */ { SK_U32 OrgIMsk; @@ -740,7 +748,7 @@ SK_BOOL IrqPend; /* stop counter */ - SK_OUT8(IoC, MR_ADDR(Port,LNK_SYNC_CTRL), LED_STOP); + SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_STOP); /* * ASIC problem: @@ -770,17 +778,18 @@ } /* load counter */ - SK_OUT32(IoC, MR_ADDR(Port,LNK_SYNC_INI), CntVal); + SK_OUT32(IoC, MR_ADDR(Port, LNK_SYNC_INI), CntVal); /* start counter */ - SK_OUT8(IoC, MR_ADDR(Port,LNK_SYNC_CTRL), LED_START); + SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_START); if (!IrqPend) { /* clear the unexpected IRQ, and restore the interrupt mask */ - SK_OUT8(IoC, MR_ADDR(Port,LNK_SYNC_CTRL), LED_CLR_IRQ); + SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_CLR_IRQ); SK_OUT32(IoC, B0_IMSK, OrgIMsk); } -} +} /* SkGeLoadLnkSyncCnt*/ + /****************************************************************************** * @@ -813,10 +822,10 @@ int SkGeCfgSync( SK_AC *pAC, /* adapter context */ SK_IOC IoC, /* IO context */ -int Port, /* Port Index (MAC_1 + n) */ +int Port, /* Port Index (MAC_1 + n) */ SK_U32 IntTime, /* Interval Timer Value in units of 8ns */ SK_U32 LimCount, /* Number of bytes to transfer during IntTime */ -int SyncMode) /* Sync Mode: TXA_ENA_ALLOC | TXA_DIS_ALLOC | 0 */ +int SyncMode) /* Sync Mode: TXA_ENA_ALLOC | TXA_DIS_ALLOC | 0 */ { int Rtv; @@ -836,8 +845,7 @@ IntTime = (IntTime / 2) * pAC->GIni.GIHstClkFact / 100; LimCount = LimCount / 8; if (IntTime > TXA_MAX_VAL || LimCount > TXA_MAX_VAL) { - SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E010, - SKERR_HWI_E010MSG); + SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E010, SKERR_HWI_E010MSG); Rtv = 1; goto CfgSyncEnd; } @@ -852,14 +860,14 @@ * - start 'Rate Control' and disable 'Force Sync' * if Interval Timer or Limit Counter not zero. */ - SK_OUT8(IoC, MR_ADDR(Port,TXA_CTRL), + SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL), TXA_ENA_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC); - SK_OUT32(IoC, MR_ADDR(Port,TXA_ITI_INI), IntTime); - SK_OUT32(IoC, MR_ADDR(Port,TXA_LIM_INI), LimCount); - SK_OUT8(IoC, MR_ADDR(Port,TXA_CTRL), + SK_OUT32(IoC, MR_ADDR(Port, TXA_ITI_INI), IntTime); + SK_OUT32(IoC, MR_ADDR(Port, TXA_LIM_INI), LimCount); + SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL), (SyncMode & (TXA_ENA_ALLOC|TXA_DIS_ALLOC))); if (IntTime != 0 || LimCount != 0) { - SK_OUT8(IoC, MR_ADDR(Port,TXA_CTRL), + SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL), TXA_DIS_FSYNC|TXA_START_RC); } } @@ -870,7 +878,8 @@ CfgSyncEnd: return (Rtv); -} +} /* SkGeCfgSync */ + /****************************************************************************** * @@ -884,12 +893,12 @@ * nothing */ static void DoInitRamQueue( -SK_AC *pAC, /* adapter context */ -SK_IOC IoC, /* IO context */ -int QuIoOffs, /* Queue IO Address Offset */ +SK_AC *pAC, /* adapter context */ +SK_IOC IoC, /* IO context */ +int QuIoOffs, /* Queue IO Address Offset */ SK_U32 QuStartAddr, /* Queue Start Address */ -SK_U32 QuEndAddr, /* Queue End Address */ -int QuType) /* Queue Type (SK_RX_SRAM_Q|SK_RX_BRAM_Q|SK_TX_RAM_Q) */ +SK_U32 QuEndAddr, /* Queue End Address */ +int QuType) /* Queue Type (SK_RX_SRAM_Q|SK_RX_BRAM_Q|SK_TX_RAM_Q) */ { SK_U32 RxUpThresVal; SK_U32 RxLoThresVal; @@ -904,13 +913,13 @@ QuEndAddr = QuEndAddr / 8; /* release local reset */ - SK_OUT8(IoC, RB_ADDR(QuIoOffs,RB_CTRL), RB_RST_CLR); + SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_RST_CLR); /* configure addresses */ - SK_OUT32(IoC, RB_ADDR(QuIoOffs,RB_START), QuStartAddr); - SK_OUT32(IoC, RB_ADDR(QuIoOffs,RB_END), QuEndAddr); - SK_OUT32(IoC, RB_ADDR(QuIoOffs,RB_WP), QuStartAddr); - SK_OUT32(IoC, RB_ADDR(QuIoOffs,RB_RP), QuStartAddr); + SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_START), QuStartAddr); + SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_END), QuEndAddr); + SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_WP), QuStartAddr); + SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RP), QuStartAddr); switch (QuType) { case SK_RX_SRAM_Q: @@ -921,10 +930,9 @@ case SK_RX_BRAM_Q: /* write threshold for Rx Queue */ - SK_OUT32(IoC, RB_ADDR(QuIoOffs,RB_RX_UTPP), - RxUpThresVal); - SK_OUT32(IoC, RB_ADDR(QuIoOffs,RB_RX_LTPP), - RxLoThresVal); + SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RX_UTPP), RxUpThresVal); + SK_OUT32(IoC, RB_ADDR(QuIoOffs,RB_RX_LTPP), RxLoThresVal); + /* the high priority threshold not used */ break; case SK_TX_RAM_Q: @@ -939,20 +947,20 @@ * enable Store & Forward Mode for the * Tx Side */ - SK_OUT8(IoC, RB_ADDR(QuIoOffs,RB_CTRL), - RB_ENA_STFWD); + SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_ENA_STFWD); } break; } /* set queue operational */ - SK_OUT8(IoC, RB_ADDR(QuIoOffs,RB_CTRL), RB_ENA_OP_MD); + SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_ENA_OP_MD); } else { /* ensure the queue is still disabled */ - SK_OUT8(IoC, RB_ADDR(QuIoOffs,RB_CTRL), RB_RST_SET); + SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_RST_SET); } -} +} /* DoInitRamQueue*/ + /****************************************************************************** * @@ -967,7 +975,7 @@ static void SkGeInitRamBufs( SK_AC *pAC, /* adapter context */ SK_IOC IoC, /* IO context */ -int Port) /* Port Index (MAC_1 + n) */ +int Port) /* Port Index (MAC_1 + n) */ { SK_GEPORT *pPrt; int RxQType; @@ -987,7 +995,8 @@ pPrt->PXsQRamEnd, SK_TX_RAM_Q); DoInitRamQueue(pAC, IoC, pPrt->PXaQOff, pPrt->PXaQRamStart, pPrt->PXaQRamEnd, SK_TX_RAM_Q); -} +} /* SkGeInitRamBufs */ + /****************************************************************************** * @@ -1022,7 +1031,8 @@ SK_OUT8(IoC, B3_RI_RTO_R2, SK_RI_TO_53); SK_OUT8(IoC, B3_RI_RTO_XA2, SK_RI_TO_53); SK_OUT8(IoC, B3_RI_RTO_XS2, SK_RI_TO_53); -} +} /* SkGeInitRamIface */ + /****************************************************************************** * @@ -1037,33 +1047,34 @@ static void SkGeInitBmu( SK_AC *pAC, /* adapter context */ SK_IOC IoC, /* IO context */ -int Port) /* Port Index (MAC_1 + n) */ +int Port) /* Port Index (MAC_1 + n) */ { SK_GEPORT *pPrt; pPrt = &pAC->GIni.GP[Port]; /* Rx Queue: Release all local resets and set the watermark */ - SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff,Q_CSR), CSR_CLR_RESET); - SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff,Q_F), SK_BMU_RX_WM); + SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_CLR_RESET); + SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_F), SK_BMU_RX_WM); /* * Tx Queue: Release all local resets if the queue is used! * set watermark */ if (pPrt->PXSQSize != 0) { - SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff,Q_CSR), CSR_CLR_RESET); - SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff,Q_F), SK_BMU_TX_WM); + SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_CLR_RESET); + SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_F), SK_BMU_TX_WM); } if (pPrt->PXAQSize != 0) { - SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff,Q_CSR), CSR_CLR_RESET); - SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff,Q_F), SK_BMU_TX_WM); + SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_CLR_RESET); + SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_F), SK_BMU_TX_WM); } /* * Do NOT enable the descriptor poll timers here, because * the descriptor addresses are not specified yet. */ -} +} /* SkGeInitBmu */ + /****************************************************************************** * @@ -1081,17 +1092,18 @@ static SK_U32 TestStopBit( SK_AC *pAC, /* Adapter Context */ SK_IOC IoC, /* IO Context */ -int QuIoOffs) /* Queue IO Address Offset */ +int QuIoOffs) /* Queue IO Address Offset */ { SK_U32 QuCsr; /* CSR contents */ - SK_IN32(IoC, Q_ADDR(QuIoOffs,Q_CSR), &QuCsr); + SK_IN32(IoC, Q_ADDR(QuIoOffs, Q_CSR), &QuCsr); if ((QuCsr & (CSR_STOP|CSR_SV_IDLE)) == 0) { - SK_OUT32(IoC, Q_ADDR(QuIoOffs,Q_CSR), CSR_STOP); - SK_IN32(IoC, Q_ADDR(QuIoOffs,Q_CSR), &QuCsr); + SK_OUT32(IoC, Q_ADDR(QuIoOffs, Q_CSR), CSR_STOP); + SK_IN32(IoC, Q_ADDR(QuIoOffs, Q_CSR), &QuCsr); } return (QuCsr); -} +} /* TestStopBit*/ + /****************************************************************************** * @@ -1173,10 +1185,10 @@ */ void SkGeStopPort( SK_AC *pAC, /* adapter context */ -SK_IOC IoC, /* IO context */ -int Port, /* port to stop (MAC_1 + n) */ -int Dir, /* Direction to Stop (SK_STOP_RX, SK_STOP_TX, SK_STOP_ALL) */ -int RstMode)/* Reset Mode (SK_SOFT_RST, SK_HARD_RST) */ +SK_IOC IoC, /* I/O context */ +int Port, /* port to stop (MAC_1 + n) */ +int Dir, /* Direction to Stop (SK_STOP_RX, SK_STOP_TX, SK_STOP_ALL) */ +int RstMode)/* Reset Mode (SK_SOFT_RST, SK_HARD_RST) */ { #ifndef SK_DIAG SK_EVPARA Para; @@ -1196,8 +1208,7 @@ if (Dir & SK_STOP_TX) { /* disable the XMACs receiver and transmitter */ XM_IN16(IoC, Port, XM_MMU_CMD, &Word); - XM_OUT16(IoC, Port, XM_MMU_CMD, - Word & ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX)); + XM_OUT16(IoC, Port, XM_MMU_CMD, Word & ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX)); /* dummy read to ensure writing */ XM_IN16(IoC, Port, XM_MMU_CMD, &Word); @@ -1207,8 +1218,8 @@ * If the BMU is in the reset state CSR_STOP will terminate * immediately. */ - SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff,Q_CSR), CSR_STOP); - SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff,Q_CSR), CSR_STOP); + SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_STOP); + SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_STOP); ToutStart = SkOsGetTime(pAC); ToutCnt = 0; @@ -1231,17 +1242,16 @@ * transmit FIFO ! */ XM_IN32(IoC, Port, XM_MODE, &DWord); - DWord |= XM_MD_FTF ; + DWord |= XM_MD_FTF; XM_OUT32(IoC, Port, XM_MODE, DWord); XsCsr = TestStopBit(pAC, IoC, pPrt->PXsQOff); XaCsr = TestStopBit(pAC, IoC, pPrt->PXaQOff); - if (ToutStart + (SK_TICKS_PER_SEC / 18) < - SkOsGetTime(pAC)) { - + if (ToutStart + (SK_TICKS_PER_SEC / 18) >= SkOsGetTime(pAC)) { /* * Timeout of 1/18 second reached. + * This needs to be checked at 1/18 sec only. */ ToutCnt++; switch (ToutCnt) { @@ -1253,35 +1263,36 @@ */ ToutStart = SkOsGetTime(pAC); if (XsCsr & CSR_STOP) { - SK_OUT32(IoC, - Q_ADDR(pPrt->PXsQOff, - Q_CSR), CSR_START); + SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_START); } if (XaCsr & CSR_STOP) { - SK_OUT32(IoC, - Q_ADDR(pPrt->PXaQOff, - Q_CSR), CSR_START); + SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_START); } break; case 2: - default: /* Fatal Error, Loop aborted */ + default: + /* Might be a problem when the driver event handler + * calls StopPort again. + * XXX. + */ + /* Fatal Error, Loop aborted */ /* Create an Error Log Entry */ - SK_ERR_LOG(pAC, SK_ERRCL_HW, + SK_ERR_LOG( + pAC, + SK_ERRCL_HW, SKERR_HWI_E018, SKERR_HWI_E018MSG); #ifndef SK_DIAG Para.Para64 = Port; - SkEventQueue(pAC, SKGE_DRV, - SK_DRV_PORT_FAIL, Para); + SkEventQueue(pAC, SKGE_DRV, SK_DRV_PORT_FAIL, Para); #endif /* !SK_DIAG */ return; } } /* - * because of the ASIC problem report entry from 21.08.98 - * it is required to wait until CSR_STOP is reset and - * CSR_SV_IDLE is set. + * Because of the ASIC problem report entry from 21.08.1998 it is + * required to wait until CSR_STOP is reset and CSR_SV_IDLE is set. */ } while ((XsCsr & (CSR_STOP|CSR_SV_IDLE)) != CSR_SV_IDLE || (XaCsr & (CSR_STOP|CSR_SV_IDLE)) != CSR_SV_IDLE); @@ -1298,10 +1309,10 @@ * Stop Interval Timer and Limit Counter of Tx Arbiter, * also disable Force Sync bit and Enable Alloc bit. */ - SK_OUT8(IoC, MR_ADDR(Port,TXA_CTRL), + SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL), TXA_DIS_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC); - SK_OUT32(IoC, MR_ADDR(Port,TXA_ITI_INI), 0x00000000L); - SK_OUT32(IoC, MR_ADDR(Port,TXA_LIM_INI), 0x00000000L); + SK_OUT32(IoC, MR_ADDR(Port, TXA_ITI_INI), 0x00000000L); + SK_OUT32(IoC, MR_ADDR(Port, TXA_LIM_INI), 0x00000000L); /* * perform a local reset of the port's tx path @@ -1311,16 +1322,16 @@ * - reset the RAM Butter sync tx queue * - reset the MAC Tx FIFO */ - SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff,Q_CSR), CSR_SET_RESET); - SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff,Q_CSR), CSR_SET_RESET); - SK_OUT8(IoC, RB_ADDR(pPrt->PXaQOff,RB_CTRL), RB_RST_SET); - SK_OUT8(IoC, RB_ADDR(pPrt->PXsQOff,RB_CTRL), RB_RST_SET); + SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), CSR_SET_RESET); + SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), CSR_SET_RESET); + SK_OUT8(IoC, RB_ADDR(pPrt->PXaQOff, RB_CTRL), RB_RST_SET); + SK_OUT8(IoC, RB_ADDR(pPrt->PXsQOff, RB_CTRL), RB_RST_SET); /* Note: MFF_RST_SET does NOT reset the XMAC! */ SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_RST_SET); /* switch Link and Tx LED off, stop the LED counters */ /* Link LED is switched off by the RLMT and the Diag itself */ - SkGeXmitLED(pAC, IoC, MR_ADDR(Port,TX_LED_INI), SK_LED_DIS); + SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_DIS); } if (Dir & SK_STOP_RX) { @@ -1331,7 +1342,7 @@ * stop the transfer of received packets. */ /* stop the port's receive queue */ - SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff,Q_CSR), CSR_STOP); + SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_STOP); i = 100; do { /* @@ -1368,12 +1379,12 @@ * - reset the RAM Buffer receive queue * - reset the MAC Rx FIFO */ - SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff,Q_CSR), CSR_SET_RESET); - SK_OUT8(IoC, RB_ADDR(pPrt->PRxQOff,RB_CTRL), RB_RST_SET); + SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_SET_RESET); + SK_OUT8(IoC, RB_ADDR(pPrt->PRxQOff, RB_CTRL), RB_RST_SET); SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_RST_SET); /* switch Rx LED off, stop the LED counter */ - SkGeXmitLED(pAC, IoC, MR_ADDR(Port,RX_LED_INI), SK_LED_DIS); + SkGeXmitLED(pAC, IoC, MR_ADDR(Port, RX_LED_INI), SK_LED_DIS); } @@ -1391,7 +1402,8 @@ if (AllPortsDis) { pAC->GIni.GIAnyPortAct = SK_FALSE; } -} +} /* SkGeStopPort */ + /****************************************************************************** * @@ -1444,7 +1456,88 @@ pAC->GIni.GIPortUsage = SK_RED_LINK; pAC->GIni.GIAnyPortAct = SK_FALSE; -} +} /* SkGeInit0*/ + +#ifdef SK_PCI_RESET + +/****************************************************************************** + * + * SkGePciReset() - Reset PCI interface + * + * Description: + * o Read PCI configuration. + * o Change power state to 3. + * o Change power state to 0. + * o Restore PCI configuration. + * + * Returns: + * 0: Success. + * 1: Power state could not be changed to 3. + */ +static int SkGePciReset( +SK_AC *pAC, /* adapter context */ +SK_IOC IoC) /* IO context */ +{ + int i; + SK_U16 PmCtlSts; + SK_U32 Bp1; + SK_U32 Bp2; + SK_U16 PciCmd; + SK_U8 Cls; + SK_U8 Lat; + SK_U8 ConfigSpace[PCI_CFG_SIZE]; + + /* + * Note: Switching to D3 state is like a software reset. + * Switching from D3 to D0 is a hardware reset. + * We have to save and restore the configuration space. + */ + for (i = 0; i < PCI_CFG_SIZE; i++) { + SkPciReadCfgDWord(pAC, i*4, &ConfigSpace[i]); + } + + /* We know the RAM Interface Arbiter is enabled. */ + SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, PCI_PM_STATE_D3); + SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts); + if ((PmCtlSts & PCI_PM_STATE) != PCI_PM_STATE_D3) { + return (1); + } + + /* + * Return to D0 state. + */ + SkPciWriteCfgWord(pAC, PCI_PM_CTL_STS, PCI_PM_STATE_D0); + + /* Check for D0 state. */ + SkPciReadCfgWord(pAC, PCI_PM_CTL_STS, &PmCtlSts); + if ((PmCtlSts & PCI_PM_STATE) != PCI_PM_STATE_D0) { + return (1); + } + + /* + * Check PCI Config Registers. + */ + SkPciReadCfgWord(pAC, PCI_COMMAND, &PciCmd); + SkPciReadCfgByte(pAC, PCI_CACHE_LSZ, &Cls); + SkPciReadCfgDWord(pAC, PCI_BASE_1ST, &Bp1); + SkPciReadCfgDWord(pAC, PCI_BASE_2ND, &Bp2); + SkPciReadCfgByte(pAC, PCI_LAT_TIM, &lat); + if (PciCmd != 0 || Cls != 0 || (Bp1 & 0xfffffff0L) != 0 || Bp2 != 1 || + Lat != 0 ) { + return (0); + } + + /* + * Restore Config Space. + */ + for (i = 0; i < PCI_CFG_SIZE; i++) { + SkPciWriteCfgDWord(pAC, i*4, ConfigSpace[i]); + } + + return (0); +} /* SkGePciReset */ + +#endif /* SK_PCI_RESET */ /****************************************************************************** * @@ -1477,6 +1570,10 @@ RetVal = 0; +#ifdef SK_PCI_RESET + (void)SkGePciReset(pAC, IoC); +#endif /* SK_PCI_RESET */ + /* Do the reset */ SK_OUT8(IoC, B0_CTST, CS_RST_SET); @@ -1486,7 +1583,7 @@ /* Reset all error bits in the PCI STATUS register */ /* * Note: Cfg cycles cannot be used, because they are not - * available on some platforms after 'boot time'. + * available on some platforms after 'boot time'. */ SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON); SK_IN16(IoC, PCI_C(PCI_STATUS), &Word); @@ -1547,12 +1644,13 @@ break; } } - SK_DBG_MSG(pAC,SK_DBGMOD_HWM,SK_DBGCAT_INIT, + SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT, ("PHY type: %d PHY addr: %x\n", pAC->GIni.GP[i].PhyType, - pAC->GIni.GP[i].PhyAddr)) ; + pAC->GIni.GP[i].PhyAddr)); return (RetVal); -} +} /* SkGeInit1*/ + /****************************************************************************** * @@ -1588,8 +1686,7 @@ pAC->GIni.GIPollTimerVal = SK_DPOLL_MAX; /* Create an Error Log Entry */ - SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E017, - SKERR_HWI_E017MSG); + SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E017, SKERR_HWI_E017MSG); } SK_OUT32(IoC, B28_DPT_INI, pAC->GIni.GIPollTimerVal); SK_OUT8(IoC, B28_DPT_CTRL, DPT_START); @@ -1607,9 +1704,9 @@ SkGeInitPktArb(pAC, IoC); /* enable the Tx Arbiters */ - SK_OUT8(IoC, MR_ADDR(MAC_1,TXA_CTRL), TXA_ENA_ARB); + SK_OUT8(IoC, MR_ADDR(MAC_1, TXA_CTRL), TXA_ENA_ARB); if (pAC->GIni.GIMacsFound > 1) { - SK_OUT8(IoC, MR_ADDR(MAC_2,TXA_CTRL), TXA_ENA_ARB); + SK_OUT8(IoC, MR_ADDR(MAC_2, TXA_CTRL), TXA_ENA_ARB); } /* enable the RAM Interface Arbiter */ @@ -1621,7 +1718,7 @@ pPrt->PRxCmd |= XM_RX_BIG_PK_OK; } } -} +} /* SkGeInit2 */ /****************************************************************************** * @@ -1660,24 +1757,24 @@ int SkGeInit( SK_AC *pAC, /* adapter context */ SK_IOC IoC, /* IO context */ -int Level) /* initialization level */ +int Level) /* initialization level */ { int RetVal; /* return value */ SK_U32 DWord; RetVal = 0; - SK_DBG_MSG(pAC,SK_DBGMOD_HWM,SK_DBGCAT_INIT, - ("SkGeInit(Level %d)\n",Level)) ; + SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_INIT, + ("SkGeInit(Level %d)\n", Level)); switch (Level) { case SK_INIT_DATA: /* Initialization Level 0 */ - SkGeInit0(pAC,IoC) ; + SkGeInit0(pAC, IoC); pAC->GIni.GILevel = SK_INIT_DATA; break; case SK_INIT_IO: /* Initialization Level 1 */ - RetVal = SkGeInit1(pAC,IoC) ; + RetVal = SkGeInit1(pAC, IoC); /* Check if the adapter seems to be accessable */ SK_OUT32(IoC, B2_IRQM_INI, 0x11335577L); @@ -1701,13 +1798,12 @@ /* Initialization Level 2 */ if (pAC->GIni.GILevel != SK_INIT_IO) { #ifndef SK_DIAG - SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E002, - SKERR_HWI_E002MSG); + SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E002, SKERR_HWI_E002MSG); #endif RetVal = 4; break; } - SkGeInit2(pAC,IoC) ; + SkGeInit2(pAC, IoC); /* Level 2 successfully passed */ pAC->GIni.GILevel = SK_INIT_RUN; @@ -1715,12 +1811,13 @@ default: /* Create an Error Log Entry */ SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E003, SKERR_HWI_E003MSG); - RetVal = 3 ; + RetVal = 3; break; } return (RetVal); -} +} /* SkGeInit*/ + /****************************************************************************** * @@ -1740,6 +1837,9 @@ int i; SK_U16 Word; + /* Ensure I2C is ready. */ + SkI2cWaitIrq(pAC, IoC); + /* Stop all current transfer activity */ for (i = 0; i < pAC->GIni.GIMacsFound; i++) { if (pAC->GIni.GP[i].PState != SK_PRT_STOP && @@ -1761,7 +1861,8 @@ /* Do the reset, all LEDs are switched off now */ SK_OUT8(IoC, B0_CTST, CS_RST_SET); -} +} /* SkGeDeInit*/ + /****************************************************************************** * @@ -1795,13 +1896,13 @@ int SkGeInitPort( SK_AC *pAC, /* adapter context */ SK_IOC IoC, /* IO context */ -int Port) /* Port to configure */ +int Port) /* Port to configure */ { SK_GEPORT *pPrt; pPrt = &pAC->GIni.GP[Port]; - if (SkGeCheckQSize(pAC,Port) != 0) { + if (SkGeCheckQSize(pAC, Port) != 0) { SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E004, SKERR_HWI_E004MSG); return (1); } @@ -1817,8 +1918,8 @@ * If 1000BT Phy needs LED initialization than swap * LED and XMAC initialization order */ - SkGeXmitLED(pAC, IoC, MR_ADDR(Port,TX_LED_INI), SK_LED_ENA); - SkGeXmitLED(pAC, IoC, MR_ADDR(Port,RX_LED_INI), SK_LED_ENA); + SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_ENA); + SkGeXmitLED(pAC, IoC, MR_ADDR(Port, RX_LED_INI), SK_LED_ENA); /* The Link LED is initialized by RLMT or Diagnostics itself */ /* Do NOT initialize the Link Sync Counter */ @@ -1844,4 +1945,4 @@ pAC->GIni.GIAnyPortAct = SK_TRUE; return (0); -} +} /* SkGeInitPort */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/skgepnmi.c linux/drivers/net/sk98lin/skgepnmi.c --- v2.4.0-test8/linux/drivers/net/sk98lin/skgepnmi.c Tue Nov 23 22:42:21 1999 +++ linux/drivers/net/sk98lin/skgepnmi.c Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skgepnmi.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.69 $ - * Date: $Date: 1999/10/18 11:42:15 $ + * Version: $Revision: 1.78 $ + * Date: $Date: 2000/09/12 10:44:58 $ * Purpose: Private Network Management Interface * ****************************************************************************/ @@ -13,8 +13,6 @@ * (C)Copyright 1998,1999 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * - * See the file "skge.c" for further information. - * * 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 @@ -29,6 +27,43 @@ * History: * * $Log: skgepnmi.c,v $ + * Revision 1.78 2000/09/12 10:44:58 cgoos + * Fixed SK_PNMI_STORE_U32 calls with typecasted argument. + * + * Revision 1.77 2000/09/07 08:10:19 rwahl + * - Modified algorithm for 64bit NDIS statistic counters; + * returns 64bit or 32bit value depending on passed buffer + * size. Indicate capability for 64bit NDIS counter, if passed + * buffer size is zero. OID_GEN_XMIT_ERROR, OID_GEN_RCV_ERROR, + * and OID_GEN_RCV_NO_BUFFER handled as 64bit counter, too. + * - corrected OID_SKGE_RLMT_PORT_PREFERRED. + * + * Revision 1.76 2000/08/03 15:23:39 rwahl + * - Correction for FrameTooLong counter has to be moved to OID handling + * routines (instead of statistic counter routine). + * - Fix in XMAC Reset Event handling: Only offset counter for hardware + * statistic registers are updated. + * + * Revision 1.75 2000/08/01 16:46:05 rwahl + * - Added StatRxLongFrames counter and correction of FrameTooLong counter. + * - Added directive to control width (default = 32bit) of NDIS statistic + * counters (SK_NDIS_64BIT_CTR). + * + * Revision 1.74 2000/07/04 11:41:53 rwahl + * - Added volition connector type. + * + * Revision 1.73 2000/03/15 16:33:10 rwahl + * Fixed bug 10510; wrong reset of virtual port statistic counters. + * + * Revision 1.72 1999/12/06 16:15:53 rwahl + * Fixed problem of instance range for current and factory MAC address. + * + * Revision 1.71 1999/12/06 10:14:20 rwahl + * Fixed bug 10476; set operation for PHY_OPERATION_MODE. + * + * Revision 1.70 1999/11/22 13:33:34 cgoos + * Changed license header to GPL. + * * Revision 1.69 1999/10/18 11:42:15 rwahl * Added typecasts for checking event dependent param (debug only). * @@ -297,7 +332,8 @@ static const char SysKonnectFileId[] = - "@(#) $Id: skgepnmi.c,v 1.69 1999/10/18 11:42:15 rwahl Exp $ (C) SysKonnect."; + "@(#) $Id: skgepnmi.c,v 1.78 2000/09/12 10:44:58 cgoos Exp $" + " (C) SysKonnect."; #include "h/skdrv1st.h" #include "h/sktypes.h" @@ -982,6 +1018,11 @@ sizeof(SK_PNMI_STAT), SK_PNMI_OFF(Stat) + SK_PNMI_STA_OFF(StatRxUnicastOkCts), SK_PNMI_RO, MacPrivateStat, SK_PNMI_HRX_UNICAST}, + {OID_SKGE_STAT_RX_LONGFRAMES, + SK_PNMI_MAC_ENTRIES, + sizeof(SK_PNMI_STAT), + SK_PNMI_OFF(Stat) + SK_PNMI_STA_OFF(StatRxLongFramesCts), + SK_PNMI_RO, MacPrivateStat, SK_PNMI_HRX_LONGFRAMES}, {OID_SKGE_STAT_RX_PFLOWC, SK_PNMI_MAC_ENTRIES, sizeof(SK_PNMI_STAT), @@ -1197,7 +1238,7 @@ 0, SK_PNMI_MAI_OFF(RlmtPortActive), SK_PNMI_RO, Rlmt, 0}, - {OID_SKGE_RLMT_PORT_PREFERED, + {OID_SKGE_RLMT_PORT_PREFERRED, 1, 0, SK_PNMI_MAI_OFF(RlmtPortPreferred), @@ -1353,7 +1394,8 @@ /* 62 */ {TRUE, XM_RXF_1023B}, /* 63 */ {TRUE, XM_RXF_MAX_SZ}, /* 64 */ {FALSE, 0}, - /* 65 */ {FALSE, 0} + /* 65 */ {FALSE, 0}, + /* 66 */ {TRUE, 0} }; @@ -1520,6 +1562,10 @@ pAC->Pnmi.Connector = 5; break; + case 'V': + pAC->Pnmi.Connector = 6; + break; + default: pAC->Pnmi.Connector = 1; break; @@ -2074,8 +2120,13 @@ case SK_PNMI_HRX_OCTETLOW: case SK_PNMI_HRX_IRLENGTH: case SK_PNMI_HRX_RESERVED22: + + /* + * the following counters aren't be handled (id > 63) + */ case SK_PNMI_HTX_SYNC: case SK_PNMI_HTX_SYNC_OCTET: + case SK_PNMI_HRX_LONGFRAMES: break; default: @@ -2270,7 +2321,7 @@ */ pAC->Pnmi.MacUpdatedFlag ++; - for (CounterIndex = 0; CounterIndex < SK_PNMI_MAX_IDX; + for (CounterIndex = 0; CounterIndex < SK_PNMI_SCNT_NOT; CounterIndex ++) { if (!StatAddress[CounterIndex].GetOffset) { @@ -2985,9 +3036,9 @@ SK_U32 Instance, /* Instance (1..n) that is to be queried or -1 */ unsigned int TableIndex) /* Index to the Id table */ { - int Ret; - SK_U32 StatVal; - + int Ret; + SK_U64 StatVal; + SK_BOOL Is64BitReq = SK_FALSE; /* * Only the active Mac is returned @@ -3022,11 +3073,28 @@ break; default: - if (*pLen < 4) { +#ifndef SK_NDIS_64BIT_CTR + if (*pLen < sizeof(SK_U32)) { + *pLen = sizeof(SK_U32); + return (SK_PNMI_ERR_TOO_SHORT); + } - *pLen = 4; +#else /* SK_NDIS_64BIT_CTR */ + + /* + * for compatibility, at least 32bit are required for oid + */ + if (*pLen < sizeof(SK_U32)) { + /* + * but indicate handling for 64bit values, + * if insufficient space is provided + */ + *pLen = sizeof(SK_U64); return (SK_PNMI_ERR_TOO_SHORT); } + + Is64BitReq = (*pLen < sizeof(SK_U64)) ? SK_FALSE : SK_TRUE; +#endif /* SK_NDIS_64BIT_CTR */ break; } @@ -3059,10 +3127,21 @@ break; default: - StatVal = (SK_U32)GetStatVal(pAC, IoC, 0, - IdTable[TableIndex].Param); - SK_PNMI_STORE_U32(pBuf, StatVal); - *pLen = sizeof(SK_U32); + StatVal = GetStatVal(pAC, IoC, 0, IdTable[TableIndex].Param); + + /* + * by default 32bit values are evaluated + */ + if (!Is64BitReq) { + SK_U32 StatVal32; + StatVal32 = (SK_U32)StatVal; + SK_PNMI_STORE_U32(pBuf, StatVal32); + *pLen = sizeof(SK_U32); + } + else { + SK_PNMI_STORE_U64(pBuf, StatVal); + *pLen = sizeof(SK_U64); + } break; } @@ -3177,6 +3256,20 @@ case OID_SKGE_STAT_RX_UTIL: return (SK_PNMI_ERR_GENERAL); */ + /* + * Frames longer than IEEE 802.3 frame max size are counted + * by XMAC in frame_too_long counter even reception of long + * frames was enabled and the frame was correct. + * So correct the value by subtracting RxLongFrame counter. + */ + case OID_SKGE_STAT_RX_TOO_LONG: + StatVal = GetStatVal(pAC, IoC, LogPortIndex, + IdTable[TableIndex].Param) - + GetStatVal(pAC, IoC, LogPortIndex, + SK_PNMI_HRX_LONGFRAMES); + SK_PNMI_STORE_U64(pBuf + Offset, StatVal); + break; + default: StatVal = GetStatVal(pAC, IoC, LogPortIndex, IdTable[TableIndex].Param); @@ -3245,7 +3338,7 @@ if ((Instance != (SK_U32)(-1))) { - if ((Instance < 1) || (Instance > SKCS_NUM_PROTOCOLS)) { + if ((Instance < 1) || (Instance > LogPortMax)) { *pLen = 0; return (SK_PNMI_ERR_UNKNOWN_INST); @@ -4289,6 +4382,7 @@ SK_U64 Val64; SK_U64 Val64RxHwErrs = 0; SK_U64 Val64TxHwErrs = 0; + SK_BOOL Is64BitReq = SK_FALSE; char Buf[256]; @@ -4315,13 +4409,37 @@ */ switch (Id) { + case OID_GEN_XMIT_ERROR: + case OID_GEN_RCV_ERROR: + case OID_GEN_RCV_NO_BUFFER: +#ifndef SK_NDIS_64BIT_CTR + if (*pLen < sizeof(SK_U32)) { + *pLen = sizeof(SK_U32); + return (SK_PNMI_ERR_TOO_SHORT); + } + +#else /* SK_NDIS_64BIT_CTR */ + + /* + * for compatibility, at least 32bit are required for oid + */ + if (*pLen < sizeof(SK_U32)) { + /* + * but indicate handling for 64bit values, + * if insufficient space is provided + */ + *pLen = sizeof(SK_U64); + return (SK_PNMI_ERR_TOO_SHORT); + } + + Is64BitReq = (*pLen < sizeof(SK_U64)) ? SK_FALSE : SK_TRUE; +#endif /* SK_NDIS_64BIT_CTR */ + break; + case OID_SKGE_PORT_NUMBER: case OID_SKGE_DEVICE_TYPE: case OID_SKGE_RESULT: case OID_SKGE_RLMT_MONITOR_NUMBER: - case OID_GEN_XMIT_ERROR: - case OID_GEN_RCV_ERROR: - case OID_GEN_RCV_NO_BUFFER: case OID_GEN_TRANSMIT_QUEUE_LENGTH: case OID_SKGE_TRAP_NUMBER: case OID_SKGE_MDB_VERSION: @@ -4420,7 +4538,8 @@ GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_SYMBOL) + GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_SHORTS) + GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_RUNT) + - GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_TOO_LONG)+ + GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_TOO_LONG)- + GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_LONGFRAMES)+ GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_FCS) + GetStatVal(pAC, IoC, 0, SK_PNMI_HRX_CEXT); break; @@ -4748,21 +4867,57 @@ break; case OID_GEN_RCV_ERROR: - Val32 = (SK_U32)(Val64RxHwErrs + pAC->Pnmi.RxNoBufCts); - SK_PNMI_STORE_U32(pBuf, Val32); - *pLen = sizeof(SK_U32); + Val64 = Val64RxHwErrs + pAC->Pnmi.RxNoBufCts; + + /* + * by default 32bit values are evaluated + */ + if (!Is64BitReq) { + SK_U32 Val32; + Val32 = (SK_U32)Val64; + SK_PNMI_STORE_U32(pBuf, Val32); + *pLen = sizeof(SK_U32); + } + else { + SK_PNMI_STORE_U64(pBuf, Val64); + *pLen = sizeof(SK_U64); + } break; case OID_GEN_XMIT_ERROR: - Val32 = (SK_U32)(Val64TxHwErrs + pAC->Pnmi.TxNoBufCts); - SK_PNMI_STORE_U32(pBuf, Val32); - *pLen = sizeof(SK_U32); + Val64 = Val64TxHwErrs + pAC->Pnmi.TxNoBufCts; + + /* + * by default 32bit values are evaluated + */ + if (!Is64BitReq) { + SK_U32 Val32; + Val32 = (SK_U32)Val64; + SK_PNMI_STORE_U32(pBuf, Val32); + *pLen = sizeof(SK_U32); + } + else { + SK_PNMI_STORE_U64(pBuf, Val64); + *pLen = sizeof(SK_U64); + } break; case OID_GEN_RCV_NO_BUFFER: - Val32 = (SK_U32)pAC->Pnmi.RxNoBufCts; - SK_PNMI_STORE_U32(pBuf, Val32); - *pLen = sizeof(SK_U32); + Val64 = pAC->Pnmi.RxNoBufCts; + + /* + * by default 32bit values are evaluated + */ + if (!Is64BitReq) { + SK_U32 Val32; + Val32 = (SK_U32)Val64; + SK_PNMI_STORE_U32(pBuf, Val32); + *pLen = sizeof(SK_U32); + } + else { + SK_PNMI_STORE_U64(pBuf, Val64); + *pLen = sizeof(SK_U64); + } break; case OID_GEN_TRANSMIT_QUEUE_LENGTH: @@ -4853,7 +5008,7 @@ case OID_SKGE_RLMT_MODE: case OID_SKGE_RLMT_PORT_ACTIVE: - case OID_SKGE_RLMT_PORT_PREFERED: + case OID_SKGE_RLMT_PORT_PREFERRED: if (*pLen < sizeof(SK_U8)) { *pLen = sizeof(SK_U8); @@ -4941,7 +5096,7 @@ *pLen = sizeof(char); break; - case OID_SKGE_RLMT_PORT_PREFERED: + case OID_SKGE_RLMT_PORT_PREFERRED: *pBuf = (char)SK_PNMI_PORT_PHYS2LOG( pAC->Rlmt.MacPreferred); *pLen = sizeof(char); @@ -5021,7 +5176,7 @@ } break; - case OID_SKGE_RLMT_PORT_PREFERED: + case OID_SKGE_RLMT_PORT_PREFERRED: /* Check if the buffer length is plausible */ if (*pLen < sizeof(char)) { @@ -5622,6 +5777,7 @@ case OID_SKGE_LINK_MODE: case OID_SKGE_FLOWCTRL_MODE: + case OID_SKGE_PHY_OPERATION_MODE: if (*pLen < Limit - LogPortIndex) { *pLen = Limit - LogPortIndex; @@ -5798,6 +5954,82 @@ Offset += sizeof(char); break; + case OID_SKGE_PHY_OPERATION_MODE : + /* Check the value range */ + Val8 = *(pBuf + Offset); + if (Val8 == 0) { + /* mode of this port remains unchanged */ + Offset += sizeof(char); + break; + } + if (Val8 < SK_MS_MODE_AUTO || + Val8 > SK_MS_MODE_SLAVE) { + + *pLen = 0; + return (SK_PNMI_ERR_BAD_VALUE); + } + + /* The preset ends here */ + if (Action == SK_PNMI_PRESET) { + + return (SK_PNMI_ERR_OK); + } + + if (LogPortIndex == 0) { + + /* + * The virtual port consists of all currently + * active ports. Find them and send an event + * with new master/slave (role) mode to SIRQ. + */ + for (PhysPortIndex = 0; + PhysPortIndex < PhysPortMax; + PhysPortIndex ++) { + + if (!pAC->Pnmi.Port[PhysPortIndex]. + ActiveFlag) { + + continue; + } + + EventParam.Para32[0] = PhysPortIndex; + EventParam.Para32[1] = (SK_U32)Val8; + if (SkGeSirqEvent(pAC, IoC, + SK_HWEV_SET_ROLE, + EventParam) > 0) { + + SK_ERR_LOG(pAC, SK_ERRCL_SW, + SK_PNMI_ERR052, + SK_PNMI_ERR052MSG); + + *pLen = 0; + return (SK_PNMI_ERR_GENERAL); + } + } + } + else { + /* + * Send an event with the new master/slave + * (role) mode to the SIRQ module. + */ + EventParam.Para32[0] = SK_PNMI_PORT_LOG2PHYS( + pAC, LogPortIndex); + EventParam.Para32[1] = (SK_U32)Val8; + if (SkGeSirqEvent(pAC, IoC, + SK_HWEV_SET_ROLE, EventParam) > 0) { + + SK_ERR_LOG(pAC, SK_ERRCL_SW, + SK_PNMI_ERR052, + SK_PNMI_ERR052MSG); + + *pLen = 0; + return (SK_PNMI_ERR_GENERAL); + } + } + + Offset += sizeof(char); + break; + default: SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR045, SK_PNMI_ERR045MSG); @@ -6670,6 +6902,12 @@ 32); break; + case SK_PNMI_HRX_LONGFRAMES: + LowVal = (SK_U32)pAC->Pnmi.Port[PhysPortIndex].StatRxLongFrameCts; + HighVal = (SK_U32) + (pAC->Pnmi.Port[PhysPortIndex].StatRxLongFrameCts >> 32); + break; + case SK_PNMI_HRX_FCS: /* * Broadcom filters fcs errors and counts it in @@ -6765,11 +7003,16 @@ SK_MEMSET((char *)&pAC->Pnmi.Port[PhysPortIndex]. StatSyncOctetsCts, 0, sizeof(pAC->Pnmi.Port[ PhysPortIndex].StatSyncOctetsCts)); + SK_MEMSET((char *)&pAC->Pnmi.Port[PhysPortIndex]. + StatRxLongFrameCts, 0, sizeof(pAC->Pnmi.Port[ + PhysPortIndex].StatRxLongFrameCts)); } /* * Clear local statistics */ + SK_MEMSET((char *)&pAC->Pnmi.VirtualCounterOffset, 0, + sizeof(pAC->Pnmi.VirtualCounterOffset)); pAC->Pnmi.RlmtChangeCts = 0; pAC->Pnmi.RlmtChangeTime = 0; SK_MEMSET((char *)&pAC->Pnmi.RlmtChangeEstimate.EstValue[0], 0, diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/skgesirq.c linux/drivers/net/sk98lin/skgesirq.c --- v2.4.0-test8/linux/drivers/net/sk98lin/skgesirq.c Tue Nov 23 22:42:21 1999 +++ linux/drivers/net/sk98lin/skgesirq.c Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skgesirq.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.46 $ - * Date: $Date: 1999/09/16 10:30:07 $ + * Version: $Revision: 1.55 $ + * Date: $Date: 2000/06/19 08:36:25 $ * Purpose: Special IRQ module * ******************************************************************************/ @@ -13,8 +13,6 @@ * (C)Copyright 1998,1999 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * - * See the file "skge.c" for further information. - * * 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 @@ -29,6 +27,34 @@ * History: * * $Log: skgesirq.c,v $ + * Revision 1.55 2000/06/19 08:36:25 cgoos + * Changed comment. + * + * Revision 1.54 2000/05/22 08:45:57 malthoff + * Fix: #10523 is valid for all BCom PHYs. + * + * Revision 1.53 2000/05/19 10:20:30 cgoos + * Removed Solaris debug output code. + * + * Revision 1.52 2000/05/19 10:19:37 cgoos + * Added PHY state check in HWLinkDown. + * Move PHY interrupt code to IS_EXT_REG case in SkGeSirqIsr. + * + * Revision 1.51 2000/05/18 05:56:20 cgoos + * Fixed typo. + * + * Revision 1.50 2000/05/17 12:49:49 malthoff + * Fixes BCom link bugs (#10523). + * + * Revision 1.49 1999/12/17 11:02:50 gklug + * fix: read PHY_STAT of Broadcom chip more often to assure good status + * + * Revision 1.48 1999/12/06 10:01:17 cgoos + * Added SET function for Role. + * + * Revision 1.47 1999/11/22 13:34:24 cgoos + * Changed license header to GPL. + * * Revision 1.46 1999/09/16 10:30:07 cgoos * Removed debugging output statement from Linux. * @@ -215,7 +241,7 @@ */ static const char SysKonnectFileId[] = - "$Id: skgesirq.c,v 1.46 1999/09/16 10:30:07 cgoos Exp $" ; + "$Id: skgesirq.c,v 1.55 2000/06/19 08:36:25 cgoos Exp $" ; #include "h/skdrv1st.h" /* Driver Specific Definitions */ #include "h/skgepnmi.h" /* PNMI Definitions */ @@ -385,6 +411,15 @@ /* disable all PHY interrupts */ switch (pAC->GIni.GP[Port].PhyType) { case SK_PHY_BCOM: + /* make sure that PHY is initialized */ + if (pAC->GIni.GP[Port].PState) { + /* Workaround BCOM Errata (#10523) all BCom */ + /* Disable Power Management if link is down */ + PHY_READ(IoC, pPrt, Port, PHY_BCOM_AUX_CTRL, + &Word); + PHY_WRITE(IoC, pPrt, Port, PHY_BCOM_AUX_CTRL, + Word | PHY_B_AC_DIS_PM); + } PHY_WRITE(IoC, pPrt, Port, PHY_BCOM_INT_MASK, 0xffff); break; @@ -766,12 +801,11 @@ } /* - * I2C Ready interrupt + * external reg interrupt */ - if (Istatus & IS_I2C_READY) { + if (Istatus & IS_EXT_REG) { SK_U16 PhyInt; SK_U16 PhyIMsk; - SK_BOOL IsPhyInt = SK_FALSE; int i; /* test IRQs from PHY */ for (i=0; iGIni.GIMacsFound; i++) { @@ -794,7 +828,6 @@ SkPhyIsrBcom(pAC, IoC, i, (SK_U16) (PhyInt & (~PhyIMsk))); - IsPhyInt = SK_TRUE; } } else { @@ -814,7 +847,6 @@ i, PhyInt, PhyIMsk)); SkPhyIsrLone(pAC, IoC, i, (SK_U16) (PhyInt & PhyIMsk)); - IsPhyInt = SK_TRUE; } break; case SK_PHY_NAT: @@ -822,9 +854,13 @@ break; } } - if (!IsPhyInt) { - SkI2cIsr(pAC, IoC); - } + } + + /* + * I2C Ready interrupt + */ + if (Istatus & IS_I2C_READY) { + SkI2cIsr(pAC, IoC); } if (Istatus & IS_LNK_SYNC_M1) { @@ -1328,8 +1364,23 @@ SK_U16 PhyStat; /* Phy Status Register */ int Done; SK_U16 ResAb; + SK_U16 SWord; pPrt = &pAC->GIni.GP[Port]; + + /* Check for No HCD Link events (#10523) */ + PHY_READ(IoC, pPrt, Port, PHY_BCOM_INT_STAT, &Isrc); + if ((Isrc & PHY_B_IS_NO_HDCL) == PHY_B_IS_NO_HDCL) { + + /* Workaround BCOM Errata */ + /* enable and disable Loopback mode if NO HCD occurs */ + PHY_READ(IoC, pPrt, Port, PHY_BCOM_CTRL, &SWord); + PHY_WRITE(IoC, pPrt, Port, PHY_BCOM_CTRL, SWord | PHY_CT_LOOP); + PHY_WRITE(IoC, pPrt, Port, PHY_BCOM_CTRL, SWord & ~PHY_CT_LOOP); + SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL, + ("No HCD Link event, Port %d\n", Port)); + } + PHY_READ(IoC, pPrt, Port, PHY_BCOM_STAT, &PhyStat); if (pPrt->PHWLinkUp) { @@ -1338,7 +1389,7 @@ pPrt->PIsave = 0; - /* Now wait for each ports link */ + /* Now wait for each port's link */ if (pPrt->PLinkMode == SK_LMODE_HALF || pPrt->PLinkMode == SK_LMODE_FULL) { AutoNeg = SK_FALSE; @@ -1355,13 +1406,43 @@ PHY_READ(IoC, pPrt, Port, PHY_BCOM_STAT, &PhyStat); SkXmAutoNegLipaBcom(pAC, IoC, Port, PhyStat); - if ((PhyStat & PHY_ST_LSYNC) == 0){ - return(SK_HW_PS_NONE) ; + + SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL, + ("AutoNeg:%d, PhyStat: %Xh.\n", AutoNeg, PhyStat)); + + PHY_READ(IoC, pPrt, Port, PHY_BCOM_1000T_STAT, &ResAb); + + if ((PhyStat & PHY_ST_LSYNC) == 0) { + if (ResAb & (PHY_B_1000S_MSF)) { + /* Error */ + SK_DBG_MSG(pAC,SK_DBGMOD_HWM,SK_DBGCAT_CTRL, + ("Master/Slave Fault port %d\n", Port)); + pPrt->PAutoNegFail = SK_TRUE; + pPrt->PMSStatus = SK_MS_STAT_FAULT; + return (SK_AND_OTHER); + } + return (SK_HW_PS_NONE); + } + + if (ResAb & (PHY_B_1000S_MSF)) { + /* Error */ + SK_DBG_MSG(pAC,SK_DBGMOD_HWM,SK_DBGCAT_CTRL, + ("Master/Slave Fault port %d\n", Port)); + pPrt->PAutoNegFail = SK_TRUE; + pPrt->PMSStatus = SK_MS_STAT_FAULT; + return (SK_AND_OTHER); + } else if (ResAb & PHY_B_1000S_MSR) { + pPrt->PMSStatus = SK_MS_STAT_MASTER; + } else { + pPrt->PMSStatus = SK_MS_STAT_SLAVE; } + + SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL, + ("AutoNeg:%d, PhyStat: %Xh.\n", AutoNeg, PhyStat)); if (AutoNeg) { if (PhyStat & PHY_ST_AN_OVER) { - SkHWLinkUp(pAC, IoC, Port) ; + SkHWLinkUp(pAC, IoC, Port); Done = SkXmAutoNegDone(pAC,IoC,Port); if (Done != SK_AND_OK) { /* Get PHY parameters, for debuging only */ @@ -1400,6 +1481,8 @@ Port)); } #endif + +#if 0 PHY_READ(IoC, pPrt, Port, PHY_BCOM_1000T_STAT, &ResAb); if (ResAb & (PHY_B_1000S_MSF)) { /* Error */ @@ -1413,6 +1496,7 @@ } else { pPrt->PMSStatus = SK_MS_STAT_SLAVE ; } +#endif /* 0 */ /* @@ -1753,6 +1837,18 @@ if (pAC->GIni.GP[Port].PFlowCtrlMode != Val8) { /* Set New Flow Control mode */ pAC->GIni.GP[Port].PFlowCtrlMode = Val8; + + /* Restart Port */ + SkEventQueue(pAC, SKGE_HWAC, SK_HWEV_PORT_STOP, Para); + SkEventQueue(pAC, SKGE_HWAC, SK_HWEV_PORT_START, Para); + } + break; + + case SK_HWEV_SET_ROLE: + Val8 = (SK_U8) Para.Para32[1]; + if (pAC->GIni.GP[Port].PMSMode != Val8) { + /* Set New link mode */ + pAC->GIni.GP[Port].PMSMode = Val8; /* Restart Port */ SkEventQueue(pAC, SKGE_HWAC, SK_HWEV_PORT_STOP, Para); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/ski2c.c linux/drivers/net/sk98lin/ski2c.c --- v2.4.0-test8/linux/drivers/net/sk98lin/ski2c.c Tue Nov 23 22:42:21 1999 +++ linux/drivers/net/sk98lin/ski2c.c Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: ski2c.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.41 $ - * Date: $Date: 1999/09/14 14:11:30 $ + * Version: $Revision: 1.44 $ + * Date: $Date: 2000/08/07 15:49:03 $ * Purpose: Funktions to access Voltage and Temperature Sensor * (taken from Monalisa (taken from Concentrator)) * @@ -11,11 +11,9 @@ /****************************************************************************** * - * (C)Copyright 1998,1999 SysKonnect, + * (C)Copyright 1998-2000 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * - * See the file "skge.c" for further information. - * * 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 @@ -30,6 +28,16 @@ * History: * * $Log: ski2c.c,v $ + * Revision 1.44 2000/08/07 15:49:03 gklug + * fix: SK_INFAST only in NetWare driver + * + * Revision 1.43 2000/08/03 14:28:17 rassmann + * - Added function to wait for I2C being ready before resetting the board. + * - Replaced one duplicate "out of range" message with correct one. + * + * Revision 1.42 1999/11/22 13:35:12 cgoos + * Changed license header to GPL. + * * Revision 1.41 1999/09/14 14:11:30 malthoff * The 1000BT Dual Link adapter has got only one Fan. * The second Fan has been removed. @@ -172,10 +180,10 @@ /* - i2C Protocol + I2C Protocol */ static const char SysKonnectFileId[] = - "$Id: ski2c.c,v 1.41 1999/09/14 14:11:30 malthoff Exp $" ; + "$Id: ski2c.c,v 1.44 2000/08/07 15:49:03 gklug Exp $"; #include "h/skdrv1st.h" /* Driver Specific Definitions */ #include "h/lm80.h" @@ -193,9 +201,9 @@ This file covers functions that allow to read write and do some bulk requests a specified I2C address. - The Genesis has 2 I2C busses. One for the EEPROM which holds + The Genesis has 2 I2C buses. One for the EEPROM which holds the VPD Data and one for temperature and voltage sensor. - The following picture shows the I2C busses, I2C devices and + The following picture shows the I2C buses, I2C devices and there control registers. Note: The VPD functions are in skvpd.c @@ -292,13 +300,13 @@ * serial data line simultaneously (ASIC: last bit of a byte = '1', I2C client * send an 'ACK'). See also Concentrator Bugreport No. 10192. */ -#define I2C_DATA_HIGH(IoC) SK_I2C_SET_BIT(IoC,I2C_DATA) -#define I2C_DATA_LOW(IoC) SK_I2C_CLR_BIT(IoC,I2C_DATA) -#define I2C_DATA_OUT(IoC) SK_I2C_SET_BIT(IoC,I2C_DATA_DIR) -#define I2C_DATA_IN(IoC) SK_I2C_CLR_BIT(IoC,I2C_DATA_DIR|I2C_DATA) -#define I2C_CLK_HIGH(IoC) SK_I2C_SET_BIT(IoC,I2C_CLK) -#define I2C_CLK_LOW(IoC) SK_I2C_CLR_BIT(IoC,I2C_CLK|I2C_DATA_DIR) -#define I2C_START_COND(IoC) SK_I2C_CLR_BIT(IoC,I2C_CLK) +#define I2C_DATA_HIGH(IoC) SK_I2C_SET_BIT(IoC, I2C_DATA) +#define I2C_DATA_LOW(IoC) SK_I2C_CLR_BIT(IoC, I2C_DATA) +#define I2C_DATA_OUT(IoC) SK_I2C_SET_BIT(IoC, I2C_DATA_DIR) +#define I2C_DATA_IN(IoC) SK_I2C_CLR_BIT(IoC, I2C_DATA_DIR|I2C_DATA) +#define I2C_CLK_HIGH(IoC) SK_I2C_SET_BIT(IoC, I2C_CLK) +#define I2C_CLK_LOW(IoC) SK_I2C_CLR_BIT(IoC, I2C_CLK|I2C_DATA_DIR) +#define I2C_START_COND(IoC) SK_I2C_CLR_BIT(IoC, I2C_CLK) #define NS2CLKT(x) ((x*125L)/10000) @@ -308,25 +316,24 @@ * sending one bit */ void SkI2cSndBit( -SK_IOC IoC, /* IoContext */ +SK_IOC IoC, /* I/O Context */ SK_U8 Bit) /* Bit to send */ { - I2C_DATA_OUT(IoC) ; + I2C_DATA_OUT(IoC); if (Bit) { I2C_DATA_HIGH(IoC); } else { I2C_DATA_LOW(IoC); } - SkDgWaitTime(IoC,NS2BCLK(T_DATA_IN_SETUP)); + SkDgWaitTime(IoC, NS2BCLK(T_DATA_IN_SETUP)); I2C_CLK_HIGH(IoC); - SkDgWaitTime(IoC,NS2BCLK(T_CLK_HIGH)); + SkDgWaitTime(IoC, NS2BCLK(T_CLK_HIGH)); I2C_CLK_LOW(IoC); -} - +} /* SkI2cSndBit*/ /* - * Signal a start to the i2C Bus. + * Signal a start to the I2C Bus. * * A start is signaled when data goes to low in a high clock cycle. * @@ -334,66 +341,70 @@ * * Status: not tested */ -void SkI2cStart(SK_IOC IoC) /* I/O Context */ +void SkI2cStart( +SK_IOC IoC) /* I/O Context */ { /* Init data and Clock to output lines */ /* Set Data high */ - I2C_DATA_OUT(IoC) ; - I2C_DATA_HIGH(IoC) ; + I2C_DATA_OUT(IoC); + I2C_DATA_HIGH(IoC); /* Set Clock high */ - I2C_CLK_HIGH(IoC) ; + I2C_CLK_HIGH(IoC); - SkDgWaitTime(IoC,NS2BCLK(T_START_SETUP)) ; + SkDgWaitTime(IoC, NS2BCLK(T_START_SETUP)); /* Set Data Low */ - I2C_DATA_LOW(IoC) ; + I2C_DATA_LOW(IoC); - SkDgWaitTime(IoC,NS2BCLK(T_START_HOLD)) ; + SkDgWaitTime(IoC, NS2BCLK(T_START_HOLD)); /* Clock low without Data to Input */ - I2C_START_COND(IoC) ; + I2C_START_COND(IoC); - SkDgWaitTime(IoC,NS2BCLK(T_CLK_LOW)) ; -} + SkDgWaitTime(IoC, NS2BCLK(T_CLK_LOW)); +} /* SkI2cStart */ -void SkI2cStop(SK_IOC IoC) /* I/O Context */ +void SkI2cStop( +SK_IOC IoC) /* I/O Context */ { /* Init data and Clock to output lines */ /* Set Data low */ - I2C_DATA_OUT(IoC) ; - I2C_DATA_LOW(IoC) ; + I2C_DATA_OUT(IoC); + I2C_DATA_LOW(IoC); - SkDgWaitTime(IoC,NS2BCLK(T_CLK_2_DATA_OUT)) ; + SkDgWaitTime(IoC, NS2BCLK(T_CLK_2_DATA_OUT)); /* Set Clock high */ - I2C_CLK_HIGH(IoC) ; + I2C_CLK_HIGH(IoC); - SkDgWaitTime(IoC,NS2BCLK(T_STOP_SETUP)) ; + SkDgWaitTime(IoC, NS2BCLK(T_STOP_SETUP)); /* * Set Data High: Do it by setting the Data Line to Input. * Because of a pull up resistor the Data Line * floods to high. */ - I2C_DATA_IN(IoC) ; + I2C_DATA_IN(IoC); /* * When I2C activity is stopped * o DATA should be set to input and * o CLOCK should be set to high! */ - SkDgWaitTime(IoC,NS2BCLK(T_BUS_IDLE)) ; -} + SkDgWaitTime(IoC, NS2BCLK(T_BUS_IDLE)); +} /* SkI2cStop */ + /* - * Receive just one bit via the i2C bus. + * Receive just one bit via the I2C bus. * * Note: Clock must be set to LOW before calling this function. * * Returns The received bit. */ -int SkI2cRcvBit(SK_IOC IoC) /* I/O Context */ +int SkI2cRcvBit( +SK_IOC IoC) /* I/O Context */ { int Bit; SK_U8 I2cSwCtrl; @@ -401,13 +412,13 @@ /* Init data as input line */ I2C_DATA_IN(IoC); - SkDgWaitTime(IoC,NS2BCLK(T_CLK_2_DATA_OUT)) ; + SkDgWaitTime(IoC, NS2BCLK(T_CLK_2_DATA_OUT)); I2C_CLK_HIGH(IoC); - SkDgWaitTime(IoC,NS2BCLK(T_CLK_HIGH)) ; + SkDgWaitTime(IoC, NS2BCLK(T_CLK_HIGH)); - SK_I2C_GET_SW(IoC,&I2cSwCtrl) ; + SK_I2C_GET_SW(IoC, &I2cSwCtrl); if (I2cSwCtrl & I2C_DATA) { Bit = 1; } else { @@ -415,10 +426,11 @@ } I2C_CLK_LOW(IoC); - SkDgWaitTime(IoC,NS2BCLK(T_CLK_LOW-T_CLK_2_DATA_OUT)) ; + SkDgWaitTime(IoC, NS2BCLK(T_CLK_LOW-T_CLK_2_DATA_OUT)); return(Bit); -} +} /* SkI2cRcvBit */ + /* * Receive an ACK. @@ -426,58 +438,64 @@ * returns 0 If acknoledged * 1 in case of an error */ -int SkI2cRcvAck(SK_IOC IoC) /* I/O Context */ +int SkI2cRcvAck( +SK_IOC IoC) /* I/O Context */ { /* * Received bit must be zero. */ - return (SkI2cRcvBit(IoC) != 0) ; -} + return (SkI2cRcvBit(IoC) != 0); +} /* SkI2cRcvAck */ + /* * Send an NACK. */ -void SkI2cSndNAck(SK_IOC IoC) /* I/O Context */ +void SkI2cSndNAck( +SK_IOC IoC) /* I/O Context */ { /* * Received bit must be zero. */ - SkI2cSndBit(IoC,1) ; -} + SkI2cSndBit(IoC, 1); +} /* SkI2cSndNAck */ + /* * Send an ACK. */ -void SkI2cSndAck(SK_IOC IoC) /* I/O Context */ +void SkI2cSndAck( +SK_IOC IoC) /* I/O Context */ { /* * Received bit must be zero. * */ - SkI2cSndBit(IoC,0) ; -} + SkI2cSndBit(IoC, 0); +} /* SkI2cSndAck */ + /* - * Send one byte to the i2C device and wait for ACK. + * Send one byte to the I2C device and wait for ACK. * * Return acknoleged status. */ int SkI2cSndByte( SK_IOC IoC, /* I/O Context */ -int Byte) /* byte to send */ +int Byte) /* byte to send */ { int i; for (i=0; i<8; i++) { if (Byte & (1<<(7-i))) { - SkI2cSndBit(IoC,1) ; + SkI2cSndBit(IoC, 1); } else { - SkI2cSndBit(IoC,0) ; + SkI2cSndBit(IoC, 0); } } - return(SkI2cRcvAck(IoC)) ; -} + return(SkI2cRcvAck(IoC)); +} /* SkI2cSndByte */ /* @@ -487,24 +505,24 @@ */ int SkI2cRcvByte( SK_IOC IoC, /* I/O Context */ -int Last) /* Last Byte Flag */ +int Last) /* Last Byte Flag */ { int i; int Byte = 0; for (i=0; i<8; i++) { - Byte <<= 1 ; - Byte |= SkI2cRcvBit(IoC) ; + Byte <<= 1; + Byte |= SkI2cRcvBit(IoC); } if (Last) { - SkI2cSndNAck(IoC) ; + SkI2cSndNAck(IoC); } else { - SkI2cSndAck(IoC) ; + SkI2cSndAck(IoC); } - return(Byte) ; -} + return(Byte); +} /* SkI2cRcvByte */ /* @@ -514,68 +532,106 @@ */ int SkI2cSndDev( SK_IOC IoC, /* I/O Context */ -int Addr, /* Device Address */ -int Rw) /* Read / Write Flag */ +int Addr, /* Device Address */ +int Rw) /* Read / Write Flag */ { - SkI2cStart(IoC) ; - Rw = ~Rw ; - Rw &= I2C_WRITE ; - return(SkI2cSndByte(IoC, (Addr<<1) | Rw)) ; -} + SkI2cStart(IoC); + Rw = ~Rw; + Rw &= I2C_WRITE; + return(SkI2cSndByte(IoC, (Addr<<1) | Rw)); +} /* SkI2cSndDev */ #endif /* SK_DIAG */ /*----------------- I2C CTRL Register Functions ----------*/ /* - * waits for a completetion of a I2C transfer + * waits for a completion of an I2C transfer * * returns 0: success, transfer completes - * 1: error, transfer does not complete, I2C transfer - * killed, wait loop terminated. + * 1: error, transfer does not complete, I2C transfer + * killed, wait loop terminated. */ int SkI2cWait( SK_AC *pAC, /* Adapter Context */ -SK_IOC IoC, /* IoContext */ -int Event) /* complete event to wait for (I2C_READ or I2C_WRITE) */ +SK_IOC IoC, /* I/O Context */ +int Event) /* complete event to wait for (I2C_READ or I2C_WRITE) */ +{ + SK_U64 StartTime; + SK_U32 I2cCtrl; + + StartTime = SkOsGetTime(pAC); + do { + if (SkOsGetTime(pAC) - StartTime > SK_TICKS_PER_SEC / 8) { + SK_I2C_STOP(IoC); +#ifndef SK_DIAG + SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_I2C_E002, SKERR_I2C_E002MSG); +#endif /* !SK_DIAG */ + return(1); + } + SK_I2C_GET_CTL(IoC, &I2cCtrl); + } while ((I2cCtrl & I2C_FLAG) == (SK_U32)Event << 31); + + return(0); +} /* SkI2cWait */ + + +/* + * waits for a completion of an I2C transfer + * + * Returns + * Nothing + */ +void SkI2cWaitIrq( +SK_AC *pAC, /* Adapter Context */ +SK_IOC IoC) /* I/O Context */ { - SK_U64 StartTime ; - SK_U32 I2cCtrl ; + SK_SENSOR *pSen; + SK_U64 StartTime; + SK_U32 IrqSrc; - StartTime = SkOsGetTime(pAC) ; + pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens]; + + if (pSen->SenState == SK_SEN_IDLE) { + return; + } + + StartTime = SkOsGetTime(pAC); do { - if (SkOsGetTime(pAC) - StartTime > SK_TICKS_PER_SEC/16) { - SK_I2C_STOP(IoC) ; + if (SkOsGetTime(pAC) - StartTime > SK_TICKS_PER_SEC / 8) { + SK_I2C_STOP(IoC); #ifndef SK_DIAG - SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_I2C_E002, - SKERR_I2C_E002MSG) ; + SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_I2C_E002, SKERR_I2C_E002MSG); #endif /* !SK_DIAG */ - return(1) ; + return; } - SK_I2C_GET_CTL(IoC,&I2cCtrl) ; - } while((I2cCtrl & I2C_FLAG) == (SK_U32)Event << 31) ; + SK_IN32(pAC, B0_ISRC, &IrqSrc); + } while ((IrqSrc & IS_I2C_READY) == 0); - return(0) ; -} + return; +} /* SkI2cWaitIrq */ #ifdef SK_DIAG + /* * writes a single byte or 4 bytes into the I2C device * * returns 0: success - * 1: error + * 1: error */ int SkI2cWrite( -SK_AC *pAC, /* Adapter Context */ +SK_AC *pAC, /* Adapter Context */ +SK_IOC IoC, /* I/O Context */ SK_U32 I2cData, /* I2C Data to write */ -int I2cDev, /* I2C Device Address */ -int I2cReg, /* I2C Device Register Address */ -int I2cBurst) /* I2C Burst Flag ( 0 || I2C_BURST ) */ -{ - SK_OUT32(pAC,B2_I2C_DATA,I2cData) ; - SK_I2C_CTL(pAC,I2C_WRITE,I2cDev,I2cReg,I2cBurst); - return(SkI2cWait(pAC,pAC,I2C_WRITE)) ; -} +int I2cDev, /* I2C Device Address */ +int I2cReg, /* I2C Device Register Address */ +int I2cBurst) /* I2C Burst Flag ( 0 || I2C_BURST ) */ +{ + SK_OUT32(IoC, B2_I2C_DATA, I2cData); + SK_I2C_CTL(IoC, I2C_WRITE, I2cDev, I2cReg, I2cBurst); + return(SkI2cWait(pAC, IoC, I2C_WRITE)); +} /* SkI2cWrite*/ + /* * reads a single byte or 4 bytes from the I2C device @@ -583,39 +639,42 @@ * returns the word read */ SK_U32 SkI2cRead( -SK_AC *pAC, /* Adapter Context */ -int I2cDev, /* I2C Device Address */ -int I2cReg, /* I2C Device Register Address */ -int I2cBurst) /* I2C Burst Flag ( 0 || I2C_BURST ) */ -{ - SK_U32 Data ; - - SK_OUT32(pAC,B2_I2C_DATA,0) ; - SK_I2C_CTL(pAC,I2C_READ,I2cDev,I2cReg,I2cBurst); - if (SkI2cWait(pAC,pAC,I2C_READ)) { - w_print("I2c Transfer Timeout!\n"); - } - SK_IN32(pAC,B2_I2C_DATA,&Data) ; - return(Data) ; -} +SK_AC *pAC, /* Adapter Context */ +SK_IOC IoC, /* I/O Context */ +int I2cDev, /* I2C Device Address */ +int I2cReg, /* I2C Device Register Address */ +int I2cBurst) /* I2C Burst Flag ( 0 || I2C_BURST ) */ +{ + SK_U32 Data; + + SK_OUT32(IoC, B2_I2C_DATA, 0); + SK_I2C_CTL(IoC, I2C_READ, I2cDev, I2cReg, I2cBurst); + if (SkI2cWait(pAC, IoC, I2C_READ)) { + w_print("I2C Transfer Timeout!\n"); + } + SK_IN32(IoC, B2_I2C_DATA, &Data); + return(Data); +} /* SkI2cRead */ + #endif /* SK_DIAG */ + /* - * read a sensors value + * read a sensor's value * - * This function read a sensors value from the I2c sensor chip. The sensor + * This function read a sensors value from the I2C sensor chip. The sensor * is defined by its index into the sensors database in the struct pAC points * to. * Returns 1 if the read is completed - * 0 if the read must be continued (I2c Bus still allocated) + * 0 if the read must be continued (I2C Bus still allocated) */ int SkI2cReadSensor( SK_AC *pAC, /* Adapter Context */ -SK_IOC IoC, /* IoContext */ +SK_IOC IoC, /* I/O Context */ SK_SENSOR *pSen) /* Sensor to be read */ { - return((*pSen->SenRead)(pAC,IoC,pSen)) ; -} + return((*pSen->SenRead)(pAC, IoC, pSen)); +} /* SkI2cReadSensor*/ /* * Do the Init state 0 initialization @@ -639,7 +698,7 @@ for (i=0; i < SK_MAX_SENSORS; i ++) { switch (i) { case 0: - pAC->I2c.SenTable[i].SenDesc = "Temperature" ; + pAC->I2c.SenTable[i].SenDesc = "Temperature"; pAC->I2c.SenTable[i].SenType = SK_SEN_TEMP; pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_ERRHIGH0; pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_ERRLOW0; @@ -733,10 +792,11 @@ pAC->I2c.SenTable[i].SenDev = LM80_ADDR; } - /* Now we are INIT dataed */ + /* Now we are "INIT data"ed */ pAC->I2c.InitLevel = SK_INIT_DATA; return(0); -} +} /* SkI2cInit0*/ + /* * Do the init state 1 initialization @@ -760,7 +820,7 @@ */ static int SkI2cInit1( SK_AC *pAC, /* Adapter Context */ -SK_IOC IoC) /* IoContext needed in level 1 */ +SK_IOC IoC) /* I/O Context */ { if (pAC->I2c.InitLevel != SK_INIT_DATA) { /* ReInit not needed in I2C module */ @@ -769,27 +829,27 @@ SK_OUT32(IoC, B2_I2C_DATA, 0); SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_CFG, 0); - (void)SkI2cWait(pAC, IoC, I2C_WRITE) ; + (void)SkI2cWait(pAC, IoC, I2C_WRITE); SK_OUT32(IoC, B2_I2C_DATA, 0xff); SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_IMSK_1, 0); - (void)SkI2cWait(pAC, IoC, I2C_WRITE) ; + (void)SkI2cWait(pAC, IoC, I2C_WRITE); SK_OUT32(IoC, B2_I2C_DATA, 0xff); SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_IMSK_2, 0); - (void)SkI2cWait(pAC, IoC, I2C_WRITE) ; + (void)SkI2cWait(pAC, IoC, I2C_WRITE); SK_OUT32(IoC, B2_I2C_DATA, 0x0); SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_FAN_CTRL, 0); - (void)SkI2cWait(pAC, IoC, I2C_WRITE) ; + (void)SkI2cWait(pAC, IoC, I2C_WRITE); SK_OUT32(IoC, B2_I2C_DATA, 0); SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_TEMP_CTRL, 0); - (void)SkI2cWait(pAC, IoC, I2C_WRITE) ; + (void)SkI2cWait(pAC, IoC, I2C_WRITE); SK_OUT32(IoC, B2_I2C_DATA, LM80_CFG_START); SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_CFG, 0); - (void)SkI2cWait(pAC, IoC, I2C_WRITE) ; + (void)SkI2cWait(pAC, IoC, I2C_WRITE); /* * MaxSens has to be initialized here, because PhyType is not @@ -820,14 +880,15 @@ /* Now we are IO initialized */ pAC->I2c.InitLevel = SK_INIT_IO; return(0); -} +} /* SkI2cInit1 */ + /* * Init level 2: Start first sensors read */ static int SkI2cInit2( SK_AC *pAC, /* Adapter Context */ -SK_IOC IoC) /* IoContext needed in level 1 */ +SK_IOC IoC) /* I/O Context */ { int ReadComplete; SK_SENSOR *pSen; @@ -839,18 +900,18 @@ } pSen = &pAC->I2c.SenTable[pAC->I2c.CurrSens]; - ReadComplete = SkI2cReadSensor(pAC,IoC,pSen); + ReadComplete = SkI2cReadSensor(pAC, IoC, pSen); if (ReadComplete) { - SK_ERR_LOG(pAC, SK_ERRCL_INIT, SKERR_I2C_E008, - SKERR_I2C_E008MSG); + SK_ERR_LOG(pAC, SK_ERRCL_INIT, SKERR_I2C_E008, SKERR_I2C_E008MSG); } /* Now we are correctly initialized */ pAC->I2c.InitLevel = SK_INIT_RUN; return(0); -} +} /* SkI2cInit2*/ + /* * Initialize I2C devices @@ -871,27 +932,29 @@ */ int SkI2cInit( SK_AC *pAC, /* Adapter Context */ -SK_IOC IoC, /* IoContext needed in level 1 */ -int Level) /* Init Level */ +SK_IOC IoC, /* I/O Context needed in levels 1 and 2 */ +int Level) /* Init Level */ { switch (Level) { case SK_INIT_DATA: - return(SkI2cInit0(pAC)) ; + return(SkI2cInit0(pAC)); case SK_INIT_IO: - return(SkI2cInit1(pAC, IoC)) ; + return(SkI2cInit1(pAC, IoC)); case SK_INIT_RUN: - return(SkI2cInit2(pAC, IoC)) ; + return(SkI2cInit2(pAC, IoC)); default: break; } - return(0) ; -} + return(0); +} /* SkI2cInit */ + #ifndef SK_DIAG + /* - * Interrupt service function for the I2c Interface + * Interrupt service function for the I2C Interface * * Clears the Interrupt source * @@ -900,23 +963,24 @@ * Starts the timer if necessary. */ void SkI2cIsr( -SK_AC *pAC, /* Adapters context */ -SK_IOC IoC) /* Io Context */ +SK_AC *pAC, /* Adapter Context */ +SK_IOC IoC) /* I/O Context */ { SK_EVPARA Para; /* Clear the interrupt source */ - SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ) ; + SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ); Para.Para64 = 0; SkEventQueue(pAC, SKGE_I2C, SK_I2CEV_IRQ, Para); -} +} /* SkI2cIsr */ + /* * Check this sensors Value against the threshold and send events. */ static void SkI2cCheckSensor( -SK_AC *pAC, /* Adapters context */ +SK_AC *pAC, /* Adapter Context */ SK_SENSOR *pSen) { SK_EVPARA ParaLocal; @@ -929,12 +993,12 @@ /* Check Dummy Reads first */ if (pAC->I2c.DummyReads > 0) { - pAC->I2c.DummyReads -- ; + pAC->I2c.DummyReads --; return; } /* Get the current time */ - CurrTime = SkOsGetTime(pAC) ; + CurrTime = SkOsGetTime(pAC); /* Set para to the most usefull setting: * The current sensor. @@ -943,17 +1007,17 @@ /* Check the Value against the thresholds */ /* First: Error Thresholds */ - TooHigh = (pSen->SenValue > pSen->SenThreErrHigh) ; - TooLow = (pSen->SenValue < pSen->SenThreErrLow) ; + TooHigh = (pSen->SenValue > pSen->SenThreErrHigh); + TooLow = (pSen->SenValue < pSen->SenThreErrLow); - IsError = SK_FALSE ; + IsError = SK_FALSE; if (TooHigh || TooLow) { - /* Error condition is satiesfied */ + /* Error condition is satisfied */ DoTrapSend = SK_TRUE; DoErrLog = SK_TRUE; /* Now error condition is satisfied */ - IsError = SK_TRUE ; + IsError = SK_TRUE; if (pSen->SenErrFlag == SK_SEN_ERR_ERR) { /* This state is the former one */ @@ -981,7 +1045,7 @@ /* We came from a different state */ /* -> Set Begin Time Stamp */ pSen->SenBegErrTS = CurrTime; - pSen->SenErrFlag = SK_SEN_ERR_ERR ; + pSen->SenErrFlag = SK_SEN_ERR_ERR; } if (DoTrapSend) { @@ -993,7 +1057,7 @@ SkEventQueue(pAC, SKGE_PNMI, (TooHigh ? SK_PNMI_EVT_SEN_ERR_UPP : SK_PNMI_EVT_SEN_ERR_LOW), - ParaLocal) ; + ParaLocal); } if (DoErrLog) { @@ -1016,12 +1080,12 @@ /* Check the Value against the thresholds */ /* 2nd: Warning thresholds */ - TooHigh = (pSen->SenValue > pSen->SenThreWarnHigh) ; - TooLow = (pSen->SenValue < pSen->SenThreWarnLow) ; + TooHigh = (pSen->SenValue > pSen->SenThreWarnHigh); + TooLow = (pSen->SenValue < pSen->SenThreWarnLow); if (!IsError && (TooHigh || TooLow)) { - /* Error condition is satiesfied */ + /* Error condition is satisfied */ DoTrapSend = SK_TRUE; DoErrLog = SK_TRUE; @@ -1051,7 +1115,7 @@ /* We came from a different state */ /* -> Set Begin Time Stamp */ pSen->SenBegWarnTS = CurrTime; - pSen->SenErrFlag = SK_SEN_ERR_WARN ; + pSen->SenErrFlag = SK_SEN_ERR_WARN; } if (DoTrapSend) { @@ -1063,7 +1127,7 @@ SkEventQueue(pAC, SKGE_PNMI, (TooHigh ? SK_PNMI_EVT_SEN_WAR_UPP : SK_PNMI_EVT_SEN_WAR_LOW), - ParaLocal) ; + ParaLocal); } if (DoErrLog) { @@ -1074,8 +1138,8 @@ SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E009, SKERR_I2C_E009MSG); } else if (pSen->SenType == SK_SEN_VOLT) { - SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E009, - SKERR_I2C_E009MSG); + SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E010, + SKERR_I2C_E010MSG); } else { SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E014, @@ -1087,7 +1151,7 @@ /* Check for NO error at all */ if (!IsError && !TooHigh && !TooLow) { /* Set o.k. Status if no error and no warning condition */ - pSen->SenErrFlag = SK_SEN_ERR_OK ; + pSen->SenErrFlag = SK_SEN_ERR_OK; } /* End of check against the thresholds */ @@ -1115,17 +1179,18 @@ if (!pSen->SenInit) { SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E013, SKERR_I2C_E013MSG); } -} +} /* SkI2cCheckSensor*/ + /* * The only Event to be served is the timeout event * */ int SkI2cEvent( -SK_AC *pAC, /* Adapters context */ -SK_IOC IoC, /* Io Context */ -SK_U32 Event, /* Module specific Event */ -SK_EVPARA Para) /* Event specific Parameter */ +SK_AC *pAC, /* Adapter Context */ +SK_IOC IoC, /* I/O Context */ +SK_U32 Event, /* Module specific Event */ +SK_EVPARA Para) /* Event specific Parameter */ { int ReadComplete; SK_SENSOR *pSen; @@ -1141,7 +1206,7 @@ if (ReadComplete) { /* Check sensor against defined thresholds */ - SkI2cCheckSensor (pAC, pSen) ; + SkI2cCheckSensor (pAC, pSen); /* Increment Current and set appropriate Timeout */ Time = SK_I2C_TIM_SHORT; @@ -1155,7 +1220,7 @@ /* Start Timer */ ParaLocal.Para64 = (SK_U64) 0; SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, Time, - SKGE_I2C, SK_I2CEV_TIM, ParaLocal) ; + SKGE_I2C, SK_I2CEV_TIM, ParaLocal); } break; case SK_I2CEV_CLEAR: @@ -1176,6 +1241,6 @@ } return(0); -} -#endif /* !SK_DIAG */ -/* End of File */ +} /* SkI2cEvent*/ + +#endif /* !SK_DIAG */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/sklm80.c linux/drivers/net/sk98lin/sklm80.c --- v2.4.0-test8/linux/drivers/net/sk98lin/sklm80.c Tue Nov 23 22:42:21 1999 +++ linux/drivers/net/sk98lin/sklm80.c Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: sklm80.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.16 $ - * Date: $Date: 1999/05/27 14:05:47 $ + * Version: $Revision: 1.17 $ + * Date: $Date: 1999/11/22 13:35:51 $ * Purpose: Funktions to access Voltage and Temperature Sensor (LM80) * ******************************************************************************/ @@ -13,8 +13,6 @@ * (C)Copyright 1998,1999 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * - * See the file "skge.c" for further information. - * * 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 @@ -29,6 +27,9 @@ * History: * * $Log: sklm80.c,v $ + * Revision 1.17 1999/11/22 13:35:51 cgoos + * Changed license header to GPL. + * * Revision 1.16 1999/05/27 14:05:47 malthoff * Fans: Set SenVal to 0 if the fan value is 0 or 0xff. Both values * are outside the limits (0: div zero error, 0xff: value not in @@ -92,7 +93,7 @@ LM80 functions */ static const char SysKonnectFileId[] = - "$Id: sklm80.c,v 1.16 1999/05/27 14:05:47 malthoff Exp $" ; + "$Id: sklm80.c,v 1.17 1999/11/22 13:35:51 cgoos Exp $" ; #include "h/skdrv1st.h" /* Driver Specific Definitions */ #include "h/lm80.h" diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/skqueue.c linux/drivers/net/sk98lin/skqueue.c --- v2.4.0-test8/linux/drivers/net/sk98lin/skqueue.c Tue Nov 23 22:42:21 1999 +++ linux/drivers/net/sk98lin/skqueue.c Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skqueue.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.14 $ - * Date: $Date: 1998/10/15 15:11:35 $ + * Version: $Revision: 1.15 $ + * Date: $Date: 1999/11/22 13:36:29 $ * Purpose: Management of an event queue. * ******************************************************************************/ @@ -13,8 +13,6 @@ * (C)Copyright 1998,1999 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * - * See the file "skge.c" for further information. - * * 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 @@ -29,6 +27,9 @@ * History: * * $Log: skqueue.c,v $ + * Revision 1.15 1999/11/22 13:36:29 cgoos + * Changed license header to GPL. + * * Revision 1.14 1998/10/15 15:11:35 gklug * fix: ID_sccs to SysKonnectFileId * @@ -81,7 +82,7 @@ Event queue and dispatcher */ static const char SysKonnectFileId[] = - "$Header: /usr56/projects/ge/schedule/skqueue.c,v 1.14 1998/10/15 15:11:35 gklug Exp $" ; + "$Header: /usr56/projects/ge/schedule/skqueue.c,v 1.15 1999/11/22 13:36:29 cgoos Exp $" ; #include "h/skdrv1st.h" /* Driver Specific Definitions */ #include "h/skqueue.h" /* Queue Definitions */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/skrlmt.c linux/drivers/net/sk98lin/skrlmt.c --- v2.4.0-test8/linux/drivers/net/sk98lin/skrlmt.c Tue Nov 23 22:42:21 1999 +++ linux/drivers/net/sk98lin/skrlmt.c Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skrlmt.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.48 $ - * Date: $Date: 1999/10/04 14:01:17 $ + * Version: $Revision: 1.49 $ + * Date: $Date: 1999/11/22 13:38:02 $ * Purpose: Manage links on SK-NET Adapters, esp. redundant ones. * ******************************************************************************/ @@ -13,8 +13,6 @@ * (C)Copyright 1998,1999 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * - * See the file "skge.c" for further information. - * * 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 @@ -29,6 +27,10 @@ * History: * * $Log: skrlmt.c,v $ + * Revision 1.49 1999/11/22 13:38:02 cgoos + * Changed license header to GPL. + * Added initialization to some variables to avoid compiler warnings. + * * Revision 1.48 1999/10/04 14:01:17 rassmann * Corrected reaction to reception of BPDU frames. * Added parameter descriptions to "For Readme" section skrlmt.txt. @@ -216,7 +218,7 @@ #ifndef lint static const char SysKonnectFileId[] = - "@(#) $Id: skrlmt.c,v 1.48 1999/10/04 14:01:17 rassmann Exp $ (C) SysKonnect."; + "@(#) $Id: skrlmt.c,v 1.49 1999/11/22 13:38:02 cgoos Exp $ (C) SysKonnect."; #endif /* !defined(lint) */ #define __SKRLMT_C diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/sktimer.c linux/drivers/net/sk98lin/sktimer.c --- v2.4.0-test8/linux/drivers/net/sk98lin/sktimer.c Tue Nov 23 22:42:21 1999 +++ linux/drivers/net/sk98lin/sktimer.c Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: sktimer.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.11 $ - * Date: $Date: 1998/12/17 13:24:13 $ + * Version: $Revision: 1.12 $ + * Date: $Date: 1999/11/22 13:38:51 $ * Purpose: High level timer functions. * ******************************************************************************/ @@ -13,8 +13,6 @@ * (C)Copyright 1998,1999 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * - * See the file "skge.c" for further information. - * * 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 @@ -29,6 +27,9 @@ * History: * * $Log: sktimer.c,v $ + * Revision 1.12 1999/11/22 13:38:51 cgoos + * Changed license header to GPL. + * * Revision 1.11 1998/12/17 13:24:13 gklug * fix: restart problem: do NOT destroy timer queue if init 1 is done * @@ -75,7 +76,7 @@ Event queue and dispatcher */ static const char SysKonnectFileId[] = - "$Header: /usr56/projects/ge/schedule/sktimer.c,v 1.11 1998/12/17 13:24:13 gklug Exp $" ; + "$Header: /usr56/projects/ge/schedule/sktimer.c,v 1.12 1999/11/22 13:38:51 cgoos Exp $" ; #include "h/skdrv1st.h" /* Driver Specific Definitions */ #include "h/skdrv2nd.h" /* Adapter Control- and Driver specific Def. */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/skvpd.c linux/drivers/net/sk98lin/skvpd.c --- v2.4.0-test8/linux/drivers/net/sk98lin/skvpd.c Mon Jul 10 16:47:23 2000 +++ linux/drivers/net/sk98lin/skvpd.c Fri Sep 15 14:34:19 2000 @@ -2,19 +2,17 @@ * * Name: skvpd.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.24 $ - * Date: $Date: 1999/03/11 14:25:49 $ + * Version: $Revision: 1.27 $ + * Date: $Date: 2000/08/10 11:29:06 $ * Purpose: Shared software to read and write VPD data * ******************************************************************************/ /****************************************************************************** * - * (C)Copyright 1998,1999 SysKonnect, + * (C)Copyright 1998-2000 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * - * See the file "skge.c" for further information. - * * 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 @@ -29,6 +27,18 @@ * History: * * $Log: skvpd.c,v $ + * Revision 1.27 2000/08/10 11:29:06 rassmann + * Editorial changes. + * Preserving 32-bit alignment in structs for the adapter context. + * Removed unused function VpdWriteDword() (#if 0). + * Made VpdReadKeyword() available for SKDIAG only. + * + * Revision 1.26 2000/06/13 08:00:01 mkarl + * additional cast to avoid compile problems in 64 bit environment + * + * Revision 1.25 1999/11/22 13:39:32 cgoos + * Changed license header to GPL. + * * Revision 1.24 1999/03/11 14:25:49 malthoff * Replace __STDC__ with SK_KR_PROTO. * @@ -62,7 +72,7 @@ * * Revision 1.14 1998/10/28 07:20:38 gklug * chg: Interface functions to use IoC as parameter as well - * fix: VpdRead/WriteDWord now return SK_U32 + * fix: VpdRead/WriteDWord now returns SK_U32 * chg: VPD_IN/OUT names conform to SK_IN/OUT * add: usage of VPD_IN/OUT8 macros * add: VpdRead/Write Stream functions to r/w a stream of data @@ -120,7 +130,7 @@ Please refer skvpd.txt for infomation how to include this module */ static const char SysKonnectFileId[] = - "@(#)$Id: skvpd.c,v 1.24 1999/03/11 14:25:49 malthoff Exp $ (C) SK" ; + "@(#)$Id: skvpd.c,v 1.27 2000/08/10 11:29:06 rassmann Exp $ (C) SK"; #include "h/skdrv1st.h" #include "h/sktypes.h" @@ -134,9 +144,9 @@ static SK_VPD_PARA *vpd_find_para( SK_AC *pAC, char *key, - SK_VPD_PARA *p) ; + SK_VPD_PARA *p); #else /* SK_KR_PROTO */ -static SK_VPD_PARA *vpd_find_para() ; +static SK_VPD_PARA *vpd_find_para(); #endif /* SK_KR_PROTO */ /* @@ -151,28 +161,29 @@ SK_IOC IoC, /* IO Context */ int event) /* event to wait for (VPD_READ / VPD_write) completion*/ { - SK_U64 start_time ; - SK_U16 state ; + SK_U64 start_time; + SK_U16 state; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, - ("vpd wait for %s\n",event?"Write":"Read")) ; - start_time = SkOsGetTime(pAC) ; + ("vpd wait for %s\n",event?"Write":"Read")); + start_time = SkOsGetTime(pAC); do { if (SkOsGetTime(pAC) - start_time > SK_TICKS_PER_SEC/16) { - VPD_STOP(pAC,IoC) ; + VPD_STOP(pAC,IoC); SK_DBG_MSG(pAC,SK_DBGMOD_VPD, SK_DBGCAT_FATAL|SK_DBGCAT_ERR, - ("ERROR:vpd wait timeout\n")) ; - return(1) ; + ("ERROR:vpd wait timeout\n")); + return(1); } - VPD_IN16(pAC,IoC,PCI_VPD_ADR_REG,&state) ; + VPD_IN16(pAC,IoC,PCI_VPD_ADR_REG,&state); SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, - ("state = %x, event %x\n",state,event)) ; - } while((int)(state & PCI_VPD_FLAG) == event) ; + ("state = %x, event %x\n",state,event)); + } while((int)(state & PCI_VPD_FLAG) == event); - return(0) ; + return(0); } +#ifdef SKDIAG /* * Read the dword at address 'addr' from the VPD EEPROM. @@ -189,27 +200,31 @@ SK_IOC IoC, /* IO Context */ int addr) /* VPD address */ { - SK_U32 Rtv ; + SK_U32 Rtv; /* start VPD read */ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, - ("vpd read dword at 0x%x\n",addr)) ; - addr &= ~VPD_WRITE ; /* ensure the R/W bit is set to read */ + ("vpd read dword at 0x%x\n",addr)); + addr &= ~VPD_WRITE; /* ensure the R/W bit is set to read */ - VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, (SK_U16) addr) ; + VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, (SK_U16) addr); /* ignore return code here */ - (void)VpdWait(pAC,IoC,VPD_READ) ; + (void)VpdWait(pAC,IoC,VPD_READ); /* Don't swap here, it's a data stream of bytes */ - Rtv = 0 ; + Rtv = 0; - VPD_IN32(pAC,IoC,PCI_VPD_DAT_REG,&Rtv) ; + VPD_IN32(pAC,IoC,PCI_VPD_DAT_REG,&Rtv); SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, - ("vpd read dword data = 0x%x\n",Rtv)) ; - return (Rtv) ; + ("vpd read dword data = 0x%x\n",Rtv)); + return (Rtv); } +#endif // SKDIAG + +#if 0 + /* Write the dword 'data' at address 'addr' into the VPD EEPROM, and verify that the data is written. @@ -229,11 +244,10 @@ Returns 0: success - 1: error, I2C transfer does not terminate - 2: error, data verify error + 1: error, I2C transfer does not terminate + 2: error, data verify error */ -#if 0 /* unused */ static int VpdWriteDWord( SK_AC *pAC, /* pAC pointer */ SK_IOC IoC, /* IO Context */ @@ -243,29 +257,30 @@ /* start VPD write */ /* Don't swap here, it's a data stream of bytes */ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, - ("vpd write dword at addr 0x%x, data = 0x%x\n",addr,data)) ; - VPD_OUT32(pAC,IoC,PCI_VPD_DAT_REG, (SK_U32)data) ; + ("vpd write dword at addr 0x%x, data = 0x%x\n",addr,data)); + VPD_OUT32(pAC,IoC,PCI_VPD_DAT_REG, (SK_U32)data); /* But do it here */ - addr |= VPD_WRITE ; + addr |= VPD_WRITE; - VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, (SK_U16)(addr | VPD_WRITE)) ; + VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, (SK_U16)(addr | VPD_WRITE)); /* this may take up to 10,6 ms */ if (VpdWait(pAC,IoC,VPD_WRITE)) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("Write Timed Out\n")) ; - return(1) ; - } ; + ("Write Timed Out\n")); + return(1); + }; /* verify data */ if (VpdReadDWord(pAC,IoC,addr) != data) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR|SK_DBGCAT_FATAL, - ("Data Verify Error\n")) ; - return(2) ; + ("Data Verify Error\n")); + return(2); } - return(0) ; -} -#endif /* unused */ + return(0); +} /* VpdWriteDWord */ + +#endif /* 0 */ /* * Read one Stream of 'len' bytes of VPD data, starting at 'addr' from @@ -280,12 +295,12 @@ int Addr, /* VPD start address */ int Len) /* number of bytes to read / to write */ { - int i ; - int j ; - SK_U16 AdrReg ; - int Rtv ; + int i; + int j; + SK_U16 AdrReg; + int Rtv; SK_U8 * pComp; /* Compare pointer */ - SK_U8 Data ; /* Input Data for Compare */ + SK_U8 Data; /* Input Data for Compare */ /* Init Compare Pointer */ pComp = (SK_U8 *) buf; @@ -297,56 +312,56 @@ * So it is initialized even if only a few bytes * are written. */ - AdrReg = (SK_U16) Addr ; - AdrReg &= ~VPD_WRITE ; /* READ operation */ + AdrReg = (SK_U16) Addr; + AdrReg &= ~VPD_WRITE; /* READ operation */ - VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg) ; + VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg); /* ignore return code here */ - Rtv = VpdWait(pAC,IoC,VPD_READ) ; + Rtv = VpdWait(pAC,IoC,VPD_READ); if (Rtv != 0) { - return(i) ; + return(i); } } /* Write current Byte */ VPD_OUT8(pAC,IoC,PCI_VPD_DAT_REG+(i%sizeof(SK_U32)), - *(SK_U8*)buf) ; + *(SK_U8*)buf); if (((i%sizeof(SK_U32)) == 3) || (i == (Len - 1))) { /* New Address needs to be written to VPD_ADDR reg */ - AdrReg = (SK_U16) Addr ; + AdrReg = (SK_U16) Addr; Addr += sizeof(SK_U32); - AdrReg |= VPD_WRITE ; /* WRITE operation */ + AdrReg |= VPD_WRITE; /* WRITE operation */ - VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg) ; + VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg); /* Wait for termination */ - Rtv = VpdWait(pAC,IoC,VPD_WRITE) ; + Rtv = VpdWait(pAC,IoC,VPD_WRITE); if (Rtv != 0) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("Write Timed Out\n")) ; - return(i - (i%sizeof(SK_U32))) ; + ("Write Timed Out\n")); + return(i - (i%sizeof(SK_U32))); } /* * Now re-read to verify */ - AdrReg &= ~VPD_WRITE ; /* READ operation */ + AdrReg &= ~VPD_WRITE; /* READ operation */ - VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg) ; + VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg); /* Wait for termination */ - Rtv = VpdWait(pAC,IoC,VPD_READ) ; + Rtv = VpdWait(pAC,IoC,VPD_READ); if (Rtv != 0) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("Verify Timed Out\n")) ; - return(i - (i%sizeof(SK_U32))) ; + ("Verify Timed Out\n")); + return(i - (i%sizeof(SK_U32))); } for (j = 0; j <= (int) (i%sizeof(SK_U32)); j ++, pComp ++ ) { - VPD_IN8(pAC,IoC,PCI_VPD_DAT_REG+j, &Data) ; + VPD_IN8(pAC,IoC,PCI_VPD_DAT_REG+j, &Data); if (Data != *pComp) { /* Verify Error */ SK_DBG_MSG(pAC,SK_DBGMOD_VPD, @@ -376,31 +391,31 @@ int Addr, /* VPD start address */ int Len) /* number of bytes to read / to write */ { - int i ; - SK_U16 AdrReg ; - int Rtv ; + int i; + SK_U16 AdrReg; + int Rtv; for (i=0; i < Len; i ++, buf++) { if ((i%sizeof(SK_U32)) == 0) { /* New Address needs to be written to VPD_ADDR reg */ - AdrReg = (SK_U16) Addr ; + AdrReg = (SK_U16) Addr; Addr += sizeof(SK_U32); - AdrReg &= ~VPD_WRITE ; /* READ operation */ + AdrReg &= ~VPD_WRITE; /* READ operation */ - VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg) ; + VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg); /* ignore return code here */ - Rtv = VpdWait(pAC,IoC,VPD_READ) ; + Rtv = VpdWait(pAC,IoC,VPD_READ); if (Rtv != 0) { - return(i) ; + return(i); } } VPD_IN8(pAC,IoC,PCI_VPD_DAT_REG+(i%sizeof(SK_U32)), - (SK_U8 *)buf) ; + (SK_U8 *)buf); } - return(Len) ; + return(Len); } /* @@ -417,29 +432,29 @@ int len, /* number of bytes to read / to write */ int dir) /* transfer direction may be VPD_READ or VPD_WRITE */ { - int Rtv ; /* Return value */ - int vpd_rom_size ; - SK_U32 our_reg2 ; + int Rtv; /* Return value */ + int vpd_rom_size; + SK_U32 our_reg2; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, ("vpd %s block, addr = 0x%x, len = %d\n", - dir?"write":"read",addr,len)) ; + dir?"write":"read",addr,len)); if (len == 0) - return (0) ; + return (0); - VPD_IN32(pAC,IoC,PCI_OUR_REG_2,&our_reg2) ; + VPD_IN32(pAC,IoC,PCI_OUR_REG_2,&our_reg2); vpd_rom_size = 256 << ((our_reg2 & PCI_VPD_ROM_SZ) >> 14); if (addr > vpd_rom_size - 4) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR|SK_DBGCAT_FATAL, ("Address error: 0x%x, exp. < 0x%x\n", - addr, vpd_rom_size - 4)) ; - return (0) ; + addr, vpd_rom_size - 4)); + return (0); } if (addr + len > vpd_rom_size) { - len = vpd_rom_size - addr ; + len = vpd_rom_size - addr; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("Warning: len was cut to %d\n",len)) ; + ("Warning: len was cut to %d\n",len)); } if (dir == VPD_READ) { @@ -448,7 +463,7 @@ Rtv = VpdWriteStream(pAC, IoC, buf, addr, len); } - return (Rtv) ; + return (Rtv); } #ifdef SKDIAG @@ -465,7 +480,7 @@ int addr, /* start reading at the VPD address */ int len) /* number of bytes to read */ { - return (VpdTransferBlock(pAC, IoC, buf, addr, len, VPD_READ)) ; + return (VpdTransferBlock(pAC, IoC, buf, addr, len, VPD_READ)); } /* @@ -480,7 +495,7 @@ int addr, /* start writing at the VPD address */ int len) /* number of bytes to write */ { - return (VpdTransferBlock(pAC, IoC, buf, addr, len, VPD_WRITE)) ; + return (VpdTransferBlock(pAC, IoC, buf, addr, len, VPD_WRITE)); } #endif /* SKDIAG */ @@ -497,64 +512,64 @@ SK_AC *pAC, /* Adapters context */ SK_IOC IoC) /* IO Context */ { - SK_VPD_PARA *r, rp ; /* RW or RV */ - int i ; - unsigned char x ; + SK_VPD_PARA *r, rp; /* RW or RV */ + int i; + unsigned char x; - SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_INIT,("VpdInit .. ")) ; + SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_INIT,("VpdInit .. ")); /* read the VPD data into the VPD buffer */ if (VpdTransferBlock(pAC,IoC,pAC->vpd.vpd_buf,0,VPD_SIZE,VPD_READ) != VPD_SIZE) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("Block Read Error\n")) ; - return(1) ; + ("Block Read Error\n")); + return(1); } /* find the end tag of the RO area */ if (!(r = vpd_find_para(pAC,VPD_RV,&rp))) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL, - ("Encoding Error: RV Tag not found\n")) ; - return (1) ; + ("Encoding Error: RV Tag not found\n")); + return (1); } if (r->p_val + r->p_len > pAC->vpd.vpd_buf + VPD_SIZE/2) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL, - ("Encoding Error: Invalid VPD struct size\n")) ; - return (1) ; + ("Encoding Error: Invalid VPD struct size\n")); + return (1); } - pAC->vpd.v.vpd_free_ro = r->p_len - 1 ; + pAC->vpd.v.vpd_free_ro = r->p_len - 1; /* test the checksum */ for (i = 0, x = 0; (unsigned)i<=(unsigned)VPD_SIZE/2 - r->p_len; i++) { - x += pAC->vpd.vpd_buf[i] ; + x += pAC->vpd.vpd_buf[i]; } if (x != 0) { /* checksum error */ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL, - ("VPD Checksum Error\n")) ; - return (1) ; + ("VPD Checksum Error\n")); + return (1); } /* find and check the end tag of the RW area */ if (!(r = vpd_find_para(pAC,VPD_RW,&rp))) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL, - ("Encoding Error: RV Tag not found\n")) ; - return (1) ; + ("Encoding Error: RV Tag not found\n")); + return (1); } if (r->p_val < pAC->vpd.vpd_buf + VPD_SIZE/2) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL, - ("Encoding Error: Invalid VPD struct size\n")) ; - return (1) ; + ("Encoding Error: Invalid VPD struct size\n")); + return (1); } - pAC->vpd.v.vpd_free_rw = r->p_len ; + pAC->vpd.v.vpd_free_rw = r->p_len; /* everything seems to be ok */ - pAC->vpd.v.vpd_status |= VPD_VALID ; + pAC->vpd.v.vpd_status |= VPD_VALID; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_INIT, ("done. Free RO = %d, Free RW = %d\n", - pAC->vpd.v.vpd_free_ro, pAC->vpd.v.vpd_free_rw)) ; + pAC->vpd.v.vpd_free_ro, pAC->vpd.v.vpd_free_rw)); - return(0) ; + return(0); } /* @@ -570,62 +585,62 @@ SK_VPD_PARA *p) /* parameter description struct */ { char *v ; /* points to vpd buffer */ - int max ; /* Maximum Number of Iterations */ + int max; /* Maximum Number of Iterations */ - v = pAC->vpd.vpd_buf ; - max = 128 ; + v = pAC->vpd.vpd_buf; + max = 128; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, - ("vpd find para %s .. ",key)) ; + ("vpd find para %s .. ",key)); /* check mandatory resource type ID string (Product Name) */ if (*v != (char) RES_ID) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL, - ("Error: 0x%x missing\n",RES_ID)) ; - return (0) ; + ("Error: 0x%x missing\n",RES_ID)); + return (0); } if (strcmp(key,VPD_NAME) == 0) { - p->p_len = VPD_GET_RES_LEN(v) ; - p->p_val = VPD_GET_VAL(v) ; + p->p_len = VPD_GET_RES_LEN(v); + p->p_val = VPD_GET_VAL(v); SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, - ("found, len = %d\n",p->p_len)) ; - return(p) ; + ("found, len = %d\n",p->p_len)); + return(p); } - v += 3 + VPD_GET_RES_LEN(v) + 3 ; - for ( ; ; ) { + v += 3 + VPD_GET_RES_LEN(v) + 3; + for (;; ) { if (SK_MEMCMP(key,v,2) == 0) { - p->p_len = VPD_GET_VPD_LEN(v) ; - p->p_val = VPD_GET_VAL(v) ; + p->p_len = VPD_GET_VPD_LEN(v); + p->p_val = VPD_GET_VAL(v); SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, - ("found, len = %d\n",p->p_len)) ; - return (p) ; + ("found, len = %d\n",p->p_len)); + return (p); } /* exit when reaching the "RW" Tag or the maximum of itera. */ - max-- ; + max--; if (SK_MEMCMP(VPD_RW,v,2) == 0 || max == 0) { - break ; + break; } if (SK_MEMCMP(VPD_RV,v,2) == 0) { - v += 3 + VPD_GET_VPD_LEN(v) + 3 ; /* skip VPD-W */ + v += 3 + VPD_GET_VPD_LEN(v) + 3; /* skip VPD-W */ } else { - v += 3 + VPD_GET_VPD_LEN(v) ; + v += 3 + VPD_GET_VPD_LEN(v); } SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, - ("scanning '%c%c' len = %d\n",v[0],v[1],v[2])) ; + ("scanning '%c%c' len = %d\n",v[0],v[1],v[2])); } #ifdef DEBUG - SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,("not found\n")) ; + SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,("not found\n")); if (max == 0) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL, - ("Key/Len Encoding error\n")) ; + ("Key/Len Encoding error\n")); } #endif - return (0) ; + return (0); } /* @@ -639,24 +654,24 @@ char *end, /* end of memory block to move */ int n) /* number of bytes the memory block has to be moved */ { - char *p ; - int i ; /* number of byte copied */ + char *p; + int i; /* number of byte copied */ if (n == 0) - return ; + return; - i = end - start + 1 ; + i = (int) (end - start + 1); if (n < 0) { - p = start + n ; + p = start + n; while (i != 0) { - *p++ = *start++ ; - i-- ; + *p++ = *start++; + i--; } } else { - p = end + n ; + p = end + n; while (i != 0) { - *p-- = *end-- ; - i-- ; + *p-- = *end--; + i--; } } } @@ -672,13 +687,13 @@ int len, /* length of the value string */ char *ip) /* inseration point */ { - SK_VPD_KEY *p ; + SK_VPD_KEY *p; - p = (SK_VPD_KEY *) ip ; - p->p_key[0] = key[0] ; - p->p_key[1] = key[1] ; - p->p_len = (unsigned char) len ; - SK_MEMCPY(&p->p_val,buf,len) ; + p = (SK_VPD_KEY *) ip; + p->p_key[0] = key[0]; + p->p_key[1] = key[1]; + p->p_len = (unsigned char) len; + SK_MEMCPY(&p->p_val,buf,len); } /* @@ -692,46 +707,46 @@ SK_AC *pAC, /* common data base */ char *etp) /* end pointer input position */ { - SK_VPD_KEY *p ; - unsigned char x ; - int i ; + SK_VPD_KEY *p; + unsigned char x; + int i; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, - ("vpd modify endtag at 0x%x = '%c%c'\n",etp,etp[0],etp[1])) ; + ("vpd modify endtag at 0x%x = '%c%c'\n",etp,etp[0],etp[1])); - p = (SK_VPD_KEY *) etp ; + p = (SK_VPD_KEY *) etp; if (p->p_key[0] != 'R' || (p->p_key[1] != 'V' && p->p_key[1] != 'W')) { /* something wrong here, encoding error */ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL, - ("Encoding Error: invalid end tag\n")) ; - return(1) ; + ("Encoding Error: invalid end tag\n")); + return(1); } if (etp > pAC->vpd.vpd_buf + VPD_SIZE/2) { /* create "RW" tag */ - p->p_len = (unsigned char)(pAC->vpd.vpd_buf+VPD_SIZE-etp-3-1) ; - pAC->vpd.v.vpd_free_rw = (int) p->p_len ; - i = pAC->vpd.v.vpd_free_rw ; - etp += 3 ; + p->p_len = (unsigned char)(pAC->vpd.vpd_buf+VPD_SIZE-etp-3-1); + pAC->vpd.v.vpd_free_rw = (int) p->p_len; + i = pAC->vpd.v.vpd_free_rw; + etp += 3; } else { /* create "RV" tag */ - p->p_len = (unsigned char)(pAC->vpd.vpd_buf+VPD_SIZE/2-etp-3) ; - pAC->vpd.v.vpd_free_ro = (int) p->p_len - 1 ; + p->p_len = (unsigned char)(pAC->vpd.vpd_buf+VPD_SIZE/2-etp-3); + pAC->vpd.v.vpd_free_ro = (int) p->p_len - 1; /* setup checksum */ for (i = 0, x = 0; i < VPD_SIZE/2 - p->p_len; i++) { - x += pAC->vpd.vpd_buf[i] ; + x += pAC->vpd.vpd_buf[i]; } - p->p_val = (char) 0 - x ; - i = pAC->vpd.v.vpd_free_ro ; - etp += 4 ; + p->p_val = (char) 0 - x; + i = pAC->vpd.v.vpd_free_ro; + etp += 4; } while (i) { - *etp++ = 0x00 ; - i-- ; + *etp++ = 0x00; + i--; } - return (0) ; + return (0); } /* @@ -756,76 +771,76 @@ int type, /* VPD_RO_KEY or VPD_RW_KEY */ int op) /* operation to do: ADD_KEY or OWR_KEY */ { - SK_VPD_PARA vp ; - char *etp ; /* end tag position */ - int free ; /* remaining space in selected area */ - char *ip ; /* input position inside the VPD buffer */ - int rtv ; /* return code */ - int head ; /* additional haeder bytes to move */ - int found ; /* additinoal bytes if the keyword was found */ + SK_VPD_PARA vp; + char *etp; /* end tag position */ + int free; /* remaining space in selected area */ + char *ip; /* input position inside the VPD buffer */ + int rtv; /* return code */ + int head; /* additional haeder bytes to move */ + int found; /* additinoal bytes if the keyword was found */ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, - ("vpd setup para key = %s, val = %s\n",key,buf)) ; + ("vpd setup para key = %s, val = %s\n",key,buf)); - rtv = 0 ; - ip = 0 ; + rtv = 0; + ip = 0; if (type == VPD_RW_KEY) { /* end tag is "RW" */ - free = pAC->vpd.v.vpd_free_rw ; - etp = pAC->vpd.vpd_buf + (VPD_SIZE - free - 1 - 3) ; + free = pAC->vpd.v.vpd_free_rw; + etp = pAC->vpd.vpd_buf + (VPD_SIZE - free - 1 - 3); } else { /* end tag is "RV" */ - free = pAC->vpd.v.vpd_free_ro ; - etp = pAC->vpd.vpd_buf + (VPD_SIZE/2 - free - 4) ; + free = pAC->vpd.v.vpd_free_ro; + etp = pAC->vpd.vpd_buf + (VPD_SIZE/2 - free - 4); } SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, ("Free RO = %d, Free RW = %d\n", - pAC->vpd.v.vpd_free_ro, pAC->vpd.v.vpd_free_rw)) ; + pAC->vpd.v.vpd_free_ro, pAC->vpd.v.vpd_free_rw)); - head = 0 ; - found = 0 ; + head = 0; + found = 0; if (op == OWR_KEY) { if (vpd_find_para(pAC,key,&vp)) { - found = 3 ; - ip = vp.p_val - 3 ; - free += vp.p_len + 3 ; + found = 3; + ip = vp.p_val - 3; + free += vp.p_len + 3; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, - ("Overwrite Key\n")) ; + ("Overwrite Key\n")); } else { - op = ADD_KEY ; + op = ADD_KEY; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL, - ("Add Key\n")) ; + ("Add Key\n")); } } if (op == ADD_KEY) { - ip = etp ; - vp.p_len = 0 ; - head = 3 ; + ip = etp; + vp.p_len = 0; + head = 3; } if (len + 3 > free) { if (free < 7) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, ("VPD Buffer Overflow, keyword not written\n")); - return (4) ; + return (4); } /* cut it again */ - len = free - 3 ; - rtv = 2 ; + len = free - 3; + rtv = 2; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("VPD Buffer Full, Keyword was cut\n")) ; + ("VPD Buffer Full, Keyword was cut\n")); } - vpd_move_para(ip + vp.p_len + found, etp+2, len-vp.p_len+head) ; - vpd_insert_key(key, buf, len, ip) ; + vpd_move_para(ip + vp.p_len + found, etp+2, len-vp.p_len+head); + vpd_insert_key(key, buf, len, ip); if (vpd_mod_endtag(pAC, etp + len - vp.p_len + head)) { - pAC->vpd.v.vpd_status &= ~VPD_VALID ; + pAC->vpd.v.vpd_status &= ~VPD_VALID; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("VPD Encoding Error\n")) ; - return(6) ; + ("VPD Encoding Error\n")); + return(6); } - return (rtv) ; + return (rtv); } @@ -833,7 +848,7 @@ * Read the contents of the VPD EEPROM and copy it to the * VPD buffer if not already done. * - * return: A pointer to the vpd_status structure. The structure contain + * return: A pointer to the vpd_status structure. The structure contains * this fields. */ SK_VPD_STATUS *VpdStat( @@ -841,9 +856,9 @@ SK_IOC IoC) /* IO Context */ { if (!(pAC->vpd.v.vpd_status & VPD_VALID)) { - (void)VpdInit(pAC,IoC) ; + (void)VpdInit(pAC,IoC); } - return(&pAC->vpd.v) ; + return(&pAC->vpd.v); } @@ -876,67 +891,67 @@ int *len, /* buffer length */ int *elements) /* number of keywords returned */ { - char *v ; - int n ; + char *v; + int n; - SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,("list vpd keys .. ")) ; - *elements = 0 ; + SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,("list vpd keys .. ")); + *elements = 0; if (!(pAC->vpd.v.vpd_status & VPD_VALID)) { if (VpdInit(pAC,IoC) != 0 ) { - *len = 0 ; + *len = 0; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("VPD Init Error, terminated\n")) ; - return(6) ; + ("VPD Init Error, terminated\n")); + return(6); } } if ((signed)strlen(VPD_NAME) + 1 <= *len) { - v = pAC->vpd.vpd_buf ; - strcpy(buf,VPD_NAME) ; - n = strlen(VPD_NAME) + 1 ; - buf += n ; - *elements = 1 ; + v = pAC->vpd.vpd_buf; + strcpy(buf,VPD_NAME); + n = strlen(VPD_NAME) + 1; + buf += n; + *elements = 1; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX, - ("'%c%c' ",v[0],v[1])) ; + ("'%c%c' ",v[0],v[1])); } else { - *len = 0 ; + *len = 0; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("buffer overflow\n")) ; - return(2) ; + ("buffer overflow\n")); + return(2); } - v += 3 + VPD_GET_RES_LEN(v) + 3 ; - for ( ; ; ) { + v += 3 + VPD_GET_RES_LEN(v) + 3; + for (;; ) { /* exit when reaching the "RW" Tag */ if (SK_MEMCMP(VPD_RW,v,2) == 0) { - break ; + break; } if (SK_MEMCMP(VPD_RV,v,2) == 0) { - v += 3 + VPD_GET_VPD_LEN(v) + 3 ; /* skip VPD-W */ - continue ; + v += 3 + VPD_GET_VPD_LEN(v) + 3; /* skip VPD-W */ + continue; } if (n+3 <= *len) { - SK_MEMCPY(buf,v,2) ; - buf += 2 ; - *buf++ = '\0' ; - n += 3 ; - v += 3 + VPD_GET_VPD_LEN(v) ; - *elements += 1 ; + SK_MEMCPY(buf,v,2); + buf += 2; + *buf++ = '\0'; + n += 3; + v += 3 + VPD_GET_VPD_LEN(v); + *elements += 1; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX, - ("'%c%c' ",v[0],v[1])) ; + ("'%c%c' ",v[0],v[1])); } else { - *len = n ; + *len = n; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("buffer overflow\n")) ; - return (2) ; + ("buffer overflow\n")); + return (2); } } - SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,("\n")) ; - *len = n ; - return(0) ; + SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,("\n")); + *len = n; + return(0); } @@ -960,34 +975,34 @@ char *buf, /* buffer where to copy the keyword value */ int *len) /* buffer length */ { - SK_VPD_PARA *p, vp ; + SK_VPD_PARA *p, vp; - SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,("vpd read %s .. ",key)) ; + SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,("vpd read %s .. ",key)); if (!(pAC->vpd.v.vpd_status & VPD_VALID)) { if (VpdInit(pAC,IoC) != 0 ) { - *len = 0 ; + *len = 0; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("vpd init error\n")) ; - return(6) ; + ("vpd init error\n")); + return(6); } } if ((p = vpd_find_para(pAC,key,&vp))) { if (p->p_len > (*(unsigned *)len)-1) { - p->p_len = *len - 1 ; + p->p_len = *len - 1; } - SK_MEMCPY(buf,p->p_val,p->p_len) ; - buf[p->p_len] = '\0' ; - *len = p->p_len ; + SK_MEMCPY(buf,p->p_val,p->p_len); + buf[p->p_len] = '\0'; + *len = p->p_len; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX, ("%c%c%c%c.., len = %d\n", - buf[0],buf[1],buf[2],buf[3],*len)) ; + buf[0],buf[1],buf[2],buf[3],*len)); } else { - *len = 0 ; - SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,("not found\n")) ; - return (1) ; + *len = 0; + SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,("not found\n")); + return (1); } - return (0) ; + return (0); } @@ -1005,9 +1020,9 @@ key[1] < '0' || key[1] > 'Z' || (key[1] > '9' && key[1] < 'A') || strlen(key) != 2) { - return (SK_FALSE) ; + return (SK_FALSE); } - return (SK_TRUE) ; + return (SK_TRUE); } /* @@ -1029,46 +1044,46 @@ char *key, /* keyword to write (allowed values "Yx", "Vx") */ char *buf) /* buffer where the keyword value can be read from */ { - int len ; /* lenght of the keyword to write */ - int rtv ; /* return code */ - int rtv2 ; + int len; /* lenght of the keyword to write */ + int rtv; /* return code */ + int rtv2; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX, - ("vpd write %s = %s\n",key,buf)) ; + ("vpd write %s = %s\n",key,buf)); if ((*key != 'Y' && *key != 'V') || key[1] < '0' || key[1] > 'Z' || (key[1] > '9' && key[1] < 'A') || strlen(key) != 2) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("illegal key tag, keyword not written\n")) ; - return (5) ; + ("illegal key tag, keyword not written\n")); + return (5); } if (!(pAC->vpd.v.vpd_status & VPD_VALID)) { if (VpdInit(pAC,IoC) != 0 ) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("vpd init error\n")) ; - return(6) ; + ("vpd init error\n")); + return(6); } } - rtv = 0 ; - len = strlen(buf) ; + rtv = 0; + len = strlen(buf); if (len > VPD_MAX_LEN) { /* cut it */ - len = VPD_MAX_LEN ; - rtv = 2 ; + len = VPD_MAX_LEN; + rtv = 2; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("keyword to long, cut after %d bytes\n",VPD_MAX_LEN)) ; + ("keyword to long, cut after %d bytes\n",VPD_MAX_LEN)); } if ((rtv2 = VpdSetupPara(pAC,key,buf,len,VPD_RW_KEY,OWR_KEY)) != 0) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("vpd write error\n")) ; - return(rtv2) ; + ("vpd write error\n")); + return(rtv2); } - return (rtv) ; + return (rtv); } /* @@ -1088,15 +1103,15 @@ SK_IOC IoC, /* IO Context */ char *key) /* keyword to read (e.g. "MN") */ { - SK_VPD_PARA *p, vp ; - char *etp ; + SK_VPD_PARA *p, vp; + char *etp; - SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("vpd delete key %s\n",key)) ; + SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("vpd delete key %s\n",key)); if (!(pAC->vpd.v.vpd_status & VPD_VALID)) { if (VpdInit(pAC,IoC) != 0 ) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("vpd init error\n")) ; - return(6) ; + ("vpd init error\n")); + return(6); } } @@ -1104,27 +1119,27 @@ if (p->p_val < pAC->vpd.vpd_buf + VPD_SIZE/2) { /* try to delete read only keyword */ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("cannot delete RO keyword\n")) ; - return (5) ; + ("cannot delete RO keyword\n")); + return (5); } - etp = pAC->vpd.vpd_buf + (VPD_SIZE-pAC->vpd.v.vpd_free_rw-1-3) ; + etp = pAC->vpd.vpd_buf + (VPD_SIZE-pAC->vpd.v.vpd_free_rw-1-3); vpd_move_para(vp.p_val+vp.p_len, etp+2, - - ((int)(vp.p_len + 3))) ; + - ((int)(vp.p_len + 3))); if (vpd_mod_endtag(pAC, etp - vp.p_len - 3)) { - pAC->vpd.v.vpd_status &= ~VPD_VALID ; + pAC->vpd.v.vpd_status &= ~VPD_VALID; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("vpd encoding error\n")) ; - return(6) ; + ("vpd encoding error\n")); + return(6); } } else { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("keyword not found\n")) ; - return (1) ; + ("keyword not found\n")); + return (1); } - return (0) ; + return (0); } /* @@ -1138,18 +1153,18 @@ SK_AC *pAC, /* Adapters context */ SK_IOC IoC) /* IO Context */ { - SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("vpd update .. ")) ; + SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("vpd update .. ")); if (pAC->vpd.v.vpd_status & VPD_VALID) { if (VpdTransferBlock(pAC,IoC,pAC->vpd.vpd_buf + VPD_SIZE/2, VPD_SIZE/2, VPD_SIZE/2, VPD_WRITE) != VPD_SIZE/2) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("transfer timed out\n")) ; - return(3) ; + ("transfer timed out\n")); + return(3); } } - SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("done\n")) ; - return (0) ; + SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("done\n")); + return (0); } @@ -1169,32 +1184,32 @@ SK_IOC IoC, /* IO Context */ char *msg) /* error log message */ { - SK_VPD_PARA *v, vf ; /* VF */ - int len ; + SK_VPD_PARA *v, vf; /* VF */ + int len; SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX, - ("vpd error log msg %s\n",msg)) ; + ("vpd error log msg %s\n",msg)); if (!(pAC->vpd.v.vpd_status & VPD_VALID)) { if (VpdInit(pAC,IoC) != 0 ) { SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR, - ("vpd init error\n")) ; - return ; + ("vpd init error\n")); + return; } } - len = strlen(msg) ; + len = strlen(msg); if (len > VPD_MAX_LEN) { /* cut it */ - len = VPD_MAX_LEN ; + len = VPD_MAX_LEN; } if ((v = vpd_find_para(pAC,VPD_VF,&vf))) { - SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("overwrite VL\n")) ; - (void)VpdSetupPara(pAC,VPD_VL,msg,len,VPD_RW_KEY,OWR_KEY) ; + SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("overwrite VL\n")); + (void)VpdSetupPara(pAC,VPD_VL,msg,len,VPD_RW_KEY,OWR_KEY); } else { - SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("write VF\n")) ; - (void)VpdSetupPara(pAC,VPD_VF,msg,len,VPD_RW_KEY,ADD_KEY) ; + SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("write VF\n")); + (void)VpdSetupPara(pAC,VPD_VF,msg,len,VPD_RW_KEY,ADD_KEY); } - (void)VpdUpdate(pAC,IoC) ; + (void)VpdUpdate(pAC,IoC); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sk98lin/skxmac2.c linux/drivers/net/sk98lin/skxmac2.c --- v2.4.0-test8/linux/drivers/net/sk98lin/skxmac2.c Tue Nov 23 22:42:21 1999 +++ linux/drivers/net/sk98lin/skxmac2.c Fri Sep 15 14:34:19 2000 @@ -2,8 +2,8 @@ * * Name: skxmac2.c * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.49 $ - * Date: $Date: 1999/11/22 08:12:13 $ + * Version: $Revision: 1.53 $ + * Date: $Date: 2000/07/27 12:22:11 $ * Purpose: Contains functions to initialize the XMAC II * ******************************************************************************/ @@ -13,8 +13,6 @@ * (C)Copyright 1998,1999 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * - * See the file "skge.c" for further information. - * * 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 @@ -29,6 +27,18 @@ * History: * * $Log: skxmac2.c,v $ + * Revision 1.53 2000/07/27 12:22:11 gklug + * fix: possible endless loop in XmHardRst. + * + * Revision 1.52 2000/05/22 08:48:31 malthoff + * Fix: #10523 errata valid for all BCOM PHYs. + * + * Revision 1.51 2000/05/17 12:52:18 malthoff + * Fixes BCom link errata (#10523). + * + * Revision 1.50 1999/11/22 13:40:14 cgoos + * Changed license header to GPL. + * * Revision 1.49 1999/11/22 08:12:13 malthoff * Add workaround for power consumption feature of Bcom C0 chip. * @@ -224,7 +234,7 @@ /* local variables ************************************************************/ static const char SysKonnectFileId[] = - "@(#)$Id: skxmac2.c,v 1.49 1999/11/22 08:12:13 malthoff Exp $ (C) SK "; + "@(#)$Id: skxmac2.c,v 1.53 2000/07/27 12:22:11 gklug Exp $ (C) SK "; /* BCOM PHY magic pattern list */ typedef struct s_PhyHack { @@ -558,6 +568,10 @@ * register (Timing requirements: Broadcom: 400ns, Level One: * none, National: 80ns). * + * ATTENTION: + * It is absolutely neccessary to reset the SW_RST Bit first + * before calling this function. + * * Returns: * nothing */ @@ -568,6 +582,7 @@ { SK_U16 Word; int i; + int TOut; SK_U32 Reg; for (i=0; i<4; i++) { @@ -575,12 +590,25 @@ /* bit contains buttoms to press */ SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), (SK_U16) MFF_CLR_MAC_RST); - SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), - (SK_U16) MFF_SET_MAC_RST); + + TOut = 0; do { + TOut ++; + if (TOut > 10000) { + /* + * Adapter seems to be in RESET state. + * Registers cannot be written. + */ + return; + } + + SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), + (SK_U16) MFF_SET_MAC_RST); SK_IN16(IoC,MR_ADDR(Port,TX_MFF_CTRL1), &Word); } while ((Word & MFF_SET_MAC_RST) == 0); } + + /* For external PHYs there must be special handling */ if (pAC->GIni.GP[Port].PhyType != SK_PHY_XMAC) { /* reset external PHY */ @@ -696,6 +724,11 @@ i++; } } + /* Workaround BCOM Errata (#10523) for all BCom PHYs*/ + /* Disable Power Management after reset */ + PHY_READ(IoC, pPrt, Port, PHY_BCOM_AUX_CTRL, &SWord); + PHY_WRITE(IoC, pPrt, Port, PHY_BCOM_AUX_CTRL, + SWord | PHY_B_AC_DIS_PM); /* * PHY LED initialization is performed in @@ -1845,6 +1878,7 @@ SK_GEPORT *pPrt; SK_U16 Reg ; /* 16bit register value */ SK_U16 IntMask; /* XMac interrupt mask */ + SK_U16 SWord; pPrt = &pAC->GIni.GP[Port]; @@ -1892,6 +1926,11 @@ } switch (pPrt->PhyType) { case SK_PHY_BCOM: + /* Workaround BCOM Errata (#10523) for all BCom Phys */ + /* Enable Power Management after link up */ + PHY_READ(IoC, pPrt, Port, PHY_BCOM_AUX_CTRL, &SWord); + PHY_WRITE(IoC, pPrt, Port, PHY_BCOM_AUX_CTRL, + SWord & ~PHY_B_AC_DIS_PM); PHY_WRITE(IoC, pPrt, Port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK); break; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/skfp/skfddi.c linux/drivers/net/skfp/skfddi.c --- v2.4.0-test8/linux/drivers/net/skfp/skfddi.c Fri Jul 14 12:12:11 2000 +++ linux/drivers/net/skfp/skfddi.c Fri Sep 15 14:34:36 2000 @@ -1654,7 +1654,8 @@ virt = mac_drv_get_space(smc, size); - size = (u_int) ((0 - (unsigned long) virt) & 15UL); + size = (u_int) (16 - (((unsigned long) virt) & 15UL)); + size = size % 16; PRINTK("Allocate %u bytes alignment gap ", size); PRINTK("for descriptor memory.\n"); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/sunlance.c linux/drivers/net/sunlance.c --- v2.4.0-test8/linux/drivers/net/sunlance.c Wed Aug 23 18:36:38 2000 +++ linux/drivers/net/sunlance.c Sun Sep 17 09:41:29 2000 @@ -1332,6 +1332,7 @@ /* Make certain the data structures used by the LANCE are aligned. */ dev->priv = (void *)(((unsigned long)dev->priv + 7) & ~7); lp = (struct lance_private *) dev->priv; + spin_lock_init(&lp->lock); /* Copy the IDPROM ethernet address to the device structure, later we * will copy the address in the device structure to the lance diff -u --recursive --new-file v2.4.0-test8/linux/drivers/net/wan/Makefile linux/drivers/net/wan/Makefile --- v2.4.0-test8/linux/drivers/net/wan/Makefile Wed Aug 23 18:36:38 2000 +++ linux/drivers/net/wan/Makefile Sun Sep 17 09:41:29 2000 @@ -35,6 +35,7 @@ obj-$(CONFIG_COMX_PROTO_FR) += comx-proto-fr.o obj-$(CONFIG_COSA) += syncppp.o cosa.o obj-$(CONFIG_LANMEDIA) += syncppp.o +obj-$(CONFIG_X25_ASY) += x25_asy.o ifeq ($(CONFIG_LANMEDIA),y) SUB_DIRS += lmc diff -u --recursive --new-file v2.4.0-test8/linux/drivers/parport/ChangeLog linux/drivers/parport/ChangeLog --- v2.4.0-test8/linux/drivers/parport/ChangeLog Thu Jul 27 17:38:00 2000 +++ linux/drivers/parport/ChangeLog Sun Sep 17 09:45:07 2000 @@ -1,3 +1,8 @@ +2000-09-16 Cesar Eduardo Barros + + * parport_pc.c (sio_via_686a_probe): Handle case + where hardware returns 255 for IRQ or DMA. + 2000-07-20 Eddie C. Dost * share.c (attach_driver_chain): attach[i](port) needs to be diff -u --recursive --new-file v2.4.0-test8/linux/drivers/parport/parport_pc.c linux/drivers/parport/parport_pc.c --- v2.4.0-test8/linux/drivers/parport/parport_pc.c Wed Aug 9 19:19:50 2000 +++ linux/drivers/parport/parport_pc.c Sun Sep 17 09:45:07 2000 @@ -2239,11 +2239,13 @@ irq = ((irq >> 4) & 0x0F); /* filter bogus IRQs */ + /* 255 means NONE, and is bogus as well */ switch (irq) { case 0: case 2: case 8: case 13: + case 255: irq = PARPORT_IRQ_NONE; break; @@ -2252,7 +2254,9 @@ } /* if ECP not enabled, DMA is not enabled, assumed bogus 'dma' value */ - if (!have_eppecp) + /* 255 means NONE. Looks like some BIOS don't set the DMA correctly + * even on ECP mode */ + if (!have_eppecp || dma == 255) dma = PARPORT_DMA_NONE; /* finally, do the probe with values obtained */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/pci/pci.c linux/drivers/pci/pci.c --- v2.4.0-test8/linux/drivers/pci/pci.c Fri Jun 23 21:55:09 2000 +++ linux/drivers/pci/pci.c Sun Sep 17 10:01:49 2000 @@ -657,134 +657,82 @@ return child; } -/* - * A CardBus bridge is basically the same as a regular PCI bridge, - * except we don't scan behind it because it will be changing. - */ -static int __init pci_scan_cardbus(struct pci_bus *bus, struct pci_dev *dev, int busnr) -{ - int i; - unsigned short cr; - unsigned int buses; - struct pci_bus *child; - - /* - * Insert it into the tree of buses. - */ - DBG("Scanning CardBus bridge %s\n", dev->slot_name); - child = pci_add_new_bus(bus, dev, ++busnr); - - for (i = 0; i < 4; i++) - child->resource[i] = &dev->resource[PCI_BRIDGE_RESOURCES+i]; - - /* - * Maybe we'll have another bus behind this one? - */ - child->subordinate = ++busnr; - sprintf(child->name, "PCI CardBus #%02x", child->number); - - /* - * Clear all status bits and turn off memory, - * I/O and master enables. - */ - pci_read_config_word(dev, PCI_COMMAND, &cr); - pci_write_config_word(dev, PCI_COMMAND, 0x0000); - pci_write_config_word(dev, PCI_STATUS, 0xffff); - - /* - * Read the existing primary/secondary/subordinate bus - * number configuration to determine if the bridge - * has already been configured by the system. If so, - * do not modify the configuration, merely note it. - */ - pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses); - if ((buses & 0xFFFFFF) != 0 && ! pcibios_assign_all_busses()) { - child->primary = buses & 0xFF; - child->secondary = (buses >> 8) & 0xFF; - child->subordinate = (buses >> 16) & 0xFF; - child->number = child->secondary; - if (child->subordinate > busnr) - busnr = child->subordinate; - } else { - /* - * Configure the bus numbers for this bridge: - */ - buses &= 0xff000000; - buses |= - (((unsigned int)(child->primary) << 0) | - ((unsigned int)(child->secondary) << 8) | - ((unsigned int)(child->subordinate) << 16)); - pci_write_config_dword(dev, PCI_PRIMARY_BUS, buses); - } - pci_write_config_word(dev, PCI_COMMAND, cr); - return busnr; -} - static unsigned int __init pci_do_scan_bus(struct pci_bus *bus); /* - * If it's a bridge, scan the bus behind it. + * If it's a bridge, configure it and scan the bus behind it. + * For CardBus bridges, we don't scan behind as the devices will + * be handled by the bridge driver itself. + * + * We need to process bridges in two passes -- first we scan those + * already configured by the BIOS and after we are done with all of + * them, we proceed to assigning numbers to the remaining buses in + * order to avoid overlaps between old and new bus numbers. */ -static int __init pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max) +static int __init pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass) { unsigned int buses; unsigned short cr; struct pci_bus *child; + int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); - /* - * Insert it into the tree of buses. - */ - DBG("Scanning behind PCI bridge %s\n", dev->slot_name); - child = pci_add_new_bus(bus, dev, ++max); - sprintf(child->name, "PCI Bus #%02x", child->number); - - /* - * Clear all status bits and turn off memory, - * I/O and master enables. - */ - pci_read_config_word(dev, PCI_COMMAND, &cr); - pci_write_config_word(dev, PCI_COMMAND, 0x0000); - pci_write_config_word(dev, PCI_STATUS, 0xffff); - - /* - * Read the existing primary/secondary/subordinate bus - * number configuration to determine if the PCI bridge - * has already been configured by the system. If so, - * do not modify the configuration, merely note it. - */ pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses); - if ((buses & 0xFFFFFF) != 0 && ! pcibios_assign_all_busses()) { - unsigned int cmax; + DBG("Scanning behind PCI bridge %s, config %06x, pass %d\n", dev->slot_name, buses & 0xffffff, pass); + if ((buses & 0xffffff) && !pcibios_assign_all_busses()) { + /* + * Bus already configured by firmware, process it in the first + * pass and just note the configuration. + */ + if (pass) + return max; + child = pci_add_new_bus(bus, dev, 0); child->primary = buses & 0xFF; child->secondary = (buses >> 8) & 0xFF; child->subordinate = (buses >> 16) & 0xFF; child->number = child->secondary; - cmax = pci_do_scan_bus(child); - if (cmax > max) max = cmax; + if (!is_cardbus) { + unsigned int cmax = pci_do_scan_bus(child); + if (cmax > max) max = cmax; + } } else { /* - * Configure the bus numbers for this bridge: + * We need to assign a number to this bus which we always + * do in the second pass. We also keep all address decoders + * on the bridge disabled during scanning. FIXME: Why? */ - buses &= 0xff000000; - buses |= - (((unsigned int)(child->primary) << 0) | - ((unsigned int)(child->secondary) << 8) | - ((unsigned int)(child->subordinate) << 16)); - pci_write_config_dword(dev, PCI_PRIMARY_BUS, buses); + if (!pass) + return max; + pci_read_config_word(dev, PCI_COMMAND, &cr); + pci_write_config_word(dev, PCI_COMMAND, 0x0000); + pci_write_config_word(dev, PCI_STATUS, 0xffff); + child = pci_add_new_bus(bus, dev, ++max); + buses = (buses & 0xff000000) + | ((unsigned int)(child->primary) << 0) + | ((unsigned int)(child->secondary) << 8) + | ((unsigned int)(child->subordinate) << 16); /* - * Now we can scan all subordinate buses: + * We need to blast all three values with a single write. */ - max = pci_do_scan_bus(child); + pci_write_config_dword(dev, PCI_PRIMARY_BUS, buses); + if (!is_cardbus) { + /* Now we can scan all subordinate buses... */ + max = pci_do_scan_bus(child); + } else { + /* + * For CardBus bridges, we leave 4 bus numbers + * as cards with a PCI-to-PCI bridge can be + * inserted later. + */ + max += 3; + } /* - * Set the subordinate bus number to its real - * value: + * Set the subordinate bus number to its real value. */ child->subordinate = max; - buses = (buses & 0xff00ffff) - | ((unsigned int)(child->subordinate) << 16); - pci_write_config_dword(dev, PCI_PRIMARY_BUS, buses); + pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); + pci_write_config_word(dev, PCI_COMMAND, cr); } - pci_write_config_word(dev, PCI_COMMAND, cr); + sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number); return max; } @@ -933,7 +881,7 @@ static unsigned int __init pci_do_scan_bus(struct pci_bus *bus) { - unsigned int devfn, max; + unsigned int devfn, max, pass; struct list_head *ln; struct pci_dev *dev, dev0; @@ -957,17 +905,12 @@ */ DBG("Fixups for bus %02x\n", bus->number); pcibios_fixup_bus(bus); - for (ln=bus->devices.next; ln != &bus->devices; ln=ln->next) { - dev = pci_dev_b(ln); - switch (dev->class >> 8) { - case PCI_CLASS_BRIDGE_PCI: - max = pci_scan_bridge(bus, dev, max); - break; - case PCI_CLASS_BRIDGE_CARDBUS: - max = pci_scan_cardbus(bus, dev, max); - break; + for (pass=0; pass < 2; pass++) + for (ln=bus->devices.next; ln != &bus->devices; ln=ln->next) { + dev = pci_dev_b(ln); + if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) + max = pci_scan_bridge(bus, dev, max, pass); } - } /* * We've scanned the bus and so we know all about what's on diff -u --recursive --new-file v2.4.0-test8/linux/drivers/pci/pci.ids linux/drivers/pci/pci.ids --- v2.4.0-test8/linux/drivers/pci/pci.ids Wed Aug 23 18:36:38 2000 +++ linux/drivers/pci/pci.ids Fri Sep 15 16:28:25 2000 @@ -1471,9 +1471,9 @@ 6055 3c556 Laptop Hurricane 5057 3c575 [Megahertz] 10/100 LAN CardBus 10b7 5a57 3C575 Megahertz 10/100 LAN Cardbus PC Card - 5157 3c575 [Megahertz] 10/100 LAN CardBus + 5157 3CCFE575BT Cyclone CardBus 10b7 5b57 3C575 Megahertz 10/100 LAN Cardbus PC Card - 5257 3CCFE575CT Cyclone CardBus + 5257 3CCFE575CT Tornado CardBus 5900 3c590 10BaseT [Vortex] 5920 3c592 EISA 10mbps Demon/Vortex 5950 3c595 100BaseTX [Vortex] @@ -1483,8 +1483,8 @@ 5b57 3c595 [Megahertz] 10/100 LAN CardBus 10b7 5b57 3C575 Megahertz 10/100 LAN Cardbus PC Card 6560 3CCFE656 Cyclone CardBus - 6562 3CCFEM656 [id 6562] Cyclone CardBus - 6564 3CCFEM656 [id 6564] Cyclone CardBus + 6562 3CCFEM656B Cyclone CardBus + 6564 3CXFEM656C Tornado CardBus 7646 3cSOHO100-TX Hurricane 8811 Token ring 9000 3c900 10BaseT [Boomerang] diff -u --recursive --new-file v2.4.0-test8/linux/drivers/pcmcia/cardbus.c linux/drivers/pcmcia/cardbus.c --- v2.4.0-test8/linux/drivers/pcmcia/cardbus.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/pcmcia/cardbus.c Fri Sep 15 16:31:09 2000 @@ -58,11 +58,6 @@ #include #include -#ifndef PCMCIA_DEBUG -#define PCMCIA_DEBUG 1 -#endif -static int pc_debug = PCMCIA_DEBUG; - #define IN_CARD_SERVICES #include #include @@ -72,6 +67,11 @@ #include #include "cs_internal.h" #include "rsrc_mgr.h" + +#ifndef PCMCIA_DEBUG +#define PCMCIA_DEBUG 1 +#endif +static int pc_debug = PCMCIA_DEBUG; /*====================================================================*/ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/pcmcia/cs.c linux/drivers/pcmcia/cs.c --- v2.4.0-test8/linux/drivers/pcmcia/cs.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/pcmcia/cs.c Fri Sep 15 16:31:09 2000 @@ -103,13 +103,13 @@ #define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i") -INT_MODULE_PARM(setup_delay, HZ/20); /* ticks */ -INT_MODULE_PARM(resume_delay, HZ/5); /* ticks */ -INT_MODULE_PARM(shutdown_delay, HZ/40); /* ticks */ -INT_MODULE_PARM(vcc_settle, 400); /* msecs */ +INT_MODULE_PARM(setup_delay, 10); /* centiseconds */ +INT_MODULE_PARM(resume_delay, 20); /* centiseconds */ +INT_MODULE_PARM(shutdown_delay, 3); /* centiseconds */ +INT_MODULE_PARM(vcc_settle, 40); /* centiseconds */ INT_MODULE_PARM(reset_time, 10); /* usecs */ -INT_MODULE_PARM(unreset_delay, 100); /* msecs */ -INT_MODULE_PARM(unreset_check, 100); /* msecs */ +INT_MODULE_PARM(unreset_delay, 10); /* centiseconds */ +INT_MODULE_PARM(unreset_check, 10); /* centiseconds */ INT_MODULE_PARM(unreset_limit, 30); /* unreset_check's */ /* Access speed for attribute memory windows */ @@ -446,10 +446,13 @@ static int send_event(socket_info_t *s, event_t event, int priority); -static void msleep(unsigned int msec) +/* + * Sleep for n_cs centiseconds (1 cs = 1/100th of a second) + */ +static void cs_sleep(unsigned int n_cs) { current->state = TASK_INTERRUPTIBLE; - schedule_timeout( (msec * HZ + 999) / 1000); + schedule_timeout( (n_cs * HZ + 99) / 100); } static void shutdown_socket(socket_info_t *s) @@ -504,7 +507,7 @@ if (!(val & SS_PENDING)) break; if (--setup_timeout) { - msleep(100); + cs_sleep(10); continue; } printk(KERN_NOTICE "cs: socket %p voltage interrogation" @@ -516,7 +519,7 @@ if (val & SS_DETECT) { DEBUG(1, "cs: setup_socket(%p): applying power\n", s); s->state |= SOCKET_PRESENT; - s->socket.flags = 0; + s->socket.flags &= SS_DEBOUNCED; if (val & SS_3VCARD) s->socket.Vcc = s->socket.Vpp = 33; else if (!(val & SS_XVCARD)) @@ -533,7 +536,7 @@ #endif } set_socket(s, &s->socket); - msleep(vcc_settle); + cs_sleep(vcc_settle); reset_socket(s); ret = 1; } else { @@ -561,7 +564,7 @@ udelay((long)reset_time); s->socket.flags &= ~SS_RESET; set_socket(s, &s->socket); - msleep(unreset_delay); + cs_sleep(unreset_delay/10); unreset_socket(s); } /* reset_socket */ @@ -580,11 +583,11 @@ break; DEBUG(2, "cs: socket %d not ready yet\n", s->sock); if (--setup_timeout) { - msleep(unreset_check); + cs_sleep(unreset_check); continue; } printk(KERN_NOTICE "cs: socket %p timed out during" - " reset\n", s); + " reset. Try increasing setup_delay.\n", s); s->state &= ~EVENT_MASK; return; } @@ -656,7 +659,7 @@ DEBUG(0, "cs: flushing pending setup\n"); s->state &= ~EVENT_MASK; } - msleep(shutdown_delay); + cs_sleep(shutdown_delay); s->state &= ~SOCKET_PRESENT; shutdown_socket(s); } @@ -679,11 +682,13 @@ } s->state |= SOCKET_SETUP_PENDING; if (s->state & SOCKET_SUSPEND) - msleep(resume_delay); + cs_sleep(resume_delay); else - msleep(setup_delay); + cs_sleep(setup_delay); + s->socket.flags |= SS_DEBOUNCED; if (setup_socket(s) == 0) s->state &= ~SOCKET_SETUP_PENDING; + s->socket.flags &= ~SS_DEBOUNCED; } } if (events & SS_BATDEAD) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/pcmcia/yenta.c linux/drivers/pcmcia/yenta.c --- v2.4.0-test8/linux/drivers/pcmcia/yenta.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/pcmcia/yenta.c Fri Sep 15 16:31:09 2000 @@ -233,6 +233,11 @@ { u16 bridge; + if (state->flags & SS_DEBOUNCED) { + /* The insertion debounce period has ended. Clear any pending insertion events */ + socket->events &= ~SS_DETECT; + state->flags &= ~SS_DEBOUNCED; /* SS_DEBOUNCED is oneshot */ + } yenta_set_power(socket, state); socket->io_irq = state->io_irq; bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~(CB_BRIDGE_CRST | CB_BRIDGE_INTR); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/BusLogic.c linux/drivers/scsi/BusLogic.c --- v2.4.0-test8/linux/drivers/scsi/BusLogic.c Mon Jul 10 16:47:24 2000 +++ linux/drivers/scsi/BusLogic.c Mon Sep 11 08:41:07 2000 @@ -61,7 +61,7 @@ */ static int - BusLogic_DriverOptionsCount = 0; + BusLogic_DriverOptionsCount; /* @@ -79,7 +79,7 @@ */ #ifdef MODULE -static char *BusLogic = NULL; +static char *BusLogic; MODULE_PARM(BusLogic, "s"); #endif @@ -90,7 +90,7 @@ */ static BusLogic_ProbeOptions_T - BusLogic_ProbeOptions = { 0 }; + BusLogic_ProbeOptions; /* @@ -99,7 +99,7 @@ */ static BusLogic_GlobalOptions_T - BusLogic_GlobalOptions = { 0 }; + BusLogic_GlobalOptions; /* @@ -108,8 +108,8 @@ */ static BusLogic_HostAdapter_T - *BusLogic_FirstRegisteredHostAdapter = NULL, - *BusLogic_LastRegisteredHostAdapter = NULL; + *BusLogic_FirstRegisteredHostAdapter, + *BusLogic_LastRegisteredHostAdapter; /* @@ -117,7 +117,7 @@ */ static int - BusLogic_ProbeInfoCount = 0; + BusLogic_ProbeInfoCount; /* @@ -128,7 +128,7 @@ */ static BusLogic_ProbeInfo_T - *BusLogic_ProbeInfoList = NULL; + *BusLogic_ProbeInfoList; /* diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/Makefile linux/drivers/scsi/Makefile --- v2.4.0-test8/linux/drivers/scsi/Makefile Wed Aug 9 19:19:50 2000 +++ linux/drivers/scsi/Makefile Sun Sep 17 10:09:29 2000 @@ -30,7 +30,7 @@ obj-$(CONFIG_SCSI) += scsi_mod.o obj-$(CONFIG_CHR_DEV_ST) += st.o -obj-$(CONFIG_BLK_DEV_SD) += sd.o +obj-$(CONFIG_BLK_DEV_SD) += sd_mod.o obj-$(CONFIG_BLK_DEV_SR) += sr_mod.o obj-$(CONFIG_CHR_DEV_SG) += sg.o @@ -151,6 +151,9 @@ scsi_mod.o: $(scsi_mod-objs) $(LD) -r -o $@ $(scsi_mod-objs) + +sd_mod.o: sd.o + $(LD) -r -o $@ sd.o sr_mod.o: $(sr_mod-objs) $(LD) -r -o $@ $(sr_mod-objs) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/pci2220i.c linux/drivers/scsi/pci2220i.c --- v2.4.0-test8/linux/drivers/scsi/pci2220i.c Fri Jun 23 21:55:10 2000 +++ linux/drivers/scsi/pci2220i.c Sun Sep 17 09:45:06 2000 @@ -2509,7 +2509,7 @@ init_timer (&padapter->reconTimer); padapter->reconTimer.function = ReconTimerExpiry; padapter->reconTimer.data = (unsigned long)padapter; - printk("\nPCI-%sI EIDE CONTROLLER: at I/O = %lX/%lX IRQ = %ld\n", str, padapter->basePort, padapter->regBase, irq); + printk("\nPCI-%sI EIDE CONTROLLER: at I/O = %lX/%lX IRQ = %d\n", str, padapter->basePort, padapter->regBase, irq); printk("Version %s, Compiled %s %s\n\n", PCI2220I_VERSION, __DATE__, __TIME__); } /**************************************************************** diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/qlogicfas.c linux/drivers/scsi/qlogicfas.c --- v2.4.0-test8/linux/drivers/scsi/qlogicfas.c Wed Feb 16 17:03:52 2000 +++ linux/drivers/scsi/qlogicfas.c Sun Sep 17 09:51:57 2000 @@ -643,8 +643,10 @@ ip[0] = 0xff; ip[1] = 0x3f; ip[2] = disk->capacity / (ip[0] * ip[1]); +#if 0 if (ip[2] > 1023) ip[2] = 1023; +#endif } return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/scsi.c linux/drivers/scsi/scsi.c --- v2.4.0-test8/linux/drivers/scsi/scsi.c Wed Aug 9 19:19:50 2000 +++ linux/drivers/scsi/scsi.c Sun Sep 17 10:09:29 2000 @@ -384,7 +384,7 @@ * return NULL. */ SCpnt = NULL; - break; + goto busy; } } /* @@ -402,6 +402,7 @@ if (SCpnt) { break; } + busy: /* * If we have been asked to wait for a free block, then * wait here. @@ -495,30 +496,7 @@ return SCpnt; } -/* - * Function: scsi_release_command - * - * Purpose: Release a command block. - * - * Arguments: SCpnt - command block we are releasing. - * - * Notes: The command block can no longer be used by the caller once - * this funciton is called. This is in effect the inverse - * of scsi_allocate_device. Note that we also must perform - * a couple of additional tasks. We must first wake up any - * processes that might have blocked waiting for a command - * block, and secondly we must hit the queue handler function - * to make sure that the device is busy. - * - * The idea is that a lot of the mid-level internals gunk - * gets hidden in this function. Upper level drivers don't - * have any chickens to wave in the air to get things to - * work reliably. - * - * This function is deprecated, and drivers should be - * rewritten to use Scsi_Request instead of Scsi_Cmnd. - */ -void scsi_release_command(Scsi_Cmnd * SCpnt) +inline void __scsi_release_command(Scsi_Cmnd * SCpnt) { unsigned long flags; Scsi_Device * SDpnt; @@ -562,6 +540,43 @@ * they wake up. */ wake_up(&SDpnt->scpnt_wait); +} + +/* + * Function: scsi_release_command + * + * Purpose: Release a command block. + * + * Arguments: SCpnt - command block we are releasing. + * + * Notes: The command block can no longer be used by the caller once + * this funciton is called. This is in effect the inverse + * of scsi_allocate_device. Note that we also must perform + * a couple of additional tasks. We must first wake up any + * processes that might have blocked waiting for a command + * block, and secondly we must hit the queue handler function + * to make sure that the device is busy. Note - there is an + * option to not do this - there were instances where we could + * recurse too deeply and blow the stack if this happened + * when we were indirectly called from the request function + * itself. + * + * The idea is that a lot of the mid-level internals gunk + * gets hidden in this function. Upper level drivers don't + * have any chickens to wave in the air to get things to + * work reliably. + * + * This function is deprecated, and drivers should be + * rewritten to use Scsi_Request instead of Scsi_Cmnd. + */ +void scsi_release_command(Scsi_Cmnd * SCpnt) +{ + request_queue_t *q; + Scsi_Device * SDpnt; + + SDpnt = SCpnt->device; + + __scsi_release_command(SCpnt); /* * Finally, hit the queue request function to make sure that @@ -569,12 +584,8 @@ * This won't block - if the device cannot take any more, life * will go on. */ - { - request_queue_t *q; - - q = &SDpnt->request_queue; - scsi_queue_next_request(q, NULL); - } + q = &SDpnt->request_queue; + scsi_queue_next_request(q, NULL); } /* diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/scsi.h linux/drivers/scsi/scsi.h --- v2.4.0-test8/linux/drivers/scsi/scsi.h Wed Apr 26 16:34:08 2000 +++ linux/drivers/scsi/scsi.h Sun Sep 17 10:09:29 2000 @@ -492,6 +492,7 @@ extern void scsi_finish_command(Scsi_Cmnd *); extern int scsi_retry_command(Scsi_Cmnd *); extern Scsi_Cmnd *scsi_allocate_device(Scsi_Device *, int, int); +extern void __scsi_release_command(Scsi_Cmnd *); extern void scsi_release_command(Scsi_Cmnd *); extern void scsi_do_cmd(Scsi_Cmnd *, const void *cmnd, void *buffer, unsigned bufflen, diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/scsi_lib.c linux/drivers/scsi/scsi_lib.c --- v2.4.0-test8/linux/drivers/scsi/scsi_lib.c Mon Jul 10 16:47:24 2000 +++ linux/drivers/scsi/scsi_lib.c Sun Sep 17 10:09:29 2000 @@ -381,6 +381,8 @@ * uptodate - 1 if I/O indicates success, 0 for I/O error. * sectors - number of sectors we want to mark. * requeue - indicates whether we should requeue leftovers. + * frequeue - indicates that if we release the command block + * that the queue request function should be called. * * Lock status: Assumed that lock is not held upon entry. * @@ -395,10 +397,12 @@ static Scsi_Cmnd *__scsi_end_request(Scsi_Cmnd * SCpnt, int uptodate, int sectors, - int requeue) + int requeue, + int frequeue) { struct request *req; struct buffer_head *bh; + Scsi_Device * SDpnt; ASSERT_LOCK(&io_request_lock, 0); @@ -458,11 +462,20 @@ } add_blkdev_randomness(MAJOR(req->rq_dev)); + SDpnt = SCpnt->device; + /* * This will goose the queue request function at the end, so we don't * need to worry about launching another command. */ - scsi_release_command(SCpnt); + __scsi_release_command(SCpnt); + + if( frequeue ) { + request_queue_t *q; + + q = &SDpnt->request_queue; + scsi_queue_next_request(q, NULL); + } return NULL; } @@ -488,7 +501,7 @@ */ Scsi_Cmnd *scsi_end_request(Scsi_Cmnd * SCpnt, int uptodate, int sectors) { - return __scsi_end_request(SCpnt, uptodate, sectors, 1); + return __scsi_end_request(SCpnt, uptodate, sectors, 1, 1); } /* @@ -648,7 +661,8 @@ SCpnt = __scsi_end_request(SCpnt, 1, good_sectors, - result == 0); + result == 0, + 1); /* * If the command completed without error, then either finish off the @@ -718,8 +732,8 @@ } break; case NOT_READY: - printk(KERN_INFO "Device %x not ready.\n", - SCpnt->request.rq_dev); + printk(KERN_INFO "Device %s not ready.\n", + kdevname(SCpnt->request.rq_dev)); SCpnt = scsi_end_request(SCpnt, 0, this_count); return; break; @@ -962,6 +976,7 @@ } } else { + SRpnt = NULL; STpnt = scsi_get_request_dev(req); if (!STpnt) { panic("Unable to find device associated with request"); @@ -1010,7 +1025,7 @@ */ blkdev_dequeue_request(req); - if (req != &SCpnt->request) { + if (req != &SCpnt->request && req != &SRpnt->sr_request ) { memcpy(&SCpnt->request, req, sizeof(struct request)); /* @@ -1048,8 +1063,12 @@ * get those allocated here. */ if (!SDpnt->scsi_init_io_fn(SCpnt)) { - scsi_end_request(SCpnt, 0, - SCpnt->request.nr_sectors); + SCpnt = __scsi_end_request(SCpnt, 0, + SCpnt->request.nr_sectors, 0, 0); + if( SCpnt != NULL ) + { + panic("Should not have leftover blocks\n"); + } spin_lock_irq(&io_request_lock); SHpnt->host_busy--; SDpnt->device_busy--; @@ -1060,8 +1079,12 @@ */ if (!STpnt->init_command(SCpnt)) { scsi_release_buffers(SCpnt); - scsi_end_request(SCpnt, 0, - SCpnt->request.nr_sectors); + SCpnt = __scsi_end_request(SCpnt, 0, + SCpnt->request.nr_sectors, 0, 0); + if( SCpnt != NULL ) + { + panic("Should not have leftover blocks\n"); + } spin_lock_irq(&io_request_lock); SHpnt->host_busy--; SDpnt->device_busy--; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/scsi_queue.c linux/drivers/scsi/scsi_queue.c --- v2.4.0-test8/linux/drivers/scsi/scsi_queue.c Fri Jan 21 18:19:16 2000 +++ linux/drivers/scsi/scsi_queue.c Sun Sep 17 10:09:29 2000 @@ -118,7 +118,7 @@ * If a host is inactive and cannot queue any commands, I don't see * how things could possibly work anyways. */ - if (cmd->device->device_blocked == 0) { + if (cmd->device->device_busy == 0) { if (scsi_retry_command(cmd) == 0) { return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/sd.c linux/drivers/scsi/sd.c --- v2.4.0-test8/linux/drivers/scsi/sd.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/scsi/sd.c Sun Sep 10 13:32:54 2000 @@ -1335,12 +1335,13 @@ return; } -int init_sd(void) +static int init_sd(void) { sd_template.module = THIS_MODULE; return scsi_register_module(MODULE_SCSI_DEV, &sd_template); } -void exit_sd(void) + +static void exit_sd(void) { struct gendisk **prev_sdgd_link; struct gendisk *sdgd; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/seagate.c linux/drivers/scsi/seagate.c --- v2.4.0-test8/linux/drivers/scsi/seagate.c Mon Jul 10 16:47:24 2000 +++ linux/drivers/scsi/seagate.c Sun Sep 17 09:51:57 2000 @@ -5,7 +5,8 @@ * * Note : TMC-880 boards don't work because they have two bits in * the status register flipped, I'll fix this "RSN" - * [why do I have strong feeling that above message is from 1993? :-) pavel@ucw.cz] + * [why do I have strong feeling that above message is from 1993? :-) + * pavel@ucw.cz] * * This card does all the I/O via memory mapped I/O, so there is no need * to check or allocate a region of the I/O address space. @@ -18,6 +19,13 @@ * * 1998-jul-29 - created DPRINTK macros and made it work under * linux 2.1.112, simplified some #defines etc. + * + * Aug 2000 - aeb - deleted seagate_st0x_biosparam(). It would try to + * read the physical disk geometry, a bad mistake. Of course it doesnt + * matter much what geometry one invents, but on large disks it + * returned 256 (or more) heads, causing all kind of failures. + * Of course this means that people might see a different geometry now, + * so boot parameters may be necessary in some cases. */ /* @@ -1701,124 +1709,6 @@ return SCSI_RESET_WAKEUP; } - -int seagate_st0x_biosparam (Disk * disk, kdev_t dev, int *ip) -{ - unsigned char buf[256 + sizeof (Scsi_Ioctl_Command)], - cmd[6], *data, *page; - Scsi_Ioctl_Command *sic = (Scsi_Ioctl_Command *) buf; - int result, formatted_sectors, total_sectors; - int cylinders, heads, sectors; - int capacity; - -/* - * Only SCSI-I CCS drives and later implement the necessary mode sense - * pages. - */ - - if (disk->device->scsi_level < 2) - return -1; - - data = sic->data; - - cmd[0] = MODE_SENSE; - cmd[1] = (disk->device->lun << 5) & 0xe5; - cmd[2] = 0x04; /* Read page 4, rigid disk geometry - page current values */ - cmd[3] = 0; - cmd[4] = 255; - cmd[5] = 0; - -/* - * We are transferring 0 bytes in the out direction, and expect to get back - * 24 bytes for each mode page. - */ - sic->inlen = 0; - sic->outlen = 256; - - memcpy (data, cmd, 6); - - if (!(result = kernel_scsi_ioctl (disk->device, SCSI_IOCTL_SEND_COMMAND, - sic))) - { -/* - * The mode page lies beyond the MODE SENSE header, with length 4, and - * the BLOCK DESCRIPTOR, with length header[3]. - */ - page = data + 4 + data[3]; - heads = (int) page[5]; - cylinders = (page[2] << 16) | (page[3] << 8) | page[4]; - - cmd[2] = 0x03; /* Read page 3, format page current - values */ - memcpy (data, cmd, 6); - - if (!(result = kernel_scsi_ioctl (disk->device, SCSI_IOCTL_SEND_COMMAND, - sic))) - { - page = data + 4 + data[3]; - sectors = (page[10] << 8) | page[11]; -/* - * Get the total number of formatted sectors from the block descriptor, - * so we can tell how many are being used for alternates. - */ - formatted_sectors = (data[4 + 1] << 16) | (data[4 + 2] << 8) - | data[4 + 3]; - - total_sectors = (heads * cylinders * sectors); - -/* - * Adjust the real geometry by subtracting - * (spare sectors / (heads * tracks)) cylinders from the number of cylinders. - * - * It appears that the CE cylinder CAN be a partial cylinder. - */ - - printk ("scsi%d : heads = %d cylinders = %d sectors = %d total = %d formatted = %d\n", - hostno, heads, cylinders, sectors, total_sectors, - formatted_sectors); - - if (!heads || !sectors || !cylinders) - result = -1; - else - cylinders -= ((total_sectors - formatted_sectors) / (heads * sectors)); - -/* - * Now, we need to do a sanity check on the geometry to see if it is - * BIOS compatible. The maximum BIOS geometry is 1024 cylinders * - * 256 heads * 64 sectors. - */ - - if ((cylinders > 1024) || (sectors > 64)) - { - /* The Seagate's seem to have some mapping. Multiply - heads*sectors*cyl to get capacity. Then start rounding down. - */ - capacity = heads * sectors * cylinders; - - /* Old MFM Drives use this, so does the Seagate */ - sectors = 17; - heads = 2; - capacity = capacity / sectors; - while (cylinders > 1024) - { - heads *= 2; /* For some reason, they go in - multiples */ - cylinders = capacity / heads; - } - } - ip[0] = heads; - ip[1] = sectors; - ip[2] = cylinders; -/* - * There should be an alternate mapping for things the seagate doesn't - * understand, but I couldn't say what it is with reasonable certainty. - */ - } - } - - return result; -} #ifdef MODULE /* Eventually this will go into an include file, but this will be later */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/seagate.h linux/drivers/scsi/seagate.h --- v2.4.0-test8/linux/drivers/scsi/seagate.h Sun Aug 23 13:42:08 1998 +++ linux/drivers/scsi/seagate.h Sun Sep 17 09:51:57 2000 @@ -20,16 +20,12 @@ const char *seagate_st0x_info(struct Scsi_Host *); int seagate_st0x_reset(Scsi_Cmnd *, unsigned int); -#include -int seagate_st0x_biosparam(Disk *, kdev_t, int*); - #define SEAGATE_ST0X { detect: seagate_st0x_detect, \ info: seagate_st0x_info, \ command: seagate_st0x_command, \ queuecommand: seagate_st0x_queue_command, \ abort: seagate_st0x_abort, \ reset: seagate_st0x_reset, \ - bios_param: seagate_st0x_biosparam, \ can_queue: 1, \ this_id: 7, \ sg_tablesize: SG_ALL, \ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/sg.c linux/drivers/scsi/sg.c --- v2.4.0-test8/linux/drivers/scsi/sg.c Wed Aug 9 19:19:50 2000 +++ linux/drivers/scsi/sg.c Sun Sep 17 10:09:29 2000 @@ -112,7 +112,7 @@ static int sg_detect(Scsi_Device *); static void sg_detach(Scsi_Device *); -static Scsi_Cmnd * dummy_cmdp = 0; /* only used for sizeof */ +static Scsi_Request * dummy_cmdp = 0; /* only used for sizeof */ static rwlock_t sg_dev_arr_lock = RW_LOCK_UNLOCKED; /* Also used to lock file descriptor list for device */ @@ -148,12 +148,12 @@ typedef struct sg_request /* SG_MAX_QUEUE requests outstanding per file */ { - Scsi_Cmnd * my_cmdp; /* != 0 when request with lower levels */ + Scsi_Request * my_cmdp; /* != 0 when request with lower levels */ struct sg_request * nextrp; /* NULL -> tail request (slist) */ struct sg_fd * parentfp; /* NULL -> not in use */ Sg_scatter_hold data; /* hold buffer, perhaps scatter list */ sg_io_hdr_t header; /* scsi command+info, see */ - unsigned char sense_b[sizeof(dummy_cmdp->sense_buffer)]; + unsigned char sense_b[sizeof(dummy_cmdp->sr_sense_buffer)]; char res_used; /* 1 -> using reserve buffer, 0 -> not ... */ char orphan; /* 1 -> drop on sight, 0 -> normal */ char sg_io_owned; /* 1 -> packet belongs to SG_IO */ @@ -230,8 +230,8 @@ static int sg_remove_request(Sg_fd * sfp, Sg_request * srp); static int sg_res_in_use(Sg_fd * sfp); static int sg_dio_in_use(Sg_fd * sfp); -static void sg_clr_scpnt(Scsi_Cmnd * SCpnt); -static void sg_shorten_timeout(Scsi_Cmnd * scpnt); +static void sg_clr_srpnt(Scsi_Request * SRpnt); +static void sg_shorten_timeout(Scsi_Request * srpnt); static int sg_ms_to_jif(unsigned int msecs); static unsigned sg_jif_to_ms(int jifs); static int sg_allow_access(unsigned char opcode, char dev_type); @@ -460,7 +460,7 @@ if ((hp->mx_sb_len > 0) && hp->sbp) { if ((CHECK_CONDITION & hp->masked_status) || (DRIVER_SENSE & hp->driver_status)) { - int sb_len = sizeof(dummy_cmdp->sense_buffer); + int sb_len = sizeof(dummy_cmdp->sr_sense_buffer); sb_len = (hp->mx_sb_len > sb_len) ? sb_len : hp->mx_sb_len; len = 8 + (int)srp->sense_b[7]; /* Additional sense length field */ len = (len > sb_len) ? sb_len : len; @@ -492,7 +492,7 @@ Sg_request * srp; struct sg_header old_hdr; sg_io_hdr_t * hp; - unsigned char cmnd[sizeof(dummy_cmdp->cmnd)]; + unsigned char cmnd[sizeof(dummy_cmdp->sr_cmnd)]; if ((! (sfp = (Sg_fd *)filp->private_data)) || (! (sdp = sfp->parentdp))) return -ENXIO; @@ -581,7 +581,7 @@ int k; Sg_request * srp; sg_io_hdr_t * hp; - unsigned char cmnd[sizeof(dummy_cmdp->cmnd)]; + unsigned char cmnd[sizeof(dummy_cmdp->sr_cmnd)]; int timeout; if (count < size_sg_io_hdr) @@ -625,7 +625,7 @@ unsigned char * cmnd, int timeout, int blocking) { int k; - Scsi_Cmnd * SCpnt; + Scsi_Request * SRpnt; Sg_device * sdp = sfp->parentdp; sg_io_hdr_t * hp = &srp->header; @@ -652,38 +652,34 @@ return k; } /* SCSI_LOG_TIMEOUT(7, printk("sg_write: allocating device\n")); */ - SCpnt = scsi_allocate_device(sdp->device, blocking, TRUE); - if (! SCpnt) { - sg_finish_rem_req(srp); - return (signal_pending(current)) ? -EINTR : -EAGAIN; - /* No available command blocks, or, interrupted while waiting */ - } + SRpnt = scsi_allocate_request(sdp->device); + /* SCSI_LOG_TIMEOUT(7, printk("sg_write: device allocated\n")); */ - srp->my_cmdp = SCpnt; - SCpnt->request.rq_dev = sdp->i_rdev; - SCpnt->request.rq_status = RQ_ACTIVE; - SCpnt->sense_buffer[0] = 0; - SCpnt->cmd_len = hp->cmd_len; + srp->my_cmdp = SRpnt; + SRpnt->sr_request.rq_dev = sdp->i_rdev; + SRpnt->sr_request.rq_status = RQ_ACTIVE; + SRpnt->sr_sense_buffer[0] = 0; + SRpnt->sr_cmd_len = hp->cmd_len; /* Set the LUN field in the command structure, overriding user input */ if (! (hp->flags & SG_FLAG_LUN_INHIBIT)) cmnd[1] = (cmnd[1] & 0x1f) | (sdp->device->lun << 5); /* SCSI_LOG_TIMEOUT(7, printk("sg_write: do cmd\n")); */ - SCpnt->use_sg = srp->data.k_use_sg; - SCpnt->sglist_len = srp->data.sglist_len; - SCpnt->bufflen = srp->data.bufflen; - SCpnt->underflow = 0; - SCpnt->buffer = srp->data.buffer; + SRpnt->sr_use_sg = srp->data.k_use_sg; + SRpnt->sr_sglist_len = srp->data.sglist_len; + SRpnt->sr_bufflen = srp->data.bufflen; + SRpnt->sr_underflow = 0; + SRpnt->sr_buffer = srp->data.buffer; switch (hp->dxfer_direction) { case SG_DXFER_TO_FROM_DEV: case SG_DXFER_FROM_DEV: - SCpnt->sc_data_direction = SCSI_DATA_READ; break; + SRpnt->sr_data_direction = SCSI_DATA_READ; break; case SG_DXFER_TO_DEV: - SCpnt->sc_data_direction = SCSI_DATA_WRITE; break; + SRpnt->sr_data_direction = SCSI_DATA_WRITE; break; case SG_DXFER_UNKNOWN: - SCpnt->sc_data_direction = SCSI_DATA_UNKNOWN; break; + SRpnt->sr_data_direction = SCSI_DATA_UNKNOWN; break; default: - SCpnt->sc_data_direction = SCSI_DATA_NONE; break; + SRpnt->sr_data_direction = SCSI_DATA_NONE; break; } srp->data.k_use_sg = 0; srp->data.sglist_len = 0; @@ -692,10 +688,10 @@ hp->duration = jiffies; /* unit jiffies now, millisecs after done */ /* Now send everything of to mid-level. The next time we hear about this packet is when sg_cmd_done_bh() is called (i.e. a callback). */ - scsi_do_cmd(SCpnt, (void *)cmnd, - (void *)SCpnt->buffer, hp->dxfer_len, + scsi_do_req(SRpnt, (void *)cmnd, + (void *)SRpnt->sr_buffer, hp->dxfer_len, sg_cmd_done_bh, timeout, SG_DEFAULT_RETRIES); - /* dxfer_len overwrites SCpnt->bufflen, hence need for b_malloc_len */ + /* dxfer_len overwrites SRpnt->sr_bufflen, hence need for b_malloc_len */ return 0; } @@ -989,7 +985,8 @@ * mid level when a command is completed (or has failed). */ static void sg_cmd_done_bh(Scsi_Cmnd * SCpnt) { - int dev = MINOR(SCpnt->request.rq_dev); + Scsi_Request * SRpnt = SCpnt->sc_request; + int dev = MINOR(SRpnt->sr_request.rq_dev); Sg_device * sdp = NULL; Sg_fd * sfp; Sg_request * srp = NULL; @@ -1002,15 +999,15 @@ if (NULL == sdp) { read_unlock(&sg_dev_arr_lock); SCSI_LOG_TIMEOUT(1, printk("sg...bh: bad args dev=%d\n", dev)); - scsi_release_command(SCpnt); - SCpnt = NULL; + scsi_release_request(SRpnt); + SRpnt = NULL; return; } sfp = sdp->headfp; while (sfp) { read_lock(&sfp->rq_list_lock); for (srp = sfp->headrp; srp; srp = srp->nextrp) { - if (SCpnt == srp->my_cmdp) + if (SRpnt == srp->my_cmdp) break; } read_unlock(&sfp->rq_list_lock); @@ -1021,41 +1018,41 @@ read_unlock(&sg_dev_arr_lock); if (! srp) { SCSI_LOG_TIMEOUT(1, printk("sg...bh: req missing, dev=%d\n", dev)); - scsi_release_command(SCpnt); - SCpnt = NULL; + scsi_release_request(SRpnt); + SRpnt = NULL; return; } /* First transfer ownership of data buffers to sg_device object. */ - srp->data.k_use_sg = SCpnt->use_sg; - srp->data.sglist_len = SCpnt->sglist_len; - srp->data.bufflen = SCpnt->bufflen; - srp->data.buffer = SCpnt->buffer; - sg_clr_scpnt(SCpnt); + srp->data.k_use_sg = SRpnt->sr_use_sg; + srp->data.sglist_len = SRpnt->sr_sglist_len; + srp->data.bufflen = SRpnt->sr_bufflen; + srp->data.buffer = SRpnt->sr_buffer; + sg_clr_srpnt(SRpnt); srp->my_cmdp = NULL; srp->done = 1; SCSI_LOG_TIMEOUT(4, printk("sg...bh: dev=%d, pack_id=%d, res=0x%x\n", - dev, srp->header.pack_id, (int)SCpnt->result)); + dev, srp->header.pack_id, (int)SRpnt->sr_result)); srp->header.resid = SCpnt->resid; /* sg_unmap_and(&srp->data, 0); */ /* unmap locked pages a.s.a.p. */ /* N.B. unit of duration changes here from jiffies to millisecs */ srp->header.duration = sg_jif_to_ms(jiffies - (int)srp->header.duration); - if (0 != SCpnt->result) { - memcpy(srp->sense_b, SCpnt->sense_buffer, sizeof(srp->sense_b)); - srp->header.status = 0xff & SCpnt->result; - srp->header.masked_status = status_byte(SCpnt->result); - srp->header.msg_status = msg_byte(SCpnt->result); - srp->header.host_status = host_byte(SCpnt->result); - srp->header.driver_status = driver_byte(SCpnt->result); + if (0 != SRpnt->sr_result) { + memcpy(srp->sense_b, SRpnt->sr_sense_buffer, sizeof(srp->sense_b)); + srp->header.status = 0xff & SRpnt->sr_result; + srp->header.masked_status = status_byte(SRpnt->sr_result); + srp->header.msg_status = msg_byte(SRpnt->sr_result); + srp->header.host_status = host_byte(SRpnt->sr_result); + srp->header.driver_status = driver_byte(SRpnt->sr_result); if ((sdp->sgdebug > 0) && ((CHECK_CONDITION == srp->header.masked_status) || (COMMAND_TERMINATED == srp->header.masked_status))) - print_sense("sg_cmd_done_bh", SCpnt); + print_req_sense("sg_cmd_done_bh", SRpnt); /* Following if statement is a patch supplied by Eric Youngdale */ - if (driver_byte(SCpnt->result) != 0 - && (SCpnt->sense_buffer[0] & 0x7f) == 0x70 - && (SCpnt->sense_buffer[2] & 0xf) == UNIT_ATTENTION + if (driver_byte(SRpnt->sr_result) != 0 + && (SRpnt->sr_sense_buffer[0] & 0x7f) == 0x70 + && (SRpnt->sr_sense_buffer[2] & 0xf) == UNIT_ATTENTION && sdp->device->removable) { /* Detected disc change. Set the bit - this may be used if */ /* there are filesystems using this device. */ @@ -1064,8 +1061,8 @@ } /* Rely on write phase to clean out srp status values, so no "else" */ - scsi_release_command(SCpnt); - SCpnt = NULL; + scsi_release_request(SRpnt); + SRpnt = NULL; if (sfp->closed) { /* whoops this fd already released, cleanup */ SCSI_LOG_TIMEOUT(1, printk("sg...bh: already closed, freeing ...\n")); @@ -1336,7 +1333,7 @@ #endif /* Can't see clean way to abort a command so shorten timeout to 1 jiffy */ -static void sg_shorten_timeout(Scsi_Cmnd * scpnt) +static void sg_shorten_timeout(Scsi_Request * srpnt) { #if 0 /* scsi_syms.c is very miserly about exported functions */ scsi_delete_timer(scpnt); @@ -2366,14 +2363,14 @@ sg_low_free(buff, size, mem_src); } -static void sg_clr_scpnt(Scsi_Cmnd * SCpnt) +static void sg_clr_srpnt(Scsi_Request * SRpnt) { - SCpnt->use_sg = 0; - SCpnt->sglist_len = 0; - SCpnt->bufflen = 0; - SCpnt->buffer = NULL; - SCpnt->underflow = 0; - SCpnt->request.rq_dev = MKDEV(0, 0); /* "sg" _disowns_ command blk */ + SRpnt->sr_use_sg = 0; + SRpnt->sr_sglist_len = 0; + SRpnt->sr_bufflen = 0; + SRpnt->sr_buffer = NULL; + SRpnt->sr_underflow = 0; + SRpnt->sr_request.rq_dev = MKDEV(0, 0); /* "sg" _disowns_ command blk */ } static int sg_ms_to_jif(unsigned int msecs) @@ -2642,8 +2639,8 @@ /* stop indenting so far ... */ PRINT_PROC(srp->res_used ? " rb>> " : ((SG_INFO_DIRECT_IO_MASK & hp->info) ? " dio>> " : " ")); - blen = srp->my_cmdp ? srp->my_cmdp->bufflen : srp->data.bufflen; - usg = srp->my_cmdp ? srp->my_cmdp->use_sg : srp->data.k_use_sg; + blen = srp->my_cmdp ? srp->my_cmdp->sr_bufflen : srp->data.bufflen; + usg = srp->my_cmdp ? srp->my_cmdp->sr_use_sg : srp->data.k_use_sg; PRINT_PROC(srp->done ? ((1 == srp->done) ? "rcv:" : "fin:") : (srp->my_cmdp ? "act:" : "prior:")); PRINT_PROC(" id=%d blen=%d", srp->header.pack_id, blen); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/sr.c linux/drivers/scsi/sr.c --- v2.4.0-test8/linux/drivers/scsi/sr.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/scsi/sr.c Sun Sep 10 13:21:13 2000 @@ -849,13 +849,13 @@ return; } -int init_sr(void) +static int __init init_sr(void) { sr_template.module = THIS_MODULE; return scsi_register_module(MODULE_SCSI_DEV, &sr_template); } -void exit_sr(void) +static void __exit exit_sr(void) { scsi_unregister_module(MODULE_SCSI_DEV, &sr_template); devfs_unregister_blkdev(MAJOR_NR, "sr"); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/sym53c8xx.c linux/drivers/scsi/sym53c8xx.c --- v2.4.0-test8/linux/drivers/scsi/sym53c8xx.c Fri Jun 23 21:55:10 2000 +++ linux/drivers/scsi/sym53c8xx.c Sun Sep 17 09:48:04 2000 @@ -698,6 +698,9 @@ #elif defined(__alpha__) # define pcivtobus(p) ((p) & 0xfffffffful) # define memcpy_to_pci(a, b, c) memcpy_toio((a), (b), (c)) +#elif defined(CONFIG_PPC) +# define pcivtobus(p) phys_to_bus(p) +# define memcpy_to_pci(a, b, c) memcpy_toio((a), (b), (c)) #else /* others */ # define pcivtobus(p) (p) # define memcpy_to_pci(a, b, c) memcpy_toio((a), (b), (c)) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/scsi/sym53c8xx_comm.h linux/drivers/scsi/sym53c8xx_comm.h --- v2.4.0-test8/linux/drivers/scsi/sym53c8xx_comm.h Fri Jun 23 21:55:10 2000 +++ linux/drivers/scsi/sym53c8xx_comm.h Sun Sep 17 09:48:04 2000 @@ -498,7 +498,7 @@ # define memcpy_to_pci(a, b, c) memcpy_toio((a), (b), (c)) #endif -#ifndef SCSI_NCR_PCI_MEM_NOT_SUPPORTED +#if defined(__i386__) && !defined(SCSI_NCR_PCI_MEM_NOT_SUPPORTED) static u_long __init remap_pci_mem(u_long base, u_long size) { u_long page_base = ((u_long) base) & PAGE_MASK; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/sound/ac97_codec.c linux/drivers/sound/ac97_codec.c --- v2.4.0-test8/linux/drivers/sound/ac97_codec.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/sound/ac97_codec.c Sun Sep 17 09:41:29 2000 @@ -48,6 +48,7 @@ static int ac97_init_mixer(struct ac97_codec *codec); static int sigmatel_init(struct ac97_codec *codec); +static int enable_eapd(struct ac97_codec *codec); #define arraysize(x) (sizeof(x)/sizeof((x)[0])) @@ -58,11 +59,14 @@ } ac97_codec_ids[] = { {0x414B4D00, "Asahi Kasei AK4540" , NULL}, {0x41445340, "Analog Devices AD1881" , NULL}, + {0x41445360, "Analog Devices AD1885" , enable_eapd}, {0x43525900, "Cirrus Logic CS4297" , NULL}, {0x43525903, "Cirrus Logic CS4297" , NULL}, {0x43525913, "Cirrus Logic CS4297A" , NULL}, {0x43525923, "Cirrus Logic CS4298" , NULL}, + {0x4352592B, "Cirrus Logic CS4294" , NULL}, {0x43525931, "Cirrus Logic CS4299" , NULL}, + {0x43525934, "Cirrus Logic CS4299" , NULL}, {0x4e534331, "National Semiconductor LM4549" , NULL}, {0x53494c22, "Silicon Laboratory Si3036" , NULL}, {0x53494c23, "Silicon Laboratory Si3038" , NULL}, @@ -562,8 +566,10 @@ /* also according to spec, we wait for codec-ready state */ if (codec->codec_wait) codec->codec_wait(codec); - else + else { + current->state = TASK_UNINTERRUPTIBLE; schedule_timeout(5); + } if ((audio = codec->codec_read(codec, AC97_RESET)) & 0x8000) { printk(KERN_ERR "ac97_codec: %s ac97 codec not present\n", @@ -582,6 +588,7 @@ id2 = codec->codec_read(codec, AC97_VENDOR_ID2); for (i = 0; i < arraysize(ac97_codec_ids); i++) { if (ac97_codec_ids[i].id == ((id1 << 16) | id2)) { + codec->id = ac97_codec_ids[i].id; codec->name = ac97_codec_ids[i].name; codec->codec_init = ac97_codec_ids[i].init; break; @@ -659,6 +666,18 @@ return 1; } + +/* + * Bring up an AD1885 + */ + +static int enable_eapd(struct ac97_codec * codec) +{ + codec->codec_write(codec, AC97_POWER_CONTROL, + codec->codec_read(codec, AC97_POWER_CONTROL)|0x8000); + return 0; +} + EXPORT_SYMBOL(ac97_read_proc); EXPORT_SYMBOL(ac97_probe_codec); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/sound/adlib_card.c linux/drivers/sound/adlib_card.c --- v2.4.0-test8/linux/drivers/sound/adlib_card.c Wed Aug 23 18:36:38 2000 +++ linux/drivers/sound/adlib_card.c Sun Sep 17 09:45:06 2000 @@ -20,15 +20,10 @@ static void __init attach_adlib_card(struct address_info *hw_config) { hw_config->slots[0] = opl3_init(hw_config->io_base, hw_config->osp, THIS_MODULE); - request_region(hw_config->io_base, 4, "OPL3/OPL2"); } static int __init probe_adlib(struct address_info *hw_config) { - if (check_region(hw_config->io_base, 4)) { - DDB(printk("opl3.c: I/O port %x already in use\n", hw_config->io_base)); - return 0; - } return opl3_detect(hw_config->io_base, hw_config->osp); } @@ -55,7 +50,6 @@ static void __exit cleanup_adlib(void) { - release_region(cfg.io_base, 4); sound_unload_synthdev(cfg.slots[0]); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/sound/cs46xx.c linux/drivers/sound/cs46xx.c --- v2.4.0-test8/linux/drivers/sound/cs46xx.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/sound/cs46xx.c Sun Sep 17 09:45:05 2000 @@ -100,12 +100,6 @@ /* maxinum number of AC97 codecs connected, AC97 2.0 defined 4 */ #define NR_AC97 2 -/* minor number of /dev/dspW */ -#define SND_DEV_DSP8 1 - -/* minor number of /dev/dspW */ -#define SND_DEV_DSP16 1 - static const unsigned sample_size[] = { 1, 2, 2, 4 }; static const unsigned sample_shift[] = { 0, 1, 1, 2 }; @@ -2485,7 +2479,7 @@ void (*active)(struct cs_card *, int); }; -static struct cs_card_type __init cards[]={ +static struct cs_card_type __initdata cards[]={ {0x1489, 0x7001, "Genius Soundmaker 128 value", amp_none, NULL}, {0x5053, 0x3357, "Voyetra", amp_voyetra, NULL}, /* MI6020/21 use the same chipset as the Thinkpads, maybe needed */ @@ -2494,7 +2488,7 @@ {PCI_VENDOR_ID_IBM, 0x0132, "Thinkpad 570", amp_none, clkrun_hack}, {PCI_VENDOR_ID_IBM, 0x0153, "Thinkpad 600X/A20/T20", amp_none, clkrun_hack}, {PCI_VENDOR_ID_IBM, 0x1010, "Thinkpad 600E (unsupported)", NULL, NULL}, - {0, 0, NULL, NULL} + {0, 0, NULL, NULL, NULL} }; static int __init cs_install(struct pci_dev *pci_dev) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/sound/dmasound/awacs_defs.h linux/drivers/sound/dmasound/awacs_defs.h --- v2.4.0-test8/linux/drivers/sound/dmasound/awacs_defs.h Thu May 11 15:30:08 2000 +++ linux/drivers/sound/dmasound/awacs_defs.h Sun Sep 17 09:48:05 2000 @@ -62,6 +62,11 @@ #define MASK_ADDR_VOLC MASK_ADDR4 /* Volume Control C -- Speaker */ #define MASK_ADDR_VOLSPK MASK_ADDR4 +/* additional registers of screamer */ +#define MASK_ADDR5 (0x5 << 12) /* Expanded Data Mode Address 5 */ +#define MASK_ADDR6 (0x6 << 12) /* Expanded Data Mode Address 6 */ +#define MASK_ADDR7 (0x7 << 12) /* Expanded Data Mode Address 7 */ + /* Address 0 Bit Masks & Macros */ /* ------- - --- ----- - ------ */ #define MASK_GAINRIGHT (0xf) /* Gain Right Mask */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/sound/dmasound/dmasound_awacs.c linux/drivers/sound/dmasound/dmasound_awacs.c --- v2.4.0-test8/linux/drivers/sound/dmasound/dmasound_awacs.c Fri Jun 23 21:55:10 2000 +++ linux/drivers/sound/dmasound/dmasound_awacs.c Sun Sep 17 09:48:05 2000 @@ -17,8 +17,12 @@ #include #include #include +#ifdef CONFIG_ADB_CUDA #include +#endif +#ifdef CONFIG_ADB_PMU #include +#endif #include #include @@ -45,6 +49,9 @@ static char awacs_name[64]; static int awacs_revision; +int awacs_is_screamer = 0; +int awacs_device_id = 0; +int awacs_has_iic = 0; #define AWACS_BURGUNDY 100 /* fake revision # for burgundy */ /* @@ -60,7 +67,7 @@ * Cached values of AWACS registers (we can't read them). * Except on the burgundy. XXX */ -int awacs_reg[5]; +int awacs_reg[8]; #define HAS_16BIT_TABLES #undef HAS_8BIT_TABLES @@ -1303,6 +1310,11 @@ awacs_write(awacs_reg[1] | MASK_ADDR1); awacs_write(awacs_reg[2] | MASK_ADDR2); awacs_write(awacs_reg[4] | MASK_ADDR4); + if (awacs_is_screamer) { + awacs_write(awacs_reg[5] + MASK_ADDR5); + awacs_write(awacs_reg[6] + MASK_ADDR6); + awacs_write(awacs_reg[7] + MASK_ADDR7); + } out_le32(&awacs->byteswap, dmasound.hard.format != AFMT_S16_BE); enable_irq(awacs_irq); enable_irq(awacs_tx_irq); @@ -1551,6 +1563,7 @@ if (sys_ctrler != SYS_CTRLER_CUDA) return; +#ifdef CONFIG_ADB_CUDA /* turn on headphones */ cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_GET_SET_IIC, 0x8a, 4, 0); @@ -1570,6 +1583,7 @@ cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_GET_SET_IIC, 0x8a, 1, 0x29); while (!req.complete) cuda_poll(); +#endif /* CONFIG_ADB_CUDA */ } @@ -1974,6 +1988,13 @@ awacs_subframe = *prop; if (device_is_compatible(sound, "burgundy")) awacs_revision = AWACS_BURGUNDY; + /* This should be verified on older screamers */ + if (device_is_compatible(sound, "screamer")) + awacs_is_screamer = 1; + prop = (unsigned int *)get_property(sound, "device-id", 0); + if (prop != 0) + awacs_device_id = *prop; + awacs_has_iic = (find_devices("perch") != NULL); /* look for a property saying what sample rates are available */ @@ -2029,10 +2050,12 @@ #ifdef CONFIG_PMAC_PBOOK if (machine_is_compatible("PowerBook1,1") || machine_is_compatible("AAPL,PowerBook1998")) { + pmu_suspend(); feature_set(np, FEATURE_Sound_CLK_enable); feature_set(np, FEATURE_Sound_power); /* Shorter delay will not work */ mdelay(1000); + pmu_resume(); } #endif awacs_tx_cmds = (volatile struct dbdma_cmd *) @@ -2050,16 +2073,28 @@ awacs_reg[0] = MASK_MUX_CD; - awacs_reg[1] = MASK_LOOPTHRU | MASK_PAROUT; + /* FIXME: Only machines with external SRS module need MASK_PAROUT */ + awacs_reg[1] = MASK_LOOPTHRU; + if (awacs_has_iic || awacs_device_id == 0x5 || /*awacs_device_id == 0x8 + || */awacs_device_id == 0xb) + awacs_reg[1] |= MASK_PAROUT; /* get default volume from nvram */ vol = (~nvram_read_byte(0x1308) & 7) << 1; awacs_reg[2] = vol + (vol << 6); awacs_reg[4] = vol + (vol << 6); + awacs_reg[5] = 0; + awacs_reg[6] = 0; + awacs_reg[7] = 0; out_le32(&awacs->control, 0x11); awacs_write(awacs_reg[0] + MASK_ADDR0); awacs_write(awacs_reg[1] + MASK_ADDR1); awacs_write(awacs_reg[2] + MASK_ADDR2); awacs_write(awacs_reg[4] + MASK_ADDR4); + if (awacs_is_screamer) { + awacs_write(awacs_reg[5] + MASK_ADDR5); + awacs_write(awacs_reg[6] + MASK_ADDR6); + awacs_write(awacs_reg[7] + MASK_ADDR7); + } /* Initialize recent versions of the awacs */ if (awacs_revision == 0) { @@ -2118,7 +2153,15 @@ break; } } - /* enable CD sound input */ + /* + * Enable CD sound input. + * The relevant bits for writing to this byte are 0x8f. + * I haven't found out what the 0x80 bit does. + * For the 0xf bits, writing 3 or 7 enables the CD + * input, any other value disables it. Values + * 1, 3, 5, 7 enable the microphone. Values 0, 2, + * 4, 6, 8 - f enable the input from the modem. + */ if (macio_base) out_8(macio_base + 0x37, 3); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/sound/emu10k1/emu_wrapper.h linux/drivers/sound/emu10k1/emu_wrapper.h --- v2.4.0-test8/linux/drivers/sound/emu10k1/emu_wrapper.h Wed Aug 23 18:36:38 2000 +++ linux/drivers/sound/emu10k1/emu_wrapper.h Sun Sep 17 09:45:06 2000 @@ -5,9 +5,4 @@ #define PCI_SET_DMA_MASK(pdev,mask) (((pdev)->dma_mask) = (mask)) -#ifndef PCI_GET_DRIVER_DATA - #define PCI_GET_DRIVER_DATA(pdev) ((pdev)->driver_data) - #define PCI_SET_DRIVER_DATA(pdev,data) (((pdev)->driver_data) = (data)) -#endif /* PCI_GET_DRIVER_DATA */ - #endif diff -u --recursive --new-file v2.4.0-test8/linux/drivers/sound/emu10k1/main.c linux/drivers/sound/emu10k1/main.c --- v2.4.0-test8/linux/drivers/sound/emu10k1/main.c Wed Aug 23 18:36:38 2000 +++ linux/drivers/sound/emu10k1/main.c Sun Sep 17 09:45:06 2000 @@ -641,7 +641,7 @@ return -ENODEV; } - PCI_SET_DRIVER_DATA(pci_dev, card); + pci_set_drvdata(pci_dev, card); PCI_SET_DMA_MASK(pci_dev, EMU10K1_DMA_MASK); card->irq = pci_dev->irq; @@ -736,7 +736,7 @@ static void __devexit emu10k1_remove(struct pci_dev *pci_dev) { - struct emu10k1_card *card = PCI_GET_DRIVER_DATA(pci_dev); + struct emu10k1_card *card = pci_get_drvdata(pci_dev); midi_exit(card); emu10k1_exit(card); @@ -755,7 +755,7 @@ kfree(card); - return; + pci_set_drvdata(pci_dev, NULL); } MODULE_AUTHOR("Bertrand Lee, Cai Ying. (Email to: emu10k1-devel@opensource.creative.com)"); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/sound/gus_card.c linux/drivers/sound/gus_card.c --- v2.4.0-test8/linux/drivers/sound/gus_card.c Wed Aug 23 18:36:38 2000 +++ linux/drivers/sound/gus_card.c Sun Sep 17 09:45:05 2000 @@ -198,7 +198,9 @@ } #endif +#ifdef CONFIG_SOUND_GUS16 static int gus16 = 0; +#endif #ifdef CONFIG_SOUND_GUSMAX static int no_wave_dma = 0;/* Set if no dma is to be used for the wave table (GF1 chip) */ @@ -223,12 +225,12 @@ MODULE_PARM(dma, "i"); MODULE_PARM(dma16, "i"); MODULE_PARM(type, "i"); -MODULE_PARM(gus16, "i"); #ifdef CONFIG_SOUND_GUSMAX MODULE_PARM(no_wave_dma, "i"); #endif #ifdef CONFIG_SOUND_GUS16 MODULE_PARM(db16, "i"); +MODULE_PARM(gus16, "i"); #endif static int __init init_gus(void) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/sound/opl3.c linux/drivers/sound/opl3.c --- v2.4.0-test8/linux/drivers/sound/opl3.c Wed Aug 23 18:36:38 2000 +++ linux/drivers/sound/opl3.c Sun Sep 17 09:45:06 2000 @@ -15,6 +15,8 @@ * Thomas Sailer ioctl code reworked (vmalloc/vfree removed) * Alan Cox modularisation, fixed sound_mem allocs. * Christoph Hellwig Adapted to module_init/module_exit + * Arnaldo C. de Melo get rid of check_region, use request_region for + * OPL4, release it on exit, some cleanups. * * Status * Believed to work. Badly needs rewriting a bit to support multiple @@ -172,6 +174,15 @@ "structure \n "); return 0; } + + memset(devc, 0, sizeof(*devc)); + strcpy(devc->fm_info.name, "OPL2"); + + if (!request_region(ioaddr, 4, devc->fm_info.name)) { + printk(KERN_WARNING "opl3: I/O port 0x%x already in use\n", ioaddr); + goto cleanup_devc; + } + devc->osp = osp; devc->base = ioaddr; @@ -187,7 +198,7 @@ signature != 0x0f) { MDB(printk(KERN_INFO "OPL3 not detected %x\n", signature)); - return 0; + goto cleanup_region; } if (signature == 0x06) /* OPL2 */ @@ -214,7 +225,7 @@ detected_model = 4; } - if (!check_region(ioaddr - 8, 2)) /* OPL4 port is free */ + if (request_region(ioaddr - 8, 2, "OPL4")) /* OPL4 port was free */ { int tmp; @@ -232,7 +243,10 @@ udelay(10); } else + { /* release OPL4 port */ + release_region(ioaddr - 8, 2); detected_model = 3; + } } opl3_command(ioaddr + 2, OPL3_MODE_REGISTER, 0); } @@ -246,6 +260,12 @@ * Melodic mode. */ return 1; +cleanup_region: + release_region(ioaddr, 4); +cleanup_devc: + kfree(devc); + devc = NULL; + return 0; } static int opl3_kill_note (int devno, int voice, int note, int velocity) @@ -1099,12 +1119,7 @@ return -1; } - memset((char *) devc, 0x00, sizeof(*devc)); - devc->osp = osp; - devc->base = ioaddr; - devc->nr_voice = 9; - strcpy(devc->fm_info.name, "OPL2"); devc->fm_info.device = 0; devc->fm_info.synth_type = SYNTH_TYPE_FM; @@ -1191,18 +1206,12 @@ if (io != -1) /* User loading pure OPL3 module */ { - if (check_region(io, 4)) - { - printk(KERN_WARNING "opl3: I/O port 0x%x already in use\n", io); - return 0; - } if (!opl3_detect(io, NULL)) { return -ENODEV; } - me = opl3_init(io, NULL, THIS_MODULE); - request_region(io, 4, devc->fm_info.name); + me = opl3_init(io, NULL, THIS_MODULE); } return 0; @@ -1212,8 +1221,11 @@ { if (devc && io != -1) { - if(devc->base) + if (devc->base) { release_region(devc->base,4); + if (devc->is_opl4) + release_region(devc->base - 8, 2); + } kfree(devc); devc = NULL; sound_unload_synthdev(me); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/sound/uart6850.c linux/drivers/sound/uart6850.c --- v2.4.0-test8/linux/drivers/sound/uart6850.c Wed Aug 23 18:36:38 2000 +++ linux/drivers/sound/uart6850.c Sun Sep 17 09:45:07 2000 @@ -13,8 +13,11 @@ * Alan Cox: Updated for new modular code. Removed snd_* irq handling. Now * uses native linux resources * Christoph Hellwig: Adapted to module_init/module_exit + * Jeff Garzik: Made it work again, in theory + * FIXME: If the request_irq() succeeds, the probe succeeds. Ug. + * + * Status: Testing required (no shit -jgarzik) * - * Status: Testing required * */ @@ -64,12 +67,11 @@ #define UART_RESET 0x95 #define UART_MODE_ON 0x03 -static int uart6850_opened = 0; +static int uart6850_opened; static int uart6850_irq; -static int uart6850_detected = 0; +static int uart6850_detected; static int my_dev; -static int reset_uart6850(void); static void (*midi_input_intr) (int dev, unsigned char data); static void poll_uart6850(unsigned long dummy); @@ -251,6 +253,9 @@ int ok, timeout; unsigned long flags; + if (!uart6850_detected) + return; + if ((my_dev = sound_alloc_mididev()) == -1) { printk(KERN_INFO "uart6850: Too many midi devices detected\n"); @@ -260,11 +265,6 @@ uart6850_osp = hw_config->osp; uart6850_irq = hw_config->irq; - if (!uart6850_detected) - { - sound_unload_mididev(my_dev); - return; - } save_flags(flags); cli(); @@ -283,7 +283,7 @@ sequencer_init(); } -static int reset_uart6850(void) +static inline int reset_uart6850(void) { uart6850_read(); return 1; /* @@ -291,10 +291,9 @@ */ } - static int __init probe_uart6850(struct address_info *hw_config) { - int ok = 0; + int ok; uart6850_osp = hw_config->osp; uart6850_base = hw_config->io_base; @@ -334,6 +333,7 @@ if (probe_uart6850(&cfg_mpu)) return -ENODEV; + attach_uart6850(&cfg_mpu); return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/sound/wf_midi.c linux/drivers/sound/wf_midi.c --- v2.4.0-test8/linux/drivers/sound/wf_midi.c Wed Aug 23 18:36:38 2000 +++ linux/drivers/sound/wf_midi.c Sun Sep 17 09:45:07 2000 @@ -781,8 +781,7 @@ return 0; } -static int __init detect_wf_mpu (int irq, int io_base) - +int __init detect_wf_mpu (int irq, int io_base) { if (check_region (io_base, 2)) { printk (KERN_WARNING "WF-MPU: I/O port %x already in use.\n", diff -u --recursive --new-file v2.4.0-test8/linux/drivers/telephony/Makefile linux/drivers/telephony/Makefile --- v2.4.0-test8/linux/drivers/telephony/Makefile Tue Jan 4 13:57:17 2000 +++ linux/drivers/telephony/Makefile Sun Sep 17 09:45:07 2000 @@ -1,35 +1,29 @@ # -# Makefile for the kernel miscellaneous drivers. +# Makefile for drivers/telephony # # Note! Dependencies are done automagically by 'make dep', which also # removes any old dependencies. DON'T put your own dependencies here # unless it's something special (ie not a .c file). # -# Note 2! The CFLAGS definitions are now inherited from the -# parent makes.. -SUB_DIRS := +SUB_DIRS := MOD_SUB_DIRS := $(SUB_DIRS) ALL_SUB_DIRS := $(SUB_DIRS) -L_TARGET := telephony.a -MX_OBJS := -M_OBJS := - -ifeq ($(CONFIG_PHONE),y) - LX_OBJS += phonedev.o -else - ifeq ($(CONFIG_PHONE),m) - MX_OBJS += phonedev.o - endif -endif - -ifeq ($(CONFIG_PHONE_IXJ),y) - L_OBJS += ixj.o -else - ifeq ($(CONFIG_PHONE_IXJ),m) - M_OBJS += ixj.o - endif -endif +obj-y := +obj-n := +obj-m := +obj- := +export-objs := phonedev.o + +obj-$(CONFIG_PHONE) += phonedev.o +obj-$(CONFIG_PHONE_IXJ) += ixj.o + +O_TARGET := telephony.o +O_OBJS := $(filter-out $(export-objs), $(obj-y)) +OX_OBJS := $(filter $(export-objs), $(obj-y)) +M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) +MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) include $(TOPDIR)/Rules.make + diff -u --recursive --new-file v2.4.0-test8/linux/drivers/telephony/ixj.c linux/drivers/telephony/ixj.c --- v2.4.0-test8/linux/drivers/telephony/ixj.c Fri Jul 14 12:12:13 2000 +++ linux/drivers/telephony/ixj.c Sun Sep 17 09:45:07 2000 @@ -4493,8 +4493,8 @@ return (((DWORD) wHi << 16) | wLo); } -static int dspio[IXJMAX + 1] = {0,}; -static int xio[IXJMAX + 1] = {0,}; +static int dspio[IXJMAX + 1]; +static int xio[IXJMAX + 1]; MODULE_DESCRIPTION("Internet PhoneJACK/Internet LineJACK module - www.quicknet.net"); MODULE_AUTHOR("Ed Okerson "); @@ -4502,27 +4502,24 @@ MODULE_PARM(dspio, "1-" __MODULE_STRING(IXJMAX) "i"); MODULE_PARM(xio, "1-" __MODULE_STRING(IXJMAX) "i"); -#ifdef MODULE - -void cleanup_module(void) +static void __exit ixj_exit(void) { cleanup(); } -int init_module(void) -#else -int __init ixj_init(void) -#endif +static int __init ixj_init(void) { int result; - int func = 0x110, i = 0; + int i = 0; int cnt = 0; int probe = 0; - struct pci_dev *dev = NULL, *old_dev = NULL; struct pci_dev *pci = NULL; #ifdef CONFIG_ISAPNP + struct pci_dev *dev = NULL, *old_dev = NULL; + int func = 0x110; + while (1) { do { old_dev = dev; @@ -4636,6 +4633,10 @@ ixj_add_timer(); return probe; } + +module_init(ixj_init); +module_exit(ixj_exit); + static void DAA_Coeff_US(int board) { diff -u --recursive --new-file v2.4.0-test8/linux/drivers/telephony/phonedev.c linux/drivers/telephony/phonedev.c --- v2.4.0-test8/linux/drivers/telephony/phonedev.c Thu Jul 27 17:38:01 2000 +++ linux/drivers/telephony/phonedev.c Sun Sep 17 09:45:07 2000 @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -143,40 +144,29 @@ * Board init functions */ -extern int ixj_init(void); /* * Initialise Telephony for linux */ -int telephony_init(void) +static int __init telephony_init(void) { printk(KERN_INFO "Linux telephony interface: v1.00\n"); if (register_chrdev(PHONE_MAJOR, "telephony", &phone_fops)) { printk("phonedev: unable to get major %d\n", PHONE_MAJOR); return -EIO; } - /* - * Init kernel installed drivers - */ -#ifdef CONFIG_PHONE_IXJ - ixj_init(); -#endif - return 0; -} -#ifdef MODULE -int init_module(void) -{ - return telephony_init(); + return 0; } -void cleanup_module(void) +static void __exit telephony_exit(void) { unregister_chrdev(PHONE_MAJOR, "telephony"); } -#endif +module_init(telephony_init); +module_exit(telephony_exit); EXPORT_SYMBOL(phone_register_device); EXPORT_SYMBOL(phone_unregister_device); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/storage/Makefile linux/drivers/usb/storage/Makefile --- v2.4.0-test8/linux/drivers/usb/storage/Makefile Fri Sep 8 13:27:12 2000 +++ linux/drivers/usb/storage/Makefile Fri Sep 8 16:39:12 2000 @@ -21,7 +21,7 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_DPCM) += dpcm.o usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ - $(usb-storage-obj-y) + initializers.o $(usb-storage-obj-y) # Extract lists of the multi-part drivers. # The 'int-*' lists are the intermediate files used to build the multi's. diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/storage/debug.c linux/drivers/usb/storage/debug.c --- v2.4.0-test8/linux/drivers/usb/storage/debug.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/usb/storage/debug.c Fri Sep 8 16:39:12 2000 @@ -1,7 +1,7 @@ /* Driver for USB Mass Storage compliant devices * Debugging Functions Source Code File * - * $Id: debug.c,v 1.3 2000/08/25 00:13:51 mdharm Exp $ + * $Id: debug.c,v 1.4 2000/09/04 02:12:47 groovyjava Exp $ * * Current development and maintenance by: * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) @@ -206,5 +206,162 @@ sg[i].address[14], sg[i].address[15]); } +} + +void usb_stor_show_sense( + unsigned char key, + unsigned char asc, + unsigned char ascq) { + + char *keys[] = { + "No Sense", + "Recovered Error", + "Not Ready", + "Medium Error", + "Hardware Error", + "Illegal Request", + "Unit Attention", + "Data Protect", + "Blank Check", + "Vendor Specific", + "Copy Aborted", + "Aborted Command", + "(Obsolete)", + "Volume Overflow", + "Miscompare" + }; + + unsigned short qual = asc; + + char *what = 0; + char *keystr = 0; + + qual <<= 8; + qual |= ascq; + + if (key>0x0E) + keystr = "(Unknown Key)"; + else + keystr = keys[key]; + + switch (qual) { + + case 0x0000: what="no additional sense information"; break; + case 0x0001: what="filemark detected"; break; + case 0x0002: what="end of partition/medium detected"; break; + case 0x0003: what="setmark detected"; break; + case 0x0004: what="beginning of partition/medium detected"; break; + case 0x0005: what="end of data detected"; break; + case 0x0006: what="I/O process terminated"; break; + case 0x0011: what="audio play operation in progress"; break; + case 0x0012: what="audio play operation paused"; break; + case 0x0013: what="audio play operation stopped due to error"; break; + case 0x0014: what="audio play operation successfully completed"; break; + case 0x0015: what="no current audio status to return"; break; + case 0x0016: what="operation in progress"; break; + case 0x0017: what="cleaning requested"; break; + case 0x0100: what="no index/sector signal"; break; + case 0x0200: what="no seek complete"; break; + case 0x0300: what="peripheral device write fault"; break; + case 0x0301: what="no write current"; break; + case 0x0302: what="excessive write errors"; break; + case 0x0400: what="LUN not ready, cause not reportable"; break; + case 0x0401: what="LUN in process of becoming ready"; break; + case 0x0402: what="LUN not ready, initializing cmd. required"; break; + case 0x0403: what="LUN not ready, manual intervention required"; break; + case 0x0404: what="LUN not ready, format in progress"; break; + case 0x0405: what="LUN not ready, rebuild in progress"; break; + case 0x0406: what="LUN not ready, recalculation in progress"; break; + case 0x0407: what="LUN not ready, operation in progress"; break; + case 0x0408: what="LUN not ready, long write in progress"; break; + case 0x0500: what="LUN doesn't respond to selection"; break; + case 0x0A00: what="error log overflow"; break; + case 0x0C04: what="compression check miscompare error"; break; + case 0x0C05: what="data expansion occurred during compression"; break; + case 0x0C06: what="block not compressible"; break; + case 0x1102: what="error too long to correct"; break; + case 0x1106: what="CIRC unrecovered error"; break; + case 0x1107: what="data resynchronization error"; break; + case 0x110D: what="decompression CRC error"; break; + case 0x110E: what="can't decompress using declared algorithm"; break; + case 0x110F: what="error reading UPC/EAN number"; break; + case 0x1110: what="error reading ISRC number"; break; + case 0x1200: what="address mark not found for ID field"; break; + case 0x1300: what="address mark not found for data field"; break; + case 0x1403: what="end of data not found"; break; + case 0x1404: what="block sequence error"; break; + case 0x1600: what="data sync mark error"; break; + case 0x1601: what="data sync error: data rewritten"; break; + case 0x1602: what="data sync error: recommend rewrite"; break; + case 0x1603: what="data sync error: data auto-reallocated"; break; + case 0x1604: what="data sync error: recommend reassignment"; break; + case 0x1900: what="defect list error"; break; + case 0x1901: what="defect list not available"; break; + case 0x1902: what="defect list error in primary list"; break; + case 0x1903: what="defect list error in grown list"; break; + case 0x1C00: what="defect list not found"; break; + case 0x2400: what="invalid field in CDB"; break; + case 0x2703: what="associated write protect"; break; + case 0x2903: what="bus device reset function occurred"; break; + case 0x2904: what="device internal reset"; break; + case 0x2B00: what="copy can't execute since host can't disconnect"; + break; + case 0x2C00: what="command sequence error"; break; + case 0x2C03: what="current program area is not empty"; break; + case 0x2C04: what="current program area is empty"; break; + case 0x2F00: what="commands cleared by another initiator"; break; + case 0x3001: what="can't read medium: unknown format"; break; + case 0x3002: what="can't read medium: incompatible format"; break; + case 0x3003: what="cleaning cartridge installed"; break; + case 0x3004: what="can't write medium: unknown format"; break; + case 0x3005: what="can't write medium: incompatible format"; break; + case 0x3006: what="can't format medium: incompatible medium"; break; + case 0x3007: what="cleaning failure"; break; + case 0x3008: what="can't write: application code mismatch"; break; + case 0x3009: what="current session not fixated for append"; break; + case 0x3201: what="defect list update failure"; break; + case 0x3400: what="enclosure failure"; break; + case 0x3500: what="enclosure services failure"; break; + case 0x3502: what="enclosure services unavailable"; break; + case 0x3503: what="enclosure services transfer failure"; break; + case 0x3504: what="enclosure services transfer refused"; break; + case 0x3B0F: what="end of medium reached"; break; + case 0x3F02: what="changed operating definition"; break; + case 0x4100: what="data path failure (should use 40 NN)"; break; + case 0x4A00: what="command phase error"; break; + case 0x4B00: what="data phase error"; break; + case 0x5100: what="erase failure"; break; + case 0x5200: what="cartridge fault"; break; + case 0x6300: what="end of user area encountered on this track"; break; + case 0x6600: what="automatic document feeder cover up"; break; + case 0x6601: what="automatic document feeder lift up"; break; + case 0x6602: what="document jam in auto doc feeder"; break; + case 0x6603: what="document miss feed auto in doc feeder"; break; + case 0x6700: what="configuration failure"; break; + case 0x6701: what="configuration of incapable LUN's failed"; break; + case 0x6702: what="add logical unit failed"; break; + case 0x6706: what="attachment of logical unit failed"; break; + case 0x6707: what="creation of logical unit failed"; break; + case 0x6900: what="data loss on logical unit"; break; + case 0x6E00: what="command to logical unit failed"; break; + case 0x7100: what="decompression exception long algorithm ID"; break; + case 0x7204: what="empty or partially written reserved track"; break; + case 0x7300: what="CD control error"; break; + + default: + if (asc==0x40) { + US_DEBUGP("%s: diagnostic failure on component" + " %02X\n", keystr, ascq); + return; + } + if (asc==0x70) { + US_DEBUGP("%s: decompression exception short" + " algorithm ID of %02X\n", keystr, ascq); + return; + } + what = "(unknown ASC/ASCQ)"; + } + + US_DEBUGP("%s: %s\n", keystr, what); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/storage/debug.h linux/drivers/usb/storage/debug.h --- v2.4.0-test8/linux/drivers/usb/storage/debug.h Fri Sep 8 13:27:12 2000 +++ linux/drivers/usb/storage/debug.h Fri Sep 8 16:39:12 2000 @@ -1,7 +1,7 @@ /* Driver for USB Mass Storage compliant devices * Debugging Functions Header File * - * $Id: debug.h,v 1.4 2000/08/25 00:13:51 mdharm Exp $ + * $Id: debug.h,v 1.5 2000/09/04 02:12:47 groovyjava Exp $ * * Current development and maintenance by: * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) @@ -55,6 +55,8 @@ #ifdef CONFIG_USB_STORAGE_DEBUG void usb_stor_show_command(Scsi_Cmnd *srb); void usb_stor_print_Scsi_Cmnd( Scsi_Cmnd* cmd ); +void usb_stor_show_sense( unsigned char key, + unsigned char asc, unsigned char ascq ); #define US_DEBUGP(x...) printk( KERN_DEBUG USB_STORAGE ## x ) #define US_DEBUGPX(x...) printk( ## x ) #define US_DEBUG(x) x diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/storage/freecom.c linux/drivers/usb/storage/freecom.c --- v2.4.0-test8/linux/drivers/usb/storage/freecom.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/usb/storage/freecom.c Fri Sep 15 21:37:23 2000 @@ -1,6 +1,6 @@ /* Driver for Freecom USB/IDE adaptor * - * $Id: freecom.c,v 1.7 2000/08/25 00:13:51 mdharm Exp $ + * $Id: freecom.c,v 1.8 2000/08/29 14:49:15 dlbrown Exp $ * * Freecom v0.1: * @@ -33,6 +33,7 @@ #include "usb.h" #include "debug.h" #include "freecom.h" +#include "linux/hdreg.h" static void pdump (void *, int); @@ -56,6 +57,18 @@ __u8 Pad[58]; }; +struct freecom_ide_out { + __u8 Type; /* Type + IDE register. */ + __u8 Pad; + __u16 Value; /* Value to write. */ + __u8 Pad2[60]; +}; + +struct freecom_ide_in { + __u8 Type; /* Type | IDE register. */ + __u8 Pad[63]; +}; + struct freecom_status { __u8 Status; __u8 Reason; @@ -63,17 +76,123 @@ __u8 Pad[60]; }; +/* Freecom stuffs the interrupt status in the INDEX_STAT bit of the ide + * register. */ +#define FCM_INT_STATUS INDEX_STAT + /* These are the packet types. The low bit indicates that this command * should wait for an interrupt. */ #define FCM_PACKET_ATAPI 0x21 /* Receive data from the IDE interface. The ATAPI packet has already * waited, so the data should be immediately available. */ -#define FCM_PACKET_INPUT 0x90 +#define FCM_PACKET_INPUT 0x81 + +/* Write a value to an ide register. Or the ide register to write after + * munging the addres a bit. */ +#define FCM_PACKET_IDE_WRITE 0x40 +#define FCM_PACKET_IDE_READ 0xC0 /* All packets (except for status) are 64 bytes long. */ #define FCM_PACKET_LENGTH 64 +/* Write a value to an ide register. */ +static int +freecom_ide_write (struct us_data *us, int reg, int value) +{ + freecom_udata_t extra = (freecom_udata_t) us->extra; + struct freecom_ide_out *ideout = + (struct freecom_ide_out *) extra->buffer; + int opipe; + int result, partial; + + printk (KERN_DEBUG "IDE out 0x%02x <- 0x%02x\n", reg, value); + + /* Get handles for both transports. */ + opipe = usb_sndbulkpipe (us->pusb_dev, us->ep_out); + + if (reg < 0 || reg > 8) + return USB_STOR_TRANSPORT_ERROR; + if (reg < 8) + reg |= 0x20; + else + reg = 0x0e; + + ideout->Type = FCM_PACKET_IDE_WRITE | reg; + ideout->Pad = 0; + ideout->Value = cpu_to_le16 (value); + memset (ideout->Pad2, 0, sizeof (ideout->Pad2)); + + result = usb_stor_bulk_msg (us, ideout, opipe, + FCM_PACKET_LENGTH, &partial); + if (result != 0) { + if (result == -ENOENT) + return US_BULK_TRANSFER_ABORTED; + else + return USB_STOR_TRANSPORT_ERROR; + } + + return USB_STOR_TRANSPORT_GOOD; +} + +/* Read a value from an ide register. */ +static int +freecom_ide_read (struct us_data *us, int reg, int *value) +{ + freecom_udata_t extra = (freecom_udata_t) us->extra; + struct freecom_ide_in *idein = + (struct freecom_ide_in *) extra->buffer; + __u8 *buffer = extra->buffer; + int ipipe, opipe; + int result, partial; + int desired_length; + + /* Get handles for both transports. */ + opipe = usb_sndbulkpipe (us->pusb_dev, us->ep_out); + ipipe = usb_rcvbulkpipe (us->pusb_dev, us->ep_in); + + if (reg < 0 || reg > 8) + return USB_STOR_TRANSPORT_ERROR; + if (reg < 8) + reg |= 0x10; + else + reg = 0x0e; + + idein->Type = FCM_PACKET_IDE_READ | reg; + memset (idein->Pad, 0, sizeof (idein->Pad)); + + result = usb_stor_bulk_msg (us, idein, opipe, + FCM_PACKET_LENGTH, &partial); + if (result != 0) { + if (result == -ENOENT) + return US_BULK_TRANSFER_ABORTED; + else + return USB_STOR_TRANSPORT_ERROR; + } + + desired_length = 1; + if (reg == 0x10) + desired_length = 2; + + result = usb_stor_bulk_msg (us, buffer, ipipe, + desired_length, &partial); + if (result != 0) { + if (result == -ENOENT) + return US_BULK_TRANSFER_ABORTED; + else + return USB_STOR_TRANSPORT_ERROR; + } + + if (desired_length == 1) + *value = buffer[0]; + else + *value = le16_to_cpu (*(__u16 *) buffer); + + printk (KERN_DEBUG "IDE in 0x%02x -> 0x%02x\n", reg, *value); + + return USB_STOR_TRANSPORT_GOOD; +} + static int freecom_readdata (Scsi_Cmnd *srb, struct us_data *us, int ipipe, int opipe, int count) @@ -83,6 +202,7 @@ (struct freecom_xfer_wrap *) extra->buffer; int result, partial; int offset; + int this_read; __u8 *buffer = extra->buffer; fxfr->Type = FCM_PACKET_INPUT | 0x00; @@ -118,6 +238,14 @@ offset = 0; while (offset < count) { +#if 0 + this_read = count - offset; + if (this_read > 64) + this_read = 64; +#else + this_read = 64; +#endif + printk (KERN_DEBUG "Start of read\n"); /* Use the given buffer directly, but only if there * is space for an entire packet. */ @@ -125,7 +253,7 @@ if (offset + 64 <= srb->request_bufflen) { result = usb_stor_bulk_msg ( us, srb->request_buffer+offset, - ipipe, 64, &partial); + ipipe, this_read, &partial); printk (KERN_DEBUG "Read111 = %d, %d\n", result, partial); pdump (srb->request_buffer+offset, @@ -133,7 +261,7 @@ } else { result = usb_stor_bulk_msg ( us, buffer, - ipipe, 64, &partial); + ipipe, this_read, &partial); printk (KERN_DEBUG "Read112 = %d, %d\n", result, partial); memcpy (srb->request_buffer+offset, @@ -156,7 +284,7 @@ return USB_STOR_TRANSPORT_ERROR; } - offset += 64; + offset += this_read; } } @@ -178,17 +306,6 @@ int length; freecom_udata_t extra; - /* Allocate a buffer for us. The upper usb transport code will - * free this for us when cleaning up. */ - if (us->extra == NULL) { - us->extra = kmalloc (sizeof (struct freecom_udata), - GFP_KERNEL); - if (us->extra == NULL) { - printk (KERN_WARNING USB_STORAGE "Out of memory\n"); - return USB_STOR_TRANSPORT_ERROR; - } - } - extra = (freecom_udata_t) us->extra; fcb = (struct freecom_cb_wrap *) extra->buffer; @@ -250,7 +367,7 @@ if (partial != 4 || result != 0) { return USB_STOR_TRANSPORT_ERROR; } - if ((fst->Reason & 1) != 0) { + if ((fst->Status & 1) != 0) { printk (KERN_DEBUG "operation failed\n"); return USB_STOR_TRANSPORT_FAILED; } @@ -274,9 +391,34 @@ switch (us->srb->sc_data_direction) { case SCSI_DATA_READ: + /* Make sure that the status indicates that the device + * wants data as well. */ + if ((fst->Status & DRQ_STAT) == 0 || (fst->Reason & 3) != 2) { + printk (KERN_DEBUG "SCSI wants data, drive doesn't have any\n"); + return USB_STOR_TRANSPORT_FAILED; + } result = freecom_readdata (srb, us, ipipe, opipe, length); if (result != USB_STOR_TRANSPORT_GOOD) return result; + + printk (KERN_DEBUG "FCM: Waiting for status\n"); + result = usb_stor_bulk_msg (us, fst, ipipe, + FCM_PACKET_LENGTH, &partial); + if (result == -ENOENT) { + US_DEBUGP ("freecom_transport: transfer aborted\n"); + return US_BULK_TRANSFER_ABORTED; + } + if (partial != 4 || result != 0) + return USB_STOR_TRANSPORT_ERROR; + if ((fst->Status & ERR_STAT) != 0) { + printk (KERN_DEBUG "operation failed\n"); + return USB_STOR_TRANSPORT_FAILED; + } + if ((fst->Reason & 3) != 3) { + printk (KERN_DEBUG "Drive seems still hungry\n"); + return USB_STOR_TRANSPORT_FAILED; + } + printk (KERN_DEBUG "Transfer happy\n"); break; default: @@ -310,6 +452,63 @@ srb->sc_data_direction); return USB_STOR_TRANSPORT_ERROR; +} + +int +freecom_init (struct us_data *us) +{ + int result, value; + int counter; + + /* Allocate a buffer for us. The upper usb transport code will + * free this for us when cleaning up. */ + if (us->extra == NULL) { + us->extra = kmalloc (sizeof (struct freecom_udata), + GFP_KERNEL); + if (us->extra == NULL) { + printk (KERN_WARNING USB_STORAGE "Out of memory\n"); + return USB_STOR_TRANSPORT_ERROR; + } + } + + result = freecom_ide_write (us, 0x06, 0xA0); + if (result != USB_STOR_TRANSPORT_GOOD) + return result; + result = freecom_ide_write (us, 0x01, 0x00); + if (result != USB_STOR_TRANSPORT_GOOD) + return result; + + counter = 50; + do { + result = freecom_ide_read (us, 0x07, &value); + if (result != USB_STOR_TRANSPORT_GOOD) + return result; + if (counter-- < 0) { + printk (KERN_WARNING USB_STORAGE "Timeout in freecom"); + return USB_STOR_TRANSPORT_ERROR; + } + } while ((value & 0x80) != 0); + + result = freecom_ide_write (us, 0x07, 0x08); + if (result != USB_STOR_TRANSPORT_GOOD) + return result; + + counter = 50; + do { + result = freecom_ide_read (us, 0x07, &value); + if (result != USB_STOR_TRANSPORT_GOOD) + return result; + if (counter-- < 0) { + printk (KERN_WARNING USB_STORAGE "Timeout in freecom"); + return USB_STOR_TRANSPORT_ERROR; + } + } while ((value & 0x80) != 0); + + result = freecom_ide_write (us, 0x08, 0x08); + if (result != USB_STOR_TRANSPORT_GOOD) + return result; + + return USB_STOR_TRANSPORT_GOOD; } int usb_stor_freecom_reset(struct us_data *us) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/storage/freecom.h linux/drivers/usb/storage/freecom.h --- v2.4.0-test8/linux/drivers/usb/storage/freecom.h Fri Sep 8 13:27:12 2000 +++ linux/drivers/usb/storage/freecom.h Fri Sep 8 16:39:12 2000 @@ -1,6 +1,6 @@ /* Driver for Freecom USB/IDE adaptor * - * $Id: freecom.h,v 1.3 2000/08/25 00:13:51 mdharm Exp $ + * $Id: freecom.h,v 1.4 2000/08/29 14:49:15 dlbrown Exp $ * * Freecom v0.1: * @@ -31,5 +31,6 @@ extern int freecom_transport(Scsi_Cmnd *srb, struct us_data *us); extern int usb_stor_freecom_reset(struct us_data *us); +extern int freecom_init (struct us_data *us); #endif diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/storage/initializers.c linux/drivers/usb/storage/initializers.c --- v2.4.0-test8/linux/drivers/usb/storage/initializers.c Wed Dec 31 16:00:00 1969 +++ linux/drivers/usb/storage/initializers.c Fri Sep 8 16:39:12 2000 @@ -0,0 +1,60 @@ +/* Special Initializers for certain USB Mass Storage devices + * + * $Id: initializers.c,v 1.2 2000/09/06 22:35:57 mdharm Exp $ + * + * Current development and maintenance by: + * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) + * + * This driver is based on the 'USB Mass Storage Class' document. This + * describes in detail the protocol used to communicate with such + * devices. Clearly, the designers had SCSI and ATAPI commands in + * mind when they created this document. The commands are all very + * similar to commands in the SCSI-II and ATAPI specifications. + * + * It is important to note that in a number of cases this class + * exhibits class-specific exemptions from the USB specification. + * Notably the usage of NAK, STALL and ACK differs from the norm, in + * that they are used to communicate wait, failed and OK on commands. + * + * Also, for certain devices, the interrupt endpoint is used to convey + * status of a command. + * + * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more + * information about this driver. + * + * 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, 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., + * 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "initializers.h" +#include "debug.h" + +/* This places the Shuttle/SCM USB<->SCSI bridge devices in multi-target + * mode */ +int usb_stor_euscsi_init(struct us_data *us) +{ + unsigned char data = 0x1; + int result; + + US_DEBUGP("Attempting to init eUSCSI bridge...\n"); + result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0), + 0x0C, USB_RECIP_INTERFACE | USB_TYPE_VENDOR, + 0x01, 0x0, &data, 0x1, 5*HZ); + US_DEBUGP("-- result is %d\n", result); + US_DEBUGP("-- data afterwards is %d\n", data); + + return 0; +} + + diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/storage/initializers.h linux/drivers/usb/storage/initializers.h --- v2.4.0-test8/linux/drivers/usb/storage/initializers.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/usb/storage/initializers.h Fri Sep 8 16:39:12 2000 @@ -0,0 +1,44 @@ +/* Header file for Special Initializers for certain USB Mass Storage devices + * + * $Id: initializers.h,v 1.1 2000/08/29 23:07:02 mdharm Exp $ + * + * Current development and maintenance by: + * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) + * + * This driver is based on the 'USB Mass Storage Class' document. This + * describes in detail the protocol used to communicate with such + * devices. Clearly, the designers had SCSI and ATAPI commands in + * mind when they created this document. The commands are all very + * similar to commands in the SCSI-II and ATAPI specifications. + * + * It is important to note that in a number of cases this class + * exhibits class-specific exemptions from the USB specification. + * Notably the usage of NAK, STALL and ACK differs from the norm, in + * that they are used to communicate wait, failed and OK on commands. + * + * Also, for certain devices, the interrupt endpoint is used to convey + * status of a command. + * + * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more + * information about this driver. + * + * 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, 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., + * 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "usb.h" + +/* This places the Shuttle/SCM USB<->SCSI bridge devices in multi-target + * mode */ +int usb_stor_euscsi_init(struct us_data *us); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/storage/protocol.c linux/drivers/usb/storage/protocol.c --- v2.4.0-test8/linux/drivers/usb/storage/protocol.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/usb/storage/protocol.c Fri Sep 8 16:39:12 2000 @@ -1,6 +1,6 @@ /* Driver for USB Mass Storage compliant devices * - * $Id: protocol.c,v 1.5 2000/08/25 00:13:51 mdharm Exp $ + * $Id: protocol.c,v 1.6 2000/09/01 22:03:55 mdharm Exp $ * * Current development and maintenance by: * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) @@ -170,7 +170,7 @@ usb_stor_invoke_transport(srb, us); /* Fix the MODE_SENSE data if we translated the command */ - if ((old_cmnd == MODE_SENSE) && (srb->result == GOOD)) + if ((old_cmnd == MODE_SENSE) && (status_byte(srb->result) == GOOD)) usb_stor_scsiSense10to6(srb); /* fix the INQUIRY data if necessary */ @@ -265,7 +265,7 @@ usb_stor_invoke_transport(srb, us); /* Fix the MODE_SENSE data if we translated the command */ - if ((old_cmnd == MODE_SENSE) && (srb->result == GOOD)) + if ((old_cmnd == MODE_SENSE) && (status_byte(srb->result) == GOOD)) usb_stor_scsiSense10to6(srb); /* Fix the data for an INQUIRY, if necessary */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/storage/scsiglue.c linux/drivers/usb/storage/scsiglue.c --- v2.4.0-test8/linux/drivers/usb/storage/scsiglue.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/usb/storage/scsiglue.c Fri Sep 8 16:39:12 2000 @@ -1,7 +1,7 @@ /* Driver for USB Mass Storage compliant devices * SCSI layer glue code * - * $Id: scsiglue.c,v 1.9 2000/08/25 00:13:51 mdharm Exp $ + * $Id: scsiglue.c,v 1.10 2000/08/30 01:22:42 mdharm Exp $ * * Current development and maintenance by: * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) @@ -189,12 +189,6 @@ return SUCCESS; } - /* This is a sanity check that we should never hit */ - if (in_interrupt()) { - printk(KERN_ERR "usb-storage: command_abort() called from an interrupt!!! BAD!!! BAD!! BAD!!\n"); - return FAILED; - } - /* if we have an urb pending, let's wake the control thread up */ if (us->current_urb->status == -EINPROGRESS) { /* cancel the URB */ @@ -213,18 +207,63 @@ return FAILED; } -/* FIXME: this doesn't do anything right now */ +/* This invokes the transport reset mechanism to reset the state of the + * device */ +static int device_reset( Scsi_Cmnd *srb ) +{ + struct us_data *us = (struct us_data *)srb->host->hostdata[0]; + + US_DEBUGP("device_reset() called\n" ); + return us->transport_reset(us); +} + +/* This resets the device port, and simulates the device + * disconnect/reconnect for all drivers which have claimed other + * interfaces. */ static int bus_reset( Scsi_Cmnd *srb ) { - // struct us_data *us = (struct us_data *)srb->host->hostdata[0]; + struct us_data *us = (struct us_data *)srb->host->hostdata[0]; + int result; + int i; - printk(KERN_CRIT "usb-storage: bus_reset() requested but not implemented\n" ); - US_DEBUGP("Bus reset requested\n"); - // us->transport_reset(us); - return FAILED; + /* we use the usb_reset_device() function to handle this for us */ + US_DEBUGP("bus_reset() called\n"); + result = usb_reset_device(us->pusb_dev) ? FAILED : SUCCESS; + + /* did the reset work? */ + if (result < 0) + return FAILED; + + /* FIXME: This needs to lock out driver probing while it's working + * or we can have race conditions */ + for (i = 0; i < us->pusb_dev->actconfig->bNumInterfaces; i++) { + struct usb_interface *intf = + &us->pusb_dev->actconfig->interface[i]; + + US_DEBUGP("Examinging driver %s...", intf->driver->name); + /* skip interfaces which we've claimed */ + if (intf->driver && !strncmp(intf->driver->name, + "usb-storage", 12)) { + US_DEBUGPX("skipping.\n"); + continue; + } + + /* simulate a disconnect and reconnect for all interfaces */ + if (intf->driver) { + US_DEBUGPX("simulating disconnect/reconnect.\n"); + down(&intf->driver->serialize); + intf->driver->disconnect(us->pusb_dev, + intf->private_data); + intf->driver->probe(us->pusb_dev, i); + up(&intf->driver->serialize); + } + } + + US_DEBUGP("bus_reset() complete\n"); + return SUCCESS; } -/* FIXME: This doesn't actually reset anything */ +/* FIXME: This doesn't do anything right now */ static int host_reset( Scsi_Cmnd *srb ) { printk(KERN_CRIT "usb-storage: host_reset() requested but not implemented\n" ); @@ -313,7 +352,7 @@ queuecommand: queuecommand, eh_abort_handler: command_abort, - eh_device_reset_handler:bus_reset, + eh_device_reset_handler:device_reset, eh_bus_reset_handler: bus_reset, eh_host_reset_handler: host_reset, diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/storage/shuttle_usbat.c linux/drivers/usb/storage/shuttle_usbat.c --- v2.4.0-test8/linux/drivers/usb/storage/shuttle_usbat.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/usb/storage/shuttle_usbat.c Fri Sep 8 16:39:12 2000 @@ -1,6 +1,6 @@ /* Driver for SCM Microsystems USB-ATAPI cable * - * $Id: shuttle_usbat.c,v 1.4 2000/08/25 00:13:51 mdharm Exp $ + * $Id: shuttle_usbat.c,v 1.7 2000/09/04 02:08:42 groovyjava Exp $ * * SCM driver v0.2: * @@ -68,6 +68,8 @@ #define LSB_of(s) ((s)&0xFF) #define MSB_of(s) ((s)>>8) +int transferred = 0; + /* * Send a control message and wait for the response. * @@ -192,7 +194,7 @@ if (result == -EPIPE) { US_DEBUGP("usbat_raw_bulk():" " output pipe stalled\n"); - return USB_STOR_TRANSPORT_FAILED; + return US_BULK_TRANSFER_SHORT; } /* the catch-all case */ @@ -225,13 +227,13 @@ int result = USB_STOR_TRANSPORT_GOOD; int transferred = 0; - unsigned char execute[8] = { - 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + // unsigned char execute[8] = { + // 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + // }; int i; struct scatterlist *sg; - char string[64]; - int pipe; + // char string[64]; + // int pipe; /* if (command_len != 0) { @@ -262,10 +264,10 @@ if (command_len != 0) direction = (command[0]&0x80) ? SCSI_DATA_READ : SCSI_DATA_WRITE; - +/* if (direction == SCSI_DATA_WRITE) { - /* Debug-print the first 48 bytes of the write transfer */ + // Debug-print the first 48 bytes of the write transfer if (!use_sg) { string[0] = 0; @@ -281,7 +283,7 @@ US_DEBUGP("%s\n", string); } } - +*/ US_DEBUGP("SCM data %s transfer %d sg buffers %d\n", ( direction==SCSI_DATA_READ ? "in" : "out"), @@ -311,9 +313,9 @@ unsigned char *content) { int result; - unsigned char command[8] = { - 0xC0, access, reg, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + // unsigned char command[8] = { + // 0xC0, access, reg, 0x00, 0x00, 0x00, 0x00, 0x00 + // }; result = usbat_send_control(us, usb_rcvctrlpipe(us->pusb_dev,0), @@ -335,9 +337,9 @@ unsigned char content) { int result; - unsigned char command[8] = { - 0x40, access|0x01, reg, content, 0x00, 0x00, 0x00, 0x00 - }; + // unsigned char command[8] = { + // 0x40, access|0x01, reg, content, 0x00, 0x00, 0x00, 0x00 + // }; result = usbat_send_control(us, usb_sndctrlpipe(us->pusb_dev,0), @@ -427,11 +429,14 @@ unsigned char status; /* Synchronizing cache on a CDR could take a heck of a long time, - but probably not more than 15 minutes or so */ + but probably not more than 10 minutes or so */ + + for (i=0; i<1800; i++) { - for (i=0; i<500; i++) { result = usbat_read(us, USBAT_ATA, 0x17, &status); - US_DEBUGP("SCM: Write ATA data status is %02X\n", status); + + // US_DEBUGP("SCM: Write ATA data status is %02X\n", status); + if (result!=USB_STOR_TRANSPORT_GOOD) return result; if (status&0x01) // check condition @@ -440,19 +445,21 @@ return USB_STOR_TRANSPORT_FAILED; if ((status&0x80)!=0x80) // not busy break; - if (i<5) - wait_ms(100); - else if (i<20) - wait_ms(500); - else if (i<49) - wait_ms(1000); - else if (i<499) - wait_ms(2000); + + if (i<500) + wait_ms(10); // 5 seconds + else if (i<700) + wait_ms(50); // 10 seconds + else if (i<1200) + wait_ms(100); // 50 seconds + else if (i<1800) + wait_ms(1000); // 10 minutes } - if (i==500) + if (i==1800) return USB_STOR_TRANSPORT_FAILED; + US_DEBUGP("Waited not busy for %d steps\n", i); return USB_STOR_TRANSPORT_GOOD; } @@ -493,15 +500,16 @@ return usbat_wait_not_busy(us); } -int usbat_write_block_test(struct us_data *us, +int usbat_rw_block_test(struct us_data *us, unsigned char access, unsigned char *registers, unsigned char *data_out, unsigned short num_registers, unsigned char data_reg, unsigned char status_reg, - unsigned char qualifier, unsigned char timeout, + unsigned char qualifier, + int direction, unsigned char *content, unsigned short len, int use_sg) { @@ -509,91 +517,129 @@ int result; // Not really sure the 0x07, 0x17, 0xfc, 0xe7 is necessary here, - // but that's what came out of the trace. + // but that's what came out of the trace every single time. unsigned char command[16] = { 0x40, access|0x07, 0x07, 0x17, 0xfc, 0xe7, LSB_of(num_registers*2), MSB_of(num_registers*2), - 0x40, access|0x05, data_reg, status_reg, - qualifier, timeout, LSB_of(len), MSB_of(len) + (direction==SCSI_DATA_WRITE ? 0x40 : 0xC0), + access|(direction==SCSI_DATA_WRITE ? 0x05 : 0x04), + data_reg, status_reg, + timeout, qualifier, LSB_of(len), MSB_of(len) }; + int i; unsigned char data[num_registers*2]; - int transferred; - struct scatterlist *sg; - char string[64]; + unsigned char status; for (i=0; ipusb_dev,0), - 0x80, - 0x40, - 0, - 0, - command, - 16); - - if (result != USB_STOR_TRANSPORT_GOOD) - return result; + for (i=0; i<20; i++) { - result = usbat_bulk_transport(us, - NULL, 0, SCSI_DATA_WRITE, data, num_registers*2, 0); - - // result = usbat_bulk_transport(us, - // command, 16, 0, data, num_registers*2, 0); + /* + * The first time we send the full command, which consists + * of downloading the SCSI command followed by downloading + * the data via a write-and-test. Any other time we only + * send the command to download the data -- the SCSI command + * is still 'active' in some sense in the device. + * + * We're only going to try sending the data 10 times. After + * that, we just return a failure. + */ + + result = usbat_send_control(us, + usb_sndctrlpipe(us->pusb_dev,0), + 0x80, + 0x40, + 0, + 0, + (i==0 ? command : command+8), + (i==0 ? 16 : 8)); - if (result!=USB_STOR_TRANSPORT_GOOD) - return result; + if (result != USB_STOR_TRANSPORT_GOOD) + return result; - // transferred = 0; + if (i==0) { - US_DEBUGP("Transfer out %d bytes, sg buffers %d\n", - len, use_sg); + result = usbat_bulk_transport(us, + NULL, 0, SCSI_DATA_WRITE, + data, num_registers*2, 0); - result = usbat_bulk_transport(us, - NULL, 0, SCSI_DATA_WRITE, content, len, use_sg); + if (result!=USB_STOR_TRANSPORT_GOOD) + return result; -/* - if (!use_sg) { + } - // Debug-print the first 48 bytes of the transfer - string[0] = 0; - for (i=0; ipusb_dev, + usb_sndbulkpipe(us->pusb_dev, + us->ep_out)); + /* + * Read status: is the device angry, or just busy? + */ + + result = usbat_read(us, USBAT_ATA, + direction==SCSI_DATA_WRITE ? 0x17 : 0x0E, + &status); + + if (result!=USB_STOR_TRANSPORT_GOOD) + return result; + if (status&0x01) // check condition + return USB_STOR_TRANSPORT_FAILED; + if (status&0x20) // device fault + return USB_STOR_TRANSPORT_FAILED; - result = usbat_raw_bulk(us, SCSI_DATA_WRITE, content, len); + US_DEBUGP("Redoing %s\n", + direction==SCSI_DATA_WRITE ? "write" : "read"); - } else { + } else if (result != US_BULK_TRANSFER_GOOD) + return result; + else + return usbat_wait_not_busy(us); - sg = (struct scatterlist *)content; - for (i=0; i sg[i].length ? - sg[i].length : len-transferred); - if (result!=US_BULK_TRANSFER_GOOD) - break; - transferred += sg[i].length; - } } -*/ - if (result!=USB_STOR_TRANSPORT_GOOD) - return result; - return usbat_wait_not_busy(us); + US_DEBUGP("Bummer! %s bulk data 10 times failed.\n", + direction==SCSI_DATA_WRITE ? "Writing" : "Reading"); + + return USB_STOR_TRANSPORT_FAILED; } int usbat_multiple_write(struct us_data *us, @@ -642,9 +688,9 @@ int usbat_read_user_io(struct us_data *us, unsigned char *data_flags) { - unsigned char command[8] = { - 0xC0, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + // unsigned char command[8] = { + // 0xC0, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + // }; int result; result = usbat_send_control(us, @@ -665,9 +711,9 @@ unsigned char enable_flags, unsigned char data_flags) { - unsigned char command[8] = { - 0x40, 0x82, enable_flags, data_flags, 0x00, 0x00, 0x00, 0x00 - }; + // unsigned char command[8] = { + // 0x40, 0x82, enable_flags, data_flags, 0x00, 0x00, 0x00, 0x00 + // }; int result; result = usbat_send_control(us, @@ -882,18 +928,18 @@ h = return length/2048 in cmnd[7-8]. */ - static char *lengths = + // static char *lengths = /* 0123456789ABCDEF 0123456789ABCDEF */ - "0XXL0XXXXXXXXXXX" "XXLXXXXXXXX0XX0X" /* 00-1F */ - "XXXXX8XXhXH0XXX0" "XXXXX0XXXXXXXXXX" /* 20-3F */ - "XXHHL0X0XXH0XX0X" "XHH00HXX0TH0H0XX" /* 40-5F */ - "XXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXX" /* 60-7F */ - "XXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXX" /* 80-9F */ - "X0XXX0XXDXDXXXXX" "XXXXXXXXX000XHBX" /* A0-BF */ - "XXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXX" /* C0-DF */ - "XDXXXXXXXXXXXXXX" "XXW00HXXXXXXXXXX"; /* E0-FF */ + // "0XXL0XXXXXXXXXXX" "XXLXXXXXXXX0XX0X" /* 00-1F */ + // "XXXXX8XXhXH0XXX0" "XXXXX0XXXXXXXXXX" /* 20-3F */ + // "XXHHL0X0XXH0XX0X" "XHH00HXX0TH0H0XX" /* 40-5F */ + // "XXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXX" /* 60-7F */ + // "XXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXX" /* 80-9F */ + // "X0XXX0XXDXDXXXXX" "XXXXXXXXX000XHBX" /* A0-BF */ + // "XXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXX" /* C0-DF */ + // "XDXXXXXXXXXXXXXX" "XXW00HXXXXXXXXXX"; /* E0-FF */ /* if (us->flags & US_FL_NEED_INIT) { US_DEBUGP("8200e: initializing\n"); @@ -986,16 +1032,36 @@ data[5] = 0xB0; // (device sel) = slave data[6] = 0xA0; // (command) = ATA PACKET COMMAND + for (i=7; i<19; i++) { + registers[i] = 0x10; + data[i] = (i-7 >= srb->cmd_len) ? 0 : srb->cmnd[i-7]; + } + + if (srb->cmnd[0] == TEST_UNIT_READY) + transferred = 0; + if (srb->sc_data_direction == SCSI_DATA_WRITE) { - for (i=7; i<19; i++) { - registers[i] = 0x10; - data[i] = (i-7 >= srb->cmd_len) ? 0 : srb->cmnd[i-7]; + result = usbat_rw_block_test(us, USBAT_ATA, + registers, data, 19, + 0x10, 0x17, 0xFD, 0x30, + SCSI_DATA_WRITE, + srb->request_buffer, + len, srb->use_sg); + + if (result == USB_STOR_TRANSPORT_GOOD) { + transferred += len; + US_DEBUGP("Wrote %08X bytes\n", transferred); } - result = usbat_write_block_test(us, USBAT_ATA, + return result; + + } else if (srb->cmnd[0] == READ_10) { + + result = usbat_rw_block_test(us, USBAT_ATA, registers, data, 19, 0x10, 0x17, 0xFD, 0x30, + SCSI_DATA_READ, srb->request_buffer, len, srb->use_sg); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/storage/transport.c linux/drivers/usb/storage/transport.c --- v2.4.0-test8/linux/drivers/usb/storage/transport.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/usb/storage/transport.c Fri Sep 15 21:37:23 2000 @@ -1,6 +1,6 @@ /* Driver for USB Mass Storage compliant devices * - * $Id: transport.c,v 1.18 2000/08/25 00:13:51 mdharm Exp $ + * $Id: transport.c,v 1.23 2000/09/08 21:20:06 mdharm Exp $ * * Current development and maintenance by: * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) @@ -48,6 +48,7 @@ #include "usb.h" #include "debug.h" +#include #include #include #include @@ -680,7 +681,7 @@ need_auto_sense = 1; } if (result == USB_STOR_TRANSPORT_ERROR) { - /* FIXME: we need to invoke a transport reset here */ + us->transport_reset(us); US_DEBUGP("-- transport indicates transport failure\n"); need_auto_sense = 0; srb->result = DID_ERROR << 16; @@ -742,7 +743,7 @@ /* issue the auto-sense command */ temp_result = us->transport(us->srb, us); if (temp_result != USB_STOR_TRANSPORT_GOOD) { - /* FIXME: we need to invoke a transport reset here */ + us->transport_reset(us); US_DEBUGP("-- auto-sense failure\n"); srb->result = DID_ERROR << 16; return; @@ -754,9 +755,15 @@ srb->sense_buffer[2] & 0xf, srb->sense_buffer[12], srb->sense_buffer[13]); +#ifdef CONFIG_USB_STORAGE_DEBUG + usb_stor_show_sense( + srb->sense_buffer[2] & 0xf, + srb->sense_buffer[12], + srb->sense_buffer[13]); +#endif /* set the result so the higher layers expect this data */ - srb->result = CHECK_CONDITION; + srb->result = CHECK_CONDITION << 1; /* we're done here, let's clean up */ srb->request_buffer = old_request_buffer; @@ -767,15 +774,15 @@ /* If things are really okay, then let's show that */ if ((srb->sense_buffer[2] & 0xf) == 0x0) - srb->result = GOOD; + srb->result = GOOD << 1; } else /* if (need_auto_sense) */ - srb->result = GOOD; + srb->result = GOOD << 1; /* Regardless of auto-sense, if we _know_ we have an error * condition, show that in the result code */ if (result == USB_STOR_TRANSPORT_FAILED) - srb->result = CHECK_CONDITION; + srb->result = CHECK_CONDITION << 1; /* If we think we're good, then make sure the sense data shows it. * This is necessary because the auto-sense for some devices always @@ -822,6 +829,9 @@ { int result; + /* Set up for status notification */ + us->ip_wanted = 1; + /* COMMAND STAGE */ /* let's send the command via the control pipe */ result = usb_stor_control_msg(us, usb_sndctrlpipe(us->pusb_dev,0), @@ -832,6 +842,9 @@ /* check the return code for the command */ US_DEBUGP("Call to usb_stor_control_msg() returned %d\n", result); if (result < 0) { + /* Reset flag for status notification */ + us->ip_wanted = 0; + /* if the command was aborted, indicate that */ if (result == -ENOENT) return USB_STOR_TRANSPORT_ABORTED; @@ -850,9 +863,6 @@ return USB_STOR_TRANSPORT_ERROR; } - /* Set up for status notification */ - us->ip_wanted = 1; - /* DATA STAGE */ /* transfer the data payload for this command, if one exists*/ if (us_transfer_length(srb)) { @@ -1167,6 +1177,9 @@ USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, us->ifnum, cmd, sizeof(cmd), HZ*5); + if (result < 0) + US_DEBUGP("CB[I] soft reset failed %d\n", result); + /* long wait for reset */ schedule_timeout(HZ*6); @@ -1177,7 +1190,8 @@ usb_rcvbulkpipe(us->pusb_dev, us->ep_out)); US_DEBUGP("CB_reset done\n"); - return 0; + /* return a result code based on the result of the control message */ + return result < 0 ? FAILED : SUCCESS; } /* This issues a Bulk-only Reset to the device in question, including @@ -1196,15 +1210,16 @@ 0, us->ifnum, NULL, 0, HZ*5); if (result < 0) - US_DEBUGP("Bulk hard reset failed %d\n", result); + US_DEBUGP("Bulk soft reset failed %d\n", result); + + /* long wait for reset */ + schedule_timeout(HZ*6); clear_halt(us->pusb_dev, usb_rcvbulkpipe(us->pusb_dev, us->ep_in)); clear_halt(us->pusb_dev, usb_sndbulkpipe(us->pusb_dev, us->ep_out)); - /* long wait for reset */ - schedule_timeout(HZ*6); - - return result; + /* return a result code based on the result of the control message */ + return result < 0 ? FAILED : SUCCESS; } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/storage/transport.h linux/drivers/usb/storage/transport.h --- v2.4.0-test8/linux/drivers/usb/storage/transport.h Fri Sep 8 13:27:12 2000 +++ linux/drivers/usb/storage/transport.h Fri Sep 8 16:39:12 2000 @@ -1,7 +1,7 @@ /* Driver for USB Mass Storage compliant devices * Transport Functions Header File * - * $Id: transport.h,v 1.11 2000/08/25 00:13:51 mdharm Exp $ + * $Id: transport.h,v 1.12 2000/09/08 21:20:06 mdharm Exp $ * * Current development and maintenance by: * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) @@ -41,8 +41,8 @@ #ifndef _TRANSPORT_H_ #define _TRANSPORT_H_ -#include #include +#include #include "usb.h" #include "scsi.h" diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/storage/usb.c linux/drivers/usb/storage/usb.c --- v2.4.0-test8/linux/drivers/usb/storage/usb.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/usb/storage/usb.c Fri Sep 15 21:37:23 2000 @@ -1,6 +1,6 @@ /* Driver for USB Mass Storage compliant devices * - * $Id: usb.c,v 1.33 2000/08/25 00:13:51 mdharm Exp $ + * $Id: usb.c,v 1.39 2000/09/08 21:20:06 mdharm Exp $ * * Current development and maintenance by: * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net) @@ -49,6 +49,7 @@ #include "transport.h" #include "protocol.h" #include "debug.h" +#include "initializers.h" #ifdef CONFIG_USB_STORAGE_HP8200e #include "shuttle_usbat.h" #endif @@ -206,7 +207,7 @@ */ if (us->srb->sc_data_direction == SCSI_DATA_UNKNOWN) { US_DEBUGP("UNKNOWN data direction\n"); - us->srb->result = DID_ERROR; + us->srb->result = DID_ERROR << 16; set_current_state(TASK_INTERRUPTIBLE); us->srb->scsi_done(us->srb); us->srb = NULL; @@ -242,7 +243,7 @@ /* handle those devices which can't do a START_STOP */ if ((us->srb->cmnd[0] == START_STOP) && (us->flags & US_FL_START_STOP)) { - us->srb->result = GOOD; + us->srb->result = GOOD << 1; set_current_state(TASK_INTERRUPTIBLE); us->srb->scsi_done(us->srb); @@ -264,12 +265,12 @@ memcpy(us->srb->request_buffer, usb_stor_sense_notready, sizeof(usb_stor_sense_notready)); - us->srb->result = GOOD; + us->srb->result = GOOD << 1; } else { memcpy(us->srb->sense_buffer, usb_stor_sense_notready, sizeof(usb_stor_sense_notready)); - us->srb->result = CHECK_CONDITION; + us->srb->result = CHECK_CONDITION << 1; } } else { /* !us->pusb_dev */ /* we've got a command, let's do it! */ @@ -328,20 +329,6 @@ * restriction. However, if the flag is not present, then you * are free to use as many characters as you like. */ - -int euscsi_init(struct us_data *us) -{ - unsigned char bar = 0x1; - int result; - - US_DEBUGP("Attempting to init eUSCSI bridge...\n"); - result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev, 0), - 0x0C, USB_RECIP_INTERFACE | USB_TYPE_VENDOR, - 0x01, 0x0, &bar, 0x1, 5*HZ); - US_DEBUGP("-- result is %d\n", result); - US_DEBUGP("-- bar afterwards is %d\n", bar); -} - static struct us_unusual_dev us_unusual_dev_list[] = { { 0x03f0, 0x0107, 0x0200, 0x0200, @@ -367,7 +354,7 @@ { 0x04e6, 0x0002, 0x0100, 0x0100, "Shuttle", "eUSCSI Bridge", - US_SC_SCSI, US_PR_BULK, euscsi_init, + US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init, US_FL_SCM_MULT_TARG }, #ifdef CONFIG_USB_STORAGE_SDDR09 @@ -392,28 +379,34 @@ US_SC_SCSI, US_PR_CB, NULL, US_FL_SINGLE_LUN}, + { 0x04e6, 0x0007, 0x0100, 0x0200, + "Sony", + "Hifd", + US_SC_SCSI, US_PR_CB, NULL, + US_FL_SINGLE_LUN}, + { 0x04e6, 0x0009, 0x0200, 0x0200, "Shuttle", - "ATA/ATAPI Bridge", + "eUSB ATA/ATAPI Adapter", US_SC_8020, US_PR_CB, NULL, US_FL_SINGLE_LUN}, - { 0x04e6, 0x000A, 0x0200, 0x0200, + { 0x04e6, 0x000a, 0x0200, 0x0200, "Shuttle", - "Compact Flash Reader", + "eUSB CompactFlash Adapter", US_SC_8020, US_PR_CB, NULL, US_FL_SINGLE_LUN}, { 0x04e6, 0x000B, 0x0100, 0x0100, "Shuttle", "eUSCSI Bridge", - US_SC_SCSI, US_PR_BULK, euscsi_init, + US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init, US_FL_SCM_MULT_TARG }, { 0x04e6, 0x000C, 0x0100, 0x0100, "Shuttle", "eUSCSI Bridge", - US_SC_SCSI, US_PR_BULK, euscsi_init, + US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init, US_FL_SCM_MULT_TARG }, { 0x04e6, 0x0101, 0x0200, 0x0200, @@ -424,7 +417,7 @@ { 0x054c, 0x0010, 0x0210, 0x0210, "Sony", - "DSC-S30/S70", + "DSC-S30/S70/505V", US_SC_SCSI, US_PR_CB, NULL, US_FL_SINGLE_LUN | US_FL_START_STOP | US_FL_MODE_XLATE }, @@ -454,10 +447,24 @@ { 0x05ab, 0x0031, 0x0100, 0x0100, "In-System", - "USB/IDE Bridge", + "USB/IDE Bridge (ATAPI ONLY!)", US_SC_8070, US_PR_BULK, NULL, 0 }, + { 0x0644, 0x0000, 0x0100, 0x0100, + "TEAC", + "Floppy Drive", + US_SC_UFI, US_PR_CB, NULL, + 0 }, + +#ifdef CONFIG_USB_STORAGE_SDDR09 + { 0x066b, 0x0105, 0x0100, 0x0100, + "Olympus", + "Camedia MAUSB-2", + US_SC_SCSI, US_PR_EUSB_SDDR09, NULL, + US_FL_SINGLE_LUN | US_FL_START_STOP }, +#endif + { 0x0693, 0x0005, 0x0100, 0x0100, "Hagiwara", "Flashgate", @@ -493,20 +500,20 @@ { 0x07af, 0x0004, 0x0100, 0x0100, "Microtech", "USB-SCSI-DB25", - US_SC_SCSI, US_PR_BULK, euscsi_init, + US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init, US_FL_SCM_MULT_TARG }, #ifdef CONFIG_USB_STORAGE_FREECOM { 0x07ab, 0xfc01, 0x0921, 0x0921, "Freecom", "USB-IDE", - US_SC_8070, US_PR_FREECOM, NULL, US_FL_SINGLE_LUN }, + US_SC_8070, US_PR_FREECOM, freecom_init, US_FL_SINGLE_LUN }, #endif { 0x07af, 0x0005, 0x0100, 0x0100, "Microtech", "USB-SCSI-HD50", - US_SC_SCSI, US_PR_BULK, euscsi_init, + US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init, US_FL_SCM_MULT_TARG }, #ifdef CONFIG_USB_STORAGE_DPCM @@ -613,7 +620,9 @@ unsigned int flags; struct us_unusual_dev *unusual_dev; struct us_data *ss = NULL; +#ifdef CONFIG_USB_STORAGE_SDDR09 int result; +#endif /* these are temporary copies -- we test on these, then put them * in the us-data structure diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/usb-core.c linux/drivers/usb/usb-core.c --- v2.4.0-test8/linux/drivers/usb/usb-core.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/usb/usb-core.c Fri Sep 15 21:37:23 2000 @@ -12,7 +12,6 @@ #include #include -#include #include #include diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/usb-ohci.c linux/drivers/usb/usb-ohci.c --- v2.4.0-test8/linux/drivers/usb/usb-ohci.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/usb/usb-ohci.c Fri Sep 8 16:36:10 2000 @@ -2,6 +2,7 @@ * URB OHCI HCD (Host Controller Driver) for USB. * * (C) Copyright 1999 Roman Weissgaerber + * (C) Copyright 2000 David Brownell * * [ Initialisation is based on Linus' ] * [ uhci code and gregs ohci fragments ] @@ -11,6 +12,10 @@ * * History: * + * 2000/08/29 use bandwidth claiming hooks (thanks Randy!), fix some + * urb unlink probs, indentation fixes + * 2000/08/11 various oops fixes mostly affecting iso and cleanup from + * device unplugs. * 2000/06/28 use PCI hotplug framework, for better power management * and for Cardbus support (David Brownell) * 2000/earlier: fixes for NEC/Lucent chips; suspend/resume handling @@ -83,15 +88,29 @@ * URB support functions *-------------------------------------------------------------------------*/ -/* free the private part of an URB */ +/* free HCD-private data associated with this URB */ static void urb_rm_priv (urb_t * urb) { urb_priv_t * urb_priv = urb->hcpriv; int i; - if (!urb_priv) return; - + /* Release int/iso bandwidth for Interrupt or Isoc. transfers */ + if (urb->bandwidth) { + switch (usb_pipetype(urb->pipe)) { + case PIPE_INTERRUPT: + usb_release_bandwidth (urb->dev, urb, 0); + break; + case PIPE_ISOCHRONOUS: + usb_release_bandwidth (urb->dev, urb, 1); + break; + default: + break; + } + } + + if (!urb_priv) + return; for (i = 0; i < urb_priv->length; i++) { if (urb_priv->td [i]) { OHCI_FREE (urb_priv->td [i]); @@ -416,6 +435,7 @@ unsigned int pipe = urb->pipe; int i, size = 0; unsigned long flags; + int bustime = 0; if (!urb->dev || !urb->dev->bus) return -EINVAL; @@ -457,6 +477,10 @@ break; case PIPE_ISOCHRONOUS: /* number of packets from URB */ size = urb->number_of_packets; + if (size <= 0) { + usb_dec_dev_use (urb->dev); + return -EINVAL; + } for (i = 0; i < urb->number_of_packets; i++) { urb->iso_frame_desc[i].actual_length = 0; urb->iso_frame_desc[i].status = -EXDEV; @@ -468,11 +492,10 @@ break; case PIPE_INTERRUPT: /* one TD */ size = 1; - break; } - /* allocate the private part or the URB */ + /* allocate the private part of the URB */ urb_priv = kmalloc (sizeof (urb_priv_t) + size * sizeof (td_t *), in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); if (!urb_priv) { @@ -487,13 +510,13 @@ urb_priv->td_cnt = 0; urb_priv->state = 0; urb_priv->ed = ed; - + /* allocate the TDs */ for (i = 0; i < size; i++) { OHCI_ALLOC (urb_priv->td[i], sizeof (td_t)); if (!urb_priv->td[i]) { - usb_dec_dev_use (urb->dev); urb_rm_priv (urb); + usb_dec_dev_use (urb->dev); return -ENOMEM; } } @@ -505,11 +528,30 @@ return -EINVAL; } - /* for ISOC transfers calculate start frame index */ - if (urb->transfer_flags & USB_ISO_ASAP) { - urb->start_frame = ((ed->state == ED_OPER)? (ed->last_iso + 1): - (le16_to_cpu (ohci->hcca.frame_no) + 10)) & 0xffff; - } + /* allocate and claim bandwidth if needed; ISO + * needs start frame index if it was't provided. + */ + switch (usb_pipetype (pipe)) { + case PIPE_ISOCHRONOUS: + if (urb->transfer_flags & USB_ISO_ASAP) { + urb->start_frame = ((ed->state == ED_OPER) + ? (ed->last_iso + 1) + : (le16_to_cpu (ohci->hcca.frame_no) + 10)) & 0xffff; + } + /* FALLTHROUGH */ + case PIPE_INTERRUPT: + if (urb->bandwidth == 0) { + bustime = usb_check_bandwidth (urb->dev, urb); + } + if (bustime < 0) { + urb_rm_priv (urb); + usb_dec_dev_use (urb->dev); + spin_unlock_irqrestore (&usb_ed_lock, flags); + return bustime; + } + usb_claim_bandwidth (urb->dev, urb, bustime, usb_pipeisoc (urb->pipe)); + } + urb->status = USB_ST_URB_PENDING; urb->actual_length = 0; @@ -573,6 +615,10 @@ urb_priv->state = URB_DEL; spin_lock_irqsave (&usb_ed_lock, flags); + + if (urb_priv->ed->state == ED_OPER) + ep_unlink(ohci, urb_priv->ed); + ep_rm_ed (urb->dev, urb_priv->ed); urb_priv->ed->state |= ED_URB_DEL; spin_unlock_irqrestore (&usb_ed_lock, flags); @@ -595,8 +641,8 @@ urb->status = -EINPROGRESS; } } else { - usb_dec_dev_use (urb->dev); urb_rm_priv (urb); + usb_dec_dev_use (urb->dev); if (urb->complete && (urb->transfer_flags & USB_ASYNC_UNLINK)) { urb->complete (urb); urb->status = 0; @@ -873,8 +919,9 @@ int inter; int interval; __u32 * ed_p; - - + + ed->hwINFO |= cpu_to_le32 (OHCI_ED_SKIP); + switch (ed->type) { case CTRL: if (ed->ed_prev == NULL) { @@ -969,16 +1016,17 @@ td_t * td; ed_t * ed_ret; volatile ed_t * ed; + unsigned long flags; - spin_lock (&usb_ed_lock); + spin_lock_irqsave (&usb_ed_lock, flags); ed = ed_ret = &(usb_to_ohci (usb_dev)->ed[(usb_pipeendpoint (pipe) << 1) | (usb_pipecontrol (pipe)? 0: usb_pipeout (pipe))]); if ((ed->state & ED_DEL) || (ed->state & ED_URB_DEL)) { /* pending delete request */ - spin_unlock (&usb_ed_lock); + spin_unlock_irqrestore (&usb_ed_lock, flags); return NULL; } @@ -987,7 +1035,7 @@ OHCI_ALLOC (td, sizeof (*td)); /* dummy td; end of td list for ed */ if (!td) { /* out of memory */ - spin_unlock (&usb_ed_lock); + spin_unlock_irqrestore (&usb_ed_lock, flags); return NULL; } ed->hwTailP = cpu_to_le32 (virt_to_bus (td)); @@ -1011,7 +1059,7 @@ ed->int_load = load; } - spin_unlock(&usb_ed_lock); + spin_unlock_irqrestore (&usb_ed_lock, flags); return ed_ret; } @@ -1029,28 +1077,29 @@ if ((ed->state & ED_DEL) || (ed->state & ED_URB_DEL)) return; - ed->hwINFO |= cpu_to_le32 (OHCI_ED_SKIP); + ed->hwINFO |= cpu_to_le32 (OHCI_ED_SKIP); if (!ohci->disabled) { - /* enable SOF interrupt */ - writel (OHCI_INTR_SF, &ohci->regs->intrstatus); - writel (OHCI_INTR_SF, &ohci->regs->intrenable); + switch (ed->type) { + case CTRL: /* stop CTRL list */ + writel (ohci->hc_control &= ~OHCI_CTRL_CLE, + &ohci->regs->control); + break; + case BULK: /* stop BULK list */ + writel (ohci->hc_control &= ~OHCI_CTRL_BLE, + &ohci->regs->control); + break; + } } frame = le16_to_cpu (ohci->hcca.frame_no) & 0x1; ed->ed_rm_list = ohci->ed_rm_list[frame]; ohci->ed_rm_list[frame] = ed; - if (ohci->disabled) - return; - - switch (ed->type) { - case CTRL: /* stop CTRL list */ - writel (ohci->hc_control &= ~OHCI_CTRL_CLE, &ohci->regs->control); - break; - case BULK: /* stop BULK list */ - writel (ohci->hc_control &= ~OHCI_CTRL_BLE, &ohci->regs->control); - break; + if (!ohci->disabled) { + /* enable SOF interrupt */ + writel (OHCI_INTR_SF, &ohci->regs->intrstatus); + writel (OHCI_INTR_SF, &ohci->regs->intrenable); } } @@ -1072,25 +1121,30 @@ td_pt = urb_priv->td [index]; /* fill the old dummy TD */ - td = urb_priv->td [index] = (td_t *) bus_to_virt (le32_to_cpup (&urb_priv->ed->hwTailP) & 0xfffffff0); + td = urb_priv->td [index] = (td_t *) + bus_to_virt (le32_to_cpup (&urb_priv->ed->hwTailP) & 0xfffffff0); td->ed = urb_priv->ed; + td->next_dl_td = NULL; td->index = index; td->urb = urb; td->hwINFO = cpu_to_le32 (info); if ((td->ed->type & 3) == PIPE_ISOCHRONOUS) { - td->hwCBP = cpu_to_le32 (((!data || !len)? - 0 : virt_to_bus (data)) & 0xFFFFF000); + td->hwCBP = cpu_to_le32 (((!data || !len) + ? 0 + : virt_to_bus (data)) & 0xFFFFF000); td->ed->last_iso = info & 0xffff; } else { - td->hwCBP = cpu_to_le32 (((!data || !len)? 0 : virt_to_bus (data))); + td->hwCBP = cpu_to_le32 (((!data || !len) + ? 0 + : virt_to_bus (data))); } - td->hwBE = cpu_to_le32 ((!data || !len )? 0: virt_to_bus (data + len - 1)); + td->hwBE = cpu_to_le32 ((!data || !len ) + ? 0 + : virt_to_bus (data + len - 1)); td->hwNextTD = cpu_to_le32 (virt_to_bus (td_pt)); td->hwPSW [0] = cpu_to_le16 ((virt_to_bus (data) & 0x0FFF) | 0xE000); td_pt->hwNextTD = 0; td->ed->hwTailP = td->hwNextTD; - - td->next_dl_td = NULL; //td_pt; } /*-------------------------------------------------------------------------*/ @@ -1375,12 +1429,19 @@ /* error code of transfer */ cc = TD_CC_GET (tdINFO); - if( cc == TD_CC_STALL) usb_endpoint_halt(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe)); + if (cc == TD_CC_STALL) + usb_endpoint_halt(urb->dev, + usb_pipeendpoint(urb->pipe), + usb_pipeout(urb->pipe)); - if (!(urb->transfer_flags & USB_DISABLE_SPD) && (cc == TD_DATAUNDERRUN)) - cc = TD_CC_NOERROR; + if (!(urb->transfer_flags & USB_DISABLE_SPD) + && (cc == TD_DATAUNDERRUN)) + cc = TD_CC_NOERROR; + if (++(urb_priv->td_cnt) == urb_priv->length) { - if (urb_priv->state != URB_DEL && !(ed->state & ED_DEL) && ed->state != ED_NEW) { + if (urb_priv->state != URB_DEL + && !(ed->state & ED_DEL) + && ed->state != ED_NEW) { urb->status = cc_to_error[cc]; sohci_return_urb (urb); } else { @@ -1393,13 +1454,13 @@ edHeadP = le32_to_cpup (&ed->hwHeadP) & 0xfffffff0; edTailP = le32_to_cpup (&ed->hwTailP); - if((edHeadP == edTailP) && (ed->state == ED_OPER)) - ep_unlink (ohci, ed); /* unlink eds if they are not busy */ - - } - spin_unlock_irqrestore (&usb_ed_lock, flags); + /* unlink eds if they are not busy */ + if ((edHeadP == edTailP) && (ed->state == ED_OPER)) + ep_unlink (ohci, ed); + } + spin_unlock_irqrestore (&usb_ed_lock, flags); - td_list = td_list_next; + td_list = td_list_next; } } @@ -2402,5 +2463,5 @@ -MODULE_AUTHOR ("Roman Weissgaerber "); +MODULE_AUTHOR ("Roman Weissgaerber , David Brownell"); MODULE_DESCRIPTION ("USB OHCI Host Controller Driver"); diff -u --recursive --new-file v2.4.0-test8/linux/drivers/usb/usb-ohci.h linux/drivers/usb/usb-ohci.h --- v2.4.0-test8/linux/drivers/usb/usb-ohci.h Wed Aug 23 18:36:38 2000 +++ linux/drivers/usb/usb-ohci.h Fri Sep 8 16:36:10 2000 @@ -1,10 +1,10 @@ - /* +/* * URB OHCI HCD (Host Controller Driver) for USB. * - *(C) Copyright 1999 Roman Weissgaerber + * (C) Copyright 1999 Roman Weissgaerber + * (C) Copyright 2000 David Brownell * * usb-ohci.h - * */ @@ -40,7 +40,7 @@ #define ED_UNLINK 0x01 #define ED_OPER 0x02 #define ED_DEL 0x04 -#define ED_URB_DEL 0x08 +#define ED_URB_DEL 0x08 /* usb_ohci_ed */ typedef struct ed { @@ -372,8 +372,8 @@ struct list_head ohci_hcd_list; /* list of all ohci_hcd */ struct ohci * next; // chain of uhci device contexts - struct list_head urb_list; // list of all pending urbs - spinlock_t urb_list_lock; // lock to keep consistency + // struct list_head urb_list; // list of all pending urbs + // spinlock_t urb_list_lock; // lock to keep consistency int ohci_int_load[32]; /* load of the 32 Interrupt Chains (for load balancing)*/ ed_t * ed_rm_list[2]; /* lists of all endpoints to be removed */ @@ -418,7 +418,7 @@ static int rh_unlink_urb(urb_t * urb); static int rh_init_int_timer(urb_t * urb); -#ifdef DEBUG +#ifdef OHCI_VERBOSE_DEBUG #define OHCI_FREE(x) kfree(x); printk("OHCI FREE: %d: %4x\n", -- __ohci_free_cnt, (unsigned int) x) #define OHCI_ALLOC(x,size) (x) = kmalloc(size, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); printk("OHCI ALLO: %d: %4x\n", ++ __ohci_free_cnt,(unsigned int) x) static int __ohci_free_cnt = 0; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/video/Makefile linux/drivers/video/Makefile --- v2.4.0-test8/linux/drivers/video/Makefile Wed Aug 9 19:19:51 2000 +++ linux/drivers/video/Makefile Sun Sep 17 09:48:04 2000 @@ -46,7 +46,10 @@ # Add fbmon.o back into obj-$(CONFIG_FB) in 2.5.x obj-$(CONFIG_FB) += fbmem.o fbcmap.o modedb.o fbcon.o fonts.o +# Only include macmodes.o if we have FB support and are PPC +ifeq ($(CONFIG_FB),y) obj-$(CONFIG_PPC) += macmodes.o +endif obj-$(CONFIG_FB_ACORN) += acornfb.o obj-$(CONFIG_FB_AMIGA) += amifb.o diff -u --recursive --new-file v2.4.0-test8/linux/drivers/video/aty.h linux/drivers/video/aty.h --- v2.4.0-test8/linux/drivers/video/aty.h Fri Jun 23 21:55:10 2000 +++ linux/drivers/video/aty.h Sun Sep 17 09:48:04 2000 @@ -461,6 +461,7 @@ #define VERTEX_2_SECONDARY_T 0x0738 /* Dword offset 1_CE */ #define VERTEX_2_SECONDARY_W 0x073C /* Dword offset 1_CF */ +#define GTC_3D_RESET_DELAY 3 /* 3D engine reset delay in ms */ /* CRTC control values (mostly CRTC_GEN_CNTL) */ @@ -747,7 +748,8 @@ #define GI_CHIP_ID 0x4749 /* RAGE PRO, BGA, PCI33 only */ #define GP_CHIP_ID 0x4750 /* RAGE PRO, PQFP, PCI33, full 3D */ #define GQ_CHIP_ID 0x4751 /* RAGE PRO, PQFP, PCI33, limited 3D */ -#define LN_CHIP_ID 0x4c4d /* RAGE Mobility AGP */ +#define LM_CHIP_ID 0x4c4d /* RAGE Mobility PCI */ +#define LN_CHIP_ID 0x4c4e /* RAGE Mobility AGP */ /* Mach64 major ASIC revisions */ @@ -998,5 +1000,12 @@ #define LCD_LT_GIO 0x07 #define LCD_POWER_MANAGEMENT 0x08 #define LCD_ZVGPIO 0x09 +#define LCD_MISC_CNTL 0x14 + +/* Values in LCD_MISC_CNTL */ +#define BIAS_MOD_LEVEL_MASK 0x0000ff00 +#define BIAS_MOD_LEVEL_SHIFT 8 +#define BLMOD_EN 0x00010000 +#define BIASMOD_EN 0x00020000 #endif /* REGMACH64_H */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/video/aty128.h linux/drivers/video/aty128.h --- v2.4.0-test8/linux/drivers/video/aty128.h Fri Jun 23 21:55:10 2000 +++ linux/drivers/video/aty128.h Sun Sep 17 09:48:04 2000 @@ -43,6 +43,7 @@ #define OVR_CLR 0x0230 #define OVR_WID_LEFT_RIGHT 0x0234 #define OVR_WID_TOP_BOTTOM 0x0238 +#define LVDS_GEN_CNTL 0x02d0 #define DDA_CONFIG 0x02e0 #define DDA_ON_OFF 0x02e4 #define VGA_DDA_CONFIG 0x02e8 @@ -267,7 +268,8 @@ #define DAC_BLANKING 0x00000004 #define DAC_RANGE_CNTL 0x00000003 #define DAC_RANGE_CNTL 0x00000003 -#define PALETTE_ACCESS_CNTL 0x00000020 +#define DAC_PALETTE_ACCESS_CNTL 0x00000020 +#define DAC_PDWN 0x00008000 /* GEN_RESET_CNTL bit constants */ #define SOFT_RESET_GUI 0x00000001 @@ -339,5 +341,12 @@ #define DP_SRC_RECT 0x00000200 #define DP_SRC_HOST 0x00000300 #define DP_SRC_HOST_BYTEALIGN 0x00000400 + +/* LVDS_GEN_CNTL constants */ +#define LVDS_BL_MOD_LEVEL_MASK 0x0000ff00 +#define LVDS_BL_MOD_LEVEL_SHIFT 8 +#define LVDS_BL_MOD_EN 0x00010000 +#define LVDS_DIGION 0x00040000 +#define LVDS_BLON 0x00080000 #endif /* REG_RAGE128_H */ diff -u --recursive --new-file v2.4.0-test8/linux/drivers/video/aty128fb.c linux/drivers/video/aty128fb.c --- v2.4.0-test8/linux/drivers/video/aty128fb.c Thu Jul 27 17:38:01 2000 +++ linux/drivers/video/aty128fb.c Sun Sep 17 09:48:04 2000 @@ -55,6 +55,15 @@ #endif #endif +#ifdef CONFIG_ADB_PMU +#include +#include +#endif + +#ifdef CONFIG_PMAC_BACKLIGHT +#include +#endif + #ifdef CONFIG_FB_COMPAT_XPMAC #include #endif @@ -211,13 +220,8 @@ #endif #ifdef CONFIG_PPC -#ifdef CONFIG_NVRAM_NOT_DEFINED -static int default_vmode __initdata = VMODE_640_480_60; +static int default_vmode __initdata = VMODE_1024_768_60; static int default_cmode __initdata = CMODE_8; -#else -static int default_vmode __initdata = VMODE_NVRAM; -static int default_cmode __initdata = CMODE_NVRAM; -#endif #endif #ifdef CONFIG_MTRR @@ -419,6 +423,15 @@ fb_rasterimg: aty128fb_rasterimg, }; +#ifdef CONFIG_PMAC_BACKLIGHT +static int aty128_set_backlight_enable(int on, int level, void* data); +static int aty128_set_backlight_level(int level, void* data); + +static struct backlight_controller aty128_backlight_controller = { + aty128_set_backlight_enable, + aty128_set_backlight_level +}; +#endif /* CONFIG_PMAC_BACKLIGHT */ /* * Functions to read from/write to the mmio registers @@ -1712,15 +1725,8 @@ if (!mac_find_mode(&var, &info->fb_info, mode_option, 8)) var = default_var; } else { -#ifdef CONFIG_NVRAM - if (default_vmode == VMODE_NVRAM) - default_vmode = nvram_read_byte(NV_VMODE); - - if (default_cmode == CMODE_NVRAM) - default_cmode = nvram_read_byte(NV_CMODE); -#endif if (default_vmode <= 0 || default_vmode > VMODE_MAX) - default_vmode = VMODE_640_480_60; + default_vmode = VMODE_1024_768_60; if (default_cmode < CMODE_8 || default_cmode > CMODE_32) default_cmode = CMODE_8; @@ -1772,6 +1778,12 @@ if (register_framebuffer(&info->fb_info) < 0) return 0; +#ifdef CONFIG_PMAC_BACKLIGHT + /* Could be extended to Rage128Pro LVDS output too */ + if (info->chip_gen == rage_M3) + register_backlight_controller(&aty128_backlight_controller, info, "ati"); +#endif /* CONFIG_PMAC_BACKLIGHT */ + printk(KERN_INFO "fb%d: %s frame buffer device on %s\n", GET_FB_IDX(info->fb_info.node), aty128fb_name, name); @@ -1916,6 +1928,11 @@ } #endif /* CONFIG_MTRR */ +#ifdef CONFIG_FB_COMPAT_XPMAC + if (!console_fb_info) + console_fb_info = &info->fb_info; +#endif + return 0; err_out: @@ -2136,6 +2153,11 @@ struct fb_info_aty128 *info = (struct fb_info_aty128 *)fb; u8 state = 0; +#ifdef CONFIG_PMAC_BACKLIGHT + if ((_machine == _MACH_Pmac) && blank) + set_backlight_enable(0); +#endif /* CONFIG_PMAC_BACKLIGHT */ + if (blank & VESA_VSYNC_SUSPEND) state |= 2; if (blank & VESA_HSYNC_SUSPEND) @@ -2144,6 +2166,11 @@ state |= 4; aty_st_8(CRTC_EXT_CNTL+1, state); + +#ifdef CONFIG_PMAC_BACKLIGHT + if ((_machine == _MACH_Pmac) && !blank) + set_backlight_enable(1); +#endif /* CONFIG_PMAC_BACKLIGHT */ } @@ -2199,7 +2226,7 @@ int i; if (info->chip_gen == rage_M3) - aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) & ~PALETTE_ACCESS_CNTL); + aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) & ~DAC_PALETTE_ACCESS_CNTL); for (i=16; i<256; i++) { aty_st_8(PALETTE_INDEX, i); @@ -2208,7 +2235,7 @@ } if (info->chip_gen == rage_M3) { - aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) | PALETTE_ACCESS_CNTL); + aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) | DAC_PALETTE_ACCESS_CNTL); for (i=16; i<256; i++) { aty_st_8(PALETTE_INDEX, i); @@ -2221,7 +2248,7 @@ /* initialize palette */ if (info->chip_gen == rage_M3) - aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) & ~PALETTE_ACCESS_CNTL); + aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) & ~DAC_PALETTE_ACCESS_CNTL); if (info->current_par.crtc.bpp == 16) aty_st_8(PALETTE_INDEX, (regno << 3)); @@ -2230,7 +2257,7 @@ col = (red << 16) | (green << 8) | blue; aty_st_le32(PALETTE_DATA, col); if (info->chip_gen == rage_M3) { - aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) | PALETTE_ACCESS_CNTL); + aty_st_le32(DAC_CNTL, aty_ld_le32(DAC_CNTL) | DAC_PALETTE_ACCESS_CNTL); if (info->current_par.crtc.bpp == 16) aty_st_8(PALETTE_INDEX, (regno << 3)); else @@ -2282,6 +2309,38 @@ } } + +#ifdef CONFIG_PMAC_BACKLIGHT +static int backlight_conv[] = { + 0xff, 0xc0, 0xb5, 0xaa, 0x9f, 0x94, 0x89, 0x7e, + 0x73, 0x68, 0x5d, 0x52, 0x47, 0x3c, 0x31, 0x24 +}; + +static int +aty128_set_backlight_enable(int on, int level, void* data) +{ + struct fb_info_aty128 *info = (struct fb_info_aty128 *)data; + unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL); + + reg |= LVDS_BL_MOD_EN | LVDS_BLON; + if (on && level > BACKLIGHT_OFF) { + reg &= ~LVDS_BL_MOD_LEVEL_MASK; + reg |= (backlight_conv[level] << LVDS_BL_MOD_LEVEL_SHIFT); + } else { + reg &= ~LVDS_BL_MOD_LEVEL_MASK; + reg |= (backlight_conv[0] << LVDS_BL_MOD_LEVEL_SHIFT); + } + aty_st_le32(LVDS_GEN_CNTL, reg); + + return 0; +} + +static int +aty128_set_backlight_level(int level, void* data) +{ + return aty128_set_backlight_enable(1, level, data); +} +#endif /* CONFIG_PMAC_BACKLIGHT */ /* * Accelerated functions diff -u --recursive --new-file v2.4.0-test8/linux/drivers/video/atyfb.c linux/drivers/video/atyfb.c --- v2.4.0-test8/linux/drivers/video/atyfb.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/video/atyfb.c Sun Sep 17 09:48:05 2000 @@ -20,6 +20,8 @@ * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive for * more details. + * + * Many thanks to Nitya from ATI devrel for support and patience ! */ /****************************************************************************** @@ -73,6 +75,10 @@ #ifdef CONFIG_NVRAM #include #endif +#ifdef CONFIG_PMAC_BACKLIGHT +#include +#endif + #ifdef __sparc__ #include #include @@ -286,6 +292,15 @@ static struct fb_info_aty* first_display = NULL; #endif +#ifdef CONFIG_PMAC_BACKLIGHT +static int aty_set_backlight_enable(int on, int level, void* data); +static int aty_set_backlight_level(int level, void* data); + +static struct backlight_controller aty_backlight_controller = { + aty_set_backlight_enable, + aty_set_backlight_level +}; +#endif /* CONFIG_PMAC_BACKLIGHT */ /* * Frame buffer device API @@ -556,6 +571,8 @@ { 0x4749, 0x4749, "3D RAGE PRO (BGA, PCI)" }, { 0x4750, 0x4750, "3D RAGE PRO (PQFP, PCI)" }, { 0x4751, 0x4751, "3D RAGE PRO (PQFP, PCI, limited 3D)" }, + { 0x4c4d, 0x4c4d, "3D RAGE Mobility (PCI)" }, + { 0x4c4e, 0x4c4e, "3D RAGE Mobility (AGP)" }, }; static const char *aty_gx_ram[8] __initdata = { @@ -567,48 +584,51 @@ }; -static inline u32 aty_ld_le32(unsigned int regindex, +static inline u32 aty_ld_le32(int regindex, const struct fb_info_aty *info) { -#if defined(__powerpc__) - unsigned long temp; - u32 val; + /* Hack for bloc 1, should be cleanly optimized by compiler */ + if (regindex >= 0x400) + regindex -= 0x800; - temp = info->ati_regbase; - asm volatile("lwbrx %0,%1,%2;eieio" : "=r"(val) : "b" (regindex), "r" (temp)); - return val; -#elif defined(__mc68000__) +#if defined(__mc68000__) return le32_to_cpu(*((volatile u32 *)(info->ati_regbase+regindex))); #else return readl (info->ati_regbase + regindex); #endif } -static inline void aty_st_le32(unsigned int regindex, u32 val, +static inline void aty_st_le32(int regindex, u32 val, const struct fb_info_aty *info) { -#if defined(__powerpc__) - unsigned long temp; + /* Hack for bloc 1, should be cleanly optimized by compiler */ + if (regindex >= 0x400) + regindex -= 0x800; - temp = info->ati_regbase; - asm volatile("stwbrx %0,%1,%2;eieio" : : "r" (val), "b" (regindex), "r" (temp) : - "memory"); -#elif defined(__mc68000__) +#if defined(__mc68000__) *((volatile u32 *)(info->ati_regbase+regindex)) = cpu_to_le32(val); #else writel (val, info->ati_regbase + regindex); #endif } -static inline u8 aty_ld_8(unsigned int regindex, +static inline u8 aty_ld_8(int regindex, const struct fb_info_aty *info) { + /* Hack for bloc 1, should be cleanly optimized by compiler */ + if (regindex >= 0x400) + regindex -= 0x800; + return readb (info->ati_regbase + regindex); } -static inline void aty_st_8(unsigned int regindex, u8 val, +static inline void aty_st_8(int regindex, u8 val, const struct fb_info_aty *info) { + /* Hack for bloc 1, should be cleanly optimized by compiler */ + if (regindex >= 0x400) + regindex -= 0x800; + writeb (val, info->ati_regbase + regindex); } @@ -675,6 +695,16 @@ BUS_FIFO_ERR_ACK, info); } +static void reset_GTC_3D_engine(const struct fb_info_aty *info) +{ + aty_st_le32(SCALE_3D_CNTL, 0xc0, info); + mdelay(GTC_3D_RESET_DELAY); + aty_st_le32(SETUP_CNTL, 0x00, info); + mdelay(GTC_3D_RESET_DELAY); + aty_st_le32(SCALE_3D_CNTL, 0x00, info); + mdelay(GTC_3D_RESET_DELAY); +} + static void init_engine(const struct atyfb_par *par, struct fb_info_aty *info) { u32 pitch_value; @@ -688,6 +718,13 @@ pitch_value = pitch_value * 3; } + /* On GTC (RagePro), we need to reset the 3D engine before */ + if (Gx == LB_CHIP_ID || Gx == LD_CHIP_ID || Gx == LI_CHIP_ID || + Gx == LP_CHIP_ID || Gx == GB_CHIP_ID || Gx == GD_CHIP_ID || + Gx == GI_CHIP_ID || Gx == GP_CHIP_ID || Gx == GQ_CHIP_ID || + Gx == LM_CHIP_ID || Gx == LN_CHIP_ID) + reset_GTC_3D_engine(info); + /* Reset engine, enable, and clear any engine errors */ reset_engine(info); /* Ensure that vga page pointers are set to zero - the upper */ @@ -2494,6 +2531,9 @@ } else if ((Gx == VT_CHIP_ID) || (Gx == VU_CHIP_ID)) { aty_st_le32(DAC_CNTL, 0x87010184, info); aty_st_le32(BUS_CNTL, 0x680000f9, info); + } else if ((Gx == LN_CHIP_ID) || (Gx == LM_CHIP_ID)) { + aty_st_le32(DAC_CNTL, 0x80010102, info); + aty_st_le32(BUS_CNTL, 0x7b33a040, info); } else { /* GT */ aty_st_le32(DAC_CNTL, 0x86010102, info); @@ -3375,6 +3415,10 @@ /* Rage LT */ pll = 230; mclk = 63; + } else if ((Gx == LN_CHIP_ID) || (Gx == LM_CHIP_ID)) { + /* Rage mobility M1 */ + pll = 230; + mclk = 50; } else { /* other RAGE */ pll = 135; @@ -3545,13 +3589,15 @@ info->fb_info.blank = &atyfbcon_blank; info->fb_info.flags = FBINFO_FLAG_DEFAULT; -#ifdef CONFIG_PPC +#ifdef CONFIG_PMAC_BACKLIGHT if (Gx == LI_CHIP_ID && machine_is_compatible("PowerBook1,1")) { /* these bits let the 101 powerbook wake up from sleep -- paulus */ aty_st_lcd(LCD_POWER_MANAGEMENT, aty_ld_lcd(LCD_POWER_MANAGEMENT, info) | (USE_F32KHZ | TRISTATE_MEM_EN), info); } -#endif /* CONFIG_PPC */ + if ((Gx == LN_CHIP_ID) || (Gx == LM_CHIP_ID)) + register_backlight_controller(&aty_backlight_controller, info, "ati"); +#endif /* CONFIG_PMAC_BACKLIGHT */ #ifdef MODULE var = default_var; @@ -3580,6 +3626,9 @@ default_vmode = VMODE_1024_768_60; else if (machine_is_compatible("iMac")) default_vmode = VMODE_1024_768_75; + else if (machine_is_compatible("PowerBook2,1")) + /* iBook with 800x600 LCD */ + default_vmode = VMODE_800_600_60; else default_vmode = VMODE_640_480_67; sense = read_aty_sense(info); @@ -4216,10 +4265,10 @@ struct fb_info_aty *info = (struct fb_info_aty *)fb; u8 gen_cntl; -#ifdef CONFIG_ADB_PMU +#ifdef CONFIG_PMAC_BACKLIGHT if ((_machine == _MACH_Pmac) && blank) - pmu_enable_backlight(0); -#endif + set_backlight_enable(0); +#endif /* CONFIG_PMAC_BACKLIGHT */ gen_cntl = aty_ld_8(CRTC_GEN_CNTL, info); if (blank > 0) @@ -4241,10 +4290,10 @@ gen_cntl &= ~(0x4c); aty_st_8(CRTC_GEN_CNTL, gen_cntl, info); -#ifdef CONFIG_ADB_PMU +#ifdef CONFIG_PMAC_BACKLIGHT if ((_machine == _MACH_Pmac) && !blank) - pmu_enable_backlight(1); -#endif + set_backlight_enable(1); +#endif /* CONFIG_PMAC_BACKLIGHT */ } @@ -4954,6 +5003,40 @@ return result; } #endif /* CONFIG_PMAC_PBOOK */ + +#ifdef CONFIG_PMAC_BACKLIGHT +static int backlight_conv[] = { + 0x00, 0x3f, 0x4c, 0x59, 0x66, 0x73, 0x80, 0x8d, + 0x9a, 0xa7, 0xb4, 0xc1, 0xcf, 0xdc, 0xe9, 0xff +}; + +static int +aty_set_backlight_enable(int on, int level, void* data) +{ + struct fb_info_aty *info = (struct fb_info_aty *)data; + unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, info); + + reg |= (BLMOD_EN | BIASMOD_EN); + if (on && level > BACKLIGHT_OFF) { + reg &= ~BIAS_MOD_LEVEL_MASK; + reg |= (backlight_conv[level] << BIAS_MOD_LEVEL_SHIFT); + } else { + reg &= ~BIAS_MOD_LEVEL_MASK; + reg |= (backlight_conv[0] << BIAS_MOD_LEVEL_SHIFT); + } + aty_st_lcd(LCD_MISC_CNTL, reg, info); + + return 0; +} + +static int +aty_set_backlight_level(int level, void* data) +{ + return aty_set_backlight_enable(1, level, data); +} + +#endif /* CONFIG_PMAC_BACKLIGHT */ + #ifdef MODULE int __init init_module(void) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/video/chipsfb.c linux/drivers/video/chipsfb.c --- v2.4.0-test8/linux/drivers/video/chipsfb.c Wed Aug 9 19:19:51 2000 +++ linux/drivers/video/chipsfb.c Sun Sep 17 09:48:05 2000 @@ -35,6 +35,9 @@ #include #include #include +#ifdef CONFIG_PMAC_BACKLIGHT +#include +#endif #include #include @@ -245,7 +248,9 @@ // used to disable backlight only for blank > 1, but it seems // useful at blank = 1 too (saves battery, extends backlight life) if (blank) { - pmu_enable_backlight(0); +#ifdef CONFIG_PMAC_BACKLIGHT + set_backlight_enable(0); +#endif /* CONFIG_PMAC_BACKLIGHT */ /* get the palette from the chip */ for (i = 0; i < 256; ++i) { out_8(p->io_base + 0x3c7, i); @@ -262,7 +267,9 @@ out_8(p->io_base + 0x3c9, 0); } } else { - pmu_enable_backlight(1); +#ifdef CONFIG_PMAC_BACKLIGHT + set_backlight_enable(1); +#endif /* CONFIG_PMAC_BACKLIGHT */ for (i = 0; i < 256; ++i) { out_8(p->io_base + 0x3c8, i); udelay(1); @@ -673,8 +680,10 @@ /* Clear the entire framebuffer */ memset(p->frame_buffer, 0, 0x100000); +#ifdef CONFIG_PMAC_BACKLIGHT /* turn on the backlight */ - pmu_enable_backlight(1); + set_backlight_enable(1); +#endif /* CONFIG_PMAC_BACKLIGHT */ init_chips(p); } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/video/controlfb.c linux/drivers/video/controlfb.c --- v2.4.0-test8/linux/drivers/video/controlfb.c Wed Aug 9 19:19:51 2000 +++ linux/drivers/video/controlfb.c Sun Sep 17 09:48:05 2000 @@ -122,6 +122,8 @@ struct fb_info *info); static int control_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info); +static int control_mmap(struct fb_info *info, struct file *file, + struct vm_area_struct *vma); static int controlfb_getcolreg(u_int regno, u_int *red, u_int *green, @@ -171,6 +173,7 @@ fb_get_cmap: control_get_cmap, fb_set_cmap: control_set_cmap, fb_pan_display: control_pan_display, + fb_mmap: control_mmap, }; @@ -327,6 +330,48 @@ return 0; } +/* Private mmap since we want to have a different caching on the framebuffer + * for controlfb. + * Note there's no locking in here; it's done in fb_mmap() in fbmem.c. + */ +static int control_mmap(struct fb_info *info, struct file *file, + struct vm_area_struct *vma) +{ + struct fb_ops *fb = info->fbops; + struct fb_fix_screeninfo fix; + struct fb_var_screeninfo var; + unsigned long off, start; + u32 len; + + fb->fb_get_fix(&fix, PROC_CONSOLE(info), info); + off = vma->vm_pgoff << PAGE_SHIFT; + + /* frame buffer memory */ + start = fix.smem_start; + len = PAGE_ALIGN((start & ~PAGE_MASK)+fix.smem_len); + if (off >= len) { + /* memory mapped io */ + off -= len; + fb->fb_get_var(&var, PROC_CONSOLE(info), info); + if (var.accel_flags) + return -EINVAL; + start = fix.mmio_start; + len = PAGE_ALIGN((start & ~PAGE_MASK)+fix.mmio_len); + pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE|_PAGE_GUARDED; + } else { + /* framebuffer */ + pgprot_val(vma->vm_page_prot) |= _PAGE_WRITETHRU; + } + start &= PAGE_MASK; + vma->vm_pgoff = off >> PAGE_SHIFT; + if (io_remap_page_range(vma->vm_start, off, + vma->vm_end - vma->vm_start, vma->vm_page_prot)) + return -EAGAIN; + + return 0; +} + + /******************** End of controlfb_ops implementation ********************/ /* (new one that is) */ @@ -466,11 +511,6 @@ } } -#ifdef CONFIG_FB_COMPAT_XPMAC -extern struct vc_mode display_info; -extern struct fb_info *console_fb_info; -#endif /* CONFIG_FB_COMPAT_XPMAC */ - static inline int control_vram_reqd(int video_mode, int color_mode) { return (control_reg_init[video_mode-1]->vres @@ -483,12 +523,14 @@ struct adb_request req; int i; +#ifdef CONFIG_ADB_CUDA for (i = 0; i < 3; ++i) { cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_GET_SET_IIC, 0x50, i + 1, params[i]); while (!req.complete) cuda_poll(); } +#endif } diff -u --recursive --new-file v2.4.0-test8/linux/drivers/video/offb.c linux/drivers/video/offb.c --- v2.4.0-test8/linux/drivers/video/offb.c Wed Aug 9 19:19:51 2000 +++ linux/drivers/video/offb.c Sun Sep 17 09:48:05 2000 @@ -43,6 +43,15 @@ static int currcon = 0; +/* Supported palette hacks */ +enum { + cmap_unknown, + cmap_m64, /* ATI Mach64 */ + cmap_r128, /* ATI Rage128 */ + cmap_M3A, /* ATI Rage Mobility M3 Head A */ + cmap_M3B /* ATI Rage Mobility M3 Head B */ +}; + struct fb_info_offb { struct fb_info info; struct fb_fix_screeninfo fix; @@ -51,7 +60,7 @@ struct { u_char red, green, blue, pad; } palette[256]; volatile unsigned char *cmap_adr; volatile unsigned char *cmap_data; - int is_rage_128; + int cmap_type; union { #ifdef FBCON_HAS_CFB16 u16 cfb16[16]; @@ -408,21 +417,27 @@ fix->type = FB_TYPE_PACKED_PIXELS; fix->type_aux = 0; - info->is_rage_128 = 0; + info->cmap_type = cmap_unknown; if (depth == 8) { /* XXX kludge for ati */ - if (strncmp(name, "ATY,Rage128", 11) == 0) { - if (dp) { + if (dp && !strncmp(name, "ATY,Rage128", 11)) { unsigned long regbase = dp->addrs[2].address; - info->cmap_adr = ioremap(regbase, 0x1FFF) + 0x00b0; - info->cmap_data = info->cmap_adr + 4; - info->is_rage_128 = 1; - } - } else if (strncmp(name, "ATY,", 4) == 0) { + info->cmap_adr = ioremap(regbase, 0x1FFF); + info->cmap_type = cmap_r128; + } else if (dp && !strncmp(name, "ATY,RageM3pA", 12)) { + unsigned long regbase = dp->parent->addrs[2].address; + info->cmap_adr = ioremap(regbase, 0x1FFF); + info->cmap_type = cmap_M3A; + } else if (dp && !strncmp(name, "ATY,RageM3pB", 12)) { + unsigned long regbase = dp->parent->addrs[2].address; + info->cmap_adr = ioremap(regbase, 0x1FFF); + info->cmap_type = cmap_M3B; + } else if (!strncmp(name, "ATY,", 4)) { unsigned long base = address & 0xff000000UL; info->cmap_adr = ioremap(base + 0x7ff000, 0x1000) + 0xcc0; info->cmap_data = info->cmap_adr + 1; + info->cmap_type = cmap_m64; } fix->visual = info->cmap_adr ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_STATIC_PSEUDOCOLOR; @@ -580,7 +595,7 @@ display_info.cmap_data_address = 0; display_info.disp_reg_address = 0; /* XXX kludge for ati */ - if (strncmp(name, "ATY,", 4) == 0) { + if (info->cmap_type == cmap_m64) { unsigned long base = address & 0xff000000UL; display_info.disp_reg_address = base + 0x7ffc00; display_info.cmap_adr_address = base + 0x7ffcc0; @@ -628,11 +643,32 @@ if (blank) for (i = 0; i < 256; i++) { - *info2->cmap_adr = i; - mach_eieio(); - for (j = 0; j < 3; j++) { - *info2->cmap_data = 0; - mach_eieio(); + switch(info2->cmap_type) { + case cmap_m64: + *info2->cmap_adr = i; + mach_eieio(); + for (j = 0; j < 3; j++) { + *info2->cmap_data = 0; + mach_eieio(); + } + break; + case cmap_M3A: + /* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */ + out_le32((unsigned *)(info2->cmap_adr + 0x58), + in_le32((unsigned *)(info2->cmap_adr + 0x58)) & ~0x20); + case cmap_r128: + /* Set palette index & data */ + out_8(info2->cmap_adr + 0xb0, i); + out_le32((unsigned *)(info2->cmap_adr + 0xb4), 0); + break; + case cmap_M3B: + /* Set PALETTE_ACCESS_CNTL in DAC_CNTL */ + out_le32((unsigned *)(info2->cmap_adr + 0x58), + in_le32((unsigned *)(info2->cmap_adr + 0x58)) | 0x20); + /* Set palette index & data */ + out_8(info2->cmap_adr + 0xb0, i); + out_le32((unsigned *)(info2->cmap_adr + 0xb4), 0); + break; } } else @@ -682,18 +718,36 @@ info2->palette[regno].green = green; info2->palette[regno].blue = blue; - *info2->cmap_adr = regno;/* On some chipsets, add << 3 in 15 bits */ - mach_eieio(); - if (info2->is_rage_128) { - out_le32((unsigned int *)info2->cmap_data, - (red << 16 | green << 8 | blue)); - } else { + switch(info2->cmap_type) { + case cmap_m64: + *info2->cmap_adr = regno; + mach_eieio(); *info2->cmap_data = red; - mach_eieio(); - *info2->cmap_data = green; - mach_eieio(); - *info2->cmap_data = blue; - mach_eieio(); + mach_eieio(); + *info2->cmap_data = green; + mach_eieio(); + *info2->cmap_data = blue; + mach_eieio(); + break; + case cmap_M3A: + /* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */ + out_le32((unsigned *)(info2->cmap_adr + 0x58), + in_le32((unsigned *)(info2->cmap_adr + 0x58)) & ~0x20); + case cmap_r128: + /* Set palette index & data */ + out_8(info2->cmap_adr + 0xb0, regno); + out_le32((unsigned *)(info2->cmap_adr + 0xb4), + (red << 16 | green << 8 | blue)); + break; + case cmap_M3B: + /* Set PALETTE_ACCESS_CNTL in DAC_CNTL */ + out_le32((unsigned *)(info2->cmap_adr + 0x58), + in_le32((unsigned *)(info2->cmap_adr + 0x58)) | 0x20); + /* Set palette index & data */ + out_8(info2->cmap_adr + 0xb0, regno); + out_le32((unsigned *)(info2->cmap_adr + 0xb4), + (red << 16 | green << 8 | blue)); + break; } if (regno < 16) diff -u --recursive --new-file v2.4.0-test8/linux/drivers/video/sisfb.c linux/drivers/video/sisfb.c --- v2.4.0-test8/linux/drivers/video/sisfb.c Fri Sep 8 13:27:12 2000 +++ linux/drivers/video/sisfb.c Sun Sep 17 10:15:35 2000 @@ -356,8 +356,6 @@ 0x0B, 0x0C, 0x0D, 0x0F, 0x10 }; -#ifdef CONFIG_FB_SIS_LINUXBIOS - #define Monitor1Sense 0x20 unsigned char SRegsInit[] = { @@ -371,6 +369,8 @@ 0x8e, 0x40, 0x00, 0x00, 0x08, 0x00, 0xff, 0xff }; +#ifdef CONFIG_FB_SIS_LINUXBIOS + unsigned char SRegs[] = { 0x03, 0x01, 0x0F, 0x00, 0x0E, 0xA1, 0x02, 0x13, 0x3F, 0x86, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, @@ -1440,7 +1440,6 @@ static u16 get_modeID_length(unsigned long ROMAddr, u16 ModeNo) { - unsigned char ModeID; u16 modeidlength; u16 usModeIDOffset; unsigned short PreviousWord,CurrentWord; diff -u --recursive --new-file v2.4.0-test8/linux/drivers/video/valkyriefb.c linux/drivers/video/valkyriefb.c --- v2.4.0-test8/linux/drivers/video/valkyriefb.c Wed Aug 9 19:19:51 2000 +++ linux/drivers/video/valkyriefb.c Sun Sep 17 09:48:05 2000 @@ -425,12 +425,14 @@ struct adb_request req; int i; +#ifdef CONFIG_ADB_CUDA for (i = 0; i < 3; ++i) { cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_GET_SET_IIC, 0x50, i + 1, params[i]); while (!req.complete) cuda_poll(); } +#endif } static void __init init_valkyrie(struct fb_info_valkyrie *p) diff -u --recursive --new-file v2.4.0-test8/linux/fs/bfs/inode.c linux/fs/bfs/inode.c --- v2.4.0-test8/linux/fs/bfs/inode.c Fri Sep 8 13:27:12 2000 +++ linux/fs/bfs/inode.c Sun Sep 17 09:51:57 2000 @@ -197,7 +197,7 @@ buf->f_bfree = buf->f_bavail = s->su_freeb; buf->f_files = s->su_lasti + 1 - BFS_ROOT_INO; buf->f_ffree = s->su_freei; - buf->f_fsid.val[0] = s->s_dev; + buf->f_fsid.val[0] = kdev_t_to_nr(s->s_dev); buf->f_namelen = BFS_NAMELEN; return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/fs/block_dev.c linux/fs/block_dev.c --- v2.4.0-test8/linux/fs/block_dev.c Fri Sep 8 13:27:12 2000 +++ linux/fs/block_dev.c Sun Sep 17 09:51:57 2000 @@ -30,17 +30,17 @@ ssize_t block, blocks; loff_t offset; ssize_t chars; - ssize_t written = 0; + ssize_t written; struct buffer_head * bhlist[NBUF]; size_t size; - kdev_t dev; + kdev_t dev = inode->i_rdev; struct buffer_head * bh, *bufferlist[NBUF]; register char * p; - write_error = buffercount = 0; - dev = inode->i_rdev; - if ( is_read_only( inode->i_rdev )) + if (is_read_only(dev)) return -EPERM; + + written = write_error = buffercount = 0; blocksize = BLOCK_SIZE; if (blksize_size[MAJOR(dev)] && blksize_size[MAJOR(dev)][MINOR(dev)]) blocksize = blksize_size[MAJOR(dev)][MINOR(dev)]; @@ -311,6 +311,39 @@ } /* + * private llseek: + * for a block special file file->f_dentry->d_inode->i_size is zero + * so we compute the size by hand (just as in block_read/write above) + */ +static loff_t block_llseek(struct file *file, loff_t offset, int origin) +{ + long long retval; + kdev_t dev; + + switch (origin) { + case 2: + dev = file->f_dentry->d_inode->i_rdev; + if (blk_size[MAJOR(dev)]) + offset += (loff_t) blk_size[MAJOR(dev)][MINOR(dev)] << BLOCK_SIZE_BITS; + /* else? return -EINVAL? */ + break; + case 1: + offset += file->f_pos; + } + retval = -EINVAL; + if (offset >= 0) { + if (offset != file->f_pos) { + file->f_pos = offset; + file->f_reada = 0; + file->f_version = ++event; + } + retval = offset; + } + return retval; +} + + +/* * Filp may be NULL when we are called by an msync of a vma * since the vma has no handle. */ @@ -612,7 +645,7 @@ int blkdev_open(struct inode * inode, struct file * filp) { - int ret = -ENODEV; + int ret = -ENXIO; struct block_device *bdev = inode->i_bdev; down(&bdev->bd_sem); lock_kernel(); @@ -678,6 +711,7 @@ struct file_operations def_blk_fops = { open: blkdev_open, release: blkdev_close, + llseek: block_llseek, read: block_read, write: block_write, fsync: block_fsync, diff -u --recursive --new-file v2.4.0-test8/linux/fs/buffer.c linux/fs/buffer.c --- v2.4.0-test8/linux/fs/buffer.c Fri Sep 8 13:27:12 2000 +++ linux/fs/buffer.c Sun Sep 17 09:56:02 2000 @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -409,8 +410,9 @@ */ #define _hashfn(dev,block) \ ((((dev)<<(bh_hash_shift - 6)) ^ ((dev)<<(bh_hash_shift - 9))) ^ \ - (((block)<<(bh_hash_shift - 6)) ^ ((block) >> 13) ^ ((block) << (bh_hash_shift - 12)))) -#define hash(dev,block) hash_table[(_hashfn(dev,block) & bh_hash_mask)] + (((block)<<(bh_hash_shift - 6)) ^ ((block) >> 13) ^ \ + ((block) << (bh_hash_shift - 12)))) +#define hash(dev,block) hash_table[(_hashfn(HASHDEV(dev),block) & bh_hash_mask)] static __inline__ void __hash_link(struct buffer_head *bh, struct buffer_head **head) { @@ -704,8 +706,8 @@ static void refill_freelist(int size) { if (!grow_buffers(size)) { - wakeup_bdflush(1); - current->policy |= SCHED_YIELD; + balance_dirty(NODEV); + wakeup_kswapd(0); /* We can't wait because of __GFP_IO */ schedule(); } } @@ -856,20 +858,31 @@ /* -1 -> no need to flush 0 -> async flush 1 -> sync flush (wait for I/O completation) */ -static int balance_dirty_state(kdev_t dev) +int balance_dirty_state(kdev_t dev) { unsigned long dirty, tot, hard_dirty_limit, soft_dirty_limit; dirty = size_buffers_type[BUF_DIRTY] >> PAGE_SHIFT; tot = nr_free_buffer_pages(); - tot -= size_buffers_type[BUF_PROTECTED] >> PAGE_SHIFT; dirty *= 200; soft_dirty_limit = tot * bdf_prm.b_un.nfract; hard_dirty_limit = soft_dirty_limit * 2; + /* First, check for the "real" dirty limit. */ if (dirty > soft_dirty_limit) { - if (dirty > hard_dirty_limit) + if (dirty > hard_dirty_limit || inactive_shortage()) + return 1; + return 0; + } + + /* + * Then, make sure the number of inactive pages won't overwhelm + * page replacement ... this should avoid stalls. + */ + if (nr_inactive_dirty_pages > + nr_free_pages() + nr_inactive_clean_pages()) { + if (free_shortage() > freepages.min) return 1; return 0; } @@ -1380,6 +1393,19 @@ } /* + * NOTE! All mapped/uptodate combinations are valid: + * + * Mapped Uptodate Meaning + * + * No No "unknown" - must do get_block() + * No Yes "hole" - zero-filled + * Yes No "allocated" - allocated on disk, not read in + * Yes Yes "valid" - allocated and up-to-date in memory. + * + * "Dirty" is valid only with the last case (mapped+uptodate). + */ + +/* * block_write_full_page() is SMP-safe - currently it's still * being called with the kernel lock held, but the code is ready. */ @@ -1758,17 +1784,24 @@ pos += blocksize; } + err = 0; + if (!buffer_mapped(bh)) { + /* Hole? Nothing to do */ + if (buffer_uptodate(bh)) + goto unlock; + get_block(inode, iblock, bh, 0); + /* Still unmapped? Nothing to do */ + if (!buffer_mapped(bh)) + goto unlock; + } + + /* Ok, it's mapped. Make sure it's up-to-date */ if (!buffer_uptodate(bh)) { - err = 0; - if (!buffer_mapped(bh)) { - get_block(inode, iblock, bh, 0); - if (!buffer_mapped(bh)) - goto unlock; - } err = -EIO; bh->b_end_io = end_buffer_io_sync; ll_rw_block(READ, 1, &bh); wait_on_buffer(bh); + /* Uhhuh. Read error. Complain and punt. */ if (!buffer_uptodate(bh)) goto unlock; } @@ -2152,6 +2185,7 @@ page = alloc_page(GFP_BUFFER); if (!page) goto out; + LockPage(page); bh = create_buffers(page, size, 0); if (!bh) goto no_buffer_head; @@ -2184,6 +2218,7 @@ page->buffers = bh; page->flags &= ~(1 << PG_referenced); lru_cache_add(page); + UnlockPage(page); atomic_inc(&buffermem_pages); return 1; @@ -2244,7 +2279,9 @@ { struct buffer_head * tmp, * bh = page->buffers; int index = BUFSIZE_INDEX(bh->b_size); + int loop = 0; +cleaned_buffers_try_again: spin_lock(&lru_list_lock); write_lock(&hash_table_lock); spin_lock(&free_list[index].lock); @@ -2290,8 +2327,14 @@ spin_unlock(&free_list[index].lock); write_unlock(&hash_table_lock); spin_unlock(&lru_list_lock); - if (wait) + if (wait) { sync_page_buffers(bh, wait); + /* We waited synchronously, so we can free the buffers. */ + if (wait > 1 && !loop) { + loop = 1; + goto cleaned_buffers_try_again; + } + } return 0; } @@ -2609,6 +2652,9 @@ CHECK_EMERGENCY_SYNC flushed = flush_dirty_buffers(0); + if (nr_inactive_dirty_pages > nr_free_pages() + + nr_inactive_clean_pages()) + flushed += page_launder(GFP_KSWAPD, 0); /* If wakeup_bdflush will wakeup us after our bdflush_done wakeup, then @@ -2619,14 +2665,16 @@ (as we would be sleeping) and so it would deadlock in SMP. */ __set_current_state(TASK_INTERRUPTIBLE); - wake_up(&bdflush_done); + wake_up_all(&bdflush_done); /* * If there are still a lot of dirty buffers around, * skip the sleep and flush some more. Otherwise, we * go to sleep waiting a wakeup. */ - if (!flushed || balance_dirty_state(NODEV) < 0) + if (!flushed || balance_dirty_state(NODEV) < 0) { + run_task_queue(&tq_disk); schedule(); + } /* Remember to mark us as running otherwise the next schedule will block. */ __set_current_state(TASK_RUNNING); diff -u --recursive --new-file v2.4.0-test8/linux/fs/dcache.c linux/fs/dcache.c --- v2.4.0-test8/linux/fs/dcache.c Wed Aug 23 18:36:38 2000 +++ linux/fs/dcache.c Sun Sep 17 09:45:07 2000 @@ -1248,7 +1248,7 @@ panic("Cannot create buffer head SLAB cache"); names_cachep = kmem_cache_create("names_cache", - PAGE_SIZE, 0, + PATH_MAX + 1, 0, SLAB_HWCACHE_ALIGN, NULL, NULL); if (!names_cachep) panic("Cannot create names SLAB cache"); diff -u --recursive --new-file v2.4.0-test8/linux/fs/inode.c linux/fs/inode.c --- v2.4.0-test8/linux/fs/inode.c Wed Aug 23 18:36:38 2000 +++ linux/fs/inode.c Mon Sep 11 08:41:07 2000 @@ -71,7 +71,7 @@ int nr_inodes; int nr_unused; int dummy[5]; -} inodes_stat = {0, 0,}; +} inodes_stat; static kmem_cache_t * inode_cachep; diff -u --recursive --new-file v2.4.0-test8/linux/fs/namei.c linux/fs/namei.c --- v2.4.0-test8/linux/fs/namei.c Wed Aug 23 18:36:38 2000 +++ linux/fs/namei.c Sun Sep 17 09:51:57 2000 @@ -107,7 +107,7 @@ static inline int do_getname(const char *filename, char *page) { int retval; - unsigned long len = PAGE_SIZE; + unsigned long len = PATH_MAX + 1; if ((unsigned long) filename >= TASK_SIZE) { if (!segment_eq(get_fs(), KERNEL_DS)) @@ -683,7 +683,7 @@ } /* SMP-safe */ -int path_init(const char *name,unsigned int flags,struct nameidata *nd) +int path_init(const char *name, unsigned int flags, struct nameidata *nd) { nd->last_type = LAST_ROOT; /* if there are only slashes... */ nd->flags = flags; diff -u --recursive --new-file v2.4.0-test8/linux/fs/ncpfs/file.c linux/fs/ncpfs/file.c --- v2.4.0-test8/linux/fs/ncpfs/file.c Mon Jul 10 16:47:26 2000 +++ linux/fs/ncpfs/file.c Fri Sep 15 14:26:23 2000 @@ -256,7 +256,7 @@ } if (ncp_write_kernel(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle, - pos, to_write, buf, &written_this_time) != 0) { + pos, to_write, bouncebuffer, &written_this_time) != 0) { errno = -EIO; break; } diff -u --recursive --new-file v2.4.0-test8/linux/fs/nfs/dir.c linux/fs/nfs/dir.c --- v2.4.0-test8/linux/fs/nfs/dir.c Fri Sep 8 13:27:13 2000 +++ linux/fs/nfs/dir.c Mon Sep 11 08:38:25 2000 @@ -809,14 +809,9 @@ dentry->d_parent->d_name.name, dentry->d_name.name, atomic_read(&dentry->d_count)); - /* - * Note that a silly-renamed file can be deleted once it's - * no longer in use -- it's just an ordinary file now. - */ - if (atomic_read(&dentry->d_count) == 1) { - dentry->d_flags &= ~DCACHE_NFSFS_RENAMED; + if (atomic_read(&dentry->d_count) == 1) goto out; /* No need to silly rename. */ - } + #ifdef NFS_PARANOIA if (!dentry->d_inode) @@ -900,12 +895,21 @@ #endif goto out; } + + /* If the dentry was sillyrenamed, we simply call d_delete() */ + if (dentry->d_flags & DCACHE_NFSFS_RENAMED) { + error = 0; + goto out_delete; + } + nfs_zap_caches(dir_i); if (inode) NFS_CACHEINV(inode); error = NFS_PROTO(dir_i)->remove(dir, &dentry->d_name); if (error < 0) goto out; + + out_delete: /* * Free the inode */ diff -u --recursive --new-file v2.4.0-test8/linux/fs/nfs/nfs3proc.c linux/fs/nfs/nfs3proc.c --- v2.4.0-test8/linux/fs/nfs/nfs3proc.c Fri Sep 8 13:27:13 2000 +++ linux/fs/nfs/nfs3proc.c Mon Sep 11 08:38:25 2000 @@ -279,6 +279,7 @@ arg->fh = NFS_FH(dir); arg->name = name->name; arg->len = name->len; + res->valid = 0; msg->rpc_proc = NFS3PROC_REMOVE; msg->rpc_argp = arg; msg->rpc_resp = res; @@ -288,10 +289,13 @@ static void nfs3_proc_unlink_done(struct dentry *dir, struct rpc_message *msg) { - struct nfs_fattr *dir_attr = (struct nfs_fattr*)msg->rpc_resp; + struct nfs_fattr *dir_attr; - nfs_refresh_inode(dir->d_inode, dir_attr); - kfree(msg->rpc_argp); + if (msg->rpc_argp) { + dir_attr = (struct nfs_fattr*)msg->rpc_resp; + nfs_refresh_inode(dir->d_inode, dir_attr); + kfree(msg->rpc_argp); + } } static int diff -u --recursive --new-file v2.4.0-test8/linux/fs/nfs/proc.c linux/fs/nfs/proc.c --- v2.4.0-test8/linux/fs/nfs/proc.c Fri Sep 8 13:27:13 2000 +++ linux/fs/nfs/proc.c Mon Sep 11 08:38:25 2000 @@ -251,8 +251,10 @@ static void nfs_proc_unlink_done(struct dentry *dir, struct rpc_message *msg) { - NFS_CACHEINV(dir->d_inode); - kfree(msg->rpc_argp); + if (msg->rpc_argp) { + NFS_CACHEINV(dir->d_inode); + kfree(msg->rpc_argp); + } } static int diff -u --recursive --new-file v2.4.0-test8/linux/fs/nfs/unlink.c linux/fs/nfs/unlink.c --- v2.4.0-test8/linux/fs/nfs/unlink.c Fri Sep 8 13:27:13 2000 +++ linux/fs/nfs/unlink.c Mon Sep 11 08:38:25 2000 @@ -121,8 +121,11 @@ { struct nfs_unlinkdata *data = (struct nfs_unlinkdata *)task->tk_calldata; struct dentry *dir = data->dir; - struct inode *dir_i = dir->d_inode; + struct inode *dir_i; + if (!dir) + return; + dir_i = dir->d_inode; nfs_zap_caches(dir_i); NFS_PROTO(dir_i)->unlink_done(dir, &task->tk_msg); rpcauth_releasecred(task->tk_auth, data->cred); @@ -206,6 +209,7 @@ return; data->count++; nfs_copy_dname(dentry, data); + dentry->d_flags &= ~DCACHE_NFSFS_RENAMED; if (data->task.tk_rpcwait == &nfs_delete_queue) rpc_wake_up_task(&data->task); nfs_put_unlinkdata(data); diff -u --recursive --new-file v2.4.0-test8/linux/fs/partitions/acorn.c linux/fs/partitions/acorn.c --- v2.4.0-test8/linux/fs/partitions/acorn.c Wed Aug 9 19:19:51 2000 +++ linux/fs/partitions/acorn.c Sun Sep 17 09:51:57 2000 @@ -7,6 +7,7 @@ */ #include #include +#include #include #include #include diff -u --recursive --new-file v2.4.0-test8/linux/fs/partitions/mac.c linux/fs/partitions/mac.c --- v2.4.0-test8/linux/fs/partitions/mac.c Thu Feb 10 17:11:18 2000 +++ linux/fs/partitions/mac.c Sun Sep 17 09:51:57 2000 @@ -21,7 +21,7 @@ #include "mac.h" #ifdef CONFIG_PPC -extern void note_bootable_part(kdev_t dev, int part); +extern void note_bootable_part(kdev_t dev, int part, int goodness); #endif /* @@ -67,7 +67,7 @@ brelse(bh); dev_pos = secsize; if ((bh = bread(dev, secsize/dev_bsize, dev_bsize)) == 0) { - printk("%s: error reading partition table\n", + printk("%s: error reading Mac partition table\n", kdevname(dev)); return -1; } @@ -77,6 +77,7 @@ brelse(bh); return 0; /* not a MacOS disk */ } + printk(" [mac]"); blocks_in_map = be32_to_cpu(part->map_count); for (blk = 1; blk <= blocks_in_map; ++blk) { pos = blk * secsize; @@ -114,7 +115,8 @@ goodness++; if (strcasecmp(part->type, "Apple_UNIX_SVR2") == 0 - || strcasecmp(part->type, "Linux_PPC") == 0) { + || (strnicmp(part->type, "Linux", 5) == 0 + && strcasecmp(part->type, "Linux_swap") != 0)) { int i, l; goodness++; @@ -143,7 +145,7 @@ } #ifdef CONFIG_PPC if (found_root_goodness) - note_bootable_part(dev, found_root); + note_bootable_part(dev, found_root, found_root_goodness); #endif brelse(bh); printk("\n"); diff -u --recursive --new-file v2.4.0-test8/linux/fs/proc/proc_misc.c linux/fs/proc/proc_misc.c --- v2.4.0-test8/linux/fs/proc/proc_misc.c Fri Sep 8 13:27:13 2000 +++ linux/fs/proc/proc_misc.c Sun Sep 17 10:13:25 2000 @@ -156,22 +156,30 @@ * have been updated. */ len += sprintf(page+len, - "MemTotal: %8lu kB\n" - "MemFree: %8lu kB\n" - "MemShared: %8lu kB\n" - "Buffers: %8lu kB\n" - "Cached: %8u kB\n" - "HighTotal: %8lu kB\n" - "HighFree: %8lu kB\n" - "LowTotal: %8lu kB\n" - "LowFree: %8lu kB\n" - "SwapTotal: %8lu kB\n" - "SwapFree: %8lu kB\n", + "MemTotal: %8lu kB\n" + "MemFree: %8lu kB\n" + "MemShared: %8lu kB\n" + "Buffers: %8lu kB\n" + "Cached: %8u kB\n" + "Active: %8u kB\n" + "Inact_dirty: %8u kB\n" + "Inact_clean: %8u kB\n" + "Inact_target: %8lu kB\n" + "HighTotal: %8lu kB\n" + "HighFree: %8lu kB\n" + "LowTotal: %8lu kB\n" + "LowFree: %8lu kB\n" + "SwapTotal: %8lu kB\n" + "SwapFree: %8lu kB\n", K(i.totalram), K(i.freeram), K(i.sharedram), K(i.bufferram), K(atomic_read(&page_cache_size)), + K(nr_active_pages), + K(nr_inactive_dirty_pages), + K(nr_inactive_clean_pages()), + K(inactive_target), K(i.totalhigh), K(i.freehigh), K(i.totalram-i.totalhigh), @@ -328,14 +336,14 @@ for (major = 0; major < DK_MAX_MAJOR; major++) { for (disk = 0; disk < DK_MAX_DISK; disk++) { - int active = kstat.dk_drive_rio[major][disk] + + int active = kstat.dk_drive[major][disk] + kstat.dk_drive_rblk[major][disk] + - kstat.dk_drive_wio[major][disk] + kstat.dk_drive_wblk[major][disk]; if (active) len += sprintf(page + len, - "(%u,%u):(%u,%u,%u,%u) ", + "(%u,%u):(%u,%u,%u,%u,%u) ", major, disk, + kstat.dk_drive[major][disk], kstat.dk_drive_rio[major][disk], kstat.dk_drive_rblk[major][disk], kstat.dk_drive_wio[major][disk], diff -u --recursive --new-file v2.4.0-test8/linux/fs/proc/procfs_syms.c linux/fs/proc/procfs_syms.c --- v2.4.0-test8/linux/fs/proc/procfs_syms.c Thu May 11 15:30:08 2000 +++ linux/fs/proc/procfs_syms.c Mon Sep 11 08:41:07 2000 @@ -28,7 +28,9 @@ if (!err) { proc_mnt = kern_mount(&proc_fs_type); err = PTR_ERR(proc_mnt); - if (!IS_ERR(proc_mnt)) + if (IS_ERR(proc_mnt)) + unregister_filesystem(&proc_fs_type); + else err = 0; } return err; diff -u --recursive --new-file v2.4.0-test8/linux/fs/ramfs/inode.c linux/fs/ramfs/inode.c --- v2.4.0-test8/linux/fs/ramfs/inode.c Wed Aug 9 19:19:51 2000 +++ linux/fs/ramfs/inode.c Sun Sep 17 09:51:57 2000 @@ -121,7 +121,7 @@ inode->i_size = 0; inode->i_blksize = PAGE_CACHE_SIZE; inode->i_blocks = 0; - inode->i_rdev = dev; + inode->i_rdev = to_kdev_t(dev); inode->i_nlink = 1; inode->i_op = NULL; inode->i_fop = NULL; diff -u --recursive --new-file v2.4.0-test8/linux/fs/super.c linux/fs/super.c --- v2.4.0-test8/linux/fs/super.c Wed Aug 23 18:36:38 2000 +++ linux/fs/super.c Sun Sep 17 09:51:57 2000 @@ -1303,20 +1303,21 @@ * information (or be NULL). * * NOTE! As pre-0.97 versions of mount() didn't use this setup, the - * flags have to have a special 16-bit magic number in the high word: - * 0xC0ED. If this magic word isn't present, the flags and data info - * aren't used, as the syscall assumes we are talking to an older - * version that didn't understand them. + * flags used to have a special 16-bit magic number in the high word: + * 0xC0ED. If this magic number is present, the high word is discarded. */ long do_mount(char * dev_name, char * dir_name, char *type_page, - unsigned long new_flags, void *data_page) + unsigned long flags, void *data_page) { struct file_system_type * fstype; struct nameidata nd; struct vfsmount *mnt = NULL; struct super_block *sb; int retval = 0; - unsigned long flags = 0; + + /* Discard magic */ + if ((flags & MS_MGC_MSK) == MS_MGC_VAL) + flags &= ~MS_MGC_MSK; /* Basic sanity checks */ @@ -1328,21 +1329,25 @@ /* OK, looks good, now let's see what do they want */ /* just change the flags? - capabilities are checked in do_remount() */ - if ((new_flags & (MS_MGC_MSK|MS_REMOUNT)) == (MS_MGC_VAL|MS_REMOUNT)) - return do_remount(dir_name, new_flags&~(MS_MGC_MSK|MS_REMOUNT), - (char *) data_page); - - if ((new_flags & MS_MGC_MSK) == MS_MGC_VAL) - flags = new_flags & ~MS_MGC_MSK; + if (flags & MS_REMOUNT) + return do_remount(dir_name, flags & ~MS_REMOUNT, + (char *) data_page); + + /* "mount --bind"? Equivalent to older "mount -t bind" */ + /* No capabilities? What if users do thousands of these? */ + if (flags & MS_BIND) + return do_loopback(dev_name, dir_name); /* For the rest we need the type */ if (!type_page || !memchr(type_page, 0, PAGE_SIZE)) return -EINVAL; +#if 0 /* Can be deleted again. Introduced in patch-2.3.99-pre6 */ /* loopback mount? This is special - requires fewer capabilities */ if (strcmp(type_page, "bind")==0) return do_loopback(dev_name, dir_name); +#endif /* for the rest we _really_ need capabilities... */ if (!capable(CAP_SYS_ADMIN)) @@ -1354,7 +1359,8 @@ return -ENODEV; /* ... and mountpoint. Do the lookup first to force automounting. */ - if (path_init(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE|LOOKUP_DIRECTORY, &nd)) + if (path_init(dir_name, + LOOKUP_FOLLOW|LOOKUP_POSITIVE|LOOKUP_DIRECTORY, &nd)) retval = path_walk(dir_name, &nd); if (retval) goto fs_out; @@ -1363,7 +1369,7 @@ if (fstype->fs_flags & FS_NOMOUNT) sb = ERR_PTR(-EINVAL); else if (fstype->fs_flags & FS_REQUIRES_DEV) - sb = get_sb_bdev(fstype, dev_name,flags, data_page); + sb = get_sb_bdev(fstype, dev_name, flags, data_page); else if (fstype->fs_flags & FS_SINGLE) sb = get_sb_single(fstype, flags, data_page); else @@ -1376,6 +1382,13 @@ /* Something was mounted here while we slept */ while(d_mountpoint(nd.dentry) && follow_down(&nd.mnt, &nd.dentry)) ; + + /* Refuse the same filesystem on the same mount point */ + retval = -EBUSY; + if (nd.mnt && nd.mnt->mnt_sb == sb + && nd.mnt->mnt_root == nd.dentry) + goto fail; + retval = -ENOENT; if (!nd.dentry->d_inode) goto fail; @@ -1403,7 +1416,7 @@ } asmlinkage long sys_mount(char * dev_name, char * dir_name, char * type, - unsigned long new_flags, void * data) + unsigned long flags, void * data) { int retval; unsigned long data_page; @@ -1423,14 +1436,18 @@ retval = copy_mount_options (dev_name, &dev_page); if (retval < 0) goto out2; + retval = copy_mount_options (data, &data_page); - if (retval >= 0) { - lock_kernel(); - retval = do_mount((char*)dev_page,dir_page,(char*)type_page, - new_flags, (void*)data_page); - unlock_kernel(); - free_page(data_page); - } + if (retval < 0) + goto out3; + + lock_kernel(); + retval = do_mount((char*)dev_page, dir_page, (char*)type_page, + flags, (void*)data_page); + unlock_kernel(); + free_page(data_page); + +out3: free_page(dev_page); out2: putname(dir_page); diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-i386/semaphore.h linux/include/asm-i386/semaphore.h --- v2.4.0-test8/linux/include/asm-i386/semaphore.h Wed Aug 9 19:19:51 2000 +++ linux/include/asm-i386/semaphore.h Sun Sep 17 09:37:02 2000 @@ -64,7 +64,7 @@ #define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1) #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0) -extern inline void sema_init (struct semaphore *sem, int val) +static inline void sema_init (struct semaphore *sem, int val) { /* * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val); @@ -105,7 +105,7 @@ * "__down_failed" is a special asm handler that calls the C * routine that actually waits. See arch/i386/kernel/semaphore.c */ -extern inline void down(struct semaphore * sem) +static inline void down(struct semaphore * sem) { #if WAITQUEUE_DEBUG CHECK_MAGIC(sem->__magic); @@ -125,7 +125,7 @@ :"memory"); } -extern inline int down_interruptible(struct semaphore * sem) +static inline int down_interruptible(struct semaphore * sem) { int result; @@ -149,7 +149,7 @@ return result; } -extern inline int down_trylock(struct semaphore * sem) +static inline int down_trylock(struct semaphore * sem) { int result; @@ -179,7 +179,7 @@ * The default case (no contention) will result in NO * jumps for both down() and up(). */ -extern inline void up(struct semaphore * sem) +static inline void up(struct semaphore * sem) { #if WAITQUEUE_DEBUG CHECK_MAGIC(sem->__magic); @@ -252,7 +252,7 @@ #define DECLARE_RWSEM_READ_LOCKED(name) __DECLARE_RWSEM_GENERIC(name,RW_LOCK_BIAS-1) #define DECLARE_RWSEM_WRITE_LOCKED(name) __DECLARE_RWSEM_GENERIC(name,0) -extern inline void init_rwsem(struct rw_semaphore *sem) +static inline void init_rwsem(struct rw_semaphore *sem) { atomic_set(&sem->count, RW_LOCK_BIAS); sem->read_bias_granted = 0; @@ -271,7 +271,7 @@ extern struct rw_semaphore *FASTCALL(__down_write_failed(struct rw_semaphore *sem)); extern struct rw_semaphore *FASTCALL(__rwsem_wake(struct rw_semaphore *sem)); -extern inline void down_read(struct rw_semaphore *sem) +static inline void down_read(struct rw_semaphore *sem) { #if WAITQUEUE_DEBUG if (sem->__magic != (long)&sem->__magic) @@ -287,7 +287,7 @@ #endif } -extern inline void down_write(struct rw_semaphore *sem) +static inline void down_write(struct rw_semaphore *sem) { #if WAITQUEUE_DEBUG if (sem->__magic != (long)&sem->__magic) @@ -311,7 +311,7 @@ * case is when there was a writer waiting, and we've * bumped the count to 0: we must wake the writer up. */ -extern inline void __up_read(struct rw_semaphore *sem) +static inline void __up_read(struct rw_semaphore *sem) { __asm__ __volatile__( "# up_read\n\t" @@ -330,7 +330,7 @@ /* releasing the writer is easy -- just release it and * wake up any sleepers. */ -extern inline void __up_write(struct rw_semaphore *sem) +static inline void __up_write(struct rw_semaphore *sem) { __asm__ __volatile__( "# up_write\n\t" @@ -346,7 +346,7 @@ ); } -extern inline void up_read(struct rw_semaphore *sem) +static inline void up_read(struct rw_semaphore *sem) { #if WAITQUEUE_DEBUG if (sem->write_bias_granted) @@ -358,7 +358,7 @@ __up_read(sem); } -extern inline void up_write(struct rw_semaphore *sem) +static inline void up_write(struct rw_semaphore *sem) { #if WAITQUEUE_DEBUG if (sem->read_bias_granted) diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/atomic.h linux/include/asm-ppc/atomic.h --- v2.4.0-test8/linux/include/asm-ppc/atomic.h Thu May 11 15:30:08 2000 +++ linux/include/asm-ppc/atomic.h Sun Sep 17 09:48:07 2000 @@ -21,7 +21,7 @@ extern void atomic_clear_mask(unsigned long mask, unsigned long *addr); extern void atomic_set_mask(unsigned long mask, unsigned long *addr); -extern __inline__ int atomic_add_return(int a, atomic_t *v) +extern __inline__ int atomic_add_return(int a, volatile atomic_t *v) { int t; @@ -37,7 +37,7 @@ return t; } -extern __inline__ int atomic_sub_return(int a, atomic_t *v) +extern __inline__ int atomic_sub_return(int a, volatile atomic_t *v) { int t; @@ -53,7 +53,7 @@ return t; } -extern __inline__ int atomic_inc_return(atomic_t *v) +extern __inline__ int atomic_inc_return(volatile atomic_t *v) { int t; @@ -69,7 +69,7 @@ return t; } -extern __inline__ int atomic_dec_return(atomic_t *v) +extern __inline__ int atomic_dec_return(volatile atomic_t *v) { int t; diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/backlight.h linux/include/asm-ppc/backlight.h --- v2.4.0-test8/linux/include/asm-ppc/backlight.h Fri Jul 14 12:12:15 2000 +++ linux/include/asm-ppc/backlight.h Sun Sep 17 09:48:07 2000 @@ -25,4 +25,4 @@ extern int set_backlight_level(int level); extern int get_backlight_level(void); -#endif \ No newline at end of file +#endif diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/bitops.h linux/include/asm-ppc/bitops.h --- v2.4.0-test8/linux/include/asm-ppc/bitops.h Mon Jul 10 16:47:27 2000 +++ linux/include/asm-ppc/bitops.h Sun Sep 17 09:48:07 2000 @@ -230,6 +230,8 @@ tmp = *p; found_first: tmp |= ~0UL << size; + if (tmp == ~0UL) /* Are any bits zero? */ + return result + size; /* Nope. */ found_middle: return result + ffz(tmp); } @@ -320,6 +322,8 @@ tmp = cpu_to_le32p(p); found_first: tmp |= ~0U << size; + if (tmp == ~0UL) /* Are any bits zero? */ + return result + size; /* Nope. */ found_middle: return result + ffz(tmp); } diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/bootx.h linux/include/asm-ppc/bootx.h --- v2.4.0-test8/linux/include/asm-ppc/bootx.h Sat Oct 9 11:47:50 1999 +++ linux/include/asm-ppc/bootx.h Sun Sep 17 09:48:08 2000 @@ -133,4 +133,3 @@ #endif #endif - \ No newline at end of file diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/cpm_8260.h linux/include/asm-ppc/cpm_8260.h --- v2.4.0-test8/linux/include/asm-ppc/cpm_8260.h Tue May 23 15:31:36 2000 +++ linux/include/asm-ppc/cpm_8260.h Sun Sep 17 09:48:08 2000 @@ -85,6 +85,7 @@ #define CPM_DATAONLY_BASE ((uint)128) #define CPM_DATAONLY_SIZE ((uint)(16 * 1024) - CPM_DATAONLY_BASE) #define CPM_DP_NOSPACE ((uint)0x7fffffff) +#define CPM_FCC_SPECIAL_BASE ((uint)0x0000b000) /* The number of pages of host memory we allocate for CPM. This is * done early in kernel initialization to get physically contiguous @@ -97,8 +98,8 @@ * and dual port ram. */ extern cpm8260_t *cpmp; /* Pointer to comm processor */ -uint m8260_cpm_dpalloc(uint size); -uint m8260_cpm_hostalloc(uint size); +uint m8260_cpm_dpalloc(uint size, uint align); +uint m8260_cpm_hostalloc(uint size, uint align); void m8260_cpm_setbrg(uint brg, uint rate); void m8260_cpm_fastbrg(uint brg, uint rate, int div16); @@ -153,7 +154,7 @@ #define PROFF_REVNUM ((uint)0x8af0) #define PROFF_RAND ((uint)0x8af8) #define PROFF_I2C_BASE ((uint)0x8afc) -#define PROFF_IDMA4_BASE ((uint)0x89fe) +#define PROFF_IDMA4_BASE ((uint)0x8afe) /* The SMCs are relocated to any of the first eight DPRAM pages. * We will fix these at the first locations of DPRAM, until we @@ -403,40 +404,44 @@ #define SCCE_ENET_TXB ((ushort)0x0002) /* A buffer was transmitted */ #define SCCE_ENET_RXB ((ushort)0x0001) /* A buffer was received */ -/* SCC Mode Register (PMSR) as used by Ethernet. +/* SCC Mode Register (PSMR) as used by Ethernet. */ -#define SCC_PMSR_HBC ((ushort)0x8000) /* Enable heartbeat */ -#define SCC_PMSR_FC ((ushort)0x4000) /* Force collision */ -#define SCC_PMSR_RSH ((ushort)0x2000) /* Receive short frames */ -#define SCC_PMSR_IAM ((ushort)0x1000) /* Check individual hash */ -#define SCC_PMSR_ENCRC ((ushort)0x0800) /* Ethernet CRC mode */ -#define SCC_PMSR_PRO ((ushort)0x0200) /* Promiscuous mode */ -#define SCC_PMSR_BRO ((ushort)0x0100) /* Catch broadcast pkts */ -#define SCC_PMSR_SBT ((ushort)0x0080) /* Special backoff timer */ -#define SCC_PMSR_LPB ((ushort)0x0040) /* Set Loopback mode */ -#define SCC_PMSR_SIP ((ushort)0x0020) /* Sample Input Pins */ -#define SCC_PMSR_LCW ((ushort)0x0010) /* Late collision window */ -#define SCC_PMSR_NIB22 ((ushort)0x000a) /* Start frame search */ -#define SCC_PMSR_FDE ((ushort)0x0001) /* Full duplex enable */ +#define SCC_PSMR_HBC ((ushort)0x8000) /* Enable heartbeat */ +#define SCC_PSMR_FC ((ushort)0x4000) /* Force collision */ +#define SCC_PSMR_RSH ((ushort)0x2000) /* Receive short frames */ +#define SCC_PSMR_IAM ((ushort)0x1000) /* Check individual hash */ +#define SCC_PSMR_ENCRC ((ushort)0x0800) /* Ethernet CRC mode */ +#define SCC_PSMR_PRO ((ushort)0x0200) /* Promiscuous mode */ +#define SCC_PSMR_BRO ((ushort)0x0100) /* Catch broadcast pkts */ +#define SCC_PSMR_SBT ((ushort)0x0080) /* Special backoff timer */ +#define SCC_PSMR_LPB ((ushort)0x0040) /* Set Loopback mode */ +#define SCC_PSMR_SIP ((ushort)0x0020) /* Sample Input Pins */ +#define SCC_PSMR_LCW ((ushort)0x0010) /* Late collision window */ +#define SCC_PSMR_NIB22 ((ushort)0x000a) /* Start frame search */ +#define SCC_PSMR_FDE ((ushort)0x0001) /* Full duplex enable */ /* Buffer descriptor control/status used by Ethernet receive. -*/ + * Common to SCC and FCC. + */ #define BD_ENET_RX_EMPTY ((ushort)0x8000) #define BD_ENET_RX_WRAP ((ushort)0x2000) #define BD_ENET_RX_INTR ((ushort)0x1000) #define BD_ENET_RX_LAST ((ushort)0x0800) #define BD_ENET_RX_FIRST ((ushort)0x0400) #define BD_ENET_RX_MISS ((ushort)0x0100) +#define BD_ENET_RX_BC ((ushort)0x0080) /* FCC Only */ +#define BD_ENET_RX_MC ((ushort)0x0040) /* FCC Only */ #define BD_ENET_RX_LG ((ushort)0x0020) #define BD_ENET_RX_NO ((ushort)0x0010) #define BD_ENET_RX_SH ((ushort)0x0008) #define BD_ENET_RX_CR ((ushort)0x0004) #define BD_ENET_RX_OV ((ushort)0x0002) #define BD_ENET_RX_CL ((ushort)0x0001) -#define BD_ENET_RX_STATS ((ushort)0x013f) /* All status bits */ +#define BD_ENET_RX_STATS ((ushort)0x01ff) /* All status bits */ /* Buffer descriptor control/status used by Ethernet transmit. -*/ + * Common to SCC and FCC. + */ #define BD_ENET_TX_READY ((ushort)0x8000) #define BD_ENET_TX_PAD ((ushort)0x4000) #define BD_ENET_TX_WRAP ((ushort)0x2000) @@ -522,6 +527,152 @@ } scc_trans_t; #define BD_SCC_TX_LAST ((ushort)0x0800) + +/* How about some FCCs..... +*/ +#define FCC_GFMR_DIAG_NORM ((uint)0x00000000) +#define FCC_GFMR_DIAG_LE ((uint)0x40000000) +#define FCC_GFMR_DIAG_AE ((uint)0x80000000) +#define FCC_GFMR_DIAG_ALE ((uint)0xc0000000) +#define FCC_GFMR_TCI ((uint)0x20000000) +#define FCC_GFMR_TRX ((uint)0x10000000) +#define FCC_GFMR_TTX ((uint)0x08000000) +#define FCC_GFMR_TTX ((uint)0x08000000) +#define FCC_GFMR_CDP ((uint)0x04000000) +#define FCC_GFMR_CTSP ((uint)0x02000000) +#define FCC_GFMR_CDS ((uint)0x01000000) +#define FCC_GFMR_CTSS ((uint)0x00800000) +#define FCC_GFMR_SYNL_NONE ((uint)0x00000000) +#define FCC_GFMR_SYNL_AUTO ((uint)0x00004000) +#define FCC_GFMR_SYNL_8 ((uint)0x00008000) +#define FCC_GFMR_SYNL_16 ((uint)0x0000c000) +#define FCC_GFMR_RTSM ((uint)0x00002000) +#define FCC_GFMR_RENC_NRZ ((uint)0x00000000) +#define FCC_GFMR_RENC_NRZI ((uint)0x00000800) +#define FCC_GFMR_REVD ((uint)0x00000400) +#define FCC_GFMR_TENC_NRZ ((uint)0x00000000) +#define FCC_GFMR_TENC_NRZI ((uint)0x00000100) +#define FCC_GFMR_TCRC_16 ((uint)0x00000000) +#define FCC_GFMR_TCRC_32 ((uint)0x00000080) +#define FCC_GFMR_ENR ((uint)0x00000020) +#define FCC_GFMR_ENT ((uint)0x00000010) +#define FCC_GFMR_MODE_ENET ((uint)0x0000000c) +#define FCC_GFMR_MODE_ATM ((uint)0x0000000a) +#define FCC_GFMR_MODE_HDLC ((uint)0x00000000) + +/* Generic FCC parameter ram. +*/ +typedef struct fcc_param { + ushort fcc_riptr; /* Rx Internal temp pointer */ + ushort fcc_tiptr; /* Tx Internal temp pointer */ + ushort fcc_res1; + ushort fcc_mrblr; /* Max receive buffer length, mod 32 bytes */ + uint fcc_rstate; /* Upper byte is Func code, must be set */ + uint fcc_rbase; /* Receive BD base */ + ushort fcc_rbdstat; /* RxBD status */ + ushort fcc_rbdlen; /* RxBD down counter */ + uint fcc_rdptr; /* RxBD internal data pointer */ + uint fcc_tstate; /* Upper byte is Func code, must be set */ + uint fcc_tbase; /* Transmit BD base */ + ushort fcc_tbdstat; /* TxBD status */ + ushort fcc_tbdlen; /* TxBD down counter */ + uint fcc_tdptr; /* TxBD internal data pointer */ + uint fcc_rbptr; /* Rx BD Internal buf pointer */ + uint fcc_tbptr; /* Tx BD Internal buf pointer */ + uint fcc_rcrc; /* Rx temp CRC */ + uint fcc_res2; + uint fcc_tcrc; /* Tx temp CRC */ +} fccp_t; + + +/* Ethernet controller through FCC. +*/ +typedef struct fcc_enet { + fccp_t fen_genfcc; + uint fen_statbuf; /* Internal status buffer */ + uint fen_camptr; /* CAM address */ + uint fen_cmask; /* Constant mask for CRC */ + uint fen_cpres; /* Preset CRC */ + uint fen_crcec; /* CRC Error counter */ + uint fen_alec; /* alignment error counter */ + uint fen_disfc; /* discard frame counter */ + ushort fen_retlim; /* Retry limit */ + ushort fen_retcnt; /* Retry counter */ + ushort fen_pper; /* Persistence */ + ushort fen_boffcnt; /* backoff counter */ + uint fen_gaddrh; /* Group address filter, high 32-bits */ + uint fen_gaddrl; /* Group address filter, low 32-bits */ + ushort fen_tfcstat; /* out of sequence TxBD */ + ushort fen_tfclen; + uint fen_tfcptr; + ushort fen_mflr; /* Maximum frame length (1518) */ + ushort fen_paddrh; /* MAC address */ + ushort fen_paddrm; + ushort fen_paddrl; + ushort fen_ibdcount; /* Internal BD counter */ + ushort fen_idbstart; /* Internal BD start pointer */ + ushort fen_ibdend; /* Internal BD end pointer */ + ushort fen_txlen; /* Internal Tx frame length counter */ + uint fen_ibdbase[8]; /* Internal use */ + uint fen_iaddrh; /* Individual address filter */ + uint fen_iaddrl; + ushort fen_minflr; /* Minimum frame length (64) */ + ushort fen_taddrh; /* Filter transfer MAC address */ + ushort fen_taddrm; + ushort fen_taddrl; + ushort fen_padptr; /* Pointer to pad byte buffer */ + ushort fen_cftype; /* control frame type */ + ushort fen_cfrange; /* control frame range */ + ushort fen_maxb; /* maximum BD count */ + ushort fen_maxd1; /* Max DMA1 length (1520) */ + ushort fen_maxd2; /* Max DMA2 length (1520) */ + ushort fen_maxd; /* internal max DMA count */ + ushort fen_dmacnt; /* internal DMA counter */ + uint fen_octc; /* Total octect counter */ + uint fen_colc; /* Total collision counter */ + uint fen_broc; /* Total broadcast packet counter */ + uint fen_mulc; /* Total multicast packet count */ + uint fen_uspc; /* Total packets < 64 bytes */ + uint fen_frgc; /* Total packets < 64 bytes with errors */ + uint fen_ospc; /* Total packets > 1518 */ + uint fen_jbrc; /* Total packets > 1518 with errors */ + uint fen_p64c; /* Total packets == 64 bytes */ + uint fen_p65c; /* Total packets 64 < bytes <= 127 */ + uint fen_p128c; /* Total packets 127 < bytes <= 255 */ + uint fen_p256c; /* Total packets 256 < bytes <= 511 */ + uint fen_p512c; /* Total packets 512 < bytes <= 1023 */ + uint fen_p1024c; /* Total packets 1024 < bytes <= 1518 */ + uint fen_cambuf; /* Internal CAM buffer poiner */ + ushort fen_rfthr; /* Received frames threshold */ + ushort fen_rfcnt; /* Received frames count */ +} fcc_enet_t; + +/* FCC Event/Mask register as used by Ethernet. +*/ +#define FCC_ENET_GRA ((ushort)0x0080) /* Graceful stop complete */ +#define FCC_ENET_RXC ((ushort)0x0040) /* Control Frame Received */ +#define FCC_ENET_TXC ((ushort)0x0020) /* Out of seq. Tx sent */ +#define FCC_ENET_TXE ((ushort)0x0010) /* Transmit Error */ +#define FCC_ENET_RXF ((ushort)0x0008) /* Full frame received */ +#define FCC_ENET_BSY ((ushort)0x0004) /* Busy. Rx Frame dropped */ +#define FCC_ENET_TXB ((ushort)0x0002) /* A buffer was transmitted */ +#define FCC_ENET_RXB ((ushort)0x0001) /* A buffer was received */ + +/* FCC Mode Register (FPSMR) as used by Ethernet. +*/ +#define FCC_PSMR_HBC ((uint)0x80000000) /* Enable heartbeat */ +#define FCC_PSMR_FC ((uint)0x40000000) /* Force Collision */ +#define FCC_PSMR_SBT ((uint)0x20000000) /* Stop backoff timer */ +#define FCC_PSMR_LPB ((uint)0x10000000) /* Local protect. 1 = FDX */ +#define FCC_PSMR_LCW ((uint)0x08000000) /* Late collision select */ +#define FCC_PSMR_FDE ((uint)0x04000000) /* Full Duplex Enable */ +#define FCC_PSMR_MON ((uint)0x02000000) /* RMON Enable */ +#define FCC_PSMR_PRO ((uint)0x00400000) /* Promiscuous Enable */ +#define FCC_PSMR_FCE ((uint)0x00200000) /* Flow Control Enable */ +#define FCC_PSMR_RSH ((uint)0x00100000) /* Receive Short Frames */ +#define FCC_PSMR_CAM ((uint)0x00000400) /* CAM enable */ +#define FCC_PSMR_BRO ((uint)0x00000200) /* Broadcast pkt discard */ +#define FCC_PSMR_ENCRC ((uint)0x00000080) /* Use 32-bit CRC */ /* IIC parameter RAM. */ diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/fcntl.h linux/include/asm-ppc/fcntl.h --- v2.4.0-test8/linux/include/asm-ppc/fcntl.h Mon Jul 10 16:47:27 2000 +++ linux/include/asm-ppc/fcntl.h Sun Sep 17 09:48:08 2000 @@ -35,6 +35,10 @@ #define F_SETSIG 10 /* for sockets. */ #define F_GETSIG 11 /* for sockets. */ +#define F_GETLK64 12 /* using 'struct flock64' */ +#define F_SETLK64 13 +#define F_SETLKW64 14 + /* for F_[GET|SET]FL */ #define FD_CLOEXEC 1 /* actually anything with low bit set goes */ @@ -66,6 +70,14 @@ off_t l_start; off_t l_len; pid_t l_pid; +}; + +struct flock64 { + short l_type; + short l_whence; + loff_t l_start; + loff_t l_len; + pid_t l_pid; }; #endif diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/feature.h linux/include/asm-ppc/feature.h --- v2.4.0-test8/linux/include/asm-ppc/feature.h Fri Jul 14 12:12:15 2000 +++ linux/include/asm-ppc/feature.h Sun Sep 17 09:48:08 2000 @@ -7,7 +7,9 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (C) 1998 Paul Mackerras. + * Copyright (C) 1998 Paul Mackerras & + * Ben. Herrenschmidt. + * * */ #ifndef __ASM_PPC_FEATURE_H @@ -75,6 +77,9 @@ * Additional functions related to Core99 machines */ extern void feature_set_gmac_power(struct device_node* device, int power); + + /* use constants in KeyLargo.h for the reset parameter */ +extern void feature_set_gmac_phy_reset(struct device_node* device, int reset); extern void feature_set_usb_power(struct device_node* device, int power); diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/hardirq.h linux/include/asm-ppc/hardirq.h --- v2.4.0-test8/linux/include/asm-ppc/hardirq.h Wed Aug 9 19:19:51 2000 +++ linux/include/asm-ppc/hardirq.h Sun Sep 17 09:48:08 2000 @@ -5,16 +5,23 @@ #include /* entry.S is sensitive to the offsets of these fields */ +/* The __last_jiffy_stamp field is needed to ensure that no decrementer + * interrupt is lost on SMP machines. Since on most CPUs it is in the same + * cache line as local_irq_count, it is cheap to access and is also used on UP + * for uniformity. + */ typedef struct { unsigned int __softirq_active; unsigned int __softirq_mask; unsigned int __local_irq_count; unsigned int __local_bh_count; unsigned int __syscall_count; + unsigned int __last_jiffy_stamp; } ____cacheline_aligned irq_cpustat_t; #include /* Standard mappings for irq_cpustat_t above */ +#define last_jiffy_stamp(cpu) __IRQ_STAT((cpu), __last_jiffy_stamp) /* * Are we in an interrupt context? Either doing bottom half * or hardware interrupt processing? diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/heathrow.h linux/include/asm-ppc/heathrow.h --- v2.4.0-test8/linux/include/asm-ppc/heathrow.h Fri Jul 14 12:12:15 2000 +++ linux/include/asm-ppc/heathrow.h Sun Sep 17 09:48:08 2000 @@ -44,4 +44,9 @@ #define HRW_BMAC_IO_ENABLE 0x60000000 /* two bits, not documented in OF */ #define HRW_BMAC_RESET 0x80000000 /* not documented in OF */ +/* We OR those features at boot on desktop G3s */ +#define HRW_DEFAULTS (HRW_SCCA_IO | HRW_SCCB_IO | HRW_SCC_ENABLE) + +/* Those seem to be different on paddington */ #define PADD_MODEM_POWER_N 0x00000001 /* modem power on paddington */ +#define PADD_RESET_SCC 0x02000000 /* check this please */ diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/highmem.h linux/include/asm-ppc/highmem.h --- v2.4.0-test8/linux/include/asm-ppc/highmem.h Wed Dec 31 16:00:00 1969 +++ linux/include/asm-ppc/highmem.h Sun Sep 17 09:48:08 2000 @@ -0,0 +1,121 @@ +/* + * highmem.h: virtual kernel memory mappings for high memory + * + * PowerPC version, stolen from the i386 version. + * + * Used in CONFIG_HIGHMEM systems for memory pages which + * are not addressable by direct kernel virtual adresses. + * + * Copyright (C) 1999 Gerhard Wichert, Siemens AG + * Gerhard.Wichert@pdb.siemens.de + * + * + * Redesigned the x86 32-bit VM architecture to deal with + * up to 16 Terrabyte physical memory. With current x86 CPUs + * we now support up to 64 Gigabytes physical RAM. + * + * Copyright (C) 1999 Ingo Molnar + */ + +#ifndef _ASM_HIGHMEM_H +#define _ASM_HIGHMEM_H + +#ifdef __KERNEL__ + +#include +#include +#include +#include + +/* undef for production */ +#define HIGHMEM_DEBUG 1 + +extern pte_t *kmap_pte; +extern pgprot_t kmap_prot; +extern pte_t *pkmap_page_table; + +extern void kmap_init(void) __init; + +/* + * Right now we initialize only a single pte table. It can be extended + * easily, subsequent pte tables have to be allocated in one physical + * chunk of RAM. + */ +#define PKMAP_BASE (0xfe000000UL) +#define LAST_PKMAP 1024 +#define LAST_PKMAP_MASK (LAST_PKMAP-1) +#define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT) +#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) + +#define KMAP_FIX_BEGIN (0xfe400000UL) + +extern unsigned long kmap_high(struct page *page); +extern void kunmap_high(struct page *page); + +extern inline unsigned long kmap(struct page *page) +{ + if (in_interrupt()) + BUG(); + if (page < highmem_start_page) + return (unsigned long) page_address(page); + return kmap_high(page); +} + +extern inline void kunmap(struct page *page) +{ + if (in_interrupt()) + BUG(); + if (page < highmem_start_page) + return; + kunmap_high(page); +} + +/* + * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap + * gives a more generic (and caching) interface. But kmap_atomic can + * be used in IRQ contexts, so in some (very limited) cases we need + * it. + */ +extern inline unsigned long kmap_atomic(struct page *page, enum km_type type) +{ + unsigned int idx; + unsigned long vaddr; + + if (page < highmem_start_page) + return (unsigned long) page_address(page); + + idx = type + KM_TYPE_NR*smp_processor_id(); + vaddr = KMAP_FIX_BEGIN + idx * PAGE_SIZE; +#if HIGHMEM_DEBUG + if (!pte_none(*(kmap_pte+idx))) + BUG(); +#endif + set_pte(kmap_pte+idx, mk_pte(page, kmap_prot)); + flush_hash_page(0, vaddr); + + return vaddr; +} + +extern inline void kunmap_atomic(unsigned long vaddr, enum km_type type) +{ +#if HIGHMEM_DEBUG + unsigned int idx = type + KM_TYPE_NR*smp_processor_id(); + + if (vaddr < KMAP_FIX_BEGIN) // FIXME + return; + + if (vaddr != KMAP_FIX_BEGIN + idx * PAGE_SIZE) + BUG(); + + /* + * force other mappings to Oops if they'll try to access + * this pte without first remap it + */ + pte_clear(kmap_pte+idx); + flush_hash_page(0, vaddr); +#endif +} + +#endif /* __KERNEL__ */ + +#endif /* _ASM_HIGHMEM_H */ diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/ide.h linux/include/asm-ppc/ide.h --- v2.4.0-test8/linux/include/asm-ppc/ide.h Thu May 11 15:30:08 2000 +++ linux/include/asm-ppc/ide.h Sun Sep 17 09:48:08 2000 @@ -63,7 +63,6 @@ void ide_outsw(ide_ioreg_t port, void *buf, int ns); void ppc_generic_ide_fix_driveid(struct hd_driveid *id); -#if 0 #undef insw #define insw(port, buf, ns) do { \ ppc_ide_md.insw((port), (buf), (ns)); \ @@ -73,7 +72,6 @@ #define outsw(port, buf, ns) do { \ ppc_ide_md.outsw((port), (buf), (ns)); \ } while (0) -#endif #undef SUPPORT_SLOW_DATA_PORTS #define SUPPORT_SLOW_DATA_PORTS 0 diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/immap_8260.h linux/include/asm-ppc/immap_8260.h --- v2.4.0-test8/linux/include/asm-ppc/immap_8260.h Thu May 11 15:30:08 2000 +++ linux/include/asm-ppc/immap_8260.h Sun Sep 17 09:48:08 2000 @@ -241,10 +241,12 @@ char res1[2]; ushort fcc_fdsr; char res2[2]; - uint fcc_fcce; - uint fcc_fccm; + ushort fcc_fcce; + char res3[2]; + ushort fcc_fccm; + char res4[2]; u_char fcc_fccs; - char res3[3]; + char res5[3]; u_char fcc_ftirr_phy[4]; } fcc_t; diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/io.h linux/include/asm-ppc/io.h --- v2.4.0-test8/linux/include/asm-ppc/io.h Fri Jun 23 21:55:11 2000 +++ linux/include/asm-ppc/io.h Sun Sep 17 09:48:08 2000 @@ -25,12 +25,12 @@ #include #elif defined(CONFIG_8260) #include -#else +#else /* 4xx/8xx/8260 */ #ifdef CONFIG_APUS #define _IO_BASE 0 #define _ISA_MEM_BASE 0 #define PCI_DRAM_OFFSET 0 -#else +#else /* CONFIG_APUS */ extern unsigned long isa_io_base; extern unsigned long isa_mem_base; extern unsigned long pci_dram_offset; @@ -54,6 +54,14 @@ #define writel(b,addr) out_le32((volatile u32 *)(addr),(b)) #endif + +#define __raw_readb(addr) (*(volatile unsigned char *)(addr)) +#define __raw_readw(addr) (*(volatile unsigned short *)(addr)) +#define __raw_readl(addr) (*(volatile unsigned int *)(addr)) +#define __raw_writeb(v, addr) (*(volatile unsigned char *)(addr) = (v)) +#define __raw_writew(v, addr) (*(volatile unsigned short *)(addr) = (v)) +#define __raw_writel(v, addr) (*(volatile unsigned int *)(addr) = (v)) + /* * The insw/outsw/insl/outsl macros don't do byte-swapping. * They are only used in practice for transferring buffers which @@ -67,26 +75,76 @@ #define insl(port, buf, nl) _insl_ns((u32 *)((port)+_IO_BASE), (buf), (nl)) #define outsl(port, buf, nl) _outsl_ns((u32 *)((port)+_IO_BASE), (buf), (nl)) +#ifdef CONFIG_ALL_PPC +/* + * We have to handle possible machine checks here on powermacs + * and potentially some CHRPs -- paulus. + */ +#define __do_in_asm(name, op) \ +extern __inline__ unsigned int name(unsigned int port) \ +{ \ + unsigned int x; \ + __asm__ __volatile__( \ + op " %0,0,%1\n" \ + "1: sync\n" \ + "2:\n" \ + ".section .fixup,\"ax\"\n" \ + "3: li %0,-1\n" \ + " b 2b\n" \ + ".previous\n" \ + ".section __ex_table,\"ax\"\n" \ + " .align 2\n" \ + " .long 1b,3b\n" \ + ".previous" \ + : "=&r" (x) \ + : "r" (port + _IO_BASE)); \ + return x; \ +} + +#define __do_out_asm(name, op) \ +extern __inline__ void name(unsigned int val, unsigned int port) \ +{ \ + __asm__ __volatile__( \ + op " %0,0,%1\n" \ + "1: sync\n" \ + "2:\n" \ + ".section __ex_table,\"ax\"\n" \ + " .align 2\n" \ + " .long 1b,2b\n" \ + ".previous" \ + : : "r" (val), "r" (port + _IO_BASE)); \ +} + +__do_in_asm(inb, "lbzx") +__do_in_asm(inw, "lhbrx") +__do_in_asm(inl, "lwbrx") +__do_out_asm(outb, "stbx") +__do_out_asm(outw, "sthbrx") +__do_out_asm(outl, "stwbrx") + +#elif defined(CONFIG_APUS) #define inb(port) in_8((u8 *)((port)+_IO_BASE)) #define outb(val, port) out_8((u8 *)((port)+_IO_BASE), (val)) -#if defined(CONFIG_APUS) #define inw(port) in_be16((u16 *)((port)+_IO_BASE)) #define outw(val, port) out_be16((u16 *)((port)+_IO_BASE), (val)) #define inl(port) in_be32((u32 *)((port)+_IO_BASE)) #define outl(val, port) out_be32((u32 *)((port)+_IO_BASE), (val)) -#else + +#else /* not APUS or ALL_PPC */ +#define inb(port) in_8((u8 *)((port)+_IO_BASE)) +#define outb(val, port) out_8((u8 *)((port)+_IO_BASE), (val)) #define inw(port) in_le16((u16 *)((port)+_IO_BASE)) #define outw(val, port) out_le16((u16 *)((port)+_IO_BASE), (val)) #define inl(port) in_le32((u32 *)((port)+_IO_BASE)) #define outl(val, port) out_le32((u32 *)((port)+_IO_BASE), (val)) #endif -#define inb_p(port) in_8((u8 *)((port)+_IO_BASE)) -#define outb_p(val, port) out_8((u8 *)((port)+_IO_BASE), (val)) -#define inw_p(port) in_le16((u16 *)((port)+_IO_BASE)) -#define outw_p(val, port) out_le16((u16 *)((port)+_IO_BASE), (val)) -#define inl_p(port) in_le32((u32 *)((port)+_IO_BASE)) -#define outl_p(val, port) out_le32((u32 *)((port)+_IO_BASE), (val)) +#define inb_p(port) inb((port)) +#define outb_p(val, port) outb((val), (port)) +#define inw_p(port) inw((port)) +#define outw_p(val, port) outw((val), (port)) +#define inl_p(port) inl((port)) +#define outl_p(val, port) outl((val), (port)) extern void _insb(volatile u8 *port, void *buf, int ns); extern void _outsb(volatile u8 *port, const void *buf, int ns); @@ -123,6 +181,8 @@ */ extern void *__ioremap(unsigned long address, unsigned long size, unsigned long flags); +extern void *__ioremap_at(unsigned long phys, unsigned long size, + unsigned long flags); extern void *ioremap(unsigned long address, unsigned long size); #define ioremap_nocache(addr, size) ioremap((addr), (size)) extern void iounmap(void *addr); diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/irq.h linux/include/asm-ppc/irq.h --- v2.4.0-test8/linux/include/asm-ppc/irq.h Thu May 11 15:30:08 2000 +++ linux/include/asm-ppc/irq.h Sun Sep 17 09:48:08 2000 @@ -184,6 +184,9 @@ */ #define SIU_INT_SMC1 ((uint)0x04) #define SIU_INT_SMC2 ((uint)0x05) +#define SIU_INT_FCC1 ((uint)0x20) +#define SIU_INT_FCC2 ((uint)0x21) +#define SIU_INT_FCC3 ((uint)0x22) #define SIU_INT_SCC1 ((uint)0x28) #define SIU_INT_SCC2 ((uint)0x29) #define SIU_INT_SCC3 ((uint)0x2a) diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/keylargo.h linux/include/asm-ppc/keylargo.h --- v2.4.0-test8/linux/include/asm-ppc/keylargo.h Wed Dec 31 16:00:00 1969 +++ linux/include/asm-ppc/keylargo.h Sun Sep 17 09:48:08 2000 @@ -0,0 +1,103 @@ +/* + * keylargo.h: definitions for using the "KeyLargo" I/O controller chip. + * + */ + +/* offset from base for feature control registers */ +#define KEYLARGO_MBCR 0x34 /* Media bay control/status */ +#define KEYLARGO_FCR0 0x38 +#define KEYLARGO_FCR1 0x3c +#define KEYLARGO_FCR2 0x40 +#define KEYLARGO_FCR3 0x44 +#define KEYLARGO_FCR4 0x48 + +/* GPIO registers */ +#define KEYLARGO_GPIO_LEVELS0 0x50 +#define KEYLARGO_GPIO_LEVELS1 0x54 +#define KEYLARGO_GPIO_EXTINT_0 0x58 +#define KEYLARGO_GPIO_EXTINT_CNT 18 +#define KEYLARGO_GPIO_0 0x6A +#define KEYLARGO_GPIO_CNT 17 + +/* Specific GPIO regs */ +#define KL_GPIO_ETH_PHY_RESET (KEYLARGO_GPIO_0+0x10) +#define KL_GPIO_ETH_PHY_RESET_ASSERT 0x04 +#define KL_GPIO_ETH_PHY_RESET_RELEASE 0x05 +#define KL_GPIO_ETH_PHY_RESET_TRISTATE 0x00 +/* + * Bits in feature control register + */ +#define KL_MBCR_MBDEV_ENABLE 0x00001000 + +#define KL0_SCC_B_INTF_ENABLE 0x00000001 /* ??? */ +#define KL0_SCC_A_INTF_ENABLE 0x00000002 /* ??? */ +#define KL0_SCC_SLOWPCLK 0x00000004 +#define KL0_SCC_RESET 0x00000008 +#define KL0_SCCA_ENABLE 0x00000010 +#define KL0_SCCB_ENABLE 0x00000020 +#define KL0_SCC_CELL_ENABLE 0x00000040 +#define KL0_IRDA_ENABLE 0x00008000 +#define KL0_IRDA_CLK32_ENABLE 0x00010000 +#define KL0_IRDA_CLK19_ENABLE 0x00020000 +#define KL0_USB0_PAD_SUSPEND0 0x00040000 +#define KL0_USB0_PAD_SUSPEND1 0x00080000 +#define KL0_USB0_CELL_ENABLE 0x00100000 +#define KL0_USB1_PAD_SUSPEND0 0x00400000 +#define KL0_USB1_PAD_SUSPEND1 0x00800000 +#define KL0_USB1_CELL_ENABLE 0x01000000 +#define KL0_USB_REF_SUSPEND 0x10000000 + +#define KL0_SERIAL_ENABLE (KL0_SCC_B_INTF_ENABLE | \ + KL0_SCC_SLOWPCLK | \ + KL0_SCC_CELL_ENABLE | KL0_SCCA_ENABLE) + +#define KL1_AUDIO_SEL_22MCLK 0x00000002 +#define KL1_AUDIO_CLK_ENABLE_BIT 0x00000008 +#define KL1_AUDIO_CLK_OUT_ENABLE 0x00000020 /* Burgundy only ? */ +#define KL1_AUDIO_CELL_ENABLE 0x00000040 +#define KL1_AUDIO_CHOOSE 0x00000080 /* Burgundy only ? */ +#define KL1_I2S0_CELL_ENABLE 0x00000400 +#define KL1_I2S0_CLK_ENABLE_BIT 0x00001000 +#define KL1_I2S0_ENABLE 0x00002000 +#define KL1_I2S1_CELL_ENABLE 0x00020000 +#define KL1_I2S1_CLK_ENABLE_BIT 0x00080000 +#define KL1_I2S1_ENABLE 0x00100000 +#define KL1_EIDE0_ENABLE 0x00800000 +#define KL1_EIDE0_RESET_N 0x01000000 +#define KL1_EIDE1_ENABLE 0x04000000 +#define KL1_EIDE1_RESET_N 0x08000000 +#define KL1_UIDE_ENABLE 0x20000000 +#define KL1_UIDE_RESET_N 0x40000000 + +#define KL2_IOBUS_ENABLE 0x00000002 +#define KL2_SLEEP_STATE_BIT 0x00000100 +#define KL2_MPIC_ENABLE 0x00020000 +#define KL2_MODEM_POWER_N 0x02000000 +#define KL2_AIRPORT_RESET_N 0x08000000 /* Or power ? */ + +#define KL3_SHUTDOWN_PLL_TOTAL 0x00000001 +#define KL3_SHUTDOWN_PLLKW6 0x00000002 +#define KL3_SHUTDOWN_PLLKW4 0x00000004 +#define KL3_SHUTDOWN_PLLKW35 0x00000008 +#define KL3_SHUTDOWN_PLLKW12 0x00000010 +#define KL3_PLL_RESET 0x00000020 +#define KL3_SHUTDOWN_PLL2X 0x00000080 +#define KL3_CLK66_ENABLE 0x00000100 +#define KL3_CLK49_ENABLE 0x00000200 +#define KL3_CLK45_ENABLE 0x00000400 +#define KL3_CLK31_ENABLE 0x00000800 +#define KL3_TIMER_CLK18_ENABLE 0x00001000 +#define KL3_I2S1_CLK18_ENABLE 0x00002000 +#define KL3_I2S0_CLK18_ENABLE 0x00004000 +#define KL3_VIA_CLK16_ENABLE 0x00008000 +#define KL3_STOPPING33_ENABLED 0x00080000 + +/* Port 0,1 : bus 0, port 2,3 : bus 1 */ +#define KL4_SET_PORT_ENABLE(p) (0x00000008 << (p<<3)) +#define KL4_SET_PORT_RESUME(p) (0x00000004 << (p<<3)) +#define KL4_SET_PORT_CONNECT(p) (0x00000002 << (p<<3)) +#define KL4_SET_PORT_DISCONNECT(p) (0x00000001 << (p<<3)) +#define KL4_GET_PORT_RESUME(p) (0x00000040 << (p<<3)) +#define KL4_GET_PORT_CONNECT(p) (0x00000020 << (p<<3)) +#define KL4_GET_PORT_DISCONNECT(p) (0x00000010 << (p<<3)) + diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/kmap_types.h linux/include/asm-ppc/kmap_types.h --- v2.4.0-test8/linux/include/asm-ppc/kmap_types.h Wed Dec 31 16:00:00 1969 +++ linux/include/asm-ppc/kmap_types.h Sun Sep 17 09:48:08 2000 @@ -0,0 +1,10 @@ +#ifndef _ASM_KMAP_TYPES_H +#define _ASM_KMAP_TYPES_H + +enum km_type { + KM_BOUNCE_READ, + KM_BOUNCE_WRITE, + KM_TYPE_NR +}; + +#endif diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/machdep.h linux/include/asm-ppc/machdep.h --- v2.4.0-test8/linux/include/asm-ppc/machdep.h Thu Jul 27 17:38:02 2000 +++ linux/include/asm-ppc/machdep.h Sun Sep 17 09:48:08 2000 @@ -31,7 +31,7 @@ void (*power_off)(void); void (*halt)(void); - void (*time_init)(void); /* Optional, may be NULL */ + long (*time_init)(void); /* Optional, may be NULL */ int (*set_rtc_time)(unsigned long nowtime); unsigned long (*get_rtc_time)(void); void (*calibrate_decr)(void); @@ -75,7 +75,7 @@ void (*pcibios_fixup)(void); void (*pcibios_fixup_bus)(struct pci_bus *); - void* (*pci_dev_io_base)(unsigned char bus, unsigned char devfn); + void* (*pci_dev_io_base)(unsigned char bus, unsigned char devfn, int physical); void* (*pci_dev_mem_base)(unsigned char bus, unsigned char devfn); int (*pci_dev_root_bridge)(unsigned char bus, unsigned char devfn); diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/mbx.h linux/include/asm-ppc/mbx.h --- v2.4.0-test8/linux/include/asm-ppc/mbx.h Sat Oct 9 11:47:50 1999 +++ linux/include/asm-ppc/mbx.h Sun Sep 17 09:48:08 2000 @@ -25,6 +25,7 @@ unsigned int bi_busfreq; /* Bus Freq, in Hz */ unsigned int bi_clun; /* Boot device controller */ unsigned int bi_dlun; /* Boot device logical dev */ + unsigned int bi_baudrate; /* ...to be like everyone else */ } bd_t; /* Memory map for the MBX as configured by EPPC-Bug. We could reprogram diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/mman.h linux/include/asm-ppc/mman.h --- v2.4.0-test8/linux/include/asm-ppc/mman.h Mon Mar 27 08:08:31 2000 +++ linux/include/asm-ppc/mman.h Sun Sep 17 09:48:08 2000 @@ -22,8 +22,8 @@ #define MS_INVALIDATE 2 /* invalidate the caches */ #define MS_SYNC 4 /* synchronous memory sync */ -#define MCL_CURRENT 1 /* lock all current mappings */ -#define MCL_FUTURE 2 /* lock all future mappings */ +#define MCL_CURRENT 0x2000 /* lock all currently mapped pages */ +#define MCL_FUTURE 0x4000 /* lock all additions to address space */ #define MADV_NORMAL 0x0 /* default page-in behavior */ #define MADV_RANDOM 0x1 /* page-in minimum required */ diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/nvram.h linux/include/asm-ppc/nvram.h --- v2.4.0-test8/linux/include/asm-ppc/nvram.h Thu May 11 15:30:08 2000 +++ linux/include/asm-ppc/nvram.h Sun Sep 17 09:48:08 2000 @@ -38,6 +38,8 @@ pmac_nvram_NR /* MacOS Name Registry partition */ }; +#ifdef __KERNEL__ + /* Return partition offset in nvram */ extern int pmac_get_partition(int partition); @@ -45,15 +47,20 @@ extern u8 pmac_xpram_read(int xpaddr); extern void pmac_xpram_write(int xpaddr, u8 data); +#endif /* __KERNEL__ */ + /* Some offsets in XPRAM */ #define PMAC_XPRAM_MACHINE_LOC 0xe4 #define PMAC_XPRAM_SOUND_VOLUME 0x08 /* Machine location structure in XPRAM */ struct pmac_machine_location { - u32 latitude; /* 2+30 bit Fractional number */ - u32 longitude; /* 2+30 bit Fractional number */ - u32 delta; /* mix of GMT delta and DLS */ + unsigned int latitude; /* 2+30 bit Fractional number */ + unsigned int longitude; /* 2+30 bit Fractional number */ + unsigned int delta; /* mix of GMT delta and DLS */ }; + +/* /dev/nvram ioctls */ +#define PMAC_NVRAM_GET_OFFSET _IOWR('p', 0x40, int) /* Get NVRAM partition offset */ #endif diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/pci-bridge.h linux/include/asm-ppc/pci-bridge.h --- v2.4.0-test8/linux/include/asm-ppc/pci-bridge.h Fri Jul 14 12:12:15 2000 +++ linux/include/asm-ppc/pci-bridge.h Sun Sep 17 09:48:08 2000 @@ -15,8 +15,12 @@ /* This version handles the new Uni-N host bridge, the iobase is now * a per-device thing. I also added the memory base so PReP can * be fixed to return 0xc0000000 (I didn't actually implement it) + * + * pci_dev_io_base() returns either a virtual (ioremap'ed) address or + * a physical address. In-kernel clients will use logical while the + * sys_pciconfig_iobase syscall returns a physical one to userland. */ -void *pci_dev_io_base(unsigned char bus, unsigned char devfn); +void *pci_dev_io_base(unsigned char bus, unsigned char devfn, int physical); void *pci_dev_mem_base(unsigned char bus, unsigned char devfn); /* Returns the root-bridge number (Uni-N number) of a device */ @@ -33,7 +37,8 @@ struct bridge_data { volatile unsigned int *cfg_addr; volatile unsigned char *cfg_data; - void *io_base; + void *io_base; /* virtual */ + unsigned long io_base_phys; int bus_number; int max_bus; struct bridge_data *next; diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/pgtable.h linux/include/asm-ppc/pgtable.h --- v2.4.0-test8/linux/include/asm-ppc/pgtable.h Wed Aug 9 19:19:51 2000 +++ linux/include/asm-ppc/pgtable.h Sun Sep 17 09:48:08 2000 @@ -69,7 +69,7 @@ extern void flush_icache_range(unsigned long, unsigned long); extern void __flush_page_to_ram(unsigned long page_va); -#define flush_page_to_ram(page) __flush_page_to_ram((unsigned long) page_address(page)) +extern void flush_page_to_ram(struct page *page); #define flush_dcache_page(page) do { } while (0) diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/processor.h linux/include/asm-ppc/processor.h --- v2.4.0-test8/linux/include/asm-ppc/processor.h Wed Aug 9 19:19:51 2000 +++ linux/include/asm-ppc/processor.h Sun Sep 17 09:48:08 2000 @@ -287,6 +287,7 @@ #define SPRN_UPMC3 0x3AD /* User Performance Counter Register 3 */ #define SPRN_UPMC4 0x3AE /* User Performance Counter Register 4 */ #define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */ +#define SPRN_VRSAVE 0x100 /* Vector Register Save Register */ #define SPRN_XER 0x001 /* Fixed Point Exception Register */ #define SPRN_ZPR 0x3B0 /* Zone Protection Register */ diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/prom.h linux/include/asm-ppc/prom.h --- v2.4.0-test8/linux/include/asm-ppc/prom.h Fri Jul 14 12:12:15 2000 +++ linux/include/asm-ppc/prom.h Sun Sep 17 09:48:08 2000 @@ -12,6 +12,9 @@ extern char *prom_display_paths[]; extern unsigned int prom_num_displays; +#ifndef CONFIG_MACH_SPECIFIC +extern int have_of; +#endif struct address_range { unsigned int space; diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/serial.h linux/include/asm-ppc/serial.h --- v2.4.0-test8/linux/include/asm-ppc/serial.h Sat Oct 9 11:47:50 1999 +++ linux/include/asm-ppc/serial.h Sun Sep 17 09:48:08 2000 @@ -23,16 +23,6 @@ #define RS_TABLE_SIZE 4 #endif -#ifdef CONFIG_PMAC -/* - * Auto-probing will cause machine checks on powermacs. - */ -#define SERIAL_PORT_DFNS -#else -/* - * PReP, CHRP, etc. - */ - /* Standard COM flags (except for COM4, because of the 8514 problem) */ #ifdef CONFIG_SERIAL_DETECT_IRQ #define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ) @@ -136,5 +126,4 @@ HUB6_SERIAL_PORT_DFNS \ MCA_SERIAL_PORT_DFNS -#endif /* CONFIG_PMAC */ #endif /* CONFIG_GEMINI */ diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/smp.h linux/include/asm-ppc/smp.h --- v2.4.0-test8/linux/include/asm-ppc/smp.h Fri Jun 23 21:55:11 2000 +++ linux/include/asm-ppc/smp.h Sun Sep 17 09:48:08 2000 @@ -24,10 +24,11 @@ extern unsigned long smp_proc_in_lock[NR_CPUS]; -extern void smp_message_pass(int target, int msg, unsigned long data, int wait); extern void smp_store_cpu_info(int id); -extern void smp_message_recv(int); -void smp_send_tlb_invalidate(int); +extern void smp_send_tlb_invalidate(int); +extern void smp_send_xmon_break(int cpu); +struct pt_regs; +extern void smp_message_recv(int, struct pt_regs *); #define NO_PROC_ID 0xFF /* No processor magic marker */ #define PROC_CHANGE_PENALTY 20 diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/spinlock.h linux/include/asm-ppc/spinlock.h --- v2.4.0-test8/linux/include/asm-ppc/spinlock.h Sun Feb 13 19:29:04 2000 +++ linux/include/asm-ppc/spinlock.h Sun Sep 17 09:48:08 2000 @@ -41,6 +41,7 @@ } rwlock_t; #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 } +#define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0) extern void _read_lock(rwlock_t *rw); extern void _read_unlock(rwlock_t *rw); diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/time.h linux/include/asm-ppc/time.h --- v2.4.0-test8/linux/include/asm-ppc/time.h Fri Jul 14 12:12:15 2000 +++ linux/include/asm-ppc/time.h Sun Sep 17 09:48:08 2000 @@ -12,11 +12,10 @@ #include /* time.c */ -extern unsigned decrementer_count; -extern unsigned count_period_num; -extern unsigned count_period_den; -extern unsigned long mktime(unsigned int, unsigned int, unsigned int, - unsigned int, unsigned int, unsigned int); +extern unsigned tb_ticks_per_jiffy; +extern unsigned tb_to_us; +extern unsigned tb_last_stamp; + extern void to_tm(int tim, struct rtc_time * tm); extern time_t last_rtc_update; @@ -37,6 +36,80 @@ #if defined(CONFIG_4xx) mtspr(SPRN_PIT, val); #else +#ifdef CONFIG_8xx_CPU6 + set_dec_cpu6(val); +#else mtspr(SPRN_DEC, val); #endif +#endif +} + +/* Accessor functions for the timebase (RTC on 601) registers. */ +/* If one day CONFIG_POWER is added just define __USE_RTC as 1 */ +#ifdef CONFIG_6xx +extern __inline__ int const __USE_RTC(void) { + return (mfspr(SPRN_PVR)>>16) == 1; +} +#else +#define __USE_RTC() 0 +#endif + +extern __inline__ unsigned long get_tbl(void) { + unsigned long tbl; + asm volatile("mftb %0" : "=r" (tbl)); + return tbl; +} + +extern __inline__ unsigned long get_rtcl(void) { + unsigned long rtcl; + asm volatile("mfrtcl %0" : "=r" (rtcl)); + return rtcl; } + +extern __inline__ unsigned get_native_tbl(void) { + if (__USE_RTC()) + return get_rtcl(); + else + return get_tbl(); +} + +/* On machines with RTC, this function can only be used safely + * after the timestamp and for 1 second. It is only used by gettimeofday + * however so it should not matter. + */ +extern __inline__ unsigned tb_ticks_since(unsigned tstamp) { + if (__USE_RTC()) { + int delta = get_rtcl() - tstamp; + return delta<0 ? delta + 1000000000 : delta; + } else { + return get_tbl() - tstamp; + } +} + +#if 0 +extern __inline__ unsigned long get_bin_rtcl(void) { + unsigned long rtcl, rtcu1, rtcu2; + asm volatile("\ +1: mfrtcu %0\n\ + mfrtcl %1\n\ + mfrtcu %2\n\ + cmpw %0,%2\n\ + bne- 1b\n" + : "=r" (rtcu1), "=r" (rtcl), "=r" (rtcu2) + : : "cr0"); + return rtcu2*1000000000+rtcl; +} + +extern __inline__ unsigned binary_tbl(void) { + if (__USE_RTC()) + return get_bin_rtcl(); + else + return get_tbl(); +} +#endif + +/* Use mulhwu to scale processor timebase to timeval */ +#define mulhwu(x,y) \ +({unsigned z; asm ("mulhwu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;}) + +unsigned mulhwu_scale_factor(unsigned, unsigned); diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/uaccess.h linux/include/asm-ppc/uaccess.h --- v2.4.0-test8/linux/include/asm-ppc/uaccess.h Fri Sep 8 13:27:13 2000 +++ linux/include/asm-ppc/uaccess.h Sun Sep 17 09:48:08 2000 @@ -57,7 +57,7 @@ /* Returns 0 if exception not found and fixup otherwise. */ extern unsigned long search_exception_table(unsigned long); - +extern void sort_exception_table(void); /* * These are the main single-value transfer routines. They automatically @@ -131,10 +131,11 @@ ".section .fixup,\"ax\"\n" \ "3: li %0,%3\n" \ " b 2b\n" \ + ".previous\n" \ ".section __ex_table,\"a\"\n" \ " .align 2\n" \ " .long 1b,3b\n" \ - ".text" \ + ".previous" \ : "=r"(err) \ : "r"(x), "b"(addr), "i"(-EFAULT), "0"(err)) @@ -178,10 +179,11 @@ "3: li %0,%3\n" \ " li %1,0\n" \ " b 2b\n" \ + ".previous\n" \ ".section __ex_table,\"a\"\n" \ " .align 2\n" \ " .long 1b,3b\n" \ - ".text" \ + ".previous" \ : "=r"(err), "=r"(x) \ : "b"(addr), "i"(-EFAULT), "0"(err)) diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/uninorth.h linux/include/asm-ppc/uninorth.h --- v2.4.0-test8/linux/include/asm-ppc/uninorth.h Wed Dec 31 16:00:00 1969 +++ linux/include/asm-ppc/uninorth.h Sun Sep 17 09:48:08 2000 @@ -0,0 +1,83 @@ +/* + * uninorth.h: definitions for using the "UniNorth" host bridge chip + * from Apple. This chip is used on "Core99" machines + * + */ + + +/* + * Uni-N config space reg. definitions + * + * (Little endian) + */ + +/* Address ranges selection. This one should work with Bandit too */ +#define UNI_N_ADDR_SELECT 0x48 +#define UNI_N_ADDR_COARSE_MASK 0xffff0000 /* 256Mb regions at *0000000 */ +#define UNI_N_ADDR_FINE_MASK 0x0000ffff /* 16Mb regions at f*000000 */ + +/* AGP registers */ +#define UNI_N_CFG_GART_BASE 0x8c +#define UNI_N_CFG_AGP_BASE 0x90 +#define UNI_N_CFG_GART_CTRL 0x94 +#define UNI_N_CFG_INTERNAL_STATUS 0x98 + +/* UNI_N_CFG_GART_CTRL bits definitions */ +#define UNI_N_CFG_GART_INVAL 0x00000001 +#define UNI_N_CFG_GART_ENABLE 0x00000100 +#define UNI_N_CFG_GART_2xRESET 0x00010000 + + +/* + * Uni-N memory mapped reg. definitions + * + * Those registers are Big-Endian !! + * + * Their meaning come from either Darwin and/or from experiments I made with + * the bootrom, I'm not sure about their exact meaning yet + * + */ + +/* Version of the UniNorth chip */ +#define UNI_N_VERSION 0x0000 /* Known versions: 3,7 and 8 */ + +/* This register is used to enable/disable various parts */ +#define UNI_N_CLOCK_CNTL 0x0020 +#define UNI_N_CLOCK_CNTL_PCI 0x00000001 /* guess ? */ +#define UNI_N_CLOCK_CNTL_GMAC 0x00000002 +#define UNI_N_CLOCK_CNTL_FW 0x00000004 /* guess ? */ + +/* Power Management control ? (from Darwin) */ +#define UNI_N_POWER_MGT 0x0030 +#define UNI_N_POWER_MGT_NORMAL 0x00 +#define UNI_N_POWER_MGT_IDLE2 0x01 +#define UNI_N_POWER_MGT_SLEEP 0x02 + +/* This register is configured by Darwin depending on the UniN + * revision + */ +#define UNI_N_ARB_CTRL 0x0040 +#define UNI_N_ARB_CTRL_QACK_DELAY_SHIFT 15 +#define UNI_N_ARB_CTRL_QACK_DELAY_MASK 0x0e1f8000 +#define UNI_N_ARB_CTRL_QACK_DELAY 0x30 +#define UNI_N_ARB_CTRL_QACK_DELAY105 0x00 + +/* This one _might_ return the CPU number of the CPU reading it; + * the bootROM decides wether to boot or to sleep/spinloop depending + * on this register beeing 0 or not + */ +#define UNI_N_CPU_NUMBER 0x0050 + +/* This register appear to be read by the bootROM to decide what + * to do on a non-recoverable reset (powerup or wakeup) + */ +#define UNI_N_HWINIT_STATE 0x0070 +#define UNI_N_HWINIT_STATE_SLEEPING 0x01 +#define UNI_N_HWINIT_STATE_RUNNING 0x02 +/* This last bit appear to be used by the bootROM to know the second + * CPU has started and will enter it's sleep loop with IP=0 + */ +#define UNI_N_HWINIT_STATE_CPU1_FLAG 0x10000000 + + + diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-ppc/unistd.h linux/include/asm-ppc/unistd.h --- v2.4.0-test8/linux/include/asm-ppc/unistd.h Wed Aug 23 18:36:39 2000 +++ linux/include/asm-ppc/unistd.h Sun Sep 17 09:48:08 2000 @@ -201,10 +201,10 @@ #define __NR_stat64 195 #define __NR_lstat64 196 #define __NR_fstat64 197 -#define __NR_sys_pciconfig_read 198 -#define __NR_sys_pciconfig_write 199 -#define __NR_sys_pciconfig_iobase 200 -#define __NR_multiplexer 201 +#define __NR_pciconfig_read 198 +#define __NR_pciconfig_write 199 +#define __NR_pciconfig_iobase 200 +#define __NR_multiplexer 201 #define __NR_getdents64 202 #define __NR(n) #n diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-sparc/io.h linux/include/asm-sparc/io.h --- v2.4.0-test8/linux/include/asm-sparc/io.h Wed Apr 26 16:34:09 2000 +++ linux/include/asm-sparc/io.h Sun Sep 17 09:50:02 2000 @@ -1,5 +1,5 @@ /* - * $Id: io.h,v 1.27 2000/04/13 04:45:59 davem Exp $ + * $Id: io.h,v 1.28 2000/09/17 05:12:00 davem Exp $ */ #ifndef __SPARC_IO_H #define __SPARC_IO_H @@ -164,6 +164,8 @@ return (void *) dst; } +#ifdef __KERNEL__ + /* * Bus number may be embedded in the higher bits of the physical address. * This is why we have no bus number argument to ioremap(). @@ -199,5 +201,7 @@ #define dma_cache_inv(_start,_size) do { } while (0) #define dma_cache_wback(_start,_size) do { } while (0) #define dma_cache_wback_inv(_start,_size) do { } while (0) + +#endif #endif /* !(__SPARC_IO_H) */ diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-sparc64/io.h linux/include/asm-sparc64/io.h --- v2.4.0-test8/linux/include/asm-sparc64/io.h Wed Apr 26 16:34:09 2000 +++ linux/include/asm-sparc64/io.h Sun Sep 17 09:50:02 2000 @@ -1,4 +1,4 @@ -/* $Id: io.h,v 1.35 2000/04/13 04:45:59 davem Exp $ */ +/* $Id: io.h,v 1.36 2000/09/17 05:12:00 davem Exp $ */ #ifndef __SPARC64_IO_H #define __SPARC64_IO_H @@ -363,6 +363,8 @@ return retval; } +#ifdef __KERNEL__ + /* On sparc64 we have the whole physical IO address space accessible * using physically addressed loads and stores, so this does nothing. */ @@ -388,5 +390,7 @@ #define dma_cache_inv(_start,_size) do { } while (0) #define dma_cache_wback(_start,_size) do { } while (0) #define dma_cache_wback_inv(_start,_size) do { } while (0) + +#endif #endif /* !(__SPARC64_IO_H) */ diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/adb.h linux/include/linux/adb.h --- v2.4.0-test8/linux/include/linux/adb.h Fri Oct 15 15:25:14 1999 +++ linux/include/linux/adb.h Sun Sep 17 09:48:05 2000 @@ -58,7 +58,6 @@ int (*probe)(void); int (*init)(void); int (*send_request)(struct adb_request *req, int sync); - /*int (*write)(struct adb_request *req);*/ int (*autopoll)(int devs); void (*poll)(void); int (*reset_bus)(void); @@ -83,6 +82,7 @@ int flags, int nbytes, ...); int adb_register(int default_id,int handler_id,struct adb_ids *ids, void (*handler)(unsigned char *, int, struct pt_regs *, int)); +int adb_unregister(int index); void adb_poll(void); void adb_input(unsigned char *, int, struct pt_regs *, int); int adb_reset_bus(void); diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/arcdevice.h linux/include/linux/arcdevice.h --- v2.4.0-test8/linux/include/linux/arcdevice.h Wed Aug 9 19:19:51 2000 +++ linux/include/linux/arcdevice.h Sun Sep 17 09:45:05 2000 @@ -340,7 +340,6 @@ void arcnet_raw_init(void); int com90xx_probe(struct net_device *dev); -void com20020pci_probe_all(void); #endif /* __KERNEL__ */ diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/blk.h linux/include/linux/blk.h --- v2.4.0-test8/linux/include/linux/blk.h Wed Aug 9 19:19:51 2000 +++ linux/include/linux/blk.h Sun Sep 17 09:45:06 2000 @@ -308,7 +308,7 @@ #elif (MAJOR_NR == I2O_MAJOR) #define DEVICE_NAME "I2O block" -#define DEVICE_REQUEST do_i2ob_request +#define DEVICE_REQUEST i2ob_request #define DEVICE_NR(device) (MINOR(device)>>4) #elif (MAJOR_NR == COMPAQ_SMART2_MAJOR) diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/cuda.h linux/include/linux/cuda.h --- v2.4.0-test8/linux/include/linux/cuda.h Fri Oct 15 15:25:14 1999 +++ linux/include/linux/cuda.h Sun Sep 17 09:48:05 2000 @@ -28,7 +28,8 @@ #ifdef __KERNEL__ -void find_via_cuda(void); +extern int find_via_cuda(void); +extern int via_cuda_start(void); extern int cuda_request(struct adb_request *req, void (*done)(struct adb_request *), int nbytes, ...); extern void cuda_poll(void); diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/fs.h linux/include/linux/fs.h --- v2.4.0-test8/linux/include/linux/fs.h Fri Sep 8 13:27:13 2000 +++ linux/include/linux/fs.h Sun Sep 17 09:51:57 2000 @@ -93,7 +93,7 @@ * as nfs_rename() will be cleaned up */ /* - * These are the fs-independent mount-flags: up to 16 flags are supported + * These are the fs-independent mount-flags: up to 32 flags are supported */ #define MS_RDONLY 1 /* Mount read-only */ #define MS_NOSUID 2 /* Ignore suid and sgid bits */ @@ -104,6 +104,7 @@ #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */ #define MS_NOATIME 1024 /* Do not update access times. */ #define MS_NODIRATIME 2048 /* Do not update directory access times */ +#define MS_BIND 4096 /* * Flags that can be altered by MS_REMOUNT diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/mm.h linux/include/linux/mm.h --- v2.4.0-test8/linux/include/linux/mm.h Fri Sep 8 13:27:13 2000 +++ linux/include/linux/mm.h Fri Sep 15 19:04:40 2000 @@ -15,7 +15,9 @@ extern unsigned long num_physpages; extern void * high_memory; extern int page_cluster; -extern struct list_head lru_cache; +/* The inactive_clean lists are per zone. */ +extern struct list_head active_list; +extern struct list_head inactive_dirty_list; #include #include @@ -149,6 +151,7 @@ atomic_t count; unsigned long flags; /* atomic flags, some possibly updated asynchronously */ struct list_head lru; + unsigned long age; wait_queue_head_t wait; struct page **pprev_hash; struct buffer_head * buffers; @@ -169,12 +172,12 @@ #define PG_uptodate 3 #define PG_dirty 4 #define PG_decr_after 5 -#define PG_unused_01 6 -#define PG__unused_02 7 +#define PG_active 6 +#define PG_inactive_dirty 7 #define PG_slab 8 #define PG_swap_cache 9 #define PG_skip 10 -#define PG_unused_03 11 +#define PG_inactive_clean 11 #define PG_highmem 12 /* bits 21-30 unused */ #define PG_reserved 31 @@ -199,6 +202,7 @@ #define ClearPageError(page) clear_bit(PG_error, &(page)->flags) #define PageReferenced(page) test_bit(PG_referenced, &(page)->flags) #define SetPageReferenced(page) set_bit(PG_referenced, &(page)->flags) +#define ClearPageReferenced(page) clear_bit(PG_referenced, &(page)->flags) #define PageTestandClearReferenced(page) test_and_clear_bit(PG_referenced, &(page)->flags) #define PageDecrAfter(page) test_bit(PG_decr_after, &(page)->flags) #define SetPageDecrAfter(page) set_bit(PG_decr_after, &(page)->flags) @@ -216,6 +220,18 @@ #define PageClearSwapCache(page) clear_bit(PG_swap_cache, &(page)->flags) #define PageTestandClearSwapCache(page) test_and_clear_bit(PG_swap_cache, &(page)->flags) + +#define PageActive(page) test_bit(PG_active, &(page)->flags) +#define SetPageActive(page) set_bit(PG_active, &(page)->flags) +#define ClearPageActive(page) clear_bit(PG_active, &(page)->flags) + +#define PageInactiveDirty(page) test_bit(PG_inactive_dirty, &(page)->flags) +#define SetPageInactiveDirty(page) set_bit(PG_inactive_dirty, &(page)->flags) +#define ClearPageInactiveDirty(page) clear_bit(PG_inactive_dirty, &(page)->flags) + +#define PageInactiveClean(page) test_bit(PG_inactive_clean, &(page)->flags) +#define SetPageInactiveClean(page) set_bit(PG_inactive_clean, &(page)->flags) +#define ClearPageInactiveClean(page) clear_bit(PG_inactive_clean, &(page)->flags) #ifdef CONFIG_HIGHMEM #define PageHighMem(page) test_bit(PG_highmem, &(page)->flags) diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/mmzone.h linux/include/linux/mmzone.h --- v2.4.0-test8/linux/include/linux/mmzone.h Fri Sep 8 13:27:13 2000 +++ linux/include/linux/mmzone.h Fri Sep 15 19:04:40 2000 @@ -28,13 +28,14 @@ spinlock_t lock; unsigned long offset; unsigned long free_pages; - char low_on_memory; - char zone_wake_kswapd; + unsigned long inactive_clean_pages; + unsigned long inactive_dirty_pages; unsigned long pages_min, pages_low, pages_high; /* * free areas of different sizes */ + struct list_head inactive_clean_list; free_area_t free_area[MAX_ORDER]; /* diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/mount.h linux/include/linux/mount.h --- v2.4.0-test8/linux/include/linux/mount.h Thu Jul 27 17:38:02 2000 +++ linux/include/linux/mount.h Sun Sep 17 09:51:57 2000 @@ -27,8 +27,7 @@ struct list_head mnt_child; /* and going through their mnt_child */ atomic_t mnt_count; int mnt_flags; - - char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ + char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ struct list_head mnt_list; uid_t mnt_owner; }; diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/pci.h linux/include/linux/pci.h --- v2.4.0-test8/linux/include/linux/pci.h Wed Apr 12 10:02:34 2000 +++ linux/include/linux/pci.h Sun Sep 17 09:45:06 2000 @@ -553,14 +553,14 @@ */ #ifndef CONFIG_PCI -extern inline int pcibios_present(void) { return 0; } -extern inline int pcibios_find_class (unsigned int class_code, unsigned short index, unsigned char *bus, unsigned char *dev_fn) +static inline int pcibios_present(void) { return 0; } +static inline int pcibios_find_class (unsigned int class_code, unsigned short index, unsigned char *bus, unsigned char *dev_fn) { return PCIBIOS_DEVICE_NOT_FOUND; } #define _PCI_NOP(o,s,t) \ - extern inline int pcibios_##o##_config_##s## (u8 bus, u8 dfn, u8 where, t val) \ + static inline int pcibios_##o##_config_##s## (u8 bus, u8 dfn, u8 where, t val) \ { return PCIBIOS_FUNC_NOT_SUPPORTED; } \ - extern inline int pci_##o##_config_##s## (struct pci_dev *dev, int where, t val) \ + static inline int pci_##o##_config_##s## (struct pci_dev *dev, int where, t val) \ { return PCIBIOS_FUNC_NOT_SUPPORTED; } #define _PCI_NOP_ALL(o,x) _PCI_NOP(o,byte,u8 x) \ _PCI_NOP(o,word,u16 x) \ @@ -568,27 +568,27 @@ _PCI_NOP_ALL(read, *) _PCI_NOP_ALL(write,) -extern inline struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *from) +static inline struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *from) { return NULL; } -extern inline struct pci_dev *pci_find_class(unsigned int class, const struct pci_dev *from) +static inline struct pci_dev *pci_find_class(unsigned int class, const struct pci_dev *from) { return NULL; } -extern inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn) +static inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn) { return NULL; } -extern inline struct pci_dev *pci_find_subsys(unsigned int vendor, unsigned int device, +static inline struct pci_dev *pci_find_subsys(unsigned int vendor, unsigned int device, unsigned int ss_vendor, unsigned int ss_device, const struct pci_dev *from) { return NULL; } -extern inline void pci_set_master(struct pci_dev *dev) { } -extern inline int pci_enable_device(struct pci_dev *dev) { return -EIO; } -extern inline int pci_module_init(struct pci_driver *drv) { return -ENODEV; } -extern inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;} -extern inline int pci_register_driver(struct pci_driver *drv) { return 0;} -extern inline void pci_unregister_driver(struct pci_driver *drv) { } -extern inline int scsi_to_pci_dma_dir(unsigned char scsi_dir) { return scsi_dir; } -extern inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; } +static inline void pci_set_master(struct pci_dev *dev) { } +static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; } +static inline int pci_module_init(struct pci_driver *drv) { return -ENODEV; } +static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;} +static inline int pci_register_driver(struct pci_driver *drv) { return 0;} +static inline void pci_unregister_driver(struct pci_driver *drv) { } +static inline int scsi_to_pci_dma_dir(unsigned char scsi_dir) { return scsi_dir; } +static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; } #else @@ -598,7 +598,7 @@ * * This MUST stay in a header, as it checks for -DMODULE */ -extern inline int pci_module_init(struct pci_driver *drv) +static inline int pci_module_init(struct pci_driver *drv) { int rc = pci_register_driver (drv); @@ -635,6 +635,20 @@ \ (pci_resource_end((dev),(bar)) - \ pci_resource_start((dev),(bar)) + 1)) + +/* Similar to the helpers above, these manipulate per-pci_dev + * driver-specific data. Currently stored as pci_dev::driver_data, + * a void pointer, but it is not present on older kernels. + */ +static inline void *pci_get_drvdata (struct pci_dev *pdev) +{ + return pdev->driver_data; +} + +static inline void pci_set_drvdata (struct pci_dev *pdev, void *data) +{ + pdev->driver_data = data; +} /* * The world is not perfect and supplies us with broken PCI devices. diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/pmu.h linux/include/linux/pmu.h --- v2.4.0-test8/linux/include/linux/pmu.h Thu Feb 10 17:11:22 2000 +++ linux/include/linux/pmu.h Sun Sep 17 09:48:05 2000 @@ -10,6 +10,7 @@ /* * PMU commands */ +#define PMU_POWER_CTRL0 0x10 /* control power of some devices */ #define PMU_POWER_CTRL 0x11 /* control power of some devices */ #define PMU_ADB_CMD 0x20 /* send ADB packet */ #define PMU_ADB_POLL_OFF 0x21 /* disable ADB auto-poll */ @@ -26,15 +27,25 @@ #define PMU_INT_ACK 0x78 /* read interrupt bits */ #define PMU_SHUTDOWN 0x7e /* turn power off */ #define PMU_SLEEP 0x7f /* put CPU to sleep */ +#define PMU_POWER_EVENTS 0x8f /* Send power-event commands to PMU */ #define PMU_RESET 0xd0 /* reset CPU */ #define PMU_GET_BRIGHTBUTTON 0xd9 /* report brightness up/down pos */ #define PMU_GET_COVER 0xdc /* report cover open/closed */ +#define PMU_SYSTEM_READY 0xdf /* tell PMU we are awake */ + +/* Bits to use with the PMU_POWER_CTRL0 command */ +#define PMU_POW0_ON 0x80 /* OR this to power ON the device */ +#define PMU_POW0_OFF 0x00 /* leave bit 7 to 0 to power it OFF */ +#define PMU_POW0_HARD_DRIVE 0x04 /* Hard drive power (on wallstreet/lombard ?) */ /* Bits to use with the PMU_POWER_CTRL command */ #define PMU_POW_ON 0x80 /* OR this to power ON the device */ #define PMU_POW_OFF 0x00 /* leave bit 7 to 0 to power it OFF */ #define PMU_POW_BACKLIGHT 0x01 /* backlight power */ +#define PMU_POW_CHARGER 0x02 /* battery charger power */ #define PMU_POW_IRLED 0x04 /* IR led power (on wallstreet) */ +#define PMU_POW_MEDIABAY 0x08 /* media bay power (wallstreet/lombard ?) */ + /* Bits in PMU interrupt and interrupt mask bytes */ #define PMU_INT_ADB_AUTO 0x04 /* ADB autopoll, when PMU_INT_ADB */ @@ -54,6 +65,25 @@ PMU_KEYLARGO_BASED, /* Core99 motherboard (PMU99) */ }; +/* PMU PMU_POWER_EVENTS commands */ +enum { + PMU_PWR_GET_POWERUP_EVENTS = 0x00, + PMU_PWR_SET_POWERUP_EVENTS = 0x01, + PMU_PWR_CLR_POWERUP_EVENTS = 0x02, + PMU_PWR_GET_WAKEUP_EVENTS = 0x03, + PMU_PWR_SET_WAKEUP_EVENTS = 0x04, + PMU_PWR_CLR_WAKEUP_EVENTS = 0x05, +}; + +/* Power events wakeup bits */ +enum { + PMU_PWR_WAKEUP_KEY = 0x01, /* Wake on key press */ + PMU_PWR_WAKEUP_AC_INSERT = 0x02, /* Wake on AC adapter plug */ + PMU_PWR_WAKEUP_AC_CHANGE = 0x04, + PMU_PWR_WAKEUP_LID_OPEN = 0x08, + PMU_PWR_WAKEUP_RING = 0x10, +}; + /* * Ioctl commands for the /dev/pmu device */ @@ -61,34 +91,38 @@ /* no param */ #define PMU_IOC_SLEEP _IO('B', 0) -/* out param: u32* backlight value: 0 to 31 */ +/* out param: u32* backlight value: 0 to 15 */ #define PMU_IOC_GET_BACKLIGHT _IOR('B', 1, sizeof(__u32*)) -/* in param: u32 backlight value: 0 to 31 */ +/* in param: u32 backlight value: 0 to 15 */ #define PMU_IOC_SET_BACKLIGHT _IOW('B', 2, sizeof(__u32)) -/* out param: u32* backlight value: 0 to 31 */ +/* out param: u32* PMU model */ #define PMU_IOC_GET_MODEL _IOR('B', 3, sizeof(__u32*)) /* out param: u32* has_adb: 0 or 1 */ #define PMU_IOC_HAS_ADB _IOR('B', 4, sizeof(__u32*)) #ifdef __KERNEL__ -int find_via_pmu(void); -int via_pmu_init(void); +extern int find_via_pmu(void); +extern int via_pmu_start(void); -int pmu_request(struct adb_request *req, +extern int pmu_request(struct adb_request *req, void (*done)(struct adb_request *), int nbytes, ...); -void pmu_poll(void); -void pmu_enable_backlight(int on); -void pmu_set_brightness(int level); +extern void pmu_poll(void); + +/* For use before switching interrupts off for a long time; + * warning: not stackable + */ +extern void pmu_suspend(void); +extern void pmu_resume(void); -void pmu_enable_irled(int on); +extern void pmu_enable_irled(int on); -void pmu_restart(void); -void pmu_shutdown(void); +extern void pmu_restart(void); +extern void pmu_shutdown(void); -int pmu_present(void); -int pmu_get_model(void); +extern int pmu_present(void); +extern int pmu_get_model(void); #ifdef CONFIG_PMAC_PBOOK /* @@ -135,4 +169,4 @@ #endif /* CONFIG_PMAC_PBOOK */ -#endif /* __KERNEL */ +#endif /* __KERNEL__ */ diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/raid/md_compatible.h linux/include/linux/raid/md_compatible.h --- v2.4.0-test8/linux/include/linux/raid/md_compatible.h Thu Feb 10 17:11:22 2000 +++ linux/include/linux/raid/md_compatible.h Sun Sep 17 09:51:57 2000 @@ -77,11 +77,7 @@ /* 011 */ #define md_signal_pending signal_pending -/* 012 */ -extern inline void md_set_global_readahead(int * table) -{ - max_readahead[MD_MAJOR] = table; -} +/* 012 - md_set_global_readahead - nowhere used */ /* 013 */ #define md_mdelay(x) mdelay(x) diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/signal.h linux/include/linux/signal.h --- v2.4.0-test8/linux/include/linux/signal.h Fri Sep 8 13:27:13 2000 +++ linux/include/linux/signal.h Sun Sep 17 09:37:02 2000 @@ -28,7 +28,7 @@ /* We don't use for these because there is no need to be atomic. */ -extern inline void sigaddset(sigset_t *set, int _sig) +static inline void sigaddset(sigset_t *set, int _sig) { unsigned long sig = _sig - 1; if (_NSIG_WORDS == 1) @@ -37,7 +37,7 @@ set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW); } -extern inline void sigdelset(sigset_t *set, int _sig) +static inline void sigdelset(sigset_t *set, int _sig) { unsigned long sig = _sig - 1; if (_NSIG_WORDS == 1) @@ -46,7 +46,7 @@ set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW)); } -extern inline int sigismember(sigset_t *set, int _sig) +static inline int sigismember(sigset_t *set, int _sig) { unsigned long sig = _sig - 1; if (_NSIG_WORDS == 1) @@ -55,7 +55,7 @@ return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); } -extern inline int sigfindinword(unsigned long word) +static inline int sigfindinword(unsigned long word) { return ffz(~word); } @@ -68,7 +68,7 @@ #include #define _SIG_SET_BINOP(name, op) \ -extern inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \ +static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \ { \ unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \ unsigned long i; \ @@ -119,7 +119,7 @@ #undef _sig_nand #define _SIG_SET_OP(name, op) \ -extern inline void name(sigset_t *set) \ +static inline void name(sigset_t *set) \ { \ unsigned long i; \ \ @@ -142,7 +142,7 @@ #undef _SIG_SET_OP #undef _sig_not -extern inline void sigemptyset(sigset_t *set) +static inline void sigemptyset(sigset_t *set) { switch (_NSIG_WORDS) { default: @@ -154,7 +154,7 @@ } } -extern inline void sigfillset(sigset_t *set) +static inline void sigfillset(sigset_t *set) { switch (_NSIG_WORDS) { default: @@ -170,22 +170,22 @@ /* Some extensions for manipulating the low 32 signals in particular. */ -extern inline void sigaddsetmask(sigset_t *set, unsigned long mask) +static inline void sigaddsetmask(sigset_t *set, unsigned long mask) { set->sig[0] |= mask; } -extern inline void sigdelsetmask(sigset_t *set, unsigned long mask) +static inline void sigdelsetmask(sigset_t *set, unsigned long mask) { set->sig[0] &= ~mask; } -extern inline int sigtestsetmask(sigset_t *set, unsigned long mask) +static inline int sigtestsetmask(sigset_t *set, unsigned long mask) { return (set->sig[0] & mask) != 0; } -extern inline void siginitset(sigset_t *set, unsigned long mask) +static inline void siginitset(sigset_t *set, unsigned long mask) { set->sig[0] = mask; switch (_NSIG_WORDS) { @@ -197,7 +197,7 @@ } } -extern inline void siginitsetinv(sigset_t *set, unsigned long mask) +static inline void siginitsetinv(sigset_t *set, unsigned long mask) { set->sig[0] = ~mask; switch (_NSIG_WORDS) { diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/swap.h linux/include/linux/swap.h --- v2.4.0-test8/linux/include/linux/swap.h Thu May 11 15:30:08 2000 +++ linux/include/linux/swap.h Fri Sep 15 19:04:40 2000 @@ -65,13 +65,17 @@ extern int nr_swap_pages; FASTCALL(unsigned int nr_free_pages(void)); +FASTCALL(unsigned int nr_inactive_clean_pages(void)); FASTCALL(unsigned int nr_free_buffer_pages(void)); FASTCALL(unsigned int nr_free_highpages(void)); -extern int nr_lru_pages; +extern int nr_active_pages; +extern int nr_inactive_dirty_pages; extern atomic_t nr_async_pages; extern struct address_space swapper_space; extern atomic_t page_cache_size; extern atomic_t buffermem_pages; +extern spinlock_t pagecache_lock; +extern void __remove_inode_page(struct page *); /* Incomplete types for prototype declarations: */ struct task_struct; @@ -83,9 +87,29 @@ extern int shm_swap(int, int); /* linux/mm/swap.c */ +extern int memory_pressure; +extern void age_page_up(struct page *); +extern void age_page_up_nolock(struct page *); +extern void age_page_down(struct page *); +extern void age_page_down_nolock(struct page *); +extern void deactivate_page(struct page *); +extern void deactivate_page_nolock(struct page *); +extern void activate_page(struct page *); +extern void activate_page_nolock(struct page *); +extern void lru_cache_add(struct page *); +extern void __lru_cache_del(struct page *); +extern void lru_cache_del(struct page *); +extern void recalculate_vm_stats(void); extern void swap_setup(void); /* linux/mm/vmscan.c */ +extern struct page * reclaim_page(zone_t *); +extern wait_queue_head_t kswapd_wait; +extern wait_queue_head_t kreclaimd_wait; +extern int page_launder(int, int); +extern int free_shortage(void); +extern int inactive_shortage(void); +extern void wakeup_kswapd(int); extern int try_to_free_pages(unsigned int gfp_mask); /* linux/mm/page_io.c */ @@ -161,30 +185,102 @@ extern spinlock_t pagemap_lru_lock; /* - * Helper macros for lru_pages handling. + * Page aging defines. + * Since we do exponential decay of the page age, we + * can chose a fairly large maximum. */ -#define lru_cache_add(page) \ -do { \ - spin_lock(&pagemap_lru_lock); \ - list_add(&(page)->lru, &lru_cache); \ - nr_lru_pages++; \ - spin_unlock(&pagemap_lru_lock); \ -} while (0) - -#define __lru_cache_del(page) \ -do { \ - list_del(&(page)->lru); \ - nr_lru_pages--; \ -} while (0) - -#define lru_cache_del(page) \ -do { \ - if (!PageLocked(page)) \ - BUG(); \ - spin_lock(&pagemap_lru_lock); \ - __lru_cache_del(page); \ - spin_unlock(&pagemap_lru_lock); \ -} while (0) +#define PAGE_AGE_START 2 +#define PAGE_AGE_ADV 3 +#define PAGE_AGE_MAX 64 + +/* + * List add/del helper macros. These must be called + * with the pagemap_lru_lock held! + */ +#define DEBUG_ADD_PAGE \ + if (PageActive(page) || PageInactiveDirty(page) || \ + PageInactiveClean(page)) BUG(); + +#define ZERO_PAGE_BUG \ + if (page_count(page) == 0) BUG(); + +#define add_page_to_active_list(page) { \ + DEBUG_ADD_PAGE \ + ZERO_PAGE_BUG \ + SetPageActive(page); \ + list_add(&(page)->lru, &active_list); \ + nr_active_pages++; \ +} + +#define add_page_to_inactive_dirty_list(page) { \ + DEBUG_ADD_PAGE \ + ZERO_PAGE_BUG \ + SetPageInactiveDirty(page); \ + list_add(&(page)->lru, &inactive_dirty_list); \ + nr_inactive_dirty_pages++; \ + page->zone->inactive_dirty_pages++; \ +} + +#define add_page_to_inactive_clean_list(page) { \ + DEBUG_ADD_PAGE \ + ZERO_PAGE_BUG \ + SetPageInactiveClean(page); \ + list_add(&(page)->lru, &page->zone->inactive_clean_list); \ + page->zone->inactive_clean_pages++; \ +} + +#define del_page_from_active_list(page) { \ + list_del(&(page)->lru); \ + ClearPageActive(page); \ + nr_active_pages--; \ + DEBUG_ADD_PAGE \ + ZERO_PAGE_BUG \ +} + +#define del_page_from_inactive_dirty_list(page) { \ + list_del(&(page)->lru); \ + ClearPageInactiveDirty(page); \ + nr_inactive_dirty_pages--; \ + page->zone->inactive_dirty_pages--; \ + DEBUG_ADD_PAGE \ + ZERO_PAGE_BUG \ +} + +#define del_page_from_inactive_clean_list(page) { \ + list_del(&(page)->lru); \ + ClearPageInactiveClean(page); \ + page->zone->inactive_clean_pages--; \ + DEBUG_ADD_PAGE \ + ZERO_PAGE_BUG \ +} + +/* + * In mm/swap.c::recalculate_vm_stats(), we substract + * inactive_target from memory_pressure every second. + * This means that memory_pressure is smoothed over + * 64 (1 << INACTIVE_SHIFT) seconds. + */ +#define INACTIVE_SHIFT 6 +#define inactive_min(a,b) ((a) < (b) ? (a) : (b)) +#define inactive_target inactive_min((memory_pressure >> INACTIVE_SHIFT), \ + (num_physpages / 4)) + +/* + * Ugly ugly ugly HACK to make sure the inactive lists + * don't fill up with unfreeable ramdisk pages. We really + * want to fix the ramdisk driver to mark its pages as + * unfreeable instead of using dirty buffer magic, but the + * next code-change time is when 2.5 is forked... + */ +#ifndef _LINUX_KDEV_T_H +#include +#endif +#ifndef _LINUX_MAJOR_H +#include +#endif + +#define page_ramdisk(page) \ + (page->buffers && (MAJOR(page->buffers->b_dev) == RAMDISK_MAJOR)) extern spinlock_t swaplock; diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/sysctl.h linux/include/linux/sysctl.h --- v2.4.0-test8/linux/include/linux/sysctl.h Wed Aug 23 18:36:39 2000 +++ linux/include/linux/sysctl.h Sun Sep 17 09:48:04 2000 @@ -522,7 +522,8 @@ DEV_CDROM=1, DEV_HWMON=2, DEV_PARPORT=3, - DEV_RAID=4 + DEV_RAID=4, + DEV_MAC_HID=5 }; /* /proc/sys/dev/cdrom */ @@ -571,6 +572,16 @@ /* /proc/sys/dev/parport/parport n/devices/device n */ enum { DEV_PARPORT_DEVICE_TIMESLICE=1, +}; + +/* /proc/sys/dev/mac_hid */ +enum { + DEV_MAC_HID_KEYBOARD_SENDS_LINUX_KEYCODES=1, + DEV_MAC_HID_KEYBOARD_LOCK_KEYCODES=2, + DEV_MAC_HID_MOUSE_BUTTON_EMULATION=3, + DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE=4, + DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE=5, + DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES=6 }; #ifdef __KERNEL__ diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/time.h linux/include/linux/time.h --- v2.4.0-test8/linux/include/linux/time.h Wed Jul 28 10:30:10 1999 +++ linux/include/linux/time.h Fri Sep 15 19:04:40 2000 @@ -45,7 +45,42 @@ value->tv_nsec = (jiffies % HZ) * (1000000000L / HZ); value->tv_sec = jiffies / HZ; } - + + +/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. + * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 + * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. + * + * [For the Julian calendar (which was used in Russia before 1917, + * Britain & colonies before 1752, anywhere else before 1582, + * and is still in use by some communities) leave out the + * -year/100+year/400 terms, and add 10.] + * + * This algorithm was first published by Gauss (I think). + * + * WARNING: this function will overflow on 2106-02-07 06:28:16 on + * machines were long is 32-bit! (However, as time_t is signed, we + * will already get problems at other places on 2038-01-19 03:14:08) + */ +static inline unsigned long +mktime (unsigned int year, unsigned int mon, + unsigned int day, unsigned int hour, + unsigned int min, unsigned int sec) +{ + if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ + mon += 12; /* Puts Feb last since it has leap day */ + year -= 1; + } + + return ((( + (unsigned long) (year/4 - year/100 + year/400 + 367*mon/12 + day) + + year*365 - 719499 + )*24 + hour /* now have hours */ + )*60 + min /* now have minutes */ + )*60 + sec; /* finally seconds */ +} + + struct timeval { time_t tv_sec; /* seconds */ suseconds_t tv_usec; /* microseconds */ diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/usb.h linux/include/linux/usb.h --- v2.4.0-test8/linux/include/linux/usb.h Wed Aug 23 18:36:39 2000 +++ linux/include/linux/usb.h Sun Sep 17 09:37:02 2000 @@ -775,13 +775,13 @@ #else /* CONFIG_USB_DEVICEFS */ -extern inline void usbdevfs_add_bus(struct usb_bus *bus) {} -extern inline void usbdevfs_remove_bus(struct usb_bus *bus) {} -extern inline void usbdevfs_add_device(struct usb_device *dev) {} -extern inline void usbdevfs_remove_device(struct usb_device *dev) {} +static inline void usbdevfs_add_bus(struct usb_bus *bus) {} +static inline void usbdevfs_remove_bus(struct usb_bus *bus) {} +static inline void usbdevfs_add_device(struct usb_device *dev) {} +static inline void usbdevfs_remove_device(struct usb_device *dev) {} -extern inline int usbdevfs_init(void) { return 0; } -extern inline void usbdevfs_cleanup(void) { } +static inline int usbdevfs_init(void) { return 0; } +static inline void usbdevfs_cleanup(void) { } #endif /* CONFIG_USB_DEVICEFS */ diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/vt_buffer.h linux/include/linux/vt_buffer.h --- v2.4.0-test8/linux/include/linux/vt_buffer.h Thu Feb 10 17:11:22 2000 +++ linux/include/linux/vt_buffer.h Sun Sep 17 09:37:02 2000 @@ -32,7 +32,7 @@ #endif #ifndef VT_BUF_HAVE_MEMSETW -extern inline void scr_memsetw(u16 *s, u16 c, unsigned int count) +static inline void scr_memsetw(u16 *s, u16 c, unsigned int count) { count /= 2; while (count--) @@ -41,7 +41,7 @@ #endif #ifndef VT_BUF_HAVE_MEMCPYW -extern inline void scr_memcpyw(u16 *d, const u16 *s, unsigned int count) +static inline void scr_memcpyw(u16 *d, const u16 *s, unsigned int count) { count /= 2; while (count--) @@ -50,7 +50,7 @@ #endif #ifndef VT_BUF_HAVE_MEMMOVEW -extern inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count) +static inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count) { if (d < s) scr_memcpyw(d, s, count); @@ -65,14 +65,14 @@ #endif #ifndef VT_BUF_HAVE_MEMCPYF -extern inline void scr_memcpyw_from(u16 *d, const u16 *s, unsigned int count) +static inline void scr_memcpyw_from(u16 *d, const u16 *s, unsigned int count) { count /= 2; while (count--) *d++ = scr_readw(s++); } -extern inline void scr_memcpyw_to(u16 *d, const u16 *s, unsigned int count) +static inline void scr_memcpyw_to(u16 *d, const u16 *s, unsigned int count) { count /= 2; while (count--) diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/wait.h linux/include/linux/wait.h --- v2.4.0-test8/linux/include/linux/wait.h Fri Sep 8 13:27:13 2000 +++ linux/include/linux/wait.h Sun Sep 17 09:37:02 2000 @@ -158,7 +158,7 @@ return !list_empty(&q->task_list); } -extern inline void __add_wait_queue(wait_queue_head_t *head, wait_queue_t *new) +static inline void __add_wait_queue(wait_queue_head_t *head, wait_queue_t *new) { #if WAITQUEUE_DEBUG if (!head || !new) @@ -174,7 +174,7 @@ /* * Used for wake-one threads: */ -extern inline void __add_wait_queue_tail(wait_queue_head_t *head, +static inline void __add_wait_queue_tail(wait_queue_head_t *head, wait_queue_t *new) { #if WAITQUEUE_DEBUG @@ -188,7 +188,7 @@ list_add_tail(&new->task_list, &head->task_list); } -extern inline void __remove_wait_queue(wait_queue_head_t *head, +static inline void __remove_wait_queue(wait_queue_head_t *head, wait_queue_t *old) { #if WAITQUEUE_DEBUG diff -u --recursive --new-file v2.4.0-test8/linux/include/linux/zftape.h linux/include/linux/zftape.h --- v2.4.0-test8/linux/include/linux/zftape.h Tue Nov 25 14:45:28 1997 +++ linux/include/linux/zftape.h Sun Sep 17 09:37:02 2000 @@ -56,7 +56,7 @@ extern int zft_init(void); -extern inline __s64 zft_div_blksz(__s64 value, __u32 blk_sz) +static inline __s64 zft_div_blksz(__s64 value, __u32 blk_sz) { if (blk_sz == 1) { return value; @@ -66,7 +66,7 @@ } } -extern inline __s64 zft_mul_blksz(__s64 value, __u32 blk_sz) +static inline __s64 zft_mul_blksz(__s64 value, __u32 blk_sz) { if (blk_sz == 1) { return value; diff -u --recursive --new-file v2.4.0-test8/linux/include/net/addrconf.h linux/include/net/addrconf.h --- v2.4.0-test8/linux/include/net/addrconf.h Thu Aug 26 13:05:41 1999 +++ linux/include/net/addrconf.h Sun Sep 17 10:03:43 2000 @@ -87,7 +87,7 @@ extern void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len); -extern __inline__ struct inet6_dev * +static inline struct inet6_dev * __in6_dev_get(struct net_device *dev) { return (struct inet6_dev *)dev->ip6_ptr; @@ -95,7 +95,7 @@ extern rwlock_t addrconf_lock; -extern __inline__ struct inet6_dev * +static inline struct inet6_dev * in6_dev_get(struct net_device *dev) { struct inet6_dev *idev = NULL; @@ -109,7 +109,7 @@ extern void in6_dev_finish_destroy(struct inet6_dev *idev); -extern __inline__ void +static inline void in6_dev_put(struct inet6_dev *idev) { if (atomic_dec_and_test(&idev->refcnt)) @@ -122,7 +122,7 @@ extern void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp); -extern __inline__ void in6_ifa_put(struct inet6_ifaddr *ifp) +static inline void in6_ifa_put(struct inet6_ifaddr *ifp) { if (atomic_dec_and_test(&ifp->refcnt)) inet6_ifa_finish_destroy(ifp); @@ -157,7 +157,7 @@ * compute link-local solicited-node multicast address */ -extern __inline__ void addrconf_addr_solict_mult_old(struct in6_addr *addr, +static inline void addrconf_addr_solict_mult_old(struct in6_addr *addr, struct in6_addr *solicited) { ipv6_addr_set(solicited, @@ -165,7 +165,7 @@ __constant_htonl(0x1), addr->s6_addr32[3]); } -extern __inline__ void addrconf_addr_solict_mult_new(struct in6_addr *addr, +static inline void addrconf_addr_solict_mult_new(struct in6_addr *addr, struct in6_addr *solicited) { ipv6_addr_set(solicited, @@ -175,21 +175,21 @@ } -extern __inline__ void ipv6_addr_all_nodes(struct in6_addr *addr) +static inline void ipv6_addr_all_nodes(struct in6_addr *addr) { ipv6_addr_set(addr, __constant_htonl(0xFF020000), 0, 0, __constant_htonl(0x1)); } -extern __inline__ void ipv6_addr_all_routers(struct in6_addr *addr) +static inline void ipv6_addr_all_routers(struct in6_addr *addr) { ipv6_addr_set(addr, __constant_htonl(0xFF020000), 0, 0, __constant_htonl(0x2)); } -extern __inline__ int ipv6_addr_is_multicast(struct in6_addr *addr) +static inline int ipv6_addr_is_multicast(struct in6_addr *addr) { return (addr->s6_addr32[0] & __constant_htonl(0xFF000000)) == __constant_htonl(0xFF000000); } diff -u --recursive --new-file v2.4.0-test8/linux/include/net/checksum.h linux/include/net/checksum.h --- v2.4.0-test8/linux/include/net/checksum.h Mon Jul 10 16:47:27 2000 +++ linux/include/net/checksum.h Sun Sep 17 10:03:43 2000 @@ -93,7 +93,7 @@ #endif #ifndef _HAVE_ARCH_COPY_AND_CSUM_FROM_USER -extern __inline__ +static inline unsigned int csum_and_copy_from_user (const char *src, char *dst, int len, int sum, int *err_ptr) { diff -u --recursive --new-file v2.4.0-test8/linux/include/net/dn_route.h linux/include/net/dn_route.h --- v2.4.0-test8/linux/include/net/dn_route.h Tue Jan 11 22:31:45 2000 +++ linux/include/net/dn_route.h Sun Sep 17 10:03:43 2000 @@ -91,12 +91,12 @@ #include #include -extern __inline__ void dn_rt_send(struct sk_buff *skb) +static inline void dn_rt_send(struct sk_buff *skb) { dev_queue_xmit(skb); } -extern __inline__ void dn_rt_finish_output(struct sk_buff *skb, char *dst) +static inline void dn_rt_finish_output(struct sk_buff *skb, char *dst) { struct net_device *dev = skb->dev; @@ -110,7 +110,7 @@ kfree_skb(skb); } -extern __inline__ void dn_nsp_send(struct sk_buff *skb) +static inline void dn_nsp_send(struct sk_buff *skb) { struct sock *sk = skb->sk; struct dn_scp *scp = &sk->protinfo.dn; diff -u --recursive --new-file v2.4.0-test8/linux/include/net/x25.h linux/include/net/x25.h --- v2.4.0-test8/linux/include/net/x25.h Wed Apr 26 16:34:09 2000 +++ linux/include/net/x25.h Sun Sep 17 10:03:43 2000 @@ -188,7 +188,7 @@ extern void x25_link_free(void); /* x25_out.c */ -extern void x25_output(struct sock *, struct sk_buff *); +extern int x25_output(struct sock *, struct sk_buff *); extern void x25_kick(struct sock *); extern void x25_enquiry_response(struct sock *); diff -u --recursive --new-file v2.4.0-test8/linux/include/pcmcia/ss.h linux/include/pcmcia/ss.h --- v2.4.0-test8/linux/include/pcmcia/ss.h Fri Sep 8 13:27:13 2000 +++ linux/include/pcmcia/ss.h Fri Sep 15 16:31:09 2000 @@ -82,6 +82,7 @@ #define SS_DMA_MODE 0x0080 #define SS_SPKR_ENA 0x0100 #define SS_OUTPUT_ENA 0x0200 +#define SS_DEBOUNCED 0x0400 /* Tell driver that the debounce delay has ended */ /* Flags for I/O port and memory windows */ #define MAP_ACTIVE 0x01 diff -u --recursive --new-file v2.4.0-test8/linux/ipc/shm.c linux/ipc/shm.c --- v2.4.0-test8/linux/ipc/shm.c Fri Sep 8 13:27:13 2000 +++ linux/ipc/shm.c Fri Sep 15 16:51:21 2000 @@ -1522,7 +1522,7 @@ } /* - * Goes through counter = (shm_rss / (prio + 1)) present shm pages. + * Goes through counter = (shm_rss >> prio) present shm pages. */ static unsigned long swap_id; /* currently being swapped */ static unsigned long swap_idx; /* next to swap */ @@ -1537,7 +1537,7 @@ struct page * page_map; zshm_swap(prio, gfp_mask); - counter = shm_rss / (prio + 1); + counter = shm_rss >> prio; if (!counter) return 0; if (shm_swap_preop(&swap_entry)) @@ -1863,7 +1863,7 @@ int counter; struct page * page_map; - counter = zshm_rss / (prio + 1); + counter = zshm_rss >> prio; if (!counter) return; next: diff -u --recursive --new-file v2.4.0-test8/linux/kernel/exit.c linux/kernel/exit.c --- v2.4.0-test8/linux/kernel/exit.c Fri Sep 8 13:27:13 2000 +++ linux/kernel/exit.c Sun Sep 17 09:51:57 2000 @@ -229,6 +229,7 @@ { __exit_files(tsk); } + static inline void __put_fs_struct(struct fs_struct *fs) { /* No need to hold fs->lock if we are killing it */ diff -u --recursive --new-file v2.4.0-test8/linux/kernel/ksyms.c linux/kernel/ksyms.c --- v2.4.0-test8/linux/kernel/ksyms.c Fri Sep 8 13:27:13 2000 +++ linux/kernel/ksyms.c Sun Sep 17 09:45:05 2000 @@ -361,8 +361,6 @@ #if !defined(CONFIG_ARCH_S390) EXPORT_SYMBOL(probe_irq_on); EXPORT_SYMBOL(probe_irq_off); -EXPORT_SYMBOL(autoirq_setup); -EXPORT_SYMBOL(autoirq_report); #endif #ifdef CONFIG_SMP diff -u --recursive --new-file v2.4.0-test8/linux/kernel/signal.c linux/kernel/signal.c --- v2.4.0-test8/linux/kernel/signal.c Fri Sep 8 13:27:13 2000 +++ linux/kernel/signal.c Mon Sep 11 08:41:08 2000 @@ -41,7 +41,7 @@ __alignof__(struct sigqueue), SIG_SLAB_DEBUG, NULL, NULL); if (!sigqueue_cachep) - panic("signals_init(): cannot create sigueue SLAB cache"); + panic("signals_init(): cannot create sigqueue SLAB cache"); } diff -u --recursive --new-file v2.4.0-test8/linux/kernel/sys.c linux/kernel/sys.c --- v2.4.0-test8/linux/kernel/sys.c Wed Aug 9 19:19:51 2000 +++ linux/kernel/sys.c Mon Sep 11 08:48:53 2000 @@ -123,18 +123,15 @@ int ret=NOTIFY_DONE; struct notifier_block *nb = *n; - read_lock(¬ifier_lock); while(nb) { ret=nb->notifier_call(nb,val,v); if(ret&NOTIFY_STOP_MASK) { - read_unlock(¬ifier_lock); return ret; } nb=nb->next; } - read_unlock(¬ifier_lock); return ret; } diff -u --recursive --new-file v2.4.0-test8/linux/kernel/sysctl.c linux/kernel/sysctl.c --- v2.4.0-test8/linux/kernel/sysctl.c Wed Aug 9 19:19:51 2000 +++ linux/kernel/sysctl.c Fri Sep 15 16:51:21 2000 @@ -235,7 +235,7 @@ static ctl_table vm_table[] = { {VM_FREEPG, "freepages", - &freepages, sizeof(freepages_t), 0644, NULL, &proc_dointvec}, + &freepages, sizeof(freepages_t), 0444, NULL, &proc_dointvec}, {VM_BDFLUSH, "bdflush", &bdf_prm, 9*sizeof(int), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec, NULL, &bdflush_min, &bdflush_max}, diff -u --recursive --new-file v2.4.0-test8/linux/mm/filemap.c linux/mm/filemap.c --- v2.4.0-test8/linux/mm/filemap.c Fri Sep 8 13:27:13 2000 +++ linux/mm/filemap.c Fri Sep 15 16:51:21 2000 @@ -46,7 +46,7 @@ struct page **page_hash_table; struct list_head lru_cache; -static spinlock_t pagecache_lock = SPIN_LOCK_UNLOCKED; +spinlock_t pagecache_lock = SPIN_LOCK_UNLOCKED; /* * NOTE: to avoid deadlocking you must never acquire the pagecache_lock with * the pagemap_lru_lock held. @@ -92,7 +92,7 @@ * sure the page is locked and that nobody else uses it - or that usage * is safe. */ -static inline void __remove_inode_page(struct page *page) +void __remove_inode_page(struct page *page) { remove_page_from_inode_queue(page); remove_page_from_hash_queue(page); @@ -235,141 +235,6 @@ spin_unlock(&pagecache_lock); } -/* - * nr_dirty represents the number of dirty pages that we will write async - * before doing sync writes. We can only do sync writes if we can - * wait for IO (__GFP_IO set). - */ -int shrink_mmap(int priority, int gfp_mask) -{ - int ret = 0, count, nr_dirty; - struct list_head * page_lru; - struct page * page = NULL; - - count = nr_lru_pages / (priority + 1); - nr_dirty = priority; - - /* we need pagemap_lru_lock for list_del() ... subtle code below */ - spin_lock(&pagemap_lru_lock); - while (count > 0 && (page_lru = lru_cache.prev) != &lru_cache) { - page = list_entry(page_lru, struct page, lru); - list_del(page_lru); - - if (PageTestandClearReferenced(page)) - goto dispose_continue; - - count--; - /* - * Avoid unscalable SMP locking for pages we can - * immediate tell are untouchable.. - */ - if (!page->buffers && page_count(page) > 1) - goto dispose_continue; - - if (TryLockPage(page)) - goto dispose_continue; - - /* Release the pagemap_lru lock even if the page is not yet - queued in any lru queue since we have just locked down - the page so nobody else may SMP race with us running - a lru_cache_del() (lru_cache_del() always run with the - page locked down ;). */ - spin_unlock(&pagemap_lru_lock); - - /* avoid freeing the page while it's locked */ - page_cache_get(page); - - /* - * Is it a buffer page? Try to clean it up regardless - * of zone - it's old. - */ - if (page->buffers) { - int wait; - /* - * 0 - free it if can do so without IO - * 1 - start write-out of dirty buffers - * 2 - wait for locked buffers - */ - wait = (gfp_mask & __GFP_IO) ? (nr_dirty-- < 0) ? 2 : 1 : 0; - if (!try_to_free_buffers(page, wait)) - goto unlock_continue; - /* page was locked, inode can't go away under us */ - if (!page->mapping) { - atomic_dec(&buffermem_pages); - goto made_buffer_progress; - } - } - - /* Take the pagecache_lock spinlock held to avoid - other tasks to notice the page while we are looking at its - page count. If it's a pagecache-page we'll free it - in one atomic transaction after checking its page count. */ - spin_lock(&pagecache_lock); - - /* - * We can't free pages unless there's just one user - * (count == 2 because we added one ourselves above). - */ - if (page_count(page) != 2) - goto cache_unlock_continue; - - /* - * Is it a page swap page? If so, we want to - * drop it if it is no longer used, even if it - * were to be marked referenced.. - */ - if (PageSwapCache(page)) { - spin_unlock(&pagecache_lock); - __delete_from_swap_cache(page); - goto made_inode_progress; - } - - /* - * Page is from a zone we don't care about. - * Don't drop page cache entries in vain. - */ - if (page->zone->free_pages > page->zone->pages_high) - goto cache_unlock_continue; - - /* is it a page-cache page? */ - if (page->mapping) { - if (!PageDirty(page) && !pgcache_under_min()) { - __remove_inode_page(page); - spin_unlock(&pagecache_lock); - goto made_inode_progress; - } - goto cache_unlock_continue; - } - - printk(KERN_ERR "shrink_mmap: unknown LRU page!\n"); - -cache_unlock_continue: - spin_unlock(&pagecache_lock); -unlock_continue: - spin_lock(&pagemap_lru_lock); - UnlockPage(page); - page_cache_release(page); -dispose_continue: - list_add(page_lru, &lru_cache); - } - goto out; - -made_inode_progress: - page_cache_release(page); -made_buffer_progress: - UnlockPage(page); - page_cache_release(page); - ret = 1; - spin_lock(&pagemap_lru_lock); - /* nr_lru_pages needs the spinlock */ - nr_lru_pages--; - -out: - spin_unlock(&pagemap_lru_lock); - - return ret; -} - static inline struct page * __find_page_nolock(struct address_space *mapping, unsigned long offset, struct page *page) { goto inside; @@ -384,7 +249,14 @@ if (page->index == offset) break; } - SetPageReferenced(page); + /* + * Touching the page may move it to the active list. + * If we end up with too few inactive pages, we wake + * up kswapd. + */ + age_page_up(page); + if (inactive_shortage() > (inactive_target * 3) / 4) + wakeup_kswapd(0); not_found: return page; } @@ -616,6 +488,7 @@ set_task_state(tsk, TASK_UNINTERRUPTIBLE); if (!PageLocked(page)) break; + run_task_queue(&tq_disk); schedule(); } while (PageLocked(page)); tsk->state = TASK_RUNNING; @@ -739,6 +612,53 @@ #endif /* + * We combine this with read-ahead to deactivate pages when we + * think there's sequential IO going on. Note that this is + * harmless since we don't actually evict the pages from memory + * but just move them to the inactive list. + * + * TODO: + * - make the readahead code smarter + * - move readahead to the VMA level so we can do the same + * trick with mmap() + * + * Rik van Riel, 2000 + */ +static void drop_behind(struct file * file, unsigned long index) +{ + struct inode *inode = file->f_dentry->d_inode; + struct address_space *mapping = inode->i_mapping; + struct page **hash; + struct page *page; + unsigned long start; + + /* Nothing to drop-behind if we're on the first page. */ + if (!index) + return; + + if (index > file->f_rawin) + start = index - file->f_rawin; + else + start = 0; + + /* + * Go backwards from index-1 and drop all pages in the + * readahead window. Since the readahead window may have + * been increased since the last time we were called, we + * stop when the page isn't there. + */ + spin_lock(&pagecache_lock); + while (--index >= start) { + hash = page_hash(mapping, index); + page = __find_page_nolock(mapping, index, *hash); + if (!page) + break; + deactivate_page(page); + } + spin_unlock(&pagecache_lock); +} + +/* * Read-ahead profiling information * -------------------------------- * Every PROFILE_MAXREADCOUNT, the following information is written @@ -961,6 +881,12 @@ if (filp->f_ramax > max_readahead) filp->f_ramax = max_readahead; + /* + * Move the pages that have already been passed + * to the inactive list. + */ + drop_behind(filp, index); + #ifdef PROFILE_READAHEAD profile_readahead((reada_ok == 2), filp); #endif @@ -2527,6 +2453,7 @@ unlock: /* Mark it unlocked again and drop the page.. */ UnlockPage(page); + deactivate_page(page); page_cache_release(page); if (status < 0) diff -u --recursive --new-file v2.4.0-test8/linux/mm/memory.c linux/mm/memory.c --- v2.4.0-test8/linux/mm/memory.c Fri Sep 8 13:27:13 2000 +++ linux/mm/memory.c Fri Sep 15 16:51:21 2000 @@ -67,7 +67,7 @@ copy_user_highpage(to, from, address); } -mem_map_t * mem_map = NULL; +mem_map_t * mem_map; /* * Note: this doesn't free the actual pages themselves. That @@ -1040,7 +1040,8 @@ num = valid_swaphandles(entry, &offset); for (i = 0; i < num; offset++, i++) { /* Don't block on I/O for read-ahead */ - if (atomic_read(&nr_async_pages) >= pager_daemon.swap_cluster) { + if (atomic_read(&nr_async_pages) >= pager_daemon.swap_cluster + * (1 << page_cluster)) { while (i++ < num) swap_free(SWP_ENTRY(SWP_TYPE(entry), offset++)); break; @@ -1239,7 +1240,7 @@ pgd = pgd_offset(mm, address); pmd = pmd_alloc(pgd, address); - + if (pmd) { pte_t * pte = pte_alloc(pmd, address); if (pte) diff -u --recursive --new-file v2.4.0-test8/linux/mm/page_alloc.c linux/mm/page_alloc.c --- v2.4.0-test8/linux/mm/page_alloc.c Fri Sep 8 13:27:13 2000 +++ linux/mm/page_alloc.c Fri Sep 15 16:51:21 2000 @@ -25,7 +25,8 @@ #endif int nr_swap_pages; -int nr_lru_pages; +int nr_active_pages; +int nr_inactive_dirty_pages; pg_data_t *pgdat_list; static char *zone_names[MAX_NR_ZONES] = { "DMA", "Normal", "HighMem" }; @@ -33,6 +34,8 @@ static int zone_balance_min[MAX_NR_ZONES] = { 10 , 10, 10, }; static int zone_balance_max[MAX_NR_ZONES] = { 255 , 255, 255, }; +struct list_head active_list; +struct list_head inactive_dirty_list; /* * Free_page() adds the page to the free lists. This is optimized for * fast normal cases (no error jumps taken normally). @@ -96,7 +99,16 @@ BUG(); if (PageDirty(page)) BUG(); + if (PageActive(page)) + BUG(); + if (PageInactiveDirty(page)) + BUG(); + if (PageInactiveClean(page)) + BUG(); + page->flags &= ~(1<age = PAGE_AGE_START; + zone = page->zone; mask = (~0UL) << order; @@ -142,10 +154,13 @@ spin_unlock_irqrestore(&zone->lock, flags); - if (zone->free_pages > zone->pages_high) { - zone->zone_wake_kswapd = 0; - zone->low_on_memory = 0; - } + /* + * We don't want to protect this variable from race conditions + * since it's nothing important, but we do want to make sure + * it never gets negative. + */ + if (memory_pressure > NR_CPUS) + memory_pressure--; } #define MARK_USED(index, order, area) \ @@ -203,6 +218,7 @@ set_page_count(page, 1); if (BAD_RANGE(zone,page)) BUG(); + DEBUG_ADD_PAGE return page; } curr_order++; @@ -213,13 +229,77 @@ return NULL; } +#define PAGES_MIN 0 +#define PAGES_LOW 1 +#define PAGES_HIGH 2 + +/* + * This function does the dirty work for __alloc_pages + * and is separated out to keep the code size smaller. + * (suggested by Davem at 1:30 AM, typed by Rik at 6 AM) + */ +static struct page * __alloc_pages_limit(zonelist_t *zonelist, + unsigned long order, int limit, int direct_reclaim) +{ + zone_t **zone = zonelist->zones; + + for (;;) { + zone_t *z = *(zone++); + unsigned long water_mark; + + if (!z) + break; + if (!z->size) + BUG(); + + /* + * We allocate if the number of free + inactive_clean + * pages is above the watermark. + */ + switch (limit) { + default: + case 0: + water_mark = z->pages_min; + break; + case 1: + water_mark = z->pages_low; + break; + case 2: + water_mark = z->pages_high; + } + + if (z->free_pages + z->inactive_clean_pages > water_mark) { + struct page *page = NULL; + /* If possible, reclaim a page directly. */ + if (direct_reclaim && z->free_pages < z->pages_min + 8) + page = reclaim_page(z); + /* If that fails, fall back to rmqueue. */ + if (!page) + page = rmqueue(z, order); + if (page) + return page; + } + } + + /* Found nothing. */ + return NULL; +} + + /* * This is the 'heart' of the zoned buddy allocator: */ struct page * __alloc_pages(zonelist_t *zonelist, unsigned long order) { zone_t **zone; - extern wait_queue_head_t kswapd_wait; + int direct_reclaim = 0; + unsigned int gfp_mask = zonelist->gfp_mask; + struct page * page = NULL; + + /* + * Allocations put pressure on the VM subsystem. + */ + memory_pressure++; /* * (If anyone calls gfp from interrupts nonatomically then it @@ -229,6 +309,27 @@ * in a higher zone fails. */ + /* + * Can we take pages directly from the inactive_clean + * list? + */ + if (order == 0 && (gfp_mask & __GFP_WAIT) && + !(current->flags & PF_MEMALLOC)) + direct_reclaim = 1; + + /* + * Are we low on inactive pages? + */ + if (inactive_shortage() > inactive_target / 2 && free_shortage()) + wakeup_kswapd(0); + +try_again: + /* + * First, see if we have any zones with lots of free memory. + * + * We allocate free memory first because it doesn't contain + * any data ... DUH! + */ zone = zonelist->zones; for (;;) { zone_t *z = *(zone++); @@ -237,82 +338,143 @@ if (!z->size) BUG(); - /* Are we supposed to free memory? Don't make it worse.. */ - if (!z->zone_wake_kswapd) { - struct page *page = rmqueue(z, order); - if (z->free_pages < z->pages_low) { - z->zone_wake_kswapd = 1; - if (waitqueue_active(&kswapd_wait)) - wake_up_interruptible(&kswapd_wait); - } + if (z->free_pages > z->pages_low) { + page = rmqueue(z, order); if (page) return page; + } else if (z->free_pages < z->pages_min && + waitqueue_active(&kreclaimd_wait)) { + wake_up_interruptible(&kreclaimd_wait); } } - /* Three possibilities to get here - * - Previous alloc_pages resulted in last zone set to have - * zone_wake_kswapd and start it. kswapd has not been able - * to release enough pages so that one zone does not have - * zone_wake_kswapd set. - * - Different sets of zones (zonelist) - * previous did not have all zones with zone_wake_kswapd but - * this one has... should kswapd be woken up? it will run once. - * - SMP race, kswapd went to sleep slightly after it as running - * in 'if (waitqueue_active(...))' above. - * + anyway the test is very cheap to do... + /* + * Try to allocate a page from a zone with a HIGH + * amount of free + inactive_clean pages. + * + * If there is a lot of activity, inactive_target + * will be high and we'll have a good chance of + * finding a page using the HIGH limit. */ - if (waitqueue_active(&kswapd_wait)) - wake_up_interruptible(&kswapd_wait); + page = __alloc_pages_limit(zonelist, order, PAGES_HIGH, direct_reclaim); + if (page) + return page; /* - * Ok, we don't have any zones that don't need some - * balancing.. See if we have any that aren't critical.. + * Then try to allocate a page from a zone with more + * than zone->pages_low free + inactive_clean pages. + * + * When the working set is very large and VM activity + * is low, we're most likely to have our allocation + * succeed here. */ - zone = zonelist->zones; - for (;;) { - zone_t *z = *(zone++); - if (!z) - break; - if (!z->low_on_memory) { - struct page *page = rmqueue(z, order); - if (z->free_pages < z->pages_min) - z->low_on_memory = 1; - if (page) - return page; - } - } + page = __alloc_pages_limit(zonelist, order, PAGES_LOW, direct_reclaim); + if (page) + return page; + + /* + * OK, none of the zones on our zonelist has lots + * of pages free. + * + * We wake up kswapd, in the hope that kswapd will + * resolve this situation before memory gets tight. + */ + wakeup_kswapd(0); /* - * Uhhuh. All the zones have been critical, which means that - * we'd better do some synchronous swap-out. kswapd has not - * been able to cope.. + * After waking up kswapd, we try to allocate a page + * from any zone which isn't critical yet. + * + * Kswapd should, in most situations, bring the situation + * back to normal in no time. + */ + page = __alloc_pages_limit(zonelist, order, PAGES_MIN, direct_reclaim); + if (page) + return page; + + /* + * Damn, we didn't succeed. + * + * This can be due to 2 reasons: + * - we're doing a higher-order allocation + * --> move pages to the free list until we succeed + * - we're /really/ tight on memory + * --> wait on the kswapd waitqueue until memory is freed */ if (!(current->flags & PF_MEMALLOC)) { - int gfp_mask = zonelist->gfp_mask; - if (!try_to_free_pages(gfp_mask)) { - if (!(gfp_mask & __GFP_HIGH)) - goto fail; + /* + * Are we dealing with a higher order allocation? + * + * Move pages from the inactive_clean to the free list + * in the hope of creating a large, physically contiguous + * piece of free memory. + */ + if (order > 0 && (gfp_mask & __GFP_WAIT)) { + zone = zonelist->zones; + /* First, clean some dirty pages. */ + page_launder(gfp_mask, 1); + for (;;) { + zone_t *z = *(zone++); + if (!z) + break; + if (!z->size) + continue; + while (z->inactive_clean_pages) { + struct page * page; + /* Move one page to the free list. */ + page = reclaim_page(z); + if (!page) + break; + __free_page(page); + /* Try if the allocation succeeds. */ + page = rmqueue(z, order); + if (page) + return page; + } + } + } + /* + * When we arrive here, we are really tight on memory. + * + * We wake up kswapd and sleep until kswapd wakes us + * up again. After that we loop back to the start. + * + * We have to do this because something else might eat + * the memory kswapd frees for us (interrupts, other + * processes, etc). + */ + if (gfp_mask & __GFP_WAIT) { + wakeup_kswapd(1); + goto try_again; } } /* * Final phase: allocate anything we can! + * + * This is basically reserved for PF_MEMALLOC and + * GFP_ATOMIC allocations... */ zone = zonelist->zones; for (;;) { - struct page *page; - zone_t *z = *(zone++); + struct page * page = NULL; if (!z) break; - page = rmqueue(z, order); + if (!z->size) + BUG(); + + if (direct_reclaim) + page = reclaim_page(z); + if (!page) + page = rmqueue(z, order); if (page) return page; } -fail: /* No luck.. */ + if (!order) + show_free_areas(); return NULL; } @@ -377,18 +539,39 @@ } /* - * Amount of free RAM allocatable as buffer memory: + * Total amount of inactive_clean (allocatable) RAM: */ -unsigned int nr_free_buffer_pages (void) +unsigned int nr_inactive_clean_pages (void) { unsigned int sum; zone_t *zone; int i; - sum = nr_lru_pages / 3; + sum = 0; for (i = 0; i < NUMNODES; i++) - for (zone = NODE_DATA(i)->node_zones; zone <= NODE_DATA(i)->node_zones+ZONE_NORMAL; zone++) - sum += zone->free_pages; + for (zone = NODE_DATA(i)->node_zones; zone < NODE_DATA(i)->node_zones + MAX_NR_ZONES; zone++) + sum += zone->inactive_clean_pages; + return sum; +} + +/* + * Amount of free RAM allocatable as buffer memory: + */ +unsigned int nr_free_buffer_pages (void) +{ + unsigned int sum; + + sum = nr_free_pages(); + sum += nr_inactive_clean_pages(); + sum += nr_inactive_dirty_pages; + /* + * We don't want dirty page writebehind to put too + * much pressure on the working set, but we want it + * to be possible to have some dirty pages in the + * working set without upsetting the writebehind logic. + */ + sum += nr_active_pages >> 4; + return sum; } @@ -418,9 +601,11 @@ nr_free_pages() << (PAGE_SHIFT-10), nr_free_highpages() << (PAGE_SHIFT-10)); - printk("( Free: %d, lru_cache: %d (%d %d %d) )\n", + printk("( Active: %d, inactive_dirty: %d, inactive_clean: %d, free: %d (%d %d %d) )\n", + nr_active_pages, + nr_inactive_dirty_pages, + nr_inactive_clean_pages(), nr_free_pages(), - nr_lru_pages, freepages.min, freepages.low, freepages.high); @@ -430,17 +615,6 @@ zone_t *zone = NODE_DATA(nid)->node_zones + type; unsigned long nr, total, flags; - printk(" %c%d%d %s: ", - (zone->free_pages > zone->pages_low - ? (zone->free_pages > zone->pages_high - ? ' ' - : 'H') - : (zone->free_pages > zone->pages_min - ? 'M' - : 'L')), - zone->zone_wake_kswapd, zone->low_on_memory, - zone->name); - total = 0; if (zone->size) { spin_lock_irqsave(&zone->lock, flags); @@ -570,7 +744,8 @@ freepages.min += i; freepages.low += i * 2; freepages.high += i * 3; - memlist_init(&lru_cache); + memlist_init(&active_list); + memlist_init(&inactive_dirty_list); /* * Some architectures (with lots of mem and discontinous memory @@ -618,6 +793,9 @@ zone->lock = SPIN_LOCK_UNLOCKED; zone->zone_pgdat = pgdat; zone->free_pages = 0; + zone->inactive_clean_pages = 0; + zone->inactive_dirty_pages = 0; + memlist_init(&zone->inactive_clean_list); if (!size) continue; @@ -631,8 +809,6 @@ zone->pages_min = mask; zone->pages_low = mask*2; zone->pages_high = mask*3; - zone->low_on_memory = 0; - zone->zone_wake_kswapd = 0; zone->zone_mem_map = mem_map + offset; zone->zone_start_mapnr = offset; zone->zone_start_paddr = zone_start_paddr; diff -u --recursive --new-file v2.4.0-test8/linux/mm/page_io.c linux/mm/page_io.c --- v2.4.0-test8/linux/mm/page_io.c Wed Aug 9 19:19:51 2000 +++ linux/mm/page_io.c Fri Sep 15 16:51:21 2000 @@ -43,7 +43,8 @@ struct inode *swapf = 0; /* Don't allow too many pending pages in flight.. */ - if (atomic_read(&nr_async_pages) > pager_daemon.swap_cluster) + if ((rw == WRITE) && atomic_read(&nr_async_pages) > + pager_daemon.swap_cluster * (1 << page_cluster)) wait = 1; if (rw == READ) { diff -u --recursive --new-file v2.4.0-test8/linux/mm/slab.c linux/mm/slab.c --- v2.4.0-test8/linux/mm/slab.c Wed Aug 23 18:36:39 2000 +++ linux/mm/slab.c Sun Sep 17 09:56:03 2000 @@ -1772,14 +1772,6 @@ /* It's safe to test this without holding the cache-lock. */ if (searchp->flags & SLAB_NO_REAP) goto next; - /* FIXME: is this really a good idea? */ - if (gfp_mask & GFP_DMA) { - if (!(searchp->gfpflags & GFP_DMA)) - goto next; - } else { - if (searchp->gfpflags & GFP_DMA) - goto next; - } spin_lock_irq(&searchp->spinlock); if (searchp->growing) goto next_unlock; diff -u --recursive --new-file v2.4.0-test8/linux/mm/swap.c linux/mm/swap.c --- v2.4.0-test8/linux/mm/swap.c Tue Dec 7 09:32:52 1999 +++ linux/mm/swap.c Sun Sep 17 09:56:02 2000 @@ -40,7 +40,18 @@ }; /* How many pages do we try to swap or page in/out together? */ -int page_cluster = 4; /* Default value modified in swap_setup() */ +int page_cluster; + +/* + * This variable contains the amount of page steals the system + * is doing, averaged over a minute. We use this to determine how + * many inactive pages we should have. + * + * In reclaim_page and __alloc_pages: memory_pressure++ + * In __free_pages_ok: memory_pressure-- + * In recalculate_vm_stats the value is decayed (once a second) + */ +int memory_pressure; /* We track the number of pages currently being asynchronously swapped out, so that we don't try to swap TOO many pages out at once */ @@ -61,13 +72,244 @@ pager_daemon_t pager_daemon = { 512, /* base number for calculating the number of tries */ SWAP_CLUSTER_MAX, /* minimum number of tries */ - SWAP_CLUSTER_MAX, /* do swap I/O in clusters of this size */ + 8, /* do swap I/O in clusters of this size */ }; +/** + * age_page_{up,down} - page aging helper functions + * @page - the page we want to age + * @nolock - are we already holding the pagelist_lru_lock? + * + * If the page is on one of the lists (active, inactive_dirty or + * inactive_clean), we will grab the pagelist_lru_lock as needed. + * If you're already holding the lock, call this function with the + * nolock argument non-zero. + */ +void age_page_up_nolock(struct page * page) +{ + /* + * We're dealing with an inactive page, move the page + * to the active list. + */ + if (!page->age) + activate_page_nolock(page); + + /* The actual page aging bit */ + page->age += PAGE_AGE_ADV; + if (page->age > PAGE_AGE_MAX) + page->age = PAGE_AGE_MAX; +} + +void age_page_down_nolock(struct page * page) +{ + /* The actual page aging bit */ + page->age /= 2; + + /* + * The page is now an old page. Move to the inactive + * list (if possible ... see below). + */ + if (!page->age) + deactivate_page_nolock(page); +} + +void age_page_up(struct page * page) +{ + /* + * We're dealing with an inactive page, move the page + * to the active list. + */ + if (!page->age) + activate_page(page); + + /* The actual page aging bit */ + page->age += PAGE_AGE_ADV; + if (page->age > PAGE_AGE_MAX) + page->age = PAGE_AGE_MAX; +} + +void age_page_down(struct page * page) +{ + /* The actual page aging bit */ + page->age /= 2; + + /* + * The page is now an old page. Move to the inactive + * list (if possible ... see below). + */ + if (!page->age) + deactivate_page(page); +} + + +/** + * (de)activate_page - move pages from/to active and inactive lists + * @page: the page we want to move + * @nolock - are we already holding the pagemap_lru_lock? + * + * Deactivate_page will move an active page to the right + * inactive list, while activate_page will move a page back + * from one of the inactive lists to the active list. If + * called on a page which is not on any of the lists, the + * page is left alone. + */ +void deactivate_page_nolock(struct page * page) +{ + page->age = 0; + + /* + * Don't touch it if it's not on the active list. + * (some pages aren't on any list at all) + */ + if (PageActive(page) && (page_count(page) <= 2 || page->buffers) && + !page_ramdisk(page)) { + + /* + * We can move the page to the inactive_dirty list + * if we know there is backing store available. + * + * We also move pages here that we cannot free yet, + * but may be able to free later - because most likely + * we're holding an extra reference on the page which + * will be dropped right after deactivate_page(). + */ + if (page->buffers || page_count(page) == 2) { + del_page_from_active_list(page); + add_page_to_inactive_dirty_list(page); + /* + * If the page is clean and immediately reusable, + * we can move it to the inactive_clean list. + */ + } else if (page->mapping && !PageDirty(page) && + !PageLocked(page)) { + del_page_from_active_list(page); + add_page_to_inactive_clean_list(page); + } + /* + * OK, we cannot free the page. Leave it alone. + */ + } +} + +void deactivate_page(struct page * page) +{ + spin_lock(&pagemap_lru_lock); + deactivate_page_nolock(page); + spin_unlock(&pagemap_lru_lock); +} + /* - * Perform any setup for the swap system + * Move an inactive page to the active list. + */ +void activate_page_nolock(struct page * page) +{ + if (PageInactiveDirty(page)) { + del_page_from_inactive_dirty_list(page); + add_page_to_active_list(page); + } else if (PageInactiveClean(page)) { + del_page_from_inactive_clean_list(page); + add_page_to_active_list(page); + } else { + /* + * The page was not on any list, so we take care + * not to do anything. + */ + } +} + +void activate_page(struct page * page) +{ + spin_lock(&pagemap_lru_lock); + activate_page_nolock(page); + spin_unlock(&pagemap_lru_lock); +} + +/** + * lru_cache_add: add a page to the page lists + * @page: the page to add + */ +void lru_cache_add(struct page * page) +{ + spin_lock(&pagemap_lru_lock); + if (!PageLocked(page)) + BUG(); + /* + * Heisenbug Compensator(tm) + * This bug shouldn't trigger, but for unknown reasons it + * sometimes does. If there are no signs of list corruption, + * we ignore the problem. Else we BUG()... + */ + if (PageActive(page) || PageInactiveDirty(page) || + PageInactiveClean(page)) { + struct list_head * page_lru = &page->lru; + if (page_lru->next->prev != page_lru) { + printk("VM: lru_cache_add, bit or list corruption..\n"); + BUG(); + } + printk("VM: lru_cache_add, page already in list!\n"); + goto page_already_on_list; + } + add_page_to_active_list(page); + /* This should be relatively rare */ + if (!page->age) + deactivate_page_nolock(page); +page_already_on_list: + spin_unlock(&pagemap_lru_lock); +} + +/** + * __lru_cache_del: remove a page from the page lists + * @page: the page to add + * + * This function is for when the caller already holds + * the pagemap_lru_lock. */ +void __lru_cache_del(struct page * page) +{ + if (PageActive(page)) { + del_page_from_active_list(page); + } else if (PageInactiveDirty(page)) { + del_page_from_inactive_dirty_list(page); + } else if (PageInactiveClean(page)) { + del_page_from_inactive_clean_list(page); + } else { + printk("VM: __lru_cache_del, found unknown page ?!\n"); + } + DEBUG_ADD_PAGE +} +/** + * lru_cache_del: remove a page from the page lists + * @page: the page to remove + */ +void lru_cache_del(struct page * page) +{ + if (!PageLocked(page)) + BUG(); + spin_lock(&pagemap_lru_lock); + __lru_cache_del(page); + spin_unlock(&pagemap_lru_lock); +} + +/** + * recalculate_vm_stats - recalculate VM statistics + * + * This function should be called once a second to recalculate + * some useful statistics the VM subsystem uses to determine + * its behaviour. + */ +void recalculate_vm_stats(void) +{ + /* + * Substract one second worth of memory_pressure from + * memory_pressure. + */ + memory_pressure -= (memory_pressure >> INACTIVE_SHIFT); +} + +/* + * Perform any setup for the swap system + */ void __init swap_setup(void) { /* Use a smaller cluster for memory <16MB or <32MB */ diff -u --recursive --new-file v2.4.0-test8/linux/mm/swap_state.c linux/mm/swap_state.c --- v2.4.0-test8/linux/mm/swap_state.c Wed Aug 9 19:19:51 2000 +++ linux/mm/swap_state.c Fri Sep 15 16:51:21 2000 @@ -73,7 +73,7 @@ PAGE_BUG(page); PageClearSwapCache(page); - remove_inode_page(page); + __remove_inode_page(page); } /* @@ -105,7 +105,9 @@ if (block_flushpage(page, 0)) lru_cache_del(page); + spin_lock(&pagecache_lock); __delete_from_swap_cache(page); + spin_unlock(&pagecache_lock); page_cache_release(page); } diff -u --recursive --new-file v2.4.0-test8/linux/mm/vmscan.c linux/mm/vmscan.c --- v2.4.0-test8/linux/mm/vmscan.c Fri Sep 8 13:27:13 2000 +++ linux/mm/vmscan.c Sun Sep 17 09:56:02 2000 @@ -9,6 +9,7 @@ * to bring the system back to freepages.high: 2.4.97, Rik van Riel. * Version: $Id: vmscan.c,v 1.5 1998/02/23 22:14:28 sct Exp $ * Zone aware kswapd started 02/00, Kanoj Sarcar (kanoj@sgi.com). + * Multiqueue VM started 5.8.00, Rik van Riel. */ #include @@ -40,6 +41,7 @@ swp_entry_t entry; struct page * page; int (*swapout)(struct page *, struct file *); + int onlist; pte = *page_table; if (!pte_present(pte)) @@ -51,16 +53,36 @@ if (mm->swap_cnt) mm->swap_cnt--; + onlist = PageActive(page); /* Don't look at this pte if it's been accessed recently. */ if (pte_young(pte)) { - /* - * Transfer the "accessed" bit from the page - * tables to the global page map. - */ set_pte(page_table, pte_mkold(pte)); - SetPageReferenced(page); + if (onlist) { + /* + * Transfer the "accessed" bit from the page + * tables to the global page map. Page aging + * will be done by refill_inactive_scan(). + */ + SetPageReferenced(page); + } else { + /* + * The page is not on the active list, so + * we have to do the page aging ourselves. + */ + age_page_up(page); + } goto out_failed; } + if (!onlist) + age_page_down(page); + + /* + * If the page is in active use by us, or if the page + * is in active use by others, don't unmap it or + * (worse) start unneeded IO. + */ + if (page->age > 0) + goto out_failed; if (TryLockPage(page)) goto out_failed; @@ -81,6 +103,7 @@ UnlockPage(page); vma->vm_mm->rss--; flush_tlb_page(vma, address); + deactivate_page(page); page_cache_release(page); goto out_failed; } @@ -116,7 +139,9 @@ * Don't do any of the expensive stuff if * we're not really interested in this zone. */ - if (page->zone->free_pages > page->zone->pages_high) + if (page->zone->free_pages + page->zone->inactive_clean_pages + + page->zone->inactive_dirty_pages + > page->zone->pages_high + inactive_target) goto out_unlock; /* @@ -152,6 +177,7 @@ if (file) fput(file); if (!error) goto out_free_success; + deactivate_page(page); page_cache_release(page); return error; } @@ -182,6 +208,7 @@ /* OK, do a physical asynchronous write to swap. */ rw_swap_page(WRITE, page, 0); + deactivate_page(page); out_free_success: page_cache_release(page); @@ -323,17 +350,22 @@ int result = swap_out_vma(mm, vma, address, gfp_mask); if (result) return result; + if (!mm->swap_cnt) + goto out_unlock; vma = vma->vm_next; if (!vma) break; address = vma->vm_start; } } + /* Reset to 0 when we reach the end of address space */ + mm->swap_address = 0; + mm->swap_cnt = 0; + +out_unlock: vmlist_access_unlock(mm); /* We didn't find anything for the process */ - mm->swap_cnt = 0; - mm->swap_address = 0; return 0; } @@ -342,6 +374,9 @@ * N.B. This function returns only 0 or 1. Return values != 1 from * the lower level routines result in continued processing. */ +#define SWAP_SHIFT 5 +#define SWAP_MIN 8 + static int swap_out(unsigned int priority, int gfp_mask) { struct task_struct * p; @@ -363,7 +398,7 @@ * Think of swap_cnt as a "shadow rss" - it tells us which process * we want to page out (always try largest first). */ - counter = (nr_threads << 2) >> (priority >> 2); + counter = (nr_threads << SWAP_SHIFT) >> priority; if (counter < 1) counter = 1; @@ -382,8 +417,11 @@ if (mm->rss <= 0) continue; /* Refresh swap_cnt? */ - if (assign == 1) - mm->swap_cnt = mm->rss; + if (assign == 1) { + mm->swap_cnt = (mm->rss >> SWAP_SHIFT); + if (mm->swap_cnt < SWAP_MIN) + mm->swap_cnt = SWAP_MIN; + } if (mm->swap_cnt > max_cnt) { max_cnt = mm->swap_cnt; best = mm; @@ -418,50 +456,393 @@ return __ret; } -/* - * Check if there is any memory pressure (free_pages < pages_low) + +/** + * reclaim_page - reclaims one page from the inactive_clean list + * @zone: reclaim a page from this zone + * + * The pages on the inactive_clean can be instantly reclaimed. + * The tests look impressive, but most of the time we'll grab + * the first page of the list and exit successfully. */ -static inline int memory_pressure(void) +struct page * reclaim_page(zone_t * zone) { - pg_data_t *pgdat = pgdat_list; + struct page * page = NULL; + struct list_head * page_lru; + int maxscan; - do { - int i; - for(i = 0; i < MAX_NR_ZONES; i++) { - zone_t *zone = pgdat->node_zones+ i; - if (zone->size && - zone->free_pages < zone->pages_low) - return 1; + /* + * We only need the pagemap_lru_lock if we don't reclaim the page, + * but we have to grab the pagecache_lock before the pagemap_lru_lock + * to avoid deadlocks and most of the time we'll succeed anyway. + */ + spin_lock(&pagecache_lock); + spin_lock(&pagemap_lru_lock); + maxscan = zone->inactive_clean_pages; + while ((page_lru = zone->inactive_clean_list.prev) != + &zone->inactive_clean_list && maxscan--) { + page = list_entry(page_lru, struct page, lru); + + /* Wrong page on list?! (list corruption, should not happen) */ + if (!PageInactiveClean(page)) { + printk("VM: reclaim_page, wrong page on list.\n"); + list_del(page_lru); + page->zone->inactive_clean_pages--; + continue; } - pgdat = pgdat->node_next; - } while (pgdat); - return 0; + /* Page is or was in use? Move it to the active list. */ + if (PageTestandClearReferenced(page) || page->age > 0 || + (!page->buffers && page_count(page) > 1)) { + del_page_from_inactive_clean_list(page); + add_page_to_active_list(page); + continue; + } + + /* The page is dirty, or locked, move to inactive_diry list. */ + if (page->buffers || TryLockPage(page)) { + del_page_from_inactive_clean_list(page); + add_page_to_inactive_dirty_list(page); + continue; + } + + /* OK, remove the page from the caches. */ + if (PageSwapCache(page)) { + __delete_from_swap_cache(page); + goto found_page; + } + + if (page->mapping) { + __remove_inode_page(page); + goto found_page; + } + + /* We should never ever get here. */ + printk(KERN_ERR "VM: reclaim_page, found unknown page\n"); + list_del(page_lru); + zone->inactive_clean_pages--; + UnlockPage(page); + } + /* Reset page pointer, maybe we encountered an unfreeable page. */ + page = NULL; + goto out; + +found_page: + del_page_from_inactive_clean_list(page); + UnlockPage(page); + if (page_count(page) != 1) + printk("VM: reclaim_page, found page with count %d!\n", + page_count(page)); +out: + spin_unlock(&pagemap_lru_lock); + spin_unlock(&pagecache_lock); + memory_pressure++; + return page; +} + +/** + * page_launder - clean dirty inactive pages, move to inactive_clean list + * @gfp_mask: what operations we are allowed to do + * @sync: should we wait synchronously for the cleaning of pages + * + * When this function is called, we are most likely low on free + + * inactive_clean pages. Since we want to refill those pages as + * soon as possible, we'll make two loops over the inactive list, + * one to move the already cleaned pages to the inactive_clean lists + * and one to (often asynchronously) clean the dirty inactive pages. + * + * In situations where kswapd cannot keep up, user processes will + * end up calling this function. Since the user process needs to + * have a page before it can continue with its allocation, we'll + * do synchronous page flushing in that case. + * + * This code is heavily inspired by the FreeBSD source code. Thanks + * go out to Matthew Dillon. + */ +#define MAX_SYNC_LAUNDER (1 << page_cluster) +#define MAX_LAUNDER (MAX_SYNC_LAUNDER * 4) +int page_launder(int gfp_mask, int sync) +{ + int synclaunder, launder_loop, maxscan, cleaned_pages, maxlaunder; + struct list_head * page_lru; + struct page * page; + + launder_loop = 0; + synclaunder = 0; + maxlaunder = 0; + cleaned_pages = 0; + + if (!(gfp_mask & __GFP_IO)) + return 0; + +dirty_page_rescan: + spin_lock(&pagemap_lru_lock); + maxscan = nr_inactive_dirty_pages; + while ((page_lru = inactive_dirty_list.prev) != &inactive_dirty_list && + maxscan-- > 0) { + page = list_entry(page_lru, struct page, lru); + + /* Wrong page on list?! (list corruption, should not happen) */ + if (!PageInactiveDirty(page)) { + printk("VM: page_launder, wrong page on list.\n"); + list_del(page_lru); + nr_inactive_dirty_pages--; + page->zone->inactive_dirty_pages--; + continue; + } + + /* Page is or was in use? Move it to the active list. */ + if (PageTestandClearReferenced(page) || page->age > 0 || + (!page->buffers && page_count(page) > 1) || + page_ramdisk(page)) { + del_page_from_inactive_dirty_list(page); + add_page_to_active_list(page); + continue; + } + + /* + * The page is locked. IO in progress? + * Move it to the back of the list. + */ + if (TryLockPage(page)) { + list_del(page_lru); + list_add(page_lru, &inactive_dirty_list); + continue; + } + + /* + * If the page has buffers, try to free the buffer mappings + * associated with this page. If we succeed we either free + * the page (in case it was a buffercache only page) or we + * move the page to the inactive_clean list. + * + * On the first round, we should free all previously cleaned + * buffer pages + */ + if (page->buffers) { + int wait, clearedbuf; + int freed_page = 0; + /* + * Since we might be doing disk IO, we have to + * drop the spinlock and take an extra reference + * on the page so it doesn't go away from under us. + */ + del_page_from_inactive_dirty_list(page); + page_cache_get(page); + spin_unlock(&pagemap_lru_lock); + + /* Will we do (asynchronous) IO? */ + if (launder_loop && synclaunder-- > 0) + wait = 2; /* Synchrounous IO */ + else if (launder_loop && maxlaunder-- > 0) + wait = 1; /* Async IO */ + else + wait = 0; /* No IO */ + + /* Try to free the page buffers. */ + clearedbuf = try_to_free_buffers(page, wait); + + /* + * Re-take the spinlock. Note that we cannot + * unlock the page yet since we're still + * accessing the page_struct here... + */ + spin_lock(&pagemap_lru_lock); + + /* The buffers were not freed. */ + if (!clearedbuf) { + add_page_to_inactive_dirty_list(page); + + /* The page was only in the buffer cache. */ + } else if (!page->mapping) { + atomic_dec(&buffermem_pages); + freed_page = 1; + cleaned_pages++; + + /* The page has more users besides the cache and us. */ + } else if (page_count(page) > 2) { + add_page_to_active_list(page); + + /* OK, we "created" a freeable page. */ + } else /* page->mapping && page_count(page) == 2 */ { + add_page_to_inactive_clean_list(page); + cleaned_pages++; + } + + /* + * Unlock the page and drop the extra reference. + * We can only do it here because we ar accessing + * the page struct above. + */ + UnlockPage(page); + page_cache_release(page); + + /* + * If we're freeing buffer cache pages, stop when + * we've got enough free memory. + */ + if (freed_page && !free_shortage()) + break; + continue; + } else if (page->mapping && !PageDirty(page)) { + /* + * If a page had an extra reference in + * deactivate_page(), we will find it here. + * Now the page is really freeable, so we + * move it to the inactive_clean list. + */ + UnlockPage(page); + del_page_from_inactive_dirty_list(page); + add_page_to_inactive_clean_list(page); + cleaned_pages++; + } else { + /* + * OK, we don't know what to do with the page. + * It's no use keeping it here, so we move it to + * the active list. + */ + UnlockPage(page); + del_page_from_inactive_dirty_list(page); + add_page_to_active_list(page); + } + } + spin_unlock(&pagemap_lru_lock); + + /* + * If we don't have enough free pages, we loop back once + * to queue the dirty pages for writeout. When we were called + * by a user process (that /needs/ a free page) and we didn't + * free anything yet, we wait synchronously on the writeout of + * MAX_SYNC_LAUNDER pages. + * + * We also wake up bdflush, since bdflush should, under most + * loads, flush out the dirty pages before we have to wait on + * IO. + */ + if (!launder_loop && free_shortage()) { + launder_loop = 1; + if (sync && !cleaned_pages) + synclaunder = MAX_SYNC_LAUNDER; + /* We only do a few "out of order" flushes. */ + maxlaunder = MAX_LAUNDER; + /* Kflushd takes care of the rest. */ + wakeup_bdflush(0); + goto dirty_page_rescan; + } + + /* Return the number of pages moved to the inactive_clean list. */ + return cleaned_pages; +} + +/** + * refill_inactive_scan - scan the active list and find pages to deactivate + * @priority: the priority at which to scan + * @oneshot: exit after deactivating one page + * + * This function will scan a portion of the active list to find + * unused pages, those pages will then be moved to the inactive list. + */ +int refill_inactive_scan(unsigned int priority, int oneshot) +{ + struct list_head * page_lru; + struct page * page; + int maxscan, page_active = 0; + int ret = 0; + + /* Take the lock while messing with the list... */ + spin_lock(&pagemap_lru_lock); + maxscan = nr_active_pages >> priority; + while (maxscan-- > 0 && (page_lru = active_list.prev) != &active_list) { + page = list_entry(page_lru, struct page, lru); + + /* Wrong page on list?! (list corruption, should not happen) */ + if (!PageActive(page)) { + printk("VM: refill_inactive, wrong page on list.\n"); + list_del(page_lru); + nr_active_pages--; + continue; + } + + /* Do aging on the pages. */ + if (PageTestandClearReferenced(page)) { + age_page_up_nolock(page); + page_active = 1; + } else { + age_page_down_nolock(page); + page_active = 0; + } + /* + * If the page is still on the active list, move it + * to the other end of the list. Otherwise it was + * deactivated by age_page_down and we exit successfully. + */ + if (page_active || PageActive(page)) { + list_del(page_lru); + list_add(page_lru, &active_list); + } else { + ret = 1; + if (oneshot) + break; + } + } + spin_unlock(&pagemap_lru_lock); + + return ret; } /* - * Check if all zones have recently had memory_pressure (zone_wake_kswapd) + * Check if there are zones with a severe shortage of free pages, + * or if all zones have a minor shortage. */ -static inline int keep_kswapd_awake(void) +int free_shortage(void) { - int all_recent = 1; pg_data_t *pgdat = pgdat_list; + int sum = 0; + int freeable = nr_free_pages() + nr_inactive_clean_pages(); + /* Are we low on truly free pages? */ + if (nr_free_pages() < freepages.min) + return freepages.high - nr_free_pages(); + + /* Are we low on free pages over-all? */ + if (freeable < freepages.high) + return freepages.high - freeable; + + /* If not, are we very low on any particular zone? */ do { int i; for(i = 0; i < MAX_NR_ZONES; i++) { zone_t *zone = pgdat->node_zones+ i; - if (zone->size) { - if (zone->free_pages < zone->pages_min) - return 1; - if (!zone->zone_wake_kswapd) - all_recent = 0; + if (zone->size && (zone->inactive_clean_pages + + zone->free_pages < zone->pages_min)) { + sum += zone->pages_min; + sum -= zone->free_pages; + sum -= zone->inactive_clean_pages; } } pgdat = pgdat->node_next; } while (pgdat); - return all_recent; + return sum; +} + +/* + * How many inactive pages are we short? + */ +int inactive_shortage(void) +{ + int shortage = 0; + + shortage += freepages.high; + shortage += inactive_target; + shortage -= nr_free_pages(); + shortage -= nr_inactive_clean_pages(); + shortage -= nr_inactive_dirty_pages; + + if (shortage > 0) + return shortage; + + return 0; } /* @@ -472,41 +853,37 @@ * We want to try to free "count" pages, and we want to * cluster them so that we get good swap-out behaviour. * - * Don't try _too_ hard, though. We don't want to have bad - * latency. - * - * Note: only called by kswapd and try_to_free_pages - * both can WAIT at top level. + * OTOH, if we're a user process (and not kswapd), we + * really care about latency. In that case we don't try + * to free too many pages. */ -#define FREE_COUNT 8 -#define SWAP_COUNT 16 -static int do_try_to_free_pages(unsigned int gfp_mask) -{ - int priority; - int count = FREE_COUNT; - int swap_count; +static int refill_inactive(unsigned int gfp_mask, int user) +{ + int priority, count, start_count, made_progress; + + count = inactive_shortage() + free_shortage(); + if (user) + count = (1 << page_cluster); + start_count = count; /* Always trim SLAB caches when memory gets low. */ kmem_cache_reap(gfp_mask); - priority = 64; + priority = 6; do { + made_progress = 0; + if (current->need_resched) { + __set_current_state(TASK_RUNNING); schedule(); - /* time has passed - pressure too? */ - if (!memory_pressure()) - goto done; } - while (shrink_mmap(priority, gfp_mask)) { + while (refill_inactive_scan(priority, 1)) { + made_progress = 1; if (!--count) goto done; } - /* check if mission completed */ - if (!keep_kswapd_awake()) - goto done; - /* Try to get rid of some shared memory pages.. */ if (gfp_mask & __GFP_IO) { /* @@ -525,10 +902,9 @@ * if (count <= 0) * goto done; */ - if (!keep_kswapd_awake()) - goto done; while (shm_swap(priority, gfp_mask)) { + made_progress = 1; if (!--count) goto done; } @@ -536,32 +912,82 @@ /* * Then, try to page stuff out.. - * - * This will not actually free any pages (they get - * put in the swap cache), so we must not count this - * as a "count" success. - */ - swap_count = SWAP_COUNT; - while (swap_out(priority, gfp_mask)) - if (--swap_count < 0) - break; + */ + while (swap_out(priority, gfp_mask)) { + made_progress = 1; + if (!--count) + goto done; + } - } while (--priority >= 0); + /* + * If we either have enough free memory, or if + * page_launder() will be able to make enough + * free memory, then stop. + */ + if (!inactive_shortage() || !free_shortage()) + goto done; + + /* + * Only switch to a lower "priority" if we + * didn't make any useful progress in the + * last loop. + */ + if (!made_progress) + priority--; + } while (priority >= 0); /* Always end on a shrink_mmap.., may sleep... */ - while (shrink_mmap(0, gfp_mask)) { + while (refill_inactive_scan(0, 1)) { if (!--count) goto done; } - /* Return 1 if any page is freed, or - * there are no more memory pressure */ - return (count < FREE_COUNT || !keep_kswapd_awake()); - + done: - return 1; + return (count < start_count); +} + +static int do_try_to_free_pages(unsigned int gfp_mask, int user) +{ + int ret = 0; + + /* + * First, reclaim unused slab cache memory. + */ + kmem_cache_reap(gfp_mask); + + /* + * If we're low on free pages, move pages from the + * inactive_dirty list to the inactive_clean list. + * + * Usually bdflush will have pre-cleaned the pages + * before we get around to moving them to the other + * list, so this is a relatively cheap operation. + */ + if (free_shortage()) + ret += page_launder(gfp_mask, user); + + /* + * If needed, we move pages from the active list + * to the inactive list. We also "eat" pages from + * the inode and dentry cache whenever we do this. + */ + if (free_shortage() || inactive_shortage()) { + if (gfp_mask & __GFP_IO) { + ret += shrink_dcache_memory(6, gfp_mask); + ret += shrink_icache_memory(6, gfp_mask); + } + + ret += refill_inactive(gfp_mask, user); + } else { + ret = 1; + } + + return ret; } DECLARE_WAIT_QUEUE_HEAD(kswapd_wait); +DECLARE_WAIT_QUEUE_HEAD(kswapd_done); +struct task_struct *kswapd_task; /* * The background pageout daemon, started as a kernel thread @@ -584,6 +1010,7 @@ tsk->pgrp = 1; strcpy(tsk->comm, "kswapd"); sigfillset(&tsk->blocked); + kswapd_task = tsk; /* * Tell the memory management that we're a "memory allocator", @@ -599,15 +1026,91 @@ */ tsk->flags |= PF_MEMALLOC; + /* + * Kswapd main loop. + */ for (;;) { - if (!keep_kswapd_awake()) { - interruptible_sleep_on(&kswapd_wait); + static int recalc = 0; + + /* If needed, try to free some memory. */ + if (inactive_shortage() || free_shortage()) { + int wait = 0; + /* Do we need to do some synchronous flushing? */ + if (waitqueue_active(&kswapd_done)) + wait = 1; + if (!do_try_to_free_pages(GFP_KSWAPD, wait)) { + /* + * if (out_of_memory()) { + * try again a few times; + * oom_kill(); + * } + */ + } } - do_try_to_free_pages(GFP_KSWAPD); + /* + * Do some (very minimal) background scanning. This + * will scan all pages on the active list once + * every minute. This clears old referenced bits + * and moves unused pages to the inactive list. + */ + refill_inactive_scan(6, 0); + + /* Once a second, recalculate some VM stats. */ + if (time_after(jiffies, recalc + HZ)) { + recalc = jiffies; + recalculate_vm_stats(); + } + + /* + * Wake up everybody waiting for free memory + * and unplug the disk queue. + */ + wake_up_all(&kswapd_done); + run_task_queue(&tq_disk); + + /* + * If we've either completely gotten rid of the + * free page shortage or the inactive page shortage + * is getting low, then stop eating CPU time. + * + * We go to sleep for one second, but if it's needed + * we'll be woken up earlier... + */ + if (!free_shortage() || !inactive_shortage()) + interruptible_sleep_on_timeout(&kswapd_wait, HZ); } } +void wakeup_kswapd(int block) +{ + DECLARE_WAITQUEUE(wait, current); + + if (current == kswapd_task) + return; + + if (!block) { + if (waitqueue_active(&kswapd_wait)) + wake_up(&kswapd_wait); + return; + } + + /* + * Kswapd could wake us up before we get a chance + * to sleep, so we have to be very careful here to + * prevent SMP races... + */ + __set_current_state(TASK_UNINTERRUPTIBLE); + add_wait_queue(&kswapd_done, &wait); + + if (waitqueue_active(&kswapd_wait)) + wake_up(&kswapd_wait); + schedule(); + + remove_wait_queue(&kswapd_done, &wait); + __set_current_state(TASK_RUNNING); +} + /* * Called by non-kswapd processes when they want more * memory. @@ -625,28 +1128,72 @@ */ int try_to_free_pages(unsigned int gfp_mask) { - int retval = 1; + int ret = 1; if (gfp_mask & __GFP_WAIT) { - current->state = TASK_RUNNING; - current->flags |= PF_MEMALLOC; - retval = do_try_to_free_pages(gfp_mask); - current->flags &= ~PF_MEMALLOC; + ret = do_try_to_free_pages(gfp_mask, 1); } - /* someone needed memory that kswapd had not provided - * make sure kswapd runs, should not happen often */ - if (waitqueue_active(&kswapd_wait)) - wake_up_interruptible(&kswapd_wait); + return ret; +} + +DECLARE_WAIT_QUEUE_HEAD(kreclaimd_wait); +/* + * Kreclaimd will move pages from the inactive_clean list to the + * free list, in order to keep atomic allocations possible under + * all circumstances. Even when kswapd is blocked on IO. + */ +int kreclaimd(void *unused) +{ + struct task_struct *tsk = current; + pg_data_t *pgdat; - return retval; + tsk->session = 1; + tsk->pgrp = 1; + strcpy(tsk->comm, "kreclaimd"); + sigfillset(&tsk->blocked); + current->flags |= PF_MEMALLOC; + + while (1) { + + /* + * We sleep until someone wakes us up from + * page_alloc.c::__alloc_pages(). + */ + interruptible_sleep_on(&kreclaimd_wait); + + /* + * Move some pages from the inactive_clean lists to + * the free lists, if it is needed. + */ + pgdat = pgdat_list; + do { + int i; + for(i = 0; i < MAX_NR_ZONES; i++) { + zone_t *zone = pgdat->node_zones + i; + if (!zone->size) + continue; + + while (zone->free_pages < zone->pages_low) { + struct page * page; + page = reclaim_page(zone); + if (!page) + break; + __free_page(page); + } + } + pgdat = pgdat->node_next; + } while (pgdat); + } } + static int __init kswapd_init(void) { - printk("Starting kswapd v1.7\n"); + printk("Starting kswapd v1.8\n"); swap_setup(); kernel_thread(kswapd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGNAL); + kernel_thread(kreclaimd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGNAL); return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/net/core/sock.c linux/net/core/sock.c --- v2.4.0-test8/linux/net/core/sock.c Wed Aug 23 18:36:39 2000 +++ linux/net/core/sock.c Sun Sep 17 10:03:43 2000 @@ -7,7 +7,7 @@ * handler for protocols to use and generic option handler. * * - * Version: $Id: sock.c,v 1.98 2000/08/16 16:09:15 davem Exp $ + * Version: $Id: sock.c,v 1.99 2000/09/16 07:33:53 davem Exp $ * * Authors: Ross Biro, * Fred N. van Kempen, @@ -609,7 +609,9 @@ { sk_cachep = kmem_cache_create("sock", sizeof(struct sock), 0, SLAB_HWCACHE_ALIGN, 0, 0); - + if (!sk_cachep) + printk(KERN_CRIT "sk_init: Cannot create sock SLAB cache!"); + if (num_physpages <= 4096) { sysctl_wmem_max = 32767; sysctl_rmem_max = 32767; diff -u --recursive --new-file v2.4.0-test8/linux/net/ipv4/af_inet.c linux/net/ipv4/af_inet.c --- v2.4.0-test8/linux/net/ipv4/af_inet.c Wed Aug 23 18:36:39 2000 +++ linux/net/ipv4/af_inet.c Sun Sep 17 10:03:43 2000 @@ -5,7 +5,7 @@ * * PF_INET protocol family socket handler. * - * Version: $Id: af_inet.c,v 1.112 2000/08/16 16:20:56 davem Exp $ + * Version: $Id: af_inet.c,v 1.113 2000/09/11 23:35:29 davem Exp $ * * Authors: Ross Biro, * Fred N. van Kempen, @@ -390,7 +390,6 @@ if (sk->prot->init) { int err = sk->prot->init(sk); if (err != 0) { - sk->dead = 1; inet_sock_release(sk); return(err); } diff -u --recursive --new-file v2.4.0-test8/linux/net/ipv4/ip_sockglue.c linux/net/ipv4/ip_sockglue.c --- v2.4.0-test8/linux/net/ipv4/ip_sockglue.c Wed Aug 23 18:36:39 2000 +++ linux/net/ipv4/ip_sockglue.c Sun Sep 17 10:03:43 2000 @@ -5,7 +5,7 @@ * * The IP to API glue. * - * Version: $Id: ip_sockglue.c,v 1.51 2000/08/09 11:59:04 davem Exp $ + * Version: $Id: ip_sockglue.c,v 1.52 2000/09/09 08:26:04 davem Exp $ * * Authors: see ip.c * @@ -380,31 +380,39 @@ { int val=0,err; - if(optlen>=sizeof(int)) { - if(get_user(val, (int *) optval)) - return -EFAULT; - } else if(optlen>=sizeof(char)) { - unsigned char ucval; - if(get_user(ucval, (unsigned char *) optval)) - return -EFAULT; - val = (int)ucval; + if (optname == IP_PKTINFO || optname == IP_RECVTTL || + optname == IP_RECVTOS || optname == IP_RECVOPTS || + optname == IP_RETOPTS || optname == IP_TOS || + optname == IP_TTL || optname == IP_HDRINCL || + optname == IP_MTU_DISCOVER || optname == IP_RECVERR || + optname == IP_MULTICAST_TTL || optname == IP_MULTICAST_LOOP || + optname == IP_ROUTER_ALERT) { + if (optlen >= sizeof(int)) { + if (get_user(val, (int *) optval)) + return -EFAULT; + } else if (optlen >= sizeof(char)) { + unsigned char ucval; + + if (get_user(ucval, (unsigned char *) optval)) + return -EFAULT; + val = (int) ucval; + } } + /* If optlen==0, it is equivalent to val == 0 */ - if(level!=SOL_IP) + if (level != SOL_IP) return -ENOPROTOOPT; + #ifdef CONFIG_IP_MROUTE - if(optname>=MRT_BASE && optname <=MRT_BASE+10) - { + if (optname >= MRT_BASE && optname <= (MRT_BASE + 10)) return ip_mroute_setsockopt(sk,optname,optval,optlen); - } #endif err = 0; lock_sock(sk); - switch(optname) - { + switch (optname) { case IP_OPTIONS: { struct ip_options * opt = NULL; diff -u --recursive --new-file v2.4.0-test8/linux/net/ipv4/netfilter/ip_nat_ftp.c linux/net/ipv4/netfilter/ip_nat_ftp.c --- v2.4.0-test8/linux/net/ipv4/netfilter/ip_nat_ftp.c Wed Aug 23 18:36:39 2000 +++ linux/net/ipv4/netfilter/ip_nat_ftp.c Sun Sep 17 10:15:00 2000 @@ -372,8 +372,9 @@ newseq = ntohl(tcph->seq) + ftp[dir].syn_offset_before; newseq = htonl(newseq); - /* Ack adjust */ - if (after(ntohl(tcph->ack_seq), ftp[!dir].syn_correction_pos)) + /* Ack adjust: other dir sees offset seq numbers */ + if (after(ntohl(tcph->ack_seq) - ftp[!dir].syn_offset_before, + ftp[!dir].syn_correction_pos)) newack = ntohl(tcph->ack_seq) - ftp[!dir].syn_offset_after; else newack = ntohl(tcph->ack_seq) - ftp[!dir].syn_offset_before; diff -u --recursive --new-file v2.4.0-test8/linux/net/ipv4/netfilter/ip_nat_standalone.c linux/net/ipv4/netfilter/ip_nat_standalone.c --- v2.4.0-test8/linux/net/ipv4/netfilter/ip_nat_standalone.c Fri Sep 8 13:27:13 2000 +++ linux/net/ipv4/netfilter/ip_nat_standalone.c Fri Sep 15 21:37:23 2000 @@ -7,6 +7,7 @@ /* (c) 1999 Paul `Rusty' Russell. Licenced under the GNU General Public Licence. */ +#include #include #include #include diff -u --recursive --new-file v2.4.0-test8/linux/net/ipv4/netfilter/iptable_mangle.c linux/net/ipv4/netfilter/iptable_mangle.c --- v2.4.0-test8/linux/net/ipv4/netfilter/iptable_mangle.c Fri Sep 8 13:27:13 2000 +++ linux/net/ipv4/netfilter/iptable_mangle.c Fri Sep 15 21:37:23 2000 @@ -3,6 +3,7 @@ * * Copyright (C) 1999 Paul `Rusty' Russell & Michael J. Neuling */ +#include #include #include #include diff -u --recursive --new-file v2.4.0-test8/linux/net/ipv4/sysctl_net_ipv4.c linux/net/ipv4/sysctl_net_ipv4.c --- v2.4.0-test8/linux/net/ipv4/sysctl_net_ipv4.c Fri Sep 8 13:27:13 2000 +++ linux/net/ipv4/sysctl_net_ipv4.c Sun Sep 17 10:03:43 2000 @@ -1,7 +1,7 @@ /* * sysctl_net_ipv4.c: sysctl interface to net IPV4 subsystem. * - * $Id: sysctl_net_ipv4.c,v 1.45 2000/09/06 23:30:29 davem Exp $ + * $Id: sysctl_net_ipv4.c,v 1.46 2000/09/16 09:38:30 davem Exp $ * * Begun April 1, 1996, Mike Shaver. * Added /proc/sys/net/ipv4 directory entry (empty =) ). [MS] @@ -15,19 +15,6 @@ #include #include -/* - * TCP configuration parameters - */ - -#define TCP_PMTU_DISC 0x00000001 /* perform PMTU discovery */ -#define TCP_CONG_AVOID 0x00000002 /* congestion avoidance algorithm */ -#define TCP_DELAY_ACKS 0x00000003 /* delayed ack stategy */ - -#if 0 -static int boolean_min = 0; -static int boolean_max = 1; -#endif - /* From icmp.c */ extern int sysctl_icmp_echo_ignore_all; extern int sysctl_icmp_echo_ignore_broadcasts; @@ -57,7 +44,10 @@ extern int inet_peer_gc_mintime; extern int inet_peer_gc_maxtime; -int tcp_retr1_max = 255; +static int tcp_retr1_max = 255; + +static int ip_local_port_range_min[] = { 1, 1 }; +static int ip_local_port_range_max[] = { 65535, 65535 }; struct ipv4_config ipv4_config; @@ -170,7 +160,8 @@ sizeof(int), 0644, NULL, &proc_dointvec}, {NET_IPV4_LOCAL_PORT_RANGE, "ip_local_port_range", &sysctl_local_port_range, sizeof(sysctl_local_port_range), 0644, - NULL, &proc_dointvec}, + NULL, &proc_dointvec_minmax, &sysctl_intvec, NULL, + ip_local_port_range_min, ip_local_port_range_max }, {NET_IPV4_ICMP_ECHO_IGNORE_ALL, "icmp_echo_ignore_all", &sysctl_icmp_echo_ignore_all, sizeof(int), 0644, NULL, &proc_dointvec}, diff -u --recursive --new-file v2.4.0-test8/linux/net/ipv4/tcp_input.c linux/net/ipv4/tcp_input.c --- v2.4.0-test8/linux/net/ipv4/tcp_input.c Fri Sep 8 13:27:13 2000 +++ linux/net/ipv4/tcp_input.c Sun Sep 17 10:11:17 2000 @@ -5,7 +5,7 @@ * * Implementation of the Transmission Control Protocol(TCP). * - * Version: $Id: tcp_input.c,v 1.199 2000/09/06 23:30:29 davem Exp $ + * Version: $Id: tcp_input.c,v 1.200 2000/09/16 16:39:16 davem Exp $ * * Authors: Ross Biro, * Fred N. van Kempen, @@ -58,6 +58,7 @@ * J Hadi Salim: ECN support */ +#include #include #include #include @@ -1952,7 +1953,7 @@ if (opsize < 2) /* "silly options" */ return; if (opsize > length) - break; /* don't parse partial options */ + return; /* don't parse partial options */ switch(opcode) { case TCPOPT_MSS: if(opsize==TCPOLEN_MSS && th->syn) { diff -u --recursive --new-file v2.4.0-test8/linux/net/ipv6/af_inet6.c linux/net/ipv6/af_inet6.c --- v2.4.0-test8/linux/net/ipv6/af_inet6.c Wed Apr 26 16:34:09 2000 +++ linux/net/ipv6/af_inet6.c Sun Sep 17 10:03:43 2000 @@ -7,10 +7,11 @@ * * Adapted from linux/net/ipv4/af_inet.c * - * $Id: af_inet6.c,v 1.56 2000/04/25 04:13:34 davem Exp $ + * $Id: af_inet6.c,v 1.57 2000/09/11 23:35:29 davem Exp $ * * Fixes: * Hideaki YOSHIFUJI : sin6_scope_id support + * Arnaldo Melo : check proc_net_create return, cleanups * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -189,7 +190,7 @@ if (sk->prot->init) { int err = sk->prot->init(sk); if (err != 0) { - sk->dead = 1; + MOD_DEC_USE_COUNT; inet_sock_release(sk); return(err); } @@ -395,10 +396,8 @@ { case FIOSETOWN: case SIOCSPGRP: - err = get_user(pid, (int *) arg); - if(err) - return err; - + if (get_user(pid, (int *) arg)) + return -EFAULT; /* see sock_no_fcntl */ if (current->pid != pid && current->pgrp != -pid && !capable(CAP_NET_ADMIN)) @@ -407,10 +406,7 @@ return(0); case FIOGETOWN: case SIOCGPGRP: - err = put_user(sk->proc,(int *)arg); - if(err) - return err; - return(0); + return put_user(sk->proc,(int *)arg); case SIOCGSTAMP: if(sk->stamp.tv_sec==0) return -ENOENT; @@ -550,6 +546,20 @@ err = igmp6_init(&inet6_family_ops); if (err) goto igmp_fail; + /* Create /proc/foo6 entries. */ +#ifdef CONFIG_PROC_FS + err = -ENOMEM; + if (!proc_net_create("raw6", 0, raw6_get_info)) + goto proc_raw6_fail; + if (!proc_net_create("tcp6", 0, tcp6_get_info)) + goto proc_tcp6_fail; + if (!proc_net_create("udp6", 0, udp6_get_info)) + goto proc_udp6_fail; + if (!proc_net_create("sockstat6", 0, afinet6_get_info)) + goto proc_sockstat6_fail; + if (!proc_net_create("snmp6", 0, afinet6_get_snmp)) + goto proc_snmp6_fail; +#endif ipv6_netdev_notif_init(); ipv6_packet_init(); ip6_route_init(); @@ -561,15 +571,6 @@ udpv6_init(); tcpv6_init(); - /* Create /proc/foo6 entries. */ -#ifdef CONFIG_PROC_FS - proc_net_create("raw6", 0, raw6_get_info); - proc_net_create("tcp6", 0, tcp6_get_info); - proc_net_create("udp6", 0, udp6_get_info); - proc_net_create("sockstat6", 0, afinet6_get_info); - proc_net_create("snmp6", 0, afinet6_get_snmp); -#endif - /* Now the userspace is allowed to create INET6 sockets. */ (void) sock_register(&inet6_family_ops); @@ -579,6 +580,18 @@ return; #endif +#ifdef CONFIG_PROC_FS +proc_snmp6_fail: + proc_net_remove("sockstat6"); +proc_sockstat6_fail: + proc_net_remove("udp6"); +proc_udp6_fail: + proc_net_remove("tcp6"); +proc_tcp6_fail: + proc_net_remove("raw6"); +proc_raw6_fail: + igmp6_cleanup(); +#endif igmp_fail: ndisc_cleanup(); ndisc_fail: diff -u --recursive --new-file v2.4.0-test8/linux/net/ipv6/ip6_fib.c linux/net/ipv6/ip6_fib.c --- v2.4.0-test8/linux/net/ipv6/ip6_fib.c Thu May 11 15:30:08 2000 +++ linux/net/ipv6/ip6_fib.c Sun Sep 17 10:03:43 2000 @@ -5,7 +5,7 @@ * Authors: * Pedro Roque * - * $Id: ip6_fib.c,v 1.21 2000/05/03 06:37:07 davem Exp $ + * $Id: ip6_fib.c,v 1.22 2000/09/12 00:38:34 davem Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -638,10 +638,8 @@ if (narg->addr) { st = fib6_lookup_1(fn->subtree, narg); - if (!(st->fn_flags & RTN_ROOT)) - { + if (st && !(st->fn_flags & RTN_ROOT)) return st; - } } } #endif diff -u --recursive --new-file v2.4.0-test8/linux/net/x25/af_x25.c linux/net/x25/af_x25.c --- v2.4.0-test8/linux/net/x25/af_x25.c Fri Sep 8 13:27:13 2000 +++ linux/net/x25/af_x25.c Sun Sep 17 10:03:43 2000 @@ -21,6 +21,8 @@ * facilities negotiation and increased * the throughput upper limit. * 2000-27-08 Arnaldo C. Melo s/suser/capable/ + micro cleanups + * 2000-04-09 Henner Eisen Set sock->state in x25_accept(). + * Fixed x25_output() related skb leakage. */ #include @@ -721,6 +723,7 @@ kfree_skb(skb); sk->ack_backlog--; newsock->sk = newsk; + newsock->state = SS_CONNECTED; return 0; } @@ -971,7 +974,11 @@ if (msg->msg_flags & MSG_OOB) { skb_queue_tail(&sk->protinfo.x25->interrupt_out_queue, skb); } else { - x25_output(sk, skb); + err = x25_output(sk, skb); + if(err){ + len = err; + kfree_skb(skb); + } } x25_kick(sk); diff -u --recursive --new-file v2.4.0-test8/linux/net/x25/x25_dev.c linux/net/x25/x25_dev.c --- v2.4.0-test8/linux/net/x25/x25_dev.c Thu Aug 26 13:05:47 1999 +++ linux/net/x25/x25_dev.c Sun Sep 17 10:03:43 2000 @@ -14,6 +14,7 @@ * * History * X.25 001 Jonathan Naylor Started coding. + * 2000-09-04 Henner Eisen Prevent freeing a dangling skb. */ #include @@ -78,12 +79,13 @@ return x25_rx_call_request(skb, neigh, lci); /* - * Its not a Call Request, nor is it a control frame, throw it awa + * Its not a Call Request, nor is it a control frame. + * Let caller throw it away. */ /* x25_transmit_clear_request(neigh, lci, 0x0D); */ - kfree_skb(skb); + printk(KERN_DEBUG "x25_receive_data(): unknown frame type %2x\n",frametype); return 0; } diff -u --recursive --new-file v2.4.0-test8/linux/net/x25/x25_link.c linux/net/x25/x25_link.c --- v2.4.0-test8/linux/net/x25/x25_link.c Wed Apr 26 16:34:10 2000 +++ linux/net/x25/x25_link.c Sun Sep 17 10:03:43 2000 @@ -17,6 +17,7 @@ * X.25 002 Jonathan Naylor New timer architecture. * mar/20/00 Daniela Squassoni Disabling/enabling of facilities * negotiation. + * 2000-09-04 Henner Eisen dev_hold() / dev_put() for x25_neigh. */ #include @@ -292,6 +293,7 @@ init_timer(&x25_neigh->t20timer); + dev_hold(dev); x25_neigh->dev = dev; x25_neigh->state = X25_LINK_STATE_0; x25_neigh->extended = 0; @@ -349,8 +351,10 @@ neigh = x25_neigh; x25_neigh = x25_neigh->next; - if (neigh->dev == dev) + if (neigh->dev == dev){ x25_remove_neigh(neigh); + dev_put(dev); + } } } diff -u --recursive --new-file v2.4.0-test8/linux/net/x25/x25_out.c linux/net/x25/x25_out.c --- v2.4.0-test8/linux/net/x25/x25_out.c Tue Feb 10 13:07:49 1998 +++ linux/net/x25/x25_out.c Sun Sep 17 10:03:43 2000 @@ -15,6 +15,7 @@ * History * X.25 001 Jonathan Naylor Started coding. * X.25 002 Jonathan Naylor New timer architecture. + * 2000-09-04 Henner Eisen Prevented x25_output() skb leakage. */ #include @@ -56,7 +57,7 @@ /* * This is where all X.25 information frames pass; */ -void x25_output(struct sock *sk, struct sk_buff *skb) +int x25_output(struct sock *sk, struct sk_buff *skb) { struct sk_buff *skbn; unsigned char header[X25_EXT_MIN_LEN]; @@ -73,9 +74,12 @@ frontlen = skb_headroom(skb); while (skb->len > 0) { - if ((skbn = sock_alloc_send_skb(sk, frontlen + max_len, 0, 0, &err)) == NULL) - return; - + if ((skbn = sock_alloc_send_skb(sk, frontlen + max_len, 0, 0, &err)) == NULL){ + int unsent = skb->len - header_len; + SOCK_DEBUG(sk, "x25_output: framgent allocation failed, err=%d, %d bytes unsent\n", err, unsent); + return err; + } + skb_reserve(skbn, frontlen); len = (max_len > skb->len) ? skb->len : max_len; @@ -102,6 +106,7 @@ } else { skb_queue_tail(&sk->write_queue, skb); } + return 0; } /* diff -u --recursive --new-file v2.4.0-test8/linux/scripts/ver_linux linux/scripts/ver_linux --- v2.4.0-test8/linux/scripts/ver_linux Mon Dec 20 18:48:22 1999 +++ linux/scripts/ver_linux Sun Sep 17 09:45:06 2000 @@ -10,6 +10,8 @@ uname -a insmod -V 2>&1 | awk 'NR==1 {print "Kernel modules ",$NF}' echo "Gnu C " `gcc --version` +make --version 2>&1 | awk -F, '{print $1}' | awk \ + '/GNU Make/{print "Gnu Make ",$NF}' ld -v 2>&1 | awk -F\) '{print $1}' | awk \ '/BFD/{print "Binutils ",$NF}' ls -l `ldd /bin/sh | awk '/libc/{print $3}'` | sed -e 's/\.so$//' \