-mm3 --- diff/Documentation/Changes 2004-02-18 08:54:06.000000000 +0000 +++ source/Documentation/Changes 2004-02-23 13:56:39.000000000 +0000 @@ -49,7 +49,7 @@ Card) hardware, for example, you probabl with pcmcia-cs. o Gnu C 2.95.3 # gcc --version -o Gnu make 3.78 # make --version +o Gnu make 3.79.1 # make --version o binutils 2.12 # ld -v o util-linux 2.10o # fdformat --version o module-init-tools 0.9.10 # depmod -V @@ -96,7 +96,7 @@ your version of gcc 2.95.x, may necessit Make ---- -You will need Gnu make 3.78 or later to build the kernel. +You will need Gnu make 3.79.1 or later to build the kernel. Binutils -------- @@ -216,13 +216,6 @@ chmod 0644 /dev/cpu/microcode as root before you can use this. You'll probably also want to get the user-space microcode_ctl utility to use with this. -If you have compiled the driver as a module you may need to add -the following line: - -alias char-major-10-184 microcode - -to your /etc/modules.conf file. - Powertweak ---------- @@ -259,17 +252,6 @@ mknod /dev/ppp c 108 0 as root. -If you build ppp support as modules, you will need the following in -your /etc/modules.conf file: - -alias char-major-108 ppp_generic -alias /dev/ppp ppp_generic -alias tty-ldisc-3 ppp_async -alias tty-ldisc-14 ppp_synctty -alias ppp-compress-21 bsd_comp -alias ppp-compress-24 ppp_deflate -alias ppp-compress-26 ppp_deflate - If you use devfsd and build ppp support as modules, you will need the following in your /etc/devfsd.conf file: @@ -319,9 +301,9 @@ gcc 2.95.3 ---------- o -Make 3.78 ---------- -o +Make +---- +o Binutils -------- --- diff/Documentation/CodingStyle 2003-07-22 18:54:26.000000000 +0100 +++ source/Documentation/CodingStyle 2004-02-23 13:56:39.000000000 +0000 @@ -1,42 +1,75 @@ - Linux kernel coding style + Linux kernel coding style This is a short document describing the preferred coding style for the linux kernel. Coding style is very personal, and I won't _force_ my views on anybody, but this is what goes for anything that I have to be able to maintain, and I'd prefer it for most other things too. Please -at least consider the points made here. +at least consider the points made here. First off, I'd suggest printing out a copy of the GNU coding standards, -and NOT read it. Burn them, it's a great symbolic gesture. +and NOT read it. Burn them, it's a great symbolic gesture. Anyway, here goes: Chapter 1: Indentation -Tabs are 8 characters, and thus indentations are also 8 characters. +Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to -be 3. +be 3. Rationale: The whole idea behind indentation is to clearly define where a block of control starts and ends. Especially when you've been looking at your screen for 20 straight hours, you'll find it a lot easier to see -how the indentation works if you have large indentations. +how the indentation works if you have large indentations. Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix -your program. +your program. In short, 8-char indents make things easier to read, and have the added -benefit of warning you when you're nesting your functions too deep. -Heed that warning. +benefit of warning you when you're nesting your functions too deep. +Heed that warning. +Don't put multiple statements on a single line unless you have +something to hide: - Chapter 2: Placing Braces + if (condition) do_this; + do_something_everytime; + +Outside of comments, documentation and except in Kconfig, spaces are never +used for indentation, and the above example is deliberately broken. + +Get a decent editor and don't leave whitespace at the end of lines. + + + Chapter 2: Breaking long lines and strings + +Coding style is all about readability and maintainability using commonly +available tools. + +The limit on the length of lines is 80 columns and this is a hard limit. + +Statements longer than 80 columns will be broken into sensible chunks. +Descendants are always substantially shorter than the parent and are placed +substantially to the right. The same applies to function headers with a long +argument list. Long strings are as well broken into shorter strings. + +void fun(int a, int b, int c) +{ + if (condition) + printk(KERN_WARNING "Warning this is a long printk with " + "3 parameters a: %u b: %u " + "c: %u \n", a, b, c); + else + next_statement; +} + + Chapter 3: Placing Braces The other issue that always comes up in C styling is the placement of braces. Unlike the indent size, there are few technical reasons to @@ -59,7 +92,7 @@ opening brace at the beginning of the ne Heretic people all over the world have claimed that this inconsistency is ... well ... inconsistent, but all right-thinking people know that (a) K&R are _right_ and (b) K&R are right. Besides, functions are -special anyway (you can't nest them in C). +special anyway (you can't nest them in C). Note that the closing brace is empty on a line of its own, _except_ in the cases where it is followed by a continuation of the same statement, @@ -79,60 +112,60 @@ and } else { .... } - -Rationale: K&R. + +Rationale: K&R. Also, note that this brace-placement also minimizes the number of empty (or almost empty) lines, without any loss of readability. Thus, as the supply of new-lines on your screen is not a renewable resource (think 25-line terminal screens here), you have more empty lines to put -comments on. +comments on. - Chapter 3: Naming + Chapter 4: Naming C is a Spartan language, and so should your naming be. Unlike Modula-2 and Pascal programmers, C programmers do not use cute names like ThisVariableIsATemporaryCounter. A C programmer would call that variable "tmp", which is much easier to write, and not the least more -difficult to understand. +difficult to understand. HOWEVER, while mixed-case names are frowned upon, descriptive names for global variables are a must. To call a global function "foo" is a -shooting offense. +shooting offense. GLOBAL variables (to be used only if you _really_ need them) need to have descriptive names, as do global functions. If you have a function that counts the number of active users, you should call that -"count_active_users()" or similar, you should _not_ call it "cntusr()". +"count_active_users()" or similar, you should _not_ call it "cntusr()". Encoding the type of a function into the name (so-called Hungarian notation) is brain damaged - the compiler knows the types anyway and can check those, and it only confuses the programmer. No wonder MicroSoft -makes buggy programs. +makes buggy programs. LOCAL variable names should be short, and to the point. If you have -some random integer loop counter, it should probably be called "i". +some random integer loop counter, it should probably be called "i". Calling it "loop_counter" is non-productive, if there is no chance of it being mis-understood. Similarly, "tmp" can be just about any type of -variable that is used to hold a temporary value. +variable that is used to hold a temporary value. If you are afraid to mix up your local variable names, you have another -problem, which is called the function-growth-hormone-imbalance syndrome. -See next chapter. +problem, which is called the function-growth-hormone-imbalance syndrome. +See next chapter. + - - Chapter 4: Functions + Chapter 5: Functions Functions should be short and sweet, and do just one thing. They should fit on one or two screenfuls of text (the ISO/ANSI screen size is 80x24, -as we all know), and do one thing and do that well. +as we all know), and do one thing and do that well. The maximum length of a function is inversely proportional to the complexity and indentation level of that function. So, if you have a conceptually simple function that is just one long (but simple) case-statement, where you have to do lots of small things for a lot of -different cases, it's OK to have a longer function. +different cases, it's OK to have a longer function. However, if you have a complex function, and you suspect that a less-than-gifted first-year high-school student might not even @@ -140,41 +173,78 @@ understand what the function is all abou maximum limits all the more closely. Use helper functions with descriptive names (you can ask the compiler to in-line them if you think it's performance-critical, and it will probably do a better job of it -than you would have done). +than you would have done). Another measure of the function is the number of local variables. They shouldn't exceed 5-10, or you're doing something wrong. Re-think the function, and split it into smaller pieces. A human brain can generally easily keep track of about 7 different things, anything more and it gets confused. You know you're brilliant, but maybe you'd like -to understand what you did 2 weeks from now. +to understand what you did 2 weeks from now. + + + Chapter 6: Centralized exiting of functions + +Albeit deprecated by some people, the equivalent of the goto statement is +used frequently by compilers in form of the unconditional jump instruction. +The goto statement comes in handy when a function exits from multiple +locations and some common work such as cleanup has to be done. - Chapter 5: Commenting +The rationale is: + +- unconditional statements are easier to understand and follow +- nesting is reduced +- errors by not updating individual exit points when making + modifications are prevented +- saves the compiler work to optimize redundant code away ;) + +int fun(int ) +{ + int result = 0; + char *buffer = kmalloc(SIZE); + + if (buffer == NULL) + return -ENOMEM; + + if (condition1) { + while (loop1) { + ... + } + result = 1; + goto out; + } + ... +out: + kfree(buffer); + return result; +} + + Chapter 7: Commenting Comments are good, but there is also a danger of over-commenting. NEVER try to explain HOW your code works in a comment: it's much better to write the code so that the _working_ is obvious, and it's a waste of -time to explain badly written code. +time to explain badly written code. -Generally, you want your comments to tell WHAT your code does, not HOW. +Generally, you want your comments to tell WHAT your code does, not HOW. Also, try to avoid putting comments inside a function body: if the function is so complex that you need to separately comment parts of it, -you should probably go back to chapter 4 for a while. You can make +you should probably go back to chapter 5 for a while. You can make small comments to note or warn about something particularly clever (or ugly), but try to avoid excess. Instead, put the comments at the head of the function, telling people what it does, and possibly WHY it does -it. +it. - Chapter 6: You've made a mess of it + Chapter 8: You've made a mess of it That's OK, we all do. You've probably been told by your long-time Unix user helper that "GNU emacs" automatically formats the C sources for you, and you've noticed that yes, it does do that, but the defaults it uses are less than desirable (in fact, they are worse than random typing - an infinite number of monkeys typing into GNU emacs would never -make a good program). +make a good program). So, you can either get rid of GNU emacs, or change it to use saner values. To do the latter, you can stick the following in your .emacs file: @@ -192,7 +262,7 @@ two lines, this mode will be automatical to add (setq auto-mode-alist (cons '("/usr/src/linux.*/.*\\.[ch]$" . linux-c-mode) - auto-mode-alist)) + auto-mode-alist)) to your .emacs file if you want to have linux-c-mode switched on automagically when you edit source files under /usr/src/linux. @@ -201,33 +271,36 @@ But even if you fail in getting emacs to everything is lost: use "indent". Now, again, GNU indent has the same brain-dead settings that GNU emacs -has, which is why you need to give it a few command line options. +has, which is why you need to give it a few command line options. However, that's not too bad, because even the makers of GNU indent recognize the authority of K&R (the GNU people aren't evil, they are just severely misguided in this matter), so you just give indent the -options "-kr -i8" (stands for "K&R, 8 character indents"). +options "-kr -i8" (stands for "K&R, 8 character indents"), or use +"scripts/Lindent", which indents in the latest style. "indent" has a lot of options, and especially when it comes to comment -re-formatting you may want to take a look at the manual page. But -remember: "indent" is not a fix for bad programming. +re-formatting you may want to take a look at the man page. But +remember: "indent" is not a fix for bad programming. - Chapter 7: Configuration-files + Chapter 9: Configuration-files -For configuration options (arch/xxx/config.in, and all the Config.in files), +For configuration options (arch/xxx/Kconfig, and all the Kconfig files), somewhat different indentation is used. -An indention level of 3 is used in the code, while the text in the config- -options should have an indention-level of 2 to indicate dependencies. The -latter only applies to bool/tristate options. For other options, just use -common sense. An example: - -if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then - tristate 'Apply nitroglycerine inside the keyboard (DANGEROUS)' CONFIG_BOOM - if [ "$CONFIG_BOOM" != "n" ]; then - bool ' Output nice messages when you explode' CONFIG_CHEER - fi -fi +Help text is indented with 2 spaces. + +if CONFIG_EXPERIMENTAL + tristate CONFIG_BOOM + default n + help + Apply nitroglycerine inside the keyboard (DANGEROUS) + bool CONFIG_CHEER + depends on CONFIG_BOOM + default y + help + Output nice messages when you explode +endif Generally, CONFIG_EXPERIMENTAL should surround all options not considered stable. All options that are known to trash data (experimental write- @@ -235,20 +308,20 @@ support for file-systems, for instance) experimental options should be denoted (EXPERIMENTAL). - Chapter 8: Data structures + Chapter 10: Data structures Data structures that have visibility outside the single-threaded environment they are created and destroyed in should always have reference counts. In the kernel, garbage collection doesn't exist (and outside the kernel garbage collection is slow and inefficient), which -means that you absolutely _have_ to reference count all your uses. +means that you absolutely _have_ to reference count all your uses. Reference counting means that you can avoid locking, and allows multiple users to have access to the data structure in parallel - and not having to worry about the structure suddenly going away from under them just -because they slept or did something else for a while. +because they slept or did something else for a while. -Note that locking is _not_ a replacement for reference counting. +Note that locking is _not_ a replacement for reference counting. Locking is used to keep data structures coherent, while reference counting is a memory management technique. Usually both are needed, and they are not to be confused with each other. @@ -264,3 +337,93 @@ filesystem code ("struct super_block": s Remember: if another thread can find your data structure, and you don't have a reference count on it, you almost certainly have a bug. + + + Chapter 11: Macros, Enums, Inline functions and RTL + +Names of macros defining constants and labels in enums are capitalized. + +#define CONSTANT 0x12345 + +Enums are preferred when defining several related constants. + +CAPITALIZED macro names are appreciated but macros resembling functions +may be named in lower case. + +Generally, inline functions are preferable to macros resembling functions. + +Macros with multiple statements should be enclosed in a do - while block: + +#define macrofun(a,b,c) \ + do { \ + if (a == 5) \ + do_this(b,c); \ + } while (0) + +Things to avoid when using macros: + +1) macros that affect control flow: + +#define FOO(x) \ + do { \ + if (blah(x) < 0) \ + return -EBUGGERED; \ + } while(0) + +is a _very_ bad idea. It looks like a function call but exits the "calling" +function; don't break the internal parsers of those who will read the code. + +2) macros that depend on having a local variable with a magic name: + +#define FOO(val) bar(index, val) + +might look like a good thing, but it's confusing as hell when one reads the +code and it's prone to breakage from seemingly innocent changes. + +3) macros with arguments that are used as l-values: FOO(x) = y; will +bite you if somebody e.g. turns FOO into an inline function. + +4) forgetting about precedence: macros defining constants using expressions +must enclose the expression in parentheses. Beware of similar issues with +macros using parameters. + +#define CONSTANT 0x4000 +#define CONSTEXP (CONSTANT | 3) + +The cpp manual deals with macros exhaustively. The gcc internals manual also +covers RTL which is used frequently with assembly language in the kernel. + + + Chapter 12: Printing kernel messages + +Kernel developers like to be seen as literate. Do mind the spelling +of kernel messages to make a good impression. Do not use crippled +words like "dont" and use "do not" or "don't" instead. + +Kernel messages do not have to be terminated with a period. + +Printing numbers in parentheses (%d) adds no value and should be avoided. + + + Chapter 13: References + +The C Programming Language, Second Edition +by Brian W. Kernighan and Dennis M. Ritchie. +Prentice Hall, Inc., 1988. +ISBN 0-13-110362-8 (paperback), 0-13-110370-9 (hardback). +URL: http://cm.bell-labs.com/cm/cs/cbook/ + +The Practice of Programming +by Brian W. Kernighan and Rob Pike. +Addison-Wesley, Inc., 1999. +ISBN 0-201-61586-X. +URL: http://cm.bell-labs.com/cm/cs/tpop/ + +GNU manuals - where in compliance with K&R and this text - for cpp, gcc, +gcc internals and indent, all available from http://www.gnu.org + +WG14 is the international standardization working group for the programming +language C, URL: http://std.dkuug.dk/JTC1/SC22/WG14/ + +-- +Last updated on 16 February 2004 by a community effort on LKML. --- diff/Documentation/DocBook/procfs_example.c 2003-07-22 18:54:26.000000000 +0100 +++ source/Documentation/DocBook/procfs_example.c 2004-02-23 13:56:39.000000000 +0000 @@ -51,7 +51,7 @@ #include -#define MODULE_VERSION "1.0" +#define MODULE_VERS "1.0" #define MODULE_NAME "procfs_example" #define FOOBAR_LEN 8 @@ -185,7 +185,7 @@ static int __init init_procfs_example(vo /* everything OK */ printk(KERN_INFO "%s %s initialised\n", - MODULE_NAME, MODULE_VERSION); + MODULE_NAME, MODULE_VERS); return 0; no_symlink: @@ -213,7 +213,7 @@ static void __exit cleanup_procfs_exampl remove_proc_entry(MODULE_NAME, NULL); printk(KERN_INFO "%s %s removed\n", - MODULE_NAME, MODULE_VERSION); + MODULE_NAME, MODULE_VERS); } --- diff/Documentation/MSI-HOWTO.txt 2004-01-19 10:22:54.000000000 +0000 +++ source/Documentation/MSI-HOWTO.txt 2004-02-23 13:56:39.000000000 +0000 @@ -1,6 +1,8 @@ The MSI Driver Guide HOWTO Tom L Nguyen tom.l.nguyen@intel.com 10/03/2003 + Revised Feb 12, 2004 by Martine Silbermann + email: Martine.Silbermann@hp.com 1. About this guide @@ -90,17 +92,14 @@ increase scalability. 5. Configuring a driver to use MSI/MSI-X By default, the kernel will not enable MSI/MSI-X on all devices that -support this capability once the patch is installed. A kernel -configuration option must be selected to enable MSI/MSI-X support. +support this capability. The CONFIG_PCI_USE_VECTOR kernel option +must be selected to enable MSI/MSI-X support. 5.1 Including MSI support into the kernel -To include MSI support into the kernel requires users to patch the -VECTOR-base patch first and then the MSI patch because the MSI -support needs VECTOR based scheme. Once these patches are installed, -setting CONFIG_PCI_USE_VECTOR enables the VECTOR based scheme and -the option for MSI-capable device drivers to selectively enable MSI -(using pci_enable_msi as desribed below). +To allow MSI-Capable device drivers to selectively enable MSI (using +pci_enable_msi as described below), the VECTOR based scheme needs to +be enabled by setting CONFIG_PCI_USE_VECTOR. Since the target of the inbound message is the local APIC, providing CONFIG_PCI_USE_VECTOR is dependent on whether CONFIG_X86_LOCAL_APIC @@ -130,7 +129,7 @@ PIN-IRQ assertion mode. 5.2 Configuring for MSI support Due to the non-contiguous fashion in vector assignment of the -existing Linux kernel, this patch does not support multiple +existing Linux kernel, this version does not support multiple messages regardless of the device function is capable of supporting more than one vector. The bus driver initializes only entry 0 of this capability if pci_enable_msi(...) is called successfully by @@ -232,7 +231,7 @@ however, in UP environment, users must m CONFIG_X86_LOCAL_APIC. Once CONFIG_X86_LOCAL_APIC=y, setting CONFIG_PCI_USE_VECTOR enables the VECTOR based scheme and the option for MSI-capable device drivers to selectively enable -MSI (using pci_enable_msi as desribed below). +MSI (using pci_enable_msi as described below). Note that CONFIG_X86_IO_APIC setting is irrelevant because MSI vector is allocated new during runtime and MSI support does not --- diff/Documentation/binfmt_misc.txt 2003-10-09 09:47:33.000000000 +0100 +++ source/Documentation/binfmt_misc.txt 2004-02-23 13:56:39.000000000 +0000 @@ -15,7 +15,7 @@ First you must mount binfmt_misc: mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc To actually register a new binary type, you have to set up a string looking like -:name:type:offset:magic:mask:interpreter: (where you can choose the ':' upon +:name:type:offset:magic:mask:interpreter:flags (where you can choose the ':' upon your needs) and echo it to /proc/sys/fs/binfmt_misc/register. Here is what the fields mean: - 'name' is an identifier string. A new /proc file will be created with this @@ -34,6 +34,28 @@ Here is what the fields mean: The mask is anded with the byte sequence of the file. - 'interpreter' is the program that should be invoked with the binary as first argument (specify the full path) + - 'flags' is an optional field that controls several aspects of the invocation + of the interpreter. It is a string of capital letters, each controls a certain + aspect. The following flags are supported - + 'P' - preserve-argv[0]. Legacy behavior of binfmt_misc is to overwrite the + original argv[0] with the full path to the binary. When this flag is + included, binfmt_misc will add an argument to the argument vector for + this purpose, thus preserving the original argv[0]. + 'O' - open-binary. Legacy behavior of binfmt_misc is to pass the full path + of the binary to the interpreter as an argument. When this flag is + included, binfmt_misc will open the file for reading and pass its + descriptor as an argument, instead of the full path, thus allowing + the interpreter to execute non-readable binaries. This feature should + be used with care - the interpreter has to be trusted not to emit + the contents of the non-readable binary. + 'C' - credentials. Currently, the behavior of binfmt_misc is to calculate + the credentials and security token of the new process according to + the interpreter. When this flag is included, these attributes are + calculated according to the binary. It also implies the 'O' flag. + This feature should be used with care as the interpreter + will run with root permissions when a setuid binary owned by root + is run with binfmt_misc. + There are some restrictions: - the whole register string may not exceed 255 characters @@ -83,9 +105,9 @@ If you want to pass special arguments to write a wrapper script for it. See Documentation/java.txt for an example. -Your interpreter should NOT look in the PATH for the filename; the -kernel passes it the full filename to use. Using the PATH can cause -unexpected behaviour and be a security hazard. +Your interpreter should NOT look in the PATH for the filename; the kernel +passes it the full filename (or the file descriptor) to use. Using $PATH can +cause unexpected behaviour and can be a security hazard. There is a web page about binfmt_misc at --- diff/Documentation/computone.txt 2003-08-20 14:16:23.000000000 +0100 +++ source/Documentation/computone.txt 2004-02-23 13:56:39.000000000 +0000 @@ -41,11 +41,11 @@ Hardware - If you have an ISA card, find Note the hardware address from the Computone ISA cards installed into the system. These are required for editing ip2.c or editing - /etc/modules.conf, or for specification on the modprobe + /etc/modprobe.conf, or for specification on the modprobe command line. - Note that the /etc/modules.conf file is named /etc/conf.modules - with older versions of the module utilities. + Note that the /etc/modules.conf should be used for older (pre-2.6) + kernels. Software - @@ -58,7 +58,7 @@ b) Run "make config" or "make menuconfig c) Set address on ISA cards then: edit /usr/src/linux/drivers/char/ip2.c if needed or - edit /etc/modules.conf if needed (module). + edit /etc/modprobe.conf if needed (module). or both to match this setting. d) Run "make modules" e) Run "make modules_install" @@ -145,11 +145,11 @@ the irqs are not specified the driver us selects polled mode). If no base addresses are specified the defaults in ip2.c are used. If you are autoloading the driver module with kerneld or kmod the base addresses and interrupt number must also be set in ip2.c -and recompile or just insert and options line in /etc/modules.conf or both. +and recompile or just insert and options line in /etc/modprobe.conf or both. The options line is equivalent to the command line and takes precidence over what is in ip2.c. -/etc/modules.conf sample: +/etc/modprobe.conf sample: options ip2 io=1,0x328 irq=1,10 alias char-major-71 ip2 alias char-major-72 ip2 --- diff/Documentation/crypto/api-intro.txt 2003-10-09 09:47:33.000000000 +0100 +++ source/Documentation/crypto/api-intro.txt 2004-02-23 13:56:39.000000000 +0000 @@ -68,7 +68,7 @@ Many real examples are available in the CONFIGURATION NOTES As Triple DES is part of the DES module, for those using modular builds, -add the following line to /etc/modules.conf: +add the following line to /etc/modprobe.conf: alias des3_ede des --- diff/Documentation/digiboard.txt 2003-10-09 09:47:16.000000000 +0100 +++ source/Documentation/digiboard.txt 2004-02-23 13:56:39.000000000 +0000 @@ -24,7 +24,7 @@ The driver can be built direct into the The pcxx driver can be configured using the command line feature while loading the kernel with LILO or LOADLIN or, if built as a module, with arguments to insmod and modprobe or with parameters in -/etc/modules.conf for modprobe and kerneld. +/etc/modprobe.conf for modprobe and kerneld. After configuring the driver you need to create the device special files as described in "Device file creation:" below and set the appropriate @@ -91,13 +91,13 @@ devices following that board, you can em The remaining board still uses ttyD8-ttyD15 and cud8-cud15. -Example line for /etc/modules.conf for use with kerneld and as default +Example line for /etc/modprobe.conf for use with kerneld and as default parameters for modprobe: options pcxx io=0x200 numports=8 -For kerneld to work you will likely need to add these two lines to your -/etc/modules.conf: +For kmod to work you will likely need to add these two lines to your +/etc/modprobe.conf: alias char-major-22 pcxx alias char-major-23 pcxx --- diff/Documentation/early-userspace/README 2003-08-26 10:00:51.000000000 +0100 +++ source/Documentation/early-userspace/README 2004-02-23 13:56:39.000000000 +0000 @@ -72,4 +72,32 @@ For questions and help, you can sign up mailing list at http://www.zytor.com/mailman/listinfo/klibc +How does it work? +================= + +The kernel has currently 3 ways to mount the root filesystem: +a) all required device and filesystem drivers compiled into the + kernel, no initrd. init/main.c:init() will call prepare_namespace() + to mount the final root filesystem, based on the root= option + and optional init= to run some other init binary than listed + at the end of init/main.c:init(). +b) some device and filesystem drivers built as modules and stored in + an initrd. The initrd must contain a binary '/linuxrc' which is + supposed to load these driver modules. It is also possible to + mount the final root filesystem via linuxrc and use the pivot_root + syscall. The initrd is mounted and executed via prepare_namespace(). +c) using initramfs. The call to prepare_namespace() must be skipped. This + means that a binary must do all the work. Said binary can be stored + into initramfs either via modifying usr/gen_init_cpio.c or via the new + initrd format, an cpio archive. It must be called "/sbin/init". + A different binary can be specified with the kinit= boot option. + This binary is responsible to do all the things prepare_namespace() + would do. + To remain backwards compatibility, the kinit binary will only run if + it comes via an initramfs cpio archive, or if the kinit= option is + specified. If this is not the case, init/main.c:init() will run + prepare_namespace() to mount the final root and exec one of the + predefined init binaries. + + Bryan O'Sullivan --- diff/Documentation/fb/intel810.txt 2003-01-02 10:43:02.000000000 +0000 +++ source/Documentation/fb/intel810.txt 2004-02-23 13:56:39.000000000 +0000 @@ -194,7 +194,7 @@ Using the same setup as described above, modprobe i810fb vram=2 xres=1024 bpp=8 hsync1=30 hsync2=55 vsync1=50 \ vsync2=85 accel=1 mtrr=1 -Or just add the following to /etc/modules.conf +Or just add the following to /etc/modprobe.conf options i810fb vram=2 xres=1024 bpp=16 hsync1=30 hsync2=55 vsync1=50 \ vsync2=85 accel=1 mtrr=1 --- diff/Documentation/filesystems/jfs.txt 2003-10-27 09:20:36.000000000 +0000 +++ source/Documentation/filesystems/jfs.txt 2004-02-23 13:56:39.000000000 +0000 @@ -12,10 +12,9 @@ Barry Arndt barndt@us.ibm.com The following mount options are supported: iocharset=name Character set to use for converting from Unicode to - ASCII. The default is compiled into the kernel as - CONFIG_NLS_DEFAULT. Use iocharset=utf8 for UTF8 - translations. This requires CONFIG_NLS_UTF8 to be set - in the kernel .config file. + ASCII. The default is to do no conversion. Use + iocharset=utf8 for UTF8 translations. This requires + CONFIG_NLS_UTF8 to be set in the kernel .config file. resize=value Resize the volume to blocks. JFS only supports growing a volume, not shrinking it. This option is only @@ -36,18 +35,6 @@ errors=continue Keep going on a filesys errors=remount-ro Default. Remount the filesystem read-only on an error. errors=panic Panic and halt the machine if an error occurs. -JFS TODO list: - -Plans for our near term development items - - - enhance support for logfile on dedicated partition - -Longer term work items - - - implement defrag utility, for online defragmenting - - add quota support - - add support for block sizes (512,1024,2048) - Please send bugs, comments, cards and letters to shaggy@austin.ibm.com. The JFS mailing list can be subscribed to by using the link labeled --- diff/Documentation/filesystems/proc.txt 2003-09-17 12:28:01.000000000 +0100 +++ source/Documentation/filesystems/proc.txt 2004-02-23 13:56:39.000000000 +0000 @@ -900,6 +900,15 @@ super-nr shows the number of currently a Every mounted file system needs a super block, so if you plan to mount lots of file systems, you may want to increase these numbers. +aio-nr and aio-max-nr +--------------------- + +aio-nr is the running total of the number of events specified on the +io_setup system call for all currently active aio contexts. If aio-nr +reaches aio-max-nr then io_setup will fail with EAGAIN. Note that +raising aio-max-nr does not result in the pre-allocation or re-sizing +of any kernel data structures. + 2.2 /proc/sys/fs/binfmt_misc - Miscellaneous binary formats ----------------------------------------------------------- --- diff/Documentation/filesystems/ufs.txt 2002-10-16 04:28:31.000000000 +0100 +++ source/Documentation/filesystems/ufs.txt 2004-02-23 13:56:39.000000000 +0000 @@ -20,6 +20,9 @@ ufstype=type_of_ufs 44bsd used in FreeBSD, NetBSD, OpenBSD supported os read-write + ufs2 used in FreeBSD 5.x + supported os read-only + sun used in SunOS (Solaris) supported as read-write --- diff/Documentation/ftape.txt 2003-10-09 09:47:33.000000000 +0100 +++ source/Documentation/ftape.txt 2004-02-23 13:56:39.000000000 +0000 @@ -242,15 +242,15 @@ C. Boot and load time configuration Module parameters can be specified either directly when invoking the program 'insmod' at the shell prompt: - insmod ftape.o ft_tracing=4 + modprobe ftape ft_tracing=4 - or by editing the file `/etc/modules.conf' in which case they take + or by editing the file `/etc/modprobe.conf' in which case they take effect each time when the module is loaded with `modprobe' (please refer to the respective manual pages). Thus, you should add a line options ftape ft_tracing=4 - to `/etc/modules.conf` if you intend to increase the debugging + to `/etc/modprobe.conf` if you intend to increase the debugging output of the driver. @@ -298,7 +298,7 @@ C. Boot and load time configuration 5. Example module parameter setting ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To do the same, but with ftape compiled as a loadable kernel - module, add the following line to `/etc/modules.conf': + module, add the following line to `/etc/modprobe.conf': options ftape ft_probe_fc10=1 ft_tracing=4 --- diff/Documentation/hayes-esp.txt 2002-10-16 04:27:12.000000000 +0100 +++ source/Documentation/hayes-esp.txt 2004-02-23 13:56:39.000000000 +0000 @@ -109,7 +109,7 @@ option with a space. For example: insmod esp dma=3 trigger=512 The esp module can be automatically loaded when needed. To cause this to -happen, add the following lines to /etc/modules.conf (replacing the last line +happen, add the following lines to /etc/modprobe.conf (replacing the last line with options for your configuration): alias char-major-57 esp --- diff/Documentation/ide.txt 2003-10-27 09:20:36.000000000 +0000 +++ source/Documentation/ide.txt 2004-02-23 13:56:39.000000000 +0000 @@ -198,12 +198,11 @@ drivers can always be compiled as loadab can only be compiled into the kernel, and the core code (ide.c) can be compiled as a loadable module provided no chipset support is needed. -When using ide.c/ide-tape.c as modules in combination with kerneld, add: +When using ide.c as a module in combination with kmod, add: alias block-major-3 ide-probe - alias char-major-37 ide-tape -respectively to /etc/modules.conf. +to /etc/modprobe.conf. When ide.c is used as a module, you can pass command line parameters to the driver using the "options=" keyword to insmod, while replacing any ',' with @@ -231,9 +230,10 @@ Summary of ide driver parameters for ker "hdx=cyl,head,sect" : disk drive is present, with specified geometry - "hdx=remap" : remap access of sector 0 to sector 1 (for EZD) + "hdx=remap" : remap access of sector 0 to sector 1 (for EZDrive) - "hdx=remap63" : remap the drive: shift all by 63 sectors (for DM) + "hdx=remap63" : remap the drive: add 63 to all sector numbers + (for DM OnTrack) "hdx=autotune" : driver will attempt to tune interface speed to the fastest PIO mode supported, @@ -242,17 +242,10 @@ Summary of ide driver parameters for ker and quite likely to cause trouble with older/odd IDE drives. - "hdx=slow" : insert a huge pause after each access to the data - port. Should be used only as a last resort. - "hdx=swapdata" : when the drive is a disk, byte swap all data "hdx=bswap" : same as above.......... - "hdx=flash" : allows for more than one ata_flash disk to be - registered. In most cases, only one device - will be present. - "hdx=scsi" : the return of the ide-scsi flag, this is useful for allowing ide-floppy, ide-tape, and ide-cdrom|writers to use ide-scsi emulation on a device specific option. --- diff/Documentation/ioctl-number.txt 2003-10-09 09:47:33.000000000 +0100 +++ source/Documentation/ioctl-number.txt 2004-02-23 13:56:39.000000000 +0000 @@ -187,3 +187,5 @@ Code Seq# Include File Comments 0xB1 00-1F PPPoX 0xCB 00-1F CBM serial IEC bus in development: +0xDD 00-3F ZFCP device driver see drivers/s390/scsi/ + --- diff/Documentation/kbuild/makefiles.txt 2003-10-09 09:47:33.000000000 +0100 +++ source/Documentation/kbuild/makefiles.txt 2004-02-23 13:56:39.000000000 +0000 @@ -638,15 +638,6 @@ When kbuild executes the following steps #arch/i386/Makefile LDFLAGS_vmlinux := -e stext - LDFLAGS_BLOB Options for $(LD) when linking the initramfs blob - - The image used for initramfs is made during the build process. - LDFLAGS_BLOB is used to specify additional flags to be used when - creating the initramfs_data.o file. - Example: - #arch/i386/Makefile - LDFLAGS_BLOB := --format binary --oformat elf32-i386 - OBJCOPYFLAGS objcopy flags When $(call if_changed,objcopy) is used to translate a .o file, --- diff/Documentation/kbuild/modules.txt 2004-01-19 10:22:54.000000000 +0000 +++ source/Documentation/kbuild/modules.txt 2004-02-23 13:56:39.000000000 +0000 @@ -17,12 +17,52 @@ out-of-the-box support for installation Compiling modules outside the official kernel --------------------------------------------- -Often modules are developed outside the official kernel. -To keep up with changes in the build system the most portable way -to compile a module outside the kernel is to use the following command-line: + +Often modules are developed outside the official kernel. To keep up +with changes in the build system the most portable way to compile a +module outside the kernel is to use the kernel build system, +kbuild. Use the following command-line: make -C path/to/kernel/src SUBDIRS=$PWD modules This requires that a makefile exits made in accordance to -Documentation/kbuild/makefiles.txt. +Documentation/kbuild/makefiles.txt. Read that file for more details on +the build system. + +The following is a short summary of how to write your Makefile to get +you up and running fast. Assuming your module will be called +yourmodule.ko, your code should be in yourmodule.c and your Makefile +should include + +obj-m := yourmodule.o + +If the code for your module is in multiple files that need to be +linked, you need to tell the build system which files to compile. In +the case of multiple files, none of these files can be named +yourmodule.c because doing so would cause a problem with the linking +step. Assuming your code exists in file1.c, file2.c, and file3.c and +you want to build yourmodule.ko from them, your Makefile should +include + +obj-m := yourmodule.o +yourmodule-objs := file1.o file2.o file3.o + +Now for a final example to put it all together. Assuming the +KERNEL_SOURCE environment variable is set to the directory where you +compiled the kernel, a simple Makefile that builds yourmodule.ko as +described above would look like + +# Tells the build system to build yourmodule.ko. +obj-m := yourmodule.o + +# Tells the build system to build these object files and link them as +# yourmodule.o, before building yourmodule.ko. This line can be left +# out if all the code for your module is in one file, yourmodule.c. If +# you are using multiple files, none of these files can be named +# yourmodule.c. +yourmodule-objs := file1.o file2.o file3.o +# Invokes the kernel build system to come back to the current +# directory and build yourmodule.ko. +default: + make -C ${KERNEL_SOURCE} SUBDIRS=`pwd` modules --- diff/Documentation/kernel-parameters.txt 2004-02-09 10:36:07.000000000 +0000 +++ source/Documentation/kernel-parameters.txt 2004-02-23 13:56:39.000000000 +0000 @@ -174,11 +174,18 @@ running once the system is up. atascsi= [HW,SCSI] Atari SCSI - atkbd.set= [HW] Select keyboard code set - Format: + atkbd.extra= [HW] Enable extra LEDs and keys on IBM RapidAccess, EzKey + and similar keyboards + + atkbd.reset= [HW] Reset keyboard during initialization + + atkbd.set= [HW] Select keyboard code set + Format: (2 = AT (default) 3 = PS/2) + + atkbd.scroll= [HW] Enable scroll wheel on MS Office and similar keyboards + atkbd.softrepeat= [HW] Use software keyboard repeat - atkbd.reset= [HW] Reset keyboard during initialization autotest [IA64] @@ -237,7 +244,7 @@ running once the system is up. Forces specified timesource (if avaliable) to be used when calculating gettimeofday(). If specicified timesource is not avalible, it defaults to PIT. - Format: { pit | tsc | cyclone | ... } + Format: { pit | tsc | cyclone | pmtmr } hpet= [IA-32,HPET] option to disable HPET and use PIT. Format: disable @@ -292,6 +299,9 @@ running once the system is up. devfs= [DEVFS] See Documentation/filesystems/devfs/boot-options. + + dhash_entries= [KNL] + Set number of hash buckets for dentry cache. digi= [HW,SERIAL] IO parameters + enable/disable command. @@ -310,6 +320,23 @@ running once the system is up. dtc3181e= [HW,SCSI] + earlyprintk= [x86, x86_64] + early_printk=vga + early_printk=serial[,ttySn[,baudrate]] + + Append ,keep to not disable it when the real console + takes over. + + Only vga or serial at a time, not both. + + Currently only ttyS0 and ttyS1 are supported. + + Interaction with the standard serial driver is not + very good. + + The VGA output is eventually overwritten by the real + console. + eata= [HW,SCSI] eda= [HW,PS2] @@ -424,6 +451,9 @@ running once the system is up. idle= [HW] Format: idle=poll or idle=halt + ihash_entries= [KNL] + Set number of hash buckets for inode cache. + in2000= [HW,SCSI] See header of drivers/scsi/in2000.c. @@ -469,6 +499,9 @@ running once the system is up. keepinitrd [HW,ARM] + kinit= Specify the path to the init executable to replace + prepare_namespace() (for initramfs archives) + l2cr= [PPC] lapic [IA-32,APIC] Enable the local APIC even if BIOS disabled it. @@ -873,6 +906,9 @@ running once the system is up. resume= [SWSUSP] Specify the partition device for software suspension + rhash_entries= [KNL,NET] + Set number of hash buckets for route cache + riscom8= [HW,SERIAL] Format: [,[,...]] @@ -1135,6 +1171,9 @@ running once the system is up. tgfx_2= See Documentation/input/joystick-parport.txt. tgfx_3= + thash_entries= [KNL,NET] + Set number of hash buckets for TCP connection + tipar= [HW] See header of drivers/char/tipar.c. --- diff/Documentation/networking/baycom.txt 2002-10-16 04:28:34.000000000 +0100 +++ source/Documentation/networking/baycom.txt 2004-02-23 13:56:39.000000000 +0000 @@ -93,10 +93,10 @@ Every time a driver is inserted into the modems it should access at which ports. This can be done with the setbaycom utility. If you are only using one modem, you can also configure the driver from the insmod command line (or by means of an option line in -/etc/modules.conf). +/etc/modprobe.conf). Examples: - insmod baycom_ser_fdx mode="ser12*" iobase=0x3f8 irq=4 + modprobe baycom_ser_fdx mode="ser12*" iobase=0x3f8 irq=4 sethdlc -i bcsf0 -p mode "ser12*" io 0x3f8 irq 4 Both lines configure the first port to drive a ser12 modem at the first --- diff/Documentation/networking/bonding.txt 2004-02-18 08:54:06.000000000 +0000 +++ source/Documentation/networking/bonding.txt 2004-02-23 13:56:39.000000000 +0000 @@ -31,6 +31,7 @@ Verifying Bond Configuration Frequently Asked Questions High Availability Promiscuous Sniffing notes +8021q VLAN support Limitations Resources and Links @@ -73,9 +74,9 @@ To install ifenslave.c, do: Bond Configuration ================== -You will need to add at least the following line to /etc/modules.conf +You will need to add at least the following line to /etc/modprobe.conf so the bonding driver will automatically load when the bond0 interface is -configured. Refer to the modules.conf manual page for specific modules.conf +configured. Refer to the modprobe.conf manual page for specific modprobe.conf syntax details. The Module Parameters section of this document describes each bonding driver parameter. @@ -132,18 +133,14 @@ You can then create a script containing appropriate rc directory. If you specifically need all network drivers loaded before the bonding driver, -adding the following line to modules.conf will cause the network driver for +adding the following line to modprobe.conf will cause the network driver for eth0 and eth1 to be loaded before the bonding driver. -probeall bond0 eth0 eth1 bonding +install bond0 /sbin/modprobe -a eth0 eth1 && /sbin/modprobe bonding Be careful not to reference bond0 itself at the end of the line, or modprobe will die in an endless recursive loop. -To have device characteristics (such as MTU size) propagate to slave devices, -set the bond characteristics before enslaving the device. The characteristics -are propagated during the enslave process. - If running SNMP agents, the bonding driver should be loaded before any network drivers participating in a bond. This requirement is due to the the interface index (ipAdEntIfIndex) being associated to the first interface found with a @@ -191,7 +188,7 @@ Module Parameters Optional parameters for the bonding driver can be supplied as command line arguments to the insmod command. Typically, these parameters are specified in -the file /etc/modules.conf (see the manual page for modules.conf). The +the file /etc/modprobe.conf (see the manual page for modprobe.conf). The available bonding driver parameters are listed below. If a parameter is not specified the default value is used. When initially configuring a bond, it is recommended "tail -f /var/log/messages" be run in a separate window to @@ -601,7 +598,7 @@ Frequently Asked Questions For ethernet cards not supporting MII status, the arp_interval and arp_ip_target parameters must be specified for bonding to work correctly. If packets have not been sent or received during the - specified arp_interval durration, an ARP request is sent to the + specified arp_interval duration, an ARP request is sent to the targets to generate send and receive traffic. If after this interval, either the successful send and/or receive count has not incremented, the next slave in the sequence will become the active @@ -669,16 +666,8 @@ Frequently Asked Questions that will be added. To restore your slaves' MAC addresses, you need to detach them - from the bond (`ifenslave -d bond0 eth0'), set them down - (`ifconfig eth0 down'), unload the drivers (`rmmod 3c59x', for - example) and reload them to get the MAC addresses from their - eeproms. If the driver is shared by several devices, you need - to turn them all down. Another solution is to look for the MAC - address at boot time (dmesg or tail /var/log/messages) and to - reset it by hand with ifconfig : - - # ifconfig eth0 down - # ifconfig eth0 hw ether 00:20:40:60:80:A0 + from the bond (`ifenslave -d bond0 eth0'). The bonding driver will then + restore the MAC addresses that the slaves had before they were enslaved. 9. Which transmit polices can be used? @@ -742,9 +731,8 @@ Example: # modprobe bonding miimon=100 -Or, put the following lines in /etc/modules.conf: +Or, put the following line in /etc/modprobe.conf: - alias bond0 bonding options bond0 miimon=100 There are currently two policies for high availability. They are dependent on @@ -815,9 +803,8 @@ To use this mode, pass "mode=1" to the m # modprobe bonding miimon=100 mode=1 -Or, put in your /etc/modules.conf : +Or, put in your /etc/modprobe.conf : - alias bond0 bonding options bond0 miimon=100 mode=active-backup Example 1: Using multiple host and multiple switches to build a "no single @@ -843,7 +830,7 @@ point of failure" solution. In this configuration, there is an ISL - Inter Switch Link (could be a trunk), several servers (host1, host2 ...) attached to both switches each, and one or -more ports to the outside world (port3...). One an only one slave on each host +more ports to the outside world (port3...). One and only one slave on each host is active at a time, while all links are still monitored (the system can detect a failure of active and backup links). @@ -919,7 +906,6 @@ setting by hand. Specifically, when you must add the promisc flag there; it will be propagated down to the slave interfaces at ifenslave time; a full example might look like: - grep bond0 /etc/modules.conf || echo alias bond0 bonding >/etc/modules.conf ifconfig bond0 promisc up for if in eth1 eth2 ...;do ifconfig $if up @@ -933,6 +919,41 @@ capacity aggregating; but it works fine just ignore all the warnings it emits. +8021q VLAN support +================== + +It is possible to configure VLAN devices over a bond interface using the 8021q +driver. However, only packets coming from the 8021q driver and passing through +bonding will be tagged by default. Self generated packets, like bonding's +learning packets or ARP packets generated by either ALB mode or the ARP +monitor mechanism, are tagged internally by bonding itself. As a result, +bonding has to "learn" what VLAN IDs are configured on top of it, and it uses +those IDs to tag self generated packets. + +For simplicity reasons, and to support the use of adapters that can do VLAN +hardware acceleration offloding, the bonding interface declares itself as +fully hardware offloaing capable, it gets the add_vid/kill_vid notifications +to gather the necessary information, and it propagates those actions to the +slaves. +In case of mixed adapter types, hardware accelerated tagged packets that should +go through an adapter that is not offloading capable are "un-accelerated" by the +bonding driver so the VLAN tag sits in the regular location. + +VLAN interfaces *must* be added on top of a bonding interface only after +enslaving at least one slave. This is because until the first slave is added the +bonding interface has a HW address of 00:00:00:00:00:00, which will be copied by +the VLAN interface when it is created. + +Notice that a problem would occur if all slaves are released from a bond that +still has VLAN interfaces on top of it. When later coming to add new slaves, the +bonding interface would get a HW address from the first slave, which might not +match that of the VLAN interfaces. It is recommended that either all VLANs are +removed and then re-added, or to manually set the bonding interface's HW +address so it matches the VLAN's. (Note: changing a VLAN interface's HW address +would set the underlying device -- i.e. the bonding interface -- to promiscouos +mode, which might not be what you want). + + Limitations =========== The main limitations are : --- diff/Documentation/networking/dl2k.txt 2002-10-16 04:28:29.000000000 +0100 +++ source/Documentation/networking/dl2k.txt 2004-02-23 13:56:39.000000000 +0000 @@ -37,15 +37,15 @@ Quick Install Install linux driver as following command: 1. make all -2. insmod dl2k.o +2. insmod dl2k.ko 3. ifconfig eth0 up 10.xxx.xxx.xxx netmask 255.0.0.0 ^^^^^^^^^^^^^^^\ ^^^^^^^^\ IP NETMASK Now eth0 should active, you can test it by "ping" or get more information by "ifconfig". If tested ok, continue the next step. -4. cp dl2k.o /lib/modules/`uname -r`/kernel/drivers/net -5. Add the following lines to /etc/modules.conf: +4. cp dl2k.ko /lib/modules/`uname -r`/kernel/drivers/net +5. Add the following line to /etc/modprobe.conf: alias eth0 dl2k 6. Run "netconfig" or "netconf" to create configuration script ifcfg-eth0 located at /etc/sysconfig/network-scripts or create it manually. @@ -154,8 +154,8 @@ Installing the Driver ----------------- 1. Copy dl2k.o to the network modules directory, typically /lib/modules/2.x.x-xx/net or /lib/modules/2.x.x/kernel/drivers/net. - 2. Locate the boot module configuration file, most commonly modules.conf - or conf.modules in the /etc directory. Add the following lines: + 2. Locate the boot module configuration file, most commonly modprobe.conf + or modules.conf (for 2.4) in the /etc directory. Add the following lines: alias ethx dl2k options dl2k --- diff/Documentation/networking/ifenslave.c 2004-02-18 08:54:06.000000000 +0000 +++ source/Documentation/networking/ifenslave.c 2004-02-23 13:56:39.000000000 +0000 @@ -89,13 +89,13 @@ * while it is running. It was already set during enslave. To * simplify things, it is now handeled separately. * - * - 2003/09/24 - Shmulik Hen + * - 2003/12/01 - Shmulik Hen * - Code cleanup and style changes * set version to 1.1.0 */ #define APP_VERSION "1.1.0" -#define APP_RELDATE "Septemer 24, 2003" +#define APP_RELDATE "December 1, 2003" #define APP_NAME "ifenslave" static char *version = --- diff/Documentation/networking/ip-sysctl.txt 2004-02-18 08:54:06.000000000 +0000 +++ source/Documentation/networking/ip-sysctl.txt 2004-02-23 13:56:39.000000000 +0000 @@ -499,6 +499,55 @@ arp_filter - BOOLEAN conf/{all,interface}/arp_filter is set to TRUE, it will be disabled otherwise +arp_announce - INTEGER + Define different restriction levels for announcing the local + source IP address from IP packets in ARP requests sent on + interface: + 0 - (default) Use any local address, configured on any interface + 1 - Try to avoid local addresses that are not in the target's + subnet for this interface. This mode is useful when target + hosts reachable via this interface require the source IP + address in ARP requests to be part of their logical network + configured on the receiving interface. When we generate the + request we will check all our subnets that include the + target IP and will preserve the source address if it is from + such subnet. If there is no such subnet we select source + address according to the rules for level 2. + 2 - Always use the best local address for this target. + In this mode we ignore the source address in the IP packet + and try to select local address that we prefer for talks with + the target host. Such local address is selected by looking + for primary IP addresses on all our subnets on the outgoing + interface that include the target IP address. If no suitable + local address is found we select the first local address + we have on the outgoing interface or on all other interfaces, + with the hope we will receive reply for our request and + even sometimes no matter the source IP address we announce. + + The max value from conf/{all,interface}/arp_announce is used. + + Increasing the restriction level gives more chance for + receiving answer from the resolved target while decreasing + the level announces more valid sender's information. + +arp_ignore - INTEGER + Define different modes for sending replies in response to + received ARP requests that resolve local target IP addresses: + 0 - (default): reply for any local target IP address, configured + on any interface + 1 - reply only if the target IP address is local address + configured on the incoming interface + 2 - reply only if the target IP address is local address + configured on the incoming interface and both with the + sender's IP address are part from same subnet on this interface + 3 - do not reply for local addresses configured with scope host, + only resolutions for global and link addresses are replied + 4-7 - reserved + 8 - do not reply for all local addresses + + The max value from conf/{all,interface}/arp_ignore is used + when ARP request is received on the {interface} + tag - INTEGER Allows you to write a number, which can be used as required. Default value is 0. --- diff/Documentation/networking/ltpc.txt 2002-10-16 04:27:48.000000000 +0100 +++ source/Documentation/networking/ltpc.txt 2004-02-23 13:56:39.000000000 +0000 @@ -25,7 +25,7 @@ the driver will try to determine them it If you load the driver as a module, you can pass the parameters "io=", "irq=", and "dma=" on the command line with insmod or modprobe, or add -them as options in /etc/modules.conf: +them as options in /etc/modprobe.conf: alias lt0 ltpc # autoload the module when the interface is configured options ltpc io=0x240 irq=9 dma=1 --- diff/Documentation/networking/sk98lin.txt 2004-02-09 10:36:07.000000000 +0000 +++ source/Documentation/networking/sk98lin.txt 2004-02-23 13:56:39.000000000 +0000 @@ -1,10 +1,10 @@ -(C)Copyright 1999-2003 Marvell(R). +(C)Copyright 1999-2004 Marvell(R). All rights reserved =========================================================================== -sk98lin.txt created 15-Dec-2003 +sk98lin.txt created 13-Feb-2004 -Readme File for sk98lin v6.21 +Readme File for sk98lin v6.23 Marvell Yukon/SysKonnect SK-98xx Gigabit Ethernet Adapter family driver for LINUX This file contains @@ -174,7 +174,7 @@ In some distributions, the configuration to the driver module. If you use the kernel module loader, you can set driver parameters -in the file /etc/modules.conf (or old name: /etc/conf.modules). +in the file /etc/modprobe.conf (or /etc/modules.conf in 2.4 or earlier). To set the driver parameters in this file, proceed as follows: 1. Insert a line of the form : --- diff/Documentation/networking/tuntap.txt 2003-05-21 11:49:49.000000000 +0100 +++ source/Documentation/networking/tuntap.txt 2004-02-23 13:56:39.000000000 +0000 @@ -45,13 +45,10 @@ Copyright (C) 1999-2000 Maxim Krasnyansk bogus network interfaces to trick firewalls or administrators. Driver module autoloading - Make sure that "Kernel module loader" - module auto-loading support is enabled - in your kernel. - Add the following line to the /etc/modules.conf: - alias char-major-10-200 tun - and run - depmod -a + Make sure that "Kernel module loader" - module auto-loading + support is enabled in your kernel. The kernel should load it on + first access. Manual loading insert the module by hand: --- diff/Documentation/networking/vortex.txt 2003-08-20 14:16:23.000000000 +0100 +++ source/Documentation/networking/vortex.txt 2004-02-23 13:56:39.000000000 +0000 @@ -59,8 +59,8 @@ Module parameters ================= There are several parameters which may be provided to the driver when -its module is loaded. These are usually placed in /etc/modules.conf -(used to be conf.modules). Example: +its module is loaded. These are usually placed in /etc/modprobe.conf +(/etc/modules.conf in 2.4). Example: options 3c59x debug=3 rx_copybreak=300 @@ -216,6 +216,19 @@ watchdog=N to increase this value on LANs which have very high collision rates. The default value is 5000 (5.0 seconds). +enable_wol=N1,N2,N3,... + + Enable Wake-on-LAN support for the relevant interface. Donald + Becker's `ether-wake' application may be used to wake suspended + machines. + + Also enables the NIC's power management support. + +global_enable_wol=N + + Sets enable_wol mode for all 3c59x NICs in the machine. Entries in + the `enable_wol' array above will override any setting of this. + Media selection --------------- @@ -413,9 +426,9 @@ steps you should take: 1) Increase the debug level. Usually this is done via: - a) modprobe driver.o debug=7 - b) In /etc/conf.modules (or modules.conf): - options driver_name debug=7 + a) modprobe driver debug=7 + b) In /etc/modprobe.conf (or /etc/modules.conf for 2.4): + options driver debug=7 2) Recreate the problem with the higher debug level, send all logs to the maintainer. --- diff/Documentation/parport.txt 2002-10-16 04:28:25.000000000 +0100 +++ source/Documentation/parport.txt 2004-02-23 13:56:40.000000000 +0000 @@ -39,7 +39,7 @@ are automatically detected. KMod ---- -If you use kmod, you will find it useful to edit /etc/modules.conf. +If you use kmod, you will find it useful to edit /etc/modprobe.conf. Here is an example of the lines that need to be added: alias parport_lowlevel parport_pc --- diff/Documentation/rocket.txt 2003-06-30 10:07:18.000000000 +0100 +++ source/Documentation/rocket.txt 2004-02-23 13:56:40.000000000 +0000 @@ -43,7 +43,7 @@ in the system log at /var/log/messages. If installed as a module, the module must be loaded. This can be done manually by entering "modprobe rocket". To have the module loaded automatically -upon system boot, edit the /etc/modules.conf file and add the line +upon system boot, edit the /etc/modprobe.conf file and add the line "alias char-major-46 rocket". In order to use the ports, their device names (nodes) must be created with mknod. --- diff/Documentation/s390/3270.txt 2003-08-20 14:16:23.000000000 +0100 +++ source/Documentation/s390/3270.txt 2004-02-23 13:56:40.000000000 +0000 @@ -48,7 +48,7 @@ one another. ReIPL as soon as possible script and the resulting /tmp/mkdev3270. If you have chosen to make tub3270 a module, you add a line to -/etc/modules.conf. If you are working on a VM virtual machine, you +/etc/modprobe.conf. If you are working on a VM virtual machine, you can use DEF GRAF to define virtual 3270 devices. You may generate both 3270 and 3215 console support, or one or the @@ -60,7 +60,7 @@ at boot time to a 3270 if it is a 3215. In brief, these are the steps: 1. Install the tub3270 patch - 2. (If a module) add a line to /etc/modules.conf + 2. (If a module) add a line to /etc/modprobe.conf 3. (If VM) define devices with DEF GRAF 4. Reboot 5. Configure @@ -84,13 +84,13 @@ Here are the installation steps in detai make modules_install 2. (Perform this step only if you have configured tub3270 as a - module.) Add a line to /etc/modules.conf to automatically + module.) Add a line to /etc/modprobe.conf to automatically load the driver when it's needed. With this line added, you will see login prompts appear on your 3270s as soon as boot is complete (or with emulated 3270s, as soon as you dial into your vm guest using the command "DIAL "). Since the line-mode major number is 227, the line to add to - /etc/modules.conf should be: + /etc/modprobe.conf should be: alias char-major-227 tub3270 3. Define graphic devices to your vm guest machine, if you --- diff/Documentation/s390/CommonIO 2003-09-30 15:46:10.000000000 +0100 +++ source/Documentation/s390/CommonIO 2004-02-23 13:56:40.000000000 +0000 @@ -8,23 +8,26 @@ Command line parameters Determines whether information on found devices and sensed device characteristics should be shown during startup, i. e. messages of the types - "Detected device 4711 on subchannel 42" and "SenseID: Device 4711 reports: ...". + "Detected device 0.0.4711 on subchannel 0.0.0042" and "SenseID: Device + 0.0.4711 reports: ...". Default is off. * cio_notoper_msg = yes | no - Determines whether messages of the type "Device 4711 became 'not operational'" - should be shown during startup; after startup, they will always be shown. + Determines whether messages of the type "Device 0.0.4711 became 'not + operational'" should be shown during startup; after startup, they will always + be shown. Default is on. -* cio_ignore = | , - | , ... +* cio_ignore = {all} | + { | } | + {! | !} - The given device numbers will be ignored by the common I/O-layer; no detection + The given devices will be ignored by the common I/O-layer; no detection and device sensing will be done on any of those devices. The subchannel to which the device in question is attached will be treated as if no device was attached. @@ -32,12 +35,19 @@ Command line parameters An ignored device can be un-ignored later; see the "/proc entries"-section for details. - The device numbers must be given hexadecimal. + The devices must be given either as bus ids (0.0.abcd) or as hexadecimal + device numbers (0xabcd or abcd, for 2.4 backward compatibility). + You can use the 'all' keyword to ignore all devices. + The '!' operator will cause the I/O-layer to _not_ ignore a device. + The order on the command line is not important. For example, - cio_ignore=0x23-0x42,0x4711 - will ignore all devices with device numbers ranging from 23 to 42 and the - device with device number 4711, if detected. + cio_ignore=0.0.0023-0.0.0042,0.0.4711 + will ignore all devices ranging from 0.0.0023 to 0.0.0042 and the device + 0.0.4711, if detected. + As another example, + cio_ignore=all,!0.0.4711,!0.0.fd00-0.0.fd02 + will ignore all devices but 0.0.4711, 0.0.fd00, 0.0.fd01, 0.0.fd02. By default, no devices are ignored. @@ -47,17 +57,19 @@ Command line parameters * /proc/cio_ignore - Lists the ranges of device numbers which are ignored by common I/O. + Lists the ranges of devices (by bus id) which are ignored by common I/O. You can un-ignore certain or all devices by piping to /proc/cio_ignore. "free all" will un-ignore all ignored devices, - "free , , ..." will un-ignore the specified devices. + "free , , ..." will un-ignore the specified + devices. - For example, if devices 23 to 42 and 4711 are ignored, - - echo free 0x30-0x32 > /proc/cio_ignore - will un-ignore devices 30 to 32 and will leave devices 23 to 2F, 33 to 42 - and 4711 ignored; - - echo free 0x41 > /proc/cio_ignore will furthermore un-ignore device 41; + For example, if devices 0.0.0023 to 0.0.0042 and 0.0.4711 are ignored, + - echo free 0.0.0030-0.0.0032 > /proc/cio_ignore + will un-ignore devices 0.0.0030 to 0.0.0032 and will leave devices 0.0.0023 + to 0.0.002f, 0.0.0033 to 0.0.0042 and 0.0.4711 ignored; + - echo free 0.0.0041 > /proc/cio_ignore will furthermore un-ignore device + 0.0.0041; - echo free all > /proc/cio_ignore will un-ignore all remaining ignored devices. @@ -66,15 +78,19 @@ Command line parameters available to the system. You can also add ranges of devices to be ignored by piping to - /proc/cio_ignore; "add , , ..." will ignore the + /proc/cio_ignore; "add , , ..." will ignore the specified devices. - Note: Already known devices cannot be ignored; this also applies to devices - which are gone after a machine check. + Note: Already known devices cannot be ignored. - For example, if device abcd is already known and all other devices a000-afff - are not known, "echo add 0xa000-0xaccc, 0xaf00-0xafff > /proc/cio_ignore" - will add af00-afff to the list of ignored devices and skip a000-accc. + For example, if device 0.0.abcd is already known and all other devices + 0.0.a000-0.0.afff are not known, + "echo add 0.0.a000-0.0.accc, 0.0.af00-0.0.afff > /proc/cio_ignore" + will add 0.0.a000-0.0.abcc, 0.0.abce-0.0.accc and 0.0.af00-0.0.afff to the + list of ignored devices and skip 0.0.abcd. + + The devices can be specified either by bus id (0.0.abcd) or, for 2.4 backward + compatibilty, by the device number in hexadecimal (0xabcd or abcd). * /proc/s390dbf/cio_*/ (S/390 debug feature) --- diff/Documentation/s390/driver-model.txt 2004-02-09 10:36:07.000000000 +0000 +++ source/Documentation/s390/driver-model.txt 2004-02-23 13:56:40.000000000 +0000 @@ -216,9 +216,17 @@ mind that most drivers will need to impl Channel paths show up, like subchannels, under the channel subsystem root (css0) and are called 'chp0.'. They have no driver and do not belong to any bus. +Please note, that unlike /proc/chpids in 2.4, the channel path objects reflect +only the logical state and not the physical state, since we cannot track the +latter consistently due to lacking machine support (we don't need to be aware +of anyway). -status - Can be 'online', 'logically offline' or 'n/a'. +status - Can be 'online' or 'offline'. Piping 'on' or 'off' sets the chpid logically online/offline. + Piping 'on' to an online chpid triggers path reprobing for all devices + the chpid connects to. This can be used to force the kernel to re-use + a channel path the user knows to be online, but the machine hasn't + created a machine check for. 3. System devices --- diff/Documentation/scsi/aic79xx.txt 2004-01-19 10:22:54.000000000 +0000 +++ source/Documentation/scsi/aic79xx.txt 2004-02-23 13:56:40.000000000 +0000 @@ -210,7 +210,7 @@ The following information is available i INCORRECTLY CAN RENDER YOUR SYSTEM INOPERABLE. USE THEM WITH CAUTION. - Edit the file "modules.conf" in the directory /etc and add/edit a + Edit the file "modprobe.conf" in the directory /etc and add/edit a line containing 'options aic79xx aic79xx=[command[,command...]]' where 'command' is one or more of the following: ----------------------------------------------------------------- --- diff/Documentation/scsi/aic7xxx.txt 2004-01-19 10:22:54.000000000 +0000 +++ source/Documentation/scsi/aic7xxx.txt 2004-02-23 13:56:40.000000000 +0000 @@ -186,7 +186,7 @@ The following information is available i INCORRECTLY CAN RENDER YOUR SYSTEM INOPERABLE. USE THEM WITH CAUTION. - Edit the file "modules.conf" in the directory /etc and add/edit a + Edit the file "modprobe.conf" in the directory /etc and add/edit a line containing 'options aic7xxx aic7xxx=[command[,command...]]' where 'command' is one or more of the following: ----------------------------------------------------------------- --- diff/Documentation/scsi/osst.txt 2002-11-18 10:11:54.000000000 +0000 +++ source/Documentation/scsi/osst.txt 2004-02-23 13:56:40.000000000 +0000 @@ -67,7 +67,7 @@ recognized. If you want to have the module autoloaded on access to /dev/osst, you may add something like alias char-major-206 osst -to your /etc/modules.conf (old name: conf.modules). +to your /etc/modprobe.conf (before 2.6: modules.conf). You may find it convenient to create a symbolic link ln -s nosst0 /dev/tape --- diff/Documentation/scsi/st.txt 2004-01-19 10:22:54.000000000 +0000 +++ source/Documentation/scsi/st.txt 2004-02-23 13:56:40.000000000 +0000 @@ -2,7 +2,7 @@ This file contains brief information abo The driver is currently maintained by Kai Mäkisara (email Kai.Makisara@kolumbus.fi) -Last modified: Sun Nov 9 22:36:02 2003 by makisara +Last modified: Thu Feb 19 21:57:30 2004 by makisara BASICS @@ -113,6 +113,26 @@ backward compatible with the numbering u only 8 bits wide. +SYSFS SUPPORT + +The driver creates the directory /sys/class/scsi_tape and populates it with +directories corresponding to the existing tape devices. There are autorewind +and non-rewind entries for each mode. The names are stxmy and stxmyn, where x +is the tape number and y is the mode. For example, the directories for the +first tape device are (assuming four modes): st0m0 st0m0n st0m1 st0m1n +st0m2 st0m2n st0m3 st0m3n. + +Each directory contains the entries: default_blksize default_compression +default_density defined dev device driver. The file 'defined' contains 1 +if the mode is defined and zero if not defined. The files 'default_*' contain +the defaults set by the user. The value -1 means the default is not set. The +file 'dev' contains the device numbers corresponding to this device. The links +'device' and 'driver' point to the SCSI device and driver entries. + +A link named 'tape' is made from the SCSI device directory to the class +directory corresponding to the mode 0 auto-rewind device (e.g., st0m0). + + BSD AND SYS V SEMANTICS The user can choose between these two behaviours of the tape driver by @@ -126,7 +146,7 @@ The default is BSD semantics. BUFFERING -The driver tries to do tranfers directly to/from user space. If this +The driver tries to do transfers directly to/from user space. If this is not possible, a driver buffer allocated at run-time is used. If direct i/o is not possible for the whole transfer, the driver buffer is used (i.e., bounce buffers for individual pages are not @@ -147,6 +167,12 @@ Buffer allocation uses chunks of memory size). Because of this the actual buffer size may be larger than the minimum allowable buffer size. +NOTE that if direct i/o is used, the small writes are not buffered. This may +cause a surprise when moving from 2.4. There small writes (e.g., tar without +-b option) may have had good throughput but this is not true any more with +2.6. Direct i/o can be turned off to solve this problem but a better solution +is to use bigger write() byte counts (e.g., tar -b 64). + Asynchronous writing. Writing the buffer contents to the tape is started and the write call returns immediately. The status is checked at the next tape operation. Asynchronous writes are not done with @@ -453,7 +479,7 @@ DEBUGGING HINTS To enable debugging messages, edit st.c and #define DEBUG 1. As seen above, debugging can be switched off with an ioctl if debugging is -compiled into the driver. The debugging output is not voluminuous. +compiled into the driver. The debugging output is not voluminous. If the tape seems to hang, I would be very interested to hear where the driver is waiting. With the command 'ps -l' you can see the state --- diff/Documentation/sonypi.txt 2003-09-17 12:28:01.000000000 +0100 +++ source/Documentation/sonypi.txt 2004-02-23 13:56:40.000000000 +0000 @@ -43,7 +43,7 @@ Driver options: --------------- Several options can be passed to the sonypi driver, either by adding them -to /etc/modules.conf file, when the driver is compiled as a module or by +to /etc/modprobe.conf file, when the driver is compiled as a module or by adding the following to the kernel command line (in your bootloader): sonypi=minor[,verbose[,fnkeyinit[,camera[,compat[,mask[,useinput]]]]]] @@ -109,7 +109,7 @@ Module use: ----------- In order to automatically load the sonypi module on use, you can put those -lines in your /etc/modules.conf file: +lines in your /etc/modprobe.conf file: alias char-major-10-250 sonypi options sonypi minor=250 --- diff/Documentation/sound/alsa/ALSA-Configuration.txt 2004-02-18 08:54:06.000000000 +0000 +++ source/Documentation/sound/alsa/ALSA-Configuration.txt 2004-02-23 13:56:40.000000000 +0000 @@ -692,6 +692,15 @@ Module parameters The power-management is supported. + Module snd-mixart + ----------------- + + Module for Digigram miXart8 soundcards. + + Module supports multiple cards. + Note: One miXart8 board will be represented as 4 alsa cards. + See MIXART.txt for details. + Module snd-mpu401 ----------------- --- diff/Documentation/sound/oss/AWE32 2002-10-16 04:28:25.000000000 +0100 +++ source/Documentation/sound/oss/AWE32 2004-02-23 13:56:40.000000000 +0000 @@ -47,12 +47,12 @@ SB32. Copy it to a directory of your choice, and unpack it there. -4) Edit /etc/modules.conf, and insert the following lines at the end of the +4) Edit /etc/modprobe.conf, and insert the following lines at the end of the file: alias sound-slot-0 sb alias sound-service-0-1 awe_wave - post-install awe_wave /usr/local/bin/sfxload PATH_TO_SOUND_BANK_FILE + install awe_wave /sbin/modprobe --first-time -i awe_wave && /usr/local/bin/sfxload PATH_TO_SOUND_BANK_FILE You will of course have to change "PATH_TO_SOUND_BANK_FILE" to the full path of of the sound bank file. That will enable the Sound Blaster and AWE --- diff/Documentation/sound/oss/AudioExcelDSP16 2002-10-16 04:27:08.000000000 +0100 +++ source/Documentation/sound/oss/AudioExcelDSP16 2004-02-23 13:56:40.000000000 +0000 @@ -41,7 +41,7 @@ mpu_base I/O base address for activate M (0x300, 0x310, 0x320 or 0x330) mpu_irq MPU-401 irq line (5, 7, 9, 10 or 0) -The /etc/modules.conf will have lines like this: +The /etc/modprobe.conf will have lines like this: options opl3 io=0x388 options ad1848 io=0x530 irq=11 dma=3 @@ -51,11 +51,11 @@ Where the aedsp16 options are the option ad1848 are the corresponding options for the MSS and OPL3 modules. Loading MSS and OPL3 needs to pre load the aedsp16 module to set up correctly -the sound card. Installation dependencies must be written in the modules.conf +the sound card. Installation dependencies must be written in the modprobe.conf file: -pre-install ad1848 modprobe aedsp16 -pre-install opl3 modprobe aedsp16 +install ad1848 /sbin/modprobe aedsp16 && /sbin/modprobe -i ad1848 +install opl3 /sbin/modprobe aedsp16 && /sbin/modprobe -i opl3 Then you must load the sound modules stack in this order: sound -> aedsp16 -> [ ad1848, opl3 ] --- diff/Documentation/sound/oss/CMI8330 2004-01-19 10:22:54.000000000 +0000 +++ source/Documentation/sound/oss/CMI8330 2004-02-23 13:56:40.000000000 +0000 @@ -143,7 +143,7 @@ CONFIG_SOUND_MSS=m -Alma Chao suggests the following /etc/modules.conf: +Alma Chao suggests the following /etc/modprobe.conf: alias sound ad1848 alias synth0 opl3 --- diff/Documentation/sound/oss/Introduction 2004-01-19 10:22:54.000000000 +0000 +++ source/Documentation/sound/oss/Introduction 2004-02-23 13:56:40.000000000 +0000 @@ -168,7 +168,7 @@ MODPROBE: ========= If loading via modprobe, these common files are automatically loaded -when requested by modprobe. For example, my /etc/modules.conf contains: +when requested by modprobe. For example, my /etc/modprobe.conf contains: alias sound sb options sb io=0x240 irq=9 dma=3 dma16=5 mpu_io=0x300 @@ -228,7 +228,7 @@ http://www.opensound.com. Before loadin driver, you should do the following: 1. remove sound modules (detailed above) -2. remove the sound modules from /etc/modules.conf +2. remove the sound modules from /etc/modprobe.conf 3. move the sound modules from /lib/modules//misc (for example, I make a /lib/modules//misc/tmp directory and copy the sound module files to that @@ -265,7 +265,7 @@ twice, you need to do the following: sb.o could be copied (or symlinked) to sb1.o for the second SoundBlaster. -2. Make a second entry in /etc/modules.conf, for example, +2. Make a second entry in /etc/modprobe.conf, for example, sound1 or sb1. This second entry should refer to the new module names for example sb1, and should include the I/O, etc. for the second sound card. @@ -369,7 +369,7 @@ There are several ways of configuring yo 2) On the command line when using insmod or in a bash script using command line calls to load sound. -3) In /etc/modules.conf when using modprobe. +3) In /etc/modprobe.conf when using modprobe. 4) Via Red Hat's GPL'd /usr/sbin/sndconfig program (text based). --- diff/Documentation/sound/oss/MAD16 2002-10-16 04:29:06.000000000 +0100 +++ source/Documentation/sound/oss/MAD16 2004-02-23 13:56:40.000000000 +0000 @@ -1,4 +1,5 @@ -(This recipe has been edited to update the configuration symbols.) +(This recipe has been edited to update the configuration symbols, + and change over to modprobe.conf for 2.6) From: Shaw Carruthers @@ -20,9 +21,9 @@ CONFIG_SOUND_ADLIB=m CONFIG_SOUND_MAD16=m CONFIG_SOUND_YM3812=m -modules.conf has: +modprobe.conf has: -alias char-major-14 mad16 +alias char-major-14-* mad16 options sb mad16=1 options mad16 io=0x530 irq=7 dma=0 dma16=1 && /usr/local/bin/aumix -w 15 -p 20 -m 0 -1 0 -2 0 -3 0 -i 0 --- diff/Documentation/sound/oss/Maestro3 2002-10-16 04:28:34.000000000 +0100 +++ source/Documentation/sound/oss/Maestro3 2004-02-23 13:56:40.000000000 +0000 @@ -64,7 +64,7 @@ It may be modular or statically linked. installed with the rest of the modules for the kernel on the system. Typically this will be in /lib/modules/ somewhere. 'alias sound-slot-0 maestro3' should also be added to your module configs (typically -/etc/modules.conf) if you're using modular OSS/Lite sound and want to +/etc/modprobe.conf) if you're using modular OSS/Lite sound and want to default to using a maestro3 chip. There are very few options to the driver. One is 'debug' which will --- diff/Documentation/sound/oss/OPL3-SA2 2002-10-16 04:27:14.000000000 +0100 +++ source/Documentation/sound/oss/OPL3-SA2 2004-02-23 13:56:40.000000000 +0000 @@ -162,7 +162,7 @@ modprobe opl3sa2 io=0x370 mss_io=0x530 m modprobe opl3 io=0x388 See the section "Automatic Module Loading" below for how to set up -/etc/modules.conf to automate this. +/etc/modprobe.conf to automate this. An important thing to remember that the opl3sa2 module's io argument is for it's own control port, which handles the card's master mixer for @@ -196,7 +196,7 @@ Automatic Module Loading Lastly, if you're using modules and want to set up automatic module loading with kmod, the kernel module loader, here is the section I -currently use in my modules.conf file: +currently use in my modprobe.conf file: # Sound alias sound-slot-0 opl3sa2 --- diff/Documentation/sound/oss/Opti 2002-10-16 04:27:53.000000000 +0100 +++ source/Documentation/sound/oss/Opti 2004-02-23 13:56:40.000000000 +0000 @@ -18,7 +18,7 @@ force the card into a mode in which it c If you have another OS installed on your computer it is recommended that Linux and the other OS use the same resources. -Also, it is recommended that resources specified in /etc/modules.conf +Also, it is recommended that resources specified in /etc/modprobe.conf and resources specified in /etc/isapnp.conf agree. Compiling the sound driver @@ -68,9 +68,9 @@ address is hard-coded into the driver. Using kmod and autoloading the sound driver ------------------------------------------- Comment: as of linux-2.1.90 kmod is replacing kerneld. -The config file '/etc/modules.conf' is used as before. +The config file '/etc/modprobe.conf' is used as before. -This is the sound part of my /etc/modules.conf file. +This is the sound part of my /etc/modprobe.conf file. Following that I will explain each line. alias mixer0 mad16 @@ -80,7 +80,7 @@ alias synth0 opl3 options sb mad16=1 options mad16 irq=10 dma=0 dma16=1 io=0x530 joystick=1 cdtype=0 options opl3 io=0x388 -post-install mad16 /sbin/ad1848_mixer_reroute 14 8 15 3 16 6 +install mad16 /sbin/modprobe -i mad16 && /sbin/ad1848_mixer_reroute 14 8 15 3 16 6 If you have an MPU daughtercard or onboard MPU you will want to add to the "options mad16" line - eg --- diff/Documentation/sound/oss/PAS16 2004-01-19 10:22:54.000000000 +0000 +++ source/Documentation/sound/oss/PAS16 2004-02-23 13:56:40.000000000 +0000 @@ -129,7 +129,7 @@ CONFIG_SOUND_YM3812 You can then get OPL3 functionality by issuing the command: insmod opl3 In addition, you must either add the following line to - /etc/modules.conf: + /etc/modprobe.conf: options opl3 io=0x388 or else add the following line to /etc/lilo.conf: opl3=0x388 @@ -159,5 +159,5 @@ following line would be appropriate: append="pas2=0x388,10,3,-1,0,-1,-1,-1 opl3=0x388" If sound is built totally modular, the above options may be -specified in /etc/modules.conf for pas2.o, sb.o and opl3.o +specified in /etc/modprobe.conf for pas2, sb and opl3 respectively. --- diff/Documentation/sound/oss/README.modules 2002-10-16 04:27:53.000000000 +0100 +++ source/Documentation/sound/oss/README.modules 2004-02-23 13:56:40.000000000 +0000 @@ -26,10 +26,10 @@ Note that it is no longer necessary or p drivers/sound dir. Now one simply configures and makes one's kernel and modules in the usual way. - Then, add to your /etc/modules.conf something like: + Then, add to your /etc/modprobe.conf something like: -alias char-major-14 sb -post-install sb /sbin/modprobe "-k" "adlib_card" +alias char-major-14-* sb +install sb /sbin/modprobe -i sb && /sbin/modprobe adlib_card options sb io=0x220 irq=7 dma=1 dma16=5 mpu_io=0x330 options adlib_card io=0x388 # FM synthesizer @@ -65,12 +65,12 @@ at the init_module() code for the card t Note that at present there is no way to configure the io, irq and other parameters for the modular drivers as one does for the wired drivers.. One needs to pass the modules the necessary parameters as arguments, either -with /etc/modules.conf or with command-line args to modprobe, e.g. +with /etc/modprobe.conf or with command-line args to modprobe, e.g. -modprobe -k sb io=0x220 irq=7 dma=1 dma16=5 mpu_io=0x330 -modprobe -k adlib_card io=0x388 +modprobe sb io=0x220 irq=7 dma=1 dma16=5 mpu_io=0x330 +modprobe adlib_card io=0x388 - recommend using /etc/modules.conf. + recommend using /etc/modprobe.conf. Persistent DMA Buffers: @@ -88,7 +88,7 @@ wasteful of RAM, but it guarantees that To make the sound driver use persistent DMA buffers we need to pass the sound.o module a "dmabuf=1" command-line argument. This is normally done -in /etc/modules.conf like so: +in /etc/modprobe.conf like so: options sound dmabuf=1 --- diff/Documentation/sound/oss/Wavefront 2004-01-19 10:22:54.000000000 +0000 +++ source/Documentation/sound/oss/Wavefront 2004-02-23 13:56:40.000000000 +0000 @@ -189,16 +189,15 @@ Here's my autoconf.h SOUND section: 6) How do I configure my card ? ************************************************************ -You need to edit /etc/modules.conf. Here's mine (edited to show the +You need to edit /etc/modprobe.conf. Here's mine (edited to show the relevant details): # Sound system - alias char-major-14 wavefront + alias char-major-14-* wavefront alias synth0 wavefront alias mixer0 cs4232 alias audio0 cs4232 - pre-install wavefront modprobe "-k" "cs4232" - post-install wavefront modprobe "-k" "opl3" + install wavefront /sbin/modprobe cs4232 && /sbin/modprobe -i wavefront && /sbin/modprobe opl3 options wavefront io=0x200 irq=9 options cs4232 synthirq=9 synthio=0x200 io=0x530 irq=5 dma=1 dma2=0 options opl3 io=0x388 --- diff/Documentation/sysctl/fs.txt 2003-01-02 10:43:02.000000000 +0000 +++ source/Documentation/sysctl/fs.txt 2004-02-23 13:56:40.000000000 +0000 @@ -138,3 +138,13 @@ thus the maximum number of mounted files can have. You only need to increase super-max if you need to mount more filesystems than the current value in super-max allows you to. + +============================================================== + +aio-nr & aio-max-nr: + +aio-nr shows the current system-wide number of asynchronous io +requests. aio-max-nr allows you to change the maximum value +aio-nr can grow to. + +============================================================== --- diff/Documentation/usb/acm.txt 2002-10-16 04:27:22.000000000 +0100 +++ source/Documentation/usb/acm.txt 2004-02-23 13:56:40.000000000 +0000 @@ -28,7 +28,7 @@ in the package: See the file COPYING. 1. Usage ~~~~~~~~ - The drivers/usb/acm.c drivers works with USB modems and USB ISDN terminal + The drivers/usb/class/cdc-acm.c drivers works with USB modems and USB ISDN terminal adapters that conform to the Universal Serial Bus Communication Device Class Abstract Control Model (USB CDC ACM) specification. @@ -65,9 +65,9 @@ minor/major numbers anywhere you want, b To use the modems you need these modules loaded: - usbcore.o - usb-[uo]hci.o or uhci.o - acm.o + usbcore.ko + uhci-hcd.ko ohci-hcd.ko or ehci-hcd.ko + cdc-acm.ko After that, the modem[s] should be accessible. You should be able to use minicom, ppp and mgetty with them. --- diff/Documentation/usb/scanner.txt 2003-05-21 11:49:49.000000000 +0100 +++ source/Documentation/usb/scanner.txt 2004-02-23 13:56:40.000000000 +0000 @@ -146,14 +146,14 @@ options to the driver. Simply add options scanner vendor=0x#### product=0x**** -to the /etc/modules.conf file replacing the #'s and the *'s with the +to the /etc/modprobe.conf file replacing the #'s and the *'s with the correct IDs. The IDs can be retrieved from the messages file or using "cat /proc/bus/usb/devices". If the default timeout is too low, i.e. there are frequent "timeout" messages, you may want to increase the timeout manually by using the parameter "read_timeout". The time is given in seconds. This is an example for -modules.conf with a timeout of 60 seconds: +modprobe.conf with a timeout of 60 seconds: options scanner read_timeout=60 --- diff/Documentation/video4linux/CQcam.txt 2003-10-09 09:47:33.000000000 +0100 +++ source/Documentation/video4linux/CQcam.txt 2004-02-23 13:56:40.000000000 +0000 @@ -62,7 +62,7 @@ But that is my personal preference. The configuration requires module configuration and device configuration. I like kmod or kerneld process with the -/etc/modules.conf file so the modules can automatically load/unload as +/etc/modprobe.conf file so the modules can automatically load/unload as they are used. The video devices could already exist, be generated using MAKEDEV, or need to be created. The following sections detail these procedures. @@ -71,15 +71,15 @@ these procedures. 2.1 Module Configuration Using modules requires a bit of work to install and pass the -parameters. Understand that entries in /etc/modules.conf of: +parameters. Understand that entries in /etc/modprobe.conf of: alias parport_lowlevel parport_pc options parport_pc io=0x378 irq=none alias char-major-81 videodev alias char-major-81-0 c-qcam -will cause the kmod/kerneld/modprobe to do certain things. If you are -using kmod or kerneld, then a request for a 'char-major-81-0' will cause +will cause the kmod/modprobe to do certain things. If you are +using kmod, then a request for a 'char-major-81-0' will cause the 'c-qcam' module to load. If you have other video sources with modules, you might want to assign the different minor numbers to different modules. --- diff/Documentation/video4linux/Zoran 2003-09-30 15:46:10.000000000 +0100 +++ source/Documentation/video4linux/Zoran 2004-02-23 13:56:40.000000000 +0000 @@ -233,7 +233,7 @@ Load zr36067.o. If it can't autodetect y option with X being the card number as given in the previous section. To have more than one card, use card=X1[,X2[,X3,[X4[..]]]] -To automate this, add the following to your /etc/modules.conf: +To automate this, add the following to your /etc/modprobe.conf: options zr36067 card=X1[,X2[,X3[,X4[..]]]] alias char-major-81-0 zr36067 --- diff/Documentation/video4linux/bttv/Modules.conf 2002-10-16 04:28:23.000000000 +0100 +++ source/Documentation/video4linux/bttv/Modules.conf 2004-02-23 13:56:40.000000000 +0000 @@ -1,3 +1,6 @@ +# For modern kernels (2.6 or above), this belongs in /etc/modprobe.conf +# For for 2.4 kernels or earlier, this belongs in /etc/modules.conf. + # i2c alias char-major-89 i2c-dev options i2c-core i2c_debug=1 --- diff/Documentation/video4linux/bttv/README 2004-02-09 10:36:07.000000000 +0000 +++ source/Documentation/video4linux/bttv/README 2004-02-23 13:56:40.000000000 +0000 @@ -22,7 +22,7 @@ very likely specified the wrong (or no) cards is in CARDLIST.bttv If bttv takes very long to load (happens sometimes with the cheap -cards which have no tuner), try adding this to your modules.conf: +cards which have no tuner), try adding this to your modprobe.conf: options i2c-algo-bit bit_test=1 For the WinTV/PVR you need one firmware file from the driver CD: --- diff/Documentation/video4linux/meye.txt 2003-11-25 15:24:57.000000000 +0000 +++ source/Documentation/video4linux/meye.txt 2004-02-23 13:56:40.000000000 +0000 @@ -42,7 +42,7 @@ Driver options: --------------- Several options can be passed to the meye driver, either by adding them -to /etc/modules.conf file, when the driver is compiled as a module, or +to /etc/modprobe.conf file, when the driver is compiled as a module, or by adding the following to the kernel command line (in your bootloader): meye=gbuffers[,gbufsize[,video_nr]] @@ -59,7 +59,7 @@ Module use: ----------- In order to automatically load the meye module on use, you can put those lines -in your /etc/modules.conf file: +in your /etc/modprobe.conf file: alias char-major-81 videodev alias char-major-81-0 meye --- diff/MAINTAINERS 2004-02-18 08:54:06.000000000 +0000 +++ source/MAINTAINERS 2004-02-23 13:56:48.000000000 +0000 @@ -521,7 +521,7 @@ CPU FREQUENCY DRIVERS P: Dave Jones M: davej@codemonkey.org.uk L: cpufreq@www.linux.org.uk -W: http://www.codemonkey.org.uk/cpufreq/ +W: http://www.codemonkey.org.uk/projects/cpufreq/ S: Maintained CPUID/MSR DRIVER @@ -862,8 +862,8 @@ W: http://www.nyx.net/~arobinso S: Maintained HFS FILESYSTEM -P: Oliver Neukum -M: oliver@neukum.org +P: Roman Zippel +M: zippel@linux-m68k.org L: linux-kernel@vger.kernel.org S: Maintained @@ -1186,6 +1186,12 @@ W: http://sf.net/projects/kernel-janitor W: http://developer.osdl.org/rddunlap/kj-patches/ S: Maintained +KGDB FOR I386 PLATFORM +P: George Anzinger +M: george@mvista.com +L: linux-net@vger.kernel.org +S: Supported + KERNEL NFSD P: Neil Brown M: neilb@cse.unsw.edu.au --- diff/Makefile 2004-02-18 08:54:06.000000000 +0000 +++ source/Makefile 2004-02-23 13:56:48.000000000 +0000 @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 3 -EXTRAVERSION = +EXTRAVERSION = -mm3 NAME=Feisty Dunnart # *DOCUMENTATION* @@ -283,7 +283,7 @@ AFLAGS := -D__ASSEMBLY__ export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \ CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \ - HOSTCXX HOSTCXXFLAGS LDFLAGS_BLOB LDFLAGS_MODULE CHECK + HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE @@ -444,6 +444,7 @@ endif ifdef CONFIG_DEBUG_INFO CFLAGS += -g +AFLAGS += -g endif # warn about C99 declaration after statement --- diff/arch/alpha/Kconfig 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/alpha/Kconfig 2004-02-23 13:56:37.000000000 +0000 @@ -569,24 +569,6 @@ config VERBOSE_MCHECK_ON source "drivers/pci/Kconfig" source "drivers/eisa/Kconfig" -config HOTPLUG - bool "Support for hot-pluggable devices" - ---help--- - Say Y here if you want to plug devices into your computer while - the system is running, and be able to use them quickly. In many - cases, the devices can likewise be unplugged at any time too. - - One well known example of this is PCMCIA- or PC-cards, credit-card - size devices such as network cards, modems or hard drives which are - plugged into slots found on all modern laptop computers. Another - example, used on modern desktops as well as laptops, is USB. - - Enable HOTPLUG and KMOD, and build a modular kernel. Get agent - software (at ) and install it. - Then your kernel will automatically call out to a user mode "policy - agent" (/sbin/hotplug) to load modules and set up software needed - to use devices as you hotplug them. - source "drivers/pcmcia/Kconfig" config SRM_ENV --- diff/arch/alpha/kernel/alpha_ksyms.c 2003-06-30 10:07:32.000000000 +0100 +++ source/arch/alpha/kernel/alpha_ksyms.c 2004-02-23 13:56:37.000000000 +0000 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include --- diff/arch/alpha/kernel/irq.c 2004-01-19 10:22:54.000000000 +0000 +++ source/arch/alpha/kernel/irq.c 2004-02-23 13:56:37.000000000 +0000 @@ -252,7 +252,7 @@ static int irq_affinity_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, irq_affinity[(long)data]); + int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); @@ -333,7 +333,7 @@ static int prof_cpu_mask_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, *(cpumask_t *)data); + int len = cpumask_scnprintf(page, count, *(cpumask_t *)data); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); --- diff/arch/alpha/kernel/osf_sys.c 2003-08-20 14:16:23.000000000 +0100 +++ source/arch/alpha/kernel/osf_sys.c 2004-02-23 13:56:37.000000000 +0000 @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -46,7 +47,6 @@ #include extern int do_pipe(int *); -extern asmlinkage unsigned long sys_brk(unsigned long); /* * Brk needs to return an error. Still support Linux's brk(0) query idiom, @@ -821,7 +821,6 @@ osf_setsysinfo(unsigned long op, void *b affects all sorts of things, like timeval and itimerval. */ extern struct timezone sys_tz; -extern asmlinkage int sys_utimes(char *, struct timeval *); extern int do_adjtimex(struct timex *); struct timeval32 @@ -1315,8 +1314,6 @@ arch_get_unmapped_area(struct file *filp } #ifdef CONFIG_OSF4_COMPAT -extern ssize_t sys_readv(unsigned long, const struct iovec *, unsigned long); -extern ssize_t sys_writev(unsigned long, const struct iovec *, unsigned long); /* Clear top 32 bits of iov_len in the user's buffer for compatibility with old versions of OSF/1 where iov_len --- diff/arch/alpha/kernel/time.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/alpha/kernel/time.c 2004-02-23 13:56:37.000000000 +0000 @@ -503,6 +503,7 @@ do_settimeofday(struct timespec *tv) time_esterror = NTP_PHASE_LIMIT; write_sequnlock_irq(&xtime_lock); + clock_was_set(); return 0; } --- diff/arch/arm/Kconfig 2004-02-18 08:54:06.000000000 +0000 +++ source/arch/arm/Kconfig 2004-02-23 13:56:37.000000000 +0000 @@ -365,24 +365,6 @@ endif source "drivers/pci/Kconfig" -config HOTPLUG - bool "Support for hot-pluggable devices" - ---help--- - Say Y here if you want to plug devices into your computer while - the system is running, and be able to use them quickly. In many - cases, the devices can likewise be unplugged at any time too. - - One well known example of this is PCMCIA- or PC-cards, credit-card - size devices such as network cards, modems or hard drives which are - plugged into slots found on all modern laptop computers. Another - example, used on modern desktops as well as laptops, is USB. - - Enable HOTPLUG and KMOD, and build a modular kernel. Get agent - software (at ) and install it. - Then your kernel will automatically call out to a user mode "policy - agent" (/sbin/hotplug) to load modules and set up software needed - to use devices as you hotplug them. - source "drivers/pcmcia/Kconfig" comment "At least one math emulation must be selected" @@ -439,9 +421,9 @@ config PM Power Management is most important for battery powered laptop computers; if you have a laptop, check out the Linux Laptop home - page on the WWW at - and the - Battery Powered Linux mini-HOWTO, available from + page on the WWW at or + Tuxmobil - Linux on Mobile Computers at + and the Battery Powered Linux mini-HOWTO, available from . Note that, even if you say N here, Linux on the x86 architecture @@ -639,6 +621,8 @@ source "drivers/media/Kconfig" source "fs/Kconfig" +source "arch/arm/oprofile/Kconfig" + source "drivers/video/Kconfig" if ARCH_ACORN || ARCH_CLPS7500 || ARCH_TBOX || ARCH_SHARK || ARCH_SA1100 || PCI --- diff/arch/arm/Makefile 2004-01-19 10:22:54.000000000 +0000 +++ source/arch/arm/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -8,7 +8,6 @@ # Copyright (C) 1995-2001 by Russell King LDFLAGS_vmlinux :=-p -X -LDFLAGS_BLOB :=--format binary AFLAGS_vmlinux.lds.o = -DTEXTADDR=$(TEXTADDR) -DDATAADDR=$(DATAADDR) OBJCOPYFLAGS :=-O binary -R .note -R .comment -S GZFLAGS :=-9 @@ -56,11 +55,6 @@ DATAADDR := . PROCESSOR := armv head-y := arch/arm/kernel/head.o arch/arm/kernel/init_task.o -ifeq ($(CONFIG_CPU_BIG_ENDIAN),y) - LDFLAGS_BLOB += --oformat elf32-bigarm -else - LDFLAGS_BLOB += --oformat elf32-littlearm -endif textaddr-y := 0xC0008000 machine-$(CONFIG_ARCH_ARCA5K) := arc @@ -116,6 +110,7 @@ endif core-$(CONFIG_FPE_NWFPE) += arch/arm/nwfpe/ core-$(CONFIG_FPE_FASTFPE) += $(FASTFPE_OBJ) +drivers-$(CONFIG_OPROFILE) += arch/arm/oprofile/ drivers-$(CONFIG_ARCH_CLPS7500) += drivers/acorn/char/ drivers-$(CONFIG_ARCH_L7200) += drivers/acorn/char/ --- diff/arch/arm/kernel/armksyms.c 2004-01-19 10:22:54.000000000 +0000 +++ source/arch/arm/kernel/armksyms.c 2004-02-23 13:56:37.000000000 +0000 @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -44,14 +45,6 @@ extern void outswb(unsigned int port, co extern void __bad_xchg(volatile void *ptr, int size); /* - * syscalls - */ -extern int sys_write(int, const char *, int); -extern int sys_read(int, char *, int); -extern int sys_lseek(int, off_t, int); -extern int sys_exit(int); - -/* * libgcc functions - functions that are used internally by the * compiler... (prototypes are not correct though, but that * doesn't really matter since they're not versioned). --- diff/arch/arm/kernel/sys_arm.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/arm/kernel/sys_arm.c 2004-02-23 13:56:37.000000000 +0000 @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -137,7 +138,6 @@ out: * Perform the select(nd, in, out, ex, tv) and mmap() system * calls. */ -extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); struct sel_arg_struct { unsigned long n; --- diff/arch/arm/kernel/time.c 2004-02-18 08:54:06.000000000 +0000 +++ source/arch/arm/kernel/time.c 2004-02-23 13:56:37.000000000 +0000 @@ -85,6 +85,9 @@ unsigned long long __attribute__((weak)) */ static inline void do_profile(struct pt_regs *regs) { + + profile_hook(regs); + if (!user_mode(regs) && prof_buffer && current->pid) { @@ -175,7 +178,7 @@ static int __init leds_init(void) int ret; ret = sysdev_class_register(&leds_sysclass); if (ret == 0) - ret = sys_device_register(&leds_device); + ret = sysdev_register(&leds_device); return ret; } --- diff/arch/arm/mach-integrator/integrator_ap.c 2004-02-18 08:54:06.000000000 +0000 +++ source/arch/arm/mach-integrator/integrator_ap.c 2004-02-23 13:56:37.000000000 +0000 @@ -173,7 +173,7 @@ static int __init irq_init_sysfs(void) { int ret = sysdev_class_register(&irq_class); if (ret == 0) - ret = sys_device_register(&irq_device); + ret = sysdev_register(&irq_device); return ret; } --- diff/arch/arm/mach-sa1100/irq.c 2003-06-30 10:07:32.000000000 +0100 +++ source/arch/arm/mach-sa1100/irq.c 2004-02-23 13:56:37.000000000 +0000 @@ -278,7 +278,7 @@ static struct sys_device sa1100irq_devic static int __init sa1100irq_init_devicefs(void) { sysdev_class_register(&sa1100irq_sysclass); - return sys_device_register(&sa1100irq_device); + return sysdev_register(&sa1100irq_device); } device_initcall(sa1100irq_init_devicefs); --- diff/arch/arm/mm/Kconfig 2004-02-18 08:54:06.000000000 +0000 +++ source/arch/arm/mm/Kconfig 2004-02-23 13:56:37.000000000 +0000 @@ -91,10 +91,28 @@ config CPU_ARM922T Say Y if you want support for the ARM922T processor. Otherwise, say N. +# ARM925T +config CPU_ARM925T + bool + depends on ARCH_OMAP1510 + default y + select CPU_32v4 + select CPU_ABRT_EV4T + select CPU_CACHE_V4WT + select CPU_COPY_V4WB + select CPU_TLB_V4WBI + help + The ARM925T is a mix between the ARM920T and ARM926T, but with + different instruction and data caches. It is used in TI's OMAP + device family. + + Say Y if you want support for the ARM925T processor. + Otherwise, say N. + # ARM926T config CPU_ARM926T bool "Support ARM926T processor" - depends on ARCH_INTEGRATOR + depends on ARCH_INTEGRATOR || ARCH_OMAP1610 select CPU_32v5 select CPU_ABRT_EV5TJ select CPU_COPY_V4WB @@ -288,7 +306,7 @@ comment "Processor Features" config ARM_THUMB bool "Support Thumb user binaries" - depends on CPU_ARM720T || CPU_ARM920T || CPU_ARM922T || CPU_ARM926T || CPU_ARM1020 || CPU_ARM1020E || CPU_ARM1022 || CPU_ARM1026 || CPU_XSCALE + depends on CPU_ARM720T || CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020 || CPU_ARM1020E || CPU_ARM1022 || CPU_ARM1026 || CPU_XSCALE default y help Say Y if you want to include kernel support for running user space @@ -311,21 +329,21 @@ config CPU_BIG_ENDIAN config CPU_ICACHE_DISABLE bool "Disable I-Cache" - depends on CPU_ARM920T || CPU_ARM922T || CPU_ARM926T || CPU_ARM1020 + depends on CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020 help Say Y here to disable the processor instruction cache. Unless you have a reason not to or are unsure, say N. config CPU_DCACHE_DISABLE bool "Disable D-Cache" - depends on CPU_ARM920T || CPU_ARM922T || CPU_ARM926T || CPU_ARM1020 + depends on CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020 help Say Y here to disable the processor data cache. Unless you have a reason not to or are unsure, say N. config CPU_DCACHE_WRITETHROUGH bool "Force write through D-cache" - depends on (CPU_ARM920T || CPU_ARM922T || CPU_ARM926T || CPU_ARM1020) && !CPU_DISABLE_DCACHE + depends on (CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020) && !CPU_DISABLE_DCACHE help Say Y here to use the data cache in writethough mode. Unless you specifically require this or are unsure, say N. --- diff/arch/arm/mm/Makefile 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/arm/mm/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -39,6 +39,7 @@ obj-$(CONFIG_CPU_ARM710) += proc-arm6_7. obj-$(CONFIG_CPU_ARM720T) += proc-arm720.o obj-$(CONFIG_CPU_ARM920T) += proc-arm920.o obj-$(CONFIG_CPU_ARM922T) += proc-arm922.o +obj-$(CONFIG_CPU_ARM925T) += proc-arm925.o obj-$(CONFIG_CPU_ARM926T) += proc-arm926.o obj-$(CONFIG_CPU_ARM1020) += proc-arm1020.o obj-$(CONFIG_CPU_ARM1020E) += proc-arm1020e.o --- diff/arch/arm26/Kconfig 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/arm26/Kconfig 2004-02-23 13:56:37.000000000 +0000 @@ -118,24 +118,6 @@ config XIP_KERNEL Select this option to create a kernel that can be programed into the OS ROMs. -config HOTPLUG - bool "Support for hot-pluggable devices" - ---help--- - Say Y here if you want to plug devices into your computer while - the system is running, and be able to use them quickly. In many - cases, the devices can likewise be unplugged at any time too. - - One well known example of this is PCMCIA- or PC-cards, credit-card - size devices such as network cards, modems or hard drives which are - plugged into slots found on all modern laptop computers. Another - example, used on modern desktops as well as laptops, is USB. - - Enable HOTPLUG and KMOD, and build a modular kernel. Get agent - software (at ) and install it. - Then your kernel will automatically call out to a user mode "policy - agent" (/sbin/hotplug) to load modules and set up software needed - to use devices as you hotplug them. - comment "At least one math emulation must be selected" config FPE_NWFPE @@ -216,11 +198,6 @@ source "drivers/input/Kconfig" source "drivers/char/Kconfig" -config KBDMOUSE - bool - depends on ARCH_ACORN && BUSMOUSE=y - default y - source "drivers/media/Kconfig" source "fs/Kconfig" --- diff/arch/arm26/Makefile 2003-09-17 12:28:01.000000000 +0100 +++ source/arch/arm26/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -8,7 +8,6 @@ # Copyright (C) 1995-2001 by Russell King LDFLAGS_vmlinux :=-p -X -LDFLAGS_BLOB :=--format binary AFLAGS_vmlinux.lds.o = -DTEXTADDR=$(TEXTADDR) -DDATAADDR=$(DATAADDR) OBJCOPYFLAGS :=-O binary -R .note -R .comment -S GZFLAGS :=-9 @@ -28,7 +27,6 @@ CFLAGS +=-mapcs-26 -mcpu=arm3 -mshort-l AFLAGS +=-mapcs-26 -mcpu=arm3 -mno-fpu -msoft-float -Wa,-mno-fpu head-y := arch/arm26/machine/head.o arch/arm26/kernel/init_task.o -LDFLAGS_BLOB += --oformat elf32-littlearm ifeq ($(CONFIG_XIP_KERNEL),y) TEXTADDR := 0x03880000 --- diff/arch/arm26/kernel/armksyms.c 2003-06-30 10:07:18.000000000 +0100 +++ source/arch/arm26/kernel/armksyms.c 2004-02-23 13:56:37.000000000 +0000 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -43,14 +44,6 @@ extern void outswb(unsigned int port, co extern void __bad_xchg(volatile void *ptr, int size); /* - * syscalls - */ -extern int sys_write(int, const char *, int); -extern int sys_read(int, char *, int); -extern int sys_lseek(int, off_t, int); -extern int sys_exit(int); - -/* * libgcc functions - functions that are used internally by the * compiler... (prototypes are not correct though, but that * doesn't really matter since they're not versioned). --- diff/arch/arm26/kernel/sys_arm.c 2003-06-30 10:07:18.000000000 +0100 +++ source/arch/arm26/kernel/sys_arm.c 2004-02-23 13:56:37.000000000 +0000 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -138,7 +139,6 @@ out: * Perform the select(nd, in, out, ex, tv) and mmap() system * calls. */ -extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); struct sel_arg_struct { unsigned long n; --- diff/arch/arm26/kernel/time.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/arm26/kernel/time.c 2004-02-23 13:56:37.000000000 +0000 @@ -179,6 +179,7 @@ int do_settimeofday(struct timespec *tv) time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; write_sequnlock_irq(&xtime_lock); + clock_was_set(); return 0; } --- diff/arch/cris/Makefile 2003-08-26 10:00:51.000000000 +0100 +++ source/arch/cris/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -24,8 +24,6 @@ SARCH := endif LD = $(CROSS_COMPILE)ld -mcrislinux -LDFLAGS_BLOB := --format binary --oformat elf32-cris \ - -T arch/cris/$(SARCH)/output_arch.ld OBJCOPYFLAGS := -O binary -R .note -R .comment -S --- diff/arch/cris/arch-v10/drivers/ethernet.c 2003-07-11 09:39:49.000000000 +0100 +++ source/arch/cris/arch-v10/drivers/ethernet.c 2004-02-23 13:56:37.000000000 +0000 @@ -482,7 +482,7 @@ etrax_ethernet_init(void) /* Register device */ err = register_netdev(dev); if (err) { - kfree(dev); + free_netdev(dev); return err; } --- diff/arch/cris/kernel/sys_cris.c 2003-07-11 09:39:50.000000000 +0100 +++ source/arch/cris/kernel/sys_cris.c 2004-02-23 13:56:37.000000000 +0000 @@ -11,6 +11,7 @@ #include #include +#include #include #include #include --- diff/arch/cris/kernel/time.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/cris/kernel/time.c 2004-02-23 13:56:37.000000000 +0000 @@ -108,6 +108,7 @@ int do_settimeofday(struct timespec *tv) time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; local_irq_restore(flags); + clock_was_set(); return 0; } --- diff/arch/h8300/Kconfig 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/h8300/Kconfig 2004-02-23 13:56:37.000000000 +0000 @@ -154,29 +154,6 @@ config ROMKERNEL endchoice -config DEFAULT_CMDLINE - bool "Use buildin commandline" - default n - help - buildin kernel commandline enabled. - -config KERNEL_COMMAND - string "Buildin commmand string" - depends on DEFAULT_CMDLINE - help - buildin kernel commandline strings. - -config BLKDEV_RESERVE - bool "BLKDEV Reserved Memory" - default n - help - Reserved BLKDEV area. - -config CONFIG_BLKDEV_RESERVE_ADDRESS - hex 'start address' - depends on BLKDEV_RESERVE - help - BLKDEV start address. endmenu menu "Executable file formats" @@ -193,26 +170,19 @@ source "drivers/block/Kconfig" source "drivers/ide/Kconfig" -source "net/Kconfig" - -source "drivers/isdn/Kconfig" +source "arch/h8300/Kconfig.ide" -source "drivers/telephony/Kconfig" +source "net/Kconfig" # -# input before char - char/joystick depends on it. As does USB. +# input - input/joystick depends on it. As does USB. # source "drivers/input/Kconfig" -# -# Character device configuration -# - menu "Character devices" config VT bool "Virtual terminal" - requires INPUT=y ---help--- If you say Y here, you will get support for terminal devices with display and keyboard devices. These are called "virtual" because you @@ -266,8 +236,37 @@ config HW_CONSOLE depends on VT && !S390 && !UM default y +config SERIAL + tristate "Serial (8250, 16450, 16550 or compatible) support" + ---help--- + This selects whether you want to include the driver for the standard + serial ports. The standard answer is Y. People who might say N + here are those that are setting up dedicated Ethernet WWW/FTP + servers, or users that have one of the various bus mice instead of a + serial mouse and don't intend to use their machine's standard serial + port for anything. (Note that the Cyclades and Stallion multi + serial port drivers do not need this driver built in for them to + work.) + + To compile this driver as a module, choose M here: the + module will be called serial. + [WARNING: Do not compile this driver as a module if you are using + non-standard serial ports, since the configuration information will + be lost when the driver is unloaded. This limitation may be lifted + in the future.] + + BTW1: If you have a mouseman serial mouse which is not recognized by + the X window system, try running gpm first. + + BTW2: If you intend to use a software modem (also called Winmodem) + under Linux, forget it. These modems are crippled and require + proprietary drivers which are only available under Windows. + + Most people will say Y or M here, so that they can use serial mice, + modems and similar devices connecting to the standard serial ports. + config SH_SCI - tristate "Serial (SCI) support" + tristate "Serial (SCI, SCIF) support" help Selecting this option will allow the Linux kernel to transfer data over SCI (Serial Communication Interface) and/or SCIF (Serial @@ -301,6 +300,8 @@ config SERIAL_CONSOLE If unsure, say N. +comment "Unix98 PTY support" + config UNIX98_PTYS bool "Unix98 PTY support" ---help--- @@ -343,15 +344,17 @@ config UNIX98_PTY_COUNT When not in use, each additional set of 256 PTYs occupy approximately 8 KB of kernel memory on 32-bit architectures. -endmenu +source "drivers/char/pcmcia/Kconfig" -source "drivers/media/Kconfig" -source "sound/Kconfig" +source "drivers/serial/Kconfig" -source "fs/Kconfig" +source "drivers/i2c/Kconfig" source "drivers/usb/Kconfig" + +endmenu +source "fs/Kconfig" menu "Kernel hacking" @@ -400,6 +403,29 @@ config CONFIG_SH_STANDARD_BIOS serial console output using GDB protocol. Require eCos/RedBoot +config DEFAULT_CMDLINE + bool "Use buildin commandline" + default n + help + buildin kernel commandline enabled. + +config KERNEL_COMMAND + string "Buildin commmand string" + depends on DEFAULT_CMDLINE + help + buildin kernel commandline strings. + +config BLKDEV_RESERVE + bool "BLKDEV Reserved Memory" + default n + help + Reserved BLKDEV area. + +config CONFIG_BLKDEV_RESERVE_ADDRESS + hex 'start address' + depends on BLKDEV_RESERVE + help + BLKDEV start address. endmenu source "security/Kconfig" --- diff/arch/h8300/defconfig 2003-08-20 14:16:24.000000000 +0100 +++ source/arch/h8300/defconfig 2004-02-23 13:56:37.000000000 +0000 @@ -1,6 +1,7 @@ # # Automatically generated make config: don't edit # +CONFIG_H8300=y # CONFIG_MMU is not set # CONFIG_SWAP is not set # CONFIG_FPU is not set @@ -13,6 +14,9 @@ CONFIG_ISA=y # Code maturity level options # CONFIG_EXPERIMENTAL=y +CONFIG_CLEAN_COMPILE=y +CONFIG_STANDALONE=y +CONFIG_BROKEN_ON_SMP=y # # General setup @@ -21,9 +25,15 @@ CONFIG_EXPERIMENTAL=y # CONFIG_BSD_PROCESS_ACCT is not set # CONFIG_SYSCTL is not set CONFIG_LOG_BUF_SHIFT=14 +# CONFIG_IKCONFIG is not set CONFIG_EMBEDDED=y +CONFIG_KALLSYMS=y CONFIG_FUTEX=y CONFIG_EPOLL=y +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_AS=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_CC_OPTIMIZE_FOR_SIZE=y # # Loadable module support @@ -37,25 +47,30 @@ CONFIG_EPOLL=y # CONFIG_H8300H_AKI3068NET is not set # CONFIG_H8300H_H8MAX is not set CONFIG_H8300H_SIM=y +# CONFIG_H8S_EDOSK2674 is not set +# CONFIG_H8S_SIM is not set # CONFIG_H83002 is not set CONFIG_H83007=y # CONFIG_H83048 is not set # CONFIG_H83068 is not set +# CONFIG_H8S2678 is not set CONFIG_CPU_H8300H=y CONFIG_CPU_CLOCK=16000 # CONFIG_RAMKERNEL is not set CONFIG_ROMKERNEL=y -# CONFIG_DEFAULT_CMDLINE is not set # # Executable file formats # -CONFIG_KCORE_AOUT=y CONFIG_BINFMT_FLAT=y # CONFIG_BINFMT_ZFLAT is not set # CONFIG_BINFMT_MISC is not set # +# Generic Driver Options +# + +# # Memory Technology Devices (MTD) # CONFIG_MTD=y @@ -72,6 +87,7 @@ CONFIG_MTD_CHAR=y CONFIG_MTD_BLOCK=y # CONFIG_FTL is not set # CONFIG_NFTL is not set +# CONFIG_INFTL is not set # # RAM/ROM/Flash chip drivers @@ -86,6 +102,7 @@ CONFIG_MTD_RAM=y # # Mapping drivers for chip access # +# CONFIG_MTD_COMPLEX_MAPPINGS is not set CONFIG_MTD_UCLINUX=y # @@ -98,9 +115,9 @@ CONFIG_MTD_UCLINUX=y # # Disk-On-Chip Device Drivers # -# CONFIG_MTD_DOC1000 is not set # CONFIG_MTD_DOC2000 is not set # CONFIG_MTD_DOC2001 is not set +# CONFIG_MTD_DOC2001PLUS is not set # # NAND Flash Device Drivers @@ -113,18 +130,100 @@ CONFIG_MTD_UCLINUX=y # CONFIG_BLK_DEV_FD is not set # CONFIG_BLK_DEV_XD is not set # CONFIG_BLK_DEV_LOOP is not set +# CONFIG_BLK_DEV_NBD is not set # CONFIG_BLK_DEV_RAM is not set # CONFIG_BLK_DEV_INITRD is not set # -# ATA/IDE/MFM/RLL support +# ATA/ATAPI/MFM/RLL support # # CONFIG_IDE is not set # +# IDE Extra configuration +# + +# # Networking support # -# CONFIG_NET is not set +CONFIG_NET=y + +# +# Networking options +# +# CONFIG_PACKET is not set +# CONFIG_NETLINK_DEV is not set +# CONFIG_UNIX is not set +# CONFIG_NET_KEY is not set +# CONFIG_INET is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_DECNET is not set +# CONFIG_BRIDGE is not set +# CONFIG_NETFILTER is not set +# CONFIG_ATM is not set +# CONFIG_VLAN_8021Q is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_NET_DIVERT is not set +# CONFIG_WAN_ROUTER is not set +# CONFIG_NET_FASTROUTE is not set +# CONFIG_NET_HW_FLOWCONTROL is not set + +# +# QoS and/or fair queueing +# +# CONFIG_NET_SCHED is not set + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +CONFIG_NETDEVICES=y + +# +# ARCnet devices +# +# CONFIG_ARCNET is not set +# CONFIG_DUMMY is not set +# CONFIG_BONDING is not set +# CONFIG_EQUALIZER is not set +# CONFIG_TUN is not set + +# +# Ethernet (10 or 100Mbit) +# +# CONFIG_NET_ETHERNET is not set + +# +# Ethernet (1000 Mbit) +# + +# +# Ethernet (10000 Mbit) +# +# CONFIG_PPP is not set +# CONFIG_SLIP is not set + +# +# Wireless LAN (non-hamradio) +# +# CONFIG_NET_RADIO is not set + +# +# Token Ring devices +# +# CONFIG_TR is not set +# CONFIG_SHAPER is not set + +# +# Wan interfaces +# +# CONFIG_WAN is not set # # Amateur Radio support @@ -132,13 +231,14 @@ CONFIG_MTD_UCLINUX=y # CONFIG_HAMRADIO is not set # -# ISDN subsystem +# IrDA (infrared) support # +# CONFIG_IRDA is not set # -# Telephony Support +# Bluetooth support # -# CONFIG_PHONE is not set +# CONFIG_BT is not set # # Input device support @@ -155,6 +255,7 @@ CONFIG_MTD_UCLINUX=y # CONFIG_GAMEPORT is not set CONFIG_SOUND_GAMEPORT=y # CONFIG_SERIO is not set +# CONFIG_SERIO_I8042 is not set # # Input Device Drivers @@ -163,14 +264,38 @@ CONFIG_SOUND_GAMEPORT=y # # Character devices # +# CONFIG_VT is not set +# CONFIG_SERIAL is not set CONFIG_SH_SCI=y CONFIG_SERIAL_CONSOLE=y + +# +# Unix98 PTY support +# # CONFIG_UNIX98_PTYS is not set # -# Multimedia devices +# Serial drivers # -# CONFIG_VIDEO_DEV is not set +# CONFIG_SERIAL_8250 is not set + +# +# Non-8250 serial port support +# + +# +# I2C support +# +# CONFIG_I2C is not set + +# +# USB support +# + +# +# USB Gadget Support +# +# CONFIG_USB_GADGET is not set # # File systems @@ -203,8 +328,10 @@ CONFIG_ROMFS_FS=y # Pseudo filesystems # CONFIG_PROC_FS=y +CONFIG_PROC_KCORE=y # CONFIG_DEVFS_FS is not set # CONFIG_TMPFS is not set +# CONFIG_HUGETLB_PAGE is not set CONFIG_RAMFS=y # @@ -226,14 +353,20 @@ CONFIG_RAMFS=y # CONFIG_UFS_FS is not set # +# Network File Systems +# +# CONFIG_EXPORTFS is not set + +# # Partition Types # # CONFIG_PARTITION_ADVANCED is not set CONFIG_MSDOS_PARTITION=y # -# USB support +# Native Language Support # +# CONFIG_NLS is not set # # Kernel hacking @@ -243,7 +376,9 @@ CONFIG_FULLDEBUG=y # CONFIG_HIGHPROFILE is not set CONFIG_NO_KERNEL_MSG=y CONFIG_GDB_MAGICPRINT=y -CONFIG_SYSCALL_PRINT=y +# CONFIG_SYSCALL_PRINT is not set +# CONFIG_DEFAULT_CMDLINE is not set +# CONFIG_BLKDEV_RESERVE is not set # # Security options --- diff/arch/h8300/kernel/signal.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/h8300/kernel/signal.c 2004-02-23 13:56:37.000000000 +0000 @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -46,8 +47,6 @@ #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) -asmlinkage long sys_wait4(pid_t pid, unsigned int * stat_addr, int options, - struct rusage * ru); asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs); /* --- diff/arch/h8300/kernel/sys_h8300.c 2003-08-20 14:16:24.000000000 +0100 +++ source/arch/h8300/kernel/sys_h8300.c 2004-02-23 13:56:37.000000000 +0000 @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -155,8 +156,6 @@ out: } #endif -extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); - struct sel_arg_struct { unsigned long n; fd_set *inp, *outp, *exp; @@ -261,7 +260,7 @@ asmlinkage int sys_ipc (uint call, int f return -EINVAL; } -asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on) +asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int on) { return -ENOSYS; } --- diff/arch/h8300/kernel/time.c 2003-11-25 15:24:57.000000000 +0000 +++ source/arch/h8300/kernel/time.c 2004-02-23 13:56:37.000000000 +0000 @@ -139,6 +139,7 @@ int do_settimeofday(struct timespec *tv) time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; write_sequnlock_irq(&xtime_lock); + clock_was_set(); return 0; } --- diff/arch/h8300/platform/h8300h/aki3068net/timer.c 2003-08-26 10:00:51.000000000 +0100 +++ source/arch/h8300/platform/h8300h/aki3068net/timer.c 2004-02-23 13:56:37.000000000 +0000 @@ -27,10 +27,10 @@ void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *)) { - outb(H8300_TIMER_COUNT_DATA,TCORA2); - outb(0x00,_8TCSR2); + ctrl_outb(H8300_TIMER_COUNT_DATA,TCORA2); + ctrl_outb(0x00,_8TCSR2); request_irq(40,timer_int,0,"timer",0); - outb(0x40|0x08|0x03,_8TCR2); + ctrl_outb(0x40|0x08|0x03,_8TCR2); } void platform_timer_eoi(void) --- diff/arch/h8300/platform/h8300h/entry.S 2003-08-26 10:00:51.000000000 +0100 +++ source/arch/h8300/platform/h8300h/entry.S 2004-02-23 13:56:37.000000000 +0000 @@ -236,7 +236,7 @@ SYMBOL_NAME_LABEL(system_call) mov.l @(LER3:16,sp),er2 jsr @er4 mov.l er0,@(LER0:16,sp) /* save the return value */ - jsr SYMBOL_NAME(syscall_trace) + jsr @SYMBOL_NAME(syscall_trace) SYMBOL_NAME_LABEL(ret_from_signal) @@ -253,7 +253,7 @@ SYMBOL_NAME_LABEL(ret_from_exception) 1: mov.l @(TI_FLAGS:16,er2),er1 btst #TIF_NEED_RESCHED,r1l - bne @SYMBOL_NAME(reschedule):16 + bne SYMBOL_NAME(reschedule):16 mov.l sp,er1 subs #4,er1 /* adjust retpc */ mov.l er2,er0 @@ -273,7 +273,7 @@ SYMBOL_NAME_LABEL(reschedule) SYMBOL_NAME_LABEL(ret_from_fork) mov.l er2,er0 jsr @SYMBOL_NAME(schedule_tail) - jmp @SYMBOL_NAME_LABEL(ret_from_exception) + jmp @SYMBOL_NAME(ret_from_exception) SYMBOL_NAME_LABEL(resume) /* --- diff/arch/h8300/platform/h8300h/generic/crt0_rom.S 2003-08-26 10:00:51.000000000 +0100 +++ source/arch/h8300/platform/h8300h/generic/crt0_rom.S 2004-02-23 13:56:37.000000000 +0000 @@ -105,6 +105,7 @@ gpio_table: ;; PBDDR .byte 0x00,0x00 + .section .rodata __target_name: .asciz "generic" --- diff/arch/h8300/platform/h8300h/generic/timer.c 2003-08-20 14:16:24.000000000 +0100 +++ source/arch/h8300/platform/h8300h/generic/timer.c 2004-02-23 13:56:37.000000000 +0000 @@ -29,13 +29,14 @@ extern int request_irq_boot(unsigned int #if defined(CONFIG_H83007) || defined(CONFIG_H83068) #include +#define CMFA 6 int platform_timer_setup(void (*timer_int)(int, void *, struct pt_regs *)) { - outb(H8300_TIMER_COUNT_DATA,TMR8CMA2); - outb(0x00,TMR8TCSR2); - request_irq_boot(40,timer_int,0,"timer",0); - outb(0x40|0x08|0x03,TMR8TCNT2); + ctrl_outb(H8300_TIMER_COUNT_DATA,TCORA2); + ctrl_outb(0x00,_8TCSR2); + request_irq(40,timer_int,0,"timer",0); + ctrl_outb(0x40|0x08|0x03,_8TCR2); return 0; } @@ -65,19 +66,19 @@ int platform_timer_setup(void (*timer_in { *(unsigned short *)GRA= H8300_TIMER_COUNT_DATA; *(unsigned short *)TCNT=0; - outb(0x23,TCR); - outb(0x00,TIOR); + ctrl_outb(0x23,TCR); + ctrl_outb(0x00,TIOR); request_timer_irq(26,timer_int,0,"timer",0); - outb(inb(TIER) | 0x01,TIER); - outb(inb(TSNC) & ~0x01,TSNC); - outb(inb(TMDR) & ~0x01,TMDR); - outb(inb(TSTR) | 0x01,TSTR); + ctrl_outb(inb(TIER) | 0x01,TIER); + ctrl_outb(inb(TSNC) & ~0x01,TSNC); + ctrl_outb(inb(TMDR) & ~0x01,TMDR); + ctrl_outb(inb(TSTR) | 0x01,TSTR); return 0; } void platform_timer_eoi(void) { - outb(inb(TSR) & ~0x01,TSR); + ctrl_outb(inb(TSR) & ~0x01,TSR); } #endif --- diff/arch/h8300/platform/h8300h/h8max/timer.c 2003-08-26 10:00:51.000000000 +0100 +++ source/arch/h8300/platform/h8300h/h8max/timer.c 2004-02-23 13:56:37.000000000 +0000 @@ -27,10 +27,10 @@ void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *)) { - outb(H8300_TIMER_COUNT_DATA,TCORA2); - outb(0x00,_8TCSR2); + ctrl_outb(H8300_TIMER_COUNT_DATA,TCORA2); + ctrl_outb(0x00,_8TCSR2); request_irq(40,timer_int,0,"timer",0); - outb(0x40|0x08|0x03,_8TCR2); + ctrl_outb(0x40|0x08|0x03,_8TCR2); } void platform_timer_eoi(void) --- diff/arch/h8300/platform/h8s/edosk2674/crt0_rom.S 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/h8300/platform/h8s/edosk2674/crt0_rom.S 2004-02-23 13:56:37.000000000 +0000 @@ -168,6 +168,7 @@ gpio_table: ;; PHDDR .byte 0x00,0x00 + .section .rodata __target_name: .asciz "EDOSK-2674" --- diff/arch/h8300/platform/h8s/edosk2674/timer.c 2003-08-26 10:00:51.000000000 +0100 +++ source/arch/h8300/platform/h8s/edosk2674/timer.c 2004-02-23 13:56:37.000000000 +0000 @@ -29,13 +29,13 @@ int __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *)) { unsigned char mstpcrl; - mstpcrl = inb(MSTPCRL); /* Enable timer */ + mstpcrl = ctrl_inb(MSTPCRL); /* Enable timer */ mstpcrl &= ~0x01; - outb(mstpcrl,MSTPCRL); - outb(H8300_TIMER_COUNT_DATA,_8TCORA1); - outb(0x00,_8TCSR1); + ctrl_outb(mstpcrl,MSTPCRL); + ctrl_outb(H8300_TIMER_COUNT_DATA,_8TCORA1); + ctrl_outb(0x00,_8TCSR1); request_irq(76,timer_int,0,"timer",0); - outb(0x40|0x08|0x03,_8TCR1); + ctrl_outb(0x40|0x08|0x03,_8TCR1); return 0; } --- diff/arch/h8300/platform/h8s/entry.S 2003-08-26 10:00:51.000000000 +0100 +++ source/arch/h8300/platform/h8s/entry.S 2004-02-23 13:56:37.000000000 +0000 @@ -233,7 +233,7 @@ SYMBOL_NAME_LABEL(system_call) mov.l @(LER3:16,sp),er2 jsr @er4 mov.l er0,@(LER0:16,sp) /* save the return value */ - jsr SYMBOL_NAME(syscall_trace) + jsr @SYMBOL_NAME(syscall_trace) SYMBOL_NAME_LABEL(ret_from_signal) @@ -250,7 +250,7 @@ SYMBOL_NAME_LABEL(ret_from_exception) 1: mov.l @(TI_FLAGS:16,er2),er1 btst #TIF_NEED_RESCHED,r1l - bne @SYMBOL_NAME(reschedule):16 + bne SYMBOL_NAME(reschedule):16 mov.l sp,er1 subs #4,er1 /* adjust retpc */ mov.l er2,er0 @@ -270,7 +270,7 @@ SYMBOL_NAME_LABEL(reschedule) SYMBOL_NAME_LABEL(ret_from_fork) mov.l er2,er0 jsr @SYMBOL_NAME(schedule_tail) - jmp @SYMBOL_NAME_LABEL(ret_from_exception) + jmp @SYMBOL_NAME(ret_from_exception) SYMBOL_NAME_LABEL(resume) --- diff/arch/h8300/platform/h8s/generic/crt0_rom.S 2003-08-26 10:00:51.000000000 +0100 +++ source/arch/h8300/platform/h8s/generic/crt0_rom.S 2004-02-23 13:56:37.000000000 +0000 @@ -110,6 +110,7 @@ gpio_table: ;; PHDDR .byte 0x00,0x00 + .section .rodata __target_name: .asciz "generic" --- diff/arch/h8300/platform/h8s/generic/timer.c 2003-08-26 10:00:51.000000000 +0100 +++ source/arch/h8300/platform/h8s/generic/timer.c 2004-02-23 13:56:37.000000000 +0000 @@ -25,10 +25,10 @@ int platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *)) { - outb(H8300_TIMER_COUNT_DATA,_8TCORA1); - outb(0x00,_8TCSR1); + ctrl_outb(H8300_TIMER_COUNT_DATA,_8TCORA1); + ctrl_outb(0x00,_8TCSR1); request_irq(76,timer_int,0,"timer",0); - outb(0x40|0x08|0x03,_8TCR1); + ctrl_outb(0x40|0x08|0x03,_8TCR1); return 0; } --- diff/arch/i386/Kconfig 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/Kconfig 2004-02-23 13:56:37.000000000 +0000 @@ -43,6 +43,15 @@ config X86_PC help Choose this option if your computer is a standard PC or compatible. +config X86_ELAN + bool "AMD Elan" + help + Select this for an AMD Elan processor. + + Do not use this option for K6/Athlon/Opteron processors! + + If unsure, choose "PC-compatible" instead. + config X86_VOYAGER bool "Voyager (NCR)" help @@ -130,6 +139,8 @@ config ES7000_CLUSTERED_APIC default y depends on SMP && X86_ES7000 && MPENTIUMIII +if !X86_ELAN + choice prompt "Processor family" default M686 @@ -222,14 +233,20 @@ config MPENTIUMIII extended prefetch instructions in addition to the Pentium II extensions. +config MPENTIUMM + bool "Pentium M" + help + Select this for Intel Pentium M (not Pentium-4 M) + notebook chips. + config MPENTIUM4 - bool "Pentium-4/Celeron(P4-based)/Xeon" + bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/Xeon" help - Select this for Intel Pentium 4 chips. This includes both - the Pentium 4 and P4-based Celeron chips. This option - enables compile flags optimized for the chip, uses the - correct cache shift, and applies any applicable Pentium III - optimizations. + Select this for Intel Pentium 4 chips. This includes the + Pentium 4, P4-based Celeron and Xeon, and Pentium-4 M + (not Pentium M) chips. This option enables compile flags + optimized for the chip, uses the correct cache shift, and + applies any applicable Pentium III optimizations. config MK6 bool "K6/K6-II/K6-III" @@ -312,6 +329,8 @@ config X86_GENERIC when it has moderate overhead. This is intended for generic distributions kernels. +endif + # # Define implied options from the CPU selection here # @@ -328,9 +347,9 @@ config X86_XADD config X86_L1_CACHE_SHIFT int default "7" if MPENTIUM4 || X86_GENERIC - default "4" if MELAN || M486 || M386 + default "4" if X86_ELAN || M486 || M386 default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 - default "6" if MK7 || MK8 + default "6" if MK7 || MK8 || MPENTIUMM config RWSEM_GENERIC_SPINLOCK bool @@ -374,22 +393,22 @@ config X86_POPAD_OK config X86_ALIGNMENT_16 bool - depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 + depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 default y config X86_GOOD_APIC bool - depends on MK7 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || MK8 + depends on MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || MK8 default y config X86_INTEL_USERCOPY bool - depends on MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 + depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 default y config X86_USE_PPRO_CHECKSUM bool - depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 + depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 default y config X86_USE_3DNOW @@ -402,6 +421,54 @@ config X86_OOSTORE depends on (MWINCHIP3D || MWINCHIP2 || MWINCHIPC6) && MTRR default y +config X86_4G + bool "4 GB kernel-space and 4 GB user-space virtual memory support" + help + This option is only useful for systems that have more than 1 GB + of RAM. + + The default kernel VM layout leaves 1 GB of virtual memory for + kernel-space mappings, and 3 GB of VM for user-space applications. + This option ups both the kernel-space VM and the user-space VM to + 4 GB. + + The cost of this option is additional TLB flushes done at + system-entry points that transition from user-mode into kernel-mode. + I.e. system calls and page faults, and IRQs that interrupt user-mode + code. There's also additional overhead to kernel operations that copy + memory to/from user-space. The overhead from this is hard to tell and + depends on the workload - it can be anything from no visible overhead + to 20-30% overhead. A good rule of thumb is to count with a runtime + overhead of 20%. + + The upside is the much increased kernel-space VM, which more than + quadruples the maximum amount of RAM supported. Kernels compiled with + this option boot on 64GB of RAM and still have more than 3.1 GB of + 'lowmem' left. Another bonus is that highmem IO bouncing decreases, + if used with drivers that still use bounce-buffers. + + There's also a 33% increase in user-space VM size - database + applications might see a boost from this. + + But the cost of the TLB flushes and the runtime overhead has to be + weighed against the bonuses offered by the larger VM spaces. The + dividing line depends on the actual workload - there might be 4 GB + systems that benefit from this option. Systems with less than 4 GB + of RAM will rarely see a benefit from this option - but it's not + out of question, the exact circumstances have to be considered. + +config X86_SWITCH_PAGETABLES + def_bool X86_4G + +config X86_4G_VM_LAYOUT + def_bool X86_4G + +config X86_UACCESS_INDIRECT + def_bool X86_4G + +config X86_HIGH_ENTRY + def_bool X86_4G + config HPET_TIMER bool "HPET Timer Support" help @@ -459,6 +526,16 @@ config NR_CPUS This is purely to save memory - each supported CPU adds approximately eight kilobytes to the kernel image. +config SCHED_SMT + bool "SMT (Hyperthreading) scheduler support" + depends on SMP + default off + help + SMT scheduler support improves the CPU scheduler's decision making + when dealing with Intel Pentium 4 chips with HyperThreading at a + cost of slightly increased overhead in some places. If unsure say + N here. + config PREEMPT bool "Preemptible Kernel" help @@ -513,7 +590,7 @@ config X86_IO_APIC config X86_TSC bool - depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2) && !X86_NUMAQ + depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2) && !X86_NUMAQ default y config X86_MCE @@ -603,8 +680,6 @@ config MICROCODE To compile this driver as a module, choose M here: the module will be called microcode. - If you use modprobe or kmod you may also want to add the line - 'alias char-major-10-184 microcode' to your /etc/modules.conf file. config X86_MSR tristate "/dev/cpu/*/msr - Model-specific register support" @@ -701,7 +776,7 @@ config X86_PAE # Common NUMA Features config NUMA bool "Numa Memory Allocation Support" - depends on SMP && HIGHMEM64G && (X86_PC || X86_NUMAQ || X86_GENERICARCH || (X86_SUMMIT && ACPI)) + depends on SMP && HIGHMEM64G && (X86_NUMAQ || X86_GENERICARCH || (X86_SUMMIT && ACPI)) default n if X86_PC default y if (X86_NUMAQ || X86_SUMMIT) @@ -809,6 +884,14 @@ config EFI anything about EFI). However, even with this option, the resultant kernel should continue to boot on existing non-EFI platforms. +config IRQBALANCE + bool "Enable kernel irq balancing" + depends on SMP + default y + help + The defalut yes will allow the kernel to do irq load balancing. + Saying no will keep the kernel from doing irq load balancing. + config HAVE_DEC_LOCK bool depends on (SMP || PREEMPT) && X86_CMPXCHG @@ -821,6 +904,19 @@ config BOOT_IOREMAP depends on (((X86_SUMMIT || X86_GENERICARCH) && NUMA) || (X86 && EFI)) default y +config REGPARM + bool "Use register arguments (EXPERIMENTAL)" + depends on EXPERIMENTAL + default n + help + Compile the kernel with -mregparm=3. This uses an different ABI + and passes the first three arguments of a function call in registers. + This will probably break binary only modules. + + This feature is only enabled for gcc-3.0 and later - earlier compilers + generate incorrect output with certain kernel constructs when + -mregparm=3 is used. + endmenu @@ -1030,12 +1126,16 @@ config PCI_GOBIOS PCI-based systems don't have any BIOS at all. Linux can also try to detect the PCI hardware directly without using the BIOS. - With this option, you can specify how Linux should detect the PCI - devices. If you choose "BIOS", the BIOS will be used, if you choose - "Direct", the BIOS won't be used, and if you choose "Any", the - kernel will try the direct access method and falls back to the BIOS - if that doesn't work. If unsure, go with the default, which is - "Any". + With this option, you can specify how Linux should detect the + PCI devices. If you choose "BIOS", the BIOS will be used, + if you choose "Direct", the BIOS won't be used, and if you + choose "MMConfig", then PCI Express MMCONFIG will be used. + If you choose "Any", the kernel will try MMCONFIG, then the + direct access method and falls back to the BIOS if that doesn't + work. If unsure, go with the default, which is "Any". + +config PCI_GOMMCONFIG + bool "MMConfig" config PCI_GODIRECT bool "Direct" @@ -1055,6 +1155,12 @@ config PCI_DIRECT depends on PCI && ((PCI_GODIRECT || PCI_GOANY) || X86_VISWS) default y +config PCI_MMCONFIG + bool + depends on PCI && (PCI_GOMMCONFIG || PCI_GOANY) + select ACPI_BOOT + default y + config PCI_USE_VECTOR bool "Vector-based interrupt indexing" depends on X86_LOCAL_APIC && X86_IO_APIC @@ -1131,24 +1237,6 @@ config SCx200 This support is also available as a module. If compiled as a module, it will be called scx200. -config HOTPLUG - bool "Support for hot-pluggable devices" - ---help--- - Say Y here if you want to plug devices into your computer while - the system is running, and be able to use them quickly. In many - cases, the devices can likewise be unplugged at any time too. - - One well known example of this is PCMCIA- or PC-cards, credit-card - size devices such as network cards, modems or hard drives which are - plugged into slots found on all modern laptop computers. Another - example, used on modern desktops as well as laptops, is USB. - - Enable HOTPLUG and KMOD, and build a modular kernel. Get agent - software (at ) and install it. - Then your kernel will automatically call out to a user mode "policy - agent" (/sbin/hotplug) to load modules and set up software needed - to use devices as you hotplug them. - source "drivers/pcmcia/Kconfig" source "drivers/pci/hotplug/Kconfig" @@ -1177,10 +1265,32 @@ config DEBUG_KERNEL Say Y here if you are developing drivers or trying to debug and identify kernel problems. +config EARLY_PRINTK + bool "Early printk" if EMBEDDED + default y + help + Write kernel log output directly into the VGA buffer or to a serial + port. + + This is useful for kernel debugging when your machine crashes very + early before the console code is initialized. For normal operation + it is not recommended because it looks ugly and doesn't cooperate + with klogd/syslogd or the X server. You should normally N here, + unless you want to debug such a crash. + config DEBUG_STACKOVERFLOW bool "Check for stack overflows" depends on DEBUG_KERNEL +config DEBUG_STACK_USAGE + bool "Stack utilization instrumentation" + depends on DEBUG_KERNEL + help + Enables the display of the minimum amount of free stack which each + task has ever had available in the sysrq-T and sysrq-P debug output. + + This option will slow down process creation somewhat. + config DEBUG_SLAB bool "Debug memory allocations" depends on DEBUG_KERNEL @@ -1231,6 +1341,15 @@ config DEBUG_PAGEALLOC This results in a large slowdown, but helps to find certain types of memory corruptions. +config SPINLINE + bool "Spinlock inlining" + depends on DEBUG_KERNEL + help + This will change spinlocks from out of line to inline, making them + account cost to the callers in readprofile, rather than the lock + itself (as ".text.lock.filename"). This can be helpful for finding + the callers of locks. + config DEBUG_HIGHMEM bool "Highmem debugging" depends on DEBUG_KERNEL && HIGHMEM @@ -1247,20 +1366,208 @@ config DEBUG_INFO Say Y here only if you plan to use gdb to debug the kernel. If you don't debug the kernel, you can say N. +config LOCKMETER + bool "Kernel lock metering" + depends on SMP + help + Say Y to enable kernel lock metering, which adds overhead to SMP locks, + but allows you to see various statistics using the lockstat command. + config DEBUG_SPINLOCK_SLEEP bool "Sleep-inside-spinlock checking" help If you say Y here, various routines which may sleep will become very noisy if they are called with a spinlock held. +config KGDB + bool "Include kgdb kernel debugger" + depends on DEBUG_KERNEL + help + If you say Y here, the system will be compiled with the debug + option (-g) and a debugging stub will be included in the + kernel. This stub communicates with gdb on another (host) + computer via a serial port. The host computer should have + access to the kernel binary file (vmlinux) and a serial port + that is connected to the target machine. Gdb can be made to + configure the serial port or you can use stty and setserial to + do this. See the 'target' command in gdb. This option also + configures in the ability to request a breakpoint early in the + boot process. To request the breakpoint just include 'kgdb' + as a boot option when booting the target machine. The system + will then break as soon as it looks at the boot options. This + option also installs a breakpoint in panic and sends any + kernel faults to the debugger. For more information see the + Documentation/i386/kgdb/kgdb.txt file. + +choice + depends on KGDB + prompt "Debug serial port BAUD" + default KGDB_115200BAUD + help + Gdb and the kernel stub need to agree on the baud rate to be + used. Some systems (x86 family at this writing) allow this to + be configured. + +config KGDB_9600BAUD + bool "9600" + +config KGDB_19200BAUD + bool "19200" + +config KGDB_38400BAUD + bool "38400" + +config KGDB_57600BAUD + bool "57600" + +config KGDB_115200BAUD + bool "115200" +endchoice + +config KGDB_PORT + hex "hex I/O port address of the debug serial port" + depends on KGDB + default 3f8 + help + Some systems (x86 family at this writing) allow the port + address to be configured. The number entered is assumed to be + hex, don't put 0x in front of it. The standard address are: + COM1 3f8 , irq 4 and COM2 2f8 irq 3. Setserial /dev/ttySx + will tell you what you have. It is good to test the serial + connection with a live system before trying to debug. + +config KGDB_IRQ + int "IRQ of the debug serial port" + depends on KGDB + default 4 + help + This is the irq for the debug port. If everything is working + correctly and the kernel has interrupts on a control C to the + port should cause a break into the kernel debug stub. + +config DEBUG_INFO + bool + depends on KGDB + default y + +config KGDB_MORE + bool "Add any additional compile options" + depends on KGDB + default n + help + Saying yes here turns on the ability to enter additional + compile options. + + +config KGDB_OPTIONS + depends on KGDB_MORE + string "Additional compile arguments" + default "-O1" + help + This option allows you enter additional compile options for + the whole kernel compile. Each platform will have a default + that seems right for it. For example on PPC "-ggdb -O1", and + for i386 "-O1". Note that by configuring KGDB "-g" is already + turned on. In addition, on i386 platforms + "-fomit-frame-pointer" is deleted from the standard compile + options. + +config NO_KGDB_CPUS + int "Number of CPUs" + depends on KGDB && SMP + default NR_CPUS + help + + This option sets the number of cpus for kgdb ONLY. It is used + to prune some internal structures so they look "nice" when + displayed with gdb. This is to overcome possibly larger + numbers that may have been entered above. Enter the real + number to get nice clean kgdb_info displays. + +config KGDB_TS + bool "Enable kgdb time stamp macros?" + depends on KGDB + default n + help + Kgdb event macros allow you to instrument your code with calls + to the kgdb event recording function. The event log may be + examined with gdb at a break point. Turning on this + capability also allows you to choose how many events to + keep. Kgdb always keeps the lastest events. + +choice + depends on KGDB_TS + prompt "Max number of time stamps to save?" + default KGDB_TS_128 + +config KGDB_TS_64 + bool "64" + +config KGDB_TS_128 + bool "128" + +config KGDB_TS_256 + bool "256" + +config KGDB_TS_512 + bool "512" + +config KGDB_TS_1024 + bool "1024" + +endchoice + +config STACK_OVERFLOW_TEST + bool "Turn on kernel stack overflow testing?" + depends on KGDB + default n + help + This option enables code in the front line interrupt handlers + to check for kernel stack overflow on interrupts and system + calls. This is part of the kgdb code on x86 systems. + +config KGDB_CONSOLE + bool "Enable serial console thru kgdb port" + depends on KGDB + default n + help + This option enables the command line "console=kgdb" option. + When the system is booted with this option in the command line + all kernel printk output is sent to gdb (as well as to other + consoles). For this to work gdb must be connected. For this + reason, this command line option will generate a breakpoint if + gdb has not yet connected. After the gdb continue command is + given all pent up console output will be printed by gdb on the + host machine. Neither this option, nor KGDB require the + serial driver to be configured. + +config KGDB_SYSRQ + bool "Turn on SysRq 'G' command to do a break?" + depends on KGDB + default y + help + This option includes an option in the SysRq code that allows + you to enter SysRq G which generates a breakpoint to the KGDB + stub. This will work if the keyboard is alive and can + interrupt the system. Because of constraints on when the + serial port interrupt can be enabled, this code may allow you + to interrupt the system before the serial port control C is + available. Just say yes here. + config FRAME_POINTER bool "Compile the kernel with frame pointers" + default KGDB help If you say Y here the resulting kernel image will be slightly larger and slower, but it will give very useful debugging information. If you don't debug the kernel, you can say N, but we may not be able to solve problems without frame pointers. +config MAGIC_SYSRQ + bool + depends on KGDB_SYSRQ + default y + config X86_FIND_SMP_CONFIG bool depends on X86_LOCAL_APIC || X86_VOYAGER --- diff/arch/i386/Makefile 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -19,7 +19,7 @@ LDFLAGS := -m elf_i386 OBJCOPYFLAGS := -O binary -R .note -R .comment -S LDFLAGS_vmlinux := -CFLAGS += -pipe +CFLAGS += -pipe -msoft-float # prevent gcc from keeping the stack 16 byte aligned CFLAGS += $(call check_gcc,-mpreferred-stack-boundary=2,) @@ -34,8 +34,9 @@ cflags-$(CONFIG_M586MMX) += $(call check cflags-$(CONFIG_M686) += -march=i686 cflags-$(CONFIG_MPENTIUMII) += $(call check_gcc,-march=pentium2,-march=i686) cflags-$(CONFIG_MPENTIUMIII) += $(call check_gcc,-march=pentium3,-march=i686) +cflags-$(CONFIG_MPENTIUMM) += $(call check_gcc,-march=pentium3,-march=i686) cflags-$(CONFIG_MPENTIUM4) += $(call check_gcc,-march=pentium4,-march=i686) -cflags-$(CONFIG_MK6) += $(call check_gcc,-march=k6,-march=i586) +cflags-$(CONFIG_MK6) += -march=k6 # Please note, that patches that add -march=athlon-xp and friends are pointless. # They make zero difference whatsosever to performance at this time. cflags-$(CONFIG_MK7) += $(call check_gcc,-march=athlon,-march=i686 $(align)-functions=4) @@ -47,6 +48,18 @@ cflags-$(CONFIG_MWINCHIP3D) += $(call ch cflags-$(CONFIG_MCYRIXIII) += $(call check_gcc,-march=c3,-march=i486) $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0 cflags-$(CONFIG_MVIAC3_2) += $(call check_gcc,-march=c3-2,-march=i686) +# AMD Elan support +cflags-$(CONFIG_X86_ELAN) += -march=i486 + +# -mregparm=3 works ok on gcc-3.0 and later +# +GCC_VERSION := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) +cflags-$(CONFIG_REGPARM) += $(shell if [ $(GCC_VERSION) -ge 0300 ] ; then echo "-mregparm=3"; fi ;) + +# Enable unit-at-a-time mode when possible. It shrinks the +# kernel considerably. +CFLAGS += $(call check_gcc,-funit-at-a-time,) + CFLAGS += $(cflags-y) # Default subarch .c files @@ -84,6 +97,9 @@ mcore-$(CONFIG_X86_ES7000) := mach-es700 # default subarch .h files mflags-y += -Iinclude/asm-i386/mach-default +mflags-$(CONFIG_KGDB) += -gdwarf-2 +mflags-$(CONFIG_KGDB_MORE) += $(shell echo $(CONFIG_KGDB_OPTIONS) | sed -e 's/"//g') + head-y := arch/i386/kernel/head.o arch/i386/kernel/init_task.o libs-y += arch/i386/lib/ --- diff/arch/i386/boot/Makefile 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/i386/boot/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -31,6 +31,8 @@ subdir- := compressed host-progs := tools/build +HOSTCFLAGS_build.o := -Iinclude + # --------------------------------------------------------------------------- $(obj)/zImage: IMAGE_OFFSET := 0x1000 --- diff/arch/i386/boot/setup.S 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/boot/setup.S 2004-02-23 13:56:37.000000000 +0000 @@ -164,7 +164,7 @@ cmd_line_ptr: .long 0 # (Header versio # can be located anywhere in # low memory 0x10000 or higher. -ramdisk_max: .long MAXMEM-1 # (Header version 0x0203 or later) +ramdisk_max: .long __MAXMEM-1 # (Header version 0x0203 or later) # The highest safe address for # the contents of an initrd @@ -776,7 +776,7 @@ end_move_self: # now we are at the r # AMD Elan bug fix by Robert Schwebel. # -#if defined(CONFIG_MELAN) +#if defined(CONFIG_X86_ELAN) movb $0x02, %al # alternate A20 gate outb %al, $0x92 # this works on SC410/SC520 a20_elan_wait: --- diff/arch/i386/kernel/Makefile 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/i386/kernel/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -7,13 +7,14 @@ extra-y := head.o init_task.o vmlinux.ld obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \ ptrace.o i8259.o ioport.o ldt.o setup.o time.o sys_i386.o \ pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \ - doublefault.o + doublefault.o entry_trampoline.o obj-y += cpu/ obj-y += timers/ obj-$(CONFIG_ACPI_BOOT) += acpi/ obj-$(CONFIG_X86_BIOS_REBOOT) += reboot.o obj-$(CONFIG_MCA) += mca.o +obj-$(CONFIG_KGDB) += kgdb_stub.o obj-$(CONFIG_X86_MSR) += msr.o obj-$(CONFIG_X86_CPUID) += cpuid.o obj-$(CONFIG_MICROCODE) += microcode.o @@ -31,6 +32,7 @@ obj-y += sysenter.o vsyscall.o obj-$(CONFIG_ACPI_SRAT) += srat.o obj-$(CONFIG_HPET_TIMER) += time_hpet.o obj-$(CONFIG_EFI) += efi.o efi_stub.o +obj-$(CONFIG_EARLY_PRINTK) += early_printk.o EXTRA_AFLAGS := -traditional --- diff/arch/i386/kernel/acpi/boot.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/kernel/acpi/boot.c 2004-02-23 13:56:37.000000000 +0000 @@ -96,6 +96,31 @@ char *__acpi_map_table(unsigned long phy } +#ifdef CONFIG_PCI_MMCONFIG +static int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size) +{ + struct acpi_table_mcfg *mcfg; + + if (!phys_addr || !size) + return -EINVAL; + + mcfg = (struct acpi_table_mcfg *) __acpi_map_table(phys_addr, size); + if (!mcfg) { + printk(KERN_WARNING PREFIX "Unable to map MCFG\n"); + return -ENODEV; + } + + if (mcfg->base_reserved) { + printk(KERN_ERR PREFIX "MMCONFIG not in low 4GB of memory\n"); + return -ENODEV; + } + + pci_mmcfg_base_addr = mcfg->base_address; + + return 0; +} +#endif /* CONFIG_PCI_MMCONFIG */ + #ifdef CONFIG_X86_LOCAL_APIC static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; @@ -339,7 +364,7 @@ acpi_scan_rsdp ( * RSDP signature. */ for (offset = 0; offset < length; offset += 16) { - if (strncmp((char *) (start + offset), "RSD PTR ", sig_len)) + if (strncmp((char *) __va(start + offset), "RSD PTR ", sig_len)) continue; return (start + offset); } @@ -376,6 +401,37 @@ static int __init acpi_parse_hpet(unsign } #endif +/* detect the location of the ACPI PM Timer */ +#ifdef CONFIG_X86_PM_TIMER +extern u32 pmtmr_ioport; + +static int __init acpi_parse_fadt(unsigned long phys, unsigned long size) +{ + struct fadt_descriptor_rev2 *fadt =0; + + fadt = (struct fadt_descriptor_rev2*) __acpi_map_table(phys,size); + if(!fadt) { + printk(KERN_WARNING PREFIX "Unable to map FADT\n"); + return 0; + } + + if (fadt->revision >= FADT2_REVISION_ID) { + /* FADT rev. 2 */ + if (fadt->xpm_tmr_blk.address_space_id != ACPI_ADR_SPACE_SYSTEM_IO) + return 0; + + pmtmr_ioport = fadt->xpm_tmr_blk.address; + } else { + /* FADT rev. 1 */ + pmtmr_ioport = fadt->V1_pm_tmr_blk; + } + if (pmtmr_ioport) + printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", pmtmr_ioport); + return 0; +} +#endif + + unsigned long __init acpi_find_rsdp (void) { @@ -398,55 +454,14 @@ acpi_find_rsdp (void) return rsdp_phys; } -/* - * acpi_boot_init() - * called from setup_arch(), always. - * 1. maps ACPI tables for later use - * 2. enumerates lapics - * 3. enumerates io-apics - * - * side effects: - * acpi_lapic = 1 if LAPIC found - * acpi_ioapic = 1 if IOAPIC found - * if (acpi_lapic && acpi_ioapic) smp_found_config = 1; - * if acpi_blacklisted() acpi_disabled = 1; - * acpi_irq_model=... - * ... - * - * return value: (currently ignored) - * 0: success - * !0: failure - */ -int __init -acpi_boot_init (void) +static int acpi_apic_setup(void) { - int result = 0; - - if (acpi_disabled && !acpi_ht) - return 1; + int result; - /* - * The default interrupt routing model is PIC (8259). This gets - * overriden if IOAPICs are enumerated (below). - */ - acpi_irq_model = ACPI_IRQ_MODEL_PIC; - - /* - * Initialize the ACPI boot-time table parser. - */ - result = acpi_table_init(); - if (result) { - acpi_disabled = 1; - return result; - } - - result = acpi_blacklisted(); - if (result) { - printk(KERN_WARNING PREFIX "BIOS listed in blacklist, disabling ACPI support\n"); - acpi_disabled = 1; - return result; - } +#ifdef CONFIG_X86_PM_TIMER + acpi_table_parse(ACPI_FADT, acpi_parse_fadt); +#endif #ifdef CONFIG_X86_LOCAL_APIC @@ -506,24 +521,17 @@ acpi_boot_init (void) acpi_lapic = 1; -#endif /*CONFIG_X86_LOCAL_APIC*/ +#endif /* CONFIG_X86_LOCAL_APIC */ #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER) /* * I/O APIC - * -------- */ - /* - * ACPI interpreter is required to complete interrupt setup, - * so if it is off, don't enumerate the io-apics with ACPI. - * If MPS is present, it will handle them, - * otherwise the system will stay in PIC mode - */ - if (acpi_disabled || acpi_noirq) { + if (acpi_noirq) { return 1; - } + } /* * if "noapic" boot option, don't look for IO-APICs @@ -538,8 +546,7 @@ acpi_boot_init (void) if (!result) { printk(KERN_ERR PREFIX "No IOAPIC entries present\n"); return -ENODEV; - } - else if (result < 0) { + } else if (result < 0) { printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n"); return result; } @@ -576,9 +583,82 @@ acpi_boot_init (void) } #endif + return 0; +} + +/* + * acpi_boot_init() + * called from setup_arch(), always. + * 1. maps ACPI tables for later use + * 2. enumerates lapics + * 3. enumerates io-apics + * + * side effects: + * acpi_lapic = 1 if LAPIC found + * acpi_ioapic = 1 if IOAPIC found + * if (acpi_lapic && acpi_ioapic) smp_found_config = 1; + * if acpi_blacklisted() acpi_disabled = 1; + * acpi_irq_model=... + * ... + * + * return value: (currently ignored) + * 0: success + * !0: failure + */ + +int __init +acpi_boot_init (void) +{ + int result, error; + + if (acpi_disabled && !acpi_ht) + return 1; + + /* + * The default interrupt routing model is PIC (8259). This gets + * overriden if IOAPICs are enumerated (below). + */ + acpi_irq_model = ACPI_IRQ_MODEL_PIC; + + /* + * Initialize the ACPI boot-time table parser. + */ + result = acpi_table_init(); + if (result) { + acpi_disabled = 1; + return result; + } + + result = acpi_blacklisted(); + if (result) { + printk(KERN_WARNING PREFIX "BIOS listed in blacklist, disabling ACPI support\n"); + acpi_disabled = 1; + return result; + } + + error = acpi_apic_setup(); + +#ifdef CONFIG_PCI_MMCONFIG + result = acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg); + if (result < 0) { + printk(KERN_ERR PREFIX "Error %d parsing MCFG\n", result); + if (!error) + error = result; + } else if (result > 1) { + printk(KERN_WARNING PREFIX "Multiple MCFG tables exist\n"); + } +#endif /* CONFIG_PCI_MMCONFIG */ + #ifdef CONFIG_HPET_TIMER - acpi_table_parse(ACPI_HPET, acpi_parse_hpet); + result = acpi_table_parse(ACPI_HPET, acpi_parse_hpet); + if (result < 0) { + printk(KERN_ERR PREFIX "Error %d parsing HPET\n", result); + if (!error) + error = result; + } else if (result > 1) { + printk(KERN_WARNING PREFIX "Multiple HPET tables exist\n"); + } #endif - return 0; + return error; } --- diff/arch/i386/kernel/apic.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/i386/kernel/apic.c 2004-02-23 13:56:37.000000000 +0000 @@ -595,7 +595,7 @@ static int __init init_lapic_sysfs(void) error = sysdev_class_register(&lapic_sysclass); if (!error) - error = sys_device_register(&device_lapic); + error = sysdev_register(&device_lapic); return error; } device_initcall(init_lapic_sysfs); --- diff/arch/i386/kernel/asm-offsets.c 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/kernel/asm-offsets.c 2004-02-23 13:56:37.000000000 +0000 @@ -4,9 +4,11 @@ * to extract and format the required data. */ +#include #include #include #include "sigframe.h" +#include #define DEFINE(sym, val) \ asm volatile("\n->" #sym " %0 " #val : : "i" (val)) @@ -28,4 +30,17 @@ void foo(void) DEFINE(RT_SIGFRAME_sigcontext, offsetof (struct rt_sigframe, uc.uc_mcontext)); + DEFINE(TI_task, offsetof (struct thread_info, task)); + DEFINE(TI_exec_domain, offsetof (struct thread_info, exec_domain)); + DEFINE(TI_flags, offsetof (struct thread_info, flags)); + DEFINE(TI_preempt_count, offsetof (struct thread_info, preempt_count)); + DEFINE(TI_addr_limit, offsetof (struct thread_info, addr_limit)); + DEFINE(TI_real_stack, offsetof (struct thread_info, real_stack)); + DEFINE(TI_virtual_stack, offsetof (struct thread_info, virtual_stack)); + DEFINE(TI_user_pgd, offsetof (struct thread_info, user_pgd)); + + DEFINE(FIX_ENTRY_TRAMPOLINE_0_addr, __fix_to_virt(FIX_ENTRY_TRAMPOLINE_0)); + DEFINE(FIX_VSYSCALL_addr, __fix_to_virt(FIX_VSYSCALL)); + DEFINE(PAGE_SIZE_asm, PAGE_SIZE); + DEFINE(task_thread_db7, offsetof (struct task_struct, thread.debugreg[7])); } --- diff/arch/i386/kernel/cpu/centaur.c 2003-05-21 11:49:49.000000000 +0100 +++ source/arch/i386/kernel/cpu/centaur.c 2004-02-23 13:56:37.000000000 +0000 @@ -246,7 +246,15 @@ static void __init winchip2_protect_mcr( lo&=~0x1C0; /* blank bits 8-6 */ wrmsr(MSR_IDT_MCR_CTRL, lo, hi); } -#endif +#endif /* CONFIG_X86_OOSTORE */ + +#define ACE_PRESENT (1 << 6) +#define ACE_ENABLED (1 << 7) +#define ACE_FCR (1 << 28) /* MSR_VIA_FCR */ + +#define RNG_PRESENT (1 << 2) +#define RNG_ENABLED (1 << 3) +#define RNG_ENABLE (1 << 6) /* MSR_VIA_RNG */ static void __init init_c3(struct cpuinfo_x86 *c) { @@ -254,6 +262,24 @@ static void __init init_c3(struct cpuinf /* Test for Centaur Extended Feature Flags presence */ if (cpuid_eax(0xC0000000) >= 0xC0000001) { + u32 tmp = cpuid_edx(0xC0000001); + + /* enable ACE unit, if present and disabled */ + if ((tmp & (ACE_PRESENT | ACE_ENABLED)) == ACE_PRESENT) { + rdmsr (MSR_VIA_FCR, lo, hi); + lo |= ACE_FCR; /* enable ACE unit */ + wrmsr (MSR_VIA_FCR, lo, hi); + printk(KERN_INFO "CPU: Enabled ACE h/w crypto\n"); + } + + /* enable RNG unit, if present and disabled */ + if ((tmp & (RNG_PRESENT | RNG_ENABLED)) == RNG_PRESENT) { + rdmsr (MSR_VIA_RNG, lo, hi); + lo |= RNG_ENABLE; /* enable RNG unit */ + wrmsr (MSR_VIA_RNG, lo, hi); + printk(KERN_INFO "CPU: Enabled h/w RNG\n"); + } + /* store Centaur Extended Feature Flags as * word 5 of the CPU capability bit array */ --- diff/arch/i386/kernel/cpu/common.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/i386/kernel/cpu/common.c 2004-02-23 13:56:37.000000000 +0000 @@ -514,12 +514,16 @@ void __init cpu_init (void) set_tss_desc(cpu,t); cpu_gdt_table[cpu][GDT_ENTRY_TSS].b &= 0xfffffdff; load_TR_desc(); - load_LDT(&init_mm.context); + if (cpu) + load_LDT(&init_mm.context); /* Set up doublefault TSS pointer in the GDT */ __set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss); cpu_gdt_table[cpu][GDT_ENTRY_DOUBLEFAULT_TSS].b &= 0xfffffdff; + if (cpu) + trap_init_virtual_GDT(); + /* Clear %fs and %gs. */ asm volatile ("xorl %eax, %eax; movl %eax, %fs; movl %eax, %gs"); --- diff/arch/i386/kernel/cpu/cpufreq/Kconfig 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/i386/kernel/cpu/cpufreq/Kconfig 2004-02-23 13:56:37.000000000 +0000 @@ -54,7 +54,7 @@ config X86_ACPI_CPUFREQ_PROC_INTF config ELAN_CPUFREQ tristate "AMD Elan" - depends on CPU_FREQ_TABLE && MELAN + depends on CPU_FREQ_TABLE && X86_ELAN ---help--- This adds the CPUFreq driver for AMD Elan SC400 and SC410 processors. --- diff/arch/i386/kernel/cpu/cpufreq/longhaul.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/kernel/cpu/cpufreq/longhaul.c 2004-02-23 13:56:37.000000000 +0000 @@ -1,5 +1,5 @@ /* - * (C) 2001-2003 Dave Jones. + * (C) 2001-2004 Dave Jones. * (C) 2002 Padraig Brady. * * Licensed under the terms of the GNU GPL License version 2. @@ -186,6 +186,7 @@ static int _guess (int guess, int maxmul return target; } + static int guess_fsb(int maxmult) { int speed = (cpu_khz/1000); @@ -203,7 +204,6 @@ static int guess_fsb(int maxmult) } - static int __init longhaul_get_ranges (void) { struct cpuinfo_x86 *c = cpu_data; @@ -359,7 +359,7 @@ static int longhaul_target (struct cpufr return 0; } -static int longhaul_cpu_init (struct cpufreq_policy *policy) +static int __init longhaul_cpu_init (struct cpufreq_policy *policy) { struct cpuinfo_x86 *c = cpu_data; char *cpuname=NULL; --- diff/arch/i386/kernel/cpu/cpufreq/longrun.c 2003-09-17 12:28:01.000000000 +0100 +++ source/arch/i386/kernel/cpu/cpufreq/longrun.c 2004-02-23 13:56:37.000000000 +0000 @@ -220,7 +220,7 @@ static unsigned int __init longrun_deter } -static int longrun_cpu_init(struct cpufreq_policy *policy) +static int __init longrun_cpu_init(struct cpufreq_policy *policy) { int result = 0; --- diff/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c 2004-02-23 13:56:37.000000000 +0000 @@ -57,8 +57,7 @@ static int cpufreq_p4_setdc(unsigned int u32 l, h; cpumask_t cpus_allowed, affected_cpu_map; struct cpufreq_freqs freqs; - int hyperthreading = 0; - int sibling = 0; + int j; if (!cpu_online(cpu) || (newstate > DC_DISABLE) || (newstate == DC_RESV)) @@ -68,13 +67,10 @@ static int cpufreq_p4_setdc(unsigned int cpus_allowed = current->cpus_allowed; /* only run on CPU to be set, or on its sibling */ - affected_cpu_map = cpumask_of_cpu(cpu); -#ifdef CONFIG_X86_HT - hyperthreading = ((cpu_has_ht) && (smp_num_siblings == 2)); - if (hyperthreading) { - sibling = cpu_sibling_map[cpu]; - cpu_set(sibling, affected_cpu_map); - } +#ifdef CONFIG_SMP + affected_cpu_map = cpu_sibling_map[cpu]; +#else + affected_cpu_map = cpumask_of_cpu(cpu); #endif set_cpus_allowed(current, affected_cpu_map); BUG_ON(!cpu_isset(smp_processor_id(), affected_cpu_map)); @@ -97,11 +93,11 @@ static int cpufreq_p4_setdc(unsigned int /* notifiers */ freqs.old = stock_freq * l / 8; freqs.new = stock_freq * newstate / 8; - freqs.cpu = cpu; - cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); - if (hyperthreading) { - freqs.cpu = sibling; - cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); + for_each_cpu(j) { + if (cpu_isset(j, affected_cpu_map)) { + freqs.cpu = j; + cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); + } } rdmsr(MSR_IA32_THERM_STATUS, l, h); @@ -132,10 +128,11 @@ static int cpufreq_p4_setdc(unsigned int set_cpus_allowed(current, cpus_allowed); /* notifiers */ - cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); - if (hyperthreading) { - freqs.cpu = cpu; - cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); + for_each_cpu(j) { + if (cpu_isset(j, affected_cpu_map)) { + freqs.cpu = j; + cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); + } } return 0; --- diff/arch/i386/kernel/cpu/cpufreq/powernow-k7.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/kernel/cpu/cpufreq/powernow-k7.c 2004-02-23 13:56:37.000000000 +0000 @@ -1,7 +1,7 @@ /* * AMD K7 Powernow driver. * (C) 2003 Dave Jones on behalf of SuSE Labs. - * (C) 2003 Dave Jones + * (C) 2003-2004 Dave Jones * * Licensed under the terms of the GNU GPL License version 2. * Based upon datasheets & sample CPUs kindly provided by AMD. --- diff/arch/i386/kernel/cpu/cpufreq/powernow-k8.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/kernel/cpu/cpufreq/powernow-k8.c 2004-02-23 13:56:37.000000000 +0000 @@ -521,7 +521,8 @@ static int check_pst_table(struct pst_s } if ((pst[j].fid > MAX_FID) || (pst[j].fid & 1) - || (pst[j].fid < HI_FID_TABLE_BOTTOM)){ + || (j && (pst[j].fid < HI_FID_TABLE_BOTTOM))) { + /* Only first fid is allowed to be in "low" range */ printk(KERN_ERR PFX "fid %d invalid : 0x%x\n", j, pst[j].fid); return -EINVAL; } --- diff/arch/i386/kernel/cpu/intel.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/kernel/cpu/intel.c 2004-02-23 13:56:37.000000000 +0000 @@ -10,6 +10,7 @@ #include #include #include +#include #include "cpu.h" @@ -19,8 +20,6 @@ #include #endif -extern int trap_init_f00f_bug(void); - #ifdef CONFIG_X86_INTEL_USERCOPY /* * Alignment at which movsl is preferred for bulk memory copies. @@ -165,7 +164,7 @@ static void __init init_intel(struct cpu c->f00f_bug = 1; if ( !f00f_workaround_enabled ) { - trap_init_f00f_bug(); + trap_init_virtual_IDT(); printk(KERN_NOTICE "Intel Pentium with F0 0F bug - workaround enabled.\n"); f00f_workaround_enabled = 1; } @@ -231,6 +230,8 @@ static void __init init_intel(struct cpu printk (KERN_INFO "CPU: L1 I cache: %dK", l1i); if ( l1d ) printk(", L1 D cache: %dK\n", l1d); + else + printk("\n"); if ( l2 ) printk(KERN_INFO "CPU: L2 cache: %dK\n", l2); if ( l3 ) @@ -248,6 +249,12 @@ static void __init init_intel(struct cpu /* SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until model 3 mask 3 */ if ((c->x86<<8 | c->x86_model<<4 | c->x86_mask) < 0x633) clear_bit(X86_FEATURE_SEP, c->x86_capability); + /* + * FIXME: SEP is disabled for 4G/4G for now: + */ +#ifdef CONFIG_X86_HIGH_ENTRY + clear_bit(X86_FEATURE_SEP, c->x86_capability); +#endif /* Names for the Pentium II/Celeron processors detectable only by also checking the cache size. --- diff/arch/i386/kernel/cpu/mcheck/non-fatal.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/i386/kernel/cpu/mcheck/non-fatal.c 2004-02-23 13:56:37.000000000 +0000 @@ -24,8 +24,6 @@ #include "mce.h" -static struct timer_list mce_timer; -static int timerset; static int firstbank; #define MCE_RATE 15*HZ /* timer rate is 15s */ @@ -35,14 +33,15 @@ static void mce_checkregs (void *info) u32 low, high; int i; - preempt_disable(); for (i=firstbank; i 1) - schedule_work (&mce_work); -#endif - mce_timer.expires = jiffies + MCE_RATE; - add_timer (&mce_timer); -} - static int __init init_nonfatal_mce_checker(void) { struct cpuinfo_x86 *c = &boot_cpu_data; @@ -91,17 +80,11 @@ static int __init init_nonfatal_mce_chec else firstbank = 0; - if (timerset == 0) { - /* Set the timer to check for non-fatal - errors every MCE_RATE seconds */ - init_timer (&mce_timer); - mce_timer.expires = jiffies + MCE_RATE; - mce_timer.data = 0; - mce_timer.function = &mce_timerfunc; - add_timer (&mce_timer); - timerset = 1; - printk(KERN_INFO "Machine check exception polling timer started.\n"); - } + /* + * Check for non-fatal errors every MCE_RATE s + */ + schedule_delayed_work(&mce_work, MCE_RATE); + printk(KERN_INFO "Machine check exception polling timer started.\n"); return 0; } module_init(init_nonfatal_mce_checker); --- diff/arch/i386/kernel/cpu/mtrr/generic.c 2003-08-26 10:00:51.000000000 +0100 +++ source/arch/i386/kernel/cpu/mtrr/generic.c 2004-02-23 13:56:37.000000000 +0000 @@ -45,7 +45,7 @@ get_fixed_ranges(mtrr_type * frs) } /* Grab all of the MTRR state for this CPU into *state */ -void get_mtrr_state(void) +void __init get_mtrr_state(void) { unsigned int i; struct mtrr_var_range *vrs; @@ -142,7 +142,7 @@ void generic_get_mtrr(unsigned int reg, *type = base_lo & 0xff; } -static int __init set_fixed_ranges(mtrr_type * frs) +static int set_fixed_ranges(mtrr_type * frs) { unsigned int *p = (unsigned int *) frs; int changed = FALSE; @@ -177,7 +177,7 @@ static int __init set_fixed_ranges(mtrr_ /* Set the MSR pair relating to a var range. Returns TRUE if changes are made */ -static int __init set_mtrr_var_ranges(unsigned int index, struct mtrr_var_range *vr) +static int set_mtrr_var_ranges(unsigned int index, struct mtrr_var_range *vr) { unsigned int lo, hi; int changed = FALSE; --- diff/arch/i386/kernel/cpu/mtrr/main.c 2003-09-17 12:28:01.000000000 +0100 +++ source/arch/i386/kernel/cpu/mtrr/main.c 2004-02-23 13:56:37.000000000 +0000 @@ -111,7 +111,7 @@ void __init set_num_var_ranges(void) num_var_ranges = config & 0xff; } -static void init_table(void) +static void __init init_table(void) { int i, max; @@ -541,7 +541,7 @@ static void __init init_ifs(void) centaur_init_mtrr(); } -static void init_other_cpus(void) +static void __init init_other_cpus(void) { if (use_intel()) get_mtrr_state(); @@ -608,7 +608,7 @@ static struct sysdev_driver mtrr_sysdev_ /** - * mtrr_init - initialie mtrrs on the boot CPU + * mtrr_init - initialize mtrrs on the boot CPU * * This needs to be called early; before any of the other CPUs are * initialized (i.e. before smp_init()). @@ -618,7 +618,7 @@ static int __init mtrr_init(void) { init_ifs(); - if ( cpu_has_mtrr ) { + if (cpu_has_mtrr) { mtrr_if = &generic_mtrr_ops; size_or_mask = 0xff000000; /* 36 bits */ size_and_mask = 0x00f00000; @@ -660,7 +660,7 @@ static int __init mtrr_init(void) } else { switch (boot_cpu_data.x86_vendor) { case X86_VENDOR_AMD: - if ( cpu_has_k6_mtrr ) { + if (cpu_has_k6_mtrr) { /* Pre-Athlon (K6) AMD CPU MTRRs */ mtrr_if = mtrr_ops[X86_VENDOR_AMD]; size_or_mask = 0xfff00000; /* 32 bits */ @@ -668,14 +668,14 @@ static int __init mtrr_init(void) } break; case X86_VENDOR_CENTAUR: - if ( cpu_has_centaur_mcr ) { + if (cpu_has_centaur_mcr) { mtrr_if = mtrr_ops[X86_VENDOR_CENTAUR]; size_or_mask = 0xfff00000; /* 32 bits */ size_and_mask = 0; } break; case X86_VENDOR_CYRIX: - if ( cpu_has_cyrix_arr ) { + if (cpu_has_cyrix_arr) { mtrr_if = mtrr_ops[X86_VENDOR_CYRIX]; size_or_mask = 0xfff00000; /* 32 bits */ size_and_mask = 0; --- diff/arch/i386/kernel/cpu/proc.c 2003-08-26 10:00:51.000000000 +0100 +++ source/arch/i386/kernel/cpu/proc.c 2004-02-23 13:56:37.000000000 +0000 @@ -50,7 +50,7 @@ static int show_cpuinfo(struct seq_file NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* VIA/Cyrix/Centaur-defined */ - NULL, NULL, "xstore", NULL, NULL, NULL, NULL, NULL, + NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, --- diff/arch/i386/kernel/doublefault.c 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/kernel/doublefault.c 2004-02-23 13:56:37.000000000 +0000 @@ -7,12 +7,13 @@ #include #include #include +#include #define DOUBLEFAULT_STACKSIZE (1024) static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE]; #define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE) -#define ptr_ok(x) ((x) > 0xc0000000 && (x) < 0xc1000000) +#define ptr_ok(x) (((x) > __PAGE_OFFSET && (x) < (__PAGE_OFFSET + 0x01000000)) || ((x) >= FIXADDR_START)) static void doublefault_fn(void) { @@ -38,8 +39,8 @@ static void doublefault_fn(void) printk("eax = %08lx, ebx = %08lx, ecx = %08lx, edx = %08lx\n", t->eax, t->ebx, t->ecx, t->edx); - printk("esi = %08lx, edi = %08lx\n", - t->esi, t->edi); + printk("esi = %08lx, edi = %08lx, ebp = %08lx\n", + t->esi, t->edi, t->ebp); } } --- diff/arch/i386/kernel/edd.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/kernel/edd.c 2004-02-23 13:56:37.000000000 +0000 @@ -134,18 +134,18 @@ edd_show_host_bus(struct edd_device *ede for (i = 0; i < 4; i++) { if (isprint(info->params.host_bus_type[i])) { - p += snprintf(p, left, "%c", info->params.host_bus_type[i]); + p += scnprintf(p, left, "%c", info->params.host_bus_type[i]); } else { - p += snprintf(p, left, " "); + p += scnprintf(p, left, " "); } } if (!strncmp(info->params.host_bus_type, "ISA", 3)) { - p += snprintf(p, left, "\tbase_address: %x\n", + p += scnprintf(p, left, "\tbase_address: %x\n", info->params.interface_path.isa.base_address); } else if (!strncmp(info->params.host_bus_type, "PCIX", 4) || !strncmp(info->params.host_bus_type, "PCI", 3)) { - p += snprintf(p, left, + p += scnprintf(p, left, "\t%02x:%02x.%d channel: %u\n", info->params.interface_path.pci.bus, info->params.interface_path.pci.slot, @@ -154,12 +154,12 @@ edd_show_host_bus(struct edd_device *ede } else if (!strncmp(info->params.host_bus_type, "IBND", 4) || !strncmp(info->params.host_bus_type, "XPRS", 4) || !strncmp(info->params.host_bus_type, "HTPT", 4)) { - p += snprintf(p, left, + p += scnprintf(p, left, "\tTBD: %llx\n", info->params.interface_path.ibnd.reserved); } else { - p += snprintf(p, left, "\tunknown: %llx\n", + p += scnprintf(p, left, "\tunknown: %llx\n", info->params.interface_path.unknown.reserved); } return (p - buf); @@ -178,43 +178,43 @@ edd_show_interface(struct edd_device *ed for (i = 0; i < 8; i++) { if (isprint(info->params.interface_type[i])) { - p += snprintf(p, left, "%c", info->params.interface_type[i]); + p += scnprintf(p, left, "%c", info->params.interface_type[i]); } else { - p += snprintf(p, left, " "); + p += scnprintf(p, left, " "); } } if (!strncmp(info->params.interface_type, "ATAPI", 5)) { - p += snprintf(p, left, "\tdevice: %u lun: %u\n", + p += scnprintf(p, left, "\tdevice: %u lun: %u\n", info->params.device_path.atapi.device, info->params.device_path.atapi.lun); } else if (!strncmp(info->params.interface_type, "ATA", 3)) { - p += snprintf(p, left, "\tdevice: %u\n", + p += scnprintf(p, left, "\tdevice: %u\n", info->params.device_path.ata.device); } else if (!strncmp(info->params.interface_type, "SCSI", 4)) { - p += snprintf(p, left, "\tid: %u lun: %llu\n", + p += scnprintf(p, left, "\tid: %u lun: %llu\n", info->params.device_path.scsi.id, info->params.device_path.scsi.lun); } else if (!strncmp(info->params.interface_type, "USB", 3)) { - p += snprintf(p, left, "\tserial_number: %llx\n", + p += scnprintf(p, left, "\tserial_number: %llx\n", info->params.device_path.usb.serial_number); } else if (!strncmp(info->params.interface_type, "1394", 4)) { - p += snprintf(p, left, "\teui: %llx\n", + p += scnprintf(p, left, "\teui: %llx\n", info->params.device_path.i1394.eui); } else if (!strncmp(info->params.interface_type, "FIBRE", 5)) { - p += snprintf(p, left, "\twwid: %llx lun: %llx\n", + p += scnprintf(p, left, "\twwid: %llx lun: %llx\n", info->params.device_path.fibre.wwid, info->params.device_path.fibre.lun); } else if (!strncmp(info->params.interface_type, "I2O", 3)) { - p += snprintf(p, left, "\tidentity_tag: %llx\n", + p += scnprintf(p, left, "\tidentity_tag: %llx\n", info->params.device_path.i2o.identity_tag); } else if (!strncmp(info->params.interface_type, "RAID", 4)) { - p += snprintf(p, left, "\tidentity_tag: %x\n", + p += scnprintf(p, left, "\tidentity_tag: %x\n", info->params.device_path.raid.array_number); } else if (!strncmp(info->params.interface_type, "SATA", 4)) { - p += snprintf(p, left, "\tdevice: %u\n", + p += scnprintf(p, left, "\tdevice: %u\n", info->params.device_path.sata.device); } else { - p += snprintf(p, left, "\tunknown: %llx %llx\n", + p += scnprintf(p, left, "\tunknown: %llx %llx\n", info->params.device_path.unknown.reserved1, info->params.device_path.unknown.reserved2); } @@ -256,7 +256,7 @@ edd_show_version(struct edd_device *edev return -EINVAL; } - p += snprintf(p, left, "0x%02x\n", info->version); + p += scnprintf(p, left, "0x%02x\n", info->version); return (p - buf); } @@ -264,7 +264,7 @@ static ssize_t edd_show_disk80_sig(struct edd_device *edev, char *buf) { char *p = buf; - p += snprintf(p, left, "0x%08x\n", edd_disk80_sig); + p += scnprintf(p, left, "0x%08x\n", edd_disk80_sig); return (p - buf); } @@ -278,16 +278,16 @@ edd_show_extensions(struct edd_device *e } if (info->interface_support & EDD_EXT_FIXED_DISK_ACCESS) { - p += snprintf(p, left, "Fixed disk access\n"); + p += scnprintf(p, left, "Fixed disk access\n"); } if (info->interface_support & EDD_EXT_DEVICE_LOCKING_AND_EJECTING) { - p += snprintf(p, left, "Device locking and ejecting\n"); + p += scnprintf(p, left, "Device locking and ejecting\n"); } if (info->interface_support & EDD_EXT_ENHANCED_DISK_DRIVE_SUPPORT) { - p += snprintf(p, left, "Enhanced Disk Drive support\n"); + p += scnprintf(p, left, "Enhanced Disk Drive support\n"); } if (info->interface_support & EDD_EXT_64BIT_EXTENSIONS) { - p += snprintf(p, left, "64-bit extensions\n"); + p += scnprintf(p, left, "64-bit extensions\n"); } return (p - buf); } @@ -302,21 +302,21 @@ edd_show_info_flags(struct edd_device *e } if (info->params.info_flags & EDD_INFO_DMA_BOUNDARY_ERROR_TRANSPARENT) - p += snprintf(p, left, "DMA boundary error transparent\n"); + p += scnprintf(p, left, "DMA boundary error transparent\n"); if (info->params.info_flags & EDD_INFO_GEOMETRY_VALID) - p += snprintf(p, left, "geometry valid\n"); + p += scnprintf(p, left, "geometry valid\n"); if (info->params.info_flags & EDD_INFO_REMOVABLE) - p += snprintf(p, left, "removable\n"); + p += scnprintf(p, left, "removable\n"); if (info->params.info_flags & EDD_INFO_WRITE_VERIFY) - p += snprintf(p, left, "write verify\n"); + p += scnprintf(p, left, "write verify\n"); if (info->params.info_flags & EDD_INFO_MEDIA_CHANGE_NOTIFICATION) - p += snprintf(p, left, "media change notification\n"); + p += scnprintf(p, left, "media change notification\n"); if (info->params.info_flags & EDD_INFO_LOCKABLE) - p += snprintf(p, left, "lockable\n"); + p += scnprintf(p, left, "lockable\n"); if (info->params.info_flags & EDD_INFO_NO_MEDIA_PRESENT) - p += snprintf(p, left, "no media present\n"); + p += scnprintf(p, left, "no media present\n"); if (info->params.info_flags & EDD_INFO_USE_INT13_FN50) - p += snprintf(p, left, "use int13 fn50\n"); + p += scnprintf(p, left, "use int13 fn50\n"); return (p - buf); } @@ -329,7 +329,7 @@ edd_show_default_cylinders(struct edd_de return -EINVAL; } - p += snprintf(p, left, "0x%x\n", info->params.num_default_cylinders); + p += scnprintf(p, left, "0x%x\n", info->params.num_default_cylinders); return (p - buf); } @@ -342,7 +342,7 @@ edd_show_default_heads(struct edd_device return -EINVAL; } - p += snprintf(p, left, "0x%x\n", info->params.num_default_heads); + p += scnprintf(p, left, "0x%x\n", info->params.num_default_heads); return (p - buf); } @@ -355,7 +355,7 @@ edd_show_default_sectors_per_track(struc return -EINVAL; } - p += snprintf(p, left, "0x%x\n", info->params.sectors_per_track); + p += scnprintf(p, left, "0x%x\n", info->params.sectors_per_track); return (p - buf); } @@ -368,7 +368,7 @@ edd_show_sectors(struct edd_device *edev return -EINVAL; } - p += snprintf(p, left, "0x%llx\n", info->params.number_of_sectors); + p += scnprintf(p, left, "0x%llx\n", info->params.number_of_sectors); return (p - buf); } --- diff/arch/i386/kernel/entry.S 2003-11-25 15:24:57.000000000 +0000 +++ source/arch/i386/kernel/entry.S 2004-02-23 13:56:37.000000000 +0000 @@ -43,11 +43,25 @@ #include #include #include +#include #include #include +#include #include #include #include "irq_vectors.h" + /* We do not recover from a stack overflow, but at least + * we know it happened and should be able to track it down. + */ +#ifdef CONFIG_STACK_OVERFLOW_TEST +#define STACK_OVERFLOW_TEST \ + testl $7680,%esp; \ + jnz 10f; \ + call stack_overflow; \ +10: +#else +#define STACK_OVERFLOW_TEST +#endif #define nr_syscalls ((syscall_table_size)/4) @@ -87,7 +101,102 @@ TSS_ESP0_OFFSET = (4 - 0x200) #define resume_kernel restore_all #endif -#define SAVE_ALL \ +#ifdef CONFIG_X86_HIGH_ENTRY + +#ifdef CONFIG_X86_SWITCH_PAGETABLES + +#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP) +/* + * If task is preempted in __SWITCH_KERNELSPACE, and moved to another cpu, + * __switch_to repoints %esp to the appropriate virtual stack; but %ebp is + * left stale, so we must check whether to repeat the real stack calculation. + */ +#define repeat_if_esp_changed \ + xorl %esp, %ebp; \ + testl $-THREAD_SIZE, %ebp; \ + jnz 0b +#else +#define repeat_if_esp_changed +#endif + +/* clobbers ebx, edx and ebp */ + +#define __SWITCH_KERNELSPACE \ + cmpl $0xff000000, %esp; \ + jb 1f; \ + \ + /* \ + * switch pagetables and load the real stack, \ + * keep the stack offset: \ + */ \ + \ + movl $swapper_pg_dir-__PAGE_OFFSET, %edx; \ + \ + /* GET_THREAD_INFO(%ebp) intermixed */ \ +0: \ + movl %esp, %ebp; \ + movl %esp, %ebx; \ + andl $(-THREAD_SIZE), %ebp; \ + andl $(THREAD_SIZE-1), %ebx; \ + orl TI_real_stack(%ebp), %ebx; \ + repeat_if_esp_changed; \ + \ + movl %edx, %cr3; \ + movl %ebx, %esp; \ +1: + +#endif + + +#define __SWITCH_USERSPACE \ + /* interrupted any of the user return paths? */ \ + \ + movl EIP(%esp), %eax; \ + \ + cmpl $int80_ret_start_marker, %eax; \ + jb 33f; /* nope - continue with sysexit check */\ + cmpl $int80_ret_end_marker, %eax; \ + jb 22f; /* yes - switch to virtual stack */ \ +33: \ + cmpl $sysexit_ret_start_marker, %eax; \ + jb 44f; /* nope - continue with user check */ \ + cmpl $sysexit_ret_end_marker, %eax; \ + jb 22f; /* yes - switch to virtual stack */ \ + /* return to userspace? */ \ +44: \ + movl EFLAGS(%esp),%ecx; \ + movb CS(%esp),%cl; \ + testl $(VM_MASK | 3),%ecx; \ + jz 2f; \ +22: \ + /* \ + * switch to the virtual stack, then switch to \ + * the userspace pagetables. \ + */ \ + \ + GET_THREAD_INFO(%ebp); \ + movl TI_virtual_stack(%ebp), %edx; \ + movl TI_user_pgd(%ebp), %ecx; \ + \ + movl %esp, %ebx; \ + andl $(THREAD_SIZE-1), %ebx; \ + orl %ebx, %edx; \ +int80_ret_start_marker: \ + movl %edx, %esp; \ + movl %ecx, %cr3; \ + \ + __RESTORE_ALL; \ +int80_ret_end_marker: \ +2: + +#else /* !CONFIG_X86_HIGH_ENTRY */ + +#define __SWITCH_KERNELSPACE +#define __SWITCH_USERSPACE + +#endif + +#define __SAVE_ALL \ cld; \ pushl %es; \ pushl %ds; \ @@ -102,7 +211,7 @@ TSS_ESP0_OFFSET = (4 - 0x200) movl %edx, %ds; \ movl %edx, %es; -#define RESTORE_INT_REGS \ +#define __RESTORE_INT_REGS \ popl %ebx; \ popl %ecx; \ popl %edx; \ @@ -111,29 +220,28 @@ TSS_ESP0_OFFSET = (4 - 0x200) popl %ebp; \ popl %eax -#define RESTORE_REGS \ - RESTORE_INT_REGS; \ -1: popl %ds; \ -2: popl %es; \ +#define __RESTORE_REGS \ + __RESTORE_INT_REGS; \ +111: popl %ds; \ +222: popl %es; \ .section .fixup,"ax"; \ -3: movl $0,(%esp); \ - jmp 1b; \ -4: movl $0,(%esp); \ - jmp 2b; \ +444: movl $0,(%esp); \ + jmp 111b; \ +555: movl $0,(%esp); \ + jmp 222b; \ .previous; \ .section __ex_table,"a";\ .align 4; \ - .long 1b,3b; \ - .long 2b,4b; \ + .long 111b,444b;\ + .long 222b,555b;\ .previous - -#define RESTORE_ALL \ - RESTORE_REGS \ +#define __RESTORE_ALL \ + __RESTORE_REGS \ addl $4, %esp; \ -1: iret; \ +333: iret; \ .section .fixup,"ax"; \ -2: sti; \ +666: sti; \ movl $(__USER_DS), %edx; \ movl %edx, %ds; \ movl %edx, %es; \ @@ -142,10 +250,19 @@ TSS_ESP0_OFFSET = (4 - 0x200) .previous; \ .section __ex_table,"a";\ .align 4; \ - .long 1b,2b; \ + .long 333b,666b;\ .previous +#define SAVE_ALL \ + __SAVE_ALL; \ + __SWITCH_KERNELSPACE; \ + STACK_OVERFLOW_TEST; + +#define RESTORE_ALL \ + __SWITCH_USERSPACE; \ + __RESTORE_ALL; +.section .entry.text,"ax" ENTRY(lcall7) pushfl # We get a different stack layout with call @@ -162,8 +279,8 @@ do_lcall: movl %eax,EFLAGS(%ebp) # movl %edx,EIP(%ebp) # Now we move them to their "normal" places movl %ecx,CS(%ebp) # - andl $-8192, %ebp # GET_THREAD_INFO - movl TI_EXEC_DOMAIN(%ebp), %edx # Get the execution domain + GET_THREAD_INFO_WITH_ESP(%ebp) # GET_THREAD_INFO + movl TI_exec_domain(%ebp), %edx # Get the execution domain call *4(%edx) # Call the lcall7 handler for the domain addl $4, %esp popl %eax @@ -208,7 +325,7 @@ ENTRY(resume_userspace) cli # make sure we don't miss an interrupt # setting need_resched or sigpending # between sampling and the iret - movl TI_FLAGS(%ebp), %ecx + movl TI_flags(%ebp), %ecx andl $_TIF_WORK_MASK, %ecx # is there any work to be done on # int/exception return? jne work_pending @@ -216,18 +333,18 @@ ENTRY(resume_userspace) #ifdef CONFIG_PREEMPT ENTRY(resume_kernel) - cmpl $0,TI_PRE_COUNT(%ebp) # non-zero preempt_count ? + cmpl $0,TI_preempt_count(%ebp) # non-zero preempt_count ? jnz restore_all need_resched: - movl TI_FLAGS(%ebp), %ecx # need_resched set ? + movl TI_flags(%ebp), %ecx # need_resched set ? testb $_TIF_NEED_RESCHED, %cl jz restore_all testl $IF_MASK,EFLAGS(%esp) # interrupts off (exception path) ? jz restore_all - movl $PREEMPT_ACTIVE,TI_PRE_COUNT(%ebp) + movl $PREEMPT_ACTIVE,TI_preempt_count(%ebp) sti call schedule - movl $0,TI_PRE_COUNT(%ebp) + movl $0,TI_preempt_count(%ebp) cli jmp need_resched #endif @@ -246,37 +363,50 @@ sysenter_past_esp: pushl $(__USER_CS) pushl $SYSENTER_RETURN -/* - * Load the potential sixth argument from user stack. - * Careful about security. - */ - cmpl $__PAGE_OFFSET-3,%ebp - jae syscall_fault -1: movl (%ebp),%ebp -.section __ex_table,"a" - .align 4 - .long 1b,syscall_fault -.previous - pushl %eax SAVE_ALL GET_THREAD_INFO(%ebp) cmpl $(nr_syscalls), %eax jae syscall_badsys - testb $_TIF_SYSCALL_TRACE,TI_FLAGS(%ebp) + testb $_TIF_SYSCALL_TRACE,TI_flags(%ebp) jnz syscall_trace_entry call *sys_call_table(,%eax,4) movl %eax,EAX(%esp) cli - movl TI_FLAGS(%ebp), %ecx + movl TI_flags(%ebp), %ecx testw $_TIF_ALLWORK_MASK, %cx jne syscall_exit_work + +#ifdef CONFIG_X86_SWITCH_PAGETABLES + + GET_THREAD_INFO(%ebp) + movl TI_virtual_stack(%ebp), %edx + movl TI_user_pgd(%ebp), %ecx + movl %esp, %ebx + andl $(THREAD_SIZE-1), %ebx + orl %ebx, %edx +sysexit_ret_start_marker: + movl %edx, %esp + movl %ecx, %cr3 +#endif + /* + * only ebx is not restored by the userspace sysenter vsyscall + * code, it assumes it to be callee-saved. + */ + movl EBX(%esp), %ebx + /* if something modifies registers it must also disable sysexit */ + movl EIP(%esp), %edx movl OLDESP(%esp), %ecx + sti sysexit +#ifdef CONFIG_X86_SWITCH_PAGETABLES +sysexit_ret_end_marker: + nop +#endif # system call handler stub @@ -287,7 +417,7 @@ ENTRY(system_call) cmpl $(nr_syscalls), %eax jae syscall_badsys # system call tracing in operation - testb $_TIF_SYSCALL_TRACE,TI_FLAGS(%ebp) + testb $_TIF_SYSCALL_TRACE,TI_flags(%ebp) jnz syscall_trace_entry syscall_call: call *sys_call_table(,%eax,4) @@ -296,10 +426,23 @@ syscall_exit: cli # make sure we don't miss an interrupt # setting need_resched or sigpending # between sampling and the iret - movl TI_FLAGS(%ebp), %ecx + movl TI_flags(%ebp), %ecx testw $_TIF_ALLWORK_MASK, %cx # current->work jne syscall_exit_work restore_all: +#ifdef CONFIG_TRAP_BAD_SYSCALL_EXITS + movl EFLAGS(%esp), %eax # mix EFLAGS and CS + movb CS(%esp), %al + testl $(VM_MASK | 3), %eax + jz resume_kernelX # returning to kernel or vm86-space + + cmpl $0,TI_preempt_count(%ebp) # non-zero preempt_count ? + jz resume_kernelX + + int $3 + +resume_kernelX: +#endif RESTORE_ALL # perform work that needs to be done immediately before resumption @@ -312,7 +455,7 @@ work_resched: cli # make sure we don't miss an interrupt # setting need_resched or sigpending # between sampling and the iret - movl TI_FLAGS(%ebp), %ecx + movl TI_flags(%ebp), %ecx andl $_TIF_WORK_MASK, %ecx # is there any work to be done other # than syscall tracing? jz restore_all @@ -327,6 +470,22 @@ work_notifysig: # deal with pending s # vm86-space xorl %edx, %edx call do_notify_resume + +#if CONFIG_X86_HIGH_ENTRY + /* + * Reload db7 if necessary: + */ + movl TI_flags(%ebp), %ecx + testb $_TIF_DB7, %cl + jnz work_db7 + + jmp restore_all + +work_db7: + movl TI_task(%ebp), %edx; + movl task_thread_db7(%edx), %edx; + movl %edx, %db7; +#endif jmp restore_all ALIGN @@ -382,7 +541,7 @@ syscall_badsys: */ .data ENTRY(interrupt) -.text +.previous vector=0 ENTRY(irq_entries_start) @@ -392,7 +551,7 @@ ENTRY(irq_entries_start) jmp common_interrupt .data .long 1b -.text +.previous vector=vector+1 .endr @@ -433,12 +592,17 @@ error_code: movl ES(%esp), %edi # get the function address movl %eax, ORIG_EAX(%esp) movl %ecx, ES(%esp) - movl %esp, %edx pushl %esi # push the error code - pushl %edx # push the pt_regs pointer movl $(__USER_DS), %edx movl %edx, %ds movl %edx, %es + +/* clobbers edx, ebx and ebp */ + __SWITCH_KERNELSPACE + + leal 4(%esp), %edx # prepare pt_regs + pushl %edx # push pt_regs + call *%edi addl $8, %esp jmp ret_from_exception @@ -515,8 +679,8 @@ ENTRY(nmi) /* Do not access memory above the end of our stack page, * it might not exist. */ - andl $0x1fff,%eax - cmpl $0x1fec,%eax + andl $(THREAD_SIZE-1),%eax + cmpl $(THREAD_SIZE-20),%eax popl %eax jae nmi_stack_correct cmpl $sysenter_entry,12(%esp) @@ -529,7 +693,7 @@ nmi_stack_correct: pushl %edx call do_nmi addl $8, %esp - RESTORE_ALL + jmp restore_all nmi_stack_fixup: FIX_STACK(12,nmi_stack_correct, 1) @@ -606,6 +770,8 @@ ENTRY(spurious_interrupt_bug) pushl $do_spurious_interrupt_bug jmp error_code +.previous + .data ENTRY(sys_call_table) .long sys_restart_syscall /* 0 - old "setup()" system call, used for restarting */ --- diff/arch/i386/kernel/head.S 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/kernel/head.S 2004-02-23 13:56:37.000000000 +0000 @@ -16,6 +16,8 @@ #include #include #include +#include +#include #define OLD_CL_MAGIC_ADDR 0x90020 #define OLD_CL_MAGIC 0xA33F @@ -325,12 +327,12 @@ rp_sidt: ret ENTRY(stack_start) - .long init_thread_union+8192 + .long init_thread_union+THREAD_SIZE .long __BOOT_DS /* This is the default interrupt "handler" :-) */ int_msg: - .asciz "Unknown interrupt\n" + .asciz "Unknown interrupt or fault at EIP %p %p %p\n" ALIGN ignore_int: cld @@ -342,9 +344,17 @@ ignore_int: movl $(__KERNEL_DS),%eax movl %eax,%ds movl %eax,%es + pushl 16(%esp) + pushl 24(%esp) + pushl 32(%esp) + pushl 40(%esp) pushl $int_msg call printk popl %eax + popl %eax + popl %eax + popl %eax + popl %eax popl %ds popl %es popl %edx @@ -377,23 +387,27 @@ cpu_gdt_descr: .fill NR_CPUS-1,8,0 # space for the other GDT descriptors /* - * This is initialized to create an identity-mapping at 0-8M (for bootup - * purposes) and another mapping of the 0-8M area at virtual address + * This is initialized to create an identity-mapping at 0-16M (for bootup + * purposes) and another mapping of the 0-16M area at virtual address * PAGE_OFFSET. */ .org 0x1000 ENTRY(swapper_pg_dir) .long 0x00102007 .long 0x00103007 - .fill BOOT_USER_PGD_PTRS-2,4,0 - /* default: 766 entries */ + .long 0x00104007 + .long 0x00105007 + .fill BOOT_USER_PGD_PTRS-4,4,0 + /* default: 764 entries */ .long 0x00102007 .long 0x00103007 - /* default: 254 entries */ - .fill BOOT_KERNEL_PGD_PTRS-2,4,0 + .long 0x00104007 + .long 0x00105007 + /* default: 252 entries */ + .fill BOOT_KERNEL_PGD_PTRS-4,4,0 /* - * The page tables are initialized to only 8MB here - the final page + * The page tables are initialized to only 16MB here - the final page * tables are set up later depending on memory size. */ .org 0x2000 @@ -402,15 +416,21 @@ ENTRY(pg0) .org 0x3000 ENTRY(pg1) +.org 0x4000 +ENTRY(pg2) + +.org 0x5000 +ENTRY(pg3) + /* * empty_zero_page must immediately follow the page tables ! (The * initialization loop counts until empty_zero_page) */ -.org 0x4000 +.org 0x6000 ENTRY(empty_zero_page) -.org 0x5000 +.org 0x7000 /* * Real beginning of normal "text" segment @@ -419,12 +439,12 @@ ENTRY(stext) ENTRY(_stext) /* - * This starts the data section. Note that the above is all - * in the text section because it has alignment requirements - * that we cannot fulfill any other way. + * This starts the data section. */ .data +.align PAGE_SIZE_asm + /* * The Global Descriptor Table contains 28 quadwords, per-CPU. */ @@ -439,7 +459,9 @@ ENTRY(boot_gdt_table) .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */ .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */ #endif - .align L1_CACHE_BYTES + +.align PAGE_SIZE_asm + ENTRY(cpu_gdt_table) .quad 0x0000000000000000 /* NULL descriptor */ .quad 0x0000000000000000 /* 0x0b reserved */ --- diff/arch/i386/kernel/i386_ksyms.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/kernel/i386_ksyms.c 2004-02-23 13:56:37.000000000 +0000 @@ -97,7 +97,6 @@ EXPORT_SYMBOL_NOVERS(__down_failed_inter EXPORT_SYMBOL_NOVERS(__down_failed_trylock); EXPORT_SYMBOL_NOVERS(__up_wakeup); /* Networking helper routines. */ -EXPORT_SYMBOL(csum_partial_copy_generic); /* Delay loops */ EXPORT_SYMBOL(__ndelay); EXPORT_SYMBOL(__udelay); @@ -111,13 +110,17 @@ EXPORT_SYMBOL_NOVERS(__get_user_4); EXPORT_SYMBOL(strpbrk); EXPORT_SYMBOL(strstr); +#if !defined(CONFIG_X86_UACCESS_INDIRECT) EXPORT_SYMBOL(strncpy_from_user); -EXPORT_SYMBOL(__strncpy_from_user); +EXPORT_SYMBOL(__direct_strncpy_from_user); EXPORT_SYMBOL(clear_user); EXPORT_SYMBOL(__clear_user); EXPORT_SYMBOL(__copy_from_user_ll); EXPORT_SYMBOL(__copy_to_user_ll); EXPORT_SYMBOL(strnlen_user); +#else /* CONFIG_X86_UACCESS_INDIRECT */ +EXPORT_SYMBOL(direct_csum_partial_copy_generic); +#endif EXPORT_SYMBOL(dma_alloc_coherent); EXPORT_SYMBOL(dma_free_coherent); --- diff/arch/i386/kernel/i387.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/kernel/i387.c 2004-02-23 13:56:37.000000000 +0000 @@ -218,6 +218,7 @@ void set_fpu_mxcsr( struct task_struct * static int convert_fxsr_to_user( struct _fpstate __user *buf, struct i387_fxsave_struct *fxsave ) { + struct _fpreg tmp[8]; /* 80 bytes scratch area */ unsigned long env[7]; struct _fpreg __user *to; struct _fpxreg *from; @@ -234,23 +235,25 @@ static int convert_fxsr_to_user( struct if ( __copy_to_user( buf, env, 7 * sizeof(unsigned long) ) ) return 1; - to = &buf->_st[0]; + to = tmp; from = (struct _fpxreg *) &fxsave->st_space[0]; for ( i = 0 ; i < 8 ; i++, to++, from++ ) { unsigned long *t = (unsigned long *)to; unsigned long *f = (unsigned long *)from; - if (__put_user(*f, t) || - __put_user(*(f + 1), t + 1) || - __put_user(from->exponent, &to->exponent)) - return 1; + *t = *f; + *(t + 1) = *(f+1); + to->exponent = from->exponent; } + if (copy_to_user(buf->_st, tmp, sizeof(struct _fpreg [8]))) + return 1; return 0; } static int convert_fxsr_from_user( struct i387_fxsave_struct *fxsave, struct _fpstate __user *buf ) { + struct _fpreg tmp[8]; /* 80 bytes scratch area */ unsigned long env[7]; struct _fpxreg *to; struct _fpreg __user *from; @@ -258,6 +261,8 @@ static int convert_fxsr_from_user( struc if ( __copy_from_user( env, buf, 7 * sizeof(long) ) ) return 1; + if (copy_from_user(tmp, buf->_st, sizeof(struct _fpreg [8]))) + return 1; fxsave->cwd = (unsigned short)(env[0] & 0xffff); fxsave->swd = (unsigned short)(env[1] & 0xffff); @@ -269,15 +274,14 @@ static int convert_fxsr_from_user( struc fxsave->fos = env[6]; to = (struct _fpxreg *) &fxsave->st_space[0]; - from = &buf->_st[0]; + from = tmp; for ( i = 0 ; i < 8 ; i++, to++, from++ ) { unsigned long *t = (unsigned long *)to; unsigned long *f = (unsigned long *)from; - if (__get_user(*t, f) || - __get_user(*(t + 1), f + 1) || - __get_user(to->exponent, &from->exponent)) - return 1; + *t = *f; + *(t + 1) = *(f + 1); + to->exponent = from->exponent; } return 0; } --- diff/arch/i386/kernel/i8259.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/i386/kernel/i8259.c 2004-02-23 13:56:37.000000000 +0000 @@ -258,7 +258,7 @@ static int __init i8259A_init_sysfs(void { int error = sysdev_class_register(&i8259_sysdev_class); if (!error) - error = sys_device_register(&device_i8259A); + error = sysdev_register(&device_i8259A); return error; } @@ -401,7 +401,7 @@ static int __init init_timer_sysfs(void) { int error = sysdev_class_register(&timer_sysclass); if (!error) - error = sys_device_register(&device_timer); + error = sysdev_register(&device_timer); return error; } --- diff/arch/i386/kernel/init_task.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/i386/kernel/init_task.c 2004-02-23 13:56:37.000000000 +0000 @@ -26,7 +26,7 @@ EXPORT_SYMBOL(init_mm); */ union thread_union init_thread_union __attribute__((__section__(".data.init_task"))) = - { INIT_THREAD_INFO(init_task) }; + { INIT_THREAD_INFO(init_task, init_thread_union) }; /* * Initial task structure. @@ -44,5 +44,5 @@ EXPORT_SYMBOL(init_task); * section. Since TSS's are completely CPU-local, we want them * on exact cacheline boundaries, to eliminate cacheline ping-pong. */ -struct tss_struct init_tss[NR_CPUS] __cacheline_aligned = { [0 ... NR_CPUS-1] = INIT_TSS }; +struct tss_struct init_tss[NR_CPUS] __attribute__((__section__(".data.tss"))) = { [0 ... NR_CPUS-1] = INIT_TSS }; --- diff/arch/i386/kernel/io_apic.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/i386/kernel/io_apic.c 2004-02-23 13:56:37.000000000 +0000 @@ -280,7 +280,7 @@ static void set_ioapic_affinity_irq(unsi spin_unlock_irqrestore(&ioapic_lock, flags); } -#if defined(CONFIG_SMP) +#if defined(CONFIG_IRQBALANCE) # include /* kernel_thread() */ # include /* kstat */ # include /* kmalloc() */ @@ -317,8 +317,7 @@ struct irq_cpu_info { #define IRQ_ALLOWED(cpu, allowed_mask) cpu_isset(cpu, allowed_mask) -#define CPU_TO_PACKAGEINDEX(i) \ - ((physical_balance && i > cpu_sibling_map[i]) ? cpu_sibling_map[i] : i) +#define CPU_TO_PACKAGEINDEX(i) (first_cpu(cpu_sibling_map[i])) #define MAX_BALANCED_IRQ_INTERVAL (5*HZ) #define MIN_BALANCED_IRQ_INTERVAL (HZ/2) @@ -401,6 +400,7 @@ static void do_irq_balance(void) unsigned long max_cpu_irq = 0, min_cpu_irq = (~0); unsigned long move_this_load = 0; int max_loaded = 0, min_loaded = 0; + int load; unsigned long useful_load_threshold = balanced_irq_interval + 10; int selected_irq; int tmp_loaded, first_attempt = 1; @@ -452,7 +452,7 @@ static void do_irq_balance(void) for (i = 0; i < NR_CPUS; i++) { if (!cpu_online(i)) continue; - if (physical_balance && i > cpu_sibling_map[i]) + if (i != CPU_TO_PACKAGEINDEX(i)) continue; if (min_cpu_irq > CPU_IRQ(i)) { min_cpu_irq = CPU_IRQ(i); @@ -471,7 +471,7 @@ tryanothercpu: for (i = 0; i < NR_CPUS; i++) { if (!cpu_online(i)) continue; - if (physical_balance && i > cpu_sibling_map[i]) + if (i != CPU_TO_PACKAGEINDEX(i)) continue; if (max_cpu_irq <= CPU_IRQ(i)) continue; @@ -551,9 +551,14 @@ tryanotherirq: * We seek the least loaded sibling by making the comparison * (A+B)/2 vs B */ - if (physical_balance && (CPU_IRQ(min_loaded) >> 1) > - CPU_IRQ(cpu_sibling_map[min_loaded])) - min_loaded = cpu_sibling_map[min_loaded]; + load = CPU_IRQ(min_loaded) >> 1; + for_each_cpu_mask(j, cpu_sibling_map[min_loaded]) { + if (load > CPU_IRQ(j)) { + /* This won't change cpu_sibling_map[min_loaded] */ + load = CPU_IRQ(j); + min_loaded = j; + } + } cpus_and(allowed_mask, cpu_online_map, irq_affinity[selected_irq]); target_cpu_mask = cpumask_of_cpu(min_loaded); @@ -689,9 +694,11 @@ static inline void move_irq(int irq) __initcall(balanced_irq_init); -#else /* !SMP */ +#else /* !CONFIG_IRQBALANCE */ static inline void move_irq(int irq) { } +#endif /* CONFIG_IRQBALANCE */ +#ifndef CONFIG_SMP void send_IPI_self(int vector) { unsigned int cfg; @@ -706,7 +713,7 @@ void send_IPI_self(int vector) */ apic_write_around(APIC_ICR, cfg); } -#endif /* defined(CONFIG_SMP) */ +#endif /* !CONFIG_SMP */ /* @@ -2150,6 +2157,10 @@ static inline void check_timer(void) { int pin1, pin2; int vector; + unsigned int ver; + + ver = apic_read(APIC_LVR); + ver = GET_APIC_VERSION(ver); /* * get/set the timer IRQ vector: @@ -2163,11 +2174,17 @@ static inline void check_timer(void) * mode for the 8259A whenever interrupts are routed * through I/O APICs. Also IRQ0 has to be enabled in * the 8259A which implies the virtual wire has to be - * disabled in the local APIC. + * disabled in the local APIC. Finally timer interrupts + * need to be acknowledged manually in the 8259A for + * do_slow_timeoffset() and for the i82489DX when using + * the NMI watchdog. */ apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT); init_8259A(1); - timer_ack = 1; + if (nmi_watchdog == NMI_IO_APIC && !APIC_INTEGRATED(ver)) + timer_ack = 1; + else + timer_ack = !cpu_has_tsc; enable_8259A_irq(0); pin1 = find_isa_irq_pin(0, mp_INT); @@ -2185,7 +2202,8 @@ static inline void check_timer(void) disable_8259A_irq(0); setup_nmi(); enable_8259A_irq(0); - check_nmi_watchdog(); + if (check_nmi_watchdog() < 0); + timer_ack = !cpu_has_tsc; } return; } @@ -2208,7 +2226,8 @@ static inline void check_timer(void) add_pin_to_irq(0, 0, pin2); if (nmi_watchdog == NMI_IO_APIC) { setup_nmi(); - check_nmi_watchdog(); + if (check_nmi_watchdog() < 0); + timer_ack = !cpu_has_tsc; } return; } --- diff/arch/i386/kernel/irq.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/i386/kernel/irq.c 2004-02-23 13:56:37.000000000 +0000 @@ -435,7 +435,7 @@ asmlinkage unsigned int do_IRQ(struct pt long esp; __asm__ __volatile__("andl %%esp,%0" : - "=r" (esp) : "0" (8191)); + "=r" (esp) : "0" (THREAD_SIZE - 1)); if (unlikely(esp < (sizeof(struct thread_info) + 1024))) { printk("do_IRQ: stack overflow: %ld\n", esp - sizeof(struct thread_info)); @@ -508,6 +508,8 @@ out: irq_exit(); + kgdb_process_breakpoint(); + return 1; } @@ -927,7 +929,7 @@ cpumask_t irq_affinity[NR_IRQS] = { [0 . static int irq_affinity_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, irq_affinity[(long)data]); + int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); @@ -968,7 +970,7 @@ static int irq_affinity_write_proc(struc static int prof_cpu_mask_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, *(cpumask_t *)data); + int len = cpumask_scnprintf(page, count, *(cpumask_t *)data); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); --- diff/arch/i386/kernel/ldt.c 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/kernel/ldt.c 2004-02-23 13:56:37.000000000 +0000 @@ -2,7 +2,7 @@ * linux/kernel/ldt.c * * Copyright (C) 1992 Krishna Balasubramanian and Linus Torvalds - * Copyright (C) 1999 Ingo Molnar + * Copyright (C) 1999, 2003 Ingo Molnar */ #include @@ -18,6 +18,8 @@ #include #include #include +#include +#include #ifdef CONFIG_SMP /* avoids "defined but not used" warnig */ static void flush_ldt(void *null) @@ -29,34 +31,31 @@ static void flush_ldt(void *null) static int alloc_ldt(mm_context_t *pc, int mincount, int reload) { - void *oldldt; - void *newldt; - int oldsize; + int oldsize, newsize, i; if (mincount <= pc->size) return 0; + /* + * LDT got larger - reallocate if necessary. + */ oldsize = pc->size; mincount = (mincount+511)&(~511); - if (mincount*LDT_ENTRY_SIZE > PAGE_SIZE) - newldt = vmalloc(mincount*LDT_ENTRY_SIZE); - else - newldt = kmalloc(mincount*LDT_ENTRY_SIZE, GFP_KERNEL); - - if (!newldt) - return -ENOMEM; - - if (oldsize) - memcpy(newldt, pc->ldt, oldsize*LDT_ENTRY_SIZE); - oldldt = pc->ldt; - memset(newldt+oldsize*LDT_ENTRY_SIZE, 0, (mincount-oldsize)*LDT_ENTRY_SIZE); - pc->ldt = newldt; - wmb(); + newsize = mincount*LDT_ENTRY_SIZE; + for (i = 0; i < newsize; i += PAGE_SIZE) { + int nr = i/PAGE_SIZE; + BUG_ON(i >= 64*1024); + if (!pc->ldt_pages[nr]) { + pc->ldt_pages[nr] = alloc_page(GFP_HIGHUSER); + if (!pc->ldt_pages[nr]) + return -ENOMEM; + clear_highpage(pc->ldt_pages[nr]); + } + } pc->size = mincount; - wmb(); - if (reload) { #ifdef CONFIG_SMP cpumask_t mask; + preempt_disable(); load_LDT(pc); mask = cpumask_of_cpu(smp_processor_id()); @@ -67,21 +66,20 @@ static int alloc_ldt(mm_context_t *pc, i load_LDT(pc); #endif } - if (oldsize) { - if (oldsize*LDT_ENTRY_SIZE > PAGE_SIZE) - vfree(oldldt); - else - kfree(oldldt); - } return 0; } static inline int copy_ldt(mm_context_t *new, mm_context_t *old) { - int err = alloc_ldt(new, old->size, 0); - if (err < 0) + int i, err, size = old->size, nr_pages = (size*LDT_ENTRY_SIZE + PAGE_SIZE-1)/PAGE_SIZE; + + err = alloc_ldt(new, size, 0); + if (err < 0) { + new->size = 0; return err; - memcpy(new->ldt, old->ldt, old->size*LDT_ENTRY_SIZE); + } + for (i = 0; i < nr_pages; i++) + copy_user_highpage(new->ldt_pages[i], old->ldt_pages[i], 0); return 0; } @@ -96,6 +94,7 @@ int init_new_context(struct task_struct init_MUTEX(&mm->context.sem); mm->context.size = 0; + memset(mm->context.ldt_pages, 0, sizeof(struct page *) * MAX_LDT_PAGES); old_mm = current->mm; if (old_mm && old_mm->context.size > 0) { down(&old_mm->context.sem); @@ -107,23 +106,21 @@ int init_new_context(struct task_struct /* * No need to lock the MM as we are the last user + * Do not touch the ldt register, we are already + * in the next thread. */ void destroy_context(struct mm_struct *mm) { - if (mm->context.size) { - if (mm == current->active_mm) - clear_LDT(); - if (mm->context.size*LDT_ENTRY_SIZE > PAGE_SIZE) - vfree(mm->context.ldt); - else - kfree(mm->context.ldt); - mm->context.size = 0; - } + int i, nr_pages = (mm->context.size*LDT_ENTRY_SIZE + PAGE_SIZE-1) / PAGE_SIZE; + + for (i = 0; i < nr_pages; i++) + __free_page(mm->context.ldt_pages[i]); + mm->context.size = 0; } static int read_ldt(void __user * ptr, unsigned long bytecount) { - int err; + int err, i; unsigned long size; struct mm_struct * mm = current->mm; @@ -138,8 +135,25 @@ static int read_ldt(void __user * ptr, u size = bytecount; err = 0; - if (copy_to_user(ptr, mm->context.ldt, size)) - err = -EFAULT; + /* + * This is necessary just in case we got here straight from a + * context-switch where the ptes were set but no tlb flush + * was done yet. We rather avoid doing a TLB flush in the + * context-switch path and do it here instead. + */ + __flush_tlb_global(); + + for (i = 0; i < size; i += PAGE_SIZE) { + int nr = i / PAGE_SIZE, bytes; + char *kaddr = kmap(mm->context.ldt_pages[nr]); + + bytes = size - i; + if (bytes > PAGE_SIZE) + bytes = PAGE_SIZE; + if (copy_to_user(ptr + i, kaddr, size - i)) + err = -EFAULT; + kunmap(mm->context.ldt_pages[nr]); + } up(&mm->context.sem); if (err < 0) return err; @@ -158,7 +172,7 @@ static int read_default_ldt(void __user err = 0; address = &default_ldt[0]; - size = 5*sizeof(struct desc_struct); + size = 5*LDT_ENTRY_SIZE; if (size > bytecount) size = bytecount; @@ -200,7 +214,15 @@ static int write_ldt(void __user * ptr, goto out_unlock; } - lp = (__u32 *) ((ldt_info.entry_number << 3) + (char *) mm->context.ldt); + /* + * No rescheduling allowed from this point to the install. + * + * We do a TLB flush for the same reason as in the read_ldt() path. + */ + preempt_disable(); + __flush_tlb_global(); + lp = (__u32 *) ((ldt_info.entry_number << 3) + + (char *) __kmap_atomic_vaddr(KM_LDT_PAGE0)); /* Allow LDTs to be cleared by the user. */ if (ldt_info.base_addr == 0 && ldt_info.limit == 0) { @@ -221,6 +243,7 @@ install: *lp = entry_1; *(lp+1) = entry_2; error = 0; + preempt_enable(); out_unlock: up(&mm->context.sem); @@ -248,3 +271,26 @@ asmlinkage int sys_modify_ldt(int func, } return ret; } + +/* + * load one particular LDT into the current CPU + */ +void load_LDT_nolock(mm_context_t *pc, int cpu) +{ + struct page **pages = pc->ldt_pages; + int count = pc->size; + int nr_pages, i; + + if (likely(!count)) { + pages = &default_ldt_page; + count = 5; + } + nr_pages = (count*LDT_ENTRY_SIZE + PAGE_SIZE-1) / PAGE_SIZE; + + for (i = 0; i < nr_pages; i++) { + __kunmap_atomic_type(KM_LDT_PAGE0 - i); + __kmap_atomic(pages[i], KM_LDT_PAGE0 - i); + } + set_ldt_desc(cpu, (void *)__kmap_atomic_vaddr(KM_LDT_PAGE0), count); + load_LDT_desc(); +} --- diff/arch/i386/kernel/microcode.c 2003-10-27 09:20:43.000000000 +0000 +++ source/arch/i386/kernel/microcode.c 2004-02-23 13:56:37.000000000 +0000 @@ -371,7 +371,9 @@ static void do_update_one (void * unused spin_lock_irqsave(µcode_update_lock, flags); /* write microcode via MSR 0x79 */ - wrmsr(MSR_IA32_UCODE_WRITE, (unsigned int)(uci->mc->bits), 0); + wrmsr(MSR_IA32_UCODE_WRITE, + (unsigned long) uci->mc->bits, + (unsigned long) uci->mc->bits >> 16 >> 16); wrmsr(MSR_IA32_UCODE_REV, 0, 0); __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx"); @@ -507,3 +509,4 @@ static void __exit microcode_exit (void) module_init(microcode_init) module_exit(microcode_exit) +MODULE_ALIAS_MISCDEV(MICROCODE_MINOR); --- diff/arch/i386/kernel/mpparse.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/kernel/mpparse.c 2004-02-23 13:56:37.000000000 +0000 @@ -668,7 +668,7 @@ void __init get_smp_config (void) * Read the physical hardware table. Anything here will * override the defaults. */ - if (!smp_read_mpc((void *)mpf->mpf_physptr)) { + if (!smp_read_mpc((void *)phys_to_virt(mpf->mpf_physptr))) { smp_found_config = 0; printk(KERN_ERR "BIOS bug, MP table errors detected!...\n"); printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)\n"); --- diff/arch/i386/kernel/nmi.c 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/kernel/nmi.c 2004-02-23 13:56:37.000000000 +0000 @@ -31,7 +31,16 @@ #include #include +#ifdef CONFIG_KGDB +#include +#ifdef CONFIG_SMP +unsigned int nmi_watchdog = NMI_IO_APIC; +#else +unsigned int nmi_watchdog = NMI_LOCAL_APIC; +#endif +#else unsigned int nmi_watchdog = NMI_NONE; +#endif static unsigned int nmi_hz = HZ; unsigned int nmi_perfctr_msr; /* the MSR to reset in NMI handler */ extern void show_registers(struct pt_regs *regs); @@ -42,7 +51,7 @@ extern void show_registers(struct pt_reg * be enabled * -1: the lapic NMI watchdog is disabled, but can be enabled */ -static int nmi_active; +int nmi_active; #define K7_EVNTSEL_ENABLE (1 << 22) #define K7_EVNTSEL_INT (1 << 20) @@ -248,7 +257,7 @@ static int __init init_lapic_nmi_sysfs(v error = sysdev_class_register(&nmi_sysclass); if (!error) - error = sys_device_register(&device_lapic_nmi); + error = sysdev_register(&device_lapic_nmi); return error; } /* must come after the local APIC's device_initcall() */ @@ -408,6 +417,9 @@ void touch_nmi_watchdog (void) for (i = 0; i < NR_CPUS; i++) alert_counter[i] = 0; } +#ifdef CONFIG_KGDB +int tune_watchdog = 5*HZ; +#endif void nmi_watchdog_tick (struct pt_regs * regs) { @@ -421,12 +433,24 @@ void nmi_watchdog_tick (struct pt_regs * sum = irq_stat[cpu].apic_timer_irqs; +#ifdef CONFIG_KGDB + if (! in_kgdb(regs) && last_irq_sums[cpu] == sum ) { + +#else if (last_irq_sums[cpu] == sum) { +#endif /* * Ayiee, looks like this CPU is stuck ... * wait a few IRQs (5 seconds) before doing the oops ... */ alert_counter[cpu]++; +#ifdef CONFIG_KGDB + if (alert_counter[cpu] == tune_watchdog) { + kgdb_handle_exception(2, SIGPWR, 0, regs); + last_irq_sums[cpu] = sum; + alert_counter[cpu] = 0; + } +#endif if (alert_counter[cpu] == 5*nmi_hz) { spin_lock(&nmi_print_lock); /* @@ -462,6 +486,7 @@ void nmi_watchdog_tick (struct pt_regs * } } +EXPORT_SYMBOL(nmi_active); EXPORT_SYMBOL(nmi_watchdog); EXPORT_SYMBOL(disable_lapic_nmi_watchdog); EXPORT_SYMBOL(enable_lapic_nmi_watchdog); --- diff/arch/i386/kernel/process.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/kernel/process.c 2004-02-23 13:56:37.000000000 +0000 @@ -47,6 +47,7 @@ #include #include #include +#include #ifdef CONFIG_MATH_EMULATION #include #endif @@ -304,6 +305,9 @@ void flush_thread(void) struct task_struct *tsk = current; memset(tsk->thread.debugreg, 0, sizeof(unsigned long)*8); +#ifdef CONFIG_X86_HIGH_ENTRY + clear_thread_flag(TIF_DB7); +#endif memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array)); /* * Forget coprocessor state.. @@ -317,9 +321,8 @@ void release_thread(struct task_struct * if (dead_task->mm) { // temporary debugging check if (dead_task->mm->context.size) { - printk("WARNING: dead process %8s still has LDT? <%p/%d>\n", + printk("WARNING: dead process %8s still has LDT? <%d>\n", dead_task->comm, - dead_task->mm->context.ldt, dead_task->mm->context.size); BUG(); } @@ -354,7 +357,17 @@ int copy_thread(int nr, unsigned long cl p->thread.esp = (unsigned long) childregs; p->thread.esp0 = (unsigned long) (childregs+1); + /* + * get the two stack pages, for the virtual stack. + * + * IMPORTANT: this code relies on the fact that the task + * structure is an 8K aligned piece of physical memory. + */ + p->thread.stack_page0 = virt_to_page((unsigned long)p->thread_info); + p->thread.stack_page1 = virt_to_page((unsigned long)p->thread_info + PAGE_SIZE); + p->thread.eip = (unsigned long) ret_from_fork; + p->thread_info->real_stack = p->thread_info; savesegment(fs,p->thread.fs); savesegment(gs,p->thread.gs); @@ -506,10 +519,41 @@ struct task_struct * __switch_to(struct __unlazy_fpu(prev_p); +#ifdef CONFIG_X86_HIGH_ENTRY + /* + * Set the ptes of the virtual stack. (NOTE: a one-page TLB flush is + * needed because otherwise NMIs could interrupt the + * user-return code with a virtual stack and stale TLBs.) + */ + __kunmap_atomic_type(KM_VSTACK0); + __kunmap_atomic_type(KM_VSTACK1); + __kmap_atomic(next->stack_page0, KM_VSTACK0); + __kmap_atomic(next->stack_page1, KM_VSTACK1); + + /* + * NOTE: here we rely on the task being the stack as well + */ + next_p->thread_info->virtual_stack = + (void *)__kmap_atomic_vaddr(KM_VSTACK0); + +#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP) + /* + * If next was preempted on entry from userspace to kernel, + * and now it's on a different cpu, we need to adjust %esp. + * This assumes that entry.S does not copy %esp while on the + * virtual stack (with interrupts enabled): which is so, + * except within __SWITCH_KERNELSPACE itself. + */ + if (unlikely(next->esp >= TASK_SIZE)) { + next->esp &= THREAD_SIZE - 1; + next->esp |= (unsigned long) next_p->thread_info->virtual_stack; + } +#endif +#endif /* * Reload esp0, LDT and the page table pointer: */ - load_esp0(tss, next); + load_virtual_esp0(tss, next_p); /* * Load the per-thread Thread-Local Storage descriptor. @@ -637,6 +681,8 @@ extern void scheduling_functions_start_h extern void scheduling_functions_end_here(void); #define first_sched ((unsigned long) scheduling_functions_start_here) #define last_sched ((unsigned long) scheduling_functions_end_here) +#define top_esp (THREAD_SIZE - sizeof(unsigned long)) +#define top_ebp (THREAD_SIZE - 2*sizeof(unsigned long)) unsigned long get_wchan(struct task_struct *p) { @@ -647,12 +693,12 @@ unsigned long get_wchan(struct task_stru return 0; stack_page = (unsigned long)p->thread_info; esp = p->thread.esp; - if (!stack_page || esp < stack_page || esp > 8188+stack_page) + if (!stack_page || esp < stack_page || esp > top_esp+stack_page) return 0; /* include/asm-i386/system.h:switch_to() pushes ebp last. */ ebp = *(unsigned long *) esp; do { - if (ebp < stack_page || ebp > 8184+stack_page) + if (ebp < stack_page || ebp > top_ebp+stack_page) return 0; eip = *(unsigned long *) (ebp+4); if (eip < first_sched || eip >= last_sched) --- diff/arch/i386/kernel/reboot.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/i386/kernel/reboot.c 2004-02-23 13:56:37.000000000 +0000 @@ -155,12 +155,11 @@ void machine_real_restart(unsigned char CMOS_WRITE(0x00, 0x8f); spin_unlock_irqrestore(&rtc_lock, flags); - /* Remap the kernel at virtual address zero, as well as offset zero - from the kernel segment. This assumes the kernel segment starts at - virtual address PAGE_OFFSET. */ - - memcpy (swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS, - sizeof (swapper_pg_dir [0]) * KERNEL_PGD_PTRS); + /* + * Remap the first 16 MB of RAM (which includes the kernel image) + * at virtual address zero: + */ + setup_identity_mappings(swapper_pg_dir, 0, 16*1024*1024); /* * Use `swapper_pg_dir' as our page directory. --- diff/arch/i386/kernel/setup.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/kernel/setup.c 2004-02-23 13:56:37.000000000 +0000 @@ -1118,6 +1118,19 @@ void __init setup_arch(char **cmdline_p) #endif paging_init(); +#ifdef CONFIG_EARLY_PRINTK + { + char *s = strstr(*cmdline_p, "earlyprintk="); + if (s) { + extern void setup_early_printk(char *); + + setup_early_printk(s); + printk("early console enabled\n"); + } + } +#endif + + dmi_scan_machine(); #ifdef CONFIG_X86_GENERICARCH --- diff/arch/i386/kernel/signal.c 2003-11-25 15:24:57.000000000 +0000 +++ source/arch/i386/kernel/signal.c 2004-02-23 13:56:37.000000000 +0000 @@ -128,28 +128,29 @@ sys_sigaltstack(const stack_t __user *us */ static int -restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *peax) +restore_sigcontext(struct pt_regs *regs, + struct sigcontext __user *__sc, int *peax) { - unsigned int err = 0; + struct sigcontext scratch; /* 88 bytes of scratch area */ /* Always make any pending restarted system calls return -EINTR */ current_thread_info()->restart_block.fn = do_no_restart_syscall; -#define COPY(x) err |= __get_user(regs->x, &sc->x) + if (copy_from_user(&scratch, __sc, sizeof(scratch))) + return -EFAULT; + +#define COPY(x) regs->x = scratch.x #define COPY_SEG(seg) \ - { unsigned short tmp; \ - err |= __get_user(tmp, &sc->seg); \ + { unsigned short tmp = scratch.seg; \ regs->x##seg = tmp; } #define COPY_SEG_STRICT(seg) \ - { unsigned short tmp; \ - err |= __get_user(tmp, &sc->seg); \ + { unsigned short tmp = scratch.seg; \ regs->x##seg = tmp|3; } #define GET_SEG(seg) \ - { unsigned short tmp; \ - err |= __get_user(tmp, &sc->seg); \ + { unsigned short tmp = scratch.seg; \ loadsegment(seg,tmp); } GET_SEG(gs); @@ -168,27 +169,23 @@ restore_sigcontext(struct pt_regs *regs, COPY_SEG_STRICT(ss); { - unsigned int tmpflags; - err |= __get_user(tmpflags, &sc->eflags); + unsigned int tmpflags = scratch.eflags; regs->eflags = (regs->eflags & ~0x40DD5) | (tmpflags & 0x40DD5); regs->orig_eax = -1; /* disable syscall checks */ } { - struct _fpstate __user * buf; - err |= __get_user(buf, &sc->fpstate); + struct _fpstate * buf = scratch.fpstate; if (buf) { if (verify_area(VERIFY_READ, buf, sizeof(*buf))) - goto badframe; - err |= restore_i387(buf); + return -EFAULT; + if (restore_i387(buf)) + return -EFAULT; } } - err |= __get_user(*peax, &sc->eax); - return err; - -badframe: - return 1; + *peax = scratch.eax; + return 0; } asmlinkage int sys_sigreturn(unsigned long __unused) @@ -266,46 +263,47 @@ badframe: */ static int -setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate, +setup_sigcontext(struct sigcontext __user *__sc, struct _fpstate __user *fpstate, struct pt_regs *regs, unsigned long mask) { - int tmp, err = 0; + struct sigcontext sc; /* 88 bytes of scratch area */ + int tmp; tmp = 0; __asm__("movl %%gs,%0" : "=r"(tmp): "0"(tmp)); - err |= __put_user(tmp, (unsigned int *)&sc->gs); + *(unsigned int *)&sc.gs = tmp; __asm__("movl %%fs,%0" : "=r"(tmp): "0"(tmp)); - err |= __put_user(tmp, (unsigned int *)&sc->fs); - - err |= __put_user(regs->xes, (unsigned int *)&sc->es); - err |= __put_user(regs->xds, (unsigned int *)&sc->ds); - err |= __put_user(regs->edi, &sc->edi); - err |= __put_user(regs->esi, &sc->esi); - err |= __put_user(regs->ebp, &sc->ebp); - err |= __put_user(regs->esp, &sc->esp); - err |= __put_user(regs->ebx, &sc->ebx); - err |= __put_user(regs->edx, &sc->edx); - err |= __put_user(regs->ecx, &sc->ecx); - err |= __put_user(regs->eax, &sc->eax); - err |= __put_user(current->thread.trap_no, &sc->trapno); - err |= __put_user(current->thread.error_code, &sc->err); - err |= __put_user(regs->eip, &sc->eip); - err |= __put_user(regs->xcs, (unsigned int *)&sc->cs); - err |= __put_user(regs->eflags, &sc->eflags); - err |= __put_user(regs->esp, &sc->esp_at_signal); - err |= __put_user(regs->xss, (unsigned int *)&sc->ss); + *(unsigned int *)&sc.fs = tmp; + *(unsigned int *)&sc.es = regs->xes; + *(unsigned int *)&sc.ds = regs->xds; + sc.edi = regs->edi; + sc.esi = regs->esi; + sc.ebp = regs->ebp; + sc.esp = regs->esp; + sc.ebx = regs->ebx; + sc.edx = regs->edx; + sc.ecx = regs->ecx; + sc.eax = regs->eax; + sc.trapno = current->thread.trap_no; + sc.err = current->thread.error_code; + sc.eip = regs->eip; + *(unsigned int *)&sc.cs = regs->xcs; + sc.eflags = regs->eflags; + sc.esp_at_signal = regs->esp; + *(unsigned int *)&sc.ss = regs->xss; tmp = save_i387(fpstate); if (tmp < 0) - err = 1; - else - err |= __put_user(tmp ? fpstate : NULL, &sc->fpstate); + return 1; + sc.fpstate = tmp ? fpstate : NULL; /* non-iBCS2 extensions.. */ - err |= __put_user(mask, &sc->oldmask); - err |= __put_user(current->thread.cr2, &sc->cr2); + sc.oldmask = mask; + sc.cr2 = current->thread.cr2; - return err; + if (copy_to_user(__sc, &sc, sizeof(sc))) + return 1; + return 0; } /* @@ -443,7 +441,7 @@ static void setup_rt_frame(int sig, stru /* Create the ucontext. */ err |= __put_user(0, &frame->uc.uc_flags); err |= __put_user(0, &frame->uc.uc_link); - err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); + err |= __put_user(current->sas_ss_sp, (unsigned long *)&frame->uc.uc_stack.ss_sp); err |= __put_user(sas_ss_flags(regs->esp), &frame->uc.uc_stack.ss_flags); err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); --- diff/arch/i386/kernel/smp.c 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/kernel/smp.c 2004-02-23 13:56:37.000000000 +0000 @@ -327,10 +327,12 @@ asmlinkage void smp_invalidate_interrupt if (flush_mm == cpu_tlbstate[cpu].active_mm) { if (cpu_tlbstate[cpu].state == TLBSTATE_OK) { +#ifndef CONFIG_X86_SWITCH_PAGETABLES if (flush_va == FLUSH_ALL) local_flush_tlb(); else __flush_tlb_one(flush_va); +#endif } else leave_mm(cpu); } @@ -396,21 +398,6 @@ static void flush_tlb_others(cpumask_t c spin_unlock(&tlbstate_lock); } -void flush_tlb_current_task(void) -{ - struct mm_struct *mm = current->mm; - cpumask_t cpu_mask; - - preempt_disable(); - cpu_mask = mm->cpu_vm_mask; - cpu_clear(smp_processor_id(), cpu_mask); - - local_flush_tlb(); - if (!cpus_empty(cpu_mask)) - flush_tlb_others(cpu_mask, mm, FLUSH_ALL); - preempt_enable(); -} - void flush_tlb_mm (struct mm_struct * mm) { cpumask_t cpu_mask; @@ -442,7 +429,10 @@ void flush_tlb_page(struct vm_area_struc if (current->active_mm == mm) { if(current->mm) - __flush_tlb_one(va); +#ifndef CONFIG_X86_SWITCH_PAGETABLES + __flush_tlb_one(va) +#endif + ; else leave_mm(smp_processor_id()); } @@ -466,7 +456,17 @@ void flush_tlb_all(void) { on_each_cpu(do_flush_tlb_all, 0, 1, 1); } - +#ifdef CONFIG_KGDB +/* + * By using the NMI code instead of a vector we just sneak thru the + * word generator coming out with just what we want. AND it does + * not matter if clustered_apic_mode is set or not. + */ +void smp_send_nmi_allbutself(void) +{ + send_IPI_allbutself(APIC_DM_NMI); +} +#endif /* * this function sends a 'reschedule' IPI to another CPU. * it goes straight through and wastes no time serializing --- diff/arch/i386/kernel/smpboot.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/i386/kernel/smpboot.c 2004-02-23 13:56:37.000000000 +0000 @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -934,7 +935,7 @@ static int boot_cpu_logical_apicid; /* Where the IO area was mapped on multiquad, always 0 otherwise */ void *xquad_portio; -int cpu_sibling_map[NR_CPUS] __cacheline_aligned; +cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned; static void __init smp_boot_cpus(unsigned int max_cpus) { @@ -948,10 +949,13 @@ static void __init smp_boot_cpus(unsigne printk("CPU%d: ", 0); print_cpu_info(&cpu_data[0]); + boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID)); boot_cpu_logical_apicid = logical_smp_processor_id(); current_thread_info()->cpu = 0; smp_tune_scheduling(); + cpus_clear(cpu_sibling_map[0]); + cpu_set(0, cpu_sibling_map[0]); /* * If we couldn't find an SMP configuration at boot time, @@ -1008,8 +1012,6 @@ static void __init smp_boot_cpus(unsigne setup_local_APIC(); map_cpu_to_logical_apicid(); - if (GET_APIC_ID(apic_read(APIC_ID)) != boot_cpu_physical_apicid) - BUG(); setup_portio_remap(); @@ -1080,32 +1082,34 @@ static void __init smp_boot_cpus(unsigne Dprintk("Boot done.\n"); /* - * If Hyper-Threading is avaialble, construct cpu_sibling_map[], so - * that we can tell the sibling CPU efficiently. + * construct cpu_sibling_map[], so that we can tell sibling CPUs + * efficiently. */ - if (cpu_has_ht && smp_num_siblings > 1) { - for (cpu = 0; cpu < NR_CPUS; cpu++) - cpu_sibling_map[cpu] = NO_PROC_ID; - - for (cpu = 0; cpu < NR_CPUS; cpu++) { - int i; - if (!cpu_isset(cpu, cpu_callout_map)) - continue; + for (cpu = 0; cpu < NR_CPUS; cpu++) + cpus_clear(cpu_sibling_map[cpu]); + + for (cpu = 0; cpu < NR_CPUS; cpu++) { + int siblings = 0; + int i; + if (!cpu_isset(cpu, cpu_callout_map)) + continue; + if (smp_num_siblings > 1) { for (i = 0; i < NR_CPUS; i++) { - if (i == cpu || !cpu_isset(i, cpu_callout_map)) + if (!cpu_isset(i, cpu_callout_map)) continue; if (phys_proc_id[cpu] == phys_proc_id[i]) { - cpu_sibling_map[cpu] = i; - printk("cpu_sibling_map[%d] = %d\n", cpu, cpu_sibling_map[cpu]); - break; + siblings++; + cpu_set(i, cpu_sibling_map[cpu]); } } - if (cpu_sibling_map[cpu] == NO_PROC_ID) { - smp_num_siblings = 1; - printk(KERN_WARNING "WARNING: No sibling found for CPU %d.\n", cpu); - } + } else { + siblings++; + cpu_set(cpu, cpu_sibling_map[cpu]); } + + if (siblings != smp_num_siblings) + printk(KERN_WARNING "WARNING: %d siblings found for CPU%d, should be %d\n", siblings, cpu, smp_num_siblings); } smpboot_setup_io_apic(); @@ -1119,6 +1123,216 @@ static void __init smp_boot_cpus(unsigne synchronize_tsc_bp(); } +#ifdef CONFIG_SCHED_SMT +#ifdef CONFIG_NUMA +static struct sched_group sched_group_cpus[NR_CPUS]; +static struct sched_group sched_group_phys[NR_CPUS]; +static struct sched_group sched_group_nodes[MAX_NUMNODES]; +static DEFINE_PER_CPU(struct sched_domain, phys_domains); +static DEFINE_PER_CPU(struct sched_domain, node_domains); +__init void arch_init_sched_domains(void) +{ + int i; + struct sched_group *first_cpu = NULL, *last_cpu = NULL; + + /* Set up domains */ + for_each_cpu(i) { + struct sched_domain *cpu_domain = cpu_sched_domain(i); + struct sched_domain *phys_domain = &per_cpu(phys_domains, i); + struct sched_domain *node_domain = &per_cpu(node_domains, i); + int node = cpu_to_node(i); + cpumask_t nodemask = node_to_cpumask(node); + + *cpu_domain = SD_SIBLING_INIT; + cpu_domain->span = cpu_sibling_map[i]; + + *phys_domain = SD_CPU_INIT; + phys_domain->span = nodemask; + + *node_domain = SD_NODE_INIT; + node_domain->span = cpu_possible_map; + } + + /* Set up CPU (sibling) groups */ + for_each_cpu(i) { + struct sched_domain *cpu_domain = cpu_sched_domain(i); + int j; + first_cpu = last_cpu = NULL; + + if (i != first_cpu(cpu_domain->span)) + continue; + + for_each_cpu_mask(j, cpu_domain->span) { + struct sched_group *cpu = &sched_group_cpus[j]; + + cpu->cpumask = CPU_MASK_NONE; + cpu_set(j, cpu->cpumask); + cpu->cpu_power = SCHED_LOAD_SCALE; + + if (!first_cpu) + first_cpu = cpu; + if (last_cpu) + last_cpu->next = cpu; + last_cpu = cpu; + } + last_cpu->next = first_cpu; + } + + for (i = 0; i < MAX_NUMNODES; i++) { + int j; + cpumask_t nodemask; + struct sched_group *node = &sched_group_nodes[i]; + cpus_and(nodemask, node_to_cpumask(i), cpu_possible_map); + + if (cpus_empty(nodemask)) + continue; + + first_cpu = last_cpu = NULL; + /* Set up physical groups */ + for_each_cpu_mask(j, nodemask) { + struct sched_domain *cpu_domain = cpu_sched_domain(j); + struct sched_group *cpu = &sched_group_phys[j]; + + if (j != first_cpu(cpu_domain->span)) + continue; + + cpu->cpumask = cpu_domain->span; + /* + * Make each extra sibling increase power by 10% of + * the basic CPU. This is very arbitrary. + */ + cpu->cpu_power = SCHED_LOAD_SCALE + SCHED_LOAD_SCALE*(cpus_weight(cpu->cpumask)-1) / 10; + node->cpu_power += cpu->cpu_power; + + if (!first_cpu) + first_cpu = cpu; + if (last_cpu) + last_cpu->next = cpu; + last_cpu = cpu; + } + last_cpu->next = first_cpu; + } + + /* Set up nodes */ + first_cpu = last_cpu = NULL; + for (i = 0; i < MAX_NUMNODES; i++) { + struct sched_group *cpu = &sched_group_nodes[i]; + cpumask_t nodemask; + cpus_and(nodemask, node_to_cpumask(i), cpu_possible_map); + + if (cpus_empty(nodemask)) + continue; + + cpu->cpumask = nodemask; + /* ->cpu_power already setup */ + + if (!first_cpu) + first_cpu = cpu; + if (last_cpu) + last_cpu->next = cpu; + last_cpu = cpu; + } + last_cpu->next = first_cpu; + + mb(); + for_each_cpu(i) { + int node = cpu_to_node(i); + struct sched_domain *cpu_domain = cpu_sched_domain(i); + struct sched_domain *phys_domain = &per_cpu(phys_domains, i); + struct sched_domain *node_domain = &per_cpu(node_domains, i); + struct sched_group *cpu_group = &sched_group_cpus[i]; + struct sched_group *phys_group = &sched_group_phys[first_cpu(cpu_domain->span)]; + struct sched_group *node_group = &sched_group_nodes[node]; + + cpu_domain->parent = phys_domain; + phys_domain->parent = node_domain; + + node_domain->groups = node_group; + phys_domain->groups = phys_group; + cpu_domain->groups = cpu_group; + } +} +#else /* CONFIG_NUMA */ +static struct sched_group sched_group_cpus[NR_CPUS]; +static struct sched_group sched_group_phys[NR_CPUS]; +static DEFINE_PER_CPU(struct sched_domain, phys_domains); +__init void arch_init_sched_domains(void) +{ + int i; + struct sched_group *first_cpu = NULL, *last_cpu = NULL; + + /* Set up domains */ + for_each_cpu(i) { + struct sched_domain *cpu_domain = cpu_sched_domain(i); + struct sched_domain *phys_domain = &per_cpu(phys_domains, i); + + *cpu_domain = SD_SIBLING_INIT; + cpu_domain->span = cpu_sibling_map[i]; + + *phys_domain = SD_CPU_INIT; + phys_domain->span = cpu_possible_map; + } + + /* Set up CPU (sibling) groups */ + for_each_cpu(i) { + struct sched_domain *cpu_domain = cpu_sched_domain(i); + int j; + first_cpu = last_cpu = NULL; + + if (i != first_cpu(cpu_domain->span)) + continue; + + for_each_cpu_mask(j, cpu_domain->span) { + struct sched_group *cpu = &sched_group_cpus[j]; + + cpus_clear(cpu->cpumask); + cpu_set(j, cpu->cpumask); + cpu->cpu_power = SCHED_LOAD_SCALE; + + if (!first_cpu) + first_cpu = cpu; + if (last_cpu) + last_cpu->next = cpu; + last_cpu = cpu; + } + last_cpu->next = first_cpu; + } + + first_cpu = last_cpu = NULL; + /* Set up physical groups */ + for_each_cpu(i) { + struct sched_domain *cpu_domain = cpu_sched_domain(i); + struct sched_group *cpu = &sched_group_phys[i]; + + if (i != first_cpu(cpu_domain->span)) + continue; + + cpu->cpumask = cpu_domain->span; + /* See SMT+NUMA setup for comment */ + cpu->cpu_power = SCHED_LOAD_SCALE + SCHED_LOAD_SCALE*(cpus_weight(cpu->cpumask)-1) / 10; + + if (!first_cpu) + first_cpu = cpu; + if (last_cpu) + last_cpu->next = cpu; + last_cpu = cpu; + } + last_cpu->next = first_cpu; + + mb(); + for_each_cpu(i) { + struct sched_domain *cpu_domain = cpu_sched_domain(i); + struct sched_domain *phys_domain = &per_cpu(phys_domains, i); + struct sched_group *cpu_group = &sched_group_cpus[i]; + struct sched_group *phys_group = &sched_group_phys[first_cpu(cpu_domain->span)]; + cpu_domain->parent = phys_domain; + phys_domain->groups = phys_group; + cpu_domain->groups = cpu_group; + } +} +#endif /* CONFIG_NUMA */ +#endif /* CONFIG_SCHED_SMT */ + /* These are wrappers to interface to the new boot process. Someone who understands all this stuff should rewrite it properly. --RR 15/Jul/02 */ void __init smp_prepare_cpus(unsigned int max_cpus) --- diff/arch/i386/kernel/sys_i386.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/i386/kernel/sys_i386.c 2004-02-23 13:56:37.000000000 +0000 @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -106,8 +107,6 @@ out: } -extern asmlinkage int sys_select(int, fd_set __user *, fd_set __user *, fd_set __user *, struct timeval __user *); - struct sel_arg_struct { unsigned long n; fd_set __user *inp, *outp, *exp; --- diff/arch/i386/kernel/sysenter.c 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/kernel/sysenter.c 2004-02-23 13:56:37.000000000 +0000 @@ -18,13 +18,18 @@ #include #include #include +#include extern asmlinkage void sysenter_entry(void); void enable_sep_cpu(void *info) { int cpu = get_cpu(); +#ifdef CONFIG_X86_HIGH_ENTRY + struct tss_struct *tss = (struct tss_struct *) __fix_to_virt(FIX_TSS_0) + cpu; +#else struct tss_struct *tss = init_tss + cpu; +#endif tss->ss1 = __KERNEL_CS; tss->esp1 = sizeof(struct tss_struct) + (unsigned long) tss; --- diff/arch/i386/kernel/time.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/i386/kernel/time.c 2004-02-23 13:56:37.000000000 +0000 @@ -346,7 +346,7 @@ static int time_init_device(void) { int error = sysdev_class_register(&pit_sysclass); if (!error) - error = sys_device_register(&device_i8253); + error = sysdev_register(&device_i8253); return error; } --- diff/arch/i386/kernel/timers/Makefile 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/i386/kernel/timers/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -6,3 +6,4 @@ obj-y := timer.o timer_none.o timer_tsc. obj-$(CONFIG_X86_CYCLONE_TIMER) += timer_cyclone.o obj-$(CONFIG_HPET_TIMER) += timer_hpet.o +obj-$(CONFIG_X86_PM_TIMER) += timer_pm.o --- diff/arch/i386/kernel/timers/common.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/i386/kernel/timers/common.c 2004-02-23 13:56:37.000000000 +0000 @@ -137,3 +137,23 @@ bad_calibration: } #endif +/* calculate cpu_khz */ +void __init init_cpu_khz(void) +{ + if (cpu_has_tsc) { + unsigned long tsc_quotient = calibrate_tsc(); + if (tsc_quotient) { + /* report CPU clock rate in Hz. + * The formula is (10^6 * 2^32) / (2^32 * 1 / (clocks/us)) = + * clock/second. Our precision is about 100 ppm. + */ + { unsigned long eax=0, edx=1000; + __asm__("divl %2" + :"=a" (cpu_khz), "=d" (edx) + :"r" (tsc_quotient), + "0" (eax), "1" (edx)); + printk("Detected %lu.%03lu MHz processor.\n", cpu_khz / 1000, cpu_khz % 1000); + } + } + } +} --- diff/arch/i386/kernel/timers/timer.c 2003-09-17 12:28:01.000000000 +0100 +++ source/arch/i386/kernel/timers/timer.c 2004-02-23 13:56:37.000000000 +0000 @@ -19,6 +19,9 @@ static struct timer_opts* timers[] = { #ifdef CONFIG_HPET_TIMER &timer_hpet, #endif +#ifdef CONFIG_X86_PM_TIMER + &timer_pmtmr, +#endif &timer_tsc, &timer_pit, NULL, --- diff/arch/i386/kernel/timers/timer_cyclone.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/i386/kernel/timers/timer_cyclone.c 2004-02-23 13:56:37.000000000 +0000 @@ -212,26 +212,7 @@ static int __init init_cyclone(char* ove } } - /* init cpu_khz. - * XXX - This should really be done elsewhere, - * and in a more generic fashion. -johnstul@us.ibm.com - */ - if (cpu_has_tsc) { - unsigned long tsc_quotient = calibrate_tsc(); - if (tsc_quotient) { - /* report CPU clock rate in Hz. - * The formula is (10^6 * 2^32) / (2^32 * 1 / (clocks/us)) = - * clock/second. Our precision is about 100 ppm. - */ - { unsigned long eax=0, edx=1000; - __asm__("divl %2" - :"=a" (cpu_khz), "=d" (edx) - :"r" (tsc_quotient), - "0" (eax), "1" (edx)); - printk("Detected %lu.%03lu MHz processor.\n", cpu_khz / 1000, cpu_khz % 1000); - } - } - } + init_cpu_khz(); /* Everything looks good! */ return 0; --- diff/arch/i386/kernel/traps.c 2003-10-27 09:20:36.000000000 +0000 +++ source/arch/i386/kernel/traps.c 2004-02-23 13:56:37.000000000 +0000 @@ -54,12 +54,8 @@ #include "mach_traps.h" -asmlinkage int system_call(void); -asmlinkage void lcall7(void); -asmlinkage void lcall27(void); - -struct desc_struct default_ldt[] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, - { 0, 0 }, { 0, 0 } }; +struct desc_struct default_ldt[] __attribute__((__section__(".data.default_ldt"))) = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; +struct page *default_ldt_page; /* Do we ignore FPU interrupts ? */ char ignore_fpu_irq = 0; @@ -91,6 +87,43 @@ asmlinkage void alignment_check(void); asmlinkage void spurious_interrupt_bug(void); asmlinkage void machine_check(void); +#ifdef CONFIG_KGDB +extern void sysenter_entry(void); +#include +#include +extern void int3(void); +extern void debug(void); +void set_intr_gate(unsigned int n, void *addr); +static void set_intr_usr_gate(unsigned int n, void *addr); +/* + * Should be able to call this breakpoint() very early in + * bring up. Just hard code the call where needed. + * The breakpoint() code is here because set_?_gate() functions + * are local (static) to trap.c. They need be done only once, + * but it does not hurt to do them over. + */ +void breakpoint(void) +{ + init_entry_mappings(); + set_intr_usr_gate(3,&int3); /* disable ints on trap */ + set_intr_gate(1,&debug); + set_intr_gate(14,&page_fault); + + BREAKPOINT; +} +#define CHK_REMOTE_DEBUG(trapnr,signr,error_code,regs,after) \ + { \ + if (!user_mode(regs) ) \ + { \ + kgdb_handle_exception(trapnr, signr, error_code, regs); \ + after; \ + } else if ((trapnr == 3) && (regs->eflags &0x200)) local_irq_enable(); \ + } +#else +#define CHK_REMOTE_DEBUG(trapnr,signr,error_code,regs,after) +#endif + + static int kstack_depth_to_print = 24; void show_trace(struct task_struct *task, unsigned long * stack) @@ -119,7 +152,7 @@ void show_trace_task(struct task_struct unsigned long esp = tsk->thread.esp; /* User space on another CPU? */ - if ((esp ^ (unsigned long)tsk->thread_info) & (PAGE_MASK<<1)) + if ((esp ^ (unsigned long)tsk->thread_info) & ~(THREAD_SIZE - 1)) return; show_trace(tsk, (unsigned long *)esp); } @@ -175,8 +208,9 @@ void show_registers(struct pt_regs *regs ss = regs->xss & 0xffff; } print_modules(); - printk("CPU: %d\nEIP: %04x:[<%08lx>] %s\nEFLAGS: %08lx\n", - smp_processor_id(), 0xffff & regs->xcs, regs->eip, print_tainted(), regs->eflags); + printk("CPU: %d\nEIP: %04x:[<%08lx>] %s VLI\nEFLAGS: %08lx\n", + smp_processor_id(), 0xffff & regs->xcs, + regs->eip, print_tainted(), regs->eflags); print_symbol("EIP is at %s\n", regs->eip); printk("eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n", @@ -192,23 +226,27 @@ void show_registers(struct pt_regs *regs * time of the fault.. */ if (in_kernel) { + u8 *eip; printk("\nStack: "); show_stack(NULL, (unsigned long*)esp); printk("Code: "); - if(regs->eip < PAGE_OFFSET) - goto bad; - for(i=0;i<20;i++) - { - unsigned char c; - if(__get_user(c, &((unsigned char*)regs->eip)[i])) { -bad: + eip = (u8 *)regs->eip - 43; + for (i = 0; i < 64; i++, eip++) { + unsigned char c = 0xff; + + if ((user_mode(regs) && get_user(c, eip)) || + (!user_mode(regs) && __direct_get_user(c, eip))) { + printk(" Bad EIP value."); break; } - printk("%02x ", c); + if (eip == (u8 *)regs->eip) + printk("<%02x> ", c); + else + printk("%02x ", c); } } printk("\n"); @@ -255,12 +293,36 @@ spinlock_t die_lock = SPIN_LOCK_UNLOCKED void die(const char * str, struct pt_regs * regs, long err) { static int die_counter; + int nl = 0; console_verbose(); spin_lock_irq(&die_lock); bust_spinlocks(1); handle_BUG(regs); printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter); +#ifdef CONFIG_PREEMPT + printk("PREEMPT "); + nl = 1; +#endif +#ifdef CONFIG_SMP + printk("SMP "); + nl = 1; +#endif +#ifdef CONFIG_DEBUG_PAGEALLOC + printk("DEBUG_PAGEALLOC"); + nl = 1; +#endif + if (nl) + printk("\n"); +#ifdef CONFIG_KGDB + /* This is about the only place we want to go to kgdb even if in + * user mode. But we must go in via a trap so within kgdb we will + * always be in kernel mode. + */ + if (user_mode(regs)) + BREAKPOINT; +#endif + CHK_REMOTE_DEBUG(0,SIGTRAP,err,regs,) show_registers(regs); bust_spinlocks(0); spin_unlock_irq(&die_lock); @@ -330,6 +392,7 @@ static inline void do_trap(int trapnr, i #define DO_ERROR(trapnr, signr, str, name) \ asmlinkage void do_##name(struct pt_regs * regs, long error_code) \ { \ + CHK_REMOTE_DEBUG(trapnr,signr,error_code,regs,)\ do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \ } @@ -347,7 +410,9 @@ asmlinkage void do_##name(struct pt_regs #define DO_VM86_ERROR(trapnr, signr, str, name) \ asmlinkage void do_##name(struct pt_regs * regs, long error_code) \ { \ + CHK_REMOTE_DEBUG(trapnr, signr, error_code,regs, return)\ do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \ + return; \ } #define DO_VM86_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \ @@ -394,8 +459,10 @@ gp_in_vm86: return; gp_in_kernel: - if (!fixup_exception(regs)) + if (!fixup_exception(regs)){ + CHK_REMOTE_DEBUG(13,SIGSEGV,error_code,regs,) die("general protection fault", regs, error_code); + } } static void mem_parity_error(unsigned char reason, struct pt_regs * regs) @@ -534,10 +601,18 @@ asmlinkage void do_debug(struct pt_regs if (regs->eflags & X86_EFLAGS_IF) local_irq_enable(); - /* Mask out spurious debug traps due to lazy DR7 setting */ + /* + * Mask out spurious debug traps due to lazy DR7 setting or + * due to 4G/4G kernel mode: + */ if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) { if (!tsk->thread.debugreg[7]) goto clear_dr7; + if (!user_mode(regs)) { + // restore upon return-to-userspace: + set_thread_flag(TIF_DB7); + goto clear_dr7; + } } if (regs->eflags & VM_MASK) @@ -557,8 +632,18 @@ asmlinkage void do_debug(struct pt_regs * allowing programs to debug themselves without the ptrace() * interface. */ +#ifdef CONFIG_KGDB + /* + * I think this is the only "real" case of a TF in the kernel + * that really belongs to user space. Others are + * "Ours all ours!" + */ + if (((regs->xcs & 3) == 0) && ((void *)regs->eip == sysenter_entry)) + goto clear_TF_reenable; +#else if ((regs->xcs & 3) == 0) goto clear_TF_reenable; +#endif if ((tsk->ptrace & (PT_DTRACE|PT_PTRACED)) == PT_DTRACE) goto clear_TF; } @@ -570,6 +655,17 @@ asmlinkage void do_debug(struct pt_regs info.si_errno = 0; info.si_code = TRAP_BRKPT; +#ifdef CONFIG_KGDB + /* + * If this is a kernel mode trap, we need to reset db7 to allow us + * to continue sanely ALSO skip the signal delivery + */ + if ((regs->xcs & 3) == 0) + goto clear_dr7; + + /* if not kernel, allow ints but only if they were on */ + if ( regs->eflags & 0x200) local_irq_enable(); +#endif /* If this is a kernel mode trap, save the user PC on entry to * the kernel, that's what the debugger can make sense of. */ @@ -584,6 +680,7 @@ clear_dr7: __asm__("movl %0,%%db7" : /* no output */ : "r" (0)); + CHK_REMOTE_DEBUG(1,SIGTRAP,error_code,regs,) return; debug_vm86: @@ -779,19 +876,53 @@ asmlinkage void math_emulate(long arg) #endif /* CONFIG_MATH_EMULATION */ -#ifdef CONFIG_X86_F00F_BUG -void __init trap_init_f00f_bug(void) +void __init trap_init_virtual_IDT(void) { - __set_fixmap(FIX_F00F_IDT, __pa(&idt_table), PAGE_KERNEL_RO); - /* - * Update the IDT descriptor and reload the IDT so that - * it uses the read-only mapped virtual address. + * "idt" is magic - it overlaps the idt_descr + * variable so that updating idt will automatically + * update the idt descriptor.. */ - idt_descr.address = fix_to_virt(FIX_F00F_IDT); + __set_fixmap(FIX_IDT, __pa(&idt_table), PAGE_KERNEL_RO); + idt_descr.address = __fix_to_virt(FIX_IDT); + __asm__ __volatile__("lidt %0" : : "m" (idt_descr)); } + +void __init trap_init_virtual_GDT(void) +{ + int cpu = smp_processor_id(); + struct Xgt_desc_struct *gdt_desc = cpu_gdt_descr + cpu; + struct Xgt_desc_struct tmp_desc = {0, 0}; + struct tss_struct * t; + + __asm__ __volatile__("sgdt %0": "=m" (tmp_desc): :"memory"); + +#ifdef CONFIG_X86_HIGH_ENTRY + if (!cpu) { + __set_fixmap(FIX_GDT_0, __pa(cpu_gdt_table), PAGE_KERNEL); + __set_fixmap(FIX_GDT_1, __pa(cpu_gdt_table) + PAGE_SIZE, PAGE_KERNEL); + __set_fixmap(FIX_TSS_0, __pa(init_tss), PAGE_KERNEL); + __set_fixmap(FIX_TSS_1, __pa(init_tss) + 1*PAGE_SIZE, PAGE_KERNEL); + __set_fixmap(FIX_TSS_2, __pa(init_tss) + 2*PAGE_SIZE, PAGE_KERNEL); + __set_fixmap(FIX_TSS_3, __pa(init_tss) + 3*PAGE_SIZE, PAGE_KERNEL); + } + + gdt_desc->address = __fix_to_virt(FIX_GDT_0) + sizeof(cpu_gdt_table[0]) * cpu; +#else + gdt_desc->address = (unsigned long)cpu_gdt_table[cpu]; +#endif + __asm__ __volatile__("lgdt %0": "=m" (*gdt_desc)); + +#ifdef CONFIG_X86_HIGH_ENTRY + t = (struct tss_struct *) __fix_to_virt(FIX_TSS_0) + cpu; +#else + t = init_tss + cpu; #endif + set_tss_desc(cpu, t); + cpu_gdt_table[cpu][GDT_ENTRY_TSS].b &= 0xfffffdff; + load_TR_desc(); +} #define _set_gate(gate_addr,type,dpl,addr,seg) \ do { \ @@ -818,20 +949,26 @@ void set_intr_gate(unsigned int n, void _set_gate(idt_table+n,14,0,addr,__KERNEL_CS); } -static void __init set_trap_gate(unsigned int n, void *addr) +void __init set_trap_gate(unsigned int n, void *addr) { _set_gate(idt_table+n,15,0,addr,__KERNEL_CS); } -static void __init set_system_gate(unsigned int n, void *addr) +void __init set_system_gate(unsigned int n, void *addr) { _set_gate(idt_table+n,15,3,addr,__KERNEL_CS); } -static void __init set_call_gate(void *a, void *addr) +void __init set_call_gate(void *a, void *addr) { _set_gate(a,12,3,addr,__KERNEL_CS); } +#ifdef CONFIG_KGDB +void set_intr_usr_gate(unsigned int n, void *addr) +{ + _set_gate(idt_table+n,14,3,addr,__KERNEL_CS); +} +#endif static void __init set_task_gate(unsigned int n, unsigned int gdt_entry) { @@ -850,11 +987,16 @@ void __init trap_init(void) #ifdef CONFIG_X86_LOCAL_APIC init_apic_mappings(); #endif + init_entry_mappings(); set_trap_gate(0,÷_error); set_intr_gate(1,&debug); set_intr_gate(2,&nmi); +#ifndef CONFIG_KGDB set_system_gate(3,&int3); /* int3-5 can be called from all */ +#else + set_intr_usr_gate(3,&int3); /* int3-5 can be called from all */ +#endif set_system_gate(4,&overflow); set_system_gate(5,&bounds); set_trap_gate(6,&invalid_op); --- diff/arch/i386/kernel/vm86.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/i386/kernel/vm86.c 2004-02-23 13:56:37.000000000 +0000 @@ -125,7 +125,7 @@ struct pt_regs * save_v86_state(struct k tss = init_tss + get_cpu(); current->thread.esp0 = current->thread.saved_esp0; current->thread.sysenter_cs = __KERNEL_CS; - load_esp0(tss, ¤t->thread); + load_virtual_esp0(tss, current); current->thread.saved_esp0 = 0; put_cpu(); @@ -305,7 +305,7 @@ static void do_sys_vm86(struct kernel_vm tsk->thread.esp0 = (unsigned long) &info->VM86_TSS_ESP0; if (cpu_has_sep) tsk->thread.sysenter_cs = 0; - load_esp0(tss, &tsk->thread); + load_virtual_esp0(tss, tsk); put_cpu(); tsk->thread.screen_bitmap = info->screen_bitmap; --- diff/arch/i386/kernel/vmlinux.lds.S 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/kernel/vmlinux.lds.S 2004-02-23 13:56:37.000000000 +0000 @@ -3,6 +3,9 @@ */ #include +#include +#include +#include OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") OUTPUT_ARCH(i386) @@ -10,7 +13,7 @@ ENTRY(startup_32) jiffies = jiffies_64; SECTIONS { - . = 0xC0000000 + 0x100000; + . = __PAGE_OFFSET + 0x100000; /* read-only */ _text = .; /* Text and read-only data */ .text : { @@ -19,6 +22,19 @@ SECTIONS *(.gnu.warning) } = 0x9090 +#ifdef CONFIG_X86_4G + . = ALIGN(PAGE_SIZE_asm); + __entry_tramp_start = .; + . = FIX_ENTRY_TRAMPOLINE_0_addr; + __start___entry_text = .; + .entry.text : AT (__entry_tramp_start) { *(.entry.text) } + __entry_tramp_end = __entry_tramp_start + SIZEOF(.entry.text); + . = __entry_tramp_end; + . = ALIGN(PAGE_SIZE_asm); +#else + .entry.text : { *(.entry.text) } +#endif + _etext = .; /* End of text section */ . = ALIGN(16); /* Exception table */ @@ -34,15 +50,12 @@ SECTIONS CONSTRUCTORS } - . = ALIGN(4096); + . = ALIGN(PAGE_SIZE_asm); __nosave_begin = .; .data_nosave : { *(.data.nosave) } - . = ALIGN(4096); + . = ALIGN(PAGE_SIZE_asm); __nosave_end = .; - . = ALIGN(4096); - .data.page_aligned : { *(.data.idt) } - . = ALIGN(32); .data.cacheline_aligned : { *(.data.cacheline_aligned) } @@ -52,7 +65,7 @@ SECTIONS .data.init_task : { *(.data.init_task) } /* will be freed after init */ - . = ALIGN(4096); /* Init code and data */ + . = ALIGN(PAGE_SIZE_asm); /* Init code and data */ __init_begin = .; .init.text : { _sinittext = .; @@ -91,7 +104,7 @@ SECTIONS from .altinstructions and .eh_frame */ .exit.text : { *(.exit.text) } .exit.data : { *(.exit.data) } - . = ALIGN(4096); + . = ALIGN(PAGE_SIZE_asm); __initramfs_start = .; .init.ramfs : { *(.init.ramfs) } __initramfs_end = .; @@ -99,10 +112,22 @@ SECTIONS __per_cpu_start = .; .data.percpu : { *(.data.percpu) } __per_cpu_end = .; - . = ALIGN(4096); + . = ALIGN(PAGE_SIZE_asm); __init_end = .; /* freed after init ends here */ - + + . = ALIGN(PAGE_SIZE_asm); + .data.page_aligned_tss : { *(.data.tss) } + + . = ALIGN(PAGE_SIZE_asm); + .data.page_aligned_default_ldt : { *(.data.default_ldt) } + + . = ALIGN(PAGE_SIZE_asm); + .data.page_aligned_idt : { *(.data.idt) } + + . = ALIGN(PAGE_SIZE_asm); + .data.page_aligned_gdt : { *(.data.gdt) } + __bss_start = .; /* BSS */ .bss : { *(.bss) } __bss_stop = .; @@ -122,4 +147,6 @@ SECTIONS .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) } + + } --- diff/arch/i386/kernel/vsyscall-sysenter.S 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/kernel/vsyscall-sysenter.S 2004-02-23 13:56:37.000000000 +0000 @@ -7,6 +7,11 @@ .type __kernel_vsyscall,@function __kernel_vsyscall: .LSTART_vsyscall: + cmpl $192, %eax + jne 1f + int $0x80 + ret +1: push %ecx .Lpush_ecx: push %edx --- diff/arch/i386/kernel/vsyscall.lds 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/kernel/vsyscall.lds 2004-02-23 13:56:37.000000000 +0000 @@ -5,7 +5,7 @@ */ /* This must match . */ -VSYSCALL_BASE = 0xffffe000; +VSYSCALL_BASE = 0xffffd000; SECTIONS { --- diff/arch/i386/lib/Makefile 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/lib/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -9,4 +9,5 @@ lib-y = checksum.o delay.o \ lib-$(CONFIG_X86_USE_3DNOW) += mmx.o lib-$(CONFIG_HAVE_DEC_LOCK) += dec_and_lock.o +lib-$(CONFIG_KGDB) += kgdb_serial.o lib-$(CONFIG_DEBUG_IOVIRT) += iodebug.o --- diff/arch/i386/lib/checksum.S 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/lib/checksum.S 2004-02-23 13:56:37.000000000 +0000 @@ -280,14 +280,14 @@ unsigned int csum_partial_copy_generic ( .previous .align 4 -.globl csum_partial_copy_generic +.globl direct_csum_partial_copy_generic #ifndef CONFIG_X86_USE_PPRO_CHECKSUM #define ARGBASE 16 #define FP 12 -csum_partial_copy_generic: +direct_csum_partial_copy_generic: subl $4,%esp pushl %edi pushl %esi @@ -422,7 +422,7 @@ DST( movb %cl, (%edi) ) #define ARGBASE 12 -csum_partial_copy_generic: +direct_csum_partial_copy_generic: pushl %ebx pushl %edi pushl %esi --- diff/arch/i386/lib/dec_and_lock.c 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/lib/dec_and_lock.c 2004-02-23 13:56:37.000000000 +0000 @@ -10,6 +10,7 @@ #include #include +#ifndef ATOMIC_DEC_AND_LOCK int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock) { int counter; @@ -38,3 +39,5 @@ slow_path: spin_unlock(lock); return 0; } +#endif + --- diff/arch/i386/lib/getuser.S 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/lib/getuser.S 2004-02-23 13:56:37.000000000 +0000 @@ -9,6 +9,7 @@ * return value. */ #include +#include /* @@ -28,7 +29,7 @@ .globl __get_user_1 __get_user_1: GET_THREAD_INFO(%edx) - cmpl TI_ADDR_LIMIT(%edx),%eax + cmpl TI_addr_limit(%edx),%eax jae bad_get_user 1: movzbl (%eax),%edx xorl %eax,%eax @@ -40,7 +41,7 @@ __get_user_2: addl $1,%eax jc bad_get_user GET_THREAD_INFO(%edx) - cmpl TI_ADDR_LIMIT(%edx),%eax + cmpl TI_addr_limit(%edx),%eax jae bad_get_user 2: movzwl -1(%eax),%edx xorl %eax,%eax @@ -52,7 +53,7 @@ __get_user_4: addl $3,%eax jc bad_get_user GET_THREAD_INFO(%edx) - cmpl TI_ADDR_LIMIT(%edx),%eax + cmpl TI_addr_limit(%edx),%eax jae bad_get_user 3: movl -3(%eax),%edx xorl %eax,%eax --- diff/arch/i386/lib/usercopy.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/i386/lib/usercopy.c 2004-02-23 13:56:37.000000000 +0000 @@ -76,7 +76,7 @@ do { \ * and returns @count. */ long -__strncpy_from_user(char *dst, const char __user *src, long count) +__direct_strncpy_from_user(char *dst, const char __user *src, long count) { long res; __do_strncpy_from_user(dst, src, count, res); @@ -102,7 +102,7 @@ __strncpy_from_user(char *dst, const cha * and returns @count. */ long -strncpy_from_user(char *dst, const char __user *src, long count) +direct_strncpy_from_user(char *dst, const char __user *src, long count) { long res = -EFAULT; if (access_ok(VERIFY_READ, src, 1)) @@ -147,7 +147,7 @@ do { \ * On success, this will be zero. */ unsigned long -clear_user(void __user *to, unsigned long n) +direct_clear_user(void __user *to, unsigned long n) { might_sleep(); if (access_ok(VERIFY_WRITE, to, n)) @@ -167,7 +167,7 @@ clear_user(void __user *to, unsigned lon * On success, this will be zero. */ unsigned long -__clear_user(void __user *to, unsigned long n) +__direct_clear_user(void __user *to, unsigned long n) { __do_clear_user(to, n); return n; @@ -184,7 +184,7 @@ __clear_user(void __user *to, unsigned l * On exception, returns 0. * If the string is too long, returns a value greater than @n. */ -long strnlen_user(const char __user *s, long n) +long direct_strnlen_user(const char __user *s, long n) { unsigned long mask = -__addr_ok(s); unsigned long res, tmp; @@ -575,3 +575,4 @@ unsigned long __copy_from_user_ll(void * n = __copy_user_zeroing_intel(to, (const void *) from, n); return n; } + --- diff/arch/i386/math-emu/fpu_system.h 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/math-emu/fpu_system.h 2004-02-23 13:56:37.000000000 +0000 @@ -15,6 +15,7 @@ #include #include #include +#include /* This sets the pointer FPU_info to point to the argument part of the stack frame of math_emulate() */ @@ -22,7 +23,7 @@ /* s is always from a cpu register, and the cpu does bounds checking * during register load --> no further bounds checks needed */ -#define LDT_DESCRIPTOR(s) (((struct desc_struct *)current->mm->context.ldt)[(s) >> 3]) +#define LDT_DESCRIPTOR(s) (((struct desc_struct *)__kmap_atomic_vaddr(KM_LDT_PAGE0))[(s) >> 3]) #define SEG_D_SIZE(x) ((x).b & (3 << 21)) #define SEG_G_BIT(x) ((x).b & (1 << 23)) #define SEG_GRANULARITY(x) (((x).b & (1 << 23)) ? 4096 : 1) --- diff/arch/i386/mm/fault.c 2003-12-19 09:51:11.000000000 +0000 +++ source/arch/i386/mm/fault.c 2004-02-23 13:56:37.000000000 +0000 @@ -27,6 +27,7 @@ #include #include #include +#include extern void die(const char *,struct pt_regs *,long); @@ -104,8 +105,17 @@ static inline unsigned long get_segment_ if (seg & (1<<2)) { /* Must lock the LDT while reading it. */ down(¤t->mm->context.sem); +#if 1 + /* horrible hack for 4/4 disabled kernels. + I'm not quite sure what the TLB flush is good for, + it's mindlessly copied from the read_ldt code */ + __flush_tlb_global(); + desc = kmap(current->mm->context.ldt_pages[(seg&~7)/PAGE_SIZE]); + desc = (void *)desc + ((seg & ~7) % PAGE_SIZE); +#else desc = current->mm->context.ldt; desc = (void *)desc + (seg & ~7); +#endif } else { /* Must disable preemption while reading the GDT. */ desc = (u32 *)&cpu_gdt_table[get_cpu()]; @@ -118,6 +128,9 @@ static inline unsigned long get_segment_ (desc[1] & 0xff000000); if (seg & (1<<2)) { +#if 1 + kunmap((void *)((unsigned long)desc & PAGE_MASK)); +#endif up(¤t->mm->context.sem); } else put_cpu(); @@ -243,6 +256,19 @@ asmlinkage void do_page_fault(struct pt_ * (error_code & 4) == 0, and that the fault was not a * protection error (error_code & 1) == 0. */ +#ifdef CONFIG_X86_4G + /* + * On 4/4 all kernels faults are either bugs, vmalloc or prefetch + */ + if (unlikely((regs->xcs & 3) == 0)) { + if (error_code & 3) + goto bad_area_nosemaphore; + + /* If it's vm86 fall through */ + if (!(regs->eflags & VM_MASK)) + goto vmalloc_fault; + } +#else if (unlikely(address >= TASK_SIZE)) { if (!(error_code & 5)) goto vmalloc_fault; @@ -252,6 +278,7 @@ asmlinkage void do_page_fault(struct pt_ */ goto bad_area_nosemaphore; } +#endif mm = tsk->mm; @@ -403,6 +430,12 @@ no_context: * Oops. The kernel tried to access some bad page. We'll have to * terminate things with extreme prejudice. */ +#ifdef CONFIG_KGDB + if (!user_mode(regs)){ + kgdb_handle_exception(14,SIGBUS, error_code, regs); + return; + } +#endif bust_spinlocks(1); --- diff/arch/i386/mm/hugetlbpage.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/i386/mm/hugetlbpage.c 2004-02-23 13:56:37.000000000 +0000 @@ -61,6 +61,27 @@ static struct page *alloc_fresh_huge_pag static void free_huge_page(struct page *page); +#ifdef CONFIG_NUMA + +static inline void huge_inc_rss(struct mm_struct *mm, struct page *page) +{ + mm->rss += (HPAGE_SIZE / PAGE_SIZE); + mm->pernode_rss[page_nodenum(page)] += (HPAGE_SIZE / PAGE_SIZE); +} + +static inline void huge_dec_rss(struct mm_struct *mm, struct page *page) +{ + mm->rss -= (HPAGE_SIZE / PAGE_SIZE); + mm->pernode_rss[page_nodenum(page)] -= (HPAGE_SIZE / PAGE_SIZE); +} + +#else /* !CONFIG_NUMA */ + +#define huge_inc_rss(mm, page) ((mm)->rss += (HPAGE_SIZE / PAGE_SIZE)) +#define huge_dec_rss(mm, page) ((mm)->rss -= (HPAGE_SIZE / PAGE_SIZE)) + +#endif /* CONFIG_NUMA */ + static struct page *alloc_hugetlb_page(void) { int i; @@ -105,7 +126,7 @@ static void set_huge_pte(struct mm_struc { pte_t entry; - mm->rss += (HPAGE_SIZE / PAGE_SIZE); + huge_inc_rss(mm, page); if (write_access) { entry = pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot))); @@ -145,7 +166,7 @@ int copy_hugetlb_page_range(struct mm_st ptepage = pte_page(entry); get_page(ptepage); set_pte(dst_pte, entry); - dst->rss += (HPAGE_SIZE / PAGE_SIZE); + huge_inc_rss(dst, ptepage); addr += HPAGE_SIZE; } return 0; @@ -314,8 +335,8 @@ void unmap_hugepage_range(struct vm_area page = pte_page(*pte); huge_page_release(page); pte_clear(pte); + huge_dec_rss(mm, page); } - mm->rss -= (end - start) >> PAGE_SHIFT; flush_tlb_range(vma, start, end); } --- diff/arch/i386/mm/init.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/i386/mm/init.c 2004-02-23 13:56:37.000000000 +0000 @@ -40,125 +40,13 @@ #include #include #include +#include DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); unsigned long highstart_pfn, highend_pfn; static int do_test_wp_bit(void); -/* - * Creates a middle page table and puts a pointer to it in the - * given global directory entry. This only returns the gd entry - * in non-PAE compilation mode, since the middle layer is folded. - */ -static pmd_t * __init one_md_table_init(pgd_t *pgd) -{ - pmd_t *pmd_table; - -#ifdef CONFIG_X86_PAE - pmd_table = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE); - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT)); - if (pmd_table != pmd_offset(pgd, 0)) - BUG(); -#else - pmd_table = pmd_offset(pgd, 0); -#endif - - return pmd_table; -} - -/* - * Create a page table and place a pointer to it in a middle page - * directory entry. - */ -static pte_t * __init one_page_table_init(pmd_t *pmd) -{ - if (pmd_none(*pmd)) { - pte_t *page_table = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); - set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE)); - if (page_table != pte_offset_kernel(pmd, 0)) - BUG(); - - return page_table; - } - - return pte_offset_kernel(pmd, 0); -} - -/* - * This function initializes a certain range of kernel virtual memory - * with new bootmem page tables, everywhere page tables are missing in - * the given range. - */ - -/* - * NOTE: The pagetables are allocated contiguous on the physical space - * so we can cache the place of the first one and move around without - * checking the pgd every time. - */ -static void __init page_table_range_init (unsigned long start, unsigned long end, pgd_t *pgd_base) -{ - pgd_t *pgd; - pmd_t *pmd; - int pgd_idx, pmd_idx; - unsigned long vaddr; - - vaddr = start; - pgd_idx = pgd_index(vaddr); - pmd_idx = pmd_index(vaddr); - pgd = pgd_base + pgd_idx; - - for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) { - if (pgd_none(*pgd)) - one_md_table_init(pgd); - - pmd = pmd_offset(pgd, vaddr); - for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end); pmd++, pmd_idx++) { - if (pmd_none(*pmd)) - one_page_table_init(pmd); - - vaddr += PMD_SIZE; - } - pmd_idx = 0; - } -} - -/* - * This maps the physical memory to kernel virtual address space, a total - * of max_low_pfn pages, by creating page tables starting from address - * PAGE_OFFSET. - */ -static void __init kernel_physical_mapping_init(pgd_t *pgd_base) -{ - unsigned long pfn; - pgd_t *pgd; - pmd_t *pmd; - pte_t *pte; - int pgd_idx, pmd_idx, pte_ofs; - - pgd_idx = pgd_index(PAGE_OFFSET); - pgd = pgd_base + pgd_idx; - pfn = 0; - - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) { - pmd = one_md_table_init(pgd); - if (pfn >= max_low_pfn) - continue; - for (pmd_idx = 0; pmd_idx < PTRS_PER_PMD && pfn < max_low_pfn; pmd++, pmd_idx++) { - /* Map with big pages if possible, otherwise create normal page tables. */ - if (cpu_has_pse) { - set_pmd(pmd, pfn_pmd(pfn, PAGE_KERNEL_LARGE)); - pfn += PTRS_PER_PTE; - } else { - pte = one_page_table_init(pmd); - - for (pte_ofs = 0; pte_ofs < PTRS_PER_PTE && pfn < max_low_pfn; pte++, pfn++, pte_ofs++) - set_pte(pte, pfn_pte(pfn, PAGE_KERNEL)); - } - } - } -} - static inline int page_kills_ppro(unsigned long pagenr) { if (pagenr >= 0x70000 && pagenr <= 0x7003F) @@ -206,11 +94,8 @@ static inline int page_is_ram(unsigned l return 0; } -#ifdef CONFIG_HIGHMEM pte_t *kmap_pte; -pgprot_t kmap_prot; -EXPORT_SYMBOL(kmap_prot); EXPORT_SYMBOL(kmap_pte); #define kmap_get_fixmap_pte(vaddr) \ @@ -218,29 +103,7 @@ EXPORT_SYMBOL(kmap_pte); void __init kmap_init(void) { - unsigned long kmap_vstart; - - /* cache the first kmap pte */ - kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN); - kmap_pte = kmap_get_fixmap_pte(kmap_vstart); - - kmap_prot = PAGE_KERNEL; -} - -void __init permanent_kmaps_init(pgd_t *pgd_base) -{ - pgd_t *pgd; - pmd_t *pmd; - pte_t *pte; - unsigned long vaddr; - - vaddr = PKMAP_BASE; - page_table_range_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base); - - pgd = swapper_pg_dir + pgd_index(vaddr); - pmd = pmd_offset(pgd, vaddr); - pte = pte_offset_kernel(pmd, vaddr); - pkmap_page_table = pte; + kmap_pte = kmap_get_fixmap_pte(__fix_to_virt(FIX_KMAP_BEGIN)); } void __init one_highpage_init(struct page *page, int pfn, int bad_ppro) @@ -255,6 +118,8 @@ void __init one_highpage_init(struct pag SetPageReserved(page); } +#ifdef CONFIG_HIGHMEM + #ifndef CONFIG_DISCONTIGMEM void __init set_highmem_pages_init(int bad_ppro) { @@ -266,12 +131,9 @@ void __init set_highmem_pages_init(int b #else extern void set_highmem_pages_init(int); #endif /* !CONFIG_DISCONTIGMEM */ - #else -#define kmap_init() do { } while (0) -#define permanent_kmaps_init(pgd_base) do { } while (0) -#define set_highmem_pages_init(bad_ppro) do { } while (0) -#endif /* CONFIG_HIGHMEM */ +# define set_highmem_pages_init(bad_ppro) do { } while (0) +#endif unsigned long __PAGE_KERNEL = _PAGE_KERNEL; @@ -281,30 +143,125 @@ unsigned long __PAGE_KERNEL = _PAGE_KERN extern void __init remap_numa_kva(void); #endif -static void __init pagetable_init (void) +static __init void prepare_pagetables(pgd_t *pgd_base, unsigned long address) +{ + pgd_t *pgd; + pmd_t *pmd; + pte_t *pte; + + pgd = pgd_base + pgd_index(address); + pmd = pmd_offset(pgd, address); + if (!pmd_present(*pmd)) { + pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); + set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))); + } +} + +static void __init fixrange_init (unsigned long start, unsigned long end, pgd_t *pgd_base) { unsigned long vaddr; - pgd_t *pgd_base = swapper_pg_dir; + for (vaddr = start; vaddr != end; vaddr += PAGE_SIZE) + prepare_pagetables(pgd_base, vaddr); +} + +void setup_identity_mappings(pgd_t *pgd_base, unsigned long start, unsigned long end) +{ + unsigned long vaddr; + pgd_t *pgd; + int i, j, k; + pmd_t *pmd; + pte_t *pte, *pte_base; + + pgd = pgd_base; + + for (i = 0; i < PTRS_PER_PGD; pgd++, i++) { + vaddr = i*PGDIR_SIZE; + if (end && (vaddr >= end)) + break; + pmd = pmd_offset(pgd, 0); + for (j = 0; j < PTRS_PER_PMD; pmd++, j++) { + vaddr = i*PGDIR_SIZE + j*PMD_SIZE; + if (end && (vaddr >= end)) + break; + if (vaddr < start) + continue; + if (cpu_has_pse) { + unsigned long __pe; + + set_in_cr4(X86_CR4_PSE); + boot_cpu_data.wp_works_ok = 1; + __pe = _KERNPG_TABLE + _PAGE_PSE + vaddr - start; + /* Make it "global" too if supported */ + if (cpu_has_pge) { + set_in_cr4(X86_CR4_PGE); +#if !defined(CONFIG_X86_SWITCH_PAGETABLES) + __pe += _PAGE_GLOBAL; + __PAGE_KERNEL |= _PAGE_GLOBAL; +#endif + } + set_pmd(pmd, __pmd(__pe)); + continue; + } + if (!pmd_present(*pmd)) + pte_base = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); + else + pte_base = (pte_t *) page_address(pmd_page(*pmd)); + pte = pte_base; + for (k = 0; k < PTRS_PER_PTE; pte++, k++) { + vaddr = i*PGDIR_SIZE + j*PMD_SIZE + k*PAGE_SIZE; + if (end && (vaddr >= end)) + break; + if (vaddr < start) + continue; + *pte = mk_pte_phys(vaddr-start, PAGE_KERNEL); + } + set_pmd(pmd, __pmd(_KERNPG_TABLE + __pa(pte_base))); + } + } +} + +static void __init pagetable_init (void) +{ + unsigned long vaddr, end; + pgd_t *pgd_base; #ifdef CONFIG_X86_PAE int i; - /* Init entries of the first-level page table to the zero page */ - for (i = 0; i < PTRS_PER_PGD; i++) - set_pgd(pgd_base + i, __pgd(__pa(empty_zero_page) | _PAGE_PRESENT)); #endif - /* Enable PSE if available */ - if (cpu_has_pse) { - set_in_cr4(X86_CR4_PSE); - } + /* + * This can be zero as well - no problem, in that case we exit + * the loops anyway due to the PTRS_PER_* conditions. + */ + end = (unsigned long)__va(max_low_pfn*PAGE_SIZE); - /* Enable PGE if available */ - if (cpu_has_pge) { - set_in_cr4(X86_CR4_PGE); - __PAGE_KERNEL |= _PAGE_GLOBAL; + pgd_base = swapper_pg_dir; +#ifdef CONFIG_X86_PAE + /* + * It causes too many problems if there's no proper pmd set up + * for all 4 entries of the PGD - so we allocate all of them. + * PAE systems will not miss this extra 4-8K anyway ... + */ + for (i = 0; i < PTRS_PER_PGD; i++) { + pmd_t *pmd = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE); + set_pgd(pgd_base + i, __pgd(__pa(pmd) + 0x1)); } +#endif + /* + * Set up lowmem-sized identity mappings at PAGE_OFFSET: + */ + setup_identity_mappings(pgd_base, PAGE_OFFSET, end); - kernel_physical_mapping_init(pgd_base); + /* + * Add flat-mode identity-mappings - SMP needs it when + * starting up on an AP from real-mode. (In the non-PAE + * case we already have these mappings through head.S.) + * All user-space mappings are explicitly cleared after + * SMP startup. + */ +#if defined(CONFIG_SMP) && defined(CONFIG_X86_PAE) + setup_identity_mappings(pgd_base, 0, 16*1024*1024); +#endif remap_numa_kva(); /* @@ -312,38 +269,64 @@ static void __init pagetable_init (void) * created - mappings will be set by set_fixmap(): */ vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK; - page_table_range_init(vaddr, 0, pgd_base); + fixrange_init(vaddr, 0, pgd_base); - permanent_kmaps_init(pgd_base); +#ifdef CONFIG_HIGHMEM + { + pgd_t *pgd; + pmd_t *pmd; + pte_t *pte; -#ifdef CONFIG_X86_PAE - /* - * Add low memory identity-mappings - SMP needs it when - * starting up on an AP from real-mode. In the non-PAE - * case we already have these mappings through head.S. - * All user-space mappings are explicitly cleared after - * SMP startup. - */ - pgd_base[0] = pgd_base[USER_PTRS_PER_PGD]; + /* + * Permanent kmaps: + */ + vaddr = PKMAP_BASE; + fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base); + + pgd = swapper_pg_dir + pgd_index(vaddr); + pmd = pmd_offset(pgd, vaddr); + pte = pte_offset_kernel(pmd, vaddr); + pkmap_page_table = pte; + } #endif } -void zap_low_mappings (void) +/* + * Clear kernel pagetables in a PMD_SIZE-aligned range. + */ +static void clear_mappings(pgd_t *pgd_base, unsigned long start, unsigned long end) { - int i; + unsigned long vaddr; + pgd_t *pgd; + pmd_t *pmd; + int i, j; + + pgd = pgd_base; + + for (i = 0; i < PTRS_PER_PGD; pgd++, i++) { + vaddr = i*PGDIR_SIZE; + if (end && (vaddr >= end)) + break; + pmd = pmd_offset(pgd, 0); + for (j = 0; j < PTRS_PER_PMD; pmd++, j++) { + vaddr = i*PGDIR_SIZE + j*PMD_SIZE; + if (end && (vaddr >= end)) + break; + if (vaddr < start) + continue; + pmd_clear(pmd); + } + } + flush_tlb_all(); +} + +void zap_low_mappings(void) +{ + printk("zapping low mappings.\n"); /* * Zap initial low-memory mappings. - * - * Note that "pgd_clear()" doesn't do it for - * us, because pgd_clear() is a no-op on i386. */ - for (i = 0; i < USER_PTRS_PER_PGD; i++) -#ifdef CONFIG_X86_PAE - set_pgd(swapper_pg_dir+i, __pgd(1 + __pa(empty_zero_page))); -#else - set_pgd(swapper_pg_dir+i, __pgd(0)); -#endif - flush_tlb_all(); + clear_mappings(swapper_pg_dir, 0, 16*1024*1024); } #ifndef CONFIG_DISCONTIGMEM @@ -393,7 +376,15 @@ void __init paging_init(void) set_in_cr4(X86_CR4_PAE); #endif __flush_tlb_all(); - + /* + * Subtle. SMP is doing it's boot stuff late (because it has to + * fork idle threads) - but it also needs low mappings for the + * protected-mode entry to work. We zap these entries only after + * the WP-bit has been tested. + */ +#ifndef CONFIG_SMP + zap_low_mappings(); +#endif kmap_init(); zone_sizes_init(); } @@ -515,22 +506,18 @@ void __init mem_init(void) if (boot_cpu_data.wp_works_ok < 0) test_wp_bit(); - /* - * Subtle. SMP is doing it's boot stuff late (because it has to - * fork idle threads) - but it also needs low mappings for the - * protected-mode entry to work. We zap these entries only after - * the WP-bit has been tested. - */ -#ifndef CONFIG_SMP - zap_low_mappings(); -#endif + entry_trampoline_setup(); + default_ldt_page = virt_to_page(default_ldt); + load_LDT(&init_mm.context); } -kmem_cache_t *pgd_cache; -kmem_cache_t *pmd_cache; +kmem_cache_t *pgd_cache, *pmd_cache, *kpmd_cache; void __init pgtable_cache_init(void) { + void (*ctor)(void *, kmem_cache_t *, unsigned long); + void (*dtor)(void *, kmem_cache_t *, unsigned long); + if (PTRS_PER_PMD > 1) { pmd_cache = kmem_cache_create("pmd", PTRS_PER_PMD*sizeof(pmd_t), @@ -540,13 +527,36 @@ void __init pgtable_cache_init(void) NULL); if (!pmd_cache) panic("pgtable_cache_init(): cannot create pmd cache"); + + if (TASK_SIZE > PAGE_OFFSET) { + kpmd_cache = kmem_cache_create("kpmd", + PTRS_PER_PMD*sizeof(pmd_t), + 0, + SLAB_HWCACHE_ALIGN | SLAB_MUST_HWCACHE_ALIGN, + kpmd_ctor, + NULL); + if (!kpmd_cache) + panic("pgtable_cache_init(): " + "cannot create kpmd cache"); + } } + + if (PTRS_PER_PMD == 1 || TASK_SIZE <= PAGE_OFFSET) + ctor = pgd_ctor; + else + ctor = NULL; + + if (PTRS_PER_PMD == 1 && TASK_SIZE <= PAGE_OFFSET) + dtor = pgd_dtor; + else + dtor = NULL; + pgd_cache = kmem_cache_create("pgd", PTRS_PER_PGD*sizeof(pgd_t), 0, SLAB_HWCACHE_ALIGN | SLAB_MUST_HWCACHE_ALIGN, - pgd_ctor, - PTRS_PER_PMD == 1 ? pgd_dtor : NULL); + ctor, + dtor); if (!pgd_cache) panic("pgtable_cache_init(): Cannot create pgd cache"); } --- diff/arch/i386/mm/pgtable.c 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/i386/mm/pgtable.c 2004-02-23 13:56:37.000000000 +0000 @@ -21,6 +21,7 @@ #include #include #include +#include void show_mem(void) { @@ -157,11 +158,20 @@ void pmd_ctor(void *pmd, kmem_cache_t *c memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t)); } +void kpmd_ctor(void *__pmd, kmem_cache_t *cache, unsigned long flags) +{ + pmd_t *kpmd, *pmd; + kpmd = pmd_offset(&swapper_pg_dir[PTRS_PER_PGD-1], + (PTRS_PER_PMD - NR_SHARED_PMDS)*PMD_SIZE); + pmd = (pmd_t *)__pmd + (PTRS_PER_PMD - NR_SHARED_PMDS); + + memset(__pmd, 0, (PTRS_PER_PMD - NR_SHARED_PMDS)*sizeof(pmd_t)); + memcpy(pmd, kpmd, NR_SHARED_PMDS*sizeof(pmd_t)); +} + /* - * List of all pgd's needed for non-PAE so it can invalidate entries - * in both cached and uncached pgd's; not needed for PAE since the - * kernel pmd is shared. If PAE were not to share the pmd a similar - * tactic would be needed. This is essentially codepath-based locking + * List of all pgd's needed so it can invalidate entries in both cached + * and uncached pgd's. This is essentially codepath-based locking * against pageattr.c; it is the unique case in which a valid change * of kernel pagetables can't be lazily synchronized by vmalloc faults. * vmalloc faults work because attached pagetables are never freed. @@ -170,30 +180,60 @@ void pmd_ctor(void *pmd, kmem_cache_t *c * could be used. The locking scheme was chosen on the basis of * manfred's recommendations and having no core impact whatsoever. * -- wli + * + * The entire issue goes away when XKVA is configured. */ spinlock_t pgd_lock = SPIN_LOCK_UNLOCKED; LIST_HEAD(pgd_list); -void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused) +/* + * This is not that hard to figure out. + * (a) PTRS_PER_PMD == 1 means non-PAE. + * (b) PTRS_PER_PMD > 1 means PAE. + * (c) TASK_SIZE > PAGE_OFFSET means XKVA. + * (d) TASK_SIZE <= PAGE_OFFSET means non-XKVA. + * + * Do *NOT* back out the preconstruction like the patch I'm cleaning + * up after this very instant did, or at all, for that matter. + * This is never called when PTRS_PER_PMD > 1 && TASK_SIZE > PAGE_OFFSET. + * -- wli + */ +void pgd_ctor(void *__pgd, kmem_cache_t *cache, unsigned long unused) { + pgd_t *pgd = (pgd_t *)__pgd; unsigned long flags; - if (PTRS_PER_PMD == 1) - spin_lock_irqsave(&pgd_lock, flags); + if (PTRS_PER_PMD == 1) { + if (TASK_SIZE <= PAGE_OFFSET) + spin_lock_irqsave(&pgd_lock, flags); + else + memcpy(&pgd[PTRS_PER_PGD - NR_SHARED_PMDS], + &swapper_pg_dir[PTRS_PER_PGD - NR_SHARED_PMDS], + NR_SHARED_PMDS * sizeof(pgd_t)); + } - memcpy((pgd_t *)pgd + USER_PTRS_PER_PGD, - swapper_pg_dir + USER_PTRS_PER_PGD, - (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t)); + if (TASK_SIZE <= PAGE_OFFSET) + memcpy(pgd + USER_PTRS_PER_PGD, + swapper_pg_dir + USER_PTRS_PER_PGD, + (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t)); if (PTRS_PER_PMD > 1) return; - list_add(&virt_to_page(pgd)->lru, &pgd_list); - spin_unlock_irqrestore(&pgd_lock, flags); - memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t)); + if (TASK_SIZE > PAGE_OFFSET) + memset(pgd, 0, (PTRS_PER_PGD - NR_SHARED_PMDS)*sizeof(pgd_t)); + else { + list_add(&virt_to_page(pgd)->lru, &pgd_list); + spin_unlock_irqrestore(&pgd_lock, flags); + memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t)); + } } -/* never called when PTRS_PER_PMD > 1 */ +/* + * Never called when PTRS_PER_PMD > 1 || TASK_SIZE > PAGE_OFFSET + * for with PAE we would list_del() multiple times, and for non-PAE + * with XKVA all the AGP pgd shootdown code is unnecessary. + */ void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long unused) { unsigned long flags; /* can be called from interrupt context */ @@ -203,6 +243,12 @@ void pgd_dtor(void *pgd, kmem_cache_t *c spin_unlock_irqrestore(&pgd_lock, flags); } +/* + * See the comments above pgd_ctor() wrt. preconstruction. + * Do *NOT* memcpy() here. If you do, you back out important + * anti- cache pollution code. + * + */ pgd_t *pgd_alloc(struct mm_struct *mm) { int i; @@ -211,15 +257,33 @@ pgd_t *pgd_alloc(struct mm_struct *mm) if (PTRS_PER_PMD == 1 || !pgd) return pgd; + /* + * In the 4G userspace case alias the top 16 MB virtual + * memory range into the user mappings as well (these + * include the trampoline and CPU data structures). + */ for (i = 0; i < USER_PTRS_PER_PGD; ++i) { - pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL); + kmem_cache_t *cache; + pmd_t *pmd; + + if (TASK_SIZE > PAGE_OFFSET && i == USER_PTRS_PER_PGD - 1) + cache = kpmd_cache; + else + cache = pmd_cache; + + pmd = kmem_cache_alloc(cache, GFP_KERNEL); if (!pmd) goto out_oom; set_pgd(&pgd[i], __pgd(1 + __pa((u64)((u32)pmd)))); } - return pgd; + return pgd; out_oom: + /* + * we don't have to handle the kpmd_cache here, since it's the + * last allocation, and has either nothing to free or when it + * succeeds the whole operation succeeds. + */ for (i--; i >= 0; i--) kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1)); kmem_cache_free(pgd_cache, pgd); @@ -230,10 +294,29 @@ void pgd_free(pgd_t *pgd) { int i; - /* in the PAE case user pgd entries are overwritten before usage */ - if (PTRS_PER_PMD > 1) - for (i = 0; i < USER_PTRS_PER_PGD; ++i) - kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1)); /* in the non-PAE case, clear_page_tables() clears user pgd entries */ + if (PTRS_PER_PMD == 1) + goto out_free; + + /* in the PAE case user pgd entries are overwritten before usage */ + for (i = 0; i < USER_PTRS_PER_PGD; ++i) { + kmem_cache_t *cache; + pmd_t *pmd = __va(pgd_val(pgd[i]) - 1); + + /* + * only userspace pmd's are cleared for us + * by mm/memory.c; it's a slab cache invariant + * that we must separate the kernel pmd slab + * all times, else we'll have bad pmd's. + */ + if (TASK_SIZE > PAGE_OFFSET && i == USER_PTRS_PER_PGD - 1) + cache = kpmd_cache; + else + cache = pmd_cache; + + kmem_cache_free(cache, pmd); + } +out_free: kmem_cache_free(pgd_cache, pgd); } + --- diff/arch/i386/oprofile/nmi_int.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/i386/oprofile/nmi_int.c 2004-02-23 13:56:37.000000000 +0000 @@ -65,14 +65,14 @@ static int __init init_driverfs(void) { int error; if (!(error = sysdev_class_register(&oprofile_sysclass))) - error = sys_device_register(&device_oprofile); + error = sysdev_register(&device_oprofile); return error; } static void __exit exit_driverfs(void) { - sys_device_unregister(&device_oprofile); + sysdev_unregister(&device_oprofile); sysdev_class_unregister(&oprofile_sysclass); } @@ -295,8 +295,6 @@ struct oprofile_operations nmi_ops = { }; -#if !defined(CONFIG_X86_64) - static int __init p4_init(void) { __u8 cpu_model = current_cpu_data.x86_model; @@ -335,7 +333,9 @@ static int __init ppro_init(void) if (cpu_model > 0xd) return 0; - if (cpu_model > 5) { + if (cpu_model == 9) { + nmi_ops.cpu_type = "i386/p6_mobile"; + } else if (cpu_model > 5) { nmi_ops.cpu_type = "i386/piii"; } else if (cpu_model > 2) { nmi_ops.cpu_type = "i386/pii"; @@ -347,9 +347,6 @@ static int __init ppro_init(void) return 1; } -#endif /* !CONFIG_X86_64 */ - - /* in order to get driverfs right */ static int using_nmi; @@ -381,7 +378,6 @@ int __init nmi_init(struct oprofile_oper } break; -#if !defined(CONFIG_X86_64) case X86_VENDOR_INTEL: switch (family) { /* Pentium IV */ @@ -400,7 +396,6 @@ int __init nmi_init(struct oprofile_oper return -ENODEV; } break; -#endif /* !CONFIG_X86_64 */ default: return -ENODEV; --- diff/arch/i386/oprofile/nmi_timer_int.c 2003-06-30 10:07:32.000000000 +0100 +++ source/arch/i386/oprofile/nmi_timer_int.c 2004-02-23 13:56:37.000000000 +0000 @@ -48,9 +48,13 @@ static struct oprofile_operations nmi_ti .cpu_type = "timer" }; - int __init nmi_timer_init(struct oprofile_operations ** ops) { + extern int nmi_active; + + if (nmi_active <= 0) + return -ENODEV; + *ops = &nmi_timer_ops; printk(KERN_INFO "oprofile: using NMI timer interrupt.\n"); return 0; --- diff/arch/i386/oprofile/op_model_p4.c 2003-08-26 10:00:51.000000000 +0100 +++ source/arch/i386/oprofile/op_model_p4.c 2004-02-23 13:56:37.000000000 +0000 @@ -382,11 +382,8 @@ static struct p4_event_binding p4_events static unsigned int get_stagger(void) { #ifdef CONFIG_SMP - int cpu; - if (smp_num_siblings > 1) { - cpu = smp_processor_id(); - return (cpu_sibling_map[cpu] > cpu) ? 0 : 1; - } + int cpu = smp_processor_id(); + return (cpu != first_cpu(cpu_sibling_map[cpu])); #endif return 0; } --- diff/arch/i386/oprofile/op_model_ppro.c 2003-08-26 10:00:51.000000000 +0100 +++ source/arch/i386/oprofile/op_model_ppro.c 2004-02-23 13:56:37.000000000 +0000 @@ -13,6 +13,7 @@ #include #include #include +#include #include "op_x86_model.h" #include "op_counter.h" @@ -101,6 +102,10 @@ static int ppro_check_ctrs(unsigned int } } + /* Only P6 based Pentium M need to re-unmask the apic vector but it + * doesn't hurt other P6 variant */ + apic_write(APIC_LVTPC, apic_read(APIC_LVTPC) & ~APIC_LVT_MASKED); + /* We can't work out if we really handled an interrupt. We * might have caught a *second* counter just after overflowing * the interrupt for this counter then arrives --- diff/arch/i386/pci/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/i386/pci/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -1,6 +1,7 @@ obj-y := i386.o obj-$(CONFIG_PCI_BIOS) += pcbios.o +obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o obj-$(CONFIG_PCI_DIRECT) += direct.o pci-y := fixup.o --- diff/arch/i386/pci/common.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/i386/pci/common.c 2004-02-23 13:56:37.000000000 +0000 @@ -20,7 +20,8 @@ extern void pcibios_sort(void); #endif -unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2; +unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | + PCI_PROBE_MMCONF; int pcibios_last_bus = -1; struct pci_bus *pci_root_bus = NULL; @@ -198,6 +199,12 @@ char * __devinit pcibios_setup(char *st return NULL; } #endif +#ifdef CONFIG_PCI_MMCONFIG + else if (!strcmp(str, "nommconf")) { + pci_probe &= ~PCI_PROBE_MMCONF; + return NULL; + } +#endif else if (!strcmp(str, "noacpi")) { acpi_noirq_set(); return NULL; --- diff/arch/i386/pci/fixup.c 2003-08-20 14:16:24.000000000 +0100 +++ source/arch/i386/pci/fixup.c 2004-02-23 13:56:37.000000000 +0000 @@ -188,22 +188,107 @@ static void __devinit pci_fixup_transpar } struct pci_fixup pcibios_fixups[] = { - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82451NX, pci_fixup_i450nx }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454GX, pci_fixup_i450gx }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8886BF, pci_fixup_umc_ide }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_5513, pci_fixup_ide_trash }, - { PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, pci_fixup_ide_bases }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_5597, pci_fixup_latency }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_5598, pci_fixup_latency }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, pci_fixup_piix4_acpi }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10, pci_fixup_ide_trash }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_11, pci_fixup_ide_trash }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_9, pci_fixup_ide_trash }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8363_0, pci_fixup_via_northbridge_bug }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8622, pci_fixup_via_northbridge_bug }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8361, pci_fixup_via_northbridge_bug }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8367_0, pci_fixup_via_northbridge_bug }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, pci_fixup_ncr53c810 }, - { PCI_FIXUP_HEADER, PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_fixup_transparent_bridge }, - { 0 } + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_INTEL, + .device = PCI_DEVICE_ID_INTEL_82451NX, + .hook = pci_fixup_i450nx + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_INTEL, + .device = PCI_DEVICE_ID_INTEL_82454GX, + .hook = pci_fixup_i450gx + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_UMC, + .device = PCI_DEVICE_ID_UMC_UM8886BF, + .hook = pci_fixup_umc_ide + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_SI, + .device = PCI_DEVICE_ID_SI_5513, + .hook = pci_fixup_ide_trash + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_ANY_ID, + .device = PCI_ANY_ID, + .hook = pci_fixup_ide_bases + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_SI, + .device = PCI_DEVICE_ID_SI_5597, + .hook = pci_fixup_latency + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_SI, + .device = PCI_DEVICE_ID_SI_5598, + .hook = pci_fixup_latency + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_INTEL, + .device = PCI_DEVICE_ID_INTEL_82371AB_3, + .hook = pci_fixup_piix4_acpi + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_INTEL, + .device = PCI_DEVICE_ID_INTEL_82801CA_10, + .hook = pci_fixup_ide_trash + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_INTEL, + .device = PCI_DEVICE_ID_INTEL_82801CA_11, + .hook = pci_fixup_ide_trash + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_INTEL, + .device = PCI_DEVICE_ID_INTEL_82801DB_9, + .hook = pci_fixup_ide_trash + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_VIA, + .device = PCI_DEVICE_ID_VIA_8363_0, + .hook = pci_fixup_via_northbridge_bug + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_VIA, + .device = PCI_DEVICE_ID_VIA_8622, + .hook = pci_fixup_via_northbridge_bug + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_VIA, + .device = PCI_DEVICE_ID_VIA_8361, + .hook = pci_fixup_via_northbridge_bug + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_VIA, + .device = PCI_DEVICE_ID_VIA_8367_0, + .hook = pci_fixup_via_northbridge_bug + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_NCR, + .device = PCI_DEVICE_ID_NCR_53C810, + .hook = pci_fixup_ncr53c810 + }, + { + .pass = PCI_FIXUP_HEADER, + .vendor = PCI_VENDOR_ID_INTEL, + .device = PCI_ANY_ID, + .hook = pci_fixup_transparent_bridge + }, + { .pass = 0 } }; --- diff/arch/i386/pci/pci.h 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/i386/pci/pci.h 2004-02-23 13:56:37.000000000 +0000 @@ -15,6 +15,9 @@ #define PCI_PROBE_BIOS 0x0001 #define PCI_PROBE_CONF1 0x0002 #define PCI_PROBE_CONF2 0x0004 +#define PCI_PROBE_MMCONF 0x0008 +#define PCI_PROBE_MASK 0x000f + #define PCI_NO_SORT 0x0100 #define PCI_BIOS_SORT 0x0200 #define PCI_NO_CHECKS 0x0400 --- diff/arch/ia64/Kconfig 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/ia64/Kconfig 2004-02-23 13:56:37.000000000 +0000 @@ -245,6 +245,12 @@ config IA64_MCA Say Y here to enable machine check support for IA-64. If you're unsure, answer Y. +config IA64_CYCLONE + bool "Support Cyclone(EXA) Time Source" + help + Say Y here to enable support for IBM EXA Cyclone time source. + If you're unsure, answer N. + config PM bool "Power Management support" depends on IA64_GENERIC || IA64_DIG || IA64_HP_ZX1 @@ -439,24 +445,6 @@ config PCI_DOMAINS source "drivers/pci/Kconfig" -config HOTPLUG - bool "Support for hot-pluggable devices" - help - Say Y here if you want to plug devices into your computer while - the system is running, and be able to use them quickly. In many - cases, the devices can likewise be unplugged at any time too. - - One well known example of this is PCMCIA- or PC-cards, credit-card - size devices such as network cards, modems or hard drives which are - plugged into slots found on all modern laptop computers. Another - example, used on modern desktops as well as laptops, is USB. - - Enable HOTPLUG and KMOD, and build a modular kernel. Get agent - software (at ) and install it. - Then your kernel will automatically call out to a user mode "policy - agent" (/sbin/hotplug) to load modules and set up software needed - to use devices as you hotplug them. - source "drivers/pci/hotplug/Kconfig" source "drivers/pcmcia/Kconfig" @@ -534,6 +522,13 @@ config BLK_DEV_RAM_SIZE depends on BLK_DEV_RAM default "4096" +config LOCKMETER + bool "Kernel lock metering" + depends on SMP + help + Say Y to enable kernel lock metering, which adds overhead to SMP locks, + but allows you to see various statistics using the lockstat command. + endmenu source "fs/Kconfig" @@ -661,7 +656,11 @@ config DEBUG_INFO debugging info resulting in a larger kernel image. Say Y here only if you plan to use gdb to debug the kernel. If you don't debug the kernel, you can say N. - + +config SYSVIPC_COMPAT + bool + depends on COMPAT && SYSVIPC + default y endmenu source "security/Kconfig" --- diff/arch/ia64/hp/sim/simeth.c 2003-08-20 14:16:08.000000000 +0100 +++ source/arch/ia64/hp/sim/simeth.c 2004-02-23 13:56:37.000000000 +0000 @@ -224,7 +224,7 @@ simeth_probe1(void) err = register_netdev(dev); if (err) { - kfree(dev); + free_netdev(dev); return err; } --- diff/arch/ia64/ia32/ia32_ioctl.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/ia64/ia32/ia32_ioctl.c 2004-02-23 13:56:37.000000000 +0000 @@ -8,6 +8,7 @@ */ #include /* argh, msdos_fs.h isn't self-contained... */ +#include #include "ia32priv.h" #define INCLUDES @@ -26,8 +27,6 @@ _ret; \ }) -asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg); - #define CODE #include "compat_ioctl.c" --- diff/arch/ia64/ia32/ia32_signal.c 2003-11-25 15:24:57.000000000 +0000 +++ source/arch/ia64/ia32/ia32_signal.c 2004-02-23 13:56:37.000000000 +0000 @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -550,9 +551,6 @@ sys32_rt_sigaction (int sig, struct siga } -extern asmlinkage long sys_rt_sigprocmask (int how, sigset_t *set, sigset_t *oset, - size_t sigsetsize); - asmlinkage long sys32_rt_sigprocmask (int how, compat_sigset_t *set, compat_sigset_t *oset, unsigned int sigsetsize) { @@ -584,8 +582,6 @@ asmlinkage long sys32_rt_sigtimedwait (compat_sigset_t *uthese, siginfo_t32 *uinfo, struct compat_timespec *uts, unsigned int sigsetsize) { - extern asmlinkage long sys_rt_sigtimedwait (const sigset_t *, siginfo_t *, - const struct timespec *, size_t); extern int copy_siginfo_to_user32 (siginfo_t32 *, siginfo_t *); mm_segment_t old_fs = get_fs(); struct timespec t; @@ -611,7 +607,6 @@ sys32_rt_sigtimedwait (compat_sigset_t * asmlinkage long sys32_rt_sigqueueinfo (int pid, int sig, siginfo_t32 *uinfo) { - extern asmlinkage long sys_rt_sigqueueinfo (int, int, siginfo_t *); extern int copy_siginfo_from_user32 (siginfo_t *to, siginfo_t32 *from); mm_segment_t old_fs = get_fs(); siginfo_t info; --- diff/arch/ia64/ia32/sys_ia32.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/ia64/ia32/sys_ia32.c 2004-02-23 13:56:37.000000000 +0000 @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -55,6 +56,7 @@ #include #include #include +#include #include "ia32priv.h" @@ -81,16 +83,9 @@ #define high2lowuid(uid) ((uid) > 65535 ? 65534 : (uid)) #define high2lowgid(gid) ((gid) > 65535 ? 65534 : (gid)) -extern asmlinkage long sys_execve (char *, char **, char **, struct pt_regs *); -extern asmlinkage long sys_mprotect (unsigned long, size_t, unsigned long); -extern asmlinkage long sys_munmap (unsigned long, size_t); extern unsigned long arch_get_unmapped_area (struct file *, unsigned long, unsigned long, unsigned long, unsigned long); -/* forward declaration: */ -asmlinkage long sys32_mprotect (unsigned int, unsigned int, int); -asmlinkage unsigned long sys_brk(unsigned long); - /* * Anything that modifies or inspects ia32 user virtual memory must hold this semaphore * while doing so. @@ -949,9 +944,6 @@ sys32_old_select (struct sel_arg_struct (struct compat_timeval *) A(a.tvp)); } -asmlinkage ssize_t sys_readv (unsigned long,const struct iovec *,unsigned long); -asmlinkage ssize_t sys_writev (unsigned long,const struct iovec *,unsigned long); - static struct iovec * get_compat_iovec (struct compat_iovec *iov32, struct iovec *iov_buf, u32 count, int type) { @@ -1031,143 +1023,6 @@ sys32_writev (int fd, struct compat_iove return ret; } -/* - * sys32_ipc() is the de-multiplexer for the SysV IPC calls in 32bit emulation.. - * - * This is really horribly ugly. - */ - -struct msgbuf32 { s32 mtype; char mtext[1]; }; - -struct ipc_perm32 { - key_t key; - compat_uid_t uid; - compat_gid_t gid; - compat_uid_t cuid; - compat_gid_t cgid; - compat_mode_t mode; - unsigned short seq; -}; - -struct ipc64_perm32 { - key_t key; - compat_uid32_t uid; - compat_gid32_t gid; - compat_uid32_t cuid; - compat_gid32_t cgid; - compat_mode_t mode; - unsigned short __pad1; - unsigned short seq; - unsigned short __pad2; - unsigned int unused1; - unsigned int unused2; -}; - -struct semid_ds32 { - struct ipc_perm32 sem_perm; /* permissions .. see ipc.h */ - compat_time_t sem_otime; /* last semop time */ - compat_time_t sem_ctime; /* last change time */ - u32 sem_base; /* ptr to first semaphore in array */ - u32 sem_pending; /* pending operations to be processed */ - u32 sem_pending_last; /* last pending operation */ - u32 undo; /* undo requests on this array */ - unsigned short sem_nsems; /* no. of semaphores in array */ -}; - -struct semid64_ds32 { - struct ipc64_perm32 sem_perm; - compat_time_t sem_otime; - unsigned int __unused1; - compat_time_t sem_ctime; - unsigned int __unused2; - unsigned int sem_nsems; - unsigned int __unused3; - unsigned int __unused4; -}; - -struct msqid_ds32 { - struct ipc_perm32 msg_perm; - u32 msg_first; - u32 msg_last; - compat_time_t msg_stime; - compat_time_t msg_rtime; - compat_time_t msg_ctime; - u32 wwait; - u32 rwait; - unsigned short msg_cbytes; - unsigned short msg_qnum; - unsigned short msg_qbytes; - compat_ipc_pid_t msg_lspid; - compat_ipc_pid_t msg_lrpid; -}; - -struct msqid64_ds32 { - struct ipc64_perm32 msg_perm; - compat_time_t msg_stime; - unsigned int __unused1; - compat_time_t msg_rtime; - unsigned int __unused2; - compat_time_t msg_ctime; - unsigned int __unused3; - unsigned int msg_cbytes; - unsigned int msg_qnum; - unsigned int msg_qbytes; - compat_pid_t msg_lspid; - compat_pid_t msg_lrpid; - unsigned int __unused4; - unsigned int __unused5; -}; - -struct shmid_ds32 { - struct ipc_perm32 shm_perm; - int shm_segsz; - compat_time_t shm_atime; - compat_time_t shm_dtime; - compat_time_t shm_ctime; - compat_ipc_pid_t shm_cpid; - compat_ipc_pid_t shm_lpid; - unsigned short shm_nattch; -}; - -struct shmid64_ds32 { - struct ipc64_perm32 shm_perm; - compat_size_t shm_segsz; - compat_time_t shm_atime; - unsigned int __unused1; - compat_time_t shm_dtime; - unsigned int __unused2; - compat_time_t shm_ctime; - unsigned int __unused3; - compat_pid_t shm_cpid; - compat_pid_t shm_lpid; - unsigned int shm_nattch; - unsigned int __unused4; - unsigned int __unused5; -}; - -struct shminfo64_32 { - unsigned int shmmax; - unsigned int shmmin; - unsigned int shmmni; - unsigned int shmseg; - unsigned int shmall; - unsigned int __unused1; - unsigned int __unused2; - unsigned int __unused3; - unsigned int __unused4; -}; - -struct shm_info32 { - int used_ids; - u32 shm_tot, shm_rss, shm_swp; - u32 swap_attempts, swap_successes; -}; - -struct ipc_kludge { - u32 msgp; - s32 msgtyp; -}; - #define SEMOP 1 #define SEMGET 2 #define SEMCTL 3 @@ -1181,454 +1036,6 @@ struct ipc_kludge { #define SHMGET 23 #define SHMCTL 24 -#define IPCOP_MASK(__x) (1UL << (__x)) - -static int -ipc_parse_version32 (int *cmd) -{ - if (*cmd & IPC_64) { - *cmd ^= IPC_64; - return IPC_64; - } else { - return IPC_OLD; - } -} - -static int -semctl32 (int first, int second, int third, void *uptr) -{ - union semun fourth; - u32 pad; - int err = 0, err2; - struct semid64_ds s; - mm_segment_t old_fs; - int version = ipc_parse_version32(&third); - - if (!uptr) - return -EINVAL; - if (get_user(pad, (u32 *)uptr)) - return -EFAULT; - if (third == SETVAL) - fourth.val = (int)pad; - else - fourth.__pad = (void *)A(pad); - switch (third) { - default: - err = -EINVAL; - break; - - case IPC_INFO: - case IPC_RMID: - case IPC_SET: - case SEM_INFO: - case GETVAL: - case GETPID: - case GETNCNT: - case GETZCNT: - case GETALL: - case SETVAL: - case SETALL: - err = sys_semctl(first, second, third, fourth); - break; - - case IPC_STAT: - case SEM_STAT: - fourth.__pad = &s; - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_semctl(first, second, third, fourth); - set_fs(old_fs); - - if (version == IPC_64) { - struct semid64_ds32 *usp64 = (struct semid64_ds32 *) A(pad); - - if (!access_ok(VERIFY_WRITE, usp64, sizeof(*usp64))) { - err = -EFAULT; - break; - } - err2 = __put_user(s.sem_perm.key, &usp64->sem_perm.key); - err2 |= __put_user(s.sem_perm.uid, &usp64->sem_perm.uid); - err2 |= __put_user(s.sem_perm.gid, &usp64->sem_perm.gid); - err2 |= __put_user(s.sem_perm.cuid, &usp64->sem_perm.cuid); - err2 |= __put_user(s.sem_perm.cgid, &usp64->sem_perm.cgid); - err2 |= __put_user(s.sem_perm.mode, &usp64->sem_perm.mode); - err2 |= __put_user(s.sem_perm.seq, &usp64->sem_perm.seq); - err2 |= __put_user(s.sem_otime, &usp64->sem_otime); - err2 |= __put_user(s.sem_ctime, &usp64->sem_ctime); - err2 |= __put_user(s.sem_nsems, &usp64->sem_nsems); - } else { - struct semid_ds32 *usp32 = (struct semid_ds32 *) A(pad); - - if (!access_ok(VERIFY_WRITE, usp32, sizeof(*usp32))) { - err = -EFAULT; - break; - } - err2 = __put_user(s.sem_perm.key, &usp32->sem_perm.key); - err2 |= __put_user(s.sem_perm.uid, &usp32->sem_perm.uid); - err2 |= __put_user(s.sem_perm.gid, &usp32->sem_perm.gid); - err2 |= __put_user(s.sem_perm.cuid, &usp32->sem_perm.cuid); - err2 |= __put_user(s.sem_perm.cgid, &usp32->sem_perm.cgid); - err2 |= __put_user(s.sem_perm.mode, &usp32->sem_perm.mode); - err2 |= __put_user(s.sem_perm.seq, &usp32->sem_perm.seq); - err2 |= __put_user(s.sem_otime, &usp32->sem_otime); - err2 |= __put_user(s.sem_ctime, &usp32->sem_ctime); - err2 |= __put_user(s.sem_nsems, &usp32->sem_nsems); - } - if (err2) - err = -EFAULT; - break; - } - return err; -} - -static int -do_sys32_msgsnd (int first, int second, int third, void *uptr) -{ - struct msgbuf *p = kmalloc(second + sizeof(struct msgbuf), GFP_USER); - struct msgbuf32 *up = (struct msgbuf32 *)uptr; - mm_segment_t old_fs; - int err; - - if (!p) - return -ENOMEM; - err = get_user(p->mtype, &up->mtype); - err |= copy_from_user(p->mtext, &up->mtext, second); - if (err) - goto out; - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_msgsnd(first, p, second, third); - set_fs(old_fs); - out: - kfree(p); - return err; -} - -static int -do_sys32_msgrcv (int first, int second, int msgtyp, int third, int version, void *uptr) -{ - struct msgbuf32 *up; - struct msgbuf *p; - mm_segment_t old_fs; - int err; - - if (!version) { - struct ipc_kludge *uipck = (struct ipc_kludge *)uptr; - struct ipc_kludge ipck; - - err = -EINVAL; - if (!uptr) - goto out; - err = -EFAULT; - if (copy_from_user(&ipck, uipck, sizeof(struct ipc_kludge))) - goto out; - uptr = (void *)A(ipck.msgp); - msgtyp = ipck.msgtyp; - } - err = -ENOMEM; - p = kmalloc(second + sizeof(struct msgbuf), GFP_USER); - if (!p) - goto out; - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_msgrcv(first, p, second, msgtyp, third); - set_fs(old_fs); - if (err < 0) - goto free_then_out; - up = (struct msgbuf32 *)uptr; - if (put_user(p->mtype, &up->mtype) || copy_to_user(&up->mtext, p->mtext, err)) - err = -EFAULT; -free_then_out: - kfree(p); -out: - return err; -} - -static int -msgctl32 (int first, int second, void *uptr) -{ - int err = -EINVAL, err2; - struct msqid64_ds m64; - struct msqid_ds32 *up32 = (struct msqid_ds32 *)uptr; - struct msqid64_ds32 *up64 = (struct msqid64_ds32 *)uptr; - mm_segment_t old_fs; - int version = ipc_parse_version32(&second); - - switch (second) { - case IPC_INFO: - case IPC_RMID: - case MSG_INFO: - err = sys_msgctl(first, second, (struct msqid_ds *)uptr); - break; - - case IPC_SET: - if (version == IPC_64) { - err = get_user(m64.msg_perm.uid, &up64->msg_perm.uid); - err |= get_user(m64.msg_perm.gid, &up64->msg_perm.gid); - err |= get_user(m64.msg_perm.mode, &up64->msg_perm.mode); - err |= get_user(m64.msg_qbytes, &up64->msg_qbytes); - } else { - err = get_user(m64.msg_perm.uid, &up32->msg_perm.uid); - err |= get_user(m64.msg_perm.gid, &up32->msg_perm.gid); - err |= get_user(m64.msg_perm.mode, &up32->msg_perm.mode); - err |= get_user(m64.msg_qbytes, &up32->msg_qbytes); - } - if (err) - break; - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_msgctl(first, second, (struct msqid_ds *)&m64); - set_fs(old_fs); - break; - - case IPC_STAT: - case MSG_STAT: - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_msgctl(first, second, (struct msqid_ds *)&m64); - set_fs(old_fs); - - if (version == IPC_64) { - if (!access_ok(VERIFY_WRITE, up64, sizeof(*up64))) { - err = -EFAULT; - break; - } - err2 = __put_user(m64.msg_perm.key, &up64->msg_perm.key); - err2 |= __put_user(m64.msg_perm.uid, &up64->msg_perm.uid); - err2 |= __put_user(m64.msg_perm.gid, &up64->msg_perm.gid); - err2 |= __put_user(m64.msg_perm.cuid, &up64->msg_perm.cuid); - err2 |= __put_user(m64.msg_perm.cgid, &up64->msg_perm.cgid); - err2 |= __put_user(m64.msg_perm.mode, &up64->msg_perm.mode); - err2 |= __put_user(m64.msg_perm.seq, &up64->msg_perm.seq); - err2 |= __put_user(m64.msg_stime, &up64->msg_stime); - err2 |= __put_user(m64.msg_rtime, &up64->msg_rtime); - err2 |= __put_user(m64.msg_ctime, &up64->msg_ctime); - err2 |= __put_user(m64.msg_cbytes, &up64->msg_cbytes); - err2 |= __put_user(m64.msg_qnum, &up64->msg_qnum); - err2 |= __put_user(m64.msg_qbytes, &up64->msg_qbytes); - err2 |= __put_user(m64.msg_lspid, &up64->msg_lspid); - err2 |= __put_user(m64.msg_lrpid, &up64->msg_lrpid); - if (err2) - err = -EFAULT; - } else { - if (!access_ok(VERIFY_WRITE, up32, sizeof(*up32))) { - err = -EFAULT; - break; - } - err2 = __put_user(m64.msg_perm.key, &up32->msg_perm.key); - err2 |= __put_user(m64.msg_perm.uid, &up32->msg_perm.uid); - err2 |= __put_user(m64.msg_perm.gid, &up32->msg_perm.gid); - err2 |= __put_user(m64.msg_perm.cuid, &up32->msg_perm.cuid); - err2 |= __put_user(m64.msg_perm.cgid, &up32->msg_perm.cgid); - err2 |= __put_user(m64.msg_perm.mode, &up32->msg_perm.mode); - err2 |= __put_user(m64.msg_perm.seq, &up32->msg_perm.seq); - err2 |= __put_user(m64.msg_stime, &up32->msg_stime); - err2 |= __put_user(m64.msg_rtime, &up32->msg_rtime); - err2 |= __put_user(m64.msg_ctime, &up32->msg_ctime); - err2 |= __put_user(m64.msg_cbytes, &up32->msg_cbytes); - err2 |= __put_user(m64.msg_qnum, &up32->msg_qnum); - err2 |= __put_user(m64.msg_qbytes, &up32->msg_qbytes); - err2 |= __put_user(m64.msg_lspid, &up32->msg_lspid); - err2 |= __put_user(m64.msg_lrpid, &up32->msg_lrpid); - if (err2) - err = -EFAULT; - } - break; - } - return err; -} - -static int -shmat32 (int first, int second, int third, int version, void *uptr) -{ - unsigned long raddr; - u32 *uaddr = (u32 *)A((u32)third); - int err; - - if (version == 1) - return -EINVAL; /* iBCS2 emulator entry point: unsupported */ - err = sys_shmat(first, uptr, second, &raddr); - if (err) - return err; - return put_user(raddr, uaddr); -} - -static int -shmctl32 (int first, int second, void *uptr) -{ - int err = -EFAULT, err2; - - struct shmid64_ds s64; - struct shmid_ds32 *up32 = (struct shmid_ds32 *)uptr; - struct shmid64_ds32 *up64 = (struct shmid64_ds32 *)uptr; - mm_segment_t old_fs; - struct shm_info32 *uip = (struct shm_info32 *)uptr; - struct shm_info si; - int version = ipc_parse_version32(&second); - struct shminfo64 smi; - struct shminfo *usi32 = (struct shminfo *) uptr; - struct shminfo64_32 *usi64 = (struct shminfo64_32 *) uptr; - - switch (second) { - case IPC_INFO: - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_shmctl(first, second, (struct shmid_ds *)&smi); - set_fs(old_fs); - - if (version == IPC_64) { - if (!access_ok(VERIFY_WRITE, usi64, sizeof(*usi64))) { - err = -EFAULT; - break; - } - err2 = __put_user(smi.shmmax, &usi64->shmmax); - err2 |= __put_user(smi.shmmin, &usi64->shmmin); - err2 |= __put_user(smi.shmmni, &usi64->shmmni); - err2 |= __put_user(smi.shmseg, &usi64->shmseg); - err2 |= __put_user(smi.shmall, &usi64->shmall); - } else { - if (!access_ok(VERIFY_WRITE, usi32, sizeof(*usi32))) { - err = -EFAULT; - break; - } - err2 = __put_user(smi.shmmax, &usi32->shmmax); - err2 |= __put_user(smi.shmmin, &usi32->shmmin); - err2 |= __put_user(smi.shmmni, &usi32->shmmni); - err2 |= __put_user(smi.shmseg, &usi32->shmseg); - err2 |= __put_user(smi.shmall, &usi32->shmall); - } - if (err2) - err = -EFAULT; - break; - - case IPC_RMID: - case SHM_LOCK: - case SHM_UNLOCK: - err = sys_shmctl(first, second, (struct shmid_ds *)uptr); - break; - - case IPC_SET: - if (version == IPC_64) { - err = get_user(s64.shm_perm.uid, &up64->shm_perm.uid); - err |= get_user(s64.shm_perm.gid, &up64->shm_perm.gid); - err |= get_user(s64.shm_perm.mode, &up64->shm_perm.mode); - } else { - err = get_user(s64.shm_perm.uid, &up32->shm_perm.uid); - err |= get_user(s64.shm_perm.gid, &up32->shm_perm.gid); - err |= get_user(s64.shm_perm.mode, &up32->shm_perm.mode); - } - if (err) - break; - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_shmctl(first, second, (struct shmid_ds *)&s64); - set_fs(old_fs); - break; - - case IPC_STAT: - case SHM_STAT: - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_shmctl(first, second, (struct shmid_ds *)&s64); - set_fs(old_fs); - if (err < 0) - break; - if (version == IPC_64) { - if (!access_ok(VERIFY_WRITE, up64, sizeof(*up64))) { - err = -EFAULT; - break; - } - err2 = __put_user(s64.shm_perm.key, &up64->shm_perm.key); - err2 |= __put_user(s64.shm_perm.uid, &up64->shm_perm.uid); - err2 |= __put_user(s64.shm_perm.gid, &up64->shm_perm.gid); - err2 |= __put_user(s64.shm_perm.cuid, &up64->shm_perm.cuid); - err2 |= __put_user(s64.shm_perm.cgid, &up64->shm_perm.cgid); - err2 |= __put_user(s64.shm_perm.mode, &up64->shm_perm.mode); - err2 |= __put_user(s64.shm_perm.seq, &up64->shm_perm.seq); - err2 |= __put_user(s64.shm_atime, &up64->shm_atime); - err2 |= __put_user(s64.shm_dtime, &up64->shm_dtime); - err2 |= __put_user(s64.shm_ctime, &up64->shm_ctime); - err2 |= __put_user(s64.shm_segsz, &up64->shm_segsz); - err2 |= __put_user(s64.shm_nattch, &up64->shm_nattch); - err2 |= __put_user(s64.shm_cpid, &up64->shm_cpid); - err2 |= __put_user(s64.shm_lpid, &up64->shm_lpid); - } else { - if (!access_ok(VERIFY_WRITE, up32, sizeof(*up32))) { - err = -EFAULT; - break; - } - err2 = __put_user(s64.shm_perm.key, &up32->shm_perm.key); - err2 |= __put_user(s64.shm_perm.uid, &up32->shm_perm.uid); - err2 |= __put_user(s64.shm_perm.gid, &up32->shm_perm.gid); - err2 |= __put_user(s64.shm_perm.cuid, &up32->shm_perm.cuid); - err2 |= __put_user(s64.shm_perm.cgid, &up32->shm_perm.cgid); - err2 |= __put_user(s64.shm_perm.mode, &up32->shm_perm.mode); - err2 |= __put_user(s64.shm_perm.seq, &up32->shm_perm.seq); - err2 |= __put_user(s64.shm_atime, &up32->shm_atime); - err2 |= __put_user(s64.shm_dtime, &up32->shm_dtime); - err2 |= __put_user(s64.shm_ctime, &up32->shm_ctime); - err2 |= __put_user(s64.shm_segsz, &up32->shm_segsz); - err2 |= __put_user(s64.shm_nattch, &up32->shm_nattch); - err2 |= __put_user(s64.shm_cpid, &up32->shm_cpid); - err2 |= __put_user(s64.shm_lpid, &up32->shm_lpid); - } - if (err2) - err = -EFAULT; - break; - - case SHM_INFO: - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_shmctl(first, second, (void *)&si); - set_fs(old_fs); - if (err < 0) - break; - - if (!access_ok(VERIFY_WRITE, uip, sizeof(*uip))) { - err = -EFAULT; - break; - } - err2 = __put_user(si.used_ids, &uip->used_ids); - err2 |= __put_user(si.shm_tot, &uip->shm_tot); - err2 |= __put_user(si.shm_rss, &uip->shm_rss); - err2 |= __put_user(si.shm_swp, &uip->shm_swp); - err2 |= __put_user(si.swap_attempts, &uip->swap_attempts); - err2 |= __put_user(si.swap_successes, &uip->swap_successes); - if (err2) - err = -EFAULT; - break; - - } - return err; -} - -extern int sem_ctls[]; -#define sc_semopm (sem_ctls[2]) - -static long -semtimedop32(int semid, struct sembuf *tsops, int nsops, - struct compat_timespec *timeout32) -{ - struct timespec t; - mm_segment_t oldfs; - long ret; - - /* parameter checking precedence should mirror sys_semtimedop() */ - if (nsops < 1 || semid < 0) - return -EINVAL; - if (nsops > sc_semopm) - return -E2BIG; - if (!access_ok(VERIFY_READ, tsops, nsops * sizeof(struct sembuf)) || - get_compat_timespec(&t, timeout32)) - return -EFAULT; - - oldfs = get_fs(); - set_fs(KERNEL_DS); - ret = sys_semtimedop(semid, tsops, nsops, &t); - set_fs(oldfs); - return ret; -} - asmlinkage long sys32_ipc(u32 call, int first, int second, int third, u32 ptr, u32 fifth) { @@ -1640,36 +1047,36 @@ sys32_ipc(u32 call, int first, int secon switch (call) { case SEMTIMEDOP: if (fifth) - return semtimedop32(first, (struct sembuf *)AA(ptr), - second, (struct compat_timespec *)AA(fifth)); + return compat_sys_semtimedop(first, compat_ptr(ptr), + second, compat_ptr(fifth)); /* else fall through for normal semop() */ case SEMOP: /* struct sembuf is the same on 32 and 64bit :)) */ - return sys_semtimedop(first, (struct sembuf *)AA(ptr), second, + return sys_semtimedop(first, compat_ptr(ptr), second, NULL); case SEMGET: return sys_semget(first, second, third); case SEMCTL: - return semctl32(first, second, third, (void *)AA(ptr)); + return compat_sys_semctl(first, second, third, compat_ptr(ptr)); case MSGSND: - return do_sys32_msgsnd(first, second, third, (void *)AA(ptr)); + return compat_sys_msgsnd(first, second, third, compat_ptr(ptr)); case MSGRCV: - return do_sys32_msgrcv(first, second, fifth, third, version, (void *)AA(ptr)); + return compat_sys_msgrcv(first, second, fifth, third, version, compat_ptr(ptr)); case MSGGET: return sys_msgget((key_t) first, second); case MSGCTL: - return msgctl32(first, second, (void *)AA(ptr)); + return compat_sys_msgctl(first, second, compat_ptr(ptr)); case SHMAT: - return shmat32(first, second, third, version, (void *)AA(ptr)); + return compat_sys_shmat(first, second, third, version, compat_ptr(ptr)); break; case SHMDT: - return sys_shmdt((char *)AA(ptr)); + return sys_shmdt(compat_ptr(ptr)); case SHMGET: return sys_shmget(first, second, third); case SHMCTL: - return shmctl32(first, second, (void *)AA(ptr)); + return compat_sys_shmctl(first, second, compat_ptr(ptr)); default: return -ENOSYS; @@ -2023,9 +1430,6 @@ restore_ia32_fpxstate (struct task_struc return 0; } -extern asmlinkage long sys_ptrace (long, pid_t, unsigned long, unsigned long, long, long, long, - long, long); - /* * Note that the IA32 version of `ptrace' calls the IA64 routine for * many of the requests. This will only work for requests that do @@ -2284,8 +1688,6 @@ sys32_pause (void) return -ERESTARTNOHAND; } -asmlinkage long sys_msync (unsigned long start, size_t len, int flags); - asmlinkage int sys32_msync (unsigned int start, unsigned int len, int flags) { @@ -2307,8 +1709,6 @@ struct sysctl32 { unsigned int __unused[4]; }; -extern asmlinkage long sys_sysctl(struct __sysctl_args *args); - asmlinkage long sys32_sysctl (struct sysctl32 *args) { @@ -2358,7 +1758,6 @@ sys32_sysctl (struct sysctl32 *args) asmlinkage long sys32_newuname (struct new_utsname *name) { - extern asmlinkage long sys_newuname(struct new_utsname * name); int ret = sys_newuname(name); if (!ret) @@ -2367,8 +1766,6 @@ sys32_newuname (struct new_utsname *name return ret; } -extern asmlinkage long sys_getresuid (uid_t *ruid, uid_t *euid, uid_t *suid); - asmlinkage long sys32_getresuid16 (u16 *ruid, u16 *euid, u16 *suid) { @@ -2385,8 +1782,6 @@ sys32_getresuid16 (u16 *ruid, u16 *euid, return ret; } -extern asmlinkage long sys_getresgid (gid_t *rgid, gid_t *egid, gid_t *sgid); - asmlinkage long sys32_getresgid16 (u16 *rgid, u16 *egid, u16 *sgid) { @@ -2407,65 +1802,100 @@ sys32_getresgid16 (u16 *rgid, u16 *egid, asmlinkage long sys32_lseek (unsigned int fd, int offset, unsigned int whence) { - extern off_t sys_lseek (unsigned int fd, off_t offset, unsigned int origin); - /* Sign-extension of "offset" is important here... */ return sys_lseek(fd, offset, whence); } -extern asmlinkage long sys_getgroups (int gidsetsize, gid_t *grouplist); +static int +groups16_to_user(short *grouplist, struct group_info *group_info) +{ + int i; + short group; + + for (i = 0; i < group_info->ngroups; i++) { + group = (short)GROUP_AT(group_info, i); + if (put_user(group, grouplist+i)) + return -EFAULT; + } + + return 0; +} + +static int +groups16_from_user(struct group_info *group_info, short *grouplist) +{ + int i; + short group; + + for (i = 0; i < group_info->ngroups; i++) { + if (get_user(group, grouplist+i)) + return -EFAULT; + GROUP_AT(group_info, i) = (gid_t)group; + } + + return 0; +} asmlinkage long sys32_getgroups16 (int gidsetsize, short *grouplist) { - mm_segment_t old_fs = get_fs(); - gid_t gl[NGROUPS]; - int ret, i; + int i; - set_fs(KERNEL_DS); - ret = sys_getgroups(gidsetsize, gl); - set_fs(old_fs); + if (gidsetsize < 0) + return -EINVAL; - if (gidsetsize && ret > 0 && ret <= NGROUPS) - for (i = 0; i < ret; i++, grouplist++) - if (put_user(gl[i], grouplist)) - return -EFAULT; - return ret; + get_group_info(current->group_info); + i = current->group_info->ngroups; + if (gidsetsize) { + if (i > gidsetsize) { + i = -EINVAL; + goto out; + } + if (groups16_to_user(grouplist, current->group_info)) { + i = -EFAULT; + goto out; + } + } +out: + put_group_info(current->group_info); + return i; } -extern asmlinkage long sys_setgroups (int gidsetsize, gid_t *grouplist); - asmlinkage long sys32_setgroups16 (int gidsetsize, short *grouplist) { - mm_segment_t old_fs = get_fs(); - gid_t gl[NGROUPS]; - int ret, i; + struct group_info *group_info; + int retval; - if ((unsigned) gidsetsize > NGROUPS) + if (!capable(CAP_SETGID)) + return -EPERM; + if ((unsigned)gidsetsize > NGROUPS_MAX) return -EINVAL; - for (i = 0; i < gidsetsize; i++, grouplist++) - if (get_user(gl[i], grouplist)) - return -EFAULT; - set_fs(KERNEL_DS); - ret = sys_setgroups(gidsetsize, gl); - set_fs(old_fs); - return ret; + + group_info = groups_alloc(gidsetsize); + if (!group_info) + return -ENOMEM; + retval = groups16_from_user(group_info, grouplist); + if (retval) { + put_group_info(group_info); + return retval; + } + + retval = set_current_groups(group_info); + put_group_info(group_info); + + return retval; } asmlinkage long sys32_truncate64 (unsigned int path, unsigned int len_lo, unsigned int len_hi) { - extern asmlinkage long sys_truncate (const char *path, unsigned long length); - return sys_truncate((const char *) A(path), ((unsigned long) len_hi << 32) | len_lo); } asmlinkage long sys32_ftruncate64 (int fd, unsigned int len_lo, unsigned int len_hi) { - extern asmlinkage long sys_ftruncate (int fd, unsigned long length); - return sys_ftruncate(fd, ((unsigned long) len_hi << 32) | len_lo); } @@ -2554,7 +1984,6 @@ struct sysinfo32 { asmlinkage long sys32_sysinfo (struct sysinfo32 *info) { - extern asmlinkage long sys_sysinfo (struct sysinfo *); struct sysinfo s; long ret, err; int bitcount = 0; @@ -2606,7 +2035,6 @@ sys32_sysinfo (struct sysinfo32 *info) asmlinkage long sys32_sched_rr_get_interval (pid_t pid, struct compat_timespec *interval) { - extern asmlinkage long sys_sched_rr_get_interval (pid_t, struct timespec *); mm_segment_t old_fs = get_fs(); struct timespec t; long ret; @@ -2622,21 +2050,18 @@ sys32_sched_rr_get_interval (pid_t pid, asmlinkage long sys32_pread (unsigned int fd, void *buf, unsigned int count, u32 pos_lo, u32 pos_hi) { - extern asmlinkage long sys_pread64 (unsigned int, char *, size_t, loff_t); return sys_pread64(fd, buf, count, ((unsigned long) pos_hi << 32) | pos_lo); } asmlinkage long sys32_pwrite (unsigned int fd, void *buf, unsigned int count, u32 pos_lo, u32 pos_hi) { - extern asmlinkage long sys_pwrite64 (unsigned int, const char *, size_t, loff_t); return sys_pwrite64(fd, buf, count, ((unsigned long) pos_hi << 32) | pos_lo); } asmlinkage long sys32_sendfile (int out_fd, int in_fd, int *offset, unsigned int count) { - extern asmlinkage long sys_sendfile (int, int, off_t *, size_t); mm_segment_t old_fs = get_fs(); long ret; off_t of; @@ -2657,7 +2082,6 @@ sys32_sendfile (int out_fd, int in_fd, i asmlinkage long sys32_personality (unsigned int personality) { - extern asmlinkage long sys_personality (unsigned long); long ret; if (current->personality == PER_LINUX32 && personality == PER_LINUX) @@ -2949,8 +2373,6 @@ sys32_timer_create(u32 clock, struct sig return err; } -extern long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice); - long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high, __u32 len_low, __u32 len_high, int advice) { @@ -3049,9 +2471,6 @@ copy_mount_stuff_to_kernel(const void *u return 0; } -extern asmlinkage long sys_mount(char * dev_name, char * dir_name, char * type, - unsigned long new_flags, void *data); - #define SMBFS_NAME "smbfs" #define NCPFS_NAME "ncpfs" @@ -3116,8 +2535,6 @@ sys32_mount(char *dev_name, char *dir_na } } -extern asmlinkage long sys_setreuid(uid_t ruid, uid_t euid); - asmlinkage long sys32_setreuid(compat_uid_t ruid, compat_uid_t euid) { uid_t sruid, seuid; @@ -3127,8 +2544,6 @@ asmlinkage long sys32_setreuid(compat_ui return sys_setreuid(sruid, seuid); } -extern asmlinkage long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid); - asmlinkage long sys32_setresuid(compat_uid_t ruid, compat_uid_t euid, compat_uid_t suid) @@ -3141,8 +2556,6 @@ sys32_setresuid(compat_uid_t ruid, compa return sys_setresuid(sruid, seuid, ssuid); } -extern asmlinkage long sys_setregid(gid_t rgid, gid_t egid); - asmlinkage long sys32_setregid(compat_gid_t rgid, compat_gid_t egid) { @@ -3153,8 +2566,6 @@ sys32_setregid(compat_gid_t rgid, compat return sys_setregid(srgid, segid); } -extern asmlinkage long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid); - asmlinkage long sys32_setresgid(compat_gid_t rgid, compat_gid_t egid, compat_gid_t sgid) @@ -3284,8 +2695,6 @@ nfs_getfh32_res_trans(union nfsctl_res * return err; } -extern asmlinkage long sys_nfsservctl(int cmd, void *arg, void *resp); - int asmlinkage sys32_nfsservctl(int cmd, struct nfsctl_arg32 *arg32, union nfsctl_res32 *res32) { --- diff/arch/ia64/kernel/Makefile 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/ia64/kernel/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -18,6 +18,7 @@ obj-$(CONFIG_IOSAPIC) += iosapic.o obj-$(CONFIG_MODULES) += module.o obj-$(CONFIG_SMP) += smp.o smpboot.o obj-$(CONFIG_PERFMON) += perfmon_default_smpl.o +obj-$(CONFIG_IA64_CYCLONE) += cyclone.o # The gate DSO image is built using a special linker script. targets += gate.so gate-syms.o --- diff/arch/ia64/kernel/acpi.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/kernel/acpi.c 2004-02-23 13:56:37.000000000 +0000 @@ -49,6 +49,8 @@ #include #include #include +#include +#include #define PREFIX "ACPI: " @@ -304,6 +306,22 @@ acpi_parse_nmi_src (acpi_table_entry_hea return 0; } +/* Hook from generic ACPI tables.c */ +void __init acpi_madt_oem_check(char *oem_id, char *oem_table_id) +{ + if (!strncmp(oem_id, "IBM", 3) && + (!strncmp(oem_table_id, "SERMOW", 6))){ + + /* Unfortunatly ITC_DRIFT is not yet part of the + * official SAL spec, so the ITC_DRIFT bit is not + * set by the BIOS on this hardware. + */ + sal_platform_features |= IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT; + + /*Start cyclone clock*/ + cyclone_setup(0); + } +} static int __init acpi_parse_madt (unsigned long phys_addr, unsigned long size) @@ -327,6 +345,10 @@ acpi_parse_madt (unsigned long phys_addr ipi_base_addr = (unsigned long) ioremap(acpi_madt->lapic_address, 0); printk(KERN_INFO PREFIX "Local APIC address 0x%lx\n", ipi_base_addr); + + acpi_madt_oem_check(acpi_madt->header.oem_id, + acpi_madt->header.oem_table_id); + return 0; } --- diff/arch/ia64/kernel/irq.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/kernel/irq.c 2004-02-23 13:56:37.000000000 +0000 @@ -940,7 +940,7 @@ void set_irq_affinity_info (unsigned int static int irq_affinity_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, irq_affinity[(long)data]); + int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); @@ -1005,7 +1005,7 @@ static int irq_affinity_write_proc (stru static int prof_cpu_mask_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, *(cpumask_t *)data); + int len = cpumask_scnprintf(page, count, *(cpumask_t *)data); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); --- diff/arch/ia64/kernel/sys_ia64.c 2003-09-17 12:28:01.000000000 +0100 +++ source/arch/ia64/kernel/sys_ia64.c 2004-02-23 13:56:37.000000000 +0000 @@ -15,6 +15,7 @@ #include /* doh, must come after sched.h... */ #include #include +#include #include #include @@ -74,7 +75,6 @@ arch_get_unmapped_area (struct file *fil asmlinkage long ia64_getpriority (int which, int who) { - extern long sys_getpriority (int, int); long prio; prio = sys_getpriority(which, who); --- diff/arch/ia64/kernel/unwind.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/kernel/unwind.c 2004-02-23 13:56:37.000000000 +0000 @@ -1416,7 +1416,7 @@ compile_reg (struct unw_state_record *sr case UNW_WHERE_FR: if (rval <= 5) - val = unw.preg_index[UNW_REG_F2 + (rval - 1)]; + val = unw.preg_index[UNW_REG_F2 + (rval - 2)]; else if (rval >= 16 && rval <= 31) val = unw.preg_index[UNW_REG_F16 + (rval - 16)]; else { --- diff/arch/ia64/lib/dec_and_lock.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/ia64/lib/dec_and_lock.c 2004-02-23 13:56:37.000000000 +0000 @@ -13,6 +13,7 @@ #include #include +#ifndef CONFIG_LOCKMETER /* * Decrement REFCOUNT and if the count reaches zero, acquire the spinlock. Both of these * operations have to be done atomically, so that the count doesn't drop to zero without @@ -40,3 +41,4 @@ atomic_dec_and_lock (atomic_t *refcount, } EXPORT_SYMBOL(atomic_dec_and_lock); +#endif --- diff/arch/ia64/pci/pci.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/ia64/pci/pci.c 2004-02-23 13:56:37.000000000 +0000 @@ -55,8 +55,11 @@ struct pci_fixup pcibios_fixups[1]; #define PCI_SAL_ADDRESS(seg, bus, devfn, reg) \ ((u64)(seg << 24) | (u64)(bus << 16) | \ - (u64)(devfn << 8) | (u64)(reg)) + (u64)(devfn << 8) | (u64)(reg)), 0 +#define PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg) \ + ((u64)(seg << 28) | (u64)(bus << 20) | \ + (u64)(devfn << 12) | (u64)(reg)), 1 static int pci_sal_read (int seg, int bus, int devfn, int reg, int len, u32 *value) @@ -64,10 +67,14 @@ pci_sal_read (int seg, int bus, int devf int result = 0; u64 data = 0; - if (!value || (seg > 255) || (bus > 255) || (devfn > 255) || (reg > 255)) + if (!value || (seg > 65535) || (bus > 255) || (devfn > 255) || (reg > 4095)) return -EINVAL; - result = ia64_sal_pci_config_read(PCI_SAL_ADDRESS(seg, bus, devfn, reg), len, &data); + if ((seg < 256) && (reg < 256)) { + result = ia64_sal_pci_config_read(PCI_SAL_ADDRESS(seg, bus, devfn, reg), len, &data); + } else { + result = ia64_sal_pci_config_read(PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg), len, &data); + } *value = (u32) data; @@ -77,13 +84,17 @@ pci_sal_read (int seg, int bus, int devf static int pci_sal_write (int seg, int bus, int devfn, int reg, int len, u32 value) { - if ((seg > 255) || (bus > 255) || (devfn > 255) || (reg > 255)) + if ((seg > 65535) || (bus > 255) || (devfn > 255) || (reg > 4095)) return -EINVAL; - return ia64_sal_pci_config_write(PCI_SAL_ADDRESS(seg, bus, devfn, reg), len, value); + if ((seg < 256) && (reg < 256)) { + return ia64_sal_pci_config_write(PCI_SAL_ADDRESS(seg, bus, devfn, reg), len, value); + } else { + return ia64_sal_pci_config_write(PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg), len, value); + } } -struct pci_raw_ops pci_sal_ops = { +static struct pci_raw_ops pci_sal_ops = { .read = pci_sal_read, .write = pci_sal_write }; @@ -153,8 +164,10 @@ alloc_resource (char *name, struct resou res->end = end; res->flags = flags; - if (insert_resource(root, res)) + if (insert_resource(root, res)) { + kfree(res); return -EBUSY; + } return 0; } --- diff/arch/ia64/sn/io/drivers/ioconfig_bus.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/ia64/sn/io/drivers/ioconfig_bus.c 2004-02-23 13:56:37.000000000 +0000 @@ -16,6 +16,7 @@ #include +#include #include #include #include --- diff/arch/ia64/sn/io/io.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/io/io.c 2004-02-23 13:56:37.000000000 +0000 @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include --- diff/arch/ia64/sn/io/machvec/pci_bus_cvlink.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/io/machvec/pci_bus_cvlink.c 2004-02-23 13:56:37.000000000 +0000 @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -28,7 +27,7 @@ vertex_hdl_t devfn_to_vertex(unsigned ch extern void register_pcibr_intr(int irq, pcibr_intr_t intr); -static void sn_dma_flush_init(unsigned long start, +static struct sn_flush_device_list *sn_dma_flush_init(unsigned long start, unsigned long end, int idx, int pin, int slot); extern int cbrick_type_get_nasid(nasid_t); @@ -54,7 +53,7 @@ set_pci_provider(struct sn_device_sysdat } /* - * pci_bus_cvlink_init() - To be called once during initialization before + * pci_bus_cvlink_init() - To be called once during initialization before * SGI IO Infrastructure init is called. */ int @@ -74,7 +73,7 @@ pci_bus_cvlink_init(void) } /* - * pci_bus_to_vertex() - Given a logical Linux Bus Number returns the associated + * pci_bus_to_vertex() - Given a logical Linux Bus Number returns the associated * pci bus vertex from the SGI IO Infrastructure. */ static inline vertex_hdl_t @@ -92,7 +91,7 @@ pci_bus_to_vertex(unsigned char busnum) } /* - * devfn_to_vertex() - returns the vertex of the device given the bus, slot, + * devfn_to_vertex() - returns the vertex of the device given the bus, slot, * and function numbers. */ vertex_hdl_t @@ -133,8 +132,8 @@ devfn_to_vertex(unsigned char busnum, un * ../pci/1, ../pci/2 .. */ if (func == 0) { - sprintf(name, "%d", slot); - if (hwgraph_traverse(pci_bus, name, &device_vertex) == + sprintf(name, "%d", slot); + if (hwgraph_traverse(pci_bus, name, &device_vertex) == GRAPH_SUCCESS) { if (device_vertex) { return(device_vertex); @@ -156,19 +155,248 @@ devfn_to_vertex(unsigned char busnum, un return(device_vertex); } +/* + * sn_alloc_pci_sysdata() - This routine allocates a pci controller + * which is expected as the pci_dev and pci_bus sysdata by the Linux + * PCI infrastructure. + */ +static struct pci_controller * +sn_alloc_pci_sysdata(void) +{ + struct pci_controller *pci_sysdata; + + pci_sysdata = kmalloc(sizeof(*pci_sysdata), GFP_KERNEL); + if (!pci_sysdata) + return NULL; + + memset(pci_sysdata, 0, sizeof(*pci_sysdata)); + return pci_sysdata; +} + +/* + * sn_pci_fixup_bus() - This routine sets up a bus's resources + * consistent with the Linux PCI abstraction layer. + */ +static int __init +sn_pci_fixup_bus(struct pci_bus *bus) +{ + struct pci_controller *pci_sysdata; + struct sn_widget_sysdata *widget_sysdata; + + pci_sysdata = sn_alloc_pci_sysdata(); + if (!pci_sysdata) { + printk(KERN_WARNING "sn_pci_fixup_bus(): Unable to " + "allocate memory for pci_sysdata\n"); + return -ENOMEM; + } + widget_sysdata = kmalloc(sizeof(struct sn_widget_sysdata), + GFP_KERNEL); + if (!widget_sysdata) { + printk(KERN_WARNING "sn_pci_fixup_bus(): Unable to " + "allocate memory for widget_sysdata\n"); + kfree(pci_sysdata); + return -ENOMEM; + } + + widget_sysdata->vhdl = pci_bus_to_vertex(bus->number); + pci_sysdata->platform_data = (void *)widget_sysdata; + bus->sysdata = pci_sysdata; + return 0; +} + + +/* + * sn_pci_fixup_slot() - This routine sets up a slot's resources + * consistent with the Linux PCI abstraction layer. Resources acquired + * from our PCI provider include PIO maps to BAR space and interrupt + * objects. + */ +static int +sn_pci_fixup_slot(struct pci_dev *dev) +{ + extern int bit_pos_to_irq(int); + unsigned int irq; + int idx; + u16 cmd; + vertex_hdl_t vhdl; + unsigned long size; + struct pci_controller *pci_sysdata; + struct sn_device_sysdata *device_sysdata; + pciio_intr_line_t lines = 0; + vertex_hdl_t device_vertex; + pciio_provider_t *pci_provider; + pciio_intr_t intr_handle; + + /* Allocate a controller structure */ + pci_sysdata = sn_alloc_pci_sysdata(); + if (!pci_sysdata) { + printk(KERN_WARNING "sn_pci_fixup_slot: Unable to " + "allocate memory for pci_sysdata\n"); + return -ENOMEM; + } + + /* Set the device vertex */ + device_sysdata = kmalloc(sizeof(struct sn_device_sysdata), GFP_KERNEL); + if (!device_sysdata) { + printk(KERN_WARNING "sn_pci_fixup_slot: Unable to " + "allocate memory for device_sysdata\n"); + kfree(pci_sysdata); + return -ENOMEM; + } + + device_sysdata->vhdl = devfn_to_vertex(dev->bus->number, dev->devfn); + pci_sysdata->platform_data = (void *) device_sysdata; + dev->sysdata = pci_sysdata; + set_pci_provider(device_sysdata); + + pci_read_config_word(dev, PCI_COMMAND, &cmd); + + /* + * Set the resources address correctly. The assumption here + * is that the addresses in the resource structure has been + * read from the card and it was set in the card by our + * Infrastructure. NOTE: PIC and TIOCP don't have big-window + * upport for PCI I/O space. So by mapping the I/O space + * first we will attempt to use Device(x) registers for I/O + * BARs (which can't use big windows like MEM BARs can). + */ + vhdl = device_sysdata->vhdl; + + /* Allocate the IORESOURCE_IO space first */ + for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) { + unsigned long start, end, addr; + + device_sysdata->pio_map[idx] = NULL; + + if (!(dev->resource[idx].flags & IORESOURCE_IO)) + continue; + + start = dev->resource[idx].start; + end = dev->resource[idx].end; + size = end - start; + if (!size) + continue; + + addr = (unsigned long)pciio_pio_addr(vhdl, 0, + PCIIO_SPACE_WIN(idx), 0, size, + &device_sysdata->pio_map[idx], 0); + + if (!addr) { + dev->resource[idx].start = 0; + dev->resource[idx].end = 0; + printk("sn_pci_fixup(): pio map failure for " + "%s bar%d\n", dev->slot_name, idx); + } else { + addr |= __IA64_UNCACHED_OFFSET; + dev->resource[idx].start = addr; + dev->resource[idx].end = addr + size; + } + + if (dev->resource[idx].flags & IORESOURCE_IO) + cmd |= PCI_COMMAND_IO; + } + + /* Allocate the IORESOURCE_MEM space next */ + for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) { + unsigned long start, end, addr; + + if ((dev->resource[idx].flags & IORESOURCE_IO)) + continue; + + start = dev->resource[idx].start; + end = dev->resource[idx].end; + size = end - start; + if (!size) + continue; + + addr = (unsigned long)pciio_pio_addr(vhdl, 0, + PCIIO_SPACE_WIN(idx), 0, size, + &device_sysdata->pio_map[idx], 0); + + if (!addr) { + dev->resource[idx].start = 0; + dev->resource[idx].end = 0; + printk("sn_pci_fixup(): pio map failure for " + "%s bar%d\n", dev->slot_name, idx); + } else { + addr |= __IA64_UNCACHED_OFFSET; + dev->resource[idx].start = addr; + dev->resource[idx].end = addr + size; + } + + if (dev->resource[idx].flags & IORESOURCE_MEM) + cmd |= PCI_COMMAND_MEMORY; + } + + /* + * Update the Command Word on the Card. + */ + cmd |= PCI_COMMAND_MASTER; /* If the device doesn't support */ + /* bit gets dropped .. no harm */ + pci_write_config_word(dev, PCI_COMMAND, cmd); + + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, (unsigned char *)&lines); + device_vertex = device_sysdata->vhdl; + pci_provider = device_sysdata->pci_provider; + device_sysdata->intr_handle = NULL; + + if (!lines) + return 0; + + irqpdaindr->curr = dev; + + intr_handle = (pci_provider->intr_alloc)(device_vertex, NULL, lines, device_vertex); + if (intr_handle == NULL) { + printk(KERN_WARNING "sn_pci_fixup: pcibr_intr_alloc() failed\n"); + kfree(pci_sysdata); + kfree(device_sysdata); + return -ENOMEM; + } + + device_sysdata->intr_handle = intr_handle; + irq = intr_handle->pi_irq; + irqpdaindr->device_dev[irq] = dev; + (pci_provider->intr_connect)(intr_handle, (intr_func_t)0, (intr_arg_t)0); + dev->irq = irq; + + register_pcibr_intr(irq, (pcibr_intr_t)intr_handle); + + for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) { + int ibits = ((pcibr_intr_t)intr_handle)->bi_ibits; + int i; + + size = dev->resource[idx].end - + dev->resource[idx].start; + if (size == 0) continue; + + for (i=0; i<8; i++) { + if (ibits & (1 << i) ) { + extern pcibr_info_t pcibr_info_get(vertex_hdl_t); + device_sysdata->dma_flush_list = + sn_dma_flush_init(dev->resource[idx].start, + dev->resource[idx].end, + idx, + i, + PCIBR_INFO_SLOT_GET_EXT(pcibr_info_get(device_sysdata->vhdl))); + } + } + } + return 0; +} + struct sn_flush_nasid_entry flush_nasid_list[MAX_NASIDS]; /* Initialize the data structures for flushing write buffers after a PIO read. - * The theory is: + * The theory is: * Take an unused int. pin and associate it with a pin that is in use. * After a PIO read, force an interrupt on the unused pin, forcing a write buffer flush - * on the in use pin. This will prevent the race condition between PIO read responses and + * on the in use pin. This will prevent the race condition between PIO read responses and * DMA writes. */ -static void +static struct sn_flush_device_list * sn_dma_flush_init(unsigned long start, unsigned long end, int idx, int pin, int slot) { - nasid_t nasid; + nasid_t nasid; unsigned long dnasid; int wid_num; int bus; @@ -187,7 +415,7 @@ sn_dma_flush_init(unsigned long start, u sizeof(struct sn_flush_device_list *), GFP_KERNEL); if (!flush_nasid_list[nasid].widget_p) { printk(KERN_WARNING "sn_dma_flush_init: Cannot allocate memory for nasid list\n"); - return; + return NULL; } memset(flush_nasid_list[nasid].widget_p, 0, (HUB_WIDGET_ID_MAX+1) * sizeof(struct sn_flush_device_list *)); } @@ -197,8 +425,8 @@ sn_dma_flush_init(unsigned long start, u itte = HUB_L(IIO_ITTE_GET(nasid, itte_index)); flush_nasid_list[nasid].iio_itte[bwin] = itte; - wid_num = (itte >> IIO_ITTE_WIDGET_SHIFT) & - IIO_ITTE_WIDGET_MASK; + wid_num = (itte >> IIO_ITTE_WIDGET_SHIFT) + & IIO_ITTE_WIDGET_MASK; bus = itte & IIO_ITTE_OFFSET_MASK; if (bus == 0x4 || bus == 0x8) { bus = 0; @@ -211,16 +439,16 @@ sn_dma_flush_init(unsigned long start, u * because these are the IOC4 slots and we don't flush them. */ if (isIO9(nasid) && bus == 0 && (slot == 1 || slot == 4)) { - return; + return NULL; } if (flush_nasid_list[nasid].widget_p[wid_num] == NULL) { flush_nasid_list[nasid].widget_p[wid_num] = (struct sn_flush_device_list *)kmalloc( DEV_PER_WIDGET * sizeof (struct sn_flush_device_list), GFP_KERNEL); if (!flush_nasid_list[nasid].widget_p[wid_num]) { printk(KERN_WARNING "sn_dma_flush_init: Cannot allocate memory for nasid sub-list\n"); - return; + return NULL; } - memset(flush_nasid_list[nasid].widget_p[wid_num], 0, + memset(flush_nasid_list[nasid].widget_p[wid_num], 0, DEV_PER_WIDGET * sizeof (struct sn_flush_device_list)); p = &flush_nasid_list[nasid].widget_p[wid_num][0]; for (i=0; iflush_addr)); pcireg_bridge_intr_addr_set(b, 6, ((virt_to_phys(&p->flush_addr) & 0xfffffffff) | - (dnasid << 36) | (0xfUL << 48))); + (dnasid << 36) | (0xfUL << 48))); } else if (pin == 2) { /* 12160 SCSI device in IO9 */ p->force_int_addr = (unsigned long)pcireg_bridge_force_always_addr_get(b, 4); pcireg_bridge_intr_device_bit_set(b, (2<<12)); dnasid = NASID_GET(virt_to_phys(&p->flush_addr)); pcireg_bridge_intr_addr_set(b, 4, ((virt_to_phys(&p->flush_addr) & 0xfffffffff) | - (dnasid << 36) | (0xfUL << 48))); + (dnasid << 36) | (0xfUL << 48))); } else { /* slot == 6 */ p->force_int_addr = (unsigned long)pcireg_bridge_force_always_addr_get(b, 7); pcireg_bridge_intr_device_bit_set(b, (5<<21)); dnasid = NASID_GET(virt_to_phys(&p->flush_addr)); pcireg_bridge_intr_addr_set(b, 7, ((virt_to_phys(&p->flush_addr) & 0xfffffffff) | - (dnasid << 36) | (0xfUL << 48))); + (dnasid << 36) | (0xfUL << 48))); } } else { p->force_int_addr = (unsigned long)pcireg_bridge_force_always_addr_get(b, (pin +2)); @@ -301,239 +529,13 @@ sn_dma_flush_init(unsigned long start, u dnasid = NASID_GET(virt_to_phys(&p->flush_addr)); pcireg_bridge_intr_addr_set(b, (pin + 2), ((virt_to_phys(&p->flush_addr) & 0xfffffffff) | - (dnasid << 36) | (0xfUL << 48))); - } -} - -/* - * sn_pci_fixup() - This routine is called when platform_pci_fixup() is - * invoked at the end of pcibios_init() to link the Linux pci - * infrastructure to SGI IO Infrasturcture - ia64/kernel/pci.c - * - * Other platform specific fixup can also be done here. - */ -static void __init -sn_pci_fixup(int arg) -{ - struct list_head *ln; - struct pci_bus *pci_bus = NULL; - struct pci_dev *device_dev = NULL; - struct sn_widget_sysdata *widget_sysdata; - struct sn_device_sysdata *device_sysdata; - pcibr_intr_t intr_handle; - pciio_provider_t *pci_provider; - vertex_hdl_t device_vertex; - pciio_intr_line_t lines = 0; - extern int numnodes; - int cnode; - - if (arg == 0) { -#ifdef CONFIG_PROC_FS - extern void register_sn_procfs(void); -#endif - extern void sgi_master_io_infr_init(void); - extern void sn_init_cpei_timer(void); - - sgi_master_io_infr_init(); - - for (cnode = 0; cnode < numnodes; cnode++) { - extern void intr_init_vecblk(cnodeid_t); - intr_init_vecblk(cnode); - } - - sn_init_cpei_timer(); - -#ifdef CONFIG_PROC_FS - register_sn_procfs(); -#endif - return; - } - - - done_probing = 1; - - /* - * Initialize the pci bus vertex in the pci_bus struct. - */ - for( ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) { - pci_bus = pci_bus_b(ln); - widget_sysdata = kmalloc(sizeof(struct sn_widget_sysdata), - GFP_KERNEL); - if (!widget_sysdata) { - printk(KERN_WARNING "sn_pci_fixup(): Unable to " - "allocate memory for widget_sysdata\n"); - return; - } - widget_sysdata->vhdl = pci_bus_to_vertex(pci_bus->number); - pci_bus->sysdata = (void *)widget_sysdata; - } - - /* - * set the root start and end so that drivers calling check_region() - * won't see a conflict - */ - -#ifdef CONFIG_IA64_SGI_SN_SIM - if (! IS_RUNNING_ON_SIMULATOR()) { - ioport_resource.start = 0xc000000000000000; - ioport_resource.end = 0xcfffffffffffffff; - } -#endif - - /* - * Set the root start and end for Mem Resource. - */ - iomem_resource.start = 0; - iomem_resource.end = 0xffffffffffffffff; - - /* - * Initialize the device vertex in the pci_dev struct. - */ - while ((device_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, device_dev)) != NULL) { - unsigned int irq; - int idx; - u16 cmd; - vertex_hdl_t vhdl; - unsigned long size; - extern int bit_pos_to_irq(int); - - /* Set the device vertex */ - - device_sysdata = kmalloc(sizeof(struct sn_device_sysdata), - GFP_KERNEL); - if (!device_sysdata) { - printk(KERN_WARNING "sn_pci_fixup: Cannot allocate memory for device sysdata\n"); - return; - } - - device_sysdata->vhdl = devfn_to_vertex(device_dev->bus->number, device_dev->devfn); - device_dev->sysdata = (void *) device_sysdata; - set_pci_provider(device_sysdata); - - pci_read_config_word(device_dev, PCI_COMMAND, &cmd); - - /* - * Set the resources address correctly. The assumption here - * is that the addresses in the resource structure has been - * read from the card and it was set in the card by our - * Infrastructure .. - */ - vhdl = device_sysdata->vhdl; - /* Allocate the IORESOURCE_IO space first */ - for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) { - unsigned long start, end, addr; - - if (!(device_dev->resource[idx].flags & IORESOURCE_IO)) - continue; - - start = device_dev->resource[idx].start; - end = device_dev->resource[idx].end; - size = end - start; - if (!size) - continue; - - addr = (unsigned long)pciio_pio_addr(vhdl, 0, - PCIIO_SPACE_WIN(idx), 0, size, 0, 0); - if (!addr) { - device_dev->resource[idx].start = 0; - device_dev->resource[idx].end = 0; - printk("sn_pci_fixup(): pio map failure for " - "%s bar%d\n", device_dev->slot_name, idx); - } else { - addr |= __IA64_UNCACHED_OFFSET; - device_dev->resource[idx].start = addr; - device_dev->resource[idx].end = addr + size; - } - - if (device_dev->resource[idx].flags & IORESOURCE_IO) - cmd |= PCI_COMMAND_IO; - } - - /* Allocate the IORESOURCE_MEM space next */ - for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) { - unsigned long start, end, addr; - - if ((device_dev->resource[idx].flags & IORESOURCE_IO)) - continue; - - start = device_dev->resource[idx].start; - end = device_dev->resource[idx].end; - size = end - start; - if (!size) - continue; - - addr = (unsigned long)pciio_pio_addr(vhdl, 0, - PCIIO_SPACE_WIN(idx), 0, size, 0, 0); - if (!addr) { - device_dev->resource[idx].start = 0; - device_dev->resource[idx].end = 0; - printk("sn_pci_fixup(): pio map failure for " - "%s bar%d\n", device_dev->slot_name, idx); - } else { - addr |= __IA64_UNCACHED_OFFSET; - device_dev->resource[idx].start = addr; - device_dev->resource[idx].end = addr + size; - } - - if (device_dev->resource[idx].flags & IORESOURCE_MEM) - cmd |= PCI_COMMAND_MEMORY; - } - - /* - * Update the Command Word on the Card. - */ - cmd |= PCI_COMMAND_MASTER; /* If the device doesn't support */ - /* bit gets dropped .. no harm */ - pci_write_config_word(device_dev, PCI_COMMAND, cmd); - - pci_read_config_byte(device_dev, PCI_INTERRUPT_PIN, - (unsigned char *)&lines); - device_sysdata = (struct sn_device_sysdata *)device_dev->sysdata; - device_vertex = device_sysdata->vhdl; - pci_provider = device_sysdata->pci_provider; - - if (!lines) { - continue; - } - - irqpdaindr->curr = device_dev; - intr_handle = (pci_provider->intr_alloc)(device_vertex, NULL, lines, device_vertex); - - if (intr_handle == NULL) { - printk("sn_pci_fixup: pcibr_intr_alloc() failed\n"); - continue; - } - irq = intr_handle->bi_irq; - irqpdaindr->device_dev[irq] = device_dev; - (pci_provider->intr_connect)(intr_handle, (intr_func_t)0, (intr_arg_t)0); - device_dev->irq = irq; - register_pcibr_intr(irq, (pcibr_intr_t)intr_handle); - - for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) { - int ibits = intr_handle->bi_ibits; - int i; - - size = device_dev->resource[idx].end - - device_dev->resource[idx].start; - if (size == 0) - continue; - - for (i=0; i<8; i++) { - if (ibits & (1 << i) ) { - sn_dma_flush_init(device_dev->resource[idx].start, - device_dev->resource[idx].end, - idx, - i, - PCIBR_INFO_SLOT_GET_EXT(pcibr_info_get(device_sysdata->vhdl))); - } - } - } - + (dnasid << 36) | (0xfUL << 48))); } + return p; } /* - * linux_bus_cvlink() Creates a link between the Linux PCI Bus number + * linux_bus_cvlink() Creates a link between the Linux PCI Bus number * to the actual hardware component that it represents: * /dev/hw/linux/busnum/0 -> ../../../hw/module/001c01/slab/0/Ibrick/xtalk/15/pci * @@ -553,7 +555,7 @@ linux_bus_cvlink(void) continue; sprintf(name, "%x", index); - (void) hwgraph_edge_add(linux_busnum, busnum_to_pcibr_vhdl[index], + (void) hwgraph_edge_add(linux_busnum, busnum_to_pcibr_vhdl[index], name); } } @@ -564,7 +566,7 @@ linux_bus_cvlink(void) * Linux PCI Bus numbers are assigned from lowest module_id numbers * (rack/slot etc.) */ -static int +static int pci_bus_map_create(struct pcibr_list_s *softlistp, moduleid_t moduleid) { @@ -574,10 +576,10 @@ pci_bus_map_create(struct pcibr_list_s * memset(moduleid_str, 0, 16); format_module_id(moduleid_str, moduleid, MODULE_FORMAT_BRIEF); - (void) ioconfig_get_busnum((char *)moduleid_str, &basebus_num); + (void) ioconfig_get_busnum((char *)moduleid_str, &basebus_num); /* - * Assign the correct bus number and also the nasid of this + * Assign the correct bus number and also the nasid of this * pci Xwidget. */ bus_number = basebus_num + pcibr_widget_to_bus(pci_bus); @@ -605,20 +607,20 @@ pci_bus_map_create(struct pcibr_list_s * printk("pci_bus_map_create: Cannot allocate memory for ate maps\n"); return -1; } - memset(busnum_to_atedmamaps[bus_number], 0x0, + memset(busnum_to_atedmamaps[bus_number], 0x0, sizeof(struct pcibr_dmamap_s) * MAX_ATE_MAPS); return(0); } /* - * pci_bus_to_hcl_cvlink() - This routine is called after SGI IO Infrastructure + * pci_bus_to_hcl_cvlink() - This routine is called after SGI IO Infrastructure * initialization has completed to set up the mappings between PCI BRIDGE - * ASIC and logical pci bus numbers. + * ASIC and logical pci bus numbers. * * Must be called before pci_init() is invoked. */ int -pci_bus_to_hcl_cvlink(void) +pci_bus_to_hcl_cvlink(void) { int i; extern pcibr_list_p pcibr_list; @@ -635,7 +637,7 @@ pci_bus_to_hcl_cvlink(void) /* Is this PCI bus associated with this moduleid? */ moduleid = NODE_MODULEID( - NASID_TO_COMPACT_NODEID(pcibr_soft->bs_nasid)); + NASID_TO_COMPACT_NODEID(pcibr_soft->bs_nasid)); if (modules[i]->id == moduleid) { struct pcibr_list_s *new_element; @@ -656,9 +658,9 @@ pci_bus_to_hcl_cvlink(void) continue; } - /* - * BASEIO IObricks attached to a module have - * a higher priority than non BASEIO IOBricks + /* + * BASEIO IObricks attached to a module have + * a higher priority than non BASEIO IOBricks * when it comes to persistant pci bus * numbering, so put them on the front of the * list. @@ -674,7 +676,7 @@ pci_bus_to_hcl_cvlink(void) softlistp = softlistp->bl_next; } - /* + /* * We now have a list of all the pci bridges associated with * the module_id, modules[i]. Call pci_bus_map_create() for * each pci bridge @@ -702,13 +704,26 @@ pci_bus_to_hcl_cvlink(void) /* * Ugly hack to get PCI setup until we have a proper ACPI namespace. */ + +#define PCI_BUSES_TO_SCAN 256 + extern struct pci_ops sn_pci_ops; int __init sn_pci_init (void) { -# define PCI_BUSES_TO_SCAN 256 int i = 0; struct pci_controller *controller; + struct list_head *ln; + struct pci_bus *pci_bus = NULL; + struct pci_dev *pci_dev = NULL; + extern int numnodes; + int cnode, ret; +#ifdef CONFIG_PROC_FS + extern void register_sn_procfs(void); +#endif + extern void sgi_master_io_infr_init(void); + extern void sn_init_cpei_timer(void); + if (!ia64_platform_is("sn2") || IS_RUNNING_ON_SIMULATOR()) return 0; @@ -721,7 +736,19 @@ sn_pci_init (void) /* * set pci_raw_ops, etc. */ - sn_pci_fixup(0); + + sgi_master_io_infr_init(); + + for (cnode = 0; cnode < numnodes; cnode++) { + extern void intr_init_vecblk(cnodeid_t); + intr_init_vecblk(cnode); + } + + sn_init_cpei_timer(); + +#ifdef CONFIG_PROC_FS + register_sn_procfs(); +#endif controller = kmalloc(sizeof(struct pci_controller), GFP_KERNEL); if (controller) { @@ -734,7 +761,53 @@ sn_pci_init (void) /* * actually find devices and fill in hwgraph structs */ - sn_pci_fixup(1); + + done_probing = 1; + + /* + * Initialize the pci bus vertex in the pci_bus struct. + */ + for( ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) { + pci_bus = pci_bus_b(ln); + ret = sn_pci_fixup_bus(pci_bus); + if ( ret ) { + printk(KERN_WARNING + "sn_pci_fixup: sn_pci_fixup_bus fails : error %d\n", + ret); + return; + } + } + + /* + * set the root start and end so that drivers calling check_region() + * won't see a conflict + */ + +#ifdef CONFIG_IA64_SGI_SN_SIM + if (! IS_RUNNING_ON_SIMULATOR()) { + ioport_resource.start = 0xc000000000000000; + ioport_resource.end = 0xcfffffffffffffff; + } +#endif + + /* + * Set the root start and end for Mem Resource. + */ + iomem_resource.start = 0; + iomem_resource.end = 0xffffffffffffffff; + + /* + * Initialize the device vertex in the pci_dev struct. + */ + while ((pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) != NULL) { + ret = sn_pci_fixup_slot(pci_dev); + if ( ret ) { + printk(KERN_WARNING + "sn_pci_fixup: sn_pci_fixup_slot fails : error %d\n", + ret); + return; + } + } return 0; } --- diff/arch/ia64/sn/io/machvec/pci_dma.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/io/machvec/pci_dma.c 2004-02-23 13:56:37.000000000 +0000 @@ -127,7 +127,7 @@ sn_pci_alloc_consistent(struct pci_dev * /* * Get hwgraph vertex for the device */ - device_sysdata = (struct sn_device_sysdata *) hwdev->sysdata; + device_sysdata = SN_DEVICE_SYSDATA(hwdev); vhdl = device_sysdata->vhdl; /* @@ -240,7 +240,7 @@ sn_pci_map_sg(struct pci_dev *hwdev, str /* * Get the hwgraph vertex for the device */ - device_sysdata = (struct sn_device_sysdata *) hwdev->sysdata; + device_sysdata = SN_DEVICE_SYSDATA(hwdev); vhdl = device_sysdata->vhdl; /* @@ -367,7 +367,7 @@ sn_pci_map_single(struct pci_dev *hwdev, /* * find vertex for the device */ - device_sysdata = (struct sn_device_sysdata *)hwdev->sysdata; + device_sysdata = SN_DEVICE_SYSDATA(hwdev); vhdl = device_sysdata->vhdl; /* --- diff/arch/ia64/sn/io/sn2/bte_error.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/bte_error.c 2004-02-23 13:56:37.000000000 +0000 @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include --- diff/arch/ia64/sn/io/sn2/geo_op.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/geo_op.c 2004-02-23 13:56:37.000000000 +0000 @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include --- diff/arch/ia64/sn/io/sn2/klconflib.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/klconflib.c 2004-02-23 13:56:37.000000000 +0000 @@ -474,8 +474,6 @@ board_serial_number_get(lboard_t *board, return(0); } -#include "asm/sn/sn_private.h" - /* * Format a module id for printing. * --- diff/arch/ia64/sn/io/sn2/ml_SN_init.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/ml_SN_init.c 2004-02-23 13:56:37.000000000 +0000 @@ -11,12 +11,12 @@ #include #include #include -#include #include #include #include #include #include +#include int maxcpus; @@ -69,12 +69,15 @@ void init_platform_nodepda(nodepda_t *np } void -init_platform_hubinfo(nodepda_t **nodepdaindr) { +init_platform_hubinfo(nodepda_t **nodepdaindr) +{ cnodeid_t cnode; hubinfo_t hubinfo; nodepda_t *npda; extern int numionodes; + if (IS_RUNNING_ON_SIMULATOR()) + return; for (cnode = 0; cnode < numionodes; cnode++) { npda = nodepdaindr[cnode]; hubinfo = (hubinfo_t)npda->pdinfo; --- diff/arch/ia64/sn/io/sn2/ml_SN_intr.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/ml_SN_intr.c 2004-02-23 13:56:37.000000000 +0000 @@ -30,6 +30,7 @@ #include #include #include +#include extern irqpda_t *irqpdaindr; extern cnodeid_t master_node_get(vertex_hdl_t vhdl); @@ -216,7 +217,6 @@ static cpuid_t intr_cpu_choose_from_node { cpuid_t cpu, best_cpu = CPU_NONE; int slice, min_count = 1000; - irqpda_t *irqs; for (slice = CPUS_PER_NODE - 1; slice >= 0; slice--) { int intrs; @@ -227,8 +227,7 @@ static cpuid_t intr_cpu_choose_from_node if (!cpu_online(cpu)) continue; - irqs = irqpdaindr; - intrs = irqs->num_irq_used; + intrs = pdacpu(cpu)->sn_num_irqs; if (min_count > intrs) { min_count = intrs; @@ -243,6 +242,7 @@ static cpuid_t intr_cpu_choose_from_node } } } + pdacpu(best_cpu)->sn_num_irqs++; return best_cpu; } --- diff/arch/ia64/sn/io/sn2/pcibr/pcibr_ate.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/pcibr/pcibr_ate.c 2004-02-23 13:56:37.000000000 +0000 @@ -8,7 +8,6 @@ #include #include -#include #include #include #include --- diff/arch/ia64/sn/io/sn2/pcibr/pcibr_config.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/pcibr/pcibr_config.c 2004-02-23 13:56:37.000000000 +0000 @@ -8,7 +8,6 @@ #include #include -#include #include #include #include --- diff/arch/ia64/sn/io/sn2/pcibr/pcibr_intr.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/pcibr/pcibr_intr.c 2004-02-23 13:56:37.000000000 +0000 @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include --- diff/arch/ia64/sn/io/sn2/pcibr/pcibr_reg.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/pcibr/pcibr_reg.c 2004-02-23 13:56:37.000000000 +0000 @@ -8,7 +8,6 @@ #include #include -#include #include #include #include --- diff/arch/ia64/sn/io/sn2/pcibr/pcibr_rrb.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/pcibr/pcibr_rrb.c 2004-02-23 13:56:37.000000000 +0000 @@ -8,7 +8,6 @@ #include #include -#include #include #include #include --- diff/arch/ia64/sn/io/sn2/pic.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/pic.c 2004-02-23 13:56:37.000000000 +0000 @@ -90,10 +90,15 @@ pic_bus1_widget_info_dup(vertex_hdl_t co peer_widget_info->w_efunc = 0; peer_widget_info->w_einfo = 0; peer_widget_info->w_name = kmalloc(strlen(peer_path) + 1, GFP_KERNEL); + if (!peer_widget_info->w_name) { + kfree(peer_widget_info); + return -ENOMEM; + } strcpy(peer_widget_info->w_name, peer_path); if (hwgraph_info_add_LBL(peer_conn_v, INFO_LBL_XWIDGET, (arbitrary_info_t)peer_widget_info) != GRAPH_SUCCESS) { + kfree(peer_widget_info->w_name); kfree(peer_widget_info); return 0; } @@ -359,6 +364,9 @@ pic_attach2(vertex_hdl_t xconn_vhdl, voi s = dev_to_name(pcibr_vhdl, devnm, MAXDEVNAME); pcibr_soft->bs_name = kmalloc(strlen(s) + 1, GFP_KERNEL); + if (!pcibr_soft->bs_name) + return -ENOMEM; + strcpy(pcibr_soft->bs_name, s); pcibr_soft->bs_conn = xconn_vhdl; --- diff/arch/ia64/sn/io/sn2/shub.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/shub.c 2004-02-23 13:56:37.000000000 +0000 @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include --- diff/arch/ia64/sn/io/sn2/shub_intr.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/shub_intr.c 2004-02-23 13:56:37.000000000 +0000 @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include --- diff/arch/ia64/sn/io/sn2/shuberror.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/io/sn2/shuberror.c 2004-02-23 13:56:37.000000000 +0000 @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include --- diff/arch/ia64/sn/io/xswitch.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/io/xswitch.c 2004-02-23 13:56:37.000000000 +0000 @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include --- diff/arch/ia64/sn/kernel/irq.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/kernel/irq.c 2004-02-23 13:56:37.000000000 +0000 @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -121,7 +120,7 @@ sn_end_irq(unsigned int irq) static void sn_set_affinity_irq(unsigned int irq, unsigned long cpu) { -#if CONFIG_SMP +#ifdef CONFIG_SMP int redir = 0; struct sn_intr_list_t *p = sn_intr_list[irq]; pcibr_intr_t intr; --- diff/arch/ia64/sn/kernel/setup.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ia64/sn/kernel/setup.c 2004-02-23 13:56:37.000000000 +0000 @@ -85,6 +85,7 @@ int numionodes; u64 master_node_bedrock_address; static void sn_init_pdas(char **); +static void scan_for_ionodes(void); static nodepda_t *nodepdaindr[MAX_COMPACT_NODES]; @@ -131,7 +132,7 @@ char drive_info[4*16]; * may not be initialized yet. */ -static int +static int __init pxm_to_nasid(int pxm) { int i; @@ -358,11 +359,10 @@ sn_setup(char **cmdline_p) * * One time setup for Node Data Area. Called by sn_setup(). */ -void +void __init sn_init_pdas(char **cmdline_p) { cnodeid_t cnode; - void scan_for_ionodes(void); /* * Make sure that the PDA fits entirely in the same page as the @@ -498,7 +498,7 @@ sn_cpu_init(void) * physical_node_map and the pda and increment numionodes. */ -void +static void __init scan_for_ionodes(void) { int nasid = 0; --- diff/arch/m68k/Kconfig 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/m68k/Kconfig 2004-02-23 13:56:37.000000000 +0000 @@ -70,8 +70,21 @@ config PCMCIA To compile this driver as modules, choose M here: the modules will be called pcmcia_core and ds. +config SUN3 + bool "Sun3 support" + select M68020 + select MMU_SUN3 if MMU + help + This option enables support for the Sun 3 series of workstations + (3/50, 3/60, 3/1xx, 3/2xx systems). Enabling this option requires + that all other hardware types must be disabled, as Sun 3 kernels + are incompatible with all other m68k targets (including Sun 3x!). + + If you don't want to compile a kernel exclusively for a Sun 3, say N. + config AMIGA bool "Amiga support" + depends on !MMU_SUN3 help This option enables support for the Amiga series of computers. If you plan to use this kernel on an Amiga, say Y here and browse the @@ -79,6 +92,7 @@ config AMIGA config ATARI bool "Atari support" + depends on !MMU_SUN3 help This option enables support for the 68000-based Atari series of computers (including the TT, Falcon and Medusa). If you plan to use @@ -109,6 +123,7 @@ config PCI config MAC bool "Macintosh support" + depends on !MMU_SUN3 help This option enables support for the Apple Macintosh series of computers (yes, there is experimental support now, at least for part @@ -129,12 +144,14 @@ config M68K_L2_CACHE config APOLLO bool "Apollo support" + depends on !MMU_SUN3 help Say Y here if you want to run Linux on an MC680x0-based Apollo Domain workstation such as the DN3500. config VME bool "VME (Motorola and BVM) support" + depends on !MMU_SUN3 help Say Y here if you want to build a kernel for a 680x0 based VME board. Boards currently supported include Motorola boards MVME147, @@ -171,6 +188,7 @@ config BVME6000 config HP300 bool "HP9000/300 support" + depends on !MMU_SUN3 help This option enables support for the HP9000/300 series of workstations. Support for these machines is still very experimental. @@ -187,30 +205,20 @@ config DIO config SUN3X bool "Sun3x support" + depends on !MMU_SUN3 + select M68030 help This option enables support for the Sun 3x series of workstations. - Be warned that this support is very experimental. You will also want - to say Y to 68030 support and N to the other processors below. + Be warned that this support is very experimental. Note that Sun 3x kernels are not compatible with Sun 3 hardware. General Linux information on the Sun 3x series (now discontinued) is at . If you don't want to compile a kernel for a Sun 3x, say N. -config SUN3 - bool "Sun3 support" - help - This option enables support for the Sun 3 series of workstations - (3/50, 3/60, 3/1xx, 3/2xx systems). Enabling this option requires - that all other hardware types must be disabled, as Sun 3 kernels - are incompatible with all other m68k targets (including Sun 3x!). - Also, you will want to say Y to 68020 support and N to the other - processors below. - - If you don't want to compile a kernel exclusively for a Sun 3, say N. - config Q40 bool "Q40/Q60 support" + depends on !MMU_SUN3 help The Q40 is a Motorola 68040-based successor to the Sinclair QL manufactured in Germany. There is an official Q40 home page at @@ -230,6 +238,7 @@ config M68020 config M68030 bool "68030 support" + depends on !MMU_SUN3 help If you anticipate running this kernel on a computer with a MC68030 processor, say Y. Otherwise, say N. Note that a MC68EC030 will not @@ -237,6 +246,7 @@ config M68030 config M68040 bool "68040 support" + depends on !MMU_SUN3 help If you anticipate running this kernel on a computer with a MC68LC040 or MC68040 processor, say Y. Otherwise, say N. Note that an @@ -245,10 +255,19 @@ config M68040 config M68060 bool "68060 support" + depends on !MMU_SUN3 help If you anticipate running this kernel on a computer with a MC68060 processor, say Y. Otherwise, say N. +config MMU_MOTOROLA + bool + depends on MMU && !MMU_SUN3 + default y + +config MMU_SUN3 + bool + config M68KFPU_EMU bool "Math emulation support (EXPERIMENTAL)" depends on EXPERIMENTAL @@ -404,105 +423,6 @@ config PROC_HARDWARE including the model, CPU, MMU, clock speed, BogoMIPS rating, and memory size. -config PARPORT - tristate "Parallel port support (EXPERIMENTAL)" - depends on EXPERIMENTAL - ---help--- - If you want to use devices connected to your machine's parallel port - (the connector at the computer with 25 holes), e.g. printer, ZIP - drive, PLIP link (Parallel Line Internet Protocol is mainly used to - create a mini network by connecting the parallel ports of two local - machines) etc., then you need to say Y here; please read - and - . - - For extensive information about drivers for many devices attaching - to the parallel port see on - the WWW. - - It is possible to share a single parallel port among several devices - and it is safe to compile all the corresponding drivers into the - kernel. To compile parallel port support as a module, choose M here: - the module will be called parport. - If you have more than one parallel port and want to specify which - port and IRQ to be used by this driver at module load time, take a - look at . - - If unsure, say Y. - -config PARPORT_AMIGA - tristate "Amiga builtin port" - depends on AMIGA && PARPORT - help - Say Y here if you need support for the parallel port hardware on - Amiga machines. This code is also available as a module (say M), - called parport_amiga. If in doubt, saying N is the safe plan. - -config PARPORT_MFC3 - tristate "Multiface III parallel port" - depends on ZORRO && PARPORT - help - Say Y here if you need parallel port support for the MFC3 card. - This code is also available as a module (say M), called - parport_mfc3. If in doubt, saying N is the safe plan. - -config PARPORT_PC - bool - depends on Q40 && PARPORT - default y - ---help--- - You should say Y here if you have a PC-style parallel port. All IBM - PC compatible computers and some Alphas have PC-style parallel - ports. - - To compile this driver as a module, choose M here: the - module will be called parport_pc. - - If unsure, say Y. - -config PARPORT_ATARI - tristate "Atari builtin port" - depends on ATARI && PARPORT - help - Say Y here if you need support for the parallel port hardware on - Atari machines. This code is also available as a module (say M), - called parport_atari. If in doubt, saying N is the safe plan. - -config PRINTER - tristate "Parallel printer support" - depends on PARPORT - ---help--- - If you intend to attach a printer to the parallel port of your Linux - box (as opposed to using a serial printer; if the connector at the - printer has 9 or 25 holes ["female"], then it's serial), say Y. - Also read the Printing-HOWTO, available from - . - - It is possible to share one parallel port among several devices - (e.g. printer and ZIP drive) and it is safe to compile the - corresponding drivers into the kernel. - To compile this driver as a module, choose M here and read - . The module will be called lp. - - If you have several parallel ports, you can specify which ports to - use with the "lp" kernel command line option. (Try "man bootparam" - or see the documentation of your boot loader (lilo or loadlin) about - how to pass options to the kernel at boot time.) The syntax of the - "lp" command line option can be found in . - - If you have more than 8 printers, you need to increase the LP_NO - macro in lp.c and the PARPORT_MAX macro in parport.h. - -config PARPORT_1284 - bool "IEEE 1284 transfer modes" - depends on PRINTER - help - If you have a printer that supports status readback or device ID, or - want to use a device that uses enhanced parallel port transfer modes - such as EPP and ECP, say Y here to enable advanced IEEE 1284 - transfer modes. Also say Y if you want device ID information to - appear in /proc/sys/dev/parport/*/autoprobe*. It is safe to say N. - config ISA bool depends on Q40 || AMIGA_PCMCIA || GG2 @@ -523,192 +443,13 @@ source "drivers/pci/Kconfig" source "drivers/zorro/Kconfig" -if Q40 -source "drivers/pnp/Kconfig" -endif - endmenu -source "drivers/base/Kconfig" - -source "drivers/mtd/Kconfig" - -source "drivers/block/Kconfig" - -source "drivers/md/Kconfig" - -source "drivers/input/Kconfig" - -source "drivers/ide/Kconfig" - -source "drivers/scsi/Kconfig" - -source "net/Kconfig" +source "drivers/Kconfig" menu "Character devices" -config SERIAL - tristate "Q40 Standard/generic serial support" if Q40 - default DN_SERIAL if APOLLO - ---help--- - This selects whether you want to include the driver for the standard - serial ports. The standard answer is Y. People who might say N - here are those that are setting up dedicated Ethernet WWW/FTP - servers, or users that have one of the various bus mice instead of a - serial mouse and don't intend to use their machine's standard serial - port for anything. (Note that the Cyclades and Stallion multi - serial port drivers do not need this driver built in for them to - work.) - - To compile this driver as a module, choose M here: the - module will be called serial. - [WARNING: Do not compile this driver as a module if you are using - non-standard serial ports, since the configuration information will - be lost when the driver is unloaded. This limitation may be lifted - in the future.] - - BTW1: If you have a mouseman serial mouse which is not recognized by - the X window system, try running gpm first. - - BTW2: If you intend to use a software modem (also called Winmodem) - under Linux, forget it. These modems are crippled and require - proprietary drivers which are only available under Windows. - - Most people will say Y or M here, so that they can use serial mice, - modems and similar devices connecting to the standard serial ports. - -config SERIAL_EXTENDED - bool "Extended dumb serial driver options" - depends on SERIAL=y - help - If you wish to use any non-standard features of the standard "dumb" - driver, say Y here. This includes HUB6 support, shared serial - interrupts, special multiport support, support for more than the - four COM 1/2/3/4 boards, etc. - - Note that the answer to this question won't directly affect the - kernel: saying N will just cause the configurator to skip all - the questions about serial driver options. If unsure, say N. - -config SERIAL_MANY_PORTS - bool "Support more than 4 serial ports" - depends on SERIAL_EXTENDED - help - Say Y here if you have dumb serial boards other than the four - standard COM 1/2/3/4 ports. This may happen if you have an AST - FourPort, Accent Async, Boca (read the Boca mini-HOWTO, available - from ), or other custom - serial port hardware which acts similar to standard serial port - hardware. If you only use the standard COM 1/2/3/4 ports, you can - say N here to save some memory. You can also say Y if you have an - "intelligent" multiport card such as Cyclades, Digiboards, etc. - -config SERIAL_SHARE_IRQ - bool "Support for sharing serial interrupts" - depends on SERIAL_EXTENDED - help - Some serial boards have hardware support which allows multiple dumb - serial ports on the same board to share a single IRQ. To enable - support for this in the serial driver, say Y here. - -config SERIAL_MULTIPORT - bool "Support special multiport boards" - depends on SERIAL_EXTENDED - help - Some multiport serial ports have special ports which are used to - signal when there are any serial ports on the board which need - servicing. Say Y here to enable the serial driver to take advantage - of those special I/O ports. - -config HUB6 - bool "Support the Bell Technologies HUB6 card" - depends on SERIAL_EXTENDED - help - Say Y here to enable support in the dumb serial driver to support - the HUB6 card. - -config VT - bool "Virtual terminal" - ---help--- - If you say Y here, you will get support for terminal devices with - display and keyboard devices. These are called "virtual" because you - can run several virtual terminals (also called virtual consoles) on - one physical terminal. This is rather useful, for example one - virtual terminal can collect system messages and warnings, another - one can be used for a text-mode user session, and a third could run - an X session, all in parallel. Switching between virtual terminals - is done with certain key combinations, usually Alt-. - - The setterm command ("man setterm") can be used to change the - properties (such as colors or beeping) of a virtual terminal. The - man page console_codes(4) ("man console_codes") contains the special - character sequences that can be used to change those properties - directly. The fonts used on virtual terminals can be changed with - the setfont ("man setfont") command and the key bindings are defined - with the loadkeys ("man loadkeys") command. - - You need at least one virtual terminal device in order to make use - of your keyboard and monitor. Therefore, only people configuring an - embedded system would want to say N here in order to save some - memory; the only way to log into such a system is then via a serial - or network connection. - - If unsure, say Y, or else you won't be able to do much with your new - shiny Linux system :-) - -config VT_CONSOLE - bool "Support for console on virtual terminal" - depends on VT - ---help--- - The system console is the device which receives all kernel messages - and warnings and which allows logins in single user mode. If you - answer Y here, a virtual terminal (the device used to interact with - a physical terminal) can be used as system console. This is the most - common mode of operations, so you should say Y here unless you want - the kernel messages be output only to a serial port (in which case - you should say Y to "Console on serial port", below). - - If you do say Y here, by default the currently visible virtual - terminal (/dev/tty0) will be used as system console. You can change - that with a kernel command line option such as "console=tty3" which - would use the third virtual terminal as system console. (Try "man - bootparam" or see the documentation of your boot loader (lilo or - loadlin) about how to pass options to the kernel at boot time.) - - If unsure, say Y. - -config HW_CONSOLE - bool - depends on VT - default y - -config NVRAM - bool - depends on ATARI - default y - ---help--- - If you say Y here and create a character special file /dev/nvram - with major number 10 and minor number 144 using mknod ("man mknod"), - you get read and write access to the 50 bytes of non-volatile memory - in the real time clock (RTC), which is contained in every PC and - most Ataris. - - This memory is conventionally called "CMOS RAM" on PCs and "NVRAM" - on Ataris. /dev/nvram may be used to view settings there, or to - change them (with some utility). It could also be used to frequently - save a few bits of very important data that may not be lost over - power-off and for which writing to disk is too insecure. Note - however that most NVRAM space in a PC belongs to the BIOS and you - should NEVER idly tamper with it. See Ralf Brown's interrupt list - for a guide to the use of CMOS bytes by your BIOS. - - On Atari machines, /dev/nvram is always configured and does not need - to be selected. - - To compile this driver as a module, choose M here: the - module will be called nvram. - config ATARI_MFPSER tristate "Atari MFP serial support" depends on ATARI @@ -787,22 +528,6 @@ config MULTIFACE_III_TTY To compile this driver as a module, choose M here. -config A2232 - tristate "Commodore A2232 serial support (EXPERIMENTAL)" - depends on AMIGA && EXPERIMENTAL - ---help--- - This option supports the 2232 7-port serial card shipped with the - Amiga 2000 and other Zorro-bus machines, dating from 1989. At - a max of 19,200 bps, the ports are served by a 6551 ACIA UART chip - each, plus a 8520 CIA, and a master 6502 CPU and buffer as well. The - ports were connected with 8 pin DIN connectors on the card bracket, - for which 8 pin to DB25 adapters were supplied. The card also had - jumpers internally to toggle various pinning configurations. - - This driver can be built as a module; but then "generic_serial" - will also be built as a module. This has to be loaded before - "ser_a2232". If you want to do this, answer M here. - config GVPIOEXT tristate "GVP IO-Extender support" depends on PARPORT=n && ZORRO @@ -1009,87 +734,10 @@ config SERIAL_CONSOLE If unsure, say N. -config USERIAL - bool "Support for user serial device modules" - -source "drivers/char/watchdog/Kconfig" - -config GEN_RTC - tristate "Generic /dev/rtc emulation" if !SUN3 - default y if SUN3 - ---help--- - 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. - - It reports status information via the file /proc/driver/rtc and its - behaviour is set by various ioctls on /dev/rtc. If you enable the - "extended RTC operation" below it will also provide an emulation - for RTC_UIE which is required by some programs and may improve - precision in some cases. - - To compile this driver as a module, choose M here: the - module will be called genrtc. To load the module automatically - add 'alias char-major-10-135 genrtc' to your /etc/modules.conf - -config GEN_RTC_X - bool "Extended RTC operation" - depends on GEN_RTC - help - Provides an emulation for RTC_UIE which is required by some programs - and may improve precision of the generic RTC support in some cases. - -config UNIX98_PTYS - bool "Unix98 PTY support" - ---help--- - A pseudo terminal (PTY) is a software device consisting of two - halves: a master and a slave. The slave device behaves identical to - a physical terminal; the master device is used by a process to - read data from and write data to the slave, thereby emulating a - terminal. Typical programs for the master side are telnet servers - and xterms. - - Linux has traditionally used the BSD-like names /dev/ptyxx for - masters and /dev/ttyxx for slaves of pseudo terminals. This scheme - has a number of problems. The GNU C library glibc 2.1 and later, - however, supports the Unix98 naming standard: in order to acquire a - pseudo terminal, a process opens /dev/ptmx; the number of the pseudo - terminal is then made available to the process and the pseudo - terminal slave can be accessed as /dev/pts/. What was - traditionally /dev/ttyp2 will then be /dev/pts/2, for example. - - The entries in /dev/pts/ are created on the fly by a virtual - file system; therefore, if you say Y here you should say Y to - "/dev/pts file system for Unix98 PTYs" as well. - - If you want to say Y here, you need to have the C library glibc 2.1 - or later (equal to libc-6.1, check with "ls -l /lib/libc.so.*"). - Read the instructions in pertaining to - pseudo terminals. It's safe to say N. - -config UNIX98_PTY_COUNT - int "Maximum number of Unix98 PTYs in use (0-2048)" - depends on UNIX98_PTYS - default "256" - help - The maximum number of Unix98 PTYs that can be used at any one time. - The default is 256, and should be enough for desktop systems. Server - machines which support incoming telnet/rlogin/ssh connections and/or - serve several X terminals may want to increase this: every incoming - connection and every xterm uses up one PTY. - - When not in use, each additional set of 256 PTYs occupy - approximately 8 KB of kernel memory on 32-bit architectures. - endmenu -source "sound/Kconfig" - source "fs/Kconfig" -source "drivers/video/Kconfig" - menu "Kernel hacking" config DEBUG_KERNEL --- diff/arch/m68k/Makefile 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/m68k/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -111,6 +111,14 @@ else bzip2 -1c vmlinux >vmlinux.bz2 endif +prepare: include/asm-$(ARCH)/offsets.h +CLEAN_FILES += include/asm-$(ARCH)/offsets.h + +arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ + include/config/MARKER + +include/asm-$(ARCH)/offsets.h: arch/$(ARCH)/kernel/asm-offsets.s + $(call filechk,gen-asm-offsets) + archclean: rm -f vmlinux.gz vmlinux.bz2 - rm -f arch/m68k/kernel/m68k_defs.h arch/m68k/kernel/m68k_defs.d --- diff/arch/m68k/amiga/amiints.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/m68k/amiga/amiints.c 2004-02-23 13:56:37.000000000 +0000 @@ -49,6 +49,7 @@ #include #include #include +#include extern int cia_request_irq(struct ciabase *base,int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *), --- diff/arch/m68k/atari/config.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/m68k/atari/config.c 2004-02-23 13:56:37.000000000 +0000 @@ -344,7 +344,7 @@ void __init config_atari(void) ATARIHW_SET(PCM_8BIT); printk( "PCM " ); } - if (!MACH_IS_HADES && hwreg_present( &codec.unused5 )) { + if (!MACH_IS_HADES && hwreg_present( &falcon_codec.unused5 )) { ATARIHW_SET(CODEC); printk( "CODEC " ); } --- diff/arch/m68k/bvme6000/bvmeints.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/m68k/bvme6000/bvmeints.c 2004-02-23 13:56:37.000000000 +0000 @@ -20,6 +20,7 @@ #include #include #include +#include static irqreturn_t bvme6000_defhand (int irq, void *dev_id, struct pt_regs *fp); --- diff/arch/m68k/fpsp040/skeleton.S 2002-11-11 11:09:42.000000000 +0000 +++ source/arch/m68k/fpsp040/skeleton.S 2004-02-23 13:56:37.000000000 +0000 @@ -40,7 +40,7 @@ #include #include -#include "../kernel/m68k_defs.h" +#include |SKELETON idnt 2,1 | Motorola 040 Floating Point Software Package --- diff/arch/m68k/hp300/time.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/m68k/hp300/time.c 2004-02-23 13:56:37.000000000 +0000 @@ -17,6 +17,7 @@ #include #include #include +#include #include "ints.h" /* Clock hardware definitions */ --- diff/arch/m68k/ifpsp060/iskeleton.S 2003-05-21 11:49:54.000000000 +0100 +++ source/arch/m68k/ifpsp060/iskeleton.S 2004-02-23 13:56:37.000000000 +0000 @@ -36,7 +36,7 @@ #include #include -#include "../kernel/m68k_defs.h" +#include |################################ --- diff/arch/m68k/kernel/Makefile 2003-08-26 10:00:52.000000000 +0100 +++ source/arch/m68k/kernel/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -16,20 +16,3 @@ obj-$(CONFIG_PCI) += bios32.o obj-$(CONFIG_MODULES) += module.o EXTRA_AFLAGS := -traditional - -$(obj)/head.o: $(obj)/head.S $(obj)/m68k_defs.h - -$(obj)/entry.o: $(obj)/entry.S $(obj)/m68k_defs.h - -$(obj)/sun3-head.o: $(obj)/sun3-head.S $(obj)/m68k_defs.h - -$(obj)/m68k_defs.h: $(src)/m68k_defs.c $(src)/m68k_defs.head - rm -f $(obj)/m68k_defs.d - SUNPRO_DEPENDENCIES="$(obj)/m68k_defs.d $(obj)/m68k_defs.h" \ - $(CC) $(filter-out -MD,$(CFLAGS)) -S $(src)/m68k_defs.c -o \ - $(obj)/m68k_defs.s - cp $(src)/m68k_defs.head $(obj)/m68k_defs.h - grep '^#define' $(obj)/m68k_defs.s >> $(obj)/m68k_defs.h - rm $(obj)/m68k_defs.s --include $(obj)/m68k_defs.d - --- diff/arch/m68k/kernel/entry.S 2003-08-20 14:16:08.000000000 +0100 +++ source/arch/m68k/kernel/entry.S 2004-02-23 13:56:37.000000000 +0000 @@ -42,7 +42,7 @@ #include #include -#include "m68k_defs.h" +#include .globl system_call, buserr, trap .globl resume, ret_from_exception --- diff/arch/m68k/kernel/head.S 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/m68k/kernel/head.S 2004-02-23 13:56:37.000000000 +0000 @@ -262,7 +262,7 @@ #include #include #include -#include "m68k_defs.h" +#include #ifdef CONFIG_MAC --- diff/arch/m68k/kernel/module.c 2003-08-20 14:16:08.000000000 +0100 +++ source/arch/m68k/kernel/module.c 2004-02-23 13:56:37.000000000 +0000 @@ -82,9 +82,38 @@ int apply_relocate_add(Elf32_Shdr *sechd unsigned int relsec, struct module *me) { - printk(KERN_ERR "module %s: ADD RELOCATION unsupported\n", - me->name); - return -ENOEXEC; + unsigned int i; + Elf32_Rela *rel = (void *)sechdrs[relsec].sh_addr; + Elf32_Sym *sym; + uint32_t *location; + + DEBUGP("Applying relocate_add section %u to %u\n", relsec, + sechdrs[relsec].sh_info); + for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { + /* This is where to make the change */ + location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + + rel[i].r_offset; + /* This is the symbol it is referring to. Note that all + undefined symbols have been resolved. */ + sym = (Elf32_Sym *)sechdrs[symindex].sh_addr + + ELF32_R_SYM(rel[i].r_info); + + switch (ELF32_R_TYPE(rel[i].r_info)) { + case R_68K_32: + /* We add the value into the location given */ + *location = rel[i].r_addend + sym->st_value; + break; + case R_68K_PC32: + /* Add the value, subtract its postition */ + *location = rel[i].r_addend + sym->st_value - (uint32_t)location; + break; + default: + printk(KERN_ERR "module %s: Unknown relocation: %u\n", + me->name, ELF32_R_TYPE(rel[i].r_info)); + return -ENOEXEC; + } + } + return 0; } int module_finalize(const Elf_Ehdr *hdr, --- diff/arch/m68k/kernel/setup.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/m68k/kernel/setup.c 2004-02-23 13:56:37.000000000 +0000 @@ -538,7 +538,6 @@ void check_bugs(void) "WHICH IS REQUIRED BY LINUX/M68K ***\n" ); printk( KERN_EMERG "Upgrade your hardware or join the FPU " "emulation project\n" ); - printk( KERN_EMERG "(see http://no-fpu.linux-m68k.org)\n" ); panic( "no FPU" ); } --- diff/arch/m68k/kernel/signal.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/m68k/kernel/signal.c 2004-02-23 13:56:37.000000000 +0000 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include --- diff/arch/m68k/kernel/sys_m68k.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/m68k/kernel/sys_m68k.c 2004-02-23 13:56:37.000000000 +0000 @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -156,8 +157,6 @@ out: } #endif -extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); - struct sel_arg_struct { unsigned long n; fd_set *inp, *outp, *exp; @@ -262,7 +261,7 @@ asmlinkage int sys_ipc (uint call, int f return -EINVAL; } -asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on) +asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int on) { return -ENOSYS; } --- diff/arch/m68k/kernel/time.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/m68k/kernel/time.c 2004-02-23 13:56:37.000000000 +0000 @@ -174,6 +174,7 @@ int do_settimeofday(struct timespec *tv) time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; write_sequnlock_irq(&xtime_lock); + clock_was_set(); return 0; } --- diff/arch/m68k/kernel/traps.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/m68k/kernel/traps.c 2004-02-23 13:56:37.000000000 +0000 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -645,7 +646,7 @@ static inline void bus_error030 (struct if (do_page_fault (&fp->ptregs, addr, errorcode) < 0) return; } else if (!(mmusr & MMU_I)) { - /* propably a 020 cas fault */ + /* probably a 020 cas fault */ if (!(ssw & RM)) printk("unexpected bus error (%#x,%#x)\n", ssw, mmusr); } else if (mmusr & (MMU_B|MMU_L|MMU_S)) { @@ -825,9 +826,12 @@ void show_trace(unsigned long *stack) * out the call path that was taken. */ if (kernel_text_address(addr)) { - if (i % 4 == 0) +#ifndef CONFIG_KALLSYMS + if (i % 5 == 0) printk("\n "); +#endif printk(" [<%08lx>]", addr); + print_symbol(" %s\n", addr); i++; } } @@ -1098,8 +1102,10 @@ void die_if_kernel (char *str, struct pt console_verbose(); printk("%s: %08x\n",str,nr); - printk("PC: [<%08lx>]\nSR: %04x SP: %p a2: %08lx\n", - fp->pc, fp->sr, fp, fp->a2); + printk("PC: [<%08lx>]",fp->pc); + print_symbol(" %s\n", fp->pc); + printk("\nSR: %04x SP: %p a2: %08lx\n", + fp->sr, fp, fp->a2); printk("d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n", fp->d0, fp->d1, fp->d2, fp->d3); printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n", --- diff/arch/m68k/mac/iop.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/m68k/mac/iop.c 2004-02-23 13:56:37.000000000 +0000 @@ -87,7 +87,7 @@ * or more messages on the receive channels have gone to the MSG_NEW state. * * Since each channel handles only one message we have to implement a small - * interrupt-driven queue on our end. Messages to e sent are placed on the + * interrupt-driven queue on our end. Messages to be sent are placed on the * queue for sending and contain a pointer to an optional callback function. * The handler for a message is called when the message state goes to * MSG_COMPLETE. @@ -118,6 +118,7 @@ #include #include #include +#include /*#define DEBUG_IOP*/ --- diff/arch/m68k/mac/macints.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/m68k/mac/macints.c 2004-02-23 13:56:37.000000000 +0000 @@ -132,8 +132,8 @@ #include #include #include - #include +#include #define DEBUG_SPURIOUS #define SHUTUP_SONIC --- diff/arch/m68k/mac/oss.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/m68k/mac/oss.c 2004-02-23 13:56:37.000000000 +0000 @@ -26,6 +26,7 @@ #include #include #include +#include int oss_present; volatile struct mac_oss *oss; --- diff/arch/m68k/mac/psc.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/m68k/mac/psc.c 2004-02-23 13:56:37.000000000 +0000 @@ -24,6 +24,7 @@ #include #include #include +#include #define DEBUG_PSC --- diff/arch/m68k/mac/via.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/m68k/mac/via.c 2004-02-23 13:56:37.000000000 +0000 @@ -23,7 +23,6 @@ #include #include #include - #include #include @@ -33,6 +32,7 @@ #include #include #include +#include volatile __u8 *via1, *via2; #if 0 --- diff/arch/m68k/math-emu/fp_emu.h 2003-08-20 14:16:08.000000000 +0100 +++ source/arch/m68k/math-emu/fp_emu.h 2004-02-23 13:56:37.000000000 +0000 @@ -39,7 +39,7 @@ #define _FP_EMU_H #ifdef __ASSEMBLY__ -#include "../kernel/m68k_defs.h" +#include #endif #include --- diff/arch/m68k/mm/Makefile 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/m68k/mm/Makefile 2004-02-23 13:56:37.000000000 +0000 @@ -4,8 +4,5 @@ obj-y := init.o fault.o hwtest.o -ifndef CONFIG_SUN3 -obj-y += kmap.o memory.o motorola.o -else -obj-y += sun3kmap.o sun3mmu.o -endif +obj-$(CONFIG_MMU_MOTOROLA) += kmap.o memory.o motorola.o +obj-$(CONFIG_MMU_SUN3) += sun3kmap.o sun3mmu.o --- diff/arch/m68k/mm/init.c 2003-08-20 14:16:08.000000000 +0100 +++ source/arch/m68k/mm/init.c 2004-02-23 13:56:37.000000000 +0000 @@ -82,7 +82,9 @@ void __init mem_init(void) int datapages = 0; int initpages = 0; unsigned long tmp; +#ifndef CONFIG_SUN3 int i; +#endif max_mapnr = num_physpages = (((unsigned long)high_memory - PAGE_OFFSET) >> PAGE_SHIFT); --- diff/arch/m68k/q40/q40ints.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/m68k/q40/q40ints.c 2004-02-23 13:56:38.000000000 +0000 @@ -26,6 +26,7 @@ #include #include #include +#include #include #include --- diff/arch/m68k/sun3/config.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/m68k/sun3/config.c 2004-02-23 13:56:38.000000000 +0000 @@ -160,7 +160,7 @@ void __init config_sun3(void) mach_hwclk = sun3_hwclk; mach_halt = sun3_halt; mach_get_hardware_list = sun3_get_hardware_list; -#if !defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_DUMMY_CONSOLE) +#if defined(CONFIG_DUMMY_CONSOLE) conswitchp = &dummy_con; #endif --- diff/arch/m68k/sun3/sun3ints.c 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/m68k/sun3/sun3ints.c 2004-02-23 13:56:38.000000000 +0000 @@ -15,6 +15,7 @@ #include #include #include +#include #include extern void sun3_leds (unsigned char); --- diff/arch/m68knommu/Kconfig 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/m68knommu/Kconfig 2004-02-23 13:56:37.000000000 +0000 @@ -464,24 +464,6 @@ config COMEMPCI source "drivers/pci/Kconfig" -config HOTPLUG - bool "Support for hot-pluggable device" - ---help--- - Say Y here if you want to plug devices into your computer while - the system is running, and be able to use them quickly. In many - cases, the devices can likewise be unplugged at any time too. - - One well known example of this is PCMCIA- or PC-cards, credit-card - size devices such as network cards, modems or hard drives which are - plugged into slots found on all modern laptop computers. Another - example, used on modern desktops as well as laptops, is USB. - - Enable HOTPLUG and KMOD, and build a modular kernel. Get agent - software (at ) and install it. - Then your kernel will automatically call out to a user mode "policy - agent" (/sbin/hotplug) to load modules and set up software needed - to use devices as you hotplug them. - source "drivers/pcmcia/Kconfig" source "drivers/pci/hotplug/Kconfig" --- diff/arch/m68knommu/kernel/signal.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/m68knommu/kernel/signal.c 2004-02-23 13:56:38.000000000 +0000 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -50,8 +51,6 @@ #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) -asmlinkage long sys_wait4(pid_t pid, unsigned int * stat_addr, int options, - struct rusage * ru); asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs); /* --- diff/arch/m68knommu/kernel/sys_m68k.c 2002-11-11 11:09:42.000000000 +0000 +++ source/arch/m68knommu/kernel/sys_m68k.c 2004-02-23 13:56:38.000000000 +0000 @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -111,8 +112,6 @@ out: return error; } -extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); - struct sel_arg_struct { unsigned long n; fd_set *inp, *outp, *exp; @@ -194,7 +193,7 @@ asmlinkage int sys_ipc (uint call, int f return -EINVAL; } -asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on) +asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int on) { return -ENOSYS; } --- diff/arch/m68knommu/kernel/time.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/m68knommu/kernel/time.c 2004-02-23 13:56:38.000000000 +0000 @@ -199,6 +199,7 @@ int do_settimeofday(struct timespec *tv) time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; write_sequnlock_irq(&xtime_lock); + clock_was_set(); return 0; } --- diff/arch/m68knommu/platform/5407/MOTOROLA/crt0_ram.S 2003-06-09 14:18:17.000000000 +0100 +++ source/arch/m68knommu/platform/5407/MOTOROLA/crt0_ram.S 2004-02-23 13:56:38.000000000 +0000 @@ -99,10 +99,12 @@ _start: movec %d0, %ACR3 /* Enable cache */ - move.l #0xa4098400, %d0 /* Write buffer, dflt precise */ + move.l #0xb6088400, %d0 /* Enable caches */ movec %d0,%CACR nop + +#ifdef CONFIG_ROMFS_FS /* * Move ROM filesystem above bss :-) */ @@ -124,6 +126,12 @@ _copy_romfs: cmp.l %a0, %a2 /* Check if at end */ bne _copy_romfs +#else /* CONFIG_ROMFS_FS */ + lea.l _ebss, %a1 + move.l %a1, _ramstart +#endif /* CONFIG_ROMFS_FS */ + + /* * Zero out the bss region. */ --- diff/arch/mips/Kconfig 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/mips/Kconfig 2004-02-23 13:56:38.000000000 +0000 @@ -1,13 +1,15 @@ config MIPS bool default y + # Horrible source of confusion. Die, die, die ... + select EMBEDDED config MIPS64 bool "64-bit kernel" help Select this option if you want to build a 64-bit kernel. You should only select this option if you have hardware that actually has a - 32-bit processor and if your application will actually benefit from + 64-bit processor and if your application will actually benefit from 64-bit processing, otherwise say N. You must say Y for kernels for SGI IP27 (Origin 200 and 2000). If in doubt say N. @@ -25,14 +27,40 @@ source "init/Kconfig" menu "Machine selection" +config MACH_JAZZ + bool "Support for the Jazz family of machines" + help + This a family of machines based on the MIPS R4030 chipset which was + used by several vendors to build RISC/os and Windows NT workstations. + Members include the Acer PICA, MIPS Magnum 4000, MIPS Millenium and + Olivetti M700-10 workstations. + config ACER_PICA_61 bool "Support for Acer PICA 1 chipset (EXPERIMENTAL)" - depends on EXPERIMENTAL + depends on MACH_JAZZ && EXPERIMENTAL help This is a machine with a R4400 133/150 MHz CPU. To compile a Linux kernel that runs on these, say Y here. For details about Linux on the MIPS architecture, check out the Linux/MIPS FAQ on the WWW at - . + . + +config MIPS_MAGNUM_4000 + bool "Support for MIPS Magnum 4000" + depends on MACH_JAZZ + help + This is a machine with a R4000 100 MHz CPU. To compile a Linux + kernel that runs on these, say Y here. For details about Linux on + the MIPS architecture, check out the Linux/MIPS FAQ on the WWW at + . + +config OLIVETTI_M700 + bool "Support for Olivetti M700-10" + depends on MACH_JAZZ + help + This is a machine with a R4000 100 MHz CPU. To compile a Linux + kernel that runs on these, say Y here. For details about Linux on + the MIPS architecture, check out the Linux/MIPS FAQ on the WWW at + . config BAGET_MIPS bool "Support for BAGET MIPS series (EXPERIMENTAL)" @@ -40,21 +68,59 @@ config BAGET_MIPS help This enables support for the Baget, a Russian embedded system. For more details about the Baget see the Linux/MIPS FAQ on - . + . + +config MACH_VR41XX + bool "Support for NEC VR41XX-based machines" config CASIO_E55 bool "Support for CASIO CASSIOPEIA E-10/15/55/65" + depends on MACH_VR41XX + +config IBM_WORKPAD + bool "Support for IBM WorkPad z50" + depends on MACH_VR41XX + +config NEC_EAGLE + bool "Support for NEC Eagle/Hawk board" + depends on MACH_VR41XX + +config TANBAC_TB0226 + bool "Support for TANBAC TB0226 (Mbase)" + depends on MACH_VR41XX + help + The TANBAC TB0226 (Mbase) is a MIPS-based platform manufactured by TANBAC. + Please refer to about Mbase. + +config TANBAC_TB0229 + bool "Support for TANBAC TB0229 (VR4131DIMM)" + depends on MACH_VR41XX + help + The TANBAC TB0229 (VR4131DIMM) is a MIPS-based platform manufactured by TANBAC. + Please refer to about VR4131DIMM. + +config VICTOR_MPC30X + bool "Support for Victor MP-C303/304" + depends on MACH_VR41XX + +config ZAO_CAPCELLA + bool "Support for ZAO Networks Capcella" + depends on MACH_VR41XX + +config TOSHIBA_JMR3927 + bool "Support for Toshiba JMR-TX3927 board" + depends on MIPS32 config MIPS_COBALT bool "Support for Cobalt Server (EXPERIMENTAL)" depends on EXPERIMENTAL -config DECSTATION +config MACH_DECSTATION bool "Support for DECstations" depends on MIPS32 || EXPERIMENTAL ---help--- This enables support for DEC's MIPS based workstations. For details - see the Linux/MIPS FAQ on and the + see the Linux/MIPS FAQ on and the DECstation porting pages on . If you have one of the following DECstation Models you definitely @@ -74,46 +140,21 @@ config MIPS_EV64120 This is an evaluation board based on the Galileo GT-64120 single-chip system controller that contains a MIPS R5000 compatible core running at 75/100MHz. Their website is located at - . Say Y here if you wish to build a + . Say Y here if you wish to build a kernel for this platform. config EVB_PCI1 bool "Enable Second PCI (PCI1)" depends on MIPS_EV64120 -if MOMENCO_OCELOT_G || MOMENCO_OCELOT - -config SYSCLK_100 - bool - default y - -endif -if MIPS_EV64120 - -choice - prompt "Galileo Chip Clock" - default SYSCLK_83 - -config SYSCLK_75 - bool "75" - -config SYSCLK_83 - bool "83.3" - -config SYSCLK_100 - bool "100" if MIPS_EV64120 - -endchoice - -endif - config MIPS_EV96100 bool "Support for Galileo EV96100 Evaluation board (EXPERIMENTAL)" depends on EXPERIMENTAL + select MIPS_GT96100 help - This is an evaluation board based on the Galielo GT-96100 LAN/WAN + This is an evaluation board based on the Galileo GT-96100 LAN/WAN communications controllers containing a MIPS R5000 compatible core - running at 83MHz. Their website is . Say Y + running at 83MHz. Their website is . Say Y here if you wish to build a kernel for this platform. config MIPS_IVR @@ -122,8 +163,8 @@ config MIPS_IVR This is an evaluation board built by Globespan to showcase thir iVR (Internet Video Recorder) design. It utilizes a QED RM5231 R5000 MIPS core. More information can be found out their website - located at P. Say Y - here if you wish to build a kernel for this platform. + located at . Say Y here if you wish to + build a kernel for this platform. config LASAT bool "Support for LASAT Networks platforms" @@ -147,9 +188,6 @@ config LASAT_SYSCTL config HP_LASERJET bool "Support for Hewlett Packard LaserJet board" -config IBM_WORKPAD - bool "Support for IBM WorkPad z50" - config MIPS_ITE8172 bool "Support for ITE 8172G board" help @@ -166,7 +204,7 @@ config IT8172_REVC Say Y here to support the older, Revision C version of the Integrated Technology Express, Inc. ITE8172 SBC. Vendor page at ; picture of the - board at . + board at . config MIPS_ATLAS bool "Support for MIPS Atlas board" @@ -174,14 +212,6 @@ config MIPS_ATLAS This enables support for the QED R5231-based MIPS Atlas evaluation board. -config MIPS_MAGNUM_4000 - bool "Support for MIPS Magnum 4000" - help - This is a machine with a R4000 100 MHz CPU. To compile a Linux - kernel that runs on these, say Y here. For details about Linux on - the MIPS architecture, check out the Linux/MIPS FAQ on the WWW at - . - config MIPS_MALTA bool "Support for MIPS Malta board" help @@ -210,6 +240,22 @@ config MOMENCO_OCELOT_C The Ocelot is a MIPS-based Single Board Computer (SBC) made by Momentum Computer . +config MOMENCO_JAGUAR_ATX + bool "Support for Momentum Jaguar board" + help + The Jaguar ATX is a MIPS-based Single Board Computer (SBC) made by + Momentum Computer . + +config PMC_YOSEMITE + bool "Support for PMC-Siera Yosemite eval board" + help + Yosemite is an evaluation board for the RM9000x2 processor + manufactured by PMC-Sierra + +config HYPERTRANSPORT + bool "Hypertransport Support for PMC-Sierra Yosemite" + depends on PMC_YOSEMITE + config DDB5074 bool "Support for NEC DDB Vrc-5074 (EXPERIMENTAL)" depends on EXPERIMENTAL @@ -244,17 +290,6 @@ config DDB5477_BUS_FREQUENCY config NEC_OSPREY bool "Support for NEC Osprey board" -config NEC_EAGLE - bool "Support for NEC Eagle/Hawk board" - -config OLIVETTI_M700 - bool "Support for Olivetti M700-10" - help - This is a machine with a R4000 100 MHz CPU. To compile a Linux - kernel that runs on these, say Y here. For details about Linux on - the MIPS architecture, check out the Linux/MIPS FAQ on the WWW at - . - config SGI_IP22 bool "Support for SGI IP22 (Indy/Indigo2)" help @@ -286,8 +321,8 @@ config SGI_SN0_N_MODE running in M-Mode, so you should say N here. config DISCONTIGMEM - bool "Discontiguous Memory Support" - depends on SGI_IP27 + bool + default y if SGI_IP27 help Say Y to upport efficient handling of discontiguous physical memory, for architectures which are either NUMA (Non-Uniform Memory Access) @@ -352,7 +387,7 @@ config SOC_AU1500 endchoice choice - prompt "AMD/Alchemy Pb1x and Db1x board support" + prompt "AMD/Alchemy Au1x00 board support" depends on SOC_AU1X00 help These are evaluation boards built by AMD/Alchemy to @@ -386,6 +421,22 @@ config MIPS_DB1500 bool "DB1500 board" depends on SOC_AU1500 +config MIPS_BOSPORUS + bool "Bosporus board" + depends on SOC_AU1500 + +config MIPS_MIRAGE + bool "Mirage board" + depends on SOC_AU1500 + +config MIPS_XXS1500 + bool "MyCable XXS1500 board" + depends on SOC_AU1500 + +config MIPS_MTX1 + bool "4G Systems MTX-1 board" + depends on SOC_AU1500 + endchoice config SIBYTE_SB1xxx_SOC @@ -393,26 +444,174 @@ config SIBYTE_SB1xxx_SOC depends on EXPERIMENTAL choice - prompt "BCM1xxx SOC Type" + prompt "BCM1xxx SOC-based board" depends on SIBYTE_SB1xxx_SOC - default SIBYTE_SB1250 + default SIBYTE_SWARM + help + Enable support for boards based on the SiByte line of SOCs + from Broadcom. There are configurations for the known + evaluation boards, or you can choose "Other" and add your + own board support code. -config SIBYTE_SB1250 +config SIBYTE_SWARM + bool "BCM91250A-SWARM" + select SIBYTE_SB1250 + +config SIBYTE_SENTOSA + bool "BCM91250E-Sentosa" + select SIBYTE_SB1250 + +config SIBYTE_RHONE + bool "BCM91125E-Rhone" + select SIBYTE_BCM1125H + +config SIBYTE_CARMEL + bool "BCM91120x-Carmel" + select SIBYTE_BCM1120 + +config SIBYTE_PTSWARM + bool "BCM91250PT-PTSWARM" + select SIBYTE_SB1250 + +config SIBYTE_LITTLESUR + bool "BCM91250C2-LittleSur" + select SIBYTE_SB1250 + +config SIBYTE_CRHINE + bool "BCM91120C-CRhine" + select SIBYTE_BCM1120 + +config SIBYTE_CRHONE + bool "BCM91125C-CRhone" + select SIBYTE_BCM1125 + +config SIBYTE_UNKNOWN + bool "Other" + +endchoice + +config SIBYTE_BOARD + bool + depends on SIBYTE_SB1xxx_SOC && !SIBYTE_UNKNOWN + default y + +choice + prompt "BCM1xxx SOC Type" + depends on SIBYTE_UNKNOWN + default SIBYTE_UNK_BCM1250 + help + Since you haven't chosen a known evaluation board from + Broadcom, you must explicitly pick the SOC this kernel is + targetted for. + +config SIBYTE_UNK_BCM1250 bool "BCM1250" + select SIBYTE_SB1250 + +config SIBYTE_UNK_BCM1120 + bool "BCM1120" + select SIBYTE_BCM1120 + +config SIBYTE_UNK_BCM1125 + bool "BCM1125" + select SIBYTE_BCM1125 + +config SIBYTE_UNK_BCM1125H + bool "BCM1125H" + select SIBYTE_BCM1125H endchoice +config SIBYTE_SB1250 + bool + +config SIBYTE_BCM1120 + bool + select SIBYTE_BCM112X + +config SIBYTE_BCM1125 + bool + select SIBYTE_BCM112X + +config SIBYTE_BCM1125H + bool + select SIBYTE_BCM112X + +config SIBYTE_BCM112X + bool + +choice + prompt "SiByte SOC Stepping" + depends on SIBYTE_SB1xxx_SOC + +config CPU_SB1_PASS_1 + bool "1250 Pass1" + depends on SIBYTE_SB1250 + +config CPU_SB1_PASS_2_1250 + bool "1250 An" + depends on SIBYTE_SB1250 + select CPU_SB1_PASS_2 + help + Also called BCM1250 Pass 2 + +config CPU_SB1_PASS_2_2 + bool "1250 Bn" + depends on SIBYTE_SB1250 + help + Also called BCM1250 Pass 2.2 + +config CPU_SB1_PASS_4 + bool "1250 Cn" + depends on SIBYTE_SB1250 + help + Also called BCM1250 Pass 3 + +config CPU_SB1_PASS_2_112x + bool "112x Hybrid" + depends on SIBYTE_BCM112X + select CPU_SB1_PASS_2 + +config CPU_SB1_PASS_3 + bool "112x An" + depends on SIBYTE_BCM112X + +endchoice + +config CPU_SB1_PASS_2 + bool + +config SIBYTE_HAS_PCI + bool + depends on SIBYTE_SB1250 || SIBYTE_BCM1125 || SIBYTE_BCM1125H + default y + +config SIBYTE_HAS_LDT + bool + depends on PCI && (SIBYTE_SB1250 || SIBYTE_BCM1125H) + default y + config SIMULATION bool "Running under simulation" depends on SIBYTE_SB1xxx_SOC + help + Build a kernel suitable for running under the GDB simulator. + Primarily adjusts the kernel's notion of time. config SIBYTE_CFE bool "Booting from CFE" depends on SIBYTE_SB1xxx_SOC + help + Make use of the CFE API for enumerating available memory, + controlling secondary CPUs, and possibly console output. config SIBYTE_CFE_CONSOLE bool "Use firmware console" depends on SIBYTE_CFE + help + Use the CFE API's console write routines during boot. Other console + options (VT console, sb1250 duart console, etc.) should not be + configured. config SIBYTE_STANDALONE bool @@ -421,12 +620,25 @@ config SIBYTE_STANDALONE config SIBYTE_STANDALONE_RAM_SIZE int "Memory size (in megabytes)" - depends on SIBYTE_SB1xxx_SOC && !SIBYTE_CFE + depends on SIBYTE_STANDALONE default "32" config SIBYTE_BUS_WATCHER - bool "Support for Bus Watcher statistics" + bool "Support for Bus Watcher statistics" depends on SIBYTE_SB1xxx_SOC + help + Handle and keep statistics on the bus error interrupts (COR_ECC, + BAD_ECC, IO_BUS). + +config SIBYTE_BW_TRACE + bool "Capture bus trace before bus error" + depends on SIBYTE_BUS_WATCHER + help + Run a continuous bus trace, dumping the raw data as soon as + a ZBbus error is detected. Cannot work if ZBbus profiling + is turned on, and also will interfere with JTAG-based trace + buffer activity. Raw buffer data is dumped to console, and + must be processed off-line. config SIBYTE_SB1250_PROF bool "Support for SB1/SOC profiling - SB1/SCD perf counters" @@ -436,15 +648,6 @@ config SIBYTE_TBPROF bool "Support for ZBbus profiling" depends on SIBYTE_SB1xxx_SOC -config SIBYTE_SWARM - bool "Support for SWARM board" - depends on SIBYTE_SB1250 - -config SIBYTE_BOARD - bool - depends on SIBYTE_SWARM - default y - config SNI_RM200_PCI bool "Support for SNI RM200 PCI" help @@ -453,32 +656,10 @@ config SNI_RM200_PCI Technology and now in turn merged with Fujitsu. Say Y here to support this machine type. -config TANBAC_TB0226 - bool "Support for TANBAC TB0226 (Mbase)" - help - The TANBAC TB0226 (Mbase) is a MIPS-based platform manufactured by TANBAC. - Please refer to about Mbase. - -config TANBAC_TB0229 - bool "Support for TANBAC TB0229 (VR4131DIMM)" - help - The TANBAC TB0229 (VR4131DIMM) is a MIPS-based platform manufactured by TANBAC. - Please refer to about VR4131DIMM. - -config TOSHIBA_JMR3927 - bool "Support for Toshiba JMR-TX3927 board" - depends on MIPS32 - config TOSHIBA_RBTX4927 bool "Support for Toshiba TBTX49[23]7 board" depends on MIPS32 -config VICTOR_MPC30X - bool "Support for Victor MP-C303/304" - -config ZAO_CAPCELLA - bool "Support for ZAO Networks Capcella" - config RWSEM_GENERIC_SPINLOCK bool default y @@ -486,6 +667,10 @@ config RWSEM_GENERIC_SPINLOCK config RWSEM_XCHGADD_ALGORITHM bool +config HAVE_DEC_LOCK + bool + default y + # # Select some configuration options automatically based on user selections. # @@ -494,35 +679,54 @@ config ARC depends on SNI_RM200_PCI || SGI_IP32 || SGI_IP27 || SGI_IP22 || MIPS_MAGNUM_4000 || OLIVETTI_M700 || ACER_PICA_61 default y -config GENERIC_ISA_DMA +config DMA_COHERENT bool - depends on SNI_RM200_PCI || MIPS_MAGNUM_4000 || OLIVETTI_M700 || ACER_PICA_61 + depends on SIBYTE_SB1xxx_SOC + default y + +config DMA_IP27 + bool + depends on SGI_IP27 default y -config CONFIG_GT64120 +config DMA_NONCOHERENT bool - depends on MIPS_EV64120 || MOMENCO_OCELOT + depends on ZAO_CAPCELLA || VICTOR_MPC30X || TOSHIBA_JMR3927 || TOSHIBA_RBTX4927 || SNI_RM200_PCI || SGI_IP32 || SGI_IP22 || NEC_EAGLE || NEC_OSPREY || DDB5477 || DDB5476 || DDB5074 || MOMENCO_OCELOT || MOMENCO_OCELOT_C || MOMENCO_OCELOT_G || MOMENCO_JAGUAR_ATX || MIPS_BOSPORUS || MIPS_DB1000 || MIPS_DB1100 || MIPS_DB1500 || MIPS_SEAD || MIPS_MALTA || MIPS_MAGNUM_4000 || MIPS_MIRAGE || MIPS_MTX1 || MIPS_XXS1500 || OLIVETTI_M700 || MIPS_ATLAS || LASAT || MIPS_ITE8172 || IBM_WORKPAD || HP_LASERJET || MIPS_IVR || MIPS_EV96100 || MIPS_EV64120 || MACH_DECSTATION || MIPS_COBALT || MIPS_PB1500 || MIPS_PB1100 || MIPS_PB1000 || CASIO_E55 || ACER_PICA_61 || TANBAC_TB0226 || TANBAC_TB0229 + default y + +config EARLY_PRINTK + bool + depends on MACH_DECSTATION + default y + +config GENERIC_ISA_DMA + bool + depends on SNI_RM200_PCI || MIPS_MAGNUM_4000 || OLIVETTI_M700 || ACER_PICA_61 || MIPS_MALTA default y config I8259 bool - depends on SNI_RM200_PCI || DDB5477 || DDB5476 || DDB5074 || MIPS_MALTA || MIPS_MAGNUM_4000 || OLIVETTI_M700 || MIPS_COBALT || ACER_PICA_61 + depends on SNI_RM200_PCI || DDB5477 || DDB5476 || DDB5074 || MACH_JAZZ || MIPS_MALTA || MIPS_COBALT + default y + +config MIPS_BONITO64 + bool + depends on MIPS_ATLAS || MIPS_MALTA default y -config MIPS_JAZZ +config MIPS_MSC bool - depends on MIPS_MAGNUM_4000 || OLIVETTI_M700 || ACER_PICA_61 + depends on MIPS_ATLAS || MIPS_MALTA default y -config NONCOHERENT_IO +config MIPS_NILE4 bool - depends on ZAO_CAPCELLA || VICTOR_MPC30X || TOSHIBA_JMR3927 || TOSHIBA_RBTX4927 || SNI_RM200_PCI || SGI_IP32 || SGI_IP22 || NEC_EAGLE || NEC_OSPREY || DDB5477 || DDB5476 || DDB5074 || MOMENCO_OCELOT || MOMENCO_OCELOT_C || MOMENCO_OCELOT_G || MIPS_SEAD || MIPS_MALTA || MIPS_MAGNUM_4000 || OLIVETTI_M700 || MIPS_ATLAS || LASAT || MIPS_ITE8172 || IBM_WORKPAD || HP_LASERJET || MIPS_IVR || MIPS_EV96100 || MIPS_EV64120 || DECSTATION || MIPS_COBALT || MIPS_PB1500 || MIPS_PB1100 || MIPS_PB1000 || CASIO_E55 || ACER_PICA_61 || TANBAC_TB0226 || TANBAC_TB0229 - default y if ZAO_CAPCELLA || VICTOR_MPC30X || TOSHIBA_JMR3927 || TOSHIBA_RBTX4927 || SNI_RM200_PCI || SGI_IP32 || SGI_IP22 || NEC_EAGLE || NEC_OSPREY || DDB5477 || DDB5476 || DDB5074 || MOMENCO_OCELOT_G || MOMENCO_OCELOT || MIPS_SEAD || MIPS_MALTA || MIPS_MAGNUM_4000 || OLIVETTI_M700 || MIPS_ATLAS || LASAT || MIPS_ITE8172 || IBM_WORKPAD || HP_LASERJET || MIPS_IVR || MIPS_EV96100 || MIPS_EV64120 || DECSTATION || MIPS_COBALT || MIPS_PB1500 || MIPS_PB1100 || MIPS_PB1000 || CASIO_E55 || ACER_PICA_61 || TANBAC_TB0226 || TANBAC_TB0229 - default n if (SIBYTE_SB1250 || SGI_IP27) + depends on LASAT + default y config CPU_LITTLE_ENDIAN bool "Generate little endian code" - default y if ACER_PICA_61 || CASIO_E55 || DDB5074 || DDB5476 || DDB5477 || DECSTATION || HP_LASERJET || IBM_WORKPAD || LASAT || MIPS_COBALT || MIPS_ITE8172 || MIPS_IVR || MIPS_PB1000 || MIPS_PB1100 || MIPS_PB1500 || NEC_OSPREY || NEC_EAGLE || OLIVETTI_M700 || SNI_RM200_PCI || VICTOR_MPC30X || ZAO_CAPCELLA + default y if ACER_PICA_61 || CASIO_E55 || DDB5074 || DDB5476 || DDB5477 || MACH_DECSTATION || HP_LASERJET || IBM_WORKPAD || LASAT || MIPS_COBALT || MIPS_ITE8172 || MIPS_IVR || MIPS_PB1000 || MIPS_PB1100 || MIPS_PB1500 || NEC_OSPREY || NEC_EAGLE || OLIVETTI_M700 || SNI_RM200_PCI || VICTOR_MPC30X || ZAO_CAPCELLA default n if BAGET_MIPS || MIPS_EV64120 || MIPS_EV96100 || MOMENCO_OCELOT || MOMENCO_OCELOT_G || SGI_IP22 || SGI_IP27 || SGI_IP32 || TOSHIBA_JMR3927 help Some MIPS machines can be configured for either little or big endian @@ -531,23 +735,22 @@ config CPU_LITTLE_ENDIAN config IRQ_CPU bool - depends on ZAO_CAPCELLA || VICTOR_MPC30X || SGI_IP22 || NEC_EAGLE || NEC_OSPREY || DDB5477 || DDB5476 || DDB5074 || IBM_WORKPAD || HP_LASERJET || DECSTATION || CASIO_E55 || TANBAC_TB0226 || TANBAC_TB0229 + depends on CASIO_E55 || DDB5074 || DDB5476 || DDB5477 || MACH_DECSTATION || HP_LASERJET || IBM_WORKPAD || MIPS_COBALT || MIPS_EV96100 || MOMENCO_OCELOT || MIPS_SEAD || MOMENCO_OCELOT_G || NEC_EAGLE || NEC_OSPREY || SGI_IP22 || VICTOR_MPC30X || TANBAC_TB0226 || TANBAC_TB0229 || ZAO_CAPCELLA default y -config VR41XX_TIME_C +config IRQ_CPU_RM7K bool - depends on ZAO_CAPCELLA || VICTOR_MPC30X || NEC_EAGLE || IBM_WORKPAD || CASIO_E55 || TANBAC_TB0226 || TANBAC_TB0229 + depends on MOMENCO_JAGUAR_ATX || MOMENCO_OCELOT || MOMENCO_OCELOT_G default y config DUMMY_KEYB bool - depends on ZAO_CAPCELLA || VICTOR_MPC30X || SIBYTE_SB1250 || NEC_EAGLE || NEC_OSPREY || DDB5477 || IBM_WORKPAD || CASIO_E55 || TANBAC_TB0226 || TANBAC_TB0229 + depends on ZAO_CAPCELLA || VICTOR_MPC30X || SIBYTE_SB1xxx_SOC || NEC_EAGLE || NEC_OSPREY || DDB5477 || CASIO_E55 || TANBAC_TB0226 || TANBAC_TB0229 default y -config VR41XX_COMMON - bool - depends on NEC_EAGLE || ZAO_CAPCELLA || VICTOR_MPC30X || IBM_WORKPAD || CASIO_E55 || TANBAC_TB0226 || TANBAC_TB0229 - default y +config VRC4171 + tristate "NEC VRC4171 Support" + depends on IBM_WORKPAD config VRC4173 tristate "NEC VRC4173 Support" @@ -563,31 +766,58 @@ config MIPS_BOARDS_GEN depends on MIPS_ATLAS || MIPS_MALTA || MIPS_SEAD default y -config ITE_BOARD_GEN +config MIPS_GT64111 bool - depends on MIPS_IVR || MIPS_ITE8172 + depends on MIPS_COBALT default y -config NEW_PCI +config MIPS_GT64120 bool - depends on ZAO_CAPCELLA || VICTOR_MPC30X || TOSHIBA_JMR3927 || TOSHIBA_RBTX4927 || NEC_EAGLE || DDB5477 || DDB5476 || DDB5074 || MIPS_ITE8172 || HP_LASERJET || MIPS_IVR || MIPS_EV96100 || MIPS_PB1500 || MIPS_PB1100 || MIPS_PB1000 || TANBAC_TB0226 || TANBAC_TB0229 + depends on MIPS_EV64120 || MIPS_EV96100 || LASAT || MIPS_ATLAS || MIPS_MALTA || MOMENCO_OCELOT default y -config SWAP_IO_SPACE - bool "Support for paging of anonymous memory" - depends on TOSHIBA_JMR3927 || TOSHIBA_RBTX4927 || SIBYTE_SB1250 || SGI_IP22 || MOMENCO_OCELOT_C || MOMENCO_OCELOT_G || MOMENCO_OCELOT || MIPS_MALTA || MIPS_ATLAS || MIPS_EV96100 || MIPS_PB1100 || MIPS_PB1000 +config MIPS_MV64340 + bool + depends on MOMENCO_JAGUAR_ATX || MOMENCO_OCELOT_C default y - help - This option allows you to choose whether you want to have support - for socalled swap devices or swap files in your kernel that are - used to provide more virtual memory than the actual RAM present - in your computer. If unusre say Y. -config SIBYTE_HAS_LDT +config MIPS_TX3927 + bool + depends on TOSHIBA_JMR3927 + default y + +config ITE_BOARD_GEN + bool + depends on MIPS_IVR || MIPS_ITE8172 + default y + +config SWAP_IO_SPACE bool - depends on SIBYTE_SB1xxx_SOC && PCI + depends on TOSHIBA_JMR3927 || TOSHIBA_RBTX4927 || SIBYTE_SB1xxx_SOC || SGI_IP22 || MOMENCO_OCELOT_C || MOMENCO_OCELOT_G || MOMENCO_OCELOT || MOMENCO_JAGUAR_ATX || MIPS_MALTA || MIPS_ATLAS || MIPS_EV96100 || MIPS_PB1100 || MIPS_PB1000 default y +# +# Unfortunately not all GT64120 systems run the chip at the same clock. +# As the user for the clock rate and try to minimize the available options. +# +choice + prompt "Galileo Chip Clock" + #default SYSCLK_83 if MIPS_EV64120 + depends on MIPS_EV64120 || MOMENCO_OCELOT || MOMENCO_OCELOT_G + default SYSCLK_83 if MIPS_EV64120 + default SYSCLK_100 if MOMENCO_OCELOT || MOMENCO_OCELOT_G + +config SYSCLK_75 + bool "75" if MIPS_EV64120 + +config SYSCLK_83 + bool "83.3" if MIPS_EV64120 + +config SYSCLK_100 + bool "100" if MIPS_EV64120 || MOMENCO_OCELOT || MOMENCO_OCELOT_G + +endchoice + config AU1000_USB_DEVICE bool depends on MIPS_PB1500 || MIPS_PB1100 || MIPS_PB1000 @@ -598,11 +828,6 @@ config COBALT_LCD depends on MIPS_COBALT default y -config MIPS_GT64120 - bool - depends on MIPS_EV64120 - default y - config MIPS_GT96100 bool depends on MIPS_EV96100 @@ -623,18 +848,18 @@ config IT8712 config BOOT_ELF32 bool - depends on DECSTATION || MIPS_ATLAS || MIPS_MALTA || SIBYTE_SB1250 || SGI_IP32 || SGI_IP22 || SNI_RM200_PCI + depends on MACH_DECSTATION || MIPS_ATLAS || MIPS_MALTA || MOMENCO_JAGUAR_ATX || SIBYTE_SB1xxx_SOC || SGI_IP32 || SGI_IP22 || SNI_RM200_PCI default y -config L1_CACHE_SHIFT +config MIPS_L1_CACHE_SHIFT int - default "4" if DECSTATION - default "5" if SGI_IP32 || SGI_IP22 || MIPS_SEAD || MIPS_MALTA || MIPS_ATLAS + default "4" if MACH_DECSTATION default "7" if SGI_IP27 + default "5" config ARC32 bool - depends on SNI_RM200_PCI || SGI_IP32 || SGI_IP22 || MIPS_MAGNUM_4000 || OLIVETTI_M700 + depends on MACH_JAZZ || SNI_RM200_PCI || SGI_IP22 || SGI_IP32 default y config FB @@ -660,9 +885,8 @@ config FB You need an utility program called fbset to make full use of frame buffer devices. Please read - and the Framebuffer-HOWTO at - for more - information. + and the Framebuffer-HOWTO at + for more information. Say Y here and to the driver for your graphics board below if you are compiling a kernel for a non-x86 architecture. @@ -694,17 +918,17 @@ config ARC_CONSOLE config ARC_MEMORY bool - depends on SNI_RM200_PCI || SGI_IP32 + depends on MACH_JAZZ || SNI_RM200_PCI || SGI_IP32 default y config ARC_PROMLIB bool - depends on SNI_RM200_PCI || SGI_IP32 || SGI_IP22 + depends on MACH_JAZZ || SNI_RM200_PCI || SGI_IP22 || SGI_IP32 default y config BOARD_SCACHE bool - depends on MIPS_EV96100 || MOMENCO_OCELOT || SGI_IP22 + depends on CPU_RM9000 || MIPS_EV96100 || MOMENCO_OCELOT || SGI_IP22 default y config ARC64 @@ -823,11 +1047,48 @@ config CPU_R10000 config CPU_RM7000 bool "RM7000" +config CPU_RM9000 + bool "RM9000" + config CPU_SB1 bool "SB1" endchoice +choice + prompt "Kernel page size" + default PAGE_SIZE_4KB + +config PAGE_SIZE_4KB + bool "4kB" + help + This option select the standard 4kB Linux page size. On some + R3000-family processors this is the only available page size. Using + 4kB page size will minimize memory consumption and is therefore + recommended for low memory systems. + +config PAGE_SIZE_16KB + bool "16kB" + depends on EXPERIMENTAL && !CPU_R3000 && !CPU_TX39XX + help + Using 16kB page size will result in higher performance kernel at + the price of higher memory consumption. This option is available on + all non-R3000 family processor. Not that at the time of this + writing this option is still high experimental; there are also + issues with compatibility of user applications. + +config PAGE_SIZE_64KB + bool "64kB" + depends on EXPERIMENTAL && !CPU_R3000 && !CPU_TX39XX + help + Using 64kB page size will result in higher performance kernel at + the price of higher memory consumption. This option is available on + all non-R3000 family processor. Not that at the time of this + writing this option is still high experimental; there are also + issues with compatibility of user applications. + +endchoice + config R5000_CPU_SCACHE bool depends on CPU_NEVADA || CPU_R5000 @@ -848,28 +1109,12 @@ config SIBYTE_DMA_PAGEOPS config CPU_HAS_PREFETCH bool "Enable prefetches" if CPU_SB1 && !CPU_SB1_PASS_2 - default y if CPU_RM7000 || CPU_MIPS64 || CPU_MIPS32 + default y if CPU_MIPS32 || CPU_MIPS64 || CPU_RM7000 || CPU_RM9000 config VTAG_ICACHE bool "Support for Virtual Tagged I-cache" if CPU_MIPS64 || CPU_MIPS32 default y if CPU_SB1 -choice - prompt "SB1 Pass" - depends on CPU_SB1 - default CPU_SB1_PASS_1 - -config CPU_SB1_PASS_1 - bool "Pass1" - -config CPU_SB1_PASS_2 - bool "Pass2" - -config CPU_SB1_PASS_2_2 - bool "Pass2.2" - -endchoice - config SB1_PASS_1_WORKAROUNDS bool depends on CPU_SB1_PASS_1 @@ -880,23 +1125,14 @@ config SB1_PASS_2_WORKAROUNDS depends on CPU_SB1 && (CPU_SB1_PASS_2_2 || CPU_SB1_PASS_2) default y -# Avoid prefetches on Pass 2 (before 2.2) -# XXXKW for now, let 2.2 use same WORKAROUNDS flag as pre-2.2 -config SB1_CACHE_ERROR - bool "Support for SB1 Cache Error handler" - depends on CPU_SB1 - -config SB1_CERR_IGNORE_RECOVERABLE - bool "Ignore recoverable cache errors" - depends on SB1_CACHE_ERROR - -config SB1_CERR_SPIN - bool "Spin instead of running handler" - depends on SB1_CACHE_ERROR +config SB1_PASS_2_1_WORKAROUNDS + bool + depends on CPU_SB1 && CPU_SB1_PASS_2 + default y config 64BIT_PHYS_ADDR bool "Support for 64-bit physical address space" - depends on (CPU_R4X00 || CPU_R5000 || CPU_RM7000 || CPU_R10000 || CPU_SB1 || CPU_MIPS32 || CPU_MIPS64) && MIPS32 + depends on (CPU_R4X00 || CPU_R5000 || CPU_RM7000 || CPU_RM9000 || CPU_R10000 || CPU_SB1 || CPU_MIPS32 || CPU_MIPS64) && MIPS32 config CPU_ADVANCED bool "Override CPU Options" @@ -927,7 +1163,7 @@ config CPU_HAS_LLDSCD config CPU_HAS_WB bool "Writeback Buffer available" if CPU_ADVANCED - default y if !CPU_ADVANCED && (CPU_R3000 || CPU_VR41XX || CPU_TX39XX) && DECSTATION + default y if !CPU_ADVANCED && CPU_R3000 && MACH_DECSTATION help Say N here for slightly better performance. You must say Y here for machines which require flushing of write buffers in software. Saying @@ -954,11 +1190,11 @@ config CPU_HAS_SYNC # config HIGHMEM bool "High Memory Support" - depends on MIPS32 && (CPU_R3000 || CPU_SB1 || CPU_R7000 || CPU_R10000) && !(BAGET_MIPS || DECSTATION) + depends on MIPS32 && (CPU_R3000 || CPU_SB1 || CPU_R7000 || CPU_R10000) && !(BAGET_MIPS || MACH_DECSTATION) config SMP bool "Multi-Processing support" - depends on SIBYTE_SB1xxx_SOC && SIBYTE_SB1250 && !SIBYTE_STANDALONE || SGI_IP27 + depends on CPU_RM9000 || (SIBYTE_SB1250 && !SIBYTE_STANDALONE) || SGI_IP27 ---help--- This enables support for systems with more than one CPU. If you have a system with only one CPU, like most personal computers, say N. If @@ -980,14 +1216,16 @@ config SMP If you don't know what to do here, say N. config NR_CPUS - int "Maximum number of CPUs (2-32)" - range 2 32 + int "Maximum number of CPUs (2-64)" + range 2 64 depends on SMP - default "32" + default "64" if SGI_IP27 + default "2" help This allows you to specify the maximum number of CPUs which this - kernel will support. The maximum supported value is 32 and the - minimum value which makes sense is 2. + kernel will support. The maximum supported value is 32 for 32-bit + kernel and 64 for 64-bit kernels; the minimum value which makes + sense is 2. This is purely to save memory - each supported CPU adds approximately eight kilobytes to the kernel image. @@ -1001,6 +1239,15 @@ config PREEMPT This allows applications to run more reliably even when the system is under load. +config DEBUG_SPINLOCK + bool "Spinlock debugging" + depends on DEBUG_KERNEL + help + Say Y here and build SMP to catch missing spinlock initialization + and certain other kinds of spinlock errors commonly made. This is + best used in conjunction with the NMI watchdog so that spinlock + deadlocks are also debuggable. + config DEBUG_SPINLOCK_SLEEP bool "Sleep-inside-spinlock checking" help @@ -1031,7 +1278,7 @@ menu "Bus options (PCI, PCMCIA, EISA, IS config PCI bool "Support for PCI controller" - depends on MIPS_DB1000 || DDB5074 || DDB5476 || DDB5477 || HP_LASERJET || LASAT || MIPS_IVR || MIPS_ATLAS || MIPS_COBALT || MIPS_EV64120 || MIPS_EV96100 || MIPS_ITE8172 || MIPS_MALTA || MOMENCO_OCELOT || MOMENCO_OCELOT_C || MOMENCO_OCELOT_G || MIPS_PB1000 || MIPS_PB1100 || MIPS_PB1500 || NEC_EAGLE || SGI_IP27 || SGI_IP32 || SIBYTE_SB1250 || SNI_RM200_PCI || TANBAC_TB0226 || TANBAC_TB0229 || TOSHIBA_JMR3927 || TOSHIBA_RBTX4927 || VICTOR_MPC30X || ZAO_CAPCELLA + depends on MIPS_DB1000 || DDB5074 || DDB5476 || DDB5477 || HP_LASERJET || LASAT || MIPS_IVR || MIPS_ATLAS || MIPS_COBALT || MIPS_EV64120 || MIPS_EV96100 || MIPS_ITE8172 || MIPS_MALTA || MOMENCO_OCELOT || MOMENCO_OCELOT_C || MOMENCO_OCELOT_G || MOMENCO_JAGUAR_ATX || MIPS_PB1000 || MIPS_PB1100 || SOC_AU1500 || NEC_EAGLE || SGI_IP27 || SGI_IP32 || SIBYTE_HAS_PCI || SNI_RM200_PCI || TANBAC_TB0226 || TANBAC_TB0229 || TOSHIBA_JMR3927 || TOSHIBA_RBTX4927 || VICTOR_MPC30X || ZAO_CAPCELLA help Find out whether you have a PCI motherboard. PCI is the name of a bus system, i.e. the way the CPU talks to the other stuff inside @@ -1056,13 +1303,6 @@ config ISA an older system, now being displaced by PCI; newer boards don't support it. If you have ISA, say Y, otherwise N. -# -# The SCSI bits are needed to get the SCSI code to link ... -# -config GENERIC_ISA_DMA - bool - default y if ACER_PICA_61 || MIPS_MAGNUM_4000 || OLIVETTI_M700 || SNI_RM200_PCI || SCSI - config EISA bool "EISA support" depends on ISA && (SGI_IP22 || SNI_RM200_PCI) @@ -1083,7 +1323,7 @@ source "drivers/eisa/Kconfig" config TC bool "TURBOchannel support" - depends on DECSTATION + depends on MACH_DECSTATION help TurboChannel is a DEC (now Compaq (now HP)) bus for Alpha and MIPS processors. Documentation on writing device drivers for TurboChannel @@ -1104,24 +1344,6 @@ config MCA config SBUS bool -config HOTPLUG - bool "Support for hot-pluggable devices" - ---help--- - Say Y here if you want to plug devices into your computer while - the system is running, and be able to use them quickly. In many - cases, the devices can likewise be unplugged at any time too. - - One well known example of this is PCMCIA- or PC-cards, credit-card - size devices such as network cards, modems or hard drives which are - plugged into slots found on all modern laptop computers. Another - example, used on modern desktops as well as laptops, is USB. - - Enable HOTPLUG and KMOD, and build a modular kernel. Get agent - software (at ) and install it. - Then your kernel will automatically call out to a user mode "policy - agent" (/sbin/hotplug) to load modules and set up software needed - to use devices as you hotplug them. - source "drivers/pcmcia/Kconfig" source "drivers/pci/hotplug/Kconfig" @@ -1180,21 +1402,10 @@ config BINFMT_ELF32 config PM bool "Power Management support (EXPERIMENTAL)" - depends on EXPERIMENTAL && SOC_AU1X00 + depends on EXPERIMENTAL && MACH_AU1X00 endmenu -source "drivers/mtd/Kconfig" - -source "drivers/parport/Kconfig" - -source "drivers/pnp/Kconfig" - -source "drivers/base/Kconfig" - -source "drivers/block/Kconfig" - - menu "MIPS initrd options" depends on BLK_DEV_INITRD @@ -1213,79 +1424,10 @@ config EMBEDDED_RAMDISK_IMAGE endmenu -source "drivers/ide/Kconfig" - -source "drivers/scsi/Kconfig" - -source "drivers/cdrom/Kconfig" - -source "drivers/md/Kconfig" - -source "drivers/message/fusion/Kconfig" - -source "drivers/ieee1394/Kconfig" - -source "drivers/message/i2o/Kconfig" - -source "net/Kconfig" - -source "drivers/isdn/Kconfig" - -source "drivers/telephony/Kconfig" - -# -# input before char - char/joystick depends on it. As does USB. -# -source "drivers/input/Kconfig" - -source "drivers/char/Kconfig" - -#source drivers/misc/Config.in - -source "drivers/media/Kconfig" +source "drivers/Kconfig" source "fs/Kconfig" -source "drivers/video/Kconfig" - - -menu "Sound" - -config SOUND - tristate "Sound card support" - ---help--- - If you have a sound card in your computer, i.e. if it can say more - than an occasional beep, say Y. Be sure to have all the information - about your sound card and its configuration down (I/O port, - interrupt and DMA channel), because you will be asked for it. - - You want to read the Sound-HOWTO, available from - . General information about - the modular sound system is contained in the files - . The file - contains some slightly - outdated but still useful information as well. - - If you have a PnP sound card and you want to configure it at boot - time using the ISA PnP tools (read - ), then you need to - compile the sound card support as a module and load that module - after the PnP configuration is finished. To do this, choose M here - and read ; the module - will be called soundcore. - - I'm told that even without a sound card, you can make your computer - say more than an occasional beep, by programming the PC speaker. - Kernel patches and supporting utilities to do that are in the pcsp - package, available at . - -source "sound/Kconfig" - -endmenu - -source "drivers/usb/Kconfig" - - menu "Kernel hacking" config CROSSCOMPILE @@ -1294,12 +1436,32 @@ config CROSSCOMPILE Say Y here if you are compiling the kernel on a different architecture than the one it is intended to run on. +config CMDLINE + string "Default kernel command string" + default "" + help + On some platforms, there is currently no way for the boot loader to + pass arguments to the kernel. For these platforms, you can supply + some command-line options at build time by entering them here. In + other cases you can specify kernel args so that you don't have + to set them up in board prom initialization routines. + config DEBUG_KERNEL bool "Kernel debugging" + config DEBUG_STACK_USAGE + bool "Enable stack utilization instrumentation" + depends on DEBUG_KERNEL + help + Enables the display of the minimum amount of free stack which each + task has ever had available in the sysrq-T and sysrq-P debug output. + + This option will slow down process creation somewhat. + config KGDB bool "Remote GDB kernel debugging" depends on DEBUG_KERNEL + select DEBUG_INFO help If you say Y here, it will be possible to remotely debug the MIPS kernel using gdb. This enlarges your kernel image disk size by @@ -1315,6 +1477,23 @@ config GDB_CONSOLE would like kernel messages to be formatted into GDB $O packets so that GDB prints them as program output, say 'Y'. +config DEBUG_INFO + bool "Compile the kernel with debug info" + depends on DEBUG_KERNEL && !KGDB + default y if KGDB + help + If you say Y here the resulting kernel image will include + debugging info resulting in a larger kernel image. + Say Y here only if you plan to use gdb to debug the kernel. + If you don't debug the kernel, you can say N. + +config SB1XXX_CORELIS + bool "Corelis Debugger" + depends on SIBYTE_SB1xxx_SOC && DEBUG_INFO + help + Select compile flags that produce code that can be processed by the + Corelis mksym utility and UDB Emulator. + config RUNTIME_DEBUG bool "Enable run-time debugging" depends on DEBUG_KERNEL --- diff/arch/mips/Makefile 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/mips/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -5,7 +5,7 @@ # # Copyright (C) 1994, 95, 96, 2003 by Ralf Baechle # DECStation modifications by Paul M. Antoine, 1996 -# Copyright (C) 2002 Maciej W. Rozycki +# Copyright (C) 2002, 2003 Maciej W. Rozycki # # This file is included by the global makefile so that you can add your own # architecture-specific flags and dependencies. Remember to do have actions @@ -16,22 +16,28 @@ # Select the object file format to substitute into the linker script. # ifdef CONFIG_CPU_LITTLE_ENDIAN -32bit-tool-prefix = mips64el-linux- +32bit-tool-prefix = mipsel-linux- 64bit-tool-prefix = mips64el-linux- 32bit-bfd = elf32-tradlittlemips 64bit-bfd = elf64-tradlittlemips else -32bit-tool-prefix = mips64-linux- +32bit-tool-prefix = mips-linux- 64bit-tool-prefix = mips64-linux- 32bit-bfd = elf32-tradbigmips 64bit-bfd = elf64-tradbigmips endif ifdef CONFIG_MIPS32 +gcc-abi = 32 +gas-abi = 32 tool-prefix = $(32bit-tool-prefix) +UTS_MACHINE := mips endif ifdef CONFIG_MIPS64 +gcc-abi = 64 +gas-abi = 32 tool-prefix = $(64bit-tool-prefix) +UTS_MACHINE := mips64 endif ifdef CONFIG_CROSSCOMPILE @@ -50,76 +56,128 @@ endif # cflags-y := -I $(TOPDIR)/include/asm/gcc cflags-y += -G 0 -mno-abicalls -fno-pic -pipe -cflags-$(CONFIG_MIPS32) += $(call check_gcc, -mabi=32,) -cflags-$(CONFIG_MIPS64) += -mabi=64 +cflags-y += $(call check_gcc, -finline-limit=100000,) LDFLAGS_vmlinux += -G 0 -static # -N MODFLAGS += -mlong-calls -cflags-$(CONFIG_KGDB) += -g cflags-$(CONFIG_SB1XXX_CORELIS) += -mno-sched-prolog -fno-omit-frame-pointer check_warning = $(shell if $(CC) $(1) -c -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi) # +# Use: $(call set_gccflags,,,,,) +# +# , -- preferred CPU and ISA designations (may require +# recent tools) +# , -- fallback CPU and ISA designations (have to work +# with up to the oldest supported tools) +# -- an ISA designation used as an ABI selector for +# gcc versions that do not support "-mabi=32" +# (depending on the CPU type, either "mips1" or +# "mips2") +# +set_gccflags = $(shell \ +while :; do \ + cpu=$(1); isa=-$(2); \ + for gcc_opt in -march= -mcpu=; do \ + $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \ + -xc /dev/null > /dev/null 2>&1 && \ + break 2; \ + done; \ + cpu=$(3); isa=-$(4); \ + for gcc_opt in -march= -mcpu=; do \ + $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \ + -xc /dev/null > /dev/null 2>&1 && \ + break 2; \ + done; \ + break; \ +done; \ +gcc_abi=-mabi=$(gcc-abi); gcc_cpu=$$cpu; \ +if $(CC) $$gcc_abi -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then \ + gcc_isa=$$isa; \ +else \ + gcc_abi=; gcc_isa=-$(5); \ +fi; \ +gas_abi=-Wa,-$(gcc-abi); gas_cpu=$$cpu; gas_isa=-Wa,$$isa; \ +while :; do \ + for gas_opt in -Wa,-march= -Wa,-mcpu=; do \ + $(CC) $$gas_abi $$gas_opt$$cpu $$gas_isa -Wa,-Z -c \ + -o /dev/null -xassembler /dev/null > /dev/null 2>&1 && \ + break 2; \ + done; \ + gas_abi=; gas_opt=; gas_cpu=; gas_isa=; \ + break; \ +done; \ +if test x$(gcc-abi) != x$(gas-abi); then \ + gas_abi="-Wa,-$(gas-abi) -Wa,-mgp$(gcc-abi)"; \ +fi; \ +echo $$gcc_abi $$gcc_opt$$gcc_cpu $$gcc_isa $$gas_abi $$gas_opt$$gas_cpu $$gas_isa) + +# # CPU-dependent compiler/assembler options for optimization. -# This is done in several steps: # -# - cflags-y contains the options which select for which processor to -# optimize the code for. The options should not contain any -# options that change the ISA level but only compiler flags to -# tune performance of the generated code. -# - 32bit-isa-y contains the options which select the ISA for 32-bit kernels. -# A kernel built those options will only work on hardware which -# actually supports this ISA. -# - 64bit-isa-y contains the options which select the ISA for 64-bit kernels. -# A kernel built those options will only work on hardware which -# actually supports this ISA. -# -cflags-$(CONFIG_CPU_R3000) += -mcpu=r3000 -32bit-isa-$(CONFIG_CPU_R3000) += -mips1 -64bit-isa-$(CONFIG_CPU_R3000) += -mboom -cflags-$(CONFIG_CPU_TX39XX) += -mcpu=r3000 -32bit-isa-$(CONFIG_CPU_TX39XX) += -mips1 -64bit-isa-$(CONFIG_CPU_TX39XX) += -mboom -cflags-$(CONFIG_CPU_R6000) += -mcpu=r6000 -32bit-isa-$(CONFIG_CPU_R6000) += -mips2 -Wa,--trap -64bit-isa-$(CONFIG_CPU_R6000) += -mboom -Wa,--trap -cflags-$(CONFIG_CPU_R4300) += -mcpu=r4300 -32bit-isa-$(CONFIG_CPU_R4300) += -mips2 -Wa,--trap -64bit-isa-$(CONFIG_CPU_R4300) += -mips3 -Wa,--trap -cflags-$(CONFIG_CPU_VR41XX) += -mcpu=r4600 -32bit-isa-$(CONFIG_CPU_VR41XX) += -mips2 -Wa,--trap -64bit-isa-$(CONFIG_CPU_VR41XX) += -mips3 -Wa,--trap -cflags-$(CONFIG_CPU_R4X00) += -mcpu=r4600 -32bit-isa-$(CONFIG_CPU_R4X00) += -mips2 -Wa,--trap -64bit-isa-$(CONFIG_CPU_R4X00) += -mips3 -Wa,--trap -cflags-$(CONFIG_CPU_MIPS32) += $(call check_gcc, -mtune=mips32, -mcpu=r4600) -32bit-isa-$(CONFIG_CPU_MIPS32) += $(call check_gcc, -mips32 -mabi=32, -mips2) -Wa,--trap -64bit-isa-$(CONFIG_CPU_MIPS32) += -mboom -cflags-$(CONFIG_CPU_MIPS64) += -32bit-isa-$(CONFIG_CPU_MIPS64) += $(call check_gcc, -mips32, -mips2) -Wa,--trap -64bit-isa-$(CONFIG_CPU_MIPS64) += $(call check_gcc, -mips64, -mips4) -Wa,--trap -cflags-$(CONFIG_CPU_R5000) += -mcpu=r8000 -32bit-isa-$(CONFIG_CPU_R5000) += -mips2 -Wa,--trap -64bit-isa-$(CONFIG_CPU_R5000) += -mips4 -Wa,--trap -cflags-$(CONFIG_CPU_R5432) += -mcpu=r5000 -32bit-isa-$(CONFIG_CPU_R5432) += -mips1 -Wa,--trap -64bit-isa-$(CONFIG_CPU_R5432) += -mips3 -Wa,--trap -cflags-$(CONFIG_CPU_NEVADA) += -mcpu=r8000 -mmad -32bit-isa-$(CONFIG_CPU_NEVADA) += -mips2 -Wa,--trap -64bit-isa-$(CONFIG_CPU_NEVADA) += -mips3 -Wa,--trap -cflags-$(CONFIG_CPU_RM7000) += $(call check_gcc, -mcpu=r7000, -mcpu=r5000) -32bit-isa-$(CONFIG_CPU_RM7000) += -mips2 -Wa,--trap -64bit-isa-$(CONFIG_CPU_RM7000) += -mips4 -Wa,--trap -cflags-$(CONFIG_CPU_SB1) += $(call check_gcc, -mcpu=sb1, -mcpu=r8000) -32bit-isa-$(CONFIG_CPU_SB1) += $(call check_gcc, -mips32, -mips2) -Wa,--trap -64bit-isa-$(CONFIG_CPU_SB1) += $(call check_gcc, -mips64, -mips4) -Wa,--trap -cflags-$(CONFIG_CPU_R8000) += -mcpu=r8000 -32bit-isa-$(CONFIG_CPU_R8000) += -mips2 -Wa,--trap -64bit-isa-$(CONFIG_CPU_R8000) += -mips4 -Wa,--trap -cflags-$(CONFIG_CPU_R10000) += -mcpu=r8000 -32bit-isa-$(CONFIG_CPU_R10000) += -mips2 -Wa,--trap -64bit-isa-$(CONFIG_CPU_R10000) += -mips4 -Wa,--trap +cflags-$(CONFIG_CPU_R3000) += \ + $(call set_gccflags,r3000,mips1,r3000,mips1,mips1) + +cflags-$(CONFIG_CPU_TX39XX) += \ + $(call set_gccflags,r3900,mips1,r3000,mips1,mips1) + +cflags-$(CONFIG_CPU_R6000) += \ + $(call set_gccflags,r6000,mips2,r6000,mips2,mips2) \ + -Wa,--trap + +cflags-$(CONFIG_CPU_R4300) += \ + $(call set_gccflags,r4300,mips3,r4300,mips3,mips2) \ + -Wa,--trap + +cflags-$(CONFIG_CPU_VR41XX) += \ + $(call set_gccflags,r4100,mips3,r4600,mips3,mips2) \ + -Wa,--trap + +cflags-$(CONFIG_CPU_R4X00) += \ + $(call set_gccflags,r4600,mips3,r4600,mips3,mips2) \ + -Wa,--trap + +cflags-$(CONFIG_CPU_MIPS32) += \ + $(call set_gccflags,mips32,mips32,r4600,mips3,mips2) \ + -Wa,--trap + +cflags-$(CONFIG_CPU_MIPS64) += \ + $(call set_gccflags,mips64,mips64,r4600,mips3,mips2) \ + -Wa,--trap + +cflags-$(CONFIG_CPU_R5000) += \ + $(call set_gccflags,r5000,mips4,r5000,mips4,mips2) \ + -Wa,--trap + +cflags-$(CONFIG_CPU_R5432) += \ + $(call set_gccflags,r5400,mips4,r5000,mips4,mips2) \ + -Wa,--trap + +cflags-$(CONFIG_CPU_NEVADA) += \ + $(call set_gccflags,rm5200,mips4,r5000,mips4,mips2) \ + -Wa,--trap +# $(call check_gcc,-mmad,) + +cflags-$(CONFIG_CPU_RM7000) += \ + $(call set_gccflags,rm7000,mips4,r5000,mips4,mips2) \ + -Wa,--trap + +cflags-$(CONFIG_CPU_RM9000) += \ + $(call set_gccflags,rm9000,mips4,r5000,mips4,mips2) \ + -Wa,--trap + +cflags-$(CONFIG_CPU_SB1) += \ + $(call set_gccflags,sb1,mips64,r5000,mips4,mips2) \ + -Wa,--trap + +cflags-$(CONFIG_CPU_R8000) += \ + $(call set_gccflags,r8000,mips4,r8000,mips4,mips2) \ + -Wa,--trap + +cflags-$(CONFIG_CPU_R10000) += \ + $(call set_gccflags,r10000,mips4,r8000,mips4,mips2) \ + -Wa,--trap ifdef CONFIG_CPU_SB1 ifdef CONFIG_SB1_PASS_1_WORKAROUNDS @@ -129,13 +187,11 @@ endif # # ramdisk/initrd support -# You need a compressed ramdisk image, named ramdisk.gz in -# arch/mips/ramdisk +# You need a compressed ramdisk image, named +# CONFIG_EMBEDDED_RAMDISK_IMAGE. Relative pathnames +# are relative to arch/mips/ramdisk/. # -ifdef CONFIG_EMBEDDED_RAMDISK -CORE_FILES += arch/mips/ramdisk/ramdisk.o -SUBDIRS += arch/mips/ramdisk -endif +core-$(CONFIG_EMBEDDED_RAMDISK) += arch/mips/ramdisk/ # # Firmware support @@ -150,18 +206,85 @@ libs-$(CONFIG_SIBYTE_CFE) += arch/mips/s # # Acer PICA 61, Mips Magnum 4000 and Olivetti M700. # -core-$(CONFIG_MIPS_JAZZ) += arch/mips/jazz/ -load-$(CONFIG_MIPS_JAZZ) += 0x80080000 +core-$(CONFIG_MACH_JAZZ) += arch/mips/jazz/ +cflags-$(CONFIG_MACH_JAZZ) += -Iinclude/asm-mips/mach-jazz +load-$(CONFIG_MACH_JAZZ) += 0x80080000 +# +# Common Alchemy Au1x00 stuff +# +core-$(CONFIG_SOC_AU1X00) += arch/mips/au1000/common/ +cflags-$(CONFIG_SOC_AU1X00) += -Iinclude/asm-mips/mach-au1x00 # -# Au1500 (Alchemy Semi PB1500) eval board +# AMD Alchemy Pb1000 eval board +# +libs-$(CONFIG_MIPS_PB1000) += arch/mips/au1000/pb1000/ +cflags-$(CONFIG_MIPS_PB1000) += -Iinclude/asm-mips/mach-pb1x00 +load-$(CONFIG_MIPS_PB1000) += 0x80100000 + +# +# AMD Alchemy Pb1100 eval board +# +libs-$(CONFIG_MIPS_PB1100) += arch/mips/au1000/pb1100/ +cflags-$(CONFIG_MIPS_PB1100) += -Iinclude/asm-mips/mach-pb1x00 +load-$(CONFIG_MIPS_PB1100) += 0x80100000 + +# +# AMD Alchemy Pb1500 eval board # -core-$(CONFIG_MIPS_PB1500) += arch/mips/au1000/common/ libs-$(CONFIG_MIPS_PB1500) += arch/mips/au1000/pb1500/ +cflags-$(CONFIG_MIPS_PB1500) += -Iinclude/asm-mips/mach-pb1x00 load-$(CONFIG_MIPS_PB1500) += 0x80100000 # +# AMD Alchemy Db1000 eval board +# +libs-$(CONFIG_MIPS_DB1000) += arch/mips/au1000/db1x00/ +cflags-$(CONFIG_MIPS_DB1000) += -Iinclude/asm-mips/mach-db1x00 +load-$(CONFIG_MIPS_DB1000) += 0x80100000 + +# +# AMD Alchemy Db1100 eval board +# +libs-$(CONFIG_MIPS_DB1100) += arch/mips/au1000/db1x00/ +cflags-$(CONFIG_MIPS_DB1100) += -Iinclude/asm-mips/mach-db1x00 +load-$(CONFIG_MIPS_DB1100) += 0x80100000 + +# +# AMD Alchemy Db1500 eval board +# +libs-$(CONFIG_MIPS_DB1500) += arch/mips/au1000/db1x00/ +cflags-$(CONFIG_MIPS_DB1500) += -Iinclude/asm-mips/mach-db1x00 +load-$(CONFIG_MIPS_DB1500) += 0x80100000 + +# +# AMD Alchemy Bosporus eval board +# +libs-$(CONFIG_MIPS_BOSPORUS) += arch/mips/au1000/db1x00/ +cflags-$(CONFIG_MIPS_BOSPORUS) += -Iinclude/asm-mips/mach-db1x00 +load-$(CONFIG_MIPS_BOSPORUS) += 0x80100000 + +# +# AMD Alchemy Mirage eval board +# +libs-$(CONFIG_MIPS_MIRAGE) += arch/mips/au1000/db1x00/ +cflags-$(CONFIG_MIPS_MIRAGE) += -Iinclude/asm-mips/mach-db1x00 +load-$(CONFIG_MIPS_MIRAGE) += 0x80100000 + +# +# 4G-Systems eval board +# +libs-$(CONFIG_MIPS_MTX1) += arch/mips/au1000/mtx-1/ +load-$(CONFIG_MIPS_MTX1) += 0x80100000 + +# +# MyCable eval board +# +libs-$(CONFIG_MIPS_XXS1500) += arch/mips/au1000/xxs1500/ +load-$(CONFIG_MIPS_XXS1500) += 0x80100000 + +# # Baget/MIPS # libs-$(CONFIG_BAGET_MIPS) += arch/mips/baget/ arch/mips/baget/prom/ @@ -176,22 +299,25 @@ load-$(CONFIG_MIPS_COBALT) += 0x80080000 # # DECstation family # -core-$(CONFIG_DECSTATION) += arch/mips/dec/ -libs-$(CONFIG_DECSTATION) += arch/mips/dec/prom/ -load-$(CONFIG_DECSTATION) += 0x80040000 +core-$(CONFIG_MACH_DECSTATION) += arch/mips/dec/ +cflags-$(CONFIG_MACH_DECSTATION)+= -Iinclude/asm-mips/mach-dec +libs-$(CONFIG_MACH_DECSTATION) += arch/mips/dec/prom/ +load-$(CONFIG_MACH_DECSTATION) += 0x80040000 CLEAN_FILES += drivers/tc/lk201-map.c # # Galileo EV64120 Board # -core-$(CONFIG_MIPS_EV64120) += arch/mips/galileo-boards/ev64120/ +core-$(CONFIG_MIPS_EV64120) += arch/mips/gt64120/ev64120/ +core-$(CONFIG_MIPS_EV64120) += arch/mips/gt64120/common/ +cflags-$(CONFIG_MIPS_EV64120) += -Iinclude/asm-mips/mach-ev64120 load-$(CONFIG_MIPS_EV64120) += 0x80100000 # # Galileo EV96100 Board # -core-$(CONFIG_MIPS_EV96100) += arch/mips/galileo-boards/generic/ \ - arch/mips/galileo-boards/ev96100/ +core-$(CONFIG_MIPS_EV96100) += arch/mips/galileo-boards/ev96100/ +cflags-$(CONFIG_MIPS_EV96100) += -Iinclude/asm-mips/mach-ev96100 load-$(CONFIG_MIPS_EV96100) += 0x80100000 # @@ -214,16 +340,23 @@ core-$(CONFIG_MIPS_ITE8172) += arch/mips load-$(CONFIG_MIPS_ITE8172) += 0x80100000 # -# MIPS Atlas board +# For all MIPS, Inc. eval boards # core-$(CONFIG_MIPS_BOARDS_GEN) += arch/mips/mips-boards/generic/ + +# +# MIPS Atlas board +# core-$(CONFIG_MIPS_ATLAS) += arch/mips/mips-boards/atlas/ +cflags-$(CONFIG_MIPS_ATLAS) += -Iinclude/asm-mips/mach-atlas +cflags-$(CONFIG_MIPS_ATLAS) += -Iinclude/asm-mips/mach-mips load-$(CONFIG_MIPS_ATLAS) += 0x80100000 # # MIPS Malta board # core-$(CONFIG_MIPS_MALTA) += arch/mips/mips-boards/malta/ +cflags-$(CONFIG_MIPS_MALTA) += -Iinclude/asm-mips/mach-mips load-$(CONFIG_MIPS_MALTA) += 0x80100000 # @@ -240,6 +373,7 @@ load-$(CONFIG_MIPS_SEAD) += 0x80100000 # core-$(CONFIG_MOMENCO_OCELOT) += arch/mips/gt64120/common/ \ arch/mips/gt64120/momenco_ocelot/ +cflags-$(CONFIG_MOMENCO_OCELOT) += -Iinclude/asm-mips/mach-ocelot load-$(CONFIG_MOMENCO_OCELOT) += 0x80100000 # @@ -260,9 +394,23 @@ core-$(CONFIG_MOMENCO_OCELOT_C) += arch/ load-$(CONFIG_MOMENCO_OCELOT_C) += 0x80100000 # -# NEC DDB Vrc-5074 +# Momentum Jaguar ATX +# +core-$(CONFIG_MOMENCO_JAGUAR_ATX) += arch/mips/momentum/jaguar_atx/ +ifdef CONFIG_JAGUAR_DMALOW +load-$(CONFIG_MOMENCO_JAGUAR_ATX) += 0x88000000 +else +load-$(CONFIG_MOMENCO_JAGUAR_ATX) += 0x80100000 +endif + +# +# NEC DDB # core-$(CONFIG_DDB5XXX_COMMON) += arch/mips/ddb5xxx/common/ + +# +# NEC DDB Vrc-5074 +# core-$(CONFIG_DDB5074) += arch/mips/ddb5xxx/ddb5074/ load-$(CONFIG_DDB5074) += 0x80080000 @@ -279,6 +427,7 @@ core-$(CONFIG_DDB5477) += arch/mips/ddb load-$(CONFIG_DDB5477) += 0x80100000 core-$(CONFIG_LASAT) += arch/mips/lasat/ +cflags-$(CONFIG_LASAT) += -Iinclude/asm-mips/mach-lasat load-$(CONFIG_LASAT) += 0x80000000 # @@ -289,9 +438,14 @@ core-$(CONFIG_NEC_OSPREY) += arch/mips/v load-$(CONFIG_NEC_OSPREY) += 0x80002000 # +# Common VR41xx +# +core-$(CONFIG_MACH_VR41XX) += arch/mips/vr41xx/common/ +cflags-$(CONFIG_MACH_VR41XX) += -Iinclude/asm-mips/mach-vr41xx + +# # NEC Eagle/Hawk (VR4122/VR4131) board # -core-$(CONFIG_VR41XX_COMMON) += arch/mips/vr41xx/common/ core-$(CONFIG_NEC_EAGLE) += arch/mips/vr41xx/nec-eagle/ load-$(CONFIG_NEC_EAGLE) += 0x80000000 @@ -340,6 +494,7 @@ load-$(CONFIG_TANBAC_TB0229) += 0x800000 # will break so for 64-bit kernels we have to raise the start address by 8kb. # core-$(CONFIG_SGI_IP22) += arch/mips/sgi-ip22/ +cflags-$(CONFIG_SGI_IP22) += -Iinclude/asm-mips/mach-ip22 ifdef CONFIG_MIPS32 load-$(CONFIG_SGI_IP22) += 0x88002000 endif @@ -356,6 +511,7 @@ endif # ifdef CONFIG_SGI_IP27 core-$(CONFIG_SGI_IP27) += arch/mips/sgi-ip27/ +cflags-$(CONFIG_SGI_IP27) += -Iinclude/asm-mips/mach-ip27 #load-$(CONFIG_SGI_IP27) += 0xa80000000001c000 ifdef CONFIG_MAPPED_KERNEL load-$(CONFIG_SGI_IP27) += 0xc001c000 @@ -373,11 +529,12 @@ endif # will break so for 64-bit kernels we have to raise the start address by 8kb. # core-$(CONFIG_SGI_IP32) += arch/mips/sgi-ip32/ +cflags-$(CONFIG_SGI_IP32) += -Iinclude/asm-mips/mach-ip32 ifdef CONFIG_MIPS32 -load-$(CONFIG_SGI_IP32) += 0x88002000 +load-$(CONFIG_SGI_IP32) += 0x80002000 endif ifdef CONFIG_MIPS64 -load-$(CONFIG_SGI_IP32) += 0x88004000 +load-$(CONFIG_SGI_IP32) += 0x80004000 endif # @@ -388,6 +545,7 @@ endif # removed (as happens, even if they have __initcall/module_init) # core-$(CONFIG_SIBYTE_BCM112X) += arch/mips/sibyte/sb1250/ + core-$(CONFIG_SIBYTE_SB1250) += arch/mips/sibyte/sb1250/ # @@ -414,7 +572,8 @@ load-$(CONFIG_SIBYTE_SWARM) := 0x8010000 # SNI RM200 PCI # core-$(CONFIG_SNI_RM200_PCI) += arch/mips/sni/ -load-$(CONFIG_SNI_RM200_PCI) += 0x80080000 +cflags-$(CONFIG_SNI_RM200_PCI) += -Iinclude/asm-mips/mach-rm200 +load-$(CONFIG_SNI_RM200_PCI) += 0x80600000 # # Toshiba JMR-TX3927 board @@ -431,6 +590,7 @@ core-$(CONFIG_TOSHIBA_RBTX4927) += arch/ core-$(CONFIG_TOSHIBA_RBTX4927) += arch/mips/tx4927/common/ load-$(CONFIG_TOSHIBA_RBTX4927) += 0x80020000 +cflags-y += -Iinclude/asm-mips/mach-generic drivers-$(CONFIG_PCI) += arch/mips/pci/ ifdef CONFIG_MIPS32 @@ -463,17 +623,6 @@ endif #AS += -64 #LDFLAGS += -m elf64bmip -ifdef CONFIG_MIPS64 -# -# We use an unusual code model for building 64-bit kernels. 64-bit ELF, -# squeezed into 32-bit ELF files. Later version of gas throw silly warnings -# which requires the use of -mgp64 which not all gas versions have ... -# -GRRR=-Wa,-mgp64 -cflags-$(CONFIG_BOOT_ELF32) += -Wa,-32 $(call check_warning, $(GRRR),) -cflags-$(CONFIG_BOOT_ELF64) += -Wa,-32 $(call check_warning, $(GRRR),) -endif - # # Choosing incompatible machines durings configuration will result in # error messages during linking. Select a default linkscript if @@ -516,25 +665,32 @@ endif ifdef CONFIG_MAPPED_KERNEL vmlinux.64: vmlinux - $(OBJCOPY) -O $(64bit-bfd) --change-addresses=0xbfffffff40000000 $< $@ + $(OBJCOPY) -O $(64bit-bfd) --remove-section=.reginfo \ + --change-addresses=0xc000000080000000 $< $@ else vmlinux.64: vmlinux - $(OBJCOPY) -O $(64bit-bfd) --change-addresses=0xa7ffffff80000000 $< $@ + $(OBJCOPY) -O $(64bit-bfd) --remove-section=.reginfo \ + --change-addresses=0xa800000080000000 $< $@ endif makeboot =$(Q)$(MAKE) -f scripts/Makefile.build obj=arch/mips/boot $(1) -# -# SNI firmware is f*cked in interesting ways ... -# +ifdef CONFIG_SGI_IP27 +all: vmlinux.64 +endif + ifdef CONFIG_SNI_RM200_PCI -all: vmlinux.rm200 +all: vmlinux.ecoff endif vmlinux.ecoff vmlinux.rm200: vmlinux +@$(call makeboot,$@) +vmlinux.srec: vmlinux + +@$(call makeboot,$@) + CLEAN_FILES += vmlinux.ecoff \ + vmlinux.srec \ vmlinux.rm200.tmp \ vmlinux.rm200 @@ -594,4 +750,6 @@ include/asm-$(ARCH)/reg.h: arch/$(ARCH)/ CLEAN_FILES += include/asm-$(ARCH)/offset.h.tmp \ include/asm-$(ARCH)/offset.h \ include/asm-$(ARCH)/reg.h.tmp \ - include/asm-$(ARCH)/reg.h + include/asm-$(ARCH)/reg.h \ + vmlinux.64 \ + vmlinux.ecoff --- diff/arch/mips/arc/cmdline.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/arc/cmdline.c 2004-02-23 13:56:38.000000000 +0000 @@ -16,8 +16,6 @@ #undef DEBUG_CMDLINE -char arcs_cmdline[CL_SIZE]; - char * __init prom_getcmdline(void) { return arcs_cmdline; --- diff/arch/mips/arc/identify.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/arc/identify.c 2004-02-23 13:56:38.000000000 +0000 @@ -63,7 +63,7 @@ static struct smatch mach_table[] = { "SNI RM200_PCI", MACH_GROUP_SNI_RM, MACH_SNI_RM200_PCI, - 0 + PROM_FLAG_DONT_FREE_TEMP } }; --- diff/arch/mips/arc/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/arc/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -10,6 +10,7 @@ #include #include +#include #include #undef DEBUG_PROM_INIT @@ -19,13 +20,13 @@ struct linux_romvec *romvec; int prom_argc; LONG *_prom_argv, *_prom_envp; -void __init prom_init(int argc, char **argv, char **envp, int *prom_vec) +void __init prom_init(void) { PSYSTEM_PARAMETER_BLOCK pb = PROMBLOCK; romvec = ROMVECTOR; - prom_argc = argc; - _prom_argv = (LONG *) argv; - _prom_envp = (LONG *) envp; + prom_argc = fw_arg0; + _prom_argv = (LONG *) fw_arg1; + _prom_envp = (LONG *) fw_arg2; if (pb->magic != 0x53435241) { prom_printf("Aieee, bad prom vector magic %08lx\n", pb->magic); --- diff/arch/mips/arc/memory.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/arc/memory.c 2004-02-23 13:56:38.000000000 +0000 @@ -26,6 +26,12 @@ #undef DEBUG +/* + * For ARC firmware memory functions the unit of meassuring memory is always + * a 4k page of memory + */ +#define ARC_PAGE_SHIFT 12 + struct linux_mdesc * __init ArcGetMemoryDescriptor(struct linux_mdesc *Current) { return (struct linux_mdesc *) ARC_CALL1(get_mdesc, Current); @@ -127,20 +133,23 @@ void __init prom_meminit(void) unsigned long base, size; long type; - base = p->base << PAGE_SHIFT; - size = p->pages << PAGE_SHIFT; + base = p->base << ARC_PAGE_SHIFT; + size = p->pages << ARC_PAGE_SHIFT; type = prom_memtype_classify(p->type); add_memory_region(base, size, type); } } -void __init prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { unsigned long freed = 0; unsigned long addr; int i; + if (prom_flags & PROM_FLAG_DONT_FREE_TEMP) + return 0; + for (i = 0; i < boot_mem_map.nr_map; i++) { if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA) continue; @@ -156,4 +165,6 @@ void __init prom_free_prom_memory (void) } } printk(KERN_INFO "Freeing prom memory: %ldkb freed\n", freed >> 10); + + return freed; } --- diff/arch/mips/arc/misc.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/arc/misc.c 2004-02-23 13:56:38.000000000 +0000 @@ -101,3 +101,8 @@ ArcFlushAllCaches(VOID) { ARC_CALL0(cache_flush); } + +DISPLAY_STATUS * __init ArcGetDisplayStatus(ULONG FileID) +{ + return ARC_CALL1(GetDisplayStatus, FileID); +} --- diff/arch/mips/au1000/common/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/common/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -5,14 +5,11 @@ # # Makefile for the Alchemy Au1000 CPU, generic files. # -# 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). -# obj-y += prom.o int-handler.o dma.o irq.o puts.o \ - time.o reset.o clocks.o power.o + time.o reset.o clocks.o power.o setup.o \ + sleeper.o obj-$(CONFIG_AU1X00_USB_DEVICE) += usbdev.o obj-$(CONFIG_KGDB) += dbg_io.o -obj-$(CONFIG_RTC) += rtc.o +obj-$(CONFIG_PCI) += pci.o --- diff/arch/mips/au1000/common/clocks.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/common/clocks.c 2004-02-23 13:56:38.000000000 +0000 @@ -28,7 +28,7 @@ */ #include -#include +#include static unsigned int au1x00_clock; // Hz static unsigned int lcd_clock; // KHz @@ -85,8 +85,7 @@ void set_au1x00_lcd_clock(void) lcd_clock = sys_busclk / 4; if (lcd_clock > 50000) /* Epson MAX */ - printk("%s: warning: LCD clock too high (%d KHz)\n", - __FUNCTION__, lcd_clock); + printk("warning: LCD clock too high (%d KHz)\n", lcd_clock); } unsigned int get_au1x00_lcd_clock(void) --- diff/arch/mips/au1000/common/dbg_io.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/common/dbg_io.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,7 +1,7 @@ #include #include -#include +#include #ifdef CONFIG_KGDB --- diff/arch/mips/au1000/common/dma.c 2003-09-17 12:28:02.000000000 +0100 +++ source/arch/mips/au1000/common/dma.c 2004-02-23 13:56:38.000000000 +0000 @@ -36,12 +36,12 @@ #include #include #include -#include -#include +#include #include +#include +#include - - +#if defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1100) /* * A note on resource allocation: * @@ -95,7 +95,6 @@ static const struct { {I2S_DATA, DMA_DR | DMA_DW32 | DMA_NC} }; - int au1000_dma_read_proc(char *buf, char **start, off_t fpos, int length, int *eof, void *data) { @@ -152,7 +151,7 @@ void dump_au1000_dma_channel(unsigned in * Requests the DMA done IRQ if irqhandler != NULL. */ int request_au1000_dma(int dev_id, const char *dev_str, - void (*irqhandler)(int, void *, struct pt_regs *), + irqreturn_t (*irqhandler)(int, void *, struct pt_regs *), unsigned long irqflags, void *irq_dev_id) { @@ -198,7 +197,6 @@ int request_au1000_dma(int dev_id, const return i; } - void free_au1000_dma(unsigned int dmanr) { struct dma_chan *chan = get_dma_chan(dmanr); @@ -215,3 +213,4 @@ void free_au1000_dma(unsigned int dmanr) chan->irq_dev = NULL; chan->dev_id = -1; } +#endif // AU1000 AU1500 AU1100 --- diff/arch/mips/au1000/common/irq.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/common/irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -26,6 +26,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include #include #include @@ -46,22 +47,9 @@ #include #include #include -#include - -#if defined(CONFIG_MIPS_PB1000) -#include -#elif defined(CONFIG_MIPS_PB1500) -#include -#elif defined(CONFIG_MIPS_PB1100) -#include -#elif defined(CONFIG_MIPS_DB1000) -#include -#elif defined(CONFIG_MIPS_DB1100) -#include -#elif defined(CONFIG_MIPS_DB1500) -#include -#else -#error unsupported Alchemy board +#include +#ifdef CONFIG_MIPS_PB1000 +#include #endif #undef DEBUG_IRQ @@ -85,8 +73,6 @@ extern void breakpoint(void); extern asmlinkage void au1000_IRQ(void); extern void set_debug_traps(void); extern irq_cpustat_t irq_stat [NR_CPUS]; -unsigned int local_bh_count[NR_CPUS]; -unsigned int local_irq_count[NR_CPUS]; static void setup_local_irq(unsigned int irq, int type, int int_req); static unsigned int startup_irq(unsigned int irq); @@ -94,10 +80,12 @@ static void end_irq(unsigned int irq_nr) static inline void mask_and_ack_level_irq(unsigned int irq_nr); static inline void mask_and_ack_rise_edge_irq(unsigned int irq_nr); static inline void mask_and_ack_fall_edge_irq(unsigned int irq_nr); +static inline void mask_and_ack_either_edge_irq(unsigned int irq_nr); inline void local_enable_irq(unsigned int irq_nr); inline void local_disable_irq(unsigned int irq_nr); extern void __init init_generic_irq(void); +void (*board_init_irq)(void); #ifdef CONFIG_PM extern void counter0_irq(int irq, void *dev_id, struct pt_regs *regs); @@ -121,6 +109,11 @@ static void setup_local_irq(unsigned int au_writel(1<<(irq_nr-32), IC1_CFG1SET); au_writel(1<<(irq_nr-32), IC1_CFG0CLR); break; + case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */ + au_writel(1<<(irq_nr-32), IC1_CFG2CLR); + au_writel(1<<(irq_nr-32), IC1_CFG1SET); + au_writel(1<<(irq_nr-32), IC1_CFG0SET); + break; case INTC_INT_HIGH_LEVEL: /* 1:0:1 */ au_writel(1<<(irq_nr-32), IC1_CFG2SET); au_writel(1<<(irq_nr-32), IC1_CFG1CLR); @@ -163,6 +156,11 @@ static void setup_local_irq(unsigned int au_writel(1< AU1000_LAST_INTC0_INT) { + au_writel(1<<(irq_nr-32), IC1_FALLINGCLR); + au_writel(1<<(irq_nr-32), IC1_RISINGCLR); + au_writel(1<<(irq_nr-32), IC1_MASKCLR); + } + else { + au_writel(1<im_irq, imp->im_type, imp->im_request); - case AU1000_SSI0_INT: - case AU1000_SSI1_INT: -#endif - case AU1000_DMA_INT_BASE: - case AU1000_DMA_INT_BASE+1: - case AU1000_DMA_INT_BASE+2: - case AU1000_DMA_INT_BASE+3: - case AU1000_DMA_INT_BASE+4: - case AU1000_DMA_INT_BASE+5: - case AU1000_DMA_INT_BASE+6: - case AU1000_DMA_INT_BASE+7: - - case AU1000_IRDA_TX_INT: - case AU1000_IRDA_RX_INT: - - case AU1000_MAC0_DMA_INT: -#if defined(CONFIG_MIPS_PB1000) || defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_PB1500) || defined(CONFIG_MIPS_DB1500) - case AU1000_MAC1_DMA_INT: -#endif - case AU1500_GPIO_204: - setup_local_irq(i, INTC_INT_HIGH_LEVEL, 0); - irq_desc[i].handler = &level_irq_type; - break; + switch (imp->im_type) { -#ifdef CONFIG_MIPS_PB1000 - case AU1000_GPIO_15: -#endif - case AU1000_USB_HOST_INT: -#if defined(CONFIG_MIPS_PB1500) || defined(CONFIG_MIPS_DB1500) - case AU1000_PCI_INTA: - case AU1000_PCI_INTB: - case AU1000_PCI_INTC: - case AU1000_PCI_INTD: - case AU1500_GPIO_201: - case AU1500_GPIO_202: - case AU1500_GPIO_203: - case AU1500_GPIO_205: - case AU1500_GPIO_207: -#endif + case INTC_INT_HIGH_LEVEL: + irq_desc[imp->im_irq].handler = &level_irq_type; + break; -#ifdef CONFIG_MIPS_PB1100 - case AU1000_GPIO_9: // PCMCIA Card Fully_Interted# - case AU1000_GPIO_10: // PCMCIA_STSCHG# - case AU1000_GPIO_11: // PCMCIA_IRQ# - case AU1000_GPIO_13: // DC_IRQ# - case AU1000_GPIO_23: // 2-wire SCL -#endif -#if defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) || defined(CONFIG_MIPS_DB1500) - case AU1000_GPIO_0: // PCMCIA Card 0 Fully_Interted# - case AU1000_GPIO_1: // PCMCIA Card 0 STSCHG# - case AU1000_GPIO_2: // PCMCIA Card 0 IRQ# - - case AU1000_GPIO_3: // PCMCIA Card 1 Fully_Interted# - case AU1000_GPIO_4: // PCMCIA Card 1 STSCHG# - case AU1000_GPIO_5: // PCMCIA Card 1 IRQ# -#endif - setup_local_irq(i, INTC_INT_LOW_LEVEL, 0); - irq_desc[i].handler = &level_irq_type; - break; - case AU1000_ACSYNC_INT: - case AU1000_AC97C_INT: - case AU1000_TOY_INT: - case AU1000_TOY_MATCH0_INT: - case AU1000_TOY_MATCH1_INT: - case AU1000_USB_DEV_SUS_INT: - case AU1000_USB_DEV_REQ_INT: - case AU1000_RTC_INT: - case AU1000_RTC_MATCH0_INT: - case AU1000_RTC_MATCH1_INT: - case AU1000_RTC_MATCH2_INT: - setup_local_irq(i, INTC_INT_RISE_EDGE, 0); - irq_desc[i].handler = &rise_edge_irq_type; - break; - - // Careful if you change match 2 request! - // The interrupt handler is called directly - // from the low level dispatch code. - case AU1000_TOY_MATCH2_INT: - setup_local_irq(i, INTC_INT_RISE_EDGE, 1); - irq_desc[i].handler = &rise_edge_irq_type; - break; - default: /* active high, level interrupt */ - setup_local_irq(i, INTC_INT_HIGH_LEVEL, 0); - irq_desc[i].handler = &level_irq_type; - break; + case INTC_INT_LOW_LEVEL: + irq_desc[imp->im_irq].handler = &level_irq_type; + break; + + case INTC_INT_RISE_EDGE: + irq_desc[imp->im_irq].handler = &rise_edge_irq_type; + break; + + case INTC_INT_FALL_EDGE: + irq_desc[imp->im_irq].handler = &fall_edge_irq_type; + break; + + case INTC_INT_RISE_AND_FALL_EDGE: + irq_desc[imp->im_irq].handler = &either_edge_irq_type; + break; + + default: + panic("Unknown au1xxx irq map"); + break; } + imp++; } set_c0_status(ALLINTS); + + /* Board specific IRQ initialization. + */ + if (board_init_irq) + (*board_init_irq)(); + #ifdef CONFIG_KGDB /* If local serial I/O used for debug port, enter kgdb at once */ puts("Waiting for kgdb to connect..."); @@ -516,7 +490,7 @@ void __init init_IRQ(void) void intc0_req0_irqdispatch(struct pt_regs *regs) { - int irq = 0, i; + int irq = 0; static unsigned long intc0_req0 = 0; intc0_req0 |= au_readl(IC0_REQ0INT); @@ -534,43 +508,33 @@ void intc0_req0_irqdispatch(struct pt_re return; } - for (i=0; i<32; i++) { - if ((intc0_req0 & (1< #include #include -#include +#include + +#ifdef CONFIG_PM #define DEBUG 1 #ifdef DEBUG @@ -48,13 +50,12 @@ # define DPRINTK(fmt, args...) #endif -extern void au1k_wait(void); static void calibrate_delay(void); -extern void set_au1000_speed(unsigned int new_freq); -extern unsigned int get_au1000_speed(void); -extern unsigned long get_au1000_uart_baud_base(void); -extern void set_au1000_uart_baud_base(unsigned long new_baud_base); +extern void set_au1x00_speed(unsigned int new_freq); +extern unsigned int get_au1x00_speed(void); +extern unsigned long get_au1x00_uart_baud_base(void); +extern void set_au1x00_uart_baud_base(unsigned long new_baud_base); extern unsigned long save_local_and_disable(int controller); extern void restore_local_and_enable(int controller, unsigned long mask); extern void local_enable_irq(unsigned int irq_nr); @@ -64,10 +65,144 @@ extern void local_enable_irq(unsigned in #define ACPI_S1_SLP_TYP 19 #define ACPI_SLEEP 21 -#ifdef CONFIG_PM static spinlock_t pm_lock = SPIN_LOCK_UNLOCKED; +/* We need to save/restore a bunch of core registers that are + * either volatile or reset to some state across a processor sleep. + * If reading a register doesn't provide a proper result for a + * later restore, we have to provide a function for loading that + * register and save a copy. + * + * We only have to save/restore registers that aren't otherwise + * done as part of a driver pm_* function. + */ +static uint sleep_aux_pll_cntrl; +static uint sleep_cpu_pll_cntrl; +static uint sleep_pin_function; +static uint sleep_uart0_inten; +static uint sleep_uart0_fifoctl; +static uint sleep_uart0_linectl; +static uint sleep_uart0_clkdiv; +static uint sleep_uart0_enable; +static uint sleep_usbhost_enable; +static uint sleep_usbdev_enable; +static uint sleep_static_memctlr[4][3]; + +/* Define this to cause the value you write to /proc/sys/pm/sleep to + * set the TOY timer for the amount of time you want to sleep. + * This is done mainly for testing, but may be useful in other cases. + * The value is number of 32KHz ticks to sleep. + */ +#define SLEEP_TEST_TIMEOUT 1 +#ifdef SLEEP_TEST_TIMEOUT +static int sleep_ticks; +void wakeup_counter0_set(int ticks); +#endif + +static void +save_core_regs(void) +{ + extern void save_au1xxx_intctl(void); + extern void pm_eth0_shutdown(void); + + /* Do the serial ports.....these really should be a pm_* + * registered function by the driver......but of course the + * standard serial driver doesn't understand our Au1xxx + * unique registers. + */ + sleep_uart0_inten = au_readl(UART0_ADDR + UART_IER); + sleep_uart0_fifoctl = au_readl(UART0_ADDR + UART_FCR); + sleep_uart0_linectl = au_readl(UART0_ADDR + UART_LCR); + sleep_uart0_clkdiv = au_readl(UART0_ADDR + UART_CLK); + sleep_uart0_enable = au_readl(UART0_ADDR + UART_MOD_CNTRL); + + /* Shutdown USB host/device. + */ + sleep_usbhost_enable = au_readl(USB_HOST_CONFIG); + + /* There appears to be some undocumented reset register.... + */ + au_writel(0, 0xb0100004); au_sync(); + au_writel(0, USB_HOST_CONFIG); au_sync(); + + sleep_usbdev_enable = au_readl(USBD_ENABLE); + au_writel(0, USBD_ENABLE); au_sync(); + + /* Save interrupt controller state. + */ + save_au1xxx_intctl(); + + /* Clocks and PLLs. + */ + sleep_aux_pll_cntrl = au_readl(SYS_AUXPLL); + + /* We don't really need to do this one, but unless we + * write it again it won't have a valid value if we + * happen to read it. + */ + sleep_cpu_pll_cntrl = au_readl(SYS_CPUPLL); + + sleep_pin_function = au_readl(SYS_PINFUNC); + + /* Save the static memory controller configuration. + */ + sleep_static_memctlr[0][0] = au_readl(MEM_STCFG0); + sleep_static_memctlr[0][1] = au_readl(MEM_STTIME0); + sleep_static_memctlr[0][2] = au_readl(MEM_STADDR0); + sleep_static_memctlr[1][0] = au_readl(MEM_STCFG1); + sleep_static_memctlr[1][1] = au_readl(MEM_STTIME1); + sleep_static_memctlr[1][2] = au_readl(MEM_STADDR1); + sleep_static_memctlr[2][0] = au_readl(MEM_STCFG2); + sleep_static_memctlr[2][1] = au_readl(MEM_STTIME2); + sleep_static_memctlr[2][2] = au_readl(MEM_STADDR2); + sleep_static_memctlr[3][0] = au_readl(MEM_STCFG3); + sleep_static_memctlr[3][1] = au_readl(MEM_STTIME3); + sleep_static_memctlr[3][2] = au_readl(MEM_STADDR3); +} + +static void +restore_core_regs(void) +{ + extern void restore_au1xxx_intctl(void); + extern void wakeup_counter0_adjust(void); + + au_writel(sleep_aux_pll_cntrl, SYS_AUXPLL); au_sync(); + au_writel(sleep_cpu_pll_cntrl, SYS_CPUPLL); au_sync(); + au_writel(sleep_pin_function, SYS_PINFUNC); au_sync(); + + /* Restore the static memory controller configuration. + */ + au_writel(sleep_static_memctlr[0][0], MEM_STCFG0); + au_writel(sleep_static_memctlr[0][1], MEM_STTIME0); + au_writel(sleep_static_memctlr[0][2], MEM_STADDR0); + au_writel(sleep_static_memctlr[1][0], MEM_STCFG1); + au_writel(sleep_static_memctlr[1][1], MEM_STTIME1); + au_writel(sleep_static_memctlr[1][2], MEM_STADDR1); + au_writel(sleep_static_memctlr[2][0], MEM_STCFG2); + au_writel(sleep_static_memctlr[2][1], MEM_STTIME2); + au_writel(sleep_static_memctlr[2][2], MEM_STADDR2); + au_writel(sleep_static_memctlr[3][0], MEM_STCFG3); + au_writel(sleep_static_memctlr[3][1], MEM_STTIME3); + au_writel(sleep_static_memctlr[3][2], MEM_STADDR3); + + /* Enable the UART if it was enabled before sleep. + * I guess I should define module control bits........ + */ + if (sleep_uart0_enable & 0x02) { + au_writel(0, UART0_ADDR + UART_MOD_CNTRL); au_sync(); + au_writel(1, UART0_ADDR + UART_MOD_CNTRL); au_sync(); + au_writel(3, UART0_ADDR + UART_MOD_CNTRL); au_sync(); + au_writel(sleep_uart0_inten, UART0_ADDR + UART_IER); au_sync(); + au_writel(sleep_uart0_fifoctl, UART0_ADDR + UART_FCR); au_sync(); + au_writel(sleep_uart0_linectl, UART0_ADDR + UART_LCR); au_sync(); + au_writel(sleep_uart0_clkdiv, UART0_ADDR + UART_CLK); au_sync(); + } + + restore_au1xxx_intctl(); + wakeup_counter0_adjust(); +} + unsigned long suspend_mode; void wakeup_from_suspend(void) @@ -78,33 +213,48 @@ void wakeup_from_suspend(void) int au_sleep(void) { unsigned long wakeup, flags; + extern void save_and_sleep(void); + spin_lock_irqsave(&pm_lock,flags); + save_core_regs(); + flush_cache_all(); - /* pin 6 is gpio */ + + /** The code below is all system dependent and we should probably + ** have a function call out of here to set this up. You need + ** to configure the GPIO or timer interrupts that will bring + ** you out of sleep. + ** For testing, the TOY counter wakeup is useful. + **/ + +#if 0 au_writel(au_readl(SYS_PINSTATERD) & ~(1 << 11), SYS_PINSTATERD); /* gpio 6 can cause a wake up event */ wakeup = au_readl(SYS_WAKEMSK); wakeup &= ~(1 << 8); /* turn off match20 wakeup */ wakeup |= 1 << 6; /* turn on gpio 6 wakeup */ - au_writel(wakeup, SYS_WAKEMSK); - +#else + /* For testing, allow match20 to wake us up. + */ +#ifdef SLEEP_TEST_TIMEOUT + wakeup_counter0_set(sleep_ticks); +#endif + wakeup = 1 << 8; /* turn on match20 wakeup */ + wakeup = 0; +#endif au_writel(1, SYS_WAKESRC); /* clear cause */ - au_writel(1, SYS_SLPPWR); /* prepare to sleep */ + au_sync(); + au_writel(wakeup, SYS_WAKEMSK); + au_sync(); - __asm__("la $4, 1f\n\t" - "lui $5, 0xb190\n\t" - "ori $5, 0x18\n\t" - "sw $4, 0($5)\n\t" - "li $4, 1\n\t" - "lui $5, 0xb190\n\t" - "ori $5, 0x7c\n\t" - "sw $4, 0($5)\n\t" "sync\n\t" "1:\t\n\t" "nop\n\t"); + save_and_sleep(); /* after a wakeup, the cpu vectors back to 0x1fc00000 so * it's up to the boot code to get us back here. */ + restore_core_regs(); spin_unlock_irqrestore(&pm_lock, flags); return 0; } @@ -113,11 +263,27 @@ static int pm_do_sleep(ctl_table * ctl, void *buffer, size_t * len) { int retval = 0; +#ifdef SLEEP_TEST_TIMEOUT +#define TMPBUFLEN2 16 + char buf[TMPBUFLEN2], *p; +#endif if (!write) { *len = 0; } else { +#ifdef SLEEP_TEST_TIMEOUT + if (*len > TMPBUFLEN2 - 1) { + return -EFAULT; + } + if (copy_from_user(buf, buffer, *len)) { + return -EFAULT; + } + buf[*len] = 0; + p = buf; + sleep_ticks = simple_strtoul(p, &p, 0); +#endif retval = pm_send_all(PM_SUSPEND, (void *) 2); + if (retval) return retval; @@ -131,6 +297,7 @@ static int pm_do_suspend(ctl_table * ctl void *buffer, size_t * len) { int retval = 0; + void au1k_wait(void); if (!write) { *len = 0; @@ -187,13 +354,13 @@ static int pm_do_freq(ctl_table * ctl, i return -EFAULT; } - old_baud_base = get_au1000_uart_baud_base(); - old_cpu_freq = get_au1000_speed(); + old_baud_base = get_au1x00_uart_baud_base(); + old_cpu_freq = get_au1x00_speed(); new_cpu_freq = pll * 12 * 1000000; new_baud_base = (new_cpu_freq / 4) / 16; - set_au1000_speed(new_cpu_freq); - set_au1000_uart_baud_base(new_baud_base); + set_au1x00_speed(new_cpu_freq); + set_au1x00_uart_baud_base(new_baud_base); old_refresh = au_readl(MEM_SDREFCFG) & 0x1ffffff; new_refresh = @@ -323,10 +490,4 @@ static void calibrate_delay(void) loops_per_jiffy &= ~loopbit; } } - -void au1k_wait(void) -{ - __asm__("nop\n\t" "nop\n\t"); -} - #endif /* CONFIG_PM */ --- diff/arch/mips/au1000/common/prom.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/common/prom.c 2004-02-23 13:56:38.000000000 +0000 @@ -44,7 +44,6 @@ /* #define DEBUG_CMDLINE */ -char arcs_cmdline[CL_SIZE]; extern int prom_argc; extern char **prom_argv, **prom_envp; @@ -153,6 +152,11 @@ int get_ethernet_addr(char *ethernet_add return 0; } -void prom_free_prom_memory (void) {} +unsigned long __init prom_free_prom_memory(void) +{ + return 0; +} + EXPORT_SYMBOL(prom_getcmdline); EXPORT_SYMBOL(get_ethernet_addr); +EXPORT_SYMBOL(str2eaddr); --- diff/arch/mips/au1000/common/puts.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/common/puts.c 2004-02-23 13:56:38.000000000 +0000 @@ -29,7 +29,7 @@ */ #include -#include +#include #define SERIAL_BASE UART_BASE #define SER_CMD 0x7 @@ -40,11 +40,11 @@ #define SLOW_DOWN static const char digits[16] = "0123456789abcdef"; -static volatile unsigned long * const com1 = (unsigned char *)SERIAL_BASE; +static volatile unsigned long * const com1 = (unsigned long *)SERIAL_BASE; #ifdef SLOW_DOWN -static inline void slow_down() +static inline void slow_down(void) { int k; for (k=0; k<10000; k++); --- diff/arch/mips/au1000/common/reset.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/common/reset.c 2004-02-23 13:56:38.000000000 +0000 @@ -35,9 +35,10 @@ #include #include #include -#include +#include extern int au_sleep(void); +extern void (*flush_cache_all)(void); void au1000_restart(char *command) { @@ -54,6 +55,10 @@ void au1000_restart(char *command) au_writel(0x00, 0xb017fffc); /* usbh_enable */ au_writel(0x00, 0xb0200058); /* usbd_enable */ au_writel(0x00, 0xb0300040); /* ir_enable */ + au_writel(0x00, 0xb4004104); /* mac dma */ + au_writel(0x00, 0xb4004114); /* mac dma */ + au_writel(0x00, 0xb4004124); /* mac dma */ + au_writel(0x00, 0xb4004134); /* mac dma */ au_writel(0x00, 0xb0520000); /* macen0 */ au_writel(0x00, 0xb0520004); /* macen1 */ au_writel(0x00, 0xb1000008); /* i2s_enable */ @@ -66,6 +71,8 @@ void au1000_restart(char *command) au_writel(0x00, 0xb1900020); /* sys_freqctrl0 */ au_writel(0x00, 0xb1900024); /* sys_freqctrl1 */ au_writel(0x00, 0xb1900028); /* sys_clksrc */ + au_writel(0x10, 0xb1900060); /* sys_cpupll */ + au_writel(0x00, 0xb1900064); /* sys_auxpll */ au_writel(0x00, 0xb1900100); /* sys_pininputen */ break; case 0x01000000: /* Au1500 */ @@ -74,6 +81,10 @@ void au1000_restart(char *command) asm("sync"); au_writel(0x00, 0xb017fffc); /* usbh_enable */ au_writel(0x00, 0xb0200058); /* usbd_enable */ + au_writel(0x00, 0xb4004104); /* mac dma */ + au_writel(0x00, 0xb4004114); /* mac dma */ + au_writel(0x00, 0xb4004124); /* mac dma */ + au_writel(0x00, 0xb4004134); /* mac dma */ au_writel(0x00, 0xb1520000); /* macen0 */ au_writel(0x00, 0xb1520004); /* macen1 */ au_writel(0x00, 0xb1100100); /* uart0_enable */ @@ -81,6 +92,8 @@ void au1000_restart(char *command) au_writel(0x00, 0xb1900020); /* sys_freqctrl0 */ au_writel(0x00, 0xb1900024); /* sys_freqctrl1 */ au_writel(0x00, 0xb1900028); /* sys_clksrc */ + au_writel(0x10, 0xb1900060); /* sys_cpupll */ + au_writel(0x00, 0xb1900064); /* sys_auxpll */ au_writel(0x00, 0xb1900100); /* sys_pininputen */ break; case 0x02000000: /* Au1100 */ @@ -90,6 +103,10 @@ void au1000_restart(char *command) au_writel(0x00, 0xb017fffc); /* usbh_enable */ au_writel(0x00, 0xb0200058); /* usbd_enable */ au_writel(0x00, 0xb0300040); /* ir_enable */ + au_writel(0x00, 0xb4004104); /* mac dma */ + au_writel(0x00, 0xb4004114); /* mac dma */ + au_writel(0x00, 0xb4004124); /* mac dma */ + au_writel(0x00, 0xb4004134); /* mac dma */ au_writel(0x00, 0xb0520000); /* macen0 */ au_writel(0x00, 0xb1000008); /* i2s_enable */ au_writel(0x00, 0xb1100100); /* uart0_enable */ @@ -100,6 +117,8 @@ void au1000_restart(char *command) au_writel(0x00, 0xb1900020); /* sys_freqctrl0 */ au_writel(0x00, 0xb1900024); /* sys_freqctrl1 */ au_writel(0x00, 0xb1900028); /* sys_clksrc */ + au_writel(0x10, 0xb1900060); /* sys_cpupll */ + au_writel(0x00, 0xb1900064); /* sys_auxpll */ au_writel(0x00, 0xb1900100); /* sys_pininputen */ break; --- diff/arch/mips/au1000/common/time.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/au1000/common/time.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,10 +1,13 @@ /* + * * Copyright (C) 2001 MontaVista Software, ppopov@mvista.com * Copied and modified Carsten Langgaard's time.c * * Carsten Langgaard, carstenl@mips.com * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. * + * ######################################################################## + * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. @@ -18,13 +21,21 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * + * ######################################################################## + * * Setting up the clock on the MIPS boards. + * + * Update. Always configure the kernel with CONFIG_NEW_TIME_C. This + * will use the user interface gettimeofday() functions from the + * arch/mips/kernel/time.c, and we provide the clock interrupt processing + * and the timer offset compute functions. If CONFIG_PM is selected, + * we also ensure the 32KHz timer is available. -- Dan */ + #include #include #include #include -#include #include #include @@ -33,18 +44,20 @@ #include #include #include -#include +#include #include #include extern void startup_match20_interrupt(void); +extern void do_softirq(void); extern volatile unsigned long wall_jiffies; unsigned long missed_heart_beats = 0; static unsigned long r4k_offset; /* Amount to increment compare reg each time */ static unsigned long r4k_cur; /* What counter should be at next timer irq */ -extern unsigned int mips_counter_frequency; +int no_au1xxx_32khz; +void (*au1k_wait_ptr)(void); /* Cycle counter value at the previous timer interrupt.. */ static unsigned int timerhi = 0, timerlo = 0; @@ -72,17 +85,10 @@ void mips_timer_interrupt(struct pt_regs { int irq = 63; unsigned long count; - int cpu = smp_processor_id(); irq_enter(); kstat_this_cpu.irqs[irq]++; -#ifdef CONFIG_PM - printk(KERN_ERR "Unexpected CP0 interrupt\n"); - regs->cp0_status &= ~IE_IRQ5; /* disable CP0 interrupt */ - return; -#endif - if (r4k_offset == 0) goto null; @@ -100,7 +106,6 @@ void mips_timer_interrupt(struct pt_regs - r4k_cur) < 0x7fffffff); irq_exit(); - return; null: @@ -114,7 +119,7 @@ void counter0_irq(int irq, void *dev_id, int time_elapsed; static int jiffie_drift = 0; - kstat_this_cpu.irqs[irq]++; + kstat.irqs[0][irq]++; if (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20) { /* should never happen! */ printk(KERN_WARNING "counter 0 w status eror\n"); @@ -150,119 +155,148 @@ void counter0_irq(int irq, void *dev_id, do_timer(regs); /* increment jiffies by one */ } } -#endif -/* - * Figure out the r4k offset, the amount to increment the compare - * register for each time tick. - * Use the Programmable Counter 1 to do this. +/* When we wakeup from sleep, we have to "catch up" on all of the + * timer ticks we have missed. */ -unsigned long cal_r4koff(void) +void +wakeup_counter0_adjust(void) { - unsigned long count; - unsigned long cpu_speed; - unsigned long start, end; - unsigned long counter; - int trim_divide = 16; - unsigned long flags; - - spin_lock_irqsave(&time_lock, flags); + unsigned long pc0; + int time_elapsed; - counter = au_readl(SYS_COUNTER_CNTRL); - au_writel(counter | SYS_CNTRL_EN1, SYS_COUNTER_CNTRL); + pc0 = au_readl(SYS_TOYREAD); + if (pc0 < last_match20) { + /* counter overflowed */ + time_elapsed = (0xffffffff - last_match20) + pc0; + } + else { + time_elapsed = pc0 - last_match20; + } - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T1S); - au_writel(trim_divide-1, SYS_RTCTRIM); /* RTC now ticks at 32.768/16 kHz */ - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T1S); - - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S); - au_writel (0, SYS_TOYWRITE); - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S); - - start = au_readl(SYS_RTCREAD); - start += 2; - /* wait for the beginning of a new tick */ - while (au_readl(SYS_RTCREAD) < start); - - /* Start r4k counter. */ - write_c0_count(0); - end = start + (32768 / trim_divide)/2; /* wait 0.5 seconds */ + while (time_elapsed > 0) { + time_elapsed -= MATCH20_INC; + last_match20 += MATCH20_INC; + } - while (end > au_readl(SYS_RTCREAD)); + last_pc0 = pc0; + au_writel(last_match20 + MATCH20_INC, SYS_TOYMATCH2); + au_sync(); - count = read_c0_count(); - cpu_speed = count * 2; - mips_counter_frequency = count; - set_au1x00_uart_baud_base(((cpu_speed) / 4) / 16); - spin_unlock_irqrestore(&time_lock, flags); - return (cpu_speed / HZ); } -void __init au1x_time_init(void) +/* This is just for debugging to set the timer for a sleep delay. +*/ +void +wakeup_counter0_set(int ticks) { - unsigned int est_freq; - - printk("calculating r4koff... "); - r4k_offset = cal_r4koff(); - printk("%08lx(%d)\n", r4k_offset, (int) r4k_offset); + unsigned long pc0; - //est_freq = 2*r4k_offset*HZ; - est_freq = r4k_offset*HZ; - est_freq += 5000; /* round */ - est_freq -= est_freq%10000; - printk("CPU frequency %d.%02d MHz\n", est_freq/1000000, - (est_freq%1000000)*100/1000000); - set_au1x00_speed(est_freq); - set_au1x00_lcd_clock(); // program the LCD clock - r4k_cur = (read_c0_count() + r4k_offset); + pc0 = au_readl(SYS_TOYREAD); + last_pc0 = pc0; + au_writel(last_match20 + (MATCH20_INC * ticks), SYS_TOYMATCH2); + au_sync(); +} +#endif - write_c0_compare(r4k_cur); +/* I haven't found anyone that doesn't use a 12 MHz source clock, + * but just in case..... + */ +#ifdef CONFIG_AU1000_SRC_CLK +#define AU1000_SRC_CLK CONFIG_AU1000_SRC_CLK +#else +#define AU1000_SRC_CLK 12000000 +#endif - /* no RTC on the pb1000 */ - xtime.tv_sec = 0; - //xtime.tv_usec = 0; +/* + * We read the real processor speed from the PLL. This is important + * because it is more accurate than computing it from the 32KHz + * counter, if it exists. If we don't have an accurate processor + * speed, all of the peripherals that derive their clocks based on + * this advertised speed will introduce error and sometimes not work + * properly. This function is futher convoluted to still allow configurations + * to do that in case they have really, really old silicon with a + * write-only PLL register, that we need the 32KHz when power management + * "wait" is enabled, and we need to detect if the 32KHz isn't present + * but requested......got it? :-) -- Dan + */ +unsigned long cal_r4koff(void) +{ + unsigned long count; + unsigned long cpu_speed; + unsigned long flags; + unsigned long counter; -#ifdef CONFIG_PM - /* - * setup counter 0, since it keeps ticking after a - * 'wait' instruction has been executed. The CP0 timer and - * counter 1 do NOT continue running after 'wait' - * - * It's too early to call request_irq() here, so we handle - * counter 0 interrupt as a special irq and it doesn't show - * up under /proc/interrupts. - */ - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S); - au_writel(0, SYS_TOYWRITE); - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S); + spin_lock_irqsave(&time_lock, flags); - au_writel(au_readl(SYS_WAKEMSK) | (1<<8), SYS_WAKEMSK); - au_writel(~0, SYS_WAKESRC); - au_sync(); - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20); + /* Power management cares if we don't have a 32KHz counter. + */ + no_au1xxx_32khz = 0; + counter = au_readl(SYS_COUNTER_CNTRL); + if (counter & SYS_CNTRL_E0) { + int trim_divide = 16; - /* setup match20 to interrupt once every 10ms */ - last_pc0 = last_match20 = au_readl(SYS_TOYREAD); - au_writel(last_match20 + MATCH20_INC, SYS_TOYMATCH2); - au_sync(); - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20); - startup_match20_interrupt(); -#endif + au_writel(counter | SYS_CNTRL_EN1, SYS_COUNTER_CNTRL); - //set_c0_status(ALLINTS); - au_sync(); -} + while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T1S); + /* RTC now ticks at 32.768/16 kHz */ + au_writel(trim_divide-1, SYS_RTCTRIM); + while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T1S); + + while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S); + au_writel (0, SYS_TOYWRITE); + while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S); + +#if defined(CONFIG_AU1000_USE32K) + { + unsigned long start, end; + + start = au_readl(SYS_RTCREAD); + start += 2; + /* wait for the beginning of a new tick + */ + while (au_readl(SYS_RTCREAD) < start); + + /* Start r4k counter. + */ + write_c0_count(0); + + /* Wait 0.5 seconds. + */ + end = start + (32768 / trim_divide)/2; -void __init au1x_timer_setup(struct irqaction *irq) -{ + while (end > au_readl(SYS_RTCREAD)); + count = read_c0_count(); + cpu_speed = count * 2; + } +#else + cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * + AU1000_SRC_CLK; + count = cpu_speed / 2; +#endif + } + else { + /* The 32KHz oscillator isn't running, so assume there + * isn't one and grab the processor speed from the PLL. + * NOTE: some old silicon doesn't allow reading the PLL. + */ + cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * AU1000_SRC_CLK; + count = cpu_speed / 2; + no_au1xxx_32khz = 1; + } + mips_hpt_frequency = count; + // Equation: Baudrate = CPU / (SD * 2 * CLKDIV * 16) + set_au1x00_uart_baud_base(cpu_speed / (2 * ((int)(au_readl(SYS_POWERCTRL)&0x03) + 2) * 16)); + spin_unlock_irqrestore(&time_lock, flags); + return (cpu_speed / HZ); } /* This is for machines which generate the exact clock. */ #define USECS_PER_JIFFY (1000000/HZ) #define USECS_PER_JIFFY_FRAC (0x100000000*1000000/HZ&0xffffffff) -#ifndef CONFIG_PM + static unsigned long div64_32(unsigned long v1, unsigned long v2, unsigned long v3) { @@ -270,30 +304,9 @@ div64_32(unsigned long v1, unsigned long do_div64_32(r0, v1, v2, v3); return r0; } -#endif -static unsigned long do_fast_gettimeoffset(void) +static unsigned long do_fast_cp0_gettimeoffset(void) { -#ifdef CONFIG_PM - unsigned long pc0; - unsigned long offset; - - pc0 = au_readl(SYS_TOYREAD); - if (pc0 < last_pc0) { - offset = 0xffffffff - last_pc0 + pc0; - printk("offset over: %x\n", (unsigned)offset); - } - else { - offset = (unsigned long)(((pc0 - last_pc0) * 305) / 10); - } - if ((pc0-last_pc0) > 2*MATCH20_INC) { - printk("huge offset %x, last_pc0 %x last_match20 %x pc0 %x\n", - (unsigned)offset, (unsigned)last_pc0, - (unsigned)last_match20, (unsigned)pc0); - } - au_sync(); - return offset; -#else u32 count; unsigned long res, tmp; unsigned long r0; @@ -334,12 +347,118 @@ static unsigned long do_fast_gettimeoffs "r" (quotient)); /* - * Due to possible jiffies inconsistencies, we need to check + * Due to possible jiffies inconsistencies, we need to check * the result so that we'll get a timer that is monotonic. */ if (res >= USECS_PER_JIFFY) res = USECS_PER_JIFFY-1; return res; +} + +#ifdef CONFIG_PM +static unsigned long do_fast_pm_gettimeoffset(void) +{ + unsigned long pc0; + unsigned long offset; + + pc0 = au_readl(SYS_TOYREAD); + au_sync(); + offset = pc0 - last_pc0; + if (offset > 2*MATCH20_INC) { + printk("huge offset %x, last_pc0 %x last_match20 %x pc0 %x\n", + (unsigned)offset, (unsigned)last_pc0, + (unsigned)last_match20, (unsigned)pc0); + } + offset = (unsigned long)((offset * 305) / 10); + return offset; +} +#endif + +void au1xxx_timer_setup(struct irqaction *irq) +{ + unsigned int est_freq; + extern unsigned long (*do_gettimeoffset)(void); + extern void au1k_wait(void); + + printk("calculating r4koff... "); + r4k_offset = cal_r4koff(); + printk("%08lx(%d)\n", r4k_offset, (int) r4k_offset); + + //est_freq = 2*r4k_offset*HZ; + est_freq = r4k_offset*HZ; + est_freq += 5000; /* round */ + est_freq -= est_freq%10000; + printk("CPU frequency %d.%02d MHz\n", est_freq/1000000, + (est_freq%1000000)*100/1000000); + set_au1x00_speed(est_freq); + set_au1x00_lcd_clock(); // program the LCD clock + + r4k_cur = (read_c0_count() + r4k_offset); + write_c0_compare(r4k_cur); + + /* no RTC on the pb1000 */ + xtime.tv_sec = 0; + //xtime.tv_usec = 0; + +#ifdef CONFIG_PM + /* + * setup counter 0, since it keeps ticking after a + * 'wait' instruction has been executed. The CP0 timer and + * counter 1 do NOT continue running after 'wait' + * + * It's too early to call request_irq() here, so we handle + * counter 0 interrupt as a special irq and it doesn't show + * up under /proc/interrupts. + * + * Check to ensure we really have a 32KHz oscillator before + * we do this. + */ + if (no_au1xxx_32khz) { + unsigned int c0_status; + + printk("WARNING: no 32KHz clock found.\n"); + do_gettimeoffset = do_fast_cp0_gettimeoffset; + + /* Ensure we get CPO_COUNTER interrupts. + */ + c0_status = read_c0_status(); + c0_status |= IE_IRQ5; + write_c0_status(c0_status); + } + else { + while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S); + au_writel(0, SYS_TOYWRITE); + while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S); + + au_writel(au_readl(SYS_WAKEMSK) | (1<<8), SYS_WAKEMSK); + au_writel(~0, SYS_WAKESRC); + au_sync(); + while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20); + + /* setup match20 to interrupt once every 10ms */ + last_pc0 = last_match20 = au_readl(SYS_TOYREAD); + au_writel(last_match20 + MATCH20_INC, SYS_TOYMATCH2); + au_sync(); + while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20); + startup_match20_interrupt(); + + do_gettimeoffset = do_fast_pm_gettimeoffset; + + /* We can use the real 'wait' instruction. + */ + au1k_wait_ptr = au1k_wait; + } + +#else + /* We have to do this here instead of in timer_init because + * the generic code in arch/mips/kernel/time.c will write + * over our function pointer. + */ + do_gettimeoffset = do_fast_cp0_gettimeoffset; #endif } + +void __init au1xxx_time_init(void) +{ +} --- diff/arch/mips/au1000/common/usbdev.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/common/usbdev.c 2004-02-23 13:56:38.000000000 +0000 @@ -26,8 +26,6 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include #include #include #include --- diff/arch/mips/au1000/db1x00/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/db1x00/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -3,18 +3,6 @@ # Author: MontaVista Software, Inc. # ppopov@mvista.com or source@mvista.com # -# Makefile for the Alchemy Semiconductor PB1000 board. -# -# 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). -# - -.S.s: - $(CPP) $(CFLAGS) $< -o $*.s -.S.o: - $(CC) $(CFLAGS) -c $< -o $*.o - -O_TARGET := db1x00.o +# Makefile for the Alchemy Semiconductor Db1x00 board. -obj-y := init.o setup.o +lib-y := init.o board_setup.o irqmap.o --- diff/arch/mips/au1000/db1x00/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/db1x00/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,5 +1,4 @@ /* - * * BRIEF MODULE DESCRIPTION * PB1000 board setup * @@ -37,7 +36,6 @@ #include #include #include -#include int prom_argc; char **prom_argv, **prom_envp; @@ -46,28 +44,31 @@ extern char *prom_getenv(char *envname); const char *get_system_type(void) { - return "Alchemy Db1000"; +#ifdef CONFIG_MIPS_BOSPORUS + return "Alchemy Bosporus Gateway Reference"; +#else + return "Alchemy Db1x00"; +#endif } -int __init prom_init(int argc, char **argv, char **envp, int *prom_vec) +void __init prom_init(void) { unsigned char *memsize_str; unsigned long memsize; - prom_argc = argc; - prom_argv = argv; - prom_envp = envp; + prom_argc = fw_arg0; + prom_argv = (char **) fw_arg1; + prom_envp = (char **) fw_arg2; mips_machgroup = MACH_GROUP_ALCHEMY; mips_machtype = MACH_DB1000; /* set the platform # */ + prom_init_cmdline(); memsize_str = prom_getenv("memsize"); - if (!memsize_str) { + if (!memsize_str) memsize = 0x04000000; - } else { + else memsize = simple_strtol(memsize_str, NULL, 0); - } add_memory_region(0, memsize, BOOT_MEM_RAM); - return 0; } --- diff/arch/mips/au1000/pb1000/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/pb1000/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -4,14 +4,5 @@ # ppopov@mvista.com or source@mvista.com # # Makefile for the Alchemy Semiconductor PB1000 board. -# -# 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). -# - -USE_STANDARD_AS_RULE := true - -O_TARGET := pb1000.o -obj-y := init.o setup.o +lib-y := init.o board_setup.o irqmap.o --- diff/arch/mips/au1000/pb1000/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/pb1000/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,5 +1,4 @@ /* - * * BRIEF MODULE DESCRIPTION * PB1000 board setup * @@ -35,7 +34,6 @@ #include #include #include -#include int prom_argc; char **prom_argv, **prom_envp; @@ -47,14 +45,14 @@ const char *get_system_type(void) return "Alchemy Pb1000"; } -int __init prom_init(int argc, char **argv, char **envp, int *prom_vec) +void __init prom_init(void) { unsigned char *memsize_str; unsigned long memsize; - prom_argc = argc; - prom_argv = argv; - prom_envp = envp; + prom_argc = (int) fw_arg0; + prom_argv = (char **) fw_arg1; + prom_envp = (char **) fw_arg2; mips_machgroup = MACH_GROUP_ALCHEMY; mips_machtype = MACH_PB1000; --- diff/arch/mips/au1000/pb1100/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/pb1100/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -4,14 +4,5 @@ # ppopov@mvista.com or source@mvista.com # # Makefile for the Alchemy Semiconductor Pb1100 board. -# -# 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). -# - -USE_STANDARD_AS_RULE := true - -O_TARGET := pb1100.o -obj-y := init.o setup.o +lib-y := init.o board_setup.o irqmap.o --- diff/arch/mips/au1000/pb1100/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/pb1100/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -27,17 +27,14 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include #include #include #include #include #include -#include #include #include -#include int prom_argc; char **prom_argv, **prom_envp; @@ -49,25 +46,25 @@ const char *get_system_type(void) return "Alchemy Pb1100"; } -int __init prom_init(int argc, char **argv, char **envp, int *prom_vec) +void __init prom_init(void) { unsigned char *memsize_str; unsigned long memsize; - prom_argc = argc; - prom_argv = argv; - prom_envp = envp; + prom_argc = fw_arg0; + prom_argv = (char **) fw_arg1; + prom_envp = (int *) fw_arg3; mips_machgroup = MACH_GROUP_ALCHEMY; mips_machtype = MACH_PB1100; prom_init_cmdline(); + memsize_str = prom_getenv("memsize"); - if (!memsize_str) { + if (!memsize_str) memsize = 0x04000000; - } else { + else memsize = simple_strtol(memsize_str, NULL, 0); - } + add_memory_region(0, memsize, BOOT_MEM_RAM); - return 0; } --- diff/arch/mips/au1000/pb1500/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/pb1500/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -4,10 +4,5 @@ # ppopov@mvista.com or source@mvista.com # # Makefile for the Alchemy Semiconductor Pb1500 board. -# -# 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). -# -lib-y := init.o setup.o +lib-y := init.o board_setup.o irqmap.o --- diff/arch/mips/au1000/pb1500/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/au1000/pb1500/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -35,7 +35,6 @@ #include #include #include -#include int prom_argc; char **prom_argv, **prom_envp; @@ -47,14 +46,14 @@ const char *get_system_type(void) return "Alchemy Pb1500"; } -int __init prom_init(int argc, char **argv, char **envp, int *prom_vec) +void __init prom_init(void) { unsigned char *memsize_str; unsigned long memsize; - prom_argc = argc; - prom_argv = argv; - prom_envp = envp; + prom_argc = (int) fw_arg0; + prom_argv = (char **) fw_arg1; + prom_envp = (char **) fw_arg2; mips_machgroup = MACH_GROUP_ALCHEMY; mips_machtype = MACH_PB1500; @@ -67,5 +66,4 @@ int __init prom_init(int argc, char **ar memsize = simple_strtol(memsize_str, NULL, 0); } add_memory_region(0, memsize, BOOT_MEM_RAM); - return 0; } --- diff/arch/mips/baget/prom/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/baget/prom/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -7,17 +7,15 @@ #include #include -char arcs_cmdline[CL_SIZE]; - const char *get_system_type(void) { /* Should probably return one of "BT23-201", "BT23-202" */ return "Baget"; } -void __init prom_init(unsigned int mem_upper) +void __init prom_init(void) { - mem_upper = PHYSADDR(mem_upper); + mem_upper = PHYSADDR(fw_arg0); mips_machgroup = MACH_GROUP_UNKNOWN; mips_machtype = MACH_UNKNOWN; @@ -28,6 +26,7 @@ void __init prom_init(unsigned int mem_u add_memory_region(0, mem_upper, BOOT_MEM_RAM); } -void prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } --- diff/arch/mips/baget/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/baget/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -470,7 +470,7 @@ extern void baget_machine_restart(char * extern void baget_machine_halt(void); extern void baget_machine_power_off(void); -void __init baget_setup(void) +static void __init baget_setup(void) { printk("BT23/63-201n found.\n"); *BAGET_WRERR_ACK = 0; @@ -485,3 +485,5 @@ void __init baget_setup(void) vac_start(); vic_start(); } + +early_initcall(baget_setup); --- diff/arch/mips/boot/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/boot/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -9,7 +9,7 @@ # # Some DECstations need all possible sections of an ECOFF executable # -ifdef CONFIG_DECSTATION +ifdef CONFIG_MACH_DECSTATION E2EFLAGS = -a else E2EFLAGS = @@ -19,33 +19,29 @@ endif # Drop some uninteresting sections in the kernel. # This is only relevant for ELF kernels but doesn't hurt a.out # -drop-sections = .reginfo .mdebug .comment .note +drop-sections = .reginfo .mdebug .comment .note .pdr strip-flags = $(addprefix --remove-section=,$(drop-sections)) -all: vmlinux.ecoff addinitrd - -vmlinux.rm200: vmlinux - $(OBJCOPY) \ - --change-addresses=0xfffffffc \ - -O elf32-tradlittlemips \ - $(strip-flags) \ - $< $@ +all: vmlinux.ecoff vmlinux.srec addinitrd vmlinux.ecoff: $(obj)/elf2ecoff vmlinux - ./elf2ecoff vmlinux $(obj)/vmlinux.ecoff $(E2EFLAGS) + $(obj)/elf2ecoff vmlinux vmlinux.ecoff $(E2EFLAGS) $(obj)/elf2ecoff: $(obj)/elf2ecoff.c $(HOSTCC) -o $@ $^ +vmlinux.srec: vmlinux + $(OBJCOPY) -S -O srec $(strip-flags) vmlinux $(obj)/vmlinux.srec + $(obj)/addinitrd: $(obj)/addinitrd.c $(HOSTCC) -o $@ $^ archhelp: - @echo '* vmlinux.rm200 - Bootable kernel image for RM200C' + @echo '* vmlinux.ecoff - ECOFF boot image' CLEAN_FILES += addinitrd \ elf2ecoff \ vmlinux.ecoff \ - vmlinux.rm200 \ + vmlinux.srec \ zImage.tmp \ zImage --- diff/arch/mips/cobalt/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/cobalt/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,6 +2,6 @@ # Makefile for the Cobalt micro systems family specific parts of the kernel # -obj-y := irq.o int-handler.o reset.o setup.o via.o promcon.o +obj-y := irq.o int-handler.o reset.o setup.o promcon.o EXTRA_AFLAGS := $(CFLAGS) --- diff/arch/mips/cobalt/int-handler.S 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/cobalt/int-handler.S 2004-02-23 13:56:38.000000000 +0000 @@ -1,11 +1,9 @@ /* - * Cobalt interrupt handler - * * 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. * - * Copyright (C) 1995, 1996, 1997 by Ralf Baechle + * Copyright (C) 1995, 1996, 1997, 2003 by Ralf Baechle * Copyright (C) 2001, 2002, 2003 by Liam Davies (ldavies@agile.tv) */ #include @@ -14,91 +12,14 @@ #include #include -/* - * cobalt_handle_int: Interrupt handler for Cobalt boards - */ .text - .set noreorder - .set noat .align 5 NESTED(cobalt_handle_int, PT_SIZE, sp) SAVE_ALL CLI - .set at - - /* - * Get pending Interrupts - */ - mfc0 s0,CP0_CAUSE # get raw irq status - mfc0 a0,CP0_STATUS # get irq mask - and s0,s0,a0 # compute masked irq status - - andi a0,s0,CAUSEF_IP2 /* Check for Galileo timer */ - beq a0,zero,1f - andi a0,s0,CAUSEF_IP6 /* Check for Via chip */ - - /* Galileo interrupt */ - jal galileo_irq - move a0,sp - j ret_from_irq - nop - -1: - beq a0,zero,1f /* Check IP6 */ - andi a0,s0,CAUSEF_IP3 - - /* Via interrupt */ - jal via_irq - move a0,sp - j ret_from_irq - nop - -1: - beq a0,zero,1f /* Check IP3 */ - andi a0,s0,CAUSEF_IP4 - /* Ethernet 0 interrupt */ - li a0,COBALT_ETH0_IRQ - jal do_IRQ - move a1,sp - - j ret_from_irq - nop - -1: - beq a0,zero,1f /* Check IP4 */ - andi a0,s0,CAUSEF_IP5 - - /* Ethernet 1 interrupt */ - li a0,COBALT_ETH1_IRQ - jal do_IRQ - move a1,sp - - j ret_from_irq - nop -1: - beq a0,zero,1f /* Check IP5 */ - andi a0,s0,CAUSEF_IP7 - - /* Serial interrupt */ - li a0,COBALT_SERIAL_IRQ - jal do_IRQ - move a1,sp - - j ret_from_irq - nop -1: - beq a0,zero,1f /* Check IP7 */ - nop - - /* PCI interrupt */ - li a0,COBALT_QUBE_SLOT_IRQ - jal do_IRQ - move a1,sp - -1: - j ret_from_irq - nop + la ra, ret_from_irq + move a1, sp + j cobalt_irq END(cobalt_handle_int) - --- diff/arch/mips/cobalt/irq.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/cobalt/irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -5,139 +5,98 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (C) 1995, 1996, 1997 by Ralf Baechle - * Copyright (C) 2001 by Liam Davies (ldavies@agile.tv) - * + * Copyright (C) 1995, 1996, 1997, 2003 by Ralf Baechle */ - #include #include -#include -#include -#include +#include -#include #include -#include -#include -#include -#include +#include +#include +#include #include -/* Cobalt Exception handler */ extern void cobalt_handle_int(void); -/* Via masking routines */ -extern void unmask_irq(unsigned int irqr); -extern void mask_irq(unsigned int irq); - - /* - * We have two types of interrupts that we handle, ones that come - * in through the CPU interrupt lines, and ones that come in on - * the via chip. The CPU mappings are: - * 0,1 - S/W (ignored) - * 2 - Galileo chip (timer) - * 3 - Tulip 0 + NCR SCSI - * 4 - Tulip 1 - * 5 - 16550 UART - * 6 - VIA southbridge PIC - * 7 - unused + * We have two types of interrupts that we handle, ones that come in through + * the CPU interrupt lines, and ones that come in on the via chip. The CPU + * mappings are: * - * The VIA chip is a master/slave 8259 setup and has the - * following interrupts - * 8 - RTC - * 9 - PCI - * 14 - IDE0 - * 15 - IDE1 + * 16, - Software interrupt 0 (unused) IE_SW0 + * 17 - Software interrupt 1 (unused) IE_SW0 + * 18 - Galileo chip (timer) IE_IRQ0 + * 19 - Tulip 0 + NCR SCSI IE_IRQ1 + * 20 - Tulip 1 IE_IRQ2 + * 21 - 16550 UART IE_IRQ3 + * 22 - VIA southbridge PIC IE_IRQ4 + * 23 - unused IE_IRQ5 * - * In the table we use a 1 to indicate that we use a VIA interrupt - * line, and IE_IRQx to indicate that we use a CPU interrupt line + * The VIA chip is a master/slave 8259 setup and has the following interrupts: * - * We map all of these onto linux IRQ #s 0-15 and forget the rest - */ -#define NOINT_LINE 0 -#define CPUINT_LINE(x) IE_IRQ##x -#define VIAINT_LINE 1 - -#define COBALT_IRQS 16 - -static unsigned short irqnr_to_type[COBALT_IRQS] = -{ CPUINT_LINE(0), NOINT_LINE, VIAINT_LINE, NOINT_LINE, - CPUINT_LINE(1), NOINT_LINE, NOINT_LINE, CPUINT_LINE(3), - VIAINT_LINE, VIAINT_LINE, NOINT_LINE, NOINT_LINE, - NOINT_LINE, CPUINT_LINE(2), VIAINT_LINE, VIAINT_LINE }; - -/* - * Cobalt CPU irq + * 8 - RTC + * 9 - PCI + * 14 - IDE0 + * 15 - IDE1 */ -static void enable_cpu_irq(unsigned int irq) +asmlinkage void cobalt_irq(struct pt_regs *regs) { - unsigned long flags; + unsigned int pending = read_c0_status() & read_c0_cause(); - local_irq_save(flags); - change_c0_status(irqnr_to_type[irq], irqnr_to_type[irq]); - local_irq_restore(flags); -} + if (pending & CAUSEF_IP2) { /* int 18 */ + unsigned long irq_src = GALILEO_INL(GT_INTRCAUSE_OFS); -static unsigned startup_cpu_irq(unsigned int irq) -{ - enable_cpu_irq(irq); + /* Check for timer irq ... */ + if (irq_src & GALILEO_T0EXP) { + /* Clear the int line */ + GALILEO_OUTL(0, GT_INTRCAUSE_OFS); + do_IRQ(COBALT_TIMER_IRQ, regs); + } + return; + } - return 0; -} + if (pending & CAUSEF_IP6) { /* int 22 */ + int irq = i8259_irq(); -static void disable_cpu_irq(unsigned int irq) -{ - unsigned long flags; + if (irq >= 0) + do_IRQ(irq, regs); + return; + } - local_irq_save(flags); - change_c0_status(irqnr_to_type[irq], ~(irqnr_to_type[irq])); - local_irq_restore(flags); -} + if (pending & CAUSEF_IP3) { /* int 19 */ + do_IRQ(COBALT_ETH0_IRQ, regs); + return; + } -#define shutdown_cpu_irq disable_cpu_irq -#define mask_and_ack_cpu_irq disable_cpu_irq + if (pending & CAUSEF_IP4) { /* int 20 */ + do_IRQ(COBALT_ETH1_IRQ, regs); + return; + } -static void end_cpu_irq(unsigned int irq) -{ - if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) - enable_cpu_irq(irq); -} + if (pending & CAUSEF_IP5) { /* int 21 */ + do_IRQ(COBALT_SERIAL_IRQ, regs); + return; + } -static struct hw_interrupt_type cobalt_cpu_irq_type = { - "Cobalt CPU", - startup_cpu_irq, - shutdown_cpu_irq, - enable_cpu_irq, - disable_cpu_irq, - mask_and_ack_cpu_irq, - end_cpu_irq, - NULL -}; + if (pending & CAUSEF_IP7) { /* int 23 */ + do_IRQ(COBALT_QUBE_SLOT_IRQ, regs); + return; + } +} void __init init_IRQ(void) { - int i; - - /* Initialise all of the IRQ descriptors */ - init_i8259_irqs(); - - /* Map the irqnr to the type int we have */ - for (i=0; i < COBALT_IRQS; i++) { - if (irqnr_to_type[i] >= CPUINT_LINE(0)) - /* cobalt_cpu_irq_type */ - irq_desc[i].handler = &cobalt_cpu_irq_type; - } - - /* Mask all cpu interrupts - (except IE4, we already masked those at VIA level) */ - clear_c0_status(ST0_IM); - set_c0_status(IE_IRQ4); + set_except_vector(0, cobalt_handle_int); - cli(); + init_i8259_irqs(); /* 0 ... 15 */ + mips_cpu_irq_init(16); /* 16 ... 23 */ - set_except_vector(0, cobalt_handle_int); + /* + * Mask all cpu interrupts + * (except IE4, we already masked those at VIA level) + */ + change_c0_status(ST0_IM, IE_IRQ4); } --- diff/arch/mips/cobalt/promcon.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/cobalt/promcon.c 2004-02-23 13:56:38.000000000 +0000 @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -70,22 +69,19 @@ void putDebugChar(char kgdb_char) ns16550_cons_put_char(kgdb_char, port); } -static kdev_t -ns16550_console_dev(struct console *c) -{ - return mk_kdev(TTY_MAJOR, 64 + c->index); -} - static struct console ns16550_console = { .name = "prom", .setup = NULL, .write = ns16550_console_write, - .device = ns16550_console_dev, .flags = CON_PRINTBUFFER, .index = -1, }; -void __init ns16550_setup_console(void) +static int __init ns16550_setup_console(void) { register_console(&ns16550_console); + + return 0; } + +console_initcall(ns16550_setup_console); --- diff/arch/mips/cobalt/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/cobalt/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -9,15 +9,13 @@ * Copyright (C) 2001, 2002, 2003 by Liam Davies (ldavies@agile.tv) * */ - #include #include #include -#include #include -#include #include +#include #include #include #include @@ -31,11 +29,9 @@ extern void cobalt_machine_restart(char extern void cobalt_machine_halt(void); extern void cobalt_machine_power_off(void); -extern struct rtc_ops std_rtc_ops; -extern struct ide_ops std_ide_ops; - +int cobalt_board_id; -char arcs_cmdline[CL_SIZE] = { +static char my_cmdline[CL_SIZE] = { "console=ttyS0,115200 " #ifdef CONFIG_IP_PNP "ip=on " @@ -52,12 +48,6 @@ const char *get_system_type(void) return "MIPS Cobalt"; } - -static void __init cobalt_time_init(void) -{ - rtc_ops = &std_rtc_ops; -} - static void __init cobalt_timer_setup(struct irqaction *irq) { /* Load timer value for 150 Hz */ @@ -72,22 +62,46 @@ static void __init cobalt_timer_setup(st GALILEO_OUTL(0x100, GT_INTRMASK_OFS); } +extern struct pci_ops gt64111_pci_ops; + +static struct resource cobalt_mem_resource = { + "GT64111 PCI MEM", GT64111_IO_BASE, 0xffffffffUL, IORESOURCE_MEM +}; + +static struct resource cobalt_io_resource = { + "GT64111 IO MEM", 0x00001000UL, 0x0fffffffUL, IORESOURCE_IO +}; + +static struct resource cobalt_io_resources[] = { + { "dma1", 0x00, 0x1f, IORESOURCE_BUSY }, + { "timer", 0x40, 0x5f, IORESOURCE_BUSY }, + { "keyboard", 0x60, 0x6f, IORESOURCE_BUSY }, + { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY }, + { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY }, +}; + +#define COBALT_IO_RESOURCES (sizeof(cobalt_io_resources)/sizeof(struct resource)) + +static struct pci_controller cobalt_pci_controller = { + .pci_ops = >64111_pci_ops, + .mem_resource = &cobalt_mem_resource, + .mem_offset = 0, + .io_resource = &cobalt_io_resource, + .io_offset = 0x00001000UL - GT64111_IO_BASE +}; -void __init cobalt_setup(void) +static void __init cobalt_setup(void) { + unsigned int devfn = PCI_DEVFN(COBALT_PCICONF_VIA, 0); + int i; _machine_restart = cobalt_machine_restart; _machine_halt = cobalt_machine_halt; _machine_power_off = cobalt_machine_power_off; - board_time_init = cobalt_time_init; board_timer_setup = cobalt_timer_setup; -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &std_ide_ops; -#endif - - set_io_port_base(KSEG1ADDR(0x10000000)); + set_io_port_base(KSEG1ADDR(GT64111_IO_BASE)); /* * This is a prom style console. We just poke at the @@ -96,18 +110,42 @@ void __init cobalt_setup(void) * get to the stage of setting up a real serial console. */ /*ns16550_setup_console();*/ + + /* request I/O space for devices used on all i[345]86 PCs */ + for (i = 0; i < COBALT_IO_RESOURCES; i++) + request_resource(&ioport_resource, cobalt_io_resources + i); + + /* Read the cobalt id register out of the PCI config space */ + PCI_CFG_SET(devfn, (VIA_COBALT_BRD_ID_REG & ~0x3)); + cobalt_board_id = GALILEO_INL(GT_PCI0_CFGDATA_OFS); + cobalt_board_id >>= ((VIA_COBALT_BRD_ID_REG & 3) * 8); + cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(cobalt_board_id); + +#ifdef CONFIG_PCI + register_pci_controller(&cobalt_pci_controller); +#endif } -/* Prom init. We read our one and only communication with the - firmware. Grab the amount of installed memory */ -void __init prom_init(int argc) +early_initcall(cobalt_setup); + +/* + * Prom init. We read our one and only communication with the firmware. + * Grab the amount of installed memory + */ + +void __init prom_init(void) { + int argc = fw_arg0; + + strcpy(arcs_cmdline, my_cmdline); + mips_machgroup = MACH_GROUP_COBALT; add_memory_region(0x0, argc & 0x7fffffff, BOOT_MEM_RAM); } -void __init prom_free_prom_memory(void) +unsigned long __init prom_free_prom_memory(void) { /* Nothing to do! */ + return 0; } --- diff/arch/mips/ddb5xxx/common/prom.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/ddb5xxx/common/prom.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,17 +1,11 @@ -/*********************************************************************** - * +/* * Copyright 2001 MontaVista Software Inc. * Author: jsun@mvista.com or jsun@junsun.net * - * arch/mips/ddb5xxx/common/prom.c - * prom.c file. - * * 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. - * - *********************************************************************** */ #include #include @@ -24,8 +18,6 @@ #include #include -char arcs_cmdline[CL_SIZE]; - const char *get_system_type(void) { switch (mips_machtype) { @@ -38,13 +30,22 @@ const char *get_system_type(void) } } +#if defined(CONFIG_DDB5477) +void ddb5477_runtime_detection(void); +#endif + /* [jsun@junsun.net] PMON passes arguments in C main() style */ -void __init prom_init(int argc, const char **arg) +void __init prom_init(void) { + int argc = fw_arg0; + char **arg = (char**) fw_arg1; int i; + /* if user passes kernel args, ignore the default one */ + if (argc > 1) + arcs_cmdline[0] = '\0'; + /* arg[0] is "g", the rest is boot parameters */ - arcs_cmdline[0] = '\0'; for (i = 1; i < argc; i++) { if (strlen(arcs_cmdline) + strlen(arg[i] + 1) >= sizeof(arcs_cmdline)) @@ -53,9 +54,6 @@ void __init prom_init(int argc, const ch strcat(arcs_cmdline, " "); } - /* by default all these boards use dhcp/nfs root fs */ - strcat(arcs_cmdline, "ip=bootp"); - mips_machgroup = MACH_GROUP_NEC_DDB; #if defined(CONFIG_DDB5074) @@ -70,8 +68,9 @@ void __init prom_init(int argc, const ch #endif } -void __init prom_free_prom_memory(void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } #if defined(CONFIG_DDB5477) --- diff/arch/mips/ddb5xxx/ddb5074/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/ddb5xxx/ddb5074/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -3,6 +3,6 @@ # under Linux. # -obj-y += setup.o irq.o int-handler.o nile4_pic.o time.o +obj-y += setup.o irq.o int-handler.o nile4_pic.o EXTRA_AFLAGS := $(CFLAGS) --- diff/arch/mips/ddb5xxx/ddb5074/nile4_pic.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/ddb5xxx/ddb5074/nile4_pic.c 2004-02-23 13:56:38.000000000 +0000 @@ -9,6 +9,7 @@ * Author: jsun@mvista.com or jsun@junsun.net * */ +#include #include #include #include --- diff/arch/mips/ddb5xxx/ddb5074/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/ddb5xxx/ddb5074/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -10,9 +10,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -28,20 +26,11 @@ #include #include - #ifdef CONFIG_KGDB extern void rs_kgdb_hook(int); extern void breakpoint(void); #endif -#if defined(CONFIG_SERIAL_CONSOLE) -extern void console_setup(char *); -#endif - -extern struct ide_ops std_ide_ops; -extern struct kbd_ops std_kbd_ops; -extern struct rtc_ops ddb_rtc_ops; - static void (*back_to_prom) (void) = (void (*)(void)) 0xbfc00000; static void ddb_machine_restart(char *command) @@ -97,13 +86,13 @@ static void __init ddb_timer_init(struct static void __init ddb_time_init(void) { - /* we have ds1396 RTC chip */ + /* we have ds1396 RTC chip */ rtc_ds1386_init(KSEG1ADDR(DDB_PCI_MEM_BASE)); } -void __init ddb_setup(void) +static void __init ddb5074_setup(void) { extern int panic_timeout; @@ -118,25 +107,16 @@ void __init ddb_setup(void) _machine_halt = ddb_machine_halt; _machine_power_off = ddb_machine_power_off; -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &std_ide_ops; -#endif - - rtc_ops = &ddb_rtc_ops; - - ddb_out32(DDB_BAR0, 0); + ddb_out32(DDB_BAR0, 0); ddb_set_pmr(DDB_PCIINIT0, DDB_PCICMD_IO, 0, 0x10); ddb_set_pmr(DDB_PCIINIT1, DDB_PCICMD_MEM, DDB_PCI_MEM_BASE , 0x10); -#ifdef CONFIG_FB - conswitchp = &dummy_con; -#endif - /* Reboot on panic */ panic_timeout = 180; } +early_initcall(ddb5074_setup); #define USE_NILE4_SERIAL 0 --- diff/arch/mips/ddb5xxx/ddb5476/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/ddb5xxx/ddb5476/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -10,11 +10,8 @@ #include #include #include -#include #include -#include #include -#include #include #include @@ -43,9 +40,6 @@ extern void breakpoint(void); #endif -extern struct ide_ops std_ide_ops; -extern struct kbd_ops std_kbd_ops; - static void (*back_to_prom) (void) = (void (*)(void)) 0xbfc00000; static void ddb_machine_restart(char *command) @@ -82,7 +76,7 @@ extern void rtc_ds1386_init(unsigned lon static void __init ddb_time_init(void) { #if defined(USE_CPU_COUNTER_TIMER) - mips_counter_frequency = CPU_COUNTER_FREQUENCY; + mips_hpt_frequency = CPU_COUNTER_FREQUENCY; #endif /* we have ds1396 RTC chip */ @@ -114,20 +108,16 @@ static void __init ddb_timer_setup(struc static struct { struct resource dma1; - struct resource pic1; struct resource timer; struct resource rtc; struct resource dma_page_reg; - struct resource pic2; struct resource dma2; } ddb5476_ioport = { { "dma1", 0x00, 0x1f, IORESOURCE_BUSY}, { - "pic1", 0x20, 0x3f, IORESOURCE_BUSY}, { "timer", 0x40, 0x5f, IORESOURCE_BUSY}, { "rtc", 0x70, 0x7f, IORESOURCE_BUSY}, { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY}, { - "pic2", 0xa0, 0xbf, IORESOURCE_BUSY}, { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY} }; @@ -142,8 +132,7 @@ static void ddb5476_board_init(void); extern void ddb5476_irq_setup(void); extern void (*irq_setup)(void); -void __init -ddb_setup(void) +static void __init ddb5476_setup(void) { extern int panic_timeout; @@ -159,21 +148,16 @@ ddb_setup(void) /* request io port/mem resources */ if (request_resource(&ioport_resource, &ddb5476_ioport.dma1) || - request_resource(&ioport_resource, &ddb5476_ioport.pic1) || request_resource(&ioport_resource, &ddb5476_ioport.timer) || request_resource(&ioport_resource, &ddb5476_ioport.rtc) || request_resource(&ioport_resource, &ddb5476_ioport.dma_page_reg) - || request_resource(&ioport_resource, &ddb5476_ioport.pic2) || request_resource(&ioport_resource, &ddb5476_ioport.dma2) || request_resource(&iomem_resource, &ddb5476_iomem.nile4)) { printk ("ddb_setup - requesting oo port resources failed.\n"); for (;;); } -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &std_ide_ops; -#endif /* Reboot on panic */ panic_timeout = 180; @@ -181,14 +165,12 @@ ddb_setup(void) /* [jsun] we need to set BAR0 so that SDRAM 0 appears at 0x0 in PCI */ /* *(long*)0xbfa00218 = 0x8; */ -#ifdef CONFIG_FB - conswitchp = &dummy_con; -#endif - /* board initialization stuff */ ddb5476_board_init(); } +early_initcall(ddb5476_setup); + /* * We don't trust bios. We essentially does hardware re-initialization * as complete as possible, as far as we know we can safely do. --- diff/arch/mips/ddb5xxx/ddb5477/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/ddb5xxx/ddb5477/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -36,9 +35,7 @@ #include #include #include -#ifdef CONFIG_PC_KEYB -#include -#endif +#include #include @@ -141,11 +138,11 @@ static void __init ddb_time_init(void) bus_frequency = detect_bus_frequency(rtc_base); } - /* mips_counter_frequency is 1/2 of the cpu core freq */ - i = (read_32bit_cp0_register(CP0_CONFIG) >> 28 ) & 7; + /* mips_hpt_frequency is 1/2 of the cpu core freq */ + i = (read_c0_config() >> 28 ) & 7; if ((current_cpu_data.cputype == CPU_R5432) && (i == 3)) i = 4; - mips_counter_frequency = bus_frequency*(i+4)/4; + mips_hpt_frequency = bus_frequency*(i+4)/4; } extern int setup_irq(unsigned int irq, struct irqaction *irqaction); @@ -153,7 +150,6 @@ extern int setup_irq(unsigned int irq, s static void __init ddb_timer_setup(struct irqaction *irq) { #if defined(USE_CPU_COUNTER_TIMER) - unsigned int count; /* we are using the cpu counter for timer interrupts */ setup_irq(CPU_IRQ_BASE + 7, irq); @@ -170,17 +166,14 @@ static void __init ddb_timer_setup(struc static void ddb5477_board_init(void); extern void ddb5477_irq_setup(void); +extern void (*irq_setup)(void); -#if defined(CONFIG_BLK_DEV_INITRD) -extern unsigned long __rd_start, __rd_end, initrd_start, initrd_end; -#endif +extern struct pci_controller ddb5477_ext_controller; +extern struct pci_controller ddb5477_io_controller; -void __init ddb_setup(void) +static int ddb5477_setup(void) { extern int panic_timeout; -#ifdef CONFIG_BLK_DEV_IDE - extern struct ide_ops std_ide_ops; -#endif /* initialize board - we don't trust the loader */ ddb5477_board_init(); @@ -202,27 +195,16 @@ void __init ddb_setup(void) /* Reboot on panic */ panic_timeout = 180; -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &std_ide_ops; -#endif - - -#ifdef CONFIG_FB - conswitchp = &dummy_con; -#endif + register_pci_controller (&ddb5477_ext_controller); + register_pci_controller (&ddb5477_io_controller); -#if defined(CONFIG_BLK_DEV_INITRD) - ROOT_DEV = Root_RAM0; - initrd_start = (unsigned long)&__rd_start; - initrd_end = (unsigned long)&__rd_end; -#endif + return 0; } +early_initcall(ddb5477_setup); + static void __init ddb5477_board_init(void) { -#ifdef CONFIG_PC_KEYB - extern struct kbd_ops std_kbd_ops; -#endif /* ----------- setup PDARs ------------ */ /* SDRAM should have been set */ @@ -351,13 +333,6 @@ static void __init ddb5477_board_init(vo /* For dual-function pins, make them all non-GPIO */ ddb_out32(DDB_GIUFUNSEL, 0x0); // ddb_out32(DDB_GIUFUNSEL, 0xfe0fcfff); /* NEC recommanded value */ - - if (mips_machtype == MACH_NEC_ROCKHOPPERII) { -#ifdef CONFIG_PC_KEYB - printk("kdb_ops is std\n"); - kbd_ops = &std_kbd_ops; -#endif - } if (mips_machtype == MACH_NEC_ROCKHOPPERII) { --- diff/arch/mips/dec/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/dec/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -3,7 +3,7 @@ # obj-y := ecc-berr.o int-handler.o ioasic-irq.o kn02-irq.o reset.o \ - rtc-dec.o setup.o time.o + setup.o time.o obj-$(CONFIG_PROM_CONSOLE) += promcon.o obj-$(CONFIG_CPU_HAS_WB) += wbflush.o --- diff/arch/mips/dec/ecc-berr.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/dec/ecc-berr.c 2004-02-23 13:56:38.000000000 +0000 @@ -74,7 +74,7 @@ static int dec_ecc_be_backend(struct pt_ if (!(erraddr & KN0X_EAR_VALID)) { /* No idea what happened. */ - printk(KERN_ALERT "Unindentified bus error %s.\n", kind); + printk(KERN_ALERT "Unidentified bus error %s.\n", kind); return action; } @@ -198,12 +198,12 @@ int dec_ecc_be_handler(struct pt_regs *r return dec_ecc_be_backend(regs, is_fixup, 0); } -void dec_ecc_be_interrupt(int irq, void *dev_id, struct pt_regs *regs) +irqreturn_t dec_ecc_be_interrupt(int irq, void *dev_id, struct pt_regs *regs) { int action = dec_ecc_be_backend(regs, 0, 1); if (action == MIPS_BE_DISCARD) - return; + return IRQ_NONE; /* * FIXME: Find affected processes and kill them, otherwise we --- diff/arch/mips/dec/int-handler.S 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/dec/int-handler.S 2004-02-23 13:56:38.000000000 +0000 @@ -13,6 +13,7 @@ * Rewritten extensively for controller-driven IRQ support * by Maciej W. Rozycki. */ +#include #include #include #include --- diff/arch/mips/dec/prom/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/dec/prom/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -3,7 +3,7 @@ # under Linux. # -lib-y += init.o memory.o cmdline.o identify.o +lib-y += init.o memory.o cmdline.o identify.o console.o lib-$(CONFIG_MIPS32) += locore.o lib-$(CONFIG_MIPS64) += call_o32.o --- diff/arch/mips/dec/prom/cmdline.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/dec/prom/cmdline.c 2004-02-23 13:56:38.000000000 +0000 @@ -2,6 +2,7 @@ * cmdline.c: read the command line passed to us by the PROM. * * Copyright (C) 1998 Harald Koerfgen + * Copyright (C) 2002, 2004 Maciej W. Rozycki */ #include #include @@ -13,8 +14,6 @@ #undef PROM_DEBUG -char arcs_cmdline[CL_SIZE]; - void __init prom_init_cmdline(s32 argc, s32 *argv, u32 magic) { char *arg; @@ -35,6 +34,6 @@ void __init prom_init_cmdline(s32 argc, } #ifdef PROM_DEBUG - prom_printf("arcs_cmdline: %s\n", &(arcs_cmdline[0])); + printk("arcs_cmdline: %s\n", &(arcs_cmdline[0])); #endif } --- diff/arch/mips/dec/prom/identify.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/dec/prom/identify.c 2004-02-23 13:56:38.000000000 +0000 @@ -2,11 +2,12 @@ * identify.c: machine identification code. * * Copyright (C) 1998 Harald Koerfgen and Paul M. Antoine - * Copyright (C) 2002, 2003 Maciej W. Rozycki + * Copyright (C) 2002, 2003, 2004 Maciej W. Rozycki */ #include #include #include +#include #include #include @@ -61,6 +62,10 @@ const char *get_system_type(void) * early. Semantically the functions belong to prom/init.c, but they * are compact enough we want them inlined. --macro */ +volatile u8 *dec_rtc_base; + +EXPORT_SYMBOL(dec_rtc_base); + static inline void prom_init_kn01(void) { dec_rtc_base = (void *)KN01_RTC_BASE; @@ -100,11 +105,13 @@ void __init prom_identify_arch(u32 magic u32 dec_sysid; if (!prom_is_rex(magic)) { - dec_sysid = simple_strtoul(prom_getenv("systype"), (char **)0, 0); + dec_sysid = simple_strtoul(prom_getenv("systype"), + (char **)0, 0); } else { dec_sysid = rex_getsysid(); if (dec_sysid == 0) { - prom_printf("Zero sysid returned from PROMs! Assuming PMAX-like machine.\n"); + printk("Zero sysid returned from PROM! " + "Assuming a PMAX-like machine.\n"); dec_sysid = 1; } } @@ -163,10 +170,8 @@ void __init prom_identify_arch(u32 magic } if (mips_machtype == MACH_DSUNKNOWN) - prom_printf("This is an %s, id is %x\n", - dec_system_strings[mips_machtype], - dec_systype); + printk("This is an %s, id is %x\n", + dec_system_strings[mips_machtype], dec_systype); else - prom_printf("This is a %s\n", - dec_system_strings[mips_machtype]); + printk("This is a %s\n", dec_system_strings[mips_machtype]); } --- diff/arch/mips/dec/prom/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/dec/prom/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -2,11 +2,12 @@ * init.c: PROM library initialisation code. * * Copyright (C) 1998 Harald Koerfgen - * Copyright (C) 2002 Maciej W. Rozycki + * Copyright (C) 2002, 2004 Maciej W. Rozycki */ #include #include #include +#include #include #include @@ -35,7 +36,7 @@ int (*__pmax_close)(int); /* - * Detect which PROM's the DECSTATION has, and set the callback vectors + * Detect which PROM the DECSTATION has, and set the callback vectors * appropriately. */ void __init which_prom(s32 magic, s32 *prom_vec) @@ -82,12 +83,22 @@ void __init which_prom(s32 magic, s32 *p } } -int __init prom_init(s32 argc, s32 *argv, u32 magic, s32 *prom_vec) +void __init prom_init(void) { extern void dec_machine_halt(void); + static char cpu_msg[] __initdata = + "Sorry, this kernel is compiled for a wrong CPU type!\n"; + static char r3k_msg[] __initdata = + "Please recompile with \"CONFIG_CPU_R3000 = y\".\n"; + static char r4k_msg[] __initdata = + "Please recompile with \"CONFIG_CPU_R4x00 = y\".\n"; + s32 argc = fw_arg0; + s32 argv = fw_arg1; + u32 magic = fw_arg2; + s32 prom_vec = fw_arg3; /* - * Determine which PROM's we have + * Determine which PROM we have * (and therefore which machine we're on!) */ which_prom(magic, prom_vec); @@ -95,12 +106,15 @@ int __init prom_init(s32 argc, s32 *argv if (prom_is_rex(magic)) rex_clear_cache(); + /* Register the early console. */ + register_prom_console(); + /* Were we compiled with the right CPU option? */ #if defined(CONFIG_CPU_R3000) if ((current_cpu_data.cputype == CPU_R4000SC) || (current_cpu_data.cputype == CPU_R4400SC)) { - prom_printf("Sorry, this kernel is compiled for the wrong CPU type!\n"); - prom_printf("Please recompile with \"CONFIG_CPU_R4x00 = y\"\n"); + printk(cpu_msg); + printk(r4k_msg); dec_machine_halt(); } #endif @@ -108,8 +122,8 @@ int __init prom_init(s32 argc, s32 *argv #if defined(CONFIG_CPU_R4X00) if ((current_cpu_data.cputype == CPU_R3000) || (current_cpu_data.cputype == CPU_R3000A)) { - prom_printf("Sorry, this kernel is compiled for the wrong CPU type!\n"); - prom_printf("Please recompile with \"CONFIG_CPU_R3000 = y\"\n"); + printk(cpu_msg); + printk(r3k_msg); dec_machine_halt(); } #endif @@ -117,6 +131,4 @@ int __init prom_init(s32 argc, s32 *argv prom_meminit(magic); prom_identify_arch(magic); prom_init_cmdline(argc, argv, magic); - - return 0; } --- diff/arch/mips/dec/prom/memory.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/dec/prom/memory.c 2004-02-23 13:56:38.000000000 +0000 @@ -93,7 +93,7 @@ void __init prom_meminit(u32 magic) rex_setup_memory_region(); } -void __init prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { unsigned long addr, end; @@ -125,4 +125,6 @@ void __init prom_free_prom_memory (void) printk("Freeing unused PROM memory: %ldk freed\n", (end - PAGE_SIZE) >> 10); + + return end - PAGE_SIZE; } --- diff/arch/mips/dec/promcon.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/dec/promcon.c 2004-02-23 13:56:38.000000000 +0000 @@ -6,7 +6,6 @@ */ #include -#include #include #include #include --- diff/arch/mips/dec/reset.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/dec/reset.c 2004-02-23 13:56:38.000000000 +0000 @@ -4,29 +4,38 @@ * Copyright (C) 199x the Anonymous * Copyright (C) 2001, 2002, 2003 Maciej W. Rozycki */ +#include +#include #include #include -#define back_to_prom() (((void (*)(void))KSEG1ADDR(0x1fc00000))()) +typedef void ATTRIB_NORET (* noret_func_t)(void); -void dec_machine_restart(char *command) +static inline void ATTRIB_NORET back_to_prom(void) +{ + noret_func_t func = (void *) KSEG1ADDR(0x1fc00000); + + func(); +} + +void ATTRIB_NORET dec_machine_restart(char *command) { back_to_prom(); } -void dec_machine_halt(void) +void ATTRIB_NORET dec_machine_halt(void) { back_to_prom(); } -void dec_machine_power_off(void) +void ATTRIB_NORET dec_machine_power_off(void) { /* DECstations don't have a software power switch */ back_to_prom(); } -void dec_intr_halt(int irq, void *dev_id, struct pt_regs *regs) +irqreturn_t dec_intr_halt(int irq, void *dev_id, struct pt_regs *regs) { dec_machine_halt(); } --- diff/arch/mips/dec/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/dec/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -19,12 +18,14 @@ #include #include -#include #include +#include +#include #include #include #include #include +#include #include #include @@ -43,10 +44,15 @@ extern void dec_machine_restart(char *command); extern void dec_machine_halt(void); extern void dec_machine_power_off(void); -extern void dec_intr_halt(int irq, void *dev_id, struct pt_regs *regs); +extern irqreturn_t dec_intr_halt(int irq, void *dev_id, struct pt_regs *regs); extern asmlinkage void decstation_handle_int(void); +#ifdef CONFIG_BLK_DEV_INITRD +extern unsigned long initrd_start, initrd_end; +extern void * __rd_start, * __rd_end; +#endif + spinlock_t ioasic_ssr_lock; volatile u32 *ioasic_base; @@ -105,28 +111,6 @@ static struct irqaction haltirq = { }; -void (*board_time_init)(struct irqaction *irq); - - -/* - * enable the periodic interrupts - */ -static void __init dec_time_init(struct irqaction *irq) -{ - /* - * Here we go, enable periodic rtc interrupts. - */ - -#ifndef LOG_2_HZ -# define LOG_2_HZ 7 -#endif - - CMOS_WRITE(RTC_REF_CLCK_32KHZ | (16 - LOG_2_HZ), RTC_REG_A); - CMOS_WRITE(CMOS_READ(RTC_REG_B) | RTC_PIE, RTC_REG_B); - setup_irq(dec_interrupt[DEC_IRQ_RTC], irq); -} - - /* * Bus error (DBE/IBE exceptions and bus interrupts) handling setup. */ @@ -147,24 +131,28 @@ void __init dec_be_init(void) } -void __init decstation_setup(void) +extern void dec_time_init(void); +extern void dec_timer_setup(struct irqaction *); + +static void __init decstation_setup(void) { +#ifdef CONFIG_BLK_DEV_INITRD + ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0); + initrd_start = (unsigned long)&__rd_start; + initrd_end = (unsigned long)&__rd_end; +#endif board_be_init = dec_be_init; board_time_init = dec_time_init; + board_timer_setup = dec_timer_setup; wbflush_setup(); _machine_restart = dec_machine_restart; _machine_halt = dec_machine_halt; _machine_power_off = dec_machine_power_off; - -#ifdef CONFIG_FB - conswitchp = &dummy_con; -#endif - - rtc_ops = &dec_rtc_ops; } +early_initcall(decstation_setup); /* * Machine-specific initialisation for KN01, aka DS2100 (aka Pmin) --- diff/arch/mips/dec/time.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/mips/dec/time.c 2004-02-23 13:56:38.000000000 +0000 @@ -9,283 +9,98 @@ * */ #include -#include -#include #include #include -#include +#include #include +#include +#include +#include #include +#include #include -#include #include -#include -#include +#include -#include #include -#include +#include +#include #include #include +#include #include -#include +#include + +#include #include #include +#include -#include -#include - -#include - -extern void (*board_time_init)(struct irqaction *irq); - -extern volatile unsigned long wall_jiffies; - -/* - * Change this if you have some constant time drift - */ -/* This is the value for the PC-style PICs. */ -/* #define USECS_PER_JIFFY (1000020/HZ) */ - -/* This is for machines which generate the exact clock. */ -#define USECS_PER_JIFFY (1000000/HZ) -#define USECS_PER_JIFFY_FRAC ((u32)((1000000ULL << 32) / HZ)) - -#define TICK_SIZE (tick_nsec / 1000) - -/* Cycle counter value at the previous timer interrupt.. */ - -static unsigned int timerhi, timerlo; - -/* - * Cached "1/(clocks per usec)*2^32" value. - * It has to be recalculated once each jiffy. - */ -static unsigned long cached_quotient = 0; - -/* Last jiffy when do_fast_gettimeoffset() was called. */ -static unsigned long last_jiffies = 0; - -/* - * On MIPS only R4000 and better have a cycle counter. - * - * FIXME: Does playing with the RP bit in c0_status interfere with this code? - */ -static unsigned long do_fast_gettimeoffset(void) -{ - u32 count; - unsigned long res, tmp; - unsigned long quotient; - - tmp = jiffies; - - quotient = cached_quotient; - - if (last_jiffies != tmp) { - last_jiffies = tmp; - if (last_jiffies != 0) { - unsigned long r0; - __asm__(".set push\n\t" - ".set mips3\n\t" - "lwu %0,%3\n\t" - "dsll32 %1,%2,0\n\t" - "or %1,%1,%0\n\t" - "ddivu $0,%1,%4\n\t" - "mflo %1\n\t" - "dsll32 %0,%5,0\n\t" - "or %0,%0,%6\n\t" - "ddivu $0,%0,%1\n\t" - "mflo %0\n\t" - ".set pop" - : "=&r" (quotient), "=&r" (r0) - : "r" (timerhi), "m" (timerlo), - "r" (tmp), "r" (USECS_PER_JIFFY), - "r" (USECS_PER_JIFFY_FRAC)); - cached_quotient = quotient; - } - } - /* Get last timer tick in absolute kernel time */ - count = read_c0_count(); - - /* .. relative to previous jiffy (32 bits is enough) */ - count -= timerlo; -//printk("count: %08lx, %08lx:%08lx\n", count, timerhi, timerlo); - - __asm__("multu %2,%3" - : "=l" (tmp), "=h" (res) - : "r" (count), "r" (quotient)); - - /* - * Due to possible jiffies inconsistencies, we need to check - * the result so that we'll get a timer that is monotonic. - */ - if (res >= USECS_PER_JIFFY) - res = USECS_PER_JIFFY - 1; - - return res; -} -static unsigned long do_ioasic_gettimeoffset(void) +static unsigned long dec_rtc_get_time(void) { - u32 count; - unsigned long res, tmp; - unsigned long quotient; - - tmp = jiffies; - - quotient = cached_quotient; - - if (last_jiffies != tmp) { - last_jiffies = tmp; - if (last_jiffies != 0) { - unsigned long r0; - do_div64_32(r0, timerhi, timerlo, tmp); - do_div64_32(quotient, USECS_PER_JIFFY, - USECS_PER_JIFFY_FRAC, r0); - cached_quotient = quotient; - } - } - /* Get last timer tick in absolute kernel time */ - count = ioasic_read(IO_REG_FCTR); - - /* .. relative to previous jiffy (32 bits is enough) */ - count -= timerlo; -//printk("count: %08x, %08x:%08x\n", count, timerhi, timerlo); - - __asm__("multu %2,%3" - : "=l" (tmp), "=h" (res) - : "r" (count), "r" (quotient)); - - /* - * Due to possible jiffies inconsistencies, we need to check - * the result so that we'll get a timer that is monotonic. - */ - if (res >= USECS_PER_JIFFY) - res = USECS_PER_JIFFY - 1; - - return res; -} - -/* This function must be called with interrupts disabled - * It was inspired by Steve McCanne's microtime-i386 for BSD. -- jrs - * - * However, the pc-audio speaker driver changes the divisor so that - * it gets interrupted rather more often - it loads 64 into the - * counter rather than 11932! This has an adverse impact on - * do_gettimeoffset() -- it stops working! What is also not - * good is that the interval that our timer function gets called - * is no longer 10.0002 ms, but 9.9767 ms. To get around this - * would require using a different timing source. Maybe someone - * could use the RTC - I know that this can interrupt at frequencies - * ranging from 8192Hz to 2Hz. If I had the energy, I'd somehow fix - * it so that at startup, the timer code in sched.c would select - * using either the RTC or the 8253 timer. The decision would be - * based on whether there was any other device around that needed - * to trample on the 8253. I'd set up the RTC to interrupt at 1024 Hz, - * and then do some jiggery to have a version of do_timer that - * advanced the clock by 1/1024 s. Every time that reached over 1/100 - * of a second, then do all the old code. If the time was kept correct - * then do_gettimeoffset could just return 0 - there is no low order - * divider that can be accessed. - * - * Ideally, you would be able to use the RTC for the speaker driver, - * but it appears that the speaker driver really needs interrupt more - * often than every 120 us or so. - * - * Anyway, this needs more thought.... pjsg (1993-08-28) - * - * If you are really that interested, you should be reading - * comp.protocols.time.ntp! - */ + unsigned int year, mon, day, hour, min, sec, real_year; + int i; -static unsigned long do_slow_gettimeoffset(void) -{ - /* - * This is a kludge until I find a way for the - * DECstations without bus cycle counter. HK + /* The Linux interpretation of the DS1287 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. */ - return 0; -} - -static unsigned long (*do_gettimeoffset) (void) = do_slow_gettimeoffset; - -/* - * This version of gettimeofday has microsecond resolution - * and better than microsecond precision on fast x86 machines with TSC. - */ -void do_gettimeofday(struct timeval *tv) -{ - unsigned long seq; - unsigned long usec, sec; - + /* 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; + /* Isn't this overkill? UIP above should guarantee consistency */ do { - seq = read_seqbegin(&xtime_lock); - usec = do_gettimeoffset(); - { - unsigned long lost = jiffies - wall_jiffies; - if (lost) - usec += lost * (1000000 / HZ); - } - sec = xtime.tv_sec; - usec += (xtime.tv_nsec / 1000); - } while (read_seqretry(&xtime_lock, seq)); - - while (usec >= 1000000) { - usec -= 1000000; - sec++; + 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)); + if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { + sec = BCD2BIN(sec); + min = BCD2BIN(min); + hour = BCD2BIN(hour); + day = BCD2BIN(day); + mon = BCD2BIN(mon); + year = BCD2BIN(year); } - - tv->tv_sec = sec; - tv->tv_usec = usec; -} - -EXPORT_SYMBOL(do_gettimeofday); - -void do_settimeofday(struct timeval *tv) -{ - write_seqlock_irq(&xtime_lock); /* - * This is revolting. We need to set "xtime" correctly. However, the - * value in this location is the value at the most recent update of - * wall time. Discover what correction gettimeofday() would have - * made, and then undo it! + * The PROM will reset the year to either '72 or '73. + * Therefore we store the real year separately, in one + * of unused BBU RAM locations. */ - tv->tv_usec -= do_gettimeoffset(); - tv->tv_usec -= (jiffies - wall_jiffies) * (1000000 / HZ); - - while (tv->tv_usec < 0) { - tv->tv_usec += 1000000; - tv->tv_sec--; - } + real_year = CMOS_READ(RTC_DEC_YEAR); + year += real_year - 72 + 2000; - xtime.tv_sec = tv->tv_sec; - xtime.tv_nsec = (tv->tv_usec * 1000); - time_adjust = 0; /* stop active adjtime() */ - time_status |= STA_UNSYNC; - time_maxerror = NTP_PHASE_LIMIT; - time_esterror = NTP_PHASE_LIMIT; - write_sequnlock_irq(&xtime_lock); + return mktime(year, mon, day, hour, min, sec); } -EXPORT_SYMBOL(do_settimeofday); - /* - * In order to set the CMOS clock precisely, set_rtc_mmss has to be - * called 500 ms after the second nowtime has started, because when + * In order to set the CMOS clock precisely, dec_rtc_set_mmss has to + * be called 500 ms after the second nowtime has started, because when * nowtime is written into the registers of the CMOS clock, it will - * jump to the next second precisely 500 ms later. Check the Motorola - * MC146818A or Dallas DS12887 data sheet for details. + * jump to the next second precisely 500 ms later. Check the Dallas + * DS1287 data sheet for details. */ -static int set_rtc_mmss(unsigned long nowtime) +static int dec_rtc_set_mmss(unsigned long nowtime) { int retval = 0; int real_seconds, real_minutes, cmos_minutes; unsigned char save_control, save_freq_select; - save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being set */ + /* tell the clock it's being set */ + save_control = CMOS_READ(RTC_CONTROL); CMOS_WRITE((save_control | RTC_SET), RTC_CONTROL); - save_freq_select = CMOS_READ(RTC_FREQ_SELECT); /* stop and reset prescaler */ + /* stop and reset prescaler */ + save_freq_select = CMOS_READ(RTC_FREQ_SELECT); CMOS_WRITE((save_freq_select | RTC_DIV_RESET2), RTC_FREQ_SELECT); cmos_minutes = CMOS_READ(RTC_MINUTES); @@ -319,10 +134,9 @@ static int set_rtc_mmss(unsigned long no } /* The following flags have to be released exactly in this order, - * otherwise the DS12887 (popular MC146818A clone with integrated - * battery and quartz) will not reset the oscillator and will not - * update precisely 500 ms later. You won't find this mentioned in - * the Dallas Semiconductor data sheets, but who believes data + * otherwise the DS1287 will not reset the oscillator and will not + * update precisely 500 ms later. You won't find this mentioned + * in the Dallas Semiconductor data sheets, but who believes data * sheets anyway ... -- Markus Kuhn */ CMOS_WRITE(save_control, RTC_CONTROL); @@ -331,177 +145,56 @@ static int set_rtc_mmss(unsigned long no return retval; } -/* last time the cmos clock got updated */ -static long last_rtc_update; -/* - * timer_interrupt() needs to keep up the real-time clock, - * as well as call the "do_timer()" routine every clocktick - */ -static inline void -timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) +static int dec_timer_state(void) { - volatile unsigned char dummy; - unsigned long seq; - - dummy = CMOS_READ(RTC_REG_C); /* ACK RTC Interrupt */ - - if (!user_mode(regs)) { - if (prof_buffer && current->pid) { - unsigned long pc = regs->cp0_epc; - - pc -= (unsigned long) _stext; - pc >>= prof_shift; - /* - * Dont ignore out-of-bounds pc values silently, - * put them into the last histogram slot, so if - * present, they will show up as a sharp peak. - */ - if (pc > prof_len - 1) - pc = prof_len - 1; - atomic_inc((atomic_t *) & prof_buffer[pc]); - } - } - do_timer(regs); - - /* - * If we have an externally synchronized Linux clock, then update - * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be - * called as close as possible to 500 ms before the new second starts. - */ - do { - seq = read_seqbegin(&xtime_lock); - - if ((time_status & STA_UNSYNC) == 0 - && xtime.tv_sec > last_rtc_update + 660 - && (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 - && (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) { - if (set_rtc_mmss(xtime.tv_sec) == 0) - last_rtc_update = xtime.tv_sec; - else - /* do it again in 60 s */ - last_rtc_update = xtime.tv_sec - 600; - } - } while (read_seqretry(&xtime_lock, seq)); - - /* As we return to user mode fire off the other CPU schedulers.. this is - basically because we don't yet share IRQ's around. This message is - rigged to be safe on the 386 - basically it's a hack, so don't look - closely for now.. */ - /*smp_message_pass(MSG_ALL_BUT_SELF, MSG_RESCHEDULE, 0L, 0); */ - write_sequnlock(&xtime_lock); + return (CMOS_READ(RTC_REG_C) & RTC_PF) != 0; } -static void r4k_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) +static void dec_timer_ack(void) { - unsigned int count; + CMOS_READ(RTC_REG_C); /* Ack the RTC interrupt. */ +} +static unsigned int dec_ioasic_hpt_read(void) +{ /* - * The cycle counter is only 32 bit which is good for about - * a minute at current count rates of upto 150MHz or so. + * The free-running counter is 32-bit which is good for about + * 2 minutes, 50 seconds at possible count rates of up to 25MHz. */ - count = read_c0_count(); - timerhi += (count < timerlo); /* Wrap around */ - timerlo = count; - - if (jiffies == ~0) { - /* - * If jiffies is to overflow in this timer_interrupt we must - * update the timer[hi]/[lo] to make do_fast_gettimeoffset() - * quotient calc still valid. -arca - */ - write_c0_count(0); - timerhi = timerlo = 0; - } + return ioasic_read(IO_REG_FCTR); +} - timer_interrupt(irq, dev_id, regs); +static void dec_ioasic_hpt_init(unsigned int count) +{ + ioasic_write(IO_REG_FCTR, ioasic_read(IO_REG_FCTR) - count); } -static void ioasic_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) + +void __init dec_time_init(void) { - unsigned int count; + rtc_get_time = dec_rtc_get_time; + rtc_set_mmss = dec_rtc_set_mmss; - /* - * The free-running counter is 32 bit which is good for about - * 2 minutes, 50 seconds at possible count rates of upto 25MHz. - */ - count = ioasic_read(IO_REG_FCTR); - timerhi += (count < timerlo); /* Wrap around */ - timerlo = count; - - if (jiffies == ~0) { - /* - * If jiffies is to overflow in this timer_interrupt we must - * update the timer[hi]/[lo] to make do_fast_gettimeoffset() - * quotient calc still valid. -arca - */ - ioasic_write(IO_REG_FCTR, 0); - timerhi = timerlo = 0; + mips_timer_state = dec_timer_state; + mips_timer_ack = dec_timer_ack; + + if (!cpu_has_counter && IOASIC) { + /* For pre-R4k systems we use the I/O ASIC's counter. */ + mips_hpt_read = dec_ioasic_hpt_read; + mips_hpt_init = dec_ioasic_hpt_init; } - timer_interrupt(irq, dev_id, regs); + /* Set up the rate of periodic DS1287 interrupts. */ + CMOS_WRITE(RTC_REF_CLCK_32KHZ | (16 - LOG_2_HZ), RTC_REG_A); } -struct irqaction irq0 = { - .handler = timer_interrupt, - .flags = SA_INTERRUPT, - .name = "timer", -}; +EXPORT_SYMBOL(do_settimeofday); -void __init time_init(void) +void __init dec_timer_setup(struct irqaction *irq) { - unsigned int year, mon, day, hour, min, sec, real_year; - int 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 */ - 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)); - if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { - sec = BCD2BIN(sec); - min = BCD2BIN(min); - hour = BCD2BIN(hour); - day = BCD2BIN(day); - mon = BCD2BIN(mon); - year = BCD2BIN(year); - } - /* - * The PROM will reset the year to either '72 or '73. - * Therefore we store the real year separately, in one - * of unused BBU RAM locations. - */ - real_year = CMOS_READ(RTC_DEC_YEAR); - year += real_year - 72 + 2000; + setup_irq(dec_interrupt[DEC_IRQ_RTC], irq); - write_seqlock_irq(&xtime_lock); - xtime.tv_sec = mktime(year, mon, day, hour, min, sec); - xtime.tv_nsec = 0; - write_sequnlock_irq(&xtime_lock); - - if (cpu_has_counter) { - write_c0_count(0); - do_gettimeoffset = do_fast_gettimeoffset; - irq0.handler = r4k_timer_interrupt; - } else if (IOASIC) { - ioasic_write(IO_REG_FCTR, 0); - do_gettimeoffset = do_ioasic_gettimeoffset; - irq0.handler = ioasic_timer_interrupt; - } - board_time_init(&irq0); + /* Enable periodic DS1287 interrupts. */ + CMOS_WRITE(CMOS_READ(RTC_REG_B) | RTC_PIE, RTC_REG_B); } --- diff/arch/mips/defconfig 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/defconfig 2004-02-23 13:56:38.000000000 +0000 @@ -3,12 +3,16 @@ # CONFIG_MIPS=y # CONFIG_MIPS64 is not set +# CONFIG_64BIT is not set CONFIG_MIPS32=y # # Code maturity level options # CONFIG_EXPERIMENTAL=y +CONFIG_CLEAN_COMPILE=y +CONFIG_STANDALONE=y +CONFIG_BROKEN_ON_SMP=y # # General setup @@ -18,12 +22,16 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y CONFIG_LOG_BUF_SHIFT=14 -# CONFIG_EMBEDDED is not set +CONFIG_IKCONFIG=y +CONFIG_IKCONFIG_PROC=y +CONFIG_EMBEDDED=y CONFIG_KALLSYMS=y CONFIG_FUTEX=y CONFIG_EPOLL=y +CONFIG_IOSCHED_NOOP=y CONFIG_IOSCHED_AS=y CONFIG_IOSCHED_DEADLINE=y +# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set # # Loadable module support @@ -38,51 +46,45 @@ CONFIG_KMOD=y # # Machine selection # -# CONFIG_ACER_PICA_61 is not set +# CONFIG_MACH_JAZZ is not set # CONFIG_BAGET_MIPS is not set -# CONFIG_CASIO_E55 is not set +# CONFIG_MACH_VR41XX is not set +# CONFIG_TOSHIBA_JMR3927 is not set # CONFIG_MIPS_COBALT is not set -# CONFIG_DECSTATION is not set +# CONFIG_MACH_DECSTATION is not set # CONFIG_MIPS_EV64120 is not set # CONFIG_MIPS_EV96100 is not set # CONFIG_MIPS_IVR is not set # CONFIG_LASAT is not set # CONFIG_HP_LASERJET is not set -# CONFIG_IBM_WORKPAD is not set # CONFIG_MIPS_ITE8172 is not set # CONFIG_MIPS_ATLAS is not set -# CONFIG_MIPS_MAGNUM_4000 is not set # CONFIG_MIPS_MALTA is not set # CONFIG_MIPS_SEAD is not set # CONFIG_MOMENCO_OCELOT is not set # CONFIG_MOMENCO_OCELOT_G is not set # CONFIG_MOMENCO_OCELOT_C is not set +# CONFIG_MOMENCO_JAGUAR_ATX is not set +# CONFIG_PMC_YOSEMITE is not set # CONFIG_DDB5074 is not set # CONFIG_DDB5476 is not set # CONFIG_DDB5477 is not set # CONFIG_NEC_OSPREY is not set -# CONFIG_NEC_EAGLE is not set -# CONFIG_OLIVETTI_M700 is not set CONFIG_SGI_IP22=y # CONFIG_SGI_IP32 is not set # CONFIG_SOC_AU1X00 is not set # CONFIG_SIBYTE_SB1xxx_SOC is not set # CONFIG_SNI_RM200_PCI is not set -# CONFIG_TANBAC_TB0226 is not set -# CONFIG_TANBAC_TB0229 is not set -# CONFIG_TOSHIBA_JMR3927 is not set # CONFIG_TOSHIBA_RBTX4927 is not set -# CONFIG_VICTOR_MPC30X is not set -# CONFIG_ZAO_CAPCELLA is not set CONFIG_RWSEM_GENERIC_SPINLOCK=y +CONFIG_HAVE_DEC_LOCK=y CONFIG_ARC=y -CONFIG_GENERIC_ISA_DMA=y -CONFIG_NONCOHERENT_IO=y +CONFIG_DMA_NONCOHERENT=y # CONFIG_CPU_LITTLE_ENDIAN is not set CONFIG_IRQ_CPU=y CONFIG_SWAP_IO_SPACE=y CONFIG_BOOT_ELF32=y -CONFIG_L1_CACHE_SHIFT=5 +CONFIG_MIPS_L1_CACHE_SHIFT=5 CONFIG_ARC32=y # CONFIG_FB is not set CONFIG_ARC_CONSOLE=y @@ -107,7 +109,11 @@ CONFIG_CPU_R5000=y # CONFIG_CPU_R8000 is not set # CONFIG_CPU_R10000 is not set # CONFIG_CPU_RM7000 is not set +# CONFIG_CPU_RM9000 is not set # CONFIG_CPU_SB1 is not set +CONFIG_PAGE_SIZE_4KB=y +# CONFIG_PAGE_SIZE_16KB is not set +# CONFIG_PAGE_SIZE_64KB is not set CONFIG_R5000_CPU_SCACHE=y # CONFIG_64BIT_PHYS_ADDR is not set # CONFIG_CPU_ADVANCED is not set @@ -127,13 +133,20 @@ CONFIG_MMU=y # # Executable file formats # -CONFIG_KCORE_ELF=y CONFIG_BINFMT_ELF=y -# CONFIG_BINFMT_MISC is not set +CONFIG_BINFMT_MISC=m CONFIG_TRAD_SIGNALS=y CONFIG_BINFMT_IRIX=y # +# Device Drivers +# + +# +# Generic Driver Options +# + +# # Memory Technology Devices (MTD) # # CONFIG_MTD is not set @@ -146,12 +159,6 @@ CONFIG_BINFMT_IRIX=y # # Plug and Play support # -# CONFIG_PNP is not set - -# -# Generic Driver Options -# -# CONFIG_FW_LOADER is not set # # Block devices @@ -172,6 +179,7 @@ CONFIG_BINFMT_IRIX=y # SCSI device support # CONFIG_SCSI=y +CONFIG_SCSI_PROC_FS=y # # SCSI support type (disk, tape, CD-ROM) @@ -195,9 +203,8 @@ CONFIG_SCSI_CONSTANTS=y # SCSI low-level drivers # CONFIG_SGIWD93_SCSI=y -# CONFIG_SCSI_AIC7XXX is not set # CONFIG_SCSI_AIC7XXX_OLD is not set -# CONFIG_SCSI_DPT_I2O is not set +# CONFIG_SCSI_SATA is not set # CONFIG_SCSI_EATA_PIO is not set # CONFIG_SCSI_DEBUG is not set @@ -212,10 +219,19 @@ CONFIG_SGIWD93_SCSI=y # CONFIG_FUSION is not set # +# IEEE 1394 (FireWire) support (EXPERIMENTAL) +# +# CONFIG_IEEE1394 is not set + +# # I2O device support # # +# Macintosh device drivers +# + +# # Networking support # CONFIG_NET=y @@ -226,7 +242,6 @@ CONFIG_NET=y CONFIG_PACKET=y CONFIG_PACKET_MMAP=y CONFIG_NETLINK_DEV=y -# CONFIG_NETFILTER is not set CONFIG_UNIX=y CONFIG_NET_KEY=y CONFIG_INET=y @@ -240,27 +255,156 @@ CONFIG_IP_PNP_BOOTP=y # CONFIG_NET_IPGRE is not set # CONFIG_IP_MROUTE is not set # CONFIG_ARPD is not set -# CONFIG_INET_ECN is not set +CONFIG_INET_ECN=y # CONFIG_SYN_COOKIES is not set -# CONFIG_INET_AH is not set -# CONFIG_INET_ESP is not set -# CONFIG_INET_IPCOMP is not set -# CONFIG_IPV6 is not set -# CONFIG_XFRM_USER is not set +CONFIG_INET_AH=m +CONFIG_INET_ESP=m +CONFIG_INET_IPCOMP=m + +# +# IP: Virtual Server Configuration +# +CONFIG_IP_VS=m +# CONFIG_IP_VS_DEBUG is not set +CONFIG_IP_VS_TAB_BITS=12 + +# +# IPVS transport protocol load balancing support +# +CONFIG_IP_VS_PROTO_TCP=y +CONFIG_IP_VS_PROTO_UDP=y +CONFIG_IP_VS_PROTO_ESP=y +CONFIG_IP_VS_PROTO_AH=y + +# +# IPVS scheduler +# +CONFIG_IP_VS_RR=m +CONFIG_IP_VS_WRR=m +CONFIG_IP_VS_LC=m +CONFIG_IP_VS_WLC=m +CONFIG_IP_VS_LBLC=m +CONFIG_IP_VS_LBLCR=m +CONFIG_IP_VS_DH=m +CONFIG_IP_VS_SH=m +CONFIG_IP_VS_SED=m +CONFIG_IP_VS_NQ=m + +# +# IPVS application helper +# +CONFIG_IP_VS_FTP=m +CONFIG_IPV6=m +CONFIG_IPV6_PRIVACY=y +CONFIG_INET6_AH=m +CONFIG_INET6_ESP=m +CONFIG_INET6_IPCOMP=m +CONFIG_IPV6_TUNNEL=m +# CONFIG_DECNET is not set +# CONFIG_BRIDGE is not set +CONFIG_NETFILTER=y +# CONFIG_NETFILTER_DEBUG is not set + +# +# IP: Netfilter Configuration +# +CONFIG_IP_NF_CONNTRACK=m +CONFIG_IP_NF_FTP=m +CONFIG_IP_NF_IRC=m +CONFIG_IP_NF_TFTP=m +CONFIG_IP_NF_AMANDA=m +CONFIG_IP_NF_QUEUE=m +CONFIG_IP_NF_IPTABLES=m +CONFIG_IP_NF_MATCH_LIMIT=m +CONFIG_IP_NF_MATCH_IPRANGE=m +CONFIG_IP_NF_MATCH_MAC=m +CONFIG_IP_NF_MATCH_PKTTYPE=m +CONFIG_IP_NF_MATCH_MARK=m +CONFIG_IP_NF_MATCH_MULTIPORT=m +CONFIG_IP_NF_MATCH_TOS=m +CONFIG_IP_NF_MATCH_RECENT=m +CONFIG_IP_NF_MATCH_ECN=m +CONFIG_IP_NF_MATCH_DSCP=m +CONFIG_IP_NF_MATCH_AH_ESP=m +CONFIG_IP_NF_MATCH_LENGTH=m +CONFIG_IP_NF_MATCH_TTL=m +CONFIG_IP_NF_MATCH_TCPMSS=m +CONFIG_IP_NF_MATCH_HELPER=m +CONFIG_IP_NF_MATCH_STATE=m +CONFIG_IP_NF_MATCH_CONNTRACK=m +CONFIG_IP_NF_MATCH_OWNER=m +CONFIG_IP_NF_FILTER=m +CONFIG_IP_NF_TARGET_REJECT=m +CONFIG_IP_NF_NAT=m +CONFIG_IP_NF_NAT_NEEDED=y +CONFIG_IP_NF_TARGET_MASQUERADE=m +CONFIG_IP_NF_TARGET_REDIRECT=m +CONFIG_IP_NF_TARGET_NETMAP=m +CONFIG_IP_NF_TARGET_SAME=m +CONFIG_IP_NF_NAT_LOCAL=y +CONFIG_IP_NF_NAT_SNMP_BASIC=m +CONFIG_IP_NF_NAT_IRC=m +CONFIG_IP_NF_NAT_FTP=m +CONFIG_IP_NF_NAT_TFTP=m +CONFIG_IP_NF_NAT_AMANDA=m +CONFIG_IP_NF_MANGLE=m +CONFIG_IP_NF_TARGET_TOS=m +CONFIG_IP_NF_TARGET_ECN=m +CONFIG_IP_NF_TARGET_DSCP=m +CONFIG_IP_NF_TARGET_MARK=m +CONFIG_IP_NF_TARGET_CLASSIFY=m +CONFIG_IP_NF_TARGET_LOG=m +CONFIG_IP_NF_TARGET_ULOG=m +CONFIG_IP_NF_TARGET_TCPMSS=m +CONFIG_IP_NF_ARPTABLES=m +CONFIG_IP_NF_ARPFILTER=m +CONFIG_IP_NF_ARP_MANGLE=m +CONFIG_IP_NF_COMPAT_IPCHAINS=m +CONFIG_IP_NF_COMPAT_IPFWADM=m + +# +# IPv6: Netfilter Configuration +# +CONFIG_IP6_NF_QUEUE=m +CONFIG_IP6_NF_IPTABLES=m +CONFIG_IP6_NF_MATCH_LIMIT=m +CONFIG_IP6_NF_MATCH_MAC=m +CONFIG_IP6_NF_MATCH_RT=m +CONFIG_IP6_NF_MATCH_OPTS=m +CONFIG_IP6_NF_MATCH_FRAG=m +CONFIG_IP6_NF_MATCH_HL=m +CONFIG_IP6_NF_MATCH_MULTIPORT=m +CONFIG_IP6_NF_MATCH_OWNER=m +CONFIG_IP6_NF_MATCH_MARK=m +CONFIG_IP6_NF_MATCH_IPV6HEADER=m +CONFIG_IP6_NF_MATCH_AHESP=m +CONFIG_IP6_NF_MATCH_LENGTH=m +CONFIG_IP6_NF_MATCH_EUI64=m +CONFIG_IP6_NF_FILTER=m +CONFIG_IP6_NF_TARGET_LOG=m +CONFIG_IP6_NF_MANGLE=m +CONFIG_IP6_NF_TARGET_MARK=m +CONFIG_XFRM=y +CONFIG_XFRM_USER=m # # SCTP Configuration (EXPERIMENTAL) # -CONFIG_IPV6_SCTP__=y -# CONFIG_IP_SCTP is not set +CONFIG_IPV6_SCTP__=m +CONFIG_IP_SCTP=m +# CONFIG_SCTP_DBG_MSG is not set +# CONFIG_SCTP_DBG_OBJCNT is not set +# CONFIG_SCTP_HMAC_NONE is not set +# CONFIG_SCTP_HMAC_SHA1 is not set +CONFIG_SCTP_HMAC_MD5=y # CONFIG_ATM is not set # CONFIG_VLAN_8021Q is not set -# CONFIG_LLC is not set -# CONFIG_DECNET is not set -# CONFIG_BRIDGE is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set # CONFIG_X25 is not set # CONFIG_LAPB is not set -# CONFIG_NET_DIVERT is not set +CONFIG_NET_DIVERT=y # CONFIG_ECONET is not set # CONFIG_WAN_ROUTER is not set # CONFIG_NET_FASTROUTE is not set @@ -269,18 +413,41 @@ CONFIG_IPV6_SCTP__=y # # QoS and/or fair queueing # -# CONFIG_NET_SCHED is not set +CONFIG_NET_SCHED=y +CONFIG_NET_SCH_CBQ=m +CONFIG_NET_SCH_HTB=m +CONFIG_NET_SCH_HFSC=m +CONFIG_NET_SCH_CSZ=m +CONFIG_NET_SCH_PRIO=m +CONFIG_NET_SCH_RED=m +CONFIG_NET_SCH_SFQ=m +CONFIG_NET_SCH_TEQL=m +CONFIG_NET_SCH_TBF=m +CONFIG_NET_SCH_GRED=m +CONFIG_NET_SCH_DSMARK=m +CONFIG_NET_SCH_INGRESS=m +CONFIG_NET_QOS=y +CONFIG_NET_ESTIMATOR=y +CONFIG_NET_CLS=y +CONFIG_NET_CLS_TCINDEX=m +CONFIG_NET_CLS_ROUTE4=m +CONFIG_NET_CLS_ROUTE=y +CONFIG_NET_CLS_FW=m +CONFIG_NET_CLS_U32=m +CONFIG_NET_CLS_RSVP=m +CONFIG_NET_CLS_RSVP6=m +CONFIG_NET_CLS_POLICE=y # # Network testing # # CONFIG_NET_PKTGEN is not set CONFIG_NETDEVICES=y -# 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_DUMMY=m +CONFIG_BONDING=m +CONFIG_EQUALIZER=m +CONFIG_TUN=m +CONFIG_ETHERTAP=m # # Ethernet (10 or 100Mbit) @@ -305,7 +472,7 @@ CONFIG_SGISEEQ=y # CONFIG_NET_RADIO is not set # -# Token Ring devices (depends on LLC=y) +# Token Ring devices # # CONFIG_SHAPER is not set @@ -325,6 +492,11 @@ CONFIG_SGISEEQ=y # CONFIG_IRDA is not set # +# Bluetooth support +# +# CONFIG_BT is not set + +# # ISDN subsystem # # CONFIG_ISDN_BOOL is not set @@ -342,7 +514,10 @@ CONFIG_INPUT=y # # Userland interfaces # -# CONFIG_INPUT_MOUSEDEV is not set +CONFIG_INPUT_MOUSEDEV=y +CONFIG_INPUT_MOUSEDEV_PSAUX=y +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 # CONFIG_INPUT_JOYDEV is not set # CONFIG_INPUT_TSDEV is not set # CONFIG_INPUT_EVDEV is not set @@ -387,27 +562,12 @@ CONFIG_HW_CONSOLE=y # # Non-8250 serial port support # -CONFIG_SERIAL_IP22_ZILOG=y -CONFIG_SERIAL_CORE=y -CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_SERIAL_IP22_ZILOG=m +CONFIG_SERIAL_CORE=m CONFIG_UNIX98_PTYS=y CONFIG_UNIX98_PTY_COUNT=256 # -# I2C support -# -# CONFIG_I2C is not set - -# -# I2C Hardware Sensors Mainboard support -# - -# -# I2C Hardware Sensors Chip support -# -# CONFIG_I2C_SENSOR is not set - -# # Mice # # CONFIG_BUSMOUSE is not set @@ -423,27 +583,12 @@ CONFIG_UNIX98_PTY_COUNT=256 # CONFIG_WATCHDOG=y # CONFIG_WATCHDOG_NOWAYOUT is not set + +# +# Watchdog Device Drivers +# # CONFIG_SOFT_WATCHDOG is not set -# CONFIG_WDT is not set -# CONFIG_WDTPCI is not set -# CONFIG_PCWATCHDOG is not set -# CONFIG_ACQUIRE_WDT is not set -# CONFIG_ADVANTECH_WDT is not set -# CONFIG_EUROTECH_WDT is not set -# CONFIG_IB700_WDT is not set -# CONFIG_I810_TCO is not set -# CONFIG_MIXCOMWD is not set -# CONFIG_SCx200_WDT is not set -# CONFIG_60XX_WDT is not set -# CONFIG_W83877F_WDT is not set -# CONFIG_MACHZ_WDT is not set -CONFIG_INDYDOG=y -# CONFIG_SC520_WDT is not set -# CONFIG_AMD7XX_TCO is not set -# CONFIG_ALIM7101_WDT is not set -# CONFIG_SC1200_WDT is not set -# CONFIG_WAFER_WDT is not set -# CONFIG_CPU5_WDT is not set +CONFIG_INDYDOG=m # CONFIG_NVRAM is not set # CONFIG_RTC is not set # CONFIG_GEN_RTC is not set @@ -458,8 +603,13 @@ CONFIG_SGI_DS1286=y # CONFIG_FTAPE is not set # CONFIG_AGP is not set # CONFIG_DRM is not set -# CONFIG_RAW_DRIVER is not set -# CONFIG_HANGCHECK_TIMER is not set +CONFIG_RAW_DRIVER=m +CONFIG_MAX_RAW_DEVS=256 + +# +# I2C support +# +# CONFIG_I2C is not set # # Multimedia devices @@ -472,9 +622,46 @@ CONFIG_SGI_DS1286=y # CONFIG_DVB is not set # +# Graphics support +# + +# +# Console display driver support +# +# CONFIG_VGA_CONSOLE is not set +# CONFIG_MDA_CONSOLE is not set +CONFIG_SGI_NEWPORT_CONSOLE=y +CONFIG_DUMMY_CONSOLE=y +CONFIG_FONT_8x16=y + +# +# Logo configuration +# +CONFIG_LOGO=y +# CONFIG_LOGO_LINUX_MONO is not set +# CONFIG_LOGO_LINUX_VGA16 is not set +# CONFIG_LOGO_LINUX_CLUT224 is not set +CONFIG_LOGO_SGI_CLUT224=y + +# +# Sound +# +# CONFIG_SOUND is not set + +# +# USB support +# + +# +# USB Gadget Support +# +# CONFIG_USB_GADGET is not set + +# # File systems # -# CONFIG_EXT2_FS is not set +CONFIG_EXT2_FS=m +# CONFIG_EXT2_FS_XATTR is not set CONFIG_EXT3_FS=y CONFIG_EXT3_FS_XATTR=y CONFIG_EXT3_FS_POSIX_ACL=y @@ -485,36 +672,48 @@ CONFIG_FS_MBCACHE=y # CONFIG_REISERFS_FS is not set # CONFIG_JFS_FS is not set CONFIG_FS_POSIX_ACL=y -# CONFIG_XFS_FS is not set -# CONFIG_MINIX_FS is not set +CONFIG_XFS_FS=m +# CONFIG_XFS_RT is not set +CONFIG_XFS_QUOTA=y +CONFIG_XFS_SECURITY=y +# CONFIG_XFS_POSIX_ACL is not set +CONFIG_MINIX_FS=m # CONFIG_ROMFS_FS is not set -# CONFIG_QUOTA is not set -CONFIG_AUTOFS_FS=y -CONFIG_AUTOFS4_FS=y +CONFIG_QUOTA=y +# CONFIG_QFMT_V1 is not set +CONFIG_QFMT_V2=m +CONFIG_QUOTACTL=y +CONFIG_AUTOFS_FS=m +CONFIG_AUTOFS4_FS=m # # CD-ROM/DVD Filesystems # -CONFIG_ISO9660_FS=y -# CONFIG_JOLIET is not set -# CONFIG_ZISOFS is not set -# CONFIG_UDF_FS is not set +CONFIG_ISO9660_FS=m +CONFIG_JOLIET=y +CONFIG_ZISOFS=y +CONFIG_ZISOFS_FS=m +CONFIG_UDF_FS=m # # DOS/FAT/NT Filesystems # -# CONFIG_FAT_FS is not set +CONFIG_FAT_FS=m +CONFIG_MSDOS_FS=m +CONFIG_VFAT_FS=m # CONFIG_NTFS_FS is not set # # Pseudo filesystems # CONFIG_PROC_FS=y +CONFIG_PROC_KCORE=y # CONFIG_DEVFS_FS is not set CONFIG_DEVPTS_FS=y CONFIG_DEVPTS_FS_XATTR=y CONFIG_DEVPTS_FS_SECURITY=y # CONFIG_TMPFS is not set +# CONFIG_HUGETLB_PAGE is not set CONFIG_RAMFS=y # @@ -525,27 +724,30 @@ CONFIG_RAMFS=y # CONFIG_HFS_FS is not set # CONFIG_BEFS_FS is not set # CONFIG_BFS_FS is not set -# CONFIG_EFS_FS is not set +CONFIG_EFS_FS=m # CONFIG_CRAMFS is not set # CONFIG_VXFS_FS is not set # CONFIG_HPFS_FS is not set # CONFIG_QNX4FS_FS is not set # CONFIG_SYSV_FS is not set -# CONFIG_UFS_FS is not set +CONFIG_UFS_FS=m +# CONFIG_UFS_FS_WRITE is not set # # Network File Systems # -CONFIG_NFS_FS=y -# CONFIG_NFS_V3 is not set +CONFIG_NFS_FS=m +CONFIG_NFS_V3=y # CONFIG_NFS_V4 is not set -CONFIG_NFSD=y -# CONFIG_NFSD_V3 is not set -# CONFIG_NFSD_TCP is not set -CONFIG_ROOT_NFS=y -CONFIG_LOCKD=y -CONFIG_EXPORTFS=y -CONFIG_SUNRPC=y +# CONFIG_NFS_DIRECTIO is not set +CONFIG_NFSD=m +CONFIG_NFSD_V3=y +# CONFIG_NFSD_V4 is not set +CONFIG_NFSD_TCP=y +CONFIG_LOCKD=m +CONFIG_LOCKD_V4=y +CONFIG_EXPORTFS=m +CONFIG_SUNRPC=m # CONFIG_SUNRPC_GSS is not set # CONFIG_SMB_FS is not set # CONFIG_CIFS is not set @@ -576,46 +778,53 @@ CONFIG_SGI_PARTITION=y # CONFIG_EFI_PARTITION is not set # -# Graphics support +# Native Language Support # - -# -# Console display driver support -# -# CONFIG_VGA_CONSOLE is not set -# CONFIG_MDA_CONSOLE is not set -CONFIG_SGI_NEWPORT_CONSOLE=y -CONFIG_DUMMY_CONSOLE=y -CONFIG_FONT_8x16=y - -# -# Logo configuration -# -CONFIG_LOGO=y -# CONFIG_LOGO_LINUX_MONO is not set -# CONFIG_LOGO_LINUX_VGA16 is not set -# CONFIG_LOGO_LINUX_CLUT224 is not set -CONFIG_LOGO_SGI_CLUT224=y - -# -# Sound -# -# CONFIG_SOUND is not set - -# -# USB support -# -# CONFIG_USB_GADGET is not set - -# -# Bluetooth support -# -# CONFIG_BT is not set +CONFIG_NLS=m +CONFIG_NLS_DEFAULT="iso8859-1" +CONFIG_NLS_CODEPAGE_437=m +CONFIG_NLS_CODEPAGE_737=m +CONFIG_NLS_CODEPAGE_775=m +CONFIG_NLS_CODEPAGE_850=m +CONFIG_NLS_CODEPAGE_852=m +CONFIG_NLS_CODEPAGE_855=m +CONFIG_NLS_CODEPAGE_857=m +CONFIG_NLS_CODEPAGE_860=m +CONFIG_NLS_CODEPAGE_861=m +CONFIG_NLS_CODEPAGE_862=m +CONFIG_NLS_CODEPAGE_863=m +CONFIG_NLS_CODEPAGE_864=m +CONFIG_NLS_CODEPAGE_865=m +CONFIG_NLS_CODEPAGE_866=m +CONFIG_NLS_CODEPAGE_869=m +CONFIG_NLS_CODEPAGE_936=m +CONFIG_NLS_CODEPAGE_950=m +CONFIG_NLS_CODEPAGE_932=m +CONFIG_NLS_CODEPAGE_949=m +CONFIG_NLS_CODEPAGE_874=m +CONFIG_NLS_ISO8859_8=m +CONFIG_NLS_CODEPAGE_1250=m +CONFIG_NLS_CODEPAGE_1251=m +CONFIG_NLS_ISO8859_1=m +CONFIG_NLS_ISO8859_2=m +CONFIG_NLS_ISO8859_3=m +CONFIG_NLS_ISO8859_4=m +CONFIG_NLS_ISO8859_5=m +CONFIG_NLS_ISO8859_6=m +CONFIG_NLS_ISO8859_7=m +CONFIG_NLS_ISO8859_9=m +CONFIG_NLS_ISO8859_13=m +CONFIG_NLS_ISO8859_14=m +CONFIG_NLS_ISO8859_15=m +CONFIG_NLS_KOI8_R=m +CONFIG_NLS_KOI8_U=m +CONFIG_NLS_UTF8=m # # Kernel hacking # CONFIG_CROSSCOMPILE=y +CONFIG_CMDLINE="" # CONFIG_DEBUG_KERNEL is not set # @@ -639,6 +848,8 @@ CONFIG_CRYPTO_BLOWFISH=y CONFIG_CRYPTO_TWOFISH=y CONFIG_CRYPTO_SERPENT=y CONFIG_CRYPTO_AES=y +CONFIG_CRYPTO_CAST5=m +CONFIG_CRYPTO_CAST6=m CONFIG_CRYPTO_DEFLATE=y # CONFIG_CRYPTO_TEST is not set --- diff/arch/mips/galileo-boards/ev96100/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/galileo-boards/ev96100/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -6,6 +6,4 @@ # Makefile for the Galileo EV96100 board. # -obj-y += init.o time.o irq.o int-handler.o setup.o puts.o - -EXTRA_AFLAGS := $(CFLAGS) +obj-y += init.o irq.o puts.o reset.o time.o int-handler.o setup.o --- diff/arch/mips/galileo-boards/ev96100/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/galileo-boards/ev96100/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -33,13 +33,12 @@ #include #include #include -#include -#include #include #include -#include -#include +#include +#include +#include /* Environment variable */ @@ -51,7 +50,6 @@ typedef struct { int prom_argc; char **prom_argv, **prom_envp; -char arcs_cmdline[CL_SIZE]; int init_debug = 0; @@ -60,8 +58,9 @@ char * __init prom_getcmdline(void) return &(arcs_cmdline[0]); } -void prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } void __init prom_init_cmdline(void) @@ -155,14 +154,14 @@ const char *get_system_type(void) return "Galileo EV96100"; } -void __init prom_init(int argc, char **argv, char **envp, int *prom_vec) +void __init prom_init(void) { volatile unsigned char *uart; char ppbuf[8]; - prom_argc = argc; - prom_argv = argv; - prom_envp = envp; + prom_argc = fw_arg0; + prom_argv = (char **) fw_arg1; + prom_envp = (char **) fw_arg2; mips_machgroup = MACH_GROUP_GALILEO; mips_machtype = MACH_EV96100; --- diff/arch/mips/galileo-boards/ev96100/int-handler.S 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/galileo-boards/ev96100/int-handler.S 2004-02-23 13:56:38.000000000 +0000 @@ -23,8 +23,9 @@ NESTED(ev96100IRQ, PT_SIZE, sp) j ret_from_irq 1: beqz t0, 3f # spurious interrupt + move a0, t0 - move a1, sp # delay slot + move a1, sp jal ev96100_cpu_irq j ret_from_irq --- diff/arch/mips/galileo-boards/ev96100/irq.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/galileo-boards/ev96100/irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -38,55 +38,10 @@ #include #include #include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include -extern void mips_timer_interrupt(int irq, struct pt_regs *regs); extern asmlinkage void ev96100IRQ(void); -static void disable_ev96100_irq(unsigned int irq_nr) -{ - unsigned long flags; - - local_irq_save(flags); - clear_c0_status(0x100 << irq_nr); - local_irq_restore(flags); -} - -static inline void enable_ev96100_irq(unsigned int irq_nr) -{ - unsigned long flags; - - local_irq_save(flags); - set_c0_status(0x100 << irq_nr); - local_irq_restore(flags); -} - -static unsigned int startup_ev96100_irq(unsigned int irq) -{ - enable_ev96100_irq(irq); - - return 0; /* never anything pending */ -} - -#define shutdown_ev96100_irq disable_ev96100_irq -#define mask_and_ack_ev96100_irq disable_ev96100_irq - -static void end_ev96100_irq (unsigned int irq) -{ - if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) - enable_ev96100_irq(irq); -} - static inline unsigned int ffz8(unsigned int word) { unsigned long k; @@ -99,35 +54,14 @@ static inline unsigned int ffz8(unsigned return k; } -asmlinkage void ev96100_cpu_irq(unsigned long cause, struct pt_regs * regs) +asmlinkage void ev96100_cpu_irq(unsigned int pendin) { - if (!(cause & 0xff00)) - return; - - do_IRQ(ffz8((cause >> 8) & 0xff), regs); + do_IRQ(ffz8(pending >> 8), regs); } -static struct hw_interrupt_type ev96100_irq_type = { - "EV96100", - startup_ev96100_irq, - shutdown_ev96100_irq, - enable_ev96100_irq, - disable_ev96100_irq, - mask_and_ack_ev96100_irq, - end_ev96100_irq -}; - void __init init_IRQ(void) { - int i; - set_except_vector(0, ev96100IRQ); init_generic_irq(); - - for (i = 0; i < 8; i++) { - irq_desc[i].status = IRQ_DISABLED; - irq_desc[i].action = 0; - irq_desc[i].depth = 1; - irq_desc[i].handler = &ev96100_irq_type; - } + mips_cpu_irq_init(0); } --- diff/arch/mips/galileo-boards/ev96100/puts.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/galileo-boards/ev96100/puts.c 2004-02-23 13:56:38.000000000 +0000 @@ -4,7 +4,7 @@ */ #include -#include +#include //#define SERIAL_BASE EV96100_UART0_REGS_BASE @@ -22,123 +22,117 @@ #undef SLOW_DOWN static const char digits[16] = "0123456789abcdef"; -static volatile unsigned char * const com1 = (unsigned char *)SERIAL_BASE; +static volatile unsigned char *const com1 = (unsigned char *) SERIAL_BASE; #ifdef SLOW_DOWN static inline void slow_down() { - int k; - for (k=0; k<10000; k++); + int k; + for (k = 0; k < 10000; k++); } #else #define slow_down() #endif -void -putch(const unsigned char c) +void putch(const unsigned char c) { - unsigned char ch; - int i = 0; + unsigned char ch; + int i = 0; - do { - ch = com1[SERB_CMD]; - slow_down(); - i++; - if (i>TIMEOUT) { - break; - } - } while (0 == (ch & TX_BUSY)); - com1[SERB_DATA] = c; -} - -void -putchar(const unsigned char c) -{ - unsigned char ch; - int i = 0; - - do { - ch = com1[SERB_CMD]; - slow_down(); - i++; - if (i>TIMEOUT) { - break; - } - } while (0 == (ch & TX_BUSY)); - com1[SERB_DATA] = c; -} - -void -puts(unsigned char *cp) -{ - unsigned char ch; - int i = 0; - - while (*cp) { - do { - ch = com1[SERB_CMD]; - slow_down(); - i++; - if (i>TIMEOUT) { - break; - } - } while (0 == (ch & TX_BUSY)); - com1[SERB_DATA] = *cp++; - } - putch('\r'); - putch('\n'); -} - -void -fputs(unsigned char *cp) -{ - unsigned char ch; - int i = 0; - - while (*cp) { - - do { - ch = com1[SERB_CMD]; - slow_down(); - i++; - if (i>TIMEOUT) { - break; - } - } while (0 == (ch & TX_BUSY)); - com1[SERB_DATA] = *cp++; - } -} - - -void -put64(uint64_t ul) -{ - int cnt; - unsigned ch; - - cnt = 16; /* 16 nibbles in a 64 bit long */ - putch('0'); - putch('x'); - do { - cnt--; - ch = (unsigned char)(ul >> cnt * 4) & 0x0F; - putch(digits[ch]); - } while (cnt > 0); -} - -void -put32(unsigned u) -{ - int cnt; - unsigned ch; - - cnt = 8; /* 8 nibbles in a 32 bit long */ - putch('0'); - putch('x'); - do { - cnt--; - ch = (unsigned char)(u >> cnt * 4) & 0x0F; - putch(digits[ch]); - } while (cnt > 0); + do { + ch = com1[SERB_CMD]; + slow_down(); + i++; + if (i > TIMEOUT) { + break; + } + } while (0 == (ch & TX_BUSY)); + com1[SERB_DATA] = c; +} + +void putchar(const unsigned char c) +{ + unsigned char ch; + int i = 0; + + do { + ch = com1[SERB_CMD]; + slow_down(); + i++; + if (i > TIMEOUT) { + break; + } + } while (0 == (ch & TX_BUSY)); + com1[SERB_DATA] = c; +} + +void puts(unsigned char *cp) +{ + unsigned char ch; + int i = 0; + + while (*cp) { + do { + ch = com1[SERB_CMD]; + slow_down(); + i++; + if (i > TIMEOUT) { + break; + } + } while (0 == (ch & TX_BUSY)); + com1[SERB_DATA] = *cp++; + } + putch('\r'); + putch('\n'); +} + +void fputs(unsigned char *cp) +{ + unsigned char ch; + int i = 0; + + while (*cp) { + + do { + ch = com1[SERB_CMD]; + slow_down(); + i++; + if (i > TIMEOUT) { + break; + } + } while (0 == (ch & TX_BUSY)); + com1[SERB_DATA] = *cp++; + } +} + + +void put64(uint64_t ul) +{ + int cnt; + unsigned ch; + + cnt = 16; /* 16 nibbles in a 64 bit long */ + putch('0'); + putch('x'); + do { + cnt--; + ch = (unsigned char) (ul >> cnt * 4) & 0x0F; + putch(digits[ch]); + } while (cnt > 0); +} + +void put32(unsigned u) +{ + int cnt; + unsigned ch; + + cnt = 8; /* 8 nibbles in a 32 bit long */ + putch('0'); + putch('x'); + do { + cnt--; + ch = (unsigned char) (u >> cnt * 4) & 0x0F; + putch(digits[ch]); + } while (cnt > 0); } --- diff/arch/mips/galileo-boards/ev96100/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/galileo-boards/ev96100/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -36,13 +36,9 @@ #include #include #include -#include #include #include #include -#include -#include -#include #include #include @@ -50,86 +46,44 @@ #include #include #include -#include #include -#if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_PROM_CONSOLE) -extern void console_setup(char *, int *); -char serial_console[20]; -#endif - -extern char * __init prom_getcmdline(void); +extern char *__init prom_getcmdline(void); extern void mips_reboot_setup(void); -extern struct rtc_ops no_rtc_ops; -extern struct resource ioport_resource; unsigned char mac_0_1[12]; -void __init ev96100_setup(void) +static void __init ev96100_setup(void) { - unsigned long config = read_c0_config(); - unsigned long status = read_c0_status(); - unsigned long info = read_c0_info(); + unsigned int config = read_c0_config(); + unsigned int status = read_c0_status(); + unsigned int info = read_c0_info(); u32 tmp; char *argptr; clear_c0_status(ST0_FR); - if (config & 0x8) { - printk("Secondary cache is enabled\n"); - } - else { - printk("Secondary cache is disabled\n"); - } - - if (status & (1<<27)) { - printk("User-mode cache ops enabled\n"); - } - else { - printk("User-mode cache ops disabled\n"); - } - - printk("CP0 info reg: %x\n", (unsigned)info); - if (info & (1<<28)) { - printk("burst mode Scache RAMS\n"); - } - else { - printk("pipelined Scache RAMS\n"); - } - - if ((info & (0x3<<26)) >> 26 == 0) { - printk("67 percent drive strength\n"); - } - else if ((info & (0x3<<26)) >> 26 == 1) { - printk("50 percent drive strength\n"); - } - else if ((info & (0x3<<26)) >> 26 == 2) { - printk("100 percent drive strength\n"); - } - else if ((info & (0x3<<26)) >> 26 == 3) { - printk("83 percent drive strength\n"); - } - - - if ((info & (0x3<<23)) >> 23 == 0) { - printk("Write Protocol: R4000 compatible\n"); - } - else if ((info & (0x3<<23)) >> 23 == 1) { - printk("Write Protocol: Reserved\n"); - } - else if ((info & (0x3<<23)) >> 23 == 2) { - printk("Write Protocol: Pipelined\n"); - } - else if ((info & (0x3<<23)) >> 23 == 3) { - printk("Write Protocol: Write re-issue\n"); - } - - if (info & 0x1) { - printk("Atomic Enable is set\n"); - } + if (config & 0x8) + printk("Secondary cache is enabled\n"); + else + printk("Secondary cache is disabled\n"); + + if (status & (1 << 27)) + printk("User-mode cache ops enabled\n"); + else + printk("User-mode cache ops disabled\n"); + + printk("CP0 info reg: %x\n", (unsigned) info); + if (info & (1 << 28)) + printk("burst mode Scache RAMS\n"); + else + printk("pipelined Scache RAMS\n"); + + if (info & 0x1) + printk("Atomic Enable is set\n"); argptr = prom_getcmdline(); #ifdef CONFIG_SERIAL_CONSOLE @@ -139,68 +93,70 @@ void __init ev96100_setup(void) } #endif - rtc_ops = &no_rtc_ops; mips_reboot_setup(); + set_io_port_base(KSEG1); ioport_resource.start = GT_PCI_IO_BASE; - ioport_resource.end = GT_PCI_IO_BASE + 0x01ffffff; + ioport_resource.end = GT_PCI_IO_BASE + 0x01ffffff; #ifdef CONFIG_BLK_DEV_INITRD - ROOT_DEV = Root_RAM0; + ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0); #endif /* - * setup gt controller master bit so we can do config cycles + * Setup GT controller master bit so we can do config cycles */ /* Clear cause register bits */ GT_WRITE(GT_INTRCAUSE_OFS, ~(GT_INTRCAUSE_MASABORT0_BIT | - GT_INTRCAUSE_TARABORT0_BIT)); + GT_INTRCAUSE_TARABORT0_BIT)); /* Setup address */ GT_WRITE(GT_PCI0_CFGADDR_OFS, - (0 << GT_PCI0_CFGADDR_BUSNUM_SHF) | - (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) | - ((PCI_COMMAND / 4) << GT_PCI0_CFGADDR_REGNUM_SHF) | + (0 << GT_PCI0_CFGADDR_BUSNUM_SHF) | + (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) | + ((PCI_COMMAND / 4) << GT_PCI0_CFGADDR_REGNUM_SHF) | GT_PCI0_CFGADDR_CONFIGEN_BIT); udelay(2); - tmp = le32_to_cpu(*(volatile u32 *)(MIPS_GT_BASE+GT_PCI0_CFGDATA_OFS)); + tmp = GT_READ(GT_PCI0_CFGDATA_OFS); tmp |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_SERR); GT_WRITE(GT_PCI0_CFGADDR_OFS, - (0 << GT_PCI0_CFGADDR_BUSNUM_SHF) | - (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) | - ((PCI_COMMAND / 4) << GT_PCI0_CFGADDR_REGNUM_SHF) | + (0 << GT_PCI0_CFGADDR_BUSNUM_SHF) | + (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) | + ((PCI_COMMAND / 4) << GT_PCI0_CFGADDR_REGNUM_SHF) | GT_PCI0_CFGADDR_CONFIGEN_BIT); udelay(2); - *(volatile u32 *)(MIPS_GT_BASE+GT_PCI0_CFGDATA_OFS) = cpu_to_le32(tmp); + GT_WRITE(GT_PCI0_CFGDATA_OFS, tmp); /* Setup address */ GT_WRITE(GT_PCI0_CFGADDR_OFS, - (0 << GT_PCI0_CFGADDR_BUSNUM_SHF) | - (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) | - ((PCI_COMMAND / 4) << GT_PCI0_CFGADDR_REGNUM_SHF) | + (0 << GT_PCI0_CFGADDR_BUSNUM_SHF) | + (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) | + ((PCI_COMMAND / 4) << GT_PCI0_CFGADDR_REGNUM_SHF) | GT_PCI0_CFGADDR_CONFIGEN_BIT); udelay(2); - tmp = le32_to_cpu(*(volatile u32 *)(MIPS_GT_BASE+GT_PCI0_CFGDATA_OFS)); + tmp = GT_READ(GT_PCI0_CFGDATA_OFS); } +early_initcall(ev96100_setup); + unsigned short get_gt_devid(void) { u32 gt_devid; /* Figure out if this is a gt96100 or gt96100A */ GT_WRITE(GT_PCI0_CFGADDR_OFS, - (0 << GT_PCI0_CFGADDR_BUSNUM_SHF) | - (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) | - ((PCI_VENDOR_ID / 4) << GT_PCI0_CFGADDR_REGNUM_SHF) | + (0 << GT_PCI0_CFGADDR_BUSNUM_SHF) | + (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) | + ((PCI_VENDOR_ID / 4) << GT_PCI0_CFGADDR_REGNUM_SHF) | GT_PCI0_CFGADDR_CONFIGEN_BIT); udelay(4); - gt_devid = le32_to_cpu(*(volatile u32 *) - (MIPS_GT_BASE+GT_PCI0_CFGDATA_OFS)); - return (unsigned short)(gt_devid>>16); + gt_devid = GT_READ(GT_PCI0_CFGDATA_OFS); + + return gt_devid >> 16; } --- diff/arch/mips/galileo-boards/ev96100/time.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/mips/galileo-boards/ev96100/time.c 2004-02-23 13:56:38.000000000 +0000 @@ -37,11 +37,11 @@ #include #include #include +#include #include #include - -#include +#include #define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5) @@ -57,202 +57,6 @@ static inline void ack_r4ktimer(unsigned write_c0_compare(newval); } -static int set_rtc_mmss(unsigned long nowtime) -{ - /* EV96100 does not have a real time clock */ - int retval = 0; - - return retval; -} - - - -/* - * Figure out the r4k offset, the amount to increment the compare - * register for each time tick. - * Use the RTC to calculate offset. - */ -static unsigned long __init cal_r4koff(void) -{ - unsigned long count; - count = 300000000/2; - return (count / HZ); -} - - -static unsigned long __init get_mips_time(void) -{ - unsigned int year, mon, day, hour, min, sec; - - year = 2000; - mon = 10; - day = 31; - hour = 0; - min = 0; - sec = 0; - return mktime(year, mon, day, hour, min, sec); -} - - -/* - * called from start_kernel() - */ -void __init time_init(void) -{ - - unsigned int est_freq; - - r4k_offset = cal_r4koff(); - - est_freq = 2*r4k_offset*HZ; - est_freq += 5000; /* round */ - est_freq -= est_freq%10000; - printk("CPU frequency %d.%02d MHz\n", est_freq/1000000, - (est_freq%1000000)*100/1000000); - r4k_cur = (read_c0_count() + r4k_offset); - - write_c0_compare(r4k_cur); - - change_c0_status(ST0_IM, IE_IRQ5); /* FIX ME */ -} - -/* This is for machines which generate the exact clock. */ -#define USECS_PER_JIFFY (1000000/HZ) - -/* Cycle counter value at the previous timer interrupt.. */ - -static unsigned int timerhi = 0, timerlo = 0; - -/* - * FIXME: Does playing with the RP bit in c0_status interfere with this code? - */ -static unsigned long do_fast_gettimeoffset(void) -{ - u32 count; - unsigned long res, tmp; - - /* Last jiffy when do_fast_gettimeoffset() was called. */ - static unsigned long last_jiffies=0; - unsigned long quotient; - - /* - * Cached "1/(clocks per usec)*2^32" value. - * It has to be recalculated once each jiffy. - */ - static unsigned long cached_quotient=0; - - tmp = jiffies; - - quotient = cached_quotient; - - if (tmp && last_jiffies != tmp) { - last_jiffies = tmp; - __asm__(".set\tnoreorder\n\t" - ".set\tnoat\n\t" - ".set\tmips3\n\t" - "lwu\t%0,%2\n\t" - "dsll32\t$1,%1,0\n\t" - "or\t$1,$1,%0\n\t" - "ddivu\t$0,$1,%3\n\t" - "mflo\t$1\n\t" - "dsll32\t%0,%4,0\n\t" - "nop\n\t" - "ddivu\t$0,%0,$1\n\t" - "mflo\t%0\n\t" - ".set\tmips0\n\t" - ".set\tat\n\t" - ".set\treorder" - :"=&r" (quotient) - :"r" (timerhi), - "m" (timerlo), - "r" (tmp), - "r" (USECS_PER_JIFFY)); - cached_quotient = quotient; - } - - /* Get last timer tick in absolute kernel time */ - count = read_c0_count(); - - /* .. relative to previous jiffy (32 bits is enough) */ - count -= timerlo; - - __asm__("multu\t%1,%2\n\t" - "mfhi\t%0" - :"=r" (res) - :"r" (count), - "r" (quotient)); - - /* - * Due to possible jiffies inconsistencies, we need to check - * the result so that we'll get a timer that is monotonic. - */ - if (res >= USECS_PER_JIFFY) - res = USECS_PER_JIFFY-1; - - return res; -} - -/* - * This version of gettimeofday has microsecond resolution - * and better than microsecond precision on fast x86 machines with TSC. - */ -void do_gettimeofday(struct timeval *tv) -{ - unsigned long seq; - unsigned long usec, sec; - - do { - seq = read_seqbegin(&xtime_lock); - - usec = do_gettimeoffset(); - { - unsigned long lost = jiffies - wall_jiffies; - if (lost) - usec += lost * (1000000 / HZ); - } - sec = xtime.tv_sec; - usec += (xtime.tv_nsec / 1000); - } while (read_seqretry(&xtime_lock, seq)); - - while (usec >= 1000000) { - usec -= 1000000; - sec++; - } - - tv->tv_sec = sec; - tv->tv_usec = usec; -} - -EXPORT_SYMBOL(do_gettimeofday); - -void do_settimeofday(struct timeval *tv) -{ - write_seqlock_irq(&xtime_lock); - /* - * This is revolting. We need to set "xtime" correctly. However, the - * value in this location is the value at the most recent update of - * wall time. Discover what correction gettimeofday() would have - * made, and then undo it! - */ - tv->tv_usec -= do_gettimeoffset(); - tv->tv_usec -= (jiffies - wall_jiffies) * (1000000 / HZ); - - while (tv->tv_usec < 0) { - tv->tv_usec += 1000000; - tv->tv_sec--; - } - - xtime.tv_sec = tv->tv_sec; - xtime.tv_nsec = (tv->tv_usec * 1000); - time_adjust = 0; /* stop active adjtime() */ - time_status |= STA_UNSYNC; - time_maxerror = NTP_PHASE_LIMIT; - time_esterror = NTP_PHASE_LIMIT; - write_sequnlock_irq(&xtime_lock); -} - -EXPORT_SYMBOL(do_settimeofday); - /* * There are a lot of conceptually broken versions of the MIPS timer interrupt * handler floating around. This one is rather different, but the algorithm --- diff/arch/mips/gt64120/common/Makefile 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/gt64120/common/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,4 +2,5 @@ # Makefile for common code of gt64120-based boards. # -obj-y += gt_irq.o +obj-y += time.o +obj-$(CONFIG_PCI) += pci.o --- diff/arch/mips/gt64120/momenco_ocelot/irq.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/gt64120/momenco_ocelot/irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -5,7 +5,7 @@ * * Copyright 2001 MontaVista Software Inc. * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net - * Copyright (C) 2000, 2001 Ralf Baechle (ralf@gnu.org) + * Copyright (C) 2000, 2001, 2003 Ralf Baechle (ralf@gnu.org) * * 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 @@ -45,103 +45,14 @@ #include #include #include +#include #include #include - -static spinlock_t rm7000_irq_lock = SPIN_LOCK_UNLOCKED; - -/* Function for careful CP0 interrupt mask access */ -static inline void modify_cp0_intmask(unsigned clr_mask_in, unsigned set_mask_in) -{ - unsigned long status; - unsigned clr_mask; - unsigned set_mask; - - /* do the low 8 bits first */ - clr_mask = 0xff & clr_mask_in; - set_mask = 0xff & set_mask_in; - status = read_c0_status(); - status &= ~((clr_mask & 0xFF) << 8); - status |= (set_mask & 0xFF) << 8; - write_c0_status(status); - - /* do the high 8 bits */ - clr_mask = 0xff & (clr_mask_in >> 8); - set_mask = 0xff & (set_mask_in >> 8); - status = read_c0_intcontrol(); - status &= ~((clr_mask & 0xFF) << 8); - status |= (set_mask & 0xFF) << 8; - write_c0_intcontrol(status); -} - -static inline void mask_irq(unsigned int irq) -{ - modify_cp0_intmask(irq, 0); -} - -static inline void unmask_irq(unsigned int irq) -{ - modify_cp0_intmask(0, irq); -} - -static void enable_cp7000_irq(unsigned int irq) -{ - unsigned long flags; - - spin_lock_irqsave(&rm7000_irq_lock, flags); - unmask_irq(1 << irq); - spin_unlock_irqrestore(&rm7000_irq_lock, flags); -} - -static unsigned int startup_cp7000_irq(unsigned int irq) -{ - enable_cp7000_irq(irq); - - return 0; /* never anything pending */ -} - -static void disable_cp7000_irq(unsigned int irq) -{ - unsigned long flags; - - spin_lock_irqsave(&rm7000_irq_lock, flags); - mask_irq(1 << irq); - spin_unlock_irqrestore(&rm7000_irq_lock, flags); -} - -#define shutdown_cp7000_irq disable_cp7000_irq - -static void mask_and_ack_cp7000_irq(unsigned int irq) -{ - mask_irq(1 << irq); -} - -static void end_cp7000_irq(unsigned int irq) -{ - if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) - unmask_irq(1 << irq); -} - -static struct hw_interrupt_type cp7000_hpcdma_irq_type = { - "CP7000", - startup_cp7000_irq, - shutdown_cp7000_irq, - enable_cp7000_irq, - disable_cp7000_irq, - mask_and_ack_cp7000_irq, - end_cp7000_irq, - NULL -}; - - extern asmlinkage void ocelot_handle_int(void); -extern void gt64120_irq_init(void); void __init init_IRQ(void) { - int i; - /* * Clear all of the interrupts while we change the able around a bit. * int-handler is not on bootstrap @@ -151,23 +62,14 @@ void __init init_IRQ(void) /* Sets the first-level interrupt dispatcher. */ set_except_vector(0, ocelot_handle_int); - init_generic_irq(); - - for (i = 0; i <= 15; i++) { - irq_desc[i].status = IRQ_DISABLED; - irq_desc[i].action = 0; - irq_desc[i].depth = 1; - irq_desc[i].handler = &cp7000_hpcdma_irq_type; - } - gt64120_irq_init(); + init_generic_irq(); + mips_cpu_irq_init(0); + rm7k_cpu_irq_init(8); #ifdef CONFIG_KGDB printk("start kgdb ...\n"); set_debug_traps(); breakpoint(); /* you may move this line to whereever you want :-) */ #endif -#ifdef CONFIG_GDB_CONSOLE - register_gdb_console(); -#endif } --- diff/arch/mips/gt64120/momenco_ocelot/prom.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/gt64120/momenco_ocelot/prom.c 2004-02-23 13:56:38.000000000 +0000 @@ -27,7 +27,6 @@ struct callvectors { }; struct callvectors* debug_vectors; -char arcs_cmdline[CL_SIZE]; extern unsigned long gt64120_base; @@ -37,10 +36,14 @@ const char *get_system_type(void) } /* [jsun@junsun.net] PMON passes arguments in C main() style */ -void __init prom_init(int argc, char **arg, char** env, struct callvectors *cv) +void __init prom_init(void) { - int i; + int argc = fw_arg0; + char **arg = (char **) fw_arg1; + char **env = (char **) fw_arg2; + struct callvectors *cv = (struct callvectors *) fw_arg3; uint32_t tmp; + int i; /* save the PROM vectors for debugging use */ debug_vectors = cv; @@ -74,10 +77,7 @@ void __init prom_init(int argc, char **a add_memory_region(0, 64 << 20, BOOT_MEM_RAM); } -void __init prom_free_prom_memory(void) -{ -} - -void __init prom_fixup_mem_map(unsigned long start, unsigned long end) +unsigned long __init prom_free_prom_memory(void) { + return 0; } --- diff/arch/mips/gt64120/momenco_ocelot/setup.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/gt64120/momenco_ocelot/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -51,23 +50,18 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include -#include #include #include -#include +#include #include "ocelot_pld.h" -extern struct rtc_ops no_rtc_ops; - unsigned long gt64120_base = KSEG1ADDR(GT_DEF_BASE); /* These functions are used for rebooting or halting the machine*/ @@ -156,7 +150,7 @@ void PMON_v2_setup() gt64120_base = 0xe0000000; } -void __init momenco_ocelot_setup(void) +static void __init momenco_ocelot_setup(void) { void (*l3func)(unsigned long)=KSEG1ADDR(&setup_l3cache); unsigned int tmpword; @@ -172,7 +166,6 @@ void __init momenco_ocelot_setup(void) * initrd_end = (ulong)ocelot_initrd_start + (ulong)ocelot_initrd_size; * initrd_below_start_ok = 1; */ - rtc_ops = &no_rtc_ops; /* do handoff reconfiguration */ if (gt64120_base == KSEG1ADDR(GT_DEF_BASE)) @@ -314,6 +307,8 @@ void __init momenco_ocelot_setup(void) GT_WRITE(0x468, 0xfef73); } +early_initcall(momenco_ocelot_setup); + extern int rm7k_tcache_enabled; /* * This runs in KSEG1. See the verbiage in rm7k.c::probe_scache() @@ -327,7 +322,7 @@ static void __init setup_l3cache(unsigne printk("Enabling L3 cache..."); /* Enable the L3 cache in the GT64120A's CPU Configuration register */ - GT_READ(0, &tmp); + tmp = GT_READ(0); GT_WRITE(0, tmp | (1<<14)); /* Enable the L3 cache in the CPU */ --- diff/arch/mips/hp-lj/init.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/hp-lj/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -17,9 +17,7 @@ const char CommandLine[] = Delimiter "root=/dev/hda3 "; -char arcs_cmdline[CL_SIZE]; - -int __init prom_init(int argc, char ** argv, char **envp) +void __init prom_init(void) { ulong mem_size = get_mem_avail(); int reserve_size = 0; @@ -43,11 +41,10 @@ int __init prom_init(int argc, char ** a mips_machtype = MACH_UNKNOWN; strcpy(arcs_cmdline, CommandLine+strlen(Delimiter)); - - return 0; } -void prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } --- diff/arch/mips/hp-lj/setup.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/hp-lj/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -14,52 +14,57 @@ #include #include #include -#include #include #include #include #include "utils.h" +extern char CommandLine[]; +extern void pci_setup(void); + #ifdef CONFIG_KGDB int remote_debug = 0; #endif const char *get_system_type(void) { - return "HP LaserJet"; /* But which exactly? */ + return "HP LaserJet"; /* But which exactly? */ } -static void (*timer_interrupt_service)(int irq, void *dev_id, struct pt_regs * regs) = NULL; +static void (*timer_interrupt_service) (int irq, void *dev_id, + struct pt_regs * regs) = NULL; -static void andros_timer_interrupt(int irq, void *dev_id, struct pt_regs * regs) +static void andros_timer_interrupt(int irq, void *dev_id, + struct pt_regs *regs) { - if (!(*((volatile unsigned int*)0xbfea0010) & 0x20)) // mask = pend & en - return; + if (!(*((volatile unsigned int *) 0xbfea0010) & 0x20)) // mask = pend & en + return; - /* clear timer interrupt */ - { - unsigned int tmr = *((volatile unsigned int*)0xbfe90040); // ctl bits - *((volatile unsigned int*)0xbfe90040) = tmr; // write to ack - *((volatile unsigned int*)0xbfea000c) = 0x20; // sys int ack - } + /* clear timer interrupt */ + { + unsigned int tmr = *((volatile unsigned int *) 0xbfe90040); // ctl bits + *((volatile unsigned int *) 0xbfe90040) = tmr; // write to ack + *((volatile unsigned int *) 0xbfea000c) = 0x20; // sys int ack + } - /* service interrupt */ - timer_interrupt_service(irq, dev_id, regs); + /* service interrupt */ + timer_interrupt_service(irq, dev_id, regs); } -static void harmony_timer_interrupt(int irq, void *dev_id, struct pt_regs * regs) +static void harmony_timer_interrupt(int irq, void *dev_id, + struct pt_regs *regs) { - if (!(*((volatile unsigned int*)0xbff63000) & 0x01)) - return; // big sys int reg, 01-timer did it - if (!(*((volatile unsigned int*)0xbff610a4) & 0x01)) - return; // local small int reg, 01-timer0 did it + if (!(*((volatile unsigned int *) 0xbff63000) & 0x01)) + return; // big sys int reg, 01-timer did it + if (!(*((volatile unsigned int *) 0xbff610a4) & 0x01)) + return; // local small int reg, 01-timer0 did it - *((volatile unsigned int*)0xbff610a4) = 1; // ack local timer0 bit - *((volatile unsigned int*)0xbff63000) = 1; // ack global timer bit + *((volatile unsigned int *) 0xbff610a4) = 1; // ack local timer0 bit + *((volatile unsigned int *) 0xbff63000) = 1; // ack global timer bit - /* service interrupt */ - timer_interrupt_service(irq, dev_id, regs); + /* service interrupt */ + timer_interrupt_service(irq, dev_id, regs); } @@ -68,87 +73,78 @@ static void harmony_timer_interrupt(int static void __init hp_time_init(struct irqaction *irq) { - timer_interrupt_service = irq->handler; + timer_interrupt_service = irq->handler; - if (GetAsicId() == AndrosAsic) { - //*((volatile unsigned int*)0xbfe90000) = 0x2f; // set by bootloader to 0x20 // prescaler - *((volatile unsigned int*)0xbfe90040) = 0x21; // 20-res of 1kHz,1-int ack // control - *((volatile unsigned int*)0xbfe90048) = 0x09; // 09-reload val // reload - *((volatile unsigned int*)0xbfe90044) = 0x09; // 09-count val // count - *((volatile unsigned int*)0xbfe90040) = 0x2f; // 8-int enable,4-reload en,2-count down en,1-int-ack - - irq->handler = andros_timer_interrupt; - irq->flags |= SA_INTERRUPT | SA_SHIRQ; - printk("setting up timer in hp_time_init\n"); - setup_irq(ASIC_IRQ_NUMBER, irq); - - // enable timer interrupt - *((volatile unsigned int*)0xbfea0000) = 0x20; - - } else if (GetAsicId() == HarmonyAsic) { - - *((volatile unsigned int*)0xbff61000) = 99; // prescaler, 100Mz sys clk - *((volatile unsigned int*)0xbff61028) = 0x09; // reload reg - *((volatile unsigned int*)0xbff61024) = 0x09; // count reg - *((volatile unsigned int*)0xbff61020) = 0x0b; // 80-1khz res on timer, 2 reload en, 1 - count down en - - irq->handler = harmony_timer_interrupt; - irq->flags |= SA_INTERRUPT | SA_SHIRQ; - setup_irq(ASIC_IRQ_NUMBER, irq); - - *((volatile unsigned int*)0xbff610a0) |= 1; // turn on timer0 - - } else if (GetAsicId() == UnknownAsic) - printk("Unknown asic in hp_time_init()\n"); - else - printk("Unsupported asic in hp_time_init()\n"); + if (GetAsicId() == AndrosAsic) { + //*((volatile unsigned int*)0xbfe90000) = 0x2f; // set by bootloader to 0x20 // prescaler + *((volatile unsigned int *) 0xbfe90040) = 0x21; // 20-res of 1kHz,1-int ack // control + *((volatile unsigned int *) 0xbfe90048) = 0x09; // 09-reload val // reload + *((volatile unsigned int *) 0xbfe90044) = 0x09; // 09-count val // count + *((volatile unsigned int *) 0xbfe90040) = 0x2f; // 8-int enable,4-reload en,2-count down en,1-int-ack + + irq->handler = andros_timer_interrupt; + irq->flags |= SA_INTERRUPT | SA_SHIRQ; + printk("setting up timer in hp_time_init\n"); + setup_irq(ASIC_IRQ_NUMBER, irq); + + // enable timer interrupt + *((volatile unsigned int *) 0xbfea0000) = 0x20; + + } else if (GetAsicId() == HarmonyAsic) { + + *((volatile unsigned int *) 0xbff61000) = 99; // prescaler, 100Mz sys clk + *((volatile unsigned int *) 0xbff61028) = 0x09; // reload reg + *((volatile unsigned int *) 0xbff61024) = 0x09; // count reg + *((volatile unsigned int *) 0xbff61020) = 0x0b; // 80-1khz res on timer, 2 reload en, 1 - count down en + + irq->handler = harmony_timer_interrupt; + irq->flags |= SA_INTERRUPT | SA_SHIRQ; + setup_irq(ASIC_IRQ_NUMBER, irq); + + *((volatile unsigned int *) 0xbff610a0) |= 1; // turn on timer0 + + } else if (GetAsicId() == UnknownAsic) + printk("Unknown asic in hp_time_init()\n"); + else + printk("Unsupported asic in hp_time_init()\n"); } static void hplj_restart(void) { - if (GetAsicId() == AndrosAsic) - *((volatile unsigned int *) 0xbfe900c0) = 0; + if (GetAsicId() == AndrosAsic) + *((volatile unsigned int *) 0xbfe900c0) = 0; - if (GetAsicId() == HarmonyAsic) - *((volatile unsigned int *) 0xbff62030) = 0; + if (GetAsicId() == HarmonyAsic) + *((volatile unsigned int *) 0xbff62030) = 0; - printk("Restart Failed ... halting instead\n"); - while(1); + printk("Restart Failed ... halting instead\n"); + while (1); } static void hplj_halt(void) { - while(1); + while (1); } -void __init hp_setup(void) +static void __init hp_setup(void) { #ifdef CONFIG_PCI - extern void pci_setup(void); - pci_setup(); -#endif - -#ifdef CONFIG_IDE - { - extern struct ide_ops std_ide_ops; - ide_ops = &std_ide_ops; - } + pci_setup(); #endif - _machine_restart =(void (*)(char *)) hplj_restart; - _machine_halt = hplj_halt; - _machine_power_off = hplj_halt; + _machine_restart = (void (*)(char *)) hplj_restart; + _machine_halt = hplj_halt; + _machine_power_off = hplj_halt; - board_timer_setup = hp_time_init; + board_timer_setup = hp_time_init; #ifdef CONFIG_KGDB - { - extern char CommandLine[]; - remote_debug = (strstr(CommandLine, "kgdb") != NULL); - } + remote_debug = (strstr(CommandLine, "kgdb") != NULL); #endif - printk("HP SETUP\n"); + printk("HP SETUP\n"); } + +early_initcall(hp_setup); --- diff/arch/mips/ite-boards/generic/irq.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/ite-boards/generic/irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -75,8 +75,6 @@ extern void breakpoint(void); #define ALLINTS_NOTIMER (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4) -unsigned int local_bh_count[NR_CPUS]; -unsigned int local_irq_count[NR_CPUS]; void disable_it8172_irq(unsigned int irq_nr); void enable_it8172_irq(unsigned int irq_nr); @@ -84,8 +82,8 @@ extern void set_debug_traps(void); extern void mips_timer_interrupt(int irq, struct pt_regs *regs); extern asmlinkage void it8172_IRQ(void); -struct it8172_intc_regs volatile *it8172_hw0_icregs - = (struct it8172_intc_regs volatile *)(KSEG1ADDR(IT8172_PCI_IO_BASE + IT_INTC_BASE)); +struct it8172_intc_regs volatile *it8172_hw0_icregs = + (struct it8172_intc_regs volatile *)(KSEG1ADDR(IT8172_PCI_IO_BASE + IT_INTC_BASE)); /* Function for careful CP0 interrupt mask access */ static inline void modify_cp0_intmask(unsigned clr_mask, unsigned set_mask) @@ -244,7 +242,6 @@ static struct hw_interrupt_type cp0_irq_ end_none }; - void enable_cpu_timer(void) { unsigned long flags; @@ -254,7 +251,6 @@ void enable_cpu_timer(void) local_irq_restore(flags); } - void __init init_IRQ(void) { int i; @@ -334,8 +330,7 @@ void it8172_hw0_irqdispatch(struct pt_re intstatus = it8172_hw0_icregs->intstatus; if (intstatus & 0x8) { panic("Got NMI interrupt"); - } - else if (intstatus & 0x4) { + } else if (intstatus & 0x4) { /* PCI interrupt */ irq = 0; status |= it8172_hw0_icregs->pci_req; @@ -372,10 +367,9 @@ void it8172_hw0_irqdispatch(struct pt_re } irq += IT8172_LPC_IRQ_BASE; //printk("LPC int %d\n", irq); - } - else { + } else return; - } + do_IRQ(irq, regs); } --- diff/arch/mips/ite-boards/generic/it8172_setup.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/ite-boards/generic/it8172_setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -47,17 +46,8 @@ #include #include -#if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_PROM_CONSOLE) -extern void console_setup(char *, int *); -char serial_console[20]; -#endif - extern struct resource ioport_resource; -#ifdef CONFIG_BLK_DEV_IDE -extern struct ide_ops std_ide_ops; -extern struct ide_ops *ide_ops; -#endif -#ifdef CONFIG_PC_KEYB +#ifdef CONFIG_SERIO_I8042 int init_8712_keyboard(void); #endif @@ -115,7 +105,7 @@ void __init it8172_init_ram_resource(uns it8172_resources.ram.end = memsize; } -void __init it8172_setup(void) +static void __init it8172_setup(void) { unsigned short dsr; char *argptr; @@ -138,10 +128,10 @@ void __init it8172_setup(void) _machine_power_off = it8172_power_off; /* - * IO/MEM resources. - * - * revisit this area. - */ + * IO/MEM resources. + * + * revisit this area. + */ set_io_port_base(KSEG1); ioport_resource.start = it8172_resources.pci_io.start; ioport_resource.end = it8172_resources.pci_io.end; @@ -161,6 +151,10 @@ void __init it8172_setup(void) * Pull enabled devices out of standby */ IT_IO_READ16(IT_PM_DSR, dsr); + + /* + * Fixme: This breaks when these drivers are modules!!! + */ #ifdef CONFIG_SOUND_IT8172 dsr &= ~IT_PM_DSR_ACSB; #else @@ -168,30 +162,24 @@ void __init it8172_setup(void) #endif #ifdef CONFIG_BLK_DEV_IT8172 dsr &= ~IT_PM_DSR_IDESB; - ide_ops = &std_ide_ops; #else dsr |= IT_PM_DSR_IDESB; #endif IT_IO_WRITE16(IT_PM_DSR, dsr); -#ifdef CONFIG_FB - conswitchp = &dummy_con; -#endif - InitLPCInterface(); #ifdef CONFIG_MIPS_ITE8172 if (SearchIT8712()) { printk("Found IT8712 Super IO\n"); - // enable IT8712 serial port + /* enable IT8712 serial port */ LPCSetConfig(LDN_SERIAL1, 0x30, 0x01); /* enable */ LPCSetConfig(LDN_SERIAL1, 0x23, 0x01); /* clock selection */ -#ifdef CONFIG_PC_KEYB +#ifdef CONFIG_SERIO_I8042 if (init_8712_keyboard()) { printk("Unable to initialize keyboard\n"); LPCSetConfig(LDN_KEYBOARD, 0x30, 0x0); /* disable keyboard */ - } - else { + } else { LPCSetConfig(LDN_KEYBOARD, 0x30, 0x1); /* enable keyboard */ LPCSetConfig(LDN_KEYBOARD, 0xf0, 0x2); LPCSetConfig(LDN_KEYBOARD, 0x71, 0x3); @@ -205,7 +193,6 @@ void __init it8172_setup(void) (LPCGetConfig(LDN_MOUSE, 0x30) == 0)) printk("Error: keyboard or mouse not enabled\n"); - kbd_ops = &std_kbd_ops; } #endif } @@ -264,16 +251,20 @@ void __init it8172_setup(void) #endif /* CONFIG_IT8172_SCR1 */ } +early_initcall(it8172_setup); -#ifdef CONFIG_PC_KEYB +#ifdef CONFIG_SERIO_I8042 /* * According to the ITE Special BIOS Note for waking up the * keyboard controller... */ -int init_8712_keyboard() +static int init_8712_keyboard(void) { unsigned int cmd_port = 0x14000064; unsigned int data_port = 0x14000060; + ^^^^^^^^^^^ + Somebody here doesn't grok the concept of io ports. + unsigned char data; int i; --- diff/arch/mips/ite-boards/generic/pmon_prom.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/ite-boards/generic/pmon_prom.c 2004-02-23 13:56:38.000000000 +0000 @@ -42,9 +42,6 @@ #include -/* #define DEBUG_CMDLINE */ - -char arcs_cmdline[CL_SIZE]; extern int prom_argc; extern char **prom_argv, **prom_envp; @@ -111,8 +108,9 @@ static inline unsigned char str2hexnum(u return 0; /* foo */ } -void prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } unsigned long __init prom_get_memsize(void) --- diff/arch/mips/ite-boards/generic/time.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/ite-boards/generic/time.c 2004-02-23 13:56:38.000000000 +0000 @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -114,7 +113,7 @@ hour_hw_to_bin(unsigned char c) static unsigned long r4k_offset; /* Amount to increment compare reg each time */ static unsigned long r4k_cur; /* What counter should be at next timer irq */ -extern unsigned int mips_counter_frequency; +extern unsigned int mips_hpt_frequency; /* * Figure out the r4k offset, the amount to increment the compare @@ -138,12 +137,12 @@ static unsigned long __init cal_r4koff(v while (CMOS_READ(RTC_REG_A) & RTC_UIP); while (!(CMOS_READ(RTC_REG_A) & RTC_UIP)); - mips_counter_frequency = read_c0_count(); + mips_hpt_frequency = read_c0_count(); /* restore interrupts */ local_irq_restore(flags); - return (mips_counter_frequency / HZ); + return (mips_hpt_frequency / HZ); } static unsigned long --- diff/arch/mips/ite-boards/ivr/init.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/ite-boards/ivr/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,5 +1,4 @@ /* - * * BRIEF MODULE DESCRIPTION * IVR board setup. * @@ -35,7 +34,6 @@ #include #include #include -#include #include #include @@ -55,16 +53,14 @@ const char *get_system_type(void) return "Globespan IVR"; } -int __init prom_init(int argc, char **argv, char **envp, int *prom_vec) +void __init prom_init(void) { unsigned long mem_size; unsigned long pcicr; - prom_argc = argc; - prom_argv = argv; - prom_envp = envp; - - puts("IVR board running..."); + prom_argc = fw_arg0; + prom_argv = (char **) fw_arg1; + prom_envp = (int *) fw_arg3; mips_machgroup = MACH_GROUP_GLOBESPAN; mips_machtype = MACH_IVR; /* Globespan's iTVC15 reference board */ @@ -85,5 +81,4 @@ int __init prom_init(int argc, char **ar it8172_init_ram_resource(mem_size); add_memory_region(0, mem_size, BOOT_MEM_RAM); - return 0; } --- diff/arch/mips/ite-boards/qed-4n-s01b/Makefile 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/ite-boards/qed-4n-s01b/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -8,5 +8,3 @@ # obj-y := init.o - -obj-$(CONFIG_PCI) += pci_fixup.o --- diff/arch/mips/ite-boards/qed-4n-s01b/init.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/ite-boards/qed-4n-s01b/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -54,16 +53,14 @@ const char *get_system_type(void) return "ITE QED-4N-S01B"; } -int __init prom_init(int argc, char **argv, char **envp, int *prom_vec) +void __init prom_init(void) { unsigned long mem_size; unsigned long pcicr; - prom_argc = argc; - prom_argv = argv; - prom_envp = envp; - - puts("ITE board running..."); + prom_argc = fw_arg0; + prom_argv = (char **) fw_arg1; + prom_envp = (int *) fw_arg3; mips_machgroup = MACH_GROUP_ITE; mips_machtype = MACH_QED_4N_S01B; /* ITE board name/number */ @@ -85,6 +82,4 @@ int __init prom_init(int argc, char **ar it8172_init_ram_resource(mem_size); add_memory_region(0, mem_size, BOOT_MEM_RAM); - - return 0; } --- diff/arch/mips/jazz/Makefile 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/jazz/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,8 +2,6 @@ # Makefile for the Jazz family specific parts of the kernel # -export-syms := jazz-ksyms.o -obj-y := int-handler.o irq.o jazzdma.o jazz-ksyms.o reset.o \ - rtc-jazz.o setup.o floppy-jazz.o kbd-jazz.o +obj-y := int-handler.o irq.o jazzdma.o reset.o setup.o EXTRA_AFLAGS := $(CFLAGS) --- diff/arch/mips/jazz/int-handler.S 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/jazz/int-handler.S 2004-02-23 13:56:38.000000000 +0000 @@ -88,9 +88,9 @@ ll_local_dev: lbu t0,JAZZ_IO_IRQ_SOURCE * cards. Oh well - for all the Jazz boxes slots are more or less just * whistles and bells and we're aware of the problem. */ -ll_isa_irq: lw a0,JAZZ_EISA_IRQ_ACK +ll_isa_irq: lw a0, JAZZ_EISA_IRQ_ACK - jal i8259_do_irq + jal do_IRQ move a1,sp j ret_from_irq @@ -133,7 +133,7 @@ ll_timer: lw zero,JAZZ_TIMER_REGISTER # /* * CPU count/compare IRQ (unused) */ -ll_count: j return +ll_count: j ret_from_irq mtc0 zero,CP0_COMPARE #if 0 --- diff/arch/mips/jazz/irq.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/jazz/irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -4,9 +4,8 @@ * for more details. * * Copyright (C) 1992 Linus Torvalds - * Copyright (C) 1994 - 2001 Ralf Baechle + * Copyright (C) 1994 - 2001, 2003 Ralf Baechle */ -#include #include #include #include @@ -18,6 +17,75 @@ extern asmlinkage void jazz_handle_int(void); +static spinlock_t r4030_lock = SPIN_LOCK_UNLOCKED; + +extern asmlinkage void sni_rm200_pci_handle_int(void); + +static void enable_r4030_irq(unsigned int irq) +{ + unsigned int mask = 1 << (irq - JAZZ_IE_PARALLEL); + unsigned long flags; + + spin_lock_irqsave(&r4030_lock, flags); + mask |= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE); + r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask); + spin_unlock_irqrestore(&r4030_lock, flags); +} + +static unsigned int startup_r4030_irq(unsigned int irq) +{ + enable_r4030_irq(irq); + return 0; /* never anything pending */ +} + +#define shutdown_r4030_irq disable_r4030_irq + +void disable_r4030_irq(unsigned int irq) +{ + unsigned int mask = ~(1 << (irq - JAZZ_IE_PARALLEL)); + unsigned long flags; + + spin_lock_irqsave(&r4030_lock, flags); + mask &= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE); + r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask); + spin_unlock_irqrestore(&r4030_lock, flags); +} + +#define mask_and_ack_r4030_irq disable_r4030_irq + +static void end_r4030_irq(unsigned int irq) +{ + if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) + enable_r4030_irq(irq); +} + +static struct hw_interrupt_type r4030_irq_type = { + "R4030", + startup_r4030_irq, + shutdown_r4030_irq, + enable_r4030_irq, + disable_r4030_irq, + mask_and_ack_r4030_irq, + end_r4030_irq, + NULL +}; + +void __init init_r4030_ints(void) +{ + int i; + + for (i = JAZZ_PARALLEL_IRQ; i <= JAZZ_TIMER_IRQ; i++) { + irq_desc[i].status = IRQ_DISABLED; + irq_desc[i].action = 0; + irq_desc[i].depth = 1; + irq_desc[i].handler = &r4030_irq_type; + } + + r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, 0); + r4030_read_reg16(JAZZ_IO_IRQ_SOURCE); /* clear pending IRQs */ + r4030_read_reg32(JAZZ_R4030_INVAL_ADDR); /* clear error bits */ +} + /* * On systems with i8259-style interrupt controllers we assume for * driver compatibility reasons interrupts 0 - 15 to be the i8259 @@ -25,21 +93,11 @@ extern asmlinkage void jazz_handle_int(v */ void __init init_IRQ (void) { - int i; - set_except_vector(0, jazz_handle_int); init_generic_irq(); init_i8259_irqs(); /* Integrated i8259 */ -#if 0 - init_jazz_irq(); + init_r4030_ints(); - /* Actually we've got more interrupts to handle ... */ - for (i = PCIMT_IRQ_INT2; i <= PCIMT_IRQ_ETHERNET; i++) { - irq_desc[i].status = IRQ_DISABLED; - irq_desc[i].action = 0; - irq_desc[i].depth = 1; - irq_desc[i].handler = &pciasic_irq_type; - } -#endif + change_c0_status(ST0_IM, IE_IRQ4 | IE_IRQ3 | IE_IRQ2 | IE_IRQ1); } --- diff/arch/mips/jazz/jazzdma.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/jazz/jazzdma.c 2004-02-23 13:56:38.000000000 +0000 @@ -9,6 +9,7 @@ */ #include #include +#include #include #include #include @@ -78,7 +79,7 @@ void __init vdma_init(void) vdma_pgtbl_init(); r4030_write_reg32(JAZZ_R4030_TRSTBL_BASE, - PHYSADDR(vdma_pagetable_start)); + CPHYSADDR(vdma_pagetable_start)); r4030_write_reg32(JAZZ_R4030_TRSTBL_LIM, VDMA_PGTBL_SIZE); r4030_write_reg32(JAZZ_R4030_TRSTBL_INV, 0); @@ -170,6 +171,8 @@ unsigned long vdma_alloc(unsigned long p return laddr; } +EXPORT_SYMBOL(vdma_alloc); + /* * Free previously allocated dma translation pages * Note that this does NOT change the translation table, @@ -201,6 +204,8 @@ int vdma_free(unsigned long laddr) return 0; } +EXPORT_SYMBOL(vdma_free); + /* * Map certain page(s) to another physical address. * Caller must have allocated the page(s) before. @@ -310,6 +315,8 @@ unsigned long vdma_log2phys(unsigned lon return pgtbl[laddr >> 12].frame + (laddr & (VDMA_PAGESIZE - 1)); } +EXPORT_SYMBOL(vdma_log2phys); + /* * Print DMA statistics */ --- diff/arch/mips/jazz/reset.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/jazz/reset.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,5 +1,8 @@ /* * Reset a Jazz machine. + * + * We don't trust the firmware so we do it the classic way by poking and + * stabbing at the keyboard controller ... */ #include #include @@ -8,25 +11,54 @@ #include #include +#define jazz_kh ((keyboard_hardware *) JAZZ_KEYBOARD_ADDRESS) + +#define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */ + +static void jazz_write_output(unsigned char val) +{ + int status; + + do { + status = jazz_kh->command; + } while (status & KBD_STAT_IBF); + jazz_kh->data = val; +} + +static void jazz_write_command(unsigned char val) +{ + int status; + + do { + status = jazz_kh->command; + } while (status & KBD_STAT_IBF); + jazz_kh->command = val; +} + +static unsigned char jazz_read_status(void) +{ + return jazz_kh->command; +} + static inline void kb_wait(void) { unsigned long start = jiffies; unsigned long timeout = start + HZ/2; do { - if (! (kbd_read_status() & 0x02)) + if (! (jazz_read_status() & 0x02)) return; - } time_before_eq(jiffies, timeout); + } while (time_before_eq(jiffies, timeout)); } void jazz_machine_restart(char *command) { - while (1) { - kb_wait (); - kbd_write_command (0xd1); - kb_wait (); - kbd_write_output (0x00); - } + while(1) { + kb_wait(); + jazz_write_command (0xd1); + kb_wait(); + jazz_write_output (0x00); + } } void jazz_machine_halt(void) --- diff/arch/mips/jazz/setup.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/mips/jazz/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -28,62 +27,33 @@ #include #include #include +#include #include -/* - * Initial irq handlers. - */ -static void no_action(int cpl, void *dev_id, struct pt_regs *regs) { } - -/* - * IRQ2 is cascade interrupt to second interrupt controller - */ -static struct irqaction irq2 = { no_action, 0, 0, "cascade", NULL, NULL}; - extern asmlinkage void jazz_handle_int(void); extern void jazz_machine_restart(char *command); extern void jazz_machine_halt(void); extern void jazz_machine_power_off(void); -extern struct ide_ops std_ide_ops; -extern struct rtc_ops jazz_rtc_ops; -extern struct kbd_ops jazz_kbd_ops; -extern struct fd_ops *fd_ops; -extern struct fd_ops jazz_fd_ops; - -void (*board_time_init)(struct irqaction *irq); - static void __init jazz_time_init(struct irqaction *irq) { - /* set the clock to 100 Hz */ - r4030_write_reg32(JAZZ_TIMER_INTERVAL, 9); - i8259_setup_irq(JAZZ_TIMER_IRQ, irq); -} - -static void __init jazz_irq_setup(void) -{ - set_except_vector(0, jazz_handle_int); - r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, - JAZZ_IE_ETHERNET | - JAZZ_IE_SCSI | - JAZZ_IE_SERIAL1 | - JAZZ_IE_SERIAL2 | - JAZZ_IE_PARALLEL | - JAZZ_IE_FLOPPY); - r4030_read_reg16(JAZZ_IO_IRQ_SOURCE); /* clear pending IRQs */ - r4030_read_reg32(JAZZ_R4030_INVAL_ADDR); /* clear error bits */ - change_c0_status(ST0_IM, IE_IRQ4 | IE_IRQ3 | IE_IRQ2 | IE_IRQ1); /* set the clock to 100 Hz */ r4030_write_reg32(JAZZ_TIMER_INTERVAL, 9); - request_region(0x20, 0x20, "pic1"); - request_region(0xa0, 0x20, "pic2"); - i8259_setup_irq(2, &irq2); + setup_irq(JAZZ_TIMER_IRQ, irq); } +static struct resource jazz_io_resources[] = { + { "dma1", 0x00, 0x1f, IORESOURCE_BUSY }, + { "timer", 0x40, 0x5f, IORESOURCE_BUSY }, + { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY }, + { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY }, +}; -void __init jazz_setup(void) +static void __init jazz_setup(void) { + int i; + /* Map 0xe0000000 -> 0x0:800005C0, 0xe0010000 -> 0x1:30000580 */ add_wired_entry (0x02000017, 0x03c00017, 0xe0000000, PM_64K); @@ -93,34 +63,24 @@ void __init jazz_setup(void) /* Map 0xe4000000 -> 0x0:600005C0, 0xe4100000 -> 400005C0 */ add_wired_entry (0x01800017, 0x01000017, 0xe4000000, PM_4M); - irq_setup = jazz_irq_setup; set_io_port_base(JAZZ_PORT_BASE); #ifdef CONFIG_EISA if (mips_machtype == MACH_MIPS_MAGNUM_4000) EISA_bus = 1; #endif isa_slot_offset = 0xe3000000; - request_region(0x00,0x20,"dma1"); - request_region(0x40,0x20,"timer"); - request_region(0x80,0x10,"dma page reg"); - request_region(0xc0,0x20,"dma2"); - board_time_init = jazz_time_init; + + /* request I/O space for devices used on all i[345]86 PCs */ + for (i = 0; i < ARRAY_SIZE(jazz_io_resources); i++) + request_resource(&ioport_resource, jazz_io_resources + i); + + board_timer_setup = jazz_time_init; /* The RTC is outside the port address space */ _machine_restart = jazz_machine_restart; _machine_halt = jazz_machine_halt; _machine_power_off = jazz_machine_power_off; -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &std_ide_ops; -#endif -#ifdef CONFIG_BLK_DEV_FD - fd_ops = &jazz_fd_ops; -#endif -#ifdef CONFIG_VT - conswitchp = &dummy_con; -#endif - #warning "Somebody should check if screen_info is ok for Jazz." screen_info = (struct screen_info) { @@ -135,8 +95,7 @@ void __init jazz_setup(void) 16 /* orig_video_points */ }; - rtc_ops = &jazz_rtc_ops; - kbd_ops = &jazz_kbd_ops; - vdma_init(); } + +early_initcall(jazz_setup); --- diff/arch/mips/jmr3927/common/prom.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/jmr3927/common/prom.c 2004-02-23 13:56:38.000000000 +0000 @@ -41,9 +41,6 @@ #include -/* #define DEBUG_CMDLINE */ - -char arcs_cmdline[CL_SIZE]; extern int prom_argc; extern char **prom_argv, **prom_envp; @@ -78,6 +75,7 @@ void __init prom_init_cmdline(void) *cp = '\0'; } -void prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } --- diff/arch/mips/jmr3927/rbhma3100/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/jmr3927/rbhma3100/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,7 +2,7 @@ # Makefile for TOSHIBA JMR-TX3927 board # -obj-y += init.o int-handler.o irq.o setup.o rtc.o +obj-y += init.o int-handler.o irq.o setup.o obj-$(CONFIG_RUNTIME_DEBUG) += debug.o obj-$(CONFIG_KGDB) += kgdb_io.o --- diff/arch/mips/jmr3927/rbhma3100/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/jmr3927/rbhma3100/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,5 +1,4 @@ -/*********************************************************************** - * +/* * Copyright 2001 MontaVista Software Inc. * Author: MontaVista Software, Inc. * ahennessy@mvista.com @@ -27,8 +26,6 @@ * 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 #include @@ -57,16 +54,17 @@ const char *get_system_type(void) } extern void puts(unsigned char *cp); -int __init prom_init(int argc, char **argv, char **envp, int *prom_vec) + +void __init prom_init(void) { #ifdef CONFIG_TOSHIBA_JMR3927 /* CCFG */ if ((tx3927_ccfgptr->ccfg & TX3927_CCFG_TLBOFF) == 0) puts("Warning: TX3927 TLB off\n"); #endif - prom_argc = argc; - prom_argv = argv; - prom_envp = envp; + prom_argc = fw_arg0; + prom_argv = (char **) fw_arg1; + prom_envp = (char **) fw_arg2; mips_machgroup = MACH_GROUP_TOSHIBA; @@ -76,5 +74,4 @@ int __init prom_init(int argc, char **ar prom_init_cmdline(); add_memory_region(0, JMR3927_SDRAM_SIZE, BOOT_MEM_RAM); - return 0; } --- diff/arch/mips/jmr3927/rbhma3100/irq.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/jmr3927/rbhma3100/irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -63,10 +63,7 @@ struct tb_irq_space* tb_irq_spaces; -unsigned int local_bh_count[NR_CPUS]; -unsigned int local_irq_count[NR_CPUS]; - -static int jmr3927_irq_base=-1; +static int jmr3927_irq_base = -1; #ifdef CONFIG_PCI static int jmr3927_gen_iack(void) @@ -84,6 +81,7 @@ extern asmlinkage void jmr3927_IRQ(void) #define irc_dlevel 0 #define irc_elevel 1 + static unsigned char irc_level[TX3927_NUM_IR] = { 5, 5, 5, 5, 5, 5, /* INT[5:0] */ 7, 7, /* SIO */ @@ -122,9 +120,12 @@ static inline void unmask_irq(unsigned i static void jmr3927_irq_disable(unsigned int irq_nr); static void jmr3927_irq_enable(unsigned int irq_nr); +static spinlock_t jmr3927_irq_lock = SPIN_LOCK_UNLOCKED; + static unsigned int jmr3927_irq_startup(unsigned int irq) { jmr3927_irq_enable(irq); + return 0; } @@ -132,10 +133,6 @@ static unsigned int jmr3927_irq_startup( static void jmr3927_irq_ack(unsigned int irq) { - db_assert(jmr3927_irq_base != -1); - db_assert(irq >= jmr3927_irq_base); - db_assert(irq < jmr3927_irq_base + JMR3927_NR_IRQ_IRC + JMR3927_NR_IRQ_IOC); - if (irq == JMR3927_IRQ_IRC_TMR0) { jmr3927_tmrptr->tisr = 0; /* ack interrupt */ } @@ -145,10 +142,6 @@ static void jmr3927_irq_ack(unsigned int static void jmr3927_irq_end(unsigned int irq) { - db_assert(jmr3927_irq_base != -1); - db_assert(irq >= jmr3927_irq_base); - db_assert(irq < jmr3927_irq_base + JMR3927_NR_IRQ_IRC + JMR3927_NR_IRQ_IOC); - jmr3927_irq_enable(irq); } @@ -156,26 +149,18 @@ static void jmr3927_irq_disable(unsigned { unsigned long flags; - db_assert(jmr3927_irq_base != -1); - db_assert(irq >= jmr3927_irq_base); - db_assert(irq < jmr3927_irq_base + JMR3927_NR_IRQ_IRC + JMR3927_NR_IRQ_IOC); - - local_irq_save(flags); + spinlock_irqsave(&jmr3927_irq_lock, flags); mask_irq(irq_nr); - local_irq_restore(flags); + spinlock_irqrestore(&jmr3927_irq_lock, flags); } static void jmr3927_irq_enable(unsigned int irq_nr) { unsigned long flags; - db_assert(jmr3927_irq_base != -1); - db_assert(irq >= jmr3927_irq_base); - db_assert(irq < jmr3927_irq_base + JMR3927_NR_IRQ_IRC + JMR3927_NR_IRQ_IOC); - - local_irq_save(flags); + spinlock_irqsave(&jmr3927_irq_lock, flags); unmask_irq(irq_nr); - local_irq_restore(flags); + spinlock_irqrestore(&jmr3927_irq_lock, flags); } /* @@ -195,8 +180,7 @@ static void mask_irq_isac(int irq_nr, in static void unmask_irq_isac(int irq_nr, int space_id) { /* 0: mask */ - unsigned char imask = - jmr3927_isac_reg_in(JMR3927_ISAC_INTM_ADDR); + unsigned char imask = jmr3927_isac_reg_in(JMR3927_ISAC_INTM_ADDR); unsigned int bit = 1 << irq_nr; jmr3927_isac_reg_out(imask | bit, JMR3927_ISAC_INTM_ADDR); /* flush write buffer */ @@ -206,8 +190,7 @@ static void unmask_irq_isac(int irq_nr, static void mask_irq_ioc(int irq_nr, int space_id) { /* 0: mask */ - unsigned char imask = - jmr3927_ioc_reg_in(JMR3927_IOC_INTM_ADDR); + unsigned char imask = jmr3927_ioc_reg_in(JMR3927_IOC_INTM_ADDR); unsigned int bit = 1 << irq_nr; jmr3927_ioc_reg_out(imask & ~bit, JMR3927_IOC_INTM_ADDR); /* flush write buffer */ @@ -216,8 +199,7 @@ static void mask_irq_ioc(int irq_nr, int static void unmask_irq_ioc(int irq_nr, int space_id) { /* 0: mask */ - unsigned char imask = - jmr3927_ioc_reg_in(JMR3927_IOC_INTM_ADDR); + unsigned char imask = jmr3927_ioc_reg_in(JMR3927_IOC_INTM_ADDR); unsigned int bit = 1 << irq_nr; jmr3927_ioc_reg_out(imask | bit, JMR3927_IOC_INTM_ADDR); /* flush write buffer */ @@ -440,6 +422,7 @@ void jmr3927_irq_setup(void) } void (*irq_setup)(void); + void __init init_IRQ(void) { @@ -456,7 +439,7 @@ void __init init_IRQ(void) irq_setup(); } -hw_irq_controller jmr3927_irq_controller = { +static hw_irq_controller jmr3927_irq_controller = { "jmr3927_irq", jmr3927_irq_startup, jmr3927_irq_shutdown, @@ -464,15 +447,13 @@ hw_irq_controller jmr3927_irq_controller jmr3927_irq_disable, jmr3927_irq_ack, jmr3927_irq_end, - NULL /* no affinity stuff for UP */ }; -void -jmr3927_irq_init(u32 irq_base) +void jmr3927_irq_init(u32 irq_base) { - extern irq_desc_t irq_desc[]; u32 i; + init_generic_irq(); for (i= irq_base; i< irq_base + JMR3927_NR_IRQ_IRC + JMR3927_NR_IRQ_IOC; i++) { irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = NULL; --- diff/arch/mips/jmr3927/rbhma3100/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/jmr3927/rbhma3100/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -199,7 +198,7 @@ extern void jmr3927_irq_setup(void); extern struct resource pci_io_resource; extern struct resource pci_mem_resource; -void __init jmr3927_setup(void) +static void __init jmr3927_setup(void) { extern int panic_timeout; char *argptr; @@ -282,6 +281,8 @@ void __init jmr3927_setup(void) #endif } +early_initcall(jmr3927_setup); + static void tx3927_setup(void); @@ -294,9 +295,6 @@ unsigned long mips_pci_mem_size; unsigned long mips_pci_io_pciaddr = 0; #endif -extern struct rtc_ops *rtc_ops; -extern struct rtc_ops jmr3927_rtc_ops; - static void __init jmr3927_board_init(void) { char *argptr; @@ -310,10 +308,6 @@ static void __init jmr3927_board_init(vo tx3927_setup(); -#ifdef CONFIG_VT - conswitchp = &dummy_con; -#endif - if (jmr3927_have_isac()) { #ifdef CONFIG_FB_E1355 @@ -328,11 +322,6 @@ static void __init jmr3927_board_init(vo /* overrides PCI-IDE */ #endif } -#ifdef USE_RTC_DS1742 - if (jmr3927_have_nvram()) { - rtc_ops = &jmr3927_rtc_ops; - } -#endif /* SIO0 DTR on */ jmr3927_ioc_reg_out(0, JMR3927_IOC_DTR_ADDR); --- diff/arch/mips/kernel/Makefile 2003-08-26 10:00:52.000000000 +0100 +++ source/arch/mips/kernel/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -24,6 +24,7 @@ obj-$(CONFIG_CPU_R4X00) += r4k_fpu.o r4 obj-$(CONFIG_CPU_R5000) += r4k_fpu.o r4k_switch.o obj-$(CONFIG_CPU_R5432) += r4k_fpu.o r4k_switch.o obj-$(CONFIG_CPU_RM7000) += r4k_fpu.o r4k_switch.o +obj-$(CONFIG_CPU_RM9000) += r4k_fpu.o r4k_switch.o obj-$(CONFIG_CPU_NEVADA) += r4k_fpu.o r4k_switch.o obj-$(CONFIG_CPU_R10000) += r4k_fpu.o r4k_switch.o obj-$(CONFIG_CPU_SB1) += r4k_fpu.o r4k_switch.o @@ -35,6 +36,7 @@ obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_I8259) += i8259.o obj-$(CONFIG_IRQ_CPU) += irq_cpu.o +obj-$(CONFIG_IRQ_CPU_RM7K) += irq-rm7000.o obj-$(CONFIG_MIPS32) += scall32-o32.o obj-$(CONFIG_MIPS64) += scall64-64.o @@ -47,12 +49,10 @@ obj-$(CONFIG_MIPS32_O32) += binfmt_elfo3 obj-$(CONFIG_KGDB) += gdb-low.o gdb-stub.o obj-$(CONFIG_PROC_FS) += proc.o -ifndef CONFIG_MAPPED_DMA_IO -obj-y += pci-dma.o -endif - obj-$(CONFIG_MIPS64) += cpu-bugs64.o +obj-$(CONFIG_GEN_RTC) += genrtc.o + CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) EXTRA_AFLAGS := $(CFLAGS) --- diff/arch/mips/kernel/binfmt_elfn32.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/kernel/binfmt_elfn32.c 2004-02-23 13:56:38.000000000 +0000 @@ -95,6 +95,19 @@ struct elf_prpsinfo32 #define elf_caddr_t u32 #define init_elf_binfmt init_elfn32_binfmt +#define jiffies_to_timeval jiffies_to_compat_timeval +static __inline__ void +jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value) +{ + /* + * Convert jiffies to nanoseconds and seperate with + * one divide. + */ + u64 nsec = (u64)jiffies * TICK_NSEC; + value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_usec); + value->tv_usec /= NSEC_PER_USEC; +} + #define ELF_CORE_EFLAGS EF_MIPS_ABI2 #undef CONFIG_BINFMT_ELF --- diff/arch/mips/kernel/binfmt_elfo32.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/kernel/binfmt_elfo32.c 2004-02-23 13:56:38.000000000 +0000 @@ -97,6 +97,18 @@ struct elf_prpsinfo32 #define elf_caddr_t u32 #define init_elf_binfmt init_elf32_binfmt +#define jiffies_to_timeval jiffies_to_compat_timeval +static __inline__ void +jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value) +{ + /* + * Convert jiffies to nanoseconds and seperate with + * one divide. + */ + u64 nsec = (u64)jiffies * TICK_NSEC; + value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_usec); + value->tv_usec /= NSEC_PER_USEC; +} #undef ELF_CORE_COPY_REGS #define ELF_CORE_COPY_REGS(_dest,_regs) elf32_core_copy_regs(_dest,_regs); --- diff/arch/mips/kernel/branch.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/branch.c 2004-02-23 13:56:38.000000000 +0000 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include --- diff/arch/mips/kernel/cpu-bugs64.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/kernel/cpu-bugs64.c 2004-02-23 13:56:38.000000000 +0000 @@ -6,6 +6,7 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ +#include #include #include #include @@ -17,18 +18,40 @@ #include #include -static inline void check_mult_sh(void) +static inline void align_mod(const int align, const int mod) +{ + asm volatile( + ".set push\n\t" + ".set noreorder\n\t" + ".balign %0\n\t" + ".rept %1\n\t" + "nop\n\t" + ".endr\n\t" + ".set pop" + : + : "n" (align), "n" (mod)); +} + +static inline void mult_sh_align_mod(long *v1, long *v2, long *w, + const int align, const int mod) { unsigned long flags; int m1, m2; - long p, s, v; + long p, s, lv1, lv2, lw; - printk("Checking for the multiply/shift bug... "); + /* + * We want the multiply and the shift to be isolated from the + * rest of the code to disable gcc optimizations. Hence the + * asm statements that execute nothing, but make gcc not know + * what the values of m1, m2 and s are and what lv2 and p are + * used for. + */ local_irq_save(flags); /* - * The following code leads to a wrong result of dsll32 when - * executed on R4000 rev. 2.2 or 3.0. + * The following code leads to a wrong result of the first + * dsll32 when executed on R4000 rev. 2.2 or 3.0 (PRId + * 00000422 or 00000430, respectively). * * See "MIPS R4000PC/SC Errata, Processor Revision 2.2 and * 3.0" by MIPS Technologies, Inc., errata #16 and #28 for @@ -36,52 +59,97 @@ static inline void check_mult_sh(void) * sigh... --macro */ asm volatile( + "" + : "=r" (m1), "=r" (m2), "=r" (s) + : "0" (5), "1" (8), "2" (5)); + align_mod(align, mod); + /* + * The trailing nop is needed to fullfill the two-instruction + * requirement between reading hi/lo and staring a mult/div. + * Leaving it out may cause gas insert a nop itself breaking + * the desired alignment of the next chunk. + */ + asm volatile( ".set push\n\t" ".set noat\n\t" ".set noreorder\n\t" ".set nomacro\n\t" - "mult %1, %2\n\t" - "dsll32 %0, %3, %4\n\t" + "mult %2, %3\n\t" + "dsll32 %0, %4, %5\n\t" "mflo $0\n\t" + "dsll32 %1, %4, %5\n\t" + "nop\n\t" ".set pop" - : "=r" (v) - : "r" (5), "r" (8), "r" (5), "I" (0) + : "=&r" (lv1), "=r" (lw) + : "r" (m1), "r" (m2), "r" (s), "I" (0) : "hi", "lo", "accum"); - local_irq_restore(flags); - - if (v == 5L << 32) { - printk("no.\n"); - return; - } - - printk("yes, workaround... "); - local_irq_save(flags); - /* - * We want the multiply and the shift to be isolated from the - * rest of the code to disable gcc optimizations. Hence the - * asm statements that execute nothing, but make gcc not know - * what the values of m1, m2 and s are and what v and p are - * used for. - * - * We have to use single integers for m1 and m2 and a double + /* We have to use single integers for m1 and m2 and a double * one for p to be sure the mulsidi3 gcc's RTL multiplication * instruction has the workaround applied. Older versions of - * gcc have correct mulsi3, but other multiplication variants - * lack the workaround. + * gcc have correct umulsi3 and mulsi3, but other + * multiplication variants lack the workaround. */ asm volatile( "" : "=r" (m1), "=r" (m2), "=r" (s) - : "0" (5), "1" (8), "2" (5)); + : "0" (m1), "1" (m2), "2" (s)); + align_mod(align, mod); p = m1 * m2; - v = s << 32; + lv2 = s << 32; asm volatile( "" - : "=r" (v) - : "0" (v), "r" (p)); + : "=r" (lv2) + : "0" (lv2), "r" (p)); local_irq_restore(flags); - if (v == 5L << 32) { + *v1 = lv1; + *v2 = lv2; + *w = lw; +} + +static inline void check_mult_sh(void) +{ + long v1[8], v2[8], w[8]; + int bug, fix, i; + + printk("Checking for the multiply/shift bug... "); + + /* + * Testing discovered false negatives for certain code offsets + * into cache lines. Hence we test all possible offsets for + * the worst assumption of an R4000 I-cache line width of 32 + * bytes. + * + * We can't use a loop as alignment directives need to be + * immediates. + */ + mult_sh_align_mod(&v1[0], &v2[0], &w[0], 32, 0); + mult_sh_align_mod(&v1[1], &v2[1], &w[1], 32, 1); + mult_sh_align_mod(&v1[2], &v2[2], &w[2], 32, 2); + mult_sh_align_mod(&v1[3], &v2[3], &w[3], 32, 3); + mult_sh_align_mod(&v1[4], &v2[4], &w[4], 32, 4); + mult_sh_align_mod(&v1[5], &v2[5], &w[5], 32, 5); + mult_sh_align_mod(&v1[6], &v2[6], &w[6], 32, 6); + mult_sh_align_mod(&v1[7], &v2[7], &w[7], 32, 7); + + bug = 0; + for (i = 0; i < 8; i++) + if (v1[i] != w[i]) + bug = 1; + + if (bug == 0) { + printk("no.\n"); + return; + } + + printk("yes, workaround... "); + + fix = 1; + for (i = 0; i < 8; i++) + if (v2[i] != w[i]) + fix = 0; + + if (fix == 1) { printk("yes.\n"); return; } @@ -117,7 +185,8 @@ static inline void check_daddi(void) handler = set_except_vector(12, handle_daddi_ov); /* * The following code fails to trigger an overflow exception - * when executed on R4000 rev. 2.2 or 3.0. + * when executed on R4000 rev. 2.2 or 3.0 (PRId 00000422 or + * 00000430, respectively). * * See "MIPS R4000PC/SC Errata, Processor Revision 2.2 and * 3.0" by MIPS Technologies, Inc., erratum #23 for details. @@ -177,15 +246,16 @@ static inline void check_daddiu(void) /* * The following code leads to a wrong result of daddiu when - * executed on R4400 rev. 1.0. + * executed on R4400 rev. 1.0 (PRId 00000440). * * See "MIPS R4400PC/SC Errata, Processor Revision 1.0" by * MIPS Technologies, Inc., erratum #7 for details. * * According to "MIPS R4000PC/SC Errata, Processor Revision * 2.2 and 3.0" by MIPS Technologies, Inc., erratum #41 this - * problem affects R4000 rev. 2.2 and 3.0, too. Testing - * failed to trigger it so far. + * problem affects R4000 rev. 2.2 and 3.0 (PRId 00000422 and + * 00000430, respectively), too. Testing failed to trigger it + * so far. * * I got no permission to duplicate the errata here, sigh... * --macro --- diff/arch/mips/kernel/cpu-probe.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/cpu-probe.c 2004-02-23 13:56:38.000000000 +0000 @@ -9,6 +9,7 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ +#include #include #include #include @@ -89,12 +90,15 @@ static inline void check_wait(void) case CPU_R5000: case CPU_NEVADA: case CPU_RM7000: +/* case CPU_RM9000: */ case CPU_TX49XX: case CPU_4KC: case CPU_4KEC: case CPU_4KSC: case CPU_5KC: /* case CPU_20KC:*/ + case CPU_24K: + case CPU_25KF: cpu_wait = r4k_wait; printk(" available.\n"); break; @@ -160,350 +164,420 @@ static inline int __cpu_has_fpu(void) } #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4KTLB \ - | MIPS_CPU_COUNTER | MIPS_CPU_CACHE_CDEX) + | MIPS_CPU_COUNTER) -__init void cpu_probe(void) +static inline void cpu_probe_legacy(struct cpuinfo_mips *c) { - struct cpuinfo_mips *c = ¤t_cpu_data; - unsigned long config0 = read_c0_config(); - unsigned long config1; - - c->processor_id = PRID_IMP_UNKNOWN; - c->fpu_id = FPIR_IMP_NONE; - c->cputype = CPU_UNKNOWN; - - if (config0 & (1 << 31)) { - /* MIPS32 or MIPS64 compliant CPU. Read Config 1 register. */ - c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | - MIPS_CPU_4KTLB | MIPS_CPU_COUNTER | MIPS_CPU_DIVEC | - MIPS_CPU_LLSC; - config1 = read_c0_config1(); - if (config1 & (1 << 3)) - c->options |= MIPS_CPU_WATCH; - if (config1 & (1 << 2)) - c->options |= MIPS_CPU_MIPS16; - if (config1 & (1 << 1)) - c->options |= MIPS_CPU_EJTAG; - if (config1 & 1) { + switch (c->processor_id & 0xff00) { + case PRID_IMP_R2000: + c->cputype = CPU_R2000; + c->isa_level = MIPS_CPU_ISA_I; + c->options = MIPS_CPU_TLB | MIPS_CPU_NOFPUEX | + MIPS_CPU_LLSC; + if (__cpu_has_fpu()) c->options |= MIPS_CPU_FPU; - c->options |= MIPS_CPU_32FPR; - } - c->scache.flags = MIPS_CACHE_NOT_PRESENT; - - c->tlbsize = ((config1 >> 25) & 0x3f) + 1; - } - - c->processor_id = read_c0_prid(); - switch (c->processor_id & 0xff0000) { - case PRID_COMP_LEGACY: - switch (c->processor_id & 0xff00) { - case PRID_IMP_R2000: - c->cputype = CPU_R2000; - c->isa_level = MIPS_CPU_ISA_I; - c->options = MIPS_CPU_TLB | MIPS_CPU_NOFPUEX | - MIPS_CPU_LLSC; - if (__cpu_has_fpu()) - c->options |= MIPS_CPU_FPU; - c->tlbsize = 64; - break; - case PRID_IMP_R3000: - if ((c->processor_id & 0xff) == PRID_REV_R3000A) - if (cpu_has_confreg()) - c->cputype = CPU_R3081E; - else - c->cputype = CPU_R3000A; + c->tlbsize = 64; + break; + case PRID_IMP_R3000: + if ((c->processor_id & 0xff) == PRID_REV_R3000A) + if (cpu_has_confreg()) + c->cputype = CPU_R3081E; else - c->cputype = CPU_R3000; - c->isa_level = MIPS_CPU_ISA_I; - c->options = MIPS_CPU_TLB | MIPS_CPU_NOFPUEX | - MIPS_CPU_LLSC; - if (__cpu_has_fpu()) - c->options |= MIPS_CPU_FPU; - c->tlbsize = 64; - break; - case PRID_IMP_R4000: + c->cputype = CPU_R3000A; + else + c->cputype = CPU_R3000; + c->isa_level = MIPS_CPU_ISA_I; + c->options = MIPS_CPU_TLB | MIPS_CPU_NOFPUEX | + MIPS_CPU_LLSC; + if (__cpu_has_fpu()) + c->options |= MIPS_CPU_FPU; + c->tlbsize = 64; + break; + case PRID_IMP_R4000: + if (read_c0_config() & CONF_SC) { + if ((c->processor_id & 0xff) >= PRID_REV_R4400) + c->cputype = CPU_R4400PC; + else + c->cputype = CPU_R4000PC; + } else { if ((c->processor_id & 0xff) >= PRID_REV_R4400) c->cputype = CPU_R4400SC; else c->cputype = CPU_R4000SC; - c->isa_level = MIPS_CPU_ISA_III; - c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | - MIPS_CPU_WATCH | MIPS_CPU_VCE | - MIPS_CPU_LLSC; - c->tlbsize = 48; - break; - case PRID_IMP_VR41XX: - switch (c->processor_id & 0xf0) { -#ifndef CONFIG_VR4181 - case PRID_REV_VR4111: - c->cputype = CPU_VR4111; - break; -#else - case PRID_REV_VR4181: - c->cputype = CPU_VR4181; - break; -#endif - case PRID_REV_VR4121: - c->cputype = CPU_VR4121; - break; - case PRID_REV_VR4122: - if ((c->processor_id & 0xf) < 0x3) - c->cputype = CPU_VR4122; - else - c->cputype = CPU_VR4181A; - break; - case PRID_REV_VR4131: - c->cputype = CPU_VR4131; - break; - default: - printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n"); - c->cputype = CPU_VR41XX; - break; - } - c->isa_level = MIPS_CPU_ISA_III; - c->options = R4K_OPTS; - c->tlbsize = 32; - break; - case PRID_IMP_R4300: - c->cputype = CPU_R4300; - c->isa_level = MIPS_CPU_ISA_III; - c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | - MIPS_CPU_LLSC; - c->tlbsize = 32; - break; - case PRID_IMP_R4600: - c->cputype = CPU_R4600; - c->isa_level = MIPS_CPU_ISA_III; - c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC; - c->tlbsize = 48; - break; - #if 0 - case PRID_IMP_R4650: - /* - * This processor doesn't have an MMU, so it's not - * "real easy" to run Linux on it. It is left purely - * for documentation. Commented out because it shares - * it's c0_prid id number with the TX3900. - */ - c->cputype = CPU_R4650; - c->isa_level = MIPS_CPU_ISA_III; - c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC; - c->tlbsize = 48; - break; - #endif - case PRID_IMP_TX39: - c->isa_level = MIPS_CPU_ISA_I; - c->options = MIPS_CPU_TLB; - - if ((c->processor_id & 0xf0) == - (PRID_REV_TX3927 & 0xf0)) { - c->cputype = CPU_TX3927; - c->tlbsize = 64; - } else { - switch (c->processor_id & 0xff) { - case PRID_REV_TX3912: - c->cputype = CPU_TX3912; - c->tlbsize = 32; - break; - case PRID_REV_TX3922: - c->cputype = CPU_TX3922; - c->tlbsize = 64; - break; - default: - c->cputype = CPU_UNKNOWN; - break; - } - } - break; - case PRID_IMP_R4700: - c->cputype = CPU_R4700; - c->isa_level = MIPS_CPU_ISA_III; - c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | - MIPS_CPU_LLSC; - c->tlbsize = 48; - break; - case PRID_IMP_TX49: - c->cputype = CPU_TX49XX; - c->isa_level = MIPS_CPU_ISA_III; - c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | - MIPS_CPU_LLSC; - c->tlbsize = 48; - break; - case PRID_IMP_R5000: - c->cputype = CPU_R5000; - c->isa_level = MIPS_CPU_ISA_IV; - c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | - MIPS_CPU_LLSC; - c->tlbsize = 48; - break; - case PRID_IMP_R5432: - c->cputype = CPU_R5432; - c->isa_level = MIPS_CPU_ISA_IV; - c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | - MIPS_CPU_WATCH | MIPS_CPU_LLSC; - c->tlbsize = 48; - break; - case PRID_IMP_R5500: - c->cputype = CPU_R5500; - c->isa_level = MIPS_CPU_ISA_IV; - c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | - MIPS_CPU_WATCH | MIPS_CPU_LLSC; - c->tlbsize = 48; - break; - case PRID_IMP_NEVADA: - c->cputype = CPU_NEVADA; - c->isa_level = MIPS_CPU_ISA_IV; - c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | - MIPS_CPU_DIVEC | MIPS_CPU_LLSC; - c->tlbsize = 48; - break; - case PRID_IMP_R6000: - c->cputype = CPU_R6000; - c->isa_level = MIPS_CPU_ISA_II; - c->options = MIPS_CPU_TLB | MIPS_CPU_FPU | - MIPS_CPU_LLSC; - c->tlbsize = 32; - break; - case PRID_IMP_R6000A: - c->cputype = CPU_R6000A; - c->isa_level = MIPS_CPU_ISA_II; - c->options = MIPS_CPU_TLB | MIPS_CPU_FPU | - MIPS_CPU_LLSC; - c->tlbsize = 32; - break; - case PRID_IMP_RM7000: - c->cputype = CPU_RM7000; - c->isa_level = MIPS_CPU_ISA_IV; - c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | - MIPS_CPU_LLSC; - /* - * Undocumented RM7000: Bit 29 in the info register of - * the RM7000 v2.0 indicates if the TLB has 48 or 64 - * entries. - * - * 29 1 => 64 entry JTLB - * 0 => 48 entry JTLB - */ - c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48; - break; - case PRID_IMP_R8000: - c->cputype = CPU_R8000; - c->isa_level = MIPS_CPU_ISA_IV; - c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | - MIPS_CPU_FPU | MIPS_CPU_32FPR | - MIPS_CPU_LLSC; - c->tlbsize = 384; /* has weird TLB: 3-way x 128 */ - break; - case PRID_IMP_R10000: - c->cputype = CPU_R10000; - c->isa_level = MIPS_CPU_ISA_IV; - c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | - MIPS_CPU_FPU | MIPS_CPU_32FPR | - MIPS_CPU_COUNTER | MIPS_CPU_WATCH | - MIPS_CPU_LLSC; - c->tlbsize = 64; - break; - case PRID_IMP_R12000: - c->cputype = CPU_R12000; - c->isa_level = MIPS_CPU_ISA_IV; - c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | - MIPS_CPU_FPU | MIPS_CPU_32FPR | - MIPS_CPU_COUNTER | MIPS_CPU_WATCH | - MIPS_CPU_LLSC; - c->tlbsize = 64; - break; - default: - c->cputype = CPU_UNKNOWN; - break; } + + c->isa_level = MIPS_CPU_ISA_III; + c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | + MIPS_CPU_WATCH | MIPS_CPU_VCE | + MIPS_CPU_LLSC; + c->tlbsize = 48; break; - case PRID_COMP_MIPS: - switch (c->processor_id & 0xff00) { - case PRID_IMP_4KC: - c->cputype = CPU_4KC; - c->isa_level = MIPS_CPU_ISA_M32; + case PRID_IMP_VR41XX: + switch (c->processor_id & 0xf0) { +#ifndef CONFIG_VR4181 + case PRID_REV_VR4111: + c->cputype = CPU_VR4111; break; - case PRID_IMP_4KEC: - c->cputype = CPU_4KEC; - c->isa_level = MIPS_CPU_ISA_M32; +#else + case PRID_REV_VR4181: + c->cputype = CPU_VR4181; break; - case PRID_IMP_4KSC: - c->cputype = CPU_4KSC; - c->isa_level = MIPS_CPU_ISA_M32; +#endif + case PRID_REV_VR4121: + c->cputype = CPU_VR4121; break; - case PRID_IMP_5KC: - c->cputype = CPU_5KC; - c->isa_level = MIPS_CPU_ISA_M64; + case PRID_REV_VR4122: + if ((c->processor_id & 0xf) < 0x3) + c->cputype = CPU_VR4122; + else + c->cputype = CPU_VR4181A; break; - case PRID_IMP_20KC: - c->cputype = CPU_20KC; - c->isa_level = MIPS_CPU_ISA_M64; + case PRID_REV_VR4130: + if ((c->processor_id & 0xf) < 0x4) + c->cputype = CPU_VR4131; + else + c->cputype = CPU_VR4133; break; default: - c->cputype = CPU_UNKNOWN; - break; + printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n"); + c->cputype = CPU_VR41XX; + break; } + c->isa_level = MIPS_CPU_ISA_III; + c->options = R4K_OPTS; + c->tlbsize = 32; break; - case PRID_COMP_ALCHEMY: - switch (c->processor_id & 0xff00) { - case PRID_IMP_AU1_REV1: - case PRID_IMP_AU1_REV2: - switch ((c->processor_id >> 24) & 0xff) { - case 0: - c->cputype = CPU_AU1000; - break; - case 1: - c->cputype = CPU_AU1500; + case PRID_IMP_R4300: + c->cputype = CPU_R4300; + c->isa_level = MIPS_CPU_ISA_III; + c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | + MIPS_CPU_LLSC; + c->tlbsize = 32; + break; + case PRID_IMP_R4600: + c->cputype = CPU_R4600; + c->isa_level = MIPS_CPU_ISA_III; + c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC; + c->tlbsize = 48; + break; + #if 0 + case PRID_IMP_R4650: + /* + * This processor doesn't have an MMU, so it's not + * "real easy" to run Linux on it. It is left purely + * for documentation. Commented out because it shares + * it's c0_prid id number with the TX3900. + */ + c->cputype = CPU_R4650; + c->isa_level = MIPS_CPU_ISA_III; + c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC; + c->tlbsize = 48; + break; + #endif + case PRID_IMP_TX39: + c->isa_level = MIPS_CPU_ISA_I; + c->options = MIPS_CPU_TLB; + + if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) { + c->cputype = CPU_TX3927; + c->tlbsize = 64; + } else { + switch (c->processor_id & 0xff) { + case PRID_REV_TX3912: + c->cputype = CPU_TX3912; + c->tlbsize = 32; break; - case 2: - c->cputype = CPU_AU1100; + case PRID_REV_TX3922: + c->cputype = CPU_TX3922; + c->tlbsize = 64; break; default: - panic("Unknown Au Core!"); + c->cputype = CPU_UNKNOWN; break; } - c->isa_level = MIPS_CPU_ISA_M32; - break; - default: - c->cputype = CPU_UNKNOWN; - break; } break; - case PRID_COMP_SIBYTE: - switch (c->processor_id & 0xff00) { - case PRID_IMP_SB1: - c->cputype = CPU_SB1; - c->isa_level = MIPS_CPU_ISA_M64; - c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | - MIPS_CPU_COUNTER | MIPS_CPU_DIVEC | - MIPS_CPU_MCHECK | MIPS_CPU_EJTAG | - MIPS_CPU_WATCH | MIPS_CPU_LLSC; -#ifndef CONFIG_SB1_PASS_1_WORKAROUNDS - /* FPU in pass1 is known to have issues. */ + case PRID_IMP_R4700: + c->cputype = CPU_R4700; + c->isa_level = MIPS_CPU_ISA_III; + c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | + MIPS_CPU_LLSC; + c->tlbsize = 48; + break; + case PRID_IMP_TX49: + c->cputype = CPU_TX49XX; + c->isa_level = MIPS_CPU_ISA_III; + c->options = R4K_OPTS | MIPS_CPU_LLSC; + if (!(c->processor_id & 0x08)) c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR; -#endif + c->tlbsize = 48; + break; + case PRID_IMP_R5000: + c->cputype = CPU_R5000; + c->isa_level = MIPS_CPU_ISA_IV; + c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | + MIPS_CPU_LLSC; + c->tlbsize = 48; + break; + case PRID_IMP_R5432: + c->cputype = CPU_R5432; + c->isa_level = MIPS_CPU_ISA_IV; + c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | + MIPS_CPU_WATCH | MIPS_CPU_LLSC; + c->tlbsize = 48; + break; + case PRID_IMP_R5500: + c->cputype = CPU_R5500; + c->isa_level = MIPS_CPU_ISA_IV; + c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | + MIPS_CPU_WATCH | MIPS_CPU_LLSC; + c->tlbsize = 48; + break; + case PRID_IMP_NEVADA: + c->cputype = CPU_NEVADA; + c->isa_level = MIPS_CPU_ISA_IV; + c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | + MIPS_CPU_DIVEC | MIPS_CPU_LLSC; + c->tlbsize = 48; + break; + case PRID_IMP_R6000: + c->cputype = CPU_R6000; + c->isa_level = MIPS_CPU_ISA_II; + c->options = MIPS_CPU_TLB | MIPS_CPU_FPU | + MIPS_CPU_LLSC; + c->tlbsize = 32; + break; + case PRID_IMP_R6000A: + c->cputype = CPU_R6000A; + c->isa_level = MIPS_CPU_ISA_II; + c->options = MIPS_CPU_TLB | MIPS_CPU_FPU | + MIPS_CPU_LLSC; + c->tlbsize = 32; + break; + case PRID_IMP_RM7000: + c->cputype = CPU_RM7000; + c->isa_level = MIPS_CPU_ISA_IV; + c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | + MIPS_CPU_LLSC; + /* + * Undocumented RM7000: Bit 29 in the info register of + * the RM7000 v2.0 indicates if the TLB has 48 or 64 + * entries. + * + * 29 1 => 64 entry JTLB + * 0 => 48 entry JTLB + */ + c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48; + break; + case PRID_IMP_RM9000: + c->cputype = CPU_RM9000; + c->isa_level = MIPS_CPU_ISA_IV; + c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | + MIPS_CPU_LLSC; + /* + * Bit 29 in the info register of the RM9000 + * indicates if the TLB has 48 or 64 entries. + * + * 29 1 => 64 entry JTLB + * 0 => 48 entry JTLB + */ + c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48; + break; + case PRID_IMP_R8000: + c->cputype = CPU_R8000; + c->isa_level = MIPS_CPU_ISA_IV; + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | + MIPS_CPU_FPU | MIPS_CPU_32FPR | + MIPS_CPU_LLSC; + c->tlbsize = 384; /* has weird TLB: 3-way x 128 */ + break; + case PRID_IMP_R10000: + c->cputype = CPU_R10000; + c->isa_level = MIPS_CPU_ISA_IV; + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | + MIPS_CPU_FPU | MIPS_CPU_32FPR | + MIPS_CPU_COUNTER | MIPS_CPU_WATCH | + MIPS_CPU_LLSC; + c->tlbsize = 64; + break; + case PRID_IMP_R12000: + c->cputype = CPU_R12000; + c->isa_level = MIPS_CPU_ISA_IV; + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | + MIPS_CPU_FPU | MIPS_CPU_32FPR | + MIPS_CPU_COUNTER | MIPS_CPU_WATCH | + MIPS_CPU_LLSC; + c->tlbsize = 64; + break; + default: + c->cputype = CPU_UNKNOWN; + break; + } +} + +static inline void decode_config1(struct cpuinfo_mips *c) +{ + unsigned long config0 = read_c0_config(); + unsigned long config1; + + if ((config0 & (1 << 31)) == 0) + return; /* actually wort a panic() */ + + /* MIPS32 or MIPS64 compliant CPU. Read Config 1 register. */ + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | + MIPS_CPU_4KTLB | MIPS_CPU_COUNTER | MIPS_CPU_DIVEC | + MIPS_CPU_LLSC | MIPS_CPU_MCHECK; + config1 = read_c0_config1(); + if (config1 & (1 << 3)) + c->options |= MIPS_CPU_WATCH; + if (config1 & (1 << 2)) + c->options |= MIPS_CPU_MIPS16; + if (config1 & (1 << 1)) + c->options |= MIPS_CPU_EJTAG; + if (config1 & 1) { + c->options |= MIPS_CPU_FPU; + c->options |= MIPS_CPU_32FPR; + } + c->scache.flags = MIPS_CACHE_NOT_PRESENT; + + c->tlbsize = ((config1 >> 25) & 0x3f) + 1; +} + +static inline void cpu_probe_mips(struct cpuinfo_mips *c) +{ + decode_config1(c); + switch (c->processor_id & 0xff00) { + case PRID_IMP_4KC: + c->cputype = CPU_4KC; + c->isa_level = MIPS_CPU_ISA_M32; + break; + case PRID_IMP_4KEC: + c->cputype = CPU_4KEC; + c->isa_level = MIPS_CPU_ISA_M32; + break; + case PRID_IMP_4KSC: + c->cputype = CPU_4KSC; + c->isa_level = MIPS_CPU_ISA_M32; + break; + case PRID_IMP_5KC: + c->cputype = CPU_5KC; + c->isa_level = MIPS_CPU_ISA_M64; + break; + case PRID_IMP_20KC: + c->cputype = CPU_20KC; + c->isa_level = MIPS_CPU_ISA_M64; + break; + case PRID_IMP_24K: + c->cputype = CPU_24K; + c->isa_level = MIPS_CPU_ISA_M32; + break; + case PRID_IMP_25KF: + c->cputype = CPU_25KF; + c->isa_level = MIPS_CPU_ISA_M64; + /* Probe for L2 cache */ + c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT; + break; + default: + c->cputype = CPU_UNKNOWN; + break; + } +} + +static inline void cpu_probe_alchemy(struct cpuinfo_mips *c) +{ + decode_config1(c); + switch (c->processor_id & 0xff00) { + case PRID_IMP_AU1_REV1: + case PRID_IMP_AU1_REV2: + switch ((c->processor_id >> 24) & 0xff) { + case 0: + c->cputype = CPU_AU1000; + break; + case 1: + c->cputype = CPU_AU1500; + break; + case 2: + c->cputype = CPU_AU1100; break; default: - c->cputype = CPU_UNKNOWN; + panic("Unknown Au Core!"); break; } + c->isa_level = MIPS_CPU_ISA_M32; + break; + default: + c->cputype = CPU_UNKNOWN; + break; + } +} + +static inline void cpu_probe_sibyte(struct cpuinfo_mips *c) +{ + decode_config1(c); + switch (c->processor_id & 0xff00) { + case PRID_IMP_SB1: + c->cputype = CPU_SB1; + c->isa_level = MIPS_CPU_ISA_M64; + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | + MIPS_CPU_COUNTER | MIPS_CPU_DIVEC | + MIPS_CPU_MCHECK | MIPS_CPU_EJTAG | + MIPS_CPU_WATCH | MIPS_CPU_LLSC; +#ifndef CONFIG_SB1_PASS_1_WORKAROUNDS + /* FPU in pass1 is known to have issues. */ + c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR; +#endif + break; + default: + c->cputype = CPU_UNKNOWN; + break; + } +} + +static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c) +{ + decode_config1(c); + switch (c->processor_id & 0xff00) { + case PRID_IMP_SR71000: + c->cputype = CPU_SR71000; + c->isa_level = MIPS_CPU_ISA_M64; + c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | + MIPS_CPU_4KTLB | MIPS_CPU_FPU | + MIPS_CPU_COUNTER | MIPS_CPU_MCHECK; + c->scache.ways = 8; + c->tlbsize = 64; + break; + default: + c->cputype = CPU_UNKNOWN; + break; + } +} + +__init void cpu_probe(void) +{ + struct cpuinfo_mips *c = ¤t_cpu_data; + + c->processor_id = PRID_IMP_UNKNOWN; + c->fpu_id = FPIR_IMP_NONE; + c->cputype = CPU_UNKNOWN; + + c->processor_id = read_c0_prid(); + switch (c->processor_id & 0xff0000) { + + case PRID_COMP_LEGACY: + cpu_probe_legacy(c); + break; + case PRID_COMP_MIPS: + cpu_probe_mips(c); + break; + case PRID_COMP_ALCHEMY: + cpu_probe_alchemy(c); + break; + case PRID_COMP_SIBYTE: + cpu_probe_sibyte(c); break; case PRID_COMP_SANDCRAFT: - switch (c->processor_id & 0xff00) { - case PRID_IMP_SR71000: - c->cputype = CPU_SR71000; - c->isa_level = MIPS_CPU_ISA_M64; - c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | - MIPS_CPU_4KTLB | MIPS_CPU_FPU | - MIPS_CPU_COUNTER | MIPS_CPU_MCHECK; - c->scache.ways = 8; - c->tlbsize = 64; - break; - default: - c->cputype = CPU_UNKNOWN; - break; - } + cpu_probe_sandcraft(c); break; default: c->cputype = CPU_UNKNOWN; --- diff/arch/mips/kernel/entry.S 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/entry.S 2004-02-23 13:56:38.000000000 +0000 @@ -52,9 +52,10 @@ ENTRY(resume_kernel) need_resched: LONG_L t0, TI_FLAGS($28) andi t1, t0, _TIF_NEED_RESCHED - beqz restore_all - if (in_exception_path) - goto restore_all; + beqz t1, restore_all + LONG_L t0, PT_STATUS(sp) # Interrupts off? + andi t0, 1 + beqz t0, restore_all li t0, PREEMPT_ACTIVE sw t0, TI_PRE_COUNT($28) local_irq_enable t0 @@ -64,7 +65,7 @@ need_resched: #endif FEXPORT(ret_from_fork) - jal schedule_tail + jal schedule_tail # a0 = task_t *prev FEXPORT(syscall_exit) local_irq_disable # make sure need_resched and @@ -75,14 +76,19 @@ FEXPORT(syscall_exit) and t0, a2, t0 bnez t0, syscall_exit_work -FEXPORT(restore_all) +FEXPORT(restore_all) # restore full frame .set noat - RESTORE_ALL_AND_RET + RESTORE_TEMP + RESTORE_AT + RESTORE_STATIC +FEXPORT(restore_partial) # restore partial frame + RESTORE_SOME + RESTORE_SP_AND_RET .set at FEXPORT(work_pending) andi t0, a2, _TIF_NEED_RESCHED - bnez t0, work_notifysig + beqz t0, work_notifysig work_resched: jal schedule @@ -103,11 +109,13 @@ work_notifysig: # deal with pending s jal do_notify_resume # a2 already loaded j restore_all +FEXPORT(syscall_exit_work_partial) + SAVE_STATIC FEXPORT(syscall_exit_work) LONG_L t0, TI_FLAGS($28) li t1, _TIF_SYSCALL_TRACE and t0, t1 - bnez t0, work_pending # trace bit is set + beqz t0, work_pending # trace bit is set local_irq_enable # could let do_syscall_trace() # call schedule() instead jal do_syscall_trace --- diff/arch/mips/kernel/gdb-low.S 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/gdb-low.S 2004-02-23 13:56:38.000000000 +0000 @@ -62,7 +62,7 @@ 1: move k0, sp subu sp, k1, GDB_FR_SIZE*2 # see comment above - LONG_S $26, GDB_FR_REG29(sp) + LONG_S k0, GDB_FR_REG29(sp) LONG_S $2, GDB_FR_REG2(sp) /* @@ -90,7 +90,7 @@ LONG_S $1, GDB_FR_REG1(sp) /* v0 already saved */ LONG_S $3, GDB_FR_REG3(sp) - LONG_S $3, GDB_FR_REG4(sp) + LONG_S $4, GDB_FR_REG4(sp) LONG_S $5, GDB_FR_REG5(sp) LONG_S $6, GDB_FR_REG6(sp) LONG_S $7, GDB_FR_REG7(sp) @@ -296,7 +296,7 @@ LONG_L v0, GDB_FR_HI(sp) LONG_L v1, GDB_FR_LO(sp) mthi v0 - mtlo v0 + mtlo v1 LONG_L $31, GDB_FR_REG31(sp) LONG_L $30, GDB_FR_REG30(sp) LONG_L $28, GDB_FR_REG28(sp) --- diff/arch/mips/kernel/gdb-stub.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/gdb-stub.c 2004-02-23 13:56:38.000000000 +0000 @@ -134,6 +134,7 @@ #include #include +#include #include #include #include @@ -233,7 +234,7 @@ static void getpacket(char *buffer) * now, read until a # or end of buffer is found */ while (count < BUFMAX) { - ch = getDebugChar() & 0x7f; + ch = getDebugChar(); if (ch == '#') break; checksum = checksum + ch; @@ -339,15 +340,22 @@ static unsigned char *mem2hex(char *mem, * may_fault is non-zero if we are reading from arbitrary memory, but is currently * not used. */ -static char *hex2mem(char *buf, char *mem, int count, int may_fault) +static char *hex2mem(char *buf, char *mem, int count, int binary, int may_fault) { int i; unsigned char ch; for (i=0; itt && ht->signo; ht++) set_except_vector(ht->tt, saved_vectors[ht->tt]); - restore_flags(flags); + local_irq_restore(flags); } /* @@ -669,6 +677,7 @@ void handle_exception (struct gdb_regs * char *ptr; unsigned long *stack; int i; + int bflag = 0; kgdb_started = 1; @@ -695,7 +704,7 @@ void handle_exception (struct gdb_regs * /* * acquire the CPU spinlocks */ - for (i=0; i< smp_num_cpus; i++) + for (i = num_online_cpus()-1; i >= 0; i--) if (spin_trylock(&kgdb_cpulock[i]) == 0) panic("kgdb: couldn't get cpulock %d\n", i); @@ -817,17 +826,17 @@ void handle_exception (struct gdb_regs * case 'G': { ptr = &input_buffer[1]; - hex2mem(ptr, (char *)®s->reg0, 32*sizeof(long), 0); + hex2mem(ptr, (char *)®s->reg0, 32*sizeof(long), 0, 0); ptr += 32*(2*sizeof(long)); - hex2mem(ptr, (char *)®s->cp0_status, 6*sizeof(long), 0); + hex2mem(ptr, (char *)®s->cp0_status, 6*sizeof(long), 0, 0); ptr += 6*(2*sizeof(long)); - hex2mem(ptr, (char *)®s->fpr0, 32*sizeof(long), 0); + hex2mem(ptr, (char *)®s->fpr0, 32*sizeof(long), 0, 0); ptr += 32*(2*sizeof(long)); - hex2mem(ptr, (char *)®s->cp1_fsr, 2*sizeof(long), 0); + hex2mem(ptr, (char *)®s->cp1_fsr, 2*sizeof(long), 0, 0); ptr += 2*(2*sizeof(long)); - hex2mem(ptr, (char *)®s->frame_ptr, 2*sizeof(long), 0); + hex2mem(ptr, (char *)®s->frame_ptr, 2*sizeof(long), 0, 0); ptr += 2*(2*sizeof(long)); - hex2mem(ptr, (char *)®s->cp0_index, 16*sizeof(long), 0); + hex2mem(ptr, (char *)®s->cp0_index, 16*sizeof(long), 0, 0); strcpy(output_buffer,"OK"); } break; @@ -849,6 +858,13 @@ void handle_exception (struct gdb_regs * break; /* + * XAA..AA,LLLL: Write LLLL escaped binary bytes at address AA.AA + */ + case 'X': + bflag = 1; + /* fall through */ + + /* * MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */ case 'M': @@ -858,7 +874,7 @@ void handle_exception (struct gdb_regs * && *ptr++ == ',' && hexToInt(&ptr, &length) && *ptr++ == ':') { - if (hex2mem(ptr, (char *)addr, length, 1)) + if (hex2mem(ptr, (char *)addr, length, bflag, 1)) strcpy(output_buffer, "OK"); else strcpy(output_buffer, "E03"); @@ -963,7 +979,7 @@ finish_kgdb: exit_kgdb_exception: /* release locks so other CPUs can go */ - for (i=0; i < smp_num_cpus; i++) + for (i = num_online_cpus()-1; i >= 0; i--) spin_unlock(&kgdb_cpulock[i]); spin_unlock(&kgdb_lock); @@ -985,7 +1001,7 @@ void breakpoint(void) __asm__ __volatile__( ".globl breakinst\n\t" ".set\tnoreorder\n\t" - "nop\n\t" + "nop\n" "breakinst:\tbreak\n\t" "nop\n\t" ".set\treorder" @@ -998,7 +1014,7 @@ void async_breakpoint(void) __asm__ __volatile__( ".globl async_breakinst\n\t" ".set\tnoreorder\n\t" - "nop\n\t" + "nop\n" "async_breakinst:\tbreak\n\t" "nop\n\t" ".set\treorder" @@ -1061,9 +1077,13 @@ static struct console gdb_console = { .index = -1 }; -__init void register_gdb_console(void) +static int __init register_gdb_console(void) { register_console(&gdb_console); + + return 0; } +console_initcall(register_gdb_console); + #endif --- diff/arch/mips/kernel/genex.S 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/kernel/genex.S 2004-02-23 13:56:38.000000000 +0000 @@ -17,6 +17,7 @@ #include #include #include +#include __INIT @@ -123,84 +124,82 @@ NESTED(except_vec4, 0, sp) 1: j 1b /* Dummy, will be replaced */ END(except_vec4) - /* - * EJTAG debug exception handler. - * The EJTAG debug exception entry point is 0xbfc00480, which - * normally is in the boot PROM, so the boot PROM must do a - * unconditional jump to this vector. - */ +/* + * EJTAG debug exception handler. + * The EJTAG debug exception entry point is 0xbfc00480, which + * normally is in the boot PROM, so the boot PROM must do a + * unconditional jump to this vector. + */ NESTED(except_vec_ejtag_debug, 0, sp) j ejtag_debug_handler - nop END(except_vec_ejtag_debug) __FINIT - /* - * EJTAG debug exception handler. - */ - NESTED(ejtag_debug_handler, PT_SIZE, sp) +/* + * EJTAG debug exception handler. + */ +NESTED(ejtag_debug_handler, PT_SIZE, sp) + .set push .set noat .set noreorder - mtc0 k0, CP0_DESAVE + MTC0 k0, CP0_DESAVE mfc0 k0, CP0_DEBUG sll k0, k0, 30 # Check for SDBBP. bgez k0, ejtag_return + nop - la k0, ejtag_debug_buffer - sw k1, 0(k0) + PTR_LA k0, ejtag_debug_buffer + LONG_S k1, 0(k0) SAVE_ALL jal ejtag_exception_handler move a0, sp RESTORE_ALL - la k0, ejtag_debug_buffer - lw k1, 0(k0) + PTR_LA k0, ejtag_debug_buffer + LONG_L k1, 0(k0) ejtag_return: - mfc0 k0, CP0_DESAVE + MFC0 k0, CP0_DESAVE .set mips32 deret - .set mips0 - nop - .set at + nop + .set pop END(ejtag_debug_handler) - /* - * This buffer is reserved for the use of the EJTAG debug - * handler. - */ +/* + * This buffer is reserved for the use of the EJTAG debug + * handler. + */ .data - EXPORT(ejtag_debug_buffer) +EXPORT(ejtag_debug_buffer) .fill LONGSIZE .previous __INIT - /* - * NMI debug exception handler for MIPS reference boards. - * The NMI debug exception entry point is 0xbfc00000, which - * normally is in the boot PROM, so the boot PROM must do a - * unconditional jump to this vector. - */ - NESTED(except_vec_nmi, 0, sp) +/* + * NMI debug exception handler for MIPS reference boards. + * The NMI debug exception entry point is 0xbfc00000, which + * normally is in the boot PROM, so the boot PROM must do a + * unconditional jump to this vector. + */ +NESTED(except_vec_nmi, 0, sp) j nmi_handler - nop END(except_vec_nmi) __FINIT - NESTED(nmi_handler, PT_SIZE, sp) +NESTED(nmi_handler, PT_SIZE, sp) + .set push .set noat - .set noreorder .set mips3 SAVE_ALL - jal nmi_exception_handler move a0, sp + jal nmi_exception_handler RESTORE_ALL eret - .set at - .set mips0 + .set pop END(nmi_handler) .macro __build_clear_none @@ -236,34 +235,41 @@ ejtag_return: recognize an unknown escape code. So make the arguments start with an n and gas will believe \n is ok ... */ .macro __BUILD_verbose nexception - ld a1, PT_EPC(sp) + LONG_L a1, PT_EPC(sp) +#if CONFIG_MIPS32 + PRINT("Got \nexception at %08lx\012") +#endif +#if CONFIG_MIPS64 PRINT("Got \nexception at %016lx\012") +#endif .endm .macro __BUILD_count exception - .set reorder LONG_L t0,exception_count_\exception LONG_ADDIU t0, 1 LONG_S t0,exception_count_\exception - .set noreorder .comm exception_count\exception, 8, 8 .endm - .macro BUILD_HANDLER exception handler clear verbose + .macro __BUILD_HANDLER exception handler clear verbose ext .align 5 NESTED(handle_\exception, PT_SIZE, sp) .set noat SAVE_ALL + FEXPORT(handle_\exception\ext) __BUILD_clear_\clear .set at __BUILD_\verbose \exception move a0, sp jal do_\handler j ret_from_exception - nop END(handle_\exception) .endm + .macro BUILD_HANDLER exception handler clear verbose + __BUILD_HANDLER \exception \handler \clear \verbose _int + .endm + BUILD_HANDLER adel ade ade silent /* #4 */ BUILD_HANDLER ades ade ade silent /* #5 */ BUILD_HANDLER ibe be cli silent /* #6 */ --- diff/arch/mips/kernel/head.S 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/head.S 2004-02-23 13:56:38.000000000 +0000 @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #ifdef CONFIG_SGI_IP27 @@ -91,6 +90,19 @@ .endm /* + * For the moment set ST0_KU so the CPU will not spit fire when + * executing 64-bit instructions. The full initialization of the + * CPU's status register is done later in per_cpu_trap_init(). + */ + .macro setup_c0_status +#ifdef CONFIG_MIPS64 + mfc0 t0, CP0_STATUS + or t0, ST0_KX + mtc0 t0, CP0_STATUS +#endif + .endm + + /* * Reserved space for exception handlers. * Necessary for machines which link their kernels at KSEG0. */ @@ -102,6 +114,8 @@ EXPORT(_stext) __INIT NESTED(kernel_entry, 16, sp) # kernel entry point + setup_c0_status + #ifdef CONFIG_SGI_IP27 GET_NASID_ASM t1 move t2, t1 # text and data are here @@ -112,18 +126,7 @@ NESTED(kernel_entry, 16, sp) # kernel CLI # disable interrupts - PTR_LA $28, init_thread_union - PTR_ADDIU sp, $28, _THREAD_SIZE - 32 - set_saved_sp sp, t0, t1 - PTR_SUBU sp, 4 * SZREG # init stack pointer - - /* - * The firmware/bootloader passes argc/argp/envp - * to us as arguments. But clear bss first because - * the romvec and other important info is stored there - * by prom_init(). - */ - PTR_LA t0, __bss_start + PTR_LA t0, __bss_start # clear .bss LONG_S zero, (t0) PTR_LA t1, __bss_stop - LONGSIZE 1: @@ -131,7 +134,17 @@ NESTED(kernel_entry, 16, sp) # kernel LONG_S zero, (t0) bne t0, t1, 1b - jal init_arch + LONG_S a0, fw_arg0 # firmware arguments + LONG_S a1, fw_arg1 + LONG_S a2, fw_arg2 + LONG_S a3, fw_arg3 + + PTR_LA $28, init_thread_union + PTR_ADDIU sp, $28, _THREAD_SIZE - 32 + set_saved_sp sp, t0, t1 + PTR_SUBU sp, 4 * SZREG # init stack pointer + + jal start_kernel END(kernel_entry) #ifdef CONFIG_SMP @@ -142,8 +155,8 @@ NESTED(kernel_entry, 16, sp) # kernel NESTED(smp_bootstrap, 16, sp) #ifdef CONFIG_SGI_IP27 GET_NASID_ASM t1 - li t0, KLDIR_OFFSET + (KLI_KERN_VARS * KLDIR_ENT_SIZE) + \ - KLDIR_OFF_POINTER + K0BASE + dli t0, KLDIR_OFFSET + (KLI_KERN_VARS * KLDIR_ENT_SIZE) + \ + KLDIR_OFF_POINTER + CAC_BASE dsll t1, NASID_SHFT or t0, t0, t1 ld t0, 0(t0) # t0 points to kern_vars struct @@ -154,17 +167,7 @@ NESTED(smp_bootstrap, 16, sp) #endif /* CONFIG_SGI_IP27 */ CLI - -#ifdef CONFIG_MIPS64 - /* - * For the moment set ST0_KU so the CPU will not spit fire when - * executing 64-bit instructions. The full initialization of the - * CPU's status register is done later in per_cpu_trap_init(). - */ - mfc0 t0, CP0_STATUS - or t0, ST0_KX - mtc0 t0, CP0_STATUS -#endif + setup_c0_status jal start_secondary END(smp_bootstrap) #endif /* CONFIG_SMP */ @@ -174,6 +177,11 @@ NESTED(smp_bootstrap, 16, sp) .comm kernelsp, NR_CPUS * 8, 8 .comm pgd_current, NR_CPUS * 8, 8 + .comm fw_arg0, SZREG, SZREG # firmware arguments + .comm fw_arg1, SZREG, SZREG + .comm fw_arg2, SZREG, SZREG + .comm fw_arg3, SZREG, SZREG + .macro page name, order=0 .globl \name \name: .size \name, (_PAGE_SIZE << \order) @@ -184,22 +192,17 @@ NESTED(smp_bootstrap, 16, sp) .data .align PAGE_SHIFT -#ifdef CONFIG_MIPS32 - /* - * Here we only have a two-level pagetable structure ... - */ - page swapper_pg_dir, _PGD_ORDER - page invalid_pte_table, _PTE_ORDER -#endif -#ifdef CONFIG_MIPS64 /* * ... but on 64-bit we've got three-level pagetables with a * slightly different layout ... */ page swapper_pg_dir, _PGD_ORDER +#ifdef CONFIG_MIPS64 page invalid_pmd_table, _PMD_ORDER +#endif page invalid_pte_table, _PTE_ORDER +#ifdef CONFIG_MIPS64 /* * 64-bit kernel mappings are really screwed up ... */ --- diff/arch/mips/kernel/i8259.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/kernel/i8259.c 2004-02-23 13:56:38.000000000 +0000 @@ -31,7 +31,7 @@ void disable_8259A_irq(unsigned int irq) * moves to arch independent land */ -static spinlock_t i8259A_lock = SPIN_LOCK_UNLOCKED; +spinlock_t i8259A_lock = SPIN_LOCK_UNLOCKED; static void end_8259A_irq (unsigned int irq) { @@ -242,7 +242,7 @@ static int __init i8259A_init_sysfs(void { int error = sysdev_class_register(&i8259_sysdev_class); if (!error) - error = sys_device_register(&device_i8259A); + error = sysdev_register(&device_i8259A); return error; } @@ -291,11 +291,6 @@ void __init init_8259A(int auto_eoi) spin_unlock_irqrestore(&i8259A_lock, flags); } -asmlinkage void i8259_do_irq(int irq, struct pt_regs regs) -{ - panic("i8259_do_irq: I want to be implemented"); -} - /* * IRQ2 is cascade interrupt to second interrupt controller */ --- diff/arch/mips/kernel/init_task.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/mips/kernel/init_task.c 2004-02-23 13:56:38.000000000 +0000 @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -26,7 +27,8 @@ EXPORT_SYMBOL(init_mm); * The things we do for performance.. */ union thread_union init_thread_union - __attribute__((__section__(".data.init_task"))) = + __attribute__((__section__(".data.init_task"), + __aligned__(THREAD_SIZE))) = { INIT_THREAD_INFO(init_task) }; /* --- diff/arch/mips/kernel/ioctl32.c 2003-09-17 12:28:02.000000000 +0100 +++ source/arch/mips/kernel/ioctl32.c 2004-02-23 13:56:38.000000000 +0000 @@ -4,7 +4,7 @@ * Copyright (C) 2000 Silicon Graphics, Inc. * Written by Ulf Carlsson (ulfc@engr.sgi.com) * Copyright (C) 2000 Ralf Baechle - * Copyright (C) 2002 Maciej W. Rozycki + * Copyright (C) 2002, 2003 Maciej W. Rozycki * * Mostly stolen from the sparc64 ioctl32 implementation. */ @@ -33,7 +33,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -45,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -60,6 +61,7 @@ #include #include #include +#include #include #include @@ -89,13 +91,12 @@ #include #include #include +#include #ifdef CONFIG_SIBYTE_TBPROF #include #endif -long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg); - static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg) { mm_segment_t old_fs = get_fs(); @@ -383,7 +384,7 @@ static inline int dev_ifconf(unsigned in struct ifreq32 *ifr32; struct ifreq *ifr; mm_segment_t old_fs; - int len; + unsigned int i, j; int err; if (copy_from_user(&ifc32, uifc32, sizeof(struct ifconf32))) @@ -402,16 +403,14 @@ static inline int dev_ifconf(unsigned in } ifr = ifc.ifc_req; ifr32 = (struct ifreq32 *)A(ifc32.ifcbuf); - len = ifc32.ifc_len / sizeof (struct ifreq32); - while (len--) { + for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) { if (copy_from_user(ifr++, ifr32++, sizeof (struct ifreq32))) { - err = -EFAULT; - goto out; + kfree (ifc.ifc_buf); + return -EFAULT; } } - old_fs = get_fs(); - set_fs (KERNEL_DS); + old_fs = get_fs(); set_fs (KERNEL_DS); err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)&ifc); set_fs (old_fs); if (err) @@ -419,16 +418,26 @@ static inline int dev_ifconf(unsigned in ifr = ifc.ifc_req; ifr32 = (struct ifreq32 *)A(ifc32.ifcbuf); - len = ifc.ifc_len / sizeof (struct ifreq); - ifc32.ifc_len = len * sizeof (struct ifreq32); - - while (len--) { + for (i = 0, j = 0; i < ifc32.ifc_len && j < ifc.ifc_len; + i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) { if (copy_to_user(ifr32++, ifr++, sizeof (struct ifreq32))) { err = -EFAULT; goto out; } } - + if (ifc32.ifcbuf == 0) { + /* Translate from 64-bit structure multiple to + * a 32-bit one. + */ + i = ifc.ifc_len; + i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32)); + ifc32.ifc_len = i; + } else { + if (i <= ifc32.ifc_len) + ifc32.ifc_len = i; + else + ifc32.ifc_len = i - sizeof (struct ifreq32); + } if (copy_to_user(uifc32, &ifc32, sizeof(struct ifconf32))) { err = -EFAULT; goto out; @@ -803,6 +812,120 @@ static int ioc_settimeout(unsigned int f return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg); } +#ifdef CONFIG_VT + +extern int tty_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg); + +static int vt_check(struct file *file) +{ + struct tty_struct *tty; + struct inode *inode = file->f_dentry->d_inode; + + if (file->f_op->ioctl != tty_ioctl) + return -EINVAL; + + tty = (struct tty_struct *)file->private_data; + if (tty_paranoia_check(tty, inode, "tty_ioctl")) + return -EINVAL; + + if (tty->driver->ioctl != vt_ioctl) + return -EINVAL; + + /* + * To have permissions to do most of the vt ioctls, we either have + * to be the owner of the tty, or super-user. + */ + if (current->tty == tty || capable(CAP_SYS_TTY_CONFIG)) + return 1; + return 0; +} + +struct consolefontdesc32 { + unsigned short charcount; /* characters in font (256 or 512) */ + unsigned short charheight; /* scan lines per character (1-32) */ + u32 chardata; /* font data in expanded form */ +}; + +static int do_fontx_ioctl(unsigned int fd, int cmd, struct consolefontdesc32 *user_cfd, struct file *file) +{ + struct consolefontdesc cfdarg; + struct console_font_op op; + int i, perm; + + perm = vt_check(file); + if (perm < 0) return perm; + + if (copy_from_user(&cfdarg, user_cfd, sizeof(struct consolefontdesc32))) + return -EFAULT; + + cfdarg.chardata = (unsigned char *)A(((struct consolefontdesc32 *)&cfdarg)->chardata); + + switch (cmd) { + case PIO_FONTX: + if (!perm) + return -EPERM; + op.op = KD_FONT_OP_SET; + op.flags = 0; + op.width = 8; + op.height = cfdarg.charheight; + op.charcount = cfdarg.charcount; + op.data = cfdarg.chardata; + return con_font_op(fg_console, &op); + case GIO_FONTX: + if (!cfdarg.chardata) + return 0; + op.op = KD_FONT_OP_GET; + op.flags = 0; + op.width = 8; + op.height = cfdarg.charheight; + op.charcount = cfdarg.charcount; + op.data = cfdarg.chardata; + i = con_font_op(fg_console, &op); + if (i) + return i; + cfdarg.charheight = op.height; + cfdarg.charcount = op.charcount; + ((struct consolefontdesc32 *)&cfdarg)->chardata = (unsigned long)cfdarg.chardata; + if (copy_to_user(user_cfd, &cfdarg, sizeof(struct consolefontdesc32))) + return -EFAULT; + return 0; + } + return -EINVAL; +} + +struct console_font_op32 { + unsigned int op; /* operation code KD_FONT_OP_* */ + unsigned int flags; /* KD_FONT_FLAG_* */ + unsigned int width, height; /* font size */ + unsigned int charcount; + u32 data; /* font data with height fixed to 32 */ +}; + +static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, struct console_font_op32 *fontop, struct file *file) +{ + struct console_font_op op; + int perm = vt_check(file), i; + struct vt_struct *vt; + + if (perm < 0) return perm; + + if (copy_from_user(&op, (void *) fontop, sizeof(struct console_font_op32))) + return -EFAULT; + if (!perm && op.op != KD_FONT_OP_GET) + return -EPERM; + op.data = (unsigned char *)A(((struct console_font_op32 *)&op)->data); + op.flags |= KD_FONT_FLAG_OLD; + vt = (struct vt_struct *)((struct tty_struct *)file->private_data)->driver_data; + i = con_font_op(vt->vc_num, &op); + if (i) return i; + ((struct console_font_op32 *)&op)->data = (unsigned long)op.data; + if (copy_to_user((void *) fontop, &op, sizeof(struct console_font_op32))) + return -EFAULT; + return 0; +} + +#endif + typedef int (* ioctl32_handler_t)(unsigned int, unsigned int, unsigned long, struct file *); #define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),sys_ioctl) @@ -819,6 +942,7 @@ COMPATIBLE_IOCTL(TCSETA) COMPATIBLE_IOCTL(TCSETAW) COMPATIBLE_IOCTL(TCSETAF) COMPATIBLE_IOCTL(TCSBRK) +COMPATIBLE_IOCTL(TCSBRKP) COMPATIBLE_IOCTL(TCXONC) COMPATIBLE_IOCTL(TCFLSH) COMPATIBLE_IOCTL(TCGETS) @@ -869,6 +993,7 @@ HANDLE_IOCTL(FBIOPUTCMAP, do_fbiocmap_io COMPATIBLE_IOCTL(FBIOPAN_DISPLAY) #endif /* CONFIG_FB */ +#ifdef CONFIG_VT /* Big K */ COMPATIBLE_IOCTL(PIO_FONT) COMPATIBLE_IOCTL(GIO_FONT) @@ -901,16 +1026,8 @@ COMPATIBLE_IOCTL(GIO_UNISCRNMAP) COMPATIBLE_IOCTL(PIO_UNISCRNMAP) COMPATIBLE_IOCTL(PIO_FONTRESET) COMPATIBLE_IOCTL(PIO_UNIMAPCLR) - -/* Big S */ -COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) -COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK) -COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK) -COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY) -COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_ENABLE) -COMPATIBLE_IOCTL(SCSI_IOCTL_TAGGED_DISABLE) -COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER) -COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND) +HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl) +HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl) /* Big V */ COMPATIBLE_IOCTL(VT_SETMODE) @@ -925,8 +1042,16 @@ COMPATIBLE_IOCTL(VT_RESIZE) COMPATIBLE_IOCTL(VT_RESIZEX) COMPATIBLE_IOCTL(VT_LOCKSWITCH) COMPATIBLE_IOCTL(VT_UNLOCKSWITCH) +#endif + +/* Big S */ +COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) +COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK) +COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK) +COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY) +COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER) +COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND) -#ifdef CONFIG_NET /* Socket level stuff */ COMPATIBLE_IOCTL(FIOSETOWN) COMPATIBLE_IOCTL(SIOCSPGRP) @@ -1034,6 +1159,7 @@ COMPATIBLE_IOCTL(DVD_AUTH) COMPATIBLE_IOCTL(LOOP_SET_FD) COMPATIBLE_IOCTL(LOOP_CLR_FD) +#ifdef CONFIG_NET /* And these ioctls need translation */ HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32) HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf) @@ -1075,7 +1201,6 @@ HANDLE_IOCTL(SIOCDELRT, routing_ioctl) */ HANDLE_IOCTL(SIOCRTMSG, ret_einval) HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp) - #endif /* CONFIG_NET */ HANDLE_IOCTL(EXT2_IOC32_GETFLAGS, do_ext2_ioctl) @@ -1147,23 +1272,23 @@ COMPATIBLE_IOCTL(RESTART_ARRAY_RW) #endif /* CONFIG_MD */ #ifdef CONFIG_SIBYTE_TBPROF -COMPATIBLE_IOCTL(SBPROF_ZBSTART), -COMPATIBLE_IOCTL(SBPROF_ZBSTOP), -COMPATIBLE_IOCTL(SBPROF_ZBWAITFULL), +COMPATIBLE_IOCTL(SBPROF_ZBSTART) +COMPATIBLE_IOCTL(SBPROF_ZBSTOP) +COMPATIBLE_IOCTL(SBPROF_ZBWAITFULL) #endif /* CONFIG_SIBYTE_TBPROF */ #if defined(CONFIG_BLK_DEV_DM) || defined(CONFIG_BLK_DEV_DM_MODULE) - IOCTL32_DEFAULT(DM_VERSION), - IOCTL32_DEFAULT(DM_REMOVE_ALL), - IOCTL32_DEFAULT(DM_DEV_CREATE), - IOCTL32_DEFAULT(DM_DEV_REMOVE), - IOCTL32_DEFAULT(DM_DEV_RELOAD), - IOCTL32_DEFAULT(DM_DEV_SUSPEND), - IOCTL32_DEFAULT(DM_DEV_RENAME), - IOCTL32_DEFAULT(DM_DEV_DEPS), - IOCTL32_DEFAULT(DM_DEV_STATUS), - IOCTL32_DEFAULT(DM_TARGET_STATUS), - IOCTL32_DEFAULT(DM_TARGET_WAIT), +COMPATIBLE_IOCTL(DM_VERSION) +COMPATIBLE_IOCTL(DM_REMOVE_ALL) +COMPATIBLE_IOCTL(DM_DEV_CREATE) +COMPATIBLE_IOCTL(DM_DEV_REMOVE) +COMPATIBLE_IOCTL(DM_DEV_RELOAD) +COMPATIBLE_IOCTL(DM_DEV_SUSPEND) +COMPATIBLE_IOCTL(DM_DEV_RENAME) +COMPATIBLE_IOCTL(DM_DEV_DEPS) +COMPATIBLE_IOCTL(DM_DEV_STATUS) +COMPATIBLE_IOCTL(DM_TARGET_STATUS) +COMPATIBLE_IOCTL(DM_TARGET_WAIT) #endif /* CONFIG_BLK_DEV_DM */ COMPATIBLE_IOCTL(MTIOCTOP) /* mtio.h ioctls */ --- diff/arch/mips/kernel/irixioctl.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/kernel/irixioctl.c 2004-02-23 13:56:38.000000000 +0000 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -26,9 +27,6 @@ struct irix_termios { cc_t c_cc[NCCS]; }; -extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, - unsigned long arg); -extern asmlinkage int sys_write(unsigned int fd,char * buf,unsigned int count); extern void start_tty(struct tty_struct *tty); static struct tty_struct *get_tty(int fd) { --- diff/arch/mips/kernel/irixsig.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/mips/kernel/irixsig.c 2004-02-23 13:56:38.000000000 +0000 @@ -210,7 +210,10 @@ irix_sigreturn(struct pt_regs *regs) int sig, i, base = 0; sigset_t blocked; - if(regs->regs[2] == 1000) + /* Always make any pending restarted system calls return -EINTR */ + current_thread_info()->restart_block.fn = do_no_restart_syscall; + + if (regs->regs[2] == 1000) base = 1; context = (struct sigctx_irix5 *) regs->regs[base + 4]; --- diff/arch/mips/kernel/irq.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/mips/kernel/irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -288,8 +288,10 @@ void inline disable_irq_nosync(unsigned void disable_irq(unsigned int irq) { + irq_desc_t *desc = irq_desc + irq; disable_irq_nosync(irq); - synchronize_irq(irq); + if (desc->action) + synchronize_irq(irq); } /** @@ -310,7 +312,7 @@ void enable_irq(unsigned int irq) spin_lock_irqsave(&desc->lock, flags); switch (desc->depth) { case 1: { - unsigned int status = desc->status & ~IRQ_DISABLED; + unsigned int status = desc->status & ~(IRQ_DISABLED | IRQ_INPROGRESS); desc->status = status; if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) { desc->status = status | IRQ_REPLAY; @@ -706,7 +708,7 @@ unsigned int probe_irq_mask(unsigned lon * appears to have triggered the interrupt. If no interrupt was * found then zero is returned. If more than one interrupt is * found then minus the first candidate is returned to indicate - * their is doubt. + * there is doubt. * * The interrupt probe logic state is returned to its previous * value. @@ -835,7 +837,7 @@ static cpumask_t irq_affinity [NR_IRQS] static int irq_affinity_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, irq_affinity[(long)data]); + int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); @@ -858,7 +860,7 @@ static int irq_affinity_write_proc (stru * way to make the system unusable accidentally :-) At least * one online CPU still has to be targeted. */ - cpus_and(tmp, tmp, cpu_online_map); + cpus_and(tmp, new_value, cpu_online_map); if (cpus_empty(tmp)) return -EINVAL; @@ -873,7 +875,7 @@ static int irq_affinity_write_proc (stru static int prof_cpu_mask_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, *(cpumask_t *)data); + int len = cpumask_scnprintf(page, count, *(cpumask_t *)data); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); --- diff/arch/mips/kernel/irq_cpu.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/kernel/irq_cpu.c 2004-02-23 13:56:38.000000000 +0000 @@ -80,7 +80,7 @@ static unsigned int mips_cpu_irq_startup static void mips_cpu_irq_ack(unsigned int irq) { /* Only necessary for soft interrupts */ - clear_c0_cause(1 << (irq - mips_cpu_irq_base + 8)); + clear_c0_cause(0x100 << (irq - mips_cpu_irq_base)); mask_mips_irq(irq); } @@ -102,6 +102,7 @@ static hw_irq_controller mips_cpu_irq_co NULL /* no affinity stuff for UP */ }; + void __init mips_cpu_irq_init(int irq_base) { int i; --- diff/arch/mips/kernel/linux32.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/mips/kernel/linux32.c 2004-02-23 13:56:38.000000000 +0000 @@ -6,6 +6,7 @@ * sys32_execve from ia64/ia32 code, Feb 2000, Kanoj Sarcar (kanoj@sgi.com) */ #include +#include #include #include #include @@ -24,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -123,8 +125,6 @@ out: } -asmlinkage long sys_truncate(const char * path, unsigned long length); - asmlinkage int sys_truncate64(const char *path, unsigned int high, unsigned int low) { @@ -133,8 +133,6 @@ asmlinkage int sys_truncate64(const char return sys_truncate(path, ((long) high << 32) | low); } -asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length); - asmlinkage int sys_ftruncate64(unsigned int fd, unsigned int high, unsigned int low) { @@ -175,26 +173,34 @@ static int count32(u32 * argv, int max) */ int copy_strings32(int argc, u32 * argv, struct linux_binprm *bprm) { + struct page *kmapped_page = NULL; + char *kaddr = NULL; + int ret; + while (argc-- > 0) { u32 str; int len; unsigned long pos; if (get_user(str, argv+argc) || !str || - !(len = strnlen_user((char *)A(str), bprm->p))) - return -EFAULT; - if (bprm->p < len) - return -E2BIG; + !(len = strnlen_user((char *)A(str), bprm->p))) { + ret = -EFAULT; + goto out; + } + + if (bprm->p < len) { + ret = -E2BIG; + goto out; + } bprm->p -= len; /* XXX: add architecture specific overflow check here. */ pos = bprm->p; while (len > 0) { - char *kaddr; int i, new, err; - struct page *page; int offset, bytes_to_copy; + struct page *page; offset = pos % PAGE_SIZE; i = pos/PAGE_SIZE; @@ -203,12 +209,19 @@ int copy_strings32(int argc, u32 * argv, if (!page) { page = alloc_page(GFP_HIGHUSER); bprm->page[i] = page; - if (!page) - return -ENOMEM; + if (!page) { + ret = -ENOMEM; + goto out; + } new = 1; } - kaddr = kmap(page); + if (page != kmapped_page) { + if (kmapped_page) + kunmap(kmapped_page); + kmapped_page = page; + kaddr = kmap(kmapped_page); + } if (new && offset) memset(kaddr, 0, offset); bytes_to_copy = PAGE_SIZE - offset; @@ -220,20 +233,42 @@ int copy_strings32(int argc, u32 * argv, } err = copy_from_user(kaddr + offset, (char *)A(str), bytes_to_copy); - flush_dcache_page(page); - kunmap(page); - - if (err) - return -EFAULT; + if (err) { + ret = -EFAULT; + goto out; + } pos += bytes_to_copy; str += bytes_to_copy; len -= bytes_to_copy; } } - return 0; + ret = 0; +out: + if (kmapped_page) + kunmap(kmapped_page); + return ret; +} + +#ifdef CONFIG_MMU + +#define free_arg_pages(bprm) do { } while (0) + +#else + +static inline void free_arg_pages(struct linux_binprm *bprm) +{ + int i; + + for (i = 0; i < MAX_ARG_PAGES; i++) { + if (bprm->page[i]) + __free_page(bprm->page[i]); + bprm->page[i] = NULL; + } } +#endif /* CONFIG_MMU */ + /* * sys32_execve() executes a new program. */ @@ -243,7 +278,8 @@ do_execve32(char * filename, u32 * argv, struct linux_binprm bprm; struct file * file; int retval; - int i; + + sched_balance_exec(); file = open_exec(filename); @@ -278,7 +314,8 @@ do_execve32(char * filename, u32 * argv, if ((retval = bprm.envc) < 0) goto out_mm; - if ((retval = security_bprm_alloc(&bprm))) + retval = security_bprm_alloc(&bprm); + if (retval) goto out; retval = prepare_binprm(&bprm); @@ -300,6 +337,8 @@ do_execve32(char * filename, u32 * argv, retval = search_binary_handler(&bprm, regs); if (retval >= 0) { + free_arg_pages(&bprm); + /* execve success */ security_bprm_free(&bprm); return retval; @@ -307,17 +346,14 @@ do_execve32(char * filename, u32 * argv, out: /* Something went wrong, return the inode and free the argument pages*/ - for (i = 0 ; i < MAX_ARG_PAGES ; i++) { - struct page * page = bprm.page[i]; - if (page) - __free_page(page); - } + free_arg_pages(&bprm); if (bprm.security) security_bprm_free(&bprm); out_mm: - mmdrop(bprm.mm); + if (bprm.mm) + mmdrop(bprm.mm); out_file: if (bprm.file) { @@ -336,7 +372,6 @@ asmlinkage int sys32_execve(nabi_no_rega char * filename; filename = getname((char *) (long)regs.regs[4]); - printk("Executing: %s\n", filename); error = PTR_ERR(filename); if (IS_ERR(filename)) goto out; @@ -375,8 +410,6 @@ xlate_dirent(void *dirent64, void *diren return; } -asmlinkage long sys_getdents(unsigned int fd, void * dirent, unsigned int count); - asmlinkage long sys32_getdents(unsigned int fd, void * dirent32, unsigned int count) { @@ -497,8 +530,6 @@ struct sysinfo32 { char _f[8]; }; -extern asmlinkage int sys_sysinfo(struct sysinfo *info); - asmlinkage int sys32_sysinfo(struct sysinfo32 *info) { struct sysinfo s; @@ -633,10 +664,6 @@ sys32_settimeofday(struct compat_timeval return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL); } -extern asmlinkage long sys_llseek(unsigned int fd, unsigned long offset_high, - unsigned long offset_low, loff_t * result, - unsigned int origin); - asmlinkage int sys32_llseek(unsigned int fd, unsigned int offset_high, unsigned int offset_low, loff_t * result, unsigned int origin) @@ -704,6 +731,7 @@ do_readv_writev32(int type, struct file * specially as they have atomicity guarantees and can handle * iovec's natively */ +#ifdef CONFIG_NET if (inode->i_sock) { int err; err = sock_readv_writev(type, inode, file, iov, count, tot_len); @@ -711,6 +739,7 @@ do_readv_writev32(int type, struct file kfree(iov); return err; } +#endif if (!file->f_op) { if (iov != iovstack) @@ -1018,10 +1047,6 @@ out_nofds: } - -extern asmlinkage int sys_sched_rr_get_interval(pid_t pid, - struct timespec *interval); - asmlinkage int sys32_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec *interval) { @@ -1183,10 +1208,10 @@ do_sys32_semctl(int first, int second, i case IPC_STAT: case SEM_STAT: fourth.__pad = &s; - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_semctl (first, second, third, fourth); - set_fs (old_fs); + old_fs = get_fs(); + set_fs(KERNEL_DS); + err = sys_semctl(first, second, third | IPC_64, fourth); + set_fs(old_fs); if (third & IPC_64) { struct semid64_ds32 *usp64 = (struct semid64_ds32 *) A(pad); @@ -1348,18 +1373,18 @@ do_sys32_msgctl (int first, int second, } if (err) break; - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_msgctl (first, second, (struct msqid_ds *)&m); - set_fs (old_fs); + old_fs = get_fs(); + set_fs(KERNEL_DS); + err = sys_msgctl(first, second | IPC_64, (struct msqid_ds *)&m); + set_fs(old_fs); break; case IPC_STAT: case MSG_STAT: - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_msgctl (first, second, (struct msqid_ds *)&m); - set_fs (old_fs); + old_fs = get_fs(); + set_fs(KERNEL_DS); + err = sys_msgctl(first, second | IPC_64, (struct msqid_ds *)&m); + set_fs(old_fs); if (second & IPC_64) { if (!access_ok(VERIFY_WRITE, up64, sizeof(*up64))) { err = -EFAULT; @@ -1420,8 +1445,6 @@ do_sys32_shmat (int first, int second, i if (version == 1) return err; - if (version == 1) - return err; err = sys_shmat (first, uptr, second, &raddr); if (err) return err; @@ -1429,21 +1452,23 @@ do_sys32_shmat (int first, int second, i return err; } +struct shm_info32 { + int used_ids; + u32 shm_tot, shm_rss, shm_swp; + u32 swap_attempts, swap_successes; +}; + static int do_sys32_shmctl (int first, int second, void *uptr) { + struct shmid64_ds32 *up64 = (struct shmid64_ds32 *)uptr; + struct shmid_ds32 *up32 = (struct shmid_ds32 *)uptr; + struct shm_info32 *uip = (struct shm_info32 *)uptr; int err = -EFAULT, err2; - struct shmid_ds s; struct shmid64_ds s64; - struct shmid_ds32 *up32 = (struct shmid_ds32 *)uptr; - struct shmid64_ds32 *up64 = (struct shmid64_ds32 *)uptr; mm_segment_t old_fs; - struct shm_info32 { - int used_ids; - u32 shm_tot, shm_rss, shm_swp; - u32 swap_attempts, swap_successes; - } *uip = (struct shm_info32 *)uptr; struct shm_info si; + struct shmid_ds s; switch (second & ~IPC_64) { case IPC_INFO: @@ -1451,7 +1476,7 @@ do_sys32_shmctl (int first, int second, case IPC_RMID: case SHM_LOCK: case SHM_UNLOCK: - err = sys_shmctl (first, second, (struct shmid_ds *)uptr); + err = sys_shmctl(first, second, (struct shmid_ds *)uptr); break; case IPC_SET: if (second & IPC_64) { @@ -1465,18 +1490,18 @@ do_sys32_shmctl (int first, int second, } if (err) break; - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_shmctl (first, second, &s); - set_fs (old_fs); + old_fs = get_fs(); + set_fs(KERNEL_DS); + err = sys_shmctl(first, second & ~IPC_64, &s); + set_fs(old_fs); break; case IPC_STAT: case SHM_STAT: - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_shmctl (first, second, (void *) &s64); - set_fs (old_fs); + old_fs = get_fs(); + set_fs(KERNEL_DS); + err = sys_shmctl(first, second | IPC_64, (void *) &s64); + set_fs(old_fs); if (err < 0) break; if (second & IPC_64) { @@ -1523,32 +1548,46 @@ do_sys32_shmctl (int first, int second, break; case SHM_INFO: - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_shmctl (first, second, (void *)&si); - set_fs (old_fs); + old_fs = get_fs(); + set_fs(KERNEL_DS); + err = sys_shmctl(first, second, (void *)&si); + set_fs(old_fs); if (err < 0) break; - err2 = put_user (si.used_ids, &uip->used_ids); - err2 |= __put_user (si.shm_tot, &uip->shm_tot); - err2 |= __put_user (si.shm_rss, &uip->shm_rss); - err2 |= __put_user (si.shm_swp, &uip->shm_swp); - err2 |= __put_user (si.swap_attempts, - &uip->swap_attempts); - err2 |= __put_user (si.swap_successes, - &uip->swap_successes); + err2 = put_user(si.used_ids, &uip->used_ids); + err2 |= __put_user(si.shm_tot, &uip->shm_tot); + err2 |= __put_user(si.shm_rss, &uip->shm_rss); + err2 |= __put_user(si.shm_swp, &uip->shm_swp); + err2 |= __put_user(si.swap_attempts, &uip->swap_attempts); + err2 |= __put_user (si.swap_successes, &uip->swap_successes); if (err2) err = -EFAULT; break; default: - err = -ENOSYS; + err = -EINVAL; break; } return err; } +static int sys32_semtimedop(int semid, struct sembuf *tsems, int nsems, + const struct compat_timespec *timeout32) +{ + struct compat_timespec t32; + struct timespec *t64 = compat_alloc_user_space(sizeof(*t64)); + + if (copy_from_user(&t32, timeout32, sizeof(t32))) + return -EFAULT; + + if (put_user(t32.tv_sec, &t64->tv_sec) || + put_user(t32.tv_nsec, &t64->tv_nsec)) + return -EFAULT; + + return sys_semtimedop(semid, tsems, nsems, t64); +} + asmlinkage long sys32_ipc (u32 call, int first, int second, int third, u32 ptr, u32 fifth) { @@ -1558,11 +1597,14 @@ sys32_ipc (u32 call, int first, int seco call &= 0xffff; switch (call) { - case SEMOP: /* struct sembuf is the same on 32 and 64bit :)) */ - err = sys_semop (first, (struct sembuf *)AA(ptr), - second); + err = sys_semtimedop (first, (struct sembuf *)AA(ptr), second, + NULL); + break; + case SEMTIMEDOP: + err = sys32_semtimedop (first, (struct sembuf *)AA(ptr), second, + (const struct compat_timespec __user *)AA(fifth)); break; case SEMGET: err = sys_semget (first, second, third); @@ -1668,56 +1710,6 @@ asmlinkage long sys32_sysctl(struct sysc #endif /* CONFIG_SYSCTL */ -extern asmlinkage int sys_sched_setaffinity(pid_t pid, unsigned int len, - unsigned long *user_mask_ptr); - -asmlinkage int sys32_sched_setaffinity(compat_pid_t pid, unsigned int len, - u32 *user_mask_ptr) -{ - unsigned long kernel_mask; - mm_segment_t old_fs; - int ret; - - if (get_user(kernel_mask, user_mask_ptr)) - return -EFAULT; - - old_fs = get_fs(); - set_fs(KERNEL_DS); - ret = sys_sched_setaffinity(pid, - /* XXX Nice api... */ - sizeof(kernel_mask), - &kernel_mask); - set_fs(old_fs); - - return ret; -} - -extern asmlinkage int sys_sched_getaffinity(pid_t pid, unsigned int len, - unsigned long *user_mask_ptr); - -asmlinkage int sys32_sched_getaffinity(compat_pid_t pid, unsigned int len, - u32 *user_mask_ptr) -{ - unsigned long kernel_mask; - mm_segment_t old_fs; - int ret; - - old_fs = get_fs(); - set_fs(KERNEL_DS); - ret = sys_sched_getaffinity(pid, - /* XXX Nice api... */ - sizeof(kernel_mask), - &kernel_mask); - set_fs(old_fs); - - if (ret == 0) { - if (put_user(kernel_mask, user_mask_ptr)) - ret = -EFAULT; - } - - return ret; -} - asmlinkage long sys32_newuname(struct new_utsname * name) { int ret = 0; @@ -1734,8 +1726,6 @@ asmlinkage long sys32_newuname(struct ne return ret; } -extern asmlinkage long sys_personality(unsigned long); - asmlinkage int sys32_personality(unsigned long personality) { int ret; @@ -1747,6 +1737,40 @@ asmlinkage int sys32_personality(unsigne return ret; } +/* ustat compatibility */ +struct ustat32 { + compat_daddr_t f_tfree; + compat_ino_t f_tinode; + char f_fname[6]; + char f_fpack[6]; +}; + +extern asmlinkage long sys_ustat(dev_t dev, struct ustat * ubuf); + +asmlinkage int sys32_ustat(dev_t dev, struct ustat32 * ubuf32) +{ + int err; + struct ustat tmp; + struct ustat32 tmp32; + mm_segment_t old_fs = get_fs(); + + set_fs(KERNEL_DS); + err = sys_ustat(dev, &tmp); + set_fs (old_fs); + + if (err) + goto out; + + memset(&tmp32,0,sizeof(struct ustat32)); + tmp32.f_tfree = tmp.f_tfree; + tmp32.f_tinode = tmp.f_tinode; + + err = copy_to_user(ubuf32,&tmp32,sizeof(struct ustat32)) ? -EFAULT : 0; + +out: + return err; +} + /* Handle adjtimex compatibility. */ struct timex32 { @@ -1820,8 +1844,6 @@ asmlinkage int sys32_adjtimex(struct tim return ret; } -extern asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t *offset, size_t count); - asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t *offset, s32 count) { @@ -1842,29 +1864,122 @@ asmlinkage int sys32_sendfile(int out_fd return ret; } -asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count); - asmlinkage ssize_t sys32_readahead(int fd, u32 pad0, u64 a2, u64 a3, size_t count) { return sys_readahead(fd, merge_64(a2, a3), count); } -asmlinkage long compat_sys_utimes(char __user * filename, - struct compat_timeval __user * utimes) +/* Argument list sizes for sys_socketcall */ +#define AL(x) ((x) * sizeof(unsigned int)) +static unsigned char socketcall_nargs[18]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), + AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), + AL(6),AL(2),AL(5),AL(5),AL(3),AL(3)}; +#undef AL + +/* + * System call vectors. + * + * Argument checking cleaned up. Saved 20% in size. + * This function doesn't need to set the kernel lock because + * it is set by the callees. + */ + +asmlinkage long sys32_socketcall(int call, unsigned int *args32) { - struct timeval times[2]; - - if (utimes) { - if (verify_area(VERIFY_READ, utimes, 2 * sizeof(*utimes))) - return -EFAULT; + unsigned int a[6]; + unsigned int a0,a1; + int err; - if (__get_user(times[0].tv_sec, &utimes[0].tv_sec) | - __get_user(times[0].tv_usec, &utimes[0].tv_usec) | - __get_user(times[1].tv_sec, &utimes[1].tv_sec) | - __get_user(times[1].tv_usec, &utimes[1].tv_usec)) - return -EFAULT; - } + extern asmlinkage long sys_socket(int family, int type, int protocol); + extern asmlinkage long sys_bind(int fd, struct sockaddr __user *umyaddr, int addrlen); + extern asmlinkage long sys_connect(int fd, struct sockaddr __user *uservaddr, int addrlen); + extern asmlinkage long sys_listen(int fd, int backlog); + extern asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, int __user *upeer_addrlen); + extern asmlinkage long sys_getsockname(int fd, struct sockaddr __user *usockaddr, int __user *usockaddr_len); + extern asmlinkage long sys_getpeername(int fd, struct sockaddr __user *usockaddr, int __user *usockaddr_len); + extern asmlinkage long sys_socketpair(int family, int type, int protocol, int __user *usockvec); + extern asmlinkage long sys_send(int fd, void __user * buff, size_t len, unsigned flags); + extern asmlinkage long sys_sendto(int fd, void __user * buff, size_t len, unsigned flags, + struct sockaddr __user *addr, int addr_len); + extern asmlinkage long sys_recv(int fd, void __user * ubuf, size_t size, unsigned flags); + extern asmlinkage long sys_recvfrom(int fd, void __user * ubuf, size_t size, unsigned flags, + struct sockaddr __user *addr, int __user *addr_len); + extern asmlinkage long sys_shutdown(int fd, int how); + extern asmlinkage long sys_setsockopt(int fd, int level, int optname, char __user *optval, int optlen); + extern asmlinkage long sys_getsockopt(int fd, int level, int optname, char __user *optval, int *optlen); + extern asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags); + extern asmlinkage long sys_recvmsg(int fd, struct msghdr __user *msg, unsigned int flags); + + + if(call<1||call>SYS_RECVMSG) + return -EINVAL; - return do_utimes(filename, utimes ? times : NULL); + /* copy_from_user should be SMP safe. */ + if (copy_from_user(a, args32, socketcall_nargs[call])) + return -EFAULT; + + a0=a[0]; + a1=a[1]; + + switch(call) + { + case SYS_SOCKET: + err = sys_socket(a0,a1,a[2]); + break; + case SYS_BIND: + err = sys_bind(a0,(struct sockaddr __user *)A(a1), a[2]); + break; + case SYS_CONNECT: + err = sys_connect(a0, (struct sockaddr __user *)A(a1), a[2]); + break; + case SYS_LISTEN: + err = sys_listen(a0,a1); + break; + case SYS_ACCEPT: + err = sys_accept(a0,(struct sockaddr __user *)A(a1), (int __user *)A(a[2])); + break; + case SYS_GETSOCKNAME: + err = sys_getsockname(a0,(struct sockaddr __user *)A(a1), (int __user *)A(a[2])); + break; + case SYS_GETPEERNAME: + err = sys_getpeername(a0, (struct sockaddr __user *)A(a1), (int __user *)A(a[2])); + break; + case SYS_SOCKETPAIR: + err = sys_socketpair(a0,a1, a[2], (int __user *)A(a[3])); + break; + case SYS_SEND: + err = sys_send(a0, (void __user *)A(a1), a[2], a[3]); + break; + case SYS_SENDTO: + err = sys_sendto(a0,(void __user *)A(a1), a[2], a[3], + (struct sockaddr __user *)A(a[4]), a[5]); + break; + case SYS_RECV: + err = sys_recv(a0, (void __user *)A(a1), a[2], a[3]); + break; + case SYS_RECVFROM: + err = sys_recvfrom(a0, (void __user *)A(a1), a[2], a[3], + (struct sockaddr __user *)A(a[4]), (int __user *)A(a[5])); + break; + case SYS_SHUTDOWN: + err = sys_shutdown(a0,a1); + break; + case SYS_SETSOCKOPT: + err = sys_setsockopt(a0, a1, a[2], (char __user *)A(a[3]), a[4]); + break; + case SYS_GETSOCKOPT: + err = sys_getsockopt(a0, a1, a[2], (char __user *)A(a[3]), (int __user *)A(a[4])); + break; + case SYS_SENDMSG: + err = sys_sendmsg(a0, (struct msghdr __user *) A(a1), a[2]); + break; + case SYS_RECVMSG: + err = sys_recvmsg(a0, (struct msghdr __user *) A(a1), a[2]); + break; + default: + err = -EINVAL; + break; + } + return err; } --- diff/arch/mips/kernel/mips_ksyms.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/mips/kernel/mips_ksyms.c 2004-02-23 13:56:38.000000000 +0000 @@ -8,27 +8,10 @@ * Copyright (C) 1996, 97, 98, 99, 2000, 01, 03 by Ralf Baechle * Copyright (C) 1999, 2000, 01 Silicon Graphics, Inc. */ -#include #include -#include -#include -#include -#include -#include -#include -#include - -#include #include -#include -#include -#include -#include -#include +#include #include -#ifdef CONFIG_BLK_DEV_FD -#include -#endif extern void *__bzero(void *__s, size_t __count); extern long __strncpy_from_user_nocheck_asm(char *__to, @@ -40,11 +23,10 @@ extern long __strlen_user_asm(const char extern long __strnlen_user_nocheck_asm(const char *s); extern long __strnlen_user_asm(const char *s); -EXPORT_SYMBOL(mips_machtype); - /* * String functions */ +EXPORT_SYMBOL_NOVERS(memchr); EXPORT_SYMBOL_NOVERS(memcmp); EXPORT_SYMBOL_NOVERS(memset); EXPORT_SYMBOL_NOVERS(memcpy); @@ -58,7 +40,6 @@ EXPORT_SYMBOL_NOVERS(strnlen); EXPORT_SYMBOL_NOVERS(strrchr); EXPORT_SYMBOL_NOVERS(strstr); -EXPORT_SYMBOL(_clear_page); EXPORT_SYMBOL(kernel_thread); /* @@ -73,24 +54,6 @@ EXPORT_SYMBOL_NOVERS(__strlen_user_asm); EXPORT_SYMBOL_NOVERS(__strnlen_user_nocheck_asm); EXPORT_SYMBOL_NOVERS(__strnlen_user_asm); -EXPORT_SYMBOL(invalid_pte_table); - -/* - * Semaphore stuff - */ -EXPORT_SYMBOL(__down); -EXPORT_SYMBOL(__down_interruptible); -EXPORT_SYMBOL(__down_trylock); -EXPORT_SYMBOL(__up); +EXPORT_SYMBOL(csum_partial); -/* - * Kernel hacking ... - */ -#include -#include - -#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) -EXPORT_SYMBOL(ide_ops); -#endif - -EXPORT_SYMBOL(get_wchan); +EXPORT_SYMBOL(invalid_pte_table); --- diff/arch/mips/kernel/module-elf32.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/kernel/module-elf32.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,20 +1,24 @@ -/* Kernel module help for MIPS. - Copyright (C) 2001 Rusty Russell. +/* + * 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 + * + * Copyright (C) 2001 Rusty Russell. + * Copyright (C) 2003, 2004 Ralf Baechle (ralf@linux-mips.org) + */ + +#undef DEBUG - 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 @@ -31,12 +35,6 @@ struct mips_hi16 { static struct mips_hi16 *mips_hi16_list; -#if 0 -#define DEBUGP printk -#else -#define DEBUGP(fmt , ...) -#endif - void *module_alloc(unsigned long size) { if (size == 0) @@ -53,52 +51,170 @@ void module_free(struct module *mod, voi table entries. */ } -/* We don't need anything special. */ -long module_core_size(const Elf32_Ehdr *hdr, - const Elf32_Shdr *sechdrs, - const char *secstrings, - struct module *module) +int module_frob_arch_sections(Elf_Ehdr *hdr, + Elf_Shdr *sechdrs, + char *secstrings, + struct module *mod) { - return module->core_size; + return 0; } -long module_init_size(const Elf32_Ehdr *hdr, - const Elf32_Shdr *sechdrs, - const char *secstrings, - struct module *module) +static int apply_r_mips_none(struct module *me, uint32_t *location, + Elf32_Addr v) { - return module->init_size; + return 0; } -int module_frob_arch_sections(Elf_Ehdr *hdr, - Elf_Shdr *sechdrs, - char *secstrings, - struct module *mod) +static int apply_r_mips_32(struct module *me, uint32_t *location, + Elf32_Addr v) +{ + *location += v; + + return 0; +} + +static int apply_r_mips_26(struct module *me, uint32_t *location, + Elf32_Addr v) +{ + if (v % 4) { + printk(KERN_ERR "module %s: dangerous relocation\n", me->name); + return -ENOEXEC; + } + + if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) { + printk(KERN_ERR + "module %s: relocation overflow\n", + me->name); + return -ENOEXEC; + } + + *location = (*location & ~0x03ffffff) | + ((*location + (v >> 2)) & 0x03ffffff); + + return 0; +} + +static int apply_r_mips_hi16(struct module *me, uint32_t *location, + Elf32_Addr v) { + struct mips_hi16 *n; + + /* + * We cannot relocate this one now because we don't know the value of + * the carry we need to add. Save the information, and let LO16 do the + * actual relocation. + */ + n = kmalloc(sizeof *n, GFP_KERNEL); + if (!n) + return -ENOMEM; + + n->addr = location; + n->value = v; + n->next = mips_hi16_list; + mips_hi16_list = n; + return 0; } +static int apply_r_mips_lo16(struct module *me, uint32_t *location, + Elf32_Addr v) +{ + unsigned long insnlo = *location; + Elf32_Addr val, vallo; + + /* Sign extend the addend we extract from the lo insn. */ + vallo = ((insnlo & 0xffff) ^ 0x8000) - 0x8000; + + if (mips_hi16_list != NULL) { + struct mips_hi16 *l; + + l = mips_hi16_list; + while (l != NULL) { + struct mips_hi16 *next; + unsigned long insn; + + /* + * The value for the HI16 had best be the same. + */ + if (v != l->value) + goto out_danger; + + /* + * Do the HI16 relocation. Note that we actually don't + * need to know anything about the LO16 itself, except + * where to find the low 16 bits of the addend needed + * by the LO16. + */ + insn = *l->addr; + val = ((insn & 0xffff) << 16) + vallo; + val += v; + + /* + * Account for the sign extension that will happen in + * the low bits. + */ + val = ((val >> 16) + ((val & 0x8000) != 0)) & 0xffff; + + insn = (insn & ~0xffff) | val; + *l->addr = insn; + + next = l->next; + kfree(l); + l = next; + } + + mips_hi16_list = NULL; + } + + /* + * Ok, we're done with the HI16 relocs. Now deal with the LO16. + */ + val = v + vallo; + insnlo = (insnlo & ~0xffff) | (val & 0xffff); + *location = insnlo; + + return 0; + +out_danger: + printk(KERN_ERR "module %s: dangerous " "relocation\n", me->name); + + return -ENOEXEC; +} + +static int (*reloc_handlers[]) (struct module *me, uint32_t *location, + Elf32_Addr v) = { + [R_MIPS_NONE] = apply_r_mips_none, + [R_MIPS_32] = apply_r_mips_32, + [R_MIPS_26] = apply_r_mips_26, + [R_MIPS_HI16] = apply_r_mips_hi16, + [R_MIPS_LO16] = apply_r_mips_lo16 +}; + int apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, unsigned int relsec, struct module *me) { - unsigned int i; - Elf32_Rel *rel = (void *)sechdrs[relsec].sh_offset; + Elf32_Rel *rel = (void *) sechdrs[relsec].sh_addr; Elf32_Sym *sym; uint32_t *location; + unsigned int i; Elf32_Addr v; + int res; - DEBUGP("Applying relocate section %u to %u\n", relsec, + pr_debug("Applying relocate section %u to %u\n", relsec, sechdrs[relsec].sh_info); + for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { + Elf32_Word r_info = rel[i].r_info; + /* This is where to make the change */ - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_offset + location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset; /* This is the symbol it is referring to */ - sym = (Elf32_Sym *)sechdrs[symindex].sh_offset - + ELF32_R_SYM(rel[i].r_info); + sym = (Elf32_Sym *)sechdrs[symindex].sh_addr + + ELF32_R_SYM(r_info); if (!sym->st_value) { printk(KERN_WARNING "%s: Unknown symbol %s\n", me->name, strtab + sym->st_name); @@ -107,115 +223,11 @@ int apply_relocate(Elf32_Shdr *sechdrs, v = sym->st_value; - switch (ELF32_R_TYPE(rel[i].r_info)) { - case R_MIPS_NONE: - break; - - case R_MIPS_32: - *location += v; - break; - - case R_MIPS_26: - if (v % 4) - printk(KERN_ERR - "module %s: dangerous relocation\n", - me->name); - return -ENOEXEC; - if ((v & 0xf0000000) != - (((unsigned long)location + 4) & 0xf0000000)) - printk(KERN_ERR - "module %s: relocation overflow\n", - me->name); - return -ENOEXEC; - *location = (*location & ~0x03ffffff) | - ((*location + (v >> 2)) & 0x03ffffff); - break; - - case R_MIPS_HI16: { - struct mips_hi16 *n; - - /* - * We cannot relocate this one now because we don't - * know the value of the carry we need to add. Save - * the information, and let LO16 do the actual - * relocation. - */ - n = (struct mips_hi16 *) kmalloc(sizeof *n, GFP_KERNEL); - n->addr = location; - n->value = v; - n->next = mips_hi16_list; - mips_hi16_list = n; - break; - } - - case R_MIPS_LO16: { - unsigned long insnlo = *location; - Elf32_Addr val, vallo; - - /* Sign extend the addend we extract from the lo insn. */ - vallo = ((insnlo & 0xffff) ^ 0x8000) - 0x8000; - - if (mips_hi16_list != NULL) { - struct mips_hi16 *l; - - l = mips_hi16_list; - while (l != NULL) { - struct mips_hi16 *next; - unsigned long insn; - - /* - * The value for the HI16 had best be - * the same. - */ - printk(KERN_ERR "module %s: dangerous " - "relocation\n", me->name); - return -ENOEXEC; - - /* - * Do the HI16 relocation. Note that - * we actually don't need to know - * anything about the LO16 itself, - * except where to find the low 16 bits - * of the addend needed by the LO16. - */ - insn = *l->addr; - val = ((insn & 0xffff) << 16) + vallo; - val += v; - - /* - * Account for the sign extension that - * will happen in the low bits. - */ - val = ((val >> 16) + ((val & 0x8000) != - 0)) & 0xffff; - - insn = (insn & ~0xffff) | val; - *l->addr = insn; - - next = l->next; - kfree(l); - l = next; - } - - mips_hi16_list = NULL; - } - - /* - * Ok, we're done with the HI16 relocs. Now deal with - * the LO16. - */ - val = v + vallo; - insnlo = (insnlo & ~0xffff) | (val & 0xffff); - *location = insnlo; - break; - } - - default: - printk(KERN_ERR "module %s: Unknown relocation: %u\n", - me->name, ELF32_R_TYPE(rel[i].r_info)); - return -ENOEXEC; - } + res = reloc_handlers[ELF32_R_TYPE(r_info)](me, location, v); + if (res) + return res; } + return 0; } @@ -225,6 +237,13 @@ int apply_relocate_add(Elf32_Shdr *sechd unsigned int relsec, struct module *me) { + /* + * Current binutils always generate .rela relocations. Keep smiling + * if it's empty, abort otherwise. + */ + if (!sechdrs[relsec].sh_size) + return 0; + printk(KERN_ERR "module %s: ADD RELOCATION unsupported\n", me->name); return -ENOEXEC; --- diff/arch/mips/kernel/module-elf64.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/kernel/module-elf64.c 2004-02-23 13:56:38.000000000 +0000 @@ -160,23 +160,6 @@ void module_free(struct module *mod, voi table entries. */ } -/* We don't need anything special. */ -long module_core_size(const Elf32_Ehdr *hdr, - const Elf32_Shdr *sechdrs, - const char *secstrings, - struct module *module) -{ - return module->core_size; -} - -long module_init_size(const Elf32_Ehdr *hdr, - const Elf32_Shdr *sechdrs, - const char *secstrings, - struct module *module) -{ - return module->init_size; -} - int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, char *secstrings, --- diff/arch/mips/kernel/offset.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/offset.c 2004-02-23 13:56:38.000000000 +0000 @@ -8,6 +8,7 @@ * Kevin Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com * Copyright (C) 2000 MIPS Technologies, Inc. */ +#include #include #include #include @@ -22,7 +23,7 @@ #define offset(string, ptr, member) \ __asm__("\n@@@" string "%0" : : "i" (_offset(ptr, member))) #define constant(string, member) \ - __asm__("\n@@@" string "%x0" : : "i" (member)) + __asm__("\n@@@" string "%x0" : : "ri" (member)) #define size(string, size) \ __asm__("\n@@@" string "%0" : : "i" (sizeof(size))) #define linefeed text("") @@ -202,10 +203,14 @@ void output_thread_fpu_defines(void) offset("#define THREAD_FCR31 ", struct task_struct, thread.fpu.hard.fcr31); + linefeed; } void output_mm_defines(void) { + text("/* Size of struct page */"); + size("#define STRUCT_PAGE_SIZE ", struct page); + linefeed; text("/* Linux mm_struct offsets. */"); offset("#define MM_USERS ", struct mm_struct, mm_users); offset("#define MM_PGD ", struct mm_struct, pgd); @@ -214,8 +219,16 @@ void output_mm_defines(void) constant("#define _PAGE_SIZE ", PAGE_SIZE); constant("#define _PAGE_SHIFT ", PAGE_SHIFT); linefeed; - constant("#define _PGDIR_SHIFT ", PGDIR_SHIFT); + constant("#define _PGD_T_SIZE ", sizeof(pgd_t)); + constant("#define _PMD_T_SIZE ", sizeof(pmd_t)); + constant("#define _PTE_T_SIZE ", sizeof(pte_t)); + linefeed; + constant("#define _PGD_T_LOG2 ", PGD_T_LOG2); + constant("#define _PMD_T_LOG2 ", PMD_T_LOG2); + constant("#define _PTE_T_LOG2 ", PTE_T_LOG2); + linefeed; constant("#define _PMD_SHIFT ", PMD_SHIFT); + constant("#define _PGDIR_SHIFT ", PGDIR_SHIFT); linefeed; constant("#define _PGD_ORDER ", PGD_ORDER); constant("#define _PMD_ORDER ", PMD_ORDER); @@ -223,6 +236,7 @@ void output_mm_defines(void) linefeed; constant("#define _PTRS_PER_PGD ", PTRS_PER_PGD); constant("#define _PTRS_PER_PMD ", PTRS_PER_PMD); + constant("#define _PTRS_PER_PTE ", PTRS_PER_PTE); linefeed; } --- diff/arch/mips/kernel/proc.c 2003-08-26 10:00:52.000000000 +0100 +++ source/arch/mips/kernel/proc.c 2004-02-23 13:56:38.000000000 +0000 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,7 @@ static const char *cpu_name[] = { [CPU_R6000A] "R6000A", [CPU_R8000] "R8000", [CPU_R10000] "R10000", + [CPU_R12000] "R12000", [CPU_R4300] "R4300", [CPU_R4650] "R4650", [CPU_R4700] "R4700", @@ -47,6 +49,7 @@ static const char *cpu_name[] = { [CPU_R4640] "R4640", [CPU_NEVADA] "Nevada", [CPU_RM7000] "RM7000", + [CPU_RM9000] "RM9000", [CPU_R5432] "R5432", [CPU_4KC] "MIPS 4Kc", [CPU_5KC] "MIPS 5Kc", @@ -63,10 +66,13 @@ static const char *cpu_name[] = { [CPU_R5500] "R5500", [CPU_TX49XX] "TX49xx", [CPU_20KC] "MIPS 20Kc", + [CPU_24K] "MIPS 24K", + [CPU_25KF] "MIPS 25Kf", [CPU_VR4111] "NEC VR4111", [CPU_VR4121] "NEC VR4121", [CPU_VR4122] "NEC VR4122", [CPU_VR4131] "NEC VR4131", + [CPU_VR4133] "NEC VR4133", [CPU_VR4181] "NEC VR4181", [CPU_VR4181A] "NEC VR4181A", [CPU_SR71000] "Sandcraft SR71000" --- diff/arch/mips/kernel/process.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/process.c 2004-02-23 13:56:38.000000000 +0000 @@ -6,7 +6,9 @@ * Copyright (C) 1994 - 1999, 2000 by Ralf Baechle and others. * Copyright (C) 1999, 2000 Silicon Graphics, Inc. */ +#include #include +#include #include #include #include @@ -246,7 +248,8 @@ static int __init get_frame_info(struct return 0; } -void __init frame_info_init(void) + +static int __init frame_info_init(void) { mips_frame_info_initialized = !get_frame_info(&schedule_frame, schedule) && @@ -254,8 +257,12 @@ void __init frame_info_init(void) !get_frame_info(&sleep_on_frame, sleep_on) && !get_frame_info(&sleep_on_timeout_frame, sleep_on_timeout) && !get_frame_info(&wait_for_completion_frame, wait_for_completion); + + return 0; } +arch_initcall(frame_info_init); + /* * Return saved PC of a blocked thread. */ @@ -341,3 +348,5 @@ out: return pc; } + +EXPORT_SYMBOL(get_wchan); --- diff/arch/mips/kernel/ptrace.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/ptrace.c 2004-02-23 13:56:38.000000000 +0000 @@ -108,7 +108,7 @@ asmlinkage int sys_ptrace(long request, /* Read the word at location addr in the USER area. */ case PTRACE_PEEKUSR: { struct pt_regs *regs; - unsigned long tmp; + unsigned long tmp = 0; regs = (struct pt_regs *) ((unsigned long) child->thread_info + THREAD_SIZE - 32 - sizeof(struct pt_regs)); @@ -312,13 +312,9 @@ asmlinkage void do_syscall_trace(void) /* The 0x80 provides a way for the tracing parent to distinguish between a syscall stop and SIGTRAP delivery */ - current->exit_code = SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) - ? 0x80 : 0); - preempt_disable(); - current->state = TASK_STOPPED; - notify_parent(current, SIGCHLD); - schedule(); - preempt_enable(); + ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) ? + 0x80 : 0)); + /* * this isn't the same as continuing with a signal, but it will do * for normal use. strace only continues with a signal if the --- diff/arch/mips/kernel/ptrace32.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/kernel/ptrace32.c 2004-02-23 13:56:38.000000000 +0000 @@ -14,7 +14,6 @@ * At this time Linux/MIPS64 only supports syscall tracing, even for 32-bit * binaries. */ -#include #include #include #include --- diff/arch/mips/kernel/r2300_switch.S 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/r2300_switch.S 2004-02-23 13:56:38.000000000 +0000 @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -31,7 +30,7 @@ * Offset to the current process status flags, the first 32 bytes of the * stack are not used. */ -#define ST_OFF (THREAD_SIZE - 32 - PT_SIZE + PT_STATUS) +#define ST_OFF (_THREAD_SIZE - 32 - PT_SIZE + PT_STATUS) /* * FPU context is saved iff the process has used it's FPU in the current @@ -87,7 +86,7 @@ LEAF(resume) move $28, a2 cpu_restore_nonscratch a1 - addiu t1, $28, THREAD_SIZE-32 + addiu t1, $28, _THREAD_SIZE - 32 sw t1, kernelsp mfc0 t1, CP0_STATUS /* Do we really need this? */ --- diff/arch/mips/kernel/r4k_fpu.S 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/r4k_fpu.S 2004-02-23 13:56:38.000000000 +0000 @@ -12,6 +12,7 @@ * Copyright (C) 2000 MIPS Technologies, Inc. * Copyright (C) 1999, 2001 Silicon Graphics, Inc. */ +#include #include #include #include --- diff/arch/mips/kernel/r4k_switch.S 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/r4k_switch.S 2004-02-23 13:56:38.000000000 +0000 @@ -18,15 +18,12 @@ #include #include #include -#include #include #include #include #include - .set mips3 - /* * Offset to the current process status flags, the first 32 bytes of the * stack are not used. @@ -196,7 +193,42 @@ LEAF(_init_fpu) dmtc1 t1, $f31 1: #endif - + +#ifdef CONFIG_CPU_MIPS32 + mtc1 t1, $f0 + mtc1 t1, $f1 + mtc1 t1, $f2 + mtc1 t1, $f3 + mtc1 t1, $f4 + mtc1 t1, $f5 + mtc1 t1, $f6 + mtc1 t1, $f7 + mtc1 t1, $f8 + mtc1 t1, $f9 + mtc1 t1, $f10 + mtc1 t1, $f11 + mtc1 t1, $f12 + mtc1 t1, $f13 + mtc1 t1, $f14 + mtc1 t1, $f15 + mtc1 t1, $f16 + mtc1 t1, $f17 + mtc1 t1, $f18 + mtc1 t1, $f19 + mtc1 t1, $f20 + mtc1 t1, $f21 + mtc1 t1, $f22 + mtc1 t1, $f23 + mtc1 t1, $f24 + mtc1 t1, $f25 + mtc1 t1, $f26 + mtc1 t1, $f27 + mtc1 t1, $f28 + mtc1 t1, $f29 + mtc1 t1, $f30 + mtc1 t1, $f31 +#else + .set mips3 dmtc1 t1, $f0 dmtc1 t1, $f2 dmtc1 t1, $f4 @@ -213,5 +245,6 @@ LEAF(_init_fpu) dmtc1 t1, $f26 dmtc1 t1, $f28 dmtc1 t1, $f30 +#endif jr ra END(_init_fpu) --- diff/arch/mips/kernel/scall32-o32.S 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/kernel/scall32-o32.S 2004-02-23 13:56:38.000000000 +0000 @@ -72,14 +72,12 @@ EXPORT(o32_syscall_exit) LONG_L a2, TI_FLAGS($28) # current->work li t0, _TIF_ALLWORK_MASK and t0, a2, t0 - bnez a2, o32_syscall_exit_work + bnez t0, o32_syscall_exit_work - RESTORE_SOME - RESTORE_SP_AND_RET + j restore_partial o32_syscall_exit_work: - SAVE_STATIC - j syscall_exit_work + j syscall_exit_work_partial /* ------------------------------------------------------------------------ */ @@ -124,7 +122,7 @@ stackargs: bltz t0, bad_stack # -> sp is bad lw t0, PT_R29(sp) # get old user stack pointer - PTR_LA t1, 3f # copy 1 to 2 arguments + PTR_LA t1, 4f # copy 1 to 3 arguments sll t3, t3, 4 subu t1, t3 jr t1 @@ -139,21 +137,26 @@ stackargs: .set push .set noreorder .set nomacro -1: lw t1, 20(t0) # argument #6 from usp +1: lw t1, 24(t0) # argument #7 from usp + nop + sw t1, 24(sp) + nop +2: lw t1, 20(t0) # argument #5 from usp nop sw t1, 20(sp) nop -2: lw t1, 16(t0) # argument #5 from usp +3: lw t1, 16(t0) # argument #5 from usp nop sw t1, 16(sp) nop -3: .set pop +4: .set pop j stack_done # go back .section __ex_table,"a" PTR 1b,bad_stack PTR 2b,bad_stack + PTR 3b,bad_stack .previous /* @@ -225,8 +228,8 @@ illegal_syscall: .previous #endif + sw zero, PT_R7(sp) # success sw v0, PT_R2(sp) # result -1: /* Success, so skip usual error handling garbage. */ LONG_L a2, TI_FLAGS($28) # syscall tracing enabled? @@ -597,7 +600,7 @@ out: jr ra sys sys_remap_file_pages 5 sys sys_set_tid_address 1 sys sys_restart_syscall 0 - sys sys_fadvise64 6 + sys sys_fadvise64_64 7 sys sys_statfs64 3 /* 4255 */ sys sys_fstatfs64 2 sys sys_timer_create 3 --- diff/arch/mips/kernel/scall64-64.S 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/kernel/scall64-64.S 2004-02-23 13:56:38.000000000 +0000 @@ -71,21 +71,14 @@ syscall_exit: # signals dont change between # sampling and return LONG_L a2, TI_FLAGS($28) # current->work - bnez a2, n64_syscall_exit_work - - j restore_all + li t0, _TIF_ALLWORK_MASK + and t0, a2, t0 + bnez t0, n64_syscall_exit_work -work_notifysig: # deal with pending signals and - # notify-resume requests - SAVE_STATIC - move a0, sp - li a1, 0 - jal do_notify_resume # a2 already loaded - RESTORE_STATIC - j restore_all + j restore_partial n64_syscall_exit_work: - j syscall_exit_work + j syscall_exit_work_partial /* ------------------------------------------------------------------------ */ @@ -167,8 +160,8 @@ illegal_syscall: .previous #endif - sw v0, PT_R2(sp) # result -1: + sd zero, PT_R7(sp) # success + sd v0, PT_R2(sp) # result /* Success, so skip usual error handling garbage. */ LONG_L a2, TI_FLAGS($28) # syscall tracing enabled? @@ -221,7 +214,7 @@ sys_call_table: PTR sys_newlstat PTR sys_poll PTR sys_lseek - PTR sys_mmap2 + PTR old_mmap PTR sys_mprotect /* 5010 */ PTR sys_munmap PTR sys_brk @@ -405,7 +398,7 @@ sys_call_table: PTR sys_lremovexattr /* 5190 */ PTR sys_fremovexattr PTR sys_tkill - PTR sys_time + PTR sys_ni_syscall PTR sys_futex PTR sys_sched_setaffinity /* 5195 */ PTR sys_sched_getaffinity @@ -427,7 +420,7 @@ sys_call_table: PTR sys_set_tid_address PTR sys_restart_syscall PTR sys_semtimedop - PTR sys_fadvise64 /* 5215 */ + PTR sys_fadvise64_64 /* 5215 */ PTR sys_timer_create PTR sys_timer_settime PTR sys_timer_gettime --- diff/arch/mips/kernel/scall64-n32.S 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/kernel/scall64-n32.S 2004-02-23 13:56:38.000000000 +0000 @@ -14,6 +14,7 @@ #include #include #include +#include #include /* This duplicates the definition from */ @@ -67,14 +68,14 @@ FEXPORT(n32_syscall_exit) # signals dont change between # sampling and return LONG_L a2, TI_FLAGS($28) # current->work - bnez a2, n32_syscall_exit_work + li t0, _TIF_ALLWORK_MASK + and t0, a2, t0 + bnez t0, n32_syscall_exit_work - RESTORE_SOME - RESTORE_SP_AND_RET + j restore_partial n32_syscall_exit_work: - SAVE_STATIC - j syscall_exit_work + j syscall_exit_work_partial /* ------------------------------------------------------------------------ */ @@ -118,7 +119,7 @@ EXPORT(sysn32_call_table) PTR sys_newlstat PTR sys_poll PTR sys_lseek - PTR sys_mmap2 + PTR old_mmap PTR sys_mprotect /* 6010 */ PTR sys_munmap PTR sys_brk @@ -302,10 +303,10 @@ EXPORT(sysn32_call_table) PTR sys_lremovexattr /* 6190 */ PTR sys_fremovexattr PTR sys_tkill - PTR sys_time + PTR sys_ni_syscall PTR compat_sys_futex - PTR sys32_sched_setaffinity /* 6195 */ - PTR sys32_sched_getaffinity + PTR compat_sys_sched_setaffinity /* 6195 */ + PTR compat_sys_sched_getaffinity PTR sys_cacheflush PTR sys_cachectl PTR sys_sysmips @@ -325,7 +326,7 @@ EXPORT(sysn32_call_table) PTR sys_set_tid_address PTR sys_restart_syscall PTR sys_semtimedop /* 6215 */ - PTR sys_fadvise64 + PTR sys_fadvise64_64 PTR sys_statfs64 PTR sys_fstatfs64 PTR sys_sendfile64 --- diff/arch/mips/kernel/scall64-o32.S 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/kernel/scall64-o32.S 2004-02-23 13:56:38.000000000 +0000 @@ -12,12 +12,14 @@ * to ABI64 calling convention. 64-bit syscalls are also processed * here for now. */ +#include #include #include #include #include #include #include +#include #include #include @@ -76,14 +78,14 @@ FEXPORT(o32_syscall_exit) # signals dont change between # sampling and return LONG_L a2, TI_FLAGS($28) - bnez a2, o32_syscall_exit_work + li t0, _TIF_ALLWORK_MASK + and t0, a2, t0 + bnez t0, o32_syscall_exit_work - RESTORE_SOME - RESTORE_SP_AND_RET + j restore_partial o32_syscall_exit_work: - SAVE_STATIC - j syscall_exit_work + j syscall_exit_work_partial /* ------------------------------------------------------------------------ */ @@ -315,7 +317,7 @@ out: jr ra sys sys_olduname 1 sys sys_umask 1 /* 4060 */ sys sys_chroot 1 - sys sys_ustat 2 + sys sys32_ustat 2 sys sys_dup2 2 sys sys_getppid 0 sys sys_getpgrp 0 /* 4065 */ @@ -355,7 +357,7 @@ out: jr ra sys compat_sys_statfs 2 sys compat_sys_fstatfs 2 /* 4100 */ sys sys_ni_syscall 0 /* sys_ioperm */ - sys sys_socketcall 2 + sys sys32_socketcall 2 sys sys_syslog 3 sys compat_sys_setitimer 3 sys compat_sys_getitimer 2 /* 4105 */ @@ -492,8 +494,8 @@ out: jr ra sys sys_tkill 2 sys sys_sendfile64 5 sys compat_sys_futex 5 - sys sys32_sched_setaffinity 3 - sys sys32_sched_getaffinity 3 /* 4240 */ + sys compat_sys_sched_setaffinity 3 + sys compat_sys_sched_getaffinity 3 /* 4240 */ sys sys_io_setup 2 sys sys_io_destroy 1 sys sys_io_getevents 5 @@ -507,7 +509,7 @@ out: jr ra sys sys_remap_file_pages 5 sys sys_set_tid_address 1 sys sys_restart_syscall 0 - sys sys_fadvise64 6 + sys sys_fadvise64_64 7 sys sys_statfs64 3 /* 4255 */ sys sys_fstatfs64 2 sys sys_timer_create 3 --- diff/arch/mips/kernel/semaphore.c 2002-10-16 04:28:26.000000000 +0100 +++ source/arch/mips/kernel/semaphore.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,129 +1,272 @@ /* - * Generic semaphore code. Buyer beware. Do your own - * specific changes in + * Copyright (C) 1999, 2001, 02, 03 Ralf Baechle + * + * Heavily inspired by the Alpha implementation */ - +#include +#include +#include #include -#include + +#ifdef CONFIG_CPU_HAS_LLDSCD +/* + * On machines without lld/scd we need a spinlock to make the manipulation of + * sem->count and sem->waking atomic. Scalability isn't an issue because + * this lock is used on UP only so it's just an empty variable. + */ +spinlock_t semaphore_lock = SPIN_LOCK_UNLOCKED; + +EXPORT_SYMBOL(semaphore_lock); +#endif /* - * Semaphores are implemented using a two-way counter: - * The "count" variable is decremented for each process - * that tries to sleep, while the "waking" variable is - * incremented when the "up()" code goes to wake up waiting - * processes. - * - * Notably, the inline "up()" and "down()" functions can - * efficiently test if they need to do any extra work (up - * needs to do something only if count was negative before - * the increment operation. - * - * waking_non_zero() (from asm/semaphore.h) must execute - * atomically. - * - * When __up() is called, the count was negative before - * incrementing it, and we need to wake up somebody. - * - * This routine adds one to the count of processes that need to - * wake up and exit. ALL waiting processes actually wake up but - * only the one that gets to the "waking" field first will gate - * through and acquire the semaphore. The others will go back - * to sleep. - * - * Note that these functions are only called when there is - * contention on the lock, and as such all this is the - * "non-critical" part of the whole semaphore business. The - * critical part is the inline stuff in - * where we want to avoid any extra jumps and calls. + * Semaphores are implemented using a two-way counter: The "count" variable is + * decremented for each process that tries to sleep, while the "waking" variable + * is incremented when the "up()" code goes to wake up waiting processes. + * + * Notably, the inline "up()" and "down()" functions can efficiently test if + * they need to do any extra work (up needs to do something only if count was + * negative before the increment operation. + * + * waking_non_zero() must execute atomically. + * + * When __up() is called, the count was negative before incrementing it, and we + * need to wake up somebody. + * + * This routine adds one to the count of processes that need to wake up and + * exit. ALL waiting processes actually wake up but only the one that gets to + * the "waking" field first will gate through and acquire the semaphore. The + * others will go back to sleep. + * + * Note that these functions are only called when there is contention on the + * lock, and as such all this is the "non-critical" part of the whole semaphore + * business. The critical part is the inline stuff in where + * we want to avoid any extra jumps and calls. */ -void __up(struct semaphore *sem) +void __up_wakeup(struct semaphore *sem) { - wake_one_more(sem); wake_up(&sem->wait); } +EXPORT_SYMBOL(__up_wakeup); + +#ifdef CONFIG_CPU_HAS_LLSC + +static inline int waking_non_zero(struct semaphore *sem) +{ + int ret, tmp; + + __asm__ __volatile__( + "1: ll %1, %2 # waking_non_zero \n" + " blez %1, 2f \n" + " subu %0, %1, 1 \n" + " sc %0, %2 \n" + " beqz %0, 1b \n" + "2: \n" + : "=r" (ret), "=r" (tmp), "+m" (sem->waking) + : "0" (0)); + + return ret; +} + +#else /* !CONFIG_CPU_HAS_LLSC */ + +static inline int waking_non_zero(struct semaphore *sem) +{ + unsigned long flags; + int waking, ret = 0; + + spin_lock_irqsave(&semaphore_lock, flags); + waking = atomic_read(&sem->waking); + if (waking > 0) { + atomic_set(&sem->waking, waking - 1); + ret = 1; + } + spin_unlock_irqrestore(&semaphore_lock, flags); + + return ret; +} + +#endif /* !CONFIG_CPU_HAS_LLSC */ + /* - * Perform the "down" function. Return zero for semaphore acquired, - * return negative for signalled out of the function. + * Perform the "down" function. Return zero for semaphore acquired, return + * negative for signalled out of the function. * - * If called from __down, the return is ignored and the wait loop is - * not interruptible. This means that a task waiting on a semaphore - * using "down()" cannot be killed until someone does an "up()" on - * the semaphore. - * - * If called from __down_interruptible, the return value gets checked - * upon return. If the return value is negative then the task continues - * with the negative value in the return register (it can be tested by - * the caller). + * If called from down, the return is ignored and the wait loop is not + * interruptible. This means that a task waiting on a semaphore using "down()" + * cannot be killed until someone does an "up()" on the semaphore. * - * Either form may be used in conjunction with "up()". + * If called from down_interruptible, the return value gets checked upon return. + * If the return value is negative then the task continues with the negative + * value in the return register (it can be tested by the caller). * + * Either form may be used in conjunction with "up()". */ -#define DOWN_VAR \ - struct task_struct *tsk = current; \ - wait_queue_t wait; \ +void __down_failed(struct semaphore * sem) +{ + struct task_struct *tsk = current; + wait_queue_t wait; + init_waitqueue_entry(&wait, tsk); + __set_current_state(TASK_UNINTERRUPTIBLE); + add_wait_queue_exclusive(&sem->wait, &wait); -#define DOWN_HEAD(task_state) \ - \ - \ - tsk->state = (task_state); \ - add_wait_queue(&sem->wait, &wait); \ - \ - /* \ - * Ok, we're set up. sem->count is known to be less than zero \ - * so we must wait. \ - * \ - * We can let go the lock for purposes of waiting. \ - * We re-acquire it after awaking so as to protect \ - * all semaphore operations. \ - * \ - * If "up()" is called before we call waking_non_zero() then \ - * we will catch it right away. If it is called later then \ - * we will have to go through a wakeup cycle to catch it. \ - * \ - * Multiple waiters contend for the semaphore lock to see \ - * who gets to gate through and who has to wait some more. \ - */ \ + /* + * Ok, we're set up. sem->count is known to be less than zero + * so we must wait. + * + * We can let go the lock for purposes of waiting. + * We re-acquire it after awaking so as to protect + * all semaphore operations. + * + * If "up()" is called before we call waking_non_zero() then + * we will catch it right away. If it is called later then + * we will have to go through a wakeup cycle to catch it. + * + * Multiple waiters contend for the semaphore lock to see + * who gets to gate through and who has to wait some more. + */ for (;;) { - -#define DOWN_TAIL(task_state) \ - tsk->state = (task_state); \ - } \ - tsk->state = TASK_RUNNING; \ + if (waking_non_zero(sem)) + break; + schedule(); + __set_current_state(TASK_UNINTERRUPTIBLE); + } + __set_current_state(TASK_RUNNING); remove_wait_queue(&sem->wait, &wait); +} + +EXPORT_SYMBOL(__down_failed); + +#ifdef CONFIG_CPU_HAS_LLDSCD + +/* + * waking_non_zero_interruptible: + * 1 got the lock + * 0 go to sleep + * -EINTR interrupted + * + * We must undo the sem->count down_interruptible decrement + * simultaneously and atomically with the sem->waking adjustment, + * otherwise we can race with wake_one_more. + * + * This is accomplished by doing a 64-bit lld/scd on the 2 32-bit words. + * + * This is crazy. Normally it's strictly forbidden to use 64-bit operations + * in the 32-bit MIPS kernel. In this case it's however ok because if an + * interrupt has destroyed the upper half of registers sc will fail. + * Note also that this will not work for MIPS32 CPUs! + * + * Pseudocode: + * + * If(sem->waking > 0) { + * Decrement(sem->waking) + * Return(SUCCESS) + * } else If(signal_pending(tsk)) { + * Increment(sem->count) + * Return(-EINTR) + * } else { + * Return(SLEEP) + * } + */ -void __down(struct semaphore * sem) +static inline int +waking_non_zero_interruptible(struct semaphore *sem, struct task_struct *tsk) { - DOWN_VAR - DOWN_HEAD(TASK_UNINTERRUPTIBLE) - if (waking_non_zero(sem)) - break; - schedule(); - DOWN_TAIL(TASK_UNINTERRUPTIBLE) + long ret, tmp; + + __asm__ __volatile__( + " .set push # waking_non_zero_interruptible \n" + " .set mips3 \n" + " .set noat \n" + "0: lld %1, %2 \n" + " li %0, 0 \n" + " sll $1, %1, 0 \n" + " blez $1, 1f \n" + " daddiu %1, %1, -1 \n" + " li %0, 1 \n" + " b 2f \n" + "1: beqz %3, 2f \n" + " li %0, %4 \n" + " dli $1, 0x0000000100000000 \n" + " daddu %1, %1, $1 \n" + "2: scd %1, %2 \n" + " beqz %1, 0b \n" + " .set pop \n" + : "=&r" (ret), "=&r" (tmp), "=m" (*sem) + : "r" (signal_pending(tsk)), "i" (-EINTR)); + + return ret; } -int __down_interruptible(struct semaphore * sem) +#else /* !CONFIG_CPU_HAS_LLDSCD */ + +static inline int waking_non_zero_interruptible(struct semaphore *sem, + struct task_struct *tsk) { - int ret = 0; - DOWN_VAR - DOWN_HEAD(TASK_INTERRUPTIBLE) + int waking, pending, ret = 0; + unsigned long flags; - ret = waking_non_zero_interruptible(sem, tsk); - if (ret) - { - if (ret == 1) - /* ret != 0 only if we get interrupted -arca */ - ret = 0; - break; + pending = signal_pending(tsk); + + spin_lock_irqsave(&semaphore_lock, flags); + waking = atomic_read(&sem->waking); + if (waking > 0) { + atomic_set(&sem->waking, waking - 1); + ret = 1; + } else if (pending) { + atomic_set(&sem->count, atomic_read(&sem->count) + 1); + ret = -EINTR; } - schedule(); - DOWN_TAIL(TASK_INTERRUPTIBLE) + spin_unlock_irqrestore(&semaphore_lock, flags); + return ret; } -int __down_trylock(struct semaphore * sem) +#endif /* !CONFIG_CPU_HAS_LLDSCD */ + +int __down_failed_interruptible(struct semaphore * sem) { - return waking_non_zero_trylock(sem); + struct task_struct *tsk = current; + wait_queue_t wait; + int ret = 0; + + init_waitqueue_entry(&wait, tsk); + __set_current_state(TASK_INTERRUPTIBLE); + add_wait_queue_exclusive(&sem->wait, &wait); + + /* + * Ok, we're set up. sem->count is known to be less than zero + * so we must wait. + * + * We can let go the lock for purposes of waiting. + * We re-acquire it after awaking so as to protect + * all semaphore operations. + * + * If "up()" is called before we call waking_non_zero() then + * we will catch it right away. If it is called later then + * we will have to go through a wakeup cycle to catch it. + * + * Multiple waiters contend for the semaphore lock to see + * who gets to gate through and who has to wait some more. + */ + for (;;) { + ret = waking_non_zero_interruptible(sem, tsk); + if (ret) { + if (ret == 1) + /* ret != 0 only if we get interrupted -arca */ + ret = 0; + break; + } + schedule(); + __set_current_state(TASK_INTERRUPTIBLE); + } + __set_current_state(TASK_RUNNING); + remove_wait_queue(&sem->wait, &wait); + + return ret; } + +EXPORT_SYMBOL(__down_failed_interruptible); --- diff/arch/mips/kernel/setup.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/mips/kernel/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include @@ -40,25 +42,21 @@ struct cpuinfo_mips cpu_data[NR_CPUS]; +EXPORT_SYMBOL(cpu_data); + #ifdef CONFIG_VT struct screen_info screen_info; #endif -#if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_BLK_DEV_FD_MODULE) -extern struct fd_ops no_fd_ops; -struct fd_ops *fd_ops; -#endif +/* + * Despite it's name this variable is even if we don't have PCI + */ +unsigned int PCI_DMA_BUS_IS_PHYS; -#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) -extern struct ide_ops no_ide_ops; -struct ide_ops *ide_ops; -#endif +EXPORT_SYMBOL(PCI_DMA_BUS_IS_PHYS); extern void * __rd_start, * __rd_end; -extern struct rtc_ops no_rtc_ops; -struct rtc_ops *rtc_ops; - /* * Setup information * @@ -67,11 +65,14 @@ struct rtc_ops *rtc_ops; unsigned long mips_machtype = MACH_UNKNOWN; unsigned long mips_machgroup = MACH_GROUP_UNKNOWN; +EXPORT_SYMBOL(mips_machtype); +EXPORT_SYMBOL(mips_machgroup); + struct boot_mem_map boot_mem_map; static char command_line[CL_SIZE]; char saved_command_line[CL_SIZE]; -extern char arcs_cmdline[CL_SIZE]; + char arcs_cmdline[CL_SIZE]=CONFIG_CMDLINE; /* * mips_io_port_base is the begin of the address space to which x86 style @@ -87,53 +88,22 @@ EXPORT_SYMBOL(mips_io_port_base); unsigned long isa_slot_offset; EXPORT_SYMBOL(isa_slot_offset); -extern void SetUpBootInfo(void); -extern void load_mmu(void); -extern ATTRIB_NORET asmlinkage void start_kernel(void); -extern void prom_init(int, char **, char **, int *); - static struct resource code_resource = { "Kernel code" }; static struct resource data_resource = { "Kernel data" }; -asmlinkage void __init init_arch(int argc, char **argv, char **envp, - int *prom_vec) +void __init add_memory_region(phys_t start, phys_t size, long type) { - /* Determine which MIPS variant we are running on. */ - cpu_probe(); - - prom_init(argc, argv, envp, prom_vec); - - cpu_report(); - - /* - * Determine the mmu/cache attached to this machine, then flush the - * tlb and caches. On the r4xx0 variants this also sets CP0_WIRED to - * zero. - */ - load_mmu(); + int x = boot_mem_map.nr_map; + struct boot_mem_map_entry *prev = boot_mem_map.map + x - 1; -#ifdef CONFIG_MIPS32 - /* Disable coprocessors and set FPU for 16/32 FPR register model */ - clear_c0_status(ST0_CU1|ST0_CU2|ST0_CU3|ST0_KX|ST0_SX|ST0_FR); - set_c0_status(ST0_CU0); -#endif -#ifdef CONFIG_MIPS64 /* - * On IP27, I am seeing the TS bit set when the kernel is loaded. - * Maybe because the kernel is in ckseg0 and not xkphys? Clear it - * anyway ... + * Try to merge with previous entry if any. This is far less than + * perfect but is sufficient for most real world cases. */ - clear_c0_status(ST0_BEV|ST0_TS|ST0_CU1|ST0_CU2|ST0_CU3); - set_c0_status(ST0_CU0|ST0_KX|ST0_SX|ST0_FR); -#endif - - start_kernel(); -} - -void __init add_memory_region(phys_t start, phys_t size, - long type) -{ - int x = boot_mem_map.nr_map; + if (x && prev->addr + prev->size == start && prev->type == type) { + prev->size += size; + return; + } if (x == BOOT_MEM_MAP_MAX) { printk("Ooops! Too many entries in the memory map!\n"); @@ -149,11 +119,12 @@ void __init add_memory_region(phys_t sta static void __init print_memory_map(void) { int i; + const int field = 2 * sizeof(unsigned long); for (i = 0; i < boot_mem_map.nr_map; i++) { printk(" memory: %0*Lx @ %0*Lx ", - sizeof(long) * 2, (u64) boot_mem_map.map[i].size, - sizeof(long) * 2, (u64) boot_mem_map.map[i].addr); + field, (unsigned long long) boot_mem_map.map[i].size, + field, (unsigned long long) boot_mem_map.map[i].addr); switch (boot_mem_map.map[i].type) { case BOOT_MEM_RAM: @@ -233,15 +204,15 @@ static inline void parse_cmdline_early(v static inline void bootmem_init(void) { + unsigned long start_pfn; +#ifndef CONFIG_SGI_IP27 + unsigned long bootmap_size, max_low_pfn, first_usable_pfn; + int i; +#endif #ifdef CONFIG_BLK_DEV_INITRD unsigned long tmp; unsigned long *initrd_header; -#endif - unsigned long bootmap_size; - unsigned long start_pfn, max_low_pfn, first_usable_pfn; - int i; -#ifdef CONFIG_BLK_DEV_INITRD tmp = (((unsigned long)&_end + PAGE_SIZE-1) & PAGE_MASK) - 8; if (tmp < (unsigned long)&_end) tmp += PAGE_SIZE; @@ -385,8 +356,7 @@ static inline void bootmem_init(void) printk("Initial ramdisk at: 0x%p (%lu bytes)\n", (void *)initrd_start, initrd_size); -/* FIXME: is this right? */ -#ifndef CONFIG_SGI_IP27 + if (CPHYSADDR(initrd_end) > PFN_PHYS(max_low_pfn)) { printk("initrd extends beyond end of memory " "(0x%0*Lx > 0x%0*Lx)\ndisabling initrd\n", @@ -394,7 +364,6 @@ static inline void bootmem_init(void) sizeof(long) * 2, PFN_PHYS(max_low_pfn)); initrd_start = initrd_end = 0; } -#endif /* !CONFIG_SGI_IP27 */ } #endif /* CONFIG_BLK_DEV_INITRD */ } @@ -456,229 +425,63 @@ static inline void resource_init(void) #undef MAXMEM #undef MAXMEM_PFN -void __init setup_arch(char **cmdline_p) +static int __initdata earlyinit_debug; + +static int __init earlyinit_debug_setup(char *str) { - extern void atlas_setup(void); - extern void baget_setup(void); - extern void cobalt_setup(void); - extern void lasat_setup(void); - extern void ddb_setup(void); - extern void decstation_setup(void); - extern void deskstation_setup(void); - extern void jazz_setup(void); - extern void sni_rm200_pci_setup(void); - extern void ip22_setup(void); - extern void ip27_setup(void); - extern void ip32_setup(void); - extern void ev96100_setup(void); - extern void malta_setup(void); - extern void sead_setup(void); - extern void ikos_setup(void); - extern void momenco_ocelot_setup(void); - extern void momenco_ocelot_g_setup(void); - extern void momenco_ocelot_c_setup(void); - extern void nec_osprey_setup(void); - extern void nec_eagle_setup(void); - extern void zao_capcella_setup(void); - extern void victor_mpc30x_setup(void); - extern void ibm_workpad_setup(void); - extern void casio_e55_setup(void); - extern void jmr3927_setup(void); - extern void it8172_setup(void); - extern void swarm_setup(void); - extern void hp_setup(void); - extern void au1x00_setup(void); - extern void frame_info_init(void); + earlyinit_debug = 1; + return 1; +} +__setup("earlyinit_debug", earlyinit_debug_setup); - frame_info_init(); +extern initcall_t __earlyinitcall_start, __earlyinitcall_end; -#ifdef CONFIG_BLK_DEV_FD - fd_ops = &no_fd_ops; -#endif +static void __init do_earlyinitcalls(void) +{ + initcall_t *call, *start, *end; -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &no_ide_ops; -#endif + start = &__earlyinitcall_start; + end = &__earlyinitcall_end; - rtc_ops = &no_rtc_ops; + for (call = start; call < end; call++) { + if (earlyinit_debug) + printk("calling earlyinitcall 0x%p\n", *call); - switch (mips_machgroup) { -#ifdef CONFIG_BAGET_MIPS - case MACH_GROUP_BAGET: - baget_setup(); - break; -#endif -#ifdef CONFIG_MIPS_COBALT - case MACH_GROUP_COBALT: - cobalt_setup(); - break; -#endif -#ifdef CONFIG_DECSTATION - case MACH_GROUP_DEC: - decstation_setup(); - break; -#endif -#ifdef CONFIG_MIPS_ATLAS - case MACH_GROUP_UNKNOWN: - atlas_setup(); - break; -#endif -#ifdef CONFIG_MIPS_JAZZ - case MACH_GROUP_JAZZ: - jazz_setup(); - break; -#endif -#ifdef CONFIG_MIPS_MALTA - case MACH_GROUP_UNKNOWN: - malta_setup(); - break; -#endif -#ifdef CONFIG_MOMENCO_OCELOT - case MACH_GROUP_MOMENCO: - momenco_ocelot_setup(); - break; -#endif -#ifdef CONFIG_MOMENCO_OCELOT_G - case MACH_GROUP_MOMENCO: - momenco_ocelot_g_setup(); - break; -#endif -#ifdef CONFIG_MOMENCO_OCELOT_C - case MACH_GROUP_MOMENCO: - momenco_ocelot_c_setup(); - break; -#endif -#ifdef CONFIG_MIPS_SEAD - case MACH_GROUP_UNKNOWN: - sead_setup(); - break; -#endif -#ifdef CONFIG_SGI_IP22 - /* As of now this is only IP22. */ - case MACH_GROUP_SGI: - ip22_setup(); - break; -#endif -#ifdef CONFIG_SGI_IP27 - case MACH_GROUP_SGI: - ip27_setup(); - break; -#endif -#ifdef CONFIG_SGI_IP32 - case MACH_GROUP_SGI: - ip32_setup(); - break; -#endif -#ifdef CONFIG_SNI_RM200_PCI - case MACH_GROUP_SNI_RM: - sni_rm200_pci_setup(); - break; -#endif -#ifdef CONFIG_DDB5074 - case MACH_GROUP_NEC_DDB: - ddb_setup(); - break; -#endif -#ifdef CONFIG_DDB5476 - case MACH_GROUP_NEC_DDB: - ddb_setup(); - break; -#endif -#ifdef CONFIG_DDB5477 - case MACH_GROUP_NEC_DDB: - ddb_setup(); - break; -#endif -#ifdef CONFIG_CPU_VR41XX - case MACH_GROUP_NEC_VR41XX: - switch (mips_machtype) { -#ifdef CONFIG_NEC_OSPREY - case MACH_NEC_OSPREY: - nec_osprey_setup(); - break; -#endif -#ifdef CONFIG_NEC_EAGLE - case MACH_NEC_EAGLE: - nec_eagle_setup(); - break; -#endif -#ifdef CONFIG_ZAO_CAPCELLA - case MACH_ZAO_CAPCELLA: - zao_capcella_setup(); - break; -#endif -#ifdef CONFIG_VICTOR_MPC30X - case MACH_VICTOR_MPC30X: - victor_mpc30x_setup(); - break; -#endif -#ifdef CONFIG_IBM_WORKPAD - case MACH_IBM_WORKPAD: - ibm_workpad_setup(); - break; -#endif -#ifdef CONFIG_CASIO_E55 - case MACH_CASIO_E55: - casio_e55_setup(); - break; -#endif -#ifdef CONFIG_TANBAC_TB0229 - case MACH_TANBAC_TB0229: - tanbac_tb0229_setup(); - break; -#endif - } - break; -#endif -#ifdef CONFIG_MIPS_EV96100 - case MACH_GROUP_GALILEO: - ev96100_setup(); - break; -#endif -#ifdef CONFIG_MIPS_EV64120 - case MACH_GROUP_GALILEO: - ev64120_setup(); - break; -#endif -#if defined(CONFIG_MIPS_IVR) || defined(CONFIG_MIPS_ITE8172) - case MACH_GROUP_ITE: - case MACH_GROUP_GLOBESPAN: - it8172_setup(); - break; -#endif -#ifdef CONFIG_LASAT - case MACH_GROUP_LASAT: - lasat_setup(); - break; -#endif -#ifdef CONFIG_SOC_AU1X00 - case MACH_GROUP_ALCHEMY: - au1x00_setup(); - break; -#endif -#ifdef CONFIG_TOSHIBA_JMR3927 - case MACH_GROUP_TOSHIBA: - jmr3927_setup(); - break; + (*call)(); + } +} + +void __init setup_arch(char **cmdline_p) +{ + cpu_probe(); + prom_init(); + cpu_report(); + +#ifdef CONFIG_MIPS32 + /* Disable coprocessors and set FPU for 16/32 FPR register model */ + clear_c0_status(ST0_CU1|ST0_CU2|ST0_CU3|ST0_KX|ST0_SX|ST0_FR); + set_c0_status(ST0_CU0); #endif -#ifdef CONFIG_TOSHIBA_RBTX4927 - case MACH_GROUP_TOSHIBA: - tx4927_setup(); - break; +#ifdef CONFIG_MIPS64 + /* + * On IP27, I am seeing the TS bit set when the kernel is loaded. + * Maybe because the kernel is in ckseg0 and not xkphys? Clear it + * anyway ... + */ + clear_c0_status(ST0_BEV|ST0_TS|ST0_CU1|ST0_CU2|ST0_CU3); + set_c0_status(ST0_CU0|ST0_KX|ST0_SX|ST0_FR); #endif -#ifdef CONFIG_SIBYTE_BOARD - case MACH_GROUP_SIBYTE: - swarm_setup(); - break; + +#if defined(CONFIG_VT) +#if defined(CONFIG_VGA_CONSOLE) + conswitchp = &vga_con; +#elif defined(CONFIG_DUMMY_CONSOLE) + conswitchp = &dummy_con; #endif -#ifdef CONFIG_HP_LASERJET - case MACH_GROUP_HP_LJ: - hp_setup(); - break; #endif - default: - panic("Unsupported architecture"); - } + + /* call board setup routine */ + do_earlyinitcalls(); strlcpy(command_line, arcs_cmdline, sizeof(command_line)); strlcpy(saved_command_line, command_line, sizeof(saved_command_line)); @@ -686,11 +489,8 @@ void __init setup_arch(char **cmdline_p) *cmdline_p = command_line; parse_cmdline_early(); - bootmem_init(); - paging_init(); - resource_init(); } --- diff/arch/mips/kernel/signal.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/signal.c 2004-02-23 13:56:38.000000000 +0000 @@ -74,8 +74,6 @@ static_unused int _sys_rt_sigsuspend(nab sigset_t *unewset, saveset, newset; size_t sigsetsize; - save_static(®s); - /* XXX Don't preclude handling different sized sigset_t's. */ sigsetsize = regs.regs[5]; if (sigsetsize != sizeof(sigset_t)) @@ -156,6 +154,9 @@ asmlinkage int restore_sigcontext(struct { int err = 0; + /* Always make any pending restarted system calls return -EINTR */ + current_thread_info()->restart_block.fn = do_no_restart_syscall; + err |= __get_user(regs->cp0_epc, &sc->sc_pc); err |= __get_user(regs->hi, &sc->sc_mdhi); err |= __get_user(regs->lo, &sc->sc_mdlo); @@ -490,7 +491,6 @@ static inline void handle_signal(unsigne switch(regs->regs[0]) { case ERESTART_RESTARTBLOCK: - current_thread_info()->restart_block.fn = do_no_restart_syscall; case ERESTARTNOHAND: regs->regs[2] = EINTR; break; @@ -508,9 +508,9 @@ static inline void handle_signal(unsigne regs->regs[0] = 0; /* Don't deal with this again. */ #ifdef CONFIG_TRAD_SIGNALS - if (ka->sa.sa_flags & SA_SIGINFO) + if (ka->sa.sa_flags & SA_SIGINFO) { #else - if (1) + if (1) { #endif #ifdef CONFIG_MIPS32_N32 if ((current->thread.mflags & MF_ABI_MASK) == MF_N32) @@ -518,8 +518,11 @@ static inline void handle_signal(unsigne else #endif setup_rt_frame(ka, regs, sig, oldset, info); + } +#ifdef CONFIG_TRAD_SIGNALS else setup_frame(ka, regs, sig, oldset); +#endif if (ka->sa.sa_flags & SA_ONESHOT) ka->sa.sa_handler = SIG_DFL; @@ -569,6 +572,7 @@ asmlinkage int do_signal(sigset_t *oldse } if (regs->regs[2] == ERESTART_RESTARTBLOCK) { regs->regs[2] = __NR_restart_syscall; + regs->regs[7] = regs->regs[26]; regs->cp0_epc -= 4; } } --- diff/arch/mips/kernel/signal32.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/kernel/signal32.c 2004-02-23 13:56:38.000000000 +0000 @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,7 @@ #include /* - * Including would give use the 64-bit syscall numbers ... */ #define __NR_O32_sigreturn 4119 #define __NR_O32_rt_sigreturn 4193 @@ -126,12 +127,12 @@ static inline int get_sigset(sigset_t *k /* * Atomically swap in the new signal mask, and wait for a signal. */ -asmlinkage inline int sys32_sigsuspend(nabi_no_regargs struct pt_regs regs) +save_static_function(sys32_sigsuspend); +static_unused int _sys32_sigsuspend(nabi_no_regargs struct pt_regs regs) { compat_sigset_t *uset; sigset_t newset, saveset; - save_static(®s); uset = (compat_sigset_t *) regs.regs[4]; if (get_sigset(&newset, uset)) return -EFAULT; @@ -153,13 +154,13 @@ asmlinkage inline int sys32_sigsuspend(n } } -asmlinkage int sys32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs) +save_static_function(sys32_rt_sigsuspend); +static_unused int _sys32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs) { compat_sigset_t *uset; sigset_t newset, saveset; size_t sigsetsize; - save_static(®s); /* XXX Don't preclude handling different sized sigset_t's. */ sigsetsize = regs.regs[5]; if (sigsetsize != sizeof(compat_sigset_t)) @@ -241,7 +242,7 @@ asmlinkage int sys32_sigaltstack(nabi_no if (!access_ok(VERIFY_READ, uss, sizeof(*uss))) return -EFAULT; err |= __get_user(sp, &uss->ss_sp); - kss.ss_size = (long) sp; + kss.ss_sp = (void *) (long) sp; err |= __get_user(kss.ss_size, &uss->ss_size); err |= __get_user(kss.ss_flags, &uss->ss_flags); if (err) @@ -270,6 +271,9 @@ static asmlinkage int restore_sigcontext { int err = 0; + /* Always make any pending restarted system calls return -EINTR */ + current_thread_info()->restart_block.fn = do_no_restart_syscall; + err |= __get_user(regs->cp0_epc, &sc->sc_pc); err |= __get_user(regs->hi, &sc->sc_mdhi); err |= __get_user(regs->lo, &sc->sc_mdlo); @@ -651,7 +655,6 @@ static inline void handle_signal(unsigne switch (regs->regs[0]) { case ERESTART_RESTARTBLOCK: - current_thread_info()->restart_block.fn = do_no_restart_syscall; case ERESTARTNOHAND: regs->regs[2] = EINTR; break; @@ -712,6 +715,7 @@ asmlinkage int do_signal32(sigset_t *old } if (regs->regs[2] == ERESTART_RESTARTBLOCK) { regs->regs[2] = __NR_O32_restart_syscall; + regs->regs[7] = regs->regs[26]; regs->cp0_epc -= 4; } } @@ -761,9 +765,6 @@ out: return ret; } -asmlinkage long sys_rt_sigprocmask(int how, sigset_t *set, sigset_t *oset, - size_t sigsetsize); - asmlinkage int sys32_rt_sigprocmask(int how, compat_sigset_t *set, compat_sigset_t *oset, unsigned int sigsetsize) { @@ -785,8 +786,6 @@ asmlinkage int sys32_rt_sigprocmask(int return ret; } -asmlinkage long sys_rt_sigpending(sigset_t *set, size_t sigsetsize); - asmlinkage int sys32_rt_sigpending(compat_sigset_t *uset, unsigned int sigsetsize) { @@ -895,8 +894,6 @@ asmlinkage int sys32_rt_sigtimedwait(com return ret; } -extern asmlinkage int sys_rt_sigqueueinfo(int pid, int sig, siginfo_t *uinfo); - asmlinkage int sys32_rt_sigqueueinfo(int pid, int sig, siginfo_t32 *uinfo) { siginfo_t info; --- diff/arch/mips/kernel/signal_n32.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/kernel/signal_n32.c 2004-02-23 13:56:38.000000000 +0000 @@ -15,8 +15,6 @@ * 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 --- diff/arch/mips/kernel/smp.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/mips/kernel/smp.c 2004-02-23 13:56:38.000000000 +0000 @@ -16,7 +16,7 @@ * Copyright (C) 2000, 2001 Kanoj Sarcar * Copyright (C) 2000, 2001 Ralf Baechle * Copyright (C) 2000, 2001 Silicon Graphics, Inc. - * Copyright (C) 2000, 2001 Broadcom Corporation + * Copyright (C) 2000, 2001, 2003 Broadcom Corporation */ #include #include @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -38,45 +39,18 @@ #include #include -int smp_threads_ready; /* Not used */ - -// static atomic_t cpus_booted = ATOMIC_INIT(0); -atomic_t cpus_booted = ATOMIC_INIT(0); - -cpumask_t phys_cpu_present_map; /* Bitmask of physically CPUs */ +cpumask_t phys_cpu_present_map; /* Bitmask of available CPUs */ +volatile cpumask_t cpu_callin_map; /* Bitmask of started secondaries */ cpumask_t cpu_online_map; /* Bitmask of currently online CPUs */ -int __cpu_number_map[NR_CPUS]; -int __cpu_logical_map[NR_CPUS]; +int __cpu_number_map[NR_CPUS]; /* Map physical to logical */ +int __cpu_logical_map[NR_CPUS]; /* Map logical to physical */ EXPORT_SYMBOL(cpu_online_map); -/* These are defined by the board-specific code. */ - -/* - * Cause the function described by call_data to be executed on the passed - * cpu. When the function has finished, increment the finished field of - * call_data. - */ -void core_send_ipi(int cpu, unsigned int action); - -/* - * Clear all undefined state in the cpu, set up sp and gp to the passed - * values, and kick the cpu into smp_bootstrap(); - */ -void prom_boot_secondary(int cpu, unsigned long sp, unsigned long gp); - -/* - * After we've done initial boot, this function is called to allow the - * board code to clean up state, if needed - */ -void prom_init_secondary(void); - -void prom_smp_finish(void); - cycles_t cacheflush_time; unsigned long cache_decay_ticks; -void smp_tune_scheduling (void) +static void smp_tune_scheduling (void) { struct cache_desc *cd = ¤t_cpu_data.scache; unsigned long cachesize; /* kB */ @@ -119,49 +93,34 @@ void smp_tune_scheduling (void) (cache_decay_ticks + 1) * 1000 / HZ); } -void __init smp_callin(void) -{ -#if 0 - calibrate_delay(); - smp_store_cpu_info(cpuid); -#endif -} +extern void __init calibrate_delay(void); -#ifndef CONFIG_SGI_IP27 /* - * Hook for doing final board-specific setup after the generic smp setup - * is done + * First C code run on the secondary CPUs after being started up by + * the master. */ asmlinkage void start_secondary(void) { unsigned int cpu = smp_processor_id(); cpu_probe(); - prom_init_secondary(); + cpu_report(); per_cpu_trap_init(); + prom_init_secondary(); /* * XXX parity protection should be folded in here when it's converted * to an option instead of something based on .cputype */ - pgd_current[cpu] = init_mm.pgd; + + calibrate_delay(); cpu_data[cpu].udelay_val = loops_per_jiffy; + prom_smp_finish(); - printk("Slave cpu booted successfully\n"); - cpu_set(cpu, cpu_online_map); - atomic_inc(&cpus_booted); - cpu_idle(); -} -#endif /* CONFIG_SGI_IP27 */ -/* - * this function sends a 'reschedule' IPI to another CPU. - * it goes straight through and wastes no time serializing - * anything. Worst case is that we lose a reschedule ... - */ -void smp_send_reschedule(int cpu) -{ - core_send_ipi(cpu, SMP_RESCHEDULE_YOURSELF); + cpu_set(cpu, cpu_callin_map); + + cpu_idle(); } spinlock_t smp_call_lock = SPIN_LOCK_UNLOCKED; @@ -201,10 +160,11 @@ int smp_call_function (void (*func) (voi spin_lock(&smp_call_lock); call_data = &data; + mb(); /* Send a message to all other CPUs and wait for them to respond */ for (i = 0; i < NR_CPUS; i++) - if (cpu_online(cpu) && i != cpu) + if (cpu_online(i) && i != cpu) core_send_ipi(i, SMP_CALL_FUNCTION); /* Wait for response */ @@ -261,6 +221,99 @@ void smp_send_stop(void) smp_call_function(stop_this_cpu, NULL, 1, 0); } +void __init smp_cpus_done(unsigned int max_cpus) +{ + prom_cpus_done(); +} + +/* called from main before smp_init() */ +void __init smp_prepare_cpus(unsigned int max_cpus) +{ + cpu_data[0].udelay_val = loops_per_jiffy; + init_new_context(current, &init_mm); + current_thread_info()->cpu = 0; + smp_tune_scheduling(); + prom_build_cpu_map(); + prom_prepare_cpus(max_cpus); +} + +/* preload SMP state for boot cpu */ +void __devinit smp_prepare_boot_cpu(void) +{ + /* + * This assumes that bootup is always handled by the processor + * with the logic and physical number 0. + */ + __cpu_number_map[0] = 0; + __cpu_logical_map[0] = 0; + cpu_set(0, phys_cpu_present_map); + cpu_set(0, cpu_online_map); + cpu_set(0, cpu_callin_map); +} + +static struct task_struct * __init fork_by_hand(void) +{ + struct pt_regs regs; + /* + * don't care about the eip and regs settings since + * we'll never reschedule the forked task. + */ + return copy_process(CLONE_VM|CLONE_IDLETASK, 0, ®s, 0, NULL, NULL); +} + +/* + * Startup the CPU with this logical number + */ +static int __init do_boot_cpu(int cpu) +{ + struct task_struct *idle; + + /* + * The following code is purely to make sure + * Linux can schedule processes on this slave. + */ + idle = fork_by_hand(); + if (IS_ERR(idle)) + panic("failed fork for CPU %d\n", cpu); + + wake_up_forked_process(idle); + + /* + * We remove it from the pidhash and the runqueue once we've + * got the process: + */ + init_idle(idle, cpu); + + unhash_process(idle); + + prom_boot_secondary(cpu, idle); + + /* XXXKW timeout */ + while (!cpu_isset(cpu, cpu_callin_map)) + udelay(100); + + cpu_set(cpu, cpu_online_map); + + return 0; +} + +/* + * Called once for each "cpu_possible(cpu)". Needs to spin up the cpu + * and keep control until "cpu_online(cpu)" is set. Note: cpu is + * physical, not logical. + */ +int __devinit __cpu_up(unsigned int cpu) +{ + int ret; + + /* Processor goes to start_secondary(), sets online flag */ + ret = do_boot_cpu(cpu); + if (ret < 0) + return ret; + + return 0; +} + /* Not really SMP stuff ... */ int setup_profiling_timer(unsigned int multiplier) { --- diff/arch/mips/kernel/syscall.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/kernel/syscall.c 2004-02-23 13:56:38.000000000 +0000 @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -111,7 +112,7 @@ static inline long do_mmap2(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long pgoff) { - int error = -EBADF; + unsigned long error = -EBADF; struct file * file = NULL; flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); @@ -134,7 +135,7 @@ out: asmlinkage unsigned long old_mmap(unsigned long addr, size_t len, int prot, int flags, int fd, off_t offset) { - int result; + unsigned long result; result = -EINVAL; if (offset & ~PAGE_MASK) @@ -156,7 +157,6 @@ sys_mmap2(unsigned long addr, unsigned l save_static_function(sys_fork); static_unused int _sys_fork(nabi_no_regargs struct pt_regs regs) { - save_static(®s); return do_fork(SIGCHLD, regs.regs[29], ®s, 0, NULL, NULL); } @@ -167,7 +167,6 @@ static_unused int _sys_clone(nabi_no_reg unsigned long newsp; int *parent_tidptr, *child_tidptr; - save_static(®s); clone_flags = regs.regs[4]; newsp = regs.regs[5]; if (!newsp) @@ -297,7 +296,11 @@ asmlinkage int sys_ipc (uint call, int f switch (call) { case SEMOP: - return sys_semop (first, (struct sembuf *)ptr, second); + return sys_semtimedop (first, (struct sembuf *)ptr, second, + NULL); + case SEMTIMEDOP: + return sys_semtimedop (first, (struct sembuf *)ptr, second, + (const struct timespec __user *)fifth); case SEMGET: return sys_semget (first, second, third); case SEMCTL: { --- diff/arch/mips/kernel/sysirix.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/mips/kernel/sysirix.c 2004-02-23 13:56:38.000000000 +0000 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -235,13 +236,6 @@ asmlinkage int irix_prctl(struct pt_regs #undef DEBUG_PROCGRPS extern unsigned long irix_mapelf(int fd, struct elf_phdr *user_phdrp, int cnt); -extern asmlinkage int sys_setpgid(pid_t pid, pid_t pgid); -extern void sys_sync(void); -extern asmlinkage int sys_getsid(pid_t pid); -extern asmlinkage long sys_write (unsigned int fd, const char *buf, unsigned long count); -extern asmlinkage long sys_lseek (unsigned int fd, off_t offset, unsigned int origin); -extern asmlinkage int sys_getgroups(int gidsetsize, gid_t *grouplist); -extern asmlinkage int sys_setgroups(int gidsetsize, gid_t *grouplist); extern int getrusage(struct task_struct *p, int who, struct rusage *ru); extern char *prom_getenv(char *name); extern long prom_setenv(char *name, char *value); @@ -368,7 +362,7 @@ asmlinkage int irix_syssgi(struct pt_reg retval = HZ; goto out; case 4: - retval = NGROUPS; + retval = NGROUPS_MAX; goto out; case 5: retval = NR_OPEN; @@ -694,9 +688,6 @@ asmlinkage int irix_pause(void) return -EINTR; } -extern asmlinkage long sys_mount(char * dev_name, char * dir_name, char * type, - unsigned long new_flags, void * data); - /* XXX need more than this... */ asmlinkage int irix_mount(char *dev_name, char *dir_name, unsigned long flags, char *type, void *data, int datalen) @@ -792,9 +783,6 @@ out: return error; } -extern asmlinkage int sys_setpgid(pid_t pid, pid_t pgid); -extern asmlinkage int sys_setsid(void); - asmlinkage int irix_setpgrp(int flags) { int error; @@ -883,8 +871,6 @@ asmlinkage unsigned long irix_sethostid( return -EINVAL; } -extern asmlinkage int sys_socket(int family, int type, int protocol); - asmlinkage int irix_socket(int family, int type, int protocol) { switch(type) { @@ -1206,8 +1192,8 @@ static int irix_xstat32_xlate(struct kst ub.st_ino = stat->ino; ub.st_mode = stat->mode; ub.st_nlink = stat->nlink; - SET_STAT_UID(ub, stat->uid); - SET_STAT_GID(ub, stat->gid); + SET_UID(ub.st_uid, stat->uid); + SET_GID(ub.st_gid, stat->gid); ub.st_rdev = sysv_encode_dev(stat->rdev); #if BITS_PER_LONG == 32 if (stat->size > MAX_NON_LFS) @@ -1356,8 +1342,6 @@ asmlinkage int irix_fxstat(int version, return error; } -extern asmlinkage int sys_mknod(const char * filename, int mode, unsigned dev); - asmlinkage int irix_xmknod(int ver, char *filename, int mode, unsigned dev) { int retval; @@ -1501,9 +1485,6 @@ asmlinkage int irix_sigqueue(int pid, in return -EINVAL; } -extern asmlinkage int sys_truncate(const char * path, unsigned long length); -extern asmlinkage int sys_ftruncate(unsigned int fd, unsigned long length); - asmlinkage int irix_truncate64(char *name, int pad, int size1, int size2) { int retval; @@ -1532,10 +1513,6 @@ out: return retval; } -extern asmlinkage unsigned long -sys_mmap(unsigned long addr, size_t len, int prot, int flags, int fd, - off_t offset); - asmlinkage int irix_mmap64(struct pt_regs *regs) { int len, prot, flags, fd, off1, off2, error, base = 0; @@ -2106,9 +2083,6 @@ out: #undef DEBUG_FCNTL -extern asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, - unsigned long arg); - #define IRIX_F_ALLOCSP 10 asmlinkage int irix_fcntl(int fd, int cmd, int arg) --- diff/arch/mips/kernel/time.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/mips/kernel/time.c 2004-02-23 13:56:38.000000000 +0000 @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -26,14 +27,20 @@ #include #include +#include #include #include #include #include -/* This is for machines which generate the exact clock. */ -#define USECS_PER_JIFFY (1000000/HZ) -#define USECS_PER_JIFFY_FRAC ((u32)((1000000ULL << 32) / HZ)) +/* + * The integer part of the number of usecs per jiffy is taken from tick, + * but the fractional part is not recorded, so we calculate it using the + * initial value of HZ. This aids systems where tick isn't really an + * integer (e.g. for HZ = 128). + */ +#define USECS_PER_JIFFY TICK_SIZE +#define USECS_PER_JIFFY_FRAC ((unsigned long)(u32)((1000000ULL << 32) / HZ)) #define TICK_SIZE (tick_nsec / 1000) @@ -53,6 +60,7 @@ spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED */ int emulate_local_timer_interrupt; + /* * By default we provide the null RTC ops */ @@ -71,6 +79,85 @@ int (*rtc_set_time)(unsigned long) = nul int (*rtc_set_mmss)(unsigned long); +/* usecs per counter cycle, shifted to left by 32 bits */ +static unsigned int sll32_usecs_per_cycle; + +/* how many counter cycles in a jiffy */ +static unsigned long cycles_per_jiffy; + +/* Cycle counter value at the previous timer interrupt.. */ +static unsigned int timerhi, timerlo; + +/* expirelo is the count value for next CPU timer interrupt */ +static unsigned int expirelo; + + +/* + * Null timer ack for systems not needing one (e.g. i8254). + */ +static void null_timer_ack(void) { /* nothing */ } + +/* + * Null high precision timer functions for systems lacking one. + */ +static unsigned int null_hpt_read(void) +{ + return 0; +} + +static void null_hpt_init(unsigned int count) { /* nothing */ } + + +/* + * Timer ack for an R4k-compatible timer of a known frequency. + */ +static void c0_timer_ack(void) +{ + unsigned int count; + + /* Ack this timer interrupt and set the next one. */ + expirelo += cycles_per_jiffy; + write_c0_compare(expirelo); + + /* Check to see if we have missed any timer interrupts. */ + count = read_c0_count(); + if ((count - expirelo) < 0x7fffffff) { + /* missed_timer_count++; */ + expirelo = count + cycles_per_jiffy; + write_c0_compare(expirelo); + } +} + +/* + * High precision timer functions for a R4k-compatible timer. + */ +static unsigned int c0_hpt_read(void) +{ + return read_c0_count(); +} + +/* For use solely as a high precision timer. */ +static void c0_hpt_init(unsigned int count) +{ + write_c0_count(read_c0_count() - count); +} + +/* For use both as a high precision timer and an interrupt source. */ +static void c0_hpt_timer_init(unsigned int count) +{ + count = read_c0_count() - count; + expirelo = (count / cycles_per_jiffy + 1) * cycles_per_jiffy; + write_c0_count(expirelo - cycles_per_jiffy); + write_c0_compare(expirelo); + write_c0_count(count); +} + +int (*mips_timer_state)(void); +void (*mips_timer_ack)(void); +unsigned int (*mips_hpt_read)(void); +void (*mips_hpt_init)(unsigned int); + + /* * This version of gettimeofday has microsecond resolution and better than * microsecond precision on fast machines with cycle counter. @@ -78,18 +165,33 @@ int (*rtc_set_mmss)(unsigned long); void do_gettimeofday(struct timeval *tv) { unsigned long seq; + unsigned long lost; unsigned long usec, sec; + unsigned long max_ntp_tick = tick_usec - tickadj; do { seq = read_seqbegin(&xtime_lock); + usec = do_gettimeoffset(); - { - unsigned long lost = jiffies - wall_jiffies; + + lost = jiffies - wall_jiffies; + + /* + * If time_adjust is negative then NTP is slowing the clock + * so make sure not to go into next possible interval. + * Better to lose some accuracy than have time go backwards.. + */ + if (unlikely(time_adjust < 0)) { + usec = min(usec, max_ntp_tick); + if (lost) - usec += lost * (1000000 / HZ); - } + usec += lost * max_ntp_tick; + } else if (unlikely(lost)) + usec += lost * tick_usec; + sec = xtime.tv_sec; usec += (xtime.tv_nsec / 1000); + } while (read_seqretry(&xtime_lock, seq)); while (usec >= 1000000) { @@ -112,14 +214,15 @@ int do_settimeofday(struct timespec *tv) return -EINVAL; write_seqlock_irq(&xtime_lock); + /* - * This is revolting. We need to set "xtime" correctly. However, the - * value in this location is the value at the most recent update of - * wall time. Discover what correction gettimeofday() would have + * This is revolting. We need to set "xtime" correctly. However, + * the value in this location is the value at the most recent update + * of wall time. Discover what correction gettimeofday() would have * made, and then undo it! */ nsec -= do_gettimeoffset() * NSEC_PER_USEC; - nsec -= (jiffies - wall_jiffies) * TICK_NSEC; + nsec -= (jiffies - wall_jiffies) * tick_nsec; wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec); wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec); @@ -127,12 +230,13 @@ int do_settimeofday(struct timespec *tv) set_normalized_timespec(&xtime, sec, nsec); set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec); - time_adjust = 0; /* stop active adjtime() */ + time_adjust = 0; /* stop active adjtime() */ time_status |= STA_UNSYNC; time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; - write_sequnlock_irq(&xtime_lock); + write_sequnlock_irq(&xtime_lock); + clock_was_set(); return 0; } @@ -145,42 +249,28 @@ EXPORT_SYMBOL(do_settimeofday); * If the exact CPU counter frequency is known, use fixed_rate_gettimeoffset. * Otherwise use calibrate_gettimeoffset() * - * If the CPU does not have counter register all, you can either supply - * your own gettimeoffset() routine, or use null_gettimeoffset() routines, - * which gives the same resolution as HZ. + * If the CPU does not have the counter register, you can either supply + * your own gettimeoffset() routine, or use null_gettimeoffset(), which + * gives the same resolution as HZ. */ +static unsigned long null_gettimeoffset(void) +{ + return 0; +} -/* usecs per counter cycle, shifted to left by 32 bits */ -static unsigned int sll32_usecs_per_cycle; - -/* how many counter cycles in a jiffy */ -static unsigned long cycles_per_jiffy; - -/* Cycle counter value at the previous timer interrupt.. */ -static unsigned int timerhi, timerlo; - -/* expirelo is the count value for next CPU timer interrupt */ -static unsigned int expirelo; - -/* last time when xtime and rtc are sync'ed up */ -static long last_rtc_update; -/* the function pointer to one of the gettimeoffset funcs*/ +/* The function pointer to one of the gettimeoffset funcs. */ unsigned long (*do_gettimeoffset)(void) = null_gettimeoffset; -unsigned long null_gettimeoffset(void) -{ - return 0; -} -unsigned long fixed_rate_gettimeoffset(void) +static unsigned long fixed_rate_gettimeoffset(void) { u32 count; unsigned long res; /* Get last timer tick in absolute kernel time */ - count = read_c0_count(); + count = mips_hpt_read(); /* .. relative to previous jiffy (32 bits is enough) */ count -= timerlo; @@ -200,6 +290,7 @@ unsigned long fixed_rate_gettimeoffset(v return res; } + /* * Cached "1/(clocks per usec) * 2^32" value. * It has to be recalculated once each jiffy. @@ -209,11 +300,10 @@ static unsigned long cached_quotient; /* Last jiffy when calibrate_divXX_gettimeoffset() was called. */ static unsigned long last_jiffies; - /* - * This is copied from dec/time.c:do_ioasic_gettimeoffset() by Maciej. + * This is moved from dec/time.c:do_ioasic_gettimeoffset() by Maciej. */ -unsigned long calibrate_div32_gettimeoffset(void) +static unsigned long calibrate_div32_gettimeoffset(void) { u32 count; unsigned long res, tmp; @@ -235,7 +325,7 @@ unsigned long calibrate_div32_gettimeoff } /* Get last timer tick in absolute kernel time */ - count = read_c0_count(); + count = mips_hpt_read(); /* .. relative to previous jiffy (32 bits is enough) */ count -= timerlo; @@ -255,7 +345,7 @@ unsigned long calibrate_div32_gettimeoff return res; } -unsigned long calibrate_div64_gettimeoffset(void) +static unsigned long calibrate_div64_gettimeoffset(void) { u32 count; unsigned long res, tmp; @@ -265,30 +355,33 @@ unsigned long calibrate_div64_gettimeoff quotient = cached_quotient; - if (tmp && last_jiffies != tmp) { + if (last_jiffies != tmp) { last_jiffies = tmp; - __asm__(".set push\n\t" - ".set noreorder\n\t" - ".set noat\n\t" - ".set mips3\n\t" - "lwu %0,%2\n\t" - "dsll32 $1,%1,0\n\t" - "or $1,$1,%0\n\t" - "ddivu $0,$1,%3\n\t" - "mflo $1\n\t" - "dsll32 %0,%4,0\n\t" - "nop\n\t" - "ddivu $0,%0,$1\n\t" - "mflo %0\n\t" - ".set pop" - : "=&r" (quotient) - : "r" (timerhi), "m" (timerlo), - "r" (tmp), "r" (USECS_PER_JIFFY)); - cached_quotient = quotient; + if (last_jiffies) { + unsigned long r0; + __asm__(".set push\n\t" + ".set mips3\n\t" + "lwu %0,%3\n\t" + "dsll32 %1,%2,0\n\t" + "or %1,%1,%0\n\t" + "ddivu $0,%1,%4\n\t" + "mflo %1\n\t" + "dsll32 %0,%5,0\n\t" + "or %0,%0,%6\n\t" + "ddivu $0,%0,%1\n\t" + "mflo %0\n\t" + ".set pop" + : "=&r" (quotient), "=&r" (r0) + : "r" (timerhi), "m" (timerlo), + "r" (tmp), "r" (USECS_PER_JIFFY), + "r" (USECS_PER_JIFFY_FRAC) + : "hi", "lo", "accum"); + cached_quotient = quotient; + } } /* Get last timer tick in absolute kernel time */ - count = read_c0_count(); + count = mips_hpt_read(); /* .. relative to previous jiffy (32 bits is enough) */ count -= timerlo; @@ -309,6 +402,9 @@ unsigned long calibrate_div64_gettimeoff } +/* last time when xtime and rtc are sync'ed up */ +static long last_rtc_update; + /* * local_timer_interrupt() does profiling and process accounting * on a per-CPU basis. @@ -345,30 +441,20 @@ void local_timer_interrupt(int irq, void } /* - * high-level timer interrupt service routines. This function + * High-level timer interrupt service routines. This function * is set as irqaction->handler and is invoked through do_IRQ. */ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - if (cpu_has_counter) { - unsigned int count; - - /* ack timer interrupt, and try to set next interrupt */ - expirelo += cycles_per_jiffy; - write_c0_compare(expirelo); - count = read_c0_count(); + unsigned long j; + unsigned int count; - /* check to see if we have missed any timer interrupts */ - if ((count - expirelo) < 0x7fffffff) { - /* missed_timer_count++; */ - expirelo = count + cycles_per_jiffy; - write_c0_compare(expirelo); - } + count = mips_hpt_read(); + mips_timer_ack(); - /* Update timerhi/timerlo for intra-jiffy calibration. */ - timerhi += count < timerlo; /* Wrap around */ - timerlo = count; - } + /* Update timerhi/timerlo for intra-jiffy calibration. */ + timerhi += count < timerlo; /* Wrap around */ + timerlo = count; /* * call the generic timer interrupt handling @@ -395,12 +481,44 @@ irqreturn_t timer_interrupt(int irq, voi write_sequnlock(&xtime_lock); /* - * If jiffies has overflowed in this timer_interrupt we must + * If jiffies has overflown in this timer_interrupt, we must * update the timer[hi]/[lo] to make fast gettimeoffset funcs * quotient calc still valid. -arca + * + * The first timer interrupt comes late as interrupts are + * enabled long after timers are initialized. Therefore the + * high precision timer is fast, leading to wrong gettimeoffset() + * calculations. We deal with it by setting it based on the + * number of its ticks between the second and the third interrupt. + * That is still somewhat imprecise, but it's a good estimate. + * --macro */ - if (!jiffies) { - timerhi = timerlo = 0; + j = jiffies; + if (j < 4) { + static unsigned int prev_count; + static int hpt_initialized; + + switch (j) { + case 0: + timerhi = timerlo = 0; + mips_hpt_init(count); + break; + case 2: + prev_count = count; + break; + case 3: + if (!hpt_initialized) { + unsigned int c3 = 3 * (count - prev_count); + + timerhi = 0; + timerlo = c3; + mips_hpt_init(count - c3); + hpt_initialized = 1; + } + break; + default: + break; + } } #if !defined(CONFIG_SMP) @@ -445,7 +563,8 @@ asmlinkage void ll_timer_interrupt(int i asmlinkage void ll_local_timer_interrupt(int irq, struct pt_regs *regs) { irq_enter(); - kstat_this_cpu.irqs[irq]++; + if (smp_processor_id() != 0) + kstat_this_cpu.irqs[irq]++; /* we keep interrupt disabled all the time */ local_timer_interrupt(irq, NULL, regs); @@ -458,7 +577,7 @@ asmlinkage void ll_local_timer_interrupt * * 1) board_time_init() - * a) (optional) set up RTC routines, - * b) (optional) calibrate and set the mips_counter_frequency + * b) (optional) calibrate and set the mips_hpt_frequency * (only needed if you intended to use fixed_rate_gettimeoffset * or use cpu counter as timer interrupt source) * 2) setup xtime based on rtc_get_time(). @@ -473,7 +592,7 @@ asmlinkage void ll_local_timer_interrupt void (*board_time_init)(void); void (*board_timer_setup)(struct irqaction *irq); -unsigned int mips_counter_frequency; +unsigned int mips_hpt_frequency; static struct irqaction timer_irqaction = { .handler = timer_interrupt, @@ -481,6 +600,49 @@ static struct irqaction timer_irqaction .name = "timer", }; +static unsigned int __init calibrate_hpt(void) +{ + u64 frequency; + u32 hpt_start, hpt_end, hpt_count, hz; + + const int loops = HZ / 10; + int log_2_loops = 0; + int i; + + /* + * We want to calibrate for 0.1s, but to avoid a 64-bit + * division we round the number of loops up to the nearest + * power of 2. + */ + while (loops > 1 << log_2_loops) + log_2_loops++; + i = 1 << log_2_loops; + + /* + * Wait for a rising edge of the timer interrupt. + */ + while (mips_timer_state()); + while (!mips_timer_state()); + + /* + * Now see how many high precision timer ticks happen + * during the calculated number of periods between timer + * interrupts. + */ + hpt_start = mips_hpt_read(); + do { + while (mips_timer_state()); + while (!mips_timer_state()); + } while (--i); + hpt_end = mips_hpt_read(); + + hpt_count = hpt_end - hpt_start; + hz = HZ; + frequency = (u64)hpt_count * (u64)hz; + + return frequency >> log_2_loops; +} + void __init time_init(void) { if (board_time_init) @@ -495,50 +657,79 @@ void __init time_init(void) set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec); - /* choose appropriate gettimeoffset routine */ - if (!cpu_has_counter) { - /* no cpu counter - sorry */ - do_gettimeoffset = null_gettimeoffset; - } else if (mips_counter_frequency != 0) { - /* we have cpu counter and know counter frequency! */ - do_gettimeoffset = fixed_rate_gettimeoffset; - } else if ((current_cpu_data.isa_level == MIPS_CPU_ISA_M32) || - (current_cpu_data.isa_level == MIPS_CPU_ISA_I) || - (current_cpu_data.isa_level == MIPS_CPU_ISA_II) ) { - /* we need to calibrate the counter but we don't have - * 64-bit division. */ - do_gettimeoffset = calibrate_div32_gettimeoffset; + /* Choose appropriate high precision timer routines. */ + if (!cpu_has_counter && !mips_hpt_read) { + /* No high precision timer -- sorry. */ + mips_hpt_read = null_hpt_read; + mips_hpt_init = null_hpt_init; + } else if (!mips_hpt_frequency && !mips_timer_state) { + /* A high precision timer of unknown frequency. */ + if (!mips_hpt_read) { + /* No external high precision timer -- use R4k. */ + mips_hpt_read = c0_hpt_read; + mips_hpt_init = c0_hpt_init; + } + + if ((current_cpu_data.isa_level == MIPS_CPU_ISA_M32) || + (current_cpu_data.isa_level == MIPS_CPU_ISA_I) || + (current_cpu_data.isa_level == MIPS_CPU_ISA_II)) + /* + * We need to calibrate the counter but we don't have + * 64-bit division. + */ + do_gettimeoffset = calibrate_div32_gettimeoffset; + else + /* + * We need to calibrate the counter but we *do* have + * 64-bit division. + */ + do_gettimeoffset = calibrate_div64_gettimeoffset; } else { - /* we need to calibrate the counter but we *do* have - * 64-bit division. */ - do_gettimeoffset = calibrate_div64_gettimeoffset; - } + /* We know counter frequency. Or we can get it. */ + if (!mips_hpt_read) { + /* No external high precision timer -- use R4k. */ + mips_hpt_read = c0_hpt_read; + + if (mips_timer_state) + mips_hpt_init = c0_hpt_init; + else { + /* No external timer interrupt -- use R4k. */ + mips_hpt_init = c0_hpt_timer_init; + mips_timer_ack = c0_timer_ack; + } + } + if (!mips_hpt_frequency) + mips_hpt_frequency = calibrate_hpt(); - /* caclulate cache parameters */ - if (mips_counter_frequency) { - cycles_per_jiffy = mips_counter_frequency / HZ; - - /* sll32_usecs_per_cycle = 10^6 * 2^32 / mips_counter_freq */ - /* any better way to do this? */ - sll32_usecs_per_cycle = mips_counter_frequency / 100000; - sll32_usecs_per_cycle = 0xffffffff / sll32_usecs_per_cycle; - sll32_usecs_per_cycle *= 10; + do_gettimeoffset = fixed_rate_gettimeoffset; - /* - * For those using cpu counter as timer, this sets up the - * first interrupt - */ - write_c0_compare(cycles_per_jiffy); - write_c0_count(0); - expirelo = cycles_per_jiffy; + /* Calculate cache parameters. */ + cycles_per_jiffy = (mips_hpt_frequency + HZ / 2) / HZ; + + /* sll32_usecs_per_cycle = 10^6 * 2^32 / mips_counter_freq */ + do_div64_32(sll32_usecs_per_cycle, + 1000000, mips_hpt_frequency / 2, + mips_hpt_frequency); + + /* Report the high precision timer rate for a reference. */ + printk("Using %u.%03u MHz high precision timer.\n", + ((mips_hpt_frequency + 500) / 1000) / 1000, + ((mips_hpt_frequency + 500) / 1000) % 1000); } + if (!mips_timer_ack) + /* No timer interrupt ack (e.g. i8254). */ + mips_timer_ack = null_timer_ack; + + /* This sets up the high precision timer for the first interrupt. */ + mips_hpt_init(mips_hpt_read()); + /* * Call board specific timer interrupt setup. * * this pointer must be setup in machine setup routine. * - * Even if the machine choose to use low-level timer interrupt, + * Even if a machine chooses to use a low-level timer interrupt, * it still needs to setup the timer_irqaction. * In that case, it might be better to set timer_irqaction.handler * to be NULL function so that we are sure the high-level code --- diff/arch/mips/kernel/traps.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/mips/kernel/traps.c 2004-02-23 13:56:38.000000000 +0000 @@ -83,12 +83,12 @@ void show_stack(struct task_struct *task sp = sp ? sp : (unsigned long *) &sp; - printk("Stack: "); - i = 1; + printk("Stack :"); + i = 0; while ((unsigned long) sp & (PAGE_SIZE - 1)) { - if (i && ((i % (64 / sizeof(unsigned long))) == 0)) + if (i && ((i % (64 / field)) == 0)) printk("\n "); - if (i > 40) { + if (i > 39) { printk(" ..."); break; } @@ -116,7 +116,7 @@ void show_trace(struct task_struct *task #ifdef CONFIG_KALLSYMS printk("\n"); #endif - while (((long) stack & (THREAD_SIZE-1)) != 0) { + while (!kstack_end(stack)) { addr = *stack++; if (kernel_text_address(addr)) { printk(" [<%0*lx>] ", field, addr); @@ -162,6 +162,7 @@ void show_code(unsigned int *pc) void show_regs(struct pt_regs *regs) { const int field = 2 * sizeof(unsigned long); + unsigned int cause = regs->cp0_cause; int i; printk("Cpu %d\n", smp_processor_id()); @@ -171,7 +172,7 @@ void show_regs(struct pt_regs *regs) */ for (i = 0; i < 32; ) { if ((i % 4) == 0) - printk("$%2d :", i); + printk("$%2d :", i); if (i == 0) printk(" %0*lx", field, 0UL); else if (i == 26 || i == 27) @@ -184,15 +185,19 @@ void show_regs(struct pt_regs *regs) printk("\n"); } - printk("Hi : %0*lx\n", field, regs->hi); - printk("Lo : %0*lx\n", field, regs->lo); + printk("Hi : %0*lx\n", field, regs->hi); + printk("Lo : %0*lx\n", field, regs->lo); /* * Saved cp0 registers */ - printk("epc : %0*lx %s\n", field, regs->cp0_epc, print_tainted()); - printk("Status: %0*lx\n", field, regs->cp0_status); - printk("Cause : %0*lx\n", field, regs->cp0_cause); + printk("epc : %0*lx ", field, regs->cp0_epc); + print_symbol("%s ", regs->cp0_epc); + printk(" %s\n", print_tainted()); + printk("ra : %0*lx ", field, regs->regs[31]); + print_symbol("%s\n", regs->regs[31]); + + printk("Status: %08x ", (uint32_t) regs->cp0_status); if (regs->cp0_status & ST0_KX) printk("KX "); @@ -220,15 +225,22 @@ void show_regs(struct pt_regs *regs) printk("EXL "); if (regs->cp0_status & ST0_IE) printk("IE "); + printk("\n"); + + printk("Cause : %08x\n", cause); + + cause = (cause & CAUSEF_EXCCODE) >> CAUSEB_EXCCODE; + if (1 <= cause && cause <= 5) + printk("BadVA : %0*lx\n", field, regs->cp0_badvaddr); + + printk("PrId : %08x\n", read_c0_prid()); } void show_registers(struct pt_regs *regs) { - const int field = 2 * sizeof(unsigned long); - show_regs(regs); - printk("Process %s (pid: %d, stackpage=%0*lx)\n", - current->comm, current->pid, field, (unsigned long) current); + printk("Process %s (pid: %d, threadinfo=%p, task=%p)\n", + current->comm, current->pid, current_thread_info(), current); show_stack(current, (long *) regs->regs[29]); show_trace(current, (long *) regs->regs[29]); show_code((unsigned int *) regs->cp0_epc); @@ -237,8 +249,8 @@ void show_registers(struct pt_regs *regs static spinlock_t die_lock = SPIN_LOCK_UNLOCKED; -void __die(const char * str, struct pt_regs * regs, const char * file, - const char * func, unsigned long line) +NORET_TYPE void __die(const char * str, struct pt_regs * regs, + const char * file, const char * func, unsigned long line) { static int die_counter; @@ -271,6 +283,56 @@ void __declare_dbe_table(void) ); } +#ifdef CONFIG_MDULES + +/* Given an address, look for it in the module exception tables. */ +const struct exception_table_entry *search_module_dbetables(unsigned long addr) +{ + unsigned long flags; + const struct exception_table_entry *e = NULL; + struct module *mod; + + spin_lock_irqsave(&modlist_lock, flags); + list_for_each_entry(mod, &modules, list) { + if (mod->arch.num_dbeentries == 0) + continue; + + e = search_extable(mod->arch.dbe_table_start, + mod->arch.dbe_table_end + + mod->arch.num_dbeentries - 1, + addr); + if (e) + break; + } + spin_unlock_irqrestore(&modlist_lock, flags); + + /* Now, if we found one, we are running inside it now, hence + we cannot unload the module, hence no refcnt needed. */ + return e; +} + +#else + +/* Given an address, look for it in the exception tables. */ +static inline const struct exception_table_entry * +search_module_dbetables(unsigned long addr) +{ + return NULL; +} + +#endif + +/* Given an address, look for it in the exception tables. */ +const struct exception_table_entry *search_dbe_tables(unsigned long addr) +{ + const struct exception_table_entry *e; + + e = search_extable(__start___dbe_table, __stop___dbe_table - 1, addr); + if (!e) + e = search_module_dbetables(addr); + return e; +} + asmlinkage void do_be(struct pt_regs *regs) { const int field = 2 * sizeof(unsigned long); @@ -280,7 +342,7 @@ asmlinkage void do_be(struct pt_regs *re /* XXX For now. Fixme, this searches the wrong table ... */ if (data && !user_mode(regs)) - fixup = search_exception_tables(regs->cp0_epc); + fixup = search_dbe_tables(exception_epc(regs)); if (fixup) action = MIPS_BE_FIXUP; @@ -725,10 +787,10 @@ asmlinkage void cache_parity_error(void) #if defined(CONFIG_CPU_MIPS32) || defined (CONFIG_CPU_MIPS64) if (reg_val & (1<<22)) - printk("DErrAddr0: 0x%08x\n", read_c0_derraddr0()); + printk("DErrAddr0: 0x%0*lx\n", field, read_c0_derraddr0()); if (reg_val & (1<<23)) - printk("DErrAddr1: 0x%08x\n", read_c0_derraddr1()); + printk("DErrAddr1: 0x%0*lx\n", field, read_c0_derraddr1()); #endif panic("Can't handle the cache error!"); @@ -794,9 +856,9 @@ void *set_except_vector(int n, void *add exception_handlers[n] = handler; if (n == 0 && cpu_has_divec) { - *(volatile u32 *)(KSEG0+0x200) = 0x08000000 | + *(volatile u32 *)(CAC_BASE + 0x200) = 0x08000000 | (0x03ffffff & (handler >> 2)); - flush_icache_range(KSEG0+0x200, KSEG0 + 0x204); + flush_icache_range(CAC_BASE + 0x200, CAC_BASE + 0x204); } return (void *)old_handler; } @@ -850,6 +912,9 @@ static inline void signal32_init(void) } #endif +extern void cpu_cache_init(void); +extern void tlb_init(void); + void __init per_cpu_trap_init(void) { unsigned int cpu = smp_processor_id(); @@ -860,6 +925,9 @@ void __init per_cpu_trap_init(void) set_c0_status(ST0_CU0|ST0_FR|ST0_KX|ST0_SX|ST0_UX); #endif + if (current_cpu_data.isa_level == MIPS_CPU_ISA_IV) + set_c0_status(ST0_XX); + /* * Some MIPS CPUs have a dedicated interrupt vector which reduces the * interrupt processing overhead. Use it where available. @@ -868,19 +936,19 @@ void __init per_cpu_trap_init(void) set_c0_cause(CAUSEF_IV); cpu_data[cpu].asid_cache = ASID_FIRST_VERSION; -#ifdef CONFIG_MIPS32 - write_c0_context(cpu << 23); -#endif -#ifdef CONFIG_MIPS64 - write_c0_context(((long)(&pgd_current[cpu])) << 23); -#endif - write_c0_wired(0); + TLBMISS_HANDLER_SETUP(); + + atomic_inc(&init_mm.mm_count); + current->active_mm = &init_mm; + BUG_ON(current->mm); + enter_lazy_tlb(&init_mm, current); + + cpu_cache_init(); + tlb_init(); } void __init trap_init(void) { - extern char except_vec0_generic; - extern char except_vec1_generic; extern char except_vec3_generic, except_vec3_r4000; extern char except_vec_ejtag_debug; extern char except_vec4; @@ -893,9 +961,7 @@ void __init trap_init(void) * This will be overriden later as suitable for a particular * configuration. */ - memcpy((void *) KSEG0 , &except_vec0_generic, 0x80); - memcpy((void *)(KSEG0 + 0x080), &except_vec1_generic, 0x80); - memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, 0x80); + memcpy((void *)(CAC_BASE + 0x180), &except_vec3_generic, 0x80); /* * Setup default vectors @@ -908,7 +974,7 @@ void __init trap_init(void) * destination. */ if (cpu_has_ejtag) - memcpy((void *)(KSEG0 + 0x300), &except_vec_ejtag_debug, 0x80); + memcpy((void *)(CAC_BASE + 0x300), &except_vec_ejtag_debug, 0x80); /* * Only some CPUs have the watch exceptions or a dedicated @@ -922,7 +988,7 @@ void __init trap_init(void) * interrupt processing overhead. Use it where available. */ if (cpu_has_divec) - memcpy((void *)(KSEG0 + 0x200), &except_vec4, 0x8); + memcpy((void *)(CAC_BASE + 0x200), &except_vec4, 0x8); /* * Some CPUs can enable/disable for cache parity detection, but does @@ -969,11 +1035,11 @@ void __init trap_init(void) set_except_vector(24, handle_mcheck); if (cpu_has_vce) - memcpy((void *)(KSEG0 + 0x180), &except_vec3_r4000, 0x80); + memcpy((void *)(CAC_BASE + 0x180), &except_vec3_r4000, 0x80); else if (cpu_has_4kex) - memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, 0x80); + memcpy((void *)(CAC_BASE + 0x180), &except_vec3_generic, 0x80); else - memcpy((void *)(KSEG0 + 0x080), &except_vec3_generic, 0x80); + memcpy((void *)(CAC_BASE + 0x080), &except_vec3_generic, 0x80); if (current_cpu_data.cputype == CPU_R6000 || current_cpu_data.cputype == CPU_R6000A) { @@ -994,11 +1060,5 @@ void __init trap_init(void) signal32_init(); #endif - flush_icache_range(KSEG0, KSEG0 + 0x400); - - if (current_cpu_data.isa_level == MIPS_CPU_ISA_IV) - set_c0_status(ST0_XX); - - atomic_inc(&init_mm.mm_count); /* XXX UP? */ - current->active_mm = &init_mm; + flush_icache_range(CAC_BASE, CAC_BASE + 0x400); } --- diff/arch/mips/kernel/unaligned.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/kernel/unaligned.c 2004-02-23 13:56:38.000000000 +0000 @@ -40,7 +40,7 @@ * Below a little program to play around with this feature. * * #include - * #include + * #include * * struct foo { * unsigned char bar[8]; @@ -99,7 +99,6 @@ static inline int emulate_load_store_ins { union mips_instruction insn; unsigned long value; - const struct exception_table_entry *fixup; unsigned int res; regs->regs[0] = 0; @@ -470,14 +469,8 @@ static inline int emulate_load_store_ins fault: /* Did we have an exception handler installed? */ - fixup = search_exception_tables(exception_epc(regs)); - if (fixup) { - unsigned long new_epc = fixup->nextinsn; - printk(KERN_DEBUG "%s: Forwarding exception at [<%lx>] (%lx)\n", - current->comm, regs->cp0_epc, new_epc); - regs->cp0_epc = new_epc; + if (fixup_exception(regs)) return 1; - } die_if_kernel ("Unhandled kernel unaligned access", regs); send_sig(SIGSEGV, current, 1); --- diff/arch/mips/kernel/vmlinux.lds.S 2003-08-26 10:00:52.000000000 +0100 +++ source/arch/mips/kernel/vmlinux.lds.S 2004-02-23 13:56:38.000000000 +0000 @@ -1,3 +1,4 @@ +#include #include #undef mips /* CPP really sucks for this job */ @@ -44,10 +45,11 @@ SECTIONS RODATA - . = ALIGN(64); - /* writeable */ .data : { /* Data */ + . = . + MAPPED_OFFSET; /* for CONFIG_MAPPED_KERNEL */ + *(.data.init_task) + *(.data) /* Align the initial ramdisk image (INITRD) on page boundaries. */ @@ -73,23 +75,11 @@ SECTIONS . = ALIGN(4096); __nosave_end = .; - . = ALIGN(4096); - .data.page_aligned : { *(.data.idt) } - . = ALIGN(32); .data.cacheline_aligned : { *(.data.cacheline_aligned) } _edata = .; /* End of data section */ -#ifdef CONFIG_MIPS32 - . = ALIGN(8192); /* init_task */ -#endif -#ifdef CONFIG_MIPS64 - . = ALIGN(16384); /* init_task */ -#endif - . = . + MAPPED_OFFSET; /* for CONFIG_MAPPED_KERNEL */ - .data.init_task : { *(.data.init_task) } - /* will be freed after init */ . = ALIGN(4096); /* Init code and data */ __init_begin = .; @@ -108,6 +98,13 @@ SECTIONS __start___param = .; __param : { *(__param) } __stop___param = .; + + .early_initcall.init : { + __earlyinitcall_start = .; + *(.initcall.early1.init) + } + __earlyinitcall_end = .; + __initcall_start = .; .initcall.init : { *(.initcall1.init) @@ -119,6 +116,7 @@ SECTIONS *(.initcall7.init) } __initcall_end = .; + __con_initcall_start = .; .con_initcall.init : { *(.con_initcall.init) } __con_initcall_end = .; --- diff/arch/mips/lasat/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/lasat/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -7,6 +7,7 @@ obj-y += reset.o setup.o prom.o lasa obj-$(CONFIG_LASAT_SYSCTL) += sysctl.o obj-$(CONFIG_DS1603) += ds1603.o +obj-$(CONFIG_PCI) += pci.o obj-$(CONFIG_PICVUE) += picvue.o obj-$(CONFIG_PICVUE_PROC) += picvue_proc.o --- diff/arch/mips/lasat/interrupt.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/lasat/interrupt.c 2004-02-23 13:56:38.000000000 +0000 @@ -2,8 +2,6 @@ * Carsten Langgaard, carstenl@mips.com * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. * - * ######################################################################## - * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. @@ -17,13 +15,9 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * - * ######################################################################## - * * Routines for generic manipulation of the interrupts found on the * Lasat boards. - * */ -#include #include #include #include @@ -41,16 +35,9 @@ static volatile int lasat_int_mask_shift extern asmlinkage void mipsIRQ(void); -#if 0 -#define DEBUG_INT(x...) printk(x) -#else -#define DEBUG_INT(x...) -#endif - void disable_lasat_irq(unsigned int irq_nr) { unsigned long flags; - DEBUG_INT("disable_lasat_irq: %d", irq_nr); local_irq_save(flags); *lasat_int_mask &= ~(1 << irq_nr) << lasat_int_mask_shift; @@ -60,7 +47,6 @@ void disable_lasat_irq(unsigned int irq_ void enable_lasat_irq(unsigned int irq_nr) { unsigned long flags; - DEBUG_INT("enable_lasat_irq: %d", irq_nr); local_irq_save(flags); *lasat_int_mask |= (1 << irq_nr) << lasat_int_mask_shift; @@ -70,6 +56,7 @@ void enable_lasat_irq(unsigned int irq_n static unsigned int startup_lasat_irq(unsigned int irq) { enable_lasat_irq(irq); + return 0; /* never anything pending */ } @@ -111,7 +98,7 @@ static unsigned long (* get_int_status)( static unsigned long get_int_status_100(void) { - return (*lasat_int_status & *lasat_int_mask); + return *lasat_int_status & *lasat_int_mask; } static unsigned long get_int_status_200(void) @@ -132,28 +119,11 @@ void lasat_hw0_irqdispatch(struct pt_reg int_status = get_int_status(); /* if int_status == 0, then the interrupt has already been cleared */ - if (int_status == 0) - return; + if (int_status) { + irq = ls1bit32(int_status); - irq = ls1bit32(int_status); - action = irq_desc[irq].action; - - DEBUG_INT("lasat_hw0_irqdispatch: irq=%d\n", irq); - - /* if action == NULL, then we don't have a handler for the irq */ - if (action == NULL) { - printk("No handler for hw0 irq: %i\n", irq); - atomic_inc(&irq_err_count); - disable_lasat_irq(irq); - return; + do_IRQ(irq, regs); } - - irq_enter(); - kstat_this_cpu.irqs[irq]++; - action->handler(irq, action->dev_id, regs); - irq_exit(); - - return; } void __init init_IRQ(void) --- diff/arch/mips/lasat/lasatIRQ.S 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/lasat/lasatIRQ.S 2004-02-23 13:56:38.000000000 +0000 @@ -2,8 +2,6 @@ * Carsten Langgaard, carstenl@mips.com * Copyright (C) 1999, 2000 MIPS Technologies, Inc. All rights reserved. * - * ######################################################################## - * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. @@ -17,13 +15,8 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * - * ######################################################################## - * * Interrupt exception dispatch code. - * */ -#include - #include #include #include --- diff/arch/mips/lasat/lasat_board.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/lasat/lasat_board.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,11 +1,7 @@ /* - * lasat_board.c - * * Thomas Horsten * Copyright (C) 2000 LASAT Networks A/S. * - * ######################################################################## - * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. @@ -19,10 +15,9 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * - * ######################################################################## - * * Routines specific to the LASAT boards */ +#include #include #include #include --- diff/arch/mips/lasat/prom.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/lasat/prom.c 2004-02-23 13:56:38.000000000 +0000 @@ -2,7 +2,6 @@ * PROM interface routines. */ #include -#include #include #include #include @@ -85,8 +84,6 @@ static void setup_prom_vectors(void) prom_printf("prom vectors set up\n"); } -char arcs_cmdline[CL_SIZE]; - static struct at93c_defs at93c_defs[N_MACHTYPES] = { {(void *)AT93C_REG_100, (void *)AT93C_RDATA_REG_100, AT93C_RDATA_SHIFT_100, AT93C_WDATA_SHIFT_100, AT93C_CS_M_100, AT93C_CLK_M_100}, @@ -94,8 +91,11 @@ static struct at93c_defs at93c_defs[N_MA AT93C_WDATA_SHIFT_200, AT93C_CS_M_200, AT93C_CLK_M_200}, }; -void __init prom_init(int argc, char **argv, char **envp, int *prom_vec) +void __init prom_init(void) { + int argc = fw_arg0; + char **argv = (char **) fw_arg1; + setup_prom_vectors(); if (current_cpu_data.cputype == CPU_R5000) @@ -110,7 +110,7 @@ void __init prom_init(int argc, char **a mips_machgroup = MACH_GROUP_LASAT; /* Get the command line */ - if (argc>0) { + if (argc > 0) { strncpy(arcs_cmdline, argv[0], CL_SIZE-1); arcs_cmdline[CL_SIZE-1] = '\0'; } @@ -119,14 +119,15 @@ void __init prom_init(int argc, char **a set_io_port_base(KSEG1); /* Set memory regions */ - ioport_resource.start = 0; /* Should be KSEGx ??? */ - ioport_resource.end = 0xffffffff; /* Should be ??? */ + ioport_resource.start = 0; + ioport_resource.end = 0xffffffff; /* Wrong, fixme. */ add_memory_region(0, lasat_board_info.li_memsize, BOOT_MEM_RAM); } -void prom_free_prom_memory(void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } const char *get_system_type(void) --- diff/arch/mips/lasat/reset.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/lasat/reset.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,10 +1,7 @@ /* - * * Thomas Horsten * Copyright (C) 2000 LASAT Networks A/S. * - * ######################################################################## - * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. @@ -18,12 +15,9 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * - * ######################################################################## - * * Reset the LASAT board. - * */ - +#include #include #include #include --- diff/arch/mips/lasat/setup.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/lasat/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -26,20 +26,17 @@ #include #include #include -#include - #include -#include +#include +#include +#include +#include #include #include #include -#include - -#include -#include -#include #include +#include #include #ifdef CONFIG_PICVUE @@ -57,13 +54,6 @@ int lasat_command_line = 0; void lasatint_init(void); -#ifdef CONFIG_BLK_DEV_IDE -extern struct ide_ops std_ide_ops; -extern struct ide_ops *ide_ops; -#endif - -extern char arcs_cmdline[CL_SIZE]; - extern void lasat_reboot_setup(void); extern void pcisetup(void); extern void edhac_init(void *, void *, void *); @@ -122,19 +112,9 @@ static struct notifier_block lasat_panic { lasat_panic_prom_monitor, NULL, INT_MIN } }; -#ifdef CONFIG_BLK_DEV_IDE -static int lasat_ide_default_irq(ide_ioreg_t base) { - return 0; -} - -static ide_ioreg_t lasat_ide_default_io_base(int index) { - return 0; -} -#endif - static void lasat_time_init(void) { - mips_counter_frequency = lasat_board_info.li_cpu_hz / 2; + mips_hpt_frequency = lasat_board_info.li_cpu_hz / 2; } static void lasat_timer_setup(struct irqaction *irq) @@ -142,7 +122,7 @@ static void lasat_timer_setup(struct irq write_c0_compare( read_c0_count() + - mips_counter_frequency / HZ); + mips_hpt_frequency / HZ); change_c0_status(ST0_IM, IE_IRQ0 | IE_IRQ5); } @@ -182,7 +162,7 @@ void __init serial_init(void) } #endif -void __init lasat_setup(void) +static void __init lasat_setup(void) { int i; lasat_misc = &lasat_misc_info[mips_machtype]; @@ -194,12 +174,6 @@ void __init lasat_setup(void) for (i = 0; i < sizeof(lasat_panic_block) / sizeof(struct notifier_block); i++) notifier_chain_register(&panic_notifier_list, &lasat_panic_block[i]); -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &std_ide_ops; - ide_ops->ide_default_irq = &lasat_ide_default_irq; - ide_ops->ide_default_io_base = &lasat_ide_default_io_base; -#endif - lasat_reboot_setup(); board_time_init = lasat_time_init; @@ -220,4 +194,4 @@ void __init lasat_setup(void) prom_printf("Lasat specific initialization complete\n"); } - +early_initcall(lasat_setup); --- diff/arch/mips/lib-32/Makefile 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/lib-32/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,8 +2,7 @@ # Makefile for MIPS-specific library files.. # -lib-y += csum_partial.o memset.o strlen_user.o strncpy_user.o strnlen_user.o \ - watch.o +lib-y += csum_partial.o memset.o watch.o ifeq ($(CONFIG_CPU_R3000)$(CONFIG_CPU_TX39XX),y) lib-y += r3k_dump_tlb.o --- diff/arch/mips/lib-32/csum_partial.S 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/lib-32/csum_partial.S 2004-02-23 13:56:38.000000000 +0000 @@ -103,8 +103,8 @@ small_csumcpy: .align 5 LEAF(csum_partial) - move sum, zero - move t7, zero + move sum, zero + move t7, zero sltiu t8, a1, 0x8 bnez t8, small_csumcpy /* < 8 bytes to copy */ --- diff/arch/mips/lib-32/dump_tlb.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/lib-32/dump_tlb.c 2004-02-23 13:56:38.000000000 +0000 @@ -143,7 +143,7 @@ void dump_list_process(struct task_struc addr = (unsigned long) address; - printk("Addr == %08x\n", addr); + printk("Addr == %08lx\n", addr); printk("task == %8p\n", t); printk("task->mm == %8p\n", t->mm); //printk("tasks->mm.pgd == %08x\n", (unsigned int) t->mm->pgd); @@ -211,10 +211,10 @@ void dump16(unsigned long *p) { int i; - for(i = 0; i < 8; i++) { - printk("*%8p = %08lx, ", p, *p); + for (i = 0; i < 8; i++) { + printk("*%08lx == %08lx, ", (unsigned long)p, *p); p++; - printk("*%8p = %08lx\n", p, *p); + printk("*%08lx == %08lx\n", (unsigned long)p, *p); p++; } } --- diff/arch/mips/lib-32/r3k_dump_tlb.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/lib-32/r3k_dump_tlb.c 2004-02-23 13:56:38.000000000 +0000 @@ -19,8 +19,7 @@ extern int r3k_have_wired_reg; /* defined in tlb-r3k.c */ -void -dump_tlb(int first, int last) +void dump_tlb(int first, int last) { int i; unsigned int asid; @@ -28,8 +27,7 @@ dump_tlb(int first, int last) asid = read_c0_entryhi() & 0xfc0; - for(i=first;i<=last;i++) - { + for (i = first; i <= last; i++) { write_c0_index(i<<8); __asm__ __volatile__( ".set\tnoreorder\n\t" @@ -63,14 +61,12 @@ dump_tlb(int first, int last) write_c0_entryhi(asid); } -void -dump_tlb_all(void) +void dump_tlb_all(void) { dump_tlb(0, current_cpu_data.tlbsize - 1); } -void -dump_tlb_wired(void) +void dump_tlb_wired(void) { int wired = r3k_have_wired_reg ? read_c0_wired() : 8; @@ -78,10 +74,9 @@ dump_tlb_wired(void) dump_tlb(0, wired - 1); } -void -dump_tlb_addr(unsigned long addr) +void dump_tlb_addr(unsigned long addr) { - unsigned int flags, oldpid; + unsigned long flags, oldpid; int index; local_irq_save(flags); @@ -101,15 +96,13 @@ dump_tlb_addr(unsigned long addr) dump_tlb(index, index); } -void -dump_tlb_nonwired(void) +void dump_tlb_nonwired(void) { int wired = r3k_have_wired_reg ? read_c0_wired() : 8; dump_tlb(wired, current_cpu_data.tlbsize - 1); } -void -dump_list_process(struct task_struct *t, void *address) +void dump_list_process(struct task_struct *t, void *address) { pgd_t *page_dir, *pgd; pmd_t *pmd; @@ -148,14 +141,12 @@ dump_list_process(struct task_struct *t, printk("\n"); } -void -dump_list_current(void *address) +void dump_list_current(void *address) { dump_list_process(current, address); } -unsigned int -vtop(void *address) +unsigned int vtop(void *address) { pgd_t *pgd; pmd_t *pmd; @@ -172,16 +163,14 @@ vtop(void *address) return paddr; } -void -dump16(unsigned long *p) +void dump16(unsigned long *p) { int i; - for(i=0;i<8;i++) - { - printk("*%08lx == %08lx, ", - (unsigned long)p, (unsigned long)*p++); - printk("*%08lx == %08lx\n", - (unsigned long)p, (unsigned long)*p++); + for (i = 0; i < 8; i++) { + printk("*%08lx == %08lx, ", (unsigned long)p, *p); + p++; + printk("*%08lx == %08lx\n", (unsigned long)p, *p); + p++; } } --- diff/arch/mips/lib-64/Makefile 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/lib-64/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,8 +2,7 @@ # Makefile for MIPS-specific library files.. # -lib-y += csum_partial.o memset.o strlen_user.o strncpy_user.o strnlen_user.o \ - watch.o +lib-y += csum_partial.o memset.o watch.o ifeq ($(CONFIG_CPU_R3000)$(CONFIG_CPU_TX39XX),y) lib-y += r3k_dump_tlb.o --- diff/arch/mips/lib-64/dump_tlb.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/lib-64/dump_tlb.c 2004-02-23 13:56:38.000000000 +0000 @@ -200,12 +200,10 @@ void dump16(unsigned long *p) { int i; - for(i = 0; i < 8; i++) { - printk("*%08lx == %08lx, ", - (unsigned long)p, (unsigned long)*p); + for (i = 0; i < 8; i++) { + printk("*%08lx == %08lx, ", (unsigned long)p, *p); p++; - printk("*%08lx == %08lx\n", - (unsigned long)p, (unsigned long)*p); + printk("*%08lx == %08lx\n", (unsigned long)p, *p); p++; } } --- diff/arch/mips/lib/Makefile 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/lib/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,9 +2,7 @@ # Makefile for MIPS-specific library files.. # -lib-y += csum_partial_copy.o memcpy.o promlib.o rtc-no.o rtc-std.o - -lib-$(subst m,y,$(CONFIG_BLK_DEV_FD)) += floppy-no.o floppy-std.o -lib-$(subst m,y,$(CONFIG_IDE)) += ide-no.o ide-std.o +lib-y += csum_partial_copy.o dec_and_lock.o memcpy.o promlib.o strlen_user.o \ + strncpy_user.o strnlen_user.o EXTRA_AFLAGS := $(CFLAGS) --- diff/arch/mips/math-emu/cp1emu.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/math-emu/cp1emu.c 2004-02-23 13:56:38.000000000 +0000 @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -233,7 +234,7 @@ static int cop1Emulate(struct pt_regs *x fpuemuprivate.stats.errors++; return SIGBUS; } - /* __computer_return_epc() will have updated cp0_epc */ + /* __compute_return_epc() will have updated cp0_epc */ contpc = REG_TO_VA xcp->cp0_epc; /* In order not to confuse ptrace() et al, tweak context */ xcp->cp0_epc = VA_TO_REG emulpc - 4; --- diff/arch/mips/math-emu/dp_fint.c 2002-10-16 04:29:02.000000000 +0100 +++ source/arch/mips/math-emu/dp_fint.c 2004-02-23 13:56:38.000000000 +0000 @@ -33,6 +33,8 @@ ieee754dp ieee754dp_fint(int x) CLEARCX; + xc = ( 0 ? xc : xc ); + if (x == 0) return ieee754dp_zero(0); if (x == 1 || x == -1) --- diff/arch/mips/math-emu/dp_flong.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/math-emu/dp_flong.c 2004-02-23 13:56:38.000000000 +0000 @@ -33,6 +33,8 @@ ieee754dp ieee754dp_flong(s64 x) CLEARCX; + xc = ( 0 ? xc : xc ); + if (x == 0) return ieee754dp_zero(0); if (x == 1 || x == -1) --- diff/arch/mips/math-emu/kernel_linkage.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/math-emu/kernel_linkage.c 2004-02-23 13:56:38.000000000 +0000 @@ -19,6 +19,7 @@ * manipulation primitives for the Algorithmics MIPS * FPU Emulator */ +#include #include #include #include --- diff/arch/mips/math-emu/sp_fint.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/math-emu/sp_fint.c 2004-02-23 13:56:38.000000000 +0000 @@ -33,6 +33,8 @@ ieee754sp ieee754sp_fint(int x) CLEARCX; + xc = ( 0 ? xc : xc ); + if (x == 0) return ieee754sp_zero(0); if (x == 1 || x == -1) --- diff/arch/mips/math-emu/sp_flong.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/math-emu/sp_flong.c 2004-02-23 13:56:38.000000000 +0000 @@ -33,6 +33,8 @@ ieee754sp ieee754sp_flong(s64 x) CLEARCX; + xc = ( 0 ? xc : xc ); + if (x == 0) return ieee754sp_zero(0); if (x == 1 || x == -1) --- diff/arch/mips/mips-boards/atlas/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/atlas/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,8 +2,6 @@ # Carsten Langgaard, carstenl@mips.com # Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. # -# ######################################################################## -# # This program is free software; you can distribute it and/or modify it # under the terms of the GNU General Public License (Version 2) as # published by the Free Software Foundation. @@ -17,10 +15,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. # -# ####################################################################### -# -# Makefile for the MIPS Atlas specific kernel interface routines -# under Linux. -# -obj-y := atlas_int.o atlas_rtc.o atlas_setup.o +obj-y := atlas_int.o atlas_setup.o +obj-$(CONFIG_KGDB) += atlas_gdb.o --- diff/arch/mips/mips-boards/atlas/atlas_int.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/atlas/atlas_int.c 2004-02-23 13:56:38.000000000 +0000 @@ -32,13 +32,13 @@ #include #include +#include #include #include #include -struct atlas_ictrl_regs *atlas_hw0_icregs - = (struct atlas_ictrl_regs *)ATLAS_ICTRL_REGS_BASE; +static struct atlas_ictrl_regs *atlas_hw0_icregs; extern asmlinkage void mipsIRQ(void); @@ -50,12 +50,14 @@ extern asmlinkage void mipsIRQ(void); void disable_atlas_irq(unsigned int irq_nr) { - atlas_hw0_icregs->intrsten = (1 << irq_nr); + atlas_hw0_icregs->intrsten = (1 << (irq_nr-ATLASINT_BASE)); + iob(); } void enable_atlas_irq(unsigned int irq_nr) { - atlas_hw0_icregs->intseten = (1 << irq_nr); + atlas_hw0_icregs->intseten = (1 << (irq_nr-ATLASINT_BASE)); + iob(); } static unsigned int startup_atlas_irq(unsigned int irq) @@ -109,7 +111,7 @@ void atlas_hw0_irqdispatch(struct pt_reg if (unlikely(int_status == 0)) return; - irq = ls1bit32(int_status); + irq = ATLASINT_BASE + ls1bit32(int_status); DEBUG_INT("atlas_hw0_irqdispatch: irq=%d\n", irq); @@ -125,6 +127,8 @@ void __init init_IRQ(void) { int i; + atlas_hw0_icregs = (struct atlas_ictrl_regs *)ioremap (ATLAS_ICTRL_REGS_BASE, sizeof(struct atlas_ictrl_regs *)); + /* * Mask out all interrupt by writing "1" to all bit position in * the interrupt reset reg. @@ -134,7 +138,7 @@ void __init init_IRQ(void) /* Now safe to set the exception vector. */ set_except_vector(0, mipsIRQ); - for (i = 0; i <= ATLASINT_END; i++) { + for (i = ATLASINT_BASE; i <= ATLASINT_END; i++) { irq_desc[i].status = IRQ_DISABLED; irq_desc[i].action = 0; irq_desc[i].depth = 1; --- diff/arch/mips/mips-boards/atlas/atlas_setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/atlas/atlas_setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -14,117 +14,82 @@ * 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. - * - * Atlas specific setup. */ #include #include #include #include -#include #include +#include +#include +#include #include #include #include #include #include +#include #include -#include #include #include -#if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_PROM_CONSOLE) -extern void console_setup(char *, int *); -char serial_console[20]; -#endif +extern void mips_reboot_setup(void); +extern void mips_time_init(void); +extern void mips_timer_setup(struct irqaction *irq); +extern unsigned long mips_rtc_get_time(void); #ifdef CONFIG_KGDB -extern void rs_kgdb_hook(int); -extern void saa9730_kgdb_hook(void); -extern void breakpoint(void); -int remote_debug = 0; +extern void kgdb_config(void); #endif -extern struct rtc_ops atlas_rtc_ops; - -extern void mips_reboot_setup(void); +static void __init serial_init(void); const char *get_system_type(void) { return "MIPS Atlas"; } -extern void mips_time_init(void); -extern void mips_timer_setup(struct irqaction *irq); -extern unsigned long mips_rtc_get_time(void); - -void __init atlas_setup(void) +static int __init atlas_setup(void) { -#ifdef CONFIG_KGDB - int rs_putDebugChar(char); - char rs_getDebugChar(void); - int saa9730_putDebugChar(char); - char saa9730_getDebugChar(void); - extern int (*generic_putDebugChar)(char); - extern char (*generic_getDebugChar)(void); -#endif - char *argptr; - ioport_resource.end = 0x7fffffff; -#ifdef CONFIG_SERIAL_CONSOLE - argptr = prom_getcmdline(); - if ((argptr = strstr(argptr, "console=ttyS0")) == NULL) { - int i = 0; - char *s = prom_getenv("modetty0"); - while(s[i] >= '0' && s[i] <= '9') - i++; - strcpy(serial_console, "ttyS0,"); - strncpy(serial_console + 6, s, i); - prom_printf("Config serial console: %s\n", serial_console); - console_setup(serial_console, NULL); - } -#endif + serial_init (); #ifdef CONFIG_KGDB - argptr = prom_getcmdline(); - if ((argptr = strstr(argptr, "kgdb=ttyS")) != NULL) { - int line; - argptr += strlen("kgdb=ttyS"); - if (*argptr != '0' && *argptr != '1') - printk("KGDB: Uknown serial line /dev/ttyS%c, " - "falling back to /dev/ttyS1\n", *argptr); - line = *argptr == '0' ? 0 : 1; - printk("KGDB: Using serial line /dev/ttyS%d for session\n", - line ? 1 : 0); - - if(line == 0) { - rs_kgdb_hook(line); - generic_putDebugChar = rs_putDebugChar; - generic_getDebugChar = rs_getDebugChar; - } else { - saa9730_kgdb_hook(); - generic_putDebugChar = saa9730_putDebugChar; - generic_getDebugChar = saa9730_getDebugChar; - } - - prom_printf("KGDB: Using serial line /dev/ttyS%d for session, " - "please connect your debugger\n", line ? 1 : 0); - - remote_debug = 1; - /* Breakpoints and stuff are in atlas_irq_setup() */ - } + kgdb_config(); #endif - argptr = prom_getcmdline(); - - if ((argptr = strstr(argptr, "nofpu")) != NULL) - cpu_data[0].options &= ~MIPS_CPU_FPU; + mips_reboot_setup(); - rtc_ops = &atlas_rtc_ops; board_time_init = mips_time_init; board_timer_setup = mips_timer_setup; rtc_get_time = mips_rtc_get_time; - mips_reboot_setup(); + return 0; +} + +early_initcall(atlas_setup); + +static void __init serial_init(void) +{ +#ifdef CONFIG_SERIAL_8250 + struct uart_port s; + + memset(&s, 0, sizeof(s)); + +#ifdef CONFIG_CPU_LITTLE_ENDIAN + s.iobase = ATLAS_UART_REGS_BASE; +#else + s.iobase = ATLAS_UART_REGS_BASE+3; +#endif + s.irq = ATLASINT_UART; + s.uartclk = ATLAS_BASE_BAUD * 16; + s.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | UPF_RESOURCES | ASYNC_AUTO_IRQ; + s.iotype = SERIAL_IO_PORT; + s.regshift = 3; + + if (early_serial_setup(&s) != 0) { + printk(KERN_ERR "Serial setup failed!\n"); + } +#endif } --- diff/arch/mips/mips-boards/generic/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/generic/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -19,9 +19,8 @@ # obj-y := mipsIRQ.o reset.o display.o init.o memory.o \ - printf.o cmdline.o -obj-$(CONFIG_MIPS_ATLAS) += time.o -obj-$(CONFIG_MIPS_MALTA) += time.o + printf.o cmdline.o time.o +obj-$(CONFIG_PCI) += pci.o obj-$(CONFIG_KGDB) += gdb_hook.o EXTRA_AFLAGS := $(CFLAGS) --- diff/arch/mips/mips-boards/generic/cmdline.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/generic/cmdline.c 2004-02-23 13:56:38.000000000 +0000 @@ -29,9 +29,7 @@ extern int *_prom_argv; * YAMON (32-bit PROM) pass arguments and environment as 32-bit pointer. * This macro take care of sign extension. */ -#define prom_argv(index) ((char *)(((int *)(int)_prom_argv)[(index)])) - -char arcs_cmdline[CL_SIZE]; +#define prom_argv(index) ((char *)(long)_prom_argv[(index)]) char * __init prom_getcmdline(void) { --- diff/arch/mips/mips-boards/generic/display.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/generic/display.c 2004-02-23 13:56:38.000000000 +0000 @@ -2,8 +2,6 @@ * Carsten Langgaard, carstenl@mips.com * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. * - * ######################################################################## - * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. @@ -17,20 +15,21 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * - * ######################################################################## - * * Display routines for display messages in MIPS boards ascii display. - * */ +#include +#include #include - void mips_display_message(const char *str) { - volatile unsigned int *display = (void *)ASCII_DISPLAY_POS_BASE; + static volatile unsigned int *display = NULL; int i; + if (unlikely(display == NULL)) + display = (volatile unsigned int *)ioremap(ASCII_DISPLAY_POS_BASE, 16*sizeof(int)); + for (i = 0; i <= 14; i=i+2) { if (*str) display[i] = *str++; @@ -38,12 +37,3 @@ void mips_display_message(const char *st display[i] = ' '; } } - -#ifndef CONFIG_MIPS_SEAD -void mips_display_word(unsigned int num) -{ - volatile unsigned int *display = (void *)ASCII_DISPLAY_WORD_BASE; - - *display = num; -} -#endif --- diff/arch/mips/mips-boards/generic/gdb_hook.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/generic/gdb_hook.c 2004-02-23 13:56:38.000000000 +0000 @@ -17,7 +17,9 @@ * * This is the interface to the remote debugger stub. */ +#include #include +#include #include #include @@ -44,7 +46,7 @@ static __inline__ void serial_out(struct outb(value, info->port+offset); } -void rs_kgdb_hook(int tty_no) { +int rs_kgdb_hook(int tty_no, int speed) { int t; struct serial_state *ser = &rs_table[tty_no]; @@ -79,17 +81,19 @@ void rs_kgdb_hook(int tty_no) { /* * and set the speed of the serial port - * (currently hardwired to 9600 8N1 */ + if (speed == 0) + speed = 9600; - /* baud rate is fixed to 9600 (is this sufficient?)*/ - t = kdb_port_info.state->baud_base / 9600; + t = kdb_port_info.state->baud_base / speed; /* set DLAB */ serial_out(&kdb_port_info, UART_LCR, UART_LCR_WLEN8 | UART_LCR_DLAB); serial_out(&kdb_port_info, UART_DLL, t & 0xff);/* LS of divisor */ serial_out(&kdb_port_info, UART_DLM, t >> 8); /* MS of divisor */ /* reset DLAB */ serial_out(&kdb_port_info, UART_LCR, UART_LCR_WLEN8); + + return speed; } int putDebugChar(char c) @@ -126,84 +130,5 @@ char rs_getDebugChar(void) while (!(serial_in(&kdb_port_info, UART_LSR) & 1)) ; - return(serial_in(&kdb_port_info, UART_RX)); -} - - -#ifdef CONFIG_MIPS_ATLAS - -#include -#include - -#define INB(a) inb((unsigned long)a) -#define OUTB(x,a) outb(x,(unsigned long)a) - -/* - * This is the interface to the remote debugger stub - * if the Philips part is used for the debug port, - * called from the platform setup code. - * - * PCI init will not have been done yet, we make a - * universal assumption about the way the bootloader (YAMON) - * have located and set up the chip. - */ -static t_uart_saa9730_regmap *kgdb_uart = (void *)(ATLAS_SAA9730_REG + SAA9730_UART_REGS_ADDR); - -static int saa9730_kgdb_active = 0; - -void saa9730_kgdb_hook(void) -{ - volatile unsigned char t; - - /* - * Clear all interrupts - */ - t = INB(&kgdb_uart->Lsr); - t += INB(&kgdb_uart->Msr); - t += INB(&kgdb_uart->Thr_Rbr); - t += INB(&kgdb_uart->Iir_Fcr); - - /* - * Now, initialize the UART - */ - /* 8 data bits, one stop bit, no parity */ - OUTB(SAA9730_LCR_DATA8, &kgdb_uart->Lcr); - - /* baud rate is fixed to 9600 (is this sufficient?)*/ - OUTB(0, &kgdb_uart->BaudDivMsb); /* HACK - Assumes standard crystal */ - OUTB(23, &kgdb_uart->BaudDivLsb); /* HACK - known for MIPS Atlas */ - - /* Set RTS/DTR active */ - OUTB(SAA9730_MCR_DTR | SAA9730_MCR_RTS, &kgdb_uart->Mcr); - saa9730_kgdb_active = 1; -} - -int saa9730_putDebugChar(char c) -{ - - if (!saa9730_kgdb_active) { /* need to init device first */ - return 0; - } - - while (!(INB(&kgdb_uart->Lsr) & SAA9730_LSR_THRE)) - ; - OUTB(c, &kgdb_uart->Thr_Rbr); - - return 1; + return serial_in(&kdb_port_info, UART_RX); } - -char saa9730_getDebugChar(void) -{ - char c; - - if (!saa9730_kgdb_active) { /* need to init device first */ - return 0; - } - while (!(INB(&kgdb_uart->Lsr) & SAA9730_LSR_DR)) - ; - - c = INB(&kgdb_uart->Thr_Rbr); - return(c); -} - -#endif --- diff/arch/mips/mips-boards/generic/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/generic/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -23,19 +23,28 @@ #include #include +#include #include #include +#ifdef CONFIG_MIPS_GT64120 #include -#include +#endif #include #include +#ifdef CONFIG_MIPS_MALTA +#include +#endif -/* Environment variable */ -typedef struct -{ - char *name; - char *val; -} t_env_var; +#ifdef CONFIG_KGDB +extern int rs_kgdb_hook(int, int); +extern int rs_putDebugChar(char); +extern char rs_getDebugChar(void); +extern int saa9730_kgdb_hook(int); +extern int saa9730_putDebugChar(char); +extern char saa9730_getDebugChar(void); + +int remote_debug = 0; +#endif int prom_argc; int *_prom_argv, *_prom_envp; @@ -44,12 +53,22 @@ int *_prom_argv, *_prom_envp; * YAMON (32-bit PROM) pass arguments and environment as 32-bit pointer. * This macro take care of sign extension, if running in 64-bit mode. */ -#define prom_envp(index) ((char *)(((int *)(int)_prom_envp)[(index)])) +#define prom_envp(index) ((char *)(long)_prom_envp[(index)]) int init_debug = 0; unsigned int mips_revision_corid; +/* Bonito64 system controller register base. */ +unsigned long _pcictrl_bonito; +unsigned long _pcictrl_bonito_pcicfg; + +/* GT64120 system controller register base */ +unsigned long _pcictrl_gt64120; + +/* MIPS System controller register base */ +unsigned long _pcictrl_msc; + char *prom_getenv(char *envname) { /* @@ -62,21 +81,21 @@ char *prom_getenv(char *envname) i = strlen(envname); - while(prom_envp(index)) { + while (prom_envp(index)) { if(strncmp(envname, prom_envp(index), i) == 0) { return(prom_envp(index+1)); } index += 2; } - return(NULL); + return NULL; } static inline unsigned char str2hexnum(unsigned char c) { - if(c >= '0' && c <= '9') + if (c >= '0' && c <= '9') return c - '0'; - if(c >= 'a' && c <= 'f') + if (c >= 'a' && c <= 'f') return c - 'a' + 10; return 0; /* foo */ } @@ -85,7 +104,7 @@ static inline void str2eaddr(unsigned ch { int i; - for(i = 0; i < 6; i++) { + for (i = 0; i < 6; i++) { unsigned char num; if((*str == '.') || (*str == ':')) @@ -118,42 +137,150 @@ int get_ethernet_addr(char *ethernet_add return 0; } -int __init prom_init(int argc, char **argv, char **envp) +#ifdef CONFIG_SERIAL_8250_CONSOLE +static void __init console_config(void) +{ + char console_string[40]; + int baud = 0; + char parity = '\0', bits = '\0', flow = '\0'; + char *s; + + if ((strstr(prom_getcmdline(), "console=ttyS")) == NULL) { + s = prom_getenv("modetty0"); + if (s) { + while (*s >= '0' && *s <= '9') + baud = baud*10 + *s++ - '0'; + if (*s == ',') s++; + if (*s) parity = *s++; + if (*s == ',') s++; + if (*s) bits = *s++; + if (*s == ',') s++; + if (*s == 'h') flow = 'r'; + } + if (baud == 0) + baud = 38400; + if (parity != 'n' && parity != 'o' && parity != 'e') + parity = 'n'; + if (bits != '7' && bits != '8') + bits = '8'; + if (flow == '\0') + flow = 'r'; + sprintf (console_string, " console=ttyS0,%d%c%c%c", baud, parity, bits, flow); + strcat (prom_getcmdline(), console_string); + prom_printf("Config serial console:%s\n", console_string); + } +} +#endif + +#ifdef CONFIG_KGDB +void __init kgdb_config (void) +{ + extern int (*generic_putDebugChar)(char); + extern char (*generic_getDebugChar)(void); + char *argptr; + int line, speed; + + argptr = prom_getcmdline(); + if ((argptr = strstr(argptr, "kgdb=ttyS")) != NULL) { + argptr += strlen("kgdb=ttyS"); + if (*argptr != '0' && *argptr != '1') + printk("KGDB: Unknown serial line /dev/ttyS%c, " + "falling back to /dev/ttyS1\n", *argptr); + line = *argptr == '0' ? 0 : 1; + printk("KGDB: Using serial line /dev/ttyS%d for session\n", line); + + speed = 0; + if (*++argptr == ',') + { + int c; + while ((c = *++argptr) && ('0' <= c && c <= '9')) + speed = speed * 10 + c - '0'; + } +#ifdef CONFIG_MIPS_ATLAS + if (line == 1) { + speed = saa9730_kgdb_hook(speed); + generic_putDebugChar = saa9730_putDebugChar; + generic_getDebugChar = saa9730_getDebugChar; + } + else +#endif + { + speed = rs_kgdb_hook(line, speed); + generic_putDebugChar = rs_putDebugChar; + generic_getDebugChar = rs_getDebugChar; + } + + prom_printf("KGDB: Using serial line /dev/ttyS%d at %d for session, " + "please connect your debugger\n", line ? 1 : 0, speed); + + { + char *s; + for (s = "Please connect GDB to this port\r\n"; *s; ) + generic_putDebugChar (*s++); + } + + remote_debug = 1; + /* Breakpoint is invoked after interrupts are initialised */ + } +} +#endif + +void __init prom_init(void) { - prom_argc = argc; - _prom_argv = (int *)argv; - _prom_envp = (int *)envp; + prom_argc = fw_arg0; + _prom_argv = (int *) fw_arg1; + _prom_envp = (int *) fw_arg2; mips_display_message("LINUX"); #ifdef CONFIG_MIPS_SEAD set_io_port_base(KSEG1); #else + /* + * early setup of _pcictrl_bonito so that we can determine + * the system controller on a CORE_EMUL board + */ + _pcictrl_bonito = (unsigned long)ioremap(BONITO_REG_BASE, BONITO_REG_SIZE); + mips_revision_corid = MIPS_REVISION_CORID; + + if (mips_revision_corid == MIPS_REVISION_CORID_CORE_EMUL) { + if (BONITO_PCIDID == 0x0001df53 || + BONITO_PCIDID == 0x0003df53) + mips_revision_corid = MIPS_REVISION_CORID_CORE_EMUL_BON; + else + mips_revision_corid = MIPS_REVISION_CORID_CORE_EMUL_MSC; + } switch(mips_revision_corid) { case MIPS_REVISION_CORID_QED_RM5261: case MIPS_REVISION_CORID_CORE_LV: case MIPS_REVISION_CORID_CORE_FPGA: + case MIPS_REVISION_CORID_CORE_FPGAR2: /* * Setup the North bridge to do Master byte-lane swapping * when running in bigendian. */ -#if defined(__MIPSEL__) + _pcictrl_gt64120 = (unsigned long)ioremap(MIPS_GT_BASE, 0x2000); + +#ifdef CONFIG_CPU_LITTLE_ENDIAN GT_WRITE(GT_PCI0_CMD_OFS, GT_PCI0_CMD_MBYTESWAP_BIT | GT_PCI0_CMD_SBYTESWAP_BIT); #else GT_WRITE(GT_PCI0_CMD_OFS, 0); #endif -#if defined(CONFIG_MIPS_MALTA) +#ifdef CONFIG_MIPS_MALTA set_io_port_base(MALTA_GT_PORT_BASE); #else - set_io_port_base(KSEG1); + set_io_port_base((unsigned long)ioremap(0, 0x20000000)); #endif - break; + + case MIPS_REVISION_CORID_CORE_EMUL_BON: case MIPS_REVISION_CORID_BONITO64: case MIPS_REVISION_CORID_CORE_20K: + _pcictrl_bonito_pcicfg = (unsigned long)ioremap(BONITO_PCICFG_BASE, BONITO_PCICFG_SIZE); + /* * Disable Bonito IOBC. */ @@ -165,7 +292,7 @@ int __init prom_init(int argc, char **ar * Setup the North bridge to do Master byte-lane swapping * when running in bigendian. */ -#if defined(__MIPSEL__) +#ifdef CONFIG_CPU_LITTLE_ENDIAN BONITO_BONGENCFG = BONITO_BONGENCFG & ~(BONITO_BONGENCFG_MSTRBYTESWAP | BONITO_BONGENCFG_BYTESWAP); @@ -175,16 +302,19 @@ int __init prom_init(int argc, char **ar BONITO_BONGENCFG_BYTESWAP; #endif -#if defined(CONFIG_MIPS_MALTA) - set_io_port_base(MALTA_BONITO_PORT_BASE); +#ifdef CONFIG_MIPS_MALTA + set_io_port_base(MALTA_BONITO_PORT_BASE); #else - set_io_port_base(KSEG1); + set_io_port_base((unsigned long)ioremap(0, 0x20000000)); #endif break; case MIPS_REVISION_CORID_CORE_MSC: - set_io_port_base(MALTA_MSC_PORT_BASE); -#if defined(__MIPSEL__) + case MIPS_REVISION_CORID_CORE_FPGA2: + case MIPS_REVISION_CORID_CORE_EMUL_MSC: + _pcictrl_msc = (unsigned long)ioremap(MIPS_MSC01_PCI_REG_BASE, 0x2000); + +#ifdef CONFIG_CPU_LITTLE_ENDIAN MSC_WRITE(MSC01_PCI_SWAP, MSC01_PCI_SWAP_NOSWAP); #else MSC_WRITE(MSC01_PCI_SWAP, @@ -192,7 +322,14 @@ int __init prom_init(int argc, char **ar MSC01_PCI_SWAP_BYTESWAP << MSC01_PCI_SWAP_MEM_SHF | MSC01_PCI_SWAP_BYTESWAP << MSC01_PCI_SWAP_BAR0_SHF); #endif + +#ifdef CONFIG_MIPS_MALTA + set_io_port_base(MALTA_MSC_PORT_BASE); +#else + set_io_port_base((unsigned long)ioremap(0, 0x20000000)); +#endif break; + default: /* Unknown Core card */ mips_display_message("CC Error"); @@ -202,6 +339,7 @@ int __init prom_init(int argc, char **ar prom_printf("\nLINUX started...\n"); prom_init_cmdline(); prom_meminit(); - - return 0; +#ifdef CONFIG_SERIAL_8250_CONSOLE + console_config(); +#endif } --- diff/arch/mips/mips-boards/generic/memory.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/generic/memory.c 2004-02-23 13:56:38.000000000 +0000 @@ -96,10 +96,10 @@ struct prom_pmemblock * __init prom_getm mdesc[3].type = yamon_dontuse; mdesc[3].base = 0x00100000; - mdesc[3].size = PHYSADDR(PFN_ALIGN(&_end)) - mdesc[3].base; + mdesc[3].size = CPHYSADDR(PFN_ALIGN(&_end)) - mdesc[3].base; mdesc[4].type = yamon_free; - mdesc[4].base = PHYSADDR(PFN_ALIGN(&_end)); + mdesc[4].base = CPHYSADDR(PFN_ALIGN(&_end)); mdesc[4].size = memsize - mdesc[4].base; return &mdesc[0]; @@ -147,12 +147,11 @@ void __init prom_meminit(void) } } -void __init -prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { - int i; unsigned long freed = 0; unsigned long addr; + int i; for (i = 0; i < boot_mem_map.nr_map; i++) { if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA) @@ -169,4 +168,6 @@ prom_free_prom_memory (void) } } printk("Freeing prom memory: %ldkb freed\n", freed >> 10); + + return freed; } --- diff/arch/mips/mips-boards/generic/printf.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/generic/printf.c 2004-02-23 13:56:38.000000000 +0000 @@ -25,53 +25,39 @@ #include #ifdef CONFIG_MIPS_ATLAS - #include -/* - * Atlas registers are memory mapped on 64-bit aligned boundaries and - * only word access are allowed. - * When reading the UART 8 bit registers only the LSB are valid. - */ -static inline unsigned int serial_in(int offset) -{ - return (*(volatile unsigned int *)(mips_io_port_base + ATLAS_UART_REGS_BASE + offset*8) & 0xff); -} - -static inline void serial_out(int offset, int value) -{ - *(volatile unsigned int *)(mips_io_port_base + ATLAS_UART_REGS_BASE + offset*8) = value; -} +#ifdef CONFIG_CPU_LITTLE_ENDIAN +#define PORT(offset) (ATLAS_UART_REGS_BASE + ((offset)<<3)) +#else +#define PORT(offset) (ATLAS_UART_REGS_BASE + 3 + ((offset)<<3)) +#endif #elif defined(CONFIG_MIPS_SEAD) #include -/* - * SEAD registers are just like Atlas registers. - */ -static inline unsigned int serial_in(int offset) -{ - return (*(volatile unsigned int *)(mips_io_port_base + SEAD_UART0_REGS_BASE + offset*8) & 0xff); -} - -static inline void serial_out(int offset, int value) -{ - *(volatile unsigned int *)(mips_io_port_base + SEAD_UART0_REGS_BASE + offset*8) = value; -} +#ifdef CONFIG_CPU_LITTLE_ENDIAN +#define PORT(offset) (SEAD_UART0_REGS_BASE + ((offset)<<3)) +#else +#define PORT(offset) (SEAD_UART0_REGS_BASE + 3 + ((offset)<<3)) +#endif #else +#define PORT(offset) (0x3f8 + (offset)) + +#endif + static inline unsigned int serial_in(int offset) { - return inb(0x3f8 + offset); + return inb(PORT(offset)); } static inline void serial_out(int offset, int value) { - outb(value, 0x3f8 + offset); + outb(value, PORT(offset)); } -#endif int putPromChar(char c) { @@ -85,7 +71,7 @@ int putPromChar(char c) char getPromChar(void) { - while (!(serial_in(UART_LSR) & 1)) + while (!(serial_in(UART_LSR) & UART_LSR_DR)) ; return serial_in(UART_RX); @@ -102,9 +88,8 @@ void __init prom_printf(char *fmt, ...) char *p, *buf_end; long flags; - int putPromChar(char); - spin_lock_irqsave(con_lock, flags); + va_start(args, fmt); l = vsprintf(buf, fmt, args); /* hopefully i < sizeof(buf) */ va_end(args); @@ -117,5 +102,8 @@ void __init prom_printf(char *fmt, ...) putPromChar('\r'); putPromChar(*p); } + /* wait for output to drain */ + while ((serial_in(UART_LSR) & UART_LSR_TEMT) == 0) + ; spin_unlock_irqrestore(con_lock, flags); } --- diff/arch/mips/mips-boards/generic/reset.c 2002-10-16 04:28:32.000000000 +0100 +++ source/arch/mips/mips-boards/generic/reset.c 2004-02-23 13:56:38.000000000 +0000 @@ -24,6 +24,7 @@ */ #include +#include #include #include #if defined(CONFIG_MIPS_ATLAS) @@ -38,14 +39,14 @@ static void atlas_machine_power_off(void static void mips_machine_restart(char *command) { - volatile unsigned int *softres_reg = (void *)SOFTRES_REG; + volatile unsigned int *softres_reg = (unsigned int *)ioremap (SOFTRES_REG, sizeof(unsigned int)); *softres_reg = GORESET; } static void mips_machine_halt(void) { - volatile unsigned int *softres_reg = (void *)SOFTRES_REG; + volatile unsigned int *softres_reg = (unsigned int *)ioremap (SOFTRES_REG, sizeof(unsigned int)); *softres_reg = GORESET; } @@ -53,7 +54,7 @@ static void mips_machine_halt(void) #if defined(CONFIG_MIPS_ATLAS) static void atlas_machine_power_off(void) { - volatile unsigned int *psustby_reg = (void *)ATLAS_PSUSTBY_REG; + volatile unsigned int *psustby_reg = (unsigned int *)ioremap(ATLAS_PSUSTBY_REG, sizeof(unsigned int)); *psustby_reg = ATLAS_GOSTBY; } @@ -66,7 +67,7 @@ void mips_reboot_setup(void) #if defined(CONFIG_MIPS_ATLAS) _machine_power_off = atlas_machine_power_off; #endif -#if defined(CONFIG_MIPS_MALTA) +#if defined(CONFIG_MIPS_MALTA) || defined(CONFIG_MIPS_SEAD) _machine_power_off = mips_machine_halt; #endif } --- diff/arch/mips/mips-boards/generic/time.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/generic/time.c 2004-02-23 13:56:38.000000000 +0000 @@ -2,8 +2,6 @@ * Carsten Langgaard, carstenl@mips.com * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. * - * ######################################################################## - * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. @@ -17,10 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * - * ######################################################################## - * * Setting up the clock on the MIPS boards. - * */ #include @@ -40,14 +35,18 @@ #include #include #include +#include #include #include -static unsigned int r4k_offset; /* Amount to increment compare reg each time */ -static unsigned int r4k_cur; /* What counter should be at next timer irq */ +unsigned long cpu_khz; +#if defined(CONFIG_MIPS_SEAD) +#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ5) +#else #define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5) +#endif #if defined(CONFIG_MIPS_ATLAS) static char display_string[] = " LINUX ON ATLAS "; @@ -55,19 +54,16 @@ static char display_string[] = " #if defined(CONFIG_MIPS_MALTA) static char display_string[] = " LINUX ON MALTA "; #endif +#if defined(CONFIG_MIPS_SEAD) +static char display_string[] = " LINUX ON SEAD "; +#endif static unsigned int display_count = 0; #define MAX_DISPLAY_COUNT (sizeof(display_string) - 8) -#define MIPS_CPU_TIMER_IRQ 7 +#define MIPS_CPU_TIMER_IRQ (NR_IRQS-1) static unsigned int timer_tick_count=0; - -static inline void ack_r4ktimer(unsigned int newval) -{ - write_c0_compare(newval); -} - void mips_timer_interrupt(struct pt_regs *regs) { if ((timer_tick_count++ % HZ) == 0) { @@ -81,12 +77,27 @@ void mips_timer_interrupt(struct pt_regs } /* - * Figure out the r4k offset, the amount to increment the compare - * register for each time tick. - * Use the RTC to calculate offset. + * Estimate CPU frequency. Sets mips_counter_frequency as a side-effect */ -static unsigned int __init cal_r4koff(void) +static unsigned int __init estimate_cpu_frequency(void) { + unsigned int prid = read_c0_prid() & 0xffff00; + unsigned int count; + +#ifdef CONFIG_MIPS_SEAD + /* + * The SEAD board doesn't have a real time clock, so we can't + * really calculate the timer frequency + * For now we hardwire the SEAD board frequency to 12MHz. + */ + + if ((prid == (PRID_COMP_MIPS | PRID_IMP_20KC)) || + (prid == (PRID_COMP_MIPS | PRID_IMP_25KF))) + count = 12000000; + else + count = 6000000; +#endif +#if defined(CONFIG_MIPS_ATLAS) || defined(CONFIG_MIPS_MALTA) unsigned int flags; local_irq_save(flags); @@ -102,73 +113,46 @@ static unsigned int __init cal_r4koff(vo while (CMOS_READ(RTC_REG_A) & RTC_UIP); while (!(CMOS_READ(RTC_REG_A) & RTC_UIP)); - mips_counter_frequency = read_c0_count(); + count = read_c0_count(); /* restore interrupts */ local_irq_restore(flags); +#endif - return (mips_counter_frequency / HZ); + mips_hpt_frequency = count; + if ((prid != (PRID_COMP_MIPS | PRID_IMP_20KC)) && + (prid != (PRID_COMP_MIPS | PRID_IMP_25KF))) + count *= 2; + + count += 5000; /* round */ + count -= count%10000; + + return count; } unsigned long __init mips_rtc_get_time(void) { - unsigned int year, mon, day, hour, min, sec; - unsigned char save_control; - - save_control = CMOS_READ(RTC_CONTROL); - - /* Freeze it. */ - CMOS_WRITE(save_control | RTC_SET, RTC_CONTROL); - - /* Read regs. */ - sec = CMOS_READ(RTC_SECONDS); - min = CMOS_READ(RTC_MINUTES); - hour = CMOS_READ(RTC_HOURS); - - if (!(save_control & RTC_24H)) - { - if ((hour & 0xf) == 0xc) - hour &= 0x80; - if (hour & 0x80) - hour = (hour & 0xf) + 12; - } - day = CMOS_READ(RTC_DAY_OF_MONTH); - mon = CMOS_READ(RTC_MONTH); - year = CMOS_READ(RTC_YEAR); - - /* Unfreeze clock. */ - CMOS_WRITE(save_control, RTC_CONTROL); - - if ((year += 1900) < 1970) - year += 100; - - return mktime(year, mon, day, hour, min, sec); + return mc146818_get_cmos_time(); } void __init mips_time_init(void) { - unsigned int est_freq, flags; + unsigned int est_freq, flags; local_irq_save(flags); +#if defined(CONFIG_MIPS_ATLAS) || defined(CONFIG_MIPS_MALTA) /* Set Data mode - binary. */ CMOS_WRITE(CMOS_READ(RTC_CONTROL) | RTC_DM_BINARY, RTC_CONTROL); +#endif - printk("calculating r4koff... "); - r4k_offset = cal_r4koff(); - printk("%08x(%d)\n", r4k_offset, r4k_offset); - - if ((read_c0_prid() & 0xffff00) == - (PRID_COMP_MIPS | PRID_IMP_20KC)) - est_freq = r4k_offset*HZ; - else - est_freq = 2*r4k_offset*HZ; + est_freq = estimate_cpu_frequency (); - est_freq += 5000; /* round */ - est_freq -= est_freq%10000; printk("CPU frequency %d.%02d MHz\n", est_freq/1000000, (est_freq%1000000)*100/1000000); + cpu_khz = est_freq / 1000; + local_irq_restore(flags); } @@ -179,7 +163,6 @@ void __init mips_timer_setup(struct irqa setup_irq(MIPS_CPU_TIMER_IRQ, irq); /* to generate the first timer interrupt */ - r4k_cur = (read_c0_count() + r4k_offset); - write_c0_compare(r4k_cur); + write_c0_compare (read_c0_count() + mips_hpt_frequency/HZ); set_c0_status(ALLINTS); } --- diff/arch/mips/mips-boards/malta/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/malta/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,8 +2,6 @@ # Carsten Langgaard, carstenl@mips.com # Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. # -# ######################################################################## -# # This program is free software; you can distribute it and/or modify it # under the terms of the GNU General Public License (Version 2) as # published by the Free Software Foundation. @@ -17,10 +15,8 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. # -# ####################################################################### -# # Makefile for the MIPS Malta specific kernel interface routines # under Linux. # -obj-y := malta_int.o malta_rtc.o malta_setup.o +obj-y := malta_int.o malta_setup.o --- diff/arch/mips/mips-boards/malta/malta_int.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/malta/malta_int.c 2004-02-23 13:56:38.000000000 +0000 @@ -32,15 +32,14 @@ #include #include -#include #include #include #include -#include #include +#include +#include extern asmlinkage void mipsIRQ(void); -extern int mips_pcibios_iack(void); #ifdef CONFIG_KGDB extern void breakpoint(void); @@ -50,6 +49,55 @@ extern int remote_debug; static spinlock_t mips_irq_lock = SPIN_LOCK_UNLOCKED; +static inline int mips_pcibios_iack(void) +{ + int irq; + u32 dummy; + + /* + * Determine highest priority pending interrupt by performing + * a PCI Interrupt Acknowledge cycle. + */ + switch(mips_revision_corid) { + case MIPS_REVISION_CORID_CORE_MSC: + case MIPS_REVISION_CORID_CORE_FPGA2: + case MIPS_REVISION_CORID_CORE_EMUL_MSC: + MSC_READ(MSC01_PCI_IACK, irq); + irq &= 0xff; + break; + case MIPS_REVISION_CORID_QED_RM5261: + case MIPS_REVISION_CORID_CORE_LV: + case MIPS_REVISION_CORID_CORE_FPGA: + case MIPS_REVISION_CORID_CORE_FPGAR2: + irq = GT_READ(GT_PCI0_IACK_OFS); + irq &= 0xff; + break; + case MIPS_REVISION_CORID_BONITO64: + case MIPS_REVISION_CORID_CORE_20K: + case MIPS_REVISION_CORID_CORE_EMUL_BON: + /* The following will generate a PCI IACK cycle on the + * Bonito controller. It's a little bit kludgy, but it + * was the easiest way to implement it in hardware at + * the given time. + */ + BONITO_PCIMAP_CFG = 0x20000; + + /* Flush Bonito register block */ + dummy = BONITO_PCIMAP_CFG; + iob(); /* sync */ + + irq = *(volatile u32 *)(_pcictrl_bonito_pcicfg); + iob(); /* sync */ + irq &= 0xff; + BONITO_PCIMAP_CFG = 0; + break; + default: + printk("Unknown Core card, don't know the system controller.\n"); + return -1; + } + return irq; +} + static inline int get_int(int *irq) { unsigned long flags; @@ -104,18 +152,22 @@ void corehi_irqdispatch(struct pt_regs * , regs->cp0_epc, regs->cp0_status, regs->cp0_cause, regs->cp0_badvaddr); switch(mips_revision_corid) { case MIPS_REVISION_CORID_CORE_MSC: + case MIPS_REVISION_CORID_CORE_FPGA2: + case MIPS_REVISION_CORID_CORE_EMUL_MSC: break; case MIPS_REVISION_CORID_QED_RM5261: case MIPS_REVISION_CORID_CORE_LV: case MIPS_REVISION_CORID_CORE_FPGA: - GT_READ(GT_INTRCAUSE_OFS, data); + case MIPS_REVISION_CORID_CORE_FPGAR2: + data = GT_READ(GT_INTRCAUSE_OFS); printk("GT_INTRCAUSE = %08x\n", data); - GT_READ(0x70, data); - GT_READ(0x78, datahi); - printk("GT_CPU_ERR_ADDR = %0x2%08x\n", datahi,data); + data = GT_READ(0x70); + datahi = GT_READ(0x78); + printk("GT_CPU_ERR_ADDR = %02x%08x\n", datahi, data); break; case MIPS_REVISION_CORID_BONITO64: case MIPS_REVISION_CORID_CORE_20K: + case MIPS_REVISION_CORID_CORE_EMUL_BON: data = BONITO_INTISR; printk("BONITO_INTISR = %08x\n", data); data = BONITO_INTEN; --- diff/arch/mips/mips-boards/malta/malta_setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/malta/malta_setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -18,12 +18,9 @@ #include #include #include -#include #include #include -#ifdef CONFIG_BLK_DEV_IDE -#include -#endif +#include #include #include @@ -32,9 +29,6 @@ #include #include #include -#ifdef CONFIG_BLK_DEV_FD -#include -#endif #include #include #include @@ -42,54 +36,56 @@ #include #endif -#if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_PROM_CONSOLE) -extern void console_setup(char *, int *); -char serial_console[20]; -#endif - -#ifdef CONFIG_KGDB -extern void rs_kgdb_hook(int); -int remote_debug = 0; -#endif - -extern struct ide_ops std_ide_ops; -extern struct fd_ops std_fd_ops; -extern struct rtc_ops malta_rtc_ops; -extern struct kbd_ops std_kbd_ops; - extern void mips_reboot_setup(void); - extern void mips_time_init(void); extern void mips_timer_setup(struct irqaction *irq); extern unsigned long mips_rtc_get_time(void); +#ifdef CONFIG_KGDB +extern void kgdb_config(void); +#endif + struct resource standard_io_resources[] = { { "dma1", 0x00, 0x1f, IORESOURCE_BUSY }, { "timer", 0x40, 0x5f, IORESOURCE_BUSY }, + { "keyboard", 0x60, 0x6f, IORESOURCE_BUSY }, { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY }, { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY }, }; -#define STANDARD_IO_RESOURCES (sizeof(standard_io_resources)/sizeof(struct resource)) - const char *get_system_type(void) { return "MIPS Malta"; } -void __init malta_setup(void) +#ifdef CONFIG_BLK_DEV_FD +void __init fd_activate(void) { -#ifdef CONFIG_KGDB - int rs_putDebugChar(char); - char rs_getDebugChar(void); - extern int (*generic_putDebugChar)(char); - extern char (*generic_getDebugChar)(void); + /* + * Activate Floppy Controller in the SMSC FDC37M817 Super I/O + * Controller. + * Done by YAMON 2.00 onwards + */ + /* Entering config state. */ + SMSC_WRITE(SMSC_CONFIG_ENTER, SMSC_CONFIG_REG); + + /* Activate floppy controller. */ + SMSC_WRITE(SMSC_CONFIG_DEVNUM, SMSC_CONFIG_REG); + SMSC_WRITE(SMSC_CONFIG_DEVNUM_FLOPPY, SMSC_DATA_REG); + SMSC_WRITE(SMSC_CONFIG_ACTIVATE, SMSC_CONFIG_REG); + SMSC_WRITE(SMSC_CONFIG_ACTIVATE_ENABLE, SMSC_DATA_REG); + + /* Exit config state. */ + SMSC_WRITE(SMSC_CONFIG_EXIT, SMSC_CONFIG_REG); +} #endif - char *argptr; - int i; + +static int __init malta_setup(void) +{ + unsigned int i; /* Request I/O space for devices used on the Malta board. */ - for (i = 0; i < STANDARD_IO_RESOURCES; i++) + for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++) request_resource(&ioport_resource, standard_io_resources+i); /* @@ -97,54 +93,79 @@ void __init malta_setup(void) */ enable_dma(4); -#ifdef CONFIG_SERIAL_CONSOLE - argptr = prom_getcmdline(); - if ((argptr = strstr(argptr, "console=")) == NULL) { - argptr = prom_getcmdline(); - strcat(argptr, " console=ttyS0,38400"); - } +#ifdef CONFIG_KGDB + kgdb_config (); #endif -#ifdef CONFIG_KGDB - argptr = prom_getcmdline(); - if ((argptr = strstr(argptr, "kgdb=ttyS")) != NULL) { - int line; - argptr += strlen("kgdb=ttyS"); - if (*argptr != '0' && *argptr != '1') - printk("KGDB: Uknown serial line /dev/ttyS%c, " - "falling back to /dev/ttyS1\n", *argptr); - line = *argptr == '0' ? 0 : 1; - printk("KGDB: Using serial line /dev/ttyS%d for session\n", - line ? 1 : 0); - - rs_kgdb_hook(line); - generic_putDebugChar = rs_putDebugChar; - generic_getDebugChar = rs_getDebugChar; + if ((mips_revision_corid == MIPS_REVISION_CORID_BONITO64) || + (mips_revision_corid == MIPS_REVISION_CORID_CORE_20K) || + (mips_revision_corid == MIPS_REVISION_CORID_CORE_EMUL_BON)) { + char *argptr; - prom_printf("KGDB: Using serial line /dev/ttyS%d for session, " - "please connect your debugger\n", line ? 1 : 0); + argptr = prom_getcmdline(); + if (strstr(argptr, "debug")) { + BONITO_BONGENCFG |= BONITO_BONGENCFG_DEBUGMODE; + printk ("Enabled Bonito debug mode\n"); + } + else + BONITO_BONGENCFG &= ~BONITO_BONGENCFG_DEBUGMODE; + +#ifdef CONFIG_DMA_COHERENT + if (BONITO_PCICACHECTRL & BONITO_PCICACHECTRL_CPUCOH_PRES) { + BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_CPUCOH_EN; + printk("Enabled Bonito CPU coherency\n"); + + argptr = prom_getcmdline(); + if (strstr(argptr, "iobcuncached")) { + BONITO_PCICACHECTRL &= ~BONITO_PCICACHECTRL_IOBCCOH_EN; + BONITO_PCIMEMBASECFG = BONITO_PCIMEMBASECFG & + ~(BONITO_PCIMEMBASECFG_MEMBASE0_CACHED | + BONITO_PCIMEMBASECFG_MEMBASE1_CACHED); + printk("Disabled Bonito IOBC coherency\n"); + } + else { + BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_IOBCCOH_EN; + BONITO_PCIMEMBASECFG |= + (BONITO_PCIMEMBASECFG_MEMBASE0_CACHED | + BONITO_PCIMEMBASECFG_MEMBASE1_CACHED); + printk("Disabled Bonito IOBC coherency\n"); + } + } + else + panic ("Hardware DMA cache coherency not supported\n"); - remote_debug = 1; - /* Breakpoints are in init_IRQ() */ +#endif + } +#ifdef CONFIG_DMA_COHERENT + else { + panic ("Hardware DMA cache coherency not supported\n"); } #endif - argptr = prom_getcmdline(); - if ((argptr = strstr(argptr, "nofpu")) != NULL) - cpu_data[0].options &= ~MIPS_CPU_FPU; - - rtc_ops = &malta_rtc_ops; - #ifdef CONFIG_BLK_DEV_IDE - ide_ops = &std_ide_ops; + /* Check PCI clock */ + { + int jmpr = (*((volatile unsigned int *)ioremap(MALTA_JMPRS_REG, sizeof(unsigned int))) >> 2) & 0x07; + static const int pciclocks[] __initdata = { + 33, 20, 25, 30, 12, 16, 37, 10 + }; + int pciclock = pciclocks[jmpr]; + char *argptr = prom_getcmdline(); + + if (pciclock != 33 && !strstr (argptr, "idebus=")) { + printk("WARNING: PCI clock is %dMHz, setting idebus\n", pciclock); + argptr += strlen(argptr); + sprintf (argptr, " idebus=%d", pciclock); + if (pciclock < 20 || pciclock > 66) + printk ("WARNING: IDE timing calculations will be incorrect\n"); + } + } #endif #ifdef CONFIG_BLK_DEV_FD - fd_ops = &std_fd_ops; + fd_activate (); #endif #ifdef CONFIG_VT #if defined(CONFIG_VGA_CONSOLE) - conswitchp = &vga_con; - screen_info = (struct screen_info) { 0, 25, /* orig-x, orig-y */ 0, /* unused */ @@ -153,11 +174,9 @@ void __init malta_setup(void) 80, /* orig-video-cols */ 0,0,0, /* ega_ax, ega_bx, ega_cx */ 25, /* orig-video-lines */ - 1, /* orig-video-isVGA */ + VIDEO_TYPE_VGAC, /* orig-video-isVGA */ 16 /* orig-video-points */ }; -#elif defined(CONFIG_DUMMY_CONSOLE) - conswitchp = &dummy_con; #endif #endif mips_reboot_setup(); @@ -165,4 +184,8 @@ void __init malta_setup(void) board_time_init = mips_time_init; board_timer_setup = mips_timer_setup; rtc_get_time = mips_rtc_get_time; + + return 0; } + +early_initcall(malta_setup); --- diff/arch/mips/mips-boards/sead/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/sead/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -23,4 +23,4 @@ # under Linux. # -obj-y := sead_int.o sead_setup.o sead_time.o +obj-y := sead_int.o sead_setup.o --- diff/arch/mips/mips-boards/sead/sead_int.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/sead/sead_int.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,8 +1,7 @@ /* * Carsten Langgaard, carstenl@mips.com * Copyright (C) 2002 MIPS Technologies, Inc. All rights reserved. - * - * ######################################################################## + * Copyright (C) 2003 Ralf Baechle (ralf@linux-mips.org) * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as @@ -17,84 +16,29 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * - * ######################################################################## - * * Routines for generic manipulation of the interrupts found on the MIPS * Sead board. - * */ -#include #include #include -#include -#include #include -#include -#include #include extern asmlinkage void mipsIRQ(void); -void disable_sead_irq(unsigned int irq_nr) -{ - if (irq_nr == SEADINT_UART0) - clear_c0_status(0x00000400); - else - if (irq_nr == SEADINT_UART1) - clear_c0_status(0x00000800); -} - -void enable_sead_irq(unsigned int irq_nr) -{ - if (irq_nr == SEADINT_UART0) - set_c0_status(0x00000400); - else - if (irq_nr == SEADINT_UART1) - set_c0_status(0x00000800); -} - -static unsigned int startup_sead_irq(unsigned int irq) -{ - enable_sead_irq(irq); - return 0; /* never anything pending */ -} - -#define shutdown_sead_irq disable_sead_irq - -#define mask_and_ack_sead_irq disable_sead_irq - -static void end_sead_irq(unsigned int irq) -{ - if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) - enable_sead_irq(irq); -} - -static struct hw_interrupt_type sead_irq_type = { - "SEAD", - startup_sead_irq, - shutdown_sead_irq, - enable_sead_irq, - disable_sead_irq, - mask_and_ack_sead_irq, - end_sead_irq, - NULL -}; - -void sead_hw0_irqdispatch(struct pt_regs *regs) +asmlinkage void sead_hw0_irqdispatch(struct pt_regs *regs) { - do_IRQ(0, regs); + do_IRQ(SEADINT_UART0, regs); } -void sead_hw1_irqdispatch(struct pt_regs *regs) +asmlinkage void sead_hw1_irqdispatch(struct pt_regs *regs) { - do_IRQ(1, regs); + do_IRQ(SEADINT_UART1, regs); } void __init init_IRQ(void) { - int i; - /* * Mask out all interrupt */ @@ -104,12 +48,5 @@ void __init init_IRQ(void) set_except_vector(0, mipsIRQ); init_generic_irq(); - - for (i = 0; i <= SEADINT_END; i++) { - irq_desc[i].status = IRQ_DISABLED; - irq_desc[i].action = NULL; - irq_desc[i].depth = 1; - irq_desc[i].lock = SPIN_LOCK_UNLOCKED; - irq_desc[i].handler = &sead_irq_type; - } + mips_cpu_irq_init(0); } --- diff/arch/mips/mips-boards/sead/sead_setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mips-boards/sead/sead_setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -20,58 +20,65 @@ #include #include #include -#include #include +#include +#include +#include #include #include #include #include #include +#include #include #include -#if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_PROM_CONSOLE) -extern void console_setup(char *, int *); -char serial_console[20]; -#endif - extern void mips_reboot_setup(void); extern void mips_time_init(void); extern void mips_timer_setup(struct irqaction *irq); +static void __init serial_init(void); + const char *get_system_type(void) { return "MIPS SEAD"; } -void __init sead_setup(void) +static void __init sead_setup(void) { - char *argptr; - ioport_resource.end = 0x7fffffff; -#ifdef CONFIG_SERIAL_CONSOLE - argptr = prom_getcmdline(); - if ((argptr = strstr(argptr, "console=ttyS0")) == NULL) { - int i = 0; - char *s = prom_getenv("modetty0"); - while(s[i] >= '0' && s[i] <= '9') - i++; - strcpy(serial_console, "ttyS0,"); - strncpy(serial_console + 6, s, i); - prom_printf("Config serial console: %s\n", serial_console); - console_setup(serial_console, NULL); - } -#endif - - argptr = prom_getcmdline(); - - if ((argptr = strstr(argptr, "nofpu")) != NULL) - cpu_data[0].options &= ~MIPS_CPU_FPU; + serial_init (); board_time_init = mips_time_init; board_timer_setup = mips_timer_setup; mips_reboot_setup(); } + +early_initcall(sead_setup); + +static void __init serial_init(void) +{ +#ifdef CONFIG_SERIAL_8250 + struct uart_port s; + + memset(&s, 0, sizeof(s)); + +#ifdef CONFIG_CPU_LITTLE_ENDIAN + s.iobase = SEAD_UART0_REGS_BASE; +#else + s.iobase = SEAD_UART0_REGS_BASE+3; +#endif + s.irq = SEADINT_UART0; + s.uartclk = SEAD_BASE_BAUD * 16; + s.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | UPF_RESOURCES | ASYNC_AUTO_IRQ; + s.iotype = 0; + s.regshift = 3; + + if (early_serial_setup(&s) != 0) { + printk(KERN_ERR "Serial setup failed!\n"); + } +#endif +} --- diff/arch/mips/mm-32/Makefile 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/mm-32/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,19 +2,18 @@ # Makefile for the Linux/MIPS-specific parts of the memory manager. # -obj-y += init.o - -obj-$(CONFIG_CPU_TX49XX) += pg-r4k.o tlbex-r4k.o -obj-$(CONFIG_CPU_R4300) += pg-r4k.o tlbex-r4k.o -obj-$(CONFIG_CPU_R4X00) += pg-r4k.o tlbex-r4k.o -obj-$(CONFIG_CPU_VR41XX) += pg-r4k.o tlbex-r4k.o -obj-$(CONFIG_CPU_R5000) += pg-r4k.o tlbex-r4k.o -obj-$(CONFIG_CPU_NEVADA) += pg-r4k.o tlbex-r4k.o -obj-$(CONFIG_CPU_R5432) += pg-r4k.o tlbex-r4k.o -obj-$(CONFIG_CPU_RM7000) += pg-r4k.o tlbex-r4k.o -obj-$(CONFIG_CPU_R10000) += pg-r4k.o tlbex-r4k.o -obj-$(CONFIG_CPU_MIPS32) += pg-r4k.o tlbex-r4k.o -obj-$(CONFIG_CPU_MIPS64) += pg-r4k.o tlbex-r4k.o +obj-$(CONFIG_CPU_TX49XX) += tlbex-r4k.o +obj-$(CONFIG_CPU_R4300) += tlbex-r4k.o +obj-$(CONFIG_CPU_R4X00) += tlbex-r4k.o +obj-$(CONFIG_CPU_VR41XX) += tlbex-r4k.o +obj-$(CONFIG_CPU_R5000) += tlbex-r4k.o +obj-$(CONFIG_CPU_NEVADA) += tlbex-r4k.o +obj-$(CONFIG_CPU_R5432) += tlbex-r4k.o +obj-$(CONFIG_CPU_RM7000) += tlbex-r4k.o +obj-$(CONFIG_CPU_RM9000) += tlbex-r4k.o +obj-$(CONFIG_CPU_R10000) += tlbex-r4k.o +obj-$(CONFIG_CPU_MIPS32) += tlbex-r4k.o +obj-$(CONFIG_CPU_MIPS64) += tlbex-r4k.o obj-$(CONFIG_CPU_SB1) += tlbex-r4k.o EXTRA_AFLAGS := $(CFLAGS) --- diff/arch/mips/mm-32/tlbex-r4k.S 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/mm-32/tlbex-r4k.S 2004-02-23 13:56:38.000000000 +0000 @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -179,9 +178,11 @@ PTE_SRL k1, k1, 6 # convert to entrylo1 P_MTC0 k1, CP0_ENTRYLO1 # load it b 1f + rm9000_tlb_hazard tlbwr # write random tlb entry 1: nop + rm9000_tlb_hazard eret # return from trap END(except_vec0_r4000) @@ -452,6 +453,7 @@ #endif invalid_tlbl: #ifdef TLB_OPTIMIZE + .set mips3 /* Test present bit in entry. */ LOAD_PTE(k0, k1) R5K_HAZARD @@ -459,11 +461,13 @@ invalid_tlbl: PTE_PRESENT(k0, k1, nopage_tlbl) PTE_MAKEVALID(k0, k1) PTE_RELOAD(k1, k0) + rm9000_tlb_hazard nop b 1f tlbwi 1: nop + rm9000_tlb_hazard .set mips3 eret .set mips0 @@ -485,11 +489,13 @@ nopage_tlbl: PTE_WRITABLE(k0, k1, nopage_tlbs) PTE_MAKEWRITE(k0, k1) PTE_RELOAD(k1, k0) + rm9000_tlb_hazard nop b 1f tlbwi 1: nop + rm9000_tlb_hazard .set mips3 eret .set mips0 @@ -516,10 +522,12 @@ nopage_tlbs: /* Now reload the entry into the tlb. */ PTE_RELOAD(k1, k0) + rm9000_tlb_hazard nop b 1f tlbwi 1: + rm9000_tlb_hazard nop .set mips3 eret @@ -529,4 +537,3 @@ nopage_tlbs: nowrite_mod: DO_FAULT(1) END(handle_mod) - --- diff/arch/mips/mm-64/Makefile 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/mm-64/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,17 +2,18 @@ # Makefile for the Linux/MIPS-specific parts of the memory manager. # -obj-y := init.o tlbex-r4k.o +obj-y := tlbex-r4k.o -obj-$(CONFIG_CPU_R4300) += pg-r4k.o tlb-glue-r4k.o -obj-$(CONFIG_CPU_R4X00) += pg-r4k.o tlb-glue-r4k.o -obj-$(CONFIG_CPU_R5000) += pg-r4k.o tlb-glue-r4k.o -obj-$(CONFIG_CPU_NEVADA) += pg-r4k.o tlb-glue-r4k.o -obj-$(CONFIG_CPU_R5432) += pg-r4k.o tlb-glue-r4k.o -obj-$(CONFIG_CPU_RM7000) += pg-r4k.o tlb-glue-r4k.o -obj-$(CONFIG_CPU_R10000) += pg-r4k.o tlb-glue-r4k.o +obj-$(CONFIG_CPU_R4300) += tlb-glue-r4k.o +obj-$(CONFIG_CPU_R4X00) += tlb-glue-r4k.o +obj-$(CONFIG_CPU_R5000) += tlb-glue-r4k.o +obj-$(CONFIG_CPU_NEVADA) += tlb-glue-r4k.o +obj-$(CONFIG_CPU_R5432) += tlb-glue-r4k.o +obj-$(CONFIG_CPU_RM7000) += tlb-glue-r4k.o +obj-$(CONFIG_CPU_RM9000) += tlb-glue-r4k.o +obj-$(CONFIG_CPU_R10000) += tlb-glue-r4k.o obj-$(CONFIG_CPU_SB1) += tlb-glue-sb1.o -obj-$(CONFIG_CPU_MIPS64) += pg-r4k.o tlb-glue-r4k.o +obj-$(CONFIG_CPU_MIPS64) += tlb-glue-r4k.o # # Debug TLB exception handler, currently unused --- diff/arch/mips/mm-64/tlbex-r4k.S 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/mm-64/tlbex-r4k.S 2004-02-23 13:56:38.000000000 +0000 @@ -10,7 +10,9 @@ #include #include #include + #include +#include #include #include #include @@ -133,9 +135,11 @@ LEAF(handle_vec1_r4k) ld k0, 0(k1) # get even pte ld k1, 8(k1) # get odd pte PTE_RELOAD k0 k1 + rm9000_tlb_hazard b 1f tlbwr 1: nop + rm9000_tlb_hazard eret 9: # handle the vmalloc range @@ -143,9 +147,11 @@ LEAF(handle_vec1_r4k) ld k0, 0(k1) # get even pte ld k1, 8(k1) # get odd pte PTE_RELOAD k0 k1 + rm9000_tlb_hazard b 1f tlbwr 1: nop + rm9000_tlb_hazard eret END(handle_vec1_r4k) @@ -173,8 +179,10 @@ LEAF(handle_vec1_r10k) ld k0, 0(k1) # get even pte ld k1, 8(k1) # get odd pte PTE_RELOAD k0 k1 + rm9000_tlb_hazard nop tlbwr + rm9000_tlb_hazard eret 9: # handle the vmalloc range @@ -182,8 +190,10 @@ LEAF(handle_vec1_r10k) ld k0, 0(k1) # get even pte ld k1, 8(k1) # get odd pte PTE_RELOAD k0 k1 + rm9000_tlb_hazard nop tlbwr + rm9000_tlb_hazard eret END(handle_vec1_r10k) @@ -191,7 +201,11 @@ END(handle_vec1_r10k) .align 5 LEAF(invalid_vmalloc_address) .set noat + SAVE_ALL + CLI + dmfc0 t0, CP0_BADVADDR + sd t0, PT_BVADDR(sp) + move a0, sp + jal show_regs PANIC("Invalid kernel address") -1: b 1b - nop END(invalid_vmalloc_address) --- diff/arch/mips/mm/Makefile 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/mips/mm/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,30 +2,38 @@ # Makefile for the Linux/MIPS-specific parts of the memory manager. # -obj-y += cache.o fault.o loadmmu.o pgtable.o +obj-y += cache.o extable.o fault.o init.o pgtable.o obj-$(CONFIG_MIPS32) += ioremap.o pgtable-32.o obj-$(CONFIG_MIPS64) += pgtable-64.o obj-$(CONFIG_HIGHMEM) += highmem.o -obj-$(CONFIG_CPU_MIPS32) += c-r4k.o cex-gen.o tlb-r4k.o -obj-$(CONFIG_CPU_MIPS64) += c-r4k.o cex-gen.o tlb-r4k.o -obj-$(CONFIG_CPU_NEVADA) += c-r4k.o cex-gen.o tlb-r4k.o -obj-$(CONFIG_CPU_R10000) += c-r4k.o cex-gen.o tlb-andes.o -obj-$(CONFIG_CPU_R3000) += pg-r3k.o c-r3k.o tlb-r3k.o tlbex-r3k.o -obj-$(CONFIG_CPU_R4300) += c-r4k.o cex-gen.o tlb-r4k.o -obj-$(CONFIG_CPU_R4X00) += c-r4k.o cex-gen.o tlb-r4k.o -obj-$(CONFIG_CPU_R5000) += c-r4k.o cex-gen.o tlb-r4k.o -obj-$(CONFIG_CPU_R5432) += c-r4k.o cex-gen.o tlb-r4k.o -obj-$(CONFIG_CPU_RM7000) += c-r4k.o cex-gen.o tlb-r4k.o +obj-$(CONFIG_CPU_MIPS32) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o +obj-$(CONFIG_CPU_MIPS64) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o +obj-$(CONFIG_CPU_NEVADA) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o +obj-$(CONFIG_CPU_R10000) += c-r4k.o cex-gen.o pg-r4k.o tlb-andes.o +obj-$(CONFIG_CPU_R3000) += c-r3k.o tlb-r3k.o pg-r4k.o tlbex-r3k.o +obj-$(CONFIG_CPU_R4300) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o +obj-$(CONFIG_CPU_R4X00) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o +obj-$(CONFIG_CPU_R5000) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o +obj-$(CONFIG_CPU_R5432) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o +obj-$(CONFIG_CPU_RM7000) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o +obj-$(CONFIG_CPU_RM9000) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o obj-$(CONFIG_CPU_SB1) += c-sb1.o cerr-sb1.o cex-sb1.o pg-sb1.o \ tlb-sb1.o -obj-$(CONFIG_CPU_TX39XX) += c-tx39.o pg-r3k.o tlb-r3k.o tlbex-r3k.o -obj-$(CONFIG_CPU_TX49XX) += c-r4k.o cex-gen.o tlb-r4k.o -obj-$(CONFIG_CPU_VR41XX) += c-r4k.o cex-gen.o tlb-r4k.o +obj-$(CONFIG_CPU_TX39XX) += c-tx39.o pg-r4k.o tlb-r3k.o tlbex-r3k.o +obj-$(CONFIG_CPU_TX49XX) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o +obj-$(CONFIG_CPU_VR41XX) += c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o obj-$(CONFIG_CPU_RM7000) += sc-rm7k.o obj-$(CONFIG_R5000_CPU_SCACHE) += sc-r5k.o obj-$(CONFIG_SGI_IP22) += sc-ip22.o +# +# Choose one DMA coherency model +# +obj-$(CONFIG_DMA_COHERENT) += dma-coherent.o +obj-$(CONFIG_DMA_NONCOHERENT) += dma-noncoherent.o +obj-$(CONFIG_DMA_IP27) += dma-ip27.o + EXTRA_AFLAGS := $(CFLAGS) --- diff/arch/mips/mm/c-r3k.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mm/c-r3k.c 2004-02-23 13:56:38.000000000 +0000 @@ -23,9 +23,6 @@ #include #include -void r3k_clear_page(void * page); -void r3k_copy_page(void * to, void * from); - static unsigned long icache_size, dcache_size; /* Size in bytes */ static unsigned long icache_lsize, dcache_lsize; /* Size in bytes */ @@ -244,6 +241,7 @@ static inline void r3k_flush_cache_all(v static inline void r3k___flush_cache_all(void) { + r3k_flush_dcache_range(KSEG0, KSEG0 + dcache_size); r3k_flush_icache_range(KSEG0, KSEG0 + icache_size); } @@ -319,8 +317,8 @@ static void r3k_dma_cache_wback_inv(unsi void __init ld_mmu_r23000(void) { - _clear_page = r3k_clear_page; - _copy_page = r3k_copy_page; + extern void build_clear_page(void); + extern void build_copy_page(void); r3k_probe_cache(); @@ -341,4 +339,7 @@ void __init ld_mmu_r23000(void) icache_size >> 10, icache_lsize); printk("Primary data cache %ldkB, linesize %ld bytes.\n", dcache_size >> 10, dcache_lsize); + + build_clear_page(); + build_copy_page(); } --- diff/arch/mips/mm/c-r4k.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/mm/c-r4k.c 2004-02-23 13:56:38.000000000 +0000 @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -28,27 +29,6 @@ static unsigned long icache_size, dcache_size, scache_size; -extern void andes_clear_page(void * page); -extern void r4k_clear_page32_d16(void * page); -extern void r4k_clear_page32_d32(void * page); -extern void r4k_clear_page_d16(void * page); -extern void r4k_clear_page_d32(void * page); -extern void r4k_clear_page_r4600_v1(void * page); -extern void r4k_clear_page_r4600_v2(void * page); -extern void r4k_clear_page_s16(void * page); -extern void r4k_clear_page_s32(void * page); -extern void r4k_clear_page_s64(void * page); -extern void r4k_clear_page_s128(void * page); -extern void andes_copy_page(void * to, void * from); -extern void r4k_copy_page_d16(void * to, void * from); -extern void r4k_copy_page_d32(void * to, void * from); -extern void r4k_copy_page_r4600_v1(void * to, void * from); -extern void r4k_copy_page_r4600_v2(void * to, void * from); -extern void r4k_copy_page_s16(void * to, void * from); -extern void r4k_copy_page_s32(void * to, void * from); -extern void r4k_copy_page_s64(void * to, void * from); -extern void r4k_copy_page_s128(void * to, void * from); - /* * Dummy cache handling routines for machines without boardcaches */ @@ -63,247 +43,215 @@ static struct bcache_ops no_sc_ops = { struct bcache_ops *bcops = &no_sc_ops; +#define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x2010) +#define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x2020) + #define R4600_HIT_CACHEOP_WAR_IMPL \ do { \ - if (R4600_V2_HIT_CACHEOP_WAR && \ - (read_c0_prid() & 0xfff0) == 0x2020) { /* R4600 V2.0 */\ + if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x()) \ *(volatile unsigned long *)KSEG1; \ - } \ if (R4600_V1_HIT_CACHEOP_WAR) \ __asm__ __volatile__("nop;nop;nop;nop"); \ } while (0) -static void r4k_blast_dcache_page(unsigned long addr) -{ - static void *l = &&init; - unsigned long dc_lsize; - - goto *l; +static void (*r4k_blast_dcache_page)(unsigned long addr); -dc_16: - blast_dcache16_page(addr); - return; - -dc_32: +static inline void r4k_blast_dcache_page_dc32(unsigned long addr) +{ R4600_HIT_CACHEOP_WAR_IMPL; blast_dcache32_page(addr); - return; +} -init: - dc_lsize = current_cpu_data.dcache.linesz; +static inline void r4k_blast_dcache_page_setup(void) +{ + unsigned long dc_lsize = cpu_dcache_line_size(); if (dc_lsize == 16) - l = &&dc_16; + r4k_blast_dcache_page = blast_dcache16_page; else if (dc_lsize == 32) - l = &&dc_32; - goto *l; + r4k_blast_dcache_page = r4k_blast_dcache_page_dc32; } -static void r4k_blast_dcache_page_indexed(unsigned long addr) -{ - static void *l = &&init; - unsigned long dc_lsize; - - goto *l; - -dc_16: - blast_dcache16_page_indexed(addr); - return; - -dc_32: - blast_dcache32_page_indexed(addr); - return; +static void (* r4k_blast_dcache_page_indexed)(unsigned long addr); -init: - dc_lsize = current_cpu_data.dcache.linesz; +static inline void r4k_blast_dcache_page_indexed_setup(void) +{ + unsigned long dc_lsize = cpu_dcache_line_size(); if (dc_lsize == 16) - l = &&dc_16; + r4k_blast_dcache_page_indexed = blast_dcache16_page_indexed; else if (dc_lsize == 32) - l = &&dc_32; - goto *l; + r4k_blast_dcache_page_indexed = blast_dcache32_page_indexed; } -static void r4k_blast_dcache(void) -{ - static void *l = &&init; - unsigned long dc_lsize; - - goto *l; +static void (* r4k_blast_dcache)(void); -dc_16: - blast_dcache16(); - return; - -dc_32: - blast_dcache32(); - return; - -init: - dc_lsize = current_cpu_data.dcache.linesz; +static void r4k_blast_dcache_setup(void) +{ + unsigned long dc_lsize = cpu_dcache_line_size(); if (dc_lsize == 16) - l = &&dc_16; + r4k_blast_dcache = blast_dcache16; else if (dc_lsize == 32) - l = &&dc_32; - goto *l; + r4k_blast_dcache = blast_dcache32; } -static void r4k_blast_icache_page(unsigned long addr) -{ - unsigned long ic_lsize = current_cpu_data.icache.linesz; - static void *l = &&init; - - goto *l; +/* force code alignment (used for TX49XX_ICACHE_INDEX_INV_WAR) */ +#define JUMP_TO_ALIGN(order) \ + __asm__ __volatile__( \ + "b\t1f\n\t" \ + ".align\t" #order "\n\t" \ + "1:\n\t" \ + ) +#define CACHE32_UNROLL32_ALIGN JUMP_TO_ALIGN(10) /* 32 * 32 = 1024 */ +#define CACHE32_UNROLL32_ALIGN2 JUMP_TO_ALIGN(11) -ic_16: - blast_icache16_page(addr); - return; - -ic_32: - blast_icache32_page(addr); - return; +static inline void blast_r4600_v1_icache32(void) +{ + unsigned long flags; -ic_64: - blast_icache64_page(addr); - return; + local_irq_save(flags); + blast_icache32(); + local_irq_restore(flags); +} -init: - if (ic_lsize == 16) - l = &&ic_16; - else if (ic_lsize == 32) - l = &&ic_32; - else if (ic_lsize == 64) - l = &&ic_64; - goto *l; +static inline void tx49_blast_icache32(void) +{ + unsigned long start = INDEX_BASE; + unsigned long end = start + current_cpu_data.icache.waysize; + unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit; + unsigned long ws_end = current_cpu_data.icache.ways << + current_cpu_data.icache.waybit; + unsigned long ws, addr; + + CACHE32_UNROLL32_ALIGN2; + /* I'm in even chunk. blast odd chunks */ + for (ws = 0; ws < ws_end; ws += ws_inc) + for (addr = start + 0x400; addr < end; addr += 0x400 * 2) + cache32_unroll32(addr|ws,Index_Invalidate_I); + CACHE32_UNROLL32_ALIGN; + /* I'm in odd chunk. blast even chunks */ + for (ws = 0; ws < ws_end; ws += ws_inc) + for (addr = start; addr < end; addr += 0x400 * 2) + cache32_unroll32(addr|ws,Index_Invalidate_I); } -static void r4k_blast_icache_page_indexed(unsigned long addr) +static inline void blast_icache32_r4600_v1_page_indexed(unsigned long page) { - unsigned long ic_lsize = current_cpu_data.icache.linesz; - static void *l = &&init; + unsigned long flags; - goto *l; + local_irq_save(flags); + blast_icache32_page_indexed(page); + local_irq_restore(flags); +} -ic_16: - blast_icache16_page_indexed(addr); - return; +static inline void tx49_blast_icache32_page_indexed(unsigned long page) +{ + unsigned long start = page; + unsigned long end = start + PAGE_SIZE; + unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit; + unsigned long ws_end = current_cpu_data.icache.ways << + current_cpu_data.icache.waybit; + unsigned long ws, addr; + + CACHE32_UNROLL32_ALIGN2; + /* I'm in even chunk. blast odd chunks */ + for (ws = 0; ws < ws_end; ws += ws_inc) + for (addr = start + 0x400; addr < end; addr += 0x400 * 2) + cache32_unroll32(addr|ws,Index_Invalidate_I); + CACHE32_UNROLL32_ALIGN; + /* I'm in odd chunk. blast even chunks */ + for (ws = 0; ws < ws_end; ws += ws_inc) + for (addr = start; addr < end; addr += 0x400 * 2) + cache32_unroll32(addr|ws,Index_Invalidate_I); +} -ic_32: - blast_icache32_page_indexed(addr); - return; +static void (* r4k_blast_icache_page)(unsigned long addr); -ic_64: - blast_icache64_page_indexed(addr); - return; +static inline void r4k_blast_icache_page_setup(void) +{ + unsigned long ic_lsize = cpu_icache_line_size(); -init: if (ic_lsize == 16) - l = &&ic_16; + r4k_blast_icache_page = blast_icache16_page; else if (ic_lsize == 32) - l = &&ic_32; + r4k_blast_icache_page = blast_icache32_page; else if (ic_lsize == 64) - l = &&ic_64; - goto *l; + r4k_blast_icache_page = blast_icache64_page; } -static void r4k_blast_icache(void) -{ - unsigned long ic_lsize = current_cpu_data.icache.linesz; - static void *l = &&init; - goto *l; +static void (* r4k_blast_icache_page_indexed)(unsigned long addr); -ic_16: - blast_icache16(); - return; - -ic_32: - blast_icache32(); - return; - -ic_64: - blast_icache64(); - return; +static inline void r4k_blast_icache_page_indexed_setup(void) +{ + unsigned long ic_lsize = cpu_icache_line_size(); -init: if (ic_lsize == 16) - l = &&ic_16; - else if (ic_lsize == 32) - l = &&ic_32; - else if (ic_lsize == 64) - l = &&ic_64; - goto *l; + r4k_blast_icache_page_indexed = blast_icache16_page_indexed; + else if (ic_lsize == 32) { + if (TX49XX_ICACHE_INDEX_INV_WAR) + r4k_blast_icache_page_indexed = + tx49_blast_icache32_page_indexed; + else if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x()) + r4k_blast_icache_page_indexed = + blast_icache32_r4600_v1_page_indexed; + else + r4k_blast_icache_page_indexed = + blast_icache32_page_indexed; + } else if (ic_lsize == 64) + r4k_blast_icache_page_indexed = blast_icache64_page_indexed; } -static void r4k_blast_scache_page(unsigned long addr) -{ - unsigned long sc_lsize = current_cpu_data.scache.linesz; - static void *l = &&init; - - goto *l; +static void (* r4k_blast_icache)(void); -sc_16: - blast_scache16_page(addr); - return; +static inline void r4k_blast_icache_setup(void) +{ + unsigned long ic_lsize = cpu_icache_line_size(); -sc_32: - blast_scache32_page(addr); - return; + if (ic_lsize == 16) + r4k_blast_icache = blast_icache16; + else if (ic_lsize == 32) { + if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x()) + r4k_blast_icache = blast_r4600_v1_icache32; + else if (TX49XX_ICACHE_INDEX_INV_WAR) + r4k_blast_icache = tx49_blast_icache32; + else + r4k_blast_icache = blast_icache32; + } else if (ic_lsize == 64) + r4k_blast_icache = blast_icache64; +} -sc_64: - blast_scache64_page(addr); - return; +static void (* r4k_blast_scache_page)(unsigned long addr); -sc_128: - blast_scache128_page(addr); - return; +static inline void r4k_blast_scache_page_setup(void) +{ + unsigned long sc_lsize = cpu_scache_line_size(); -init: if (sc_lsize == 16) - l = &&sc_16; + r4k_blast_scache_page = blast_scache16_page; else if (sc_lsize == 32) - l = &&sc_32; + r4k_blast_scache_page = blast_scache32_page; else if (sc_lsize == 64) - l = &&sc_64; + r4k_blast_scache_page = blast_scache64_page; else if (sc_lsize == 128) - l = &&sc_128; - goto *l; + r4k_blast_scache_page = blast_scache128_page; } -static void r4k_blast_scache(void) -{ - unsigned long sc_lsize = current_cpu_data.scache.linesz; - static void *l = &&init; - - goto *l; - -sc_16: - blast_scache16(); - return; - -sc_32: - blast_scache32(); - return; - -sc_64: - blast_scache64(); - return; +static void (* r4k_blast_scache)(void); -sc_128: - blast_scache128(); - return; +static inline void r4k_blast_scache_setup(void) +{ + unsigned long sc_lsize = cpu_scache_line_size(); -init: if (sc_lsize == 16) - l = &&sc_16; + r4k_blast_scache = blast_scache16; else if (sc_lsize == 32) - l = &&sc_32; + r4k_blast_scache = blast_scache32; else if (sc_lsize == 64) - l = &&sc_64; + r4k_blast_scache = blast_scache64; else if (sc_lsize == 128) - l = &&sc_128; - goto *l; + r4k_blast_scache = blast_scache128; } static void r4k_flush_cache_all(void) @@ -334,11 +282,16 @@ static void r4k___flush_cache_all(void) static void r4k_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) { - if (cpu_context(smp_processor_id(), vma->vm_mm) != 0) { + int exec; + + if (!(cpu_context(smp_processor_id(), vma->vm_mm))) + return; + + exec = vma->vm_flags & VM_EXEC; + if (cpu_has_dc_aliases || exec) r4k_blast_dcache(); - if (vma->vm_flags & VM_EXEC) - r4k_blast_icache(); - } + if (exec) + r4k_blast_icache(); } static void r4k_flush_cache_mm(struct mm_struct *mm) @@ -410,7 +363,7 @@ static void r4k_flush_cache_page(struct * Do indexed flush, too much work to get the (possible) TLB refills * to work correctly. */ - page = (KSEG0 + (page & (dcache_size - 1))); + page = INDEX_BASE + (page & (dcache_size - 1)); if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) r4k_blast_dcache_page_indexed(page); if (exec) { @@ -493,7 +446,9 @@ static void r4k_flush_icache_page(struct */ if (cpu_has_subset_pcaches) { unsigned long addr = (unsigned long) page_address(page); + r4k_blast_scache_page(addr); + ClearPageDcacheDirty(page); return; } @@ -501,6 +456,7 @@ static void r4k_flush_icache_page(struct if (!cpu_has_ic_fills_f_dc) { unsigned long addr = (unsigned long) page_address(page); r4k_blast_dcache_page(addr); + ClearPageDcacheDirty(page); } /* @@ -516,7 +472,7 @@ static void r4k_flush_icache_page(struct r4k_blast_icache(); } -#ifdef CONFIG_NONCOHERENT_IO +#ifdef CONFIG_DMA_NONCOHERENT static void r4k_dma_cache_wback_inv(unsigned long addr, unsigned long size) { @@ -606,7 +562,7 @@ static void r4k_dma_cache_inv(unsigned l bc_inv(addr, size); } -#endif /* CONFIG_NONCOHERENT_IO */ +#endif /* CONFIG_DMA_NONCOHERENT */ /* * While we're protected against bad userland addresses we don't care @@ -621,6 +577,26 @@ static void r4k_flush_cache_sigtramp(uns R4600_HIT_CACHEOP_WAR_IMPL; protected_writeback_dcache_line(addr & ~(dc_lsize - 1)); protected_flush_icache_line(addr & ~(ic_lsize - 1)); + if (MIPS4K_ICACHE_REFILL_WAR) { + __asm__ __volatile__ ( + ".set push\n\t" + ".set noat\n\t" + ".set mips3\n\t" +#if CONFIG_MIPS32 + "la $at,1f\n\t" +#endif +#if CONFIG_MIPS64 + "dla $at,1f\n\t" +#endif + "cache %0,($at)\n\t" + "nop; nop; nop\n" + "1:\n\t" + ".set pop" + : + : "i" (Hit_Invalidate_I)); + } + if (MIPS_CACHE_SYNC_WAR) + __asm__ __volatile__ ("sync"); } static void r4k_flush_icache_all(void) @@ -638,7 +614,7 @@ static inline void rm7k_erratum31(void) write_c0_taglo(0); write_c0_taghi(0); - for (addr = KSEG0; addr <= KSEG0 + 4096; addr += ic_lsize) { + for (addr = INDEX_BASE; addr <= INDEX_BASE + 4096; addr += ic_lsize) { __asm__ __volatile__ ( ".set noreorder\n\t" ".set mips3\n\t" @@ -687,6 +663,8 @@ static void __init probe_pcache(void) c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); c->dcache.ways = 2; c->dcache.waybit= ffs(dcache_size/2) - 1; + + c->options |= MIPS_CPU_CACHE_CDEX_P; break; case CPU_R5432: @@ -700,6 +678,8 @@ static void __init probe_pcache(void) c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); c->dcache.ways = 2; c->dcache.waybit = 0; + + c->options |= MIPS_CPU_CACHE_CDEX_P; break; case CPU_TX49XX: @@ -712,6 +692,8 @@ static void __init probe_pcache(void) c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); c->dcache.ways = 4; c->dcache.waybit = 0; + + c->options |= MIPS_CPU_CACHE_CDEX_P; break; case CPU_R4000PC: @@ -730,6 +712,8 @@ static void __init probe_pcache(void) c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); c->dcache.ways = 1; c->dcache.waybit = 0; /* does not matter */ + + c->options |= MIPS_CPU_CACHE_CDEX_P; break; case CPU_R10000: @@ -743,9 +727,20 @@ static void __init probe_pcache(void) c->dcache.linesz = 32; c->dcache.ways = 2; c->dcache.waybit = 0; + + c->options |= MIPS_CPU_PREFETCH; break; + case CPU_VR4133: + write_c0_config(config & ~CONF_EB); case CPU_VR4131: + /* Workaround for cache instruction bug of VR4131 */ + if (c->processor_id == 0x0c80U || c->processor_id == 0x0c81U || + c->processor_id == 0x0c82U) { + config &= ~0x00000030U; + config |= 0x00410000U; + write_c0_config(config); + } icache_size = 1 << (10 + ((config & CONF_IC) >> 9)); c->icache.linesz = 16 << ((config & CONF_IB) >> 5); c->icache.ways = 2; @@ -755,6 +750,8 @@ static void __init probe_pcache(void) c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); c->dcache.ways = 2; c->dcache.waybit = ffs(dcache_size/2) - 1; + + c->options |= MIPS_CPU_CACHE_CDEX_P; break; case CPU_VR41XX: @@ -772,11 +769,14 @@ static void __init probe_pcache(void) c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); c->dcache.ways = 1; c->dcache.waybit = 0; /* does not matter */ + + c->options |= MIPS_CPU_CACHE_CDEX_P; break; case CPU_RM7000: rm7k_erratum31(); + case CPU_RM9000: icache_size = 1 << (12 + ((config & CONF_IC) >> 9)); c->icache.linesz = 16 << ((config & CONF_IB) >> 5); c->icache.ways = 4; @@ -786,6 +786,8 @@ static void __init probe_pcache(void) c->dcache.linesz = 16 << ((config & CONF_DB) >> 4); c->dcache.ways = 4; c->dcache.waybit = ffs(dcache_size / c->dcache.ways) - 1; + + c->options |= MIPS_CPU_CACHE_CDEX_P | MIPS_CPU_PREFETCH; break; default: @@ -810,6 +812,9 @@ static void __init probe_pcache(void) c->icache.linesz; c->icache.waybit = ffs(icache_size/c->icache.ways) - 1; + if (config & 0x8) /* VI bit */ + c->icache.flags |= MIPS_CACHE_VTAG; + /* * Now probe the MIPS32 / MIPS64 data cache. */ @@ -826,6 +831,8 @@ static void __init probe_pcache(void) c->dcache.ways * c->dcache.linesz; c->dcache.waybit = ffs(dcache_size/c->dcache.ways) - 1; + + c->options |= MIPS_CPU_PREFETCH; break; } @@ -859,9 +866,6 @@ static void __init probe_pcache(void) if (c->dcache.waysize > PAGE_SIZE) c->dcache.flags |= MIPS_CACHE_ALIASES; - if (config & 0x8) /* VI bit */ - c->icache.flags |= MIPS_CACHE_VTAG; - switch (c->cputype) { case CPU_20KC: /* @@ -949,71 +953,6 @@ static int __init probe_scache(void) return 1; } -static void __init setup_noscache_funcs(void) -{ - unsigned int prid; - - switch (current_cpu_data.dcache.linesz) { - case 16: - if (cpu_has_64bits) - _clear_page = r4k_clear_page_d16; - else - _clear_page = r4k_clear_page32_d16; - _copy_page = r4k_copy_page_d16; - - break; - case 32: - prid = read_c0_prid() & 0xfff0; - if (prid == 0x2010) { /* R4600 V1.7 */ - _clear_page = r4k_clear_page_r4600_v1; - _copy_page = r4k_copy_page_r4600_v1; - } else if (prid == 0x2020) { /* R4600 V2.0 */ - _clear_page = r4k_clear_page_r4600_v2; - _copy_page = r4k_copy_page_r4600_v2; - } else { - if (cpu_has_64bits) - _clear_page = r4k_clear_page_d32; - else - _clear_page = r4k_clear_page32_d32; - _copy_page = r4k_copy_page_d32; - } - break; - } -} - -static void __init setup_scache_funcs(void) -{ - struct cpuinfo_mips *c = ¤t_cpu_data; - - if (c->dcache.linesz > c->scache.linesz) - panic("Invalid primary cache configuration detected"); - - if (c->cputype == CPU_R10000 || c->cputype == CPU_R12000) { - _clear_page = andes_clear_page; - _copy_page = andes_copy_page; - return; - } - - switch (c->scache.linesz) { - case 16: - _clear_page = r4k_clear_page_s16; - _copy_page = r4k_copy_page_s16; - break; - case 32: - _clear_page = r4k_clear_page_s32; - _copy_page = r4k_copy_page_s32; - break; - case 64: - _clear_page = r4k_clear_page_s64; - _copy_page = r4k_copy_page_s64; - break; - case 128: - _clear_page = r4k_clear_page_s128; - _copy_page = r4k_copy_page_s128; - break; - } -} - typedef int (*probe_func_t)(unsigned long); extern int r5k_sc_init(void); extern int rm7k_sc_init(void); @@ -1031,14 +970,14 @@ static void __init setup_scache(void) * Linux memory managment. */ switch (c->cputype) { - case CPU_R4000PC: case CPU_R4000SC: case CPU_R4000MC: - case CPU_R4400PC: case CPU_R4400SC: case CPU_R4400MC: probe_scache_kseg1 = (probe_func_t) (KSEG1ADDR(&probe_scache)); sc_present = probe_scache_kseg1(config); + if (sc_present) + c->options |= MIPS_CPU_CACHE_CDEX_S; break; case CPU_R10000: @@ -1052,14 +991,13 @@ static void __init setup_scache(void) case CPU_R5000: case CPU_NEVADA: - setup_noscache_funcs(); #ifdef CONFIG_R5000_CPU_SCACHE r5k_sc_init(); #endif return; case CPU_RM7000: - setup_noscache_funcs(); + case CPU_RM9000: #ifdef CONFIG_RM7000_CPU_SCACHE rm7k_sc_init(); #endif @@ -1069,10 +1007,8 @@ static void __init setup_scache(void) sc_present = 0; } - if (!sc_present) { - setup_noscache_funcs(); + if (!sc_present) return; - } if ((c->isa_level == MIPS_CPU_ISA_M32 || c->isa_level == MIPS_CPU_ISA_M64) && @@ -1088,7 +1024,6 @@ static void __init setup_scache(void) scache_size >> 10, way_string[c->scache.ways], c->scache.linesz); c->options |= MIPS_CPU_SUBSET_CACHES; - setup_scache_funcs(); } static inline void coherency_setup(void) @@ -1112,29 +1047,38 @@ static inline void coherency_setup(void) clear_c0_config(CONF_CU); break; } - } void __init ld_mmu_r4xx0(void) { + extern void build_clear_page(void); + extern void build_copy_page(void); extern char except_vec2_generic; struct cpuinfo_mips *c = ¤t_cpu_data; /* Default cache error handler for R4000 and R5000 family */ - memcpy((void *)(KSEG0 + 0x100), &except_vec2_generic, 0x80); - memcpy((void *)(KSEG1 + 0x100), &except_vec2_generic, 0x80); + memcpy((void *)(CAC_BASE + 0x100), &except_vec2_generic, 0x80); + memcpy((void *)(UNCAC_BASE + 0x100), &except_vec2_generic, 0x80); probe_pcache(); setup_scache(); - coherency_setup(); if (c->dcache.sets * c->dcache.ways > PAGE_SIZE) c->dcache.flags |= MIPS_CACHE_ALIASES; + r4k_blast_dcache_page_setup(); + r4k_blast_dcache_page_indexed_setup(); + r4k_blast_dcache_setup(); + r4k_blast_icache_page_setup(); + r4k_blast_icache_page_indexed_setup(); + r4k_blast_icache_setup(); + r4k_blast_scache_page_setup(); + r4k_blast_scache_setup(); + /* * Some MIPS32 and MIPS64 processors have physically indexed caches. * This code supports virtually indexed processors and will be - * unnecessarily unefficient on physically indexed processors. + * unnecessarily inefficient on physically indexed processors. */ shm_align_mask = max_t( unsigned long, c->dcache.sets * c->dcache.linesz - 1, @@ -1152,11 +1096,15 @@ void __init ld_mmu_r4xx0(void) flush_data_cache_page = r4k_flush_data_cache_page; flush_icache_range = r4k_flush_icache_range; -#ifdef CONFIG_NONCOHERENT_IO +#ifdef CONFIG_DMA_NONCOHERENT _dma_cache_wback_inv = r4k_dma_cache_wback_inv; _dma_cache_wback = r4k_dma_cache_wback_inv; _dma_cache_inv = r4k_dma_cache_inv; #endif __flush_cache_all(); + coherency_setup(); + + build_clear_page(); + build_copy_page(); } --- diff/arch/mips/mm/c-sb1.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/mm/c-sb1.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,7 +1,7 @@ /* * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) * Copyright (C) 1997, 2001 Ralf Baechle (ralf@gnu.org) - * Copyright (C) 2000, 2001 Broadcom Corporation + * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -25,14 +25,7 @@ #include #include -#ifdef CONFIG_SIBYTE_DMA_PAGEOPS extern void sb1_dma_init(void); -extern void sb1_clear_page_dma(void * page); -extern void sb1_copy_page_dma(void * to, void * from); -#else -extern void sb1_clear_page(void * page); -extern void sb1_copy_page(void * to, void * from); -#endif /* These are probed at ld_mmu time */ static unsigned long icache_size; @@ -85,6 +78,11 @@ static unsigned int dcache_range_cutoff; " sync \n" \ " .set mips0") +#define mispredict() \ + __asm__ __volatile__( \ + " bnezl $0, 1f \n" /* Force mispredict */ \ + "1: \n"); + /* * Writeback and invalidate the entire dcache */ @@ -107,14 +105,18 @@ static inline void __sb1_writeback_inv_d static inline void __sb1_writeback_inv_dcache_range(unsigned long start, unsigned long end) { + unsigned long index; + start &= ~(dcache_line_size - 1); end = (end + dcache_line_size - 1) & ~(dcache_line_size - 1); while (start != end) { - cache_set_op(Index_Writeback_Inv_D, start); - cache_set_op(Index_Writeback_Inv_D, start ^ (1<<12)); + index = start & dcache_index_mask; + cache_set_op(Index_Writeback_Inv_D, index); + cache_set_op(Index_Writeback_Inv_D, index ^ (1<<12)); start += dcache_line_size; } + sync(); } /* @@ -194,6 +196,7 @@ static void sb1_flush_cache_page(struct if (!(vma->vm_flags & VM_EXEC)) return; + addr &= PAGE_MASK; args.vma = vma; args.addr = addr; on_each_cpu(sb1_flush_cache_page_ipi, (void *) &args, 1, 1); @@ -219,11 +222,7 @@ static inline void __sb1_flush_icache_ra cache_set_op(Index_Invalidate_I, start & icache_index_mask); start += icache_line_size; } - - __asm__ __volatile__( - " bnezl $0, 1f \n" /* Force mispredict */ - "1: \n"); - + mispredict(); sync(); } @@ -362,31 +361,10 @@ asm("sb1_flush_icache_page = local_sb1_f */ static void local_sb1_flush_cache_sigtramp(unsigned long addr) { - __asm__ __volatile__ ( - " .set push \n" - " .set noreorder \n" - " .set noat \n" - " .set mips4 \n" - " cache %2, (0<<13)(%0) \n" /* Index-inval this address */ - " cache %2, (1<<13)(%0) \n" /* Index-inval this address */ - " cache %2, (2<<13)(%0) \n" /* Index-inval this address */ - " cache %2, (3<<13)(%0) \n" /* Index-inval this address */ - " xori $1, %0, 1<<12 \n" /* Flip index bit 12 */ - " cache %2, (0<<13)($1) \n" /* Index-inval this address */ - " cache %2, (1<<13)($1) \n" /* Index-inval this address */ - " cache %2, (2<<13)($1) \n" /* Index-inval this address */ - " cache %2, (3<<13)($1) \n" /* Index-inval this address */ - " cache %3, (0<<13)(%1) \n" /* Index-inval this address */ - " cache %3, (1<<13)(%1) \n" /* Index-inval this address */ - " cache %3, (2<<13)(%1) \n" /* Index-inval this address */ - " cache %3, (3<<13)(%1) \n" /* Index-inval this address */ - " bnezl $0, 1f \n" /* Force mispredict */ - " nop \n" - "1: \n" - " .set pop \n" - : - : "r" (addr & dcache_index_mask), "r" (addr & icache_index_mask), - "i" (Index_Writeback_Inv_D), "i" (Index_Invalidate_I)); + cache_set_op(Index_Writeback_Inv_D, addr & dcache_index_mask); + cache_set_op(Index_Writeback_Inv_D, (addr ^ (1<<12)) & dcache_index_mask); + cache_set_op(Index_Invalidate_I, addr & icache_index_mask); + mispredict(); } #ifdef CONFIG_SMP @@ -504,20 +482,17 @@ static __init void probe_cache_sizes(voi void ld_mmu_sb1(void) { extern char except_vec2_sb1; + extern char handle_vec2_sb1; /* Special cache error handler for SB1 */ - memcpy((void *)(KSEG0 + 0x100), &except_vec2_sb1, 0x80); - memcpy((void *)(KSEG1 + 0x100), &except_vec2_sb1, 0x80); + memcpy((void *)(CAC_BASE + 0x100), &except_vec2_sb1, 0x80); + memcpy((void *)(UNCAC_BASE + 0x100), &except_vec2_sb1, 0x80); + memcpy((void *)KSEG1ADDR(&handle_vec2_sb1), &handle_vec2_sb1, 0x80); probe_cache_sizes(); #ifdef CONFIG_SIBYTE_DMA_PAGEOPS - _clear_page = sb1_clear_page_dma; - _copy_page = sb1_copy_page_dma; sb1_dma_init(); -#else - _clear_page = sb1_clear_page; - _copy_page = sb1_copy_page; #endif /* @@ -526,7 +501,6 @@ void ld_mmu_sb1(void) * occur */ flush_cache_range = (void *) sb1_nop; - flush_cache_page = sb1_flush_cache_page; flush_cache_mm = (void (*)(struct mm_struct *))sb1_nop; flush_cache_all = sb1_nop; @@ -535,6 +509,9 @@ void ld_mmu_sb1(void) flush_icache_page = sb1_flush_icache_page; flush_icache_all = __sb1_flush_icache_all; /* local only */ + /* This implies an Icache flush too, so can't be nop'ed */ + flush_cache_page = sb1_flush_cache_page; + flush_cache_sigtramp = sb1_flush_cache_sigtramp; flush_data_cache_page = (void *) sb1_nop; @@ -547,13 +524,15 @@ void ld_mmu_sb1(void) * This is the only way to force the update of K0 to complete * before subsequent instruction fetch. */ - write_c0_epc(&&here); -here: __asm__ __volatile__( + " .set noat \n" " .set noreorder \n" " .set mips3\n\t \n" + " la $1, 1f \n" + " mtc0 $1, $14 \n" " eret \n" - " .set mips0\n\t \n" + "1: .set mips0\n\t \n" + " .set at \n" " .set reorder" : : --- diff/arch/mips/mm/c-tx39.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/mm/c-tx39.c 2004-02-23 13:56:38.000000000 +0000 @@ -28,9 +28,6 @@ static unsigned long icache_size, dcache #include -extern void r3k_clear_page(void * page); -extern void r3k_copy_page(void * to, void * from); - extern int r3k_have_wired_reg; /* in r3k-tlb.c */ /* This sequence is required to ensure icache is disabled immediately */ @@ -410,11 +407,10 @@ static __init void tx39_probe_cache(void void __init ld_mmu_tx39(void) { + extern void build_clear_page(void); + extern void build_copy_page(void); unsigned long config; - _clear_page = r3k_clear_page; - _copy_page = r3k_copy_page; - config = read_c0_conf(); config &= ~TX39_CONF_WBON; write_c0_conf(config); @@ -489,4 +485,7 @@ void __init ld_mmu_tx39(void) icache_size >> 10, current_cpu_data.icache.linesz); printk("Primary data cache %ldkb, linesize %d bytes\n", dcache_size >> 10, current_cpu_data.dcache.linesz); + + build_clear_page(); + build_copy_page(); } --- diff/arch/mips/mm/cache.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/mm/cache.c 2004-02-23 13:56:38.000000000 +0000 @@ -5,12 +5,45 @@ * * Copyright (C) 1994 - 2003 by Ralf Baechle */ +#include +#include #include #include #include #include #include +#include +#include +#include + +/* Cache operations. */ +void (*flush_cache_all)(void); +void (*__flush_cache_all)(void); +void (*flush_cache_mm)(struct mm_struct *mm); +void (*flush_cache_range)(struct vm_area_struct *vma, unsigned long start, + unsigned long end); +void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page); +void (*flush_icache_range)(unsigned long start, unsigned long end); +void (*flush_icache_page)(struct vm_area_struct *vma, struct page *page); + +/* MIPS specific cache operations */ +void (*flush_cache_sigtramp)(unsigned long addr); +void (*flush_data_cache_page)(unsigned long addr); +void (*flush_icache_all)(void); + +#ifdef CONFIG_DMA_NONCOHERENT + +/* DMA cache operations. */ +void (*_dma_cache_wback_inv)(unsigned long start, unsigned long size); +void (*_dma_cache_wback)(unsigned long start, unsigned long size); +void (*_dma_cache_inv)(unsigned long start, unsigned long size); + +EXPORT_SYMBOL(_dma_cache_wback_inv); +EXPORT_SYMBOL(_dma_cache_wback); +EXPORT_SYMBOL(_dma_cache_inv); + +#endif /* CONFIG_DMA_NONCOHERENT */ asmlinkage int sys_cacheflush(void *addr, int bytes, int cache) { @@ -61,3 +94,59 @@ void __update_cache(struct vm_area_struc } EXPORT_SYMBOL(flush_dcache_page); + +extern void ld_mmu_r23000(void); +extern void ld_mmu_r4xx0(void); +extern void ld_mmu_tx39(void); +extern void ld_mmu_r6000(void); +extern void ld_mmu_tfp(void); +extern void ld_mmu_andes(void); +extern void ld_mmu_sb1(void); + +void __init cpu_cache_init(void) +{ + if (cpu_has_4ktlb) { +#if defined(CONFIG_CPU_R4X00) || defined(CONFIG_CPU_VR41XX) || \ + defined(CONFIG_CPU_R4300) || defined(CONFIG_CPU_R5000) || \ + defined(CONFIG_CPU_NEVADA) || defined(CONFIG_CPU_R5432) || \ + defined(CONFIG_CPU_R5500) || defined(CONFIG_CPU_MIPS32) || \ + defined(CONFIG_CPU_MIPS64) || defined(CONFIG_CPU_TX49XX) || \ + defined(CONFIG_CPU_RM7000) || defined(CONFIG_CPU_RM9000) + ld_mmu_r4xx0(); +#endif + } else switch (current_cpu_data.cputype) { +#ifdef CONFIG_CPU_R3000 + case CPU_R2000: + case CPU_R3000: + case CPU_R3000A: + case CPU_R3081E: + ld_mmu_r23000(); + break; +#endif +#ifdef CONFIG_CPU_TX39XX + case CPU_TX3912: + case CPU_TX3922: + case CPU_TX3927: + ld_mmu_tx39(); + break; +#endif +#ifdef CONFIG_CPU_R10000 + case CPU_R10000: + case CPU_R12000: + ld_mmu_r4xx0(); + break; +#endif +#ifdef CONFIG_CPU_SB1 + case CPU_SB1: + ld_mmu_sb1(); + break; +#endif + + case CPU_R8000: + panic("R8000 is unsupported"); + break; + + default: + panic("Yeee, unsupported cache architecture."); + } +} --- diff/arch/mips/mm/cerr-sb1.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/mm/cerr-sb1.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001 Broadcom Corporation + * Copyright (C) 2001,2002,2003 Broadcom Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -15,7 +15,7 @@ * 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 @@ -25,7 +25,7 @@ #include #include #endif - + /* SB1 definitions */ /* XXX should come from config1 XXX */ @@ -141,11 +141,11 @@ static void check_bus_watcher(void) uint32_t status, l2_err, memio_err; /* Destructive read, clears register and interrupt */ - status = csr_in32(IO_SPACE_BASE | A_SCD_BUS_ERR_STATUS); + status = csr_in32(IOADDR(A_SCD_BUS_ERR_STATUS)); /* Bit 31 is always on, but there's no #define for that */ if (status & ~(1UL << 31)) { - l2_err = csr_in32(IO_SPACE_BASE | A_BUS_L2_ERRORS); - memio_err = csr_in32(IO_SPACE_BASE | A_BUS_MEM_IO_ERRORS); + l2_err = csr_in32(IOADDR(A_BUS_L2_ERRORS)); + memio_err = csr_in32(IOADDR(A_BUS_MEM_IO_ERRORS)); prom_printf("Bus watcher error counters: %08x %08x\n", l2_err, memio_err); prom_printf("\nLast recorded signature:\n"); prom_printf("Request %02x from %d, answered by %d with Dcode %d\n", @@ -192,7 +192,9 @@ asmlinkage void sb1_cache_error(void) prom_printf(" c0_cerr_i == %08x", cerr_i); breakout_cerri(cerr_i); if (CP0_CERRI_IDX_VALID(cerr_i)) { - if ((eepc & SB1_CACHE_INDEX_MASK) != (cerr_i & SB1_CACHE_INDEX_MASK)) + /* Check index of EPC, allowing for delay slot */ + if (((eepc & SB1_CACHE_INDEX_MASK) != (cerr_i & SB1_CACHE_INDEX_MASK)) && + ((eepc & SB1_CACHE_INDEX_MASK) != ((cerr_i & SB1_CACHE_INDEX_MASK) - 4))) prom_printf(" cerr_i idx doesn't match eepc\n"); else { res = extract_ic(cerr_i & SB1_CACHE_INDEX_MASK, --- diff/arch/mips/mm/cex-sb1.S 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/mm/cex-sb1.S 2004-02-23 13:56:38.000000000 +0000 @@ -22,40 +22,122 @@ #include #include #include +#include +#include #include - .text - .set noat - .set mips4 +#define C0_ERRCTL $26 /* CP0: Error info */ +#define C0_CERR_I $27 /* CP0: Icache error */ +#define C0_CERR_D $27,1 /* CP0: Dcache error */ + + /* + * Based on SiByte sample software cache-err/cerr.S + * CVS revision 1.8. Only the 'unrecoverable' case + * is changed. + */ __INIT - - /* Cache Error handler for SB1 */ - LEAF(except_vec2_sb1) - mfc0 k1, $26 - # check if error was recoverable - bltz k1, leave_cerr -#ifdef CONFIG_SB1_PASS_1_WORKAROUNDS - # look for signature of spurious CErr - lui k0, 0x4000 - bne k0, k1, 1f - .word 0x401Bd801 # mfc0 k1, $27, 1 - lui k0, 0xffe0 - and k1, k0, k1 - lui k0, 0x0200 - beq k0, k1, leave_cerr -1: -#endif - j handle_vec2_sb1 -leave_cerr: - # clear/unlock the registers - mtc0 zero, $26 - mtc0 zero, $27 - .word 0x4080d801 # mtc0 zero, $27, 1 - .word 0x4080d803 # mtc0 zero, $27, 3 + .set mips64 + .set noreorder + .set noat + + /* + * sb1_cerr_vec: code to be copied to the Cache Error + * Exception vector. The code must be pushed out to memory + * (either by copying to Kseg0 and Kseg1 both, or by flushing + * the L1 and L2) since it is fetched as 0xa0000100. + * + * NOTE: Be sure this handler is at most 28 instructions long + * since the final 16 bytes of the exception vector memory + * (0x170-0x17f) are used to preserve k0, k1, and ra. + */ + +LEAF(except_vec2_sb1) + /* + * If this error is recoverable, we need to exit the handler + * without having dirtied any registers. To do this, + * save/restore k0 and k1 from low memory (Useg is direct + * mapped while ERL=1). Note that we can't save to a + * CPU-specific location without ruining a register in the + * process. This means we are vulnerable to data corruption + * whenever the handler is reentered by a second CPU. + */ + sd k0,0x170($0) + sd k1,0x178($0) + + /* + * M_ERRCTL_RECOVERABLE is bit 31, which makes it easy to tell + * if we can fast-path out of here for a h/w-recovered error. + */ + mfc0 k1,C0_ERRCTL + bgtz k1,attempt_recovery + sll k0,k1,1 + +recovered_dcache: + /* + * Unlock CacheErr-D (which in turn unlocks CacheErr-DPA). + * Ought to log the occurence of this recovered dcache error. + */ + b recovered + mtc0 $0,C0_CERR_D + +attempt_recovery: + /* + * k0 has C0_ERRCTL << 1, which puts 'DC' at bit 31. Any + * Dcache errors we can recover from will take more extensive + * processing. For now, they are considered "unrecoverable". + * Note that 'DC' becoming set (outside of ERL mode) will + * cause 'IC' to clear; so if there's an Icache error, we'll + * only find out about it if we recover from this error and + * continue executing. + */ + bltz k0,unrecoverable + sll k0,1 + + /* + * k0 has C0_ERRCTL << 2, which puts 'IC' at bit 31. If an + * Icache error isn't indicated, I'm not sure why we got here. + * Consider that case "unrecoverable" for now. + */ + bgez k0,unrecoverable + +attempt_icache_recovery: + /* + * External icache errors are due to uncorrectable ECC errors + * in the L2 cache or Memory Controller and cannot be + * recovered here. + */ + mfc0 k0,C0_CERR_I /* delay slot */ + li k1,1 << 26 /* ICACHE_EXTERNAL */ + and k1,k0 + bnez k1,unrecoverable + andi k0,0x1fe0 + + /* + * Since the error is internal, the 'IDX' field from + * CacheErr-I is valid and we can just invalidate all blocks + * in that set. + */ + cache Index_Invalidate_I,(0<<13)(k0) + cache Index_Invalidate_I,(1<<13)(k0) + cache Index_Invalidate_I,(2<<13)(k0) + cache Index_Invalidate_I,(3<<13)(k0) + + /* Ought to log this recovered icache error */ + +recovered: + /* Restore the saved registers */ + ld k0,0x170($0) + ld k1,0x178($0) eret - END(except_vec2_sb1) + +unrecoverable: + /* Unrecoverable Icache or Dcache error; log it and/or fail */ + j handle_vec2_sb1 + nop + +END(except_vec2_sb1) __FINIT @@ -75,7 +157,16 @@ leave_cerr: mfc0 k0, CP0_STATUS sll k0, k0, 3 # check CU0 (kernel?) bltz k0, 2f + nop + + /* Get a valid Kseg0 stack pointer. Any task's stack pointer + * will do, although if we ever want to resume execution we + * better not have corrupted any state. */ get_saved_sp -2: j sb1_cache_error + move sp, k1 + +2: + j sb1_cache_error + nop END(handle_vec2_sb1) --- diff/arch/mips/mm/fault.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/mm/fault.c 2004-02-23 13:56:38.000000000 +0000 @@ -5,7 +5,6 @@ * * Copyright (C) 1995 - 2000 by Ralf Baechle */ -#include #include #include #include @@ -18,7 +17,6 @@ #include #include #include -#include #include /* For unblank_screen() */ #include @@ -30,13 +28,6 @@ #include #include -#define development_version (LINUX_VERSION_CODE & 0x100) - -/* - * Macro for exception fixup code to access integer registers. - */ -#define dpf_reg(r) (regs->regs[r]) - /* * This routine handles page faults. It determines the address, * and the problem, and then passes it off to one of the appropriate @@ -45,19 +36,20 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write, unsigned long address) { - struct vm_area_struct * vma; + struct vm_area_struct * vma = NULL; struct task_struct *tsk = current; struct mm_struct *mm = tsk->mm; - const struct exception_table_entry *fixup; - const int szlong = sizeof(unsigned long); + const int field = sizeof(unsigned long) * 2; siginfo_t info; #if 0 printk("Cpu%d[%s:%d:%0*lx:%ld:%0*lx]\n", smp_processor_id(), - current->comm, current->pid, szlong, address, write, - szlong, regs->cp0_epc); + current->comm, current->pid, field, address, write, + field, regs->cp0_epc); #endif + info.si_code = SEGV_MAPERR; + /* * We fault-in kernel-space virtual memory on-demand. The * 'reference' page table is init_mm.pgd. @@ -67,16 +59,15 @@ asmlinkage void do_page_fault(struct pt_ * only copy the information from the master page table, * nothing more. */ - if (address >= VMALLOC_START) + if (unlikely(address >= VMALLOC_START)) goto vmalloc_fault; - info.si_code = SEGV_MAPERR; /* * If we're in an interrupt or have no user * context, we must not take the fault.. */ if (in_atomic() || !mm) - goto no_context; + goto bad_area_nosemaphore; down_read(&mm->mmap_sem); vma = find_vma(mm, address); @@ -134,6 +125,7 @@ survive: bad_area: up_read(&mm->mmap_sem); +bad_area_nosemaphore: /* User mode accesses just cause a SIGSEGV */ if (user_mode(regs)) { tsk->thread.cp0_badvaddr = address; @@ -143,9 +135,9 @@ bad_area: "invalid %s\n%0*lx (epc == %0*lx, ra == %0*lx)\n", tsk->comm, write ? "write access to" : "read access from", - szlong, address, - szlong, (unsigned long) regs->cp0_epc, - szlong, (unsigned long) regs->regs[31]); + field, address, + field, (unsigned long) regs->cp0_epc, + field, (unsigned long) regs->regs[31]); #endif info.si_signo = SIGSEGV; info.si_errno = 0; @@ -157,15 +149,8 @@ bad_area: no_context: /* Are we prepared to handle this kernel fault? */ - fixup = search_exception_tables(exception_epc(regs)); - if (fixup) { - unsigned long new_epc = fixup->nextinsn; - - tsk->thread.cp0_baduaddr = address; - if (development_version) - printk(KERN_DEBUG "%s: Exception at [<%lx>] (%lx)\n", - tsk->comm, regs->cp0_epc, new_epc); - regs->cp0_epc = new_epc; + if (fixup_exception(regs)) { + current->thread.cp0_baduaddr = address; return; } @@ -178,8 +163,8 @@ no_context: printk(KERN_ALERT "CPU %d Unable to handle kernel paging request at " "virtual address %0*lx, epc == %0*lx, ra == %0*lx\n", - smp_processor_id(), szlong, address, szlong, regs->cp0_epc, - szlong, regs->regs[31]); + smp_processor_id(), field, address, field, regs->cp0_epc, + field, regs->regs[31]); die("Oops", regs); /* @@ -201,6 +186,10 @@ out_of_memory: do_sigbus: up_read(&mm->mmap_sem); + /* Kernel mode? Handle exceptions or die */ + if (!user_mode(regs)) + goto no_context; + /* * Send a sigbus, regardless of whether we were in kernel * or user mode. @@ -212,10 +201,6 @@ do_sigbus: info.si_addr = (void *) address; force_sig_info(SIGBUS, &info, tsk); - /* Kernel mode? Handle exceptions or die */ - if (!user_mode(regs)) - goto no_context; - return; vmalloc_fault: --- diff/arch/mips/mm/highmem.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/mips/mm/highmem.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,3 +1,4 @@ +#include #include #include #include --- diff/arch/mips/mm/pg-sb1.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/mm/pg-sb1.c 2004-02-23 13:56:38.000000000 +0000 @@ -22,6 +22,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include +#include #include #include @@ -38,8 +39,11 @@ #define SB1_PREF_STORE_STREAMED_HINT "5" #endif -/* These are the functions hooked by the memory management function pointers */ -void sb1_clear_page(void *page) +#ifdef CONFIG_SIBYTE_DMA_PAGEOPS +static inline void clear_page_cpu(void *page) +#else +void clear_page(void *page) +#endif { unsigned char *addr = (unsigned char *) page; unsigned char *end = addr + PAGE_SIZE; @@ -77,7 +81,11 @@ void sb1_clear_page(void *page) } while (addr != end); } -void sb1_copy_page(void *to, void *from) +#ifdef CONFIG_SIBYTE_DMA_PAGEOPS +static inline void copy_page_cpu(void *to, void *from) +#else +void copy_page(void *to, void *from) +#endif { unsigned char *src = from; unsigned char *dst = to; @@ -157,55 +165,58 @@ void sb1_dma_init(void) uint64_t base_val = PHYSADDR(&page_descr[cpu]) | V_DM_DSCR_BASE_RINGSZ(1); __raw_writeq(base_val, - IO_SPACE_BASE + A_DM_REGISTER(cpu, R_DM_DSCR_BASE)); + IOADDR(A_DM_REGISTER(cpu, R_DM_DSCR_BASE))); __raw_writeq(base_val | M_DM_DSCR_BASE_RESET, - IO_SPACE_BASE + A_DM_REGISTER(cpu, R_DM_DSCR_BASE)); + IOADDR(A_DM_REGISTER(cpu, R_DM_DSCR_BASE))); __raw_writeq(base_val | M_DM_DSCR_BASE_ENABL, - IO_SPACE_BASE + A_DM_REGISTER(cpu, R_DM_DSCR_BASE)); + IOADDR(A_DM_REGISTER(cpu, R_DM_DSCR_BASE))); } -void sb1_clear_page_dma(void *page) +void clear_page(void *page) { int cpu = smp_processor_id(); /* if the page is above Kseg0, use old way */ - if (KSEGX(page) != K0BASE) - return sb1_clear_page(page); + if (KSEGX(page) != CAC_BASE) + return clear_page_cpu(page); page_descr[cpu].dscr_a = PHYSADDR(page) | M_DM_DSCRA_ZERO_MEM | M_DM_DSCRA_L2C_DEST | M_DM_DSCRA_INTERRUPT; page_descr[cpu].dscr_b = V_DM_DSCRB_SRC_LENGTH(PAGE_SIZE); - __raw_writeq(1, IO_SPACE_BASE + A_DM_REGISTER(cpu, R_DM_DSCR_COUNT)); + __raw_writeq(1, IOADDR(A_DM_REGISTER(cpu, R_DM_DSCR_COUNT))); /* * Don't really want to do it this way, but there's no * reliable way to delay completion detection. */ - while (!(__raw_readq(IO_SPACE_BASE + A_DM_REGISTER(cpu, R_DM_DSCR_BASE_DEBUG)) & M_DM_DSCR_BASE_INTERRUPT)) + while (!(__raw_readq(IOADDR(A_DM_REGISTER(cpu, R_DM_DSCR_BASE_DEBUG)) & M_DM_DSCR_BASE_INTERRUPT))) ; - __raw_readq(IO_SPACE_BASE + A_DM_REGISTER(cpu, R_DM_DSCR_BASE)); + __raw_readq(IOADDR(A_DM_REGISTER(cpu, R_DM_DSCR_BASE))); } -void sb1_copy_page_dma(void *to, void *from) +void copy_page(void *to, void *from) { unsigned long from_phys = PHYSADDR(from); unsigned long to_phys = PHYSADDR(to); int cpu = smp_processor_id(); /* if either page is above Kseg0, use old way */ - if ((KSEGX(to) != K0BASE) || (KSEGX(from) != K0BASE)) - return sb1_copy_page(to, from); + if ((KSEGX(to) != CAC_BASE) || (KSEGX(from) != CAC_BASE)) + return copy_page_cpu(to, from); page_descr[cpu].dscr_a = PHYSADDR(to_phys) | M_DM_DSCRA_L2C_DEST | M_DM_DSCRA_INTERRUPT; page_descr[cpu].dscr_b = PHYSADDR(from_phys) | V_DM_DSCRB_SRC_LENGTH(PAGE_SIZE); - __raw_writeq(1, IO_SPACE_BASE + A_DM_REGISTER(cpu, R_DM_DSCR_COUNT)); + __raw_writeq(1, IOADDR(A_DM_REGISTER(cpu, R_DM_DSCR_COUNT))); /* * Don't really want to do it this way, but there's no * reliable way to delay completion detection. */ - while (!(__raw_readq(IO_SPACE_BASE + A_DM_REGISTER(cpu, R_DM_DSCR_BASE_DEBUG)) & M_DM_DSCR_BASE_INTERRUPT)) + while (!(__raw_readq(IOADDR(A_DM_REGISTER(cpu, R_DM_DSCR_BASE_DEBUG)) & M_DM_DSCR_BASE_INTERRUPT))) ; - __raw_readq(IO_SPACE_BASE + A_DM_REGISTER(cpu, R_DM_DSCR_BASE)); + __raw_readq(IOADDR(A_DM_REGISTER(cpu, R_DM_DSCR_BASE))); } #endif + +EXPORT_SYMBOL(clear_page); +EXPORT_SYMBOL(copy_page); --- diff/arch/mips/mm/pgtable-32.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/mm/pgtable-32.c 2004-02-23 13:56:38.000000000 +0000 @@ -5,8 +5,11 @@ * * Copyright (C) 2003 by Ralf Baechle */ +#include #include #include +#include +#include #include void pgd_init(unsigned long page) @@ -26,6 +29,37 @@ void pgd_init(unsigned long page) } } +#ifdef CONFIG_HIGHMEM +static void __init fixrange_init (unsigned long start, unsigned long end, + pgd_t *pgd_base) +{ + pgd_t *pgd; + pmd_t *pmd; + pte_t *pte; + int i, j; + unsigned long vaddr; + + vaddr = start; + i = __pgd_offset(vaddr); + j = __pmd_offset(vaddr); + pgd = pgd_base + i; + + for ( ; (i < PTRS_PER_PGD) && (vaddr != end); pgd++, i++) { + pmd = (pmd_t *)pgd; + for (; (j < PTRS_PER_PMD) && (vaddr != end); pmd++, j++) { + if (pmd_none(*pmd)) { + pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); + set_pmd(pmd, __pmd((unsigned long)pte)); + if (pte != pte_offset_kernel(pmd, 0)) + BUG(); + } + vaddr += PMD_SIZE; + } + j = 0; + } +} +#endif + void __init pagetable_init(void) { #ifdef CONFIG_HIGHMEM --- diff/arch/mips/mm/pgtable-64.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/mm/pgtable-64.c 2004-02-23 13:56:38.000000000 +0000 @@ -64,7 +64,7 @@ void __init pagetable_init(void) memset((void *)kptbl, 0, PAGE_SIZE << PGD_ORDER); memset((void *)kpmdtbl, 0, PAGE_SIZE); - set_pgd(swapper_pg_dir, __pgd(kpmdtbl)); + set_pgd(swapper_pg_dir, __pgd((unsigned long)kpmdtbl)); /* * The 64-bit kernel uses a flat pagetable for it's kernel mappings ... --- diff/arch/mips/mm/pgtable.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mm/pgtable.c 2004-02-23 13:56:38.000000000 +0000 @@ -4,6 +4,7 @@ void show_mem(void) { +#ifndef CONFIG_DISCONTIGMEM /* XXX(hch): later.. */ int pfn, total = 0, reserved = 0; int shared = 0, cached = 0; int highmem = 0; @@ -30,4 +31,5 @@ void show_mem(void) printk("%d reserved pages\n",reserved); printk("%d pages shared\n",shared); printk("%d pages swap cached\n",cached); +#endif } --- diff/arch/mips/mm/sc-r5k.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mm/sc-r5k.c 2004-02-23 13:56:38.000000000 +0000 @@ -14,6 +14,7 @@ #include #include #include +#include /* Secondary cache size in bytes, if present. */ static unsigned long scache_size; @@ -21,24 +22,13 @@ static unsigned long scache_size; #define SC_LINE 32 #define SC_PAGE (128*SC_LINE) -#define cache_op(base,op) \ -__asm__ __volatile__(" \ - .set noreorder; \ - .set mips3; \ - cache %1, (%0); \ - .set mips0; \ - .set reorder" \ - : \ - : "r" (base), \ - "i" (op)); - static inline void blast_r5000_scache(void) { - unsigned long start = KSEG0; - unsigned long end = KSEG0 + scache_size; + unsigned long start = INDEX_BASE; + unsigned long end = start + scache_size; while(start < end) { - cache_op(start, R5K_Page_Invalidate_S); + cache_op(R5K_Page_Invalidate_S, start); start += SC_PAGE; } } @@ -59,7 +49,7 @@ static void r5k_dma_cache_inv_sc(unsigne a = addr & ~(SC_PAGE - 1); end = (addr + size - 1) & ~(SC_PAGE - 1); while (a <= end) { - cache_op(a, R5K_Page_Invalidate_S); + cache_op(R5K_Page_Invalidate_S, a); a += SC_PAGE; } } @@ -69,7 +59,7 @@ static void r5k_sc_enable(void) unsigned long flags; local_irq_save(flags); - change_c0_config(R5K_CONF_SE, R5K_CONF_SE); + set_c0_config(R5K_CONF_SE); blast_r5000_scache(); local_irq_restore(flags); } @@ -80,7 +70,7 @@ static void r5k_sc_disable(void) local_irq_save(flags); blast_r5000_scache(); - change_c0_config(R5K_CONF_SE, 0); + clear_c0_config(R5K_CONF_SE); local_irq_restore(flags); } --- diff/arch/mips/mm/sc-rm7k.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mm/sc-rm7k.c 2004-02-23 13:56:38.000000000 +0000 @@ -129,7 +129,7 @@ static __init void rm7k_sc_enable(void) static void rm7k_sc_disable(void) { - set_c0_config(1<<3); /* CONF_SE */ + clear_c0_config(1<<3); /* CONF_SE */ } static inline int __init rm7k_sc_probe(void) @@ -140,11 +140,11 @@ static inline int __init rm7k_sc_probe(v if ((config >> 31) & 1) return 0; - printk(KERN_INFO "Secondary cache size %ldK, linesize 32 bytes.\n", + printk(KERN_INFO "Secondary cache size %ldK, linesize %ld bytes.\n", (scache_size >> 10), sc_lsize); - if ((config >> 3) & 1) - return; + if ((config >> 3) & 1) /* CONF_SE */ + return 1; printk(KERN_INFO "Enabling secondary cache..."); func(); --- diff/arch/mips/mm/tlb-andes.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/mm/tlb-andes.c 2004-02-23 13:56:38.000000000 +0000 @@ -7,6 +7,7 @@ * Copyright (C) 1999 Silicon Graphics, Inc. * Copyright (C) 2000 Kanoj Sarcar (kanoj@sgi.com) */ +#include #include #include #include @@ -16,6 +17,9 @@ #include #include +extern void except_vec0_generic(void); +extern void except_vec0_r4000(void); +extern void except_vec1_generic(void); extern void except_vec1_r10k(void); #define NTLB_ENTRIES 64 @@ -235,7 +239,7 @@ void __update_tlb(struct vm_area_struct local_irq_restore(flags); } -void __init andes_tlb_init(void) +void __init tlb_init(void) { /* * You should never change this register: @@ -253,5 +257,14 @@ void __init andes_tlb_init(void) /* Did I tell you that ARC SUCKS? */ - memcpy((void *)KSEG1 + 0x080, except_vec1_r10k, 0x80); +#ifdef CONFIG_MIPS32 + memcpy((void *)KSEG0, &except_vec0_r4000, 0x80); + memcpy((void *)(KSEG0 + 0x080), &except_vec1_generic, 0x80); + flush_icache_range(KSEG0, KSEG0 + 0x100); +#endif +#ifdef CONFIG_MIPS64 + memcpy((void *)(CKSEG0 + 0x000), &except_vec0_generic, 0x80); + memcpy((void *)(CKSEG0 + 0x080), except_vec1_r10k, 0x80); + flush_icache_range(CKSEG0 + 0x80, CKSEG0 + 0x100); +#endif } --- diff/arch/mips/mm/tlb-r3k.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mm/tlb-r3k.c 2004-02-23 13:56:38.000000000 +0000 @@ -10,7 +10,6 @@ * Copyright (C) 2002 Ralf Baechle * Copyright (C) 2002 Maciej W. Rozycki */ -#include #include #include #include @@ -282,7 +281,7 @@ void __init add_wired_entry(unsigned lon } } -void __init r3k_tlb_init(void) +void __init tlb_init(void) { local_flush_tlb_all(); memcpy((void *)KSEG0, &except_vec0_r2300, 0x80); --- diff/arch/mips/mm/tlb-r4k.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/mm/tlb-r4k.c 2004-02-23 13:56:38.000000000 +0000 @@ -19,9 +19,11 @@ #include #include +extern void except_vec0_generic(void); extern void except_vec0_nevada(void); extern void except_vec0_r4000(void); extern void except_vec0_r4600(void); +extern void except_vec1_generic(void); extern void except_vec1_r4k(void); /* CP0 hazard avoidance. */ @@ -50,7 +52,7 @@ void local_flush_tlb_all(void) * Make sure all entries differ. If they're not different * MIPS32 will take revenge ... */ - write_c0_entryhi(KSEG0 + entry * 0x2000); + write_c0_entryhi(CKSEG0 + (entry << (PAGE_SHIFT + 1))); write_c0_index(entry); BARRIER; tlb_write_indexed(); @@ -104,7 +106,8 @@ void local_flush_tlb_range(struct vm_are if (idx < 0) continue; /* Make sure all entries differ. */ - write_c0_entryhi(KSEG0 + idx * 0x2000); + write_c0_entryhi(CKSEG0 + + (idx << (PAGE_SHIFT + 1))); BARRIER; tlb_write_indexed(); BARRIER; @@ -146,7 +149,7 @@ void local_flush_tlb_kernel_range(unsign if (idx < 0) continue; /* Make sure all entries differ. */ - write_c0_entryhi(KSEG0 + idx * 0x2000); + write_c0_entryhi(CKSEG0 + (idx << (PAGE_SHIFT + 1))); BARRIER; tlb_write_indexed(); BARRIER; @@ -180,7 +183,7 @@ void local_flush_tlb_page(struct vm_area if (idx < 0) goto finish; /* Make sure all entries differ. */ - write_c0_entryhi(KSEG0 + idx * 0x2000); + write_c0_entryhi(CKSEG0 + (idx << (PAGE_SHIFT + 1))); BARRIER; tlb_write_indexed(); @@ -212,7 +215,7 @@ void local_flush_tlb_one(unsigned long p write_c0_entrylo1(0); if (idx >= 0) { /* Make sure all entries differ. */ - write_c0_entryhi(KSEG0+(idx<<(PAGE_SHIFT+1))); + write_c0_entryhi(CKSEG0 + (idx << (PAGE_SHIFT + 1))); BARRIER; tlb_write_indexed(); } @@ -378,25 +381,25 @@ out: static void __init probe_tlb(unsigned long config) { - unsigned int prid, config1; + struct cpuinfo_mips *c = ¤t_cpu_data; + unsigned int reg; - prid = read_c0_prid() & ASID_MASK; - if (prid == PRID_IMP_RM7000 || !(config & (1 << 31))) - /* - * Not a MIPS32/MIPS64 CPU.. Config 1 register not - * supported, we assume R4k style. Cpu probing already figured - * out the number of tlb entries. - */ + /* + * If this isn't a MIPS32 / MIPS64 compliant CPU. Config 1 register + * is not supported, we assume R4k style. Cpu probing already figured + * out the number of tlb entries. + */ + if ((c->processor_id & 0xff0000) == PRID_COMP_LEGACY) return; - config1 = read_c0_config1(); + reg = read_c0_config1(); if (!((config >> 7) & 3)) - panic("No MMU present"); - else - current_cpu_data.tlbsize = ((config1 >> 25) & 0x3f) + 1; + panic("No TLB present"); + + c->tlbsize = ((reg >> 25) & 0x3f) + 1; } -void __init r4k_tlb_init(void) +void __init tlb_init(void) { unsigned int config = read_c0_config(); @@ -408,7 +411,7 @@ void __init r4k_tlb_init(void) * be set for 4kb pages. */ probe_tlb(config); - write_c0_pagemask(PM_4K); + write_c0_pagemask(PM_DEFAULT_MASK); write_c0_wired(0); temp_tlb_entry = current_cpu_data.tlbsize - 1; local_flush_tlb_all(); @@ -420,10 +423,12 @@ void __init r4k_tlb_init(void) memcpy((void *)KSEG0, &except_vec0_r4600, 0x80); else memcpy((void *)KSEG0, &except_vec0_r4000, 0x80); - flush_icache_range(KSEG0, KSEG0 + 0x80); + memcpy((void *)(KSEG0 + 0x080), &except_vec1_generic, 0x80); + flush_icache_range(KSEG0, KSEG0 + 0x100); #endif #ifdef CONFIG_MIPS64 - memcpy((void *)(KSEG0 + 0x80), except_vec1_r4k, 0x80); - flush_icache_range(KSEG0 + 0x80, KSEG0 + 0x100); + memcpy((void *)(CKSEG0 + 0x00), &except_vec0_generic, 0x80); + memcpy((void *)(CKSEG0 + 0x80), except_vec1_r4k, 0x80); + flush_icache_range(CKSEG0 + 0x80, CKSEG0 + 0x100); #endif } --- diff/arch/mips/mm/tlb-sb1.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/mm/tlb-sb1.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,7 +1,7 @@ /* * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) * Copyright (C) 1997, 2001 Ralf Baechle (ralf@gnu.org) - * Copyright (C) 2000, 2001 Broadcom Corporation + * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -18,12 +18,21 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include +#include #include #include #include +#ifdef CONFIG_MIPS32 extern void except_vec0_sb1(void); +extern void except_vec1_generic(void); +#endif +#ifdef CONFIG_MIPS64 +extern void except_vec0_generic(void); extern void except_vec1_sb1(void); +#endif + +#define UNIQUE_ENTRYHI(idx) (KSEG0 + ((idx) << (PAGE_SHIFT + 1))) /* Dump the current entry* and pagemask registers */ static inline void dump_cur_tlb_regs(void) @@ -96,10 +105,13 @@ void local_flush_tlb_all(void) old_ctx = read_c0_entryhi() & ASID_MASK; write_c0_entrylo0(0); write_c0_entrylo1(0); - for (entry = 0; entry < current_cpu_data.tlbsize; entry++) { - write_c0_entryhi(KSEG0 + (PAGE_SIZE << 1) * entry); + + entry = read_c0_wired(); + while (entry < current_cpu_data.tlbsize) { + write_c0_entryhi(UNIQUE_ENTRYHI(entry)); write_c0_index(entry); tlb_write_indexed(); + entry++; } write_c0_entryhi(old_ctx); local_irq_restore(flags); @@ -111,7 +123,7 @@ void local_flush_tlb_all(void) * Use increments of the maximum page size (16MB), and check for duplicate * entries before doing a given write. Then, when we're safe from collisions * with the firmware, go back and give all the entries invalid addresses with - * the normal flush routine. + * the normal flush routine. Wired entries will be killed as well! */ void sb1_sanitize_tlb(void) { @@ -165,7 +177,7 @@ void local_flush_tlb_range(struct vm_are idx = read_c0_index(); write_c0_entrylo0(0); write_c0_entrylo1(0); - write_c0_entryhi(KSEG0 + (idx << (PAGE_SHIFT+1))); + write_c0_entryhi(UNIQUE_ENTRYHI(idx)); if (idx < 0) continue; tlb_write_indexed(); @@ -203,7 +215,7 @@ void local_flush_tlb_kernel_range(unsign idx = read_c0_index(); write_c0_entrylo0(0); write_c0_entrylo1(0); - write_c0_entryhi(KSEG0 + (idx << (PAGE_SHIFT+1))); + write_c0_entryhi(UNIQUE_ENTRYHI(idx)); if (idx < 0) continue; tlb_write_indexed(); @@ -231,10 +243,10 @@ void local_flush_tlb_page(struct vm_area idx = read_c0_index(); write_c0_entrylo0(0); write_c0_entrylo1(0); - if(idx < 0) + if (idx < 0) goto finish; /* Make sure all entries differ. */ - write_c0_entryhi(KSEG0+(idx<<(PAGE_SHIFT+1))); + write_c0_entryhi(UNIQUE_ENTRYHI(idx)); tlb_write_indexed(); finish: write_c0_entryhi(oldpid); @@ -243,29 +255,30 @@ void local_flush_tlb_page(struct vm_area } /* - * This one is only used for pages with the global bit set so we don't care - * much about the ASID. + * Remove one kernel space TLB entry. This entry is assumed to be marked + * global so we don't do the ASID thing. */ void local_flush_tlb_one(unsigned long page) { unsigned long flags; int oldpid, idx; - local_irq_save(flags); page &= (PAGE_MASK << 1); oldpid = read_c0_entryhi() & ASID_MASK; + + local_irq_save(flags); write_c0_entryhi(page); tlb_probe(); idx = read_c0_index(); - write_c0_entrylo0(0); - write_c0_entrylo1(0); if (idx >= 0) { /* Make sure all entries differ. */ - write_c0_entryhi(KSEG0+(idx<<(PAGE_SHIFT+1))); + write_c0_entryhi(UNIQUE_ENTRYHI(idx)); + write_c0_entrylo0(0); + write_c0_entrylo1(0); tlb_write_indexed(); } - write_c0_entryhi(oldpid); + write_c0_entryhi(oldpid); local_irq_restore(flags); } @@ -315,14 +328,43 @@ void __update_tlb(struct vm_area_struct local_irq_restore(flags); } +void __init add_wired_entry(unsigned long entrylo0, unsigned long entrylo1, + unsigned long entryhi, unsigned long pagemask) +{ + unsigned long flags; + unsigned long wired; + unsigned long old_pagemask; + unsigned long old_ctx; + + local_irq_save(flags); + old_ctx = read_c0_entryhi() & 0xff; + old_pagemask = read_c0_pagemask(); + wired = read_c0_wired(); + write_c0_wired(wired + 1); + write_c0_index(wired); + + write_c0_pagemask(pagemask); + write_c0_entryhi(entryhi); + write_c0_entrylo0(entrylo0); + write_c0_entrylo1(entrylo1); + tlb_write_indexed(); + + write_c0_entryhi(old_ctx); + write_c0_pagemask(old_pagemask); + + local_flush_tlb_all(); + local_irq_restore(flags); +} + /* * This is called from loadmmu.c. We have to set up all the * memory management function pointers, as well as initialize * the caches and tlbs */ -void sb1_tlb_init(void) +void tlb_init(void) { - write_c0_pagemask(PM_4K); + write_c0_pagemask(PM_DEFAULT_MASK); + write_c0_wired(0); /* * We don't know what state the firmware left the TLB's in, so this is @@ -332,11 +374,13 @@ void sb1_tlb_init(void) sb1_sanitize_tlb(); #ifdef CONFIG_MIPS32 - memcpy((void *)KSEG0, except_vec0_sb1, 0x80); - flush_icache_range(KSEG0, KSEG0 + 0x80); + memcpy((void *)KSEG0, &except_vec0_sb1, 0x80); + memcpy((void *)(KSEG0 + 0x080), &except_vec1_generic, 0x80); + flush_icache_range(KSEG0, KSEG0 + 0x100); #endif #ifdef CONFIG_MIPS64 - memcpy((void *)KSEG0 + 0x80, except_vec1_sb1, 0x80); - flush_icache_range(KSEG0 + 0x80, KSEG0 + 0x100); + memcpy((void *)CKSEG0, &except_vec0_generic, 0x80); + memcpy((void *)(CKSEG0 + 0x80), &except_vec1_sb1, 0x80); + flush_icache_range(CKSEG0, CKSEG0 + 0x100); #endif } --- diff/arch/mips/mm/tlbex-r3k.S 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/mm/tlbex-r3k.S 2004-02-23 13:56:38.000000000 +0000 @@ -19,7 +19,6 @@ #include #include #include -#include #include #include --- diff/arch/mips/momentum/ocelot_c/cpci-irq.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_c/cpci-irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include --- diff/arch/mips/momentum/ocelot_c/int-handler.S 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_c/int-handler.S 2004-02-23 13:56:38.000000000 +0000 @@ -12,8 +12,6 @@ * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ -#define __ASSEMBLY__ -#include #include #include #include --- diff/arch/mips/momentum/ocelot_c/irq.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_c/irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -28,6 +28,7 @@ * 675 Mass Ave, Cambridge, MA 02139, USA. * */ +#include #include #include #include @@ -47,120 +48,31 @@ #include #include - -static spinlock_t irq_lock = SPIN_LOCK_UNLOCKED; - -/* Function for careful CP0 interrupt mask access */ -static inline void modify_cp0_intmask(unsigned clr_mask_in, unsigned set_mask_in) -{ - unsigned long status; - unsigned clr_mask; - unsigned set_mask; - - /* do the low 8 bits first */ - clr_mask = 0xff & clr_mask_in; - set_mask = 0xff & set_mask_in; - status = read_c0_status(); - status &= ~((clr_mask & 0xFF) << 8); - status |= (set_mask & 0xFF) << 8; - write_c0_status(status); -} - -static inline void mask_irq(unsigned int irq) -{ - modify_cp0_intmask(irq, 0); -} - -static inline void unmask_irq(unsigned int irq) -{ - modify_cp0_intmask(0, irq); -} - -static void enable_cp7000_irq(unsigned int irq) -{ - unsigned long flags; - - spin_lock_irqsave(&irq_lock, flags); - unmask_irq(1 << irq); - spin_unlock_irqrestore(&irq_lock, flags); -} - -static unsigned int startup_cp7000_irq(unsigned int irq) -{ - enable_cp7000_irq(irq); - - return 0; /* never anything pending */ -} - -static void disable_cp7000_irq(unsigned int irq) -{ - unsigned long flags; - - spin_lock_irqsave(&irq_lock, flags); - mask_irq(1 << irq); - spin_unlock_irqrestore(&irq_lock, flags); -} - -#define shutdown_cp7000_irq disable_cp7000_irq - -static void mask_and_ack_cp7000_irq(unsigned int irq) -{ - mask_irq(1 << irq); -} - -static void end_cp7000_irq(unsigned int irq) -{ - if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) - unmask_irq(1 << irq); -} - -static struct hw_interrupt_type cp7000_hpcdma_irq_type = { -#ifdef CONFIG_CPU_SR71000 - "SR71000", -#else - "RM7000", -#endif - startup_cp7000_irq, - shutdown_cp7000_irq, - enable_cp7000_irq, - disable_cp7000_irq, - mask_and_ack_cp7000_irq, - end_cp7000_irq, - NULL -}; - extern asmlinkage void ocelot_handle_int(void); extern void mv64340_irq_init(void); extern void uart_irq_init(void); extern void cpci_irq_init(void); -static struct irqaction cascade_fpga = - { no_action, SA_INTERRUPT, 0, "cascade via FPGA", NULL, NULL }; -static struct irqaction cascade_mv64340 = - { no_action, SA_INTERRUPT, 0, "cascade via MV64340", NULL, NULL }; +static struct irqaction cascade_fpga = { + no_action, SA_INTERRUPT, 0, "cascade via FPGA", NULL, NULL +}; + +static struct irqaction cascade_mv64340 = { + no_action, SA_INTERRUPT, 0, "cascade via MV64340", NULL, NULL +}; void __init init_IRQ(void) { - int i; - /* * Clear all of the interrupts while we change the able around a bit. * int-handler is not on bootstrap */ - clear_c0_status(ST0_IM | ST0_BEV); - __cli(); + clear_c0_status(ST0_IM); /* Sets the first-level interrupt dispatcher. */ set_except_vector(0, ocelot_handle_int); init_generic_irq(); - - /* set up handler for first 8 IRQs as the CPU */ - for (i = 0; i < 8; i++) { - irq_desc[i].status = IRQ_DISABLED; - irq_desc[i].action = 0; - irq_desc[i].depth = 1; - irq_desc[i].handler = &cp7000_hpcdma_irq_type; - } + mips_cpu_irq_init(0); /* set up the cascading interrupts */ setup_irq(3, &cascade_fpga); @@ -176,7 +88,4 @@ void __init init_IRQ(void) set_debug_traps(); breakpoint(); /* you may move this line to whereever you want :-) */ #endif -#ifdef CONFIG_GDB_CONSOLE - register_gdb_console(); -#endif } --- diff/arch/mips/momentum/ocelot_c/mv-irq.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_c/mv-irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -4,7 +4,7 @@ * * arch/mips/momentum/ocelot_c/mv-irq.c * Interrupt routines for mv64340. Interrupt numbers are assigned from - * MV64340_IRQ_BASE to MV64340_IRQ_BASE+64. + * MV64340_IRQ_BASE to MV64340_IRQ_BASE+63. * * 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 @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include --- diff/arch/mips/momentum/ocelot_c/ocelot_c_fpga.h 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_c/ocelot_c_fpga.h 2004-02-23 13:56:38.000000000 +0000 @@ -22,11 +22,21 @@ * 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. + * + * Louis Hamilton, Red Hat, Inc. + * hamilton@redhat.com [MIPS64 modifications] */ + #ifndef __OCELOT_C_FPGA_H__ #define __OCELOT_C_FPGA_H__ -#define OCELOT_C_CS0_ADDR (0xfc000000) +#include + +#ifdef CONFIG_MIPS64 +#define OCELOT_C_CS0_ADDR (0xfffffffffc000000) +#else +#define OCELOT_C_CS0_ADDR (0xfc000000) +#endif #define OCELOT_C_REG_BOARDREV 0x0 #define OCELOT_C_REG_FPGA_REV 0x1 --- diff/arch/mips/momentum/ocelot_c/pci-irq.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_c/pci-irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -17,7 +17,6 @@ #include #include #include -#include #include #include --- diff/arch/mips/momentum/ocelot_c/prom.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_c/prom.c 2004-02-23 13:56:38.000000000 +0000 @@ -2,6 +2,9 @@ * Copyright 2002 Momentum Computer Inc. * Author: Matthew Dharm * + * Louis Hamilton, Red Hat, Inc. + * hamilton@redhat.com [MIPS64 modifications] + * * Based on Ocelot Linux port, which is * Copyright 2001 MontaVista Software Inc. * Author: jsun@mvista.com or jsun@junsun.net @@ -35,7 +38,6 @@ struct callvectors { }; struct callvectors* debug_vectors; -char arcs_cmdline[CL_SIZE]; extern unsigned long mv64340_base; extern unsigned long cpu_clock; @@ -101,11 +103,110 @@ void get_mac(char dest[6]) } #endif + +#ifdef CONFIG_MIPS64 + +unsigned long signext(unsigned long addr) +{ + addr &= 0xffffffff; + return (unsigned long)((int)addr); +} + +void *get_arg(unsigned long args, int arc) +{ + unsigned long ul; + unsigned char *puc, uc; + + args += (arc * 4); + ul = (unsigned long)signext(args); + puc = (unsigned char *)ul; + if (puc == 0) + return (void *)0; + +#ifdef CONFIG_CPU_LITTLE_ENDIAN + uc = *puc++; + ul = (unsigned long)uc; + uc = *puc++; + ul |= (((unsigned long)uc) << 8); + uc = *puc++; + ul |= (((unsigned long)uc) << 16); + uc = *puc++; + ul |= (((unsigned long)uc) << 24); +#else /* CONFIG_CPU_LITTLE_ENDIAN */ + uc = *puc++; + ul = ((unsigned long)uc) << 24; + uc = *puc++; + ul |= (((unsigned long)uc) << 16); + uc = *puc++; + ul |= (((unsigned long)uc) << 8); + uc = *puc++; + ul |= ((unsigned long)uc); +#endif /* CONFIG_CPU_LITTLE_ENDIAN */ + ul = signext(ul); + return (void *)ul; +} + +char *arg64(unsigned long addrin, int arg_index) +{ + unsigned long args; + char *p; + args = signext(addrin); + p = (char *)get_arg(args, arg_index); + return p; +} +#endif /* CONFIG_MIPS64 */ + + /* [jsun@junsun.net] PMON passes arguments in C main() style */ -void __init prom_init(int argc, char **arg, char** env, struct callvectors *cv) +void __init prom_init(void) { + int argc = fw_arg0; + char **arg = (char **) fw_arg1; + char **env = (char **) fw_arg2; int i; +#ifdef CONFIG_MIPS64 + char *ptr; + + printk("prom_init - MIPS64\n"); + /* save the PROM vectors for debugging use */ + debug_vectors = (struct callvectors *)signext((unsigned long)cv); + + /* arg[0] is "g", the rest is boot parameters */ + arcs_cmdline[0] = '\0'; + + for (i = 1; i < argc; i++) { + ptr = (char *)arg64((unsigned long)arg, i); + if ((strlen(arcs_cmdline) + strlen(ptr) + 1) >= + sizeof(arcs_cmdline)) + break; + strcat(arcs_cmdline, ptr); + strcat(arcs_cmdline, " "); + } + i = 0; + while (1) { + ptr = (char *)arg64((unsigned long)env, i); + if (! ptr) + break; + + if (strncmp("gtbase", ptr, strlen("gtbase")) == 0) { + mv64340_base = simple_strtol(ptr + strlen("gtbase="), + NULL, 16); + + if ((mv64340_base & 0xffffffff00000000) == 0) + mv64340_base |= 0xffffffff00000000; + + printk("mv64340_base set to 0x%016lx\n", mv64340_base); + } + if (strncmp("cpuclock", ptr, strlen("cpuclock")) == 0) { + cpu_clock = simple_strtol(ptr + strlen("cpuclock="), + NULL, 10); + printk("cpu_clock set to %d\n", cpu_clock); + } + i++; + } + printk("arcs_cmdline: %s\n", arcs_cmdline); +#else /* CONFIG_MIPS64 */ /* save the PROM vectors for debugging use */ debug_vectors = cv; @@ -119,9 +220,6 @@ void __init prom_init(int argc, char **a strcat(arcs_cmdline, " "); } - mips_machgroup = MACH_GROUP_MOMENCO; - mips_machtype = MACH_MOMENCO_OCELOT_C; - while (*env) { if (strncmp("gtbase", *env, strlen("gtbase")) == 0) { mv64340_base = simple_strtol(*env + strlen("gtbase="), @@ -133,19 +231,22 @@ void __init prom_init(int argc, char **a } env++; } +#endif /* CONFIG_MIPS64 */ + + mips_machgroup = MACH_GROUP_MOMENCO; + mips_machtype = MACH_MOMENCO_OCELOT_C; #ifdef CONFIG_MV64340_ETH /* get the base MAC address for on-board ethernet ports */ get_mac(prom_mac_addr_base); #endif +#ifndef CONFIG_MIPS64 debug_vectors->printf("Booting Linux kernel...\n"); +#endif } -void __init prom_free_prom_memory(void) -{ -} - -void __init prom_fixup_mem_map(unsigned long start, unsigned long end) +unsigned long __init prom_free_prom_memory(void) { + return 0; } --- diff/arch/mips/momentum/ocelot_c/reset.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_c/reset.c 2004-02-23 13:56:38.000000000 +0000 @@ -10,7 +10,11 @@ * * Copyright (C) 2002 Momentum Computer Inc. * Author: Matthew Dharm + * + * Louis Hamilton, Red Hat, Inc. + * hamilton@redhat.com [MIPS64 modifications] */ +#include #include #include #include @@ -23,7 +27,12 @@ void momenco_ocelot_restart(char *command) { /* base address of timekeeper portion of part */ - void *nvram = (void*) 0xfc807000; + void *nvram = (void *) +#ifdef CONFIG_MIPS64 + 0xfffffffffc807000; +#else + 0xfc807000; +#endif /* Ask the NVRAM/RTC/watchdog chip to assert reset in 1/16 second */ writeb(0x84, nvram + 0xff7); --- diff/arch/mips/momentum/ocelot_c/setup.c 2003-08-20 14:16:08.000000000 +0100 +++ source/arch/mips/momentum/ocelot_c/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -10,6 +10,9 @@ * Author: Matthew Dharm, Momentum Computer * mdharm@momenco.com * + * Louis Hamilton, Red Hat, Inc. + * hamilton@redhat.com [MIPS64 modifications] + * * Author: RidgeRun, Inc. * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com * @@ -37,11 +40,11 @@ * 675 Mass Ave, Cambridge, MA 02139, USA. * */ +#include #include #include #include #include -#include #include #include #include @@ -53,21 +56,19 @@ #include #include #include -#include #include #include #include #include #include #include -#include -#include #include #include #include #include "ocelot_c_fpga.h" unsigned long mv64340_base; +extern unsigned long mv64340_sram_base; unsigned long cpu_clock; /* These functions are used for rebooting or halting the machine*/ @@ -79,6 +80,7 @@ void momenco_time_init(void); static char reset_reason; +void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1, unsigned long entryhi, unsigned long pagemask); #define ENTRYLO(x) ((pte_val(mk_pte_phys((x), PAGE_KERNEL_UNCACHED)) >> 6)|1) /* setup code for a handoff from a version 2 PMON 2000 PROM */ @@ -99,7 +101,19 @@ void PMON_v2_setup(void) Internal SRAM 0xfe000000 0xfe000000 M-Systems DOC (CS3) 0xff000000 0xff000000 */ + printk("PMON_v2_setup\n"); +#ifdef CONFIG_MIPS64 + /* marvell and extra space */ + add_wired_entry(ENTRYLO(0xf4000000), ENTRYLO(0xf4010000), 0xfffffffff4000000, PM_64K); + /* fpga, rtc, and uart */ + add_wired_entry(ENTRYLO(0xfc000000), ENTRYLO(0xfd000000), 0xfffffffffc000000, PM_16M); + /* m-sys and internal SRAM */ + add_wired_entry(ENTRYLO(0xfe000000), ENTRYLO(0xff000000), 0xfffffffffe000000, PM_16M); + + mv64340_base = 0xfffffffff4000000; + mv64340_sram_base = 0xfffffffffe000000; +#else /* marvell and extra space */ add_wired_entry(ENTRYLO(0xf4000000), ENTRYLO(0xf4010000), 0xf4000000, PM_64K); /* fpga, rtc, and uart */ @@ -108,11 +122,17 @@ void PMON_v2_setup(void) add_wired_entry(ENTRYLO(0xfe000000), ENTRYLO(0xff000000), 0xfe000000, PM_16M); mv64340_base = 0xf4000000; + mv64340_sram_base = 0xfe000000; +#endif } unsigned long m48t37y_get_time(void) { +#ifdef CONFIG_MIPS64 + unsigned char *rtc_base = (unsigned char*)0xfffffffffc800000; +#else unsigned char* rtc_base = (unsigned char*)0xfc800000; +#endif unsigned int year, month, day, hour, min, sec; /* stop the update */ @@ -137,7 +157,11 @@ unsigned long m48t37y_get_time(void) int m48t37y_set_time(unsigned long sec) { +#ifdef CONFIG_MIPS64 + unsigned char* rtc_base = (unsigned char*)0xfffffffffc800000; +#else unsigned char* rtc_base = (unsigned char*)0xfc800000; +#endif struct rtc_time tm; /* convert to a more useful format -- note months count from 0 */ @@ -179,19 +203,20 @@ void momenco_timer_setup(struct irqactio void momenco_time_init(void) { #ifdef CONFIG_CPU_SR71000 - mips_counter_frequency = cpu_clock; + mips_hpt_frequency = cpu_clock; #elif defined(CONFIG_CPU_RM7000) - mips_counter_frequency = cpu_clock / 2; + mips_hpt_frequency = cpu_clock / 2; #else #error Unknown CPU for this board #endif + printk("momenco_time_init cpu_clock=%d\n", cpu_clock); board_timer_setup = momenco_timer_setup; rtc_get_time = m48t37y_get_time; rtc_set_time = m48t37y_set_time; } -void __init momenco_ocelot_c_setup(void) +static void __init momenco_ocelot_c_setup(void) { unsigned int tmpword; @@ -307,6 +332,9 @@ void __init momenco_ocelot_c_setup(void) } } +early_initcall(momenco_ocelot_c_setup); + +#ifndef CONFIG_MIPS64 /* This needs to be one of the first initcalls, because no I/O port access can work before this */ static int io_base_ioremap(void) @@ -324,3 +352,4 @@ static int io_base_ioremap(void) } module_init(io_base_ioremap); +#endif --- diff/arch/mips/momentum/ocelot_c/uart-irq.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_c/uart-irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include --- diff/arch/mips/momentum/ocelot_g/gt-irq.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_g/gt-irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include --- diff/arch/mips/momentum/ocelot_g/int-handler.S 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_g/int-handler.S 2004-02-23 13:56:38.000000000 +0000 @@ -9,8 +9,6 @@ * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ -#define __ASSEMBLY__ -#include #include #include #include --- diff/arch/mips/momentum/ocelot_g/irq.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_g/irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -28,6 +28,7 @@ * 675 Mass Ave, Cambridge, MA 02139, USA. * */ +#include #include #include #include @@ -44,120 +45,27 @@ #include #include #include +#include #include #include - -static spinlock_t rm7000_irq_lock = SPIN_LOCK_UNLOCKED; - -/* Function for careful CP0 interrupt mask access */ -static inline void modify_cp0_intmask(unsigned clr_mask_in, unsigned set_mask_in) -{ - unsigned long status; - unsigned clr_mask; - unsigned set_mask; - - /* do the low 8 bits first */ - clr_mask = 0xff & clr_mask_in; - set_mask = 0xff & set_mask_in; - status = read_c0_status(); - status &= ~((clr_mask & 0xFF) << 8); - status |= (set_mask & 0xFF) << 8; - write_c0_status(status); - - /* do the high 8 bits */ - clr_mask = 0xff & (clr_mask_in >> 8); - set_mask = 0xff & (set_mask_in >> 8); - status = read_c0_intcontrol(); - status &= ~((clr_mask & 0xFF) << 8); - status |= (set_mask & 0xFF) << 8; - write_c0_intrcontrol(status); -} - -static inline void mask_irq(unsigned int irq) -{ - modify_cp0_intmask(irq, 0); -} - -static inline void unmask_irq(unsigned int irq) -{ - modify_cp0_intmask(0, irq); -} - -static void enable_cp7000_irq(unsigned int irq) -{ - unsigned long flags; - - spin_lock_irqsave(&rm7000_irq_lock, flags); - unmask_irq(1 << irq); - spin_unlock_irqrestore(&rm7000_irq_lock, flags); -} - -static unsigned int startup_cp7000_irq(unsigned int irq) -{ - enable_cp7000_irq(irq); - - return 0; /* never anything pending */ -} - -static void disable_cp7000_irq(unsigned int irq) -{ - unsigned long flags; - - spin_lock_irqsave(&rm7000_irq_lock, flags); - mask_irq(1 << irq); - spin_unlock_irqrestore(&rm7000_irq_lock, flags); -} - -#define shutdown_cp7000_irq disable_cp7000_irq - -static void mask_and_ack_cp7000_irq(unsigned int irq) -{ - mask_irq(1 << irq); -} - -static void end_cp7000_irq(unsigned int irq) -{ - if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) - unmask_irq(1 << irq); -} - -static struct hw_interrupt_type cp7000_hpcdma_irq_type = { - "CP7000", - startup_cp7000_irq, - shutdown_cp7000_irq, - enable_cp7000_irq, - disable_cp7000_irq, - mask_and_ack_cp7000_irq, - end_cp7000_irq, - NULL -}; - - extern asmlinkage void ocelot_handle_int(void); extern void gt64240_irq_init(void); void __init init_IRQ(void) { - int i; - /* * Clear all of the interrupts while we change the able around a bit. * int-handler is not on bootstrap */ - clear_c0_status(ST0_IM | ST0_BEV); + clear_c0_status(ST0_IM); local_irq_disable(); /* Sets the first-level interrupt dispatcher. */ set_except_vector(0, ocelot_handle_int); init_generic_irq(); - - for (i = 0; i <= 15; i++) { - irq_desc[i].status = IRQ_DISABLED; - irq_desc[i].action = 0; - irq_desc[i].depth = 1; - irq_desc[i].handler = &cp7000_hpcdma_irq_type; - } + mips_cpu_irq_init(0); + rm7k_cpu_irq_init(8); gt64240_irq_init(); @@ -166,7 +74,4 @@ void __init init_IRQ(void) set_debug_traps(); breakpoint(); /* you may move this line to whereever you want :-) */ #endif -#ifdef CONFIG_GDB_CONSOLE - register_gdb_console(); -#endif } --- diff/arch/mips/momentum/ocelot_g/pci-irq.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_g/pci-irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -17,7 +17,6 @@ #include #include #include -#include #include #include --- diff/arch/mips/momentum/ocelot_g/prom.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/momentum/ocelot_g/prom.c 2004-02-23 13:56:38.000000000 +0000 @@ -35,7 +35,6 @@ struct callvectors { }; struct callvectors* debug_vectors; -char arcs_cmdline[CL_SIZE]; extern unsigned long gt64240_base; extern unsigned long bus_clock; @@ -50,10 +49,14 @@ const char *get_system_type(void) } /* [jsun@junsun.net] PMON passes arguments in C main() style */ -void __init prom_init(int argc, char **arg, char** env, struct callvectors *cv) +void __init prom_init(void) { - int i; uint32_t tmp; + int argc = fw_arg0; + char **arg = (char **) fw_arg1; + char **env = (char **) fw_arg2; + struct callvectors *cv = (struct callvectors *) fw_arg3; + int i; /* save the PROM vectors for debugging use */ debug_vectors = cv; @@ -91,10 +94,7 @@ void __init prom_init(int argc, char **a debug_vectors->printf("Booting Linux kernel...\n"); } -void __init prom_free_prom_memory(void) -{ -} - -void __init prom_fixup_mem_map(unsigned long start, unsigned long end) +unsigned long __init prom_free_prom_memory(void) { + return 0; } --- diff/arch/mips/momentum/ocelot_g/setup.c 2003-08-20 14:16:08.000000000 +0100 +++ source/arch/mips/momentum/ocelot_g/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -39,10 +39,10 @@ * 675 Mass Ave, Cambridge, MA 02139, USA. * */ +#include #include #include #include -#include #include #include #include @@ -54,22 +54,17 @@ #include #include #include -#include #include #include #include #include #include #include -#include -#include #include #include #include "gt64240.h" #include "ocelot_pld.h" -extern struct rtc_ops no_rtc_ops; - #ifdef CONFIG_GALILLEO_GT64240_ETH extern unsigned char prom_mac_addr_base[6]; #endif @@ -120,7 +115,7 @@ void PMON_v2_setup(void) gt64240_base = 0xf4000000; } -void __init momenco_ocelot_g_setup(void) +static void __init momenco_ocelot_g_setup(void) { void (*l3func)(unsigned long)=KSEG1ADDR(&setup_l3cache); unsigned int tmpword; @@ -136,7 +131,6 @@ void __init momenco_ocelot_g_setup(void) * initrd_end = (ulong)ocelot_initrd_start + (ulong)ocelot_initrd_size; * initrd_below_start_ok = 1; */ - rtc_ops = &no_rtc_ops; /* do handoff reconfiguration */ PMON_v2_setup(); @@ -203,6 +197,8 @@ void __init momenco_ocelot_g_setup(void) GT_WRITE(0x468, 0xfef73); } +early_initcall(momenco_ocelot_g_setup); + extern int rm7k_tcache_enabled; /* * This runs in KSEG1. See the verbiage in rm7k.c::probe_scache() --- diff/arch/mips/pci/Makefile 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/pci/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -1,36 +1,50 @@ # # Makefile for the PCI specific kernel interface routines under Linux. # -# This is all organized on a per system base which is horribly wrong and -# really wants a cleanup. You have been warned. + +obj-y += pci.o + +# +# PCI bus host bridge specific code # +obj-$(CONFIG_ITE_BOARD_GEN) += ops-it8172.o +obj-$(CONFIG_MIPS_BONITO64) += ops-bonito64.o +obj-$(CONFIG_MIPS_GT64111) += ops-gt64111.o +obj-$(CONFIG_MIPS_GT64120) += ops-gt64120.o +obj-$(CONFIG_MIPS_GT96100) += ops-gt96100.o +obj-$(CONFIG_MIPS_MV64340) += ops-mv64340.o +obj-$(CONFIG_MIPS_MSC) += ops-msc.o +obj-$(CONFIG_MIPS_NILE4) += ops-nile4.o +obj-$(CONFIG_MIPS_TX3927) += ops-jmr3927.o -obj-$(CONFIG_NEW_PCI) += pci.o -obj-$(CONFIG_PCI_AUTO) += pci-auto.o -obj-$(CONFIG_DDB5074) += pci-ddb5074.o ops-ddb5074.o -obj-$(CONFIG_DDB5476) += pci-ddb5476.o ops-ddb5476.o -obj-$(CONFIG_DDB5477) += pci-ddb5477.o ops-ddb5477.o +# +# These are still pretty much in the old state, watch, go blind. +# +obj-$(CONFIG_DDB5074) += fixup-ddb5074.o pci-ddb5074.o ops-ddb5074.o +obj-$(CONFIG_DDB5476) += ops-ddb5476.o pci-ddb5476.o +obj-$(CONFIG_DDB5477) += fixup-ddb5477.o pci-ddb5477.o ops-ddb5477.o obj-$(CONFIG_HP_LASERJET) += pci-hplj.o -obj-$(CONFIG_ITE_BOARD_GEN) += ops-it8172.o -obj-$(CONFIG_LASAT) += pci-lasat.o common.o -obj-$(CONFIG_MIPS_BOARDS_GEN) += pci-mips.o -obj-$(CONFIG_MIPS_COBALT) += pci-cobalt.o -obj-$(CONFIG_MIPS_EV64120) += ops-ev64120.o -obj-$(CONFIG_MIPS_EV96100) += fixup-ev96100.o ops-ev96100.o +obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o +obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o +obj-$(CONFIG_MIPS_EV96100) += fixup-ev64120.o +obj-$(CONFIG_MIPS_EV96100) += fixup-ev96100.o pci-ev96100.o obj-$(CONFIG_MIPS_ITE8172) += fixup-ite8172g.o obj-$(CONFIG_MIPS_IVR) += fixup-ivr.o -obj-$(CONFIG_MIPS_PB1500) += fixups-au1000.o ops-au1000.o -obj-$(CONFIG_MOMENCO_OCELOT) += fixups-ocelot.o ops-ocelot.o +obj-$(CONFIG_SOC_AU1500) += fixup-au1000.o ops-au1000.o +obj-$(CONFIG_MIPS_MALTA) += fixup-malta.o +obj-$(CONFIG_MOMENCO_OCELOT) += fixup-ocelot.o pci-ocelot.o +obj-$(CONFIG_MOMENCO_OCELOT_C) += pci-ocelot-c.o +obj-$(CONFIG_MOMENCO_OCELOT_G) += pci-ocelot-g.o obj-$(CONFIG_NEC_EAGLE) += fixup-eagle.o ops-vrc4173.o +obj-$(CONFIG_PMC_YOSEMITE) += fixup-yosemite.o ops-titan.o obj-$(CONFIG_SGI_IP27) += pci-ip27.o -obj-$(CONFIG_SGI_IP32) += pci-ip32.o +obj-$(CONFIG_SGI_IP32) += fixup-ip32.o ops-mace.o pci-ip32.o obj-$(CONFIG_SIBYTE_SB1250) += pci-sb1250.o -obj-$(CONFIG_SNI_RM200_PCI) += pci-sni.o +obj-$(CONFIG_SNI_RM200_PCI) += fixup-sni.o ops-sni.o obj-$(CONFIG_TANBAC_TB0226) += fixup-tb0226.o obj-$(CONFIG_TANBAC_TB0229) += fixup-tb0229.o -obj-$(CONFIG_TOSHIBA_JMR3927) += fixup-jmr3927.o ops-jmr3927.o -#obj-$(CONFIG_MOMENCO_OCELOT_C) += pci-ocelot-c.o -obj-$(CONFIG_MOMENCO_OCELOT_G) += pci-ocelot-g.o +obj-$(CONFIG_TOSHIBA_JMR3927) += fixup-jmr3927.o pci-jmr3927.o +obj-$(CONFIG_TOSHIBA_RBTX4927) += fixup-rbtx4927.o ops-tx4927.o obj-$(CONFIG_VICTOR_MPC30X) += fixup-capcella.o -obj-$(CONFIG_VR41XX_COMMON) += pci-vr41xx.o +obj-$(CONFIG_MACH_VR41XX) += pci-vr41xx.o obj-$(CONFIG_ZAO_CAPCELLA) += fixup-victor-mpc30x.o --- diff/arch/mips/pci/fixup-au1000.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/fixup-au1000.c 2004-02-23 13:56:38.000000000 +0000 @@ -32,93 +32,31 @@ #include #include -#include +#include //#include #ifdef CONFIG_MIPS_PB1000 -#include +#include #endif -#undef DEBUG -#ifdef DEBUG -#define DBG(x...) printk(x) -#else -#define DBG(x...) -#endif +/* + * Shortcut + */ +#define INTA AU1000_PCI_INTA +#define INTB AU1000_PCI_INTB -static void fixup_resource(int r_num, struct pci_dev *dev); -#ifdef CONFIG_SOC_AU1500 -static unsigned long virt_io_addr; +static char irq_tab_alchemy[][5] __initdata = { + [11] = { -1, INTA, INTA, INTA, INTA }, + [12] = { -1, INTA, INTA, INTA, INTA } +#if defined( CONFIG_SOC_AU1550 ) + [13] = { -1, INTB, INTB, INTB, INTB } #endif +}; -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ - /* will need to fixup IO resources */ -} - -void __init pcibios_fixup(void) +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { -#ifdef CONFIG_SOC_AU1500 - int i; - struct pci_dev *dev; - - virt_io_addr = (unsigned long) ioremap(Au1500_PCI_IO_START, - Au1500_PCI_IO_END - - Au1500_PCI_IO_START + 1); - - if (!virt_io_addr) { - printk(KERN_ERR "Unable to ioremap pci space\n"); - return; - } - - set_io_port_base(virt_io_addr); -#endif - -#ifdef CONFIG_MIPS_PB1000 /* This is truly board specific */ - unsigned long pci_mem_start = (unsigned long) PCI_MEM_START; - - au_writel(0, PCI_BRIDGE_CONFIG); // set extend byte to 0 - au_writel(0, SDRAM_MBAR); // set mbar to 0 - au_writel(0x2, SDRAM_CMD); // enable memory accesses - au_sync_delay(1); - - // set extend byte to mbar of ext slot - au_writel(((pci_mem_start >> 24) & 0xff) | - (1 << 8 | 1 << 9 | 1 << 10 | 1 << 27), - PCI_BRIDGE_CONFIG); - DBG("Set bridge config to %x\n", au_readl(PCI_BRIDGE_CONFIG)); -#endif + return irq_tab_alchemy[slot][pin]; } -void __init pcibios_fixup_irqs(void) -{ -#ifdef CONFIG_SOC_AU1500 - unsigned int slot, func; - unsigned char pin; - struct pci_dev *dev = NULL; - - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - if (dev->bus->number != 0) - return; - - dev->irq = 0xff; - slot = PCI_SLOT(dev->devfn); - switch (slot) { - case 12: - case 13: - dev->irq = AU1000_PCI_INTA; - break; - - } - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); - DBG("slot %d irq %d\n", slot, dev->irq); - } -#endif -} -unsigned int pcibios_assign_all_busses(void) -{ - return 0; -} - -static void fixup_resource(int r_num, struct pci_dev *dev) -{ -} +struct pci_fixup pcibios_fixups[] __initdata = { + { 0 } +}; --- diff/arch/mips/pci/fixup-capcella.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/fixup-capcella.c 2004-02-23 13:56:38.000000000 +0000 @@ -18,55 +18,23 @@ #include -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ -} - -void __init pcibios_fixup(void) -{ -} - -void __init pcibios_fixup_irqs(void) -{ - struct pci_dev *dev = NULL; - u8 slot, func, pin; - - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - slot = PCI_SLOT(dev->devfn); - func = PCI_FUNC(dev->devfn); - dev->irq = 0; - - switch (slot) { - case 11: - dev->irq = RTL8139_1_IRQ; - break; - case 12: - dev->irq = RTL8139_2_IRQ; - break; - case 14: - pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); - switch (pin) { - case 1: - dev->irq = PC104PLUS_INTA_IRQ; - break; - case 2: - dev->irq = PC104PLUS_INTB_IRQ; - break; - case 3: - dev->irq = PC104PLUS_INTC_IRQ; - break; - case 4: - dev->irq = PC104PLUS_INTD_IRQ; - break; - } - break; - } - - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); - } -} +/* + * Shortcuts + */ +#define INT1 RTL8139_1_IRQ +#define INT2 RTL8139_2_IRQ +#define INTA PC104PLUS_INTA_IRQ +#define INTB PC104PLUS_INTB_IRQ +#define INTC PC104PLUS_INTC_IRQ +#define INTD PC104PLUS_INTD_IRQ + +static char irq_tab_capcella[][5] __initdata = { + [11] = { -1, INT1, INT1, INT1, INT1 }, + [12] = { -1, INT2, INT2, INT2, INT2 }, + [14] = { -1, INTA, INTB, INTC, INTD } +}; -unsigned int pcibios_assign_all_busses(void) +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - return 0; + return irq_tab_capcella[slot][pin]; } --- diff/arch/mips/pci/fixup-eagle.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/fixup-eagle.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,46 +1,14 @@ /* - * FILE NAME - * arch/mips/vr41xx/nec-eagle/pci_fixup.c + * arch/mips/vr41xx/nec-eagle/pci_fixup.c * - * BRIEF MODULE DESCRIPTION - * The NEC Eagle/Hawk Board specific PCI fixups. + * The NEC Eagle/Hawk Board specific PCI fixups. * - * Author: Yoichi Yuasa - * yyuasa@mvista.com or source@mvista.com + * Author: Yoichi Yuasa * - * Copyright 2001,2002 MontaVista Software Inc. - * - * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * 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. - */ -/* - * Changes: - * MontaVista Software Inc. or - * - Moved mips_pci_channels[] to arch/mips/vr41xx/vr4122/eagle/setup.c. - * - Added support for NEC Hawk. - * - * Paul Mundt - * - Fix empty break statements. - * - * MontaVista Software Inc. or - * - New creation, NEC Eagle is supported. + * 2001-2002,2004 (c) MontaVista, Software, Inc. This file is licensed under + * the terms of the GNU General Public License version 2. This program + * is licensed "as is" without any warranty of any kind, whether express + * or implied. */ #include #include @@ -48,119 +16,45 @@ #include #include -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ -} +/* + * Shortcuts + */ +#define INTA CP_INTA_IRQ +#define INTB CP_INTB_IRQ +#define INTC CP_INTC_IRQ +#define INTD CP_INTD_IRQ +#define PCMCIA1 VRC4173_PCMCIA1_IRQ +#define PCMCIA2 VRC4173_PCMCIA2_IRQ +#define LAN LANINTA_IRQ +#define SLOT PCISLOT_IRQ + +static char irq_tab_eagle[][5] __initdata = { + [ 8] = { 0, INTA, INTB, INTC, INTD }, + [ 9] = { 0, INTD, INTA, INTB, INTC }, + [10] = { 0, INTC, INTD, INTA, INTB }, + [12] = { 0, PCMCIA1, 0, 0, 0 }, + [13] = { 0, PCMCIA2, 0, 0, 0 }, + [28] = { 0, LAN, 0, 0, 0 }, + [29] = { 0, SLOT, INTB, INTC, INTD }, +}; -void __init pcibios_fixup(void) -{ -} +/* + * This is a multifunction device. + */ +static char irq_func_tab[] __initdata = { + VRC4173_CASCADE_IRQ, + VRC4173_AC97_IRQ, + VRC4173_USB_IRQ +}; -void __init pcibios_fixup_irqs(void) +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - struct pci_dev *dev = NULL; - u8 slot, func, pin; - - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - slot = PCI_SLOT(dev->devfn); - func = PCI_FUNC(dev->devfn); - pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); - dev->irq = 0; - - switch (slot) { - case 8: - switch (pin) { - case 1: - dev->irq = CP_INTA_IRQ; - break; - case 2: - dev->irq = CP_INTB_IRQ; - break; - case 3: - dev->irq = CP_INTC_IRQ; - break; - case 4: - dev->irq = CP_INTD_IRQ; - break; - } - break; - case 9: - switch (pin) { - case 1: - dev->irq = CP_INTD_IRQ; - break; - case 2: - dev->irq = CP_INTA_IRQ; - break; - case 3: - dev->irq = CP_INTB_IRQ; - break; - case 4: - dev->irq = CP_INTC_IRQ; - break; - } - break; - case 10: - switch (pin) { - case 1: - dev->irq = CP_INTC_IRQ; - break; - case 2: - dev->irq = CP_INTD_IRQ; - break; - case 3: - dev->irq = CP_INTA_IRQ; - break; - case 4: - dev->irq = CP_INTB_IRQ; - break; - } - break; - case 12: - dev->irq = VRC4173_PCMCIA1_IRQ; - break; - case 13: - dev->irq = VRC4173_PCMCIA2_IRQ; - break; - case 28: - dev->irq = LANINTA_IRQ; - break; - case 29: - switch (pin) { - case 1: - dev->irq = PCISLOT_IRQ; - break; - case 2: - dev->irq = CP_INTB_IRQ; - break; - case 3: - dev->irq = CP_INTC_IRQ; - break; - case 4: - dev->irq = CP_INTD_IRQ; - break; - } - break; - case 30: - switch (func) { - case 0: - dev->irq = VRC4173_CASCADE_IRQ; - break; - case 1: - dev->irq = VRC4173_AC97_IRQ; - break; - case 2: - dev->irq = VRC4173_USB_IRQ; - break; - } - break; - } + if (slot == 30) + return irq_func_tab[PCI_FUNC(dev->devfn)]; - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); - } + return irq_tab_eagle[slot][pin]; } -unsigned int pcibios_assign_all_busses(void) -{ - return 0; -} +struct pci_fixup pcibios_fixups[] __initdata = { + { .pass = 0, }, +}; --- diff/arch/mips/pci/fixup-ite8172g.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/fixup-ite8172g.c 2004-02-23 13:56:38.000000000 +0000 @@ -35,155 +35,40 @@ #include #include -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ -} +/* + * Shortcuts + */ +#define INTA IT8172_PCI_INTA_IRQ +#define INTB IT8172_PCI_INTB_IRQ +#define INTC IT8172_PCI_INTC_IRQ +#define INTD IT8172_PCI_INTD_IRQ + +static const int internal_func_irqs[7] __initdata = { + IT8172_AC97_IRQ, + IT8172_DMA_IRQ, + IT8172_CDMA_IRQ, + IT8172_USB_IRQ, + IT8172_BRIDGE_MASTER_IRQ, + IT8172_IDE_IRQ, + IT8172_MC68K_IRQ +}; + +static char irq_tab_ite8172g[][5] __initdata = { + [0x10] = { 0, INTA, INTB, INTC, INTD }, + [0x11] = { 0, INTA, INTB, INTC, INTD }, + [0x12] = { 0, INTB, INTC, INTD, INTA }, + [0x13] = { 0, INTC, INTD, INTA, INTB }, + [0x14] = { 0, INTD, INTA, INTB, INTC }, +}; -void __init pcibios_fixup(void) +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { -} - -void __init pcibios_fixup_irqs(void) -{ - unsigned int slot, func; - unsigned char pin; - struct pci_dev *dev = NULL; - - const int internal_func_irqs[7] = { - IT8172_AC97_IRQ, - IT8172_DMA_IRQ, - IT8172_CDMA_IRQ, - IT8172_USB_IRQ, - IT8172_BRIDGE_MASTER_IRQ, - IT8172_IDE_IRQ, - IT8172_MC68K_IRQ - }; - - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - if (dev->bus->number != 0) - return; - - pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); - slot = PCI_SLOT(dev->devfn); - func = PCI_FUNC(dev->devfn); - - switch (slot) { - case 0x01: - /* - * Internal device 1 is actually 7 different - * internal devices on the IT8172G (a multi- - * function device). - */ - if (func < 7) - dev->irq = internal_func_irqs[func]; - break; - case 0x10: - switch (pin) { - case 1: /* pin A */ - dev->irq = IT8172_PCI_INTA_IRQ; - break; - case 2: /* pin B */ - dev->irq = IT8172_PCI_INTB_IRQ; - break; - case 3: /* pin C */ - dev->irq = IT8172_PCI_INTC_IRQ; - break; - case 4: /* pin D */ - dev->irq = IT8172_PCI_INTD_IRQ; - break; - default: - dev->irq = 0xff; - break; - - } - break; - case 0x11: - switch (pin) { - case 1: /* pin A */ - dev->irq = IT8172_PCI_INTA_IRQ; - break; - case 2: /* pin B */ - dev->irq = IT8172_PCI_INTB_IRQ; - break; - case 3: /* pin C */ - dev->irq = IT8172_PCI_INTC_IRQ; - break; - case 4: /* pin D */ - dev->irq = IT8172_PCI_INTD_IRQ; - break; - default: - dev->irq = 0xff; - break; - - } - break; - case 0x12: - switch (pin) { - case 1: /* pin A */ - dev->irq = IT8172_PCI_INTB_IRQ; - break; - case 2: /* pin B */ - dev->irq = IT8172_PCI_INTC_IRQ; - break; - case 3: /* pin C */ - dev->irq = IT8172_PCI_INTD_IRQ; - break; - case 4: /* pin D */ - dev->irq = IT8172_PCI_INTA_IRQ; - break; - default: - dev->irq = 0xff; - break; - - } - break; - case 0x13: - switch (pin) { - case 1: /* pin A */ - dev->irq = IT8172_PCI_INTC_IRQ; - break; - case 2: /* pin B */ - dev->irq = IT8172_PCI_INTD_IRQ; - break; - case 3: /* pin C */ - dev->irq = IT8172_PCI_INTA_IRQ; - break; - case 4: /* pin D */ - dev->irq = IT8172_PCI_INTB_IRQ; - break; - default: - dev->irq = 0xff; - break; - - } - break; - case 0x14: - switch (pin) { - case 1: /* pin A */ - dev->irq = IT8172_PCI_INTD_IRQ; - break; - case 2: /* pin B */ - dev->irq = IT8172_PCI_INTA_IRQ; - break; - case 3: /* pin C */ - dev->irq = IT8172_PCI_INTB_IRQ; - break; - case 4: /* pin D */ - dev->irq = IT8172_PCI_INTC_IRQ; - break; - default: - dev->irq = 0xff; - break; + /* + * Internal device 1 is actually 7 different internal devices on the + * IT8172G (a multifunction device). + */ + if (slot == 1) + return internal_func_irqs[PCI_FUNC(dev->devfn)]; - } - break; - default: - continue; /* do nothing */ - } -#ifdef DEBUG - printk("irq fixup: slot %d, int line %d, int number %d\n", - slot, pin, dev->irq); -#endif - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); - } + return irq_tab_ite8172g[slot][pin]; } --- diff/arch/mips/pci/fixup-ivr.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/fixup-ivr.c 2004-02-23 13:56:38.000000000 +0000 @@ -36,118 +36,34 @@ #include #include -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ -} - -void __init pcibios_fixup(void) -{ -} +/* + * Shortcuts + */ +#define INTA IT8172_PCI_INTA_IRQ +#define INTB IT8172_PCI_INTB_IRQ +#define INTC IT8172_PCI_INTC_IRQ +#define INTD IT8172_PCI_INTD_IRQ + +static const int internal_func_irqs[7] __initdata = { + IT8172_AC97_IRQ, + IT8172_DMA_IRQ, + IT8172_CDMA_IRQ, + IT8172_USB_IRQ, + IT8172_BRIDGE_MASTER_IRQ, + IT8172_IDE_IRQ, + IT8172_MC68K_IRQ +}; + +static char irq_tab_ivr[][5] __initdata = { + [0x11] = { INTC, INTC, INTD, INTA, INTB }, /* Realtek RTL-8139 */ + [0x12] = { INTB, INTB, INTB, INTC, INTC }, /* IVR slot */ + [0x13] = { INTA, INTA, INTB, INTC, INTD } /* Expansion slot */ +}; -void __init pcibios_fixup_irqs(void) +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - unsigned int slot, func; - unsigned char pin; - struct pci_dev *dev = NULL; - - const int internal_func_irqs[7] = { - IT8172_AC97_IRQ, - IT8172_DMA_IRQ, - IT8172_CDMA_IRQ, - IT8172_USB_IRQ, - IT8172_BRIDGE_MASTER_IRQ, - IT8172_IDE_IRQ, - IT8172_MC68K_IRQ - }; - - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - if (dev->bus->number != 0) - return; - - pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); - slot = PCI_SLOT(dev->devfn); - func = PCI_FUNC(dev->devfn); - - switch (slot) { - case 0x01: - /* - * Internal device 1 is actually 7 different - * internal devices on the IT8172G (multi-function - * device). - */ - if (func < 7) - dev->irq = internal_func_irqs[func]; - break; - case 0x11: // Realtek RTL-8139 - switch (pin) { - case 0: /* pin A, hardware bug */ - case 1: /* pin A */ - dev->irq = IT8172_PCI_INTC_IRQ; - break; - case 2: /* pin B */ - dev->irq = IT8172_PCI_INTD_IRQ; - break; - case 3: /* pin C */ - dev->irq = IT8172_PCI_INTA_IRQ; - break; - case 4: /* pin D */ - dev->irq = IT8172_PCI_INTB_IRQ; - break; - default: - dev->irq = 0xff; - break; - - } - break; - case 0x12: // ivr slot - switch (pin) { - case 0: /* pin A, hardware bug */ - case 1: /* pin A */ - dev->irq = IT8172_PCI_INTB_IRQ; - break; - case 2: /* pin B */ - dev->irq = IT8172_PCI_INTB_IRQ; - break; - case 3: /* pin C */ - dev->irq = IT8172_PCI_INTC_IRQ; - break; - case 4: /* pin D */ - dev->irq = IT8172_PCI_INTD_IRQ; - break; - default: - dev->irq = 0xff; - break; - - } - break; - case 0x13: // expansion slot - switch (pin) { - case 0: /* pin A, hardware bug */ - case 1: /* pin A */ - dev->irq = IT8172_PCI_INTA_IRQ; - break; - case 2: /* pin B */ - dev->irq = IT8172_PCI_INTB_IRQ; - break; - case 3: /* pin C */ - dev->irq = IT8172_PCI_INTC_IRQ; - break; - case 4: /* pin D */ - dev->irq = IT8172_PCI_INTD_IRQ; - break; - default: - dev->irq = 0xff; - break; + if (slot == 1) + return internal_func_irqs[PCI_FUNC(dev->devfn)]; - } - break; - default: - break; - } -#ifdef DEBUG - printk("irq fixup: slot %d, int line %d, int number %d\n", - slot, pin, dev->irq); -#endif - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); - } + return irq_tab_ivr[slot][pin]; } --- diff/arch/mips/pci/fixup-jmr3927.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/fixup-jmr3927.c 2004-02-23 13:56:38.000000000 +0000 @@ -34,51 +34,27 @@ #include -#undef DEBUG -#ifdef DEBUG -#define DBG(x...) printk(x) -#else -#define DBG(x...) -#endif - -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ - /* will need to fixup IO resources */ -} - -void __init pcibios_fixup(void) -{ - /* nothing to do here */ -} - -int pci_get_irq(struct pci_dev *dev, int pin) +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { unsigned char irq = pin; /* IRQ rotation (PICMG) */ irq--; /* 0-3 */ if (dev->bus->parent == NULL && - PCI_SLOT(dev->devfn) == TX3927_PCIC_IDSEL_AD_TO_SLOT(23)) { + slot == TX3927_PCIC_IDSEL_AD_TO_SLOT(23)) { /* PCI CardSlot (IDSEL=A23, DevNu=12) */ /* PCIA => PCIC (IDSEL=A23) */ /* NOTE: JMR3927 JP1 must be set to OPEN */ irq = (irq + 2) % 4; } else if (dev->bus->parent == NULL && - PCI_SLOT(dev->devfn) == - TX3927_PCIC_IDSEL_AD_TO_SLOT(22)) { + slot == TX3927_PCIC_IDSEL_AD_TO_SLOT(22)) { /* PCI CardSlot (IDSEL=A22, DevNu=11) */ /* PCIA => PCIA (IDSEL=A22) */ /* NOTE: JMR3927 JP1 must be set to OPEN */ irq = (irq + 0) % 4; } else { /* PCI Backplane */ - irq = (irq + 3 + PCI_SLOT(dev->devfn)) % 4; -#if 0 /* ??? */ - for (bus = dev->bus; bus->parent != NULL; - bus = bus->parent) { - irq = (irq + 3 + PCI_SLOT(bus->self->devfn)) % 4; - } -#endif + irq = (irq + 3 + slot) % 4; } irq++; /* 1-4 */ @@ -101,7 +77,7 @@ int pci_get_irq(struct pci_dev *dev, int /* Check OnBoard Ethernet (IDSEL=A24, DevNu=13) */ if (dev->bus->parent == NULL && - PCI_SLOT(dev->devfn) == TX3927_PCIC_IDSEL_AD_TO_SLOT(24)) { + slot == TX3927_PCIC_IDSEL_AD_TO_SLOT(24)) { extern int jmr3927_ether1_irq; /* check this irq line was reserved for ether1 */ if (jmr3927_ether1_irq != JMR3927_IRQ_ETHER0) @@ -112,27 +88,12 @@ int pci_get_irq(struct pci_dev *dev, int return irq; } -void __init pcibios_fixup_irqs(void) +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - unsigned char irq; - struct pci_dev *dev = NULL; + /* SMSC SLC90E66 IDE uses irq 14, 15 (default) */ + if (!(dev->vendor == PCI_VENDOR_ID_EFAR && + dev->device == PCI_DEVICE_ID_EFAR_SLC90E66_1)) + return pci_get_irq(dev, pin); - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq); - if (irq == 0) - return; - - /* SMSC SLC90E66 IDE uses irq 14, 15 (default) */ - if (!(dev->vendor == PCI_VENDOR_ID_EFAR && - dev->device == PCI_DEVICE_ID_EFAR_SLC90E66_1)) { - irq = pci_get_irq(dev, irq); - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, - irq); - } - - pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); - printk(KERN_INFO "PCI: %02x:%02x IRQ %02x\n", - dev->bus->number, dev->devfn, irq); - dev->irq = irq; - } + dev->irq = irq; } --- diff/arch/mips/pci/fixup-ocelot.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/fixup-ocelot.c 2004-02-23 13:56:38.000000000 +0000 @@ -13,12 +13,11 @@ #include #include #include -#include #include #include -void __devinit gt64120_board_pcibios_fixup_bus(struct pci_bus *bus) +void __devinit pcibios_fixup_bus(struct pci_bus *bus) { struct pci_bus *current_bus = bus; struct pci_dev *devices; @@ -38,8 +37,7 @@ void __devinit gt64120_board_pcibios_fix */ if ((devices->vendor != 0x8086) || (devices->device != 0x1209)) { - panic - ("gt64120_board_pcibios_fixup_bus: found " + panic("pcibios_fixup_bus: found " "unexpected PCI device in slot 1."); } devices->irq = 2; /* irq_nr is 2 for INT0 */ --- diff/arch/mips/pci/fixup-tb0226.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/fixup-tb0226.c 2004-02-23 13:56:38.000000000 +0000 @@ -18,14 +18,6 @@ #include -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ -} - -void __init pcibios_fixup(void) -{ -} - void __init pcibios_fixup_irqs(void) { struct pci_dev *dev = NULL; @@ -84,8 +76,3 @@ void __init pcibios_fixup_irqs(void) pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); } } - -unsigned int pcibios_assign_all_busses(void) -{ - return 0; -} --- diff/arch/mips/pci/fixup-tb0229.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/fixup-tb0229.c 2004-02-23 13:56:38.000000000 +0000 @@ -19,14 +19,6 @@ #include -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ -} - -void __init pcibios_fixup(void) -{ -} - void __init pcibios_fixup_irqs(void) { #ifdef CONFIG_TANBAC_TB0219 @@ -70,8 +62,3 @@ void __init pcibios_fixup_irqs(void) } #endif } - -unsigned int pcibios_assign_all_busses(void) -{ - return 0; -} --- diff/arch/mips/pci/fixup-victor-mpc30x.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/fixup-victor-mpc30x.c 2004-02-23 13:56:38.000000000 +0000 @@ -19,54 +19,30 @@ #include #include -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ -} - -void __init pcibios_fixup(void) -{ -} +/* + * Shortcuts + */ +#define PCMCIA1 VRC4173_PCMCIA1_IRQ +#define PCMCIA2 VRC4173_PCMCIA2_IRQ +#define MQ MQ200_IRQ + +static const int internal_func_irqs[8] __initdata = { + VRC4173_CASCADE_IRQ, + VRC4173_AC97_IRQ, + VRC4173_USB_IRQ, + +}; + +static char irq_tab_mpc30x[][5] __initdata = { + [12] = { PCMCIA1, PCMCIA1, 0, 0 }, + [13] = { PCMCIA2, PCMCIA2, 0, 0 }, + [29] = { MQ, MQ, 0, 0 }, /* mediaQ MQ-200 */ +}; -void __init pcibios_fixup_irqs(void) +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - struct pci_dev *dev = NULL; - u8 slot, func; + if (slot == 30) + return internal_func_irqs[PCI_FUNC(dev->devfn)]; - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - slot = PCI_SLOT(dev->devfn); - func = PCI_FUNC(dev->devfn); - dev->irq = 0; - - switch (slot) { - case 12: /* NEC VRC4173 CARDU1 */ - dev->irq = VRC4173_PCMCIA1_IRQ; - break; - case 13: /* NEC VRC4173 CARDU2 */ - dev->irq = VRC4173_PCMCIA2_IRQ; - break; - case 29: /* mediaQ MQ-200 */ - dev->irq = MQ200_IRQ; - break; - case 30: - switch (func) { - case 0: /* NEC VRC4173 */ - dev->irq = VRC4173_CASCADE_IRQ; - break; - case 1: /* NEC VRC4173 AC97U */ - dev->irq = VRC4173_AC97_IRQ; - break; - case 2: /* NEC VRC4173 USBU */ - dev->irq = VRC4173_USB_IRQ; - break; - } - break; - } - - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); - } -} - -unsigned int pcibios_assign_all_busses(void) -{ - return 0; + return irq_tab_mpc30x[slot][pin]; } --- diff/arch/mips/pci/ops-au1000.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/ops-au1000.c 2004-02-23 13:56:38.000000000 +0000 @@ -34,47 +34,14 @@ #include #include -#include +#include #ifdef CONFIG_MIPS_PB1000 -#include +#include #endif -#include #define PCI_ACCESS_READ 0 #define PCI_ACCESS_WRITE 1 -#undef DEBUG -#ifdef DEBUG -#define DBG(x...) printk(x) -#else -#define DBG(x...) -#endif - -/* TBD */ -static struct resource pci_io_resource = { - "pci IO space", - (u32) PCI_IO_START, - (u32) PCI_IO_END, - IORESOURCE_IO -}; - -static struct resource pci_mem_resource = { - "pci memory space", - (u32) PCI_MEM_START, - (u32) PCI_MEM_END, - IORESOURCE_MEM -}; - -extern struct pci_ops au1x_pci_ops; - -struct pci_channel mips_pci_channels[] = { - {&au1x_pci_ops, &pci_io_resource, &pci_mem_resource, - PCI_FIRST_DEVFN, PCI_LAST_DEVFN}, - {(struct pci_ops *) NULL, (struct resource *) NULL, - (struct resource *) NULL, (int) NULL, (int) NULL} -}; - - #ifdef CONFIG_MIPS_PB1000 /* * "Bus 2" is really the first and only external slot on the pb1000. @@ -102,12 +69,6 @@ static int config_access(unsigned char a } au_sync_udelay(1); - DBG("config_access: %d bus %d dev_fn %x at %x *data %x, conf %x\n", - access_type, bus, dev_fn, where, *data, config); - - DBG("bridge config reg: %x (%x)\n", au_readl(PCI_BRIDGE_CONFIG), - *data); - if (au_readl(PCI_BRIDGE_CONFIG) & (1 << 16)) { *data = 0xffffffff; return -1; @@ -178,20 +139,11 @@ static int config_access(unsigned char a } au_sync_udelay(2); - - DBG("config_access: %d bus %d device %d at %x *data %x, conf %x\n", - access_type, bus->number, device, where, *data, config); - /* unmap io space */ iounmap((void *) cfg_addr); /* check master abort */ status = au_readl(Au1500_PCI_STATCMD); -#if 0 - if (access_type == PCI_ACCESS_READ) { - printk("read data: %x\n", *data); - } -#endif if (status & (1 << 29)) { *data = 0xffffffff; return -1; @@ -268,9 +220,6 @@ write_config_word(struct pci_bus *bus, u { u32 data = 0; - if (where & 1) - return PCIBIOS_BAD_REGISTER_NUMBER; - if (config_access(PCI_ACCESS_READ, bus, devfn, where, &data)) return -1; @@ -288,9 +237,6 @@ static int write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val) { - if (where & 3) - return PCIBIOS_BAD_REGISTER_NUMBER; - if (config_access(PCI_ACCESS_WRITE, bus, devfn, where, &val)) return -1; --- diff/arch/mips/pci/ops-ddb5074.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/ops-ddb5074.c 2004-02-23 13:56:38.000000000 +0000 @@ -14,7 +14,6 @@ * option) any later version. * */ -#include #include #include #include @@ -270,66 +269,3 @@ struct pci_ops ddb5476_ext_pci_ops = { extpci_write_config_word, extpci_write_config_dword }; - - -#if defined(CONFIG_RUNTIME_DEBUG) -void jsun_scan_pci_bus(void) -{ - struct pci_bus bus; - struct pci_dev dev; - unsigned int devfn; - int j; - - pci_config_workaround = 0; - - bus.parent = NULL; /* we scan the top level only */ - dev.bus = &bus; - dev.sysdata = NULL; - - /* scan ext pci bus and io pci bus */ - for (j = 0; j < 1; j++) { - printk(KERN_INFO "scan ddb5476 external PCI bus:\n"); - bus.ops = &ddb5476_ext_pci_ops; - - for (devfn = 0; devfn < 0x100; devfn += 8) { - u32 temp; - u16 temp16; - u8 temp8; - int i; - - dev.devfn = devfn; - db_verify(pci_read_config_dword(&dev, 0, &temp), - == PCIBIOS_SUCCESSFUL); - if (temp == 0xffffffff) - continue; - - printk(KERN_INFO "slot %d: (addr %d) \n", - devfn / 8, 11 + devfn / 8); - - /* verify read word and byte */ - db_verify(pci_read_config_word(&dev, 2, &temp16), - == PCIBIOS_SUCCESSFUL); - db_assert(temp16 == (temp >> 16)); - db_verify(pci_read_config_byte(&dev, 3, &temp8), - == PCIBIOS_SUCCESSFUL); - db_assert(temp8 == (temp >> 24)); - db_verify(pci_read_config_byte(&dev, 1, &temp8), - == PCIBIOS_SUCCESSFUL); - db_assert(temp8 == ((temp >> 8) & 0xff)); - - for (i = 0; i < 16; i++) { - if ((i % 4) == 0) - printk(KERN_INFO); - db_verify(pci_read_config_dword - (&dev, i * 4, &temp), - == PCIBIOS_SUCCESSFUL); - printk("\t%08X", temp); - if ((i % 4) == 3) - printk("\n"); - } - } - } - - pci_config_workaround = 1; -} -#endif --- diff/arch/mips/pci/ops-ddb5476.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/ops-ddb5476.c 2004-02-23 13:56:38.000000000 +0000 @@ -14,7 +14,6 @@ * option) any later version. * */ -#include #include #include #include @@ -285,66 +284,3 @@ struct pci_ops ddb5476_ext_pci_ops = { extpci_write_config_word, extpci_write_config_dword }; - - -#if defined(CONFIG_RUNTIME_DEBUG) -void jsun_scan_pci_bus(void) -{ - struct pci_bus bus; - struct pci_dev dev; - unsigned int devfn; - int j; - - pci_config_workaround = 0; - - bus.parent = NULL; /* we scan the top level only */ - dev.bus = &bus; - dev.sysdata = NULL; - - /* scan ext pci bus and io pci bus */ - for (j = 0; j < 1; j++) { - printk(KERN_INFO "scan ddb5476 external PCI bus:\n"); - bus.ops = &ddb5476_ext_pci_ops; - - for (devfn = 0; devfn < 0x100; devfn += 8) { - u32 temp; - u16 temp16; - u8 temp8; - int i; - - dev.devfn = devfn; - db_verify(pci_read_config_dword(&dev, 0, &temp), - == PCIBIOS_SUCCESSFUL); - if (temp == 0xffffffff) - continue; - - printk(KERN_INFO "slot %d: (addr %d) \n", - devfn / 8, 11 + devfn / 8); - - /* verify read word and byte */ - db_verify(pci_read_config_word(&dev, 2, &temp16), - == PCIBIOS_SUCCESSFUL); - db_assert(temp16 == (temp >> 16)); - db_verify(pci_read_config_byte(&dev, 3, &temp8), - == PCIBIOS_SUCCESSFUL); - db_assert(temp8 == (temp >> 24)); - db_verify(pci_read_config_byte(&dev, 1, &temp8), - == PCIBIOS_SUCCESSFUL); - db_assert(temp8 == ((temp >> 8) & 0xff)); - - for (i = 0; i < 16; i++) { - if ((i % 4) == 0) - printk(KERN_INFO); - db_verify(pci_read_config_dword - (&dev, i * 4, &temp), - == PCIBIOS_SUCCESSFUL); - printk("\t%08X", temp); - if ((i % 4) == 3) - printk("\n"); - } - } - } - - pci_config_workaround = 1; -} -#endif --- diff/arch/mips/pci/ops-ddb5477.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/ops-ddb5477.c 2004-02-23 13:56:38.000000000 +0000 @@ -67,7 +67,7 @@ static inline u32 ddb_access_config_base { u32 pci_addr = 0; u32 pciinit_offset = 0; - u32 virt_addr = swap->config_base; + u32 virt_addr; u32 option; /* minimum pdar (window) size is 2MB */ @@ -127,39 +127,41 @@ static inline void ddb_close_config_base } static int read_config_dword(struct pci_config_swap *swap, - struct pci_bus *bus, u32 where, u32 * val) + struct pci_bus *bus, u32 devfn, u32 where, + u32 * val) { - u32 bus, slot_num, func_num; + u32 bus_num, slot_num, func_num; u32 base; db_assert((where & 3) == 0); db_assert(where < (1 << 8)); /* check if the bus is top-level */ - if (dev->bus->parent != NULL) { - bus = dev->bus->number; - db_assert(bus != 0); + if (bus->parent != NULL) { + bus_num = bus->number; + db_assert(bus_num != 0); } else { - bus = 0; + bus_num = 0; } - slot_num = PCI_SLOT(dev->devfn); - func_num = PCI_FUNC(dev->devfn); - base = ddb_access_config_base(swap, bus, slot_num); + slot_num = PCI_SLOT(devfn); + func_num = PCI_FUNC(devfn); + base = ddb_access_config_base(swap, bus_num, slot_num); *val = *(volatile u32 *) (base + (func_num << 8) + where); ddb_close_config_base(swap); return PCIBIOS_SUCCESSFUL; } static int read_config_word(struct pci_config_swap *swap, - struct pci_bus *bus, u32 where, u16 * val) + struct pci_bus *bus, u32 devfn, u32 where, + u16 * val) { int status; u32 result; db_assert((where & 1) == 0); - status = read_config_dword(swap, bus, where & ~3, &result); + status = read_config_dword(swap, bus, devfn, where & ~3, &result); if (where & 2) result >>= 16; *val = result & 0xffff; @@ -167,13 +169,13 @@ static int read_config_word(struct pci_c } static int read_config_byte(struct pci_config_swap *swap, - struct pci_bus *bus, unsigned int devfn, + struct pci_bus *bus, u32 devfn, u32 where, u8 * val) { int status; u32 result; - status = read_config_dword(swap, bus, where & ~3, &result); + status = read_config_dword(swap, bus, devfn, where & ~3, &result); if (where & 1) result >>= 8; if (where & 2) @@ -184,10 +186,10 @@ static int read_config_byte(struct pci_c } static int write_config_dword(struct pci_config_swap *swap, - struct pci_bus *bus, unsigned int devfn, + struct pci_bus *bus, u32 devfn, u32 where, u32 val) { - u32 busno, slot_num, func_num; + u32 bus_num, slot_num, func_num; u32 base; db_assert((where & 3) == 0); @@ -195,30 +197,29 @@ static int write_config_dword(struct pci /* check if the bus is top-level */ if (bus->parent != NULL) { - busno = bus->number; - db_assert(busno != 0); + bus_num = bus->number; + db_assert(bus_num != 0); } else { - busno = 0; + bus_num = 0; } slot_num = PCI_SLOT(devfn); func_num = PCI_FUNC(devfn); - base = ddb_access_config_base(swap, busno, slot_num); + base = ddb_access_config_base(swap, bus_num, slot_num); *(volatile u32 *) (base + (func_num << 8) + where) = val; ddb_close_config_base(swap); return PCIBIOS_SUCCESSFUL; } static int write_config_word(struct pci_config_swap *swap, - struct pci_bus *bus, unsigned int devfn, - int where, u16 val) + struct pci_bus *bus, u32 devfn, u32 where, u16 val) { int status, shift = 0; u32 result; db_assert((where & 1) == 0); - status = read_config_dword(swap, dev, where & ~3, &result); + status = read_config_dword(swap, bus, devfn, where & ~3, &result); if (status != PCIBIOS_SUCCESSFUL) return status; @@ -226,17 +227,16 @@ static int write_config_word(struct pci_ shift += 16; result &= ~(0xffff << shift); result |= val << shift; - return write_config_dword(swap, dev, where & ~3, result); + return write_config_dword(swap, bus, devfn, where & ~3, result); } static int write_config_byte(struct pci_config_swap *swap, - struct pci_bus *bus, unsigned int devfn, - int where, u8 val) + struct pci_bus *bus, u32 devfn, u32 where, u8 val) { int status, shift = 0; u32 result; - status = read_config_dword(swap, dev, where & ~3, &result); + status = read_config_dword(swap, bus, devfn, where & ~3, &result); if (status != PCIBIOS_SUCCESSFUL) return status; @@ -246,28 +246,25 @@ static int write_config_byte(struct pci_ shift += 8; result &= ~(0xff << shift); result |= val << shift; - return write_config_dword(swap, dev, where & ~3, result); + return write_config_dword(swap, bus, devfn, where & ~3, result); } -/* - * Dump solution for now so I don't break hw I can't test on ... - */ -#define MAKE_PCI_OPS(prefix, rw, unitname, unittype, pciswap) \ -static int prefix##_##rw##_config(struct pci_bus *bus, int where, int size, unittype val) \ +#define MAKE_PCI_OPS(prefix, rw, pciswap, star) \ +static int prefix##_##rw##_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 star val) \ { \ if (size == 1) \ - return rw##_config_byte(pciswap, bus, where, val); \ + return rw##_config_byte(pciswap, bus, devfn, where, (u8 star)val); \ else if (size == 2) \ - return rw##_config_word(pciswap, bus, where, val); \ + return rw##_config_word(pciswap, bus, devfn, where, (u16 star)val); \ /* Size must be 4 */ \ - return rw##_config_dword(pciswap, bus, where, val); \ + return rw##_config_dword(pciswap, bus, devfn, where, val); \ } -MAKE_PCI_OPS(extpci, read, &ext_pci_swap) - MAKE_PCI_OPS(extpci, write, &ext_pci_swap) +MAKE_PCI_OPS(extpci, read, &ext_pci_swap, *) +MAKE_PCI_OPS(extpci, write, &ext_pci_swap,) - MAKE_PCI_OPS(iopci, read, &io_pci_swap) - MAKE_PCI_OPS(iopci, write, &io_pci_swap) +MAKE_PCI_OPS(iopci, read, &io_pci_swap, *) +MAKE_PCI_OPS(iopci, write, &io_pci_swap,) struct pci_ops ddb5477_ext_pci_ops = { .read = extpci_read_config, --- diff/arch/mips/pci/ops-it8172.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/ops-it8172.c 2004-02-23 13:56:38.000000000 +0000 @@ -77,10 +77,10 @@ static struct resource pci_mem_resource_ extern struct pci_ops it8172_pci_ops; -struct pci_channel mips_pci_channels[] = { - {&it8172_pci_ops, &pci_io_resource, &pci_mem_resource_0, 0x10, - 0xff}, - {NULL, NULL, NULL, NULL, NULL} +struct pci_controller it8172_controller = { + .pci_ops = &it8172_pci_ops, + .io_resource = &pci_io_resource, + .mem_resource = &pci_mem_resource_0, }; static int it8172_pcibios_config_access(unsigned char access_type, @@ -212,8 +212,3 @@ struct pci_ops it8172_pci_ops = { .read = read_config, .write = write_config, }; - -unsigned __init int pcibios_assign_all_busses(void) -{ - return 1; -} --- diff/arch/mips/pci/pci-ddb5074.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/pci-ddb5074.c 2004-02-23 13:56:38.000000000 +0000 @@ -24,9 +24,10 @@ static struct resource extpci_mem_resour extern struct pci_ops ddb5476_ext_pci_ops; -struct pci_channel mips_pci_channels[] = { - {&ddb5476_ext_pci_ops, &extpci_io_resource, &extpci_mem_resource}, - {NULL, NULL, NULL} +struct pci_controller ddb5476_controller = { + .pci_ops = &ddb5476_ext_pci_ops, + .io_resource = &extpci_io_resource, + .mem_resource = &extpci_mem_resource, }; #define PCI_EXT_INTA 8 @@ -38,40 +39,19 @@ struct pci_channel mips_pci_channels[] = #define MAX_SLOT_NUM 14 static unsigned char irq_map[MAX_SLOT_NUM] = { - /* SLOT: 0 */ nile4_to_irq(PCI_EXT_INTE), - /* SLOT: 1 */ nile4_to_irq(PCI_EXT_INTA), - /* SLOT: 2 */ nile4_to_irq(PCI_EXT_INTA), - /* SLOT: 3 */ nile4_to_irq(PCI_EXT_INTB), - /* SLOT: 4 */ nile4_to_irq(PCI_EXT_INTC), - /* SLOT: 5 */ nile4_to_irq(NILE4_INT_UART), - /* SLOT: 6 */ 0xff, - /* SLOT: 7 */ 0xff, - /* SLOT: 8 */ 0xff, - /* SLOT: 9 */ 0xff, - /* SLOT: 10 */ nile4_to_irq(PCI_EXT_INTE), - /* SLOT: 11 */ 0xff, - /* SLOT: 12 */ 0xff, - /* SLOT: 13 */ nile4_to_irq(PCI_EXT_INTE), + [ 0] = nile4_to_irq(PCI_EXT_INTE), + [ 1] = nile4_to_irq(PCI_EXT_INTA), + [ 2] = nile4_to_irq(PCI_EXT_INTA), + [ 3] = nile4_to_irq(PCI_EXT_INTB), + [ 4] = nile4_to_irq(PCI_EXT_INTC), + [ 5] = nile4_to_irq(NILE4_INT_UART), + [10] = nile4_to_irq(PCI_EXT_INTE), + [13] = nile4_to_irq(PCI_EXT_INTE), }; -void __init pcibios_fixup_irqs(void) +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - - struct pci_dev *dev = NULL; - int slot_num; - - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - slot_num = PCI_SLOT(dev->devfn); - db_assert(slot_num < MAX_SLOT_NUM); - printk("irq_map[%d]: %02x\n", slot_num, irq_map[slot_num]); - db_assert(irq_map[slot_num] != 0xff); - - pci_write_config_byte(dev, - PCI_INTERRUPT_LINE, - irq_map[slot_num]); - - dev->irq = irq_map[slot_num]; - } + return irq_map[slot]; } void __init ddb_pci_reset_bus(void) @@ -92,38 +72,3 @@ void __init ddb_pci_reset_bus(void) ddb_out32(DDB_PCICTRL + 4, temp); } - -unsigned __init int pcibios_assign_all_busses(void) -{ - /* we hope pci_auto has assigned the bus numbers to all buses */ - return 1; -} - -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ -} - -void __init pcibios_fixup(void) -{ - struct pci_dev *dev = NULL; - - while ((dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, - dev)) != NULL) { - /* - * It's nice to have the LEDs on the GPIO pins - * available for debugging - */ - extern struct pci_dev *pci_pmu; - u8 t8; - - pci_pmu = dev; /* for LEDs D2 and D3 */ - /* Program the lines for LEDs D2 and D3 to output */ - pci_read_config_byte(dev, 0x7d, &t8); - t8 |= 0xc0; - pci_write_config_byte(dev, 0x7d, t8); - /* Turn LEDs D2 and D3 off */ - pci_read_config_byte(dev, 0x7e, &t8); - t8 |= 0xc0; - pci_write_config_byte(dev, 0x7e, t8); - } -} --- diff/arch/mips/pci/pci-ddb5476.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/pci-ddb5476.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,4 +1,3 @@ -#include #include #include #include @@ -25,9 +24,10 @@ static struct resource extpci_mem_resour extern struct pci_ops ddb5476_ext_pci_ops; -struct pci_channel mips_pci_channels[] = { - {&ddb5476_ext_pci_ops, &extpci_io_resource, &extpci_mem_resource}, - {NULL, NULL, NULL} +struct pci_controller ddb5476_controller = { + .pci_ops = &ddb5476_ext_pci_ops, + .io_resource = &extpci_io_resource, + .mem_resource = &extpci_mem_resource }; @@ -53,64 +53,21 @@ struct pci_channel mips_pci_channels[] = */ #define MAX_SLOT_NUM 21 static unsigned char irq_map[MAX_SLOT_NUM] = { - /* SLOT: 0, AD:11 */ 0xff, - /* SLOT: 1, AD:12 */ 0xff, - /* SLOT: 2, AD:13 */ 9, - /* USB */ - /* SLOT: 3, AD:14 */ 10, - /* PMU */ - /* SLOT: 4, AD:15 */ 0xff, - /* SLOT: 5, AD:16 */ 0x0, - /* P2P bridge */ - /* SLOT: 6, AD:17 */ nile4_to_irq(PCI_EXT_INTB), - /* SLOT: 7, AD:18 */ nile4_to_irq(PCI_EXT_INTC), - /* SLOT: 8, AD:19 */ nile4_to_irq(PCI_EXT_INTD), - /* SLOT: 9, AD:20 */ nile4_to_irq(PCI_EXT_INTA), - /* SLOT: 10, AD:21 */ 0xff, - /* SLOT: 11, AD:22 */ 0xff, - /* SLOT: 12, AD:23 */ 0xff, - /* SLOT: 13, AD:24 */ 14, - /* HD controller, M5229 */ - /* SLOT: 14, AD:25 */ 0xff, - /* SLOT: 15, AD:26 */ 0xff, - /* SLOT: 16, AD:27 */ 0xff, - /* SLOT: 17, AD:28 */ 0xff, - /* SLOT: 18, AD:29 */ 0xff, - /* SLOT: 19, AD:30 */ 0xff, - /* SLOT: 20, AD:31 */ 0xff + [ 2] = 9, /* AD:13 USB */ + [ 3] = 10, /* AD:14 PMU */ + [ 5] = 0, /* AD:16 P2P bridge */ + [ 6] = nile4_to_irq(PCI_EXT_INTB), /* AD:17 */ + [ 7] = nile4_to_irq(PCI_EXT_INTC), /* AD:18 */ + [ 8] = nile4_to_irq(PCI_EXT_INTD), /* AD:19 */ + [ 9] = nile4_to_irq(PCI_EXT_INTA), /* AD:20 */ + [13] = 14, /* AD:24 HD controller, M5229 */ }; -extern int vrc5477_irq_to_irq(int irq); -void __init pcibios_fixup_irqs(void) +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - struct pci_dev *dev = NULL; - int slot_num; - - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - slot_num = PCI_SLOT(dev->devfn); - - /* we don't do IRQ fixup for sub-bus yet */ - if (dev->bus->parent != NULL) { - db_run(printk - ("Don't know how to fixup irq for PCI device %d on sub-bus %d\n", - slot_num, dev->bus->number)); - continue; - } - - db_assert(slot_num < MAX_SLOT_NUM); - db_assert(irq_map[slot_num] != 0xff); - - pci_write_config_byte(dev, - PCI_INTERRUPT_LINE, - irq_map[slot_num]); - dev->irq = irq_map[slot_num]; - } + return irq_map[slot]; } -#if defined(CONFIG_RUNTIME_DEBUG) -extern void jsun_scan_pci_bus(void); -#endif - void __init ddb_pci_reset_bus(void) { u32 temp; @@ -129,17 +86,3 @@ void __init ddb_pci_reset_bus(void) ddb_out32(DDB_PCICTRL + 4, temp); } - -unsigned __init int pcibios_assign_all_busses(void) -{ - /* we hope pci_auto has assigned the bus numbers to all buses */ - return 1; -} - -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ -} - -void __init pcibios_fixup(void) -{ -} --- diff/arch/mips/pci/pci-ddb5477.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/pci-ddb5477.c 2004-02-23 13:56:38.000000000 +0000 @@ -9,7 +9,6 @@ * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ -#include #include #include #include @@ -52,12 +51,19 @@ static struct resource iopci_mem_resourc extern struct pci_ops ddb5477_ext_pci_ops; extern struct pci_ops ddb5477_io_pci_ops; -struct pci_channel mips_pci_channels[] = { - {&ddb5477_ext_pci_ops, &extpci_io_resource, &extpci_mem_resource}, - {&ddb5477_io_pci_ops, &iopci_io_resource, &iopci_mem_resource}, - {NULL, NULL, NULL} +struct pci_controller ddb5477_ext_controller = { + .pci_ops = &ddb5477_ext_pci_ops, + .io_resource = &extpci_io_resource, + .mem_resource = &extpci_mem_resource }; +struct pci_controller ddb5477_io_controller = { + .pci_ops = &ddb5477_io_pci_ops, + .io_resource = &iopci_io_resource, + .mem_resource = &iopci_mem_resource +}; + + /* * we fix up irqs based on the slot number. @@ -82,16 +88,11 @@ static unsigned char irq_map[MAX_SLOT_NU /* SLOT: 1, AD:12 */ 0xff, /* SLOT: 2, AD:13 */ 0xff, /* SLOT: 3, AD:14 */ 0xff, - /* SLOT: 4, AD:15 */ VRC5477_IRQ_INTA, - /* onboard tulip */ - /* SLOT: 5, AD:16 */ VRC5477_IRQ_INTB, - /* slot 1 */ - /* SLOT: 6, AD:17 */ VRC5477_IRQ_INTC, - /* slot 2 */ - /* SLOT: 7, AD:18 */ VRC5477_IRQ_INTD, - /* slot 3 */ - /* SLOT: 8, AD:19 */ VRC5477_IRQ_INTE, - /* slot 4 */ + /* SLOT: 4, AD:15 */ VRC5477_IRQ_INTA, /* onboard tulip */ + /* SLOT: 5, AD:16 */ VRC5477_IRQ_INTB, /* slot 1 */ + /* SLOT: 6, AD:17 */ VRC5477_IRQ_INTC, /* slot 2 */ + /* SLOT: 7, AD:18 */ VRC5477_IRQ_INTD, /* slot 3 */ + /* SLOT: 8, AD:19 */ VRC5477_IRQ_INTE, /* slot 4 */ /* SLOT: 9, AD:20 */ 0xff, /* SLOT: 10, AD:21 */ 0xff, /* SLOT: 11, AD:22 */ 0xff, @@ -101,31 +102,21 @@ static unsigned char irq_map[MAX_SLOT_NU /* SLOT: 15, AD:26 */ 0xff, /* SLOT: 16, AD:27 */ 0xff, /* SLOT: 17, AD:28 */ 0xff, - /* SLOT: 18, AD:29 */ VRC5477_IRQ_IOPCI_INTC, - /* vrc5477 ac97 */ - /* SLOT: 19, AD:30 */ VRC5477_IRQ_IOPCI_INTB, - /* vrc5477 usb peri */ - /* SLOT: 20, AD:31 */ VRC5477_IRQ_IOPCI_INTA, - /* vrc5477 usb host */ + /* SLOT: 18, AD:29 */ VRC5477_IRQ_IOPCI_INTC, /* vrc5477 ac97 */ + /* SLOT: 19, AD:30 */ VRC5477_IRQ_IOPCI_INTB, /* vrc5477 usb peri */ + /* SLOT: 20, AD:31 */ VRC5477_IRQ_IOPCI_INTA, /* vrc5477 usb host */ }; static unsigned char rockhopperII_irq_map[MAX_SLOT_NUM] = { /* SLOT: 0, AD:11 */ 0xff, - /* SLOT: 1, AD:12 */ VRC5477_IRQ_INTB, - /* onboard AMD PCNET */ + /* SLOT: 1, AD:12 */ VRC5477_IRQ_INTB, /* onboard AMD PCNET */ /* SLOT: 2, AD:13 */ 0xff, /* SLOT: 3, AD:14 */ 0xff, - /* SLOT: 4, AD:15 */ 14, - /* M5229 ide ISA irq */ - /* SLOT: 5, AD:16 */ VRC5477_IRQ_INTD, - /* slot 3 */ - /* SLOT: 6, AD:17 */ VRC5477_IRQ_INTA, - /* slot 4 */ - /* SLOT: 7, AD:18 */ VRC5477_IRQ_INTD, - /* slot 5 */ - /* SLOT: 8, AD:19 */ 0, - /* M5457 modem nop */ - /* SLOT: 9, AD:20 */ VRC5477_IRQ_INTA, - /* slot 2 */ + /* SLOT: 4, AD:15 */ 14, /* M5229 ide ISA irq */ + /* SLOT: 5, AD:16 */ VRC5477_IRQ_INTD, /* slot 3 */ + /* SLOT: 6, AD:17 */ VRC5477_IRQ_INTA, /* slot 4 */ + /* SLOT: 7, AD:18 */ VRC5477_IRQ_INTD, /* slot 5 */ + /* SLOT: 8, AD:19 */ 0, /* M5457 modem nop */ + /* SLOT: 9, AD:20 */ VRC5477_IRQ_INTA, /* slot 2 */ /* SLOT: 10, AD:21 */ 0xff, /* SLOT: 11, AD:22 */ 0xff, /* SLOT: 12, AD:23 */ 0xff, @@ -133,62 +124,57 @@ static unsigned char rockhopperII_irq_ma /* SLOT: 14, AD:25 */ 0xff, /* SLOT: 15, AD:26 */ 0xff, /* SLOT: 16, AD:27 */ 0xff, - /* SLOT: 17, AD:28 */ 0, - /* M7101 PMU nop */ - /* SLOT: 18, AD:29 */ VRC5477_IRQ_IOPCI_INTC, - /* vrc5477 ac97 */ - /* SLOT: 19, AD:30 */ VRC5477_IRQ_IOPCI_INTB, - /* vrc5477 usb peri */ - /* SLOT: 20, AD:31 */ VRC5477_IRQ_IOPCI_INTA, - /* vrc5477 usb host */ + /* SLOT: 17, AD:28 */ 0, /* M7101 PMU nop */ + /* SLOT: 18, AD:29 */ VRC5477_IRQ_IOPCI_INTC, /* vrc5477 ac97 */ + /* SLOT: 19, AD:30 */ VRC5477_IRQ_IOPCI_INTB, /* vrc5477 usb peri */ + /* SLOT: 20, AD:31 */ VRC5477_IRQ_IOPCI_INTA, /* vrc5477 usb host */ }; -void __init pcibios_fixup_irqs(void) +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - struct pci_dev *dev = NULL; int slot_num; unsigned char *slot_irq_map; unsigned char irq; + /* + * We ignore the swizzled slot and pin values. The original + * pci_fixup_irq() codes largely base irq number on the dev slot + * numbers because except for one case they are unique even + * though there are multiple pci buses. + */ + if (mips_machtype == MACH_NEC_ROCKHOPPERII) slot_irq_map = rockhopperII_irq_map; else slot_irq_map = irq_map; + slot_num = PCI_SLOT(dev->devfn); + irq = slot_irq_map[slot_num]; - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - slot_num = PCI_SLOT(dev->devfn); - irq = slot_irq_map[slot_num]; - - db_assert(slot_num < MAX_SLOT_NUM); - - db_assert(irq != 0xff); - - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); - - dev->irq = irq; - - if (mips_machtype == MACH_NEC_ROCKHOPPERII) { - /* hack to distinquish overlapping slot 20s, one - * on bus 0 (ALI USB on the M1535 on the backplane), - * and one on bus 2 (NEC USB controller on the CPU board) - * Make the M1535 USB - ISA IRQ number 9. - */ - if (slot_num == 20 && dev->bus->number == 0) { - pci_write_config_byte(dev, - PCI_INTERRUPT_LINE, - 9); - dev->irq = 9; - } + db_assert(slot_num < MAX_SLOT_NUM); + + db_assert(irq != 0xff); + + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); + + if (mips_machtype == MACH_NEC_ROCKHOPPERII) { + /* hack to distinquish overlapping slot 20s, one + * on bus 0 (ALI USB on the M1535 on the backplane), + * and one on bus 2 (NEC USB controller on the CPU board) + * Make the M1535 USB - ISA IRQ number 9. + */ + if (slot_num == 20 && dev->bus->number == 0) { + pci_write_config_byte(dev, + PCI_INTERRUPT_LINE, + 9); + irq = 9; } } + + return irq; } -#if defined(CONFIG_RUNTIME_DEBUG) -extern void jsun_scan_pci_bus(void); -extern void jsun_assign_pci_resource(void); -#endif void ddb_pci_reset_bus(void) { u32 temp; @@ -212,88 +198,3 @@ void ddb_pci_reset_bus(void) temp &= ~0xc0000000; ddb_out32(DDB_PCICTL1_H, temp); } - -unsigned __init int pcibios_assign_all_busses(void) -{ - /* we hope pci_auto has assigned the bus numbers to all buses */ - return 1; -} - -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ -} - -/* - * fixup baseboard AMD chip so that tx does not underflow. - * bcr_18 |= 0x0800 - * This sets NOUFLO bit which makes tx not start until whole pkt - * is fetched to the chip. - */ -#define PCNET32_WIO_RDP 0x10 -#define PCNET32_WIO_RAP 0x12 -#define PCNET32_WIO_RESET 0x14 -#define PCNET32_WIO_BDP 0x16 -void __init fix_amd_lance(struct pci_dev *dev) -{ - unsigned long ioaddr; - u16 temp; - - ioaddr = pci_resource_start(dev, 0); - - inw(ioaddr + PCNET32_WIO_RESET); /* reset chip */ - - /* bcr_18 |= 0x0800 */ - outw(18, ioaddr + PCNET32_WIO_RAP); - temp = inw(ioaddr + PCNET32_WIO_BDP); - temp |= 0x0800; - outw(18, ioaddr + PCNET32_WIO_RAP); - outw(temp, ioaddr + PCNET32_WIO_BDP); -} - -void __init pcibios_fixup(void) -{ - struct pci_dev *dev = NULL; - - if (mips_machtype != MACH_NEC_ROCKHOPPERII) - return; - - -#define M1535_CONFIG_PORT 0x3f0 -#define M1535_INDEX_PORT 0x3f0 -#define M1535_DATA_PORT 0x3f1 - - printk("Configuring ALI M1535 Super I/O mouse irq.\n"); - - request_region(M1535_CONFIG_PORT, 2, "M1535 Super I/O config"); - - /* Enter config mode. */ - outb(0x51, M1535_CONFIG_PORT); - outb(0x23, M1535_CONFIG_PORT); - - /* Select device 0x07. */ - outb(0x07, M1535_INDEX_PORT); - outb(0x07, M1535_DATA_PORT); - - /* Set mouse irq (register 0x72) to 12. */ - outb(0x72, M1535_INDEX_PORT); - outb(0x0c, M1535_DATA_PORT); - - /* Exit config mode. */ - outb(0xbb, M1535_CONFIG_PORT); - - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - if (dev->vendor == PCI_VENDOR_ID_AL) - if (dev->device == PCI_DEVICE_ID_AL_M1535 - || dev->device == PCI_DEVICE_ID_AL_M1533) { - u8 old; - printk - ("Enabling ALI M1533/35 PS2 keyboard/mouse.\n"); - pci_read_config_byte(dev, 0x41, &old); - pci_write_config_byte(dev, 0x41, old | 0xd0); - } - - if (dev->vendor == PCI_VENDOR_ID_AMD && - dev->device == PCI_DEVICE_ID_AMD_LANCE) - fix_amd_lance(dev); - } -} --- diff/arch/mips/pci/pci-hplj.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/pci-hplj.c 2004-02-23 13:56:38.000000000 +0000 @@ -15,8 +15,8 @@ #include #include -volatile u32 *pci_config_address_reg = (volatile u32 *) 0xfdead000; -volatile u32 *pci_config_data_reg = (volatile u32 *) 0xfdead000; +static volatile u32 *pci_config_address_reg = (volatile u32 *) 0xfdead000; +static volatile u32 *pci_config_data_reg = (volatile u32 *) 0xfdead000; @@ -107,21 +107,12 @@ struct pci_ops hp_pci_ops = { }; -struct pci_channel mips_pci_channels[] = { - {&hp_pci_ops, &ioport_resource, &iomem_resource}, - {NULL, NULL, NULL} +struct pci_controller hp_controller = { + .pci_ops = &hp_pci_ops, + .io_resource = &ioport_resource, + .mem_resource = &iomem_resource, }; -unsigned __init int pcibios_assign_all_busses(void) -{ - return 1; -} - -void __init pcibios_fixup(void) -{ -} - - void __init pcibios_fixup_irqs(void) { struct pci_dev *dev = NULL; @@ -210,43 +201,4 @@ void __init pci_setup(void) pci_config_data_reg = (u32 *) (((u32) mips_io_port_base) | 0xcfc); pci_config_address_reg = (u32 *) (((u32) pci_regs_base_offset) | 0xcf8); - -} - - -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ - int pos; - int bases; - - printk("adjusting pci device: %s\n", dev->name); - - switch (dev->hdr_type) { - case PCI_HEADER_TYPE_NORMAL: - bases = 6; - break; - case PCI_HEADER_TYPE_BRIDGE: - bases = 2; - break; - case PCI_HEADER_TYPE_CARDBUS: - bases = 1; - break; - default: - bases = 0; - break; - } - for (pos = 0; pos < bases; pos++) { - struct resource *res = &dev->resource[pos]; - if (res->start >= IO_MEM_LOGICAL_START && - res->end <= IO_MEM_LOGICAL_END) { - res->start += IO_MEM_VIRTUAL_OFFSET; - res->end += IO_MEM_VIRTUAL_OFFSET; - } - if (res->start >= IO_PORT_LOGICAL_START && - res->end <= IO_PORT_LOGICAL_END) { - res->start += IO_PORT_VIRTUAL_OFFSET; - res->end += IO_PORT_VIRTUAL_OFFSET; - } - } - } --- diff/arch/mips/pci/pci-ip27.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/pci/pci-ip27.c 2004-02-23 13:56:38.000000000 +0000 @@ -3,6 +3,7 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * + * Copyright (C) 2003 Christoph Hellwig (hch@lst.de) * Copyright (C) 1999, 2000 Ralf Baechle (ralf@gnu.org) * Copyright (C) 1999, 2000 Silicon Graphics, Inc. */ @@ -11,8 +12,9 @@ #include #include #include +#include #include -#include +#include #include /* @@ -26,6 +28,12 @@ #define MAX_DEVICES_PER_PCIBUS 8 /* + * XXX: No kmalloc available when we do our crosstalk scan, + * we should try to move it later in the boot process. + */ +static struct bridge_controller bridges[MAX_PCI_BUSSES]; + +/* * No locking needed until PCI initialization is done parallely. */ int irqstore[MAX_PCI_BUSSES][MAX_DEVICES_PER_PCIBUS]; @@ -34,7 +42,7 @@ int lastirq = BASE_PCI_IRQ; /* * Translate from irq to software PCI bus number and PCI slot. */ -int irq_to_bus[MAX_PCI_BUSSES * MAX_DEVICES_PER_PCIBUS]; +struct bridge_controller *irq_to_bridge[MAX_PCI_BUSSES * MAX_DEVICES_PER_PCIBUS]; int irq_to_slot[MAX_PCI_BUSSES * MAX_DEVICES_PER_PCIBUS]; /* @@ -42,90 +50,136 @@ int irq_to_slot[MAX_PCI_BUSSES * MAX_DEV * not really documented, so right now I can't write code which uses it. * Therefore we use type 0 accesses for now even though they won't work * correcly for PCI-to-PCI bridges. + * + * The function is complicated by the ultimate brokeness of the IOC3 chip + * which is used in SGI systems. The IOC3 can only handle 32-bit PCI + * accesses and does only decode parts of it's address space. */ -#define CF0_READ_PCI_CFG(bus,devfn,where,value,bm,mask) \ -do { \ - bridge_t *bridge; \ - int slot = PCI_SLOT(devfn); \ - int fn = PCI_FUNC(devfn); \ - volatile u32 *addr; \ - u32 cf, __bit; \ - unsigned int bus_id = (unsigned) bus->number; \ - \ - bridge = (bridge_t *) NODE_SWIN_BASE(bus_to_nid[bus_id], \ - bus_to_wid[bus_id]); \ - \ - __bit = (((where) & (bm)) << 3); \ - addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2]; \ - if (get_dbe(cf, addr)) \ - return PCIBIOS_DEVICE_NOT_FOUND; \ - *value = (cf >> __bit) & (mask); \ - return PCIBIOS_SUCCESSFUL; \ -} while (0) static int pci_conf0_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 * value) { - u32 vprod; + struct bridge_controller *bc = BRIDGE_CONTROLLER(bus); + bridge_t *bridge = bc->base; + int slot = PCI_SLOT(devfn); + int fn = PCI_FUNC(devfn); + volatile void *addr; + u32 cf, shift, mask; + int res; + + addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[PCI_VENDOR_ID]; + if (get_dbe(cf, (u32 *) addr)) + return PCIBIOS_DEVICE_NOT_FOUND; - CF0_READ_PCI_CFG(bus, devfn, PCI_VENDOR_ID, &vprod, 0, 0xffffffff); - if (vprod == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)) - && ((where >= 0x14 && where < 0x40) || (where >= 0x48))) { - *value = 0; - return PCIBIOS_SUCCESSFUL; - } + /* + * IOC3 is fucked fucked beyond believe ... Don't even give the + * generic PCI code a chance to look at it for real ... + */ + if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16))) + goto oh_my_gawd; + + addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[where ^ (4 - size)]; if (size == 1) - CF0_READ_PCI_CFG(bus, devfn, where, (u8 *) value, 3, 0xff); + res = get_dbe(*value, (u8 *) addr); else if (size == 2) - CF0_READ_PCI_CFG(bus, devfn, where, (u16 *) value, 2, - 0xffff); + res = get_dbe(*value, (u16 *) addr); else - CF0_READ_PCI_CFG(bus, devfn, where, (u32 *) value, 0, - 0xffffffff); -} + res = get_dbe(*value, (u32 *) addr); + + return PCIBIOS_SUCCESSFUL; + +oh_my_gawd: + + /* + * IOC3 is fucked fucked beyond believe ... Don't even give the + * generic PCI code a chance to look at the wrong register. + */ + if ((where >= 0x14 && where < 0x40) || (where >= 0x48)) { + *value = 0; + return PCIBIOS_SUCCESSFUL; + } + + /* + * IOC3 is fucked fucked beyond believe ... Don't try to access + * anything but 32-bit words ... + */ + addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2]; -#define CF0_WRITE_PCI_CFG(bus,devfn,where,value,bm,mask) \ -do { \ - bridge_t *bridge; \ - int slot = PCI_SLOT(devfn); \ - int fn = PCI_FUNC(devfn); \ - volatile u32 *addr; \ - u32 cf, __bit; \ - unsigned int bus_id = (unsigned) bus->number; \ - \ - bridge = (bridge_t *) NODE_SWIN_BASE(bus_to_nid[bus_id], \ - bus_to_wid[bus_id]); \ - \ - __bit = (((where) & (bm)) << 3); \ - addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2]; \ - if (get_dbe(cf, addr)) \ - return PCIBIOS_DEVICE_NOT_FOUND; \ - cf &= (~mask); \ - cf |= (value); \ - put_dbe(cf, addr); \ - return PCIBIOS_SUCCESSFUL; \ -} while (0) + if (get_dbe(cf, (u32 *) addr)) + return PCIBIOS_DEVICE_NOT_FOUND; + + shift = ((where & 3) << 3); + mask = (0xffffffffU >> ((4 - size) << 3)); + *value = (cf >> shift) & mask; + + return PCIBIOS_SUCCESSFUL; +} static int pci_conf0_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value) { - u32 vprod; + struct bridge_controller *bc = BRIDGE_CONTROLLER(bus); + bridge_t *bridge = bc->base; + int slot = PCI_SLOT(devfn); + int fn = PCI_FUNC(devfn); + volatile void *addr; + u32 cf, shift, mask, smask; + int res; + + addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[PCI_VENDOR_ID]; + if (get_dbe(cf, (u32 *) addr)) + return PCIBIOS_DEVICE_NOT_FOUND; - CF0_READ_PCI_CFG(bus, devfn, PCI_VENDOR_ID, &vprod, 0, 0xffffffff); - if (vprod == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)) - && ((where >= 0x14 && where < 0x40) || (where >= 0x48))) { - return PCIBIOS_SUCCESSFUL; + /* + * IOC3 is fucked fucked beyond believe ... Don't even give the + * generic PCI code a chance to look at it for real ... + */ + if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16))) + goto oh_my_gawd; + + addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[where ^ (4 - size)]; + + if (size == 1) { + res = put_dbe(value, (u8 *) addr); + } else if (size == 2) { + res = put_dbe(value, (u16 *) addr); + } else { + res = put_dbe(value, (u32 *) addr); } - if (size == 1) - CF0_WRITE_PCI_CFG(bus, devfn, where, (u8) value, 3, 0xff); - else if (size == 2) - CF0_WRITE_PCI_CFG(bus, devfn, where, (u16) value, 2, - 0xffff); - else - CF0_WRITE_PCI_CFG(bus, devfn, where, (u32) value, 0, - 0xffffffff); + if (res) + return PCIBIOS_DEVICE_NOT_FOUND; + + return PCIBIOS_SUCCESSFUL; + +oh_my_gawd: + + /* + * IOC3 is fucked fucked beyond believe ... Don't even give the + * generic PCI code a chance to touch the wrong register. + */ + if ((where >= 0x14 && where < 0x40) || (where >= 0x48)) + return PCIBIOS_SUCCESSFUL; + + /* + * IOC3 is fucked fucked beyond believe ... Don't try to access + * anything but 32-bit words ... + */ + addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2]; + + if (get_dbe(cf, (u32 *) addr)) + return PCIBIOS_DEVICE_NOT_FOUND; + + shift = ((where & 3) << 3); + mask = (0xffffffffU >> ((4 - size) << 3)); + smask = mask << shift; + + cf = (cf & ~smask) | ((value & mask) << shift); + if (put_dbe(cf, (u32 *) addr)) + return PCIBIOS_DEVICE_NOT_FOUND; + + return PCIBIOS_SUCCESSFUL; } static struct pci_ops bridge_pci_ops = { @@ -133,39 +187,79 @@ static struct pci_ops bridge_pci_ops = { .write = pci_conf0_write_config, }; -static int __init pcibios_init(void) +int __init bridge_probe(nasid_t nasid, int widget_id, int masterwid) { - struct pci_ops *ops = &bridge_pci_ops; - int i; + struct bridge_controller *bc; + bridge_t *bridge; + static int num_bridges = 0; + + printk("a bridge\n"); + + /* XXX: kludge alert.. */ + if (!num_bridges) + ioport_resource.end = ~0UL; + + bc = &bridges[num_bridges++]; + + bc->pc.pci_ops = &bridge_pci_ops; + bc->pc.mem_resource = &bc->mem; + bc->pc.io_resource = &bc->io; + + bc->mem.name = "Bridge PCI MEM"; + bc->pc.mem_offset = 0; + bc->mem.start = 0; + bc->mem.end = ~0UL; + bc->mem.flags = IORESOURCE_MEM; + + bc->io.name = "Bridge IO MEM"; + bc->io.start = 0UL; + bc->pc.io_offset = 0UL; + bc->io.end = ~0UL; + bc->io.flags = IORESOURCE_IO; + + bc->irq_cpu = smp_processor_id(); + bc->widget_id = widget_id; + bc->nasid = nasid; - ioport_resource.end = ~0UL; + bc->baddr = (u64)masterwid << 60; + bc->baddr |= (1UL << 56); /* Barrier set */ - for (i = 0; i < num_bridges; i++) { - printk("PCI: Probing PCI hardware on host bus %2d.\n", i); - pci_scan_bus(i, ops, NULL); - } + /* + * point to this bridge + */ + bridge = (bridge_t *) RAW_NODE_SWIN_BASE(nasid, widget_id); - return 0; -} + /* + * Clear all pending interrupts. + */ + bridge->b_int_rst_stat = BRIDGE_IRR_ALL_CLR; -subsys_initcall(pcibios_init); + /* + * Until otherwise set up, assume all interrupts are from slot 0 + */ + bridge->b_int_device = (u32) 0x0; -static inline u8 bridge_swizzle(u8 pin, u8 slot) -{ - return (((pin - 1) + slot) % 4) + 1; -} + /* + * swap pio's to pci mem and io space (big windows) + */ + bridge->b_wid_control |= BRIDGE_CTRL_IO_SWAP | + BRIDGE_CTRL_MEM_SWAP; -static u8 __devinit pci_swizzle(struct pci_dev *dev, u8 * pinp) -{ - u8 pin = *pinp; + /* + * Hmm... IRIX sets additional bits in the address which + * are documented as reserved in the bridge docs. + */ + bridge->b_wid_int_upper = 0x8000 | (masterwid << 16); + bridge->b_wid_int_lower = 0x01800090; /* PI_INT_PEND_MOD off*/ + bridge->b_dir_map = (masterwid << 20); /* DMA */ + bridge->b_int_enable = 0; - while (dev->bus->self) { /* Move up the chain of bridges. */ - pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn)); - dev = dev->bus->self; - } - *pinp = pin; + bridge->b_wid_tflush; /* wait until Bridge PIO complete */ + + bc->base = bridge; - return PCI_SLOT(dev->devfn); + register_pci_controller(&bc->pc); + return 0; } /* @@ -177,9 +271,12 @@ static u8 __devinit pci_swizzle(struct p * A given PCI device, in general, should be able to intr any of the cpus * on any one of the hubs connected to its xbow. */ -static int __devinit pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) +int __devinit pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - if ((dev->bus->number >= MAX_PCI_BUSSES) + struct bridge_controller *bc = BRIDGE_CONTROLLER(dev->bus); + int busno = dev->bus->number; + + if ((busno >= MAX_PCI_BUSSES) || (pin != 1) || (slot >= MAX_DEVICES_PER_PCIBUS)) panic("Increase supported PCI busses %d,%d,%d", @@ -188,47 +285,14 @@ static int __devinit pci_map_irq(struct /* * Already assigned? Then return previously assigned value ... */ - if (irqstore[dev->bus->number][slot]) - return irqstore[dev->bus->number][slot]; + if (irqstore[busno][slot]) + return irqstore[busno][slot]; - irq_to_bus[lastirq] = dev->bus->number; + irq_to_bridge[lastirq] = bc; irq_to_slot[lastirq] = slot; - irqstore[dev->bus->number][slot] = lastirq; - lastirq++; - return lastirq - 1; -} - -void __init pcibios_update_irq(struct pci_dev *dev, int irq) -{ - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); -} + irqstore[busno][slot] = lastirq; -void __devinit pcibios_fixup_bus(struct pci_bus *b) -{ - pci_fixup_irqs(pci_swizzle, pci_map_irq); -} - -int pcibios_enable_device(struct pci_dev *dev, int mask) -{ - /* Not needed, since we enable all devices at startup. */ - return 0; -} - -void pcibios_align_resource(void *data, struct resource *res, - unsigned long size, unsigned long align) -{ -} - -unsigned int pcibios_assign_all_busses(void) -{ - return 0; -} - -char *__devinit pcibios_setup(char *str) -{ - /* Nothing to do for now. */ - - return str; + return lastirq++; } /* @@ -240,9 +304,8 @@ char *__devinit pcibios_setup(char *str) static void __init pci_disable_swapping(struct pci_dev *dev) { - unsigned int bus_id = (unsigned) dev->bus->number; - bridge_t *bridge = (bridge_t *) NODE_SWIN_BASE(bus_to_nid[bus_id], - bus_to_wid[bus_id]); + struct bridge_controller *bc = BRIDGE_CONTROLLER(dev->bus); + bridge_t *bridge = bc->base; int slot = PCI_SLOT(dev->devfn); /* Turn off byte swapping */ @@ -252,9 +315,8 @@ static void __init pci_disable_swapping( static void __init pci_enable_swapping(struct pci_dev *dev) { - unsigned int bus_id = (unsigned) dev->bus->number; - bridge_t *bridge = (bridge_t *) NODE_SWIN_BASE(bus_to_nid[bus_id], - bus_to_wid[bus_id]); + struct bridge_controller *bc = BRIDGE_CONTROLLER(dev->bus); + bridge_t *bridge = bc->base; int slot = PCI_SLOT(dev->devfn); /* Turn on byte swapping */ @@ -264,23 +326,23 @@ static void __init pci_enable_swapping(s static void __init pci_fixup_ioc3(struct pci_dev *d) { - unsigned long bus_id = (unsigned) d->bus->number; + struct bridge_controller *bc = BRIDGE_CONTROLLER(d->bus); + unsigned long offset = NODE_OFFSET(bc->nasid); - printk("PCI: Fixing base addresses for IOC3 device %s\n", - pci_name(d)); + printk("PCI: Fixing base addresses for IOC3 device %s\n", pci_name(d)); - d->resource[0].start |= NODE_OFFSET(bus_to_nid[bus_id]); - d->resource[0].end |= NODE_OFFSET(bus_to_nid[bus_id]); + d->resource[0].start |= offset; + d->resource[0].end |= offset; pci_disable_swapping(d); } static void __init pci_fixup_isp1020(struct pci_dev *d) { + struct bridge_controller *bc = BRIDGE_CONTROLLER(d->bus); unsigned short command; - d->resource[0].start |= - ((unsigned long) (bus_to_nid[d->bus->number]) << 32); + d->resource[0].start |= (unsigned long) bc->nasid << 32; printk("PCI: Fixing isp1020 in [bus:slot.fn] %s\n", pci_name(d)); /* @@ -289,7 +351,6 @@ static void __init pci_fixup_isp1020(str * bit set. Things stop working if we program the controllers as not * having PCI_COMMAND_MEMORY, so we have to fudge the mem_flags. */ - pci_set_master(d); pci_read_config_word(d, PCI_COMMAND, &command); command |= PCI_COMMAND_MEMORY; @@ -302,9 +363,8 @@ static void __init pci_fixup_isp1020(str static void __init pci_fixup_isp2x00(struct pci_dev *d) { - unsigned int bus_id = (unsigned) d->bus->number; - bridge_t *bridge = (bridge_t *) NODE_SWIN_BASE(bus_to_nid[bus_id], - bus_to_wid[bus_id]); + struct bridge_controller *bc = BRIDGE_CONTROLLER(d->bus); + bridge_t *bridge = bc->base; bridgereg_t devreg; int i; int slot = PCI_SLOT(d->devfn); @@ -378,14 +438,11 @@ static void __init pci_fixup_isp2x00(str struct pci_fixup pcibios_fixups[] = { {PCI_FIXUP_HEADER, PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC3, pci_fixup_ioc3}, - {PCI_FIXUP_HEADER, PCI_VENDOR_ID_QLOGIC, - PCI_DEVICE_ID_QLOGIC_ISP1020, + {PCI_FIXUP_HEADER, PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1020, pci_fixup_isp1020}, - {PCI_FIXUP_HEADER, PCI_VENDOR_ID_QLOGIC, - PCI_DEVICE_ID_QLOGIC_ISP2100, + {PCI_FIXUP_HEADER, PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100, pci_fixup_isp2x00}, - {PCI_FIXUP_HEADER, PCI_VENDOR_ID_QLOGIC, - PCI_DEVICE_ID_QLOGIC_ISP2200, + {PCI_FIXUP_HEADER, PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200, pci_fixup_isp2x00}, {0} }; --- diff/arch/mips/pci/pci-ip32.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/pci-ip32.c 2004-02-23 13:56:38.000000000 +0000 @@ -5,453 +5,141 @@ * * Copyright (C) 2000, 2001 Keith M Wesolowski */ +#include #include #include +#include #include #include -#include +#include #include -#include #include -#include #undef DEBUG_MACE_PCI /* - * O2 has up to 5 PCI devices connected into the MACE bridge. The device - * map looks like this: - * - * 0 aic7xxx 0 - * 1 aic7xxx 1 - * 2 expansion slot - * 3 N/C - * 4 N/C - */ - -#define chkslot(_bus,_devfn) \ -do { \ - if ((_bus)->number > 0 || PCI_SLOT (_devfn) < 1 \ - || PCI_SLOT (_devfn) > 3) \ - return PCIBIOS_DEVICE_NOT_FOUND; \ -} while (0) - -#define mkaddr(_devfn, where) \ -((((_devfn) & 0xffUL) << 8) | ((where) & 0xfcUL)) - -void macepci_error(int irq, void *dev, struct pt_regs *regs); - -static int macepci_read_config(struct pci_bus *bus, unsigned int devfn, - int where, int size, u32 * val) -{ - switch (size) { - case 1: - *val = 0xff; - chkslot(bus, devfn); - mace_write_32(MACEPCI_CONFIG_ADDR, mkaddr(devfn, where)); - *val = - mace_read_8(MACEPCI_CONFIG_DATA + - ((where & 3UL) ^ 3UL)); - - return PCIBIOS_SUCCESSFUL; - - case 2: - *val = 0xffff; - chkslot(bus, devfn); - if (where & 1) - return PCIBIOS_BAD_REGISTER_NUMBER; - mace_write_32(MACEPCI_CONFIG_ADDR, mkaddr(devfn, where)); - *val = - mace_read_16(MACEPCI_CONFIG_DATA + - ((where & 2UL) ^ 2UL)); - - return PCIBIOS_SUCCESSFUL; - - case 4: - *val = 0xffffffff; - chkslot(bus, devfn); - if (where & 3) - return PCIBIOS_BAD_REGISTER_NUMBER; - mace_write_32(MACEPCI_CONFIG_ADDR, mkaddr(devfn, where)); - *val = mace_read_32(MACEPCI_CONFIG_DATA); - - return PCIBIOS_SUCCESSFUL; - } -} - -static int macepci_write_config(struct pci_bus *bus, unsigned int devfn, - int where, int size, u32 val) -{ - switch (size) { - case 1: - chkslot(bus, devfn); - mace_write_32(MACEPCI_CONFIG_ADDR, mkaddr(devfn, where)); - mace_write_8(MACEPCI_CONFIG_DATA + ((where & 3UL) ^ 3UL), - val); - - return PCIBIOS_SUCCESSFUL; - - case 2: - chkslot(bus, devfn); - if (where & 1) - return PCIBIOS_BAD_REGISTER_NUMBER; - mace_write_32(MACEPCI_CONFIG_ADDR, mkaddr(devfn, where)); - mace_write_16(MACEPCI_CONFIG_DATA + ((where & 2UL) ^ 2UL), - val); - - return PCIBIOS_SUCCESSFUL; - - case 4: - chkslot(bus, devfn); - if (where & 3) - return PCIBIOS_BAD_REGISTER_NUMBER; - mace_write_32(MACEPCI_CONFIG_ADDR, mkaddr(devfn, where)); - mace_write_32(MACEPCI_CONFIG_DATA, val); - - return PCIBIOS_SUCCESSFUL; - } -} - -static struct pci_ops macepci_ops = { - .read = macepci_read_config, - .write = macepci_write_config, -}; - -struct pci_fixup pcibios_fixups[] = { {0} }; - -static int __init pcibios_init(void) -{ - struct pci_dev *dev = NULL; - u32 start, size; - u16 cmd; - u32 base_io = 0x3000; /* The first i/o address to assign after SCSI */ - u32 base_mem = 0x80100000; /* Likewise */ - u32 rev = mace_read_32(MACEPCI_REV); - int i; - - printk("MACE: PCI rev %d detected at %016lx\n", rev, - (u64) MACE_BASE + MACE_PCI); - - /* These are *bus* addresses */ - ioport_resource.start = 0; - ioport_resource.end = 0xffffffffUL; - iomem_resource.start = 0x80000000UL; - iomem_resource.end = 0xffffffffUL; - - /* Clear any outstanding errors and enable interrupts */ - mace_write_32(MACEPCI_ERROR_ADDR, 0); - mace_write_32(MACEPCI_ERROR_FLAGS, 0); - mace_write_32(MACEPCI_CONTROL, 0xff008500); - crime_write_64(CRIME_HARD_INT, 0UL); - crime_write_64(CRIME_SOFT_INT, 0UL); - crime_write_64(CRIME_INT_STAT, 0x000000000000ff00UL); - - if (request_irq(MACE_PCI_BRIDGE_IRQ, macepci_error, 0, - "MACE PCI error", NULL)) - panic("PCI bridge can't get interrupt; can't happen."); - - pci_scan_bus(0, &macepci_ops, NULL); - -#ifdef DEBUG_MACE_PCI - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - printk("Device: %d/%d/%d ARCS-assigned bus resource map\n", - dev->bus->number, PCI_SLOT(dev->devfn), - PCI_FUNC(dev->devfn)); - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { - if (dev->resource[i].start == 0) - continue; - printk("%d: %016lx - %016lx (flags %04lx)\n", - i, dev->resource[i].start, - dev->resource[i].end, - dev->resource[i].flags); - } - } -#endif - /* - * Assign sane resources to and enable all devices. The requirement - * for the SCSI controllers is well-known: a 256-byte I/O region - * which we must assign, and a 1-page memory region which is - * assigned by the system firmware. - */ - dev = NULL; - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - switch (PCI_SLOT(dev->devfn)) { - case 1: /* SCSI bus 0 */ - dev->resource[0].start = 0x1000UL; - dev->resource[0].end = 0x10ffUL; - break; - case 2: /* SCSI bus 1 */ - dev->resource[0].start = 0x2000UL; - dev->resource[0].end = 0x20ffUL; - break; - default: /* Slots - I guess we have only 1 */ - for (i = 0; i < 6; i++) { - size = dev->resource[i].end - - dev->resource[i].start; - if (!size - || !(dev->resource[i].flags - & (IORESOURCE_IO | - IORESOURCE_MEM))) { - dev->resource[i].start = - dev->resource[i].end = 0UL; - continue; - } - if (dev->resource[i].flags & IORESOURCE_IO) { - dev->resource[i].start = base_io; - base_io += PAGE_ALIGN(size); - } else { - dev->resource[i].start = base_mem; - base_mem += 0x100000UL; - } - dev->resource[i].end = - dev->resource[i].start + size; - } - break; - } - for (i = 0; i < 6; i++) { - if (dev->resource[i].start == 0) - continue; - start = dev->resource[i].start; - if (dev->resource[i].flags & IORESOURCE_IO) - start |= 1; - pci_write_config_dword(dev, - PCI_BASE_ADDRESS_0 + - (i << 2), (u32) start); - } - pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0x20); - pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x30); - pci_read_config_word(dev, PCI_COMMAND, &cmd); - cmd |= - (PCI_COMMAND_IO | PCI_COMMAND_MEMORY | - PCI_COMMAND_SPECIAL | PCI_COMMAND_INVALIDATE | - PCI_COMMAND_PARITY); - pci_write_config_word(dev, PCI_COMMAND, cmd); - pci_set_master(dev); - } - /* - * Fixup O2 PCI slot. Bad hack. - */ -/* devtag = pci_make_tag(0, 0, 3, 0); - - slot = macepci_conf_read(0, devtag, PCI_COMMAND_STATUS_REG); - slot |= PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE; - macepci_conf_write(0, devtag, PCI_COMMAND_STATUS_REG, slot); - - slot = macepci_conf_read(0, devtag, PCI_MAPREG_START); - if (slot == 0xffffffe1) - macepci_conf_write(0, devtag, PCI_MAPREG_START, 0x00001000); - - slot = macepci_conf_read(0, devtag, PCI_MAPREG_START + (2 << 2)); - if ((slot & 0xffff0000) == 0) { - slot += 0x00010000; - macepci_conf_write(0, devtag, PCI_MAPREG_START + (2 << 2), - 0x00000000); - } - */ -#ifdef DEBUG_MACE_PCI - printk("Triggering PCI bridge interrupt...\n"); - mace_write_32(MACEPCI_ERROR_FLAGS, MACEPCI_ERROR_INTERRUPT_TEST); - - dev = NULL; - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - printk("Device: %d/%d/%d final bus resource map\n", - dev->bus->number, PCI_SLOT(dev->devfn), - PCI_FUNC(dev->devfn)); - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { - if (dev->resource[i].start == 0) - continue; - printk("%d: %016lx - %016lx (flags %04lx)\n", - i, dev->resource[i].start, - dev->resource[i].end, - dev->resource[i].flags); - } - } -#endif - - return 0; -} - -subsys_initcall(pcibios_init); - -/* - * Given a PCI slot number (a la PCI_SLOT(...)) and the interrupt pin of - * the device (1-4 => A-D), tell what irq to use. Note that we don't - * in theory have slots 4 and 5, and we never normally use the shared - * irqs. I suppose a device without a pin A will thank us for doing it - * right if there exists such a broken piece of crap. - */ -static int __devinit macepci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) -{ - chkslot(dev->bus, dev->devfn); - if (pin == 0) - pin = 1; - switch (slot) { - case 1: - return MACEPCI_SCSI0_IRQ; - case 2: - return MACEPCI_SCSI1_IRQ; - case 3: - switch (pin) { - case 2: - return MACEPCI_SHARED0_IRQ; - case 3: - return MACEPCI_SHARED1_IRQ; - case 4: - return MACEPCI_SHARED2_IRQ; - case 1: - default: - return MACEPCI_SLOT0_IRQ; - } - case 4: - switch (pin) { - case 2: - return MACEPCI_SHARED2_IRQ; - case 3: - return MACEPCI_SHARED0_IRQ; - case 4: - return MACEPCI_SHARED1_IRQ; - case 1: - default: - return MACEPCI_SLOT1_IRQ; - } - return MACEPCI_SLOT1_IRQ; - case 5: - switch (pin) { - case 2: - return MACEPCI_SHARED1_IRQ; - case 3: - return MACEPCI_SHARED2_IRQ; - case 4: - return MACEPCI_SHARED0_IRQ; - case 1: - default: - return MACEPCI_SLOT2_IRQ; - } - default: - return 0; - } -} - -/* - * It's not entirely clear what this does in a system with no bridges. - * In any case, bridges are not supported by Linux in O2. - */ -static u8 __init macepci_swizzle(struct pci_dev *dev, u8 * pinp) -{ - if (PCI_SLOT(dev->devfn) == 2) - *pinp = 2; - else - *pinp = 1; - return PCI_SLOT(dev->devfn); -} - -/* All devices are enabled during initialization. */ -int pcibios_enable_device(struct pci_dev *dev, int mask) -{ - return PCIBIOS_SUCCESSFUL; -} - -char *__init pcibios_setup(char *str) -{ - return str; -} - -void pcibios_align_resource(void *data, struct resource *res, - unsigned long size, unsigned long align) -{ -} - -void __init pcibios_update_irq(struct pci_dev *dev, int irq) -{ - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); -} - -void __devinit pcibios_fixup_bus(struct pci_bus *b) -{ - pci_fixup_irqs(macepci_swizzle, macepci_map_irq); -} - -/* * Handle errors from the bridge. This includes master and target aborts, * various command and address errors, and the interrupt test. This gets * registered on the bridge error irq. It's conceivable that some of these * conditions warrant a panic. Anybody care to say which ones? */ -void macepci_error(int irq, void *dev, struct pt_regs *regs) +static irqreturn_t macepci_error(int irq, void *dev, struct pt_regs *regs) { - u32 flags, error_addr; - char space; - - flags = mace_read_32(MACEPCI_ERROR_FLAGS); - error_addr = mace_read_32(MACEPCI_ERROR_ADDR); + char s; + unsigned int flags = mace->pci.error; + unsigned int addr = mace->pci.error_addr; if (flags & MACEPCI_ERROR_MEMORY_ADDR) - space = 'M'; + s = 'M'; else if (flags & MACEPCI_ERROR_CONFIG_ADDR) - space = 'C'; + s = 'C'; else - space = 'X'; + s = 'X'; if (flags & MACEPCI_ERROR_MASTER_ABORT) { - printk("MACEPCI: Master abort at 0x%08x (%c)\n", - error_addr, space); - mace_write_32(MACEPCI_ERROR_FLAGS, - flags & ~MACEPCI_ERROR_MASTER_ABORT); + printk("MACEPCI: Master abort at 0x%08x (%c)\n", addr, s); + flags &= ~MACEPCI_ERROR_MASTER_ABORT; } if (flags & MACEPCI_ERROR_TARGET_ABORT) { - printk("MACEPCI: Target abort at 0x%08x (%c)\n", - error_addr, space); - mace_write_32(MACEPCI_ERROR_FLAGS, - flags & ~MACEPCI_ERROR_TARGET_ABORT); + printk("MACEPCI: Target abort at 0x%08x (%c)\n", addr, s); + flags &= ~MACEPCI_ERROR_TARGET_ABORT; } if (flags & MACEPCI_ERROR_DATA_PARITY_ERR) { - printk("MACEPCI: Data parity error at 0x%08x (%c)\n", - error_addr, space); - mace_write_32(MACEPCI_ERROR_FLAGS, flags - & ~MACEPCI_ERROR_DATA_PARITY_ERR); + printk("MACEPCI: Data parity error at 0x%08x (%c)\n", addr, s); + flags &= ~MACEPCI_ERROR_DATA_PARITY_ERR; } if (flags & MACEPCI_ERROR_RETRY_ERR) { - printk("MACEPCI: Retry error at 0x%08x (%c)\n", error_addr, - space); - mace_write_32(MACEPCI_ERROR_FLAGS, flags - & ~MACEPCI_ERROR_RETRY_ERR); + printk("MACEPCI: Retry error at 0x%08x (%c)\n", addr, s); + flags &= ~MACEPCI_ERROR_RETRY_ERR; } if (flags & MACEPCI_ERROR_ILLEGAL_CMD) { - printk("MACEPCI: Illegal command at 0x%08x (%c)\n", - error_addr, space); - mace_write_32(MACEPCI_ERROR_FLAGS, - flags & ~MACEPCI_ERROR_ILLEGAL_CMD); + printk("MACEPCI: Illegal command at 0x%08x (%c)\n", addr, s); + flags &= ~MACEPCI_ERROR_ILLEGAL_CMD; } if (flags & MACEPCI_ERROR_SYSTEM_ERR) { - printk("MACEPCI: System error at 0x%08x (%c)\n", - error_addr, space); - mace_write_32(MACEPCI_ERROR_FLAGS, flags - & ~MACEPCI_ERROR_SYSTEM_ERR); + printk("MACEPCI: System error at 0x%08x (%c)\n", addr, s); + flags &= ~MACEPCI_ERROR_SYSTEM_ERR; } if (flags & MACEPCI_ERROR_PARITY_ERR) { - printk("MACEPCI: Parity error at 0x%08x (%c)\n", - error_addr, space); - mace_write_32(MACEPCI_ERROR_FLAGS, - flags & ~MACEPCI_ERROR_PARITY_ERR); + printk("MACEPCI: Parity error at 0x%08x (%c)\n", addr, s); + flags &= ~MACEPCI_ERROR_PARITY_ERR; } if (flags & MACEPCI_ERROR_OVERRUN) { - printk("MACEPCI: Overrun error at 0x%08x (%c)\n", - error_addr, space); - mace_write_32(MACEPCI_ERROR_FLAGS, flags - & ~MACEPCI_ERROR_OVERRUN); + printk("MACEPCI: Overrun error at 0x%08x (%c)\n", addr, s); + flags &= ~MACEPCI_ERROR_OVERRUN; } if (flags & MACEPCI_ERROR_SIG_TABORT) { printk("MACEPCI: Signaled target abort (clearing)\n"); - mace_write_32(MACEPCI_ERROR_FLAGS, flags - & ~MACEPCI_ERROR_SIG_TABORT); + flags &= ~MACEPCI_ERROR_SIG_TABORT; } if (flags & MACEPCI_ERROR_INTERRUPT_TEST) { printk("MACEPCI: Interrupt test triggered (clearing)\n"); - mace_write_32(MACEPCI_ERROR_FLAGS, flags - & ~MACEPCI_ERROR_INTERRUPT_TEST); + flags &= ~MACEPCI_ERROR_INTERRUPT_TEST; } + + mace->pci.error = flags; + + return IRQ_HANDLED; } -unsigned int pcibios_assign_all_busses(void) + +extern struct pci_ops mace_pci_ops; +#ifdef CONFIG_MIPS64 +static struct resource mace_pci_mem_resource = { + .name = "SGI O2 PCI MEM", + .start = MACEPCI_HI_MEMORY, + .end = 0x2FFFFFFFFUL, + .flags = IORESOURCE_MEM, +}; +static struct resource mace_pci_io_resource = { + .name = "SGI O2 PCI IO", + .start = 0x00000000UL, + .end = 0xffffffffUL, + .flags = IORESOURCE_IO, +}; +#define MACE_PCI_MEM_OFFSET 0x200000000 +#else +static struct resource mace_pci_mem_resource = { + .name = "SGI O2 PCI MEM", + .start = MACEPCI_LOW_MEMORY, + .end = MACEPCI_LOW_MEMORY + 0x2000000 - 1, + .flags = IORESOURCE_MEM, +}; +static struct resource mace_pci_io_resource = { + .name = "SGI O2 PCI IO", + .start = 0x00000000, + .end = 0xFFFFFFFF, + .flags = IORESOURCE_IO, +}; +#define MACE_PCI_MEM_OFFSET (MACEPCI_LOW_MEMORY - 0x80000000) +#endif +static struct pci_controller mace_pci_controller = { + .pci_ops = &mace_pci_ops, + .mem_resource = &mace_pci_mem_resource, + .io_resource = &mace_pci_io_resource, + .iommu = 0, + .mem_offset = MACE_PCI_MEM_OFFSET, + .io_offset = 0, +}; + +static int __init mace_init(void) { + PCIBIOS_MIN_IO = 0x1000; + + /* Clear any outstanding errors and enable interrupts */ + mace->pci.error_addr = 0; + mace->pci.error = 0; + mace->pci.control = 0xff008500; + + printk("MACE PCI rev %d\n", mace->pci.rev); + + BUG_ON(request_irq(MACE_PCI_BRIDGE_IRQ, macepci_error, 0, + "MACE PCI error", NULL)); + + ioport_resource.end = mace_pci_io_resource.end; + register_pci_controller(&mace_pci_controller); + return 0; } + +arch_initcall(mace_init); --- diff/arch/mips/pci/pci-ocelot-c.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/pci/pci-ocelot-c.c 2004-02-23 13:56:38.000000000 +0000 @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -38,388 +37,8 @@ * devices. */ -#define MAX_PCI_DEVS 10 - void mv64340_board_pcibios_fixup_bus(struct pci_bus *c); -/* Functions to implement "pci ops" */ -static int marvell_pcibios_read_config_word(struct pci_dev *dev, - int offset, u16 * val); -static int marvell_pcibios_read_config_byte(struct pci_dev *dev, - int offset, u8 * val); -static int marvell_pcibios_read_config_dword(struct pci_dev *dev, - int offset, u32 * val); -static int marvell_pcibios_write_config_byte(struct pci_dev *dev, - int offset, u8 val); -static int marvell_pcibios_write_config_word(struct pci_dev *dev, - int offset, u16 val); -static int marvell_pcibios_write_config_dword(struct pci_dev *dev, - int offset, u32 val); -static void marvell_pcibios_set_master(struct pci_dev *dev); - -/* - * General-purpose PCI functions. - */ - - -/* - * pci_range_ck - - * - * Check if the pci device that are trying to access does really exists - * on the evaluation board. - * - * Inputs : - * bus - bus number (0 for PCI 0 ; 1 for PCI 1) - * dev - number of device on the specific pci bus - * - * Outpus : - * 0 - if OK , 1 - if failure - */ -static __inline__ int pci_range_ck(unsigned char bus, unsigned char dev) -{ - /* Accessing device 31 crashes the MV-64340. */ - if (dev < 5) - return 0; - return -1; -} - -/* - * marvell_pcibios_(read/write)_config_(dword/word/byte) - - * - * reads/write a dword/word/byte register from the configuration space - * of a device. - * - * Note that bus 0 and bus 1 are local, and we assume all other busses are - * bridged from bus 1. This is a safe assumption, since any other - * configuration will require major modifications to the CP7000G - * - * Inputs : - * bus - bus number - * dev - device number - * offset - register offset in the configuration space - * val - value to be written / read - * - * Outputs : - * PCIBIOS_SUCCESSFUL when operation was succesfull - * PCIBIOS_DEVICE_NOT_FOUND when the bus or dev is errorneous - * PCIBIOS_BAD_REGISTER_NUMBER when accessing non aligned - */ - -static int marvell_pcibios_read_config_dword(struct pci_dev *device, - int offset, u32 * val) -{ - int dev, bus, func; - uint32_t address_reg, data_reg; - uint32_t address; - - bus = device->bus->number; - dev = PCI_SLOT(device->devfn); - func = PCI_FUNC(device->devfn); - - /* verify the range */ - if (pci_range_ck(bus, dev)) - return PCIBIOS_DEVICE_NOT_FOUND; - - /* select the MV-64340 registers to communicate with the PCI bus */ - if (bus == 0) { - address_reg = MV64340_PCI_0_CONFIG_ADDR; - data_reg = MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG; - } else { - address_reg = MV64340_PCI_1_CONFIG_ADDR; - data_reg = MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG; - } - - address = (bus << 16) | (dev << 11) | (func << 8) | - (offset & 0xfc) | 0x80000000; - - /* start the configuration cycle */ - MV_WRITE(address_reg, address); - - /* read the data */ - MV_READ(data_reg, val); - - return PCIBIOS_SUCCESSFUL; -} - - -static int marvell_pcibios_read_config_word(struct pci_dev *device, - int offset, u16 * val) -{ - int dev, bus, func; - uint32_t address_reg, data_reg; - uint32_t address; - - bus = device->bus->number; - dev = PCI_SLOT(device->devfn); - func = PCI_FUNC(device->devfn); - - /* verify the range */ - if (pci_range_ck(bus, dev)) - return PCIBIOS_DEVICE_NOT_FOUND; - - /* select the MV-64340 registers to communicate with the PCI bus */ - if (bus == 0) { - address_reg = MV64340_PCI_0_CONFIG_ADDR; - data_reg = MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG; - } else { - address_reg = MV64340_PCI_1_CONFIG_ADDR; - data_reg = MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG; - } - - address = (bus << 16) | (dev << 11) | (func << 8) | - (offset & 0xfc) | 0x80000000; - - /* start the configuration cycle */ - MV_WRITE(address_reg, address); - - /* read the data */ - MV_READ_16(data_reg + (offset & 0x3), val); - - return PCIBIOS_SUCCESSFUL; -} - -static int marvell_pcibios_read_config_byte(struct pci_dev *device, - int offset, u8 * val) -{ - int dev, bus, func; - uint32_t address_reg, data_reg; - uint32_t address; - - bus = device->bus->number; - dev = PCI_SLOT(device->devfn); - func = PCI_FUNC(device->devfn); - - /* verify the range */ - if (pci_range_ck(bus, dev)) - return PCIBIOS_DEVICE_NOT_FOUND; - - /* select the MV-64340 registers to communicate with the PCI bus */ - if (bus == 0) { - address_reg = MV64340_PCI_0_CONFIG_ADDR; - data_reg = MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG; - } else { - address_reg = MV64340_PCI_1_CONFIG_ADDR; - data_reg = MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG; - } - - address = (bus << 16) | (dev << 11) | (func << 8) | - (offset & 0xfc) | 0x80000000; - - /* start the configuration cycle */ - MV_WRITE(address_reg, address); - - /* write the data */ - MV_READ_8(data_reg + (offset & 0x3), val); - - return PCIBIOS_SUCCESSFUL; -} - -static int marvell_pcibios_write_config_dword(struct pci_dev *device, - int offset, u32 val) -{ - int dev, bus, func; - uint32_t address_reg, data_reg; - uint32_t address; - - bus = device->bus->number; - dev = PCI_SLOT(device->devfn); - func = PCI_FUNC(device->devfn); - - /* verify the range */ - if (pci_range_ck(bus, dev)) - return PCIBIOS_DEVICE_NOT_FOUND; - - /* select the MV-64340 registers to communicate with the PCI bus */ - if (bus == 0) { - address_reg = MV64340_PCI_0_CONFIG_ADDR; - data_reg = MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG; - } else { - address_reg = MV64340_PCI_1_CONFIG_ADDR; - data_reg = MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG; - } - - address = (bus << 16) | (dev << 11) | (func << 8) | - (offset & 0xfc) | 0x80000000; - - /* start the configuration cycle */ - MV_WRITE(address_reg, address); - - /* write the data */ - MV_WRITE(data_reg, val); - - return PCIBIOS_SUCCESSFUL; -} - - -static int marvell_pcibios_write_config_word(struct pci_dev *device, - int offset, u16 val) -{ - int dev, bus, func; - uint32_t address_reg, data_reg; - uint32_t address; - - bus = device->bus->number; - dev = PCI_SLOT(device->devfn); - func = PCI_FUNC(device->devfn); - - /* verify the range */ - if (pci_range_ck(bus, dev)) - return PCIBIOS_DEVICE_NOT_FOUND; - - /* select the MV-64340 registers to communicate with the PCI bus */ - if (bus == 0) { - address_reg = MV64340_PCI_0_CONFIG_ADDR; - data_reg = MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG; - } else { - address_reg = MV64340_PCI_1_CONFIG_ADDR; - data_reg = MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG; - } - - address = (bus << 16) | (dev << 11) | (func << 8) | - (offset & 0xfc) | 0x80000000; - - /* start the configuration cycle */ - MV_WRITE(address_reg, address); - - /* write the data */ - MV_WRITE_16(data_reg + (offset & 0x3), val); - - return PCIBIOS_SUCCESSFUL; -} - -static int marvell_pcibios_write_config_byte(struct pci_dev *device, - int offset, u8 val) -{ - int dev, bus, func; - uint32_t address_reg, data_reg; - uint32_t address; - - bus = device->bus->number; - dev = PCI_SLOT(device->devfn); - func = PCI_FUNC(device->devfn); - - /* verify the range */ - if (pci_range_ck(bus, dev)) - return PCIBIOS_DEVICE_NOT_FOUND; - - /* select the MV-64340 registers to communicate with the PCI bus */ - if (bus == 0) { - address_reg = MV64340_PCI_0_CONFIG_ADDR; - data_reg = MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG; - } else { - address_reg = MV64340_PCI_1_CONFIG_ADDR; - data_reg = MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG; - } - - address = (bus << 16) | (dev << 11) | (func << 8) | - (offset & 0xfc) | 0x80000000; - - /* start the configuration cycle */ - MV_WRITE(address_reg, address); - - /* write the data */ - MV_WRITE_8(data_reg + (offset & 0x3), val); - - return PCIBIOS_SUCCESSFUL; -} - -static void marvell_pcibios_set_master(struct pci_dev *dev) -{ - u16 cmd; - - marvell_pcibios_read_config_word(dev, PCI_COMMAND, &cmd); - cmd |= PCI_COMMAND_MASTER; - marvell_pcibios_write_config_word(dev, PCI_COMMAND, cmd); -} - -/* Externally-expected functions. Do not change function names */ - -int pcibios_enable_resources(struct pci_dev *dev) -{ - u16 cmd, old_cmd; - u8 tmp1; - int idx; - struct resource *r; - - marvell_pcibios_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", pci_name(dev)); - return -EINVAL; - } - if (r->flags & IORESOURCE_IO) - cmd |= PCI_COMMAND_IO; - if (r->flags & IORESOURCE_MEM) - cmd |= PCI_COMMAND_MEMORY; - } - if (cmd != old_cmd) { - marvell_pcibios_write_config_word(dev, PCI_COMMAND, cmd); - } - - /* - * Let's fix up the latency timer and cache line size here. Cache - * line size = 32 bytes / sizeof dword (4) = 8. - * Latency timer must be > 8. 32 is random but appears to work. - */ - marvell_pcibios_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &tmp1); - if (tmp1 != 8) { - printk(KERN_WARNING - "PCI setting cache line size to 8 from " "%d\n", - tmp1); - marvell_pcibios_write_config_byte(dev, PCI_CACHE_LINE_SIZE, - 8); - } - marvell_pcibios_read_config_byte(dev, PCI_LATENCY_TIMER, &tmp1); - if (tmp1 < 32) { - printk(KERN_WARNING - "PCI setting latency timer to 32 from %d\n", tmp1); - marvell_pcibios_write_config_byte(dev, PCI_LATENCY_TIMER, - 32); - } - - return 0; -} - -int pcibios_enable_device(struct pci_dev *dev, int mask) -{ - return pcibios_enable_resources(dev); -} - -void pcibios_align_resource(void *data, struct resource *res, - unsigned long size) -{ - struct pci_dev *dev = data; - - if (res->flags & IORESOURCE_IO) { - unsigned long start = res->start; - - /* We need to avoid collisions with `mirrored' VGA ports - and other strange ISA hardware, so we always want the - addresses kilobyte aligned. */ - if (size > 0x100) { - printk(KERN_ERR "PCI: I/O Region %s/%d too large" - " (%ld bytes)\n", pci_name(dev), - dev->resource - res, size); - } - - start = (start + 1024 - 1) & ~(1024 - 1); - res->start = start; - } -} - -struct pci_ops marvell_pci_ops = { - marvell_pcibios_read_config_byte, - marvell_pcibios_read_config_word, - marvell_pcibios_read_config_dword, - marvell_pcibios_write_config_byte, - marvell_pcibios_write_config_word, - marvell_pcibios_write_config_dword -}; - struct pci_fixup pcibios_fixups[] = { {0} }; @@ -437,22 +56,6 @@ void __init pcibios_init(void) iomem_resource.start = 0xc0000000; iomem_resource.end = 0xc0000000 + 0x20000000 - 1; - pci_scan_bus(0, &marvell_pci_ops, NULL); - pci_scan_bus(1, &marvell_pci_ops, NULL); -} - -/* - * for parsing "pci=" kernel boot arguments. - */ -char *pcibios_setup(char *str) -{ - printk(KERN_INFO "rr: pcibios_setup\n"); - /* Nothing to do for now. */ - - return str; -} - -unsigned __init int pcibios_assign_all_busses(void) -{ - return 1; + pci_scan_bus(0, &mv64340_bus0_pci_ops, NULL); + pci_scan_bus(1, &mv64340_bus1_pci_ops, NULL); } --- diff/arch/mips/pci/pci-ocelot-g.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/pci/pci-ocelot-g.c 2004-02-23 13:56:38.000000000 +0000 @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include "gt64240.h" @@ -41,8 +40,6 @@ * devices. */ -#define MAX_PCI_DEVS 10 - void gt64240_board_pcibios_fixup_bus(struct pci_bus *c); /* Functions to implement "pci ops" */ @@ -58,9 +55,6 @@ static int galileo_pcibios_write_config_ int offset, u16 val); static int galileo_pcibios_write_config_dword(int bus, int devfn, int offset, u32 val); -#if 0 -static void galileo_pcibios_set_master(struct pci_dev *dev); -#endif static int pci_read(struct pci_bus *bus, unsigned int devfs, int where, int size, u32 * val); @@ -343,96 +337,6 @@ static int galileo_pcibios_write_config_ return PCIBIOS_SUCCESSFUL; } -#if 0 -static void galileo_pcibios_set_master(struct pci_dev *dev) -{ - u16 cmd; - - galileo_pcibios_read_config_word(dev, PCI_COMMAND, &cmd); - cmd |= PCI_COMMAND_MASTER; - galileo_pcibios_write_config_word(dev, PCI_COMMAND, cmd); -} -#endif - -/* Externally-expected functions. Do not change function names */ - -int pcibios_enable_resources(struct pci_dev *dev) -{ - u16 cmd, old_cmd; - u8 tmp1; - int idx; - struct resource *r; - - pci_read(dev->bus, dev->devfn, PCI_COMMAND, 2, (u32 *) & 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", pci_name(dev)); - return -EINVAL; - } - if (r->flags & IORESOURCE_IO) - cmd |= PCI_COMMAND_IO; - if (r->flags & IORESOURCE_MEM) - cmd |= PCI_COMMAND_MEMORY; - } - if (cmd != old_cmd) { - pci_write(dev->bus, dev->devfn, PCI_COMMAND, 2, cmd); - } - - /* - * Let's fix up the latency timer and cache line size here. Cache - * line size = 32 bytes / sizeof dword (4) = 8. - * Latency timer must be > 8. 32 is random but appears to work. - */ - pci_read(dev->bus, dev->devfn, PCI_CACHE_LINE_SIZE, 1, - (u32 *) & tmp1); - if (tmp1 != 8) { - printk(KERN_WARNING - "PCI setting cache line size to 8 from " "%d\n", - tmp1); - pci_write(dev->bus, dev->devfn, PCI_CACHE_LINE_SIZE, 1, 8); - } - pci_read(dev->bus, dev->devfn, PCI_LATENCY_TIMER, 1, - (u32 *) & tmp1); - if (tmp1 < 32) { - printk(KERN_WARNING - "PCI setting latency timer to 32 from %d\n", tmp1); - pci_write(dev->bus, dev->devfn, PCI_LATENCY_TIMER, 1, 32); - } - - return 0; -} - -int pcibios_enable_device(struct pci_dev *dev, int mask) -{ - return pcibios_enable_resources(dev); -} - -void pcibios_align_resource(void *data, struct resource *res, - unsigned long size, unsigned long align) -{ - struct pci_dev *dev = data; - - if (res->flags & IORESOURCE_IO) { - unsigned long start = res->start; - - /* We need to avoid collisions with `mirrored' VGA ports - and other strange ISA hardware, so we always want the - addresses kilobyte aligned. */ - if (size > 0x100) { - printk(KERN_ERR "PCI: I/O Region %s/%d too large" - " (%ld bytes)\n", pci_name(dev), - dev->resource - res, size); - } - - start = (start + 1024 - 1) & ~(1024 - 1); - res->start = start; - } -} - struct pci_ops galileo_pci_ops = { .read = pci_read, .write = pci_write @@ -554,19 +458,3 @@ static int __init pcibios_init(void) } subsys_initcall(pcibios_init); - -/* - * for parsing "pci=" kernel boot arguments. - */ -char *pcibios_setup(char *str) -{ - printk(KERN_INFO "rr: pcibios_setup\n"); - /* Nothing to do for now. */ - - return str; -} - -unsigned __init int pcibios_assign_all_busses(void) -{ - return 1; -} --- diff/arch/mips/pci/pci-sb1250.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/pci-sb1250.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001,2002 Broadcom Corporation + * Copyright (C) 2001,2002,2003 Broadcom Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -37,10 +37,13 @@ #include #include +#include +#include + #include #include #include -#include +#include /* * Macros for calculating offsets into config space given a device @@ -158,6 +161,8 @@ static int sb1250_pcibios_write(struct p else if (size == 2) data = (data & ~(0xffff << ((where & 3) << 3))) | (val << ((where & 3) << 3)); + else + data = val; WRITECFG32(cfgaddr, data); @@ -169,8 +174,27 @@ struct pci_ops sb1250_pci_ops = { .write = sb1250_pcibios_write }; +static struct resource sb1250_mem_resource = { + .name = "SB1250 PCI MEM", + .start = 0x14000000UL, + .end = 0x17ffffffUL, + .flags = IORESOURCE_MEM, +}; + +static struct resource sb1250_io_resource = { + .name = "SB1250 IO MEM", + .start = 0x14000000UL, + .end = 0x17ffffffUL, + .flags = IORESOURCE_IO, +}; + +struct pci_controller sb1250_controller = { + .pci_ops = &sb1250_pci_ops, + .mem_resource = &sb1250_mem_resource, + .io_resource = &sb1250_io_resource +}; -void __init pcibios_init(void) +int __init pcibios_init(void) xxx This needs to be called somehow ... { uint32_t cmdreg; uint64_t reg; @@ -181,7 +205,7 @@ void __init pcibios_init(void) /* * See if the PCI bus has been configured by the firmware. */ - reg = *((volatile uint64_t *) KSEG1ADDR(A_SCD_SYSTEM_CFG)); + reg = *((volatile uint64_t *) IOADDR(A_SCD_SYSTEM_CFG)); if (!(reg & M_SYS_PCI_HOST)) { sb1250_bus_status |= PCI_DEVICE_MODE; } else { @@ -193,7 +217,7 @@ void __init pcibios_init(void) printk ("PCI: Skipping PCI probe. Bus is not initialized.\n"); iounmap(cfg_space); - return; + return 0; } sb1250_bus_status |= PCI_BUS_ENABLED; } @@ -234,48 +258,14 @@ void __init pcibios_init(void) } #endif - /* Probe for PCI hardware */ - - printk("PCI: Probing PCI hardware on host bus 0.\n"); - pci_scan_bus(0, &sb1250_pci_ops, NULL); + register_pci_controller(&sb1250_controller); #ifdef CONFIG_VGA_CONSOLE take_over_console(&vga_con, 0, MAX_NR_CONSOLES - 1, 1); #endif -} - -int pcibios_enable_device(struct pci_dev *dev, int mask) -{ - /* Not needed, since we enable all devices at startup. */ return 0; } -void pcibios_align_resource(void *data, struct resource *res, - unsigned long size, unsigned long align) -{ -} - -char *__init pcibios_setup(char *str) -{ - /* Nothing to do for now. */ - - return str; -} - struct pci_fixup pcibios_fixups[] = { {0} }; - -/* - * Called after each bus is probed, but before its children - * are examined. - */ -void __devinit pcibios_fixup_bus(struct pci_bus *b) -{ - pci_read_bridge_bases(b); -} - -unsigned int pcibios_assign_all_busses(void) -{ - return 1; -} --- diff/arch/mips/pci/pci-vr41xx.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/pci-vr41xx.c 2004-02-23 13:56:38.000000000 +0000 @@ -8,7 +8,7 @@ * Author: Yoichi Yuasa * yyuasa@mvista.com or source@mvista.com * - * Copyright 2001,2002 MontaVista Software Inc. + * Copyright 2001-2003 MontaVista Software Inc. * * 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 @@ -49,9 +49,7 @@ #include #include -#include "pciu.h" - -extern unsigned long vr41xx_vtclock; +#include "pci-vr41xx.h" static inline int vr41xx_pci_config_access(unsigned char bus, unsigned int devfn, int where) @@ -150,6 +148,7 @@ struct pci_ops vr41xx_pci_ops = { void __init vr41xx_pciu_init(struct vr41xx_pci_address_map *map) { struct vr41xx_pci_address_space *s; + unsigned long vtclock; u32 config; int n; @@ -169,11 +168,12 @@ void __init vr41xx_pciu_init(struct vr41 udelay(1); /* Select PCI clock */ - if (vr41xx_vtclock < MAX_PCI_CLOCK) + vtclock = vr41xx_get_vtclock_frequency(); + if (vtclock < MAX_PCI_CLOCK) writel(EQUAL_VTCLOCK, PCICLKSELREG); - else if ((vr41xx_vtclock / 2) < MAX_PCI_CLOCK) + else if ((vtclock / 2) < MAX_PCI_CLOCK) writel(HALF_VTCLOCK, PCICLKSELREG); - else if ((vr41xx_vtclock / 4) < MAX_PCI_CLOCK) + else if ((vtclock / 4) < MAX_PCI_CLOCK) writel(QUARTER_VTCLOCK, PCICLKSELREG); else printk(KERN_INFO "Warning: PCI Clock is over 33MHz.\n"); --- diff/arch/mips/pci/pci-vr41xx.h 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/pci-vr41xx.h 2004-02-23 13:56:38.000000000 +0000 @@ -107,9 +107,6 @@ #define MAX_PCI_CLOCK 33333333 -#define PCIU_CLOCK 0x0080 -#define PCI_CLOCK 0x2000 - static inline int pciu_read_config_byte(int where, u8 * val) { u32 data; --- diff/arch/mips/pci/pci.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/pci/pci.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,233 +1,304 @@ /* - * Copyright 2001 MontaVista Software Inc. - * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net - * - * Modified to be mips generic, ppopov@mvista.com - * arch/mips/kernel/pci.c - * Common MIPS PCI routines. - * * 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 file contains common PCI routines meant to be shared for - * all MIPS machines. - * - * Strategies: - * - * . We rely on pci_auto.c file to assign PCI resources (MEM and IO) - * TODO: this should be optional for some machines where they do have - * a real "pcibios" that does resource assignment. - * - * . We then use pci_scan_bus() to "discover" all the resources for - * later use by Linux. - * - * . We finally reply on a board supplied function, pcibios_fixup_irq(), to - * to assign the interrupts. We may use setup-irq.c under drivers/pci - * later. - * - * . Specifically, we will *NOT* use pci_assign_unassigned_resources(), - * because we assume all PCI devices should have the resources correctly - * assigned and recorded. - * - * Limitations: * - * . We "collapse" all IO and MEM spaces in sub-buses under a top-level bus - * into a contiguous range. - * - * . In the case of Memory space, the rnage is 1:1 mapping with CPU physical - * address space. - * - * . In the case of IO space, it starts from 0, and the beginning address - * is mapped to KSEG0ADDR(mips_io_port) in the CPU physical address. - * - * . These are the current MIPS limitations (by ioremap, etc). In the - * future, we may remove them. - * - * Credits: - * Most of the code are derived from the pci routines from PPC and Alpha, - * which were mostly writtne by - * Cort Dougan, cort@fsmlabs.com - * Matt Porter, mporter@mvista.com - * Dave Rusling david.rusling@reo.mts.dec.com - * David Mosberger davidm@cs.arizona.edu + * Copyright (C) 2003 Ralf Baechle (ralf@linux-mips.org) */ #include #include +#include +#include #include #include #include #include -extern void pcibios_fixup(void); -extern void pcibios_fixup_irqs(void); +/* + * Indicate whether we respect the PCI setup left by the firmware. + * + * Make this long-lived so that we know when shutting down + * whether we probed only or not. + */ +int pci_probe_only; -void __init pcibios_fixup_irqs(void) -{ - struct pci_dev *dev = NULL; - int slot_num; +#define PCI_ASSIGN_ALL_BUSSES 1 +unsigned int pci_probe = PCI_ASSIGN_ALL_BUSSES; - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - slot_num = PCI_SLOT(dev->devfn); - switch (slot_num) { - case 2: - dev->irq = 3; - break; - case 3: - dev->irq = 4; - break; - case 4: - dev->irq = 5; - break; - default: - break; - } +/* + * The PCI controller list. + */ + +struct pci_controller *hose_head, **hose_tail = &hose_head; +struct pci_controller *pci_isa_hose; + +unsigned long PCIBIOS_MIN_IO = 0x0000; +unsigned long PCIBIOS_MIN_MEM = 0; + +/* + * 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, unsigned long align) +{ + struct pci_dev *dev = data; + struct pci_controller *hose = dev->sysdata; + unsigned long start = res->start; + + if (res->flags & IORESOURCE_IO) { + /* Make sure we start at our min on all hoses */ + if (start - hose->io_resource->start < PCIBIOS_MIN_IO) + start = PCIBIOS_MIN_IO + hose->io_resource->start; + + /* + * Put everything into 0x00-0xff region modulo 0x400 + */ + if (start & 0x300) + start = (start + 0x3ff) & ~0x3ff; + } else if (res->flags & IORESOURCE_MEM) { + /* Make sure we start at our min on all hoses */ + if (start - hose->mem_resource->start < PCIBIOS_MIN_MEM) + start = PCIBIOS_MIN_MEM + hose->mem_resource->start; } + + res->start = start; } -void __init pcibios_fixup_resources(struct pci_dev *dev) -{ /* HP-LJ */ - int pos; - int bases; - - printk("adjusting pci device: %s\n", dev->name); - - switch (dev->hdr_type) { - case PCI_HEADER_TYPE_NORMAL: - bases = 6; - break; - case PCI_HEADER_TYPE_BRIDGE: - bases = 2; - break; - case PCI_HEADER_TYPE_CARDBUS: - bases = 1; - break; - default: - bases = 0; - break; - } - for (pos = 0; pos < bases; pos++) { - struct resource *res = &dev->resource[pos]; - if (res->start >= IO_MEM_LOGICAL_START && - res->end <= IO_MEM_LOGICAL_END) { - res->start += IO_MEM_VIRTUAL_OFFSET; - res->end += IO_MEM_VIRTUAL_OFFSET; - } - if (res->start >= IO_PORT_LOGICAL_START && - res->end <= IO_PORT_LOGICAL_END) { - res->start += IO_PORT_VIRTUAL_OFFSET; - res->end += IO_PORT_VIRTUAL_OFFSET; - } - } +struct pci_controller * __init alloc_pci_controller(void) +{ + return alloc_bootmem(sizeof(struct pci_controller)); +} + +void __init register_pci_controller(struct pci_controller *hose) +{ + *hose_tail = hose; + hose_tail = &hose->next; +} + +/* Most MIPS systems have straight-forward swizzling needs. */ +static inline u8 bridge_swizzle(u8 pin, u8 slot) +{ + return (((pin - 1) + slot) % 4) + 1; } -struct pci_fixup pcibios_fixups[] = { - {PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, - pcibios_fixup_resources}, - {0} -}; +static u8 __init common_swizzle(struct pci_dev *dev, u8 *pinp) +{ + u8 pin = *pinp; -extern int pciauto_assign_resources(int busno, struct pci_channel *hose); + while (dev->bus->parent) { + pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn)); + /* Move up the chain of bridges. */ + dev = dev->bus->self; + } + *pinp = pin; + + /* The slot is the slot of the last bridge. */ + return PCI_SLOT(dev->devfn); +} static int __init pcibios_init(void) { - struct pci_channel *p; + struct pci_controller *hose; struct pci_bus *bus; - int busno; + int next_busno; + int need_domain_info = 0; -#ifdef CONFIG_PCI_AUTO - /* assign resources */ - busno = 0; - for (p = mips_pci_channels; p->pci_ops != NULL; p++) { - busno = pciauto_assign_resources(busno, p) + 1; - } -#endif + /* Scan all of the recorded PCI controllers. */ + for (next_busno = 0, hose = hose_head; hose; hose = hose->next) { + + if (request_resource(&iomem_resource, hose->mem_resource) < 0) + goto out; + if (request_resource(&ioport_resource, hose->io_resource) < 0) + goto out_free_mem_resource; + + if (!hose->iommu) + PCI_DMA_BUS_IS_PHYS = 1; + + bus = pci_scan_bus(next_busno, hose->pci_ops, hose); + hose->bus = bus; + hose->need_domain_info = need_domain_info; + next_busno = bus->subordinate + 1; + /* Don't allow 8-bit bus number overflow inside the hose - + reserve some space for bridges. */ + if (next_busno > 224) { + next_busno = 0; + need_domain_info = 1; + } + continue; - /* scan the buses */ - busno = 0; - for (p = mips_pci_channels; p->pci_ops != NULL; p++) { - bus = pci_scan_bus(busno, p->pci_ops, p); - busno = bus->subordinate + 1; +out_free_mem_resource: + release_resource(hose->mem_resource); + +out: + printk(KERN_WARNING + "Skipping PCI bus scan due to resource conflict\n"); } - /* machine dependent fixups */ - pcibios_fixup(); - /* fixup irqs (board specific routines) */ - pcibios_fixup_irqs(); + if (!pci_probe_only) + pci_assign_unassigned_resources(); + pci_fixup_irqs(common_swizzle, pcibios_map_irq); return 0; } subsys_initcall(pcibios_init); -int pcibios_enable_device(struct pci_dev *dev, int mask) +static int pcibios_enable_resources(struct pci_dev *dev, int mask) { - /* pciauto_assign_resources() will enable all devices found */ + 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++) { + /* Only set up the requested stuff */ + if (!(mask & (1<resource[idx]; + if (!r->start && r->end) { + printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev)); + 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", pci_name(dev), old_cmd, cmd); + pci_write_config_word(dev, PCI_COMMAND, cmd); + } return 0; } -unsigned long __init pci_bridge_check_io(struct pci_dev *bridge) +/* + * If we set up a device for bus mastering, we need to check the latency + * timer as certain crappy BIOSes forget to set it properly. + */ +unsigned int pcibios_max_latency = 255; + +void pcibios_set_master(struct pci_dev *dev) +{ + u8 lat; + pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat); + if (lat < 16) + lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency; + else if (lat > pcibios_max_latency) + lat = pcibios_max_latency; + else + return; + printk(KERN_DEBUG "PCI: Setting latency timer of device %s to %d\n", + pci_name(dev), lat); + pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat); +} + +unsigned int pcibios_assign_all_busses(void) +{ + return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0; +} + +int pcibios_enable_device(struct pci_dev *dev, int mask) { - u16 io; + int err; + + if ((err = pcibios_enable_resources(dev, mask)) < 0) + return err; - pci_read_config_word(bridge, PCI_IO_BASE, &io); - if (!io) { - pci_write_config_word(bridge, PCI_IO_BASE, 0xf0f0); - pci_read_config_word(bridge, PCI_IO_BASE, &io); - pci_write_config_word(bridge, PCI_IO_BASE, 0x0); - } - if (io) - return IORESOURCE_IO; - //printk(KERN_WARNING "PCI: bridge %s does not support I/O forwarding!\n", bridge->name); return 0; } +static void __init pcibios_fixup_device_resources(struct pci_dev *dev, + struct pci_bus *bus) +{ + /* Update device resources. */ + struct pci_controller *hose = (struct pci_controller *)bus->sysdata; + unsigned long offset; + int i; + + for (i = 0; i < PCI_NUM_RESOURCES; i++) { + if (!dev->resource[i].start) + continue; + if (dev->resource[i].flags & IORESOURCE_IO) + offset = hose->io_offset; + else if (dev->resource[i].flags & IORESOURCE_MEM) + offset = hose->mem_offset; + + dev->resource[i].start += offset; + dev->resource[i].end += offset; + } +} + void __devinit pcibios_fixup_bus(struct pci_bus *bus) { - /* Propogate hose info into the subordinate devices. */ + /* Propagate hose info into the subordinate devices. */ - struct pci_channel *hose = bus->sysdata; + struct pci_controller *hose = bus->sysdata; + struct list_head *ln; struct pci_dev *dev = bus->self; if (!dev) { - /* Root bus */ bus->resource[0] = hose->io_resource; bus->resource[1] = hose->mem_resource; - } else { - /* This is a bridge. Do not care how it's initialized, - just link its resources to the bus ones */ - int i; - - for (i = 0; i < 3; i++) { - bus->resource[i] = - &dev->resource[PCI_BRIDGE_RESOURCES + i]; - bus->resource[i]->name = bus->name; - } - bus->resource[0]->flags |= pci_bridge_check_io(dev); - bus->resource[1]->flags |= IORESOURCE_MEM; - /* For now, propagate hose limits to the bus; - we'll adjust them later. */ - bus->resource[0]->end = hose->io_resource->end; - bus->resource[1]->end = hose->mem_resource->end; - /* Turn off downstream PF memory address range by default */ - bus->resource[2]->start = 1024 * 1024; - bus->resource[2]->end = bus->resource[2]->start - 1; + } else if (pci_probe_only && + (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { + pci_read_bridge_bases(bus); + pcibios_fixup_device_resources(dev, bus); + } + + for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) { + struct pci_dev *dev = pci_dev_b(ln); + + if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI) + pcibios_fixup_device_resources(dev, bus); } } -char *pcibios_setup(char *str) +void __init +pcibios_update_irq(struct pci_dev *dev, int irq) { - return str; + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); +} + +void __devinit +pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, + struct resource *res) +{ + struct pci_controller *hose = (struct pci_controller *)dev->sysdata; + unsigned long offset = 0; + + if (res->flags & IORESOURCE_IO) + offset = hose->io_offset; + else if (res->flags & IORESOURCE_MEM) + offset = hose->mem_offset; + + region->start = res->start - offset; + region->end = res->end - offset; } -void pcibios_align_resource(void *data, struct resource *res, - unsigned long size, unsigned long align) +#ifdef CONFIG_HOTPLUG +EXPORT_SYMBOL(pcibios_resource_to_bus); +#endif + +char *pcibios_setup(char *str) { - /* this should not be called */ + return str; } --- diff/arch/mips/ramdisk/Makefile 2003-08-20 14:16:08.000000000 +0100 +++ source/arch/mips/ramdisk/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,8 +2,19 @@ # Makefile for a ramdisk image # +obj-y += ramdisk.o + + O_FORMAT = $(shell $(OBJDUMP) -i | head -n 2 | grep elf32) -img = $(CONFIG_EMBEDDED_RAMDISK_IMAGE) -ramdisk.o: $(subst ",,$(img)) ld.script - echo "O_FORMAT: " $(O_FORMAT) - $(LD) -T ld.script -b binary --oformat $(O_FORMAT) -o $@ $(img) +img := $(subst ",,$(CONFIG_EMBEDDED_RAMDISK_IMAGE)) +# add $(src) when $(img) is relative +img := $(subst $(src)//,/,$(src)/$(img)) + +quiet_cmd_ramdisk = LD $@ +define cmd_ramdisk + $(LD) -T $(src)/ld.script -b binary --oformat $(O_FORMAT) -o $@ $(img) +endef + +$(obj)/ramdisk.o: $(img) $(src)/ld.script + $(call cmd,ramdisk) + --- diff/arch/mips/sgi-ip22/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sgi-ip22/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -4,8 +4,7 @@ # obj-y += ip22-mc.o ip22-hpc.o ip22-int.o ip22-irq.o ip22-berr.o \ - ip22-time.o ip22-rtc.o ip22-nvram.o ip22-reset.o \ - ip22-setup.o ip22-ksyms.o + ip22-time.o ip22-nvram.o ip22-reset.o ip22-setup.o obj-$(CONFIG_EISA) += ip22-eisa.o --- diff/arch/mips/sgi-ip22/ip22-berr.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sgi-ip22/ip22-berr.c 2004-02-23 13:56:38.000000000 +0000 @@ -44,18 +44,18 @@ static void save_and_clear_buserr(void) static void print_buserr(void) { if (extio_stat & EXTIO_MC_BUSERR) - printk(KERN_ALERT "MC Bus Error\n"); + printk(KERN_ERR "MC Bus Error\n"); if (extio_stat & EXTIO_HPC3_BUSERR) - printk(KERN_ALERT "HPC3 Bus Error 0x%x:\n", + printk(KERN_ERR "HPC3 Bus Error 0x%x:\n", hpc3_berr_stat, (hpc3_berr_stat & HPC3_BESTAT_PIDMASK) >> HPC3_BESTAT_PIDSHIFT, (hpc3_berr_stat & HPC3_BESTAT_CTYPE) ? "PIO" : "DMA", hpc3_berr_stat & HPC3_BESTAT_BLMASK); if (extio_stat & EXTIO_EISA_BUSERR) - printk(KERN_ALERT "EISA Bus Error\n"); + printk(KERN_ERR "EISA Bus Error\n"); if (cpu_err_stat & CPU_ERRMASK) - printk(KERN_ALERT "CPU error 0x%x<%s%s%s%s%s%s> @ 0x%08x\n", + printk(KERN_ERR "CPU error 0x%x<%s%s%s%s%s%s> @ 0x%08x\n", cpu_err_stat, cpu_err_stat & SGIMC_CSTAT_RD ? "RD " : "", cpu_err_stat & SGIMC_CSTAT_PAR ? "PAR " : "", @@ -65,7 +65,7 @@ static void print_buserr(void) cpu_err_stat & SGIMC_CSTAT_BAD_DATA ? "BAD_DATA " : "", cpu_err_addr); if (gio_err_stat & GIO_ERRMASK) - printk(KERN_ALERT "GIO error 0x%x:<%s%s%s%s%s%s%s%s> @ 0x08%x\n", + printk(KERN_ERR "GIO error 0x%x:<%s%s%s%s%s%s%s%s> @ 0x08%x\n", gio_err_stat, gio_err_stat & SGIMC_GSTAT_RD ? "RD " : "", gio_err_stat & SGIMC_GSTAT_WR ? "WR " : "", @@ -87,13 +87,19 @@ static void print_buserr(void) void ip22_be_interrupt(int irq, struct pt_regs *regs) { + const int field = 2 * sizeof(unsigned long); + save_and_clear_buserr(); print_buserr(); - panic("Bus error, epc == %08lx, ra == %08lx", - regs->cp0_epc, regs->regs[31]); + printk(KERN_ALERT "%s bus error, epc == %0*lx, ra == %0*lx\n", + (regs->cp0_cause & 4) ? "Data" : "Instruction", + field, regs->cp0_epc, field, regs->regs[31]); + /* Assume it would be too dangerous to continue ... */ + die_if_kernel("Oops", regs); + force_sig(SIGBUS, current); } -int ip22_be_handler(struct pt_regs *regs, int is_fixup) +static int ip22_be_handler(struct pt_regs *regs, int is_fixup) { save_and_clear_buserr(); if (is_fixup) --- diff/arch/mips/sgi-ip22/ip22-hpc.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sgi-ip22/ip22-hpc.c 2004-02-23 13:56:38.000000000 +0000 @@ -6,16 +6,23 @@ */ #include +#include #include -#include +#include #include #include #include struct hpc3_regs *hpc3c0, *hpc3c1; + +EXPORT_SYMBOL(hpc3c0); +EXPORT_SYMBOL(hpc3c1); + struct sgioc_regs *sgioc; +EXPORT_SYMBOL(sgioc); + /* We need software copies of these because they are write only. */ u8 sgi_ioc_reset, sgi_ioc_write; @@ -23,8 +30,11 @@ extern char *system_type; void __init sgihpc_init(void) { - hpc3c0 = (struct hpc3_regs *)(KSEG1 + HPC3_CHIP0_BASE); - hpc3c1 = (struct hpc3_regs *)(KSEG1 + HPC3_CHIP1_BASE); + /* ioremap can't fail */ + hpc3c0 = (struct hpc3_regs *) + ioremap(HPC3_CHIP0_BASE, sizeof(struct hpc3_regs)); + hpc3c1 = (struct hpc3_regs *) + ioremap(HPC3_CHIP1_BASE, sizeof(struct hpc3_regs)); /* IOC lives in PBUS PIO channel 6 */ sgioc = (struct sgioc_regs *)hpc3c0->pbus_extregs[6]; --- diff/arch/mips/sgi-ip22/ip22-int.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sgi-ip22/ip22-int.c 2004-02-23 13:56:38.000000000 +0000 @@ -9,7 +9,7 @@ * - Interrupt handling fixes * Copyright (C) 2001, 2003 Ladislav Michl (ladis@linux-mips.org) */ - +#include #include #include #include --- diff/arch/mips/sgi-ip22/ip22-mc.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sgi-ip22/ip22-mc.c 2004-02-23 13:56:38.000000000 +0000 @@ -7,11 +7,11 @@ */ #include +#include #include -#include +#include #include -#include #include #include #include @@ -19,6 +19,8 @@ struct sgimc_regs *sgimc; +EXPORT_SYMBOL(sgimc); + static inline unsigned long get_bank_addr(unsigned int memconfig) { return ((memconfig & SGIMC_MCONFIG_BASEADDR) << @@ -106,7 +108,9 @@ void __init sgimc_init(void) { u32 tmp; - sgimc = (struct sgimc_regs *)(KSEG1 + SGIMC_BASE); + /* ioremap can't fail */ + sgimc = (struct sgimc_regs *) + ioremap(SGIMC_BASE, sizeof(struct sgimc_regs)); printk(KERN_INFO "MC: SGI memory controller Revision %d\n", (int) sgimc->systemid & SGIMC_SYSID_MASKREV); @@ -198,4 +202,7 @@ void __init sgimc_init(void) } void __init prom_meminit(void) {} -void __init prom_free_prom_memory (void) {} +unsigned long __init prom_free_prom_memory(void) +{ + return 0; +} --- diff/arch/mips/sgi-ip22/ip22-nvram.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sgi-ip22/ip22-nvram.c 2004-02-23 13:56:38.000000000 +0000 @@ -3,6 +3,7 @@ * * Copyright (C) 2003 Ladislav Michl (ladis@linux-mips.org) */ +#include #include #include @@ -95,6 +96,8 @@ unsigned short ip22_eeprom_read(volatile return res; } +EXPORT_SYMBOL(ip22_eeprom_read); + /* * Read specified register from main NVRAM */ @@ -112,3 +115,5 @@ unsigned short ip22_nvram_read(int reg) return (tmp << 8) | (hpc3c0->bbram[reg] & 0xff); } } + +EXPORT_SYMBOL(ip22_nvram_read); --- diff/arch/mips/sgi-ip22/ip22-reset.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sgi-ip22/ip22-reset.c 2004-02-23 13:56:38.000000000 +0000 @@ -6,6 +6,8 @@ * Copyright (C) 1997, 1998, 2001, 2003 by Ralf Baechle */ #include +#include +#include #include #include #include @@ -16,10 +18,10 @@ #include #include #include -#include #include #include #include +#include #include /* @@ -45,12 +47,12 @@ static void sgi_machine_restart(char *co static void sgi_machine_halt(void) __attribute__((noreturn)); static void sgi_machine_power_off(void) __attribute__((noreturn)); -/* XXX How to pass the reboot command to the firmware??? */ static void sgi_machine_restart(char *command) { if (machine_state & MACHINE_SHUTTING_DOWN) sgi_machine_power_off(); - ArcReboot(); + sgimc->cpuctrl0 |= SGIMC_CCTRL0_SYSINIT; + while (1); } static void sgi_machine_halt(void) @@ -62,23 +64,23 @@ static void sgi_machine_halt(void) static void sgi_machine_power_off(void) { - unsigned char val; + unsigned int tmp; local_irq_disable(); /* Disable watchdog */ - val = CMOS_READ(RTC_CMD); - CMOS_WRITE(val | RTC_WAM, RTC_CMD); - CMOS_WRITE(0, RTC_WSEC); - CMOS_WRITE(0, RTC_WHSEC); + tmp = hpc3c0->rtcregs[RTC_CMD] & 0xff; + hpc3c0->rtcregs[RTC_CMD] = tmp | RTC_WAM; + hpc3c0->rtcregs[RTC_WSEC] = 0; + hpc3c0->rtcregs[RTC_WHSEC] = 0; - while(1) { + while (1) { sgioc->panel = ~SGIOC_PANEL_POWERON; /* Good bye cruel world ... */ /* If we're still running, we probably got sent an alarm interrupt. Read the flag to clear it. */ - val = CMOS_READ(RTC_HOURS_ALARM); + tmp = hpc3c0->rtcregs[RTC_HOURS_ALARM]; } } @@ -112,7 +114,7 @@ static void debounce(unsigned long data) } if (machine_state & MACHINE_PANICED) - ArcReboot(); + sgimc->cpuctrl0 |= SGIMC_CCTRL0_SYSINIT; enable_irq(SGI_PANEL_IRQ); } @@ -139,6 +141,8 @@ static inline void power_button(void) void (*indy_volume_button)(int) = NULL; +EXPORT_SYMBOL(indy_volume_button); + static inline void volume_up_button(unsigned long data) { del_timer(&volume_timer); @@ -182,12 +186,10 @@ static irqreturn_t panel_int(int irq, vo } /* Power button was pressed - * * ioc.ps page 22: "The Panel Register is called Power Control by Full * House. Only lowest 2 bits are used. Guiness uses upper four bits * for volume control". This is not true, all bits are pulled high - * on fullhouse - */ + * on fullhouse */ if (ip22_is_fullhouse() || !(buttons & SGIOC_PANEL_POWERINTR)) { power_button(); return IRQ_HANDLED; --- diff/arch/mips/sgi-ip22/ip22-setup.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sgi-ip22/ip22-setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -5,6 +5,7 @@ * Copyright (C) 1997, 1998 Ralf Baechle (ralf@gnu.org) */ #include +#include #include #include #include @@ -18,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -34,12 +34,6 @@ extern void breakpoint(void); static int remote_debug = 0; #endif -#if defined(CONFIG_IP22_SERIAL_CONSOLE) || defined(CONFIG_ARC_CONSOLE) -extern void console_setup(char *); -#endif - -extern struct rtc_ops ip22_rtc_ops; - unsigned long sgi_gfxaddr; /* @@ -63,7 +57,7 @@ void ip22_do_break(void) extern void ip22_be_init(void) __init; extern void ip22_time_init(void) __init; -void __init ip22_setup(void) +static int __init ip22_setup(void) { char *ctype; #ifdef CONFIG_KGDB @@ -87,8 +81,8 @@ void __init ip22_setup(void) indy_sc_init(); #endif - /* Set the IO space to some sane value */ - set_io_port_base (KSEG1ADDR (0x00080000)); + /* Set EISA IO port base for Indigo2 */ + set_io_port_base(KSEG1ADDR(0x00080000)); /* ARCS console environment variable is set to "g?" for * graphics console, it is set to "d" for the first serial @@ -96,20 +90,17 @@ void __init ip22_setup(void) */ ctype = ArcGetEnvironmentVariable("console"); if (ctype && *ctype == 'd') { -#ifdef CONFIG_IP22_SERIAL_CONSOLE - if (*(ctype + 1) == '2') - console_setup("ttyS1"); - else - console_setup("ttyS0"); -#endif - } -#ifdef CONFIG_ARC_CONSOLE - else if (!ctype || *ctype != 'g') { + static char options[8]; + char *baud = ArcGetEnvironmentVariable("dbaud"); + if (baud) + strcpy(options, baud); + add_preferred_console("ttyS", *(ctype + 1) == '2' ? 1 : 0, + baud ? options : NULL); + } else if (!ctype || *ctype != 'g') { /* Use ARC if we don't want serial ('d') or Newport ('g'). */ prom_flags |= PROM_FLAG_USE_AS_CONSOLE; - console_setup("arc"); + add_preferred_console("arc", 0, NULL); } -#endif #ifdef CONFIG_KGDB kgdb_ttyd = prom_getcmdline(); @@ -133,14 +124,13 @@ void __init ip22_setup(void) #endif #ifdef CONFIG_VT - conswitchp = &dummy_con; #ifdef CONFIG_SGI_NEWPORT_CONSOLE if (ctype && *ctype == 'g'){ - unsigned long *gfxinfo; - long (*__vec)(void) = - (void *) *(long *)((PROMBLOCK)->pvector + 0x20); + ULONG *gfxinfo; + ULONG * (*__vec)(void) = (void *) (long) + *((_PULONG *)(long)((PROMBLOCK)->pvector + 0x20)); - gfxinfo = (unsigned long *)__vec(); + gfxinfo = __vec(); sgi_gfxaddr = ((gfxinfo[1] >= 0xa0000000 && gfxinfo[1] <= 0xc0000000) ? gfxinfo[1] - 0xa0000000 : 0); @@ -148,21 +138,12 @@ void __init ip22_setup(void) /* newport addresses? */ if (sgi_gfxaddr == 0x1f0f0000 || sgi_gfxaddr == 0x1f4f0000) { conswitchp = &newport_con; - - screen_info = (struct screen_info) { - .orig_x = 0, - .orig_y = 0, - .orig_video_page = 0, - .orig_video_mode = 0, - .orig_video_cols = 160, - .orig_video_ega_bx = 0, - .orig_video_lines = 64, - .orig_video_isVGA = 0, - .orig_video_points = 16, - }; } } #endif #endif - rtc_ops = &ip22_rtc_ops; + + return 0; } + +early_initcall(ip22_setup); --- diff/arch/mips/sgi-ip22/ip22-time.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sgi-ip22/ip22-time.c 2004-02-23 13:56:38.000000000 +0000 @@ -7,9 +7,10 @@ * Ralf Baechle or David S. Miller (sorry guys, i'm really not sure) * * Copyright (C) 2001 by Ladislav Michl + * Copyright (C) 2003 Ralf Baechle (ralf@linux-mips.org) */ - #include +#include #include #include #include @@ -21,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -41,7 +41,7 @@ static unsigned long indy_rtc_get_time(v sec = BCD2BIN(hpc3c0->rtcregs[RTC_SECONDS] & 0xff); min = BCD2BIN(hpc3c0->rtcregs[RTC_MINUTES] & 0xff); - hrs = BCD2BIN(hpc3c0->rtcregs[RTC_HOURS] & 0x1f); + hrs = BCD2BIN(hpc3c0->rtcregs[RTC_HOURS] & 0x3f); day = BCD2BIN(hpc3c0->rtcregs[RTC_DATE] & 0xff); mon = BCD2BIN(hpc3c0->rtcregs[RTC_MONTH] & 0x1f); yrs = BCD2BIN(hpc3c0->rtcregs[RTC_YEAR] & 0xff); @@ -114,7 +114,7 @@ static unsigned long dosample(void) * for every 1/HZ seconds. We round off the nearest 1 MHz of master * clock (= 1000000 / HZ / 2). */ - //return (ct1 - ct0 + (500000/HZ/2)) / (500000/HZ) * (500000/HZ); + /*return (ct1 - ct0 + (500000/HZ/2)) / (500000/HZ) * (500000/HZ);*/ return (ct1 - ct0) / (500000/HZ) * (500000/HZ); } @@ -164,7 +164,7 @@ static __init void indy_time_init(void) (int) (r4k_tick / (500000 / HZ)), (int) (r4k_tick % (500000 / HZ))); - mips_counter_frequency = r4k_tick * HZ; + mips_hpt_frequency = r4k_tick * HZ; } /* Generic SGI handler for (spurious) 8254 interrupts */ --- diff/arch/mips/sgi-ip27/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sgi-ip27/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -6,4 +6,6 @@ obj-y := ip27-berr.o ip27-console.o ip27 ip27-klconfig.o ip27-klnuma.o ip27-memory.o ip27-nmi.o ip27-reset.o \ ip27-setup.o ip27-timer.o +obj-$(CONFIG_SMP) += ip27-smp.o + EXTRA_AFLAGS := $(CFLAGS) --- diff/arch/mips/sgi-ip27/ip27-console.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sgi-ip27/ip27-console.c 2004-02-23 13:56:38.000000000 +0000 @@ -9,16 +9,23 @@ #include #include #include -#include +#include +#include +#include + #include +#include #include #include #include #include #include -#define IOC3_BAUD (22000000 / (3*16)) -#define IOC3_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST) +#include +#include + +#define IOC3_CLK (22000000 / 3) +#define IOC3_FLAGS (0) static inline struct ioc3_uartregs *console_uart(void) { @@ -44,19 +51,23 @@ char __init prom_getchar(void) static void inline ioc3_console_probe(void) { - struct serial_struct req; + struct uart_port up; - /* Register to interrupt zero because we share the interrupt with - the serial driver which we don't properly support yet. */ - memset(&req, 0, sizeof(req)); - req.irq = 0; - req.flags = IOC3_COM_FLAGS; - req.io_type = SERIAL_IO_MEM; - req.iomem_reg_shift = 0; - req.baud_base = IOC3_BAUD; + /* + * Register to interrupt zero because we share the interrupt with + * the serial driver which we don't properly support yet. + */ + memset(&up, 0, sizeof(up)); + up.membase = (unsigned char *) console_uart(); + up.irq = 0; + up.uartclk = IOC3_CLK; + up.regshift = 0; + up.iotype = UPIO_MEM; + up.flags = IOC3_FLAGS; + up.line = 0; - req.iomem_base = (unsigned char *) console_uart(); - register_serial(&req); + if (early_serial_setup(&up)) + printk(KERN_ERR "Early serial init of port 0 failed\n"); } __init void ip27_setup_console(void) --- diff/arch/mips/sgi-ip27/ip27-init.c 2003-08-26 10:00:52.000000000 +0100 +++ source/arch/mips/sgi-ip27/ip27-init.c 2004-02-23 13:56:38.000000000 +0000 @@ -6,13 +6,13 @@ * Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com) * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc. */ - #include #include #include #include #include /* for numnodes */ #include +#include #include #include #include @@ -34,25 +34,12 @@ #include #include #include -#include -#include #define CPU_NONE (cpuid_t)-1 -/* - * The following should work till 64 nodes, ie 128p SN0s. - */ -#define CNODEMASK_CLRALL(p) (p) = 0 -#define CNODEMASK_TSTB(p, bit) ((p) & (1ULL << (bit))) -#define CNODEMASK_SETB(p, bit) ((p) |= 1ULL << (bit)) - -cpumask_t boot_cpumask; -hubreg_t region_mask; +static DECLARE_BITMAP(hub_init_mask, MAX_COMPACT_NODES); +static hubreg_t region_mask; static int fine_mode; -int maxcpus; -static spinlock_t hub_mask_lock = SPIN_LOCK_UNLOCKED; -static cnodemask_t hub_init_mask; -static atomic_t numstarted = ATOMIC_INIT(1); static int router_distance; nasid_t master_nasid = INVALID_NASID; @@ -61,7 +48,7 @@ nasid_t compact_to_nasid_node[MAX_COMPA cnodeid_t cpuid_to_compact_node[MAXCPUS]; char node_distances[MAX_COMPACT_NODES][MAX_COMPACT_NODES]; -hubreg_t get_region(cnodeid_t cnode) +static hubreg_t get_region(cnodeid_t cnode) { if (fine_mode) return COMPACT_TO_NASID_NODEID(cnode) >> NASID_TO_FINEREG_SHFT; @@ -79,312 +66,47 @@ static void gen_region_mask(hubreg_t *re } } -int is_fine_dirmode(void) +static int is_fine_dirmode(void) { return (((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_REGIONSIZE_MASK) >> NSRI_REGIONSIZE_SHFT) & REGIONSIZE_FINE); } -nasid_t get_actual_nasid(lboard_t *brd) -{ - klhub_t *hub; - - if (!brd) - return INVALID_NASID; - - /* find out if we are a completely disabled brd. */ - hub = (klhub_t *)find_first_component(brd, KLSTRUCT_HUB); - if (!hub) - return INVALID_NASID; - if (!(hub->hub_info.flags & KLINFO_ENABLE)) /* disabled node brd */ - return hub->hub_info.physid; - else - return brd->brd_nasid; -} - -/* Tweak this for maximum number of CPUs to activate */ -static int max_cpus = NR_CPUS; - -int do_cpumask(cnodeid_t cnode, nasid_t nasid, cpumask_t *boot_cpumask, - int *highest) -{ - static int tot_cpus_found = 0; - lboard_t *brd; - klcpu_t *acpu; - int cpus_found = 0; - cpuid_t cpuid; - - brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_IP27); - - do { - acpu = (klcpu_t *)find_first_component(brd, KLSTRUCT_CPU); - while (acpu) { - cpuid = acpu->cpu_info.virtid; - /* cnode is not valid for completely disabled brds */ - if (get_actual_nasid(brd) == brd->brd_nasid) - cpuid_to_compact_node[cpuid] = cnode; - if (cpuid > *highest) - *highest = cpuid; - /* Only let it join in if it's marked enabled */ - if ((acpu->cpu_info.flags & KLINFO_ENABLE) && - (tot_cpus_found != max_cpus)) { - CPUMASK_SETB(*boot_cpumask, cpuid); - cpus_found++; - tot_cpus_found++; - } - acpu = (klcpu_t *)find_component(brd, (klinfo_t *)acpu, - KLSTRUCT_CPU); - } - brd = KLCF_NEXT(brd); - if (brd) - brd = find_lboard(brd,KLTYPE_IP27); - else - break; - } while (brd); - - return cpus_found; -} - -cpuid_t cpu_node_probe(cpumask_t *boot_cpumask, int *numnodes) -{ - int i, cpus = 0, highest = 0; - gda_t *gdap = GDA; - nasid_t nasid; - - /* - * Initialize the arrays to invalid nodeid (-1) - */ - for (i = 0; i < MAX_COMPACT_NODES; i++) - compact_to_nasid_node[i] = INVALID_NASID; - for (i = 0; i < MAX_NASIDS; i++) - nasid_to_compact_node[i] = INVALID_CNODEID; - for (i = 0; i < MAXCPUS; i++) - cpuid_to_compact_node[i] = INVALID_CNODEID; - - *numnodes = 0; - for (i = 0; i < MAX_COMPACT_NODES; i++) { - if ((nasid = gdap->g_nasidtable[i]) == INVALID_NASID) { - break; - } else { - compact_to_nasid_node[i] = nasid; - nasid_to_compact_node[nasid] = i; - (*numnodes)++; - cpus += do_cpumask(i, nasid, boot_cpumask, &highest); - } - } - - /* - * Cpus are numbered in order of cnodes. Currently, disabled - * cpus are not numbered. - */ - - return highest + 1; -} - -int cpu_enabled(cpuid_t cpu) +extern void pcibr_setup(cnodeid_t); +void per_hub_init(cnodeid_t cnode) { - if (cpu == CPU_NONE) - return 0; - return CPUMASK_TSTB(boot_cpumask, cpu) != 0; -} + nasid_t nasid = COMPACT_TO_NASID_NODEID(cnode); -void mlreset(void) -{ - int i; - void init_topology_matrix(void); - void dump_topology(void); - - - master_nasid = get_nasid(); - fine_mode = is_fine_dirmode(); + if (test_and_set_bit(cnode, hub_init_mask)) + return; /* - * Probe for all CPUs - this creates the cpumask and - * sets up the mapping tables. + * Set CRB timeout at 5ms, (< PI timeout of 10ms) */ - CPUMASK_CLRALL(boot_cpumask); - maxcpus = cpu_node_probe(&boot_cpumask, &numnodes); - printk("Discovered %d cpus on %d nodes\n", maxcpus, numnodes); + REMOTE_HUB_S(nasid, IIO_ICTP, 0x800); + REMOTE_HUB_S(nasid, IIO_ICTO, 0xff); - init_topology_matrix(); - dump_topology(); - - gen_region_mask(®ion_mask, numnodes); - CNODEMASK_CLRALL(hub_init_mask); - - setup_replication_mask(numnodes); + hub_rtc_init(cnode); + pcibr_setup(cnode); +#ifdef CONFIG_REPLICATE_EXHANDLERS /* - * Set all nodes' calias sizes to 8k + * If this is not a headless node initialization, + * copy over the caliased exception handlers. */ - for (i = 0; i < numnodes; i++) { - nasid_t nasid; - - nasid = COMPACT_TO_NASID_NODEID(i); - - /* - * Always have node 0 in the region mask, otherwise - * CALIAS accesses get exceptions since the hub - * thinks it is a node 0 address. - */ - REMOTE_HUB_S(nasid, PI_REGION_PRESENT, (region_mask | 1)); -#ifdef CONFIG_REPLICATE_EXHANDLERS - REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_8K); -#else - REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_0); -#endif - -#ifdef LATER - /* - * Set up all hubs to have a big window pointing at - * widget 0. Memory mode, widget 0, offset 0 - */ - REMOTE_HUB_S(nasid, IIO_ITTE(SWIN0_BIGWIN), - ((HUB_PIO_MAP_TO_MEM << IIO_ITTE_IOSP_SHIFT) | - (0 << IIO_ITTE_WIDGET_SHIFT))); -#endif - } -} - - -void intr_clear_bits(nasid_t nasid, volatile hubreg_t *pend, int base_level, - char *name) -{ - volatile hubreg_t bits; - int i; - - /* Check pending interrupts */ - if ((bits = HUB_L(pend)) != 0) - for (i = 0; i < N_INTPEND_BITS; i++) - if (bits & (1 << i)) - LOCAL_HUB_CLR_INTR(base_level + i); -} - -void intr_clear_all(nasid_t nasid) -{ - REMOTE_HUB_S(nasid, PI_INT_MASK0_A, 0); - REMOTE_HUB_S(nasid, PI_INT_MASK0_B, 0); - REMOTE_HUB_S(nasid, PI_INT_MASK1_A, 0); - REMOTE_HUB_S(nasid, PI_INT_MASK1_B, 0); - intr_clear_bits(nasid, REMOTE_HUB_ADDR(nasid, PI_INT_PEND0), - INT_PEND0_BASELVL, "INT_PEND0"); - intr_clear_bits(nasid, REMOTE_HUB_ADDR(nasid, PI_INT_PEND1), - INT_PEND1_BASELVL, "INT_PEND1"); -} - -void sn_mp_setup(void) -{ - cnodeid_t cnode; -#if 0 - cpuid_t cpu; -#endif - - for (cnode = 0; cnode < numnodes; cnode++) { -#if 0 - init_platform_nodepda(); -#endif - intr_clear_all(COMPACT_TO_NASID_NODEID(cnode)); + if (get_compact_nodeid() == cnode) { + extern char except_vec0, except_vec1_r10k; + extern char except_vec2_generic, except_vec3_generic; + + memcpy((void *)(KSEG0 + 0x100), &except_vec2_generic, 0x80); + memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, 0x80); + memcpy((void *)KSEG0, &except_vec0, 0x80); + memcpy((void *)KSEG0 + 0x080, &except_vec1_r10k, 0x80); + memcpy((void *)(KSEG0 + 0x100), (void *) KSEG0, 0x80); + memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, 0x100); + __flush_cache_all(); } -#if 0 - for (cpu = 0; cpu < maxcpus; cpu++) { - init_platform_pda(); - } -#endif -} - -void per_hub_init(cnodeid_t cnode) -{ - extern void pcibr_setup(cnodeid_t); - cnodemask_t done; - nasid_t nasid; - - nasid = COMPACT_TO_NASID_NODEID(cnode); - - spin_lock(&hub_mask_lock); - /* Test our bit. */ - if (!(done = CNODEMASK_TSTB(hub_init_mask, cnode))) { - /* Turn our bit on in the mask. */ - CNODEMASK_SETB(hub_init_mask, cnode); - /* - * Do the actual initialization if it hasn't been done yet. - * We don't need to hold a lock for this work. - */ - /* - * Set CRB timeout at 5ms, (< PI timeout of 10ms) - */ - REMOTE_HUB_S(nasid, IIO_ICTP, 0x800); - REMOTE_HUB_S(nasid, IIO_ICTO, 0xff); - hub_rtc_init(cnode); - pcibr_setup(cnode); -#ifdef CONFIG_REPLICATE_EXHANDLERS - /* - * If this is not a headless node initialization, - * copy over the caliased exception handlers. - */ - if (get_compact_nodeid() == cnode) { - extern char except_vec0, except_vec1_r10k; - extern char except_vec2_generic, except_vec3_generic; - - memcpy((void *)(KSEG0 + 0x100), &except_vec2_generic, - 0x80); - memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, - 0x80); - memcpy((void *)KSEG0, &except_vec0, 0x80); - memcpy((void *)KSEG0 + 0x080, &except_vec1_r10k, 0x80); - memcpy((void *)(KSEG0 + 0x100), (void *) KSEG0, 0x80); - memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, - 0x100); - __flush_cache_all(); - } -#endif - } - spin_unlock(&hub_mask_lock); -} - -/* - * This is similar to hard_smp_processor_id(). - */ -cpuid_t getcpuid(void) -{ - klcpu_t *klcpu; - - klcpu = nasid_slice_to_cpuinfo(get_nasid(),LOCAL_HUB_L(PI_CPU_NUM)); - return klcpu->cpu_info.virtid; -} - -void per_cpu_init(void) -{ - extern void install_cpu_nmi_handler(int slice); - extern void load_mmu(void); - static int is_slave = 0; - int cpu = smp_processor_id(); - cnodeid_t cnode = get_compact_nodeid(); - -#if 0 - intr_init(); -#endif - clear_c0_status(ST0_IM); - per_hub_init(cnode); - cpu_time_init(); - if (smp_processor_id()) /* master can't do this early, no kmalloc */ - install_cpuintr(cpu); - /* Install our NMI handler if symmon hasn't installed one. */ - install_cpu_nmi_handler(cputoslice(cpu)); -#if 0 - install_tlbintr(cpu); #endif - set_c0_status(SRB_DEV0 | SRB_DEV1); - if (is_slave) { - clear_c0_status(ST0_BEV); - if (current_cpu_data.isa_level == MIPS_CPU_ISA_IV) - set_c0_status(ST0_XX); - set_c0_status(ST0_KX|ST0_SX|ST0_UX); - local_irq_enable(); - load_mmu(); - atomic_inc(&numstarted); - } else { - is_slave = 1; - } } cnodeid_t get_compact_nodeid(void) @@ -399,154 +121,9 @@ cnodeid_t get_compact_nodeid(void) return NASID_TO_COMPACT_NODEID(nasid); } -#ifdef CONFIG_SMP - -/* - * Takes as first input the PROM assigned cpu id, and the kernel - * assigned cpu id as the second. - */ -static void alloc_cpupda(cpuid_t cpu, int cpunum) -{ - cnodeid_t node; - nasid_t nasid; - - node = get_cpu_cnode(cpu); - nasid = COMPACT_TO_NASID_NODEID(node); - - cputonasid(cpunum) = nasid; - cputocnode(cpunum) = node; - cputoslice(cpunum) = get_cpu_slice(cpu); - cpu_data[cpunum].p_cpuid = cpu; -} - -static struct task_struct * __init fork_by_hand(void) -{ - struct pt_regs regs; - /* - * don't care about the eip and regs settings since - * we'll never reschedule the forked task. - */ - return copy_process(CLONE_VM|CLONE_IDLETASK, 0, ®s, 0, NULL, NULL); -} - -static int __init do_boot_cpu(int cpu, int num_cpus) -{ - extern void smp_bootstrap(void); - cpuid_t mycpuid = getcpuid(); - struct task_struct *idle; - - if (cpu == mycpuid) { - alloc_cpupda(cpu, num_cpus); - return 1; - } - - /* Skip holes in CPU space */ - if (!CPUMASK_TSTB(boot_cpumask, cpu)) - return 0; - - /* - * The following code is purely to make sure - * Linux can schedule processes on this slave. - */ - idle = fork_by_hand(); - if (IS_ERR(idle)) - panic("failed fork for CPU %d", cpu); - - /* - * We remove it from the pidhash and the runqueue - * once we got the process: - */ - init_idle(idle, cpu); - - alloc_cpupda(cpu, num_cpus); - - unhash_process(idle); - - /* - * Launch a slave into smp_bootstrap(). It doesn't take an - * argument, and we set sp to the kernel stack of the newly - * created idle process, gp to the proc struct so that - * current_thread_info() will work. - */ - LAUNCH_SLAVE(cputonasid(num_cpus),cputoslice(num_cpus), - (launch_proc_t)MAPPED_KERN_RW_TO_K0(smp_bootstrap), - 0, (void *)((unsigned long)idle->thread_info + - THREAD_SIZE - 32), (void *)idle); - - /* - * Now optimistically set the mapping arrays. We - * need to wait here, verify the cpu booted up, then - * fire up the next cpu. - */ - __cpu_number_map[cpu] = num_cpus; - __cpu_logical_map[num_cpus] = cpu; - cpu_set(cpu, cpu_online_map); - - /* - * Wait this cpu to start up and initialize its hub, - * and discover the io devices it will control. - * - * XXX: We really want to fire up launch all the CPUs - * at once. We have to preserve the order of the - * devices on the bridges first though. - */ - while (atomic_read(&numstarted) != num_cpus); - - return 1; -} - -void __init smp_boot_cpus(void) -{ - int num_cpus = 0; - cpuid_t cpu; - cnodeid_t cnode; - - init_new_context(current, &init_mm); - current_thread_info()->cpu = 0; - smp_tune_scheduling(); - - sn_mp_setup(); - /* Master has already done per_cpu_init() */ - install_cpuintr(smp_processor_id()); -#if 0 - bte_lateinit(); - ecc_init(); -#endif - - replicate_kernel_text(numnodes); - /* Launch slaves. */ - for (cpu = 0; cpu < maxcpus; cpu++) { - num_cpus += do_boot_cpu(cpu, num_cpus); - } - -#ifdef LATER - Wait logic goes here. -#endif - for (cnode = 0; cnode < numnodes; cnode++) { -#if 0 - if (cnodetocpu(cnode) == -1) { - printk("Initializing headless hub,cnode %d", cnode); - per_hub_init(cnode); - } -#endif - } -#if 0 - cpu_io_setup(); - init_mfhi_war(); -#endif -} - -#else /* CONFIG_SMP */ -void __init start_secondary(void) -{ - /* XXX Why do we need this empty definition at all? */ -} -#endif /* CONFIG_SMP */ - - #define rou_rflag rou_flags -void router_recurse(klrou_t *router_a, klrou_t *router_b, int depth) +static void router_recurse(klrou_t *router_a, klrou_t *router_b, int depth) { klrou_t *router; lboard_t *brd; @@ -582,13 +159,13 @@ void router_recurse(klrou_t *router_a, k router_a->rou_rflag = 0; } -int node_distance(nasid_t nasid_a, nasid_t nasid_b) +static int node_distance(nasid_t nasid_a, nasid_t nasid_b) { - nasid_t nasid; - cnodeid_t cnode; + klrou_t *router, *router_a = NULL, *router_b = NULL; lboard_t *brd, *dest_brd; + cnodeid_t cnode; + nasid_t nasid; int port; - klrou_t *router, *router_a = NULL, *router_b = NULL; /* Figure out which routers nodes in question are connected to */ for (cnode = 0; cnode < numnodes; cnode++) { @@ -625,7 +202,7 @@ int node_distance(nasid_t nasid_a, nasid } } - } while ( (brd = find_lboard_class(KLCF_NEXT(brd), KLTYPE_ROUTER)) ); + } while ((brd = find_lboard_class(KLCF_NEXT(brd), KLTYPE_ROUTER))); } if (router_a == NULL) { @@ -649,7 +226,7 @@ int node_distance(nasid_t nasid_a, nasid return router_distance; } -void init_topology_matrix(void) +static void init_topology_matrix(void) { nasid_t nasid, nasid2; cnodeid_t row, col; @@ -667,7 +244,7 @@ void init_topology_matrix(void) } } -void dump_topology(void) +static void dump_topology(void) { nasid_t nasid; cnodeid_t cnode; @@ -728,93 +305,56 @@ void dump_topology(void) } } -#if 0 -#define brd_widgetnum brd_slot -#define NODE_OFFSET_TO_KLINFO(n,off) ((klinfo_t*) TO_NODE_CAC(n,off)) -void -dump_klcfg(void) +void mlreset(void) { - cnodeid_t cnode; int i; - nasid_t nasid; - lboard_t *lbptr; - gda_t *gdap; - - gdap = (gda_t *)GDA_ADDR(get_nasid()); - if (gdap->g_magic != GDA_MAGIC) { - printk("dumpklcfg_cmd: Invalid GDA MAGIC\n"); - return; - } - for (cnode = 0; cnode < MAX_COMPACT_NODES; cnode ++) { - nasid = gdap->g_nasidtable[cnode]; + master_nasid = get_nasid(); + fine_mode = is_fine_dirmode(); - if (nasid == INVALID_NASID) - continue; + /* + * Probe for all CPUs - this creates the cpumask and sets up the + * mapping tables. We need to do this as early as possible. + */ +#ifdef CONFIG_SMP + cpu_node_probe(); +#endif - printk("\nDumpping klconfig Nasid %d:\n", nasid); + init_topology_matrix(); + dump_topology(); - lbptr = KL_CONFIG_INFO(nasid); + gen_region_mask(®ion_mask, numnodes); - while (lbptr) { - printk(" %s, Nasid %d, Module %d, widget 0x%x, partition %d, NIC 0x%x lboard 0x%lx", - "board name here", /* BOARD_NAME(lbptr->brd_type), */ - lbptr->brd_nasid, lbptr->brd_module, - lbptr->brd_widgetnum, - lbptr->brd_partition, - (lbptr->brd_nic), lbptr); - if (lbptr->brd_flags & DUPLICATE_BOARD) - printk(" -D"); - printk("\n"); - for (i = 0; i < lbptr->brd_numcompts; i++) { - klinfo_t *kli; - kli = NODE_OFFSET_TO_KLINFO(NASID_GET(lbptr), lbptr->brd_compts[i]); - printk(" type %2d, flags 0x%04x, diagval %3d, physid %4d, virtid %2d: %s\n", - kli->struct_type, - kli->flags, - kli->diagval, - kli->physid, - kli->virtid, - "comp. name here"); - /* COMPONENT_NAME(kli->struct_type)); */ - } - lbptr = KLCF_NEXT(lbptr); - } - } - printk("\n"); + setup_replication_mask(numnodes); + + /* + * Set all nodes' calias sizes to 8k + */ + for (i = 0; i < numnodes; i++) { + nasid_t nasid; - /* Useful to print router maps also */ + nasid = COMPACT_TO_NASID_NODEID(i); - for (cnode = 0; cnode < MAX_COMPACT_NODES; cnode ++) { - klrou_t *kr; - int i; - - nasid = gdap->g_nasidtable[cnode]; - if (nasid == INVALID_NASID) - continue; - lbptr = KL_CONFIG_INFO(nasid); - - while (lbptr) { - - lbptr = find_lboard_class(lbptr, KLCLASS_ROUTER); - if(!lbptr) - break; - if (!KL_CONFIG_DUPLICATE_BOARD(lbptr)) { - printk("%llx -> \n", lbptr->brd_nic); - kr = (klrou_t *)find_first_component(lbptr, - KLSTRUCT_ROU); - for (i = 1; i <= MAX_ROUTER_PORTS; i++) { - printk("[%d, %llx]; ", - kr->rou_port[i].port_nasid, - kr->rou_port[i].port_offset); - } - printk("\n"); - } - lbptr = KLCF_NEXT(lbptr); - } - printk("\n"); - } + /* + * Always have node 0 in the region mask, otherwise + * CALIAS accesses get exceptions since the hub + * thinks it is a node 0 address. + */ + REMOTE_HUB_S(nasid, PI_REGION_PRESENT, (region_mask | 1)); +#ifdef CONFIG_REPLICATE_EXHANDLERS + REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_8K); +#else + REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_0); +#endif - dump_topology(); -} +#ifdef LATER + /* + * Set up all hubs to have a big window pointing at + * widget 0. Memory mode, widget 0, offset 0 + */ + REMOTE_HUB_S(nasid, IIO_ITTE(SWIN0_BIGWIN), + ((HUB_PIO_MAP_TO_MEM << IIO_ITTE_IOSP_SHIFT) | + (0 << IIO_ITTE_WIDGET_SHIFT))); #endif + } +} --- diff/arch/mips/sgi-ip27/ip27-irq-glue.S 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sgi-ip27/ip27-irq-glue.S 2004-02-23 13:56:38.000000000 +0000 @@ -12,53 +12,34 @@ #include .text - .set noat .align 5 NESTED(ip27_irq, PT_SIZE, sp) SAVE_ALL CLI - .set at - /* IP27 may signal interrupt which we're not interested in. - Mask them out. */ mfc0 s0, CP0_CAUSE mfc0 t0, CP0_STATUS and s0, t0 - - /* First check for RT interrupt. */ - andi a0, s0, CAUSEF_IP4 - beqz a0, 1f - - /* Ok, a timer interrupt. */ move a0, sp - jal rt_timer_interrupt + la ra, ret_from_irq - j ret_from_irq - -1: andi a0, s0, (CAUSEF_IP2 | CAUSEF_IP3) - beqz a0, 1f - - /* ... a device interrupt ... */ - move a0, sp - jal ip27_do_irq - - j ret_from_irq - -1: -#if 1 - mfc0 a1, CP0_STATUS - srl a1, a1, 8 - andi a1, 0xff - - mfc0 a2, CP0_CAUSE - srl a2, a2, 8 - andi a2, 0xff - - move a3, s0 - PRINT("Spurious interrupt, c0_status = %02x, c0_cause = %02x, pending %02x.\n") - ld a1, PT_EPC(sp) -0: b 0b -#endif + /* First check for RT interrupt. */ + andi t0, s0, CAUSEF_IP4 + bnez t0, ip4 + andi t0, s0, CAUSEF_IP2 + bnez t0, ip2 + andi t0, s0, CAUSEF_IP3 + bnez t0, ip3 + andi t0, s0, CAUSEF_IP5 + bnez t0, ip5 + andi t0, s0, CAUSEF_IP6 + bnez t0, ip6 + j ra + +ip2: j ip27_do_irq_mask0 # PI_INT_PEND_0 or CC_PEND_{A|B} +ip3: j ip27_do_irq_mask1 # PI_INT_PEND_1 +ip4: j ip27_rt_timer_interrupt +ip5: j ip27_prof_timer +ip6: j ip27_hub_error - j ret_from_irq END(ip27_irq) --- diff/arch/mips/sgi-ip27/ip27-irq.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sgi-ip27/ip27-irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -38,7 +38,6 @@ #include #include - #undef DEBUG_IRQ #ifdef DEBUG_IRQ #define DBG(x...) printk(x) @@ -46,10 +45,18 @@ #define DBG(x...) #endif -/* These should die */ -unsigned char bus_to_wid[256]; /* widget id for linux pci bus */ -unsigned char bus_to_nid[256]; /* nasid for linux pci bus */ -unsigned char num_bridges; /* number of bridges in the system */ +/* + * Number of levels in INT_PEND0. Can be set to 128 if we also + * consider INT_PEND1. + */ +#define PERNODE_LEVELS 64 + +/* + * we need to map irq's up to at least bit 7 of the INT_MASK0_A register + * since bits 0-6 are pre-allocated for other purposes. + */ +#define FAST_IRQ_TO_LEVEL(i) (i) +#define LEVEL_TO_IRQ(c, l) (node_level_to_irq[CPUID_TO_COMPACT_NODEID(c)][(l)]) /* * Linux has a controller-independent x86 interrupt architecture. @@ -69,30 +76,26 @@ unsigned char num_bridges; /* number of extern asmlinkage void ip27_irq(void); -extern int irq_to_bus[], irq_to_slot[], bus_to_cpu[]; -int intr_connect_level(int cpu, int bit); -int intr_disconnect_level(int cpu, int bit); +extern struct bridge_controller *irq_to_bridge[]; +extern int irq_to_slot[]; /* * There is a single intpend register per node, and we want to have * distinct levels for intercpu intrs for both cpus A and B on a node. */ -int node_level_to_irq[MAX_COMPACT_NODES][PERNODE_LEVELS]; +static int node_level_to_irq[MAX_COMPACT_NODES][PERNODE_LEVELS]; /* * use these macros to get the encoded nasid and widget id * from the irq value */ -#define IRQ_TO_BUS(i) irq_to_bus[(i)] -#define IRQ_TO_CPU(i) bus_to_cpu[IRQ_TO_BUS(i)] -#define NASID_FROM_PCI_IRQ(i) bus_to_nid[IRQ_TO_BUS(i)] -#define WID_FROM_PCI_IRQ(i) bus_to_wid[IRQ_TO_BUS(i)] +#define IRQ_TO_BRIDGE(i) irq_to_bridge[(i)] #define SLOT_FROM_PCI_IRQ(i) irq_to_slot[i] static inline int alloc_level(cpuid_t cpunum, int irq) { cnodeid_t nodenum = CPUID_TO_COMPACT_NODEID(cpunum); - int j = LEAST_LEVEL + 3; /* resched & crosscall entries taken */ + int j = BASE_PCI_IRQ; /* pre-allocated entries */ while (++j < PERNODE_LEVELS) { if (node_level_to_irq[nodenum][j] == -1) { @@ -100,9 +103,8 @@ static inline int alloc_level(cpuid_t cp return j; } } - printk("Cpu %ld flooded with devices\n", cpunum); - while(1); - return -1; + + panic("Cpu %ld flooded with devices\n", cpunum); } static inline int find_level(cpuid_t *cpunum, int irq) @@ -111,16 +113,15 @@ static inline int find_level(cpuid_t *cp cnodeid_t nodenum = INVALID_CNODEID; while (++nodenum < MAX_COMPACT_NODES) { - j = LEAST_LEVEL + 3; /* resched & crosscall entries taken */ + j = BASE_PCI_IRQ; /* Pre-allocated entries */ while (++j < PERNODE_LEVELS) if (node_level_to_irq[nodenum][j] == irq) { *cpunum = 0; /* XXX Fixme */ return(j); } } - printk("Could not identify cpu/level for irq %d\n", irq); - while(1); - return(-1); + + panic("Could not identify cpu/level for irq %d\n", irq); } /* @@ -150,73 +151,206 @@ static int ms1bit(unsigned long x) * same intr. This effect is mostly seen for intercpu intrs. * Kanoj 05.13.00 */ -void ip27_do_irq(struct pt_regs *regs) + +void ip27_do_irq_mask0(struct pt_regs *regs) { int irq, swlevel; hubreg_t pend0, mask0; - cpuid_t thiscpu = smp_processor_id(); - int pi_int_mask0 = ((cputoslice(thiscpu) == 0) ? - PI_INT_MASK0_A : PI_INT_MASK0_B); + cpuid_t cpu = smp_processor_id(); + int pi_int_mask0 = + (cputoslice(cpu) == 0) ? PI_INT_MASK0_A : PI_INT_MASK0_B; /* copied from Irix intpend0() */ - while (((pend0 = LOCAL_HUB_L(PI_INT_PEND0)) & - (mask0 = LOCAL_HUB_L(pi_int_mask0))) != 0) { - pend0 &= mask0; /* Pick intrs we should look at */ - if (pend0) { - /* Prevent any of the picked intrs from recursing */ - LOCAL_HUB_S(pi_int_mask0, mask0 & ~(pend0)); - do { - swlevel = ms1bit(pend0); - LOCAL_HUB_CLR_INTR(swlevel); - /* "map" swlevel to irq */ - irq = LEVEL_TO_IRQ(thiscpu, swlevel); - do_IRQ(irq, regs); - /* clear bit in pend0 */ - pend0 ^= 1ULL << swlevel; - } while(pend0); - /* Now allow the set of serviced intrs again */ - LOCAL_HUB_S(pi_int_mask0, mask0); - LOCAL_HUB_L(PI_INT_PEND0); - } + pend0 = LOCAL_HUB_L(PI_INT_PEND0); + mask0 = LOCAL_HUB_L(pi_int_mask0); + + pend0 &= mask0; /* Pick intrs we should look at */ + if (!pend0) + return; + + /* Prevent any of the picked intrs from recursing */ + LOCAL_HUB_S(pi_int_mask0, mask0 & ~pend0); + + swlevel = ms1bit(pend0); +#ifdef CONFIG_SMP + if (pend0 & (1UL << CPU_RESCHED_A_IRQ)) { + LOCAL_HUB_CLR_INTR(CPU_RESCHED_A_IRQ); + } else if (pend0 & (1UL << CPU_RESCHED_B_IRQ)) { + LOCAL_HUB_CLR_INTR(CPU_RESCHED_B_IRQ); + } else if (pend0 & (1UL << CPU_CALL_A_IRQ)) { + LOCAL_HUB_CLR_INTR(CPU_CALL_A_IRQ); + smp_call_function_interrupt(); + } else if (pend0 & (1UL << CPU_CALL_B_IRQ)) { + LOCAL_HUB_CLR_INTR(CPU_CALL_B_IRQ); + smp_call_function_interrupt(); + } else +#endif + { + /* "map" swlevel to irq */ + irq = LEVEL_TO_IRQ(cpu, swlevel); + do_IRQ(irq, regs); + } + + /* clear bit in pend0 */ + pend0 ^= 1UL << swlevel; + + /* Now allow the set of serviced intrs again */ + LOCAL_HUB_S(pi_int_mask0, mask0); + LOCAL_HUB_L(PI_INT_PEND0); +} + +void ip27_do_irq_mask1(struct pt_regs *regs) +{ + int irq, swlevel; + hubreg_t pend1, mask1; + cpuid_t cpu = smp_processor_id(); + int pi_int_mask1 = (cputoslice(cpu) == 0) ? PI_INT_MASK1_A : PI_INT_MASK1_B; + + /* copied from Irix intpend0() */ + pend1 = LOCAL_HUB_L(PI_INT_PEND1); + mask1 = LOCAL_HUB_L(pi_int_mask1); + + pend1 &= mask1; /* Pick intrs we should look at */ + if (!pend1) + return; + + /* Prevent any of the picked intrs from recursing */ + LOCAL_HUB_S(pi_int_mask1, mask1 & ~pend1); + + swlevel = ms1bit(pend1); + /* "map" swlevel to irq */ + irq = LEVEL_TO_IRQ(cpu, swlevel); + LOCAL_HUB_CLR_INTR(swlevel); + do_IRQ(irq, regs); + /* clear bit in pend1 */ + pend1 ^= 1UL << swlevel; + + /* Now allow the set of serviced intrs again */ + LOCAL_HUB_S(pi_int_mask1, mask1); + LOCAL_HUB_L(PI_INT_PEND1); +} + +void ip27_prof_timer(struct pt_regs *regs) +{ + panic("CPU %d got a profiling interrupt", smp_processor_id()); +} + +void ip27_hub_error(struct pt_regs *regs) +{ + panic("CPU %d got a hub error interrupt", smp_processor_id()); +} + +/* + * Get values that vary depending on which CPU and bit we're operating on. + */ +static void intr_get_ptrs(cpuid_t cpu, int bit, int *new_bit, + hubreg_t **intpend_masks, int *ip) +{ + struct hub_intmasks_s *hub_intmasks = &cpu_data[cpu].p_intmasks; + + if (bit < N_INTPEND_BITS) { + *intpend_masks = &hub_intmasks->intpend0_masks; + *ip = 0; + *new_bit = bit; + } else { + *intpend_masks = &hub_intmasks->intpend1_masks; + *ip = 1; + *new_bit = bit - N_INTPEND_BITS; } } +static int intr_connect_level(int cpu, int bit) +{ + int ip; + int slice = cputoslice(cpu); + volatile hubreg_t *mask_reg; + hubreg_t *intpend_masks; + nasid_t nasid = COMPACT_TO_NASID_NODEID(cputocnode(cpu)); + + intr_get_ptrs(cpu, bit, &bit, &intpend_masks, &ip); + + /* Make sure it's not already pending when we connect it. */ + REMOTE_HUB_CLR_INTR(nasid, bit + ip * N_INTPEND_BITS); + + *intpend_masks |= (1UL << bit); + + if (ip == 0) { + mask_reg = REMOTE_HUB_ADDR(nasid, PI_INT_MASK0_A + + PI_INT_MASK_OFFSET * slice); + } else { + mask_reg = REMOTE_HUB_ADDR(nasid, PI_INT_MASK1_A + + PI_INT_MASK_OFFSET * slice); + } + HUB_S(mask_reg, intpend_masks[0]); + + return 0; +} + +static int intr_disconnect_level(int cpu, int bit) +{ + int ip; + int slice = cputoslice(cpu); + volatile hubreg_t *mask_reg; + hubreg_t *intpend_masks; + nasid_t nasid = COMPACT_TO_NASID_NODEID(cputocnode(cpu)); + + intr_get_ptrs(cpu, bit, &bit, &intpend_masks, &ip); + intpend_masks[0] &= ~(1ULL << (u64)bit); + if (ip == 0) { + mask_reg = REMOTE_HUB_ADDR(nasid, PI_INT_MASK0_A + + PI_INT_MASK_OFFSET * slice); + } else { + mask_reg = REMOTE_HUB_ADDR(nasid, PI_INT_MASK1_A + + PI_INT_MASK_OFFSET * slice); + } + HUB_S(mask_reg, intpend_masks[0]); + + return 0; +} /* Startup one of the (PCI ...) IRQs routes over a bridge. */ static unsigned int startup_bridge_irq(unsigned int irq) { + struct bridge_controller *bc; bridgereg_t device; bridge_t *bridge; int pin, swlevel; - cpuid_t cpu; - nasid_t master = NASID_FROM_PCI_IRQ(irq); if (irq < BASE_PCI_IRQ) return 0; - bridge = (bridge_t *) NODE_SWIN_BASE(master, WID_FROM_PCI_IRQ(irq)); pin = SLOT_FROM_PCI_IRQ(irq); - cpu = IRQ_TO_CPU(irq); + bc = IRQ_TO_BRIDGE(irq); + bridge = bc->base; DBG("bridge_startup(): irq= 0x%x pin=%d\n", irq, pin); /* * "map" irq to a swlevel greater than 6 since the first 6 bits * of INT_PEND0 are taken */ - swlevel = alloc_level(cpu, irq); - intr_connect_level(cpu, swlevel); + swlevel = alloc_level(bc->irq_cpu, irq); + intr_connect_level(bc->irq_cpu, swlevel); - bridge->b_int_addr[pin].addr = (0x20000 | swlevel | (master << 8)); + bridge->b_int_addr[pin].addr = (0x20000 | swlevel | (bc->nasid << 8)); bridge->b_int_enable |= (1 << pin); /* more stuff in int_enable reg */ bridge->b_int_enable |= 0x7ffffe00; /* - * XXX This only works if b_int_device is initialized to 0! - * We program the bridge to have a 1:1 mapping between devices + * Enable sending of an interrupt clear packt to the hub on a high to + * low transition of the interrupt pin. + * + * IRIX sets additional bits in the address which are documented as + * reserved in the bridge docs. + */ + bridge->b_int_mode |= (1UL << pin); + + /* + * We assume the bridge to have a 1:1 mapping between devices * (slots) and intr pins. */ device = bridge->b_int_device; + device &= ~(7 << (pin*3)); device |= (pin << (pin*3)); bridge->b_int_device = device; @@ -226,17 +360,15 @@ static unsigned int startup_bridge_irq(u } /* Shutdown one of the (PCI ...) IRQs routes over a bridge. */ -static unsigned int shutdown_bridge_irq(unsigned int irq) +static void shutdown_bridge_irq(unsigned int irq) { - bridge_t *bridge; + struct bridge_controller *bc = IRQ_TO_BRIDGE(irq); + bridge_t *bridge = bc->base; int pin, swlevel; cpuid_t cpu; - if (irq < BASE_PCI_IRQ) - return 0; + BUG_ON(irq < BASE_PCI_IRQ); - bridge = (bridge_t *) NODE_SWIN_BASE(NASID_FROM_PCI_IRQ(irq), - WID_FROM_PCI_IRQ(irq)); DBG("bridge_shutdown: irq 0x%x\n", irq); pin = SLOT_FROM_PCI_IRQ(irq); @@ -250,8 +382,6 @@ static unsigned int shutdown_bridge_irq( bridge->b_int_enable &= ~(1 << pin); bridge->b_widget.w_tflush; /* Flush */ - - return 0; /* Never anything pending. */ } static inline void enable_bridge_irq(unsigned int irq) @@ -269,20 +399,18 @@ static void mask_and_ack_bridge_irq(unsi /* All the braindamage happens magically for us in ip27_do_irq */ } -static void end_bridge_irq (unsigned int irq) +static void end_bridge_irq(unsigned int irq) { - if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) - enable_bridge_irq(irq); } static struct hw_interrupt_type bridge_irq_type = { - "bridge", - startup_bridge_irq, - shutdown_bridge_irq, - enable_bridge_irq, - disable_bridge_irq, - mask_and_ack_bridge_irq, - end_bridge_irq + .typename = "bridge", + .startup = startup_bridge_irq, + .shutdown = shutdown_bridge_irq, + .enable = enable_bridge_irq, + .disable = disable_bridge_irq, + .ack = mask_and_ack_bridge_irq, + .end = end_bridge_irq, }; void irq_debug(void) @@ -297,7 +425,11 @@ void irq_debug(void) void __init init_IRQ(void) { - int i; + int i, j; + + for (i = 0; i < MAX_COMPACT_NODES; i++) + for (j = 0; j < PERNODE_LEVELS; j++) + node_level_to_irq[i][j] = -1; set_except_vector(0, ip27_irq); @@ -312,177 +444,29 @@ void __init init_IRQ(void) } } -/* - * Get values that vary depending on which CPU and bit we're operating on. - */ -static hub_intmasks_t *intr_get_ptrs(cpuid_t cpu, int bit, int *new_bit, - hubreg_t **intpend_masks, int *ip) +void install_ipi(void) { - hub_intmasks_t *hub_intmasks; - - hub_intmasks = &cpu_data[cpu].p_intmasks; - if (bit < N_INTPEND_BITS) { - *intpend_masks = hub_intmasks->intpend0_masks; - *ip = 0; - *new_bit = bit; - } else { - *intpend_masks = hub_intmasks->intpend1_masks; - *ip = 1; - *new_bit = bit - N_INTPEND_BITS; - } - return hub_intmasks; -} - -int intr_connect_level(int cpu, int bit) -{ - int ip; - int slice = cputoslice(cpu); - volatile hubreg_t *mask_reg; - hubreg_t *intpend_masks; - nasid_t nasid = COMPACT_TO_NASID_NODEID(cputocnode(cpu)); - - (void)intr_get_ptrs(cpu, bit, &bit, &intpend_masks, &ip); - - /* Make sure it's not already pending when we connect it. */ - REMOTE_HUB_CLR_INTR(nasid, bit + ip * N_INTPEND_BITS); - - intpend_masks[0] |= (1ULL << (u64)bit); - - if (ip == 0) { - mask_reg = REMOTE_HUB_ADDR(nasid, PI_INT_MASK0_A + - PI_INT_MASK_OFFSET * slice); + int slice = LOCAL_HUB_L(PI_CPU_NUM); + int cpu = smp_processor_id(); + hubreg_t mask, set; + + if (slice == 0) { + LOCAL_HUB_CLR_INTR(CPU_RESCHED_A_IRQ); + LOCAL_HUB_CLR_INTR(CPU_CALL_A_IRQ); + mask = LOCAL_HUB_L(PI_INT_MASK0_A); /* Slice A */ + set = (1UL << FAST_IRQ_TO_LEVEL(CPU_RESCHED_A_IRQ)) | + (1UL << FAST_IRQ_TO_LEVEL(CPU_CALL_A_IRQ)); + mask |= set; + cpu_data[cpu].p_intmasks.intpend0_masks |= set; + LOCAL_HUB_S(PI_INT_MASK0_A, mask); } else { - mask_reg = REMOTE_HUB_ADDR(nasid, PI_INT_MASK1_A + - PI_INT_MASK_OFFSET * slice); + LOCAL_HUB_CLR_INTR(CPU_RESCHED_B_IRQ); + LOCAL_HUB_CLR_INTR(CPU_CALL_B_IRQ); + mask = LOCAL_HUB_L(PI_INT_MASK0_B); /* Slice B */ + set = (1UL << FAST_IRQ_TO_LEVEL(CPU_RESCHED_B_IRQ)) | + (1UL << FAST_IRQ_TO_LEVEL(CPU_CALL_B_IRQ)); + mask |= set; + cpu_data[cpu].p_intmasks.intpend0_masks |= set; + LOCAL_HUB_S(PI_INT_MASK0_B, mask); } - HUB_S(mask_reg, intpend_masks[0]); - return(0); -} - -int intr_disconnect_level(int cpu, int bit) -{ - int ip; - int slice = cputoslice(cpu); - volatile hubreg_t *mask_reg; - hubreg_t *intpend_masks; - nasid_t nasid = COMPACT_TO_NASID_NODEID(cputocnode(cpu)); - - (void)intr_get_ptrs(cpu, bit, &bit, &intpend_masks, &ip); - intpend_masks[0] &= ~(1ULL << (u64)bit); - if (ip == 0) { - mask_reg = REMOTE_HUB_ADDR(nasid, PI_INT_MASK0_A + - PI_INT_MASK_OFFSET * slice); - } else { - mask_reg = REMOTE_HUB_ADDR(nasid, PI_INT_MASK1_A + - PI_INT_MASK_OFFSET * slice); - } - HUB_S(mask_reg, intpend_masks[0]); - return(0); -} - - -irqreturn_t handle_resched_intr(int irq, void *dev_id, struct pt_regs *regs) -{ - /* Nothing, the return from intr will work for us */ - return IRQ_NONE; -} - -#ifdef CONFIG_SMP - -void core_send_ipi(int destid, unsigned int action) -{ - int irq; - -#if (CPUS_PER_NODE == 2) - switch (action) { - case SMP_RESCHEDULE_YOURSELF: - irq = CPU_RESCHED_A_IRQ; - break; - case SMP_CALL_FUNCTION: - irq = CPU_CALL_A_IRQ; - break; - default: - panic("sendintr"); - } - irq += cputoslice(destid); - - /* - * Convert the compact hub number to the NASID to get the correct - * part of the address space. Then set the interrupt bit associated - * with the CPU we want to send the interrupt to. - */ - REMOTE_HUB_SEND_INTR(COMPACT_TO_NASID_NODEID(cputocnode(destid)), - FAST_IRQ_TO_LEVEL(irq)); -#else - << Bomb! Must redefine this for more than 2 CPUS. >> -#endif -} - -#endif - -extern irqreturn_t smp_call_function_interrupt(int irq, void *dev, - struct pt_regs *regs); - -void install_cpuintr(int cpu) -{ -#ifdef CONFIG_SMP -#if (CPUS_PER_NODE == 2) - static int done = 0; - - /* - * This is a hack till we have a pernode irqlist. Currently, - * just have the master cpu set up the handlers for the per - * cpu irqs. - */ - if (done == 0) { - int j; - - if (request_irq(CPU_RESCHED_A_IRQ, handle_resched_intr, - 0, "resched", 0)) - panic("intercpu intr unconnectible"); - if (request_irq(CPU_RESCHED_B_IRQ, handle_resched_intr, - 0, "resched", 0)) - panic("intercpu intr unconnectible"); - if (request_irq(CPU_CALL_A_IRQ, smp_call_function_interrupt, - 0, "callfunc", 0)) - panic("intercpu intr unconnectible"); - if (request_irq(CPU_CALL_B_IRQ, smp_call_function_interrupt, - 0, "callfunc", 0)) - panic("intercpu intr unconnectible"); - - for (j = 0; j < PERNODE_LEVELS; j++) - LEVEL_TO_IRQ(0, j) = -1; - LEVEL_TO_IRQ(0, FAST_IRQ_TO_LEVEL(CPU_RESCHED_A_IRQ)) = - CPU_RESCHED_A_IRQ; - LEVEL_TO_IRQ(0, FAST_IRQ_TO_LEVEL(CPU_RESCHED_B_IRQ)) = - CPU_RESCHED_B_IRQ; - LEVEL_TO_IRQ(0, FAST_IRQ_TO_LEVEL(CPU_CALL_A_IRQ)) = - CPU_CALL_A_IRQ; - LEVEL_TO_IRQ(0, FAST_IRQ_TO_LEVEL(CPU_CALL_B_IRQ)) = - CPU_CALL_B_IRQ; - for (j = 1; j < MAX_COMPACT_NODES; j++) - memcpy(&node_level_to_irq[j][0], - &node_level_to_irq[0][0], - sizeof(node_level_to_irq[0][0])*PERNODE_LEVELS); - - done = 1; - } - - intr_connect_level(cpu, FAST_IRQ_TO_LEVEL(CPU_RESCHED_A_IRQ + - cputoslice(cpu))); - intr_connect_level(cpu, FAST_IRQ_TO_LEVEL(CPU_CALL_A_IRQ + - cputoslice(cpu))); -#else /* CPUS_PER_NODE */ -#error Must redefine this for more than 2 CPUS. -#endif /* CPUS_PER_NODE */ -#endif /* CONFIG_SMP */ -} - -void install_tlbintr(int cpu) -{ -#if 0 - int intr_bit = N_INTPEND_BITS + TLB_INTR_A + cputoslice(cpu); - - intr_connect_level(cpu, intr_bit); -#endif } --- diff/arch/mips/sgi-ip27/ip27-klnuma.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sgi-ip27/ip27-klnuma.c 2004-02-23 13:56:38.000000000 +0000 @@ -15,8 +15,7 @@ #include #include #include -#include -#include +#include #include #include @@ -34,8 +33,8 @@ void __init setup_replication_mask(int m cnodeid_t cnode; /* Set only the master cnode's bit. The master cnode is always 0. */ - CPUMASK_CLRALL(ktext_repmask); - CPUMASK_SETB(ktext_repmask, 0); + cpus_clear(ktext_repmask); + cpu_set(0, ktext_repmask); numa_kernel_replication_ratio = 0; #ifdef CONFIG_REPLICATE_KTEXT @@ -51,7 +50,7 @@ void __init setup_replication_mask(int m !(cnode % numa_kernel_replication_ratio)) { /* Advertise that we have a copy of the kernel */ - CPUMASK_SETB(ktext_repmask, cnode); + cpu_set(cnode, ktext_repmask); } } @@ -67,12 +66,11 @@ static __init void set_ktext_source(nasi client_cnode = NASID_TO_COMPACT_NODEID(client_nasid); - kvp = &(PLAT_NODE_DATA(client_cnode)->kern_vars); + kvp = &(HUB_DATA(client_nasid)->kern_vars); KERN_VARS_ADDR(client_nasid) = (unsigned long)kvp; kvp->kv_magic = KV_MAGIC; - kvp->kv_ro_nasid = server_nasid; kvp->kv_rw_nasid = master_nasid; kvp->kv_ro_baseaddr = NODE_CAC_BASE(server_nasid); @@ -109,7 +107,7 @@ void __init replicate_kernel_text(int ma client_nasid = COMPACT_TO_NASID_NODEID(cnode); /* Check if this node should get a copy of the kernel */ - if (CPUMASK_TSTB(ktext_repmask, cnode)) { + if (cpu_isset(cnode, ktext_repmask)) { server_nasid = client_nasid; copy_kernel(server_nasid); } @@ -134,7 +132,7 @@ pfn_t node_getfirstfree(cnodeid_t cnode) loadbase = CKSSEG + 16777216; #endif offset = PAGE_ALIGN((unsigned long)(&_end)) - loadbase; - if ((cnode == 0) || (CPUMASK_TSTB(ktext_repmask, cnode))) + if ((cnode == 0) || (cpu_isset(cnode, ktext_repmask))) return (TO_NODE(nasid, offset) >> PAGE_SHIFT); else return (KDM_TO_PHYS(PAGE_ALIGN(SYMMON_STK_ADDR(nasid, 0))) >> --- diff/arch/mips/sgi-ip27/ip27-memory.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sgi-ip27/ip27-memory.c 2004-02-23 13:56:38.000000000 +0000 @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -36,10 +37,10 @@ extern pfn_t node_getfirstfree(cnodeid_t short slot_lastfilled_cache[MAX_COMPACT_NODES]; unsigned short slot_psize_cache[MAX_COMPACT_NODES][MAX_MEM_SLOTS]; -static pfn_t numpages; -plat_pg_data_t *plat_node_data[MAX_COMPACT_NODES]; -bootmem_data_t plat_node_bdata[MAX_COMPACT_NODES]; +struct bootmem_data plat_node_bdata[MAX_COMPACT_NODES]; +struct pglist_data *node_data[MAX_COMPACT_NODES]; +struct hub_data *hub_data[MAX_COMPACT_NODES]; int numa_debug(void) { @@ -52,7 +53,7 @@ int numa_debug(void) * Return the number of pages of memory provided by the given slot * on the specified node. */ -pfn_t slot_getsize(cnodeid_t node, int slot) +static pfn_t slot_getsize(cnodeid_t node, int slot) { return (pfn_t) slot_psize_cache[node][slot]; } @@ -60,7 +61,7 @@ pfn_t slot_getsize(cnodeid_t node, int s /* * Return highest slot filled */ -int node_getlastslot(cnodeid_t node) +static int node_getlastslot(cnodeid_t node) { return (int) slot_lastfilled_cache[node]; } @@ -68,7 +69,7 @@ int node_getlastslot(cnodeid_t node) /* * Return the pfn of the last free page of memory on a node. */ -pfn_t node_getmaxclick(cnodeid_t node) +static pfn_t node_getmaxclick(cnodeid_t node) { pfn_t slot_psize; int slot; @@ -90,7 +91,7 @@ pfn_t node_getmaxclick(cnodeid_t node) * If there's no memory on the node, return 0. This is likely * to cause problems. */ - return (pfn_t)0; + return 0; } static pfn_t slot_psize_compute(cnodeid_t node, int slot) @@ -107,7 +108,7 @@ static pfn_t slot_psize_compute(cnodeid_ return 0; /* Get the memory bank structure */ - banks = (klmembnk_t *)find_first_component(brd, KLSTRUCT_MEMBNK); + banks = (klmembnk_t *) find_first_component(brd, KLSTRUCT_MEMBNK); if (!banks) return 0; @@ -116,20 +117,19 @@ static pfn_t slot_psize_compute(cnodeid_ /* hack for 128 dimm banks */ if (size <= 128) { - if (slot%4 == 0) { + if (slot % 4 == 0) { size <<= 20; /* size in bytes */ return(size >> PAGE_SHIFT); - } else { + } else return 0; - } } else { size /= 4; size <<= 20; - return(size >> PAGE_SHIFT); + return size >> PAGE_SHIFT; } } -pfn_t szmem(pfn_t fpage, pfn_t maxpmem) +static pfn_t szmem(void) { cnodeid_t node; int slot, numslots; @@ -165,10 +165,8 @@ pfn_t szmem(pfn_t fpage, pfn_t maxpmem) slot_lastfilled_cache[node] = slot; } } - if (maxpmem) - return((maxpmem > num_pages) ? num_pages : maxpmem); - else - return num_pages; + + return num_pages; } /* @@ -176,32 +174,32 @@ pfn_t szmem(pfn_t fpage, pfn_t maxpmem) * contains at least 32 MBytes of memory. We assume all bootmem data * fits on the first slot. */ +extern void mlreset(void); void __init prom_meminit(void) { - extern void mlreset(void); cnodeid_t node; - pfn_t slot_firstpfn, slot_lastpfn, slot_freepfn; - unsigned long bootmap_size; - int node_datasz; - node_datasz = PFN_UP(sizeof(plat_pg_data_t)); mlreset(); - numpages = szmem(0, 0); - for (node = (numnodes - 1); node >= 0; node--) { - slot_firstpfn = slot_getbasepfn(node, 0); - slot_lastpfn = slot_firstpfn + slot_getsize(node, 0); - slot_freepfn = node_getfirstfree(node); - /* Foll line hack for non discontigmem; remove once discontigmem - * becomes the default. */ - max_low_pfn = (slot_lastpfn - slot_firstpfn); + + num_physpages = szmem(); + + for (node = 0; node < numnodes; node++) { + pfn_t slot_firstpfn = slot_getbasepfn(node, 0); + pfn_t slot_lastpfn = slot_firstpfn + slot_getsize(node, 0); + pfn_t slot_freepfn = node_getfirstfree(node); + unsigned long bootmap_size; /* - * Allocate the node data structure on the node first. + * Allocate the node data structures on the node first. */ - plat_node_data[node] = (plat_pg_data_t *)(__va(slot_freepfn \ - << PAGE_SHIFT)); - NODE_DATA(node)->bdata = plat_node_bdata + node; - slot_freepfn += node_datasz; + node_data[node] = __va(slot_freepfn << PAGE_SHIFT); + node_data[node]->bdata = &plat_node_bdata[node]; + + hub_data[node] = node_data[node] + 1; + + slot_freepfn += PFN_UP(sizeof(struct pglist_data) + + sizeof(struct hub_data)); + bootmap_size = init_bootmem_node(NODE_DATA(node), slot_freepfn, slot_firstpfn, slot_lastpfn); free_bootmem_node(NODE_DATA(node), slot_firstpfn << PAGE_SHIFT, @@ -209,123 +207,90 @@ void __init prom_meminit(void) reserve_bootmem_node(NODE_DATA(node), slot_firstpfn << PAGE_SHIFT, ((slot_freepfn - slot_firstpfn) << PAGE_SHIFT) + bootmap_size); } - printk("Total memory probed : 0x%lx pages\n", numpages); } -void __init -prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { /* We got nothing to free here ... */ + return 0; } -#ifdef CONFIG_DISCONTIGMEM - -static pfn_t pagenr; +extern void pagetable_init(void); +extern unsigned long setup_zero_pages(void); void __init paging_init(void) { - pmd_t *pmd = kpmdtbl; - pte_t *pte = kptbl; - - cnodeid_t node; unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0}; - int i; + unsigned node; - /* Initialize the entire pgd. */ - pgd_init((unsigned long)swapper_pg_dir); - pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table); - memset((void *)invalid_pte_table, 0, sizeof(pte_t) * PTRS_PER_PTE); - - /* This is for vmalloc */ - memset((void *)kptbl, 0, PAGE_SIZE << PGD_ORDER); - memset((void *)kpmdtbl, 0, PAGE_SIZE); - set_pgd(swapper_pg_dir, __pgd(kpmdtbl)); - for (i = 0; i < (1 << PGD_ORDER); pmd++,i++,pte+=PTRS_PER_PTE) - pmd_val(*pmd) = (unsigned long)pte; + pagetable_init(); for (node = 0; node < numnodes; node++) { pfn_t start_pfn = slot_getbasepfn(node, 0); - pfn_t end_pfn = node_getmaxclick(node); + pfn_t end_pfn = node_getmaxclick(node) + 1; + + zones_size[ZONE_DMA] = end_pfn - start_pfn; + free_area_init_node(node, NODE_DATA(node), NULL, + zones_size, start_pfn, NULL); - zones_size[ZONE_DMA] = end_pfn + 1 - start_pfn; - free_area_init_node(node, NODE_DATA(node), 0, zones_size, - start_pfn, 0); + if (end_pfn > max_low_pfn) + max_low_pfn = end_pfn; } } void __init mem_init(void) { - extern unsigned long setup_zero_pages(void); - cnodeid_t nid; - unsigned long tmp; - unsigned long codesize, datasize, initsize; - int slot, numslots; - struct page *pg, *pslot; - - num_physpages = numpages; /* memory already sized by szmem */ - max_mapnr = pagenr; /* already found during paging_init */ - high_memory = (void *) __va(max_mapnr << PAGE_SHIFT); + unsigned long codesize, datasize, initsize, tmp; + unsigned node; - for (nid = 0; nid < numnodes; nid++) { + high_memory = (void *) __va(num_physpages << PAGE_SHIFT); - /* - * Hack till free_area_init_core() zeroes free_pages - */ - for (tmp = 0; tmp < MAX_NR_ZONES; tmp++) - PLAT_NODE_DATA(nid)->gendata.node_zones[tmp].free_pages=0; + for (node = 0; node < numnodes; node++) { + unsigned slot, numslots; + struct page *end, *p; + /* * This will free up the bootmem, ie, slot 0 memory. */ - totalram_pages += free_all_bootmem_node(NODE_DATA(nid)); + totalram_pages += free_all_bootmem_node(NODE_DATA(node)); /* * We need to manually do the other slots. */ - pg = NODE_DATA(nid)->node_mem_map + slot_getsize(nid, 0); - numslots = node_getlastslot(nid); + numslots = node_getlastslot(node); for (slot = 1; slot <= numslots; slot++) { - pslot = NODE_DATA(nid)->node_mem_map + - slot_getbasepfn(nid, slot) - slot_getbasepfn(nid, 0); - - /* - * Mark holes in previous slot. May also want to - * free up the pages that hold the memmap entries. - */ - while (pg < pslot) { - pg++; - } + p = NODE_DATA(node)->node_mem_map + + (slot_getbasepfn(node, slot) - + slot_getbasepfn(node, 0)); /* * Free valid memory in current slot. */ - pslot += slot_getsize(nid, slot); - while (pg < pslot) { + for (end = p + slot_getsize(node, slot); p < end; p++) { /* if (!page_is_ram(pgnr)) continue; */ /* commented out until page_is_ram works */ - ClearPageReserved(pg); - atomic_set(&pg->count, 1); - __free_page(pg); + ClearPageReserved(p); + set_page_count(p, 1); + __free_page(p); totalram_pages++; - pg++; pgnr++; } } } totalram_pages -= setup_zero_pages(); /* This comes from node 0 */ - codesize = (unsigned long) _etext - (unsigned long) _stext; - datasize = (unsigned long) _edata - (unsigned long) _fdata; - initsize = (unsigned long) __init_end - (unsigned long) __init_begin; - - tmp = (unsigned long) nr_free_pages(); - printk("Memory: %luk/%luk available (%ldk kernel code, %ldk reserved, " - "%ldk data, %ldk init)\n", - tmp << (PAGE_SHIFT-10), - num_physpages << (PAGE_SHIFT-10), - codesize >> 10, - (num_physpages - tmp) << (PAGE_SHIFT-10), - datasize >> 10, - initsize >> 10); + codesize = (unsigned long) &_etext - (unsigned long) &_text; + datasize = (unsigned long) &_edata - (unsigned long) &_etext; + initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin; + + tmp = nr_free_pages(); + printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, " + "%ldk reserved, %ldk data, %ldk init, %ldk highmem)\n", + tmp << (PAGE_SHIFT-10), + num_physpages << (PAGE_SHIFT-10), + codesize >> 10, + (num_physpages - tmp) << (PAGE_SHIFT-10), + datasize >> 10, + initsize >> 10, + (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10))); } - -#endif /* CONFIG_DISCONTIGMEM */ --- diff/arch/mips/sgi-ip27/ip27-nmi.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sgi-ip27/ip27-nmi.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,3 +1,4 @@ +#include #include #include #include @@ -51,24 +52,102 @@ void install_cpu_nmi_handler(int slice) * into the eframe format for the node under consideration. */ -void -nmi_cpu_eframe_save(nasid_t nasid, - int slice) +void nmi_cpu_eframe_save(nasid_t nasid, int slice) { - int i, numberof_nmi_cpu_regs; - machreg_t *prom_format; - - /* Get the total number of registers being saved by the prom */ - numberof_nmi_cpu_regs = sizeof(struct reg_struct) / sizeof(machreg_t); + struct reg_struct *nr; + int i; /* Get the pointer to the current cpu's register set. */ - prom_format = - (machreg_t *)(TO_UNCAC(TO_NODE(nasid, IP27_NMI_KREGS_OFFSET)) + - slice * IP27_NMI_KREGS_CPU_SIZE); + nr = (struct reg_struct *) + (TO_UNCAC(TO_NODE(nasid, IP27_NMI_KREGS_OFFSET)) + + slice * IP27_NMI_KREGS_CPU_SIZE); printk("NMI nasid %d: slice %d\n", nasid, slice); - for (i = 0; i < numberof_nmi_cpu_regs; i++) - printk("0x%lx ", prom_format[i]); + + /* + * Saved main processor registers + */ + for (i = 0; i < 32; ) { + if ((i % 4) == 0) + printk("$%2d :", i); + printk(" %016lx", nr->gpr[i]); + + i++; + if ((i % 4) == 0) + printk("\n"); + } + + printk("Hi : (value lost)\n"); + printk("Lo : (value lost)\n"); + + /* + * Saved cp0 registers + */ + printk("epc : %016lx ", nr->epc); + print_symbol("%s ", nr->epc); + printk("%s\n", print_tainted()); + printk("ErrEPC: %016lx ", nr->error_epc); + print_symbol("%s\n", nr->error_epc); + printk("ra : %016lx ", nr->gpr[31]); + print_symbol("%s\n", nr->gpr[31]); + printk("Status: %08lx ", nr->sr); + + if (nr->sr & ST0_KX) + printk("KX "); + if (nr->sr & ST0_SX) + printk("SX "); + if (nr->sr & ST0_UX) + printk("UX "); + + switch (nr->sr & ST0_KSU) { + case KSU_USER: + printk("USER "); + break; + case KSU_SUPERVISOR: + printk("SUPERVISOR "); + break; + case KSU_KERNEL: + printk("KERNEL "); + break; + default: + printk("BAD_MODE "); + break; + } + + if (nr->sr & ST0_ERL) + printk("ERL "); + if (nr->sr & ST0_EXL) + printk("EXL "); + if (nr->sr & ST0_IE) + printk("IE "); + printk("\n"); + + printk("Cause : %08lx\n", nr->cause); + printk("PrId : %08x\n", read_c0_prid()); + printk("BadVA : %016lx\n", nr->badva); + printk("CErr : %016lx\n", nr->cache_err); + printk("NMI_SR: %016lx\n", nr->nmi_sr); + + printk("\n"); +} + +void nmi_dump_hub_irq(nasid_t nasid, int slice) +{ + hubreg_t mask0, mask1, pend0, pend1; + + if (slice == 0) { /* Slice A */ + mask0 = REMOTE_HUB_L(nasid, PI_INT_MASK0_A); + mask1 = REMOTE_HUB_L(nasid, PI_INT_MASK1_A); + } else { /* Slice B */ + mask0 = REMOTE_HUB_L(nasid, PI_INT_MASK0_B); + mask1 = REMOTE_HUB_L(nasid, PI_INT_MASK1_B); + } + + pend0 = REMOTE_HUB_L(nasid, PI_INT_PEND0); + pend1 = REMOTE_HUB_L(nasid, PI_INT_PEND1); + + printk("PI_INT_MASK0: %16lx PI_INT_MASK1: %16lx\n", mask0, mask1); + printk("PI_INT_PEND0: %16lx PI_INT_PEND1: %16lx\n", pend0, pend1); printk("\n\n"); } @@ -76,11 +155,10 @@ nmi_cpu_eframe_save(nasid_t nasid, * Copy the cpu registers which have been saved in the IP27prom format * into the eframe format for the node under consideration. */ -void -nmi_node_eframe_save(cnodeid_t cnode) +void nmi_node_eframe_save(cnodeid_t cnode) { - int cpu; - nasid_t nasid; + nasid_t nasid; + int slice; /* Make sure that we have a valid node */ if (cnode == CNODEID_NONE) @@ -91,8 +169,10 @@ nmi_node_eframe_save(cnodeid_t cnode) return; /* Save the registers into eframe for each cpu */ - for(cpu = 0; cpu < NODE_NUM_CPUS(cnode); cpu++) - nmi_cpu_eframe_save(nasid, cpu); + for (slice = 0; slice < NODE_NUM_CPUS(slice); slice++) { + nmi_cpu_eframe_save(nasid, slice); + nmi_dump_hub_irq(nasid, slice); + } } /* --- diff/arch/mips/sgi-ip27/ip27-setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sgi-ip27/ip27-setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -105,22 +105,99 @@ static void __init verify_mode(void) } #define XBOW_WIDGET_PART_NUM 0x0 -#define XXBOW_WIDGET_PART_NUM 0xd000 /* Xbridge */ +#define XXBOW_WIDGET_PART_NUM 0xd000 /* Xbow in Xbridge */ #define BASE_XBOW_PORT 8 /* Lowest external port */ -unsigned int bus_to_cpu[256]; -unsigned long bus_to_baddr[256]; +extern int bridge_probe(nasid_t nasid, int widget, int masterwid); + +static int __init probe_one_port(nasid_t nasid, int widget, int masterwid) +{ + widgetreg_t widget_id; + xwidget_part_num_t partnum; + + widget_id = *(volatile widgetreg_t *) + (RAW_NODE_SWIN_BASE(nasid, widget) + WIDGET_ID); + partnum = XWIDGET_PART_NUM(widget_id); + + printk(KERN_INFO "Cpu %d, Nasid 0x%x, widget 0x%x (partnum 0x%x) is ", + smp_processor_id(), nasid, widget, partnum); + + switch (partnum) { + case BRIDGE_WIDGET_PART_NUM: + case XBRIDGE_WIDGET_PART_NUM: + bridge_probe(nasid, widget, masterwid); + break; + default: + break; + } + + return 0; +} + +static int __init xbow_probe(nasid_t nasid) +{ + lboard_t *brd; + klxbow_t *xbow_p; + unsigned masterwid, i; + + printk("is xbow\n"); + + /* + * found xbow, so may have multiple bridges + * need to probe xbow + */ + brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_MIDPLANE8); + if (!brd) + return -ENODEV; + + xbow_p = (klxbow_t *)find_component(brd, NULL, KLSTRUCT_XBOW); + if (!xbow_p) + return -ENODEV; + + /* + * Okay, here's a xbow. Lets arbitrate and find + * out if we should initialize it. Set enabled + * hub connected at highest or lowest widget as + * master. + */ +#ifdef WIDGET_A + i = HUB_WIDGET_ID_MAX + 1; + do { + i--; + } while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) || + (!XBOW_PORT_IS_ENABLED(xbow_p, i))); +#else + i = HUB_WIDGET_ID_MIN - 1; + do { + i++; + } while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) || + (!XBOW_PORT_IS_ENABLED(xbow_p, i))); +#endif + + masterwid = i; + if (nasid != XBOW_PORT_NASID(xbow_p, i)) + return 1; + + for (i = HUB_WIDGET_ID_MIN; i <= HUB_WIDGET_ID_MAX; i++) { + if (XBOW_PORT_IS_ENABLED(xbow_p, i) && + XBOW_PORT_TYPE_IO(xbow_p, i)) + probe_one_port(nasid, i, masterwid); + } + + return 0; +} + +static spinlock_t pcibr_setup_lock = SPIN_LOCK_UNLOCKED; void __init pcibr_setup(cnodeid_t nid) { - int i, start, num; - unsigned long masterwid; - bridge_t *bridge; volatile u64 hubreg; - nasid_t nasid, masternasid; + nasid_t nasid; xwidget_part_num_t partnum; widgetreg_t widget_id; - static spinlock_t pcibr_setup_lock = SPIN_LOCK_UNLOCKED; + + + spin_lock(&pcibr_setup_lock); /* * If the master is doing this for headless node, nothing to do. @@ -132,164 +209,66 @@ void __init pcibr_setup(cnodeid_t nid) * is selectable by WIDGET_A below. */ if (nid != get_compact_nodeid()) - return; - /* - * find what's on our local node - */ - spin_lock(&pcibr_setup_lock); - start = num_bridges; /* Remember where we start from */ + goto out; + + /* find what's on our local node */ nasid = COMPACT_TO_NASID_NODEID(nid); hubreg = REMOTE_HUB_L(nasid, IIO_LLP_CSR); - if (hubreg & IIO_LLP_CSR_IS_UP) { - /* link is up */ - widget_id = *(volatile widgetreg_t *) - (RAW_NODE_SWIN_BASE(nasid, 0x0) + WIDGET_ID); - partnum = XWIDGET_PART_NUM(widget_id); - printk("Cpu %d, Nasid 0x%x, pcibr_setup(): found partnum= 0x%x", - smp_processor_id(), nasid, partnum); - if (partnum == BRIDGE_WIDGET_PART_NUM) { - /* - * found direct connected bridge so must be Origin200 - */ - printk("...is bridge\n"); - num_bridges = 1; - bus_to_wid[0] = 0x8; - bus_to_nid[0] = 0; - masterwid = 0xa; - bus_to_baddr[0] = 0xa100000000000000UL; - } else if (partnum == XBOW_WIDGET_PART_NUM) { - lboard_t *brd; - klxbow_t *xbow_p; - /* - * found xbow, so may have multiple bridges - * need to probe xbow - */ - printk("...is xbow\n"); - - if ((brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), - KLTYPE_MIDPLANE8)) == NULL) - printk("argh\n"); - else - printk("brd = 0x%lx\n", (unsigned long) brd); - if ((xbow_p = (klxbow_t *) - find_component(brd, NULL, KLSTRUCT_XBOW)) == NULL) - printk("argh\n"); - else { - /* - * Okay, here's a xbow. Lets arbitrate and find - * out if we should initialize it. Set enabled - * hub connected at highest or lowest widget as - * master. - */ -#ifdef WIDGET_A - i = HUB_WIDGET_ID_MAX + 1; - do { - i--; - } while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) || - (!XBOW_PORT_IS_ENABLED(xbow_p, i))); -#else - i = HUB_WIDGET_ID_MIN - 1; - do { - i++; - } while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) || - (!XBOW_PORT_IS_ENABLED(xbow_p, i))); -#endif - masterwid = i; - masternasid = XBOW_PORT_NASID(xbow_p, i); - if (nasid == masternasid) - for (i=HUB_WIDGET_ID_MIN; i<=HUB_WIDGET_ID_MAX; i++) { - if (!XBOW_PORT_IS_ENABLED(xbow_p, i)) - continue; - if (XBOW_PORT_TYPE_IO(xbow_p, i)) { - widget_id = *(volatile widgetreg_t *) - (RAW_NODE_SWIN_BASE(nasid, i) + WIDGET_ID); - partnum = XWIDGET_PART_NUM(widget_id); - if (partnum == BRIDGE_WIDGET_PART_NUM) { - printk("widget 0x%x is a bridge\n", i); - bus_to_wid[num_bridges] = i; - bus_to_nid[num_bridges] = nasid; - bus_to_baddr[num_bridges] = ((masterwid << 60) | (1UL << 56)); /* Barrier set */ - num_bridges++; - } - } - } - } - } else if (partnum == XXBOW_WIDGET_PART_NUM) { - /* - * found xbridge, assume ibrick for now - */ - printk("...is xbridge\n"); - bus_to_wid[0] = 0xb; - bus_to_wid[1] = 0xe; - bus_to_wid[2] = 0xf; - - bus_to_nid[0] = 0; - bus_to_nid[1] = 0; - bus_to_nid[2] = 0; - - bus_to_baddr[0] = 0xa100000000000000UL; - bus_to_baddr[1] = 0xa100000000000000UL; - bus_to_baddr[2] = 0xa100000000000000UL; - masterwid = 0xa; - num_bridges = 3; - } - } - num = num_bridges - start; - spin_unlock(&pcibr_setup_lock); - /* - * set bridge registers - */ - for (i = start; i < (start + num); i++) { - - DBG("pcibr_setup: bus= %d bus_to_wid[%2d]= %d bus_to_nid[%2d]= %d\n", - i, i, bus_to_wid[i], i, bus_to_nid[i]); - - bus_to_cpu[i] = smp_processor_id(); - /* - * point to this bridge - */ - bridge = (bridge_t *) NODE_SWIN_BASE(bus_to_nid[i],bus_to_wid[i]); - /* - * Clear all pending interrupts. - */ - bridge->b_int_rst_stat = (BRIDGE_IRR_ALL_CLR); - /* - * Until otherwise set up, assume all interrupts are from slot 0 - */ - bridge->b_int_device = (u32) 0x0; - /* - * swap pio's to pci mem and io space (big windows) - */ - bridge->b_wid_control |= BRIDGE_CTRL_IO_SWAP; - bridge->b_wid_control |= BRIDGE_CTRL_MEM_SWAP; - - /* - * Hmm... IRIX sets additional bits in the address which - * are documented as reserved in the bridge docs. - */ - bridge->b_int_mode = 0x0; /* Don't clear ints */ - bridge->b_wid_int_upper = 0x8000 | (masterwid << 16); - bridge->b_wid_int_lower = 0x01800090; /* PI_INT_PEND_MOD off*/ - bridge->b_dir_map = (masterwid << 20); /* DMA */ - bridge->b_int_enable = 0; - bridge->b_wid_tflush; /* wait until Bridge PIO complete */ + /* check whether the link is up */ + if (!(hubreg & IIO_LLP_CSR_IS_UP)) + goto out; + + widget_id = *(volatile widgetreg_t *) + (RAW_NODE_SWIN_BASE(nasid, 0x0) + WIDGET_ID); + partnum = XWIDGET_PART_NUM(widget_id); + + printk(KERN_INFO "Cpu %d, Nasid 0x%x: partnum 0x%x is ", + smp_processor_id(), nasid, partnum); + + switch (partnum) { + case BRIDGE_WIDGET_PART_NUM: + bridge_probe(nasid, 0x8, 0xa); + break; + case XBOW_WIDGET_PART_NUM: + case XXBOW_WIDGET_PART_NUM: + xbow_probe(nasid); + break; + default: + printk(" unknown widget??\n"); + break; } + + out: + spin_unlock(&pcibr_setup_lock); } extern void ip27_setup_console(void); extern void ip27_time_init(void); extern void ip27_reboot_setup(void); -void __init ip27_setup(void) +void __init per_cpu_init(void) +{ + cnodeid_t cnode = get_compact_nodeid(); + int cpu = smp_processor_id(); + + clear_c0_status(ST0_IM); + per_hub_init(cnode); + cpu_time_init(); + install_ipi(); + /* Install our NMI handler if symmon hasn't installed one. */ + install_cpu_nmi_handler(cputoslice(cpu)); + set_c0_status(SRB_DEV0 | SRB_DEV1); +} + +static int __init ip27_setup(void) { - nasid_t nid; hubreg_t p, e; + nasid_t nid; ip27_setup_console(); ip27_reboot_setup(); - num_bridges = 0; /* * hub_rtc init and cpu clock intr enabled for later calibrate_delay. */ @@ -314,6 +293,11 @@ void __init ip27_setup(void) ioc3_eth_init(); per_cpu_init(); - mips_io_port_base = IO_BASE; + set_io_port_base(IO_BASE); + board_time_init = ip27_time_init; + + return 0; } + +early_initcall(ip27_setup); --- diff/arch/mips/sgi-ip27/ip27-timer.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sgi-ip27/ip27-timer.c 2004-02-23 13:56:38.000000000 +0000 @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -90,10 +89,10 @@ static int set_rtc_mmss(unsigned long no return retval; } -void rt_timer_interrupt(struct pt_regs *regs) +void ip27_rt_timer_interrupt(struct pt_regs *regs) { int cpu = smp_processor_id(); - int cpuA = ((cputoslice(cpu)) == 0); + int cpuA = cputoslice(cpu) == 0; int irq = 9; /* XXX Assign number */ irq_enter(); @@ -182,12 +181,23 @@ static __init unsigned long get_m48t35_t return mktime(year, month, date, hour, min, sec); } +static void ip27_timer_setup(struct irqaction *irq) +{ + /* over-write the handler, we use our own way */ + irq->handler = no_action; + + /* setup irqaction */ +// setup_irq(IP27_TIMER_IRQ, irq); /* XXX Can't do this yet. */ +} + void __init ip27_time_init(void) { xtime.tv_sec = get_m48t35_time(); xtime.tv_nsec = 0; do_gettimeoffset = ip27_do_gettimeoffset; + + board_timer_setup = ip27_timer_setup; } void __init cpu_time_init(void) --- diff/arch/mips/sgi-ip32/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sgi-ip32/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -3,7 +3,7 @@ # under Linux. # -obj-y += ip32-berr.o ip32-rtc.o ip32-setup.o ip32-irq.o ip32-irq-glue.o \ - ip32-timer.o crime.o ip32-reset.o +obj-y += ip32-berr.o ip32-irq.o ip32-irq-glue.o ip32-setup.o ip32-timer.o \ + crime.o ip32-reset.o EXTRA_AFLAGS := $(CFLAGS) --- diff/arch/mips/sgi-ip32/crime.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sgi-ip32/crime.c 2004-02-23 13:56:38.000000000 +0000 @@ -5,92 +5,101 @@ * * Copyright (C) 2001, 2003 Keith M Wesolowski */ -#include -#include -#include -#include -#include #include #include #include #include +#include +#include +#include +#include +#include +#include + +void *sgi_crime; +struct sgi_mace *mace; -void __init crime_init (void) +void __init crime_init(void) { - u64 id = crime_read_64 (CRIME_ID); - u64 rev = id & CRIME_ID_REV; + unsigned int id, rev; + const int field = 2 * sizeof(unsigned long); + + sgi_crime = ioremap(CRIME_BASE, 1); + mace = ioremap(MACE_BASE, sizeof(struct sgi_mace)); + id = crime_read(CRIME_ID); + rev = id & CRIME_ID_REV; id = (id & CRIME_ID_IDBITS) >> 4; - printk ("CRIME id %1lx rev %ld detected at 0x%016lx\n", id, rev, - (unsigned long) CRIME_BASE); + printk (KERN_INFO "CRIME id %1x rev %d at 0x%0*lx\n", + id, rev, field, (unsigned long) CRIME_BASE); } -irqreturn_t crime_memerr_intr (unsigned int irq, void *dev_id, struct pt_regs *regs) +irqreturn_t +crime_memerr_intr (unsigned int irq, void *dev_id, struct pt_regs *regs) { - u64 memerr = crime_read_64 (CRIME_MEM_ERROR_STAT); - u64 addr = crime_read_64 (CRIME_MEM_ERROR_ADDR); + unsigned long stat, addr; int fatal = 0; - memerr &= CRIME_MEM_ERROR_STAT_MASK; - addr &= CRIME_MEM_ERROR_ADDR_MASK; + stat = crime_read(CRIME_MEM_ERROR_STAT) & CRIME_MEM_ERROR_STAT_MASK; + addr = crime_read(CRIME_MEM_ERROR_ADDR) & CRIME_MEM_ERROR_ADDR_MASK; - printk("CRIME memory error at 0x%08lx ST 0x%08lx<", addr, memerr); + printk("CRIME memory error at 0x%08lx ST 0x%08lx<", addr, stat); - if (memerr & CRIME_MEM_ERROR_INV) + if (stat & CRIME_MEM_ERROR_INV) printk("INV,"); - if (memerr & CRIME_MEM_ERROR_ECC) { - u64 ecc_syn = crime_read_64(CRIME_MEM_ERROR_ECC_SYN); - u64 ecc_gen = crime_read_64(CRIME_MEM_ERROR_ECC_CHK); - - ecc_syn &= CRIME_MEM_ERROR_ECC_SYN_MASK; - ecc_gen &= CRIME_MEM_ERROR_ECC_CHK_MASK; + if (stat & CRIME_MEM_ERROR_ECC) { + unsigned long ecc_syn = crime_read(CRIME_MEM_ERROR_ECC_SYN) & + CRIME_MEM_ERROR_ECC_SYN_MASK; + unsigned long ecc_gen = crime_read(CRIME_MEM_ERROR_ECC_CHK) & + CRIME_MEM_ERROR_ECC_CHK_MASK; printk("ECC,SYN=0x%08lx,GEN=0x%08lx,", ecc_syn, ecc_gen); } - if (memerr & CRIME_MEM_ERROR_MULTIPLE) { + if (stat & CRIME_MEM_ERROR_MULTIPLE) { fatal = 1; printk("MULTIPLE,"); } - if (memerr & CRIME_MEM_ERROR_HARD_ERR) { + if (stat & CRIME_MEM_ERROR_HARD_ERR) { fatal = 1; printk("HARD,"); } - if (memerr & CRIME_MEM_ERROR_SOFT_ERR) + if (stat & CRIME_MEM_ERROR_SOFT_ERR) printk("SOFT,"); - if (memerr & CRIME_MEM_ERROR_CPU_ACCESS) + if (stat & CRIME_MEM_ERROR_CPU_ACCESS) printk("CPU,"); - if (memerr & CRIME_MEM_ERROR_VICE_ACCESS) + if (stat & CRIME_MEM_ERROR_VICE_ACCESS) printk("VICE,"); - if (memerr & CRIME_MEM_ERROR_GBE_ACCESS) + if (stat & CRIME_MEM_ERROR_GBE_ACCESS) printk("GBE,"); - if (memerr & CRIME_MEM_ERROR_RE_ACCESS) - printk("RE,REID=0x%02lx,", (memerr & CRIME_MEM_ERROR_RE_ID)>>8); - if (memerr & CRIME_MEM_ERROR_MACE_ACCESS) - printk("MACE,MACEID=0x%02lx,", memerr & CRIME_MEM_ERROR_MACE_ID); + if (stat & CRIME_MEM_ERROR_RE_ACCESS) + printk("RE,REID=0x%02lx,", (stat & CRIME_MEM_ERROR_RE_ID)>>8); + if (stat & CRIME_MEM_ERROR_MACE_ACCESS) + printk("MACE,MACEID=0x%02lx,", stat & CRIME_MEM_ERROR_MACE_ID); - crime_write_64 (CRIME_MEM_ERROR_STAT, 0); + crime_write(0, CRIME_MEM_ERROR_STAT); if (fatal) { printk("FATAL>\n"); - panic("Fatal memory error detected, halting\n"); - } else { + panic("Fatal memory error."); + } else printk("NONFATAL>\n"); - } return IRQ_HANDLED; } -irqreturn_t crime_cpuerr_intr (unsigned int irq, void *dev_id, struct pt_regs *regs) +irqreturn_t +crime_cpuerr_intr (unsigned int irq, void *dev_id, struct pt_regs *regs) { - u64 cpuerr = crime_read_64 (CRIME_CPU_ERROR_STAT); - u64 addr = crime_read_64 (CRIME_CPU_ERROR_ADDR); - cpuerr &= CRIME_CPU_ERROR_MASK; - addr <<= 2UL; + unsigned long stat = crime_read(CRIME_CPU_ERROR_STAT) & + CRIME_CPU_ERROR_MASK; + uint64_t addr = crime_read(CRIME_CPU_ERROR_ADDR) & + CRIME_CPU_ERROR_ADDR_MASK; + addr <<= 2; + + printk ("CRIME CPU error at 0x%09lx status 0x%08lx\n", addr, stat); - printk ("CRIME CPU error detected at 0x%09lx status 0x%08lx\n", - addr, cpuerr); + crime_write(0, CRIME_CPU_ERROR_STAT); - crime_write_64 (CRIME_CPU_ERROR_STAT, 0); return IRQ_HANDLED; } --- diff/arch/mips/sgi-ip32/ip32-irq-glue.S 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sgi-ip32/ip32-irq-glue.S 2004-02-23 13:56:38.000000000 +0000 @@ -13,7 +13,6 @@ #include #include #include -#include .text .set noreorder --- diff/arch/mips/sgi-ip32/ip32-irq.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sgi-ip32/ip32-irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -22,15 +22,18 @@ #include #include +#include #include -#include #include #include -#include +#include /* issue a PIO read to make sure no PIO writes are pending */ -#define flush_crime_bus() crime_read_64(CRIME_CONTROL); -#define flush_mace_bus() mace_read_64(MACEISA_FLASH_NIC_REG); +#define flush_crime_bus() crime_read(CRIME_CONTROL); +static void inline flush_mace_bus(void) +{ + volatile unsigned long junk = mace_perif_ctrl_read(misc); +} #undef DEBUG_IRQ #ifdef DEBUG_IRQ @@ -54,16 +57,16 @@ * * CRIME_INT_STAT 31:0: * - * 0 -> 1 Video in 1 - * 1 -> 2 Video in 2 - * 2 -> 3 Video out - * 3 -> 4 Mace ethernet - * 4 -> S SuperIO sub-interrupt - * 5 -> M Miscellaneous sub-interrupt - * 6 -> A Audio sub-interrupt - * 7 -> 8 PCI bridge errors - * 8 -> 9 PCI SCSI aic7xxx 0 - * 9 -> 10 PCI SCSI aic7xxx 1 + * 0 -> 1 Video in 1 + * 1 -> 2 Video in 2 + * 2 -> 3 Video out + * 3 -> 4 Mace ethernet + * 4 -> S SuperIO sub-interrupt + * 5 -> M Miscellaneous sub-interrupt + * 6 -> A Audio sub-interrupt + * 7 -> 8 PCI bridge errors + * 8 -> 9 PCI SCSI aic7xxx 0 + * 9 -> 10 PCI SCSI aic7xxx 1 * 10 -> 11 PCI slot 0 * 11 -> 12 unused (PCI slot 1) * 12 -> 13 unused (PCI slot 2) @@ -82,9 +85,9 @@ * 25 -> 26 RE empty level * 26 -> 27 RE full level * 27 -> 28 RE idle level - * 28 -> 29 unused (software 0) (E) - * 29 -> 30 unused (software 1) (E) - * 30 -> 31 unused (software 2) - crime 1.5 CPU SysCorError (E) + * 28 -> 29 unused (software 0) (E) + * 29 -> 30 unused (software 1) (E) + * 30 -> 31 unused (software 2) - crime 1.5 CPU SysCorError (E) * 31 -> 32 VICE * * S, M, A: Use the MACE ISA interrupt register @@ -106,20 +109,24 @@ * is quite different anyway. */ +/* + * IRQ spinlock - Ralf says not to disable CPU interrupts, + * and I think he knows better. + */ +static spinlock_t ip32_irq_lock = SPIN_LOCK_UNLOCKED; + /* Some initial interrupts to set up */ extern irqreturn_t crime_memerr_intr (int irq, void *dev_id, - struct pt_regs *regs); + struct pt_regs *regs); extern irqreturn_t crime_cpuerr_intr (int irq, void *dev_id, - struct pt_regs *regs); + struct pt_regs *regs); struct irqaction memerr_irq = { crime_memerr_intr, SA_INTERRUPT, - 0, "CRIME memory error", NULL, - NULL }; + 0, "CRIME memory error", NULL, NULL }; struct irqaction cpuerr_irq = { crime_cpuerr_intr, SA_INTERRUPT, - 0, "CRIME CPU error", NULL, - NULL }; + 0, "CRIME CPU error", NULL, NULL }; -extern void ip32_handle_int (void); +extern void ip32_handle_int(void); /* * For interrupts wired from a single device to the CPU. Only the clock @@ -144,7 +151,7 @@ static void disable_cpu_irq(unsigned int static void end_cpu_irq(unsigned int irq) { - if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) enable_cpu_irq (irq); } @@ -167,21 +174,20 @@ static struct hw_interrupt_type ip32_cpu * We get to split the register in half and do faster lookups. */ -static u64 crime_mask=0; +static uint64_t crime_mask; static void enable_crime_irq(unsigned int irq) { unsigned long flags; - local_irq_save(flags); + spin_lock_irqsave(&ip32_irq_lock, flags); crime_mask |= 1 << (irq - 1); - crime_write_64(CRIME_INT_MASK, crime_mask); - local_irq_restore(flags); + crime_write(crime_mask, CRIME_INT_MASK); + spin_unlock_irqrestore(&ip32_irq_lock, flags); } static unsigned int startup_crime_irq(unsigned int irq) { - crime_mask = crime_read_64(CRIME_INT_MASK); enable_crime_irq(irq); return 0; /* This is probably not right; we could have pending irqs */ } @@ -190,14 +196,14 @@ static void disable_crime_irq(unsigned i { unsigned long flags; - local_irq_save(flags); + spin_lock_irqsave(&ip32_irq_lock, flags); crime_mask &= ~(1 << (irq - 1)); - crime_write_64(CRIME_INT_MASK, crime_mask); + crime_write(crime_mask, CRIME_INT_MASK); flush_crime_bus(); - local_irq_restore(flags); + spin_unlock_irqrestore(&ip32_irq_lock, flags); } -static void mask_and_ack_crime_irq (unsigned int irq) +static void mask_and_ack_crime_irq(unsigned int irq) { unsigned long flags; @@ -205,20 +211,20 @@ static void mask_and_ack_crime_irq (unsi if ((irq >= CRIME_GBE0_IRQ && irq <= CRIME_GBE3_IRQ) || (irq >= CRIME_RE_EMPTY_E_IRQ && irq <= CRIME_RE_IDLE_E_IRQ) || (irq >= CRIME_SOFT0_IRQ && irq <= CRIME_SOFT2_IRQ)) { - u64 crime_int; - local_irq_save(flags); - crime_int = crime_read_64(CRIME_HARD_INT); + uint64_t crime_int; + spin_lock_irqsave(&ip32_irq_lock, flags); + crime_int = crime_read(CRIME_HARD_INT); crime_int &= ~(1 << (irq - 1)); - crime_write_64(CRIME_HARD_INT, crime_int); - local_irq_restore(flags); + crime_write(crime_int, CRIME_HARD_INT); + spin_unlock_irqrestore(&ip32_irq_lock, flags); } disable_crime_irq(irq); } static void end_crime_irq(unsigned int irq) { - if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) - enable_crime_irq (irq); + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) + enable_crime_irq(irq); } #define shutdown_crime_irq disable_crime_irq @@ -240,24 +246,22 @@ static struct hw_interrupt_type ip32_cri * next chunk of the CRIME register in one piece. */ -static u32 macepci_mask; +static unsigned long macepci_mask; static void enable_macepci_irq(unsigned int irq) { unsigned long flags; - local_irq_save(flags); + spin_lock_irqsave(&ip32_irq_lock, flags); macepci_mask |= MACEPCI_CONTROL_INT(irq - 9); - mace_write_32(MACEPCI_CONTROL, macepci_mask); - crime_mask |= 1 << (irq - 1); - crime_write_64(CRIME_INT_MASK, crime_mask); - local_irq_restore(flags); + mace->pci.control = macepci_mask; + crime_mask |= 1 << (irq - 1); + crime_write(crime_mask, CRIME_INT_MASK); + spin_unlock_irqrestore(&ip32_irq_lock, flags); } static unsigned int startup_macepci_irq(unsigned int irq) { - crime_mask = crime_read_64 (CRIME_INT_MASK); - macepci_mask = mace_read_32(MACEPCI_CONTROL); enable_macepci_irq (irq); return 0; } @@ -266,20 +270,20 @@ static void disable_macepci_irq(unsigned { unsigned long flags; - local_irq_save(flags); + spin_lock_irqsave(&ip32_irq_lock, flags); crime_mask &= ~(1 << (irq - 1)); - crime_write_64(CRIME_INT_MASK, crime_mask); + crime_write(crime_mask, CRIME_INT_MASK); flush_crime_bus(); macepci_mask &= ~MACEPCI_CONTROL_INT(irq - 9); - mace_write_32(MACEPCI_CONTROL, macepci_mask); + mace->pci.control = macepci_mask; flush_mace_bus(); - local_irq_restore(flags); + spin_unlock_irqrestore(&ip32_irq_lock, flags); } static void end_macepci_irq(unsigned int irq) { if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) - enable_macepci_irq (irq); + enable_macepci_irq(irq); } #define shutdown_macepci_irq disable_macepci_irq @@ -300,7 +304,40 @@ static struct hw_interrupt_type ip32_mac * CRIME register. */ -u32 maceisa_mask = 0; +#define MACEISA_AUDIO_INT (MACEISA_AUDIO_SW_INT | \ + MACEISA_AUDIO_SC_INT | \ + MACEISA_AUDIO1_DMAT_INT | \ + MACEISA_AUDIO1_OF_INT | \ + MACEISA_AUDIO2_DMAT_INT | \ + MACEISA_AUDIO2_MERR_INT | \ + MACEISA_AUDIO3_DMAT_INT | \ + MACEISA_AUDIO3_MERR_INT) +#define MACEISA_MISC_INT (MACEISA_RTC_INT | \ + MACEISA_KEYB_INT | \ + MACEISA_KEYB_POLL_INT | \ + MACEISA_MOUSE_INT | \ + MACEISA_MOUSE_POLL_INT | \ + MACEISA_TIMER0_INT | \ + MACEISA_TIMER1_INT | \ + MACEISA_TIMER2_INT) +#define MACEISA_SUPERIO_INT (MACEISA_PARALLEL_INT | \ + MACEISA_PAR_CTXA_INT | \ + MACEISA_PAR_CTXB_INT | \ + MACEISA_PAR_MERR_INT | \ + MACEISA_SERIAL1_INT | \ + MACEISA_SERIAL1_TDMAT_INT | \ + MACEISA_SERIAL1_TDMAPR_INT | \ + MACEISA_SERIAL1_TDMAME_INT | \ + MACEISA_SERIAL1_RDMAT_INT | \ + MACEISA_SERIAL1_RDMAOR_INT | \ + MACEISA_SERIAL2_INT | \ + MACEISA_SERIAL2_TDMAT_INT | \ + MACEISA_SERIAL2_TDMAPR_INT | \ + MACEISA_SERIAL2_TDMAME_INT | \ + MACEISA_SERIAL2_RDMAT_INT | \ + MACEISA_SERIAL2_RDMAOR_INT) + +static unsigned long maceisa_mask; static void enable_maceisa_irq (unsigned int irq) { @@ -320,19 +357,17 @@ static void enable_maceisa_irq (unsigned crime_int = MACE_SUPERIO_INT; break; } - DBG ("crime_int %016lx enabled\n", crime_int); - local_irq_save(flags); + DBG ("crime_int %08x enabled\n", crime_int); + spin_lock_irqsave(&ip32_irq_lock, flags); crime_mask |= crime_int; - crime_write_64(CRIME_INT_MASK, crime_mask); + crime_write(crime_mask, CRIME_INT_MASK); maceisa_mask |= 1 << (irq - 33); - mace_write_32(MACEISA_INT_MASK, maceisa_mask); - local_irq_restore(flags); + mace_perif_ctrl_write(maceisa_mask, imask); + spin_unlock_irqrestore(&ip32_irq_lock, flags); } -static unsigned int startup_maceisa_irq (unsigned int irq) +static unsigned int startup_maceisa_irq(unsigned int irq) { - crime_mask = crime_read_64 (CRIME_INT_MASK); - maceisa_mask = mace_read_32(MACEISA_INT_MASK); enable_maceisa_irq(irq); return 0; } @@ -342,7 +377,7 @@ static void disable_maceisa_irq(unsigned unsigned int crime_int = 0; unsigned long flags; - local_irq_save(flags); + spin_lock_irqsave(&ip32_irq_lock, flags); maceisa_mask &= ~(1 << (irq - 33)); if(!(maceisa_mask & MACEISA_AUDIO_INT)) crime_int |= MACE_AUDIO_INT; @@ -351,28 +386,27 @@ static void disable_maceisa_irq(unsigned if(!(maceisa_mask & MACEISA_SUPERIO_INT)) crime_int |= MACE_SUPERIO_INT; crime_mask &= ~crime_int; - crime_write_64(CRIME_INT_MASK, crime_mask); + crime_write(crime_mask, CRIME_INT_MASK); flush_crime_bus(); - mace_write_32(MACEISA_INT_MASK, maceisa_mask); + mace_perif_ctrl_write(maceisa_mask, imask); flush_mace_bus(); - local_irq_restore(flags); + spin_unlock_irqrestore(&ip32_irq_lock, flags); } static void mask_and_ack_maceisa_irq(unsigned int irq) { - u32 mace_int; - unsigned long flags; + unsigned long mace_int, flags; switch (irq) { case MACEISA_PARALLEL_IRQ: case MACEISA_SERIAL1_TDMAPR_IRQ: case MACEISA_SERIAL2_TDMAPR_IRQ: /* edge triggered */ - local_irq_save(flags); - mace_int = mace_read_32(MACEISA_INT_STAT); + spin_lock_irqsave(&ip32_irq_lock, flags); + mace_int = mace_perif_ctrl_read(istat); mace_int &= ~(1 << (irq - 33)); - mace_write_32(MACEISA_INT_STAT, mace_int); - local_irq_restore(flags); + mace_perif_ctrl_write(mace_int, istat); + spin_unlock_irqrestore(&ip32_irq_lock, flags); break; } disable_maceisa_irq(irq); @@ -380,8 +414,8 @@ static void mask_and_ack_maceisa_irq(uns static void end_maceisa_irq(unsigned irq) { - if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) - enable_maceisa_irq (irq); + if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) + enable_maceisa_irq(irq); } #define shutdown_maceisa_irq disable_maceisa_irq @@ -405,15 +439,14 @@ static void enable_mace_irq(unsigned int { unsigned long flags; - local_irq_save(flags); + spin_lock_irqsave(&ip32_irq_lock, flags); crime_mask |= 1 << (irq - 1); - crime_write_64 (CRIME_INT_MASK, crime_mask); - local_irq_restore (flags); + crime_write(crime_mask, CRIME_INT_MASK); + spin_unlock_irqrestore(&ip32_irq_lock, flags); } static unsigned int startup_mace_irq(unsigned int irq) { - crime_mask = crime_read_64 (CRIME_INT_MASK); enable_mace_irq(irq); return 0; } @@ -422,17 +455,17 @@ static void disable_mace_irq(unsigned in { unsigned long flags; - local_irq_save(flags); + spin_lock_irqsave(&ip32_irq_lock, flags); crime_mask &= ~(1 << (irq - 1)); - crime_write_64 (CRIME_INT_MASK, crime_mask); + crime_write(crime_mask, CRIME_INT_MASK); flush_crime_bus(); - local_irq_restore(flags); + spin_unlock_irqrestore(&ip32_irq_lock, flags); } static void end_mace_irq(unsigned int irq) { if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) - enable_mace_irq (irq); + enable_mace_irq(irq); } #define shutdown_mace_irq disable_mace_irq @@ -449,28 +482,22 @@ static struct hw_interrupt_type ip32_mac NULL }; -static void ip32_unknown_interrupt (struct pt_regs *regs) +static void ip32_unknown_interrupt(struct pt_regs *regs) { - u64 crime; - u32 mace; + uint64_t crime; printk ("Unknown interrupt occurred!\n"); - printk ("cp0_status: %08x\n", - read_c0_status ()); - printk ("cp0_cause: %08x\n", - read_c0_cause ()); - crime = crime_read_64 (CRIME_INT_MASK); - printk ("CRIME interrupt mask: %016lx\n", crime); - crime = crime_read_64 (CRIME_INT_STAT); - printk ("CRIME interrupt status: %016lx\n", crime); - crime = crime_read_64 (CRIME_HARD_INT); - printk ("CRIME hardware interrupt register: %016lx\n", crime); - mace = mace_read_32 (MACEISA_INT_MASK); - printk ("MACE ISA interrupt mask: %08x\n", mace); - mace = mace_read_32 (MACEISA_INT_STAT); - printk ("MACE ISA interrupt status: %08x\n", mace); - mace = mace_read_32 (MACEPCI_CONTROL); - printk ("MACE PCI control register: %08x\n", mace); + printk ("cp0_status: %08x\n", read_c0_status()); + printk ("cp0_cause: %08x\n", read_c0_cause()); + crime = crime_read(CRIME_INT_MASK); + printk ("CRIME intr mask: %016lx\n", crime); + crime = crime_read(CRIME_INT_STAT); + printk ("CRIME intr status: %016lx\n", crime); + crime = crime_read(CRIME_HARD_INT); + printk ("CRIME hardware intr register: %016lx\n", crime); + printk ("MACE ISA intr mask: %08lx\n", mace_perif_ctrl_read(imask)); + printk ("MACE ISA intr status: %08lx\n", mace_perif_ctrl_read(istat)); + printk ("MACE PCI control register: %08x\n", mace->pci.control); printk("Register dump:\n"); show_regs(regs); @@ -481,18 +508,19 @@ static void ip32_unknown_interrupt (stru } /* CRIME 1.1 appears to deliver all interrupts to this one pin. */ +/* change this to loop over all edge-triggered irqs, exception masked out ones */ void ip32_irq0(struct pt_regs *regs) { - u64 crime_int; + uint64_t crime_int; int irq = 0; - crime_int = crime_read_64(CRIME_INT_STAT) & crime_mask; - irq = ffs(crime_int); - crime_int = 1ULL << (irq - 1); + crime_int = crime_read(CRIME_INT_STAT) & crime_mask; + irq = ffs(crime_int); + crime_int = 1 << (irq - 1); if (crime_int & CRIME_MACEISA_INT_MASK) { - u32 mace_int = mace_read_32 (MACEISA_INT_STAT) & maceisa_mask; - irq = ffs (mace_int) + 32; + unsigned long mace_int = mace_perif_ctrl_read(istat); + irq = ffs(mace_int & maceisa_mask) + 32; } DBG("*irq %u*\n", irq); do_IRQ(irq, regs); @@ -500,51 +528,43 @@ void ip32_irq0(struct pt_regs *regs) void ip32_irq1(struct pt_regs *regs) { - ip32_unknown_interrupt (regs); + ip32_unknown_interrupt(regs); } void ip32_irq2(struct pt_regs *regs) { - ip32_unknown_interrupt (regs); + ip32_unknown_interrupt(regs); } void ip32_irq3(struct pt_regs *regs) { - ip32_unknown_interrupt (regs); + ip32_unknown_interrupt(regs); } void ip32_irq4(struct pt_regs *regs) { - ip32_unknown_interrupt (regs); + ip32_unknown_interrupt(regs); } void ip32_irq5(struct pt_regs *regs) { - do_IRQ (CLOCK_IRQ, regs); + do_IRQ(CLOCK_IRQ, regs); } void __init init_IRQ(void) { unsigned int irq; - int i; + init_generic_irq(); /* Install our interrupt handler, then clear and disable all - * CRIME and MACE interrupts. - */ - crime_write_64(CRIME_INT_MASK, 0); - crime_write_64(CRIME_HARD_INT, 0); - crime_write_64(CRIME_SOFT_INT, 0); - mace_write_32(MACEISA_INT_STAT, 0); - mace_write_32(MACEISA_INT_MASK, 0); + * CRIME and MACE interrupts. */ + crime_write(0, CRIME_INT_MASK); + crime_write(0, CRIME_HARD_INT); + crime_write(0, CRIME_SOFT_INT); + mace_perif_ctrl_write(0, istat); + mace_perif_ctrl_write(0, imask); set_except_vector(0, ip32_handle_int); - for (i = 0; i < NR_IRQS; i++) { - irq_desc[i].status = IRQ_DISABLED; - irq_desc[i].action = NULL; - irq_desc[i].depth = 1; - irq_desc[i].handler = &no_irq_type; - } - for (irq = 0; irq <= IP32_IRQ_MAX; irq++) { hw_irq_controller *controller; --- diff/arch/mips/sgi-ip32/ip32-reset.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sgi-ip32/ip32-reset.c 2004-02-23 13:56:38.000000000 +0000 @@ -16,13 +16,13 @@ #include #include +#include #include #include -#include -#include -#include #include #include +#include +#include #include #define POWERDOWN_TIMEOUT 120 @@ -33,7 +33,7 @@ #define PANIC_FREQ (HZ / 8) static struct timer_list power_timer, blink_timer, debounce_timer; -static int shuting_down = 0, has_paniced = 0; +static int has_paniced, shuting_down; static void ip32_machine_restart(char *command) __attribute__((noreturn)); static void ip32_machine_halt(void) __attribute__((noreturn)); @@ -41,16 +41,13 @@ static void ip32_machine_power_off(void) static void ip32_machine_restart(char *cmd) { - if (shuting_down) - ip32_machine_power_off(); - ArcReboot(); + crime_write(CRIME_CONTROL_HARD_RESET, CRIME_CONTROL); + while (1); } static inline void ip32_machine_halt(void) { - if (shuting_down) - ip32_machine_power_off(); - ArcEnterInteractiveMode(); + ip32_machine_power_off(); } static void ip32_machine_power_off(void) @@ -76,10 +73,7 @@ static void ip32_machine_power_off(void) CMOS_WRITE(xctrl_a | DS_XCTRL4A_PAB, DS_B1_XCTRL4A); CMOS_WRITE(reg_a, RTC_REG_A); wbflush(); - - while(1) { - printk(KERN_DEBUG "Power off!\n"); - } + while (1); } static void power_timeout(unsigned long data) @@ -89,35 +83,33 @@ static void power_timeout(unsigned long static void blink_timeout(unsigned long data) { - u64 mc_led = mace_read_64(MACEISA_FLASH_NIC_REG); - - mc_led ^= MACEISA_LED_RED; - mace_write_64(MACEISA_FLASH_NIC_REG, mc_led); + unsigned long led = mace_perif_ctrl_read(misc) ^ MACEISA_LED_RED; + mace_perif_ctrl_write(led, misc); mod_timer(&blink_timer, jiffies+data); } static void debounce(unsigned long data) { - volatile unsigned char reg_a,reg_c,xctrl_a; + volatile unsigned char reg_a, reg_c, xctrl_a; reg_c = CMOS_READ(RTC_INTR_FLAGS); CMOS_WRITE(reg_a | DS_REGA_DV0, RTC_REG_A); wbflush(); xctrl_a = CMOS_READ(DS_B1_XCTRL4A); - if( (xctrl_a & DS_XCTRL4A_IFS ) || ( reg_c & RTC_IRQF ) ) { + if ((xctrl_a & DS_XCTRL4A_IFS) || (reg_c & RTC_IRQF )) { /* Interrupt still being sent. */ debounce_timer.expires = jiffies + 50; add_timer(&debounce_timer); /* clear interrupt source */ - CMOS_WRITE( xctrl_a & ~DS_XCTRL4A_IFS, DS_B1_XCTRL4A); + CMOS_WRITE(xctrl_a & ~DS_XCTRL4A_IFS, DS_B1_XCTRL4A); CMOS_WRITE(reg_a & ~DS_REGA_DV0, RTC_REG_A); return; } CMOS_WRITE(reg_a & ~DS_REGA_DV0, RTC_REG_A); if (has_paniced) - ArcReboot(); + ip32_machine_restart(NULL); enable_irq(MACEISA_RTC_IRQ); } @@ -147,7 +139,7 @@ static irqreturn_t ip32_rtc_int(int irq, volatile unsigned char reg_c; reg_c = CMOS_READ(RTC_INTR_FLAGS); - if( ! (reg_c & RTC_IRQF) ) { + if (!(reg_c & RTC_IRQF)) { printk(KERN_WARNING "%s: RTC IRQ without RTC_IRQF\n", __FUNCTION__); } @@ -164,18 +156,17 @@ static irqreturn_t ip32_rtc_int(int irq, } static int panic_event(struct notifier_block *this, unsigned long event, - void *ptr) + void *ptr) { - u64 mc_led; + unsigned long led; if (has_paniced) return NOTIFY_DONE; has_paniced = 1; /* turn off the green LED */ - mc_led = mace_read_64(MACEISA_FLASH_NIC_REG); - mc_led |= MACEISA_LED_GREEN; - mace_write_64(MACEISA_FLASH_NIC_REG, mc_led); + led = mace_perif_ctrl_read(misc) | MACEISA_LED_GREEN; + mace_perif_ctrl_write(led, misc); blink_timer.data = PANIC_FREQ; blink_timeout(PANIC_FREQ); @@ -189,7 +180,11 @@ static struct notifier_block panic_block static __init int ip32_reboot_setup(void) { - u64 mc_led = mace_read_64(MACEISA_FLASH_NIC_REG); + /* turn on the green led only */ + unsigned long led = mace_perif_ctrl_read(misc); + led |= MACEISA_LED_RED; + led &= ~MACEISA_LED_GREEN; + mace_perif_ctrl_write(led, misc); _machine_restart = ip32_machine_restart; _machine_halt = ip32_machine_halt; @@ -199,11 +194,6 @@ static __init int ip32_reboot_setup(void blink_timer.function = blink_timeout; notifier_chain_register(&panic_notifier_list, &panic_block); - /* turn on the green led only */ - mc_led |= MACEISA_LED_RED; - mc_led &= ~MACEISA_LED_GREEN; - mace_write_64(MACEISA_FLASH_NIC_REG, mc_led); - return 0; } --- diff/arch/mips/sgi-ip32/ip32-setup.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sgi-ip32/ip32-setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -6,29 +6,26 @@ * for more details. * * Copyright (C) 2000 Harald Koerfgen + * Copyright (C) 2002, 03 Ilya A. Volynets */ #include #include #include -#include #include #include +#include #include #include #include #include -#include -#include -#include #include #include - -extern struct rtc_ops ip32_rtc_ops; -extern u32 cc_interval; +#include +#include +#include #ifdef CONFIG_SGI_O2MACE_ETH - /* * This is taken care of in here 'cause they say using Arc later on is * problematic @@ -60,44 +57,83 @@ static inline void str2eaddr(unsigned ch #endif extern void ip32_time_init(void); -extern void ip32_be_init(void); -extern void __init ip32_timer_setup (struct irqaction *irq); -extern void __init crime_init (void); +extern void ip32_be_init(void); +extern void __init ip32_timer_setup (struct irqaction *irq); +extern void __init crime_init (void); + +#ifdef CONFIG_SERIAL_8250 +#include +#include +#include +extern int __init early_serial_setup(struct uart_port *port); + +#define STD_COM_FLAGS (ASYNC_SKIP_TEST) +#define BASE_BAUD (1843200 / 16) +#endif /* CONFIG_SERIAL_8250 */ -void __init ip32_setup(void) +static int __init ip32_setup(void) { -#ifdef CONFIG_SERIAL_CONSOLE - char *ctype; -#endif - TLBMISS_HANDLER_SETUP (); + set_io_port_base((unsigned long) ioremap(MACEPCI_LOW_IO, 0x2000000)); + + crime_init(); - mips_io_port_base = UNCACHEDADDR(MACEPCI_HI_IO);; +#ifdef CONFIG_SERIAL_8250 + { + static struct uart_port o2_serial[2]; + + memset(o2_serial, 0, sizeof(o2_serial)); + o2_serial[0].type = PORT_16550A; + o2_serial[0].line = 0; + o2_serial[0].irq = MACEISA_SERIAL1_IRQ; + o2_serial[0].flags = STD_COM_FLAGS | UPF_RESOURCES; + o2_serial[0].uartclk = BASE_BAUD * 16; + o2_serial[0].iotype = UPIO_MEM; + o2_serial[0].membase = (char *)&mace->isa.serial1; + o2_serial[0].fifosize = 14; + /* How much to shift register offset by. Each UART register + * is replicated over 256 byte space */ + o2_serial[0].regshift = 8; + o2_serial[1].type = PORT_16550A; + o2_serial[1].line = 1; + o2_serial[1].irq = MACEISA_SERIAL2_IRQ; + o2_serial[1].flags = STD_COM_FLAGS | UPF_RESOURCES; + o2_serial[1].uartclk = BASE_BAUD * 16; + o2_serial[1].iotype = UPIO_MEM; + o2_serial[1].membase = (char *)&mace->isa.serial2; + o2_serial[1].fifosize = 14; + o2_serial[1].regshift = 8; -#ifdef CONFIG_SERIAL_CONSOLE - ctype = ArcGetEnvironmentVariable("console"); - if (*ctype == 'd') { - if (ctype[1] == '2') - console_setup ("ttyS1"); - else - console_setup ("ttyS0"); + early_serial_setup(&o2_serial[0]); + early_serial_setup(&o2_serial[1]); } #endif #ifdef CONFIG_SGI_O2MACE_ETH { - char *mac=ArcGetEnvironmentVariable("eaddr"); + char *mac = ArcGetEnvironmentVariable("eaddr"); str2eaddr(o2meth_eaddr, mac); } #endif -#ifdef CONFIG_VT - conswitchp = &dummy_con; +#if defined(CONFIG_SERIAL_CORE_CONSOLE) + { + char* con = ArcGetEnvironmentVariable("console"); + if (con && *con == 'd') { + static char options[8]; + char *baud = ArcGetEnvironmentVariable("dbaud"); + if (baud) + strcpy(options, baud); + add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0, + baud ? options : NULL); + } + } #endif - rtc_ops = &ip32_rtc_ops; board_be_init = ip32_be_init; board_time_init = ip32_time_init; board_timer_setup = ip32_timer_setup; - crime_init(); + return 0; } + +early_initcall(ip32_setup); --- diff/arch/mips/sgi-ip32/ip32-timer.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sgi-ip32/ip32-timer.c 2004-02-23 13:56:38.000000000 +0000 @@ -16,18 +16,18 @@ #include #include #include -#include #include #include #include -#include -#include #include #include -#include #include #include +#include +#include + +#include extern volatile unsigned long wall_jiffies; @@ -47,23 +47,25 @@ static unsigned int timerhi, timerlo; static irqreturn_t cc_timer_interrupt(int irq, void *dev_id, struct pt_regs * regs); -void __init ip32_timer_setup (struct irqaction *irq) +static inline uint64_t crime_time(void) { - u64 crime_time; - u32 cc_tick; + return crime_read(CRIME_TIMER) & CRIME_TIMER_MASK; +} +void __init ip32_timer_setup (struct irqaction *irq) +{ + uint64_t time; + unsigned int cc_tick; write_c0_count(0); irq->handler = cc_timer_interrupt; printk("Calibrating system timer... "); - crime_time = crime_read_64(CRIME_TIME) & CRIME_TIME_MASK; + time = crime_time(); cc_tick = read_c0_count(); - while ((crime_read_64 (CRIME_TIME) & CRIME_TIME_MASK) - crime_time - < WAIT_MS * 1000000 / CRIME_NS_PER_TICK) - ; + while (crime_time() - time < WAIT_MS * 1000000 / CRIME_NS_PER_TICK) ; cc_tick = read_c0_count() - cc_tick; cc_interval = cc_tick / HZ * (1000 / WAIT_MS); /* @@ -75,7 +77,7 @@ void __init ip32_timer_setup (struct irq printk("%d MHz CPU detected\n", (int) (cc_interval / PER_MHZ)); - setup_irq (CLOCK_IRQ, irq); + setup_irq(CLOCK_IRQ, irq); #define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5) /* Set ourselves up for future interrupts */ write_c0_compare(read_c0_count() + cc_interval); @@ -85,7 +87,7 @@ void __init ip32_timer_setup (struct irq static irqreturn_t cc_timer_interrupt(int irq, void *dev_id, struct pt_regs * regs) { - u32 count; + unsigned int count; /* * The cycle counter is only 32 bit which is good for about --- diff/arch/mips/sibyte/cfe/console.c 2003-09-17 12:28:02.000000000 +0100 +++ source/arch/mips/sibyte/cfe/console.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,5 +1,5 @@ +#include #include -#include #include #include @@ -41,12 +41,6 @@ static void cfe_console_write(struct con } -static struct tty_driver *cfe_console_device(struct console *c, int *index) -{ - *index = -1; - return NULL; -} - static int cfe_console_setup(struct console *cons, char *str) { char consdev[32]; @@ -72,7 +66,6 @@ static int cfe_console_setup(struct cons static struct console sb1250_cfe_cons = { .name = "cfe", .write = cfe_console_write, - .device = cfe_console_device, .setup = cfe_console_setup, .flags = CON_PRINTBUFFER, .index = -1, --- diff/arch/mips/sibyte/cfe/setup.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sibyte/cfe/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -51,17 +51,11 @@ phys_t board_mem_region_addrs[SIBYTE_MAX phys_t board_mem_region_sizes[SIBYTE_MAX_MEM_REGIONS]; unsigned int board_mem_region_count; -/* This is the kernel command line. Actually, it's - copied, eventually, to command_line, and looks to be - quite redundant. But not something to fix just now */ -extern char arcs_cmdline[]; - int cfe_cons_handle; -#ifdef CONFIG_EMBEDDED_RAMDISK -/* These are symbols defined by the ramdisk linker script */ -extern unsigned char __rd_start; -extern unsigned char __rd_end; +#ifdef CONFIG_BLK_DEV_INITRD +extern unsigned long initrd_start, initrd_end; +extern void * __rd_start, * __rd_end; #endif #ifdef CONFIG_SMP @@ -191,6 +185,8 @@ static int __init initrd_setup(char *str { char rdarg[64]; int idx; + char *tmp, *endptr; + unsigned long initrd_size; /* Make a copy of the initrd argument so we can smash it up here */ for (idx = 0; idx < sizeof(rdarg)-1; idx++) { @@ -205,8 +201,6 @@ static int __init initrd_setup(char *str *Initrd location comes in the form "@" * e.g. initrd=3abfd@80010000. This is set up by the loader. */ - char *tmp, *endptr; - unsigned long initrd_size; for (tmp = str; *tmp != '@'; tmp++) { if (!*tmp) { goto fail; @@ -240,12 +234,15 @@ static int __init initrd_setup(char *str #endif /* - * prom_init is called just after the cpu type is determined, from init_arch() + * prom_init is called just after the cpu type is determined, from setup_arch() */ -__init int prom_init(int argc, char **argv, char **envp, int *prom_vec) +void __init prom_init(void) { uint64_t cfe_ept, cfe_handle; unsigned int cfe_eptseal; + int argc = fw_arg0; + char **envp = (char **) fw_arg2; + int *prom_vec = (int *) fw_arg3; #ifdef CONFIG_KGDB char *arg; #endif @@ -345,13 +342,12 @@ __init int prom_init(int argc, char **ar mips_machgroup = MACH_GROUP_SIBYTE; prom_meminit(); - - return 0; } -void prom_free_prom_memory(void) +unsigned long __init prom_free_prom_memory(void) { /* Not sure what I'm supposed to do here. Nothing, I think */ + return 0; } void prom_putchar(char c) --- diff/arch/mips/sibyte/cfe/smp.c 2003-08-26 10:00:52.000000000 +0100 +++ source/arch/mips/sibyte/cfe/smp.c 2004-02-23 13:56:38.000000000 +0000 @@ -16,64 +16,82 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include - -#include +#include #include "cfe_api.h" #include "cfe_error.h" -extern void asmlinkage smp_bootstrap(void); - -/* Boot all other cpus in the system, initialize them, and - bring them into the boot fn */ -int prom_boot_secondary(int cpu, unsigned long sp, unsigned long gp) +/* + * Use CFE to find out how many CPUs are available, setting up + * phys_cpu_present_map and the logical/physical mappings. + * XXXKW will the boot CPU ever not be physical 0? + */ +void __init prom_build_cpu_map(void) { - int retval; - - retval = cfe_cpu_start(cpu, &smp_bootstrap, sp, gp, 0); - if (retval != 0) { - printk("cfe_start_cpu(%i) returned %i\n" , cpu, retval); - return 0; - } else { - return 1; + int i, num; + + cpus_clear(phys_cpu_present_map); + cpu_set(0, phys_cpu_present_map); + __cpu_number_map[0] = 0; + __cpu_logical_map[0] = 0; + + for (i=1, num=0; ithread_info, 0); + if (retval != 0) + printk("cfe_start_cpu(%i) returned %i\n" , cpu, retval); +} - /* Use CFE to find out how many CPUs are available */ - for (i=1; i #include #include -#include #include #include #include @@ -65,8 +64,8 @@ static void arm_tb(void) u_int64_t tb_options = M_SCD_TRACE_CFG_FREEZE_FULL; /* Generate an SCD_PERFCNT interrupt in TB_PERIOD Zclks to trigger start of trace. XXX vary sampling period */ - __raw_writeq(0, KSEG1 + A_SCD_PERF_CNT_1); - scdperfcnt = __raw_readq(KSEG1 + A_SCD_PERF_CNT_CFG); + __raw_writeq(0, IOADDR(A_SCD_PERF_CNT_1)); + scdperfcnt = __raw_readq(IOADDR(A_SCD_PERF_CNT_CFG)); /* Unfortunately, in Pass 2 we must clear all counters to knock down a previous interrupt request. This means that bus profiling requires ALL of the SCD perf counters. */ @@ -74,15 +73,15 @@ static void arm_tb(void) M_SPC_CFG_ENABLE | // enable counting M_SPC_CFG_CLEAR | // clear all counters V_SPC_CFG_SRC1(1), // counter 1 counts cycles - KSEG1 + A_SCD_PERF_CNT_CFG); - __raw_writeq(next, KSEG1 + A_SCD_PERF_CNT_1); + IOADDR(A_SCD_PERF_CNT_CFG)); + __raw_writeq(next, IOADDR(A_SCD_PERF_CNT_1)); /* Reset the trace buffer */ - __raw_writeq(M_SCD_TRACE_CFG_RESET, KSEG1 + A_SCD_TRACE_CFG); + __raw_writeq(M_SCD_TRACE_CFG_RESET, IOADDR(A_SCD_TRACE_CFG)); #if 0 && defined(M_SCD_TRACE_CFG_FORCECNT) /* XXXKW may want to expose control to the data-collector */ tb_options |= M_SCD_TRACE_CFG_FORCECNT; #endif - __raw_writeq(tb_options, KSEG1 + A_SCD_TRACE_CFG); + __raw_writeq(tb_options, IOADDR(A_SCD_TRACE_CFG)); sbp.tb_armed = 1; } @@ -94,22 +93,22 @@ static irqreturn_t sbprof_tb_intr(int ir /* XXX should use XKPHYS to make writes bypass L2 */ u_int64_t *p = sbp.sbprof_tbbuf[sbp.next_tb_sample++]; /* Read out trace */ - __raw_writeq(M_SCD_TRACE_CFG_START_READ, KSEG1 + A_SCD_TRACE_CFG); + __raw_writeq(M_SCD_TRACE_CFG_START_READ, IOADDR(A_SCD_TRACE_CFG)); __asm__ __volatile__ ("sync" : : : "memory"); /* Loop runs backwards because bundles are read out in reverse order */ for (i = 256 * 6; i > 0; i -= 6) { // Subscripts decrease to put bundle in the order // t0 lo, t0 hi, t1 lo, t1 hi, t2 lo, t2 hi - p[i-1] = __raw_readq(KSEG1 + A_SCD_TRACE_READ); // read t2 hi - p[i-2] = __raw_readq(KSEG1 + A_SCD_TRACE_READ); // read t2 lo - p[i-3] = __raw_readq(KSEG1 + A_SCD_TRACE_READ); // read t1 hi - p[i-4] = __raw_readq(KSEG1 + A_SCD_TRACE_READ); // read t1 lo - p[i-5] = __raw_readq(KSEG1 + A_SCD_TRACE_READ); // read t0 hi - p[i-6] = __raw_readq(KSEG1 + A_SCD_TRACE_READ); // read t0 lo + p[i-1] = __raw_readq(IOADDR(A_SCD_TRACE_READ)); // read t2 hi + p[i-2] = __raw_readq(IOADDR(A_SCD_TRACE_READ)); // read t2 lo + p[i-3] = __raw_readq(IOADDR(A_SCD_TRACE_READ)); // read t1 hi + p[i-4] = __raw_readq(IOADDR(A_SCD_TRACE_READ)); // read t1 lo + p[i-5] = __raw_readq(IOADDR(A_SCD_TRACE_READ)); // read t0 hi + p[i-6] = __raw_readq(IOADDR(A_SCD_TRACE_READ)); // read t0 lo } if (!sbp.tb_enable) { DBG(printk(DEVNAME ": tb_intr shutdown\n")); - __raw_writeq(M_SCD_TRACE_CFG_RESET, KSEG1 + A_SCD_TRACE_CFG); + __raw_writeq(M_SCD_TRACE_CFG_RESET, IOADDR(A_SCD_TRACE_CFG)); sbp.tb_armed = 0; wake_up(&sbp.tb_sync); } else { @@ -118,7 +117,7 @@ static irqreturn_t sbprof_tb_intr(int ir } else { /* No more trace buffer samples */ DBG(printk(DEVNAME ": tb_intr full\n")); - __raw_writeq(M_SCD_TRACE_CFG_RESET, KSEG1 + A_SCD_TRACE_CFG); + __raw_writeq(M_SCD_TRACE_CFG_RESET, IOADDR(A_SCD_TRACE_CFG)); sbp.tb_armed = 0; if (!sbp.tb_enable) { wake_up(&sbp.tb_sync); @@ -134,7 +133,7 @@ static irqreturn_t sbprof_pc_intr(int ir return IRQ_NONE; } -static int sbprof_zbprof_start(struct file *filp) +int sbprof_zbprof_start(struct file *filp) { u_int64_t scdperfcnt; @@ -152,13 +151,13 @@ static int sbprof_zbprof_start(struct fi return -EBUSY; } /* Make sure there isn't a perf-cnt interrupt waiting */ - scdperfcnt = __raw_readq(KSEG1 + A_SCD_PERF_CNT_CFG); + scdperfcnt = __raw_readq(IOADDR(A_SCD_PERF_CNT_CFG)); /* Disable and clear counters, override SRC_1 */ __raw_writeq((scdperfcnt & ~(M_SPC_CFG_SRC1 | M_SPC_CFG_ENABLE)) | M_SPC_CFG_ENABLE | M_SPC_CFG_CLEAR | V_SPC_CFG_SRC1(1), - KSEG1 + A_SCD_PERF_CNT_CFG); + IOADDR(A_SCD_PERF_CNT_CFG)); /* We grab this interrupt to prevent others from trying to use it, even though we don't want to service the interrupts @@ -173,51 +172,51 @@ static int sbprof_zbprof_start(struct fi pass them through. I am exploiting my knowledge that cp0_status masks out IP[5]. krw */ __raw_writeq(K_INT_MAP_I3, - KSEG1 + A_IMR_REGISTER(0, R_IMR_INTERRUPT_MAP_BASE) + (K_INT_PERF_CNT<<3)); + IOADDR(A_IMR_REGISTER(0, R_IMR_INTERRUPT_MAP_BASE) + (K_INT_PERF_CNT<<3))); /* Initialize address traps */ - __raw_writeq(0, KSEG1 + A_ADDR_TRAP_UP_0); - __raw_writeq(0, KSEG1 + A_ADDR_TRAP_UP_1); - __raw_writeq(0, KSEG1 + A_ADDR_TRAP_UP_2); - __raw_writeq(0, KSEG1 + A_ADDR_TRAP_UP_3); - - __raw_writeq(0, KSEG1 + A_ADDR_TRAP_DOWN_0); - __raw_writeq(0, KSEG1 + A_ADDR_TRAP_DOWN_1); - __raw_writeq(0, KSEG1 + A_ADDR_TRAP_DOWN_2); - __raw_writeq(0, KSEG1 + A_ADDR_TRAP_DOWN_3); - - __raw_writeq(0, KSEG1 + A_ADDR_TRAP_CFG_0); - __raw_writeq(0, KSEG1 + A_ADDR_TRAP_CFG_1); - __raw_writeq(0, KSEG1 + A_ADDR_TRAP_CFG_2); - __raw_writeq(0, KSEG1 + A_ADDR_TRAP_CFG_3); + __raw_writeq(0, IOADDR(A_ADDR_TRAP_UP_0)); + __raw_writeq(0, IOADDR(A_ADDR_TRAP_UP_1)); + __raw_writeq(0, IOADDR(A_ADDR_TRAP_UP_2)); + __raw_writeq(0, IOADDR(A_ADDR_TRAP_UP_3)); + + __raw_writeq(0, IOADDR(A_ADDR_TRAP_DOWN_0)); + __raw_writeq(0, IOADDR(A_ADDR_TRAP_DOWN_1)); + __raw_writeq(0, IOADDR(A_ADDR_TRAP_DOWN_2)); + __raw_writeq(0, IOADDR(A_ADDR_TRAP_DOWN_3)); + + __raw_writeq(0, IOADDR(A_ADDR_TRAP_CFG_0)); + __raw_writeq(0, IOADDR(A_ADDR_TRAP_CFG_1)); + __raw_writeq(0, IOADDR(A_ADDR_TRAP_CFG_2)); + __raw_writeq(0, IOADDR(A_ADDR_TRAP_CFG_3)); /* Initialize Trace Event 0-7 */ // when interrupt - __raw_writeq(M_SCD_TREVT_INTERRUPT, KSEG1 + A_SCD_TRACE_EVENT_0); - __raw_writeq(0, KSEG1 + A_SCD_TRACE_EVENT_1); - __raw_writeq(0, KSEG1 + A_SCD_TRACE_EVENT_2); - __raw_writeq(0, KSEG1 + A_SCD_TRACE_EVENT_3); - __raw_writeq(0, KSEG1 + A_SCD_TRACE_EVENT_4); - __raw_writeq(0, KSEG1 + A_SCD_TRACE_EVENT_5); - __raw_writeq(0, KSEG1 + A_SCD_TRACE_EVENT_6); - __raw_writeq(0, KSEG1 + A_SCD_TRACE_EVENT_7); + __raw_writeq(M_SCD_TREVT_INTERRUPT, IOADDR(A_SCD_TRACE_EVENT_0)); + __raw_writeq(0, IOADDR(A_SCD_TRACE_EVENT_1)); + __raw_writeq(0, IOADDR(A_SCD_TRACE_EVENT_2)); + __raw_writeq(0, IOADDR(A_SCD_TRACE_EVENT_3)); + __raw_writeq(0, IOADDR(A_SCD_TRACE_EVENT_4)); + __raw_writeq(0, IOADDR(A_SCD_TRACE_EVENT_5)); + __raw_writeq(0, IOADDR(A_SCD_TRACE_EVENT_6)); + __raw_writeq(0, IOADDR(A_SCD_TRACE_EVENT_7)); /* Initialize Trace Sequence 0-7 */ // Start on event 0 (interrupt) __raw_writeq(V_SCD_TRSEQ_FUNC_START|0x0fff, - KSEG1 + A_SCD_TRACE_SEQUENCE_0); + IOADDR(A_SCD_TRACE_SEQUENCE_0)); // dsamp when d used | asamp when a used __raw_writeq(M_SCD_TRSEQ_ASAMPLE|M_SCD_TRSEQ_DSAMPLE|K_SCD_TRSEQ_TRIGGER_ALL, - KSEG1 + A_SCD_TRACE_SEQUENCE_1); - __raw_writeq(0, KSEG1 + A_SCD_TRACE_SEQUENCE_2); - __raw_writeq(0, KSEG1 + A_SCD_TRACE_SEQUENCE_3); - __raw_writeq(0, KSEG1 + A_SCD_TRACE_SEQUENCE_4); - __raw_writeq(0, KSEG1 + A_SCD_TRACE_SEQUENCE_5); - __raw_writeq(0, KSEG1 + A_SCD_TRACE_SEQUENCE_6); - __raw_writeq(0, KSEG1 + A_SCD_TRACE_SEQUENCE_7); + IOADDR(A_SCD_TRACE_SEQUENCE_1)); + __raw_writeq(0, IOADDR(A_SCD_TRACE_SEQUENCE_2)); + __raw_writeq(0, IOADDR(A_SCD_TRACE_SEQUENCE_3)); + __raw_writeq(0, IOADDR(A_SCD_TRACE_SEQUENCE_4)); + __raw_writeq(0, IOADDR(A_SCD_TRACE_SEQUENCE_5)); + __raw_writeq(0, IOADDR(A_SCD_TRACE_SEQUENCE_6)); + __raw_writeq(0, IOADDR(A_SCD_TRACE_SEQUENCE_7)); /* Now indicate the PERF_CNT interrupt as a trace-relevant interrupt */ - __raw_writeq((1ULL << K_INT_PERF_CNT), KSEG1 + A_IMR_REGISTER(0, R_IMR_INTERRUPT_TRACE)); + __raw_writeq((1ULL << K_INT_PERF_CNT), IOADDR(A_IMR_REGISTER(0, R_IMR_INTERRUPT_TRACE))); arm_tb(); @@ -226,7 +225,7 @@ static int sbprof_zbprof_start(struct fi return 0; } -static int sbprof_zbprof_stop(void) +int sbprof_zbprof_stop(void) { DBG(printk(DEVNAME ": stopping\n")); --- diff/arch/mips/sibyte/sb1250/bus_watcher.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sibyte/sb1250/bus_watcher.c 2004-02-23 13:56:38.000000000 +0000 @@ -25,6 +25,7 @@ * /proc/bus_watcher if PROC_FS is on. */ +#include #include #include #include @@ -80,10 +81,10 @@ void check_bus_watcher(void) #ifdef CONFIG_SB1_PASS_1_WORKAROUNDS /* Destructive read, clears register and interrupt */ - status = csr_in32(IO_SPACE_BASE | A_SCD_BUS_ERR_STATUS); + status = csr_in32(IOADDR(A_SCD_BUS_ERR_STATUS)); #else /* Use non-destructive register */ - status = csr_in32(IO_SPACE_BASE | A_SCD_BUS_ERR_STATUS_DEBUG); + status = csr_in32(IOADDR(A_SCD_BUS_ERR_STATUS_DEBUG)); #endif if (!(status & 0x7fffffff)) { printk("Using last values reaped by bus watcher driver\n"); @@ -91,8 +92,8 @@ void check_bus_watcher(void) l2_err = bw_stats.l2_err; memio_err = bw_stats.memio_err; } else { - l2_err = csr_in32(IO_SPACE_BASE | A_BUS_L2_ERRORS); - memio_err = csr_in32(IO_SPACE_BASE | A_BUS_MEM_IO_ERRORS); + l2_err = csr_in32(IOADDR(A_BUS_L2_ERRORS)); + memio_err = csr_in32(IOADDR(A_BUS_MEM_IO_ERRORS)); } if (status & ~(1UL << 31)) print_summary(status, l2_err, memio_err); @@ -175,31 +176,46 @@ static irqreturn_t sibyte_bw_int(int irq { struct bw_stats_struct *stats = data; unsigned long cntr; +#ifdef CONFIG_SIBYTE_BW_TRACE + int i; +#endif #ifndef CONFIG_PROC_FS char bw_buf[1024]; #endif +#ifdef CONFIG_SIBYTE_BW_TRACE + csr_out32(M_SCD_TRACE_CFG_FREEZE, IOADDR(A_SCD_TRACE_CFG)); + csr_out32(M_SCD_TRACE_CFG_START_READ, IOADDR(A_SCD_TRACE_CFG)); + + for (i=0; i<256*6; i++) + printk("%016llx\n", (unsigned long long)__raw_readq(IOADDR(A_SCD_TRACE_READ))); + + csr_out32(M_SCD_TRACE_CFG_RESET, IOADDR(A_SCD_TRACE_CFG)); + csr_out32(M_SCD_TRACE_CFG_START, IOADDR(A_SCD_TRACE_CFG)); +#endif + /* Destructive read, clears register and interrupt */ - stats->status = csr_in32(IO_SPACE_BASE | A_SCD_BUS_ERR_STATUS); + stats->status = csr_in32(IOADDR(A_SCD_BUS_ERR_STATUS)); stats->status_printed = 0; - stats->l2_err = cntr = csr_in32(IO_SPACE_BASE | A_BUS_L2_ERRORS); + stats->l2_err = cntr = csr_in32(IOADDR(A_BUS_L2_ERRORS)); stats->l2_cor_d += G_SCD_L2ECC_CORR_D(cntr); stats->l2_bad_d += G_SCD_L2ECC_BAD_D(cntr); stats->l2_cor_t += G_SCD_L2ECC_CORR_T(cntr); stats->l2_bad_t += G_SCD_L2ECC_BAD_T(cntr); - csr_out32(0, IO_SPACE_BASE | A_BUS_L2_ERRORS); + csr_out32(0, IOADDR(A_BUS_L2_ERRORS)); - stats->memio_err = cntr = csr_in32(IO_SPACE_BASE | A_BUS_MEM_IO_ERRORS); + stats->memio_err = cntr = csr_in32(IOADDR(A_BUS_MEM_IO_ERRORS)); stats->mem_cor_d += G_SCD_MEM_ECC_CORR(cntr); stats->mem_bad_d += G_SCD_MEM_ECC_BAD(cntr); stats->bus_error += G_SCD_MEM_BUSERR(cntr); - csr_out32(0, IO_SPACE_BASE | A_BUS_MEM_IO_ERRORS); + csr_out32(0, IOADDR(A_BUS_MEM_IO_ERRORS)); #ifndef CONFIG_PROC_FS bw_print_buffer(bw_buf, stats); printk(bw_buf); #endif + return IRQ_HANDLED; } @@ -228,6 +244,14 @@ int __init sibyte_bus_watcher(void) create_proc_decoder(&bw_stats); #endif +#ifdef CONFIG_SIBYTE_BW_TRACE + csr_out32((M_SCD_TRSEQ_ASAMPLE | M_SCD_TRSEQ_DSAMPLE | + K_SCD_TRSEQ_TRIGGER_ALL), + IOADDR(A_SCD_TRACE_SEQUENCE_0)); + csr_out32(M_SCD_TRACE_CFG_RESET, IOADDR(A_SCD_TRACE_CFG)); + csr_out32(M_SCD_TRACE_CFG_START, IOADDR(A_SCD_TRACE_CFG)); +#endif + return 0; } --- diff/arch/mips/sibyte/sb1250/irq.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sibyte/sb1250/irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -64,9 +64,6 @@ extern unsigned long ldt_eoi_space; #include extern void breakpoint(void); static int kgdb_irq; -#ifdef CONFIG_GDB_CONSOLE -extern void register_gdb_console(void); -#endif /* kgdb is on when configured. Pass "nokgdb" kernel arg to turn it off */ static int kgdb_flag = 1; @@ -110,9 +107,9 @@ void sb1250_mask_irq(int cpu, int irq) u64 cur_ints; spin_lock_irqsave(&sb1250_imr_lock, flags); - cur_ints = ____raw_readq(KSEG1 + A_IMR_MAPPER(cpu) + R_IMR_INTERRUPT_MASK); + cur_ints = ____raw_readq(IOADDR(A_IMR_MAPPER(cpu) + R_IMR_INTERRUPT_MASK)); cur_ints |= (((u64) 1) << irq); - ____raw_writeq(cur_ints, KSEG1 + A_IMR_MAPPER(cpu) + R_IMR_INTERRUPT_MASK); + ____raw_writeq(cur_ints, IOADDR(A_IMR_MAPPER(cpu) + R_IMR_INTERRUPT_MASK)); spin_unlock_irqrestore(&sb1250_imr_lock, flags); } @@ -122,9 +119,9 @@ void sb1250_unmask_irq(int cpu, int irq) u64 cur_ints; spin_lock_irqsave(&sb1250_imr_lock, flags); - cur_ints = ____raw_readq(KSEG1 + A_IMR_MAPPER(cpu) + R_IMR_INTERRUPT_MASK); + cur_ints = ____raw_readq(IOADDR(A_IMR_MAPPER(cpu) + R_IMR_INTERRUPT_MASK)); cur_ints &= ~(((u64) 1) << irq); - ____raw_writeq(cur_ints, KSEG1 + A_IMR_MAPPER(cpu) + R_IMR_INTERRUPT_MASK); + ____raw_writeq(cur_ints, IOADDR(A_IMR_MAPPER(cpu) + R_IMR_INTERRUPT_MASK)); spin_unlock_irqrestore(&sb1250_imr_lock, flags); } @@ -159,19 +156,19 @@ static void sb1250_set_affinity(unsigned /* Swizzle each CPU's IMR (but leave the IP selection alone) */ old_cpu = sb1250_irq_owner[irq]; - cur_ints = ____raw_readq(KSEG1 + A_IMR_MAPPER(old_cpu) + R_IMR_INTERRUPT_MASK); + cur_ints = ____raw_readq(IOADDR(A_IMR_MAPPER(old_cpu) + R_IMR_INTERRUPT_MASK)); int_on = !(cur_ints & (((u64) 1) << irq)); if (int_on) { /* If it was on, mask it */ cur_ints |= (((u64) 1) << irq); - ____raw_writeq(cur_ints, KSEG1 + A_IMR_MAPPER(old_cpu) + R_IMR_INTERRUPT_MASK); + ____raw_writeq(cur_ints, IOADDR(A_IMR_MAPPER(old_cpu) + R_IMR_INTERRUPT_MASK)); } sb1250_irq_owner[irq] = cpu; if (int_on) { /* unmask for the new CPU */ - cur_ints = ____raw_readq(KSEG1 + A_IMR_MAPPER(cpu) + R_IMR_INTERRUPT_MASK); + cur_ints = ____raw_readq(IOADDR(A_IMR_MAPPER(cpu) + R_IMR_INTERRUPT_MASK)); cur_ints &= ~(((u64) 1) << irq); - ____raw_writeq(cur_ints, KSEG1 + A_IMR_MAPPER(cpu) + R_IMR_INTERRUPT_MASK); + ____raw_writeq(cur_ints, IOADDR(A_IMR_MAPPER(cpu) + R_IMR_INTERRUPT_MASK)); } spin_unlock(&sb1250_imr_lock); spin_unlock_irqrestore(&desc->lock, flags); @@ -214,19 +211,24 @@ static void ack_sb1250_irq(unsigned int * deliver the interrupts to all CPUs (which makes affinity * changing easier for us) */ - pending = __raw_readq(KSEG1 + A_IMR_REGISTER(sb1250_irq_owner[irq], - R_IMR_LDT_INTERRUPT)); + pending = __raw_readq(IOADDR(A_IMR_REGISTER(sb1250_irq_owner[irq], + R_IMR_LDT_INTERRUPT))); pending &= ((u64)1 << (irq)); if (pending) { int i; for (i=0; i -#define duart_out(reg, val) csr_out32(val, KSEG1 + A_DUART_CHANREG(kgdb_port,reg)) -#define duart_in(reg) csr_in32(KSEG1 + A_DUART_CHANREG(kgdb_port,reg)) +#define duart_out(reg, val) csr_out32(val, IOADDR(A_DUART_CHANREG(kgdb_port,reg))) +#define duart_in(reg) csr_in32(IOADDR(A_DUART_CHANREG(kgdb_port,reg))) void sb1250_kgdb_interrupt(struct pt_regs *regs) { @@ -430,7 +427,7 @@ void sb1250_kgdb_interrupt(struct pt_reg * host to stop the break, since we would see another * interrupt on the end-of-break too) */ - kstat_this_cpu.irqs[K_INT_UART_1]++; + kstat_this_cpu.irqs[kgdb_irq]++; mdelay(500); duart_out(R_DUART_CMD, V_DUART_MISC_CMD_RESET_BREAK_INT | M_DUART_RX_EN | M_DUART_TX_EN); --- diff/arch/mips/sibyte/sb1250/irq_handler.S 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sibyte/sb1250/irq_handler.S 2004-02-23 13:56:38.000000000 +0000 @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -53,8 +52,7 @@ .set push .set noreorder .set noat - #.set mips64 - .set mips4 + .set mips64 .align 5 NESTED(sb1250_irq_handler, PT_SIZE, sp) SAVE_ALL @@ -136,8 +134,7 @@ beqz s0, 4f /* No interrupts. Return */ move a1, sp -3: #dclz s1, s0 /* Find the next interrupt */ - .word 0x72118824 # dclz s1, s0 +3: dclz s1, s0 /* Find the next interrupt */ dsubu a0, zero, s1 daddiu a0, a0, 63 jal do_IRQ --- diff/arch/mips/sibyte/sb1250/prom.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sibyte/sb1250/prom.c 2004-02-23 13:56:38.000000000 +0000 @@ -27,8 +27,6 @@ #include #include -extern char arcs_cmdline[]; - #ifdef CONFIG_EMBEDDED_RAMDISK /* These are symbols defined by the ramdisk linker script */ extern unsigned char __rd_start; @@ -91,9 +89,9 @@ static void prom_linux_exit(void) } /* - * prom_init is called just after the cpu type is determined, from init_arch() + * prom_init is called just after the cpu type is determined, from setup_arch() */ -__init int prom_init(int argc, char **argv, char **envp, int *prom_vec) +void __init prom_init(void) { _machine_restart = (void (*)(char *))prom_linux_exit; _machine_halt = prom_linux_exit; @@ -103,13 +101,12 @@ __init int prom_init(int argc, char **ar mips_machgroup = MACH_GROUP_SIBYTE; prom_meminit(); - - return 0; } -void prom_free_prom_memory(void) +unsigned long __init prom_free_prom_memory(void) { /* Not sure what I'm supposed to do here. Nothing, I think */ + return 0; } void prom_putchar(char c) --- diff/arch/mips/sibyte/sb1250/setup.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sibyte/sb1250/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -15,7 +15,7 @@ * 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 @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -154,7 +153,7 @@ void sb1250_setup(void) int bad_config = 0; sb1_pass = read_c0_prid() & 0xff; - sys_rev = __raw_readq(IO_SPACE_BASE | A_SCD_SYSTEM_REVISION); + sys_rev = __raw_readq(IOADDR(A_SCD_SYSTEM_REVISION)); soc_type = SYS_SOC_TYPE(sys_rev); soc_pass = G_SYS_REVISION(sys_rev); @@ -163,11 +162,8 @@ void sb1250_setup(void) machine_restart(NULL); } - plldiv = G_SYS_PLL_DIV(__raw_readq(IO_SPACE_BASE | A_SCD_SYSTEM_CFG)); + plldiv = G_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG))); zbbus_mhz = ((plldiv >> 1) * 50) + ((plldiv & 1) * 25); -#ifndef CONFIG_SB1_PASS_1_WORKAROUNDS - __raw_writeq(0, KSEG1 + A_SCD_ZBBUS_CYCLE_COUNT); -#endif prom_printf("Broadcom SiByte %s %s @ %d MHz (SB1 rev %d)\n", soc_str, pass_str, zbbus_mhz * 2, sb1_pass); --- diff/arch/mips/sibyte/sb1250/smp.c 2003-08-26 10:00:52.000000000 +0100 +++ source/arch/mips/sibyte/sb1250/smp.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001 Broadcom Corporation + * Copyright (C) 2001, 2002, 2003 Broadcom Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,30 +28,44 @@ #include #include -extern irqreturn_t smp_call_function_interrupt(int irq, void *dev, - struct pt_regs *regs); -extern void smp_tune_scheduling(void); - -/* - * These are routines for dealing with the sb1250 smp capabilities - * independent of board/firmware - */ - -static u64 mailbox_set_regs[] = { - KSEG1 + A_IMR_CPU0_BASE + R_IMR_MAILBOX_SET_CPU, - KSEG1 + A_IMR_CPU1_BASE + R_IMR_MAILBOX_SET_CPU +static void *mailbox_set_regs[] = { + (void *)IOADDR(A_IMR_CPU0_BASE + R_IMR_MAILBOX_SET_CPU), + (void *)IOADDR(A_IMR_CPU1_BASE + R_IMR_MAILBOX_SET_CPU) }; -static u64 mailbox_clear_regs[] = { - KSEG1 + A_IMR_CPU0_BASE + R_IMR_MAILBOX_CLR_CPU, - KSEG1 + A_IMR_CPU1_BASE + R_IMR_MAILBOX_CLR_CPU +static void *mailbox_clear_regs[] = { + (void *)IOADDR(A_IMR_CPU0_BASE + R_IMR_MAILBOX_CLR_CPU), + (void *)IOADDR(A_IMR_CPU1_BASE + R_IMR_MAILBOX_CLR_CPU) }; -static u64 mailbox_regs[] = { - KSEG1 + A_IMR_CPU0_BASE + R_IMR_MAILBOX_CPU, - KSEG1 + A_IMR_CPU1_BASE + R_IMR_MAILBOX_CPU +static void *mailbox_regs[] = { + (void *)IOADDR(A_IMR_CPU0_BASE + R_IMR_MAILBOX_CPU), + (void *)IOADDR(A_IMR_CPU1_BASE + R_IMR_MAILBOX_CPU) }; +/* + * SMP init and finish on secondary CPUs + */ +void sb1250_smp_init(void) +{ + unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 | + STATUSF_IP1 | STATUSF_IP0; + + /* Set interrupt mask, but don't enable */ + change_c0_status(ST0_IM, imask); +} + +void sb1250_smp_finish(void) +{ + extern void sb1250_time_init(void); + sb1250_time_init(); + local_irq_enable(); +} + +/* + * These are routines for dealing with the sb1250 smp capabilities + * independent of board/firmware + */ /* * Simple enough; everything is set up, so just poke the appropriate mailbox @@ -62,14 +76,8 @@ void core_send_ipi(int cpu, unsigned int __raw_writeq((((u64)action)<< 48), mailbox_set_regs[cpu]); } - -void sb1250_smp_finish(void) -{ - extern void sb1_sanitize_tlb(void); - - sb1_sanitize_tlb(); - sb1250_time_init(); -} +extern irqreturn_t smp_call_function_interrupt(int irq, void *dev, + struct pt_regs *regs); void sb1250_mailbox_interrupt(struct pt_regs *regs) { @@ -78,10 +86,10 @@ void sb1250_mailbox_interrupt(struct pt_ kstat_this_cpu.irqs[K_INT_MBOX_0]++; /* Load the mailbox register to figure out what we're supposed to do */ - action = (__raw_readq(mailbox_regs[cpu]) >> 48) & 0xffff; + action = (____raw_readq(mailbox_regs[cpu]) >> 48) & 0xffff; /* Clear the mailbox to clear the interrupt */ - __raw_writeq(((u64)action)<<48, mailbox_clear_regs[cpu]); + ____raw_writeq(((u64)action)<<48, mailbox_clear_regs[cpu]); /* * Nothing to do for SMP_RESCHEDULE_YOURSELF; returning from the @@ -92,66 +100,3 @@ void sb1250_mailbox_interrupt(struct pt_ smp_call_function_interrupt(0, NULL, regs); } } - -extern atomic_t cpus_booted; -extern void prom_setup_smp(void); -extern int prom_boot_secondary(int cpu, unsigned long sp, unsigned long gp); - -void __init smp_boot_cpus(void) -{ - int cur_cpu = 0; - int cpu; - - prom_setup_smp(); - init_new_context(current, &init_mm); - current_thread_info()->cpu = 0; - cpu_data[0].udelay_val = loops_per_jiffy; - cpu_data[0].asid_cache = ASID_FIRST_VERSION; - cpus_clear(cpu_online_map); - cpu_set(0, cpu_online_map); - atomic_set(&cpus_booted, 1); /* Master CPU is already booted... */ - smp_tune_scheduling(); - - /* - * This loop attempts to compensate for "holes" in the CPU - * numbering. It's overkill, but general. - */ - for (cpu = 1; cpu < num_online_cpus(); ) { - struct task_struct *idle; - struct pt_regs regs; - int retval; - printk("Starting CPU %d... ", cpu); - - /* Spawn a new process normally. Grab a pointer to - its task struct so we can mess with it */ - idle = copy_process(CLONE_VM | CLONE_IDLETASK, 0, ®s, 0, - NULL, NULL); - if (IS_ERR(idle)) - panic("failed fork for CPU %d", cpu); - - /* - * We remove it from the pidhash and the runqueue - * once we got the process: - */ - init_idle(idle, cpu); - - unhash_process(idle); - - do { - /* Iterate until we find a CPU that comes up */ - cur_cpu++; - retval = prom_boot_secondary(cur_cpu, - (unsigned long)idle + THREAD_SIZE - 32, - (unsigned long)idle); - } while (!retval && (cur_cpu < NR_CPUS)); - if (retval) { - cpu++; - } else { - panic("CPU discovery disaster"); - } - } - - /* Wait for everyone to come up */ - while (atomic_read(&cpus_booted) != num_online_cpus()); - smp_threads_ready = 1; -} --- diff/arch/mips/sibyte/sb1250/time.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sibyte/sb1250/time.c 2004-02-23 13:56:38.000000000 +0000 @@ -67,23 +67,21 @@ void sb1250_time_init(void) sb1250_mask_irq(cpu, irq); /* Map the timer interrupt to ip[4] of this cpu */ - __raw_writeq(IMR_IP4_VAL, KSEG1 + A_IMR_REGISTER(cpu, R_IMR_INTERRUPT_MAP_BASE) - + (irq<<3)); + __raw_writeq(IMR_IP4_VAL, IOADDR(A_IMR_REGISTER(cpu, R_IMR_INTERRUPT_MAP_BASE) + + (irq << 3))); /* the general purpose timer ticks at 1 Mhz independent if the rest of the system */ /* Disable the timer and set up the count */ - __raw_writeq(0, KSEG1 + A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG)); + __raw_writeq(0, IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG))); #ifdef CONFIG_SIMULATION - __raw_writeq(50000 / HZ, KSEG1 + - A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_INIT)); + __raw_writeq(50000 / HZ, IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_INIT))); #else - __raw_writeq(1000000/HZ, KSEG1 + - A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_INIT)); + __raw_writeq(1000000/HZ, IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_INIT))); #endif /* Set the timer running */ __raw_writeq(M_SCD_TIMER_ENABLE|M_SCD_TIMER_MODE_CONTINUOUS, - KSEG1 + A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG)); + IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG))); sb1250_unmask_irq(cpu, irq); sb1250_steal_irq(irq); @@ -105,7 +103,7 @@ void sb1250_timer_interrupt(struct pt_re /* Reset the timer */ ____raw_writeq(M_SCD_TIMER_ENABLE|M_SCD_TIMER_MODE_CONTINUOUS, - KSEG1 + A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG)); + IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG))); /* * CPU 0 handles the global timer interrupt job @@ -129,7 +127,7 @@ void sb1250_timer_interrupt(struct pt_re unsigned long sb1250_gettimeoffset(void) { unsigned long count = - __raw_readq(KSEG1 + A_SCD_TIMER_REGISTER(0, R_SCD_TIMER_CNT)); + __raw_readq(IOADDR(A_SCD_TIMER_REGISTER(0, R_SCD_TIMER_CNT))); return 1000000/HZ - count; } --- diff/arch/mips/sibyte/swarm/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/sibyte/swarm/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -1,3 +1,3 @@ -lib-y = setup.o cmdline.o rtc_xicor1241.o rtc_m41t81.o +lib-y = setup.o rtc_xicor1241.o rtc_m41t81.o lib-$(CONFIG_KGDB) += dbg_io.o --- diff/arch/mips/sibyte/swarm/dbg_io.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sibyte/swarm/dbg_io.c 2004-02-23 13:56:38.000000000 +0000 @@ -37,8 +37,8 @@ static int duart_initialized = 0; /* 0: /* -------------------- END OF CONFIG --------------------- */ extern int kgdb_port; -#define duart_out(reg, val) csr_out32(val, KSEG1 + A_DUART_CHANREG(kgdb_port,reg)) -#define duart_in(reg) csr_in32(KSEG1 + A_DUART_CHANREG(kgdb_port,reg)) +#define duart_out(reg, val) csr_out32(val, IOADDR(A_DUART_CHANREG(kgdb_port,reg))) +#define duart_in(reg) csr_in32(IOADDR(A_DUART_CHANREG(kgdb_port,reg))) void putDebugChar(unsigned char c); unsigned char getDebugChar(void); --- diff/arch/mips/sibyte/swarm/rtc_m41t81.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sibyte/swarm/rtc_m41t81.c 2004-02-23 13:56:38.000000000 +0000 @@ -82,7 +82,7 @@ #define M41T81REG_SQW 0x13 /* square wave register */ #define M41T81_CCR_ADDRESS 0x68 -#define SMB_CSR(reg) (KSEG1 | A_SMB_REGISTER(1, reg)) +#define SMB_CSR(reg) (IOADDR(A_SMB_REGISTER(1, reg))) static int m41t81_read(uint8_t addr) { --- diff/arch/mips/sibyte/swarm/rtc_xicor1241.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sibyte/swarm/rtc_xicor1241.c 2004-02-23 13:56:38.000000000 +0000 @@ -57,7 +57,7 @@ #define X1241_CCR_ADDRESS 0x6F -#define SMB_CSR(reg) (KSEG1 | A_SMB_REGISTER(1, reg)) +#define SMB_CSR(reg) (IOADDR(A_SMB_REGISTER(1, reg))) static int xicor_read(uint8_t addr) { --- diff/arch/mips/sibyte/swarm/setup.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sibyte/swarm/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000, 2001 Broadcom Corporation + * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,13 +20,12 @@ * Setup code for the SWARM board */ +#include #include #include #include #include #include -#include -#include #include #include @@ -40,13 +39,6 @@ #include #include -extern struct rtc_ops *rtc_ops; -extern struct rtc_ops swarm_rtc_ops; - -#ifdef CONFIG_BLK_DEV_IDE -extern struct ide_ops sibyte_ide_ops; -#endif - extern void sb1250_setup(void); extern int xicor_probe(void); @@ -88,7 +80,7 @@ int swarm_be_handler(struct pt_regs *reg return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL); } -void __init swarm_setup(void) +static void __init swarm_setup(void) { extern int panic_timeout; @@ -125,14 +117,7 @@ void __init swarm_setup(void) #endif " CFE\n"); -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &sibyte_ide_ops; -#endif - #ifdef CONFIG_VT -#ifdef CONFIG_DUMMY_CONSOLE - conswitchp = &dummy_con; -#endif screen_info = (struct screen_info) { 0, 0, /* orig-x, orig-y */ 0, /* unused */ @@ -148,6 +133,8 @@ void __init swarm_setup(void) #endif } +early_initcall(swarm_setup); + #ifdef LEDS_PHYS #ifdef CONFIG_SIBYTE_CARMEL @@ -157,7 +144,7 @@ void __init swarm_setup(void) #endif #define setled(index, c) \ - ((unsigned char *)(LEDS_PHYS|IO_SPACE_BASE|0x20))[(3-(index))<<3] = (c) + ((unsigned char *)(IOADDR(LEDS_PHYS)+0x20))[(3-(index))<<3] = (c) void setleds(char *str) { int i; --- diff/arch/mips/sibyte/swarm/time.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sibyte/swarm/time.c 2004-02-23 13:56:38.000000000 +0000 @@ -75,7 +75,7 @@ static unsigned int usec_bias = 0; #define X1241_CCR_ADDRESS 0x6F -#define SMB_CSR(reg) (KSEG1 | A_SMB_REGISTER(1, reg)) +#define SMB_CSR(reg) (IOADDR(A_SMB_REGISTER(1, reg))) static int xicor_read(uint8_t addr) { --- diff/arch/mips/sni/Makefile 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sni/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,6 +2,6 @@ # Makefile for the SNI specific part of the kernel # -obj-y += int-handler.o io.o irq.o pcimt_scache.o reset.o setup.o +obj-y += int-handler.o irq.o pcimt_scache.o reset.o setup.o EXTRA_AFLAGS := $(CFLAGS) --- diff/arch/mips/sni/int-handler.S 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sni/int-handler.S 2004-02-23 13:56:38.000000000 +0000 @@ -37,8 +37,12 @@ led_cache: .byte 0 mfc0 t1, CP0_CAUSE and t0, t1 - andi t1, t0, 0x4a00 # hardware interrupt 1 - bnez t1, _hwint134 + andi t1, t0, 0x0800 # hardware interrupt 1 + bnez t1, _hwint1 + andi t1, t0, 0x4000 # hardware interrupt 4 + bnez t1, _hwint4 + andi t1, t0, 0x2000 # hardware interrupt 3 + bnez t1, _hwint3 andi t1, t0, 0x1000 # hardware interrupt 2 bnez t1, _hwint2 andi t1, t0, 0x8000 # hardware interrupt 5 @@ -55,20 +59,48 @@ led_cache: .byte 0 /* hwint0 should deal with MP agent, ASIC PCI, EISA NMI and debug button interrupts. */ _hwint0: jal pciasic_hwint0 - move a1, sp + move a0, sp + j ret_from_irq + nop /* - * hwint 1 deals with EISA and SCSI interrupts, - * hwint 3 should deal with the PCI A - D interrupts, - * hwint 4 is used for only the onboard PCnet 32. + * hwint 1 deals with EISA and SCSI interrupts */ -_hwint134: jal pciasic_hwint134 +_hwint1: jal pciasic_hwint1 + move a0, sp + j ret_from_irq + nop -/* This interrupt was used for the com1 console on the first prototypes. */ +/* + * This interrupt was used for the com1 console on the first prototypes; + * it's unsed otherwise + */ _hwint2: jal pciasic_hwint2 + move a0, sp + j ret_from_irq + nop + +/* + * hwint 3 are the PCI interrupts A - D + */ +_hwint3: jal pciasic_hwint3 + move a0, sp + j ret_from_irq + nop + +/* + * hwint 4 is used for only the onboard PCnet 32. + */ +_hwint4: jal pciasic_hwint4 + move a0, sp + j ret_from_irq + nop /* hwint5 is the r4k count / compare interrupt */ _hwint5: jal pciasic_hwint5 + move a0, sp + j ret_from_irq + nop END(sni_rm200_pci_handle_int) --- diff/arch/mips/sni/irq.c 2003-08-20 14:16:25.000000000 +0100 +++ source/arch/mips/sni/irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -21,7 +21,15 @@ spinlock_t pciasic_lock = SPIN_LOCK_UNLO extern asmlinkage void sni_rm200_pci_handle_int(void); -static void enable_pciasic_irq(unsigned int irq); +static void enable_pciasic_irq(unsigned int irq) +{ + unsigned int mask = 1 << (irq - PCIMT_IRQ_INT2); + unsigned long flags; + + spin_lock_irqsave(&pciasic_lock, flags); + *(volatile u8 *) PCIMT_IRQSEL |= mask; + spin_unlock_irqrestore(&pciasic_lock, flags); +} static unsigned int startup_pciasic_irq(unsigned int irq) { @@ -41,16 +49,6 @@ void disable_pciasic_irq(unsigned int ir spin_unlock_irqrestore(&pciasic_lock, flags); } -static void enable_pciasic_irq(unsigned int irq) -{ - unsigned int mask = 1 << (irq - PCIMT_IRQ_INT2); - unsigned long flags; - - spin_lock_irqsave(&pciasic_lock, flags); - *(volatile u8 *) PCIMT_IRQSEL |= mask; - spin_unlock_irqrestore(&pciasic_lock, flags); -} - #define mask_and_ack_pciasic_irq disable_pciasic_irq static void end_pciasic_irq(unsigned int irq) @@ -60,7 +58,7 @@ static void end_pciasic_irq(unsigned int } static struct hw_interrupt_type pciasic_irq_type = { - "PCIASIC", + "ASIC-PCI", startup_pciasic_irq, shutdown_pciasic_irq, enable_pciasic_irq, @@ -92,36 +90,72 @@ void pciasic_hwint5(struct pt_regs *regs panic("hwint5 and no handler yet"); } -static inline int ls1bit8(unsigned int x) +static unsigned int ls1bit8(unsigned int x) { - int b = 8, s; + int b = 7, s; - x <<= 24; s = 4; if ((x & 0x0f) == 0) s = 0; b -= s; x <<= s; - s = 2; if ((x & 0x03) == 0) s = 0; b -= s; x <<= s; - s = 1; if ((x & 0x01) == 0) s = 0; b -= s; + s = 2; if ((x & 0x30) == 0) s = 0; b -= s; x <<= s; + s = 1; if ((x & 0x40) == 0) s = 0; b -= s; return b; } /* * hwint 1 deals with EISA and SCSI interrupts, + * + * The EISA_INT bit in CSITPEND is high active, all others are low active. + */ +void pciasic_hwint1(struct pt_regs *regs) +{ + u8 pend = *(volatile char *)PCIMT_CSITPEND; + unsigned long flags; + + if (pend & IT_EISA) { + int irq; + /* + * Note: ASIC PCI's builtin interrupt achknowledge feature is + * broken. Using it may result in loss of some or all i8259 + * interupts, so don't use PCIMT_INT_ACKNOWLEDGE ... + */ + irq = i8259_irq(); + if (unlikely(irq < 0)) + return; + + do_IRQ(irq, regs); + } + + if (!(pend & IT_SCSI)) { + flags = read_c0_status(); + clear_c0_status(ST0_IM); + do_IRQ(PCIMT_IRQ_SCSI, regs); + write_c0_status(flags); + } +} + +/* * hwint 3 should deal with the PCI A - D interrupts, - * hwint 4 is used for only the onboard PCnet 32. */ -void pciasic_hwint134(struct pt_regs *regs) +void pciasic_hwint3(struct pt_regs *regs) { u8 pend = *(volatile char *)PCIMT_CSITPEND; int irq; + pend &= (IT_INTA | IT_INTB | IT_INTC | IT_INTD); + clear_c0_status(IE_IRQ3); irq = PCIMT_IRQ_INT2 + ls1bit8(pend); - if (irq == PCIMT_IRQ_EISA) { - pend = *(volatile char *)PCIMT_INT_ACKNOWLEDGE; - if (!(pend ^ 0xff)) - return; - } do_IRQ(irq, regs); - return; + set_c0_status(IE_IRQ3); +} + +/* + * hwint 4 is used for only the onboard PCnet 32. + */ +void pciasic_hwint4(struct pt_regs *regs) +{ + clear_c0_status(IE_IRQ4); + do_IRQ(PCIMT_IRQ_ETHERNET, regs); + set_c0_status(IE_IRQ4); } void __init init_pciasic(void) @@ -156,4 +190,6 @@ void __init init_IRQ (void) irq_desc[i].depth = 1; irq_desc[i].handler = &pciasic_irq_type; } + + change_c0_status(ST0_IM, IE_IRQ1|IE_IRQ2|IE_IRQ3|IE_IRQ4); } --- diff/arch/mips/sni/setup.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/mips/sni/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -5,7 +5,7 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (C) 1996, 1997, 1998, 2000, 2003 by Ralf Baechle + * Copyright (C) 1996, 1997, 1998, 2000, 2003, 2004 by Ralf Baechle */ #include #include @@ -14,17 +14,20 @@ #include #include #include -#include -#include #include +#include #include #include -#include +#include +#include +#include #include #include #include #include +#include +#include #include #include #include @@ -36,9 +39,6 @@ extern void sni_machine_restart(char *co extern void sni_machine_halt(void); extern void sni_machine_power_off(void); -extern struct ide_ops std_ide_ops; -extern struct rtc_ops std_rtc_ops; - static void __init sni_rm200_pci_timer_setup(struct irqaction *irq) { /* set the clock to 100 Hz */ @@ -48,9 +48,6 @@ static void __init sni_rm200_pci_timer_s setup_irq(0, irq); } - -extern unsigned char sni_map_isa_cache; - /* * A bit more gossip about the iron we're running on ... */ @@ -73,56 +70,135 @@ static inline void sni_pcimt_detect(void printk("%s.\n", boardtype); } -void __init sni_rm200_pci_setup(void) +static void __init sni_display_setup(void) +{ +#ifdef CONFIG_VT +#if defined(CONFIG_VGA_CONSOLE) + struct screen_info *si = &screen_info; + DISPLAY_STATUS *di; + + di = ArcGetDisplayStatus(1); + + if (di) { + si->orig_x = di->CursorXPosition; + si->orig_y = di->CursorYPosition; + si->orig_video_cols = di->CursorMaxXPosition; + si->orig_video_lines = di->CursorMaxYPosition; + si->orig_video_isVGA = VIDEO_TYPE_VGAC; + si->orig_video_points = 16; + } +#endif +#endif +} + +static struct resource sni_io_resource = { + "PCIMT IO MEM", 0x00001000UL, 0x03bfffffUL, IORESOURCE_IO, +}; + +static struct resource pcimt_io_resources[] = { + { "dma1", 0x00, 0x1f, IORESOURCE_BUSY }, + { "timer", 0x40, 0x5f, IORESOURCE_BUSY }, + { "keyboard", 0x60, 0x6f, IORESOURCE_BUSY }, + { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY }, + { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY }, + { "PCI config data", 0xcfc, 0xcff, IORESOURCE_BUSY } +}; + +static struct resource sni_mem_resource = { + "PCIMT PCI MEM", 0x10000000UL, 0xffffffffUL, IORESOURCE_MEM +}; + +/* + * The RM200/RM300 has a few holes in it's PCI/EISA memory address space used + * for other purposes. Be paranoid and allocate all of the before the PCI + * code gets a chance to to map anything else there ... + * + * This leaves the following areas available: + * + * 0x10000000 - 0x1009ffff (640kB) PCI/EISA/ISA Bus Memory + * 0x10100000 - 0x13ffffff ( 15MB) PCI/EISA/ISA Bus Memory + * 0x18000000 - 0x1fbfffff (124MB) PCI/EISA Bus Memory + * 0x1ff08000 - 0x1ffeffff (816kB) PCI/EISA Bus Memory + * 0xa0000000 - 0xffffffff (1.5GB) PCI/EISA Bus Memory + */ +static struct resource pcimt_mem_resources[] = { + { "Video RAM area", 0x100a0000, 0x100bffff, IORESOURCE_BUSY }, + { "ISA Reserved", 0x100c0000, 0x100fffff, IORESOURCE_BUSY }, + { "PCI IO", 0x14000000, 0x17bfffff, IORESOURCE_BUSY }, + { "Cache Replacement Area", 0x17c00000, 0x17ffffff, IORESOURCE_BUSY}, + { "PCI INT Acknowledge", 0x1a000000, 0x1a000003, IORESOURCE_BUSY }, + { "Boot PROM", 0x1fc00000, 0x1fc7ffff, IORESOURCE_BUSY}, + { "Diag PROM", 0x1fc80000, 0x1fcfffff, IORESOURCE_BUSY}, + { "X-Bus", 0x1fd00000, 0x1fdfffff, IORESOURCE_BUSY}, + { "BIOS map", 0x1fe00000, 0x1fefffff, IORESOURCE_BUSY}, + { "NVRAM / EEPROM", 0x1ff00000, 0x1ff7ffff, IORESOURCE_BUSY}, + { "ASIC PCI", 0x1fff0000, 0x1fffefff, IORESOURCE_BUSY}, + { "MP Agent", 0x1ffff000, 0x1fffffff, IORESOURCE_BUSY}, + { "Main Memory", 0x20000000, 0x9fffffff, IORESOURCE_BUSY} +}; + +static void __init sni_resource_init(void) +{ + int i; + + /* request I/O space for devices used on all i[345]86 PCs */ + for (i = 0; i < ARRAY_SIZE(pcimt_io_resources); i++) + request_resource(&ioport_resource, pcimt_io_resources + i); + + /* request mem space for pcimt-specific devices */ + for (i = 0; i < ARRAY_SIZE(pcimt_mem_resources); i++) + request_resource(&sni_mem_resource, pcimt_mem_resources + i); + + ioport_resource.end = sni_io_resource.end; +} + +extern struct pci_ops sni_pci_ops; + +static struct pci_controller sni_controller = { + .pci_ops = &sni_pci_ops, + .mem_resource = &sni_mem_resource, + .mem_offset = 0x10000000UL, + .io_resource = &sni_io_resource, + .io_offset = 0x00000000UL +}; + +static inline void sni_pcimt_time_init(void) +{ + rtc_get_time = mc146818_get_cmos_time; + rtc_set_time = mc146818_set_rtc_mmss; +} + +static int __init sni_rm200_pci_setup(void) { sni_pcimt_detect(); sni_pcimt_sc_init(); + sni_pcimt_time_init(); set_io_port_base(SNI_PORT_BASE); + ioport_resource.end = sni_io_resource.end; /* * Setup (E)ISA I/O memory access stuff */ isa_slot_offset = 0xb0000000; - // sni_map_isa_cache = 0; #ifdef CONFIG_EISA EISA_bus = 1; #endif - request_region(0x00,0x20,"dma1"); - request_region(0x40,0x20,"timer"); - /* XXX FIXME: CONFIG_RTC */ - request_region(0x70,0x10,"rtc"); - request_region(0x80,0x10,"dma page reg"); - request_region(0xc0,0x20,"dma2"); + sni_resource_init(); board_timer_setup = sni_rm200_pci_timer_setup; _machine_restart = sni_machine_restart; _machine_halt = sni_machine_halt; _machine_power_off = sni_machine_power_off; - /* - * Some cluefull person has placed the PCI config data directly in - * the I/O port space ... - */ - request_region(0xcfc,0x04,"PCI config data"); + sni_display_setup(); -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &std_ide_ops; +#ifdef CONFIG_PCI + register_pci_controller(&sni_controller); #endif - conswitchp = &vga_con; - - screen_info = (struct screen_info) { - 0, 0, /* orig-x, orig-y */ - 0, /* unused */ - 52, /* orig_video_page */ - 3, /* orig_video_mode */ - 80, /* orig_video_cols */ - 4626, 3, 9, /* unused, ega_bx, unused */ - 50, /* orig_video_lines */ - 0x22, /* orig_video_isVGA */ - 16 /* orig_video_points */ - }; - rtc_ops = &std_rtc_ops; + return 0; } + +early_initcall(sni_rm200_pci_setup); --- diff/arch/mips/tx4927/common/tx4927_irq.c 2003-09-17 12:28:02.000000000 +0100 +++ source/arch/mips/tx4927/common/tx4927_irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -23,6 +23,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include #include #include --- diff/arch/mips/tx4927/common/tx4927_irq_handler.S 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/tx4927/common/tx4927_irq_handler.S 2004-02-23 13:56:38.000000000 +0000 @@ -29,7 +29,6 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include #include #include #include --- diff/arch/mips/tx4927/common/tx4927_setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/tx4927/common/tx4927_setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,8 +1,4 @@ /* - * linux/arch/mips/tx4927/common/tx4927_setup.c - * - * common tx4927 setup stuff - * * Author: MontaVista Software, Inc. * source@mvista.com * @@ -28,7 +24,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ - +#include #include #include #include @@ -49,13 +45,11 @@ #include #include #include -#include #include #undef DEBUG -void __init tx4927_setup(void); void __init tx4927_time_init(void); void __init tx4927_timer_setup(struct irqaction *irq); void dump_cp0(char *key); @@ -70,7 +64,7 @@ static void tx4927_write_buffer_flush(vo } -void __init tx4927_setup(void) +static void __init tx4927_setup(void) { board_time_init = tx4927_time_init; board_timer_setup = tx4927_timer_setup; @@ -86,6 +80,7 @@ void __init tx4927_setup(void) return; } +early_initcall(tx4927_setup); void __init tx4927_time_init(void) { @@ -120,7 +115,7 @@ void __init tx4927_timer_setup(struct ir /* to generate the first timer interrupt */ c1 = read_c0_count(); - count = c1 + (mips_counter_frequency / HZ); + count = c1 + (mips_hpt_frequency / HZ); write_c0_compare(count); c2 = read_c0_count(); --- diff/arch/mips/tx4927/toshiba_rbtx4927/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/tx4927/toshiba_rbtx4927/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,7 +2,4 @@ obj-y += toshiba_rbtx4927_prom.o obj-y += toshiba_rbtx4927_setup.o obj-y += toshiba_rbtx4927_irq.o -obj-$(CONFIG_PCI) += toshiba_rbtx4927_pci_fixup.o -obj-$(CONFIG_PCI) += toshiba_rbtx4927_pci_ops.o - EXTRA_AFLAGS := $(CFLAGS) --- diff/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c 2003-09-17 12:28:02.000000000 +0100 +++ source/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c 2004-02-23 13:56:38.000000000 +0000 @@ -124,7 +124,6 @@ JP7 is not bus master -- do NOT use -- o #include #include #include -#include #include #include #include @@ -132,7 +131,6 @@ JP7 is not bus master -- do NOT use -- o #include #include #include -#include #include #include #ifdef CONFIG_RTC_DS1742 --- diff/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_prom.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_prom.c 2004-02-23 13:56:38.000000000 +0000 @@ -36,14 +36,10 @@ #include #include -#ifndef COMMAND_LINE_SIZE -#define COMMAND_LINE_SIZE CL_SIZE -#endif - -char arcs_cmdline[COMMAND_LINE_SIZE] = "console=ttyS0,38400 ip=any root=nfs rw"; - -void __init prom_init_cmdline(int argc, char **argv) +void __init prom_init_cmdline(void) { + int argc = (int) fw_arg0; + char **argv = (char **) fw_arg1; int i; /* Always ignore the "-c" at argv[0] */ /* ignore all built-in args if any f/w args given */ @@ -59,14 +55,14 @@ void __init prom_init_cmdline(int argc, } } -void __init prom_init(int argc, char **argv, char **envp, int *pvec) +void __init prom_init(void) { + const char* toshiba_name_list[] = GROUP_TOSHIBA_NAMES; extern int tx4927_get_mem_size(void); + extern char* toshiba_name; int msize; - const char* toshiba_name_list[] = GROUP_TOSHIBA_NAMES; - extern char* toshiba_name; - prom_init_cmdline(argc, argv); + prom_init_cmdline(); mips_machgroup = MACH_GROUP_TOSHIBA; @@ -81,13 +77,9 @@ void __init prom_init(int argc, char **a add_memory_region(0, msize << 20, BOOT_MEM_RAM); } -void __init prom_free_prom_memory(void) -{ -} - - -void __init prom_fixup_mem_map(unsigned long start, unsigned long end) +unsigned long __init prom_free_prom_memory(void) { + return 0; } const char *get_system_type(void) --- diff/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c 2003-08-20 14:16:08.000000000 +0100 +++ source/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -52,18 +52,14 @@ #include #include #include -#include #include #include -#include #include #include #include #include -#include #include #include -#include #ifdef CONFIG_RTC_DS1742 #include #endif @@ -73,20 +69,11 @@ #include #ifdef CONFIG_PCI #include -#include -#include -#include -#include #include #endif -#ifdef CONFIG_PC_KEYB -#include -#endif #ifdef CONFIG_BLK_DEV_IDEPCI #include -#include #include -extern struct ide_ops std_ide_ops; #endif #undef TOSHIBA_RBTX4927_SETUP_DEBUG @@ -326,7 +313,7 @@ void print_pci_status(void) printk("PCIC STATUS %lx\n", tx4927_pcicptr->pcicstatus); } -static struct pci_dev *fake_pci_dev(struct pci_channel *hose, +static struct pci_dev *fake_pci_dev(struct pci_controller *hose, int top_bus, int busnr, int devfn) { static struct pci_dev dev; @@ -348,7 +335,7 @@ static struct pci_dev *fake_pci_dev(stru } #define EARLY_PCI_OP(rw, size, type) \ -static int early_##rw##_config_##size(struct pci_channel *hose, \ +static int early_##rw##_config_##size(struct pci_controller *hose, \ int top_bus, int bus, int devfn, int offset, type value) \ { \ return pci_##rw##_config_##size( \ @@ -363,22 +350,15 @@ EARLY_PCI_OP(write, byte, u8) EARLY_PCI_OP(write, word, u16) EARLY_PCI_OP(write, dword, u32) -static int __init tx4927_pcibios_init(int busno, struct pci_channel *hose) +static int __init tx4927_pcibios_init(int busno, struct pci_controller *hose) { - u32 pci_devfn; - int devfn_start = 0; - int devfn_stop = 0xff; unsigned int id; + u32 pci_devfn; TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS, "-\n"); - if (hose->first_devfn) - devfn_start = hose->first_devfn; - if (hose->last_devfn) - devfn_stop = hose->last_devfn; - - for (pci_devfn = devfn_start; pci_devfn < devfn_stop; pci_devfn++) { + for (pci_devfn = 0x0; pci_devfn < 0xff; pci_devfn++) { early_read_config_dword(hose, busno, busno, pci_devfn, PCI_VENDOR_ID, &id); @@ -604,7 +584,7 @@ static int __init tx4927_pcibios_init(in TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS, "+\n"); - return (busno); + return busno; } extern struct resource pci_io_resource; @@ -852,17 +832,9 @@ void tx4927_pci_setup(void) TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2, ":pci setup complete:\n"); - //tx4927_dump_pcic_settings(); - - { - struct pci_channel *p; - int busno; + //tx4927_dump_pcic_settings(); - busno = 0; - for (p = mips_pci_channels; p->pci_ops != NULL; p++) { - busno = tx4927_pcibios_init(busno, p) + 1; - } - } + tx4927_pcibios_init(0, &tx4927_controller); TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2, "+\n"); } @@ -972,31 +944,6 @@ void __init toshiba_rbtx4927_setup(void) _machine_halt = toshiba_rbtx4927_halt; _machine_power_off = toshiba_rbtx4927_power_off; - -#ifdef CONFIG_BLK_DEV_IDEPCI - { - TOSHIBA_RBTX4927_SETUP_DPRINTK - (TOSHIBA_RBTX4927_SETUP_SETUP, - ":ide_ops=&std_ide_ops(modified)\n"); - ide_ops = &std_ide_ops; - } -#else - { - TOSHIBA_RBTX4927_SETUP_DPRINTK - (TOSHIBA_RBTX4927_SETUP_SETUP, - ":ide_ops=\n"); - } -#endif - -#ifdef CONFIG_FB - { - conswitchp = &dummy_con; - } -#endif - - - - #ifdef CONFIG_PCI /* PCIC */ @@ -1063,7 +1010,7 @@ void __init toshiba_rbtx4927_setup(void) { u32 id = 0; - early_read_config_dword(&mips_pci_channels[0], 0, 0, 0x90, + early_read_config_dword(&tx4927_controller, 0, 0, 0x90, PCI_VENDOR_ID, &id); if (id == 0x94601055) { tx4927_using_backplane = 1; @@ -1073,30 +1020,6 @@ void __init toshiba_rbtx4927_setup(void) } } - - /* this is only done if backplane board installed, so must wait for pci */ -#ifdef CONFIG_PC_KEYB - { - if (tx4927_using_backplane) { - extern struct kbd_ops std_kbd_ops; - kbd_ops = &std_kbd_ops; - TOSHIBA_RBTX4927_SETUP_DPRINTK - (TOSHIBA_RBTX4927_SETUP_SETUP, - ":kbd_ops=&std_kbd_ops\n"); - } else { - TOSHIBA_RBTX4927_SETUP_DPRINTK - (TOSHIBA_RBTX4927_SETUP_SETUP, - ":kbd_ops=\n"); - } - } -#else - { - TOSHIBA_RBTX4927_SETUP_DPRINTK - (TOSHIBA_RBTX4927_SETUP_SETUP, - ":kbd_ops=\n"); - } -#endif - /* this is on ISA bus behind PCI bus, so need PCI up first */ #ifdef CONFIG_TOSHIBA_FPCIB0 { @@ -1167,7 +1090,7 @@ toshiba_rbtx4927_time_init(void) ":rtc_ds1742_init()+\n"); TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT, - ":Calibrate mips_counter_frequency-\n"); + ":Calibrate mips_hpt_frequency-\n"); rtc_ds1742_wait(); /* get the count */ @@ -1180,29 +1103,29 @@ toshiba_rbtx4927_time_init(void) c2 = read_c0_count(); TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT, - ":Calibrate mips_counter_frequency+\n"); + ":Calibrate mips_hpt_frequency+\n"); TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT, ":c1=%12u\n", c1); TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT, ":c2=%12u\n", c2); /* this diff is as close as we are going to get to counter ticks per sec */ - mips_counter_frequency = abs(c2 - c1); + mips_hpt_frequency = abs(c2 - c1); TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT, - ":f1=%12u\n", mips_counter_frequency); + ":f1=%12u\n", mips_hpt_frequency); /* round to 1/10th of a MHz */ - mips_counter_frequency /= (100 * 1000); - mips_counter_frequency *= (100 * 1000); + mips_hpt_frequency /= (100 * 1000); + mips_hpt_frequency *= (100 * 1000); TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT, - ":f2=%12u\n", mips_counter_frequency); + ":f2=%12u\n", mips_hpt_frequency); TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_INFO, - ":mips_counter_frequency=%uHz (%uMHz)\n", - mips_counter_frequency, - mips_counter_frequency / 1000000); + ":mips_hpt_frequency=%uHz (%uMHz)\n", + mips_hpt_frequency, + mips_hpt_frequency / 1000000); #else - mips_counter_frequency = 100000000; + mips_hpt_frequency = 100000000; #endif TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT, "+\n"); --- diff/arch/mips/vr4181/osprey/prom.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/vr4181/osprey/prom.c 2004-02-23 13:56:38.000000000 +0000 @@ -19,8 +19,6 @@ #include #include -char arcs_cmdline[CL_SIZE]; - const char *get_system_type(void) { return "NEC_Vr41xx Osprey"; @@ -30,10 +28,11 @@ const char *get_system_type(void) * [jsun] right now we assume it is the nec debug monitor, which does * not pass any arguments. */ -void __init prom_init() +void __init prom_init(void) { - strcpy(arcs_cmdline, "ip=bootp "); - strcat(arcs_cmdline, "ether=46,0x03fe0300,eth0 "); + // cmdline is now set in default config + // strcpy(arcs_cmdline, "ip=bootp "); + // strcat(arcs_cmdline, "ether=46,0x03fe0300,eth0 "); // strcpy(arcs_cmdline, "ether=0,0x0300,eth0 " // strcat(arcs_cmdline, "video=vr4181fb:xres:240,yres:320,bpp:8 "); @@ -44,11 +43,7 @@ void __init prom_init() add_memory_region(0, 16 << 20, BOOT_MEM_RAM); } -void __init prom_free_prom_memory(void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } - -void __init prom_fixup_mem_map(unsigned long start, unsigned long end) -{ -} - --- diff/arch/mips/vr4181/osprey/setup.c 2003-08-20 14:16:36.000000000 +0100 +++ source/arch/mips/vr4181/osprey/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -16,7 +16,6 @@ */ #include -#include #include #include #include @@ -32,7 +31,7 @@ extern void nec_osprey_power_off(void); extern void vr4181_init_serial(void); extern void vr4181_init_time(void); -void __init nec_osprey_setup(void) +static void __init nec_osprey_setup(void) { set_io_port_base(VR4181_PORT_BASE); isa_slot_offset = VR4181_ISAMEM_BASE; @@ -40,10 +39,6 @@ void __init nec_osprey_setup(void) vr4181_init_serial(); vr4181_init_time(); -#ifdef CONFIG_FB - conswitchp = &dummy_con; -#endif - _machine_restart = nec_osprey_restart; _machine_halt = nec_osprey_halt; _machine_power_off = nec_osprey_power_off; @@ -69,3 +64,5 @@ void __init nec_osprey_setup(void) */ *VR4181_GPINTTYPL = 0x3000; } + +early_initcall(nec_osprey_setup); --- diff/arch/mips/vr41xx/casio-e55/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/casio-e55/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -3,5 +3,3 @@ # obj-y += init.o setup.o - -obj-$(CONFIG_IDE) += ide-e55.o --- diff/arch/mips/vr41xx/casio-e55/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/casio-e55/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -13,22 +13,21 @@ * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ -#include #include #include #include #include -char arcs_cmdline[CL_SIZE]; - const char *get_system_type(void) { return "CASIO CASSIOPEIA E-11/15/55/65"; } -void __init prom_init(int argc, char **argv, unsigned long magic, int *prom_vec) +void __init prom_init(void) { + int argc = fw_arg0; + char **argv = (char **) fw_arg1; int i; /* @@ -44,6 +43,7 @@ void __init prom_init(int argc, char **a mips_machtype = MACH_CASIO_E55; } -void __init prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } --- diff/arch/mips/vr41xx/casio-e55/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/casio-e55/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,28 +1,29 @@ /* - * FILE NAME - * arch/mips/vr41xx/casio-e55/setup.c + * setup.c, Setup for the CASIO CASSIOPEIA E-11/15/55/65. * - * BRIEF MODULE DESCRIPTION - * Setup for the CASIO CASSIOPEIA E-11/15/55/65. + * Copyright (C) 2002-2003 Yoichi Yuasa * - * Copyright 2002 Yoichi Yuasa - * yuasa@hh.iij4u.or.jp + * 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. + * + * 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 #include #include -#include #include #include @@ -31,11 +32,7 @@ extern unsigned long initrd_start, initr extern void * __rd_start, * __rd_end; #endif -#ifdef CONFIG_BLK_DEV_IDE -extern struct ide_ops e55_ide_ops; -#endif - -void __init casio_e55_setup(void) +static void __init casio_e55_setup(void) { set_io_port_base(IO_PORT_BASE); ioport_resource.start = IO_PORT_RESOURCE_START; @@ -49,26 +46,18 @@ void __init casio_e55_setup(void) initrd_end = (unsigned long)&__rd_end; #endif - _machine_restart = vr41xx_restart; - _machine_halt = vr41xx_halt; - _machine_power_off = vr41xx_power_off; - board_time_init = vr41xx_time_init; board_timer_setup = vr41xx_timer_setup; -#ifdef CONFIG_FB - conswitchp = &dummy_con; -#endif - -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &e55_ide_ops; -#endif - vr41xx_bcu_init(); - vr41xx_cmu_init(0); + vr41xx_cmu_init(); + + vr41xx_pmu_init(); #ifdef CONFIG_SERIAL_8250 vr41xx_siu_init(SIU_RS232C, 0); #endif } + +early_initcall(casio_e55_setup); --- diff/arch/mips/vr41xx/common/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/common/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,9 +2,9 @@ # Makefile for common code of the NEC VR4100 series. # -obj-y += bcu.o cmu.o giu.o icu.o int-handler.o reset.o +obj-y += bcu.o cmu.o giu.o icu.o int-handler.o ksyms.o pmu.o rtc.o obj-$(CONFIG_SERIAL_8250) += serial.o -obj-$(CONFIG_VR41XX_TIME_C) += time.o +obj-$(CONFIG_VRC4171) += vrc4171.o obj-$(CONFIG_VRC4173) += vrc4173.o EXTRA_AFLAGS := $(CFLAGS) --- diff/arch/mips/vr41xx/common/bcu.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/common/bcu.c 2004-02-23 13:56:38.000000000 +0000 @@ -33,27 +33,23 @@ /* * Changes: * MontaVista Software Inc. or + * - New creation, NEC VR4122 and VR4131 are supported. * - Added support for NEC VR4111 and VR4121. * - * Paul Mundt - * - Calculate mips_counter_frequency properly on VR4131. - * - * MontaVista Software Inc. or - * - New creation, NEC VR4122 and VR4131 are supported. + * Yoichi Yuasa + * - Added support for NEC VR4133. */ #include +#include #include -#include #include #include -#include -#include -#define VR4111_CLKSPEEDREG KSEG1ADDR(0x0b000014) -#define VR4122_CLKSPEEDREG KSEG1ADDR(0x0f000014) -#define VR4131_CLKSPEEDREG VR4122_CLKSPEEDREG +#define CLKSPEEDREG_TYPE1 KSEG1ADDR(0x0b000014) +#define CLKSPEEDREG_TYPE2 KSEG1ADDR(0x0f000014) #define CLKSP(x) ((x) & 0x001f) + #define CLKSP_VR4133(x) ((x) & 0x0007) #define DIV2B 0x8000 #define DIV3B 0x4000 @@ -65,15 +61,27 @@ #define TDIVMODE(x) (2 << (((x) & 0x1000) >> 12)) #define VTDIVMODE(x) (((x) & 0x0700) >> 8) -unsigned long vr41xx_vtclock = 0; +static unsigned long vr41xx_vtclock; +static unsigned long vr41xx_tclock; + +unsigned long vr41xx_get_vtclock_frequency(void) +{ + return vr41xx_vtclock; +} + +unsigned long vr41xx_get_tclock_frequency(void) +{ + return vr41xx_tclock; +} -static inline u16 read_clkspeed(void) +static inline uint16_t read_clkspeed(void) { switch (current_cpu_data.cputype) { case CPU_VR4111: - case CPU_VR4121: return readw(VR4111_CLKSPEEDREG); - case CPU_VR4122: return readw(VR4122_CLKSPEEDREG); - case CPU_VR4131: return readw(VR4131_CLKSPEEDREG); + case CPU_VR4121: return readw(CLKSPEEDREG_TYPE1); + case CPU_VR4122: + case CPU_VR4131: + case CPU_VR4133: return readw(CLKSPEEDREG_TYPE2); default: printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n"); break; @@ -82,7 +90,7 @@ static inline u16 read_clkspeed(void) return 0; } -static inline unsigned long calculate_pclock(u16 clkspeed) +static inline unsigned long calculate_pclock(uint16_t clkspeed) { unsigned long pclock = 0; @@ -90,63 +98,90 @@ static inline unsigned long calculate_pc case CPU_VR4111: case CPU_VR4121: pclock = 18432000 * 64; + pclock /= CLKSP(clkspeed); break; case CPU_VR4122: pclock = 18432000 * 98; + pclock /= CLKSP(clkspeed); break; case CPU_VR4131: pclock = 18432000 * 108; + pclock /= CLKSP(clkspeed); + break; + case CPU_VR4133: + switch (CLKSP_VR4133(clkspeed)) { + case 0: + pclock = 133000000; + break; + case 1: + pclock = 149000000; + break; + case 2: + pclock = 165900000; + break; + case 3: + pclock = 199100000; + break; + case 4: + pclock = 265900000; + break; + default: + printk(KERN_INFO "Unknown PClock speed for NEC VR4133\n"); + break; + } break; default: printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n"); break; } - pclock /= CLKSP(clkspeed); printk(KERN_INFO "PClock: %ldHz\n", pclock); return pclock; } -static inline unsigned long calculate_vtclock(u16 clkspeed, unsigned long pclock) +static inline unsigned long calculate_vtclock(uint16_t clkspeed, unsigned long pclock) { + unsigned long vtclock = 0; + switch (current_cpu_data.cputype) { case CPU_VR4111: /* The NEC VR4111 doesn't have the VTClock. */ break; case CPU_VR4121: - vr41xx_vtclock = pclock; + vtclock = pclock; /* DIVVT == 9 Divide by 1.5 . VTClock = (PClock * 6) / 9 */ if (DIVVT(clkspeed) == 9) - vr41xx_vtclock = pclock * 6; + vtclock = pclock * 6; /* DIVVT == 10 Divide by 2.5 . VTClock = (PClock * 4) / 10 */ else if (DIVVT(clkspeed) == 10) - vr41xx_vtclock = pclock * 4; - vr41xx_vtclock /= DIVVT(clkspeed); - printk(KERN_INFO "VTClock: %ldHz\n", vr41xx_vtclock); + vtclock = pclock * 4; + vtclock /= DIVVT(clkspeed); + printk(KERN_INFO "VTClock: %ldHz\n", vtclock); break; case CPU_VR4122: if(VTDIVMODE(clkspeed) == 7) - vr41xx_vtclock = pclock / 1; + vtclock = pclock / 1; else if(VTDIVMODE(clkspeed) == 1) - vr41xx_vtclock = pclock / 2; + vtclock = pclock / 2; else - vr41xx_vtclock = pclock / VTDIVMODE(clkspeed); - printk(KERN_INFO "VTClock: %ldHz\n", vr41xx_vtclock); + vtclock = pclock / VTDIVMODE(clkspeed); + printk(KERN_INFO "VTClock: %ldHz\n", vtclock); break; case CPU_VR4131: - vr41xx_vtclock = pclock / VTDIVMODE(clkspeed); - printk(KERN_INFO "VTClock: %ldHz\n", vr41xx_vtclock); + case CPU_VR4133: + vtclock = pclock / VTDIVMODE(clkspeed); + printk(KERN_INFO "VTClock: %ldHz\n", vtclock); break; default: printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n"); break; } - return vr41xx_vtclock; + return vtclock; } -static inline unsigned long calculate_tclock(u16 clkspeed, unsigned long pclock, +static inline unsigned long calculate_tclock(uint16_t clkspeed, unsigned long pclock, unsigned long vtclock) { unsigned long tclock = 0; @@ -165,6 +200,7 @@ static inline unsigned long calculate_tc break; case CPU_VR4122: case CPU_VR4131: + case CPU_VR4133: tclock = vtclock / TDIVMODE(clkspeed); break; default: @@ -177,30 +213,14 @@ static inline unsigned long calculate_tc return tclock; } -static inline unsigned long calculate_mips_counter_frequency(unsigned long tclock) -{ - /* - * VR4131 Revision 2.0 and 2.1 use a value of (tclock / 2). - */ - if ((current_cpu_data.processor_id == PRID_VR4131_REV2_0) || - (current_cpu_data.processor_id == PRID_VR4131_REV2_1)) - tclock /= 2; - else - tclock /= 4; - - return tclock; -} - void __init vr41xx_bcu_init(void) { - unsigned long pclock, vtclock, tclock; - u16 clkspeed; + unsigned long pclock; + uint16_t clkspeed; clkspeed = read_clkspeed(); pclock = calculate_pclock(clkspeed); - vtclock = calculate_vtclock(clkspeed, pclock); - tclock = calculate_tclock(clkspeed, pclock, vtclock); - - mips_counter_frequency = calculate_mips_counter_frequency(tclock); + vr41xx_vtclock = calculate_vtclock(clkspeed, pclock); + vr41xx_tclock = calculate_tclock(clkspeed, pclock, vr41xx_vtclock); } --- diff/arch/mips/vr41xx/common/cmu.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/common/cmu.c 2004-02-23 13:56:38.000000000 +0000 @@ -33,52 +33,193 @@ /* * Changes: * MontaVista Software Inc. or + * - New creation, NEC VR4122 and VR4131 are supported. * - Added support for NEC VR4111 and VR4121. * - * MontaVista Software Inc. or - * - New creation, NEC VR4122 and VR4131 are supported. + * Yoichi Yuasa + * - Added support for NEC VR4133. */ #include +#include #include #include #include +#include -#define VR4111_CMUCLKMSK KSEG1ADDR(0x0b000060) -#define VR4122_CMUCLKMSK KSEG1ADDR(0x0f000060) - -static u32 vr41xx_cmu_base = 0; -static u16 cmuclkmsk = 0; - -#define write_cmu(mask) writew((mask), vr41xx_cmu_base) +#define CMUCLKMSK_TYPE1 KSEG1ADDR(0x0b000060) +#define CMUCLKMSK_TYPE2 KSEG1ADDR(0x0f000060) + #define MSKPIU 0x0001 + #define MSKSIU 0x0002 + #define MSKAIU 0x0004 + #define MSKKIU 0x0008 + #define MSKFIR 0x0010 + #define MSKDSIU 0x0820 + #define MSKCSI 0x0040 + #define MSKPCIU 0x0080 + #define MSKSSIU 0x0100 + #define MSKSHSP 0x0200 + #define MSKFFIR 0x0400 + #define MSKSCSI 0x1000 + #define MSKPPCIU 0x2000 +#define CMUCLKMSK2 KSEG1ADDR(0x0f000064) + #define MSKCEU 0x0001 + #define MSKMAC0 0x0002 + #define MSKMAC1 0x0004 + +static u32 vr41xx_cmu_base; +static u16 cmuclkmsk, cmuclkmsk2; + +#define read_cmuclkmsk() readw(vr41xx_cmu_base) +#define read_cmuclkmsk2() readw(CMUCLKMSK2) +#define write_cmuclkmsk() writew(cmuclkmsk, vr41xx_cmu_base) +#define write_cmuclkmsk2() writew(cmuclkmsk2, CMUCLKMSK2) -void vr41xx_clock_supply(u16 mask) +void vr41xx_clock_supply(unsigned int clock) { - cmuclkmsk |= mask; - write_cmu(cmuclkmsk); + switch (clock) { + case PIU_CLOCK: + cmuclkmsk |= MSKPIU; + break; + case SIU_CLOCK: + cmuclkmsk |= MSKSIU | MSKSSIU; + break; + case AIU_CLOCK: + cmuclkmsk |= MSKAIU; + break; + case KIU_CLOCK: + cmuclkmsk |= MSKKIU; + break; + case FIR_CLOCK: + cmuclkmsk |= MSKFIR | MSKFFIR; + break; + case DSIU_CLOCK: + if (current_cpu_data.cputype == CPU_VR4111 || + current_cpu_data.cputype == CPU_VR4121) + cmuclkmsk |= MSKDSIU; + else + cmuclkmsk |= MSKSIU | MSKDSIU; + break; + case CSI_CLOCK: + cmuclkmsk |= MSKCSI | MSKSCSI; + break; + case PCIU_CLOCK: + cmuclkmsk |= MSKPCIU; + break; + case HSP_CLOCK: + cmuclkmsk |= MSKSHSP; + break; + case PCI_CLOCK: + cmuclkmsk |= MSKPPCIU; + break; + case CEU_CLOCK: + cmuclkmsk2 |= MSKCEU; + break; + case ETHER0_CLOCK: + cmuclkmsk2 |= MSKMAC0; + break; + case ETHER1_CLOCK: + cmuclkmsk2 |= MSKMAC1; + break; + default: + break; + } + + if (clock == CEU_CLOCK || clock == ETHER0_CLOCK || + clock == ETHER1_CLOCK) + write_cmuclkmsk2(); + else + write_cmuclkmsk(); } -void vr41xx_clock_mask(u16 mask) +void vr41xx_clock_mask(unsigned int clock) { - cmuclkmsk &= ~mask; - write_cmu(cmuclkmsk); + switch (clock) { + case PIU_CLOCK: + cmuclkmsk &= ~MSKPIU; + break; + case SIU_CLOCK: + if (current_cpu_data.cputype == CPU_VR4111 || + current_cpu_data.cputype == CPU_VR4121) { + cmuclkmsk &= ~(MSKSIU | MSKSSIU); + } else { + if (cmuclkmsk & MSKDSIU) + cmuclkmsk &= ~MSKSSIU; + else + cmuclkmsk &= ~(MSKSIU | MSKSSIU); + } + break; + case AIU_CLOCK: + cmuclkmsk &= ~MSKAIU; + break; + case KIU_CLOCK: + cmuclkmsk &= ~MSKKIU; + break; + case FIR_CLOCK: + cmuclkmsk &= ~(MSKFIR | MSKFFIR); + break; + case DSIU_CLOCK: + if (current_cpu_data.cputype == CPU_VR4111 || + current_cpu_data.cputype == CPU_VR4121) { + cmuclkmsk &= ~MSKDSIU; + } else { + if (cmuclkmsk & MSKSIU) + cmuclkmsk &= ~MSKDSIU; + else + cmuclkmsk &= ~(MSKSIU | MSKDSIU); + } + break; + case CSI_CLOCK: + cmuclkmsk &= ~(MSKCSI | MSKSCSI); + break; + case PCIU_CLOCK: + cmuclkmsk &= ~MSKPCIU; + break; + case HSP_CLOCK: + cmuclkmsk &= ~MSKSHSP; + break; + case PCI_CLOCK: + cmuclkmsk &= ~MSKPPCIU; + break; + case CEU_CLOCK: + cmuclkmsk2 &= ~MSKCEU; + break; + case ETHER0_CLOCK: + cmuclkmsk2 &= ~MSKMAC0; + break; + case ETHER1_CLOCK: + cmuclkmsk2 &= ~MSKMAC1; + break; + default: + break; + } + + if (clock == CEU_CLOCK || clock == ETHER0_CLOCK || + clock == ETHER1_CLOCK) + write_cmuclkmsk2(); + else + write_cmuclkmsk(); } -void __init vr41xx_cmu_init(u16 mask) +void __init vr41xx_cmu_init(void) { switch (current_cpu_data.cputype) { case CPU_VR4111: case CPU_VR4121: - vr41xx_cmu_base = VR4111_CMUCLKMSK; + vr41xx_cmu_base = CMUCLKMSK_TYPE1; break; case CPU_VR4122: case CPU_VR4131: - vr41xx_cmu_base = VR4122_CMUCLKMSK; + vr41xx_cmu_base = CMUCLKMSK_TYPE2; + break; + case CPU_VR4133: + vr41xx_cmu_base = CMUCLKMSK_TYPE2; + cmuclkmsk2 = read_cmuclkmsk2(); break; default: panic("Unexpected CPU of NEC VR4100 series"); break; } - cmuclkmsk = mask; + cmuclkmsk = read_cmuclkmsk(); } --- diff/arch/mips/vr41xx/common/giu.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/common/giu.c 2004-02-23 13:56:38.000000000 +0000 @@ -34,20 +34,23 @@ * Changes: * MontaVista Software Inc. or * - New creation, NEC VR4111, VR4121, VR4122 and VR4131 are supported. + * + * Yoichi Yuasa + * - Added support for NEC VR4133. */ #include #include #include #include +#include #include -#include #include #include #include -#define VR4111_GIUIOSELL KSEG1ADDR(0x0b000100) -#define VR4122_GIUIOSELL KSEG1ADDR(0x0f000140) +#define GIUIOSELL_TYPE1 KSEG1ADDR(0x0b000100) +#define GIUIOSELL_TYPE2 KSEG1ADDR(0x0f000140) #define GIUIOSELL 0x00 #define GIUIOSELH 0x02 @@ -61,15 +64,19 @@ #define GIUINTALSELH 0x16 #define GIUINTHTSELL 0x18 #define GIUINTHTSELH 0x1a +#define GIUFEDGEINHL 0x20 +#define GIUFEDGEINHH 0x22 +#define GIUREDGEINHL 0x24 +#define GIUREDGEINHH 0x26 -u32 vr41xx_giu_base = 0; +static uint32_t giu_base; -#define read_giuint(offset) readw(vr41xx_giu_base + (offset)) -#define write_giuint(val, offset) writew((val), vr41xx_giu_base + (offset)) +#define read_giuint(offset) readw(giu_base + (offset)) +#define write_giuint(val, offset) writew((val), giu_base + (offset)) -static inline u16 set_giuint(u16 offset, u16 set) +static inline uint16_t set_giuint(uint8_t offset, uint16_t set) { - u16 res; + uint16_t res; res = read_giuint(offset); res |= set; @@ -78,9 +85,9 @@ static inline u16 set_giuint(u16 offset, return res; } -static inline u16 clear_giuint(u16 offset, u16 clear) +static inline uint16_t clear_giuint(uint8_t offset, uint16_t clear) { - u16 res; + uint16_t res; res = read_giuint(offset); res &= ~clear; @@ -92,51 +99,83 @@ static inline u16 clear_giuint(u16 offse void vr41xx_enable_giuint(int pin) { if (pin < 16) - set_giuint(GIUINTENL, (u16)1 << pin); + set_giuint(GIUINTENL, (uint16_t)1 << pin); else - set_giuint(GIUINTENH, (u16)1 << (pin - 16)); + set_giuint(GIUINTENH, (uint16_t)1 << (pin - 16)); } void vr41xx_disable_giuint(int pin) { if (pin < 16) - clear_giuint(GIUINTENL, (u16)1 << pin); + clear_giuint(GIUINTENL, (uint16_t)1 << pin); else - clear_giuint(GIUINTENH, (u16)1 << (pin - 16)); + clear_giuint(GIUINTENH, (uint16_t)1 << (pin - 16)); } void vr41xx_clear_giuint(int pin) { if (pin < 16) - write_giuint((u16)1 << pin, GIUINTSTATL); + write_giuint((uint16_t)1 << pin, GIUINTSTATL); else - write_giuint((u16)1 << (pin - 16), GIUINTSTATH); + write_giuint((uint16_t)1 << (pin - 16), GIUINTSTATH); } void vr41xx_set_irq_trigger(int pin, int trigger, int hold) { - u16 mask; + uint16_t mask; if (pin < 16) { - mask = (u16)1 << pin; - if (trigger == TRIGGER_EDGE) { + mask = (uint16_t)1 << pin; + if (trigger != TRIGGER_LEVEL) { set_giuint(GIUINTTYPL, mask); if (hold == SIGNAL_HOLD) set_giuint(GIUINTHTSELL, mask); else clear_giuint(GIUINTHTSELL, mask); + if (current_cpu_data.cputype == CPU_VR4133) { + switch (trigger) { + case TRIGGER_EDGE_FALLING: + set_giuint(GIUFEDGEINHL, mask); + clear_giuint(GIUREDGEINHL, mask); + break; + case TRIGGER_EDGE_RISING: + clear_giuint(GIUFEDGEINHL, mask); + set_giuint(GIUREDGEINHL, mask); + break; + default: + set_giuint(GIUFEDGEINHL, mask); + set_giuint(GIUREDGEINHL, mask); + break; + } + } } else { clear_giuint(GIUINTTYPL, mask); clear_giuint(GIUINTHTSELL, mask); } } else { - mask = (u16)1 << (pin - 16); - if (trigger == TRIGGER_EDGE) { + mask = (uint16_t)1 << (pin - 16); + if (trigger != TRIGGER_LEVEL) { set_giuint(GIUINTTYPH, mask); if (hold == SIGNAL_HOLD) set_giuint(GIUINTHTSELH, mask); else clear_giuint(GIUINTHTSELH, mask); + if (current_cpu_data.cputype == CPU_VR4133) { + switch (trigger) { + case TRIGGER_EDGE_FALLING: + set_giuint(GIUFEDGEINHH, mask); + clear_giuint(GIUREDGEINHH, mask); + break; + case TRIGGER_EDGE_RISING: + clear_giuint(GIUFEDGEINHH, mask); + set_giuint(GIUREDGEINHH, mask); + break; + default: + set_giuint(GIUFEDGEINHH, mask); + set_giuint(GIUREDGEINHH, mask); + break; + } + } } else { clear_giuint(GIUINTTYPH, mask); clear_giuint(GIUINTHTSELH, mask); @@ -148,16 +187,16 @@ void vr41xx_set_irq_trigger(int pin, int void vr41xx_set_irq_level(int pin, int level) { - u16 mask; + uint16_t mask; if (pin < 16) { - mask = (u16)1 << pin; + mask = (uint16_t)1 << pin; if (level == LEVEL_HIGH) set_giuint(GIUINTALSELL, mask); else clear_giuint(GIUINTALSELL, mask); } else { - mask = (u16)1 << (pin - 16); + mask = (uint16_t)1 << (pin - 16); if (level == LEVEL_HIGH) set_giuint(GIUINTALSELH, mask); else @@ -198,7 +237,7 @@ int vr41xx_cascade_irq(unsigned int irq, if(!get_irq_number) return -EINVAL; - pin = irq - GIU_IRQ(0); + pin = GIU_IRQ_TO_PIN(irq); giuint_cascade[pin].flag = GIUINT_CASCADE; giuint_cascade[pin].get_irq_number = get_irq_number; @@ -219,7 +258,7 @@ unsigned int giuint_do_IRQ(int pin, stru disable_irq(GIUINT_CASCADE_IRQ); cascade = &giuint_cascade[pin]; - giuint_irq = pin + GIU_IRQ(0); + giuint_irq = GIU_IRQ(pin); if (cascade->flag == GIUINT_CASCADE) { cascade_irq = cascade->get_irq_number(giuint_irq); disable_irq(giuint_irq); @@ -242,11 +281,12 @@ void __init vr41xx_giuint_init(void) switch (current_cpu_data.cputype) { case CPU_VR4111: case CPU_VR4121: - vr41xx_giu_base = VR4111_GIUIOSELL; + giu_base = GIUIOSELL_TYPE1; break; case CPU_VR4122: case CPU_VR4131: - vr41xx_giu_base = VR4122_GIUIOSELL; + case CPU_VR4133: + giu_base = GIUIOSELL_TYPE2; break; default: panic("GIU: Unexpected CPU of NEC VR4100 series"); --- diff/arch/mips/vr41xx/common/icu.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/common/icu.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,9 +1,9 @@ /* * FILE NAME - * arch/mips/vr41xx/vr4122/common/icu.c + * arch/mips/vr41xx/common/icu.c * * BRIEF MODULE DESCRIPTION - * Interrupt Control Unit routines for the NEC VR4122 and VR4131. + * Interrupt Control Unit routines for the NEC VR4100 series. * * Author: Yoichi Yuasa * yyuasa@mvista.com or source@mvista.com @@ -33,65 +33,78 @@ /* * Changes: * MontaVista Software Inc. or + * - New creation, NEC VR4122 and VR4131 are supported. * - Added support for NEC VR4111 and VR4121. * - * Paul Mundt - * - kgdb support. - * - * MontaVista Software Inc. or - * - New creation, NEC VR4122 and VR4131 are supported. + * Yoichi Yuasa + * - Coped with INTASSIGN of NEC VR4133. */ #include #include #include #include +#include #include -#include #include -#include #include -#include +#include +#include #include extern asmlinkage void vr41xx_handle_interrupt(void); -extern void __init init_generic_irq(void); -extern void mips_cpu_irq_init(u32 irq_base); - extern void vr41xx_giuint_init(void); +extern void vr41xx_enable_giuint(int pin); +extern void vr41xx_disable_giuint(int pin); +extern void vr41xx_clear_giuint(int pin); extern unsigned int giuint_do_IRQ(int pin, struct pt_regs *regs); -static u32 vr41xx_icu1_base = 0; -static u32 vr41xx_icu2_base = 0; +static uint32_t icu1_base; +static uint32_t icu2_base; -#define VR4111_SYSINT1REG KSEG1ADDR(0x0b000080) -#define VR4111_SYSINT2REG KSEG1ADDR(0x0b000200) +static unsigned char sysint1_assign[16] = { + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static unsigned char sysint2_assign[16] = { + 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -#define VR4122_SYSINT1REG KSEG1ADDR(0x0f000080) -#define VR4122_SYSINT2REG KSEG1ADDR(0x0f0000a0) +#define SYSINT1REG_TYPE1 KSEG1ADDR(0x0b000080) +#define SYSINT2REG_TYPE1 KSEG1ADDR(0x0b000200) + +#define SYSINT1REG_TYPE2 KSEG1ADDR(0x0f000080) +#define SYSINT2REG_TYPE2 KSEG1ADDR(0x0f0000a0) #define SYSINT1REG 0x00 +#define INTASSIGN0 0x04 +#define INTASSIGN1 0x06 #define GIUINTLREG 0x08 #define MSYSINT1REG 0x0c #define MGIUINTLREG 0x14 #define NMIREG 0x18 #define SOFTREG 0x1a +#define INTASSIGN2 0x1c +#define INTASSIGN3 0x1e #define SYSINT2REG 0x00 #define GIUINTHREG 0x02 #define MSYSINT2REG 0x06 #define MGIUINTHREG 0x08 -#define read_icu1(offset) readw(vr41xx_icu1_base + (offset)) -#define write_icu1(val, offset) writew((val), vr41xx_icu1_base + (offset)) +#define SYSINT1_IRQ_TO_PIN(x) ((x) - SYSINT1_IRQ_BASE) /* Pin 0-15 */ +#define SYSINT2_IRQ_TO_PIN(x) ((x) - SYSINT2_IRQ_BASE) /* Pin 0-15 */ + +#define read_icu1(offset) readw(icu1_base + (offset)) +#define write_icu1(val, offset) writew((val), icu1_base + (offset)) -#define read_icu2(offset) readw(vr41xx_icu2_base + (offset)) -#define write_icu2(val, offset) writew((val), vr41xx_icu2_base + (offset)) +#define read_icu2(offset) readw(icu2_base + (offset)) +#define write_icu2(val, offset) writew((val), icu2_base + (offset)) -static inline u16 set_icu1(u16 offset, u16 set) +#define INTASSIGN_MAX 4 +#define INTASSIGN_MASK 0x0007 + +static inline uint16_t set_icu1(uint8_t offset, uint16_t set) { - u16 res; + uint16_t res; res = read_icu1(offset); res |= set; @@ -100,9 +113,9 @@ static inline u16 set_icu1(u16 offset, u return res; } -static inline u16 clear_icu1(u16 offset, u16 clear) +static inline uint16_t clear_icu1(uint8_t offset, uint16_t clear) { - u16 res; + uint16_t res; res = read_icu1(offset); res &= ~clear; @@ -111,9 +124,9 @@ static inline u16 clear_icu1(u16 offset, return res; } -static inline u16 set_icu2(u16 offset, u16 set) +static inline uint16_t set_icu2(uint8_t offset, uint16_t set) { - u16 res; + uint16_t res; res = read_icu2(offset); res |= set; @@ -122,9 +135,9 @@ static inline u16 set_icu2(u16 offset, u return res; } -static inline u16 clear_icu2(u16 offset, u16 clear) +static inline uint16_t clear_icu2(uint8_t offset, uint16_t clear) { - u16 res; + uint16_t res; res = read_icu2(offset); res &= ~clear; @@ -137,17 +150,17 @@ static inline u16 clear_icu2(u16 offset, static void enable_sysint1_irq(unsigned int irq) { - set_icu1(MSYSINT1REG, (u16)1 << (irq - SYSINT1_IRQ_BASE)); + set_icu1(MSYSINT1REG, (uint16_t)1 << SYSINT1_IRQ_TO_PIN(irq)); } static void disable_sysint1_irq(unsigned int irq) { - clear_icu1(MSYSINT1REG, (u16)1 << (irq - SYSINT1_IRQ_BASE)); + clear_icu1(MSYSINT1REG, (uint16_t)1 << SYSINT1_IRQ_TO_PIN(irq)); } static unsigned int startup_sysint1_irq(unsigned int irq) { - set_icu1(MSYSINT1REG, (u16)1 << (irq - SYSINT1_IRQ_BASE)); + set_icu1(MSYSINT1REG, (uint16_t)1 << SYSINT1_IRQ_TO_PIN(irq)); return 0; /* never anything pending */ } @@ -158,35 +171,34 @@ static unsigned int startup_sysint1_irq( static void end_sysint1_irq(unsigned int irq) { if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) - set_icu1(MSYSINT1REG, (u16)1 << (irq - SYSINT1_IRQ_BASE)); + set_icu1(MSYSINT1REG, (uint16_t)1 << SYSINT1_IRQ_TO_PIN(irq)); } static struct hw_interrupt_type sysint1_irq_type = { - "SYSINT1", - startup_sysint1_irq, - shutdown_sysint1_irq, - enable_sysint1_irq, - disable_sysint1_irq, - ack_sysint1_irq, - end_sysint1_irq, - NULL + .typename = "SYSINT1", + .startup = startup_sysint1_irq, + .shutdown = shutdown_sysint1_irq, + .enable = enable_sysint1_irq, + .disable = disable_sysint1_irq, + .ack = ack_sysint1_irq, + .end = end_sysint1_irq, }; /*=======================================================================*/ static void enable_sysint2_irq(unsigned int irq) { - set_icu2(MSYSINT2REG, (u16)1 << (irq - SYSINT2_IRQ_BASE)); + set_icu2(MSYSINT2REG, (uint16_t)1 << SYSINT2_IRQ_TO_PIN(irq)); } static void disable_sysint2_irq(unsigned int irq) { - clear_icu2(MSYSINT2REG, (u16)1 << (irq - SYSINT2_IRQ_BASE)); + clear_icu2(MSYSINT2REG, (uint16_t)1 << SYSINT2_IRQ_TO_PIN(irq)); } static unsigned int startup_sysint2_irq(unsigned int irq) { - set_icu2(MSYSINT2REG, (u16)1 << (irq - SYSINT2_IRQ_BASE)); + set_icu2(MSYSINT2REG, (uint16_t)1 << SYSINT2_IRQ_TO_PIN(irq)); return 0; /* never anything pending */ } @@ -197,18 +209,17 @@ static unsigned int startup_sysint2_irq( static void end_sysint2_irq(unsigned int irq) { if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) - set_icu2(MSYSINT2REG, (u16)1 << (irq - SYSINT2_IRQ_BASE)); + set_icu2(MSYSINT2REG, (uint16_t)1 << SYSINT2_IRQ_TO_PIN(irq)); } static struct hw_interrupt_type sysint2_irq_type = { - "SYSINT2", - startup_sysint2_irq, - shutdown_sysint2_irq, - enable_sysint2_irq, - disable_sysint2_irq, - ack_sysint2_irq, - end_sysint2_irq, - NULL + .typename = "SYSINT2", + .startup = startup_sysint2_irq, + .shutdown = shutdown_sysint2_irq, + .enable = enable_sysint2_irq, + .disable = disable_sysint2_irq, + .ack = ack_sysint2_irq, + .end = end_sysint2_irq, }; /*=======================================================================*/ @@ -217,12 +228,11 @@ static void enable_giuint_irq(unsigned i { int pin; - pin = irq - GIU_IRQ_BASE; + pin = GIU_IRQ_TO_PIN(irq); if (pin < 16) - set_icu1(MGIUINTLREG, (u16)1 << pin); + set_icu1(MGIUINTLREG, (uint16_t)1 << pin); else - set_icu2(MGIUINTHREG, (u16)1 << (pin - 16)); - + set_icu2(MGIUINTHREG, (uint16_t)1 << (pin - 16)); vr41xx_enable_giuint(pin); } @@ -230,18 +240,17 @@ static void disable_giuint_irq(unsigned { int pin; - pin = irq - GIU_IRQ_BASE; + pin = GIU_IRQ_TO_PIN(irq); vr41xx_disable_giuint(pin); - if (pin < 16) - clear_icu1(MGIUINTLREG, (u16)1 << pin); + clear_icu1(MGIUINTLREG, (uint16_t)1 << pin); else - clear_icu2(MGIUINTHREG, (u16)1 << (pin - 16)); + clear_icu2(MGIUINTHREG, (uint16_t)1 << (pin - 16)); } static unsigned int startup_giuint_irq(unsigned int irq) { - vr41xx_clear_giuint(irq - GIU_IRQ_BASE); + vr41xx_clear_giuint(GIU_IRQ_TO_PIN(irq)); enable_giuint_irq(irq); @@ -254,7 +263,7 @@ static void ack_giuint_irq(unsigned int { disable_giuint_irq(irq); - vr41xx_clear_giuint(irq - GIU_IRQ_BASE); + vr41xx_clear_giuint(GIU_IRQ_TO_PIN(irq)); } static void end_giuint_irq(unsigned int irq) @@ -264,14 +273,13 @@ static void end_giuint_irq(unsigned int } static struct hw_interrupt_type giuint_irq_type = { - "GIUINT", - startup_giuint_irq, - shutdown_giuint_irq, - enable_giuint_irq, - disable_giuint_irq, - ack_giuint_irq, - end_giuint_irq, - NULL + .typename = "GIUINT", + .startup = startup_giuint_irq, + .shutdown = shutdown_giuint_irq, + .enable = enable_giuint_irq, + .disable = disable_giuint_irq, + .ack = ack_giuint_irq, + .end = end_giuint_irq, }; /*=======================================================================*/ @@ -285,13 +293,14 @@ static void __init vr41xx_icu_init(void) switch (current_cpu_data.cputype) { case CPU_VR4111: case CPU_VR4121: - vr41xx_icu1_base = VR4111_SYSINT1REG; - vr41xx_icu2_base = VR4111_SYSINT2REG; + icu1_base = SYSINT1REG_TYPE1; + icu2_base = SYSINT2REG_TYPE1; break; case CPU_VR4122: case CPU_VR4131: - vr41xx_icu1_base = VR4122_SYSINT1REG; - vr41xx_icu2_base = VR4122_SYSINT2REG; + case CPU_VR4133: + icu1_base = SYSINT1REG_TYPE2; + icu2_base = SYSINT2REG_TYPE2; break; default: panic("Unexpected CPU of NEC VR4100 series"); @@ -313,7 +322,11 @@ static void __init vr41xx_icu_init(void) irq_desc[i].handler = &giuint_irq_type; } - setup_irq(ICU_CASCADE_IRQ, &icu_cascade); + setup_irq(INT0_CASCADE_IRQ, &icu_cascade); + setup_irq(INT1_CASCADE_IRQ, &icu_cascade); + setup_irq(INT2_CASCADE_IRQ, &icu_cascade); + setup_irq(INT3_CASCADE_IRQ, &icu_cascade); + setup_irq(INT4_CASCADE_IRQ, &icu_cascade); } void __init init_IRQ(void) @@ -327,31 +340,171 @@ void __init init_IRQ(void) vr41xx_giuint_init(); set_except_vector(0, vr41xx_handle_interrupt); +} + +/*=======================================================================*/ + +static inline int set_sysint1_assign(unsigned int irq, unsigned char assign) +{ + irq_desc_t *desc = irq_desc + irq; + uint16_t intassign0, intassign1; + unsigned int pin; + + pin = SYSINT1_IRQ_TO_PIN(irq); + + spin_lock_irq(&desc->lock); -#ifdef CONFIG_KGDB - printk("Setting debug traps - please connect the remote debugger.\n"); - set_debug_traps(); - breakpoint(); -#endif + intassign0 = read_icu1(INTASSIGN0); + intassign1 = read_icu1(INTASSIGN1); + + switch (pin) { + case 0: + intassign0 &= ~INTASSIGN_MASK; + intassign0 |= (uint16_t)assign; + break; + case 1: + intassign0 &= ~(INTASSIGN_MASK << 3); + intassign0 |= (uint16_t)assign << 3; + break; + case 2: + intassign0 &= ~(INTASSIGN_MASK << 6); + intassign0 |= (uint16_t)assign << 6; + break; + case 3: + intassign0 &= ~(INTASSIGN_MASK << 9); + intassign0 |= (uint16_t)assign << 9; + break; + case 8: + intassign0 &= ~(INTASSIGN_MASK << 12); + intassign0 |= (uint16_t)assign << 12; + break; + case 9: + intassign1 &= ~INTASSIGN_MASK; + intassign1 |= (uint16_t)assign; + break; + case 11: + intassign1 &= ~(INTASSIGN_MASK << 6); + intassign1 |= (uint16_t)assign << 6; + break; + case 12: + intassign1 &= ~(INTASSIGN_MASK << 9); + intassign1 |= (uint16_t)assign << 9; + break; + default: + return -EINVAL; + } + + sysint1_assign[pin] = assign; + write_icu1(intassign0, INTASSIGN0); + write_icu1(intassign1, INTASSIGN1); + + spin_unlock_irq(&desc->lock); + + return 0; +} + +static inline int set_sysint2_assign(unsigned int irq, unsigned char assign) +{ + irq_desc_t *desc = irq_desc + irq; + uint16_t intassign2, intassign3; + unsigned int pin; + + pin = SYSINT2_IRQ_TO_PIN(irq); + + spin_lock_irq(&desc->lock); + + intassign2 = read_icu1(INTASSIGN2); + intassign3 = read_icu1(INTASSIGN3); + + switch (pin) { + case 0: + intassign2 &= ~INTASSIGN_MASK; + intassign2 |= (uint16_t)assign; + break; + case 1: + intassign2 &= ~(INTASSIGN_MASK << 3); + intassign2 |= (uint16_t)assign << 3; + break; + case 3: + intassign2 &= ~(INTASSIGN_MASK << 6); + intassign2 |= (uint16_t)assign << 6; + break; + case 4: + intassign2 &= ~(INTASSIGN_MASK << 9); + intassign2 |= (uint16_t)assign << 9; + break; + case 5: + intassign2 &= ~(INTASSIGN_MASK << 12); + intassign2 |= (uint16_t)assign << 12; + break; + case 6: + intassign3 &= ~INTASSIGN_MASK; + intassign3 |= (uint16_t)assign; + break; + case 7: + intassign3 &= ~(INTASSIGN_MASK << 3); + intassign3 |= (uint16_t)assign << 3; + break; + case 8: + intassign3 &= ~(INTASSIGN_MASK << 6); + intassign3 |= (uint16_t)assign << 6; + break; + case 9: + intassign3 &= ~(INTASSIGN_MASK << 9); + intassign3 |= (uint16_t)assign << 9; + break; + case 10: + intassign3 &= ~(INTASSIGN_MASK << 12); + intassign3 |= (uint16_t)assign << 12; + break; + default: + return -EINVAL; + } + + sysint2_assign[pin] = assign; + write_icu1(intassign2, INTASSIGN2); + write_icu1(intassign3, INTASSIGN3); + + spin_unlock_irq(&desc->lock); + + return 0; +} + +int vr41xx_set_intassign(unsigned int irq, unsigned char intassign) +{ + int retval = -EINVAL; + + if (current_cpu_data.cputype != CPU_VR4133) + return -EINVAL; + + if (intassign > INTASSIGN_MAX) + return -EINVAL; + + if (irq >= SYSINT1_IRQ_BASE && irq <= SYSINT1_IRQ_LAST) + retval = set_sysint1_assign(irq, intassign); + else if (irq >= SYSINT2_IRQ_BASE && irq <= SYSINT2_IRQ_LAST) + retval = set_sysint2_assign(irq, intassign); + + return retval; } /*=======================================================================*/ -static inline void giuint_irqdispatch(u16 pendl, u16 pendh, struct pt_regs *regs) +static inline void giuint_irq_dispatch(uint16_t pendl, uint16_t pendh, + struct pt_regs *regs) { int i; if (pendl) { for (i = 0; i < 16; i++) { - if (pendl & (0x0001 << i)) { + if (pendl & ((uint16_t)1 << i)) { giuint_do_IRQ(i, regs); return; } } - } - else if (pendh) { + } else { for (i = 0; i < 16; i++) { - if (pendh & (0x0001 << i)) { + if (pendh & ((uint16_t)1 << i)) { giuint_do_IRQ(i + 16, regs); return; } @@ -359,10 +512,10 @@ static inline void giuint_irqdispatch(u1 } } -asmlinkage void icu_irqdispatch(struct pt_regs *regs) +asmlinkage void irq_dispatch(unsigned char intnum, struct pt_regs *regs) { - u16 pend1, pend2, pendl, pendh; - u16 mask1, mask2, maskl, maskh; + uint16_t pend1, pend2, pendl, pendh; + uint16_t mask1, mask2, maskl, maskh; int i; pend1 = read_icu1(SYSINT1REG); @@ -377,31 +530,36 @@ asmlinkage void icu_irqdispatch(struct p pendh = read_icu2(GIUINTHREG); maskh = read_icu2(MGIUINTHREG); - pend1 &= mask1; - pend2 &= mask2; - pendl &= maskl; - pendh &= maskh; - - if (pend1) { - if ((pend1 & 0x01ff) == 0x0100) { - giuint_irqdispatch(pendl, pendh, regs); - } - else { - for (i = 0; i < 16; i++) { - if (pend1 & (0x0001 << i)) { - do_IRQ(SYSINT1_IRQ_BASE + i, regs); - break; + mask1 &= pend1; + mask2 &= pend2; + maskl &= pendl; + maskh &= pendh; + + if (mask1) { + for (i = 0; i < 16; i++) { + if (intnum == sysint1_assign[i] && + (mask1 & ((uint16_t)1 << i))) { + if (i == 8 && (maskl | maskh)) { + giuint_irq_dispatch(maskl, maskh, regs); + return; + } else { + do_IRQ(SYSINT1_IRQ(i), regs); + return; } } } - return; } - else if (pend2) { + + if (mask2) { for (i = 0; i < 16; i++) { - if (pend2 & (0x0001 << i)) { - do_IRQ(SYSINT2_IRQ_BASE + i, regs); - break; + if (intnum == sysint2_assign[i] && + (mask2 & ((uint16_t)1 << i))) { + do_IRQ(SYSINT2_IRQ(i), regs); + return; } } } + + printk(KERN_ERR "spurious interrupt: %04x,%04x,%04x,%04x\n", pend1, pend2, pendl, pendh); + atomic_inc(&irq_err_count); } --- diff/arch/mips/vr41xx/common/int-handler.S 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/common/int-handler.S 2004-02-23 13:56:38.000000000 +0000 @@ -34,6 +34,9 @@ * Changes: * MontaVista Software Inc. or * - New creation, NEC VR4100 series are supported. + * + * Yoichi Yuasa + * - Coped with INTASSIGN of NEC VR4133. */ #include #include @@ -59,55 +62,52 @@ andi t0, 0xff00 and t0, t0, t1 - andi t1, t0, CAUSEF_IP7 # timer interrupt - beqz t1, 1f + andi t1, t0, CAUSEF_IP7 # MIPS timer interrupt + bnez t1, handle_irq li a0, 7 - jal ll_timer_interrupt - move a1, sp - j ret_from_irq -1: - andi t1, t0, 0x7800 # check for IP3-6 - beqz t1, 2f + andi t1, t0, 0x7800 # check for Int1-4 + beqz t1, 1f - andi t1, t0, CAUSEF_IP3 # check for IP3 - bnez t1, handle_it + andi t1, t0, CAUSEF_IP3 # check for Int1 + bnez t1, handle_int + li a0, 1 + + andi t1, t0, CAUSEF_IP4 # check for Int2 + bnez t1, handle_int + li a0, 2 + + andi t1, t0, CAUSEF_IP5 # check for Int3 + bnez t1, handle_int li a0, 3 - andi t1, t0, CAUSEF_IP4 # check for IP4 - bnez t1, handle_it + andi t1, t0, CAUSEF_IP6 # check for Int4 + bnez t1, handle_int li a0, 4 - andi t1, t0, CAUSEF_IP5 # check for IP5 - bnez t1, handle_it - li a0, 5 - - andi t1, t0, CAUSEF_IP6 # check for IP6 - bnez t1, handle_it - li a0, 6 - -2: - andi t1, t0, CAUSEF_IP2 # check for IP2 - beqz t1, 3f - move a0, sp - jal icu_irqdispatch - nop - j ret_from_irq - nop +1: + andi t1, t0, CAUSEF_IP2 # check for Int0 + bnez t1, handle_int + li a0, 0 -3: andi t1, t0, CAUSEF_IP0 # check for IP0 - bnez t1, handle_it + bnez t1, handle_irq li a0, 0 andi t1, t0, CAUSEF_IP1 # check for IP1 - bnez t1, handle_it + bnez t1, handle_irq li a0, 1 j spurious_interrupt nop -handle_it: +handle_int: + jal irq_dispatch + move a1, sp + j ret_from_irq + nop + +handle_irq: jal do_IRQ move a1, sp j ret_from_irq --- diff/arch/mips/vr41xx/common/serial.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/common/serial.c 2004-02-23 13:56:38.000000000 +0000 @@ -33,14 +33,16 @@ /* * Changes: * MontaVista Software Inc. or + * - New creation, NEC VR4122 and VR4131 are supported. * - Added support for NEC VR4111 and VR4121. * - * MontaVista Software Inc. or - * - New creation, NEC VR4122 and VR4131 are supported. + * Yoichi Yuasa + * - Added support for NEC VR4133. */ #include #include #include +#include #include #include @@ -48,12 +50,12 @@ #include /* VR4111 and VR4121 SIU Registers */ -#define VR4111_SIURB KSEG1ADDR(0x0c000000) -#define VR4111_SIUIRSEL KSEG1ADDR(0x0c000008) +#define SIURB_TYPE1 KSEG1ADDR(0x0c000000) +#define SIUIRSEL_TYPE1 KSEG1ADDR(0x0c000008) -/* VR4122 and VR4131 SIU Registers */ -#define VR4122_SIURB KSEG1ADDR(0x0f000800) -#define VR4122_SIUIRSEL KSEG1ADDR(0x0f000808) +/* VR4122, VR4131 and VR4133 SIU Registers */ +#define SIURB_TYPE2 KSEG1ADDR(0x0f000800) +#define SIUIRSEL_TYPE2 KSEG1ADDR(0x0f000808) #define USE_RS232C 0x00 #define USE_IRDA 0x01 @@ -66,7 +68,6 @@ #define TMICMODE 0x20 #define SIU_BASE_BAUD 1152000 -#define SIU_CLOCK 0x0102 /* VR4122 and VR4131 DSIU Registers */ #define DSIURB KSEG1ADDR(0x0f000820) @@ -75,7 +76,6 @@ #define INTDSIU 0x0800 #define DSIU_BASE_BAUD 1152000 -#define DSIU_CLOCK 0x0802 int vr41xx_serial_ports = 0; @@ -102,11 +102,12 @@ void vr41xx_siu_ifselect(int interface, switch (current_cpu_data.cputype) { case CPU_VR4111: case CPU_VR4121: - writew(val, VR4111_SIUIRSEL); + writew(val, SIUIRSEL_TYPE1); break; case CPU_VR4122: case CPU_VR4131: - writew(val, VR4122_SIUIRSEL); + case CPU_VR4133: + writew(val, SIUIRSEL_TYPE2); break; default: printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n"); @@ -129,11 +130,12 @@ void __init vr41xx_siu_init(int interfac switch (current_cpu_data.cputype) { case CPU_VR4111: case CPU_VR4121: - s.iomem_base = (unsigned char *)VR4111_SIURB; + s.iomem_base = (unsigned char *)SIURB_TYPE1; break; case CPU_VR4122: case CPU_VR4131: - s.iomem_base = (unsigned char *)VR4122_SIURB; + case CPU_VR4133: + s.iomem_base = (unsigned char *)SIURB_TYPE2; break; default: panic("Unexpected CPU of NEC VR4100 series"); @@ -154,7 +156,8 @@ void __init vr41xx_dsiu_init(void) struct serial_struct s; if (current_cpu_data.cputype != CPU_VR4122 && - current_cpu_data.cputype != CPU_VR4131) + current_cpu_data.cputype != CPU_VR4131 && + current_cpu_data.cputype != CPU_VR4133) return; memset(&s, 0, sizeof(s)); --- diff/arch/mips/vr41xx/common/vrc4173.c 2003-09-17 12:28:02.000000000 +0100 +++ source/arch/mips/vr41xx/common/vrc4173.c 2004-02-23 13:56:38.000000000 +0000 @@ -30,7 +30,6 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include #include #include #include @@ -195,8 +194,8 @@ static inline void vrc4173_icu_init(int vrc4173_outw(0, VRC4173_MSYSINT1REG); - vr41xx_set_irq_trigger(cascade_irq - GIU_IRQ(0), TRIGGER_LEVEL, SIGNAL_THROUGH); - vr41xx_set_irq_level(cascade_irq - GIU_IRQ(0), LEVEL_LOW); + vr41xx_set_irq_trigger(GIU_IRQ_TO_PIN(cascade_irq), TRIGGER_LEVEL, SIGNAL_THROUGH); + vr41xx_set_irq_level(GIU_IRQ_TO_PIN(cascade_irq), LEVEL_LOW); for (i = VRC4173_IRQ_BASE; i <= VRC4173_IRQ_LAST; i++) irq_desc[i].handler = &vrc4173_irq_type; --- diff/arch/mips/vr41xx/ibm-workpad/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/ibm-workpad/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -3,4 +3,3 @@ # obj-y += init.o setup.o -obj-$(CONFIG_IDE) += ide-workpad.o --- diff/arch/mips/vr41xx/ibm-workpad/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/ibm-workpad/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -13,22 +13,21 @@ * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ -#include #include #include #include #include -char arcs_cmdline[CL_SIZE]; - const char *get_system_type(void) { return "IBM WorkPad z50"; } -void __init prom_init(int argc, char **argv, unsigned long magic, int *prom_vec) +void __init prom_init(void) { + int argc = fw_arg0; + char **argv = (char **) fw_arg1; int i; /* @@ -44,6 +43,7 @@ void __init prom_init(int argc, char **a mips_machtype = MACH_IBM_WORKPAD; } -void __init prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } --- diff/arch/mips/vr41xx/ibm-workpad/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/ibm-workpad/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,28 +1,29 @@ /* - * FILE NAME - * arch/mips/vr41xx/workpad/setup.c + * setup.c, Setup for the IBM WorkPad z50. * - * BRIEF MODULE DESCRIPTION - * Setup for the IBM WorkPad z50. + * Copyright (C) 2002-2003 Yoichi Yuasa * - * Copyright 2002 Yoichi Yuasa - * yuasa@hh.iij4u.or.jp + * 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. + * + * 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 #include #include -#include #include #include @@ -31,11 +32,7 @@ extern unsigned long initrd_start, initr extern void * __rd_start, * __rd_end; #endif -#ifdef CONFIG_BLK_DEV_IDE -extern struct ide_ops workpad_ide_ops; -#endif - -void __init ibm_workpad_setup(void) +static void __init ibm_workpad_setup(void) { set_io_port_base(IO_PORT_BASE); ioport_resource.start = IO_PORT_RESOURCE_START; @@ -49,26 +46,18 @@ void __init ibm_workpad_setup(void) initrd_end = (unsigned long)&__rd_end; #endif - _machine_restart = vr41xx_restart; - _machine_halt = vr41xx_halt; - _machine_power_off = vr41xx_power_off; - board_time_init = vr41xx_time_init; board_timer_setup = vr41xx_timer_setup; -#ifdef CONFIG_FB - conswitchp = &dummy_con; -#endif - -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &workpad_ide_ops; -#endif - vr41xx_bcu_init(); - vr41xx_cmu_init(0); + vr41xx_cmu_init(); + + vr41xx_pmu_init(); #ifdef CONFIG_SERIAL_8250 vr41xx_siu_init(SIU_RS232C, 0); #endif } + +early_initcall(ibm_workpad_setup); --- diff/arch/mips/vr41xx/nec-eagle/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/nec-eagle/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -8,4 +8,3 @@ # obj-y += init.o irq.o setup.o -obj-$(CONFIG_IDE) += ide-eagle.o --- diff/arch/mips/vr41xx/nec-eagle/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/nec-eagle/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -38,22 +38,21 @@ * MontaVista Software Inc. or * - New creation, NEC Eagle is supported. */ -#include #include #include #include #include -char arcs_cmdline[CL_SIZE]; - const char *get_system_type(void) { return "NEC Eagle/Hawk"; } -void __init prom_init(int argc, char **argv, unsigned long magic, int *prom_vec) +void __init prom_init(void) { + int argc = fw_arg0; + char **argv = (char **) fw_arg1; int i; /* @@ -69,6 +68,7 @@ void __init prom_init(int argc, char **a mips_machtype = MACH_NEC_EAGLE; } -void __init prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } --- diff/arch/mips/vr41xx/nec-eagle/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/nec-eagle/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,55 +1,23 @@ /* - * FILE NAME - * arch/mips/vr41xx/nec-eagle/setup.c + * arch/mips/vr41xx/nec-eagle/setup.c * - * BRIEF MODULE DESCRIPTION - * Setup for the NEC Eagle/Hawk board. + * Setup for the NEC Eagle/Hawk board. * - * Author: Yoichi Yuasa - * yyuasa@mvista.com or source@mvista.com + * Author: Yoichi Yuasa * - * Copyright 2001,2002 MontaVista Software Inc. - * - * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * 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. - */ -/* - * Changes: - * MontaVista Software Inc. or - * - Moved mips_pci_channels[] from arch/mips/vr41xx/vr4122/eagle/setup.c. - * - Added support for NEC Hawk. - * - * MontaVista Software Inc. or - * - New creation, NEC Eagle is supported. + * 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under + * the terms of the GNU General Public License version 2. This program + * is licensed "as is" without any warranty of any kind, whether express + * or implied. */ #include #include -#include -#include #include #include #include #include #include -#include #include #include @@ -58,10 +26,6 @@ extern unsigned long initrd_start, initr extern void * __rd_start, * __rd_end; #endif -#ifdef CONFIG_BLK_DEV_IDE -extern struct ide_ops eagle_ide_ops; -#endif - extern void eagle_irq_init(void); #ifdef CONFIG_PCI @@ -84,9 +48,10 @@ static struct resource vr41xx_pci_mem_re extern struct pci_ops vr41xx_pci_ops; -struct pci_channel mips_pci_channels[] = { - {&vr41xx_pci_ops, &vr41xx_pci_io_resource, &vr41xx_pci_mem_resource, 0, 256}, - {NULL, NULL, NULL, 0, 0} +struct pci_controller vr41xx_controller = { + .pci_ops = &vr41xx_pci_ops, + .io_resource = &vr41xx_pci_io_resource, + .mem_resource = &vr41xx_pci_mem_resource, }; struct vr41xx_pci_address_space vr41xx_pci_mem1 = { @@ -114,7 +79,7 @@ static struct vr41xx_pci_address_map pci }; #endif -void __init nec_eagle_setup(void) +static int nec_eagle_setup(void) { set_io_port_base(IO_PORT_BASE); ioport_resource.start = IO_PORT_RESOURCE_START; @@ -128,26 +93,16 @@ void __init nec_eagle_setup(void) initrd_end = (unsigned long)&__rd_end; #endif - _machine_restart = vr41xx_restart; - _machine_halt = vr41xx_halt; - _machine_power_off = vr41xx_power_off; - board_time_init = vr41xx_time_init; board_timer_setup = vr41xx_timer_setup; board_irq_init = eagle_irq_init; -#ifdef CONFIG_FB - conswitchp = &dummy_con; -#endif - -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &eagle_ide_ops; -#endif - vr41xx_bcu_init(); - vr41xx_cmu_init(0); + vr41xx_cmu_init(); + + vr41xx_pmu_init(); #ifdef CONFIG_SERIAL_8250 vr41xx_dsiu_init(); @@ -159,4 +114,8 @@ void __init nec_eagle_setup(void) vrc4173_preinit(); #endif + + return 0; } + +early_initcall(nec_eagle_setup); --- diff/arch/mips/vr41xx/tanbac-tb0226/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/tanbac-tb0226/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -13,9 +13,9 @@ * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ -#include #include #include +#include #include #include @@ -23,16 +23,15 @@ #include #include -char arcs_cmdline[CL_SIZE]; - const char *get_system_type(void) { return "TANBAC TB0226"; } -void __init prom_init(int argc, char **argv, unsigned long magic, int *prom_vec) +void __init prom_init(void) { - u32 config; + int argc = fw_arg0; + char **argv = (char **) fw_arg1; int i; /* @@ -46,19 +45,9 @@ void __init prom_init(int argc, char **a mips_machgroup = MACH_GROUP_NEC_VR41XX; mips_machtype = MACH_TANBAC_TB0226; - - switch (current_cpu_data.processor_id) { - case PRID_VR4131_REV1_2: - config = read_c0_config(); - config &= ~0x00000030UL; - config |= 0x00410000UL; - write_c0_config(config); - break; - default: - break; - } } -void __init prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } --- diff/arch/mips/vr41xx/tanbac-tb0226/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/tanbac-tb0226/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,26 +1,27 @@ /* - * FILE NAME - * arch/mips/vr41xx/tanbac-tb0226/setup.c + * setup.c, Setup for the TANBAC TB0226. * - * BRIEF MODULE DESCRIPTION - * Setup for the TANBAC TB0226. + * Copyright (C) 2002-2003 Yoichi Yuasa * - * Copyright 2002,2003 Yoichi Yuasa - * yuasa@hh.iij4u.or.jp + * 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. + * + * 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 -#include #include #include @@ -46,17 +47,10 @@ static struct resource vr41xx_pci_mem_re extern struct pci_ops vr41xx_pci_ops; -struct pci_channel mips_pci_channels[] = { - { .pci_ops = &vr41xx_pci_ops, - .io_resource = &vr41xx_pci_io_resource, - .mem_resource = &vr41xx_pci_mem_resource, - .first_devfn = 0, - .last_devfn = 256, }, - { .pci_ops = NULL, - .io_resource = NULL, - .mem_resource = NULL, - .first_devfn = 0, - .last_devfn = 0, }, +struct pci_controller vr41xx_controller[] = { + .pci_ops = &vr41xx_pci_ops, + .io_resource = &vr41xx_pci_io_resource, + .mem_resource = &vr41xx_pci_mem_resource, }; struct vr41xx_pci_address_space vr41xx_pci_mem1 = { @@ -98,20 +92,14 @@ void __init tanbac_tb0226_setup(void) initrd_end = (unsigned long)&__rd_end; #endif - _machine_restart = vr41xx_restart; - _machine_halt = vr41xx_halt; - _machine_power_off = vr41xx_power_off; - board_time_init = vr41xx_time_init; board_timer_setup = vr41xx_timer_setup; -#ifdef CONFIG_FB - conswitchp = &dummy_con; -#endif - vr41xx_bcu_init(); - vr41xx_cmu_init(0); + vr41xx_cmu_init(); + + vr41xx_pmu_init(); vr41xx_siu_init(SIU_RS232C, 0); @@ -119,3 +107,5 @@ void __init tanbac_tb0226_setup(void) vr41xx_pciu_init(&pci_address_map); #endif } + +early_initcall(tanbac_tb0226_setup); --- diff/arch/mips/vr41xx/tanbac-tb0229/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/tanbac-tb0229/Makefile 2004-02-23 13:56:38.000000000 +0000 @@ -2,4 +2,6 @@ # Makefile for the TANBAC TB0229(VR4131DIMM) specific parts of the kernel # -obj-y := init.o reboot.o setup.o +obj-y := init.o setup.o + +obj-$(CONFIG_TANBAC_TB0219) += reboot.o --- diff/arch/mips/vr41xx/tanbac-tb0229/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/tanbac-tb0229/init.c 2004-02-23 13:56:38.000000000 +0000 @@ -17,10 +17,10 @@ * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ -#include #include #include #include +#include #include #include @@ -28,16 +28,15 @@ #include #include -char arcs_cmdline[CL_SIZE]; - const char *get_system_type(void) { return "TANBAC TB0229"; } -void __init prom_init(int argc, char **argv, unsigned long magic, int *prom_vec) +void __init prom_init(void) { - u32 config; + int argc = fw_arg0; + char **argv = (char **) fw_arg1; int i; /* @@ -51,19 +50,9 @@ void __init prom_init(int argc, char **a mips_machgroup = MACH_GROUP_NEC_VR41XX; mips_machtype = MACH_TANBAC_TB0229; - - switch (current_cpu_data.processor_id) { - case PRID_VR4131_REV1_2: - config = read_c0_config(); - config &= ~0x00000030UL; - config |= 0x00410000UL; - write_c0_config(config); - break; - default: - break; - } } -void __init prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } --- diff/arch/mips/vr41xx/tanbac-tb0229/reboot.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/tanbac-tb0229/reboot.c 2004-02-23 13:56:38.000000000 +0000 @@ -13,6 +13,7 @@ * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ +#include #include #include @@ -20,11 +21,7 @@ void tanbac_tb0229_restart(char *command) { -#ifdef CONFIG_TANBAC_TB0219 local_irq_disable(); tb0229_hard_reset(); while (1); -#else - vr41xx_restart(command); -#endif } --- diff/arch/mips/vr41xx/tanbac-tb0229/setup.c 2003-08-20 14:16:08.000000000 +0100 +++ source/arch/mips/vr41xx/tanbac-tb0229/setup.c 2004-02-23 13:56:38.000000000 +0000 @@ -1,25 +1,27 @@ /* - * FILE NAME - * arch/mips/vr41xx/tanbac-tb0229/setup.c + * setup.c, Setup for the TANBAC TB0229 (VR4131DIMM) * - * BRIEF MODULE DESCRIPTION - * Setup for the TANBAC TB0229 (VR4131DIMM) + * Copyright (C) 2002-2003 Yoichi Yuasa * - * Copyright 2002,2003 Yoichi Yuasa - * yuasa@hh.iij4u.or.jp + * Modified for TANBAC TB0229: + * Copyright (C) 2003 Megasolution Inc. * - * Modified for TANBAC TB0229: - * Copyright 2003 Megasolution Inc. - * matsu@megasolution.jp + * 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. + * + * 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 @@ -50,17 +52,10 @@ static struct resource vr41xx_pci_mem_re extern struct pci_ops vr41xx_pci_ops; -struct pci_channel mips_pci_channels[] = { - { .pci_ops = &vr41xx_pci_ops, - .io_resource = &vr41xx_pci_io_resource, - .mem_resource = &vr41xx_pci_mem_resource, - .first_devfn = 0, - .last_devfn = 256, }, - { .pci_ops = NULL, - .io_resource = NULL, - .mem_resource = NULL, - .first_devfn = 0, - .last_devfn = 0, } +struct pci_controller vr41xx_controller = { + .pci_ops = &vr41xx_pci_ops, + .io_resource = &vr41xx_pci_io_resource, + .mem_resource = &vr41xx_pci_mem_resource, }; struct vr41xx_pci_address_space vr41xx_pci_mem1 = { @@ -88,7 +83,7 @@ static struct vr41xx_pci_address_map pci }; #endif -void __init tanbac_tb0229_setup(void) +static void __init tanbac_tb0229_setup(void) { set_io_port_base(IO_PORT_BASE); ioport_resource.start = IO_PORT_RESOURCE_START; @@ -102,20 +97,14 @@ void __init tanbac_tb0229_setup(void) initrd_end = (unsigned long)&__rd_end; #endif - _machine_restart = tanbac_tb0229_restart; - _machine_halt = vr41xx_halt; - _machine_power_off = vr41xx_power_off; - board_time_init = vr41xx_time_init; board_timer_setup = vr41xx_timer_setup; -#ifdef CONFIG_FB - conswitchp = &dummy_con; -#endif - vr41xx_bcu_init(); - vr41xx_cmu_init(0); + vr41xx_cmu_init(); + + vr41xx_pmu_init(); vr41xx_siu_init(SIU_RS232C, 0); vr41xx_dsiu_init(); @@ -123,5 +112,10 @@ void __init tanbac_tb0229_setup(void) #ifdef CONFIG_PCI vr41xx_pciu_init(&pci_address_map); #endif + +#ifdef CONFIG_TANBAC_TB0219 + _machine_restart = tanbac_tb0229_restart; +#endif } +early_initcall(tanbac_tb0229_setup); --- diff/arch/mips/vr41xx/victor-mpc30x/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/victor-mpc30x/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -3,4 +3,3 @@ # obj-y += init.o setup.o -obj-$(CONFIG_IDE) += ide-mpc30x.o --- diff/arch/mips/vr41xx/victor-mpc30x/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/victor-mpc30x/init.c 2004-02-23 13:56:39.000000000 +0000 @@ -13,7 +13,6 @@ * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ -#include #include #include #include @@ -23,15 +22,15 @@ #include #include -char arcs_cmdline[CL_SIZE]; - const char *get_system_type(void) { return "Victor MP-C303/304"; } -void __init prom_init(int argc, char **argv, unsigned long magic, int *prom_vec) +void __init prom_init(void) { + int argc = fw_arg0; + char **argv = (char **) fw_arg1; int i; /* @@ -49,6 +48,7 @@ void __init prom_init(int argc, char **a add_memory_region(0, 32 << 20, BOOT_MEM_RAM); } -void __init prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } --- diff/arch/mips/vr41xx/victor-mpc30x/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/victor-mpc30x/setup.c 2004-02-23 13:56:39.000000000 +0000 @@ -1,29 +1,30 @@ /* - * FILE NAME - * arch/mips/vr41xx/victor-mpc30x/setup.c + * setup.c, Setup for the Victor MP-C303/304. * - * BRIEF MODULE DESCRIPTION - * Setup for the Victor MP-C303/304. + * Copyright (C) 2002-2003 Yoichi Yuasa * - * Copyright 2002 Yoichi Yuasa - * yuasa@hh.iij4u.or.jp + * 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. + * + * 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 #include #include #include -#include #include #include @@ -32,10 +33,6 @@ extern unsigned long initrd_start, initr extern void * __rd_start, * __rd_end; #endif -#ifdef CONFIG_BLK_DEV_IDE -extern struct ide_ops mpc30x_ide_ops; -#endif - #ifdef CONFIG_PCI static struct resource vr41xx_pci_io_resource = { "PCI I/O space", @@ -53,9 +50,10 @@ static struct resource vr41xx_pci_mem_re extern struct pci_ops vr41xx_pci_ops; -struct pci_channel mips_pci_channels[] = { - {&vr41xx_pci_ops, &vr41xx_pci_io_resource, &vr41xx_pci_mem_resource, 0, 256}, - {NULL, NULL, NULL, 0, 0} +struct pci_controller vr41xx_controller[] = { + .pci_ops = &vr41xx_pci_ops, + .io_resource = &vr41xx_pci_io_resource, + .mem_resource = &vr41xx_pci_mem_resource, }; struct vr41xx_pci_address_space vr41xx_pci_mem1 = { @@ -83,7 +81,7 @@ static struct vr41xx_pci_address_map pci }; #endif -void __init victor_mpc30x_setup(void) +static void __init victor_mpc30x_setup(void) { set_io_port_base(IO_PORT_BASE); ioport_resource.start = IO_PORT_RESOURCE_START; @@ -97,24 +95,14 @@ void __init victor_mpc30x_setup(void) initrd_end = (unsigned long)&__rd_end; #endif - _machine_restart = vr41xx_restart; - _machine_halt = vr41xx_halt; - _machine_power_off = vr41xx_power_off; - board_time_init = vr41xx_time_init; board_timer_setup = vr41xx_timer_setup; -#ifdef CONFIG_FB - conswitchp = &dummy_con; -#endif - -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &mpc30x_ide_ops; -#endif - vr41xx_bcu_init(); - vr41xx_cmu_init(0); + vr41xx_cmu_init(); + + vr41xx_pmu_init(); #ifdef CONFIG_SERIAL_8250 vr41xx_siu_init(SIU_RS232C, 0); @@ -124,3 +112,5 @@ void __init victor_mpc30x_setup(void) vr41xx_pciu_init(&pci_address_map); #endif } + +early_initcall(victor_mpc30x_setup); --- diff/arch/mips/vr41xx/zao-capcella/Makefile 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/zao-capcella/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -3,4 +3,3 @@ # obj-y += init.o setup.o -obj-$(CONFIG_IDE) += ide-capcella.o --- diff/arch/mips/vr41xx/zao-capcella/init.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/zao-capcella/init.c 2004-02-23 13:56:39.000000000 +0000 @@ -13,9 +13,9 @@ * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ -#include #include #include +#include #include #include @@ -23,8 +23,6 @@ #include #include -char arcs_cmdline[CL_SIZE]; - const char *get_system_type(void) { return "ZAO Networks Capcella"; @@ -32,7 +30,8 @@ const char *get_system_type(void) void __init prom_init(int argc, char **argv, unsigned long magic, int *prom_vec) { - u32 config; + int argc = fw_arg0; + char **argv = (char **) fw_arg1; int i; /* @@ -46,19 +45,9 @@ void __init prom_init(int argc, char **a mips_machgroup = MACH_GROUP_NEC_VR41XX; mips_machtype = MACH_ZAO_CAPCELLA; - - switch (current_cpu_data.processor_id) { - case PRID_VR4131_REV1_2: - config = read_c0_config(); - config &= ~0x00000030UL; - config |= 0x00410000UL; - write_c0_config(config); - break; - default: - break; - } } -void __init prom_free_prom_memory (void) +unsigned long __init prom_free_prom_memory(void) { + return 0; } --- diff/arch/mips/vr41xx/zao-capcella/setup.c 2003-07-08 09:55:17.000000000 +0100 +++ source/arch/mips/vr41xx/zao-capcella/setup.c 2004-02-23 13:56:39.000000000 +0000 @@ -1,29 +1,30 @@ /* - * FILE NAME - * arch/mips/vr41xx/zao-capcella/setup.c + * setup.c, Setup for the ZAO Networks Capcella. * - * BRIEF MODULE DESCRIPTION - * Setup for the ZAO Networks Capcella. + * Copyright (C) 2002-2003 Yoichi Yuasa * - * Copyright 2002 Yoichi Yuasa - * yuasa@hh.iij4u.or.jp + * 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. + * + * 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 #include #include #include -#include #include #include @@ -32,10 +33,6 @@ extern unsigned long initrd_start, initr extern void * __rd_start, * __rd_end; #endif -#ifdef CONFIG_BLK_DEV_IDE -extern struct ide_ops capcella_ide_ops; -#endif - #ifdef CONFIG_PCI static struct resource vr41xx_pci_io_resource = { "PCI I/O space", @@ -53,9 +50,10 @@ static struct resource vr41xx_pci_mem_re extern struct pci_ops vr41xx_pci_ops; -struct pci_channel mips_pci_channels[] = { - {&vr41xx_pci_ops, &vr41xx_pci_io_resource, &vr41xx_pci_mem_resource, 0, 256}, - {NULL, NULL, NULL, 0, 0} +struct pci_controller vr41xx_controller = { + .pci_ops = &vr41xx_pci_ops, + .io_resource = &vr41xx_pci_io_resource, + .mem_resource = &vr41xx_pci_mem_resource, }; struct vr41xx_pci_address_space vr41xx_pci_mem1 = { @@ -83,7 +81,7 @@ static struct vr41xx_pci_address_map pci }; #endif -void __init zao_capcella_setup(void) +static void __init zao_capcella_setup(void) { set_io_port_base(IO_PORT_BASE); ioport_resource.start = IO_PORT_RESOURCE_START; @@ -97,24 +95,14 @@ void __init zao_capcella_setup(void) initrd_end = (unsigned long)&__rd_end; #endif - _machine_restart = vr41xx_restart; - _machine_halt = vr41xx_halt; - _machine_power_off = vr41xx_power_off; - board_time_init = vr41xx_time_init; board_timer_setup = vr41xx_timer_setup; -#ifdef CONFIG_FB - conswitchp = &dummy_con; -#endif - -#ifdef CONFIG_BLK_DEV_IDE - ide_ops = &capcella_ide_ops; -#endif - vr41xx_bcu_init(); - vr41xx_cmu_init(0x0102); + vr41xx_cmu_init(); + + vr41xx_pmu_init(); #ifdef CONFIG_SERIAL_8250 vr41xx_siu_init(SIU_RS232C, 0); @@ -125,3 +113,5 @@ void __init zao_capcella_setup(void) vr41xx_pciu_init(&pci_address_map); #endif } + +early_initcall(zao_capcella_setup); --- diff/arch/parisc/hpux/ioctl.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/parisc/hpux/ioctl.c 2004-02-23 13:56:39.000000000 +0000 @@ -35,13 +35,12 @@ #include #include +#include #include #include #include #include -int sys_ioctl(unsigned int, unsigned int, unsigned long); - static int hpux_ioctl_t(int fd, unsigned long cmd, unsigned long arg) { int result = -EOPNOTSUPP; --- diff/arch/parisc/hpux/sys_hpux.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/parisc/hpux/sys_hpux.c 2004-02-23 13:56:39.000000000 +0000 @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -34,8 +35,6 @@ #include #include -unsigned long sys_brk(unsigned long addr); - unsigned long hpux_brk(unsigned long addr) { /* Sigh. Looks like HP/UX libc relies on kernel bugs. */ @@ -61,7 +60,6 @@ int hpux_ptrace(void) int hpux_wait(int *stat_loc) { - extern int sys_waitpid(int, int *, int); return sys_waitpid(-1, stat_loc, 0); } @@ -213,7 +211,6 @@ int hpux_statfs(const char *path, struct kfree(kpath); /* just fake it, beginning of structures match */ - extern int sys_statfs(const char *, struct statfs *); error = sys_statfs(path, (struct statfs *) buf); /* ignoring rest of statfs struct, but it should be zeros. Need to do @@ -269,9 +266,6 @@ static int hpux_uname(struct hpux_utsnam return error; } -int sys_sethostname(char *, int); -int sys_gethostname(char *, int); - /* Note: HP-UX just uses the old suser() function to check perms * in this system call. We'll use capable(CAP_SYS_ADMIN). */ --- diff/arch/parisc/kernel/ioctl32.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/parisc/kernel/ioctl32.c 2004-02-23 13:56:39.000000000 +0000 @@ -8,6 +8,8 @@ * ioctls. */ +#include + #define INCLUDES #include "compat_ioctl.c" --- diff/arch/parisc/kernel/parisc_ksyms.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/parisc/kernel/parisc_ksyms.c 2004-02-23 13:56:39.000000000 +0000 @@ -27,6 +27,7 @@ #include #include #include +#include #include EXPORT_SYMBOL(memchr); @@ -83,10 +84,6 @@ EXPORT_SYMBOL(__memcpy_fromio); EXPORT_SYMBOL(__memset_io); #include -extern long sys_open(const char *, int, int); -extern off_t sys_lseek(int, off_t, int); -extern int sys_read(int, char *, int); -extern int sys_write(int, const char *, int); EXPORT_SYMBOL(sys_open); EXPORT_SYMBOL(sys_lseek); EXPORT_SYMBOL(sys_read); --- diff/arch/parisc/kernel/signal32.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/parisc/kernel/signal32.c 2004-02-23 13:56:39.000000000 +0000 @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -92,9 +93,6 @@ get_sigset32(compat_sigset_t *up, sigset int sys32_rt_sigprocmask(int how, compat_sigset_t *set, compat_sigset_t *oset, unsigned int sigsetsize) { - extern long sys_rt_sigprocmask(int how, - sigset_t *set, sigset_t *oset, - size_t sigsetsize); sigset_t old_set, new_set; int ret; @@ -115,7 +113,6 @@ int sys32_rt_sigpending(compat_sigset_t { int ret; sigset_t set; - extern long sys_rt_sigpending(sigset_t *set, size_t sigsetsize); KERNEL_SYSCALL(ret, sys_rt_sigpending, &set, sigsetsize); --- diff/arch/parisc/kernel/sys_parisc.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/parisc/kernel/sys_parisc.c 2004-02-23 13:56:39.000000000 +0000 @@ -30,6 +30,7 @@ #include #include #include +#include int sys_pipe(int *fildes) { @@ -182,10 +183,6 @@ long sys_shmat_wrapper(int shmid, char * /* Fucking broken ABI */ #ifdef CONFIG_PARISC64 -extern asmlinkage long sys_truncate(const char *, unsigned long); -extern asmlinkage long sys_ftruncate(unsigned int, unsigned long); -extern asmlinkage long sys_fcntl(unsigned int, unsigned int, unsigned long); - asmlinkage long parisc_truncate64(const char * path, unsigned int high, unsigned int low) { @@ -214,9 +211,6 @@ asmlinkage long sys_fcntl64(unsigned int } #else -extern asmlinkage long sys_truncate64(const char *, loff_t); -extern asmlinkage long sys_ftruncate64(unsigned int, loff_t); - asmlinkage long parisc_truncate64(const char * path, unsigned int high, unsigned int low) { @@ -230,12 +224,6 @@ asmlinkage long parisc_ftruncate64(unsig } #endif -extern asmlinkage ssize_t sys_pread64(unsigned int fd, char *buf, - size_t count, loff_t pos); -extern asmlinkage ssize_t sys_pwrite64(unsigned int fd, const char *buf, - size_t count, loff_t pos); -extern asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count); - asmlinkage ssize_t parisc_pread64(unsigned int fd, char *buf, size_t count, unsigned int high, unsigned int low) { @@ -257,7 +245,7 @@ asmlinkage ssize_t parisc_readahead(int /* * This changes the io permissions bitmap in the current task. */ -asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int turn_on) +asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) { return -ENOSYS; } --- diff/arch/parisc/kernel/sys_parisc32.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/parisc/kernel/sys_parisc32.c 2004-02-23 13:56:39.000000000 +0000 @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -357,7 +358,6 @@ asmlinkage long sys32_sched_rr_get_inter { struct timespec t; int ret; - extern asmlinkage long sys_sched_rr_get_interval(pid_t pid, struct timespec *interval); KERNEL_SYSCALL(ret, sys_sched_rr_get_interval, pid, &t); if (put_compat_timespec(&t, interval)) @@ -1089,7 +1089,6 @@ asmlinkage long sys32_msgrcv(int msqid, } -extern asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t *offset, size_t count); asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t *offset, s32 count) { mm_segment_t old_fs = get_fs(); @@ -1197,7 +1196,6 @@ asmlinkage int sys32_nfsservctl(int cmd, return ret; } -extern asmlinkage ssize_t sys_sendfile64(int out_fd, int in_fd, loff_t *offset, size_t count); typedef long __kernel_loff_t32; /* move this to asm/posix_types.h? */ asmlinkage int sys32_sendfile64(int out_fd, int in_fd, __kernel_loff_t32 *offset, s32 count) @@ -1345,8 +1343,6 @@ asmlinkage int sys32_sysinfo(struct sysi * half of the argument has been zeroed by syscall.S. */ -extern asmlinkage off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin); - asmlinkage int sys32_lseek(unsigned int fd, int offset, unsigned int origin) { return sys_lseek(fd, offset, origin); @@ -1367,8 +1363,6 @@ asmlinkage long sys32_semctl(int semid, return sys_semctl (semid, semnum, cmd, arg); } -extern long sys_lookup_dcookie(u64 cookie64, char *buf, size_t len); - long sys32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char *buf, size_t len) { --- diff/arch/parisc/kernel/time.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/parisc/kernel/time.c 2004-02-23 13:56:39.000000000 +0000 @@ -230,6 +230,7 @@ do_settimeofday (struct timespec *tv) time_esterror = NTP_PHASE_LIMIT; } write_sequnlock_irq(&xtime_lock); + clock_was_set(); return 0; } EXPORT_SYMBOL(do_settimeofday); --- diff/arch/ppc/8260_io/enet.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/ppc/8260_io/enet.c 2004-02-23 13:56:39.000000000 +0000 @@ -851,7 +851,7 @@ static int __init scc_enet_init(void) err = register_netdev(dev); if (err) { - kfree(dev); + free_netdev(dev); return err; } --- diff/arch/ppc/8260_io/fcc_enet.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/ppc/8260_io/fcc_enet.c 2004-02-23 13:56:39.000000000 +0000 @@ -1371,7 +1371,7 @@ static int __init fec_enet_init(void) err = register_netdev(dev); if (err) { - kfree(dev); + free_netdev(dev); return err; } --- diff/arch/ppc/8xx_io/enet.c 2003-09-30 15:46:11.000000000 +0100 +++ source/arch/ppc/8xx_io/enet.c 2004-02-23 13:56:39.000000000 +0000 @@ -949,7 +949,7 @@ static int __init scc_enet_init(void) err = register_netdev(dev); if (err) { - kfree(dev); + free_netdev(dev); return err; } --- diff/arch/ppc/8xx_io/fec.c 2003-06-30 10:07:19.000000000 +0100 +++ source/arch/ppc/8xx_io/fec.c 2004-02-23 13:56:39.000000000 +0000 @@ -1748,7 +1748,7 @@ static int __init fec_enet_init(void) err = register_netdev(dev); if (err) { - kfree(dev); + free_netdev(dev); return err; } --- diff/arch/ppc/Kconfig 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ppc/Kconfig 2004-02-23 13:56:39.000000000 +0000 @@ -978,24 +978,6 @@ config PCI_PERMEDIA source "drivers/pci/Kconfig" -config HOTPLUG - bool "Support for hot-pluggable devices" - ---help--- - Say Y here if you want to plug devices into your computer while - the system is running, and be able to use them quickly. In many - cases, the devices can likewise be unplugged at any time too. - - One well known example of this is PCMCIA- or PC-cards, credit-card - size devices such as network cards, modems or hard drives which are - plugged into slots found on all modern laptop computers. Another - example, used on modern desktops as well as laptops, is USB. - - Enable HOTPLUG and KMOD, and build a modular kernel. Get agent - software (at ) and install it. - Then your kernel will automatically call out to a user mode "policy - agent" (/sbin/hotplug) to load modules and set up software needed - to use devices as you hotplug them. - source "drivers/pcmcia/Kconfig" endmenu --- diff/arch/ppc/boot/ld.script 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/ppc/boot/ld.script 2004-02-23 13:56:39.000000000 +0000 @@ -82,6 +82,7 @@ SECTIONS *(__ksymtab) *(__ksymtab_strings) *(__bug_table) + *(__kcrctab) } } --- diff/arch/ppc/kernel/irq.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/ppc/kernel/irq.c 2004-02-23 13:56:39.000000000 +0000 @@ -575,7 +575,7 @@ cpumask_t irq_affinity [NR_IRQS]; static int irq_affinity_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, irq_affinity[(long)data]); + int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); @@ -616,7 +616,7 @@ static int irq_affinity_write_proc (stru static int prof_cpu_mask_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, *(cpumask_t *)data); + int len = cpumask_scnprintf(page, count, *(cpumask_t *)data); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); --- diff/arch/ppc/kernel/l2cr.S 2003-09-30 15:46:12.000000000 +0100 +++ source/arch/ppc/kernel/l2cr.S 2004-02-23 13:56:39.000000000 +0000 @@ -130,11 +130,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) mtspr HID0,r4 /* Disable DPM */ sync - /* Flush & disable L1 */ - mr r5,r3 - bl __flush_disable_L1 - mr r3,r5 - /* Get the current enable bit of the L2CR into r4 */ mfspr r4,L2CR @@ -236,7 +231,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_SPEC7450) sync 4: - bl __inval_enable_L1 /* Restore HID0[DPM] to whatever it was before */ sync @@ -394,11 +388,10 @@ BEGIN_FTR_SECTION END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) sync - /* Load counter to 0x1000 cache lines (128k) and + /* Load counter to 0x4000 cache lines (512k) and * load cache with datas */ - lis r3,0x0002 -// li r3,0x1000 /* 128kB / 32B */ + li r3,0x4000 /* 512kB / 32B */ mtctr r3 li r3, 0 1: @@ -409,8 +402,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) sync /* Now flush those cache lines */ - lis r3,0x0002 -// li r3,0x1000 /* 128kB / 32B */ + li r3,0x4000 /* 512kB / 32B */ mtctr r3 li r3, 0 1: --- diff/arch/ppc/kernel/setup.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ppc/kernel/setup.c 2004-02-23 13:56:39.000000000 +0000 @@ -53,7 +53,7 @@ extern void ppc6xx_idle(void); extern void power4_idle(void); extern boot_infos_t *boot_infos; -char saved_command_line[256]; +char saved_command_line[COMMAND_LINE_SIZE]; unsigned char aux_device_present; struct ide_machdep_calls ppc_ide_md; char *sysmap; @@ -501,7 +501,7 @@ void parse_bootinfo(struct bi_record *re ulong *data = rec->data; switch (rec->tag) { case BI_CMD_LINE: - memcpy(cmd_line, (void *)data, rec->size); + strlcpy(cmd_line, (void *)data, sizeof(cmd_line)); break; case BI_SYSMAP: sysmap = (char *)((data[0] >= (KERNELBASE)) ? data[0] : @@ -538,7 +538,7 @@ machine_init(unsigned long r3, unsigned unsigned long r6, unsigned long r7) { #ifdef CONFIG_CMDLINE - strcpy(cmd_line, CONFIG_CMDLINE); + strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line)); #endif /* CONFIG_CMDLINE */ #ifdef CONFIG_6xx @@ -676,7 +676,7 @@ void __init setup_arch(char **cmdline_p) init_mm.brk = (unsigned long) klimit; /* Save unparsed command line copy for /proc/cmdline */ - strcpy(saved_command_line, cmd_line); + strlcpy(saved_command_line, cmd_line, sizeof(saved_command_line)); *cmdline_p = cmd_line; /* set up the bootmem stuff with available memory */ --- diff/arch/ppc/kernel/smp.c 2004-02-18 08:54:07.000000000 +0000 +++ source/arch/ppc/kernel/smp.c 2004-02-23 13:56:39.000000000 +0000 @@ -54,6 +54,7 @@ int smp_hw_index[NR_CPUS]; struct thread_info *secondary_ti; EXPORT_SYMBOL(cpu_online_map); +EXPORT_SYMBOL(cpu_possible_map); /* SMP operations for this machine */ static struct smp_ops_t *smp_ops; --- diff/arch/ppc/kernel/syscalls.c 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/ppc/kernel/syscalls.c 2004-02-23 13:56:39.000000000 +0000 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -200,8 +201,6 @@ out: return err; } -extern int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); - /* * Due to some executables calling the wrong select we sometimes * get wrong args. This determines how the args are being passed --- diff/arch/ppc/kernel/time.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/ppc/kernel/time.c 2004-02-23 13:56:39.000000000 +0000 @@ -294,6 +294,7 @@ int do_settimeofday(struct timespec *tv) time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; write_sequnlock_irqrestore(&xtime_lock, flags); + clock_was_set(); return 0; } --- diff/arch/ppc/platforms/pmac_pic.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc/platforms/pmac_pic.c 2004-02-23 13:56:39.000000000 +0000 @@ -646,7 +646,7 @@ static int __init init_pmacpic_sysfs(voi printk(KERN_DEBUG "Registering pmac pic with sysfs...\n"); sysdev_class_register(&pmacpic_sysclass); - sys_device_register(&device_pmacpic); + sysdev_register(&device_pmacpic); sysdev_driver_register(&pmacpic_sysclass, &driver_pmacpic); return 0; } --- diff/arch/ppc/syslib/open_pic.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc/syslib/open_pic.c 2004-02-23 13:56:39.000000000 +0000 @@ -1032,7 +1032,7 @@ static int __init init_openpic_sysfs(voi printk(KERN_ERR "Failed registering openpic sys class\n"); return -ENODEV; } - rc = sys_device_register(&device_openpic); + rc = sysdev_register(&device_openpic); if (rc) { printk(KERN_ERR "Failed registering openpic sys device\n"); return -ENODEV; --- diff/arch/ppc/syslib/open_pic2.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc/syslib/open_pic2.c 2004-02-23 13:56:39.000000000 +0000 @@ -699,7 +699,7 @@ static int __init init_openpic2_sysfs(vo printk(KERN_ERR "Failed registering openpic sys class\n"); return -ENODEV; } - rc = sys_device_register(&device_openpic2); + rc = sysdev_register(&device_openpic2); if (rc) { printk(KERN_ERR "Failed registering openpic sys device\n"); return -ENODEV; --- diff/arch/ppc64/Kconfig 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/Kconfig 2004-02-23 13:56:39.000000000 +0000 @@ -227,24 +227,6 @@ source "fs/Kconfig.binfmt" source "drivers/pci/Kconfig" -config HOTPLUG - bool "Support for hot-pluggable devices" - ---help--- - Say Y here if you want to plug devices into your computer while - the system is running, and be able to use them quickly. In many - cases, the devices can likewise be unplugged at any time too. - - One well known example of this is PCMCIA- or PC-cards, credit-card - size devices such as network cards, modems or hard drives which are - plugged into slots found on all modern laptop computers. Another - example, used on modern desktops as well as laptops, is USB. - - Enable HOTPLUG and KMOD, and build a modular kernel. Get agent - software (at ) and install it. - Then your kernel will automatically call out to a user mode "policy - agent" (/sbin/hotplug) to load modules and set up software needed - to use devices as you hotplug them. - source "drivers/pcmcia/Kconfig" source "drivers/pci/hotplug/Kconfig" @@ -334,6 +316,19 @@ config DEBUG_KERNEL Say Y here if you are developing drivers or trying to debug and identify kernel problems. +config DEBUG_STACKOVERFLOW + bool "Check for stack overflows" + depends on DEBUG_KERNEL + +config DEBUG_STACK_USAGE + bool "Stack utilization instrumentation" + depends on DEBUG_KERNEL + help + Enables the display of the minimum amount of free stack which each + task has ever had available in the sysrq-T and sysrq-P debug output. + + This option will slow down process creation somewhat. + config DEBUG_SLAB bool "Debug memory allocations" depends on DEBUG_KERNEL --- diff/arch/ppc64/Makefile 2004-02-09 10:36:07.000000000 +0000 +++ source/arch/ppc64/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -27,15 +27,16 @@ LDFLAGS_vmlinux := -Bstatic -e $(KERNELL CFLAGS += -msoft-float -pipe -Wno-uninitialized -mminimal-toc \ -mtraceback=none -HAS_POWER4 := $(shell if $(CC) -mcpu=power4 -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo y; else echo n; fi;) -ifeq ($(HAS_POWER4),y) ifeq ($(CONFIG_POWER4_ONLY),y) -CFLAGS += -mcpu=power4 + CFLAGS += $(call check_gcc,-mcpu=power4,) else -CFLAGS += -mtune=power4 -endif + CFLAGS += $(call check_gcc,-mtune=power4,) endif +# Enable unit-at-a-time mode when possible. It shrinks the +# kernel considerably. +CFLAGS += $(call check_gcc,-funit-at-a-time,) + head-y := arch/ppc64/kernel/head.o libs-y += arch/ppc64/lib/ @@ -70,4 +71,11 @@ arch/ppc64/kernel/asm-offsets.s: include include/asm-ppc64/offsets.h: arch/ppc64/kernel/asm-offsets.s $(call filechk,gen-asm-offsets) +define archhelp + echo '* zImage - Compressed kernel image (arch/$(ARCH)/boot/zImage)' + echo ' zImage.initrd- Compressed kernel image with initrd attached, + echo ' sourced from arch/$(ARCH)/boot/ramdisk.image.gz' + echo ' (arch/$(ARCH)/boot/zImage.initrd)' +endef + CLEAN_FILES += include/asm-ppc64/offsets.h --- diff/arch/ppc64/boot/Makefile 2003-09-30 15:46:12.000000000 +0100 +++ source/arch/ppc64/boot/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -20,7 +20,7 @@ # CROSS32_COMPILE is setup as a prefix just like CROSS_COMPILE # in the toplevel makefile. -CROSS32_COMPILE = +CROSS32_COMPILE ?= #CROSS32_COMPILE = /usr/local/ppc/bin/powerpc-linux- BOOTCC := $(CROSS32_COMPILE)gcc --- diff/arch/ppc64/kernel/Makefile 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -14,11 +14,13 @@ obj-y := setup.o entry.o t obj-$(CONFIG_PPC_OF) += of_device.o -obj-$(CONFIG_PCI) += pci.o pci_dn.o pci_dma.o pci_dma_direct.o +obj-$(CONFIG_PCI) += pci.o pci_dn.o pci_dma.o ifdef CONFIG_PPC_ISERIES obj-$(CONFIG_PCI) += iSeries_pci.o iSeries_pci_reset.o \ iSeries_IoMmTable.o +else +obj-$(CONFIG_PCI) += pci_dma_direct.o endif obj-$(CONFIG_PPC_ISERIES) += iSeries_irq.o \ --- diff/arch/ppc64/kernel/chrp_setup.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/chrp_setup.c 2004-02-23 13:56:39.000000000 +0000 @@ -129,7 +129,6 @@ void __init chrp_request_regions(void) void __init chrp_setup_arch(void) { - extern char cmd_line[]; struct device_node *root; unsigned int *opprop; --- diff/arch/ppc64/kernel/cputable.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/cputable.c 2004-02-23 13:56:39.000000000 +0000 @@ -46,7 +46,7 @@ extern void __setup_cpu_ppc970(unsigned struct cpu_spec cpu_specs[] = { { /* Power3 */ - 0xffff0000, 0x00400000, "Power3 (630)", + 0xffff0000, 0x00400000, "POWER3 (630)", CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_DABR | CPU_FTR_IABR, COMMON_USER_PPC64, @@ -55,7 +55,7 @@ struct cpu_spec cpu_specs[] = { COMMON_PPC64_FW }, { /* Power3+ */ - 0xffff0000, 0x00410000, "Power3 (630+)", + 0xffff0000, 0x00410000, "POWER3 (630+)", CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_DABR | CPU_FTR_IABR, COMMON_USER_PPC64, @@ -64,7 +64,7 @@ struct cpu_spec cpu_specs[] = { COMMON_PPC64_FW }, { /* Northstar */ - 0xffff0000, 0x00330000, "Northstar", + 0xffff0000, 0x00330000, "RS64-II (northstar)", CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_DABR | CPU_FTR_IABR, COMMON_USER_PPC64, @@ -73,7 +73,7 @@ struct cpu_spec cpu_specs[] = { COMMON_PPC64_FW }, { /* Pulsar */ - 0xffff0000, 0x00340000, "Pulsar", + 0xffff0000, 0x00340000, "RS64-III (pulsar)", CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_DABR | CPU_FTR_IABR, COMMON_USER_PPC64, @@ -82,7 +82,7 @@ struct cpu_spec cpu_specs[] = { COMMON_PPC64_FW }, { /* I-star */ - 0xffff0000, 0x00360000, "I-star", + 0xffff0000, 0x00360000, "RS64-III (icestar)", CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_DABR | CPU_FTR_IABR, COMMON_USER_PPC64, @@ -91,7 +91,7 @@ struct cpu_spec cpu_specs[] = { COMMON_PPC64_FW }, { /* S-star */ - 0xffff0000, 0x00370000, "S-star", + 0xffff0000, 0x00370000, "RS64-IV (sstar)", CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_DABR | CPU_FTR_IABR, COMMON_USER_PPC64, @@ -100,7 +100,7 @@ struct cpu_spec cpu_specs[] = { COMMON_PPC64_FW }, { /* Power4 */ - 0xffff0000, 0x00350000, "Power4", + 0xffff0000, 0x00350000, "POWER4 (gp)", CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_DABR, COMMON_USER_PPC64, @@ -109,7 +109,7 @@ struct cpu_spec cpu_specs[] = { COMMON_PPC64_FW }, { /* Power4+ */ - 0xffff0000, 0x00380000, "Power4+", + 0xffff0000, 0x00380000, "POWER4+ (gq)", CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_DABR, COMMON_USER_PPC64, @@ -126,8 +126,17 @@ struct cpu_spec cpu_specs[] = { __setup_cpu_ppc970, COMMON_PPC64_FW }, + { /* PPC970FX */ + 0xffff0000, 0x003c0000, "PPC970FX", + CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | + CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_ALTIVEC_COMP | CPU_FTR_CAN_NAP, + COMMON_USER_PPC64 | PPC_FEATURE_HAS_ALTIVEC_COMP, + 128, 128, + __setup_cpu_ppc970, + COMMON_PPC64_FW + }, { /* Power5 */ - 0xffff0000, 0x003a0000, "Power5", + 0xffff0000, 0x003a0000, "POWER5 (gr)", CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2, COMMON_USER_PPC64, @@ -136,7 +145,7 @@ struct cpu_spec cpu_specs[] = { COMMON_PPC64_FW }, { /* default match */ - 0x00000000, 0x00000000, "(Power4-Compatible)", + 0x00000000, 0x00000000, "POWER4 (compatible)", CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_DABR, COMMON_USER_PPC64, --- diff/arch/ppc64/kernel/eeh.c 2004-02-09 10:36:08.000000000 +0000 +++ source/arch/ppc64/kernel/eeh.c 2004-02-23 13:56:39.000000000 +0000 @@ -31,6 +31,7 @@ #include #include #include +#include #include "pci.h" #define BUID_HI(buid) ((buid) >> 32) @@ -49,6 +50,8 @@ static int eeh_implemented; static char *eeh_opts; static int eeh_opts_last; +unsigned char slot_err_buf[RTAS_ERROR_LOG_MAX]; + pte_t *find_linux_pte(pgd_t *pgdir, unsigned long va); /* from htab.c */ static int eeh_check_opts_config(struct device_node *dn, int class_code, int vendor_id, int device_id, @@ -113,8 +116,22 @@ unsigned long eeh_check_failure(void *to */ if (dn->eeh_config_addr) { ret = rtas_call(ibm_read_slot_reset_state, 3, 3, rets, - dn->eeh_config_addr, BUID_HI(dn->phb->buid), BUID_LO(dn->phb->buid)); + dn->eeh_config_addr, BUID_HI(dn->phb->buid), + BUID_LO(dn->phb->buid)); if (ret == 0 && rets[1] == 1 && rets[0] >= 2) { + unsigned long slot_err_ret; + + memset(slot_err_buf, 0, RTAS_ERROR_LOG_MAX); + slot_err_ret = rtas_call(rtas_token("ibm,slot-error-detail"), + 8, 1, NULL, dn->eeh_config_addr, + BUID_HI(dn->phb->buid), + BUID_LO(dn->phb->buid), NULL, 0, + __pa(slot_err_buf), RTAS_ERROR_LOG_MAX, + 2 /* Permanent Error */); + + if (slot_err_ret == 0) + log_error(slot_err_buf, ERR_TYPE_RTAS_LOG, 1 /* Fatal */); + /* * XXX We should create a separate sysctl for this. * @@ -123,9 +140,11 @@ unsigned long eeh_check_failure(void *to * can use it here. */ if (panic_on_oops) - panic("EEH: MMIO failure (%ld) on device:\n%s\n", rets[0], pci_name(dev)); + panic("EEH: MMIO failure (%ld) on device:\n%s\n", + rets[0], pci_name(dev)); else - printk("EEH: MMIO failure (%ld) on device:\n%s\n", rets[0], pci_name(dev)); + printk("EEH: MMIO failure (%ld) on device:\n%s\n", + rets[0], pci_name(dev)); } } eeh_false_positives++; @@ -228,10 +247,8 @@ void eeh_init(void) { struct device_node *phb; struct eeh_early_enable_info info; - - extern char cmd_line[]; /* Very early cmd line parse. Cheap, but works. */ - char *eeh_force_off = strstr(cmd_line, "eeh-force-off"); - char *eeh_force_on = strstr(cmd_line, "eeh-force-on"); + char *eeh_force_off = strstr(saved_command_line, "eeh-force-off"); + char *eeh_force_on = strstr(saved_command_line, "eeh-force-on"); ibm_set_eeh_option = rtas_token("ibm,set-eeh-option"); ibm_set_slot_reset = rtas_token("ibm,set-slot-reset"); --- diff/arch/ppc64/kernel/head.S 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/head.S 2004-02-23 13:56:39.000000000 +0000 @@ -2177,4 +2177,4 @@ stab_array: */ .globl cmd_line cmd_line: - .space 512 + .space 512 /* COMMAND_LINE_SIZE */ --- diff/arch/ppc64/kernel/iSeries_irq.c 2004-02-09 10:36:08.000000000 +0000 +++ source/arch/ppc64/kernel/iSeries_irq.c 2004-02-23 13:56:39.000000000 +0000 @@ -57,6 +57,7 @@ static hw_irq_controller iSeries_IRQ_han void iSeries_init_irq_desc(irq_desc_t *desc) { + desc->handler = &iSeries_IRQ_handler; } /* This is called by init_IRQ. set in ppc_md.init_IRQ by iSeries_setup.c */ @@ -87,22 +88,6 @@ int __init iSeries_allocate_IRQ(HvBusNum #define IRQ_TO_IDSEL(irq) (((((irq) - 1) >> 3) & 7) + 1) #define IRQ_TO_FUNC(irq) (((irq) - 1) & 7) -/* - * This is called out of iSeries_scan_slot to assign the EADS slot - * to its IRQ number - */ -int __init iSeries_assign_IRQ(int irq, HvBusNumber busNumber, - HvSubBusNumber subBusNumber, HvAgentId deviceId) -{ - irq_desc_t *desc = get_real_irq_desc(irq); - - if (desc == NULL) - return -1; - desc->handler = &iSeries_IRQ_handler; - return 0; -} - - /* This is called by iSeries_activate_IRQs */ static unsigned int iSeries_startup_IRQ(unsigned int irq) { @@ -125,6 +110,11 @@ static unsigned int iSeries_startup_IRQ( } /* + * Temporary hack + */ +#define get_irq_desc(irq) &irq_desc[(irq)] + +/* * This is called out of iSeries_fixup to activate interrupt * generation for usable slots */ --- diff/arch/ppc64/kernel/iSeries_pci.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/iSeries_pci.c 2004-02-23 13:56:39.000000000 +0000 @@ -406,7 +406,6 @@ static int iSeries_Scan_Bridge_Slot(HvBu /* iSeries_allocate_IRQ.: 0x18.00.12(0xA3) */ Irq = iSeries_allocate_IRQ(Bus, 0, EADsIdSel); - iSeries_assign_IRQ(Irq, Bus, 0, EADsIdSel); PPCDBG(PPCDBG_BUSWALK, "PCI:- allocate and assign IRQ 0x%02X.%02X.%02X = 0x%02X\n", Bus, 0, EADsIdSel, Irq); --- diff/arch/ppc64/kernel/iSeries_setup.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/iSeries_setup.c 2004-02-23 13:56:39.000000000 +0000 @@ -315,7 +315,6 @@ void __init iSeries_init_early(void) ppc_md.setup_residual = iSeries_setup_residual; ppc_md.get_cpuinfo = iSeries_get_cpuinfo; ppc_md.init_IRQ = iSeries_init_IRQ; - ppc_md.init_irq_desc = iSeries_init_irq_desc; ppc_md.get_irq = iSeries_get_irq; ppc_md.init = NULL; --- diff/arch/ppc64/kernel/ioctl32.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/ppc64/kernel/ioctl32.c 2004-02-23 13:56:39.000000000 +0000 @@ -23,6 +23,7 @@ #define INCLUDES #include "compat_ioctl.c" #include +#include #include #define CODE --- diff/arch/ppc64/kernel/irq.c 2004-02-09 10:36:08.000000000 +0000 +++ source/arch/ppc64/kernel/irq.c 2004-02-23 13:56:39.000000000 +0000 @@ -476,8 +476,18 @@ void ppc_irq_dispatch_handler(struct pt_ struct irqaction *action; int cpu = smp_processor_id(); irq_desc_t *desc = irq_desc + irq; + irqreturn_t action_ret; kstat_cpu(cpu).irqs[irq]++; + + if (desc->status & IRQ_PER_CPU) { + /* no locking required for CPU-local interrupts: */ + ack_irq(irq); + action_ret = handle_irq_event(irq, regs, desc->action); + desc->handler->end(irq); + return; + } + spin_lock(&desc->lock); ack_irq(irq); /* @@ -485,8 +495,7 @@ void ppc_irq_dispatch_handler(struct pt_ WAITING is used by probe to mark irqs that are being tested */ status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING); - if (!(status & IRQ_PER_CPU)) - status |= IRQ_PENDING; /* we _want_ to handle it */ + status |= IRQ_PENDING; /* we _want_ to handle it */ /* * If the IRQ is disabled for whatever reason, we cannot @@ -509,8 +518,7 @@ void ppc_irq_dispatch_handler(struct pt_ goto out; } status &= ~IRQ_PENDING; /* we commit to handling */ - if (!(status & IRQ_PER_CPU)) - status |= IRQ_INPROGRESS; /* we are handling it */ + status |= IRQ_INPROGRESS; /* we are handling it */ } desc->status = status; @@ -534,8 +542,6 @@ void ppc_irq_dispatch_handler(struct pt_ * SMP environment. */ for (;;) { - irqreturn_t action_ret; - spin_unlock(&desc->lock); action_ret = handle_irq_event(irq, regs, action); spin_lock(&desc->lock); @@ -568,6 +574,21 @@ int do_IRQ(struct pt_regs *regs) irq_enter(); +#ifdef CONFIG_DEBUG_STACKOVERFLOW + /* Debugging check for stack overflow: is there less than 8KB free? */ + { + long sp; + + sp = __get_SP() & (THREAD_SIZE-1); + + if (unlikely(sp < (sizeof(struct thread_info) + 8192))) { + printk("do_IRQ: stack overflow: %ld\n", + sp - sizeof(struct thread_info)); + dump_stack(); + } + } +#endif + lpaca = get_paca(); #ifdef CONFIG_SMP if (lpaca->xLpPaca.xIntDword.xFields.xIpiCnt) { @@ -664,7 +685,7 @@ cpumask_t irq_affinity [NR_IRQS] = { [0 static int irq_affinity_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, irq_affinity[(long)data]); + int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); @@ -702,7 +723,7 @@ static int irq_affinity_write_proc (stru static int prof_cpu_mask_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, *(cpumask_t *)data); + int len = cpumask_scnprintf(page, count, *(cpumask_t *)data); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); --- diff/arch/ppc64/kernel/lmb.c 2003-05-21 11:49:45.000000000 +0100 +++ source/arch/ppc64/kernel/lmb.c 2004-02-23 13:56:39.000000000 +0000 @@ -1,5 +1,4 @@ /* - * * Procedures for interfacing to Open Firmware. * * Peter Bergner, IBM Corp. June 2001. @@ -13,46 +12,63 @@ #include #include +#include #include #include #include #include #include #include -#include -extern unsigned long klimit; -extern unsigned long reloc_offset(void); +struct lmb lmb __initdata; +static unsigned long __init +lmb_addrs_overlap(unsigned long base1, unsigned long size1, + unsigned long base2, unsigned long size2) +{ + return ((base1 < (base2+size2)) && (base2 < (base1+size1))); +} -static long lmb_add_region(struct lmb_region *, unsigned long, unsigned long, unsigned long); +static long __init +lmb_addrs_adjacent(unsigned long base1, unsigned long size1, + unsigned long base2, unsigned long size2) +{ + if (base2 == base1 + size1) + return 1; + else if (base1 == base2 + size2) + return -1; -struct lmb lmb = { - 0, 0, - {0,0,0,0,{{0,0,0}}}, - {0,0,0,0,{{0,0,0}}} -}; + return 0; +} +static long __init +lmb_regions_adjacent(struct lmb_region *rgn, unsigned long r1, unsigned long r2) +{ + unsigned long base1 = rgn->region[r1].base; + unsigned long size1 = rgn->region[r1].size; + unsigned long base2 = rgn->region[r2].base; + unsigned long size2 = rgn->region[r2].size; + + return lmb_addrs_adjacent(base1, size1, base2, size2); +} /* Assumption: base addr of region 1 < base addr of region 2 */ -static void +static void __init lmb_coalesce_regions(struct lmb_region *rgn, unsigned long r1, unsigned long r2) { unsigned long i; rgn->region[r1].size += rgn->region[r2].size; - for (i=r2; i < rgn->cnt-1 ;i++) { + for (i=r2; i < rgn->cnt-1; i++) { rgn->region[i].base = rgn->region[i+1].base; rgn->region[i].physbase = rgn->region[i+1].physbase; rgn->region[i].size = rgn->region[i+1].size; - rgn->region[i].type = rgn->region[i+1].type; } rgn->cnt--; } - /* This routine called with relocation disabled. */ -void +void __init lmb_init(void) { unsigned long offset = reloc_offset(); @@ -63,38 +79,20 @@ lmb_init(void) */ _lmb->memory.region[0].base = 0; _lmb->memory.region[0].size = 0; - _lmb->memory.region[0].type = LMB_MEMORY_AREA; _lmb->memory.cnt = 1; /* Ditto. */ _lmb->reserved.region[0].base = 0; _lmb->reserved.region[0].size = 0; - _lmb->reserved.region[0].type = LMB_MEMORY_AREA; _lmb->reserved.cnt = 1; } -/* This is only used here, it doesn't deserve to be in bitops.h */ -static __inline__ long cnt_trailing_zeros(unsigned long mask) -{ - long cnt; - - asm( -" addi %0,%1,-1 \n\ - andc %0,%0,%1 \n\ - cntlzd %0,%0 \n\ - subfic %0,%0,64" - : "=r" (cnt) - : "r" (mask)); - return cnt; -} - /* This routine called with relocation disabled. */ -void +void __init lmb_analyze(void) { unsigned long i; unsigned long mem_size = 0; - unsigned long io_size = 0; unsigned long size_mask = 0; unsigned long offset = reloc_offset(); struct lmb *_lmb = PTRRELOC(&lmb); @@ -102,13 +100,9 @@ lmb_analyze(void) unsigned long physbase = 0; #endif - for (i=0; i < _lmb->memory.cnt ;i++) { - unsigned long lmb_type = _lmb->memory.region[i].type; + for (i=0; i < _lmb->memory.cnt; i++) { unsigned long lmb_size; - if ( lmb_type != LMB_MEMORY_AREA ) - continue; - lmb_size = _lmb->memory.region[i].size; #ifdef CONFIG_MSCHUNKS @@ -121,84 +115,20 @@ lmb_analyze(void) size_mask |= lmb_size; } -#ifdef CONFIG_MSCHUNKS - for (i=0; i < _lmb->memory.cnt ;i++) { - unsigned long lmb_type = _lmb->memory.region[i].type; - unsigned long lmb_size; - - if ( lmb_type != LMB_IO_AREA ) - continue; - - lmb_size = _lmb->memory.region[i].size; - - _lmb->memory.region[i].physbase = physbase; - physbase += lmb_size; - io_size += lmb_size; - size_mask |= lmb_size; - } -#endif /* CONFIG_MSCHUNKS */ - _lmb->memory.size = mem_size; - _lmb->memory.iosize = io_size; - _lmb->memory.lcd_size = (1UL << cnt_trailing_zeros(size_mask)); } /* This routine called with relocation disabled. */ -long -lmb_add(unsigned long base, unsigned long size) -{ - unsigned long offset = reloc_offset(); - struct lmb *_lmb = PTRRELOC(&lmb); - struct lmb_region *_rgn = &(_lmb->memory); - - /* On pSeries LPAR systems, the first LMB is our RMO region. */ - if ( base == 0 ) - _lmb->rmo_size = size; - - return lmb_add_region(_rgn, base, size, LMB_MEMORY_AREA); - -} - -#ifdef CONFIG_MSCHUNKS -/* This routine called with relocation disabled. */ -long -lmb_add_io(unsigned long base, unsigned long size) -{ - unsigned long offset = reloc_offset(); - struct lmb *_lmb = PTRRELOC(&lmb); - struct lmb_region *_rgn = &(_lmb->memory); - - return lmb_add_region(_rgn, base, size, LMB_IO_AREA); - -} -#endif /* CONFIG_MSCHUNKS */ - -long -lmb_reserve(unsigned long base, unsigned long size) -{ - unsigned long offset = reloc_offset(); - struct lmb *_lmb = PTRRELOC(&lmb); - struct lmb_region *_rgn = &(_lmb->reserved); - - return lmb_add_region(_rgn, base, size, LMB_MEMORY_AREA); -} - -/* This routine called with relocation disabled. */ -static long -lmb_add_region(struct lmb_region *rgn, unsigned long base, unsigned long size, - unsigned long type) +static long __init +lmb_add_region(struct lmb_region *rgn, unsigned long base, unsigned long size) { unsigned long i, coalesced = 0; long adjacent; /* First try and coalesce this LMB with another. */ - for (i=0; i < rgn->cnt ;i++) { + for (i=0; i < rgn->cnt; i++) { unsigned long rgnbase = rgn->region[i].base; unsigned long rgnsize = rgn->region[i].size; - unsigned long rgntype = rgn->region[i].type; - - if ( rgntype != type ) - continue; adjacent = lmb_addrs_adjacent(base,size,rgnbase,rgnsize); if ( adjacent > 0 ) { @@ -227,17 +157,15 @@ lmb_add_region(struct lmb_region *rgn, u } /* Couldn't coalesce the LMB, so add it to the sorted table. */ - for (i=rgn->cnt-1; i >= 0 ;i--) { + for (i=rgn->cnt-1; i >= 0; i--) { if (base < rgn->region[i].base) { rgn->region[i+1].base = rgn->region[i].base; rgn->region[i+1].physbase = rgn->region[i].physbase; rgn->region[i+1].size = rgn->region[i].size; - rgn->region[i+1].type = rgn->region[i].type; } else { rgn->region[i+1].base = base; rgn->region[i+1].physbase = lmb_abs_to_phys(base); rgn->region[i+1].size = size; - rgn->region[i+1].type = type; break; } } @@ -246,12 +174,38 @@ lmb_add_region(struct lmb_region *rgn, u return 0; } -long +/* This routine called with relocation disabled. */ +long __init +lmb_add(unsigned long base, unsigned long size) +{ + unsigned long offset = reloc_offset(); + struct lmb *_lmb = PTRRELOC(&lmb); + struct lmb_region *_rgn = &(_lmb->memory); + + /* On pSeries LPAR systems, the first LMB is our RMO region. */ + if ( base == 0 ) + _lmb->rmo_size = size; + + return lmb_add_region(_rgn, base, size); + +} + +long __init +lmb_reserve(unsigned long base, unsigned long size) +{ + unsigned long offset = reloc_offset(); + struct lmb *_lmb = PTRRELOC(&lmb); + struct lmb_region *_rgn = &(_lmb->reserved); + + return lmb_add_region(_rgn, base, size); +} + +long __init lmb_overlaps_region(struct lmb_region *rgn, unsigned long base, unsigned long size) { unsigned long i; - for (i=0; i < rgn->cnt ;i++) { + for (i=0; i < rgn->cnt; i++) { unsigned long rgnbase = rgn->region[i].base; unsigned long rgnsize = rgn->region[i].size; if ( lmb_addrs_overlap(base,size,rgnbase,rgnsize) ) { @@ -262,13 +216,13 @@ lmb_overlaps_region(struct lmb_region *r return (i < rgn->cnt) ? i : -1; } -unsigned long +unsigned long __init lmb_alloc(unsigned long size, unsigned long align) { return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE); } -unsigned long +unsigned long __init lmb_alloc_base(unsigned long size, unsigned long align, unsigned long max_addr) { long i, j; @@ -278,13 +232,9 @@ lmb_alloc_base(unsigned long size, unsig struct lmb_region *_mem = &(_lmb->memory); struct lmb_region *_rsv = &(_lmb->reserved); - for (i=_mem->cnt-1; i >= 0 ;i--) { + for (i=_mem->cnt-1; i >= 0; i--) { unsigned long lmbbase = _mem->region[i].base; unsigned long lmbsize = _mem->region[i].size; - unsigned long lmbtype = _mem->region[i].type; - - if ( lmbtype != LMB_MEMORY_AREA ) - continue; if ( max_addr == LMB_ALLOC_ANYWHERE ) base = _ALIGN_DOWN(lmbbase+lmbsize-size, align); @@ -305,12 +255,12 @@ lmb_alloc_base(unsigned long size, unsig if ( i < 0 ) return 0; - lmb_add_region(_rsv, base, size, LMB_MEMORY_AREA); + lmb_add_region(_rsv, base, size); return base; } -unsigned long +unsigned long __init lmb_phys_mem_size(void) { unsigned long offset = reloc_offset(); @@ -327,7 +277,7 @@ lmb_phys_mem_size(void) #endif /* CONFIG_MSCHUNKS */ } -unsigned long +unsigned long __init lmb_end_of_DRAM(void) { unsigned long offset = reloc_offset(); @@ -335,9 +285,7 @@ lmb_end_of_DRAM(void) struct lmb_region *_mem = &(_lmb->memory); unsigned long idx; - for(idx=_mem->cnt-1; idx >= 0 ;idx--) { - if ( _mem->region[idx].type != LMB_MEMORY_AREA ) - continue; + for(idx=_mem->cnt-1; idx >= 0; idx--) { #ifdef CONFIG_MSCHUNKS return (_mem->region[idx].physbase + _mem->region[idx].size); #else @@ -348,8 +296,7 @@ lmb_end_of_DRAM(void) return 0; } - -unsigned long +unsigned long __init lmb_abs_to_phys(unsigned long aa) { unsigned long i, pa = aa; @@ -357,7 +304,7 @@ lmb_abs_to_phys(unsigned long aa) struct lmb *_lmb = PTRRELOC(&lmb); struct lmb_region *_mem = &(_lmb->memory); - for (i=0; i < _mem->cnt ;i++) { + for (i=0; i < _mem->cnt; i++) { unsigned long lmbbase = _mem->region[i].base; unsigned long lmbsize = _mem->region[i].size; if ( lmb_addrs_overlap(aa,1,lmbbase,lmbsize) ) { @@ -368,47 +315,3 @@ lmb_abs_to_phys(unsigned long aa) return pa; } - -void -lmb_dump(char *str) -{ - unsigned long i; - - udbg_printf("\nlmb_dump: %s\n", str); - udbg_printf(" debug = %s\n", - (lmb.debug) ? "TRUE" : "FALSE"); - udbg_printf(" memory.cnt = %d\n", - lmb.memory.cnt); - udbg_printf(" memory.size = 0x%lx\n", - lmb.memory.size); - udbg_printf(" memory.lcd_size = 0x%lx\n", - lmb.memory.lcd_size); - for (i=0; i < lmb.memory.cnt ;i++) { - udbg_printf(" memory.region[%d].base = 0x%lx\n", - i, lmb.memory.region[i].base); - udbg_printf(" .physbase = 0x%lx\n", - lmb.memory.region[i].physbase); - udbg_printf(" .size = 0x%lx\n", - lmb.memory.region[i].size); - udbg_printf(" .type = 0x%lx\n", - lmb.memory.region[i].type); - } - - udbg_printf("\n"); - udbg_printf(" reserved.cnt = %d\n", - lmb.reserved.cnt); - udbg_printf(" reserved.size = 0x%lx\n", - lmb.reserved.size); - udbg_printf(" reserved.lcd_size = 0x%lx\n", - lmb.reserved.lcd_size); - for (i=0; i < lmb.reserved.cnt ;i++) { - udbg_printf(" reserved.region[%d].base = 0x%lx\n", - i, lmb.reserved.region[i].base); - udbg_printf(" .physbase = 0x%lx\n", - lmb.reserved.region[i].physbase); - udbg_printf(" .size = 0x%lx\n", - lmb.reserved.region[i].size); - udbg_printf(" .type = 0x%lx\n", - lmb.reserved.region[i].type); - } -} --- diff/arch/ppc64/kernel/lparcfg.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/lparcfg.c 2004-02-23 13:56:39.000000000 +0000 @@ -29,7 +29,7 @@ #include #include -#define MODULE_VERSION "1.0" +#define MODULE_VERS "1.0" #define MODULE_NAME "lparcfg" static struct proc_dir_entry *proc_ppc64_lparcfg; @@ -134,7 +134,7 @@ static int lparcfg_data(unsigned char *b memset(buf, 0, size); shared = (int)(lpaca->xLpPacaPtr->xSharedProc); - n += snprintf(buf, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf, LPARCFG_BUFF_SIZE - n, "serial_number=%c%c%c%c%c%c%c\n", e2a(xItExtVpdPanel.mfgID[2]), e2a(xItExtVpdPanel.mfgID[3]), @@ -144,7 +144,7 @@ static int lparcfg_data(unsigned char *b e2a(xItExtVpdPanel.systemSerial[4]), e2a(xItExtVpdPanel.systemSerial[5])); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "system_type=%c%c%c%c\n", e2a(xItExtVpdPanel.machineType[0]), e2a(xItExtVpdPanel.machineType[1]), @@ -152,23 +152,23 @@ static int lparcfg_data(unsigned char *b e2a(xItExtVpdPanel.machineType[3])); lp_index = HvLpConfig_getLpIndex(); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "partition_id=%d\n", (int)lp_index); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "system_active_processors=%d\n", (int)HvLpConfig_getSystemPhysicalProcessors()); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "system_potential_processors=%d\n", (int)HvLpConfig_getSystemPhysicalProcessors()); processors = (int)HvLpConfig_getPhysicalProcessors(); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "partition_active_processors=%d\n", processors); max_processors = (int)HvLpConfig_getMaxPhysicalProcessors(); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "partition_potential_processors=%d\n", max_processors); if(shared) { @@ -178,22 +178,22 @@ static int lparcfg_data(unsigned char *b entitled_capacity = processors * 100; max_entitled_capacity = max_processors * 100; } - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "partition_entitled_capacity=%d\n", entitled_capacity); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "partition_max_entitled_capacity=%d\n", max_entitled_capacity); if(shared) { pool_id = HvLpConfig_getSharedPoolIndex(); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, "pool=%d\n", + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "pool=%d\n", (int)pool_id); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "pool_capacity=%d\n", (int)(HvLpConfig_getNumProcsInSharedPool(pool_id)*100)); } - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "shared_processor_mode=%d\n", shared); return 0; @@ -297,13 +297,13 @@ static int lparcfg_data(unsigned char *b if(lp_index_ptr) lp_index = *lp_index_ptr; } - n = snprintf(buf, LPARCFG_BUFF_SIZE - n, + n = scnprintf(buf, LPARCFG_BUFF_SIZE - n, "serial_number=%s\n", system_id); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "system_type=%s\n", model); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "partition_id=%d\n", (int)lp_index); rtas_node = find_path_device("/rtas"); @@ -317,74 +317,74 @@ static int lparcfg_data(unsigned char *b if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) { h_get_ppp(&h_entitled,&h_unallocated,&h_aggregation,&h_resource); #ifdef DEBUG - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "R4=0x%lx\n", h_entitled); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "R5=0x%lx\n", h_unallocated); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "R6=0x%lx\n", h_aggregation); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "R7=0x%lx\n", h_resource); #endif /* DEBUG */ } if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) { system_potential_processors = get_splpar_potential_characteristics(); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "system_active_processors=%ld\n", (h_resource >> 2*8) & 0xffff); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "system_potential_processors=%d\n", system_potential_processors); } else { system_potential_processors = system_active_processors; - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "system_active_processors=%d\n", system_active_processors); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "system_potential_processors=%d\n", system_potential_processors); } processors = systemcfg->processorCount; - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "partition_active_processors=%d\n", processors); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "partition_potential_processors=%d\n", system_active_processors); /* max_entitled_capacity will come out of get_splpar_potential_characteristics() when that function is complete */ max_entitled_capacity = system_active_processors * 100; if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) { - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "partition_entitled_capacity=%ld\n", h_entitled); } else { - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "partition_entitled_capacity=%d\n", system_active_processors*100); } - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "partition_max_entitled_capacity=%d\n", max_entitled_capacity); shared = 0; - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "shared_processor_mode=%d\n", shared); if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) { - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "pool=%ld\n", (h_aggregation >> 0*8)&0xffff); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "pool_capacity=%ld\n", (h_resource >> 3*8) &0xffff); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "group=%ld\n", (h_aggregation >> 2*8)&0xffff); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "capped=%ld\n", (h_resource >> 6*8)&0x40); - n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, + n += scnprintf(buf+n, LPARCFG_BUFF_SIZE - n, "capacity_weight=%d\n", (int)(h_resource>>5*8)&0xFF); } return 0; --- diff/arch/ppc64/kernel/misc.S 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/misc.S 2004-02-23 13:56:39.000000000 +0000 @@ -383,10 +383,6 @@ _GLOBAL(abs) neg r3,r3 10: blr -_GLOBAL(_get_SP) - mr r3,r1 /* Close enough */ - blr - _GLOBAL(_get_PVR) mfspr r3,PVR blr --- diff/arch/ppc64/kernel/pSeries_nvram.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/pSeries_nvram.c 2004-02-23 13:56:39.000000000 +0000 @@ -41,7 +41,8 @@ static ssize_t pSeries_nvram_read(char * unsigned long flags; char *p = buf; - if (nvram_size == 0 || nvram_fetch) + + if (nvram_size == 0 || nvram_fetch == RTAS_UNKNOWN_SERVICE) return -ENODEV; if (*index >= nvram_size) @@ -83,7 +84,7 @@ static ssize_t pSeries_nvram_write(char unsigned long flags; const char *p = buf; - if (nvram_size == 0 || nvram_store) + if (nvram_size == 0 || nvram_store == RTAS_UNKNOWN_SERVICE) return -ENODEV; if (*index >= nvram_size) --- diff/arch/ppc64/kernel/pmac_setup.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/pmac_setup.c 2004-02-23 13:56:39.000000000 +0000 @@ -73,7 +73,6 @@ #include "pmac.h" -extern char saved_command_line[]; static int current_root_goodness = -1; #define DEFAULT_ROOT_DEVICE Root_SDA1 /* sda1 - slightly silly choice */ --- diff/arch/ppc64/kernel/ppc_ksyms.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/ppc_ksyms.c 2004-02-23 13:56:39.000000000 +0000 @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -48,7 +49,6 @@ #include #endif -extern int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg); extern int do_signal(sigset_t *, struct pt_regs *); int abs(int); --- diff/arch/ppc64/kernel/process.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/process.c 2004-02-23 13:56:39.000000000 +0000 @@ -162,7 +162,7 @@ struct task_struct *__switch_to(struct t * for that first. */ if ((cur_cpu_spec->cpu_features & CPU_FTR_SLB) && - GET_ESID((unsigned long)_get_SP()) != GET_ESID(PAGE_OFFSET)) { + GET_ESID(__get_SP()) != GET_ESID(PAGE_OFFSET)) { union { unsigned long word0; slb_dword0 data; @@ -171,7 +171,7 @@ struct task_struct *__switch_to(struct t esid_data.word0 = 0; /* class bit is in valid field for slbie instruction */ esid_data.data.v = 1; - esid_data.data.esid = GET_ESID((unsigned long)_get_SP()); + esid_data.data.esid = GET_ESID(__get_SP()); asm volatile("isync; slbie %0; isync" : : "r" (esid_data)); } local_irq_restore(flags); @@ -202,13 +202,11 @@ void show_regs(struct pt_regs * regs) #endif /* CONFIG_SMP */ for (i = 0; i < 32; i++) { - long r; if ((i % 4) == 0) { printk("\n" KERN_INFO "GPR%02d: ", i); } - if (__get_user(r, &(regs->gpr[i]))) - return; - printk("%016lX ", r); + + printk("%016lX ", regs->gpr[i]); } printk("\n"); /* @@ -473,6 +471,20 @@ out: return error; } +static int kstack_depth_to_print = 64; + +static inline int validate_sp(unsigned long sp, struct task_struct *p) +{ + unsigned long stack_page = (unsigned long)p->thread_info; + + if (sp < stack_page + sizeof(struct thread_struct)) + return 0; + if (sp >= stack_page + THREAD_SIZE) + return 0; + + return 1; +} + /* * These bracket the sleeping functions.. */ @@ -484,24 +496,23 @@ extern void scheduling_functions_end_her unsigned long get_wchan(struct task_struct *p) { unsigned long ip, sp; - unsigned long stack_page = (unsigned long)p->thread_info; int count = 0; + if (!p || p == current || p->state == TASK_RUNNING) return 0; + sp = p->thread.ksp; + if (!validate_sp(sp, p)) + return 0; + do { sp = *(unsigned long *)sp; - if (sp < (stack_page + sizeof(struct thread_struct)) || - sp >= (stack_page + THREAD_SIZE)) + if (!validate_sp(sp, p)) return 0; if (count > 0) { ip = *(unsigned long *)(sp + 16); - /* - * XXX we mask the upper 32 bits until procps - * gets fixed. - */ if (ip < first_sched || ip >= last_sched) - return (ip & 0xFFFFFFFF); + return ip; } } while (count++ < 16); return 0; @@ -510,33 +521,35 @@ unsigned long get_wchan(struct task_stru void show_stack(struct task_struct *p, unsigned long *_sp) { unsigned long ip; - unsigned long stack_page = (unsigned long)p->thread_info; int count = 0; unsigned long sp = (unsigned long)_sp; - if (!p) + if (sp == 0) { + if (p) { + sp = p->thread.ksp; + } else { + sp = __get_SP(); + p = current; + } + } + + if (!validate_sp(sp, p)) return; - if (sp == 0) - sp = p->thread.ksp; printk("Call Trace:\n"); do { - if (__get_user(sp, (unsigned long *)sp)) - break; - if (sp < stack_page + sizeof(struct thread_struct)) - break; - if (sp >= stack_page + THREAD_SIZE) - break; - if (__get_user(ip, (unsigned long *)(sp + 16))) - break; + sp = *(unsigned long *)sp; + if (!validate_sp(sp, p)) + return; + ip = *(unsigned long *)(sp + 16); printk("[%016lx] ", ip); print_symbol("%s\n", ip); - } while (count++ < 32); + } while (count++ < kstack_depth_to_print); } void dump_stack(void) { - show_stack(current, (unsigned long *)_get_SP()); + show_stack(current, (unsigned long *)__get_SP()); } EXPORT_SYMBOL(dump_stack); --- diff/arch/ppc64/kernel/prom.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/prom.c 2004-02-23 13:56:39.000000000 +0000 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,7 @@ #include #include #include +#include #include "open_pic.h" #ifdef CONFIG_LOGO_LINUX_CLUT224 @@ -184,14 +186,14 @@ extern void enter_prom(void *dummy,...); extern void copy_and_flush(unsigned long dest, unsigned long src, unsigned long size, unsigned long offset); -extern char cmd_line[512]; /* XXX */ unsigned long dev_tree_size; +unsigned long _get_PIR(void); #ifdef CONFIG_HMT struct { unsigned int pir; unsigned int threadid; -} hmt_thread_data[NR_CPUS] = {0}; +} hmt_thread_data[NR_CPUS]; #endif /* CONFIG_HMT */ char testString[] = "LINUX\n"; @@ -698,9 +700,6 @@ prom_dump_lmb(void) prom_print(RELOC(" memory.size = 0x")); prom_print_hex(_lmb->memory.size); prom_print_nl(); - prom_print(RELOC(" memory.lcd_size = 0x")); - prom_print_hex(_lmb->memory.lcd_size); - prom_print_nl(); for (i=0; i < _lmb->memory.cnt ;i++) { prom_print(RELOC(" memory.region[0x")); prom_print_hex(i); @@ -713,9 +712,6 @@ prom_dump_lmb(void) prom_print(RELOC(" .size = 0x")); prom_print_hex(_lmb->memory.region[i].size); prom_print_nl(); - prom_print(RELOC(" .type = 0x")); - prom_print_hex(_lmb->memory.region[i].type); - prom_print_nl(); } prom_print_nl(); @@ -725,9 +721,6 @@ prom_dump_lmb(void) prom_print(RELOC(" reserved.size = 0x")); prom_print_hex(_lmb->reserved.size); prom_print_nl(); - prom_print(RELOC(" reserved.lcd_size = 0x")); - prom_print_hex(_lmb->reserved.lcd_size); - prom_print_nl(); for (i=0; i < _lmb->reserved.cnt ;i++) { prom_print(RELOC(" reserved.region[0x")); prom_print_hex(i); @@ -740,9 +733,6 @@ prom_dump_lmb(void) prom_print(RELOC(" .size = 0x")); prom_print_hex(_lmb->reserved.region[i].size); prom_print_nl(); - prom_print(RELOC(" .type = 0x")); - prom_print_hex(_lmb->reserved.region[i].type); - prom_print_nl(); } } #endif /* DEBUG_PROM */ @@ -1084,6 +1074,10 @@ prom_hold_cpus(unsigned long mem) if (*acknowledge == cpuid) { prom_print(RELOC("ok\n")); + /* We have to get every CPU out of OF, + * even if we never start it. */ + if (cpuid >= NR_CPUS) + goto next; #ifdef CONFIG_SMP /* Set the number of active processors. */ _systemcfg->processorCount++; @@ -1110,9 +1104,12 @@ prom_hold_cpus(unsigned long mem) cpu_set(cpuid, RELOC(cpu_present_at_boot)); } + next: /* Init paca for secondary threads. They start later. */ for (i=1; i < cpu_threads; i++) { cpuid++; + if (cpuid >= NR_CPUS) + continue; _xPaca[cpuid].xHwProcNum = interrupt_server[i]; prom_print_hex(interrupt_server[i]); prom_print(RELOC(" : preparing thread ... ")); @@ -1157,7 +1154,11 @@ prom_hold_cpus(unsigned long mem) prom_print(RELOC("Processor is not HMT capable\n")); } #endif - + + if (cpuid >= NR_CPUS) + prom_print(RELOC("WARNING: maximum CPUs (" __stringify(NR_CPUS) + ") exceeded: ignoring extras\n")); + #ifdef DEBUG_PROM prom_print(RELOC("prom_hold_cpus: end...\n")); #endif @@ -1202,9 +1203,9 @@ smt_setup(void) sizeof(option)); if (option[0] != 0) { found = 1; - if (!strcmp(option, "off")) + if (!strcmp(option, RELOC("off"))) my_smt_enabled = SMT_OFF; - else if (!strcmp(option, "on")) + else if (!strcmp(option, RELOC("on"))) my_smt_enabled = SMT_ON; else my_smt_enabled = SMT_DYNAMIC; @@ -1508,10 +1509,8 @@ prom_init(unsigned long r3, unsigned lon call_prom(RELOC("getprop"), 4, 1, _prom->chosen, RELOC("bootargs"), p, sizeof(cmd_line)); if (p != NULL && p[0] != 0) - strncpy(RELOC(cmd_line), p, sizeof(cmd_line)); + strlcpy(RELOC(cmd_line), p, sizeof(cmd_line)); } - RELOC(cmd_line[sizeof(cmd_line) - 1]) = 0; - mem = prom_initialize_lmb(mem); @@ -2987,8 +2986,10 @@ static int of_finish_dynamic_node(struct /* now do the work of finish_node_interrupts */ ints = (unsigned int *) get_property(node, "interrupts", &intlen); - if (!ints) + if (!ints) { + err = -ENODEV; goto out; + } intrcells = prom_n_intr_cells(node); intlen /= intrcells * sizeof(unsigned int); --- diff/arch/ppc64/kernel/rtas-proc.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/rtas-proc.c 2004-02-23 13:56:39.000000000 +0000 @@ -287,9 +287,9 @@ static ssize_t ppc_rtas_poweron_read(str char stkbuf[40]; /* its small, its on stack */ int n, sn; if (power_on_time == 0) - n = snprintf(stkbuf, 40, "Power on time not set\n"); + n = scnprintf(stkbuf,sizeof(stkbuf),"Power on time not set\n"); else - n = snprintf(stkbuf, 40, "%lu\n", power_on_time); + n = scnprintf(stkbuf,sizeof(stkbuf),"%lu\n",power_on_time); sn = strlen (stkbuf) +1; if (*ppos >= sn) @@ -410,9 +410,10 @@ static ssize_t ppc_rtas_clock_read(struc if (error != 0){ printk(KERN_WARNING "error: reading the clock returned: %s\n", ppc_rtas_process_error(error)); - n = snprintf (stkbuf, 40, "0"); + n = scnprintf (stkbuf, sizeof(stkbuf), "0"); } else { - n = snprintf (stkbuf, 40, "%lu\n", mktime(year, mon, day, hour, min, sec)); + n = scnprintf (stkbuf, sizeof(stkbuf), "%lu\n", + mktime(year, mon, day, hour, min, sec)); } kfree(ret); @@ -819,7 +820,7 @@ int get_location_code(struct individual_ n += check_location_string(ret, buffer + n); n += sprintf ( buffer+n, " "); /* see how many characters we have printed */ - snprintf ( t, 50, "%s ", ret); + scnprintf(t, sizeof(t), "%s ", ret); pos += strlen(t); if (pos >= llen) pos=0; @@ -863,7 +864,7 @@ static ssize_t ppc_rtas_tone_freq_read(s int n, sn; char stkbuf[40]; /* its small, its on stack */ - n = snprintf(stkbuf, 40, "%lu\n", rtas_tone_frequency); + n = scnprintf(stkbuf, 40, "%lu\n", rtas_tone_frequency); sn = strlen (stkbuf) +1; if (*ppos >= sn) @@ -917,7 +918,7 @@ static ssize_t ppc_rtas_tone_volume_read int n, sn; char stkbuf[40]; /* its small, its on stack */ - n = snprintf(stkbuf, 40, "%lu\n", rtas_tone_volume); + n = scnprintf(stkbuf, 40, "%lu\n", rtas_tone_volume); sn = strlen (stkbuf) +1; if (*ppos >= sn) --- diff/arch/ppc64/kernel/rtas.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/ppc64/kernel/rtas.c 2004-02-23 13:56:39.000000000 +0000 @@ -59,6 +59,8 @@ struct rtas_t rtas = { .lock = SPIN_LOCK_UNLOCKED }; +char rtas_err_buf[RTAS_ERROR_LOG_MAX]; + extern unsigned long reloc_offset(void); spinlock_t rtas_data_buf_lock = SPIN_LOCK_UNLOCKED; @@ -126,6 +128,34 @@ rtas_token(const char *service) return tokp ? *tokp : RTAS_UNKNOWN_SERVICE; } +void +log_rtas_error(struct rtas_args *rtas_args) +{ + struct rtas_args err_args; + + err_args.token = rtas_token("rtas-last-error"); + err_args.nargs = 2; + err_args.nret = 1; + err_args.rets = (rtas_arg_t *)&(err_args.args[2]); + + err_args.args[0] = (rtas_arg_t)__pa(rtas_err_buf); + err_args.args[1] = RTAS_ERROR_LOG_MAX; + err_args.args[2] = 0; + + get_paca()->xRtas = err_args; + + PPCDBG(PPCDBG_RTAS, "\tentering rtas with 0x%lx\n", + (void *)__pa((unsigned long)&err_args)); + enter_rtas((void *)__pa((unsigned long)&get_paca()->xRtas)); + PPCDBG(PPCDBG_RTAS, "\treturned from rtas ...\n"); + + err_args = get_paca()->xRtas; + get_paca()->xRtas = *rtas_args; + + if (err_args.rets[0] == 0) + log_error(rtas_err_buf, ERR_TYPE_RTAS_LOG, 0); +} + long rtas_call(int token, int nargs, int nret, unsigned long *outputs, ...) @@ -166,6 +196,10 @@ rtas_call(int token, int nargs, int nret (void *)__pa((unsigned long)rtas_args)); enter_rtas((void *)__pa((unsigned long)rtas_args)); PPCDBG(PPCDBG_RTAS, "\treturned from rtas ...\n"); + + if (rtas_args->rets[0] == -1) + log_rtas_error(rtas_args); + #if 0 /* Gotta do something different here, use global lock for now... */ spin_unlock_irqrestore(&rtas_args->lock, s); #else @@ -410,9 +444,14 @@ asmlinkage int ppc_rtas(struct rtas_args return -EFAULT; spin_lock_irqsave(&rtas.lock, flags); + get_paca()->xRtas = args; enter_rtas((void *)__pa((unsigned long)&get_paca()->xRtas)); args = get_paca()->xRtas; + + if (args.rets[0] == -1) + log_rtas_error(&args); + spin_unlock_irqrestore(&rtas.lock, flags); /* Copy out args. */ --- diff/arch/ppc64/kernel/rtas_flash.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/ppc64/kernel/rtas_flash.c 2004-02-23 13:56:39.000000000 +0000 @@ -20,7 +20,7 @@ #include #include -#define MODULE_VERSION "1.0" +#define MODULE_VERS "1.0" #define MODULE_NAME "rtas_flash" #define FIRMWARE_FLASH_NAME "firmware_flash" --- diff/arch/ppc64/kernel/rtasd.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/rtasd.c 2004-02-23 13:56:39.000000000 +0000 @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -336,15 +337,31 @@ static int get_eventscan_parms(void) return 0; } -extern long sys_sched_get_priority_max(int policy); +static void do_event_scan(int event_scan) +{ + int error; + do { + memset(logdata, 0, rtas_error_log_max); + error = rtas_call(event_scan, 4, 1, NULL, + RTAS_EVENT_SCAN_ALL_EVENTS, 0, + __pa(logdata), rtas_error_log_max); + if (error == -1) { + printk(KERN_ERR "event-scan failed\n"); + break; + } + + if (error == 0) + pSeries_log_error(logdata, ERR_TYPE_RTAS_LOG, 0); + + } while(error == 0); +} static int rtasd(void *unused) { unsigned int err_type; int cpu = 0; - int error; - int first_pass = 1; int event_scan = rtas_token("event-scan"); + cpumask_t all = CPU_MASK_ALL; int rc; daemonize("rtasd"); @@ -375,48 +392,45 @@ static int rtasd(void *unused) } } -repeat: - for (cpu = 0; cpu < NR_CPUS; cpu++) { - if (!cpu_online(cpu)) - continue; - + /* First pass. */ + lock_cpu_hotplug(); + for_each_online_cpu(cpu) { DEBUG("scheduling on %d\n", cpu); set_cpus_allowed(current, cpumask_of_cpu(cpu)); DEBUG("watchdog scheduled on cpu %d\n", smp_processor_id()); - do { - memset(logdata, 0, rtas_error_log_max); - error = rtas_call(event_scan, 4, 1, NULL, - RTAS_EVENT_SCAN_ALL_EVENTS, 0, - __pa(logdata), rtas_error_log_max); - if (error == -1) { - printk(KERN_ERR "event-scan failed\n"); - break; - } - - if (error == 0) - pSeries_log_error(logdata, ERR_TYPE_RTAS_LOG, 0); - - } while(error == 0); - - /* - * Check all cpus for pending events quickly, sleeping for - * at least one second since some machines have problems - * if we call event-scan too quickly - */ + do_event_scan(event_scan); set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(first_pass ? HZ : (HZ*60/rtas_event_scan_rate) / 2); + schedule_timeout(HZ); } + unlock_cpu_hotplug(); - if (first_pass && (surveillance_timeout != -1)) { + if (surveillance_timeout != -1) { DEBUG("enabling surveillance\n"); if (enable_surveillance(surveillance_timeout)) goto error_vfree; DEBUG("surveillance enabled\n"); } - first_pass = 0; - goto repeat; + lock_cpu_hotplug(); + cpu = first_cpu_const(mk_cpumask_const(cpu_online_map)); + for (;;) { + set_cpus_allowed(current, cpumask_of_cpu(cpu)); + do_event_scan(event_scan); + set_cpus_allowed(current, all); + + /* Drop hotplug lock, and sleep for a bit (at least + * one second since some machines have problems if we + * call event-scan too quickly). */ + unlock_cpu_hotplug(); + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout((HZ*60/rtas_event_scan_rate) / 2); + lock_cpu_hotplug(); + + cpu = next_cpu_const(cpu, mk_cpumask_const(cpu_online_map)); + if (cpu == NR_CPUS) + cpu = first_cpu_const(mk_cpumask_const(cpu_online_map)); + } error_vfree: if (rtas_log_buf) --- diff/arch/ppc64/kernel/scanlog.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/ppc64/kernel/scanlog.c 2004-02-23 13:56:39.000000000 +0000 @@ -30,7 +30,7 @@ #include #include -#define MODULE_VERSION "1.0" +#define MODULE_VERS "1.0" #define MODULE_NAME "scanlog" /* Status returns from ibm,scan-log-dump */ --- diff/arch/ppc64/kernel/setup.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/setup.c 2004-02-23 13:56:39.000000000 +0000 @@ -80,7 +80,7 @@ unsigned long decr_overclock_proc0_set = int powersave_nap; -char saved_command_line[256]; +char saved_command_line[COMMAND_LINE_SIZE]; unsigned char aux_device_present; void parse_cmd_line(unsigned long r3, unsigned long r4, unsigned long r5, @@ -155,7 +155,7 @@ void __init disable_early_printk(void) void setup_system(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7) { -#ifdef CONFIG_PPC_PSERIES +#if defined(CONFIG_SMP) && defined(CONFIG_PPC_PSERIES) unsigned int ret, i; #endif @@ -232,8 +232,8 @@ void setup_system(unsigned long r3, unsi systemcfg->processorCount++; } } - } #endif /* CONFIG_SMP */ + } #endif /* CONFIG_PPC_PSERIES */ #ifdef CONFIG_PPC_PMAC @@ -477,7 +477,7 @@ static int __init set_preferred_console( char *name; /* The user has requested a console so this is already set up. */ - if (strstr(cmd_line, "console=")) + if (strstr(saved_command_line, "console=")) return -EBUSY; prom_stdout = find_path_device(of_stdout_device); @@ -536,7 +536,7 @@ int parse_bootinfo(void) for ( ; rec->tag != BI_LAST ; rec = bi_rec_next(rec) ) { switch (rec->tag) { case BI_CMD_LINE: - memcpy(cmd_line, (void *)rec->data, rec->size); + strlcpy(cmd_line, (void *)rec->data, sizeof(cmd_line)); break; case BI_SYSMAP: sysmap = __va(rec->data[0]); @@ -620,7 +620,7 @@ void __init setup_arch(char **cmdline_p) init_mm.brk = klimit; /* Save unparsed command line copy for /proc/cmdline */ - strcpy(saved_command_line, cmd_line); + strlcpy(saved_command_line, cmd_line, sizeof(saved_command_line)); *cmdline_p = cmd_line; /* set up the bootmem stuff with available memory */ --- diff/arch/ppc64/kernel/signal32.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/ppc64/kernel/signal32.c 2004-02-23 13:56:39.000000000 +0000 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include --- diff/arch/ppc64/kernel/smp.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/smp.c 2004-02-23 13:56:39.000000000 +0000 @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include @@ -54,10 +56,9 @@ int smp_threads_ready; unsigned long cache_decay_ticks; -/* Initialised so it doesn't end up in bss */ -cpumask_t cpu_possible_map = CPU_MASK_NONE; +cpumask_t cpu_possible_map = CPU_MASK_NONE; cpumask_t cpu_online_map = CPU_MASK_NONE; -cpumask_t cpu_available_map = CPU_MASK_NONE; +cpumask_t cpu_available_map = CPU_MASK_NONE; cpumask_t cpu_present_at_boot = CPU_MASK_NONE; EXPORT_SYMBOL(cpu_online_map); @@ -71,14 +72,12 @@ extern unsigned char stab_array[]; extern int cpu_idle(void *unused); void smp_call_function_interrupt(void); -void smp_message_pass(int target, int msg, unsigned long data, int wait); extern long register_vpa(unsigned long flags, unsigned long proc, unsigned long vpa); -#define smp_message_pass(t,m,d,w) smp_ops->message_pass((t),(m),(d),(w)) - /* Low level assembly function used to backup CPU 0 state */ extern void __save_cpu_setup(void); + #ifdef CONFIG_PPC_ISERIES static unsigned long iSeries_smp_message[NR_CPUS]; @@ -95,20 +94,24 @@ void iSeries_smp_message_recv( struct pt smp_message_recv( msg, regs ); } -static void smp_iSeries_message_pass(int target, int msg, unsigned long data, int wait) +static inline void smp_iSeries_do_message(int cpu, int msg) +{ + set_bit(msg, &iSeries_smp_message[cpu]); + HvCall_sendIPI(&(paca[cpu])); +} + +static void smp_iSeries_message_pass(int target, int msg) { int i; - for (i = 0; i < NR_CPUS; ++i) { - if (!cpu_online(i)) - continue; - - if ((target == MSG_ALL) || - (target == i) || - ((target == MSG_ALL_BUT_SELF) && - (i != smp_processor_id())) ) { - set_bit(msg, &iSeries_smp_message[i]); - HvCall_sendIPI(&(paca[i])); + if (target < NR_CPUS) + smp_iSeries_do_message(target, msg); + else { + for_each_online_cpu(i) { + if (target == MSG_ALL_BUT_SELF + && i == smp_processor_id()) + continue; + smp_iSeries_do_message(i, msg); } } } @@ -150,22 +153,15 @@ static int smp_iSeries_probe(void) static void smp_iSeries_kick_cpu(int nr) { - struct ItLpPaca * lpPaca; - /* Verify we have a Paca for processor nr */ - if ( ( nr <= 0 ) || - ( nr >= NR_CPUS ) ) - return; + struct ItLpPaca *lpPaca; + + BUG_ON(nr < 0 || nr >= NR_CPUS); + /* Verify that our partition has a processor nr */ lpPaca = paca[nr].xLpPacaPtr; - if ( lpPaca->xDynProcStatus >= 2 ) + if (lpPaca->xDynProcStatus >= 2) return; - /* The information for processor bringup must - * be written out to main store before we release - * the processor. - */ - mb(); - /* The processor is currently spinning, waiting * for the xProcStart field to become non-zero * After we set xProcStart, the processor will @@ -194,7 +190,7 @@ void __init smp_init_iSeries(void) #endif #ifdef CONFIG_PPC_PSERIES -void smp_openpic_message_pass(int target, int msg, unsigned long data, int wait) +void smp_openpic_message_pass(int target, int msg) { /* make sure we're sending something that translates to an IPI */ if ( msg > 0x3 ){ @@ -219,13 +215,9 @@ void smp_openpic_message_pass(int target static int __init smp_openpic_probe(void) { - int i; - int nr_cpus = 0; + int nr_cpus; - for (i = 0; i < NR_CPUS; i++) { - if (cpu_possible(i)) - nr_cpus++; - } + nr_cpus = cpus_weight(cpu_possible_map); if (nr_cpus > 1) openpic_request_IPIs(); @@ -240,16 +232,7 @@ static void __devinit smp_openpic_setup_ static void smp_pSeries_kick_cpu(int nr) { - /* Verify we have a Paca for processor nr */ - if ( ( nr <= 0 ) || - ( nr >= NR_CPUS ) ) - return; - - /* The information for processor bringup must - * be written out to main store before we release - * the processor. - */ - mb(); + BUG_ON(nr < 0 || nr >= NR_CPUS); /* The processor is currently spinning, waiting * for the xProcStart field to become non-zero @@ -266,8 +249,8 @@ static void __init smp_space_timers(unsi unsigned long offset = tb_ticks_per_jiffy / max_cpus; unsigned long previous_tb = paca[boot_cpuid].next_jiffy_update_tb; - for (i = 0; i < NR_CPUS; i++) { - if (cpu_possible(i) && i != boot_cpuid) { + for_each_cpu(i) { + if (i != boot_cpuid) { paca[i].next_jiffy_update_tb = previous_tb + offset; previous_tb = paca[i].next_jiffy_update_tb; @@ -287,20 +270,25 @@ void vpa_init(int cpu) register_vpa(flags, cpu, __pa((unsigned long)&(paca[cpu].xLpPaca))); } -static void smp_xics_message_pass(int target, int msg, unsigned long data, int wait) +static inline void smp_xics_do_message(int cpu, int msg) { - int i; + set_bit(msg, &xics_ipi_message[cpu].value); + mb(); + xics_cause_IPI(cpu); +} + +static void smp_xics_message_pass(int target, int msg) +{ + unsigned int i; - for (i = 0; i < NR_CPUS; ++i) { - if (!cpu_online(i)) - continue; - - if (target == MSG_ALL || target == i - || (target == MSG_ALL_BUT_SELF - && i != smp_processor_id())) { - set_bit(msg, &xics_ipi_message[i].value); - mb(); - xics_cause_IPI(i); + if (target < NR_CPUS) { + smp_xics_do_message(target, msg); + } else { + for_each_online_cpu(i) { + if (target == MSG_ALL_BUT_SELF + && i == smp_processor_id()) + continue; + smp_xics_do_message(i, msg); } } } @@ -309,18 +297,11 @@ extern void xics_request_IPIs(void); static int __init smp_xics_probe(void) { - int i; - int nr_cpus = 0; - - for (i = 0; i < NR_CPUS; i++) { - if (cpu_possible(i)) - nr_cpus++; - } #ifdef CONFIG_SMP xics_request_IPIs(); #endif - return nr_cpus; + return cpus_weight(cpu_possible_map); } static void __devinit smp_xics_setup_cpu(int cpu) @@ -422,13 +403,13 @@ void smp_message_recv(int msg, struct pt void smp_send_reschedule(int cpu) { - smp_message_pass(cpu, PPC_MSG_RESCHEDULE, 0, 0); + smp_ops->message_pass(cpu, PPC_MSG_RESCHEDULE); } #ifdef CONFIG_DEBUGGER void smp_send_debugger_break(int cpu) { - smp_message_pass(cpu, PPC_MSG_DEBUGGER_BREAK, 0, 0); + smp_ops->message_pass(cpu, PPC_MSG_DEBUGGER_BREAK); } #endif @@ -498,7 +479,7 @@ int smp_call_function (void (*func) (voi call_data = &data; wmb(); /* 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); + smp_ops->message_pass(MSG_ALL_BUT_SELF, PPC_MSG_CALL_FUNCTION); /* Wait for response */ timeout = SMP_CALL_TIMEOUT; @@ -554,6 +535,9 @@ void smp_call_function_interrupt(void) info = call_data->info; wait = call_data->wait; + if (!wait) + smp_mb__before_atomic_inc(); + /* * Notify initiating CPU that I've grabbed the data and am * about to execute the function @@ -563,8 +547,10 @@ void smp_call_function_interrupt(void) * At this point the info structure may be out of scope unless wait==1 */ (*func)(info); - if (wait) + if (wait) { + smp_mb__before_atomic_inc(); atomic_inc(&call_data->finished); + } } extern unsigned long decr_overclock; @@ -660,6 +646,12 @@ int __devinit __cpu_up(unsigned int cpu) paca[cpu].xCurrent = (u64)p; current_set[cpu] = p->thread_info; + /* The information for processor bringup must + * be written out to main store before we release + * the processor. + */ + mb(); + /* wake up cpus */ smp_ops->kick_cpu(cpu); @@ -736,3 +728,71 @@ void __init smp_cpus_done(unsigned int m set_cpus_allowed(current, old_mask); } + +#ifdef CONFIG_NUMA +static struct node node_devices[MAX_NUMNODES]; + +static void register_nodes(void) +{ + int i; + int ret; + + for (i = 0; i < MAX_NUMNODES; i++) { + if (node_online(i)) { + int p_node = parent_node(i); + struct node *parent = NULL; + + if (p_node != i) + parent = &node_devices[p_node]; + + ret = register_node(&node_devices[i], i, parent); + if (ret) + printk(KERN_WARNING "register_nodes: " + "register_node %d failed (%d)", i, ret); + } + } +} +#else +static void register_nodes(void) +{ + return 0; +} +#endif + +/* Only valid if CPU is online. */ +static ssize_t show_physical_id(struct sys_device *dev, char *buf) +{ + struct cpu *cpu = container_of(dev, struct cpu, sysdev); + + return sprintf(buf, "%u\n", get_hard_smp_processor_id(cpu->sysdev.id)); +} +static SYSDEV_ATTR(physical_id, 0444, show_physical_id, NULL); + +static DEFINE_PER_CPU(struct cpu, cpu_devices); + +static int __init topology_init(void) +{ + int cpu; + struct node *parent = NULL; + int ret; + + register_nodes(); + + for_each_cpu(cpu) { +#ifdef CONFIG_NUMA + parent = &node_devices[cpu_to_node(cpu)]; +#endif + ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu, parent); + if (ret) + printk(KERN_WARNING "topology_init: register_cpu %d " + "failed (%d)\n", cpu, ret); + + ret = sysdev_create_file(&per_cpu(cpu_devices, cpu).sysdev, + &attr_physical_id); + if (ret) + printk(KERN_WARNING "toplogy_init: sysdev_create_file " + "%d failed (%d)\n", cpu, ret); + } + return 0; +} +__initcall(topology_init); --- diff/arch/ppc64/kernel/stab.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/stab.c 2004-02-23 13:56:39.000000000 +0000 @@ -18,12 +18,11 @@ #include #include #include -#include #include -int make_ste(unsigned long stab, unsigned long esid, unsigned long vsid); -void make_slbe(unsigned long esid, unsigned long vsid, int large, - int kernel_segment); +static int make_ste(unsigned long stab, unsigned long esid, unsigned long vsid); +static void make_slbe(unsigned long esid, unsigned long vsid, int large, + int kernel_segment); /* * Build an entry for the base kernel segment and put it into @@ -69,7 +68,7 @@ DEFINE_PER_CPU(long, stab_cache[NR_STAB_ /* * Create a segment table entry for the given esid/vsid pair. */ -int make_ste(unsigned long stab, unsigned long esid, unsigned long vsid) +static int make_ste(unsigned long stab, unsigned long esid, unsigned long vsid) { unsigned long entry, group, old_esid, castout_entry, i; unsigned int global_entry; @@ -88,7 +87,7 @@ int make_ste(unsigned long stab, unsigne ste->dw0.dw0.kp = 1; asm volatile("eieio":::"memory"); ste->dw0.dw0.v = 1; - return(global_entry | entry); + return (global_entry | entry); } } /* Now search the secondary group. */ @@ -144,7 +143,7 @@ int make_ste(unsigned long stab, unsigne static inline void __ste_allocate(unsigned long esid, unsigned long vsid) { unsigned char stab_entry; - unsigned long *offset; + unsigned long offset; int region_id = REGION_ID(esid << SID_SHIFT); stab_entry = make_ste(get_paca()->xStab_data.virt, esid, vsid); @@ -152,11 +151,12 @@ static inline void __ste_allocate(unsign if (region_id != USER_REGION_ID) return; - offset = &__get_cpu_var(stab_cache_ptr); - if (*offset < NR_STAB_CACHE_ENTRIES) { - __get_cpu_var(stab_cache[*offset]) = stab_entry; - } - (*offset)++; + offset = __get_cpu_var(stab_cache_ptr); + if (offset < NR_STAB_CACHE_ENTRIES) + __get_cpu_var(stab_cache[offset++]) = stab_entry; + else + offset = NR_STAB_CACHE_ENTRIES+1; + __get_cpu_var(stab_cache_ptr) = offset; } /* @@ -242,20 +242,18 @@ void flush_stab(struct task_struct *tsk, { STE *stab = (STE *) get_paca()->xStab_data.virt; STE *ste; - unsigned long *offset = &__get_cpu_var(stab_cache_ptr); + unsigned long offset = __get_cpu_var(stab_cache_ptr); /* Force previous translations to complete. DRENG */ asm volatile("isync" : : : "memory"); - if (*offset <= NR_STAB_CACHE_ENTRIES) { + if (offset <= NR_STAB_CACHE_ENTRIES) { int i; - for (i = 0; i < *offset; i++) { + for (i = 0; i < offset; i++) { ste = stab + __get_cpu_var(stab_cache[i]); ste->dw0.dw0.v = 0; } - - asm volatile("sync; slbia; sync":::"memory"); } else { unsigned long entry; @@ -273,11 +271,11 @@ void flush_stab(struct task_struct *tsk, ste->dw0.dw0.v = 0; } } - - asm volatile("sync; slbia; sync":::"memory"); } - *offset = 0; + asm volatile("sync; slbia; sync":::"memory"); + + __get_cpu_var(stab_cache_ptr) = 0; preload_stab(tsk, mm); } @@ -292,8 +290,8 @@ void flush_stab(struct task_struct *tsk, * NOTE: A context syncronising instruction is required before and after * this, in the common case we use exception entry and rfid. */ -void make_slbe(unsigned long esid, unsigned long vsid, int large, - int kernel_segment) +static void make_slbe(unsigned long esid, unsigned long vsid, int large, + int kernel_segment) { unsigned long entry, castout_entry; union { @@ -326,7 +324,7 @@ void make_slbe(unsigned long esid, unsig castout_entry = 1; asm volatile("slbmfee %0,%1" : "=r" (esid_data) : "r" (entry)); } while (esid_data.data.v && - esid_data.data.esid == GET_ESID((unsigned long)_get_SP())); + esid_data.data.esid == GET_ESID(__get_SP())); get_paca()->xStab_data.next_round_robin = castout_entry; @@ -350,7 +348,7 @@ void make_slbe(unsigned long esid, unsig /* * No need for an isync before or after this slbmte. The exception - * we enter with and the rfid we exit with are context synchronizing. + * we enter with and the rfid we exit with are context synchronizing. */ asm volatile("slbmte %0,%1" : : "r" (vsid_data), "r" (esid_data)); } @@ -360,7 +358,7 @@ static inline void __slb_allocate(unsign { int large = 0; int region_id = REGION_ID(esid << SID_SHIFT); - unsigned long *offset; + unsigned long offset; if (cur_cpu_spec->cpu_features & CPU_FTR_16M_PAGE) { if (region_id == KERNEL_REGION_ID) @@ -374,11 +372,12 @@ static inline void __slb_allocate(unsign if (region_id != USER_REGION_ID) return; - offset = &__get_cpu_var(stab_cache_ptr); - if (*offset < NR_STAB_CACHE_ENTRIES) { - __get_cpu_var(stab_cache[*offset]) = esid; - } - (*offset)++; + offset = __get_cpu_var(stab_cache_ptr); + if (offset < NR_STAB_CACHE_ENTRIES) + __get_cpu_var(stab_cache[offset++]) = esid; + else + offset = NR_STAB_CACHE_ENTRIES+1; + __get_cpu_var(stab_cache_ptr) = offset; } /* @@ -457,9 +456,9 @@ static void preload_slb(struct task_stru /* Flush all user entries from the segment table of the current processor. */ void flush_slb(struct task_struct *tsk, struct mm_struct *mm) { - unsigned long *offset = &__get_cpu_var(stab_cache_ptr); + unsigned long offset = __get_cpu_var(stab_cache_ptr); - if (*offset <= NR_STAB_CACHE_ENTRIES) { + if (offset <= NR_STAB_CACHE_ENTRIES) { int i; union { unsigned long word0; @@ -467,7 +466,7 @@ void flush_slb(struct task_struct *tsk, } esid_data; asm volatile("isync" : : : "memory"); - for (i = 0; i < *offset; i++) { + for (i = 0; i < offset; i++) { esid_data.word0 = 0; esid_data.data.esid = __get_cpu_var(stab_cache[i]); asm volatile("slbie %0" : : "r" (esid_data)); @@ -477,7 +476,7 @@ void flush_slb(struct task_struct *tsk, asm volatile("isync; slbia; isync" : : : "memory"); } - *offset = 0; + __get_cpu_var(stab_cache_ptr) = 0; preload_slb(tsk, mm); } --- diff/arch/ppc64/kernel/sys_ppc32.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/sys_ppc32.c 2004-02-23 13:56:39.000000000 +0000 @@ -54,6 +54,8 @@ #include #include #include +#include +#include #include #include #include @@ -65,6 +67,7 @@ #include #include #include +#include #include @@ -778,8 +781,6 @@ int cp_compat_stat(struct kstat *stat, s return err; } -extern asmlinkage long sys_sysfs(int option, unsigned long arg1, unsigned long arg2); - /* Note: it is necessary to treat option as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -1155,8 +1156,6 @@ struct sysinfo32 { char _f[20-2*sizeof(int)-sizeof(int)]; }; -extern asmlinkage long sys_sysinfo(struct sysinfo *info); - asmlinkage long sys32_sysinfo(struct sysinfo32 *info) { struct sysinfo s; @@ -1868,8 +1867,6 @@ asmlinkage long sys32_ipc(u32 call, u32 return err; } -extern asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t* offset, size_t count); - /* Note: it is necessary to treat out_fd and in_fd as unsigned ints, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -1894,8 +1891,6 @@ asmlinkage long sys32_sendfile(u32 out_f return ret; } -extern asmlinkage ssize_t sys_sendfile64(int out_fd, int in_fd, loff_t *offset, size_t count); - asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t *offset, s32 count) { mm_segment_t old_fs = get_fs(); @@ -2158,9 +2153,6 @@ void start_thread32(struct pt_regs* regs #endif /* CONFIG_ALTIVEC */ } -extern asmlinkage int sys_prctl(int option, unsigned long arg2, unsigned long arg3, - unsigned long arg4, unsigned long arg5); - /* Note: it is necessary to treat option as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2175,14 +2167,12 @@ asmlinkage long sys32_prctl(u32 option, (unsigned long) arg5); } -extern asmlinkage int sys_sched_rr_get_interval(pid_t pid, struct timespec *interval); - /* Note: it is necessary to treat pid as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) * and the register representation of a signed int (msr in 64-bit mode) is performed. */ -asmlinkage int sys32_sched_rr_get_interval(u32 pid, struct compat_timespec *interval) +asmlinkage long sys32_sched_rr_get_interval(u32 pid, struct compat_timespec *interval) { struct timespec t; int ret; @@ -2196,9 +2186,6 @@ asmlinkage int sys32_sched_rr_get_interv return ret; } -extern asmlinkage int sys_pciconfig_read(unsigned long bus, unsigned long dfn, unsigned long off, - unsigned long len, unsigned char *buf); - asmlinkage int sys32_pciconfig_read(u32 bus, u32 dfn, u32 off, u32 len, u32 ubuf) { return sys_pciconfig_read((unsigned long) bus, @@ -2208,12 +2195,6 @@ asmlinkage int sys32_pciconfig_read(u32 (unsigned char *)AA(ubuf)); } - - - -extern asmlinkage int sys_pciconfig_write(unsigned long bus, unsigned long dfn, unsigned long off, - unsigned long len, unsigned char *buf); - asmlinkage int sys32_pciconfig_write(u32 bus, u32 dfn, u32 off, u32 len, u32 ubuf) { return sys_pciconfig_write((unsigned long) bus, @@ -2281,8 +2262,6 @@ asmlinkage int sys32_pciconfig_iobase(u3 } -extern asmlinkage int sys_newuname(struct new_utsname * name); - asmlinkage int ppc64_newuname(struct new_utsname * name) { int errno = sys_newuname(name); @@ -2295,8 +2274,6 @@ asmlinkage int ppc64_newuname(struct new return errno; } -extern asmlinkage long sys_personality(unsigned long); - asmlinkage int ppc64_personality(unsigned long personality) { int ret; @@ -2310,8 +2287,6 @@ asmlinkage int ppc64_personality(unsigne -extern asmlinkage long sys_access(const char * filename, int mode); - /* Note: it is necessary to treat mode as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2323,8 +2298,6 @@ asmlinkage long sys32_access(const char } -extern asmlinkage long sys_creat(const char * pathname, int mode); - /* Note: it is necessary to treat mode as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2336,8 +2309,6 @@ asmlinkage long sys32_creat(const char * } -extern asmlinkage long sys_waitpid(pid_t pid, unsigned int * stat_addr, int options); - /* Note: it is necessary to treat pid and options as unsigned ints, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2349,8 +2320,6 @@ asmlinkage long sys32_waitpid(u32 pid, u } -extern asmlinkage long sys_getgroups(int gidsetsize, gid_t *grouplist); - /* Note: it is necessary to treat gidsetsize as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2362,8 +2331,6 @@ asmlinkage long sys32_getgroups(u32 gids } -extern asmlinkage long sys_getpgid(pid_t pid); - /* Note: it is necessary to treat pid as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2375,8 +2342,6 @@ asmlinkage long sys32_getpgid(u32 pid) } -extern asmlinkage long sys_getpriority(int which, int who); - /* Note: it is necessary to treat which and who as unsigned ints, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2388,8 +2353,6 @@ asmlinkage long sys32_getpriority(u32 wh } -extern asmlinkage long sys_getsid(pid_t pid); - /* Note: it is necessary to treat pid as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2400,7 +2363,6 @@ asmlinkage long sys32_getsid(u32 pid) return sys_getsid((int)pid); } -extern asmlinkage long sys_kill(int pid, int sig); /* Note: it is necessary to treat pid and sig as unsigned ints, * with the corresponding cast to a signed int to insure that the @@ -2413,8 +2375,6 @@ asmlinkage long sys32_kill(u32 pid, u32 } -extern asmlinkage long sys_mkdir(const char * pathname, int mode); - /* Note: it is necessary to treat mode as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2425,16 +2385,12 @@ asmlinkage long sys32_mkdir(const char * return sys_mkdir(pathname, (int)mode); } -extern asmlinkage long sys_nice(int increment); - long sys32_nice(u32 increment) { /* sign extend increment */ return sys_nice((int)increment); } -extern off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin); - off_t ppc32_lseek(unsigned int fd, u32 offset, unsigned int origin) { /* sign extend n */ @@ -2472,8 +2428,6 @@ out_error: goto out; } -extern asmlinkage long sys_readlink(const char * path, char * buf, int bufsiz); - /* Note: it is necessary to treat bufsiz as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2484,8 +2438,6 @@ asmlinkage long sys32_readlink(const cha return sys_readlink(path, buf, (int)bufsiz); } -extern asmlinkage long sys_sched_get_priority_max(int policy); - /* Note: it is necessary to treat option as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2497,8 +2449,6 @@ asmlinkage long sys32_sched_get_priority } -extern asmlinkage long sys_sched_get_priority_min(int policy); - /* Note: it is necessary to treat policy as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2510,8 +2460,6 @@ asmlinkage long sys32_sched_get_priority } -extern asmlinkage long sys_sched_getparam(pid_t pid, struct sched_param *param); - /* Note: it is necessary to treat pid as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2523,8 +2471,6 @@ asmlinkage long sys32_sched_getparam(u32 } -extern asmlinkage long sys_sched_getscheduler(pid_t pid); - /* Note: it is necessary to treat pid as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2536,8 +2482,6 @@ asmlinkage long sys32_sched_getscheduler } -extern asmlinkage long sys_sched_setparam(pid_t pid, struct sched_param *param); - /* Note: it is necessary to treat pid as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2549,8 +2493,6 @@ asmlinkage long sys32_sched_setparam(u32 } -extern asmlinkage long sys_sched_setscheduler(pid_t pid, int policy, struct sched_param *param); - /* Note: it is necessary to treat pid and policy as unsigned ints, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2562,8 +2504,6 @@ asmlinkage long sys32_sched_setscheduler } -extern asmlinkage long sys_setdomainname(char *name, int len); - /* Note: it is necessary to treat len as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2575,8 +2515,6 @@ asmlinkage long sys32_setdomainname(char } -extern asmlinkage long sys_setgroups(int gidsetsize, gid_t *grouplist); - /* Note: it is necessary to treat gidsetsize as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2588,8 +2526,6 @@ asmlinkage long sys32_setgroups(u32 gids } -extern asmlinkage long sys_sethostname(char *name, int len); - asmlinkage long sys32_sethostname(char *name, u32 len) { /* sign extend len */ @@ -2597,8 +2533,6 @@ asmlinkage long sys32_sethostname(char * } -extern asmlinkage long sys_setpgid(pid_t pid, pid_t pgid); - /* Note: it is necessary to treat pid and pgid as unsigned ints, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2610,16 +2544,12 @@ asmlinkage long sys32_setpgid(u32 pid, u } -extern asmlinkage long sys_setpriority(int which, int who, int niceval); - long sys32_setpriority(u32 which, u32 who, u32 niceval) { /* sign extend which, who and niceval */ return sys_setpriority((int)which, (int)who, (int)niceval); } -extern asmlinkage long sys_ssetmask(int newmask); - /* Note: it is necessary to treat newmask as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2630,8 +2560,6 @@ asmlinkage long sys32_ssetmask(u32 newma return sys_ssetmask((int) newmask); } -extern asmlinkage long sys_syslog(int type, char * buf, int len); - long sys32_syslog(u32 type, char * buf, u32 len) { /* sign extend len */ @@ -2639,8 +2567,6 @@ long sys32_syslog(u32 type, char * buf, } -extern asmlinkage long sys_umask(int mask); - /* Note: it is necessary to treat mask as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2652,8 +2578,6 @@ asmlinkage long sys32_umask(u32 mask) } -extern asmlinkage long sys_umount(char * name, int flags); - /* Note: it is necessary to treat flags as an unsigned int, * with the corresponding cast to a signed int to insure that the * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) @@ -2756,10 +2680,6 @@ int sys32_olduname(struct oldold_utsname return error; } -extern unsigned long sys_mmap(unsigned long addr, size_t len, - unsigned long prot, unsigned long flags, - unsigned long fd, off_t offset); - unsigned long sys32_mmap2(unsigned long addr, size_t len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long pgoff) @@ -2801,8 +2721,6 @@ long sys32_utimes(char *filename, struct return ret; } -extern long sys_tgkill(int tgid, int pid, int sig); - long sys32_tgkill(u32 tgid, u32 pid, int sig) { /* sign extend tgid, pid */ @@ -2813,11 +2731,6 @@ long sys32_tgkill(u32 tgid, u32 pid, int * long long munging: * The 32 bit ABI passes long longs in an odd even register pair. */ -extern ssize_t sys_pread64(unsigned int fd, char *buf, size_t count, - loff_t pos); - -extern ssize_t sys_pwrite64(unsigned int fd, const char *buf, size_t count, - loff_t pos); compat_ssize_t sys32_pread64(unsigned int fd, char *ubuf, compat_size_t count, u32 reg6, u32 poshi, u32 poslo) @@ -2831,16 +2744,11 @@ compat_ssize_t sys32_pwrite64(unsigned i return sys_pwrite64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo); } -extern ssize_t sys_readahead(int fd, loff_t offset, size_t count); - compat_ssize_t sys32_readahead(int fd, u32 r4, u32 offhi, u32 offlo, u32 count) { return sys_readahead(fd, ((loff_t)offhi << 32) | offlo, count); } -extern asmlinkage long sys_truncate(const char * path, unsigned long length); -extern asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length); - asmlinkage int sys32_truncate64(const char * path, u32 reg4, unsigned long high, unsigned long low) { @@ -2853,8 +2761,6 @@ asmlinkage int sys32_ftruncate64(unsigne return sys_ftruncate(fd, (high << 32) | low); } -extern long sys_lookup_dcookie(u64 cookie64, char *buf, size_t len); - long ppc32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char *buf, size_t len) { @@ -2862,8 +2768,6 @@ long ppc32_lookup_dcookie(u32 cookie_hig buf, len); } -extern int sys_fadvise64(int fd, loff_t offset, size_t len, int advice); - long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low, size_t len, int advice) { --- diff/arch/ppc64/kernel/syscalls.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/ppc64/kernel/syscalls.c 2004-02-23 13:56:39.000000000 +0000 @@ -22,6 +22,7 @@ #include #include +#include #include #include #include --- diff/arch/ppc64/kernel/time.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/time.c 2004-02-23 13:56:39.000000000 +0000 @@ -418,6 +418,7 @@ int do_settimeofday(struct timespec *tv) } write_sequnlock_irqrestore(&xtime_lock, flags); + clock_was_set(); return 0; } --- diff/arch/ppc64/kernel/traps.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/traps.c 2004-02-23 13:56:39.000000000 +0000 @@ -70,11 +70,30 @@ static spinlock_t die_lock = SPIN_LOCK_U void die(const char *str, struct pt_regs *regs, long err) { static int die_counter; + int nl = 0; console_verbose(); spin_lock_irq(&die_lock); bust_spinlocks(1); printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter); +#ifdef CONFIG_PREEMPT + printk("PREEMPT "); + nl = 1; +#endif +#ifdef CONFIG_SMP + printk("SMP NR_CPUS=%d ", NR_CPUS); + nl = 1; +#endif +#ifdef CONFIG_DEBUG_PAGEALLOC + printk("DEBUG_PAGEALLOC "); + nl = 1; +#endif +#ifdef CONFIG_NUMA + printk("NUMA "); + nl = 1; +#endif + if (nl) + printk("\n"); show_regs(regs); bust_spinlocks(0); spin_unlock_irq(&die_lock); @@ -97,7 +116,7 @@ _exception(int signr, siginfo_t *info, s if (!user_mode(regs)) { if (debugger(regs)) return; - die("Exception in kernel mode\n", regs, signr); + die("Exception in kernel mode", regs, signr); } force_sig_info(signr, info, current); --- diff/arch/ppc64/kernel/xics.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/kernel/xics.c 2004-02-23 13:56:39.000000000 +0000 @@ -475,9 +475,7 @@ nextnode: if (systemcfg->platform == PLATFORM_PSERIES) { #ifdef CONFIG_SMP - for (i = 0; i < NR_CPUS; ++i) { - if (!cpu_possible(i)) - continue; + for_each_cpu(i) { xics_per_cpu[i] = __ioremap((ulong)inodes[get_hard_smp_processor_id(i)].addr, (ulong)inodes[get_hard_smp_processor_id(i)].size, _PAGE_NO_CACHE); --- diff/arch/ppc64/mm/init.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/mm/init.c 2004-02-23 13:56:39.000000000 +0000 @@ -699,10 +699,6 @@ void __init do_init_bootmem(void) /* add all physical memory to the bootmem map */ for (i=0; i < lmb.memory.cnt; i++) { unsigned long physbase, size; - unsigned long type = lmb.memory.region[i].type; - - if ( type != LMB_MEMORY_AREA ) - continue; physbase = lmb.memory.region[i].physbase; size = lmb.memory.region[i].size; @@ -743,12 +739,8 @@ static int __init setup_kcore(void) for (i=0; i < lmb.memory.cnt; i++) { unsigned long physbase, size; - unsigned long type = lmb.memory.region[i].type; struct kcore_list *kcore_mem; - if (type != LMB_MEMORY_AREA) - continue; - physbase = lmb.memory.region[i].physbase; size = lmb.memory.region[i].size; --- diff/arch/ppc64/mm/numa.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/ppc64/mm/numa.c 2004-02-23 13:56:39.000000000 +0000 @@ -100,6 +100,8 @@ static int __init parse_numa_properties( if (numa_domain >= MAX_NUMNODES) BUG(); + node_set_online(numa_domain); + if (max_domain < numa_domain) max_domain = numa_domain; @@ -201,13 +203,15 @@ err: return -1; } -void setup_nonnuma(void) +static void __init setup_nonnuma(void) { unsigned long i; for (i = 0; i < NR_CPUS; i++) map_cpu_to_node(i, 0); + node_set_online(0); + node_data[0].node_start_pfn = 0; node_data[0].node_spanned_pages = lmb_end_of_DRAM() / PAGE_SIZE; @@ -257,10 +261,6 @@ void __init do_init_bootmem(void) for (i = 0; i < lmb.memory.cnt; i++) { unsigned long physbase, size; - unsigned long type = lmb.memory.region[i].type; - - if (type != LMB_MEMORY_AREA) - continue; physbase = lmb.memory.region[i].physbase; size = lmb.memory.region[i].size; --- diff/arch/s390/Kconfig 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/s390/Kconfig 2004-02-23 13:56:39.000000000 +0000 @@ -143,6 +143,11 @@ config COMPAT depends on S390_SUPPORT default y +config SYSVIPC_COMPAT + bool + depends on COMPAT && SYSVIPC + default y + config BINFMT_ELF32 tristate "Kernel support for 31 bit ELF binaries" depends on S390_SUPPORT @@ -250,6 +255,98 @@ config SHARED_KERNEL You should only select this option if you know what you are doing and want to exploit this feature. +config CMM + tristate "Cooperative memory management" + help + Select this option, if you want to enable the kernel interface + to reduce the memory size of the system. This is accomplished + by allocating pages of memory and put them "on hold". This only + makes sense for a system running under VM where the unused pages + will be reused by VM for other guest systems. The interface + allows an external monitor to balance memory of many systems. + Everybody who wants to run Linux under VM should select this + option. + +config CMM_PROC + bool "/proc interface to cooperative memory management" + depends on CMM + help + Select this option to enable the /proc interface to the + cooperative memory management. + +config CMM_IUCV + bool "IUCV special message interface to cooperative memory management" + depends on CMM && (SMSGIUCV=y || CMM=SMSGIUCV) + help + Select this option to enable the special message interface to + the cooperative memory management. + +config VIRT_TIMER + bool "Virtual CPU timer support" + help + This provides a kernel interface for virtual CPU timers. + Default is disabled. + +config APPLDATA_BASE + bool "Linux - VM Monitor Stream, base infrastructure" + depends on PROC_FS && VIRT_TIMER=y + help + This provides a kernel interface for creating and updating z/VM APPLDATA + monitor records. The monitor records are updated at certain time + intervals, once the timer is started. + Writing 1 or 0 to /proc/appldata/timer starts(1) or stops(0) the timer, + i.e. enables or disables monitoring on the Linux side. + A custom interval value (in seconds) can be written to + /proc/appldata/interval. + + Defaults are 60 seconds interval and timer off. + The /proc entries can also be read from, showing the current settings. + +config APPLDATA_MEM + tristate "Monitor memory management statistics" + depends on APPLDATA_BASE + help + This provides memory management related data to the Linux - VM Monitor + Stream, like paging/swapping rate, memory utilisation, etc. + Writing 1 or 0 to /proc/appldata/memory creates(1) or removes(0) a z/VM + APPLDATA monitor record, i.e. enables or disables monitoring this record + on the z/VM side. + + Default is disabled. + The /proc entry can also be read from, showing the current settings. + + This can also be compiled as a module, which will be called + appldata_mem.o. + +config APPLDATA_OS + tristate "Monitor OS statistics" + depends on APPLDATA_BASE + help + This provides OS related data to the Linux - VM Monitor Stream, like + CPU utilisation, etc. + Writing 1 or 0 to /proc/appldata/os creates(1) or removes(0) a z/VM + APPLDATA monitor record, i.e. enables or disables monitoring this record + on the z/VM side. + + Default is disabled. + This can also be compiled as a module, which will be called + appldata_os.o. + +config APPLDATA_NET_SUM + tristate "Monitor overall network statistics" + depends on APPLDATA_BASE + help + This provides network related data to the Linux - VM Monitor Stream, + currently there is only a total sum of network I/O statistics, no + per-interface data. + Writing 1 or 0 to /proc/appldata/net_sum creates(1) or removes(0) a z/VM + APPLDATA monitor record, i.e. enables or disables monitoring this record + on the z/VM side. + + Default is disabled. + This can also be compiled as a module, which will be called + appldata_net_sum.o. + endmenu config PCMCIA --- diff/arch/s390/Makefile 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/s390/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -35,6 +35,7 @@ cflags-$(CONFIG_MARCH_Z990) += $(call ch CFLAGS += $(cflags-y) CFLAGS += $(call check_gcc,-finline-limit=10000,) CFLAGS += -pipe -fno-strength-reduce -Wno-sign-compare +CFLAGS += -mbackchain OBJCOPYFLAGS := -O binary LDFLAGS_vmlinux := -e start @@ -43,7 +44,8 @@ head-$(CONFIG_ARCH_S390_31) += arch/$(AR head-$(CONFIG_ARCH_S390X) += arch/$(ARCH)/kernel/head64.o head-y += arch/$(ARCH)/kernel/init_task.o -core-y += arch/$(ARCH)/mm/ arch/$(ARCH)/kernel/ +core-y += arch/$(ARCH)/mm/ arch/$(ARCH)/kernel/ \ + arch/$(ARCH)/appldata/ libs-y += arch/$(ARCH)/lib/ drivers-y += drivers/s390/ drivers-$(CONFIG_MATHEMU) += arch/$(ARCH)/math-emu/ --- diff/arch/s390/defconfig 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/s390/defconfig 2004-02-23 13:56:39.000000000 +0000 @@ -76,6 +76,8 @@ CONFIG_BINFMT_MISC=m # CONFIG_PROCESS_DEBUG is not set CONFIG_PFAULT=y # CONFIG_SHARED_KERNEL is not set +# CONFIG_CMM is not set +# CONFIG_VIRT_TIMER is not set # CONFIG_PCMCIA is not set # @@ -132,11 +134,13 @@ CONFIG_BLK_DEV_INITRD=y # S/390 block device drivers # CONFIG_BLK_DEV_XPRAM=m +# CONFIG_DCSSBLK is not set CONFIG_DASD=y # CONFIG_DASD_PROFILE is not set CONFIG_DASD_ECKD=y CONFIG_DASD_FBA=y CONFIG_DASD_DIAG=y +# CONFIG_DASD_CMB is not set # # Multi-device support (RAID and LVM) @@ -311,6 +315,8 @@ CONFIG_NET_ETHERNET=y CONFIG_LCS=m CONFIG_CTC=m CONFIG_IUCV=m +# CONFIG_NETIUCV is not set +# CONFIG_SMSGIUCV is not set CONFIG_QETH=y # --- diff/arch/s390/kernel/compat_linux.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/s390/kernel/compat_linux.c 2004-02-23 13:56:39.000000000 +0000 @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -71,17 +72,6 @@ #include "compat_linux.h" -extern asmlinkage long sys_chown(const char *, uid_t,gid_t); -extern asmlinkage long sys_lchown(const char *, uid_t,gid_t); -extern asmlinkage long sys_fchown(unsigned int, uid_t,gid_t); -extern asmlinkage long sys_setregid(gid_t, gid_t); -extern asmlinkage long sys_setgid(gid_t); -extern asmlinkage long sys_setreuid(uid_t, uid_t); -extern asmlinkage long sys_setuid(uid_t); -extern asmlinkage long sys_setresuid(uid_t, uid_t, uid_t); -extern asmlinkage long sys_setresgid(gid_t, gid_t, gid_t); -extern asmlinkage long sys_setfsuid(uid_t); -extern asmlinkage long sys_setfsgid(gid_t); /* For this source file, we want overflow handling. */ @@ -190,40 +180,81 @@ asmlinkage long sys32_setfsgid16(u16 gid return sys_setfsgid((gid_t)gid); } +static int groups16_to_user(u16 *grouplist, struct group_info *group_info) +{ + int i; + u16 group; + + for (i = 0; i < group_info->ngroups; i++) { + group = (u16)GROUP_AT(group_info, i); + if (put_user(group, grouplist+i)) + return -EFAULT; + } + + return 0; +} + +static int groups16_from_user(struct group_info *group_info, u16 *grouplist) +{ + int i; + u16 group; + + for (i = 0; i < group_info->ngroups; i++) { + if (get_user(group, grouplist+i)) + return -EFAULT; + GROUP_AT(group_info, i) = (gid_t)group; + } + + return 0; +} + asmlinkage long sys32_getgroups16(int gidsetsize, u16 *grouplist) { - u16 groups[NGROUPS]; - int i,j; + int i; if (gidsetsize < 0) return -EINVAL; - i = current->ngroups; + + get_group_info(current->group_info); + i = current->group_info->ngroups; if (gidsetsize) { - if (i > gidsetsize) - return -EINVAL; - for(j=0;jgroups[j]; - if (copy_to_user(grouplist, groups, sizeof(u16)*i)) - return -EFAULT; + if (i > gidsetsize) { + i = -EINVAL; + goto out; + } + if (groups16_to_user(grouplist, current->group_info)) { + i = -EFAULT; + goto out; + } } +out: + put_group_info(current->group_info); return i; } asmlinkage long sys32_setgroups16(int gidsetsize, u16 *grouplist) { - u16 groups[NGROUPS]; - int i; + struct group_info *group_info; + int retval; if (!capable(CAP_SETGID)) return -EPERM; - if ((unsigned) gidsetsize > NGROUPS) + if ((unsigned)gidsetsize > NGROUPS_MAX) return -EINVAL; - if (copy_from_user(groups, grouplist, gidsetsize * sizeof(u16))) - return -EFAULT; - for (i = 0 ; i < gidsetsize ; i++) - current->groups[i] = (gid_t)groups[i]; - current->ngroups = gidsetsize; - return 0; + + group_info = groups_alloc(gidsetsize); + if (!group_info) + return -ENOMEM; + retval = groups16_from_user(group_info, grouplist); + if (retval) { + put_group_info(group_info); + return retval; + } + + retval = set_current_groups(group_info); + put_group_info(group_info); + + return retval; } asmlinkage long sys32_getuid16(void) @@ -262,541 +293,6 @@ static inline long put_tv32(struct compa __put_user(i->tv_usec, &o->tv_usec))); } -struct msgbuf32 { s32 mtype; char mtext[1]; }; - -struct ipc64_perm_ds32 -{ - __kernel_key_t key; - __kernel_uid32_t uid; - __kernel_gid32_t gid; - __kernel_uid32_t cuid; - __kernel_gid32_t cgid; - compat_mode_t mode; - unsigned short __pad1; - unsigned short seq; - unsigned short __pad2; - unsigned int __unused1; - unsigned int __unused2; -}; - -struct ipc_perm32 -{ - key_t key; - compat_uid_t uid; - compat_gid_t gid; - compat_uid_t cuid; - compat_gid_t cgid; - compat_mode_t mode; - unsigned short seq; -}; - -struct semid_ds32 { - struct ipc_perm32 sem_perm; /* permissions .. see ipc.h */ - compat_time_t sem_otime; /* last semop time */ - compat_time_t sem_ctime; /* last change time */ - u32 sem_base; /* ptr to first semaphore in array */ - u32 sem_pending; /* pending operations to be processed */ - u32 sem_pending_last; /* last pending operation */ - u32 undo; /* undo requests on this array */ - unsigned short sem_nsems; /* no. of semaphores in array */ -}; - -struct semid64_ds32 { - struct ipc64_perm_ds32 sem_perm; - unsigned int __pad1; - compat_time_t sem_otime; - unsigned int __pad2; - compat_time_t sem_ctime; - u32 sem_nsems; - u32 __unused1; - u32 __unused2; -}; - -struct msqid_ds32 -{ - struct ipc_perm32 msg_perm; - u32 msg_first; - u32 msg_last; - compat_time_t msg_stime; - compat_time_t msg_rtime; - compat_time_t msg_ctime; - u32 wwait; - u32 rwait; - unsigned short msg_cbytes; - unsigned short msg_qnum; - unsigned short msg_qbytes; - compat_ipc_pid_t msg_lspid; - compat_ipc_pid_t msg_lrpid; -}; - -struct msqid64_ds32 { - struct ipc64_perm_ds32 msg_perm; - unsigned int __pad1; - compat_time_t msg_stime; - unsigned int __pad2; - compat_time_t msg_rtime; - unsigned int __pad3; - compat_time_t msg_ctime; - unsigned int msg_cbytes; - unsigned int msg_qnum; - unsigned int msg_qbytes; - compat_pid_t msg_lspid; - compat_pid_t msg_lrpid; - unsigned int __unused1; - unsigned int __unused2; -}; - - -struct shmid_ds32 { - struct ipc_perm32 shm_perm; - int shm_segsz; - compat_time_t shm_atime; - compat_time_t shm_dtime; - compat_time_t shm_ctime; - compat_ipc_pid_t shm_cpid; - compat_ipc_pid_t shm_lpid; - unsigned short shm_nattch; -}; - -struct shmid64_ds32 { - struct ipc64_perm_ds32 shm_perm; - compat_size_t shm_segsz; - compat_time_t shm_atime; - unsigned int __unused1; - compat_time_t shm_dtime; - unsigned int __unused2; - compat_time_t shm_ctime; - unsigned int __unused3; - compat_pid_t shm_cpid; - compat_pid_t shm_lpid; - unsigned int shm_nattch; - unsigned int __unused4; - unsigned int __unused5; -}; - -extern int sem_ctls[]; -#define sc_semopm (sem_ctls[2]) -#define SEMOPM_FAST 64 /* ~ 372 bytes on stack */ - -static long -do_sys32_semtimedop (int semid, struct sembuf *tsops, int nsops, - struct compat_timespec *timeout32) -{ - struct sembuf *sops, fast_sops[SEMOPM_FAST]; - struct timespec t; - mm_segment_t oldfs; - long ret; - - /* parameter checking precedence should mirror sys_semtimedop() */ - if (nsops < 1 || semid < 0) - return -EINVAL; - if (nsops > sc_semopm) - return -E2BIG; - if (nsops <= SEMOPM_FAST) - sops = fast_sops; - else { - sops = kmalloc(nsops * sizeof(*sops), GFP_KERNEL); - if (sops == NULL) - return -ENOMEM; - } - if (copy_from_user(sops, tsops, nsops * sizeof(*tsops)) || - get_compat_timespec(&t, timeout32)) - ret = -EFAULT; - else { - oldfs = get_fs(); - set_fs(KERNEL_DS); - ret = sys_semtimedop(semid, sops, nsops, &t); - set_fs(oldfs); - } - if (sops != fast_sops) - kfree(sops); - return ret; -} - -#define IPCOP_MASK(__x) (1UL << (__x)) -static int do_sys32_semctl(int first, int second, int third, void *uptr) -{ - union semun fourth; - u32 pad; - int err = -EINVAL; - - if (!uptr) - goto out; - err = -EFAULT; - if (get_user (pad, (u32 *)uptr)) - goto out; - if(third == SETVAL) - fourth.val = (int)pad; - else - fourth.__pad = (void *)A(pad); - if (IPCOP_MASK (third) & - (IPCOP_MASK (IPC_INFO) | IPCOP_MASK (SEM_INFO) | IPCOP_MASK (GETVAL) | - IPCOP_MASK (GETPID) | IPCOP_MASK (GETNCNT) | IPCOP_MASK (GETZCNT) | - IPCOP_MASK (GETALL) | IPCOP_MASK (SETALL) | IPCOP_MASK (IPC_RMID))) { - err = sys_semctl (first, second, third, fourth); - } else if (third & IPC_64) { - struct semid64_ds s; - struct semid64_ds32 *usp = (struct semid64_ds32 *)A(pad); - mm_segment_t old_fs; - int need_back_translation; - - if (third == (IPC_SET|IPC_64)) { - err = get_user (s.sem_perm.uid, &usp->sem_perm.uid); - err |= __get_user (s.sem_perm.gid, &usp->sem_perm.gid); - err |= __get_user (s.sem_perm.mode, &usp->sem_perm.mode); - if (err) - goto out; - fourth.__pad = &s; - } - need_back_translation = - (IPCOP_MASK (third) & - (IPCOP_MASK (SEM_STAT) | IPCOP_MASK (IPC_STAT))) != 0; - if (need_back_translation) - fourth.__pad = &s; - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_semctl (first, second, third, fourth); - set_fs (old_fs); - if (need_back_translation) { - int err2 = put_user (s.sem_perm.key, &usp->sem_perm.key); - err2 |= __put_user (high2lowuid(s.sem_perm.uid), &usp->sem_perm.uid); - err2 |= __put_user (high2lowgid(s.sem_perm.gid), &usp->sem_perm.gid); - err2 |= __put_user (high2lowuid(s.sem_perm.cuid), &usp->sem_perm.cuid); - err2 |= __put_user (high2lowgid(s.sem_perm.cgid), &usp->sem_perm.cgid); - err2 |= __put_user (s.sem_perm.mode, &usp->sem_perm.mode); - err2 |= __put_user (s.sem_perm.seq, &usp->sem_perm.seq); - err2 |= __put_user (s.sem_otime, &usp->sem_otime); - err2 |= __put_user (s.sem_ctime, &usp->sem_ctime); - err2 |= __put_user (s.sem_nsems, &usp->sem_nsems); - if (err2) err = -EFAULT; - } - } else { - struct semid_ds s; - struct semid_ds32 *usp = (struct semid_ds32 *)A(pad); - mm_segment_t old_fs; - int need_back_translation; - - if (third == IPC_SET) { - err = get_user (s.sem_perm.uid, &usp->sem_perm.uid); - err |= __get_user (s.sem_perm.gid, &usp->sem_perm.gid); - err |= __get_user (s.sem_perm.mode, &usp->sem_perm.mode); - if (err) - goto out; - fourth.__pad = &s; - } - need_back_translation = - (IPCOP_MASK (third) & - (IPCOP_MASK (SEM_STAT) | IPCOP_MASK (IPC_STAT))) != 0; - if (need_back_translation) - fourth.__pad = &s; - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_semctl (first, second, third, fourth); - set_fs (old_fs); - if (need_back_translation) { - int err2 = put_user (s.sem_perm.key, &usp->sem_perm.key); - err2 |= __put_user (high2lowuid(s.sem_perm.uid), &usp->sem_perm.uid); - err2 |= __put_user (high2lowgid(s.sem_perm.gid), &usp->sem_perm.gid); - err2 |= __put_user (high2lowuid(s.sem_perm.cuid), &usp->sem_perm.cuid); - err2 |= __put_user (high2lowgid(s.sem_perm.cgid), &usp->sem_perm.cgid); - err2 |= __put_user (s.sem_perm.mode, &usp->sem_perm.mode); - err2 |= __put_user (s.sem_perm.seq, &usp->sem_perm.seq); - err2 |= __put_user (s.sem_otime, &usp->sem_otime); - err2 |= __put_user (s.sem_ctime, &usp->sem_ctime); - err2 |= __put_user (s.sem_nsems, &usp->sem_nsems); - if (err2) err = -EFAULT; - } - } -out: - return err; -} - -static int do_sys32_msgsnd (int first, int second, int third, void *uptr) -{ - struct msgbuf *p = kmalloc (second + sizeof (struct msgbuf), GFP_USER); - struct msgbuf32 *up = (struct msgbuf32 *)uptr; - mm_segment_t old_fs; - int err; - - if (!p) - return -ENOMEM; - - err = -EINVAL; - if (second > MSGMAX || first < 0 || second < 0) - goto out; - - err = -EFAULT; - if (!uptr) - goto out; - if (get_user (p->mtype, &up->mtype) || - __copy_from_user (p->mtext, &up->mtext, second)) - goto out; - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_msgsnd (first, p, second, third); - set_fs (old_fs); -out: - kfree (p); - return err; -} - -static int do_sys32_msgrcv (int first, int second, int msgtyp, int third, - int version, void *uptr) -{ - struct msgbuf32 *up; - struct msgbuf *p; - mm_segment_t old_fs; - int err; - - if (first < 0 || second < 0) - return -EINVAL; - - if (!version) { - struct ipc_kludge_32 *uipck = (struct ipc_kludge_32 *)uptr; - struct ipc_kludge_32 ipck; - - err = -EINVAL; - if (!uptr) - goto out; - err = -EFAULT; - if (copy_from_user (&ipck, uipck, sizeof (struct ipc_kludge_32))) - goto out; - uptr = (void *)A(ipck.msgp); - msgtyp = ipck.msgtyp; - } - err = -ENOMEM; - p = kmalloc (second + sizeof (struct msgbuf), GFP_USER); - if (!p) - goto out; - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_msgrcv (first, p, second, msgtyp, third); - set_fs (old_fs); - if (err < 0) - goto free_then_out; - up = (struct msgbuf32 *)uptr; - if (put_user (p->mtype, &up->mtype) || - __copy_to_user (&up->mtext, p->mtext, err)) - err = -EFAULT; -free_then_out: - kfree (p); -out: - return err; -} - -static int do_sys32_msgctl (int first, int second, void *uptr) -{ - int err; - - if (IPCOP_MASK (second) & - (IPCOP_MASK (IPC_INFO) | IPCOP_MASK (MSG_INFO) | - IPCOP_MASK (IPC_RMID))) { - err = sys_msgctl (first, second, (struct msqid_ds *)uptr); - } else if (second & IPC_64) { - struct msqid64_ds m; - struct msqid64_ds32 *up = (struct msqid64_ds32 *)uptr; - mm_segment_t old_fs; - - if (second == (IPC_SET|IPC_64)) { - err = get_user (m.msg_perm.uid, &up->msg_perm.uid); - err |= __get_user (m.msg_perm.gid, &up->msg_perm.gid); - err |= __get_user (m.msg_perm.mode, &up->msg_perm.mode); - err |= __get_user (m.msg_qbytes, &up->msg_qbytes); - if (err) - goto out; - } - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_msgctl (first, second, (struct msqid_ds *)&m); - set_fs (old_fs); - if (IPCOP_MASK (second) & - (IPCOP_MASK (MSG_STAT) | IPCOP_MASK (IPC_STAT))) { - int err2 = put_user (m.msg_perm.key, &up->msg_perm.key); - err2 |= __put_user (high2lowuid(m.msg_perm.uid), &up->msg_perm.uid); - err2 |= __put_user (high2lowgid(m.msg_perm.gid), &up->msg_perm.gid); - err2 |= __put_user (high2lowuid(m.msg_perm.cuid), &up->msg_perm.cuid); - err2 |= __put_user (high2lowgid(m.msg_perm.cgid), &up->msg_perm.cgid); - err2 |= __put_user (m.msg_perm.mode, &up->msg_perm.mode); - err2 |= __put_user (m.msg_perm.seq, &up->msg_perm.seq); - err2 |= __put_user (m.msg_stime, &up->msg_stime); - err2 |= __put_user (m.msg_rtime, &up->msg_rtime); - err2 |= __put_user (m.msg_ctime, &up->msg_ctime); - err2 |= __put_user (m.msg_cbytes, &up->msg_cbytes); - err2 |= __put_user (m.msg_qnum, &up->msg_qnum); - err2 |= __put_user (m.msg_qbytes, &up->msg_qbytes); - err2 |= __put_user (m.msg_lspid, &up->msg_lspid); - err2 |= __put_user (m.msg_lrpid, &up->msg_lrpid); - if (err2) - err = -EFAULT; - } - } else { - struct msqid_ds m; - struct msqid_ds32 *up = (struct msqid_ds32 *)uptr; - mm_segment_t old_fs; - - if (second == IPC_SET) { - err = get_user (m.msg_perm.uid, &up->msg_perm.uid); - err |= __get_user (m.msg_perm.gid, &up->msg_perm.gid); - err |= __get_user (m.msg_perm.mode, &up->msg_perm.mode); - err |= __get_user (m.msg_qbytes, &up->msg_qbytes); - if (err) - goto out; - } - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_msgctl (first, second, &m); - set_fs (old_fs); - if (IPCOP_MASK (second) & - (IPCOP_MASK (MSG_STAT) | IPCOP_MASK (IPC_STAT))) { - int err2 = put_user (m.msg_perm.key, &up->msg_perm.key); - err2 |= __put_user (high2lowuid(m.msg_perm.uid), &up->msg_perm.uid); - err2 |= __put_user (high2lowgid(m.msg_perm.gid), &up->msg_perm.gid); - err2 |= __put_user (high2lowuid(m.msg_perm.cuid), &up->msg_perm.cuid); - err2 |= __put_user (high2lowgid(m.msg_perm.cgid), &up->msg_perm.cgid); - err2 |= __put_user (m.msg_perm.mode, &up->msg_perm.mode); - err2 |= __put_user (m.msg_perm.seq, &up->msg_perm.seq); - err2 |= __put_user (m.msg_stime, &up->msg_stime); - err2 |= __put_user (m.msg_rtime, &up->msg_rtime); - err2 |= __put_user (m.msg_ctime, &up->msg_ctime); - err2 |= __put_user (m.msg_cbytes, &up->msg_cbytes); - err2 |= __put_user (m.msg_qnum, &up->msg_qnum); - err2 |= __put_user (m.msg_qbytes, &up->msg_qbytes); - err2 |= __put_user (m.msg_lspid, &up->msg_lspid); - err2 |= __put_user (m.msg_lrpid, &up->msg_lrpid); - if (err2) - err = -EFAULT; - } - } - -out: - return err; -} - -static int do_sys32_shmat (int first, int second, int third, int version, void *uptr) -{ - unsigned long raddr; - u32 *uaddr = (u32 *)A((u32)third); - int err = -EINVAL; - - if (version == 1) - goto out; - err = sys_shmat (first, uptr, second, &raddr); - if (err) - goto out; - err = put_user (raddr, uaddr); -out: - return err; -} - -static int do_sys32_shmctl (int first, int second, void *uptr) -{ - int err; - - if (IPCOP_MASK (second) & - (IPCOP_MASK (IPC_INFO) | IPCOP_MASK (SHM_LOCK) | IPCOP_MASK (SHM_UNLOCK) | - IPCOP_MASK (IPC_RMID))) { - if (second == (IPC_INFO|IPC_64)) - second = IPC_INFO; /* So that we don't have to translate it */ - err = sys_shmctl (first, second, (struct shmid_ds *)uptr); - } else if ((second & IPC_64) && second != (SHM_INFO|IPC_64)) { - struct shmid64_ds s; - struct shmid64_ds32 *up = (struct shmid64_ds32 *)uptr; - mm_segment_t old_fs; - - if (second == (IPC_SET|IPC_64)) { - err = get_user (s.shm_perm.uid, &up->shm_perm.uid); - err |= __get_user (s.shm_perm.gid, &up->shm_perm.gid); - err |= __get_user (s.shm_perm.mode, &up->shm_perm.mode); - if (err) - goto out; - } - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_shmctl (first, second, (struct shmid_ds *)&s); - set_fs (old_fs); - if (err < 0) - goto out; - - /* Mask it even in this case so it becomes a CSE. */ - if (IPCOP_MASK (second) & - (IPCOP_MASK (SHM_STAT) | IPCOP_MASK (IPC_STAT))) { - int err2 = put_user (s.shm_perm.key, &up->shm_perm.key); - err2 |= __put_user (high2lowuid(s.shm_perm.uid), &up->shm_perm.uid); - err2 |= __put_user (high2lowgid(s.shm_perm.gid), &up->shm_perm.gid); - err2 |= __put_user (high2lowuid(s.shm_perm.cuid), &up->shm_perm.cuid); - err2 |= __put_user (high2lowgid(s.shm_perm.cgid), &up->shm_perm.cgid); - err2 |= __put_user (s.shm_perm.mode, &up->shm_perm.mode); - err2 |= __put_user (s.shm_perm.seq, &up->shm_perm.seq); - err2 |= __put_user (s.shm_atime, &up->shm_atime); - err2 |= __put_user (s.shm_dtime, &up->shm_dtime); - err2 |= __put_user (s.shm_ctime, &up->shm_ctime); - err2 |= __put_user (s.shm_segsz, &up->shm_segsz); - err2 |= __put_user (s.shm_nattch, &up->shm_nattch); - err2 |= __put_user (s.shm_cpid, &up->shm_cpid); - err2 |= __put_user (s.shm_lpid, &up->shm_lpid); - if (err2) - err = -EFAULT; - } - } else { - struct shmid_ds s; - struct shmid_ds32 *up = (struct shmid_ds32 *)uptr; - mm_segment_t old_fs; - - second &= ~IPC_64; - if (second == IPC_SET) { - err = get_user (s.shm_perm.uid, &up->shm_perm.uid); - err |= __get_user (s.shm_perm.gid, &up->shm_perm.gid); - err |= __get_user (s.shm_perm.mode, &up->shm_perm.mode); - if (err) - goto out; - } - old_fs = get_fs (); - set_fs (KERNEL_DS); - err = sys_shmctl (first, second, &s); - set_fs (old_fs); - if (err < 0) - goto out; - - /* Mask it even in this case so it becomes a CSE. */ - if (second == SHM_INFO) { - struct shm_info32 { - int used_ids; - u32 shm_tot, shm_rss, shm_swp; - u32 swap_attempts, swap_successes; - } *uip = (struct shm_info32 *)uptr; - struct shm_info *kp = (struct shm_info *)&s; - int err2 = put_user (kp->used_ids, &uip->used_ids); - err2 |= __put_user (kp->shm_tot, &uip->shm_tot); - err2 |= __put_user (kp->shm_rss, &uip->shm_rss); - err2 |= __put_user (kp->shm_swp, &uip->shm_swp); - err2 |= __put_user (kp->swap_attempts, &uip->swap_attempts); - err2 |= __put_user (kp->swap_successes, &uip->swap_successes); - if (err2) - err = -EFAULT; - } else if (IPCOP_MASK (second) & - (IPCOP_MASK (SHM_STAT) | IPCOP_MASK (IPC_STAT))) { - int err2 = put_user (s.shm_perm.key, &up->shm_perm.key); - err2 |= __put_user (high2lowuid(s.shm_perm.uid), &up->shm_perm.uid); - err2 |= __put_user (high2lowgid(s.shm_perm.gid), &up->shm_perm.gid); - err2 |= __put_user (high2lowuid(s.shm_perm.cuid), &up->shm_perm.cuid); - err2 |= __put_user (high2lowgid(s.shm_perm.cgid), &up->shm_perm.cgid); - err2 |= __put_user (s.shm_perm.mode, &up->shm_perm.mode); - err2 |= __put_user (s.shm_perm.seq, &up->shm_perm.seq); - err2 |= __put_user (s.shm_atime, &up->shm_atime); - err2 |= __put_user (s.shm_dtime, &up->shm_dtime); - err2 |= __put_user (s.shm_ctime, &up->shm_ctime); - err2 |= __put_user (s.shm_segsz, &up->shm_segsz); - err2 |= __put_user (s.shm_nattch, &up->shm_nattch); - err2 |= __put_user (s.shm_cpid, &up->shm_cpid); - err2 |= __put_user (s.shm_lpid, &up->shm_lpid); - if (err2) - err = -EFAULT; - } - } -out: - return err; -} - /* * sys32_ipc() is the de-multiplexer for the SysV IPC calls in 32bit emulation. * @@ -804,89 +300,66 @@ out: */ asmlinkage int sys32_ipc (u32 call, int first, int second, int third, u32 ptr) { - int version, err; + if(call >> 16) /* hack for backward compatibility */ + return -EINVAL; - version = call >> 16; /* hack for backward compatibility */ call &= 0xffff; - if(version) - return -EINVAL; - if (call <= SEMTIMEDOP) switch (call) { case SEMTIMEDOP: - if (third) { - err = do_sys32_semtimedop(first, - (struct sembuf *)AA(ptr), - second, - (struct compat_timespec *) - AA((u32)third)); - goto out; - } + if (third) + return compat_sys_semtimedop(first, + compat_ptr(ptr), second, + compat_ptr(third)); /* else fall through for normal semop() */ case SEMOP: /* struct sembuf is the same on 32 and 64bit :)) */ - err = sys_semtimedop (first, (struct sembuf *)AA(ptr), + return sys_semtimedop (first, compat_ptr(ptr), second, NULL); - goto out; case SEMGET: - err = sys_semget (first, second, third); - goto out; + return sys_semget (first, second, third); case SEMCTL: - err = do_sys32_semctl (first, second, third, (void *)AA(ptr)); - goto out; + return compat_sys_semctl (first, second, third, + compat_ptr(ptr)); default: - err = -EINVAL; - goto out; + return -EINVAL; }; if (call <= MSGCTL) switch (call) { case MSGSND: - err = do_sys32_msgsnd (first, second, third, (void *)AA(ptr)); - goto out; + return compat_sys_msgsnd (first, second, third, + compat_ptr(ptr)); case MSGRCV: - err = do_sys32_msgrcv (first, second, 0, third, - version, (void *)AA(ptr)); - goto out; + return compat_sys_msgrcv (first, second, 0, third, + 0, compat_ptr(ptr)); case MSGGET: - err = sys_msgget ((key_t) first, second); - goto out; + return sys_msgget ((key_t) first, second); case MSGCTL: - err = do_sys32_msgctl (first, second, (void *)AA(ptr)); - goto out; + return compat_sys_msgctl (first, second, + compat_ptr(ptr)); default: - err = -EINVAL; - goto out; + return -EINVAL; } if (call <= SHMCTL) switch (call) { case SHMAT: - err = do_sys32_shmat (first, second, third, - version, (void *)AA(ptr)); - goto out; + return compat_sys_shmat (first, second, third, + 0, compat_ptr(ptr)); case SHMDT: - err = sys_shmdt ((char *)AA(ptr)); - goto out; + return sys_shmdt(compat_ptr(ptr)); case SHMGET: - err = sys_shmget (first, second, third); - goto out; + return sys_shmget(first, second, third); case SHMCTL: - err = do_sys32_shmctl (first, second, (void *)AA(ptr)); - goto out; + return compat_sys_shmctl(first, second, + compat_ptr(ptr)); default: - err = -EINVAL; - goto out; + return -EINVAL; } - err = -EINVAL; - -out: - return err; + return -EINVAL; } -extern asmlinkage long sys_truncate(const char * path, unsigned long length); -extern asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length); - asmlinkage int sys32_truncate64(const char * path, unsigned long high, unsigned long low) { if ((int)high < 0) @@ -1356,8 +829,6 @@ int cp_compat_stat(struct kstat *stat, s return err; } -extern asmlinkage int sys_sysfs(int option, unsigned long arg1, unsigned long arg2); - asmlinkage int sys32_sysfs(int option, u32 arg1, u32 arg2) { return sys_sysfs(option, arg1, arg2); @@ -1531,9 +1002,7 @@ struct sysinfo32 { char _f[8]; }; -extern asmlinkage int sys_sysinfo(struct sysinfo *info); - -asmlinkage int sys32_sysinfo(struct sysinfo32 *info) +asmlinkage int sys32_sysinfo(struct sysinfo32 __user *info) { struct sysinfo s; int ret, err; @@ -1561,10 +1030,8 @@ asmlinkage int sys32_sysinfo(struct sysi return ret; } -extern asmlinkage int sys_sched_rr_get_interval(pid_t pid, struct timespec *interval); - asmlinkage int sys32_sched_rr_get_interval(compat_pid_t pid, - struct compat_timespec *interval) + struct compat_timespec __user *interval) { struct timespec t; int ret; @@ -1578,9 +1045,8 @@ asmlinkage int sys32_sched_rr_get_interv return ret; } -extern asmlinkage int sys_rt_sigprocmask(int how, sigset_t *set, sigset_t *oset, size_t sigsetsize); - -asmlinkage int sys32_rt_sigprocmask(int how, compat_sigset_t *set, compat_sigset_t *oset, compat_size_t sigsetsize) +asmlinkage int sys32_rt_sigprocmask(int how, compat_sigset_t __user *set, + compat_sigset_t __user *oset, compat_size_t sigsetsize) { sigset_t s; compat_sigset_t s32; @@ -1614,9 +1080,8 @@ asmlinkage int sys32_rt_sigprocmask(int return 0; } -extern asmlinkage int sys_rt_sigpending(sigset_t *set, size_t sigsetsize); - -asmlinkage int sys32_rt_sigpending(compat_sigset_t *set, compat_size_t sigsetsize) +asmlinkage int sys32_rt_sigpending(compat_sigset_t __user *set, + compat_size_t sigsetsize) { sigset_t s; compat_sigset_t s32; @@ -1723,11 +1188,8 @@ sys32_rt_sigtimedwait(compat_sigset_t *u return ret; } -extern asmlinkage int -sys_rt_sigqueueinfo(int pid, int sig, siginfo_t *uinfo); - asmlinkage int -sys32_rt_sigqueueinfo(int pid, int sig, siginfo_t32 *uinfo) +sys32_rt_sigqueueinfo(int pid, int sig, siginfo_t32 __user *uinfo) { siginfo_t info; int ret; @@ -1956,40 +1418,30 @@ out: #ifdef CONFIG_MODULES -extern asmlinkage int sys_init_module(const char *name_user, struct module *mod_user); - -/* Hey, when you're trying to init module, take time and prepare us a nice 64bit - * module structure, even if from 32bit modutils... Why to pollute kernel... :)) - */ -asmlinkage int sys32_init_module(const char *name_user, struct module *mod_user) +asmlinkage int +sys32_init_module(void __user *umod, unsigned long len, + const char __user *uargs) { - return sys_init_module(name_user, mod_user); + return sys_init_module(umod, len, uargs); } -extern asmlinkage int sys_delete_module(const char *name_user); - -asmlinkage int sys32_delete_module(const char *name_user) +asmlinkage int +sys32_delete_module(const char __user *name_user, unsigned int flags) { - return sys_delete_module(name_user); + return sys_delete_module(name_user, flags); } -struct module_info32 { - u32 addr; - u32 size; - u32 flags; - s32 usecount; -}; - #else /* CONFIG_MODULES */ asmlinkage int -sys32_init_module(const char *name_user, struct module *mod_user) +sys32_init_module(void __user *umod, unsigned long len, + const char __user *uargs) { return -ENOSYS; } asmlinkage int -sys32_delete_module(const char *name_user) +sys32_delete_module(const char __user *name_user, unsigned int flags) { return -ENOSYS; } @@ -2153,10 +1605,6 @@ static int nfs_getfh32_res_trans(union n return copy_to_user(res32, kres, sizeof(*res32)) ? -EFAULT : 0; } -/* -asmlinkage long sys_ni_syscall(void); -*/ - int asmlinkage sys32_nfsservctl(int cmd, struct nfsctl_arg32 *arg32, union nfsctl_res32 *res32) { struct nfsctl_arg *karg = NULL; @@ -2271,9 +1719,8 @@ asmlinkage int sys32_settimeofday(struct return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL); } -asmlinkage int sys_utimes(char *, struct timeval *); - -asmlinkage int sys32_utimes(char *filename, struct compat_timeval *tvs) +asmlinkage int sys32_utimes(char __user *filename, + struct compat_timeval __user *tvs) { char *kfilename; struct timeval ktvs[2]; @@ -2307,8 +1754,6 @@ asmlinkage int sys32_pause(void) return -ERESTARTNOHAND; } -extern asmlinkage int sys_prctl(int option, unsigned long arg2, unsigned long arg3, - unsigned long arg4, unsigned long arg5); asmlinkage int sys32_prctl(int option, u32 arg2, u32 arg3, u32 arg4, u32 arg5) { @@ -2320,12 +1765,6 @@ asmlinkage int sys32_prctl(int option, u } -extern asmlinkage ssize_t sys_pread64(unsigned int fd, char * buf, - size_t count, loff_t pos); - -extern asmlinkage ssize_t sys_pwrite64(unsigned int fd, const char * buf, - size_t count, loff_t pos); - asmlinkage compat_ssize_t sys32_pread64(unsigned int fd, char *ubuf, compat_size_t count, u32 poshi, u32 poslo) { @@ -2342,15 +1781,11 @@ asmlinkage compat_ssize_t sys32_pwrite64 return sys_pwrite64(fd, ubuf, count, ((loff_t)AA(poshi) << 32) | AA(poslo)); } -extern asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count); - asmlinkage compat_ssize_t sys32_readahead(int fd, u32 offhi, u32 offlo, s32 count) { return sys_readahead(fd, ((loff_t)AA(offhi) << 32) | AA(offlo), count); } -extern asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t *offset, size_t count); - asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t *offset, s32 count) { mm_segment_t old_fs = get_fs(); @@ -2370,9 +1805,6 @@ asmlinkage int sys32_sendfile(int out_fd return ret; } -extern asmlinkage ssize_t sys_sendfile64(int out_fd, int in_fd, - loff_t *offset, size_t count); - asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t *offset, s32 count) { @@ -2466,8 +1898,6 @@ asmlinkage int sys32_adjtimex(struct tim return ret; } -extern asmlinkage long sys_setpriority(int which, int who, int niceval); - asmlinkage int sys_setpriority32(u32 which, u32 who, u32 niceval) { return sys_setpriority((int) which, @@ -2485,7 +1915,7 @@ struct __sysctl_args32 { u32 __unused[4]; }; -extern asmlinkage long sys32_sysctl(struct __sysctl_args32 *args) +asmlinkage long sys32_sysctl(struct __sysctl_args32 *args) { struct __sysctl_args32 tmp; int error; @@ -2677,8 +2107,6 @@ out: return error; } -asmlinkage ssize_t sys_read(unsigned int fd, char * buf, size_t count); - asmlinkage compat_ssize_t sys32_read(unsigned int fd, char * buf, size_t count) { if ((compat_ssize_t) count < 0) @@ -2687,8 +2115,6 @@ asmlinkage compat_ssize_t sys32_read(uns return sys_read(fd, buf, count); } -asmlinkage ssize_t sys_write(unsigned int fd, const char * buf, size_t count); - asmlinkage compat_ssize_t sys32_write(unsigned int fd, char * buf, size_t count) { if ((compat_ssize_t) count < 0) --- diff/arch/s390/kernel/compat_linux.h 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/s390/kernel/compat_linux.h 2004-02-23 13:56:39.000000000 +0000 @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include --- diff/arch/s390/kernel/compat_wrapper.S 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/s390/kernel/compat_wrapper.S 2004-02-23 13:56:39.000000000 +0000 @@ -567,13 +567,15 @@ compat_sys_sigprocmask_wrapper: .globl sys32_init_module_wrapper sys32_init_module_wrapper: - llgtr %r2,%r2 # const char * - llgtr %r3,%r3 # struct module * + llgtr %r2,%r2 # void * + llgfr %r3,%r3 # unsigned long + llgtr %r4,%r4 # char * jg sys32_init_module # branch to system call .globl sys32_delete_module_wrapper sys32_delete_module_wrapper: llgtr %r2,%r2 # const char * + llgfr %r3,%r3 # unsigned int jg sys32_delete_module # branch to system call .globl sys32_quotactl_wrapper --- diff/arch/s390/kernel/process.c 2003-09-30 15:46:12.000000000 +0100 +++ source/arch/s390/kernel/process.c 2004-02-23 13:56:39.000000000 +0000 @@ -40,6 +40,9 @@ #include #include #include +#ifdef CONFIG_VIRT_TIMER +#include +#endif asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); @@ -77,6 +80,14 @@ void default_idle(void) return; } +#ifdef CONFIG_VIRT_TIMER + /* + * hook to stop timers that should not tick while CPU is idle + */ + if (stop_timers()) + return; +#endif + /* * Wait for external, I/O or machine check interrupt and * switch off machine check bit after the wait has ended. --- diff/arch/s390/kernel/s390_ext.c 2003-09-30 15:46:12.000000000 +0100 +++ source/arch/s390/kernel/s390_ext.c 2004-02-23 13:56:39.000000000 +0000 @@ -111,6 +111,7 @@ void do_extint(struct pt_regs *regs, uns int index; irq_enter(); + asm volatile ("mc 0,0"); if (S390_lowcore.int_clock >= S390_lowcore.jiffy_timer) account_ticks(regs); kstat_cpu(smp_processor_id()).irqs[EXTERNAL_INTERRUPT]++; --- diff/arch/s390/kernel/s390_ksyms.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/s390/kernel/s390_ksyms.c 2004-02-23 13:56:39.000000000 +0000 @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +19,9 @@ #ifdef CONFIG_IP_MULTICAST #include #endif +#ifdef CONFIG_VIRT_TIMER +#include +#endif /* * memory management @@ -28,6 +32,7 @@ EXPORT_SYMBOL_NOVERS(_zb_findmap); EXPORT_SYMBOL_NOVERS(__copy_from_user_asm); EXPORT_SYMBOL_NOVERS(__copy_to_user_asm); EXPORT_SYMBOL_NOVERS(__clear_user_asm); +EXPORT_SYMBOL(diag10); /* * semaphore ops @@ -53,6 +58,7 @@ EXPORT_SYMBOL_NOVERS(strnlen); EXPORT_SYMBOL_NOVERS(strrchr); EXPORT_SYMBOL_NOVERS(strstr); EXPORT_SYMBOL_NOVERS(strpbrk); +EXPORT_SYMBOL_NOVERS(strcpy); /* * binfmt_elf loader @@ -64,6 +70,17 @@ EXPORT_SYMBOL(overflowgid); EXPORT_SYMBOL(empty_zero_page); /* + * virtual CPU timer + */ +#ifdef CONFIG_VIRT_TIMER +EXPORT_SYMBOL(init_virt_timer); +EXPORT_SYMBOL(add_virt_timer); +EXPORT_SYMBOL(add_virt_timer_periodic); +EXPORT_SYMBOL(mod_virt_timer); +EXPORT_SYMBOL(del_virt_timer); +#endif + +/* * misc. */ EXPORT_SYMBOL(machine_flags); @@ -75,5 +92,5 @@ EXPORT_SYMBOL(console_device); EXPORT_SYMBOL_NOVERS(do_call_softirq); EXPORT_SYMBOL(sys_wait4); EXPORT_SYMBOL(cpcmd); +EXPORT_SYMBOL(smp_call_function_on); EXPORT_SYMBOL(sys_ioctl); - --- diff/arch/s390/kernel/semaphore.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/s390/kernel/semaphore.c 2004-02-23 13:56:39.000000000 +0000 @@ -33,8 +33,9 @@ static inline int __sem_update_count(str " cs %0,%1,0(%3)\n" " jl 0b\n" : "=&d" (old_val), "=&d" (new_val), - "+m" (sem->count) - : "a" (&sem->count), "d" (incr) : "cc" ); + "=m" (sem->count) + : "a" (&sem->count), "d" (incr), "m" (sem->count) + : "cc" ); return old_val; } --- diff/arch/s390/kernel/smp.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/s390/kernel/smp.c 2004-02-23 13:56:39.000000000 +0000 @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -65,7 +66,7 @@ extern char vmpoff_cmd[]; extern void do_reipl(unsigned long devno); -static sigp_ccode smp_ext_bitcall(int, ec_bit_sig); +static void smp_ext_bitcall(int, ec_bit_sig); static void smp_ext_bitcall_others(ec_bit_sig); /* @@ -150,6 +151,59 @@ int smp_call_function (void (*func) (voi return 0; } +/* + * Call a function on one CPU + * cpu : the CPU the function should be executed on + * + * You must not call this function with disabled interrupts or from a + * hardware interrupt handler. You may call it from a bottom half. + * + * It is guaranteed that the called function runs on the specified CPU, + * preemption is disabled. + */ +int smp_call_function_on(void (*func) (void *info), void *info, + int nonatomic, int wait, int cpu) +{ + struct call_data_struct data; + int curr_cpu; + + if (!cpu_online(cpu)) + return -EINVAL; + + /* disable preemption for local function call */ + curr_cpu = get_cpu(); + + if (curr_cpu == cpu) { + /* direct call to function */ + func(info); + put_cpu(); + 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; + smp_ext_bitcall(cpu, ec_call_function); + + /* Wait for response */ + while (atomic_read(&data.started) != 1) + cpu_relax(); + + if (wait) + while (atomic_read(&data.finished) != 1) + cpu_relax(); + + spin_unlock_bh(&call_lock); + put_cpu(); + return 0; +} + static inline void do_send_stop(void) { u32 dummy; @@ -305,16 +359,14 @@ void do_ext_call_interrupt(struct pt_reg * Send an external call sigp to another cpu and return without waiting * for its completion. */ -static sigp_ccode smp_ext_bitcall(int cpu, ec_bit_sig sig) +static void smp_ext_bitcall(int cpu, ec_bit_sig sig) { - sigp_ccode ccode; - /* * Set signaling bit in lowcore of target cpu and kick it */ set_bit(sig, (unsigned long *) &lowcore_ptr[cpu]->ext_call_fast); - ccode = signal_processor(cpu, sigp_external_call); - return ccode; + while(signal_processor(cpu, sigp_external_call) == sigp_busy) + udelay(10); } /* @@ -350,6 +402,7 @@ void smp_ptlb_all(void) { on_each_cpu(smp_ptlb_callback, NULL, 0, 1); } +EXPORT_SYMBOL(smp_ptlb_all); #endif /* ! CONFIG_ARCH_S390X */ /* --- diff/arch/s390/kernel/sys_s390.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/s390/kernel/sys_s390.c 2004-02-23 13:56:39.000000000 +0000 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -125,8 +126,6 @@ out: return error; } -extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); - #ifndef CONFIG_ARCH_S390X struct sel_arg_struct { unsigned long n; @@ -290,15 +289,13 @@ asmlinkage int sys_olduname(struct oldol return error; } -asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on) +asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int on) { return -ENOSYS; } #else /* CONFIG_ARCH_S390X */ -extern asmlinkage int sys_newuname(struct new_utsname * name); - asmlinkage int s390x_newuname(struct new_utsname * name) { int ret = sys_newuname(name); @@ -310,8 +307,6 @@ asmlinkage int s390x_newuname(struct new return ret; } -extern asmlinkage long sys_personality(unsigned long); - asmlinkage int s390x_personality(unsigned long personality) { int ret; @@ -331,8 +326,6 @@ asmlinkage int s390x_personality(unsigne */ #ifndef CONFIG_ARCH_S390X -extern asmlinkage long sys_fadvise64(int, loff_t, size_t, int); - asmlinkage long s390_fadvise64(int fd, u32 offset_high, u32 offset_low, size_t len, int advice) { @@ -342,8 +335,6 @@ s390_fadvise64(int fd, u32 offset_high, #endif -extern asmlinkage long sys_fadvise64_64(int, loff_t, loff_t, int); - struct fadvise64_64_args { int fd; long long offset; --- diff/arch/s390/kernel/time.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/s390/kernel/time.c 2004-02-23 13:56:39.000000000 +0000 @@ -24,16 +24,17 @@ #include #include #include +#include +#include #include #include #include #include - -#include -#include - #include +#ifdef CONFIG_VIRT_TIMER +#include +#endif /* change this if you have some constant time drift */ #define USECS_PER_JIFFY ((unsigned long) 1000000/HZ) @@ -51,19 +52,25 @@ u64 jiffies_64 = INITIAL_JIFFIES; EXPORT_SYMBOL(jiffies_64); -static ext_int_info_t ext_int_info_timer; +static ext_int_info_t ext_int_info_cc; static u64 init_timer_cc; static u64 jiffies_timer_cc; static u64 xtime_cc; extern unsigned long wall_jiffies; +#ifdef CONFIG_VIRT_TIMER +#define VTIMER_MAGIC (0x4b87ad6e + 1) +static ext_int_info_t ext_int_info_timer; +DEFINE_PER_CPU(struct vtimer_queue, virt_cpu_timer); +#endif + /* * Scheduler clock - returns current time in nanosec units. */ unsigned long long sched_clock(void) { - return (get_clock() - jiffies_timer_cc) >> 2; + return ((get_clock() - jiffies_timer_cc) * 1000) >> 12; } void tod_to_timeval(__u64 todval, struct timespec *xtime) @@ -142,6 +149,7 @@ int do_settimeofday(struct timespec *tv) time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; write_sequnlock_irq(&xtime_lock); + clock_was_set(); return 0; } @@ -225,13 +233,208 @@ void account_ticks(struct pt_regs *regs) #endif } +#ifdef CONFIG_VIRT_TIMER +void start_cpu_timer(void) +{ + struct vtimer_queue *vt_list; + + vt_list = &per_cpu(virt_cpu_timer, smp_processor_id()); + set_vtimer(vt_list->idle); +} + +int stop_cpu_timer(void) +{ + __u64 done; + struct vtimer_queue *vt_list; + + vt_list = &per_cpu(virt_cpu_timer, smp_processor_id()); + + /* nothing to do */ + if (list_empty(&vt_list->list)) { + vt_list->idle = VTIMER_MAX_SLICE; + goto fire; + } + + /* store progress */ + asm volatile ("STPT %0" : "=m" (done)); + + /* + * If done is negative we do not stop the CPU timer + * because we will get instantly an interrupt that + * will start the CPU timer again. + */ + if (done & 1LL<<63) + return 1; + else + vt_list->offset += vt_list->to_expire - done; + + /* save the actual expire value */ + vt_list->idle = done; + + /* + * We cannot halt the CPU timer, we just write a value that + * nearly never expires (only after 71 years) and re-write + * the stored expire value if we continue the timer + */ + fire: + set_vtimer(VTIMER_MAX_SLICE); + return 0; +} + +void do_monitor_call(struct pt_regs *regs, long interruption_code) +{ + /* disable monitor call class 0 */ + __ctl_clear_bit(8, 15); + + start_cpu_timer(); +} + +/* + * called from cpu_idle to stop any timers + * returns 1 if CPU should not be stopped + */ +int stop_timers(void) +{ + if (stop_cpu_timer()) + return 1; + + /* enable monitor call class 0 */ + __ctl_set_bit(8, 15); + + return 0; +} + +void set_vtimer(__u64 expires) +{ + asm volatile ("SPT %0" : : "m" (expires)); + + /* store expire time for this CPU timer */ + per_cpu(virt_cpu_timer, smp_processor_id()).to_expire = expires; +} + +/* + * Sorted add to a list. List is linear searched until first bigger + * element is found. + */ +void list_add_sorted(struct vtimer_list *timer, struct list_head *head) +{ + struct vtimer_list *event; + + list_for_each_entry(event, head, entry) { + if (event->expires > timer->expires) { + list_add_tail(&timer->entry, &event->entry); + return; + } + } + list_add_tail(&timer->entry, head); +} + /* - * Start the clock comparator on the current CPU. + * Do the callback functions of expired vtimer events. + * Called from within the interrupt handler. + */ +static void do_callbacks(struct list_head *cb_list, struct pt_regs *regs) +{ + struct vtimer_queue *vt_list; + struct vtimer_list *event, *tmp; + void (*fn)(unsigned long, struct pt_regs*); + unsigned long data; + + if (list_empty(cb_list)) + return; + + vt_list = &per_cpu(virt_cpu_timer, smp_processor_id()); + + list_for_each_entry_safe(event, tmp, cb_list, entry) { + fn = event->function; + data = event->data; + fn(data, regs); + + if (!event->interval) + /* delete one shot timer */ + list_del_init(&event->entry); + else { + /* move interval timer back to list */ + spin_lock(&vt_list->lock); + list_del_init(&event->entry); + list_add_sorted(event, &vt_list->list); + spin_unlock(&vt_list->lock); + } + } +} + +/* + * Handler for the virtual CPU timer. + */ +static void do_cpu_timer_interrupt(struct pt_regs *regs, __u16 error_code) +{ + int cpu; + __u64 next, delta; + struct vtimer_queue *vt_list; + struct vtimer_list *event, *tmp; + struct list_head *ptr; + /* the callback queue */ + struct list_head cb_list; + + INIT_LIST_HEAD(&cb_list); + cpu = smp_processor_id(); + vt_list = &per_cpu(virt_cpu_timer, cpu); + + /* walk timer list, fire all expired events */ + spin_lock(&vt_list->lock); + + if (vt_list->to_expire < VTIMER_MAX_SLICE) + vt_list->offset += vt_list->to_expire; + + list_for_each_entry_safe(event, tmp, &vt_list->list, entry) { + if (event->expires > vt_list->offset) + /* found first unexpired event, leave */ + break; + + /* re-charge interval timer, we have to add the offset */ + if (event->interval) + event->expires = event->interval + vt_list->offset; + + /* move expired timer to the callback queue */ + list_move_tail(&event->entry, &cb_list); + } + spin_unlock(&vt_list->lock); + do_callbacks(&cb_list, regs); + + /* next event is first in list */ + spin_lock(&vt_list->lock); + if (!list_empty(&vt_list->list)) { + ptr = vt_list->list.next; + event = list_entry(ptr, struct vtimer_list, entry); + next = event->expires - vt_list->offset; + + /* add the expired time from this interrupt handler + * and the callback functions + */ + asm volatile ("STPT %0" : "=m" (delta)); + delta = 0xffffffffffffffffLL - delta + 1; + vt_list->offset += delta; + next -= delta; + } else { + vt_list->offset = 0; + next = VTIMER_MAX_SLICE; + } + spin_unlock(&vt_list->lock); + set_vtimer(next); +} +#endif + +/* + * Start the clock comparator and the virtual CPU timer + * on the current CPU. */ void init_cpu_timer(void) { unsigned long cr0; __u64 timer; +#ifdef CONFIG_VIRT_TIMER + struct vtimer_queue *vt_list; +#endif timer = jiffies_timer_cc + jiffies_64 * CLK_TICKS_PER_JIFFY; S390_lowcore.jiffy_timer = timer + CLK_TICKS_PER_JIFFY; @@ -241,6 +444,22 @@ void init_cpu_timer(void) __ctl_store(cr0, 0, 0); cr0 |= 0x800; __ctl_load(cr0, 0, 0); + +#ifdef CONFIG_VIRT_TIMER + /* kick the virtual timer */ + timer = VTIMER_MAX_SLICE; + asm volatile ("SPT %0" : : "m" (timer)); + __ctl_store(cr0, 0, 0); + cr0 |= 0x400; + __ctl_load(cr0, 0, 0); + + vt_list = &per_cpu(virt_cpu_timer, smp_processor_id()); + INIT_LIST_HEAD(&vt_list->list); + spin_lock_init(&vt_list->lock); + vt_list->to_expire = 0; + vt_list->offset = 0; + vt_list->idle = 0; +#endif } /* @@ -280,11 +499,252 @@ void __init time_init(void) set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec); - /* request the 0x1004 external interrupt */ + /* request the clock comparator external interrupt */ if (register_early_external_interrupt(0x1004, 0, - &ext_int_info_timer) != 0) + &ext_int_info_cc) != 0) panic("Couldn't request external interrupt 0x1004"); - /* init CPU timer */ +#ifdef CONFIG_VIRT_TIMER + /* request the cpu timer external interrupt */ + if (register_early_external_interrupt(0x1005, do_cpu_timer_interrupt, + &ext_int_info_timer) != 0) + panic("Couldn't request external interrupt 0x1005"); +#endif + init_cpu_timer(); } + +#ifdef CONFIG_VIRT_TIMER +void init_virt_timer(struct vtimer_list *timer) +{ + timer->magic = VTIMER_MAGIC; + timer->function = NULL; + INIT_LIST_HEAD(&timer->entry); + spin_lock_init(&timer->lock); +} + +static inline int check_vtimer(struct vtimer_list *timer) +{ + if (timer->magic != VTIMER_MAGIC) + return -EINVAL; + return 0; +} + +static inline int vtimer_pending(struct vtimer_list *timer) +{ + return (!list_empty(&timer->entry)); +} + +/* + * this function should only run on the specified CPU + */ +static void internal_add_vtimer(struct vtimer_list *timer) +{ + unsigned long flags; + __u64 done; + struct vtimer_list *event; + struct vtimer_queue *vt_list; + + vt_list = &per_cpu(virt_cpu_timer, timer->cpu); + spin_lock_irqsave(&vt_list->lock, flags); + + if (timer->cpu != smp_processor_id()) + printk("internal_add_vtimer: BUG, running on wrong CPU"); + + /* if list is empty we only have to set the timer */ + if (list_empty(&vt_list->list)) { + /* reset the offset, this may happen if the last timer was + * just deleted by mod_virt_timer and the interrupt + * didn't happen until here + */ + vt_list->offset = 0; + goto fire; + } + + /* save progress */ + asm volatile ("STPT %0" : "=m" (done)); + + /* calculate completed work */ + done = vt_list->to_expire - done + vt_list->offset; + vt_list->offset = 0; + + list_for_each_entry(event, &vt_list->list, entry) + event->expires -= done; + + fire: + list_add_sorted(timer, &vt_list->list); + + /* get first element, which is the next vtimer slice */ + event = list_entry(vt_list->list.next, struct vtimer_list, entry); + + set_vtimer(event->expires); + spin_unlock_irqrestore(&vt_list->lock, flags); + /* release CPU aquired in prepare_vtimer or mod_virt_timer() */ + put_cpu(); +} + +static inline int prepare_vtimer(struct vtimer_list *timer) +{ + if (check_vtimer(timer) || !timer->function) { + printk("add_virt_timer: uninitialized timer\n"); + return -EINVAL; + } + + if (!timer->expires || timer->expires > VTIMER_MAX_SLICE) { + printk("add_virt_timer: invalid timer expire value!\n"); + return -EINVAL; + } + + if (vtimer_pending(timer)) { + printk("add_virt_timer: timer pending\n"); + return -EBUSY; + } + + timer->cpu = get_cpu(); + return 0; +} + +/* + * add_virt_timer - add an oneshot virtual CPU timer + */ +void add_virt_timer(void *new) +{ + struct vtimer_list *timer; + + timer = (struct vtimer_list *)new; + + if (prepare_vtimer(timer) < 0) + return; + + timer->interval = 0; + internal_add_vtimer(timer); +} + +/* + * add_virt_timer_int - add an interval virtual CPU timer + */ +void add_virt_timer_periodic(void *new) +{ + struct vtimer_list *timer; + + timer = (struct vtimer_list *)new; + + if (prepare_vtimer(timer) < 0) + return; + + timer->interval = timer->expires; + internal_add_vtimer(timer); +} + +/* + * If we change a pending timer the function must be called on the CPU + * where the timer is running on, e.g. by smp_call_function_on() + * + * The original mod_timer adds the timer if it is not pending. For compatibility + * we do the same. The timer will be added on the current CPU as a oneshot timer. + * + * returns whether it has modified a pending timer (1) or not (0) + */ +int mod_virt_timer(struct vtimer_list *timer, __u64 expires) +{ + struct vtimer_queue *vt_list; + unsigned long flags; + int cpu; + + if (check_vtimer(timer) || !timer->function) { + printk("mod_virt_timer: uninitialized timer\n"); + return -EINVAL; + } + + if (!expires || expires > VTIMER_MAX_SLICE) { + printk("mod_virt_timer: invalid expire range\n"); + return -EINVAL; + } + + /* + * This is a common optimization triggered by the + * networking code - if the timer is re-modified + * to be the same thing then just return: + */ + if (timer->expires == expires && vtimer_pending(timer)) + return 1; + + cpu = get_cpu(); + vt_list = &per_cpu(virt_cpu_timer, cpu); + + /* disable interrupts before test if timer is pending */ + spin_lock_irqsave(&vt_list->lock, flags); + + /* if timer isn't pending add it on the current CPU */ + if (!vtimer_pending(timer)) { + spin_unlock_irqrestore(&vt_list->lock, flags); + /* we do not activate an interval timer with mod_virt_timer */ + timer->interval = 0; + timer->expires = expires; + timer->cpu = cpu; + internal_add_vtimer(timer); + return 0; + } + + /* check if we run on the right CPU */ + if (timer->cpu != cpu) { + printk("mod_virt_timer: running on wrong CPU, check your code\n"); + spin_unlock_irqrestore(&vt_list->lock, flags); + put_cpu(); + return -EINVAL; + } + + list_del_init(&timer->entry); + timer->expires = expires; + + /* also change the interval if we have an interval timer */ + if (timer->interval) + timer->interval = expires; + + /* the timer can't expire anymore so we can release the lock */ + spin_unlock_irqrestore(&vt_list->lock, flags); + internal_add_vtimer(timer); + return 1; +} + +/* + * delete a virtual timer + * + * returns whether the deleted timer was pending (1) or not (0) + */ +int del_virt_timer(struct vtimer_list *timer) +{ + unsigned long flags; + struct vtimer_queue *vt_list; + + if (check_vtimer(timer)) { + printk("del_virt_timer: timer not initialized\n"); + return -EINVAL; + } + + /* check if timer is pending */ + if (!vtimer_pending(timer)) + return 0; + + if (!cpu_online(timer->cpu)) { + printk("del_virt_timer: CPU not present!\n"); + return -1; + } + + vt_list = &per_cpu(virt_cpu_timer, timer->cpu); + spin_lock_irqsave(&vt_list->lock, flags); + + /* we don't interrupt a running timer, just let it expire! */ + list_del_init(&timer->entry); + + /* last timer removed */ + if (list_empty(&vt_list->list)) { + vt_list->to_expire = 0; + vt_list->offset = 0; + } + + spin_unlock_irqrestore(&vt_list->lock, flags); + return 1; +} +#endif + --- diff/arch/s390/kernel/traps.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/s390/kernel/traps.c 2004-02-23 13:56:39.000000000 +0000 @@ -64,6 +64,9 @@ extern void pfault_fini(void); extern void pfault_interrupt(struct pt_regs *regs, __u16 error_code); static ext_int_info_t ext_int_pfault; #endif +#ifdef CONFIG_VIRT_TIMER +extern pgm_check_handler_t do_monitor_call; +#endif #define stack_pointer ({ void **sp; asm("la %0,0(15)" : "=&d" (sp)); sp; }) @@ -625,6 +628,9 @@ void __init trap_init(void) #endif /* CONFIG_ARCH_S390X */ pgm_check_table[0x15] = &operand_exception; pgm_check_table[0x1C] = &privileged_op; +#ifdef CONFIG_VIRT_TIMER + pgm_check_table[0x40] = &do_monitor_call; +#endif if (MACHINE_IS_VM) { /* * First try to get pfault pseudo page faults going. --- diff/arch/s390/lib/Makefile 2003-06-30 10:07:19.000000000 +0100 +++ source/arch/s390/lib/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -5,5 +5,5 @@ EXTRA_AFLAGS := -traditional lib-y += delay.o -lib-$(CONFIG_ARCH_S390_31) += memset.o strcmp.o strncpy.o uaccess.o -lib-$(CONFIG_ARCH_S390X) += memset64.o strcmp64.o strncpy64.o uaccess64.o +lib-$(CONFIG_ARCH_S390_31) += memset.o strcmp.o strcpy.o strncpy.o uaccess.o +lib-$(CONFIG_ARCH_S390X) += memset64.o strcmp64.o strcpy64.o strncpy64.o uaccess64.o --- diff/arch/s390/lib/strncpy.S 2002-10-16 04:28:25.000000000 +0100 +++ source/arch/s390/lib/strncpy.S 2004-02-23 13:56:39.000000000 +0000 @@ -23,8 +23,13 @@ strncpy_loop: LA 3,1(3) STC 0,0(1) LA 1,1(1) - JZ strncpy_exit # ICM inserted a 0x00 + JZ strncpy_pad # ICM inserted a 0x00 BRCT 4,strncpy_loop # R4 -= 1, jump to strncpy_loop if > 0 strncpy_exit: BR 14 - +strncpy_clear: + STC 0,0(1) + LA 1,1(1) +strncpy_pad: + BRCT 4,strncpy_clear + BR 14 --- diff/arch/s390/lib/strncpy64.S 2003-05-21 11:50:08.000000000 +0100 +++ source/arch/s390/lib/strncpy64.S 2004-02-23 13:56:39.000000000 +0000 @@ -23,8 +23,13 @@ strncpy_loop: LA 3,1(3) STC 0,0(1) LA 1,1(1) - JZ strncpy_exit # ICM inserted a 0x00 + JZ strncpy_pad # ICM inserted a 0x00 BRCTG 4,strncpy_loop # R4 -= 1, jump to strncpy_loop if > 0 strncpy_exit: BR 14 - +strncpy_clear: + STC 0,0(1) + LA 1,1(1) +strncpy_pad: + BRCTG 4,strncpy_clear + BR 14 --- diff/arch/s390/math-emu/math.c 2003-06-09 14:18:18.000000000 +0100 +++ source/arch/s390/math-emu/math.c 2004-02-23 13:56:39.000000000 +0000 @@ -99,7 +99,6 @@ int sysctl_ieee_emulation_warnings=1; static void display_emulation_not_implemented(struct pt_regs *regs, char *instr) { - struct pt_regs *regs; __u16 *location; #ifdef CONFIG_SYSCTL --- diff/arch/s390/mm/Makefile 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/s390/mm/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -2,4 +2,6 @@ # Makefile for the linux s390-specific parts of the memory manager. # -obj-y := init.o fault.o ioremap.o +obj-y := init.o fault.o ioremap.o extmem.o +obj-$(CONFIG_CMM) += cmm.o + --- diff/arch/s390/mm/init.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/s390/mm/init.c 2004-02-23 13:56:39.000000000 +0000 @@ -40,6 +40,19 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_ga pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE))); char empty_zero_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); +void diag10(unsigned long addr) +{ +#ifdef __s390x__ + if (addr >= 0x80000000) + return; + asm volatile ("sam31\n\t" + "diag %0,%0,0x10\n\t" + "sam64" : : "a" (addr) ); +#else + asm volatile ("diag %0,%0,0x10" : : "a" (addr) ); +#endif +} + void show_mem(void) { int i, total = 0, reserved = 0; --- diff/arch/sh/Kconfig 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/sh/Kconfig 2004-02-23 13:56:39.000000000 +0000 @@ -609,24 +609,6 @@ source "arch/sh/drivers/pci/Kconfig" source "drivers/pci/Kconfig" -config HOTPLUG - bool "Support for hot-pluggable devices" - ---help--- - Say Y here if you want to plug devices into your computer while - the system is running, and be able to use them quickly. In many - cases, the devices can likewise be unplugged at any time too. - - One well known example of this is PCMCIA- or PC-cards, credit-card - size devices such as network cards, modems or hard drives which are - plugged into slots found on all modern laptop computers. Another - example, used on modern desktops as well as laptops, is USB. - - Enable HOTPLUG and KMOD, and build a modular kernel. Get agent - software (at ) and install it. - Then your kernel will automatically call out to a user mode "policy - agent" (/sbin/hotplug) to load modules and set up software needed - to use devices as you hotplug them. - source "drivers/pcmcia/Kconfig" source "drivers/pci/hotplug/Kconfig" --- diff/arch/sh/kernel/sys_sh.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/sh/kernel/sys_sh.c 2004-02-23 13:56:39.000000000 +0000 @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -240,16 +241,12 @@ asmlinkage int sys_uname(struct old_utsn asmlinkage ssize_t sys_pread_wrapper(unsigned int fd, char * buf, size_t count, long dummy, loff_t pos) { - extern asmlinkage ssize_t sys_pread64(unsigned int fd, char * buf, - size_t count, loff_t pos); return sys_pread64(fd, buf, count, pos); } asmlinkage ssize_t sys_pwrite_wrapper(unsigned int fd, const char * buf, size_t count, long dummy, loff_t pos) { - extern asmlinkage ssize_t sys_pwrite64(unsigned int fd, const char * buf, - size_t count, loff_t pos); return sys_pwrite64(fd, buf, count, pos); } --- diff/arch/sparc/Makefile 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/sparc/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -11,21 +11,12 @@ # Uncomment the first CFLAGS if you are doing kgdb source level # debugging of the kernel to get the proper debugging information. -IS_EGCS := $(shell if $(CC) -m32 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo y; else echo n; fi; ) -NEW_GAS := $(shell if $(LD) --version 2>&1 | grep 'elf64_sparc' > /dev/null; then echo y; else echo n; fi) - -ifeq ($(NEW_GAS),y) AS := $(AS) -32 LDFLAGS := -m elf32_sparc -endif #CFLAGS := $(CFLAGS) -g -pipe -fcall-used-g5 -fcall-used-g7 -ifneq ($(IS_EGCS),y) -CFLAGS := $(CFLAGS) -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 -else CFLAGS := $(CFLAGS) -m32 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 AFLAGS := $(AFLAGS) -m32 -endif #LDFLAGS_vmlinux = -N -Ttext 0xf0004000 # Since 2.5.40, the first stage is left not btfix-ed. --- diff/arch/sparc/kernel/entry.S 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/sparc/kernel/entry.S 2004-02-23 13:56:39.000000000 +0000 @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -68,8 +67,8 @@ in_trap_handler: ! available before jumping into C code. It will also restore the world if you ! return from handle_exception. - .globl C_LABEL(trap_low) -C_LABEL(trap_low): + .globl trap_low +trap_low: rd %wim, %l3 SAVE_ALL @@ -104,7 +103,7 @@ C_LABEL(trap_low): wr %l0, PSR_ET, %psr WRITE_PAUSE - call C_LABEL(handle_exception) + call handle_exception add %sp, STACKFRAME_SZ, %o0 ! Pass address of registers /* Load new kgdb register set. */ @@ -134,8 +133,8 @@ C_LABEL(trap_low): #ifdef CONFIG_BLK_DEV_FD .text .align 4 - .globl C_LABEL(floppy_hardint) -C_LABEL(floppy_hardint): + .globl floppy_hardint +floppy_hardint: /* * This code cannot touch registers %l0 %l1 and %l2 * because SAVE_ALL depends on their values. It depends @@ -149,21 +148,21 @@ C_LABEL(floppy_hardint): */ /* Do we have work to do? */ - sethi %hi(C_LABEL(doing_pdma)), %l7 - ld [%l7 + %lo(C_LABEL(doing_pdma))], %l7 + sethi %hi(doing_pdma), %l7 + ld [%l7 + %lo(doing_pdma)], %l7 cmp %l7, 0 be floppy_dosoftint nop /* Load fdc register base */ - sethi %hi(C_LABEL(fdc_status)), %l3 - ld [%l3 + %lo(C_LABEL(fdc_status))], %l3 + sethi %hi(fdc_status), %l3 + ld [%l3 + %lo(fdc_status)], %l3 /* Setup register addresses */ - sethi %hi(C_LABEL(pdma_vaddr)), %l5 ! transfer buffer - ld [%l5 + %lo(C_LABEL(pdma_vaddr))], %l4 - sethi %hi(C_LABEL(pdma_size)), %l5 ! bytes to go - ld [%l5 + %lo(C_LABEL(pdma_size))], %l6 + sethi %hi(pdma_vaddr), %l5 ! transfer buffer + ld [%l5 + %lo(pdma_vaddr)], %l4 + sethi %hi(pdma_size), %l5 ! bytes to go + ld [%l5 + %lo(pdma_size)], %l6 next_byte: ldub [%l3], %l7 @@ -195,15 +194,15 @@ floppy_write: /* fall through... */ floppy_tdone: - sethi %hi(C_LABEL(pdma_vaddr)), %l5 - st %l4, [%l5 + %lo(C_LABEL(pdma_vaddr))] - sethi %hi(C_LABEL(pdma_size)), %l5 - st %l6, [%l5 + %lo(C_LABEL(pdma_size))] + sethi %hi(pdma_vaddr), %l5 + st %l4, [%l5 + %lo(pdma_vaddr)] + sethi %hi(pdma_size), %l5 + st %l6, [%l5 + %lo(pdma_size)] /* Flip terminal count pin */ - set C_LABEL(auxio_register), %l7 + set auxio_register, %l7 ld [%l7], %l7 - set C_LABEL(sparc_cpu_model), %l5 + set sparc_cpu_model, %l5 ld [%l5], %l5 subcc %l5, 1, %g0 /* enum { sun4c = 1 }; */ be 1f @@ -228,9 +227,9 @@ floppy_tdone: stb %l5, [%l7] /* Prevent recursion */ - sethi %hi(C_LABEL(doing_pdma)), %l7 + sethi %hi(doing_pdma), %l7 b floppy_dosoftint - st %g0, [%l7 + %lo(C_LABEL(doing_pdma))] + st %g0, [%l7 + %lo(doing_pdma)] /* We emptied the FIFO, but we haven't read everything * as of yet. Store the current transfer address and @@ -238,10 +237,10 @@ floppy_tdone: * fast IRQ comes in. */ floppy_fifo_emptied: - sethi %hi(C_LABEL(pdma_vaddr)), %l5 - st %l4, [%l5 + %lo(C_LABEL(pdma_vaddr))] - sethi %hi(C_LABEL(pdma_size)), %l7 - st %l6, [%l7 + %lo(C_LABEL(pdma_size))] + sethi %hi(pdma_vaddr), %l5 + st %l4, [%l5 + %lo(pdma_vaddr)] + sethi %hi(pdma_size), %l7 + st %l6, [%l7 + %lo(pdma_size)] /* Restore condition codes */ wr %l0, 0x0, %psr @@ -251,13 +250,13 @@ floppy_fifo_emptied: rett %l2 floppy_overrun: - sethi %hi(C_LABEL(pdma_vaddr)), %l5 - st %l4, [%l5 + %lo(C_LABEL(pdma_vaddr))] - sethi %hi(C_LABEL(pdma_size)), %l5 - st %l6, [%l5 + %lo(C_LABEL(pdma_size))] + sethi %hi(pdma_vaddr), %l5 + st %l4, [%l5 + %lo(pdma_vaddr)] + sethi %hi(pdma_size), %l5 + st %l6, [%l5 + %lo(pdma_size)] /* Prevent recursion */ - sethi %hi(C_LABEL(doing_pdma)), %l7 - st %g0, [%l7 + %lo(C_LABEL(doing_pdma))] + sethi %hi(doing_pdma), %l7 + st %g0, [%l7 + %lo(doing_pdma)] /* fall through... */ floppy_dosoftint: @@ -273,7 +272,7 @@ floppy_dosoftint: mov 11, %o0 ! floppy irq level (unused anyway) mov %g0, %o1 ! devid is not used in fast interrupts - call C_LABEL(sparc_floppy_irq) + call sparc_floppy_irq add %sp, STACKFRAME_SZ, %o2 ! struct pt_regs *regs RESTORE_ALL @@ -290,7 +289,7 @@ bad_trap_handler: mov %l7, %o0 ! trap number mov %l0, %o1 ! psr - call C_LABEL(do_hw_interrupt) + call do_hw_interrupt mov %l1, %o2 ! pc RESTORE_ALL @@ -322,7 +321,7 @@ real_irq_continue: WRITE_PAUSE mov %l7, %o0 ! irq level patch_handler_irq: - call C_LABEL(handler_irq) + call handler_irq add %sp, STACKFRAME_SZ, %o1 ! pt_regs ptr or %l0, PSR_PIL, %g2 ! restore PIL after handler_irq wr %g2, PSR_ET, %psr ! keep ET up @@ -339,7 +338,7 @@ smp4m_ticker: WRITE_PAUSE wr %g2, PSR_ET, %psr WRITE_PAUSE - call C_LABEL(smp4m_percpu_timer_interrupt) + call smp4m_percpu_timer_interrupt add %sp, STACKFRAME_SZ, %o0 wr %l0, PSR_ET, %psr WRITE_PAUSE @@ -351,7 +350,7 @@ smp4m_ticker: */ maybe_smp4m_msg: GET_PROCESSOR_MID(o3, o2) - set C_LABEL(sun4m_interrupts), %l5 + set sun4m_interrupts, %l5 ld [%l5], %o5 sethi %hi(0x60000000), %o4 sll %o3, 12, %o3 @@ -378,10 +377,10 @@ maybe_smp4m_msg: tst %o2 bne 2f nop - call C_LABEL(smp_reschedule_irq) + call smp_reschedule_irq add %o7, 8, %o7 2: - call C_LABEL(smp_stop_cpu_irq) + call smp_stop_cpu_irq nop RESTORE_ALL @@ -391,7 +390,7 @@ linux_trap_ipi15_sun4m: SAVE_ALL sethi %hi(0x80000000), %o2 GET_PROCESSOR_MID(o0, o1) - set C_LABEL(sun4m_interrupts), %l5 + set sun4m_interrupts, %l5 ld [%l5], %o5 sll %o0, 12, %o0 add %o5, %o0, %o5 @@ -407,7 +406,7 @@ linux_trap_ipi15_sun4m: WRITE_PAUSE wr %l4, PSR_ET, %psr WRITE_PAUSE - call C_LABEL(smp4m_cross_call_irq) + call smp4m_cross_call_irq nop b ret_trap_lockless_ipi clr %l6 @@ -426,7 +425,7 @@ linux_trap_ipi15_sun4m: WRITE_PAUSE wr %l4, PSR_ET, %psr WRITE_PAUSE - call C_LABEL(sun4m_nmi) + call sun4m_nmi nop st %l4, [%l5 + 0x8] WRITE_PAUSE @@ -447,7 +446,7 @@ smp4d_ticker: WRITE_PAUSE wr %g2, PSR_ET, %psr WRITE_PAUSE - call C_LABEL(smp4d_percpu_timer_interrupt) + call smp4d_percpu_timer_interrupt add %sp, STACKFRAME_SZ, %o0 wr %l0, PSR_ET, %psr WRITE_PAUSE @@ -475,7 +474,7 @@ linux_trap_ipi15_sun4d: WRITE_PAUSE wr %l4, PSR_ET, %psr WRITE_PAUSE - call C_LABEL(smp4d_cross_call_irq) + call smp4d_cross_call_irq nop b ret_trap_lockless_ipi clr %l6 @@ -513,7 +512,7 @@ bad_instruction: add %sp, STACKFRAME_SZ, %o0 mov %l1, %o1 mov %l2, %o2 - call C_LABEL(do_illegal_instruction) + call do_illegal_instruction mov %l0, %o3 RESTORE_ALL @@ -533,7 +532,7 @@ priv_instruction: add %sp, STACKFRAME_SZ, %o0 mov %l1, %o1 mov %l2, %o2 - call C_LABEL(do_priv_instruction) + call do_priv_instruction mov %l0, %o3 RESTORE_ALL @@ -552,7 +551,7 @@ mna_handler: WRITE_PAUSE ld [%l1], %o1 - call C_LABEL(kernel_unaligned_trap) + call kernel_unaligned_trap add %sp, STACKFRAME_SZ, %o0 RESTORE_ALL @@ -564,7 +563,7 @@ mna_fromuser: WRITE_PAUSE ld [%l1], %o1 - call C_LABEL(user_unaligned_trap) + call user_unaligned_trap add %sp, STACKFRAME_SZ, %o0 RESTORE_ALL @@ -581,7 +580,7 @@ fpd_trap_handler: add %sp, STACKFRAME_SZ, %o0 mov %l1, %o1 mov %l2, %o2 - call C_LABEL(do_fpd_trap) + call do_fpd_trap mov %l0, %o3 RESTORE_ALL @@ -593,8 +592,8 @@ fpe_trap_handler: set fpsave_magic, %l5 cmp %l1, %l5 be 1f - sethi %hi(C_LABEL(fpsave)), %l5 - or %l5, %lo(C_LABEL(fpsave)), %l5 + sethi %hi(fpsave), %l5 + or %l5, %lo(fpsave), %l5 cmp %l1, %l5 bne 2f sethi %hi(fpsave_catch2), %l5 @@ -620,7 +619,7 @@ fpe_trap_handler: add %sp, STACKFRAME_SZ, %o0 mov %l1, %o1 mov %l2, %o2 - call C_LABEL(do_fpe_trap) + call do_fpe_trap mov %l0, %o3 RESTORE_ALL @@ -637,7 +636,7 @@ do_tag_overflow: add %sp, STACKFRAME_SZ, %o0 mov %l1, %o1 mov %l2, %o2 - call C_LABEL(handle_tag_overflow) + call handle_tag_overflow mov %l0, %o3 RESTORE_ALL @@ -654,7 +653,7 @@ do_watchpoint: add %sp, STACKFRAME_SZ, %o0 mov %l1, %o1 mov %l2, %o2 - call C_LABEL(handle_watchpoint) + call handle_watchpoint mov %l0, %o3 RESTORE_ALL @@ -671,7 +670,7 @@ do_reg_access: add %sp, STACKFRAME_SZ, %o0 mov %l1, %o1 mov %l2, %o2 - call C_LABEL(handle_reg_access) + call handle_reg_access mov %l0, %o3 RESTORE_ALL @@ -688,7 +687,7 @@ do_cp_disabled: add %sp, STACKFRAME_SZ, %o0 mov %l1, %o1 mov %l2, %o2 - call C_LABEL(handle_cp_disabled) + call handle_cp_disabled mov %l0, %o3 RESTORE_ALL @@ -705,7 +704,7 @@ do_cp_exception: add %sp, STACKFRAME_SZ, %o0 mov %l1, %o1 mov %l2, %o2 - call C_LABEL(handle_cp_exception) + call handle_cp_exception mov %l0, %o3 RESTORE_ALL @@ -722,7 +721,7 @@ do_hw_divzero: add %sp, STACKFRAME_SZ, %o0 mov %l1, %o1 mov %l2, %o2 - call C_LABEL(handle_hw_divzero) + call handle_hw_divzero mov %l0, %o3 RESTORE_ALL @@ -739,7 +738,7 @@ do_flush_windows: bne dfw_kernel nop - call C_LABEL(flush_user_windows) + call flush_user_windows nop /* Advance over the trap instruction. */ @@ -805,8 +804,8 @@ linux_trap_nmi_sun4c: /* Ugh, we need to clear the IRQ line. This is now * a very sun4c specific trap handler... */ - sethi %hi(C_LABEL(interrupt_enable)), %l5 - ld [%l5 + %lo(C_LABEL(interrupt_enable))], %l5 + sethi %hi(interrupt_enable), %l5 + ld [%l5 + %lo(interrupt_enable)], %l5 ldub [%l5], %l6 andn %l6, INTS_ENAB, %l6 stb %l6, [%l5] @@ -829,51 +828,51 @@ linux_trap_nmi_sun4c: lda [%o0] ASI_CONTROL, %o4 ! async vaddr sub %o0, 0x4, %o0 lda [%o0] ASI_CONTROL, %o3 ! async error - call C_LABEL(sparc_lvl15_nmi) + call sparc_lvl15_nmi add %sp, STACKFRAME_SZ, %o0 RESTORE_ALL .align 4 - .globl C_LABEL(invalid_segment_patch1_ff) - .globl C_LABEL(invalid_segment_patch2_ff) -C_LABEL(invalid_segment_patch1_ff): cmp %l4, 0xff -C_LABEL(invalid_segment_patch2_ff): mov 0xff, %l3 + .globl invalid_segment_patch1_ff + .globl invalid_segment_patch2_ff +invalid_segment_patch1_ff: cmp %l4, 0xff +invalid_segment_patch2_ff: mov 0xff, %l3 .align 4 - .globl C_LABEL(invalid_segment_patch1_1ff) - .globl C_LABEL(invalid_segment_patch2_1ff) -C_LABEL(invalid_segment_patch1_1ff): cmp %l4, 0x1ff -C_LABEL(invalid_segment_patch2_1ff): mov 0x1ff, %l3 + .globl invalid_segment_patch1_1ff + .globl invalid_segment_patch2_1ff +invalid_segment_patch1_1ff: cmp %l4, 0x1ff +invalid_segment_patch2_1ff: mov 0x1ff, %l3 .align 4 - .globl C_LABEL(num_context_patch1_16), C_LABEL(num_context_patch2_16) -C_LABEL(num_context_patch1_16): mov 0x10, %l7 -C_LABEL(num_context_patch2_16): mov 0x10, %l7 + .globl num_context_patch1_16, num_context_patch2_16 +num_context_patch1_16: mov 0x10, %l7 +num_context_patch2_16: mov 0x10, %l7 .align 4 - .globl C_LABEL(vac_linesize_patch_32) -C_LABEL(vac_linesize_patch_32): subcc %l7, 32, %l7 + .globl vac_linesize_patch_32 +vac_linesize_patch_32: subcc %l7, 32, %l7 .align 4 - .globl C_LABEL(vac_hwflush_patch1_on), C_LABEL(vac_hwflush_patch2_on) + .globl vac_hwflush_patch1_on, vac_hwflush_patch2_on /* * Ugly, but we cant use hardware flushing on the sun4 and we'd require * two instructions (Anton) */ #ifdef CONFIG_SUN4 -C_LABEL(vac_hwflush_patch1_on): nop +vac_hwflush_patch1_on: nop #else -C_LABEL(vac_hwflush_patch1_on): addcc %l7, -PAGE_SIZE, %l7 +vac_hwflush_patch1_on: addcc %l7, -PAGE_SIZE, %l7 #endif -C_LABEL(vac_hwflush_patch2_on): sta %g0, [%l3 + %l7] ASI_HWFLUSHSEG +vac_hwflush_patch2_on: sta %g0, [%l3 + %l7] ASI_HWFLUSHSEG - .globl C_LABEL(invalid_segment_patch1), C_LABEL(invalid_segment_patch2) - .globl C_LABEL(num_context_patch1), C_LABEL(num_context_patch2) - .globl C_LABEL(vac_linesize_patch), C_LABEL(vac_hwflush_patch1) - .globl C_LABEL(vac_hwflush_patch2) + .globl invalid_segment_patch1, invalid_segment_patch2 + .globl num_context_patch1, num_context_patch2 + .globl vac_linesize_patch, vac_hwflush_patch1 + .globl vac_hwflush_patch2 .align 4 .globl sun4c_fault @@ -886,8 +885,8 @@ C_LABEL(vac_hwflush_patch2_on): sta %g0 ! We want error in %l5, vaddr in %l6 sun4c_fault: #ifdef CONFIG_SUN4 - sethi %hi(C_LABEL(sun4c_memerr_reg)), %l4 - ld [%l4+%lo(C_LABEL(sun4c_memerr_reg))], %l4 ! memerr ctrl reg addr + sethi %hi(sun4c_memerr_reg), %l4 + ld [%l4+%lo(sun4c_memerr_reg)], %l4 ! memerr ctrl reg addr ld [%l4], %l6 ! memerr ctrl reg ld [%l4 + 4], %l5 ! memerr vaddr reg andcc %l6, 0x80, %g0 ! check for error type @@ -895,7 +894,7 @@ sun4c_fault: be 0f ! normal error sethi %hi(AC_BUS_ERROR), %l4 ! bus err reg addr - call C_LABEL(prom_halt) ! something weird happened + call prom_halt ! something weird happened ! what exactly did happen? ! what should we do here? @@ -959,12 +958,12 @@ sun4c_fault: /* Test for NULL pte_t * in vmalloc area. */ sethi %hi(VMALLOC_START), %l4 cmp %l5, %l4 - blu,a C_LABEL(invalid_segment_patch1) + blu,a invalid_segment_patch1 lduXa [%l5] ASI_SEGMAP, %l4 - sethi %hi(C_LABEL(swapper_pg_dir)), %l4 + sethi %hi(swapper_pg_dir), %l4 srl %l5, SUN4C_PGDIR_SHIFT, %l6 - or %l4, %lo(C_LABEL(swapper_pg_dir)), %l4 + or %l4, %lo(swapper_pg_dir), %l4 sll %l6, 2, %l6 ld [%l4 + %l6], %l4 #ifdef CONFIG_SUN4 @@ -976,15 +975,15 @@ sun4c_fault: be sun4c_fault_fromuser lduXa [%l5] ASI_SEGMAP, %l4 -C_LABEL(invalid_segment_patch1): +invalid_segment_patch1: cmp %l4, 0x7f bne 1f - sethi %hi(C_LABEL(sun4c_kfree_ring)), %l4 - or %l4, %lo(C_LABEL(sun4c_kfree_ring)), %l4 + sethi %hi(sun4c_kfree_ring), %l4 + or %l4, %lo(sun4c_kfree_ring), %l4 ld [%l4 + 0x18], %l3 deccc %l3 ! do we have a free entry? bcs,a 2f ! no, unmap one. - sethi %hi(C_LABEL(sun4c_kernel_ring)), %l4 + sethi %hi(sun4c_kernel_ring), %l4 st %l3, [%l4 + 0x18] ! sun4c_kfree_ring.num_entries-- @@ -997,8 +996,8 @@ C_LABEL(invalid_segment_patch1): st %l7, [%l3 + 0x04] ! next->prev = entry->prev st %l3, [%l7 + 0x00] ! entry->prev->next = next - sethi %hi(C_LABEL(sun4c_kernel_ring)), %l4 - or %l4, %lo(C_LABEL(sun4c_kernel_ring)), %l4 + sethi %hi(sun4c_kernel_ring), %l4 + or %l4, %lo(sun4c_kernel_ring), %l4 ! head = &sun4c_kernel_ring.ringhd ld [%l4 + 0x00], %l7 ! head->next @@ -1016,7 +1015,7 @@ C_LABEL(invalid_segment_patch1): ld [%l6 + 0x08], %l5 2: - or %l4, %lo(C_LABEL(sun4c_kernel_ring)), %l4 + or %l4, %lo(sun4c_kernel_ring), %l4 ! head = &sun4c_kernel_ring.ringhd ld [%l4 + 0x04], %l6 ! entry = head->prev @@ -1030,11 +1029,11 @@ C_LABEL(invalid_segment_patch1): sethi %hi((64 * 1024)), %l7 #endif 9: -C_LABEL(vac_hwflush_patch1): -C_LABEL(vac_linesize_patch): +vac_hwflush_patch1: +vac_linesize_patch: subcc %l7, 16, %l7 bne 9b -C_LABEL(vac_hwflush_patch2): +vac_hwflush_patch2: sta %g0, [%l3 + %l7] ASI_FLUSHSEG st %l5, [%l6 + 0x08] ! entry->vaddr = address @@ -1055,7 +1054,7 @@ C_LABEL(vac_hwflush_patch2): mov %l3, %l5 ! address = tmp 4: -C_LABEL(num_context_patch1): +num_context_patch1: mov 0x08, %l7 ld [%l6 + 0x08], %l4 @@ -1072,7 +1071,7 @@ C_LABEL(num_context_patch1): 3: deccc %l7 sethi %hi(AC_CONTEXT), %l3 stba %l7, [%l3] ASI_CONTROL -C_LABEL(invalid_segment_patch2): +invalid_segment_patch2: mov 0x7f, %l3 stXa %l3, [%l5] ASI_SEGMAP andn %l4, 0x1ff, %l3 @@ -1108,12 +1107,12 @@ C_LABEL(invalid_segment_patch2): add %l5, %l4, %l5 b 7f - sethi %hi(C_LABEL(sun4c_kernel_faults)), %l4 + sethi %hi(sun4c_kernel_faults), %l4 1: srl %l5, SUN4C_PGDIR_SHIFT, %l3 - sethi %hi(C_LABEL(swapper_pg_dir)), %l4 - or %l4, %lo(C_LABEL(swapper_pg_dir)), %l4 + sethi %hi(swapper_pg_dir), %l4 + or %l4, %lo(swapper_pg_dir), %l4 sll %l3, 2, %l3 ld [%l4 + %l3], %l4 #ifndef CONFIG_SUN4 @@ -1137,11 +1136,11 @@ C_LABEL(invalid_segment_patch2): bne 2b add %l5, %l4, %l5 - sethi %hi(C_LABEL(sun4c_kernel_faults)), %l4 + sethi %hi(sun4c_kernel_faults), %l4 7: - ld [%l4 + %lo(C_LABEL(sun4c_kernel_faults))], %l3 + ld [%l4 + %lo(sun4c_kernel_faults)], %l3 inc %l3 - st %l3, [%l4 + %lo(C_LABEL(sun4c_kernel_faults))] + st %l3, [%l4 + %lo(sun4c_kernel_faults)] /* Restore condition codes */ wr %l0, 0x0, %psr @@ -1163,14 +1162,14 @@ sun4c_fault_fromuser: wr %l0, PSR_ET, %psr WRITE_PAUSE - call C_LABEL(do_sun4c_fault) + call do_sun4c_fault add %sp, STACKFRAME_SZ, %o0 ! arg1 = pt_regs ptr RESTORE_ALL .align 4 - .globl C_LABEL(srmmu_fault) -C_LABEL(srmmu_fault): + .globl srmmu_fault +srmmu_fault: mov 0x400, %l5 mov 0x300, %l4 @@ -1197,7 +1196,7 @@ C_LABEL(srmmu_fault): wr %l0, PSR_ET, %psr WRITE_PAUSE - call C_LABEL(do_sparc_fault) + call do_sparc_fault add %sp, STACKFRAME_SZ, %o0 ! arg1 = pt_regs ptr RESTORE_ALL @@ -1207,19 +1206,19 @@ C_LABEL(srmmu_fault): * like indir_syscall(scall_num, arg0, arg1, arg2...); etc. * This is complete brain damage. */ - .globl C_LABEL(sunos_indir) -C_LABEL(sunos_indir): + .globl sunos_indir +sunos_indir: mov %o7, %l4 cmp %o0, NR_SYSCALLS blu,a 1f sll %o0, 0x2, %o0 - sethi %hi(C_LABEL(sunos_nosys)), %l6 + sethi %hi(sunos_nosys), %l6 b 2f - or %l6, %lo(C_LABEL(sunos_nosys)), %l6 + or %l6, %lo(sunos_nosys), %l6 1: - set C_LABEL(sunos_sys_table), %l7 + set sunos_sys_table, %l7 ld [%l7 + %o0], %l6 2: @@ -1233,17 +1232,17 @@ C_LABEL(sunos_indir): #endif .align 4 - .globl C_LABEL(sys_nis_syscall) -C_LABEL(sys_nis_syscall): + .globl sys_nis_syscall +sys_nis_syscall: mov %o7, %l5 add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg - call C_LABEL(c_sys_nis_syscall) + call c_sys_nis_syscall mov %l5, %o7 .align 4 - .globl C_LABEL(sys_ptrace) -C_LABEL(sys_ptrace): - call C_LABEL(do_ptrace) + .globl sys_ptrace +sys_ptrace: + call do_ptrace add %sp, STACKFRAME_SZ, %o0 ld [%curptr + TI_FLAGS], %l5 @@ -1251,49 +1250,49 @@ C_LABEL(sys_ptrace): be 1f nop - call C_LABEL(syscall_trace) + call syscall_trace nop 1: RESTORE_ALL .align 4 - .globl C_LABEL(sys_execve) -C_LABEL(sys_execve): + .globl sys_execve +sys_execve: mov %o7, %l5 add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg - call C_LABEL(sparc_execve) + call sparc_execve mov %l5, %o7 .align 4 - .globl C_LABEL(sys_pipe) -C_LABEL(sys_pipe): + .globl sys_pipe +sys_pipe: mov %o7, %l5 add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg - call C_LABEL(sparc_pipe) + call sparc_pipe mov %l5, %o7 .align 4 - .globl C_LABEL(sys_sigaltstack) -C_LABEL(sys_sigaltstack): + .globl sys_sigaltstack +sys_sigaltstack: mov %o7, %l5 mov %fp, %o2 - call C_LABEL(do_sigaltstack) + call do_sigaltstack mov %l5, %o7 .align 4 - .globl C_LABEL(sys_sigstack) -C_LABEL(sys_sigstack): + .globl sys_sigstack +sys_sigstack: mov %o7, %l5 mov %fp, %o2 - call C_LABEL(do_sys_sigstack) + call do_sys_sigstack mov %l5, %o7 .align 4 - .globl C_LABEL(sys_sigpause) -C_LABEL(sys_sigpause): + .globl sys_sigpause +sys_sigpause: /* Note: %o0 already has correct value... */ - call C_LABEL(do_sigpause) + call do_sigpause add %sp, STACKFRAME_SZ, %o1 ld [%curptr + TI_FLAGS], %l5 @@ -1301,7 +1300,7 @@ C_LABEL(sys_sigpause): be 1f nop - call C_LABEL(syscall_trace) + call syscall_trace nop 1: @@ -1309,9 +1308,9 @@ C_LABEL(sys_sigpause): RESTORE_ALL .align 4 - .globl C_LABEL(sys_sigsuspend) -C_LABEL(sys_sigsuspend): - call C_LABEL(do_sigsuspend) + .globl sys_sigsuspend +sys_sigsuspend: + call do_sigsuspend add %sp, STACKFRAME_SZ, %o0 ld [%curptr + TI_FLAGS], %l5 @@ -1319,7 +1318,7 @@ C_LABEL(sys_sigsuspend): be 1f nop - call C_LABEL(syscall_trace) + call syscall_trace nop 1: @@ -1327,10 +1326,10 @@ C_LABEL(sys_sigsuspend): RESTORE_ALL .align 4 - .globl C_LABEL(sys_rt_sigsuspend) -C_LABEL(sys_rt_sigsuspend): + .globl sys_rt_sigsuspend +sys_rt_sigsuspend: /* Note: %o0, %o1 already have correct value... */ - call C_LABEL(do_rt_sigsuspend) + call do_rt_sigsuspend add %sp, STACKFRAME_SZ, %o2 ld [%curptr + TI_FLAGS], %l5 @@ -1338,7 +1337,7 @@ C_LABEL(sys_rt_sigsuspend): be 1f nop - call C_LABEL(syscall_trace) + call syscall_trace nop 1: @@ -1346,9 +1345,9 @@ C_LABEL(sys_rt_sigsuspend): RESTORE_ALL .align 4 - .globl C_LABEL(sys_sigreturn) -C_LABEL(sys_sigreturn): - call C_LABEL(do_sigreturn) + .globl sys_sigreturn +sys_sigreturn: + call do_sigreturn add %sp, STACKFRAME_SZ, %o0 ld [%curptr + TI_FLAGS], %l5 @@ -1356,7 +1355,7 @@ C_LABEL(sys_sigreturn): be 1f nop - call C_LABEL(syscall_trace) + call syscall_trace nop 1: @@ -1366,9 +1365,9 @@ C_LABEL(sys_sigreturn): RESTORE_ALL .align 4 - .globl C_LABEL(sys_rt_sigreturn) -C_LABEL(sys_rt_sigreturn): - call C_LABEL(do_rt_sigreturn) + .globl sys_rt_sigreturn +sys_rt_sigreturn: + call do_rt_sigreturn add %sp, STACKFRAME_SZ, %o0 ld [%curptr + TI_FLAGS], %l5 @@ -1376,7 +1375,7 @@ C_LABEL(sys_rt_sigreturn): be 1f nop - call C_LABEL(syscall_trace) + call syscall_trace nop 1: @@ -1391,8 +1390,8 @@ C_LABEL(sys_rt_sigreturn): * XXX code just like on sparc64... -DaveM */ .align 4 - .globl C_LABEL(sys_fork), flush_patch_two -C_LABEL(sys_fork): + .globl sys_fork, flush_patch_two +sys_fork: mov %o7, %l5 flush_patch_two: FLUSH_ALL_KERNEL_WINDOWS; @@ -1406,12 +1405,12 @@ flush_patch_two: std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr] add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr mov 0, %o3 - call C_LABEL(sparc_do_fork) + call sparc_do_fork mov %l5, %o7 /* Whee, kernel threads! */ - .globl C_LABEL(sys_clone), flush_patch_three -C_LABEL(sys_clone): + .globl sys_clone, flush_patch_three +sys_clone: mov %o7, %l5 flush_patch_three: FLUSH_ALL_KERNEL_WINDOWS; @@ -1430,12 +1429,12 @@ flush_patch_three: std %g4, [%o4 + AOFF_task_thread + AOFF_thread_fork_kpsr] add %sp, STACKFRAME_SZ, %o2 ! arg2: pt_regs ptr mov 0, %o3 - call C_LABEL(sparc_do_fork) + call sparc_do_fork mov %l5, %o7 /* Whee, real vfork! */ - .globl C_LABEL(sys_vfork), flush_patch_four -C_LABEL(sys_vfork): + .globl sys_vfork, flush_patch_four +sys_vfork: flush_patch_four: FLUSH_ALL_KERNEL_WINDOWS; ld [%curptr + TI_TASK], %o4 @@ -1447,16 +1446,16 @@ flush_patch_four: sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0 mov %fp, %o1 or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0 - sethi %hi(C_LABEL(sparc_do_fork)), %l1 + sethi %hi(sparc_do_fork), %l1 mov 0, %o3 - jmpl %l1 + %lo(C_LABEL(sparc_do_fork)), %g0 + jmpl %l1 + %lo(sparc_do_fork), %g0 add %sp, STACKFRAME_SZ, %o2 .align 4 linux_sparc_ni_syscall: - sethi %hi(C_LABEL(sys_ni_syscall)), %l7 + sethi %hi(sys_ni_syscall), %l7 b syscall_is_too_hard - or %l7, %lo(C_LABEL(sys_ni_syscall)), %l7 + or %l7, %lo(sys_ni_syscall), %l7 linux_fast_syscall: andn %l7, 3, %l7 @@ -1467,7 +1466,7 @@ linux_fast_syscall: mov %i3, %o3 linux_syscall_trace: - call C_LABEL(syscall_trace) + call syscall_trace nop mov %i0, %o0 mov %i1, %o1 @@ -1476,11 +1475,11 @@ linux_syscall_trace: b 2f mov %i4, %o4 - .globl C_LABEL(ret_from_fork) -C_LABEL(ret_from_fork): + .globl ret_from_fork +ret_from_fork: call schedule_tail mov %g3, %o0 - b C_LABEL(ret_sys_call) + b ret_sys_call ld [%sp + STACKFRAME_SZ + PT_I0], %o0 /* Linux native and SunOS system calls enter here... */ @@ -1518,8 +1517,8 @@ syscall_is_too_hard: st %o0, [%sp + STACKFRAME_SZ + PT_I0] - .globl C_LABEL(ret_sys_call) -C_LABEL(ret_sys_call): + .globl ret_sys_call +ret_sys_call: ld [%curptr + TI_FLAGS], %l6 cmp %o0, -ENOIOCTLCMD ld [%sp + STACKFRAME_SZ + PT_PSR], %g3 @@ -1554,7 +1553,7 @@ C_LABEL(ret_sys_call): st %l2, [%sp + STACKFRAME_SZ + PT_NPC] linux_syscall_trace2: - call C_LABEL(syscall_trace) + call syscall_trace add %l1, 0x4, %l2 /* npc = npc+4 */ st %l1, [%sp + STACKFRAME_SZ + PT_PC] b ret_trap_entry @@ -1595,7 +1594,7 @@ solaris_syscall: nop mov %i0, %l5 - call C_LABEL(do_solaris_syscall) + call do_solaris_syscall add %sp, STACKFRAME_SZ, %o0 st %o0, [%sp + STACKFRAME_SZ + PT_I0] @@ -1651,7 +1650,7 @@ sunos_syscall: nop nop mov %i0, %l5 - call C_LABEL(do_sunos_syscall) + call do_sunos_syscall add %sp, STACKFRAME_SZ, %o0 #endif @@ -1664,7 +1663,7 @@ bsd_syscall: blu,a 1f sll %g1, 2, %l4 - set C_LABEL(sys_ni_syscall), %l7 + set sys_ni_syscall, %l7 b bsd_is_too_hard nop @@ -1707,8 +1706,8 @@ bsd_is_too_hard: */ sub %g0, %o0, %o0 #if 0 /* XXX todo XXX */ - sethi %hi(C_LABEL(bsd_xlatb_rorl), %o3 - or %o3, %lo(C_LABEL(bsd_xlatb_rorl)), %o3 + sethi %hi(bsd_xlatb_rorl), %o3 + or %o3, %lo(bsd_xlatb_rorl), %o3 sll %o0, 2, %o0 ld [%o3 + %o0], %o0 #endif @@ -1731,8 +1730,8 @@ bsd_is_too_hard: * void *fpqueue, unsigned long *fpqdepth) */ - .globl C_LABEL(fpsave) -C_LABEL(fpsave): + .globl fpsave +fpsave: st %fsr, [%o1] ! this can trap on us if fpu is in bogon state ld [%o1], %g1 set 0x2000, %g4 @@ -1782,13 +1781,13 @@ fpsave_catch: st %fsr, [%o1] fpsave_catch2: - b C_LABEL(fpsave) + 4 + b fpsave + 4 st %fsr, [%o1] /* void fpload(unsigned long *fpregs, unsigned long *fsr); */ - .globl C_LABEL(fpload) -C_LABEL(fpload): + .globl fpload +fpload: ldd [%o0 + 0x00], %f0 ldd [%o0 + 0x08], %f2 ldd [%o0 + 0x10], %f4 @@ -1809,8 +1808,8 @@ C_LABEL(fpload): retl nop - .globl C_LABEL(ndelay) -C_LABEL(ndelay): + .globl ndelay +ndelay: save %sp, -STACKFRAME_SZ, %sp mov %i0, %o0 call .umul @@ -1818,8 +1817,8 @@ C_LABEL(ndelay): ba delay_continue nop - .globl C_LABEL(udelay) -C_LABEL(udelay): + .globl udelay +udelay: save %sp, -STACKFRAME_SZ, %sp mov %i0, %o0 sethi %hi(0x10c6), %o1 @@ -1827,12 +1826,12 @@ C_LABEL(udelay): or %o1, %lo(0x10c6), %o1 delay_continue: #ifndef CONFIG_SMP - sethi %hi(C_LABEL(loops_per_jiffy)), %o3 + sethi %hi(loops_per_jiffy), %o3 call .umul - ld [%o3 + %lo(C_LABEL(loops_per_jiffy))], %o1 + ld [%o3 + %lo(loops_per_jiffy)], %o1 #else GET_PROCESSOR_OFFSET(o4, o2) - set C_LABEL(cpu_data), %o3 + set cpu_data, %o3 call .umul ld [%o3 + %o4], %o1 #endif @@ -1858,14 +1857,14 @@ breakpoint_trap: WRITE_PAUSE st %i0, [%sp + STACKFRAME_SZ + PT_G0] ! for restarting syscalls - call C_LABEL(sparc_breakpoint) + call sparc_breakpoint add %sp, STACKFRAME_SZ, %o0 RESTORE_ALL .align 4 - .globl C_LABEL(__handle_exception), flush_patch_exception -C_LABEL(__handle_exception): + .globl __handle_exception, flush_patch_exception +__handle_exception: flush_patch_exception: FLUSH_ALL_KERNEL_WINDOWS; ldd [%o0], %o6 @@ -1873,7 +1872,7 @@ flush_patch_exception: mov 1, %g1 ! signal EFAULT condition .align 4 - .globl C_LABEL(kill_user_windows), kuw_patch1_7win + .globl kill_user_windows, kuw_patch1_7win .globl kuw_patch1 kuw_patch1_7win: sll %o3, 6, %o3 @@ -1881,7 +1880,7 @@ kuw_patch1_7win: sll %o3, 6, %o3 * case scenerio, it is several times better than taking the * traps with the old method of just doing flush_user_windows(). */ -C_LABEL(kill_user_windows): +kill_user_windows: ld [%g6 + TI_UWINMASK], %o0 ! get current umask orcc %g0, %o0, %g0 ! if no bits set, we are done be 3f ! nothing to do @@ -1911,8 +1910,8 @@ kuw_patch1: st %g0, [%g6 + TI_W_SAVED] ! no windows saved .align 4 - .globl C_LABEL(restore_current) -C_LABEL(restore_current): + .globl restore_current +restore_current: LOAD_CURRENT(g6, o0) retl nop @@ -1932,8 +1931,8 @@ linux_trap_ipi15_pcic: * The busy loop is necessary because the PIO error * sometimes does not go away quickly and we trap again. */ - sethi %hi(C_LABEL(pcic_regs)), %o1 - ld [%o1 + %lo(C_LABEL(pcic_regs))], %o2 + sethi %hi(pcic_regs), %o1 + ld [%o1 + %lo(pcic_regs)], %o2 ! Get pending status for printouts later. ld [%o2 + PCI_SYS_INT_PENDING], %o0 @@ -1952,12 +1951,12 @@ linux_trap_ipi15_pcic: wr %l4, PSR_ET, %psr WRITE_PAUSE - call C_LABEL(pcic_nmi) + call pcic_nmi add %sp, STACKFRAME_SZ, %o1 ! struct pt_regs *regs RESTORE_ALL - .globl C_LABEL(pcic_nmi_trap_patch) -C_LABEL(pcic_nmi_trap_patch): + .globl pcic_nmi_trap_patch +pcic_nmi_trap_patch: sethi %hi(linux_trap_ipi15_pcic), %l3 jmpl %l3 + %lo(linux_trap_ipi15_pcic), %g0 rd %psr, %l0 --- diff/arch/sparc/kernel/etrap.S 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/sparc/kernel/etrap.S 2004-02-23 13:56:39.000000000 +0000 @@ -5,7 +5,6 @@ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) */ -#include #include #include #include @@ -217,9 +216,9 @@ tsetup_patch6: /* Call MMU-architecture dependent stack checking * routine. */ - .globl C_LABEL(tsetup_mmu_patchme) -C_LABEL(tsetup_mmu_patchme): - b C_LABEL(tsetup_sun4c_stackchk) + .globl tsetup_mmu_patchme +tsetup_mmu_patchme: + b tsetup_sun4c_stackchk andcc %sp, 0x7, %g0 /* Architecture specific stack checking routines. When either @@ -229,8 +228,8 @@ C_LABEL(tsetup_mmu_patchme): */ #define glob_tmp g1 - .globl C_LABEL(tsetup_sun4c_stackchk) -C_LABEL(tsetup_sun4c_stackchk): + .globl tsetup_sun4c_stackchk +tsetup_sun4c_stackchk: /* Done by caller: andcc %sp, 0x7, %g0 */ bne trap_setup_user_stack_is_bolixed sra %sp, 29, %glob_tmp @@ -276,8 +275,8 @@ tsetup_sun4c_onepage: jmpl %t_retpc + 0x8, %g0 mov %t_kstack, %sp - .globl C_LABEL(tsetup_srmmu_stackchk) -C_LABEL(tsetup_srmmu_stackchk): + .globl tsetup_srmmu_stackchk +tsetup_srmmu_stackchk: /* Check results of callers andcc %sp, 0x7, %g0 */ bne trap_setup_user_stack_is_bolixed sethi %hi(PAGE_OFFSET), %glob_tmp --- diff/arch/sparc/kernel/head.S 2003-05-21 11:50:14.000000000 +0100 +++ source/arch/sparc/kernel/head.S 2004-02-23 13:56:39.000000000 +0000 @@ -14,7 +14,6 @@ #include #include -#include #include #include #include @@ -34,18 +33,18 @@ */ .align 4 - .globl C_LABEL(cputyp) -C_LABEL(cputyp): + .globl cputyp +cputyp: .word 1 .align 4 - .globl C_LABEL(cputypval) -C_LABEL(cputypval): + .globl cputypval +cputypval: .asciz "sun4c" .ascii " " -C_LABEL(cputypvalend): -C_LABEL(cputypvallen) = C_LABEL(cputypvar) - C_LABEL(cputypval) +cputypvalend: +cputypvallen = cputypvar - cputypval .align 4 /* @@ -56,12 +55,12 @@ C_LABEL(cputypvallen) = C_LABEL(cputypva /* Uh, actually Linus it is I who cannot spell. Too much murky * Sparc assembly will do this to ya. */ -C_LABEL(cputypvar): +cputypvar: .asciz "compatability" /* Tested on SS-5, SS-10. Probably someone at Sun applied a spell-checker. */ .align 4 -C_LABEL(cputypvar_sun4m): +cputypvar_sun4m: .asciz "compatible" .align 4 @@ -88,14 +87,14 @@ sun4e_notsup: /* The Sparc trap table, bootloader gives us control at _start. */ .text .globl start, _stext, _start, __stext - .globl C_LABEL(trapbase) + .globl trapbase _start: /* danger danger */ __stext: _stext: start: -C_LABEL(trapbase): +trapbase: #ifdef CONFIG_SMP -C_LABEL(trapbase_cpu0): +trapbase_cpu0: #endif /* We get control passed to us here at t_zero. */ t_zero: b gokernel; nop; nop; nop; @@ -202,13 +201,13 @@ t_badfc:BAD_TRAP(0xfc) BAD_TRAP(0xfd) dbtrap: BAD_TRAP(0xfe) /* Debugger/PROM breakpoint #1 */ dbtrap2:BAD_TRAP(0xff) /* Debugger/PROM breakpoint #2 */ - .globl C_LABEL(end_traptable) -C_LABEL(end_traptable): + .globl end_traptable +end_traptable: #ifdef CONFIG_SMP /* Trap tables for the other cpus. */ - .globl C_LABEL(trapbase_cpu1), C_LABEL(trapbase_cpu2), C_LABEL(trapbase_cpu3) -C_LABEL(trapbase_cpu1): + .globl trapbase_cpu1, trapbase_cpu2, trapbase_cpu3 +trapbase_cpu1: BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction) TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler) WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler) @@ -276,7 +275,7 @@ C_LABEL(trapbase_cpu1): BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb) BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff) -C_LABEL(trapbase_cpu2): +trapbase_cpu2: BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction) TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler) WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler) @@ -344,7 +343,7 @@ C_LABEL(trapbase_cpu2): BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb) BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff) -C_LABEL(trapbase_cpu3): +trapbase_cpu3: BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction) TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler) WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler) @@ -418,25 +417,25 @@ C_LABEL(trapbase_cpu3): /* This was the only reasonable way I could think of to properly align * these page-table data structures. */ - .globl C_LABEL(pg0), C_LABEL(pg1), C_LABEL(pg2), C_LABEL(pg3) - .globl C_LABEL(empty_bad_page) - .globl C_LABEL(empty_bad_page_table) - .globl C_LABEL(empty_zero_page) - .globl C_LABEL(swapper_pg_dir) -C_LABEL(swapper_pg_dir): .skip PAGE_SIZE -C_LABEL(pg0): .skip PAGE_SIZE -C_LABEL(pg1): .skip PAGE_SIZE -C_LABEL(pg2): .skip PAGE_SIZE -C_LABEL(pg3): .skip PAGE_SIZE -C_LABEL(empty_bad_page): .skip PAGE_SIZE -C_LABEL(empty_bad_page_table): .skip PAGE_SIZE -C_LABEL(empty_zero_page): .skip PAGE_SIZE - - .global C_LABEL(root_flags) - .global C_LABEL(ram_flags) - .global C_LABEL(root_dev) - .global C_LABEL(sparc_ramdisk_image) - .global C_LABEL(sparc_ramdisk_size) + .globl pg0, pg1, pg2, pg3 + .globl empty_bad_page + .globl empty_bad_page_table + .globl empty_zero_page + .globl swapper_pg_dir +swapper_pg_dir: .skip PAGE_SIZE +pg0: .skip PAGE_SIZE +pg1: .skip PAGE_SIZE +pg2: .skip PAGE_SIZE +pg3: .skip PAGE_SIZE +empty_bad_page: .skip PAGE_SIZE +empty_bad_page_table: .skip PAGE_SIZE +empty_zero_page: .skip PAGE_SIZE + + .global root_flags + .global ram_flags + .global root_dev + .global sparc_ramdisk_image + .global sparc_ramdisk_size /* This stuff has to be in sync with SILO and other potential boot loaders * Fields should be kept upward compatible and whenever any change is made, @@ -445,17 +444,17 @@ C_LABEL(empty_zero_page): .skip PAGE_SI .ascii "HdrS" .word LINUX_VERSION_CODE .half 0x0203 /* HdrS version */ -C_LABEL(root_flags): +root_flags: .half 1 -C_LABEL(root_dev): +root_dev: .half 0 -C_LABEL(ram_flags): +ram_flags: .half 0 -C_LABEL(sparc_ramdisk_image): +sparc_ramdisk_image: .word 0 -C_LABEL(sparc_ramdisk_size): +sparc_ramdisk_size: .word 0 - .word C_LABEL(reboot_command) + .word reboot_command .word 0, 0, 0 .word _end @@ -517,7 +516,7 @@ copy_prom_lvl14: /* DJHR * preserve our linked/calculated instructions */ - set C_LABEL(lvl14_save), %g1 + set lvl14_save, %g1 set t_irq14, %g3 sub %g1, %l6, %g1 ! translate to physical sub %g3, %l6, %g3 ! translate to physical @@ -761,11 +760,11 @@ execute_in_high_mem: mov %l0, %o0 ! put back romvec mov %l1, %o1 ! and debug_vec - sethi %hi( C_LABEL(prom_vector_p) ), %g1 - st %o0, [%g1 + %lo( C_LABEL(prom_vector_p) )] + sethi %hi(prom_vector_p), %g1 + st %o0, [%g1 + %lo(prom_vector_p)] - sethi %hi( C_LABEL(linux_dbvec) ), %g1 - st %o1, [%g1 + %lo( C_LABEL(linux_dbvec) )] + sethi %hi(linux_dbvec), %g1 + st %o1, [%g1 + %lo(linux_dbvec)] ld [%o0 + 0x4], %o3 and %o3, 0x3, %o5 ! get the version @@ -808,10 +807,10 @@ found_version: or %g0, %g0, %o0 ! next_node(0) = first_node or %o0, %g0, %g6 - sethi %hi( C_LABEL(cputypvar) ), %o1 ! First node has cpu-arch - or %o1, %lo( C_LABEL(cputypvar) ), %o1 - sethi %hi( C_LABEL(cputypval) ), %o2 ! information, the string - or %o2, %lo( C_LABEL(cputypval) ), %o2 + sethi %hi(cputypvar), %o1 ! First node has cpu-arch + or %o1, %lo(cputypvar), %o1 + sethi %hi(cputypval), %o2 ! information, the string + or %o2, %lo(cputypval), %o2 ld [%l1], %l0 ! 'compatibility' tells ld [%l0 + 0xc], %l0 ! that we want 'sun4x' where call %l0 ! x is one of '', 'c', 'm', @@ -824,17 +823,17 @@ found_version: nop or %g6, %g0, %o0 - sethi %hi( C_LABEL(cputypvar_sun4m) ), %o1 - or %o1, %lo( C_LABEL(cputypvar_sun4m) ), %o1 - sethi %hi( C_LABEL(cputypval) ), %o2 - or %o2, %lo( C_LABEL(cputypval) ), %o2 + sethi %hi(cputypvar_sun4m), %o1 + or %o1, %lo(cputypvar_sun4m), %o1 + sethi %hi(cputypval), %o2 + or %o2, %lo(cputypval), %o2 ld [%l1], %l0 ld [%l0 + 0xc], %l0 call %l0 nop got_prop: - set C_LABEL(cputypval), %o2 + set cputypval, %o2 ldub [%o2 + 0x4], %l1 cmp %l1, ' ' @@ -853,7 +852,7 @@ got_prop: b no_sun4u_here ! AIEEE, a V9 sun4u... Get our BIG BROTHER kernel :)) nop -1: set C_LABEL(cputypval), %l1 +1: set cputypval, %l1 ldub [%l1 + 0x4], %l1 cmp %l1, 'm' ! Test for sun4d, sun4e ? be sun4m_init @@ -875,8 +874,8 @@ got_prop: sun4d_init: /* Need to patch call to handler_irq */ - set C_LABEL(patch_handler_irq), %g4 - set C_LABEL(sun4d_handler_irq), %g5 + set patch_handler_irq, %g4 + set sun4d_handler_irq, %g5 sethi %hi(0x40000000), %g3 ! call sub %g5, %g4, %g5 srl %g5, 2, %g5 @@ -997,8 +996,8 @@ sun4c_continue_boot: * show-time! */ - sethi %hi( C_LABEL(cputyp) ), %o0 - st %g4, [%o0 + %lo( C_LABEL(cputyp) )] + sethi %hi(cputyp), %o0 + st %g4, [%o0 + %lo(cputyp)] /* Turn on Supervisor, EnableFloating, and all the PIL bits. * Also puts us in register window zero with traps off. @@ -1008,14 +1007,14 @@ sun4c_continue_boot: WRITE_PAUSE /* I want a kernel stack NOW! */ - set C_LABEL(init_thread_union), %g1 + set init_thread_union, %g1 set (THREAD_SIZE - STACKFRAME_SZ), %g2 add %g1, %g2, %sp mov 0, %fp /* And for good luck */ /* Zero out our BSS section. */ - set C_LABEL(__bss_start) , %o0 ! First address of BSS - set C_LABEL(end) , %o1 ! Last address of BSS + set __bss_start , %o0 ! First address of BSS + set end , %o1 ! Last address of BSS add %o0, 0x1, %o0 1: stb %g0, [%o0] @@ -1026,11 +1025,11 @@ sun4c_continue_boot: /* Initialize the uwinmask value for init task just in case. * But first make current_set[boot_cpu_id] point to something useful. */ - set C_LABEL(init_thread_union), %g6 - set C_LABEL(current_set), %g2 + set init_thread_union, %g6 + set current_set, %g2 #ifdef CONFIG_SMP - sethi %hi(C_LABEL(boot_cpu_id4)), %g3 - ldub [%g3 + %lo(C_LABEL(boot_cpu_id4))], %g3 + sethi %hi(boot_cpu_id4), %g3 + ldub [%g3 + %lo(boot_cpu_id4)], %g3 st %g6, [%g2] add %g2, %g3, %g2 #endif @@ -1124,14 +1123,14 @@ sun4c_continue_boot: st %g4, [%g5 + 0x1c] 2: - sethi %hi( C_LABEL(nwindows) ), %g4 - st %g3, [%g4 + %lo( C_LABEL(nwindows) )] ! store final value + sethi %hi(nwindows), %g4 + st %g3, [%g4 + %lo(nwindows)] ! store final value sub %g3, 0x1, %g3 - sethi %hi( C_LABEL(nwindowsm1) ), %g4 - st %g3, [%g4 + %lo( C_LABEL(nwindowsm1) )] + sethi %hi(nwindowsm1), %g4 + st %g3, [%g4 + %lo(nwindowsm1)] /* Here we go, start using Linux's trap table... */ - set C_LABEL(trapbase), %g3 + set trapbase, %g3 wr %g3, 0x0, %tbr WRITE_PAUSE @@ -1147,12 +1146,12 @@ sun4c_continue_boot: * off to start_kernel(). */ - sethi %hi( C_LABEL(prom_vector_p) ), %g5 - ld [%g5 + %lo( C_LABEL(prom_vector_p) )], %o0 - call C_LABEL(prom_init) + sethi %hi(prom_vector_p), %g5 + ld [%g5 + %lo(prom_vector_p)], %o0 + call prom_init nop - call C_LABEL(start_kernel) + call start_kernel nop /* We should not get here. */ @@ -1162,7 +1161,7 @@ sun4c_continue_boot: sun4_init: #ifdef CONFIG_SUN4 /* There, happy now Adrian? */ - set C_LABEL(cputypval), %o2 ! Let everyone know we + set cputypval, %o2 ! Let everyone know we set ' ', %o0 ! are a "sun4 " architecture stb %o0, [%o2 + 0x4] @@ -1289,8 +1288,8 @@ halt_me: * gets initialized in c-code so all routines can use it. */ - .globl C_LABEL(prom_vector_p) -C_LABEL(prom_vector_p): + .globl prom_vector_p +prom_vector_p: .word 0 /* We calculate the following at boot time, window fills/spills and trap entry @@ -1298,25 +1297,25 @@ C_LABEL(prom_vector_p): */ .align 4 - .globl C_LABEL(nwindows) - .globl C_LABEL(nwindowsm1) -C_LABEL(nwindows): + .globl nwindows + .globl nwindowsm1 +nwindows: .word 8 -C_LABEL(nwindowsm1): +nwindowsm1: .word 7 /* Boot time debugger vector value. We need this later on. */ .align 4 - .globl C_LABEL(linux_dbvec) -C_LABEL(linux_dbvec): + .globl linux_dbvec +linux_dbvec: .word 0 .word 0 .align 8 - .globl C_LABEL(lvl14_save) -C_LABEL(lvl14_save): + .globl lvl14_save +lvl14_save: .word 0 .word 0 .word 0 --- diff/arch/sparc/kernel/rtrap.S 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/sparc/kernel/rtrap.S 2004-02-23 13:56:39.000000000 +0000 @@ -4,7 +4,6 @@ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) */ -#include #include #include #include @@ -47,9 +46,9 @@ rtrap_7win_patch5: and %g1, 0x7f, %g1 .globl ret_trap_entry, rtrap_patch1, rtrap_patch2 .globl rtrap_patch3, rtrap_patch4, rtrap_patch5 - .globl C_LABEL(ret_trap_lockless_ipi) + .globl ret_trap_lockless_ipi ret_trap_entry: -C_LABEL(ret_trap_lockless_ipi): +ret_trap_lockless_ipi: andcc %t_psr, PSR_PS, %g0 be 1f nop @@ -64,7 +63,7 @@ C_LABEL(ret_trap_lockless_ipi): be signal_p nop - call C_LABEL(schedule) + call schedule nop ld [%curptr + TI_FLAGS], %g2 @@ -76,7 +75,7 @@ signal_p: clr %o0 mov %l5, %o2 mov %l6, %o3 - call C_LABEL(do_signal) + call do_signal add %sp, STACKFRAME_SZ, %o1 ! pt_regs ptr /* Fall through. */ @@ -95,7 +94,7 @@ ret_trap_continue: WRITE_PAUSE mov 1, %o1 - call C_LABEL(try_to_clear_window_buffer) + call try_to_clear_window_buffer add %sp, STACKFRAME_SZ, %o0 b signal_p @@ -131,8 +130,8 @@ rtrap_patch2: and %glob_tmp, 0xff, %glob * branch to the user stack checking routine * for return from traps. */ - .globl C_LABEL(rtrap_mmu_patchme) -C_LABEL(rtrap_mmu_patchme): b C_LABEL(sun4c_rett_stackchk) + .globl rtrap_mmu_patchme +rtrap_mmu_patchme: b sun4c_rett_stackchk andcc %fp, 0x7, %g0 ret_trap_userwins_ok: @@ -165,7 +164,7 @@ ret_trap_unaligned_pc: wr %t_psr, PSR_ET, %psr WRITE_PAUSE - call C_LABEL(do_memaccess_unaligned) + call do_memaccess_unaligned nop b signal_p @@ -215,15 +214,15 @@ ret_trap_user_stack_is_bolixed: wr %t_psr, PSR_ET, %psr WRITE_PAUSE - call C_LABEL(window_ret_fault) + call window_ret_fault add %sp, STACKFRAME_SZ, %o0 b signal_p ld [%curptr + TI_FLAGS], %g2 - .globl C_LABEL(sun4c_rett_stackchk) -C_LABEL(sun4c_rett_stackchk): + .globl sun4c_rett_stackchk +sun4c_rett_stackchk: be 1f and %fp, 0xfff, %g1 ! delay slot @@ -286,8 +285,8 @@ sun4c_rett_onepage: b ret_trap_userwins_ok save %g0, %g0, %g0 - .globl C_LABEL(srmmu_rett_stackchk) -C_LABEL(srmmu_rett_stackchk): + .globl srmmu_rett_stackchk +srmmu_rett_stackchk: bne ret_trap_user_stack_is_bolixed sethi %hi(PAGE_OFFSET), %g1 cmp %g1, %fp --- diff/arch/sparc/kernel/sclow.S 2003-06-09 14:18:18.000000000 +0100 +++ source/arch/sparc/kernel/sclow.S 2004-02-23 13:56:39.000000000 +0000 @@ -6,7 +6,6 @@ * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) */ -#include #include #include #include @@ -31,7 +30,7 @@ jmp %l2; \ rett %l2 + 4; -#define LABEL(func) CONCAT(func, _low) +#define LABEL(func) func##_low .globl LABEL(sunosnop) LABEL(sunosnop): --- diff/arch/sparc/kernel/setup.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/sparc/kernel/setup.c 2004-02-23 13:56:39.000000000 +0000 @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -66,7 +67,6 @@ struct screen_info screen_info = { extern unsigned long trapbase; void (*prom_palette)(int); -asmlinkage void sys_sync(void); /* it's really int */ /* Pretty sick eh? */ void prom_sync_me(void) --- diff/arch/sparc/kernel/smp.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/sparc/kernel/smp.c 2004-02-23 13:56:39.000000000 +0000 @@ -56,9 +56,6 @@ int smp_activated = 0; volatile int __cpu_number_map[NR_CPUS]; volatile int __cpu_logical_map[NR_CPUS]; cycles_t cacheflush_time = 0; /* XXX */ -spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] = { - [0 ... (ATOMIC_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED -}; /* The only guaranteed locking primitive available on all Sparc * processors is 'ldstub [%reg + immediate], %dest_reg' which atomically --- diff/arch/sparc/kernel/sparc_ksyms.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/sparc/kernel/sparc_ksyms.c 2004-02-23 13:56:39.000000000 +0000 @@ -298,8 +298,7 @@ EXPORT_SYMBOL(__copy_user); EXPORT_SYMBOL(__strncpy_from_user); /* Networking helper routines. */ -/* XXX This is NOVERS because C_LABEL_STR doesn't get the version number. -DaveM */ -EXPORT_SYMBOL_NOVERS(__csum_partial_copy_sparc_generic); +EXPORT_SYMBOL(__csum_partial_copy_sparc_generic); EXPORT_SYMBOL(csum_partial); /* Cache flushing. */ --- diff/arch/sparc/kernel/sunos_asm.S 2003-05-21 11:50:14.000000000 +0100 +++ source/arch/sparc/kernel/sunos_asm.S 2004-02-23 13:56:39.000000000 +0000 @@ -9,7 +9,6 @@ * Copyright (C) 1995 Adrian M. Rodriguez (adrian@remus.rutgers.edu) */ -#include #include .text @@ -19,50 +18,50 @@ * value as in [%sp + STACKFRAME_SZ + PT_I0] */ /* SunOS getpid() returns pid in %o0 and ppid in %o1 */ - .globl C_LABEL(sunos_getpid) -C_LABEL(sunos_getpid): - call C_LABEL(sys_getppid) + .globl sunos_getpid +sunos_getpid: + call sys_getppid nop - call C_LABEL(sys_getpid) + call sys_getpid st %o0, [%sp + STACKFRAME_SZ + PT_I1] - b C_LABEL(ret_sys_call) + b ret_sys_call st %o0, [%sp + STACKFRAME_SZ + PT_I0] /* SunOS getuid() returns uid in %o0 and euid in %o1 */ - .globl C_LABEL(sunos_getuid) -C_LABEL(sunos_getuid): - call C_LABEL(sys_geteuid16) + .globl sunos_getuid +sunos_getuid: + call sys_geteuid16 nop - call C_LABEL(sys_getuid16) + call sys_getuid16 st %o0, [%sp + STACKFRAME_SZ + PT_I1] - b C_LABEL(ret_sys_call) + b ret_sys_call st %o0, [%sp + STACKFRAME_SZ + PT_I0] /* SunOS getgid() returns gid in %o0 and egid in %o1 */ - .globl C_LABEL(sunos_getgid) -C_LABEL(sunos_getgid): - call C_LABEL(sys_getegid16) + .globl sunos_getgid +sunos_getgid: + call sys_getegid16 nop - call C_LABEL(sys_getgid16) + call sys_getgid16 st %o0, [%sp + STACKFRAME_SZ + PT_I1] - b C_LABEL(ret_sys_call) + b ret_sys_call st %o0, [%sp + STACKFRAME_SZ + PT_I0] /* SunOS's execv() call only specifies the argv argument, the * environment settings are the same as the calling processes. */ - .globl C_LABEL(sunos_execv) -C_LABEL(sunos_execv): + .globl sunos_execv +sunos_execv: st %g0, [%sp + STACKFRAME_SZ + PT_I2] - call C_LABEL(sparc_execve) + call sparc_execve add %sp, STACKFRAME_SZ, %o0 - b C_LABEL(ret_sys_call) + b ret_sys_call ld [%sp + STACKFRAME_SZ + PT_I0], %o0 --- diff/arch/sparc/kernel/sunos_ioctl.c 2002-10-16 04:27:53.000000000 +0100 +++ source/arch/sparc/kernel/sunos_ioctl.c 2004-02-23 13:56:39.000000000 +0000 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -32,7 +33,6 @@ extern char sunkbd_layout; /* NR_OPEN is now larger and dynamic in recent kernels. */ #define SUNOS_NR_OPEN 256 -extern asmlinkage int sys_ioctl(unsigned int, unsigned int, unsigned long); extern asmlinkage int sys_setsid(void); asmlinkage int sunos_ioctl (int fd, unsigned long cmd, unsigned long arg) --- diff/arch/sparc/kernel/sys_sparc.c 2003-07-22 18:54:27.000000000 +0100 +++ source/arch/sparc/kernel/sys_sparc.c 2004-02-23 13:56:39.000000000 +0000 @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -78,8 +79,6 @@ unsigned long arch_get_unmapped_area(str } } -extern asmlinkage unsigned long sys_brk(unsigned long brk); - asmlinkage unsigned long sparc_brk(unsigned long brk) { if(ARCH_SUN4C_SUN4) { --- diff/arch/sparc/kernel/sys_sunos.c 2003-09-17 12:28:03.000000000 +0100 +++ source/arch/sparc/kernel/sys_sunos.c 2004-02-23 13:56:39.000000000 +0000 @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -564,8 +565,6 @@ asmlinkage int sunos_pathconf(char *path } /* SunOS mount system call emulation */ -extern asmlinkage int -sys_select(int n, fd_set *inp, fd_set *outp, fd_set *exp, struct timeval *tvp); asmlinkage int sunos_select(int width, fd_set *inp, fd_set *outp, fd_set *exp, struct timeval *tvp) { @@ -621,11 +620,6 @@ struct sunos_nfs_mount_args { }; -extern asmlinkage int sys_connect(int fd, struct sockaddr *uservaddr, int addrlen); -extern asmlinkage int sys_socket(int family, int type, int protocol); -extern asmlinkage int sys_bind(int fd, struct sockaddr *umyaddr, int addrlen); - - /* Bind the socket on a local reserved port and connect it to the * remote server. This on Linux/i386 is done by the mount program, * not by the kernel. @@ -814,8 +808,6 @@ out: return ret; } -extern asmlinkage int sys_setsid(void); -extern asmlinkage int sys_setpgid(pid_t, pid_t); asmlinkage int sunos_setpgrp(pid_t pid, pid_t pgid) { @@ -1050,15 +1042,6 @@ static inline int check_nonblock(int ret return ret; } -extern asmlinkage ssize_t sys_read(unsigned int fd,char *buf,int count); -extern asmlinkage ssize_t sys_write(unsigned int fd,char *buf,int count); -extern asmlinkage int sys_recv(int fd, void * ubuf, int size, unsigned flags); -extern asmlinkage int sys_send(int fd, void * buff, int len, unsigned flags); -extern asmlinkage int sys_accept(int fd, struct sockaddr *sa, int *addrlen); -extern asmlinkage int sys_readv(unsigned long fd, const struct iovec * vector, long count); -extern asmlinkage int sys_writev(unsigned long fd, const struct iovec * vector, long count); - - asmlinkage int sunos_read(unsigned int fd,char *buf,int count) { int ret; @@ -1164,9 +1147,6 @@ sunos_sigaction(int sig, const struct ol } -extern asmlinkage int sys_setsockopt(int fd, int level, int optname, char *optval, int optlen); -extern asmlinkage int sys_getsockopt(int fd, int level, int optname, char *optval, int *optlen); - asmlinkage int sunos_setsockopt(int fd, int level, int optname, char *optval, int optlen) { --- diff/arch/sparc/kernel/time.c 2003-12-19 09:51:02.000000000 +0000 +++ source/arch/sparc/kernel/time.c 2004-02-23 13:56:39.000000000 +0000 @@ -535,6 +535,7 @@ int do_settimeofday(struct timespec *tv) write_seqlock_irq(&xtime_lock); ret = bus_do_settimeofday(tv); write_sequnlock_irq(&xtime_lock); + clock_was_set(); return ret; } --- diff/arch/sparc/kernel/trampoline.S 2003-05-21 11:50:14.000000000 +0100 +++ source/arch/sparc/kernel/trampoline.S 2004-02-23 13:56:39.000000000 +0000 @@ -6,7 +6,6 @@ */ #include -#include #include #include #include @@ -15,8 +14,8 @@ #include #include - .globl C_LABEL(sun4m_cpu_startup), C_LABEL(__smp4m_processor_id) - .globl C_LABEL(sun4d_cpu_startup), C_LABEL(__smp4d_processor_id) + .globl sun4m_cpu_startup, __smp4m_processor_id + .globl sun4d_cpu_startup, __smp4d_processor_id __INIT .align 4 @@ -26,21 +25,21 @@ * in and sets PIL in %psr to 15, no irqs. */ -C_LABEL(sun4m_cpu_startup): +sun4m_cpu_startup: cpu1_startup: - sethi %hi(C_LABEL(trapbase_cpu1)), %g3 + sethi %hi(trapbase_cpu1), %g3 b 1f - or %g3, %lo(C_LABEL(trapbase_cpu1)), %g3 + or %g3, %lo(trapbase_cpu1), %g3 cpu2_startup: - sethi %hi(C_LABEL(trapbase_cpu2)), %g3 + sethi %hi(trapbase_cpu2), %g3 b 1f - or %g3, %lo(C_LABEL(trapbase_cpu2)), %g3 + or %g3, %lo(trapbase_cpu2), %g3 cpu3_startup: - sethi %hi(C_LABEL(trapbase_cpu3)), %g3 + sethi %hi(trapbase_cpu3), %g3 b 1f - or %g3, %lo(C_LABEL(trapbase_cpu3)), %g3 + or %g3, %lo(trapbase_cpu3), %g3 1: /* Set up a sane %psr -- PIL<0xf> S<0x1> PS<0x1> CWP<0x0> */ @@ -58,7 +57,7 @@ cpu3_startup: WRITE_PAUSE /* Give ourselves a stack and curptr. */ - set C_LABEL(current_set), %g5 + set current_set, %g5 srl %g3, 10, %g4 and %g4, 0xc, %g4 ld [%g5 + %g4], %g6 @@ -73,13 +72,13 @@ cpu3_startup: WRITE_PAUSE /* Init our caches, etc. */ - set C_LABEL(poke_srmmu), %g5 + set poke_srmmu, %g5 ld [%g5], %g5 call %g5 nop /* Start this processor. */ - call C_LABEL(smp4m_callin) + call smp4m_callin nop b,a smp_do_cpu_idle @@ -88,22 +87,22 @@ cpu3_startup: .align 4 smp_do_cpu_idle: - call C_LABEL(init_idle) + call init_idle nop - call C_LABEL(cpu_idle) + call cpu_idle mov 0, %o0 - call C_LABEL(cpu_panic) + call cpu_panic nop -C_LABEL(__smp4m_processor_id): +__smp4m_processor_id: rd %tbr, %g2 srl %g2, 12, %g2 and %g2, 3, %g2 retl mov %g1, %o7 -C_LABEL(__smp4d_processor_id): +__smp4d_processor_id: lda [%g0] ASI_M_VIKING_TMP1, %g2 retl mov %g1, %o7 @@ -114,7 +113,7 @@ C_LABEL(__smp4d_processor_id): __INIT .align 4 -C_LABEL(sun4d_cpu_startup): +sun4d_cpu_startup: /* Set up a sane %psr -- PIL<0xf> S<0x1> PS<0x1> CWP<0x0> */ set (PSR_PIL | PSR_S | PSR_PS), %g1 wr %g1, 0x0, %psr ! traps off though @@ -126,7 +125,7 @@ C_LABEL(sun4d_cpu_startup): WRITE_PAUSE /* Set tbr - we use just one trap table. */ - set C_LABEL(trapbase), %g1 + set trapbase, %g1 wr %g1, 0x0, %tbr WRITE_PAUSE @@ -138,7 +137,7 @@ C_LABEL(sun4d_cpu_startup): sta %g1, [%g0] ASI_M_VIKING_TMP1 /* Give ourselves a stack and curptr. */ - set C_LABEL(current_set), %g5 + set current_set, %g5 srl %g3, 1, %g4 ld [%g5 + %g4], %g6 @@ -152,13 +151,13 @@ C_LABEL(sun4d_cpu_startup): WRITE_PAUSE /* Init our caches, etc. */ - set C_LABEL(poke_srmmu), %g5 + set poke_srmmu, %g5 ld [%g5], %g5 call %g5 nop /* Start this processor. */ - call C_LABEL(smp4d_callin) + call smp4d_callin nop b,a smp_do_cpu_idle --- diff/arch/sparc/kernel/wof.S 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/sparc/kernel/wof.S 2004-02-23 13:56:39.000000000 +0000 @@ -4,7 +4,6 @@ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) */ -#include #include #include #include @@ -164,8 +163,8 @@ spwin_fromuser: * the label 'spwin_user_stack_is_bolixed' which will take * care of things at that point. */ - .globl C_LABEL(spwin_mmu_patchme) -C_LABEL(spwin_mmu_patchme): b C_LABEL(spwin_sun4c_stackchk) + .globl spwin_mmu_patchme +spwin_mmu_patchme: b spwin_sun4c_stackchk andcc %sp, 0x7, %g0 spwin_good_ustack: @@ -253,7 +252,7 @@ spnwin_patch3: and %twin_tmp, 0xff, %twi /* Turn on traps and call c-code to deal with it. */ wr %t_psr, PSR_ET, %psr nop - call C_LABEL(window_overflow_fault) + call window_overflow_fault nop /* Return from trap if C-code actually fixes things, if it @@ -307,8 +306,8 @@ spwin_bad_ustack_from_kernel: * As noted above %curptr cannot be touched by this routine at all. */ - .globl C_LABEL(spwin_sun4c_stackchk) -C_LABEL(spwin_sun4c_stackchk): + .globl spwin_sun4c_stackchk +spwin_sun4c_stackchk: /* LOCATION: Window to be saved on the stack */ /* See if the stack is in the address space hole but first, @@ -379,8 +378,8 @@ spwin_sun4c_onepage: * works for all current v8/srmmu implementations, we'll * see... */ - .globl C_LABEL(spwin_srmmu_stackchk) -C_LABEL(spwin_srmmu_stackchk): + .globl spwin_srmmu_stackchk +spwin_srmmu_stackchk: /* LOCATION: Window to be saved on the stack */ /* Because of SMP concerns and speed we play a trick. --- diff/arch/sparc/kernel/wuf.S 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/sparc/kernel/wuf.S 2004-02-23 13:56:39.000000000 +0000 @@ -4,7 +4,6 @@ * Copyright (C) 1995 David S. Miller */ -#include #include #include #include @@ -135,8 +134,8 @@ fwin_from_user: /* Branch to the architecture specific stack validation * routine. They can be found below... */ - .globl C_LABEL(fwin_mmu_patchme) -C_LABEL(fwin_mmu_patchme): b C_LABEL(sun4c_fwin_stackchk) + .globl fwin_mmu_patchme +fwin_mmu_patchme: b sun4c_fwin_stackchk andcc %sp, 0x7, %g0 #define STACK_OFFSET (THREAD_SIZE - TRACEREG_SZ - STACKFRAME_SZ) @@ -190,7 +189,7 @@ fwin_user_stack_is_bolixed: wr %t_psr, PSR_ET, %psr ! enable traps nop - call C_LABEL(window_underflow_fault) + call window_underflow_fault mov %g4, %o0 b ret_trap_entry @@ -244,8 +243,8 @@ fwin_user_finish_up: */ .align 4 - .globl C_LABEL(sun4c_fwin_stackchk) -C_LABEL(sun4c_fwin_stackchk): + .globl sun4c_fwin_stackchk +sun4c_fwin_stackchk: /* LOCATION: Window 'W' */ /* Caller did 'andcc %sp, 0x7, %g0' */ @@ -295,8 +294,8 @@ sun4c_fwin_onepage: /* A page had bad page permissions, losing... */ b,a fwin_user_stack_is_bolixed - .globl C_LABEL(srmmu_fwin_stackchk) -C_LABEL(srmmu_fwin_stackchk): + .globl srmmu_fwin_stackchk +srmmu_fwin_stackchk: /* LOCATION: Window 'W' */ /* Caller did 'andcc %sp, 0x7, %g0' */ --- diff/arch/sparc/lib/Makefile 2003-06-30 10:07:20.000000000 +0100 +++ source/arch/sparc/lib/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -7,5 +7,5 @@ EXTRA_AFLAGS := -ansi -DST_DIV0=0x02 lib-y := mul.o rem.o sdiv.o udiv.o umul.o urem.o ashrdi3.o memcpy.o memset.o \ strlen.o checksum.o blockops.o memscan.o memcmp.o strncmp.o \ strncpy_from_user.o divdi3.o udivdi3.o strlen_user.o \ - copy_user.o locks.o atomic.o bitops.o debuglocks.o lshrdi3.o \ - ashldi3.o rwsem.o muldi3.o bitext.o + copy_user.o locks.o atomic.o atomic32.o bitops.o debuglocks.o \ + lshrdi3.o ashldi3.o rwsem.o muldi3.o bitext.o --- diff/arch/sparc/lib/ashldi3.S 2002-10-16 04:27:16.000000000 +0100 +++ source/arch/sparc/lib/ashldi3.S 2004-02-23 13:56:39.000000000 +0000 @@ -5,12 +5,10 @@ * Copyright (C) 1999 David S. Miller (davem@redhat.com) */ -#include - .text .align 4 - .globl C_LABEL(__ashldi3) -C_LABEL(__ashldi3): + .globl __ashldi3 +__ashldi3: cmp %o2, 0 be 9f mov 0x20, %g2 --- diff/arch/sparc/lib/ashrdi3.S 2002-10-16 04:28:24.000000000 +0100 +++ source/arch/sparc/lib/ashrdi3.S 2004-02-23 13:56:39.000000000 +0000 @@ -5,12 +5,10 @@ * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) */ -#include - .text .align 4 - .globl C_LABEL(__ashrdi3) -C_LABEL(__ashrdi3): + .globl __ashrdi3 +__ashrdi3: tst %o2 be 3f or %g0, 32, %g2 --- diff/arch/sparc/lib/atomic.S 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/sparc/lib/atomic.S 2004-02-23 13:56:39.000000000 +0000 @@ -4,7 +4,6 @@ */ #include -#include #include #include --- diff/arch/sparc/lib/bitops.S 2002-10-16 04:28:31.000000000 +0100 +++ source/arch/sparc/lib/bitops.S 2004-02-23 13:56:39.000000000 +0000 @@ -4,7 +4,6 @@ */ #include -#include #include #include @@ -29,7 +28,7 @@ ___set_bit: wr %g5, 0x0, %psr nop; nop; nop #ifdef CONFIG_SMP - set C_LABEL(bitops_spinlock), %g5 + set bitops_spinlock, %g5 2: ldstub [%g5], %g7 ! Spin on the byte lock for SMP. orcc %g7, 0x0, %g0 ! Did we get it? bne 2b ! Nope... @@ -39,7 +38,7 @@ ___set_bit: and %g7, %g2, %g2 #ifdef CONFIG_SMP st %g5, [%g1] - set C_LABEL(bitops_spinlock), %g5 + set bitops_spinlock, %g5 stb %g0, [%g5] #else st %g5, [%g1] @@ -58,7 +57,7 @@ ___clear_bit: wr %g5, 0x0, %psr nop; nop; nop #ifdef CONFIG_SMP - set C_LABEL(bitops_spinlock), %g5 + set bitops_spinlock, %g5 2: ldstub [%g5], %g7 ! Spin on the byte lock for SMP. orcc %g7, 0x0, %g0 ! Did we get it? bne 2b ! Nope... @@ -68,7 +67,7 @@ ___clear_bit: and %g7, %g2, %g2 #ifdef CONFIG_SMP st %g5, [%g1] - set C_LABEL(bitops_spinlock), %g5 + set bitops_spinlock, %g5 stb %g0, [%g5] #else st %g5, [%g1] @@ -87,7 +86,7 @@ ___change_bit: wr %g5, 0x0, %psr nop; nop; nop #ifdef CONFIG_SMP - set C_LABEL(bitops_spinlock), %g5 + set bitops_spinlock, %g5 2: ldstub [%g5], %g7 ! Spin on the byte lock for SMP. orcc %g7, 0x0, %g0 ! Did we get it? bne 2b ! Nope... @@ -97,7 +96,7 @@ ___change_bit: and %g7, %g2, %g2 #ifdef CONFIG_SMP st %g5, [%g1] - set C_LABEL(bitops_spinlock), %g5 + set bitops_spinlock, %g5 stb %g0, [%g5] #else st %g5, [%g1] --- diff/arch/sparc/lib/blockops.S 2003-05-21 11:49:45.000000000 +0100 +++ source/arch/sparc/lib/blockops.S 2004-02-23 13:56:39.000000000 +0000 @@ -4,7 +4,6 @@ * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) */ -#include #include /* Zero out 64 bytes of memory at (buf + offset). @@ -46,9 +45,9 @@ .text .align 4 - .globl C_LABEL(bzero_1page), C_LABEL(__copy_1page) + .globl bzero_1page, __copy_1page -C_LABEL(bzero_1page): +bzero_1page: /* NOTE: If you change the number of insns of this routine, please check * arch/sparc/mm/hypersparc.S */ /* %o0 = buf */ @@ -67,7 +66,7 @@ C_LABEL(bzero_1page): retl nop -C_LABEL(__copy_1page): +__copy_1page: /* NOTE: If you change the number of insns of this routine, please check * arch/sparc/mm/hypersparc.S */ /* %o0 = dst, %o1 = src */ --- diff/arch/sparc/lib/checksum.S 2003-09-30 15:46:12.000000000 +0100 +++ source/arch/sparc/lib/checksum.S 2004-02-23 13:56:39.000000000 +0000 @@ -13,7 +13,6 @@ * BSD4.4 portable checksum routine */ -#include #include #define CSUM_BIGCHUNK(buf, offset, sum, t0, t1, t2, t3, t4, t5) \ @@ -104,8 +103,8 @@ csum_partial_fix_alignment: /* The common case is to get called with a nicely aligned * buffer of size 0x20. Follow the code path for that case. */ - .globl C_LABEL(csum_partial) -C_LABEL(csum_partial): /* %o0=buf, %o1=len, %o2=sum */ + .globl csum_partial +csum_partial: /* %o0=buf, %o1=len, %o2=sum */ andcc %o0, 0x7, %g0 ! alignment problems? bne csum_partial_fix_alignment ! yep, handle it sethi %hi(cpte - 8), %g7 ! prepare table jmp ptr @@ -142,8 +141,8 @@ cpte: bne csum_partial_end_cruft ! yep cpout: retl ! get outta here mov %o2, %o0 ! return computed csum - .globl C_LABEL(__csum_partial_copy_start), C_LABEL(__csum_partial_copy_end) -C_LABEL(__csum_partial_copy_start): + .globl __csum_partial_copy_start, __csum_partial_copy_end +__csum_partial_copy_start: /* Work around cpp -rob */ #define ALLOC #alloc @@ -329,8 +328,8 @@ cc_dword_align: * out of you, game over, lights out. */ .align 8 - .globl C_LABEL(__csum_partial_copy_sparc_generic) -C_LABEL(__csum_partial_copy_sparc_generic): + .globl __csum_partial_copy_sparc_generic +__csum_partial_copy_sparc_generic: /* %o0=src, %o1=dest, %g1=len, %g7=sum */ xor %o0, %o1, %o4 ! get changing bits andcc %o4, 3, %g0 ! check for mismatched alignment @@ -472,7 +471,7 @@ ccslow: cmp %g1, 0 4: addcc %g7, %g5, %g7 retl addx %g0, %g7, %o0 -C_LABEL(__csum_partial_copy_end): +__csum_partial_copy_end: /* We do these strange calculations for the csum_*_from_user case only, ie. * we only bother with faults on loads... */ @@ -551,7 +550,7 @@ C_LABEL(__csum_partial_copy_end): mov %i5, %o0 mov %i7, %o1 mov %i4, %o2 - call C_LABEL(lookup_fault) + call lookup_fault mov %g7, %i4 cmp %o0, 2 bne 1f @@ -561,7 +560,7 @@ C_LABEL(__csum_partial_copy_end): mov %i0, %o1 mov %i1, %o0 5: - call C_LABEL(__memcpy) + call __memcpy mov %i2, %o2 tst %o0 bne,a 2f @@ -570,7 +569,7 @@ C_LABEL(__csum_partial_copy_end): 2: mov %i1, %o0 6: - call C_LABEL(__bzero) + call __bzero mov %i3, %o1 1: ld [%sp + 168], %o2 ! struct_ptr of parent --- diff/arch/sparc/lib/copy_user.S 2003-09-30 15:46:12.000000000 +0100 +++ source/arch/sparc/lib/copy_user.S 2004-02-23 13:56:39.000000000 +0000 @@ -11,7 +11,6 @@ * Returns 0 if successful, otherwise count of bytes not copied yet */ -#include #include #include #include @@ -118,7 +117,7 @@ .globl __copy_user_begin __copy_user_begin: - .globl C_LABEL(__copy_user) + .globl __copy_user dword_align: andcc %o1, 1, %g0 be 4f @@ -145,7 +144,7 @@ dword_align: b 3f add %o0, 2, %o0 -C_LABEL(__copy_user): /* %o0=dst %o1=src %o2=len */ +__copy_user: /* %o0=dst %o1=src %o2=len */ xor %o0, %o1, %o4 1: andcc %o4, 3, %o5 --- diff/arch/sparc/lib/locks.S 2002-10-16 04:29:02.000000000 +0100 +++ source/arch/sparc/lib/locks.S 2004-02-23 13:56:39.000000000 +0000 @@ -6,7 +6,6 @@ * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz) */ -#include #include #include #include --- diff/arch/sparc/lib/lshrdi3.S 2002-10-16 04:27:55.000000000 +0100 +++ source/arch/sparc/lib/lshrdi3.S 2004-02-23 13:56:39.000000000 +0000 @@ -1,9 +1,7 @@ /* $Id: lshrdi3.S,v 1.1 1999/03/21 06:37:45 davem Exp $ */ -#include - - .globl C_LABEL(__lshrdi3) -C_LABEL(__lshrdi3): + .globl __lshrdi3 +__lshrdi3: cmp %o2, 0 be 3f mov 0x20, %g2 --- diff/arch/sparc/lib/memcmp.S 2002-10-16 04:28:33.000000000 +0100 +++ source/arch/sparc/lib/memcmp.S 2004-02-23 13:56:39.000000000 +0000 @@ -1,10 +1,8 @@ -#include - .text .align 4 - .global C_LABEL(__memcmp), C_LABEL(memcmp) -C_LABEL(__memcmp): -C_LABEL(memcmp): + .global __memcmp, memcmp +__memcmp: +memcmp: #if 1 cmp %o2, 0 ble L3 --- diff/arch/sparc/lib/memcpy.S 2002-10-16 04:29:06.000000000 +0100 +++ source/arch/sparc/lib/memcpy.S 2004-02-23 13:56:39.000000000 +0000 @@ -9,13 +9,11 @@ #ifdef __KERNEL__ -#include - #define FUNC(x) \ - .globl C_LABEL(x); \ - .type C_LABEL(x),@function; \ + .globl x; \ + .type x,@function; \ .align 4; \ -C_LABEL(x): +x: #undef FASTER_REVERSE #undef FASTER_NONALIGNED --- diff/arch/sparc/lib/memscan.S 2002-10-16 04:27:53.000000000 +0100 +++ source/arch/sparc/lib/memscan.S 2004-02-23 13:56:39.000000000 +0000 @@ -4,8 +4,6 @@ * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) */ -#include - /* In essence, this is just a fancy strlen. */ #define LO_MAGIC 0x01010101 @@ -13,9 +11,9 @@ .text .align 4 - .globl C_LABEL(__memscan_zero), C_LABEL(__memscan_generic) - .globl C_LABEL(memscan) -C_LABEL(__memscan_zero): + .globl __memscan_zero, __memscan_generic + .globl memscan +__memscan_zero: /* %o0 = addr, %o1 = size */ cmp %o1, 0 bne,a 1f @@ -114,8 +112,8 @@ mzero_found_it: retl sub %o0, 2, %o0 -C_LABEL(memscan): -C_LABEL(__memscan_generic): +memscan: +__memscan_generic: /* %o0 = addr, %o1 = c, %o2 = size */ cmp %o2, 0 bne,a 0f --- diff/arch/sparc/lib/memset.S 2003-09-30 15:46:12.000000000 +0100 +++ source/arch/sparc/lib/memset.S 2004-02-23 13:56:39.000000000 +0000 @@ -7,7 +7,6 @@ * occurs and we were called as clear_user. */ -#include #include /* Work around cpp -rob */ @@ -61,12 +60,12 @@ .globl __bzero_begin __bzero_begin: - .globl C_LABEL(__bzero), C_LABEL(__memset), - .globl C_LABEL(memset) - .globl C_LABEL(__memset_start), C_LABEL(__memset_end) -C_LABEL(__memset_start): -C_LABEL(__memset): -C_LABEL(memset): + .globl __bzero, __memset, + .globl memset + .globl __memset_start, __memset_end +__memset_start: +__memset: +memset: and %o1, 0xff, %g3 sll %g3, 8, %g2 or %g3, %g2, %g3 @@ -90,7 +89,7 @@ C_LABEL(memset): b 4f sub %o0, %o2, %o0 -C_LABEL(__bzero): +__bzero: mov %g0, %g3 1: cmp %o1, 7 @@ -168,7 +167,7 @@ C_LABEL(__bzero): 0: retl clr %o0 -C_LABEL(__memset_end): +__memset_end: .section .fixup,#alloc,#execinstr .align 4 @@ -195,7 +194,7 @@ C_LABEL(__memset_end): save %sp, -104, %sp mov %i5, %o0 mov %i7, %o1 - call C_LABEL(lookup_fault) + call lookup_fault mov %i4, %o2 ret restore --- diff/arch/sparc/lib/strlen.S 2002-10-16 04:28:32.000000000 +0100 +++ source/arch/sparc/lib/strlen.S 2004-02-23 13:56:39.000000000 +0000 @@ -5,8 +5,6 @@ * Copyright (C) 1996 Jakub Jelinek (jj@sunsite.mff.cuni.cz) */ -#include - #define LO_MAGIC 0x01010101 #define HI_MAGIC 0x80808080 @@ -42,8 +40,8 @@ mov 2, %o0 .align 4 - .global C_LABEL(strlen) -C_LABEL(strlen): + .global strlen +strlen: mov %o0, %o1 andcc %o0, 3, %g0 bne 0b --- diff/arch/sparc/lib/strlen_user.S 2002-10-16 04:27:57.000000000 +0100 +++ source/arch/sparc/lib/strlen_user.S 2004-02-23 13:56:39.000000000 +0000 @@ -8,8 +8,6 @@ * Copyright (C) 1996 Jakub Jelinek (jj@sunsite.mff.cuni.cz) */ -#include - #define LO_MAGIC 0x01010101 #define HI_MAGIC 0x80808080 @@ -47,10 +45,10 @@ mov 3, %o0 .align 4 - .global C_LABEL(__strlen_user), C_LABEL(__strnlen_user) -C_LABEL(__strlen_user): + .global __strlen_user, __strnlen_user +__strlen_user: sethi %hi(32768), %o1 -C_LABEL(__strnlen_user): +__strnlen_user: mov %o1, %g1 mov %o0, %o1 andcc %o0, 3, %g0 --- diff/arch/sparc/lib/strncmp.S 2002-10-16 04:27:19.000000000 +0100 +++ source/arch/sparc/lib/strncmp.S 2004-02-23 13:56:39.000000000 +0000 @@ -3,13 +3,11 @@ * generic strncmp routine. */ -#include - .text .align 4 - .global C_LABEL(__strncmp), C_LABEL(strncmp) -C_LABEL(__strncmp): -C_LABEL(strncmp): + .global __strncmp, strncmp +__strncmp: +strncmp: mov %o0, %g3 mov 0, %o3 --- diff/arch/sparc/lib/strncpy_from_user.S 2002-10-16 04:28:28.000000000 +0100 +++ source/arch/sparc/lib/strncpy_from_user.S 2004-02-23 13:56:39.000000000 +0000 @@ -3,7 +3,6 @@ * Copyright(C) 1996 David S. Miller */ -#include #include #include @@ -17,8 +16,8 @@ * bytes copied if we hit a null byte */ - .globl C_LABEL(__strncpy_from_user) -C_LABEL(__strncpy_from_user): + .globl __strncpy_from_user +__strncpy_from_user: /* %o0=dest, %o1=src, %o2=count */ mov %o2, %o3 1: --- diff/arch/sparc/math-emu/Makefile 2002-12-16 09:26:06.000000000 +0000 +++ source/arch/sparc/math-emu/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -2,7 +2,7 @@ # Makefile for the FPU instruction emulation. # -obj-y := math.o ashldi3.o +obj-y := math.o EXTRA_AFLAGS := -ansi EXTRA_CFLAGS = -I. -I$(TOPDIR)/include/math-emu -w --- diff/arch/sparc/mm/viking.S 2002-11-11 11:09:36.000000000 +0000 +++ source/arch/sparc/mm/viking.S 2004-02-23 13:56:39.000000000 +0000 @@ -15,7 +15,6 @@ #include #include #include -#include #include #ifdef CONFIG_SMP --- diff/arch/sparc/prom/printf.c 2002-10-16 04:27:16.000000000 +0100 +++ source/arch/sparc/prom/printf.c 2004-02-23 13:56:39.000000000 +0000 @@ -39,7 +39,7 @@ prom_printf(char *fmt, ...) int i; va_start(args, fmt); - i = vsnprintf(ppbuf, sizeof(ppbuf), fmt, args); + i = vscnprintf(ppbuf, sizeof(ppbuf), fmt, args); va_end(args); prom_write(ppbuf, i); --- diff/arch/sparc64/Kconfig 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/sparc64/Kconfig 2004-02-23 13:56:39.000000000 +0000 @@ -186,24 +186,6 @@ config SPARC64 SPARC64 ports; its web page is available at . -config HOTPLUG - bool "Support for hot-pluggable devices" - ---help--- - Say Y here if you want to plug devices into your computer while - the system is running, and be able to use them quickly. In many - cases, the devices can likewise be unplugged at any time too. - - One well known example of this is PCMCIA- or PC-cards, credit-card - size devices such as network cards, modems or hard drives which are - plugged into slots found on all modern laptop computers. Another - example, used on modern desktops as well as laptops, is USB. - - Enable HOTPLUG and KMOD, and build a modular kernel. Get agent - software (at ) and install it. - Then your kernel will automatically call out to a user mode "policy - agent" (/sbin/hotplug) to load modules and set up software needed - to use devices as you hotplug them. - # Global things across all Sun machines. config RWSEM_GENERIC_SPINLOCK bool @@ -718,12 +700,19 @@ config DEBUG_BOOTMEM depends on DEBUG_KERNEL bool "Debug BOOTMEM initialization" +config LOCKMETER + bool "Kernel lock metering" + depends on SMP && !PREEMPT + help + Say Y to enable kernel lock metering, which adds overhead to SMP locks, + but allows you to see various statistics using the lockstat command. + # We have a custom atomic_dec_and_lock() implementation but it's not # compatible with spinlock debugging so we need to fall back on # the generic version in that case. config HAVE_DEC_LOCK bool - depends on SMP && !DEBUG_SPINLOCK + depends on SMP && !DEBUG_SPINLOCK && !LOCKMETER default y config MCOUNT --- diff/arch/sparc64/defconfig 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/sparc64/defconfig 2004-02-23 13:56:39.000000000 +0000 @@ -120,6 +120,7 @@ CONFIG_FB=y CONFIG_FB_CG6=y # CONFIG_FB_RIVA is not set # CONFIG_FB_MATROX is not set +# CONFIG_FB_RADEON_OLD is not set # CONFIG_FB_RADEON is not set # CONFIG_FB_ATY128 is not set # CONFIG_FB_ATY is not set @@ -233,6 +234,7 @@ CONFIG_IDE_TASKFILE_IO=y # # IDE chipset support/bugfixes # +CONFIG_IDE_GENERIC=y CONFIG_BLK_DEV_IDEPCI=y # CONFIG_IDEPCI_SHARE_IRQ is not set # CONFIG_BLK_DEV_OFFBOARD is not set @@ -253,6 +255,7 @@ CONFIG_BLK_DEV_CY82C693=m CONFIG_BLK_DEV_CS5520=m CONFIG_BLK_DEV_CS5530=m CONFIG_BLK_DEV_HPT34X=m +# CONFIG_HPT34X_AUTODMA is not set CONFIG_BLK_DEV_HPT366=m CONFIG_BLK_DEV_SC1200=m CONFIG_BLK_DEV_PIIX=m @@ -340,15 +343,16 @@ CONFIG_SCSI_QLOGIC_FC=y CONFIG_SCSI_QLOGIC_FC_FIRMWARE=y # CONFIG_SCSI_QLOGIC_1280 is not set CONFIG_SCSI_QLOGICPTI=m -CONFIG_SCSI_QLA2XXX_CONFIG=y -CONFIG_SCSI_QLA2XXX=m -CONFIG_SCSI_QLA21XX=m -CONFIG_SCSI_QLA22XX=m -CONFIG_SCSI_QLA23XX=m +CONFIG_SCSI_QLA2XXX=y +# CONFIG_SCSI_QLA21XX is not set +# CONFIG_SCSI_QLA22XX is not set +# CONFIG_SCSI_QLA2300 is not set +# CONFIG_SCSI_QLA2322 is not set +# CONFIG_SCSI_QLA6312 is not set +# CONFIG_SCSI_QLA6322 is not set CONFIG_SCSI_DC395x=m CONFIG_SCSI_DC390T=m # CONFIG_SCSI_DC390T_NOGENSUPP is not set -# CONFIG_SCSI_NSP32 is not set CONFIG_SCSI_DEBUG=m CONFIG_SCSI_SUNESP=y @@ -382,6 +386,7 @@ CONFIG_MD_RAID6=m CONFIG_MD_MULTIPATH=m CONFIG_BLK_DEV_DM=m # CONFIG_DM_IOCTL_V4 is not set +CONFIG_DM_CRYPT=m # # Fusion MPT device support @@ -615,7 +620,6 @@ CONFIG_XFRM_USER=m # CONFIG_IPV6_SCTP__=m CONFIG_IP_SCTP=m -# CONFIG_SCTP_ADLER32 is not set # CONFIG_SCTP_DBG_MSG is not set # CONFIG_SCTP_DBG_OBJCNT is not set # CONFIG_SCTP_HMAC_NONE is not set @@ -649,6 +653,7 @@ CONFIG_NET_DIVERT=y CONFIG_NET_SCHED=y CONFIG_NET_SCH_CBQ=m CONFIG_NET_SCH_HTB=m +CONFIG_NET_SCH_HFSC=m CONFIG_NET_SCH_CSZ=m CONFIG_NET_SCH_ATM=y CONFIG_NET_SCH_PRIO=m @@ -709,6 +714,8 @@ CONFIG_DE2104X=m CONFIG_TULIP=m # CONFIG_TULIP_MWI is not set # CONFIG_TULIP_MMIO is not set +CONFIG_TULIP_NAPI=y +CONFIG_TULIP_NAPI_HW_MITIGATION=y CONFIG_DE4X5=m CONFIG_WINBOND_840=m # CONFIG_DM9102 is not set @@ -724,6 +731,7 @@ CONFIG_DGRS=m CONFIG_EEPRO100=m # CONFIG_EEPRO100_PIO is not set CONFIG_E100=m +CONFIG_E100_NAPI=y CONFIG_FEALNX=m CONFIG_NATSEMI=m CONFIG_NE2K_PCI=m @@ -733,6 +741,7 @@ CONFIG_8139TOO=m # CONFIG_8139TOO_TUNE_TWISTER is not set # CONFIG_8139TOO_8129 is not set # CONFIG_8139_OLD_RX_RESET is not set +CONFIG_8139_RXBUF_IDX=1 CONFIG_SIS900=m CONFIG_EPIC100=m CONFIG_SUNDANCE=m @@ -800,6 +809,8 @@ CONFIG_HERMES=m CONFIG_PLX_HERMES=m CONFIG_TMD_HERMES=m CONFIG_PCI_HERMES=m +CONFIG_ATMEL=m +CONFIG_PCI_ATMEL=m CONFIG_NET_WIRELESS=y # @@ -904,6 +915,7 @@ CONFIG_IRDA_FAST_RR=y # FIR device drivers # # CONFIG_USB_IRDA is not set +CONFIG_SIGMATEL_FIR=m # CONFIG_TOSHIBA_FIR is not set # CONFIG_VLSI_FIR is not set @@ -936,17 +948,20 @@ CONFIG_BT_HCIVHCI=m # # ISDN subsystem # -CONFIG_ISDN_BOOL=y +CONFIG_ISDN=m + +# +# Old ISDN4Linux +# +# CONFIG_ISDN_I4L is not set # # CAPI subsystem # CONFIG_ISDN_CAPI=m -CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y -CONFIG_ISDN_CAPI_MIDDLEWARE=y +# CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON is not set +# CONFIG_ISDN_CAPI_MIDDLEWARE is not set CONFIG_ISDN_CAPI_CAPI20=m -CONFIG_ISDN_CAPI_CAPIFS_BOOL=y -CONFIG_ISDN_CAPI_CAPIFS=m # # CAPI hardware drivers @@ -955,12 +970,18 @@ CONFIG_ISDN_CAPI_CAPIFS=m # # Active AVM cards # -# CONFIG_CAPI_AVM is not set +CONFIG_CAPI_AVM=y # # Active Eicon DIVA Server cards # -# CONFIG_CAPI_EICON is not set +CONFIG_CAPI_EICON=y +CONFIG_ISDN_DIVAS=m +CONFIG_ISDN_DIVAS_BRIPCI=y +CONFIG_ISDN_DIVAS_PRIPCI=y +CONFIG_ISDN_DIVAS_DIVACAPI=m +CONFIG_ISDN_DIVAS_USERIDI=m +CONFIG_ISDN_DIVAS_MAINT=m # # Telephony Support @@ -1080,6 +1101,8 @@ CONFIG_I2C_SENSOR=m CONFIG_SENSORS_ADM1021=m CONFIG_SENSORS_ASB100=m CONFIG_SENSORS_EEPROM=m +CONFIG_SENSORS_FSCHER=m +CONFIG_SENSORS_GL518SM=m CONFIG_SENSORS_IT87=m CONFIG_SENSORS_LM75=m CONFIG_SENSORS_LM78=m @@ -1100,11 +1123,11 @@ CONFIG_EXT2_FS=y CONFIG_EXT2_FS_XATTR=y CONFIG_EXT2_FS_POSIX_ACL=y CONFIG_EXT2_FS_SECURITY=y -CONFIG_EXT3_FS=m +CONFIG_EXT3_FS=y CONFIG_EXT3_FS_XATTR=y CONFIG_EXT3_FS_POSIX_ACL=y CONFIG_EXT3_FS_SECURITY=y -CONFIG_JBD=m +CONFIG_JBD=y # CONFIG_JBD_DEBUG is not set CONFIG_FS_MBCACHE=y # CONFIG_REISERFS_FS is not set @@ -1116,6 +1139,7 @@ CONFIG_FS_POSIX_ACL=y CONFIG_XFS_FS=m # CONFIG_XFS_RT is not set CONFIG_XFS_QUOTA=y +CONFIG_XFS_SECURITY=y CONFIG_XFS_POSIX_ACL=y CONFIG_MINIX_FS=m CONFIG_ROMFS_FS=m @@ -1145,7 +1169,9 @@ CONFIG_VFAT_FS=m # CONFIG_PROC_FS=y CONFIG_PROC_KCORE=y -# CONFIG_DEVFS_FS is not set +CONFIG_DEVFS_FS=y +CONFIG_DEVFS_MOUNT=y +# CONFIG_DEVFS_DEBUG is not set CONFIG_DEVPTS_FS=y CONFIG_DEVPTS_FS_XATTR=y # CONFIG_DEVPTS_FS_SECURITY is not set @@ -1205,7 +1231,6 @@ CONFIG_NCP_FS=m # CONFIG_NCPFS_EXTRAS is not set CONFIG_CODA_FS=m # CONFIG_CODA_FS_OLD_API is not set -# CONFIG_INTERMEZZO_FS is not set CONFIG_AFS_FS=m CONFIG_RXRPC=m @@ -1386,6 +1411,7 @@ CONFIG_SND_VIRMIDI=m # CONFIG_SND_ALI5451=m CONFIG_SND_AZT3328=m +CONFIG_SND_BT87X=m CONFIG_SND_CS46XX=m # CONFIG_SND_CS46XX_NEW_DSP is not set CONFIG_SND_CS4281=m @@ -1488,7 +1514,6 @@ CONFIG_USB_KBTAB=m # USB Imaging devices # CONFIG_USB_MDC800=m -CONFIG_USB_SCANNER=m CONFIG_USB_MICROTEK=m CONFIG_USB_HPUSBSCSI=m @@ -1594,12 +1619,29 @@ CONFIG_USB_LCD=m CONFIG_USB_LED=m CONFIG_USB_SPEEDTOUCH=m CONFIG_USB_TEST=m + +# +# USB Gadget Support +# # CONFIG_USB_GADGET is not set # -# Watchdog +# Watchdog Cards +# +CONFIG_WATCHDOG=y +# CONFIG_WATCHDOG_NOWAYOUT is not set + +# +# Watchdog Device Drivers +# +CONFIG_SOFT_WATCHDOG=m + +# +# PCI-based Watchdog Cards # -# CONFIG_SOFT_WATCHDOG is not set +CONFIG_PCIPCWATCHDOG=m +CONFIG_WDTPCI=m +CONFIG_WDT_501_PCI=y # # Profiling support @@ -1619,6 +1661,7 @@ CONFIG_MAGIC_SYSRQ=y # CONFIG_DEBUG_DCFLUSH is not set # CONFIG_DEBUG_INFO is not set # CONFIG_STACK_DEBUG is not set +# CONFIG_DEBUG_BOOTMEM is not set CONFIG_HAVE_DEC_LOCK=y # --- diff/arch/sparc64/kernel/ioctl32.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/sparc64/kernel/ioctl32.c 2004-02-23 13:56:39.000000000 +0000 @@ -12,6 +12,7 @@ #define INCLUDES #include "compat_ioctl.c" #include +#include #include #include #include --- diff/arch/sparc64/kernel/irq.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/sparc64/kernel/irq.c 2004-02-23 13:56:39.000000000 +0000 @@ -1211,7 +1211,7 @@ static int irq_affinity_read_proc (char if (cpus_empty(mask)) mask = cpu_online_map; - len = cpumask_snprintf(page, count, mask); + len = cpumask_scnprintf(page, count, mask); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); --- diff/arch/sparc64/kernel/setup.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/sparc64/kernel/setup.c 2004-02-23 13:56:39.000000000 +0000 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -71,7 +72,6 @@ struct screen_info screen_info = { void (*prom_palette)(int); void (*prom_keyboard)(void); -asmlinkage void sys_sync(void); /* it's really int */ static void prom_console_write(struct console *con, const char *s, unsigned n) @@ -603,7 +603,7 @@ static int __init set_preferred_console( } console_initcall(set_preferred_console); -asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on) +asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int on) { return -EIO; } --- diff/arch/sparc64/kernel/sparc64_ksyms.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/sparc64/kernel/sparc64_ksyms.c 2004-02-23 13:56:39.000000000 +0000 @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -84,21 +85,13 @@ extern void syscall_trace(void); extern u32 sunos_sys_table[], sys_call_table32[]; extern void tl0_solaris(void); extern void sys_sigsuspend(void); -extern int sys_getppid(void); -extern int sys_getpid(void); -extern int sys_geteuid(void); -extern int sys_getuid(void); -extern int sys_getegid(void); -extern int sys_getgid(void); extern int svr4_getcontext(svr4_ucontext_t *uc, struct pt_regs *regs); extern int svr4_setcontext(svr4_ucontext_t *uc, struct pt_regs *regs); -extern int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg); extern int compat_sys_ioctl(unsigned int fd, unsigned int cmd, u32 arg); extern int (*handle_mathemu)(struct pt_regs *, struct fpustate *); extern long sparc32_open(const char * filename, int flags, int mode); extern int io_remap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long offset, unsigned long size, pgprot_t prot, int space); -extern long sys_close(unsigned int); - + extern int __ashrdi3(int, int); extern void dump_thread(struct pt_regs *, struct user *); --- diff/arch/sparc64/kernel/sunos_ioctl32.c 2003-05-21 11:50:14.000000000 +0100 +++ source/arch/sparc64/kernel/sunos_ioctl32.c 2004-02-23 13:56:39.000000000 +0000 @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -90,8 +91,6 @@ struct ifconf32 { compat_caddr_t ifcbuf; }; -extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg); - extern asmlinkage int compat_sys_ioctl(unsigned int, unsigned int, u32); extern asmlinkage int sys_setsid(void); --- diff/arch/sparc64/kernel/sys_sparc.c 2003-07-22 18:54:27.000000000 +0100 +++ source/arch/sparc64/kernel/sys_sparc.c 2004-02-23 13:56:39.000000000 +0000 @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -161,8 +162,6 @@ unsigned long get_fb_unmapped_area(struc return addr; } -extern asmlinkage unsigned long sys_brk(unsigned long brk); - asmlinkage unsigned long sparc_brk(unsigned long brk) { /* People could try to be nasty and use ta 0x6d in 32bit programs */ @@ -280,8 +279,6 @@ out: return err; } -extern asmlinkage int sys_newuname(struct new_utsname __user *name); - asmlinkage int sparc64_newuname(struct new_utsname __user *name) { int ret = sys_newuname(name); @@ -292,8 +289,6 @@ asmlinkage int sparc64_newuname(struct n return ret; } -extern asmlinkage long sys_personality(unsigned long); - asmlinkage int sparc64_personality(unsigned long personality) { int ret; --- diff/arch/sparc64/kernel/sys_sparc32.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/sparc64/kernel/sys_sparc32.c 2004-02-23 13:56:39.000000000 +0000 @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -88,17 +89,6 @@ __ret; \ }) -extern asmlinkage long sys_chown(const char *, uid_t,gid_t); -extern asmlinkage long sys_lchown(const char *, uid_t,gid_t); -extern asmlinkage long sys_fchown(unsigned int, uid_t,gid_t); -extern asmlinkage long sys_setregid(gid_t, gid_t); -extern asmlinkage long sys_setgid(gid_t); -extern asmlinkage long sys_setreuid(uid_t, uid_t); -extern asmlinkage long sys_setuid(uid_t); -extern asmlinkage long sys_setresuid(uid_t, uid_t, uid_t); -extern asmlinkage long sys_setresgid(gid_t, gid_t, gid_t); -extern asmlinkage long sys_setfsuid(uid_t); -extern asmlinkage long sys_setfsgid(gid_t); asmlinkage long sys32_chown16(const char * filename, u16 user, u16 group) { @@ -179,40 +169,81 @@ asmlinkage long sys32_setfsgid16(u16 gid return sys_setfsgid((gid_t)gid); } +static int groups16_to_user(u16 *grouplist, struct group_info *group_info) +{ + int i; + u16 group; + + for (i = 0; i < group_info->ngroups; i++) { + group = (u16)GROUP_AT(group_info, i); + if (put_user(group, grouplist+i)) + return -EFAULT; + } + + return 0; +} + +static int groups16_from_user(struct group_info *group_info, u16 *grouplist) +{ + int i; + u16 group; + + for (i = 0; i < group_info->ngroups; i++) { + if (get_user(group, grouplist+i)) + return -EFAULT; + GROUP_AT(group_info, i) = (gid_t)group; + } + + return 0; +} + asmlinkage long sys32_getgroups16(int gidsetsize, u16 *grouplist) { - u16 groups[NGROUPS]; - int i,j; + int i; if (gidsetsize < 0) return -EINVAL; - i = current->ngroups; + + get_group_info(current->group_info); + i = current->group_info->ngroups; if (gidsetsize) { - if (i > gidsetsize) - return -EINVAL; - for(j=0;jgroups[j]; - if (copy_to_user(grouplist, groups, sizeof(u16)*i)) - return -EFAULT; + if (i > gidsetsize) { + i = -EINVAL; + goto out; + } + if (groups16_to_user(grouplist, current->group_info)) { + i = -EFAULT; + goto out; + } } +out: + put_group_info(current->group_info); return i; } asmlinkage long sys32_setgroups16(int gidsetsize, u16 *grouplist) { - u16 groups[NGROUPS]; - int i; + struct group_info *group_info; + int retval; if (!capable(CAP_SETGID)) return -EPERM; - if ((unsigned) gidsetsize > NGROUPS) + if ((unsigned)gidsetsize > NGROUPS_MAX) return -EINVAL; - if (copy_from_user(groups, grouplist, gidsetsize * sizeof(u16))) - return -EFAULT; - for (i = 0 ; i < gidsetsize ; i++) - current->groups[i] = (gid_t)groups[i]; - current->ngroups = gidsetsize; - return 0; + + group_info = groups_alloc(gidsetsize); + if (!group_info) + return -ENOMEM; + retval = groups16_from_user(group_info, grouplist); + if (retval) { + put_group_info(group_info); + return retval; + } + + retval = set_current_groups(group_info); + put_group_info(group_info); + + return retval; } asmlinkage long sys32_getuid16(void) @@ -251,9 +282,7 @@ static inline long put_tv32(struct compa __put_user(i->tv_usec, &o->tv_usec))); } -extern asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on); - -asmlinkage int sys32_ioperm(u32 from, u32 num, int on) +asmlinkage long sys32_ioperm(u32 from, u32 num, int on) { return sys_ioperm((unsigned long)from, (unsigned long)num, on); } @@ -795,9 +824,6 @@ out: return err; } -extern asmlinkage long sys_truncate(const char * path, unsigned long length); -extern asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length); - asmlinkage int sys32_truncate64(const char * path, unsigned long high, unsigned long low) { if ((int)high < 0) @@ -1303,8 +1329,6 @@ int cp_compat_stat(struct kstat *stat, s return err; } -extern asmlinkage int sys_sysfs(int option, unsigned long arg1, unsigned long arg2); - asmlinkage int sys32_sysfs(int option, u32 arg1, u32 arg2) { return sys_sysfs(option, arg1, arg2); @@ -1530,8 +1554,6 @@ struct sysinfo32 { char _f[20-2*sizeof(int)-sizeof(int)]; }; -extern asmlinkage int sys_sysinfo(struct sysinfo *info); - asmlinkage int sys32_sysinfo(struct sysinfo32 *info) { struct sysinfo s; @@ -1579,8 +1601,6 @@ asmlinkage int sys32_sysinfo(struct sysi return ret; } -extern asmlinkage int sys_sched_rr_get_interval(pid_t pid, struct timespec *interval); - asmlinkage int sys32_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec *interval) { struct timespec t; @@ -1595,8 +1615,6 @@ asmlinkage int sys32_sched_rr_get_interv return ret; } -extern asmlinkage int sys_rt_sigprocmask(int how, sigset_t *set, sigset_t *oset, size_t sigsetsize); - asmlinkage int sys32_rt_sigprocmask(int how, compat_sigset_t *set, compat_sigset_t *oset, compat_size_t sigsetsize) { sigset_t s; @@ -1631,8 +1649,6 @@ asmlinkage int sys32_rt_sigprocmask(int return 0; } -extern asmlinkage int sys_rt_sigpending(sigset_t *set, size_t sigsetsize); - asmlinkage int sys32_rt_sigpending(compat_sigset_t *set, compat_size_t sigsetsize) { sigset_t s; @@ -1740,9 +1756,6 @@ sys32_rt_sigtimedwait(compat_sigset_t *u return ret; } -extern asmlinkage int -sys_rt_sigqueueinfo(int pid, int sig, siginfo_t *uinfo); - asmlinkage int sys32_rt_sigqueueinfo(int pid, int sig, siginfo_t32 *uinfo) { @@ -2073,15 +2086,11 @@ out: #ifdef CONFIG_MODULES -extern asmlinkage long sys_init_module(void *, unsigned long, const char *); - asmlinkage int sys32_init_module(void *umod, u32 len, const char *uargs) { return sys_init_module(umod, len, uargs); } -extern asmlinkage long sys_delete_module(const char *, unsigned int); - asmlinkage int sys32_delete_module(const char *name_user, unsigned int flags) { return sys_delete_module(name_user, flags); @@ -2323,7 +2332,6 @@ done: return err; } #else /* !NFSD */ -extern asmlinkage long sys_ni_syscall(void); int asmlinkage sys32_nfsservctl(int cmd, void *notused, void *notused2) { return sys_ni_syscall(); @@ -2416,17 +2424,6 @@ asmlinkage int sys32_pause(void) } /* PCI config space poking. */ -extern asmlinkage int sys_pciconfig_read(unsigned long bus, - unsigned long dfn, - unsigned long off, - unsigned long len, - unsigned char *buf); - -extern asmlinkage int sys_pciconfig_write(unsigned long bus, - unsigned long dfn, - unsigned long off, - unsigned long len, - unsigned char *buf); asmlinkage int sys32_pciconfig_read(u32 bus, u32 dfn, u32 off, u32 len, u32 ubuf) { @@ -2446,9 +2443,6 @@ asmlinkage int sys32_pciconfig_write(u32 (unsigned char *)AA(ubuf)); } -extern asmlinkage int sys_prctl(int option, unsigned long arg2, unsigned long arg3, - unsigned long arg4, unsigned long arg5); - asmlinkage int sys32_prctl(int option, u32 arg2, u32 arg3, u32 arg4, u32 arg5) { return sys_prctl(option, @@ -2459,12 +2453,6 @@ asmlinkage int sys32_prctl(int option, u } -extern asmlinkage ssize_t sys_pread64(unsigned int fd, char * buf, - size_t count, loff_t pos); - -extern asmlinkage ssize_t sys_pwrite64(unsigned int fd, const char * buf, - size_t count, loff_t pos); - asmlinkage compat_ssize_t sys32_pread64(unsigned int fd, char *ubuf, compat_size_t count, u32 poshi, u32 poslo) { @@ -2477,8 +2465,6 @@ asmlinkage compat_ssize_t sys32_pwrite64 return sys_pwrite64(fd, ubuf, count, ((loff_t)AA(poshi) << 32) | AA(poslo)); } -extern asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count); - asmlinkage compat_ssize_t sys32_readahead(int fd, u32 offhi, u32 offlo, s32 count) { return sys_readahead(fd, ((loff_t)AA(offhi) << 32) | AA(offlo), count); @@ -2495,8 +2481,6 @@ long sys32_fadvise64_64(int fd, u32 offh ((loff_t)AA(lenhi)<<32)|AA(lenlo), advice); } -extern asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t *offset, size_t count); - asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t *offset, s32 count) { mm_segment_t old_fs = get_fs(); @@ -2516,8 +2500,6 @@ asmlinkage int sys32_sendfile(int out_fd return ret; } -extern asmlinkage ssize_t sys_sendfile64(int out_fd, int in_fd, loff_t *offset, size_t count); - asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t *offset, s32 count) { mm_segment_t old_fs = get_fs(); @@ -2692,8 +2674,6 @@ out: return ret; } -extern asmlinkage long sys_setpriority(int which, int who, int niceval); - asmlinkage int sys_setpriority32(u32 which, u32 who, u32 niceval) { return sys_setpriority((int) which, @@ -2753,8 +2733,6 @@ asmlinkage long sys32_sysctl(struct __sy #endif } -extern long sys_lookup_dcookie(u64 cookie64, char *buf, size_t len); - long sys32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char *buf, size_t len) { return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low, --- diff/arch/sparc64/kernel/sys_sunos32.c 2003-09-17 12:28:03.000000000 +0100 +++ source/arch/sparc64/kernel/sys_sunos32.c 2004-02-23 13:56:39.000000000 +0000 @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -584,11 +585,6 @@ struct sunos_nfs_mount_args { char *netname; /* server's netname */ }; -extern asmlinkage int sys_mount(char *, char *, char *, unsigned long, void *); -extern asmlinkage int sys_connect(int fd, struct sockaddr *uservaddr, int addrlen); -extern asmlinkage int sys_socket(int family, int type, int protocol); -extern asmlinkage int sys_bind(int fd, struct sockaddr *umyaddr, int addrlen); - /* Bind the socket on a local reserved port and connect it to the * remote server. This on Linux/i386 is done by the mount program, @@ -781,8 +777,6 @@ out: return ret; } -extern asmlinkage int sys_setsid(void); -extern asmlinkage int sys_setpgid(pid_t, pid_t); asmlinkage int sunos_setpgrp(pid_t pid, pid_t pgid) { @@ -1200,11 +1194,6 @@ static inline int check_nonblock(int ret return ret; } -extern asmlinkage ssize_t sys_read(unsigned int fd, char *buf, unsigned long count); -extern asmlinkage ssize_t sys_write(unsigned int fd, char *buf, unsigned long count); -extern asmlinkage int sys_recv(int fd, void *ubuf, size_t size, unsigned flags); -extern asmlinkage int sys_send(int fd, void *buff, size_t len, unsigned flags); -extern asmlinkage int sys_accept(int fd, struct sockaddr *sa, int *addrlen); extern asmlinkage int sys32_readv(u32 fd, u32 vector, s32 count); extern asmlinkage int sys32_writev(u32 fd, u32 vector, s32 count); @@ -1302,9 +1291,6 @@ asmlinkage int sunos_sigaction (int sig, return ret; } -extern asmlinkage int sys_setsockopt(int fd, int level, int optname, - char *optval, int optlen); - asmlinkage int sunos_setsockopt(int fd, int level, int optname, u32 optval, int optlen) { --- diff/arch/sparc64/kernel/time.c 2003-11-25 15:24:57.000000000 +0000 +++ source/arch/sparc64/kernel/time.c 2004-02-23 13:56:39.000000000 +0000 @@ -1126,6 +1126,7 @@ int do_settimeofday(struct timespec *tv) time_maxerror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT; write_sequnlock_irq(&xtime_lock); + clock_was_set(); return 0; } --- diff/arch/sparc64/lib/rwlock.S 2003-11-25 15:24:57.000000000 +0000 +++ source/arch/sparc64/lib/rwlock.S 2004-02-23 13:56:39.000000000 +0000 @@ -85,5 +85,20 @@ __write_trylock_succeed: __write_trylock_fail: retl mov 0, %o0 + + .globl __read_trylock +__read_trylock: /* %o0 = lock_ptr */ + ldsw [%o0], %g5 + brlz,pn %g5, 100f + add %g5, 1, %g7 + cas [%o0], %g5, %g7 + cmp %g5, %g7 + bne,pn %icc, __read_trylock + membar #StoreLoad | #StoreStore + retl + mov 1, %o0 +100: retl + mov 0, %o0 + rwlock_impl_end: --- diff/arch/sparc64/prom/printf.c 2003-05-21 11:50:14.000000000 +0100 +++ source/arch/sparc64/prom/printf.c 2004-02-23 13:56:39.000000000 +0000 @@ -40,7 +40,7 @@ prom_printf(char *fmt, ...) int i; va_start(args, fmt); - i = vsnprintf(ppbuf, sizeof(ppbuf), fmt, args); + i = vscnprintf(ppbuf, sizeof(ppbuf), fmt, args); va_end(args); prom_write(ppbuf, i); --- diff/arch/sparc64/solaris/ioctl.c 2003-05-21 11:50:14.000000000 +0100 +++ source/arch/sparc64/solaris/ioctl.c 2004-02-23 13:56:39.000000000 +0000 @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -34,8 +35,6 @@ #include "conv.h" #include "socksys.h" -extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, - unsigned long arg); extern asmlinkage int compat_sys_ioctl(unsigned int fd, unsigned int cmd, u32 arg); asmlinkage int solaris_ioctl(unsigned int fd, unsigned int cmd, u32 arg); --- diff/arch/sparc64/solaris/socksys.c 2003-09-17 12:28:03.000000000 +0100 +++ source/arch/sparc64/solaris/socksys.c 2004-02-23 13:56:39.000000000 +0000 @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -35,9 +36,6 @@ #include "conv.h" #include "socksys.h" -extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, - unsigned long arg); - static int af_inet_protocols[] = { IPPROTO_ICMP, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, IPPROTO_UDP, IPPROTO_IDP, IPPROTO_RAW, --- diff/arch/sparc64/solaris/timod.c 2003-09-17 12:28:03.000000000 +0100 +++ source/arch/sparc64/solaris/timod.c 2004-02-23 13:56:39.000000000 +0000 @@ -27,8 +27,6 @@ #include "conv.h" #include "socksys.h" -extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, - unsigned long arg); asmlinkage int solaris_ioctl(unsigned int fd, unsigned int cmd, u32 arg); static spinlock_t timod_pagelock = SPIN_LOCK_UNLOCKED; --- diff/arch/um/Makefile-i386 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/um/Makefile-i386 2004-02-23 13:56:39.000000000 +0000 @@ -9,7 +9,6 @@ ELF_ARCH = $(SUBARCH) ELF_FORMAT = elf32-$(SUBARCH) OBJCOPYFLAGS := -O binary -R .note -R .comment -S -LDFLAGS_BLOB := --format binary --oformat elf32-i386 SYS_DIR := $(ARCH_DIR)/include/sysdep-i386 SYS_UTIL_DIR := $(ARCH_DIR)/sys-i386/util --- diff/arch/um/drivers/net_kern.c 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/um/drivers/net_kern.c 2004-02-23 13:56:39.000000000 +0000 @@ -358,8 +358,12 @@ static int eth_configure(int n, void *in rtnl_lock(); err = register_netdevice(dev); rtnl_unlock(); - if (err) + if (err) { + device->dev = NULL; + /* XXX: should we call ->remove() here? */ + free_netdev(dev); return 1; + } lp = dev->priv; INIT_LIST_HEAD(&lp->list); --- diff/arch/um/include/kern_util.h 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/um/include/kern_util.h 2004-02-23 13:56:39.000000000 +0000 @@ -45,7 +45,6 @@ extern int page_mask(void); extern int need_finish_fork(void); extern void free_stack(unsigned long stack, int order); extern void add_input_request(int op, void (*proc)(int), void *arg); -extern int sys_execve(char *file, char **argv, char **env); extern char *current_cmd(void); extern void timer_handler(int sig, union uml_pt_regs *regs); extern int set_signals(int enable); --- diff/arch/um/kernel/irq.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/um/kernel/irq.c 2004-02-23 13:56:39.000000000 +0000 @@ -575,7 +575,7 @@ static cpumask_t irq_affinity [NR_IRQS] static int irq_affinity_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, irq_affinity[(long)data]); + int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); @@ -613,7 +613,7 @@ static int irq_affinity_write_proc (stru static int prof_cpu_mask_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, *(cpumask_t *)data); + int len = cpumask_scnprintf(page, count, *(cpumask_t *)data); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); --- diff/arch/um/kernel/sys_call_table.c 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/um/kernel/sys_call_table.c 2004-02-23 13:56:39.000000000 +0000 @@ -8,6 +8,7 @@ #include "linux/version.h" #include "linux/sys.h" #include "linux/swap.h" +#include "linux/syscalls.h" #include "linux/sysctl.h" #include "asm/signal.h" #include "sysdep/syscalls.h" @@ -268,9 +269,9 @@ syscall_handler_t *sys_call_table[] = { [ __NR_creat ] = sys_creat, [ __NR_link ] = sys_link, [ __NR_unlink ] = sys_unlink, + [ __NR_execve ] = (syscall_handler_t *) sys_execve, /* declared differently in kern_util.h */ - [ __NR_execve ] = (syscall_handler_t *) sys_execve, [ __NR_chdir ] = sys_chdir, [ __NR_time ] = um_time, [ __NR_mknod ] = sys_mknod, --- diff/arch/um/kernel/syscall_kern.c 2003-10-09 09:47:16.000000000 +0100 +++ source/arch/um/kernel/syscall_kern.c 2004-02-23 13:56:39.000000000 +0000 @@ -11,6 +11,7 @@ #include "linux/msg.h" #include "linux/shm.h" #include "linux/sys.h" +#include "linux/syscalls.h" #include "linux/unistd.h" #include "linux/slab.h" #include "linux/utime.h" --- diff/arch/um/kernel/time.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/um/kernel/time.c 2004-02-23 13:56:39.000000000 +0000 @@ -93,6 +93,7 @@ void do_gettimeofday(struct timeval *tv) gettimeofday(tv, NULL); timeradd(tv, &local_offset, tv); time_unlock(flags); + clock_was_set(); } EXPORT_SYMBOL(do_gettimeofday); --- diff/arch/v850/Kconfig 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/v850/Kconfig 2004-02-23 13:56:39.000000000 +0000 @@ -236,24 +236,6 @@ menu "Bus options (PCI, PCMCIA, EISA, MC source "drivers/pci/Kconfig" -config HOTPLUG - bool "Support for hot-pluggable device" - ---help--- - Say Y here if you want to plug devices into your computer while - the system is running, and be able to use them quickly. In many - cases, the devices can likewise be unplugged at any time too. - - One well known example of this is PCMCIA- or PC-cards, credit-card - size devices such as network cards, modems or hard drives which are - plugged into slots found on all modern laptop computers. Another - example, used on modern desktops as well as laptops, is USB. - - Enable HOTPLUG and KMOD, and build a modular kernel. Get agent - software (at ) and install it. - Then your kernel will automatically call out to a user mode "policy - agent" (/sbin/hotplug) to load modules and set up software needed - to use devices as you hotplug them. - source "drivers/pcmcia/Kconfig" source "drivers/pci/hotplug/Kconfig" --- diff/arch/v850/kernel/ptrace.c 2003-06-30 10:07:20.000000000 +0100 +++ source/arch/v850/kernel/ptrace.c 2004-02-23 13:56:39.000000000 +0000 @@ -141,7 +141,7 @@ int sys_ptrace(long request, long pid, l rval = -EPERM; if (pid == 1) /* you may not mess with init */ - goto out; + goto out_tsk; if (request == PTRACE_ATTACH) { rval = ptrace_attach(child); --- diff/arch/v850/kernel/syscalls.c 2002-12-30 10:17:12.000000000 +0000 +++ source/arch/v850/kernel/syscalls.c 2004-02-23 13:56:39.000000000 +0000 @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include --- diff/arch/v850/kernel/time.c 2003-10-09 09:47:33.000000000 +0100 +++ source/arch/v850/kernel/time.c 2004-02-23 13:56:39.000000000 +0000 @@ -193,6 +193,7 @@ int do_settimeofday(struct timespec *tv) time_esterror = NTP_PHASE_LIMIT; write_sequnlock_irq (&xtime_lock); + clock_was_set(); return 0; } --- diff/arch/x86_64/Kconfig 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/x86_64/Kconfig 2004-02-23 13:56:39.000000000 +0000 @@ -15,6 +15,7 @@ config X86_64 help Port to the x86-64 architecture. x86-64 is a 64-bit extension to the classical 32-bit x86 architecture. For details see http://www.x86-64.org + and http://www.intel.com/technology/64bitextensions/ config 64BIT def_bool y @@ -48,12 +49,14 @@ config EARLY_PRINTK bool default y help - Write kernel log output directly into the VGA buffer. This is useful - for kernel debugging when your machine crashes very early before - the console code is initialized. For normal operation it is not - recommended because it looks ugly and doesn't cooperate with - klogd/syslogd or the X server. You should normally N here, unless - you want to debug such a crash. + Write kernel log output directly into the VGA buffer or to a serial + port. + + This is useful for kernel debugging when your machine crashes very + early before the console code is initialized. For normal operation + it is not recommended because it looks ugly and doesn't cooperate + with klogd/syslogd or the X server. You should normally N here, + unless you want to debug such a crash. config HPET_TIMER bool @@ -89,6 +92,11 @@ config MK8 help Optimize for AMD Opteron/Athlon64/Hammer/K8 CPUs. +config MPSC + bool "Intel x86-64" + help + Optimize for Intel CPUs with 64-bit extension technology. + config GENERIC_CPU bool "Generic-x86-64" help @@ -101,11 +109,13 @@ endchoice # config X86_L1_CACHE_BYTES int - default "64" + default "128" if GENERIC_CPU || MPSC + default "64" if MK8 config X86_L1_CACHE_SHIFT int - default "6" + default "7" if GENERIC_CPU || MPSC + default "6" if MK8 config X86_TSC bool @@ -115,6 +125,23 @@ config X86_GOOD_APIC bool default y +config MICROCODE + tristate "/dev/cpu/microcode - Intel CPU microcode support" + ---help--- + If you say Y here the 'File systems' section, you will be + able to update the microcode on Intel processors. You will + obviously need the actual microcode binary data itself which is + not shipped with the Linux kernel. + + For latest news and information on obtaining all the required + ingredients for this driver, check: + . + + To compile this driver as a module, choose M here: the + module will be called microcode. + If you use modprobe or kmod you may also want to add the line + 'alias char-major-10-184 microcode' to your /etc/modules.conf file. + config X86_MSR tristate "/dev/cpu/*/msr - Model-specific register support" help @@ -132,6 +159,11 @@ config X86_CPUID with major 203 and minors 0 to 31 for /dev/cpu/0/cpuid to /dev/cpu/31/cpuid. +config X86_HT + bool + depends on SMP + default y + config MATH_EMULATION bool @@ -256,9 +288,13 @@ config GART_IOMMU Normally the kernel will take the right choice by itself. If unsure say Y +config SWIOTLB + select GART_IOMMU + bool "Software IOTLB support" + config DUMMY_IOMMU bool - depends on !GART_IOMMU + depends on !GART_IOMMU && !SWIOTLB default y help Don't use IOMMU code. This will cause problems when you have more than 4GB @@ -315,24 +351,6 @@ config PCI_USE_VECTOR source "drivers/pci/Kconfig" -config HOTPLUG - bool "Support for hot-pluggable devices" - ---help--- - Say Y here if you want to plug devices into your computer while - the system is running, and be able to use them quickly. In many - cases, the devices can likewise be unplugged at any time too. - - One well-known example of this is PCMCIA- or PC-cards, credit-card - size devices such as network cards, modems, or hard drives which are - plugged into slots found on all modern laptop computers. Another - example, used on modern desktops as well as laptops, is USB. - - Enable HOTPLUG and KMOD, and build a modular kernel. Get agent - software (at ) and install it. - Then your kernel will automatically call out to a user mode "policy - agent" (/sbin/hotplug) to load modules and set up software needed - to use devices as you hotplug them. - source "drivers/pcmcia/Kconfig" source "drivers/pci/hotplug/Kconfig" @@ -362,6 +380,10 @@ config COMPAT depends on IA32_EMULATION default y +config SYSVIPC_COMPAT + bool + depends on COMPAT && SYSVIPC + default y config UID16 bool @@ -433,6 +455,7 @@ config INIT_DEBUG config DEBUG_INFO bool "Compile the kernel with debug info" depends on DEBUG_KERNEL + default n help If you say Y here the resulting kernel image will include debugging info resulting in a larger kernel image. @@ -464,9 +487,8 @@ config IOMMU_LEAK help Add a simple leak tracer to the IOMMU code. This is useful when you are debugging a buggy device driver that leaks IOMMU mappings. - -#config X86_REMOTE_DEBUG -# bool "kgdb debugging stub" + +source "arch/x86_64/Kconfig.kgdb" endmenu --- diff/arch/x86_64/Makefile 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/x86_64/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -39,6 +39,10 @@ LDFLAGS_vmlinux := -e stext check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1 ; then echo "$(1)"; else echo "$(2)"; fi) +cflags-$(CONFIG_MK8) += $(call check_gcc,-march=k8,) +cflags-$(CONFIG_MPSC) += $(call check_gcc,-march=pentium4,) +CFLAGS += $(cflags-y) + CFLAGS += -mno-red-zone CFLAGS += -mcmodel=kernel CFLAGS += -pipe @@ -52,7 +56,10 @@ CFLAGS += -Wno-sign-compare ifneq ($(CONFIG_DEBUG_INFO),y) CFLAGS += -fno-asynchronous-unwind-tables endif -#CFLAGS += $(call check_gcc,-funit-at-a-time,) + +# Enable unit-at-a-time mode when possible. It shrinks the +# kernel considerably. +CFLAGS += $(call check_gcc,-funit-at-a-time,) head-y := arch/x86_64/kernel/head.o arch/x86_64/kernel/head64.o arch/x86_64/kernel/init_task.o --- diff/arch/x86_64/boot/setup.S 2003-07-22 18:54:27.000000000 +0100 +++ source/arch/x86_64/boot/setup.S 2004-02-23 13:56:39.000000000 +0000 @@ -292,8 +292,9 @@ loader_ok: /* minimum CPUID flags for x86-64 */ /* see http://www.x86-64.org/lists/discuss/msg02971.html */ #define SSE_MASK ((1<<25)|(1<<26)) -#define REQUIRED_MASK1 ((1<<0)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<8)|(1<<11)| \ - (1<<13)|(1<<15)|(1<<24)|(1<<29)) +#define REQUIRED_MASK1 ((1<<0)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<8)|\ + (1<<13)|(1<<15)|(1<<24)) +#define REQUIRED_MASK2 (1<<29) pushfl /* standard way to check for cpuid */ popl %eax @@ -305,10 +306,10 @@ loader_ok: popl %eax cmpl %eax,%ebx jz no_longmode /* cpu has no cpuid */ - movl $0x80000000,%eax + movl $0x0,%eax cpuid - cmpl $0x80000001,%eax - jb no_longmode /* no extended cpuid */ + cmpl $0x1,%eax + jb no_longmode /* no cpuid 1 */ xor %di,%di cmpl $0x68747541,%ebx /* AuthenticAMD */ jnz noamd @@ -318,11 +319,20 @@ loader_ok: jnz noamd mov $1,%di /* cpu is from AMD */ noamd: - movl $0x80000001,%eax + movl $0x1,%eax cpuid andl $REQUIRED_MASK1,%edx xorl $REQUIRED_MASK1,%edx jnz no_longmode + movl $0x80000000,%eax + cpuid + cmpl $0x80000001,%eax + jb no_longmode /* no extended cpuid */ + movl $0x80000001,%eax + cpuid + andl $REQUIRED_MASK2,%edx + xorl $REQUIRED_MASK2,%edx + jnz no_longmode sse_test: movl $1,%eax cpuid --- diff/arch/x86_64/ia32/ia32_ioctl.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/x86_64/ia32/ia32_ioctl.c 2004-02-23 13:56:39.000000000 +0000 @@ -10,12 +10,11 @@ */ #define INCLUDES +#include #include "compat_ioctl.c" #include #include -extern asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg); - #define CODE #include "compat_ioctl.c" --- diff/arch/x86_64/ia32/ipc32.c 2003-08-20 14:16:26.000000000 +0100 +++ source/arch/x86_64/ia32/ipc32.c 2004-02-23 13:56:39.000000000 +0000 @@ -1,655 +1,19 @@ #include -#include -#include -#include +#include +#include +#include +#include #include #include -#include #include -#include #include #include -#include -#include -#include -#include -#include - -#include - -/* - * sys32_ipc() is the de-multiplexer for the SysV IPC calls in 32bit emulation.. - * - * This is really horribly ugly. - */ - -struct msgbuf32 { - s32 mtype; - char mtext[1]; -}; - -struct ipc_perm32 { - int key; - compat_uid_t uid; - compat_gid_t gid; - compat_uid_t cuid; - compat_gid_t cgid; - unsigned short mode; - unsigned short seq; -}; - -struct ipc64_perm32 { - unsigned key; - compat_uid32_t uid; - compat_gid32_t gid; - compat_uid32_t cuid; - compat_gid32_t cgid; - unsigned short mode; - unsigned short __pad1; - unsigned short seq; - unsigned short __pad2; - unsigned int unused1; - unsigned int unused2; -}; - -struct semid_ds32 { - struct ipc_perm32 sem_perm; /* permissions .. see ipc.h */ - compat_time_t sem_otime; /* last semop time */ - compat_time_t sem_ctime; /* last change time */ - u32 sem_base; /* ptr to first semaphore in array */ - u32 sem_pending; /* pending operations to be processed */ - u32 sem_pending_last; /* last pending operation */ - u32 undo; /* undo requests on this array */ - unsigned short sem_nsems; /* no. of semaphores in array */ -}; - -struct semid64_ds32 { - struct ipc64_perm32 sem_perm; - compat_time_t sem_otime; - unsigned int __unused1; - compat_time_t sem_ctime; - unsigned int __unused2; - unsigned int sem_nsems; - unsigned int __unused3; - unsigned int __unused4; -}; - -struct msqid_ds32 { - struct ipc_perm32 msg_perm; - u32 msg_first; - u32 msg_last; - compat_time_t msg_stime; - compat_time_t msg_rtime; - compat_time_t msg_ctime; - u32 wwait; - u32 rwait; - unsigned short msg_cbytes; - unsigned short msg_qnum; - unsigned short msg_qbytes; - compat_ipc_pid_t msg_lspid; - compat_ipc_pid_t msg_lrpid; -}; - -struct msqid64_ds32 { - struct ipc64_perm32 msg_perm; - compat_time_t msg_stime; - unsigned int __unused1; - compat_time_t msg_rtime; - unsigned int __unused2; - compat_time_t msg_ctime; - unsigned int __unused3; - unsigned int msg_cbytes; - unsigned int msg_qnum; - unsigned int msg_qbytes; - compat_pid_t msg_lspid; - compat_pid_t msg_lrpid; - unsigned int __unused4; - unsigned int __unused5; -}; - -struct shmid_ds32 { - struct ipc_perm32 shm_perm; - int shm_segsz; - compat_time_t shm_atime; - compat_time_t shm_dtime; - compat_time_t shm_ctime; - compat_ipc_pid_t shm_cpid; - compat_ipc_pid_t shm_lpid; - unsigned short shm_nattch; -}; - -struct shmid64_ds32 { - struct ipc64_perm32 shm_perm; - compat_size_t shm_segsz; - compat_time_t shm_atime; - unsigned int __unused1; - compat_time_t shm_dtime; - unsigned int __unused2; - compat_time_t shm_ctime; - unsigned int __unused3; - compat_pid_t shm_cpid; - compat_pid_t shm_lpid; - unsigned int shm_nattch; - unsigned int __unused4; - unsigned int __unused5; -}; - -struct shminfo64_32 { - unsigned int shmmax; - unsigned int shmmin; - unsigned int shmmni; - unsigned int shmseg; - unsigned int shmall; - unsigned int __unused1; - unsigned int __unused2; - unsigned int __unused3; - unsigned int __unused4; -}; - -struct shm_info32 { - int used_ids; - u32 shm_tot, shm_rss, shm_swp; - u32 swap_attempts, swap_successes; -}; - -struct ipc_kludge { - u32 msgp; - s32 msgtyp; -}; - - -#define A(__x) ((unsigned long)(__x)) -#define AA(__x) ((unsigned long)(__x)) - -#define SEMOP 1 -#define SEMGET 2 -#define SEMCTL 3 -#define TIMEDSEMOP 4 -#define MSGSND 11 -#define MSGRCV 12 -#define MSGGET 13 -#define MSGCTL 14 -#define SHMAT 21 -#define SHMDT 22 -#define SHMGET 23 -#define SHMCTL 24 - -#define IPCOP_MASK(__x) (1UL << (__x)) - -static int -ipc_parse_version32 (int *cmd) -{ - if (*cmd & IPC_64) { - *cmd ^= IPC_64; - return IPC_64; - } else { - return IPC_OLD; - } -} - -static int put_semid(void *user_semid, struct semid64_ds *s, int version) -{ - int err2; - switch (version) { - case IPC_64: { - struct semid64_ds32 *usp64 = (struct semid64_ds32 *) user_semid; - - if (!access_ok(VERIFY_WRITE, usp64, sizeof(*usp64))) { - err2 = -EFAULT; - break; - } - err2 = __put_user(s->sem_perm.key, &usp64->sem_perm.key); - err2 |= __put_user(s->sem_perm.uid, &usp64->sem_perm.uid); - err2 |= __put_user(s->sem_perm.gid, &usp64->sem_perm.gid); - err2 |= __put_user(s->sem_perm.cuid, &usp64->sem_perm.cuid); - err2 |= __put_user(s->sem_perm.cgid, &usp64->sem_perm.cgid); - err2 |= __put_user(s->sem_perm.mode, &usp64->sem_perm.mode); - err2 |= __put_user(s->sem_perm.seq, &usp64->sem_perm.seq); - err2 |= __put_user(s->sem_otime, &usp64->sem_otime); - err2 |= __put_user(s->sem_ctime, &usp64->sem_ctime); - err2 |= __put_user(s->sem_nsems, &usp64->sem_nsems); - break; - } - default: { - struct semid_ds32 *usp32 = (struct semid_ds32 *) user_semid; - - if (!access_ok(VERIFY_WRITE, usp32, sizeof(*usp32))) { - err2 = -EFAULT; - break; - } - err2 = __put_user(s->sem_perm.key, &usp32->sem_perm.key); - err2 |= __put_user(s->sem_perm.uid, &usp32->sem_perm.uid); - err2 |= __put_user(s->sem_perm.gid, &usp32->sem_perm.gid); - err2 |= __put_user(s->sem_perm.cuid, &usp32->sem_perm.cuid); - err2 |= __put_user(s->sem_perm.cgid, &usp32->sem_perm.cgid); - err2 |= __put_user(s->sem_perm.mode, &usp32->sem_perm.mode); - err2 |= __put_user(s->sem_perm.seq, &usp32->sem_perm.seq); - err2 |= __put_user(s->sem_otime, &usp32->sem_otime); - err2 |= __put_user(s->sem_ctime, &usp32->sem_ctime); - err2 |= __put_user(s->sem_nsems, &usp32->sem_nsems); - break; - } - } - return err2; -} - -static int -semctl32 (int first, int second, int third, void *uptr) -{ - union semun fourth; - u32 pad; - int err; - struct semid64_ds s; - mm_segment_t old_fs; - int version = ipc_parse_version32(&third); - - if (!uptr) - return -EINVAL; - if (get_user(pad, (u32 *)uptr)) - return -EFAULT; - if (third == SETVAL) - fourth.val = (int)pad; - else - fourth.__pad = (void *)A(pad); - switch (third) { - case IPC_INFO: - case IPC_RMID: - case IPC_SET: - case SEM_INFO: - case GETVAL: - case GETPID: - case GETNCNT: - case GETZCNT: - case GETALL: - case SETVAL: - case SETALL: - err = sys_semctl(first, second, third, fourth); - break; - - case IPC_STAT: - case SEM_STAT: - fourth.__pad = &s; - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_semctl(first, second, third, fourth); - set_fs(old_fs); - if (!err) - err = put_semid((void *)A(pad), &s, version); - break; - default: - err = -EINVAL; - break; - } - return err; -} - -#define MAXBUF (64*1024) - -static int -do_sys32_msgsnd (int first, int second, int third, void *uptr) -{ - struct msgbuf *p; - struct msgbuf32 *up = (struct msgbuf32 *)uptr; - mm_segment_t old_fs; - int err; - - if (second >= MAXBUF-sizeof(struct msgbuf)) - return -EINVAL; - p = kmalloc(second + sizeof(struct msgbuf), GFP_USER); - if (!p) - return -ENOMEM; - err = get_user(p->mtype, &up->mtype); - err |= (copy_from_user(p->mtext, &up->mtext, second) ? -EFAULT : 0); - if (err) - goto out; - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_msgsnd(first, p, second, third); - set_fs(old_fs); - out: - kfree(p); - return err; -} - -static int -do_sys32_msgrcv (int first, int second, int msgtyp, int third, int version, void *uptr) -{ - struct msgbuf32 *up; - struct msgbuf *p; - mm_segment_t old_fs; - int err; - - if (!version) { - struct ipc_kludge *uipck = (struct ipc_kludge *)uptr; - struct ipc_kludge ipck; - - err = -EINVAL; - if (!uptr) - goto out; - err = -EFAULT; - if (copy_from_user(&ipck, uipck, sizeof(struct ipc_kludge))) - goto out; - uptr = (void *)A(ipck.msgp); - msgtyp = ipck.msgtyp; - } - if (second >= MAXBUF-sizeof(struct msgbuf)) - return -EINVAL; - err = -ENOMEM; - p = kmalloc(second + sizeof(struct msgbuf), GFP_USER); - if (!p) - goto out; - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_msgrcv(first, p, second, msgtyp, third); - set_fs(old_fs); - if (err < 0) - goto free_then_out; - up = (struct msgbuf32 *)uptr; - if (put_user(p->mtype, &up->mtype) || copy_to_user(&up->mtext, p->mtext, err)) - err = -EFAULT; -free_then_out: - kfree(p); -out: - return err; -} - - -static int -msgctl32 (int first, int second, void *uptr) -{ - int err = -EINVAL, err2; - struct msqid_ds m; - struct msqid64_ds m64; - struct msqid_ds32 *up32 = (struct msqid_ds32 *)uptr; - struct msqid64_ds32 *up64 = (struct msqid64_ds32 *)uptr; - mm_segment_t old_fs; - int version = ipc_parse_version32(&second); - - switch (second) { - case IPC_INFO: - case IPC_RMID: - case MSG_INFO: - err = sys_msgctl(first, second, (struct msqid_ds *)uptr); - break; - - case IPC_SET: - if (version == IPC_64) { - err = get_user(m.msg_perm.uid, &up64->msg_perm.uid); - err |= get_user(m.msg_perm.gid, &up64->msg_perm.gid); - err |= get_user(m.msg_perm.mode, &up64->msg_perm.mode); - err |= get_user(m.msg_qbytes, &up64->msg_qbytes); - } else { - err = get_user(m.msg_perm.uid, &up32->msg_perm.uid); - err |= get_user(m.msg_perm.gid, &up32->msg_perm.gid); - err |= get_user(m.msg_perm.mode, &up32->msg_perm.mode); - err |= get_user(m.msg_qbytes, &up32->msg_qbytes); - } - if (err) - break; - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_msgctl(first, second, &m); - set_fs(old_fs); - break; - - case IPC_STAT: - case MSG_STAT: - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_msgctl(first, second, (void *) &m64); - set_fs(old_fs); - if (version == IPC_64) { - if (!access_ok(VERIFY_WRITE, up64, sizeof(*up64))) { - err = -EFAULT; - break; - } - err2 = __put_user(m64.msg_perm.key, &up64->msg_perm.key); - err2 |= __put_user(m64.msg_perm.uid, &up64->msg_perm.uid); - err2 |= __put_user(m64.msg_perm.gid, &up64->msg_perm.gid); - err2 |= __put_user(m64.msg_perm.cuid, &up64->msg_perm.cuid); - err2 |= __put_user(m64.msg_perm.cgid, &up64->msg_perm.cgid); - err2 |= __put_user(m64.msg_perm.mode, &up64->msg_perm.mode); - err2 |= __put_user(m64.msg_perm.seq, &up64->msg_perm.seq); - err2 |= __put_user(m64.msg_stime, &up64->msg_stime); - err2 |= __put_user(m64.msg_rtime, &up64->msg_rtime); - err2 |= __put_user(m64.msg_ctime, &up64->msg_ctime); - err2 |= __put_user(m64.msg_cbytes, &up64->msg_cbytes); - err2 |= __put_user(m64.msg_qnum, &up64->msg_qnum); - err2 |= __put_user(m64.msg_qbytes, &up64->msg_qbytes); - err2 |= __put_user(m64.msg_lspid, &up64->msg_lspid); - err2 |= __put_user(m64.msg_lrpid, &up64->msg_lrpid); - if (err2) - err = -EFAULT; - } else { - if (!access_ok(VERIFY_WRITE, up32, sizeof(*up32))) { - err = -EFAULT; - break; - } - err2 = __put_user(m64.msg_perm.key, &up32->msg_perm.key); - err2 |= __put_user(m64.msg_perm.uid, &up32->msg_perm.uid); - err2 |= __put_user(m64.msg_perm.gid, &up32->msg_perm.gid); - err2 |= __put_user(m64.msg_perm.cuid, &up32->msg_perm.cuid); - err2 |= __put_user(m64.msg_perm.cgid, &up32->msg_perm.cgid); - err2 |= __put_user(m64.msg_perm.mode, &up32->msg_perm.mode); - err2 |= __put_user(m64.msg_perm.seq, &up32->msg_perm.seq); - err2 |= __put_user(m64.msg_stime, &up32->msg_stime); - err2 |= __put_user(m64.msg_rtime, &up32->msg_rtime); - err2 |= __put_user(m64.msg_ctime, &up32->msg_ctime); - err2 |= __put_user(m64.msg_cbytes, &up32->msg_cbytes); - err2 |= __put_user(m64.msg_qnum, &up32->msg_qnum); - err2 |= __put_user(m64.msg_qbytes, &up32->msg_qbytes); - err2 |= __put_user(m64.msg_lspid, &up32->msg_lspid); - err2 |= __put_user(m64.msg_lrpid, &up32->msg_lrpid); - if (err2) - err = -EFAULT; - } - break; - } - return err; -} - -static int -shmat32 (int first, int second, int third, int version, void *uptr) -{ - unsigned long raddr; - u32 *uaddr = (u32 *)A((u32)third); - int err; - - if (version == 1) - return -EINVAL; /* iBCS2 emulator entry point: unsupported */ - err = sys_shmat(first, uptr, second, &raddr); - if (err) - return err; - return put_user(raddr, uaddr); -} - -static int put_shmid64(struct shmid64_ds *s64p, void *uptr, int version) -{ - int err2; -#define s64 (*s64p) - if (version == IPC_64) { - struct shmid64_ds32 *up64 = (struct shmid64_ds32 *)uptr; - - if (!access_ok(VERIFY_WRITE, up64, sizeof(*up64))) - return -EFAULT; - - err2 = __put_user(s64.shm_perm.key, &up64->shm_perm.key); - err2 |= __put_user(s64.shm_perm.uid, &up64->shm_perm.uid); - err2 |= __put_user(s64.shm_perm.gid, &up64->shm_perm.gid); - err2 |= __put_user(s64.shm_perm.cuid, &up64->shm_perm.cuid); - err2 |= __put_user(s64.shm_perm.cgid, &up64->shm_perm.cgid); - err2 |= __put_user(s64.shm_perm.mode, &up64->shm_perm.mode); - err2 |= __put_user(s64.shm_perm.seq, &up64->shm_perm.seq); - err2 |= __put_user(s64.shm_atime, &up64->shm_atime); - err2 |= __put_user(s64.shm_dtime, &up64->shm_dtime); - err2 |= __put_user(s64.shm_ctime, &up64->shm_ctime); - err2 |= __put_user(s64.shm_segsz, &up64->shm_segsz); - err2 |= __put_user(s64.shm_nattch, &up64->shm_nattch); - err2 |= __put_user(s64.shm_cpid, &up64->shm_cpid); - err2 |= __put_user(s64.shm_lpid, &up64->shm_lpid); - } else { - struct shmid_ds32 *up32 = (struct shmid_ds32 *)uptr; - - if (!access_ok(VERIFY_WRITE, up32, sizeof(*up32))) - return -EFAULT; - - err2 = __put_user(s64.shm_perm.key, &up32->shm_perm.key); - err2 |= __put_user(s64.shm_perm.uid, &up32->shm_perm.uid); - err2 |= __put_user(s64.shm_perm.gid, &up32->shm_perm.gid); - err2 |= __put_user(s64.shm_perm.cuid, &up32->shm_perm.cuid); - err2 |= __put_user(s64.shm_perm.cgid, &up32->shm_perm.cgid); - err2 |= __put_user(s64.shm_perm.mode, &up32->shm_perm.mode); - err2 |= __put_user(s64.shm_perm.seq, &up32->shm_perm.seq); - err2 |= __put_user(s64.shm_atime, &up32->shm_atime); - err2 |= __put_user(s64.shm_dtime, &up32->shm_dtime); - err2 |= __put_user(s64.shm_ctime, &up32->shm_ctime); - err2 |= __put_user(s64.shm_segsz, &up32->shm_segsz); - err2 |= __put_user(s64.shm_nattch, &up32->shm_nattch); - err2 |= __put_user(s64.shm_cpid, &up32->shm_cpid); - err2 |= __put_user(s64.shm_lpid, &up32->shm_lpid); - } -#undef s64 - return err2 ? -EFAULT : 0; -} -static int -shmctl32 (int first, int second, void *uptr) -{ - int err = -EFAULT, err2; - struct shmid_ds s; - struct shmid64_ds s64; - mm_segment_t old_fs; - struct shm_info32 *uip = (struct shm_info32 *)uptr; - struct shm_info si; - int version = ipc_parse_version32(&second); - struct shminfo64 smi; - struct shminfo *usi32 = (struct shminfo *) uptr; - struct shminfo64_32 *usi64 = (struct shminfo64_32 *) uptr; - - switch (second) { - case IPC_INFO: - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_shmctl(first, second, (struct shmid_ds *)&smi); - set_fs(old_fs); - - if (version == IPC_64) { - if (!access_ok(VERIFY_WRITE, usi64, sizeof(*usi64))) { - err = -EFAULT; - break; - } - err2 = __put_user(smi.shmmax, &usi64->shmmax); - err2 |= __put_user(smi.shmmin, &usi64->shmmin); - err2 |= __put_user(smi.shmmni, &usi64->shmmni); - err2 |= __put_user(smi.shmseg, &usi64->shmseg); - err2 |= __put_user(smi.shmall, &usi64->shmall); - } else { - if (!access_ok(VERIFY_WRITE, usi32, sizeof(*usi32))) { - err = -EFAULT; - break; - } - err2 = __put_user(smi.shmmax, &usi32->shmmax); - err2 |= __put_user(smi.shmmin, &usi32->shmmin); - err2 |= __put_user(smi.shmmni, &usi32->shmmni); - err2 |= __put_user(smi.shmseg, &usi32->shmseg); - err2 |= __put_user(smi.shmall, &usi32->shmall); - } - if (err2) - err = -EFAULT; - break; - - case IPC_RMID: - case SHM_LOCK: - case SHM_UNLOCK: - err = sys_shmctl(first, second, (struct shmid_ds *)uptr); - break; - - case IPC_SET: - if (version == IPC_64) { - struct shmid64_ds32 *up64 = (struct shmid64_ds32 *)uptr; - err = get_user(s.shm_perm.uid, &up64->shm_perm.uid); - err |= get_user(s.shm_perm.gid, &up64->shm_perm.gid); - err |= get_user(s.shm_perm.mode, &up64->shm_perm.mode); - } else { - struct shmid_ds32 *up32 = (struct shmid_ds32 *)uptr; - err = get_user(s.shm_perm.uid, &up32->shm_perm.uid); - err |= get_user(s.shm_perm.gid, &up32->shm_perm.gid); - err |= get_user(s.shm_perm.mode, &up32->shm_perm.mode); - } - if (err) - break; - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_shmctl(first, second, &s); - set_fs(old_fs); - break; - - case IPC_STAT: - case SHM_STAT: - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_shmctl(first, second, (void *) &s64); - set_fs(old_fs); - - if (err < 0) - break; - err2 = put_shmid64(&s64, uptr, version); - if (err2) - err = err2; - break; - - case SHM_INFO: - old_fs = get_fs(); - set_fs(KERNEL_DS); - err = sys_shmctl(first, second, (void *)&si); - set_fs(old_fs); - if (err < 0) - break; - - if (!access_ok(VERIFY_WRITE, uip, sizeof(*uip))) { - err = -EFAULT; - break; - } - err2 = __put_user(si.used_ids, &uip->used_ids); - err2 |= __put_user(si.shm_tot, &uip->shm_tot); - err2 |= __put_user(si.shm_rss, &uip->shm_rss); - err2 |= __put_user(si.shm_swp, &uip->shm_swp); - err2 |= __put_user(si.swap_attempts, &uip->swap_attempts); - err2 |= __put_user(si.swap_successes, &uip->swap_successes); - if (err2) - err = -EFAULT; - break; - default: - err = -EINVAL; - break; - } - return err; -} - -extern int sem_ctls[]; - -static long semtimedop32(int semid, struct sembuf *sb, - unsigned nsops, struct compat_timespec *ts32) -{ - struct timespec ts; - mm_segment_t oldfs = get_fs(); - long ret; - - if (nsops > sem_ctls[2]) - return -E2BIG; - if (!access_ok(VERIFY_READ, sb, nsops * sizeof(struct sembuf))) - return -EFAULT; - if (ts32 && get_compat_timespec(&ts, ts32)) - return -EFAULT; - - set_fs(KERNEL_DS); - ret = sys_semtimedop(semid, sb, nsops, ts32 ? &ts : NULL); - set_fs(oldfs); - return ret; -} +#include asmlinkage long -sys32_ipc (u32 call, int first, int second, int third, u32 ptr, u32 fifth) +sys32_ipc(u32 call, int first, int second, int third, + compat_uptr_t ptr, u32 fifth) { int version; @@ -659,35 +23,35 @@ sys32_ipc (u32 call, int first, int seco switch (call) { case SEMOP: /* struct sembuf is the same on 32 and 64bit :)) */ - return sys_semtimedop(first, (struct sembuf *)AA(ptr), second, - NULL); - case TIMEDSEMOP: - return semtimedop32(first, (struct sembuf *)AA(ptr), second, - (struct compat_timespec *)AA(fifth)); + return sys_semtimedop(first, compat_ptr(ptr), second, NULL); + case SEMTIMEDOP: + return compat_sys_semtimedop(first, compat_ptr(ptr), second, + compat_ptr(fifth)); case SEMGET: return sys_semget(first, second, third); case SEMCTL: - return semctl32(first, second, third, (void *)AA(ptr)); + return compat_sys_semctl(first, second, third, compat_ptr(ptr)); case MSGSND: - return do_sys32_msgsnd(first, second, third, (void *)AA(ptr)); + return compat_sys_msgsnd(first, second, third, compat_ptr(ptr)); case MSGRCV: - return do_sys32_msgrcv(first, second, fifth, third, version, (void *)AA(ptr)); + return compat_sys_msgrcv(first, second, fifth, third, + version, compat_ptr(ptr)); case MSGGET: return sys_msgget((key_t) first, second); case MSGCTL: - return msgctl32(first, second, (void *)AA(ptr)); + return compat_sys_msgctl(first, second, compat_ptr(ptr)); case SHMAT: - return shmat32(first, second, third, version, (void *)AA(ptr)); + return compat_sys_shmat(first, second, third, version, + compat_ptr(ptr)); break; case SHMDT: - return sys_shmdt((char *)AA(ptr)); + return sys_shmdt(compat_ptr(ptr)); case SHMGET: return sys_shmget(first, second, third); case SHMCTL: - return shmctl32(first, second, (void *)AA(ptr)); + return compat_sys_shmctl(first, second, compat_ptr(ptr)); } return -ENOSYS; } - --- diff/arch/x86_64/ia32/ptrace32.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/x86_64/ia32/ptrace32.c 2004-02-23 13:56:39.000000000 +0000 @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include #include @@ -223,8 +225,6 @@ static struct task_struct *find_target(i } -extern asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, unsigned long data); - asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data) { struct task_struct *child; --- diff/arch/x86_64/ia32/sys_ia32.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/x86_64/ia32/sys_ia32.c 2004-02-23 13:56:39.000000000 +0000 @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -110,9 +111,6 @@ int cp_compat_stat(struct kstat *kbuf, s return 0; } -extern long sys_truncate(char *, loff_t); -extern long sys_ftruncate(int, loff_t); - asmlinkage long sys32_truncate64(char * filename, unsigned long offset_low, unsigned long offset_high) { @@ -236,8 +234,6 @@ sys32_mmap(struct mmap_arg_struct *arg) return retval; } -extern asmlinkage long sys_mprotect(unsigned long start,size_t len,unsigned long prot); - asmlinkage long sys32_mprotect(unsigned long start, size_t len, unsigned long prot) { @@ -363,12 +359,9 @@ sys32_sigaction (int sig, struct old_sig return ret; } -extern asmlinkage long sys_rt_sigprocmask(int how, sigset_t *set, sigset_t *oset, - size_t sigsetsize); - asmlinkage long -sys32_rt_sigprocmask(int how, compat_sigset_t *set, compat_sigset_t *oset, - unsigned int sigsetsize) +sys32_rt_sigprocmask(int how, compat_sigset_t __user *set, + compat_sigset_t __user *oset, unsigned int sigsetsize) { sigset_t s; compat_sigset_t s32; @@ -734,9 +727,6 @@ sys32_old_select(struct sel_arg_struct * (struct compat_timeval *)A(a.tvp)); } -asmlinkage ssize_t sys_readv(unsigned long,const struct iovec *,unsigned long); -asmlinkage ssize_t sys_writev(unsigned long,const struct iovec *,unsigned long); - static struct iovec * get_compat_iovec(struct compat_iovec *iov32, struct iovec *iov_buf, u32 *count, int type, int *errp) { @@ -878,18 +868,12 @@ int sys32_ni_syscall(int call) /* 32-bit timeval and related flotsam. */ -extern asmlinkage long sys_sysfs(int option, unsigned long arg1, - unsigned long arg2); - asmlinkage long sys32_sysfs(int option, u32 arg1, u32 arg2) { return sys_sysfs(option, arg1, arg2); } -extern asmlinkage long sys_mount(char * dev_name, char * dir_name, char * type, - unsigned long new_flags, void *data); - static char *badfs[] = { "smbfs", "ncpfs", NULL }; @@ -940,8 +924,6 @@ struct sysinfo32 { char _f[20-2*sizeof(u32)-sizeof(int)]; }; -extern asmlinkage long sys_sysinfo(struct sysinfo *info); - asmlinkage long sys32_sysinfo(struct sysinfo32 *info) { @@ -991,9 +973,6 @@ sys32_sysinfo(struct sysinfo32 *info) return 0; } -extern asmlinkage long sys_sched_rr_get_interval(pid_t pid, - struct timespec *interval); - asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec *interval) { @@ -1009,10 +988,8 @@ sys32_sched_rr_get_interval(compat_pid_t return ret; } -extern asmlinkage long sys_rt_sigpending(sigset_t *set, size_t sigsetsize); - asmlinkage long -sys32_rt_sigpending(compat_sigset_t *set, compat_size_t sigsetsize) +sys32_rt_sigpending(compat_sigset_t __user *set, compat_size_t sigsetsize) { sigset_t s; compat_sigset_t s32; @@ -1035,9 +1012,6 @@ sys32_rt_sigpending(compat_sigset_t *set return ret; } -extern asmlinkage long -sys_rt_sigtimedwait(const sigset_t *uthese, siginfo_t *uinfo, - const struct timespec *uts, size_t sigsetsize); asmlinkage long sys32_rt_sigtimedwait(compat_sigset_t *uthese, siginfo_t32 *uinfo, @@ -1077,9 +1051,6 @@ sys32_rt_sigtimedwait(compat_sigset_t *u return ret; } -extern asmlinkage long -sys_rt_sigqueueinfo(int pid, int sig, siginfo_t *uinfo); - asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig, siginfo_t32 *uinfo) { @@ -1165,12 +1136,6 @@ sys32_sysctl(struct sysctl_ia32 *args32) #endif } -extern asmlinkage ssize_t sys_pread64(unsigned int fd, char * buf, - size_t count, loff_t pos); - -extern asmlinkage ssize_t sys_pwrite64(unsigned int fd, const char * buf, - size_t count, loff_t pos); - /* warning: next two assume little endian */ asmlinkage long sys32_pread(unsigned int fd, char *ubuf, u32 count, u32 poslo, u32 poshi) @@ -1187,8 +1152,6 @@ sys32_pwrite(unsigned int fd, char *ubuf } -extern asmlinkage long sys_personality(unsigned long); - asmlinkage long sys32_personality(unsigned long personality) { @@ -1202,9 +1165,6 @@ sys32_personality(unsigned long personal return ret; } -extern asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t *offset, - size_t count); - asmlinkage long sys32_sendfile(int out_fd, int in_fd, compat_off_t *offset, s32 count) { @@ -1375,9 +1335,7 @@ long sys32_uname(struct old_utsname * na return err?-EFAULT:0; } -extern int sys_ustat(dev_t, struct ustat *); - -long sys32_ustat(unsigned dev, struct ustat32 *u32p) +long sys32_ustat(unsigned dev, struct ustat32 __user *u32p) { struct ustat u; mm_segment_t seg; @@ -1500,15 +1458,11 @@ asmlinkage long sys32_clone(unsigned int * Some system calls that need sign extended arguments. This could be done by a generic wrapper. */ -extern off_t sys_lseek (unsigned int fd, off_t offset, unsigned int origin); - long sys32_lseek (unsigned int fd, int offset, unsigned int whence) { return sys_lseek(fd, offset, whence); } -extern int sys_kill(pid_t pid, int sig); - long sys32_kill(int pid, int sig) { return sys_kill(pid, sig); @@ -1736,15 +1690,12 @@ done: return err; } #else /* !NFSD */ -extern asmlinkage long sys_ni_syscall(void); long asmlinkage sys32_nfsservctl(int cmd, void *notused, void *notused2) { return sys_ni_syscall(); } #endif -extern long sys_io_setup(unsigned nr_reqs, aio_context_t *ctx); - long sys32_io_setup(unsigned nr_reqs, u32 *ctx32p) { long ret; @@ -1802,11 +1753,6 @@ asmlinkage long sys32_io_submit(aio_cont return i ? i : ret; } -extern asmlinkage long sys_io_getevents(aio_context_t ctx_id, - long min_nr, - long nr, - struct io_event *events, - struct timespec *timeout); asmlinkage long sys32_io_getevents(aio_context_t ctx_id, unsigned long min_nr, @@ -1895,8 +1841,6 @@ sys32_timer_create(u32 clock, struct sig return err; } -extern long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice); - long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high, __u32 len_low, __u32 len_high, int advice) { --- diff/arch/x86_64/kernel/Makefile 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/x86_64/kernel/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -12,6 +12,7 @@ obj-y := process.o semaphore.o signal.o obj-$(CONFIG_MTRR) += ../../i386/kernel/cpu/mtrr/ obj-$(CONFIG_ACPI) += acpi/ obj-$(CONFIG_X86_MSR) += msr.o +obj-$(CONFIG_MICROCODE) += microcode.o obj-$(CONFIG_X86_CPUID) += cpuid.o obj-$(CONFIG_SMP) += smp.o smpboot.o trampoline.o obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o @@ -22,12 +23,15 @@ obj-$(CONFIG_CPU_FREQ) += cpufreq/ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-$(CONFIG_GART_IOMMU) += pci-gart.o aperture.o obj-$(CONFIG_DUMMY_IOMMU) += pci-nommu.o pci-dma.o +obj-$(CONFIG_SWIOTLB) += swiotlb.o obj-$(CONFIG_MODULES) += module.o +obj-$(CONFIG_KGDB) += kgdb_stub.o obj-y += topology.o bootflag-y += ../../i386/kernel/bootflag.o cpuid-$(subst m,y,$(CONFIG_X86_CPUID)) += ../../i386/kernel/cpuid.o topology-y += ../../i386/mach-default/topology.o - +swiotlb-$(CONFIG_SWIOTLB) += ../../ia64/lib/swiotlb.o +microcode-$(subst m,y,$(CONFIG_X86_CPUID)) += ../../i386/kernel/microcode.o --- diff/arch/x86_64/kernel/aperture.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/x86_64/kernel/aperture.c 2004-02-23 13:56:39.000000000 +0000 @@ -24,6 +24,8 @@ #include #include +int iommu_aperture; + int fallback_aper_order __initdata = 1; /* 64MB */ int fallback_aper_force __initdata = 0; @@ -206,6 +208,8 @@ void __init iommu_hole_init(void) if (read_pci_config(0, num, 3, 0x00) != NB_ID_3) continue; + iommu_aperture = 1;; + aper_order = (read_pci_config(0, num, 3, 0x90) >> 1) & 7; aper_size = (32 * 1024 * 1024) << aper_order; aper_base = read_pci_config(0, num, 3, 0x94) & 0x7fff; --- diff/arch/x86_64/kernel/apic.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/x86_64/kernel/apic.c 2004-02-23 13:56:39.000000000 +0000 @@ -552,7 +552,7 @@ static int __init init_lapic_sysfs(void) /* XXX: remove suspend/resume procs if !apic_pm_state.active? */ error = sysdev_class_register(&lapic_sysclass); if (!error) - error = sys_device_register(&device_lapic); + error = sysdev_register(&device_lapic); return error; } device_initcall(init_lapic_sysfs); --- diff/arch/x86_64/kernel/early_printk.c 2003-06-09 14:18:18.000000000 +0100 +++ source/arch/x86_64/kernel/early_printk.c 2004-02-23 13:56:39.000000000 +0000 @@ -7,7 +7,11 @@ /* Simple VGA output */ +#ifdef __i386__ +#define VGABASE __pa(__PAGE_OFFSET + 0xb8000UL) +#else #define VGABASE 0xffffffff800b8000UL +#endif #define MAX_YPOS 25 #define MAX_XPOS 80 @@ -22,15 +26,14 @@ static void early_vga_write(struct conso while ((c = *str++) != '\0' && n-- > 0) { if (current_ypos >= MAX_YPOS) { /* scroll 1 line up */ - for(k = 1, j = 0; k < MAX_YPOS; k++, j++) { - for(i = 0; i < MAX_XPOS; i++) { + for (k = 1, j = 0; k < MAX_YPOS; k++, j++) { + for (i = 0; i < MAX_XPOS; i++) { writew(readw(VGABASE + 2*(MAX_XPOS*k + i)), VGABASE + 2*(MAX_XPOS*j + i)); } } - for(i = 0; i < MAX_XPOS; i++) { + for (i = 0; i < MAX_XPOS; i++) writew(0x720, VGABASE + 2*(MAX_XPOS*j + i)); - } current_ypos = MAX_YPOS-1; } if (c == '\n') { @@ -38,7 +41,8 @@ static void early_vga_write(struct conso current_ypos++; } else if (c != '\r') { writew(((0x7 << 8) | (unsigned short) c), - VGABASE + 2*(MAX_XPOS*current_ypos + current_xpos++)); + VGABASE + 2*(MAX_XPOS*current_ypos + + current_xpos++)); if (current_xpos >= MAX_XPOS) { current_xpos = 0; current_ypos++; @@ -78,7 +82,7 @@ static int early_serial_putc(unsigned ch { unsigned timeout = 0xffff; while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout) - rep_nop(); + cpu_relax(); outb(ch, early_serial_base + TXR); return timeout ? 0 : -1; } @@ -93,10 +97,13 @@ static void early_serial_write(struct co } } +#define DEFAULT_BAUD 9600 + static __init void early_serial_init(char *opt) { unsigned char c; - unsigned divisor, baud = 38400; + unsigned divisor; + unsigned baud = DEFAULT_BAUD; char *s, *e; if (*opt == ',') @@ -109,25 +116,26 @@ static __init void early_serial_init(cha early_serial_base = simple_strtoul(s, &e, 16); } else { static int bases[] = { 0x3f8, 0x2f8 }; - if (!strncmp(s,"ttyS",4)) - s+=4; - port = simple_strtoul(s, &e, 10); - if (port > 1 || s == e) - port = 0; - early_serial_base = bases[port]; - } + + if (!strncmp(s,"ttyS",4)) + s += 4; + port = simple_strtoul(s, &e, 10); + if (port > 1 || s == e) + port = 0; + early_serial_base = bases[port]; + } } - outb(0x3, early_serial_base + LCR); /* 8n1 */ - outb(0, early_serial_base + IER); /* no interrupt */ - outb(0, early_serial_base + FCR); /* no fifo */ - outb(0x3, early_serial_base + MCR); /* DTR + RTS */ + outb(0x3, early_serial_base + LCR); /* 8n1 */ + outb(0, early_serial_base + IER); /* no interrupt */ + outb(0, early_serial_base + FCR); /* no fifo */ + outb(0x3, early_serial_base + MCR); /* DTR + RTS */ s = strsep(&opt, ","); if (s != NULL) { baud = simple_strtoul(s, &e, 0); if (baud == 0 || s == e) - baud = 38400; + baud = DEFAULT_BAUD; } divisor = 115200 / baud; @@ -154,8 +162,9 @@ void early_printk(const char *fmt, ...) char buf[512]; int n; va_list ap; + va_start(ap,fmt); - n = vsnprintf(buf,512,fmt,ap); + n = vscnprintf(buf,512,fmt,ap); early_console->write(early_console,buf,n); va_end(ap); } @@ -170,6 +179,8 @@ int __init setup_early_printk(char *opt) if (early_console_initialized) return -1; + opt = strchr(opt, '=') + 1; + strlcpy(buf,opt,sizeof(buf)); space = strchr(buf, ' '); if (space) @@ -200,19 +211,12 @@ void __init disable_early_printk(void) if (!early_console_initialized || !early_console) return; if (!keep_early) { - printk("disabling early console...\n"); + printk("disabling early console\n"); unregister_console(early_console); early_console_initialized = 0; } else { - printk("keeping early console.\n"); + printk("keeping early console\n"); } } -/* syntax: earlyprintk=vga - earlyprintk=serial[,ttySn[,baudrate]] - Append ,keep to not disable it when the real console takes over. - Only vga or serial at a time, not both. - Currently only ttyS0 and ttyS1 are supported. - Interaction with the standard serial driver is not very good. - The VGA output is eventually overwritten by the real console. */ -__setup("earlyprintk=", setup_early_printk); +__setup("earlyprintk=", setup_early_printk); --- diff/arch/x86_64/kernel/head.S 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/x86_64/kernel/head.S 2004-02-23 13:56:39.000000000 +0000 @@ -16,6 +16,7 @@ #include #include #include +#include /* we are not able to switch in one step to the final KERNEL ADRESS SPACE * because we need identity-mapped pages on setup so define __START_KERNEL to @@ -322,7 +323,6 @@ gdt: .endr #endif -.align 64 /* cacheline aligned */ ENTRY(gdt_table32) .quad 0x0000000000000000 /* This one is magic */ .quad 0x0000000000000000 /* unused */ @@ -334,7 +334,7 @@ gdt32_end: * Also sysret mandates a special GDT layout */ -.align 64 /* cacheline aligned, keep this synchronized with asm/desc.h */ +.align L1_CACHE_BYTES /* The TLS descriptors are currently at a different place compared to i386. Hopefully nobody expects them at a fixed place (Wine?) */ @@ -354,18 +354,13 @@ ENTRY(cpu_gdt_table) .quad 0 /* unused now */ .quad 0x00009a000000ffff /* __KERNEL16_CS - 16bit PM for S3 wakeup. */ /* base must be patched for real base address. */ - /* This should be a multiple of the cache line size */ gdt_end: - .globl gdt_end - - /* GDTs of other CPUs */ -#ifdef CONFIG_SMP - .rept NR_CPUS-1 - .quad 0,0,0,0,0,0,0,0,0,0,0 - .endr -#endif + /* asm/segment.h:GDT_ENTRIES must match this */ + /* This should be a multiple of the cache line size */ + /* GDTs of other CPUs: */ + .fill (GDT_SIZE * NR_CPUS) - (gdt_end - cpu_gdt_table) - .align 64 + .align L1_CACHE_BYTES ENTRY(idt_table) .rept 256 .quad 0 --- diff/arch/x86_64/kernel/head64.c 2003-05-21 11:50:00.000000000 +0100 +++ source/arch/x86_64/kernel/head64.c 2004-02-23 13:56:39.000000000 +0000 @@ -83,9 +83,9 @@ void __init x86_64_start_kernel(char * r /* default console: */ if (!strstr(saved_command_line, "console=")) strcat(saved_command_line, " console=tty0"); - s = strstr(saved_command_line, "earlyprintk="); + s = strstr(saved_command_line, "earlyprintk="); if (s != NULL) - setup_early_printk(s+12); + setup_early_printk(s); #ifdef CONFIG_DISCONTIGMEM s = strstr(saved_command_line, "numa="); if (s != NULL) --- diff/arch/x86_64/kernel/i8259.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/x86_64/kernel/i8259.c 2004-02-23 13:56:39.000000000 +0000 @@ -430,7 +430,7 @@ static int __init init_timer_sysfs(void) { int error = sysdev_class_register(&timer_sysclass); if (!error) - error = sys_device_register(&device_timer); + error = sysdev_register(&device_timer); return error; } --- diff/arch/x86_64/kernel/irq.c 2004-01-19 10:22:55.000000000 +0000 +++ source/arch/x86_64/kernel/irq.c 2004-02-23 13:56:39.000000000 +0000 @@ -405,6 +405,9 @@ out: spin_unlock(&desc->lock); irq_exit(); + + kgdb_process_breakpoint(); + return 1; } @@ -826,7 +829,7 @@ static cpumask_t irq_affinity [NR_IRQS] static int irq_affinity_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, irq_affinity[(long)data]); + int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); @@ -864,7 +867,7 @@ static int irq_affinity_write_proc (stru static int prof_cpu_mask_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) { - int len = cpumask_snprintf(page, count, *(cpumask_t *)data); + int len = cpumask_scnprintf(page, count, *(cpumask_t *)data); if (count - len < 2) return -EINVAL; len += sprintf(page + len, "\n"); --- diff/arch/x86_64/kernel/nmi.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/x86_64/kernel/nmi.c 2004-02-23 13:56:39.000000000 +0000 @@ -39,7 +39,7 @@ * be enabled * -1: the lapic NMI watchdog is disabled, but can be enabled */ -static int nmi_active; +int nmi_active; /* oprofile uses this */ static int panic_on_timeout; unsigned int nmi_watchdog = NMI_LOCAL_APIC; @@ -218,7 +218,7 @@ static int __init init_lapic_nmi_sysfs(v error = sysdev_class_register(&nmi_sysclass); if (!error) - error = sys_device_register(&device_lapic_nmi); + error = sysdev_register(&device_lapic_nmi); return error; } /* must come after the local APIC's device_initcall() */ @@ -380,6 +380,7 @@ void unset_nmi_callback(void) nmi_callback = dummy_nmi_callback; } +EXPORT_SYMBOL(nmi_active); EXPORT_SYMBOL(nmi_watchdog); EXPORT_SYMBOL(disable_lapic_nmi_watchdog); EXPORT_SYMBOL(enable_lapic_nmi_watchdog); --- diff/arch/x86_64/kernel/pci-gart.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/x86_64/kernel/pci-gart.c 2004-02-23 13:56:39.000000000 +0000 @@ -354,6 +354,11 @@ dma_addr_t pci_map_single(struct pci_dev BUG_ON(dir == PCI_DMA_NONE); +#ifdef CONFIG_SWIOTLB + if (swiotlb) + return swiotlb_map_single(&dev->dev,addr,size,dir); +#endif + phys_mem = virt_to_phys(addr); if (!need_iommu(dev, phys_mem, size)) return phys_mem; @@ -460,6 +465,12 @@ int pci_map_sg(struct pci_dev *dev, stru BUG_ON(dir == PCI_DMA_NONE); if (nents == 0) return 0; + +#ifdef CONFIG_SWIOTLB + if (swiotlb) + return swiotlb_map_sg(&dev->dev,sg,nents,dir); +#endif + out = 0; start = 0; for (i = 0; i < nents; i++) { @@ -520,6 +531,14 @@ void pci_unmap_single(struct pci_dev *hw unsigned long iommu_page; int npages; int i; + +#ifdef CONFIG_SWIOTLB + if (swiotlb) { + swiotlb_unmap_single(&hwdev->dev,dma_addr,size,direction); + return; + } +#endif + if (dma_addr < iommu_bus_base + EMERGENCY_PAGES*PAGE_SIZE || dma_addr >= iommu_bus_base + iommu_size) return; @@ -570,7 +589,7 @@ int pci_dma_supported(struct pci_dev *de return 0; } - if (no_iommu && (mask < (end_pfn << PAGE_SHIFT))) + if (no_iommu && (mask < (end_pfn << PAGE_SHIFT)) && !swiotlb) return 0; return 1; @@ -680,6 +699,7 @@ static __init int init_k8_gatt(struct ag return 0; nommu: + /* Should not happen anymore */ printk(KERN_ERR "PCI-DMA: More than 4GB of RAM and no IOMMU\n" KERN_ERR "PCI-DMA: 32bit PCI IO may malfunction."); return -1; @@ -694,6 +714,7 @@ static int __init pci_iommu_init(void) unsigned long iommu_start; struct pci_dev *dev; + #ifndef CONFIG_AGP_AMD64 no_agp = 1; #else @@ -704,7 +725,14 @@ static int __init pci_iommu_init(void) (agp_copy_info(&info) < 0); #endif - if (no_iommu || (!force_iommu && end_pfn < 0xffffffff>>PAGE_SHIFT)) { + if (swiotlb) { + no_iommu = 1; + printk(KERN_INFO "PCI-DMA: Using SWIOTLB :-(\n"); + return -1; + } + + if (no_iommu || (!force_iommu && end_pfn < 0xffffffff>>PAGE_SHIFT) || + !iommu_aperture) { printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n"); no_iommu = 1; return -1; --- diff/arch/x86_64/kernel/process.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/x86_64/kernel/process.c 2004-02-23 13:56:39.000000000 +0000 @@ -140,6 +140,52 @@ void cpu_idle (void) } } +/* + * This uses new MONITOR/MWAIT instructions on P4 processors with PNI, + * which can obviate IPI to trigger checking of need_resched. + * We execute MONITOR against need_resched and enter optimized wait state + * through MWAIT. Whenever someone changes need_resched, we would be woken + * up from MWAIT (without an IPI). + */ +static void mwait_idle(void) +{ + local_irq_enable(); + + if (!need_resched()) { + set_thread_flag(TIF_POLLING_NRFLAG); + do { + __monitor((void *)¤t_thread_info()->flags, 0, 0); + if (need_resched()) + break; + __mwait(0, 0); + } while (!need_resched()); + clear_thread_flag(TIF_POLLING_NRFLAG); + } +} + +void __init select_idle_routine(const struct cpuinfo_x86 *c) +{ + static int printed; + if (cpu_has(c, X86_FEATURE_MWAIT)) { + /* + * Skip, if setup has overridden idle. + * Also, take care of system with asymmetric CPUs. + * Use, mwait_idle only if all cpus support it. + * If not, we fallback to default_idle() + */ + if (!pm_idle) { + if (!printed) { + printk("using mwait in idle threads.\n"); + printed = 1; + } + pm_idle = mwait_idle; + } + return; + } + pm_idle = default_idle; + return; +} + static int __init idle_setup (char *str) { if (!strncmp(str, "poll", 4)) { --- diff/arch/x86_64/kernel/setup.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/x86_64/kernel/setup.c 2004-02-23 13:56:39.000000000 +0000 @@ -76,6 +76,9 @@ unsigned long pci_mem_start = 0x10000000 unsigned long saved_video_mode; +int swiotlb; +EXPORT_SYMBOL(swiotlb); + /* * Setup options */ @@ -440,7 +443,6 @@ void __init setup_arch(char **cmdline_p) } } #endif - paging_init(); #ifndef CONFIG_SMP @@ -584,6 +586,193 @@ static int __init init_amd(struct cpuinf return r; } +static void __init detect_ht(void) +{ +#ifdef CONFIG_SMP + extern int phys_proc_id[NR_CPUS]; + + u32 eax, ebx, ecx, edx; + int index_lsb, index_msb, tmp; + int initial_apic_id; + int cpu = smp_processor_id(); + + cpuid(1, &eax, &ebx, &ecx, &edx); + smp_num_siblings = (ebx & 0xff0000) >> 16; + + if (smp_num_siblings == 1) { + printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); + } else if (smp_num_siblings > 1) { + index_lsb = 0; + index_msb = 31; + /* + * At this point we only support two siblings per + * processor package. + */ +#define NR_SIBLINGS 2 + if (smp_num_siblings != NR_SIBLINGS) { + printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", smp_num_siblings); + smp_num_siblings = 1; + return; + } + tmp = smp_num_siblings; + while ((tmp & 1) == 0) { + tmp >>=1 ; + index_lsb++; + } + tmp = smp_num_siblings; + while ((tmp & 0x80000000 ) == 0) { + tmp <<=1 ; + index_msb--; + } + if (index_lsb != index_msb ) + index_msb++; + initial_apic_id = ebx >> 24 & 0xff; + phys_proc_id[cpu] = initial_apic_id >> index_msb; + + printk(KERN_INFO "CPU: Physical Processor ID: %d\n", + phys_proc_id[cpu]); + } +#endif +} + +#define LVL_1_INST 1 +#define LVL_1_DATA 2 +#define LVL_2 3 +#define LVL_3 4 +#define LVL_TRACE 5 + +struct _cache_table +{ + unsigned char descriptor; + char cache_type; + short size; +}; + +/* all the cache descriptor types we care about (no TLB or trace cache entries) */ +static struct _cache_table cache_table[] __initdata = +{ + { 0x06, LVL_1_INST, 8 }, + { 0x08, LVL_1_INST, 16 }, + { 0x0a, LVL_1_DATA, 8 }, + { 0x0c, LVL_1_DATA, 16 }, + { 0x22, LVL_3, 512 }, + { 0x23, LVL_3, 1024 }, + { 0x25, LVL_3, 2048 }, + { 0x29, LVL_3, 4096 }, + { 0x2c, LVL_1_DATA, 32 }, + { 0x30, LVL_1_INST, 32 }, + { 0x39, LVL_2, 128 }, + { 0x3b, LVL_2, 128 }, + { 0x3c, LVL_2, 256 }, + { 0x41, LVL_2, 128 }, + { 0x42, LVL_2, 256 }, + { 0x43, LVL_2, 512 }, + { 0x44, LVL_2, 1024 }, + { 0x45, LVL_2, 2048 }, + { 0x66, LVL_1_DATA, 8 }, + { 0x67, LVL_1_DATA, 16 }, + { 0x68, LVL_1_DATA, 32 }, + { 0x70, LVL_TRACE, 12 }, + { 0x71, LVL_TRACE, 16 }, + { 0x72, LVL_TRACE, 32 }, + { 0x79, LVL_2, 128 }, + { 0x7a, LVL_2, 256 }, + { 0x7b, LVL_2, 512 }, + { 0x7c, LVL_2, 1024 }, + { 0x82, LVL_2, 256 }, + { 0x83, LVL_2, 512 }, + { 0x84, LVL_2, 1024 }, + { 0x85, LVL_2, 2048 }, + { 0x86, LVL_2, 512 }, + { 0x87, LVL_2, 1024 }, + { 0x00, 0, 0} +}; + +static void __init init_intel(struct cpuinfo_x86 *c) +{ + /* Cache sizes */ + unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; + unsigned n; + + select_idle_routine(c); + if (c->cpuid_level > 1) { + /* supports eax=2 call */ + int i, j, n; + int regs[4]; + unsigned char *dp = (unsigned char *)regs; + + /* Number of times to iterate */ + n = cpuid_eax(2) & 0xFF; + + for ( i = 0 ; i < n ; i++ ) { + cpuid(2, ®s[0], ®s[1], ®s[2], ®s[3]); + + /* If bit 31 is set, this is an unknown format */ + for ( j = 0 ; j < 3 ; j++ ) { + if ( regs[j] < 0 ) regs[j] = 0; + } + + /* Byte 0 is level count, not a descriptor */ + for ( j = 1 ; j < 16 ; j++ ) { + unsigned char des = dp[j]; + unsigned char k = 0; + + /* look up this descriptor in the table */ + while (cache_table[k].descriptor != 0) + { + if (cache_table[k].descriptor == des) { + switch (cache_table[k].cache_type) { + case LVL_1_INST: + l1i += cache_table[k].size; + break; + case LVL_1_DATA: + l1d += cache_table[k].size; + break; + case LVL_2: + l2 += cache_table[k].size; + break; + case LVL_3: + l3 += cache_table[k].size; + break; + case LVL_TRACE: + trace += cache_table[k].size; + break; + } + + break; + } + + k++; + } + } + } + + if (trace) + printk (KERN_INFO "CPU: Trace cache: %dK uops", trace); + else if (l1i) + printk (KERN_INFO "CPU: L1 I cache: %dK", l1i); + if (l1d) + printk(", L1 D cache: %dK\n", l1d); + else + printk("\n"); + if (l2) + printk(KERN_INFO "CPU: L2 cache: %dK\n", l2); + if (l3) + printk(KERN_INFO "CPU: L3 cache: %dK\n", l3); + + c->x86_cache_size = l2 ? l2 : (l1i+l1d); + } + + if (cpu_has(c, X86_FEATURE_HT)) + detect_ht(); + + n = cpuid_eax(0x80000000); + if (n >= 0x80000008) { + unsigned eax = cpuid_eax(0x80000008); + c->x86_virt_bits = (eax >> 8) & 0xff; + c->x86_phys_bits = eax & 0xff; + } +} void __init get_cpu_vendor(struct cpuinfo_x86 *c) { @@ -591,6 +780,8 @@ void __init get_cpu_vendor(struct cpuinf if (!strcmp(v, "AuthenticAMD")) c->x86_vendor = X86_VENDOR_AMD; + else if (!strcmp(v, "GenuineIntel")) + c->x86_vendor = X86_VENDOR_INTEL; else c->x86_vendor = X86_VENDOR_UNKNOWN; } @@ -606,7 +797,7 @@ struct cpu_model_info { */ void __init identify_cpu(struct cpuinfo_x86 *c) { - int junk, i; + int i; u32 xlvl, tfms; c->loops_per_jiffy = loops_per_jiffy; @@ -630,7 +821,7 @@ void __init identify_cpu(struct cpuinfo_ /* Intel-defined flags: level 0x00000001 */ if (c->cpuid_level >= 0x00000001) { __u32 misc; - cpuid(0x00000001, &tfms, &misc, &junk, + cpuid(0x00000001, &tfms, &misc, &c->x86_capability[4], &c->x86_capability[0]); c->x86 = (tfms >> 8) & 0xf; c->x86_model = (tfms >> 4) & 0xf; @@ -679,9 +870,13 @@ void __init identify_cpu(struct cpuinfo_ init_amd(c); break; + case X86_VENDOR_INTEL: + init_intel(c); + break; + case X86_VENDOR_UNKNOWN: default: - /* Not much we can do here... */ + display_cacheinfo(c); break; } @@ -732,7 +927,7 @@ static int show_cpuinfo(struct seq_file "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce", "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov", "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx", - "fxsr", "sse", "sse2", "ss", NULL, "tm", "ia64", NULL, + "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", NULL, /* AMD-defined */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -751,6 +946,12 @@ static int show_cpuinfo(struct seq_file NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + + /* Intel-defined (#2) */ + "pni", NULL, NULL, "monitor", "ds_cpl", NULL, NULL, "tm2", + "est", NULL, "cid", NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }; static char *x86_power_flags[] = { "ts", /* temperature sensor */ @@ -790,6 +991,14 @@ static int show_cpuinfo(struct seq_file if (c->x86_cache_size >= 0) seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); +#ifdef CONFIG_X86_HT + if (cpu_has_ht) { + extern int phys_proc_id[NR_CPUS]; + seq_printf(m, "physical id\t: %d\n", phys_proc_id[c - cpu_data]); + seq_printf(m, "siblings\t: %d\n", smp_num_siblings); + } +#endif + seq_printf(m, "fpu\t\t: yes\n" "fpu_exception\t: yes\n" --- diff/arch/x86_64/kernel/smp.c 2003-11-25 15:24:57.000000000 +0000 +++ source/arch/x86_64/kernel/smp.c 2004-02-23 13:56:39.000000000 +0000 @@ -362,6 +362,18 @@ void smp_send_reschedule(int cpu) send_IPI_mask(cpumask_of_cpu(cpu), RESCHEDULE_VECTOR); } +#ifdef CONFIG_KGDB +/* + * By using the NMI code instead of a vector we just sneak thru the + * word generator coming out with just what we want. AND it does + * not matter if clustered_apic_mode is set or not. + */ +void smp_send_nmi_allbutself(void) +{ + send_IPI_allbutself(APIC_DM_NMI); +} +#endif + /* * Structure and data for smp_call_function(). This is designed to minimise * static memory requirements. It also looks cleaner. --- diff/arch/x86_64/kernel/smpboot.c 2003-09-17 12:28:03.000000000 +0100 +++ source/arch/x86_64/kernel/smpboot.c 2004-02-23 13:56:39.000000000 +0000 @@ -53,6 +53,10 @@ #include #include +/* Number of siblings per CPU package */ +int smp_num_siblings = 1; +int phys_proc_id[NR_CPUS]; /* Package ID of each logical CPU */ + /* Bitmask of currently online CPUs */ cpumask_t cpu_online_map; @@ -66,6 +70,8 @@ struct cpuinfo_x86 cpu_data[NR_CPUS] __c /* Set when the idlers are all forked */ int smp_threads_ready; +int cpu_sibling_map[NR_CPUS] __cacheline_aligned; + /* * Trampoline 80x86 program as an array. */ @@ -857,6 +863,34 @@ static void __init smp_boot_cpus(unsigne Dprintk("Before bogocount - setting activated=1.\n"); } + /* + * If Hyper-Threading is avaialble, construct cpu_sibling_map[], so + * that we can tell the sibling CPU efficiently. + */ + if (cpu_has_ht && smp_num_siblings > 1) { + for (cpu = 0; cpu < NR_CPUS; cpu++) + cpu_sibling_map[cpu] = NO_PROC_ID; + + for (cpu = 0; cpu < NR_CPUS; cpu++) { + int i; + if (!cpu_isset(cpu, cpu_callout_map)) + continue; + + for (i = 0; i < NR_CPUS; i++) { + if (i == cpu || !cpu_isset(i, cpu_callout_map)) + continue; + if (phys_proc_id[cpu] == phys_proc_id[i]) { + cpu_sibling_map[cpu] = i; + break; + } + } + if (cpu_sibling_map[cpu] == NO_PROC_ID) { + smp_num_siblings = 1; + printk(KERN_WARNING "WARNING: No sibling found for CPU %d.\n", cpu); + } + } + } + Dprintk("Boot done.\n"); /* --- diff/arch/x86_64/kernel/sys_x86_64.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/x86_64/kernel/sys_x86_64.c 2004-02-23 13:56:39.000000000 +0000 @@ -4,6 +4,7 @@ #include #include +#include #include #include #include --- diff/arch/x86_64/kernel/traps.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/x86_64/kernel/traps.c 2004-02-23 13:56:39.000000000 +0000 @@ -45,6 +45,9 @@ #include #include +#ifdef CONFIG_KGDB +#include +#endif extern struct gate_struct idt_table[256]; --- diff/arch/x86_64/kernel/x8664_ksyms.c 2004-02-09 10:36:09.000000000 +0000 +++ source/arch/x86_64/kernel/x8664_ksyms.c 2004-02-23 13:56:39.000000000 +0000 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -180,8 +181,6 @@ EXPORT_SYMBOL_NOVERS(memcpy); EXPORT_SYMBOL_NOVERS(__memcpy); /* syscall export needed for misdesigned sound drivers. */ -extern ssize_t sys_read(unsigned int fd, char * buf, size_t count); -extern off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin); EXPORT_SYMBOL(sys_read); EXPORT_SYMBOL(sys_lseek); EXPORT_SYMBOL(sys_open); @@ -194,6 +193,10 @@ EXPORT_SYMBOL(atomic_dec_and_lock); EXPORT_SYMBOL(die_chain); +#ifdef CONFIG_SMP +EXPORT_SYMBOL(cpu_sibling_map); +#endif + extern void do_softirq_thunk(void); EXPORT_SYMBOL_NOVERS(do_softirq_thunk); --- diff/arch/x86_64/lib/Makefile 2003-06-30 10:07:20.000000000 +0100 +++ source/arch/x86_64/lib/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -11,3 +11,4 @@ lib-y += memcpy.o memmove.o memset.o cop lib-$(CONFIG_IO_DEBUG) += iodebug.o lib-$(CONFIG_HAVE_DEC_LOCK) += dec_and_lock.o +lib-$(CONFIG_KGDB) += kgdb_serial.o --- diff/arch/x86_64/lib/copy_page.S 2003-09-30 15:46:12.000000000 +0100 +++ source/arch/x86_64/lib/copy_page.S 2004-02-23 13:56:39.000000000 +0000 @@ -8,11 +8,6 @@ .globl copy_page .p2align 4 copy_page: - prefetch (%rsi) - prefetch 1*64(%rsi) - prefetchw (%rdi) - prefetchw 1*64(%rdi) - subq $3*8,%rsp movq %rbx,(%rsp) movq %r12,1*8(%rsp) @@ -32,7 +27,7 @@ copy_page: movq 48 (%rsi), %r11 movq 56 (%rsi), %r12 - prefetch 5*64(%rsi) + prefetcht0 5*64(%rsi) movq %rax, (%rdi) movq %rbx, 8 (%rdi) @@ -43,8 +38,6 @@ copy_page: movq %r11, 48 (%rdi) movq %r12, 56 (%rdi) - prefetchw 5*64(%rdi) - leaq 64 (%rsi), %rsi leaq 64 (%rdi), %rdi --- diff/arch/x86_64/lib/csum-copy.S 2003-09-30 15:46:12.000000000 +0100 +++ source/arch/x86_64/lib/csum-copy.S 2004-02-23 13:56:39.000000000 +0000 @@ -59,15 +59,6 @@ csum_partial_copy_generic: cmpl $3*64,%edx jle .Lignore - ignore - prefetch (%rdi) - ignore - prefetch 1*64(%rdi) - ignore - prefetchw (%rsi) - ignore - prefetchw 1*64(%rsi) - .Lignore: subq $7*8,%rsp movq %rbx,2*8(%rsp) @@ -115,7 +106,7 @@ csum_partial_copy_generic: movq 56(%rdi),%r13 ignore 2f - prefetch 5*64(%rdi) + prefetcht0 5*64(%rdi) 2: adcq %rbx,%rax adcq %r8,%rax @@ -146,8 +137,6 @@ csum_partial_copy_generic: dest movq %r13,56(%rsi) - ignore 3f - prefetchw 5*64(%rsi) 3: leaq 64(%rdi),%rdi --- diff/arch/x86_64/mm/init.c 2004-02-18 08:54:08.000000000 +0000 +++ source/arch/x86_64/mm/init.c 2004-02-23 13:56:39.000000000 +0000 @@ -402,6 +402,13 @@ void __init mem_init(void) int codesize, reservedpages, datasize, initsize; int tmp; +#ifdef CONFIG_SWIOTLB + if (!iommu_aperture && end_pfn >= 0xffffffff>>PAGE_SHIFT) { + swiotlb_init(); + swiotlb = 1; + } +#endif + /* How many end-of-memory variables you have, grandma! */ max_low_pfn = end_pfn; max_pfn = end_pfn; --- diff/arch/x86_64/oprofile/Makefile 2003-09-30 15:46:12.000000000 +0100 +++ source/arch/x86_64/oprofile/Makefile 2004-02-23 13:56:39.000000000 +0000 @@ -1,7 +1,6 @@ # # oprofile for x86-64. -# Just reuse the one from i386. The Hammer performance counters -# are similar to Athlon. +# Just reuse the one from i386. # obj-$(CONFIG_OPROFILE) += oprofile.o @@ -13,7 +12,8 @@ DRIVER_OBJS = $(addprefix ../../../drive timer_int.o ) OPROFILE-y := init.o -OPROFILE-$(CONFIG_X86_LOCAL_APIC) += nmi_int.o op_model_athlon.o +OPROFILE-$(CONFIG_X86_LOCAL_APIC) += nmi_int.o op_model_athlon.o op_model_p4.o \ + op_model_ppro.o OPROFILE-$(CONFIG_X86_IO_APIC) += nmi_timer_int.o oprofile-y = $(DRIVER_OBJS) $(addprefix ../../i386/oprofile/, $(OPROFILE-y)) --- diff/drivers/Makefile 2003-09-17 12:28:03.000000000 +0100 +++ source/drivers/Makefile 2004-02-23 13:56:43.000000000 +0000 @@ -45,7 +45,7 @@ obj-$(CONFIG_I2C) += i2c/ obj-$(CONFIG_PHONE) += telephony/ obj-$(CONFIG_MD) += md/ obj-$(CONFIG_BT) += bluetooth/ -obj-$(CONFIG_ISDN_BOOL) += isdn/ +obj-$(CONFIG_ISDN) += isdn/ obj-$(CONFIG_MCA) += mca/ obj-$(CONFIG_EISA) += eisa/ obj-$(CONFIG_CPU_FREQ) += cpufreq/ --- diff/drivers/acorn/char/i2c.c 2004-02-09 10:36:09.000000000 +0000 +++ source/drivers/acorn/char/i2c.c 2004-02-23 13:56:40.000000000 +0000 @@ -311,9 +311,6 @@ static struct i2c_adapter ioc_ops = { .algo_data = &ioc_data, .client_register = ioc_client_reg, .client_unregister = ioc_client_unreg, - .dev = { - .name = "IOC/IOMD", - }, }; static int __init i2c_ioc_init(void) --- diff/drivers/acorn/char/pcf8583.c 2003-06-09 14:18:18.000000000 +0100 +++ source/drivers/acorn/char/pcf8583.c 2004-02-23 13:56:40.000000000 +0000 @@ -37,8 +37,7 @@ static struct i2c_client_address_data ad #define DAT(x) ((unsigned int)(x->dev.driver_data)) static int -pcf8583_attach(struct i2c_adapter *adap, int addr, unsigned short flags, - int kind) +pcf8583_attach(struct i2c_adapter *adap, int addr, int kind) { struct i2c_client *c; unsigned char buf[1], ad[1] = { 0 }; @@ -51,13 +50,11 @@ pcf8583_attach(struct i2c_adapter *adap, if (!c) return -ENOMEM; - strcpy(c->dev.name, "PCF8583"); + memset(c, 0, sizeof(*c)); c->id = pcf8583_driver.id; - c->flags = 0; c->addr = addr; c->adapter = adap; c->driver = &pcf8583_driver; - c->dev.driver_data = NULL; if (i2c_transfer(c->adapter, msgs, 2) == 2) DAT(c) = buf[0]; --- diff/drivers/acpi/Kconfig 2004-02-18 08:54:08.000000000 +0000 +++ source/drivers/acpi/Kconfig 2004-02-23 13:56:40.000000000 +0000 @@ -263,5 +263,23 @@ config ACPI_RELAXED_AML particular, many Toshiba laptops require this for correct operation of the AC module. +config X86_PM_TIMER + bool "Power Management Timer Support" + depends on X86 && ACPI + depends on ACPI_BOOT && EXPERIMENTAL + default n + help + The Power Management Timer is available on all ACPI-capable, + in most cases even if ACPI is unusable or blacklisted. + + This timing source is not affected by powermanagement features + like aggressive processor idling, throttling, frequency and/or + voltage scaling, unlike the commonly used Time Stamp Counter + (TSC) timing source. + + So, if you see messages like 'Losing too many ticks!' in the + kernel logs, and/or you are using a this on a notebook which + does not yet have an HPET, you should say "Y" here. + endmenu --- diff/drivers/acpi/dispatcher/dsmthdat.c 2004-02-09 10:36:09.000000000 +0000 +++ source/drivers/acpi/dispatcher/dsmthdat.c 2004-02-23 13:56:40.000000000 +0000 @@ -206,8 +206,7 @@ acpi_ds_method_data_init_args ( * Store the argument in the method/walk descriptor. * Do not copy the arg in order to implement call by reference */ - status = acpi_ds_method_data_set_value (AML_ARG_OP, index, params[index], - walk_state); + status = acpi_ds_method_data_set_value (AML_ARG_OP, index, params[index], walk_state); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } @@ -465,6 +464,7 @@ acpi_ds_method_data_get_value ( return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); default: + ACPI_REPORT_ERROR (("Not Arg/Local opcode: %X\n", opcode)); return_ACPI_STATUS (AE_AML_INTERNAL); } } @@ -597,7 +597,10 @@ acpi_ds_store_object_to_local ( /* * If the reference count on the object is more than one, we must - * take a copy of the object before we store. + * take a copy of the object before we store. A reference count + * of exactly 1 means that the object was just created during the + * evaluation of an expression, and we can safely use it since it + * is not used anywhere else. */ new_obj_desc = obj_desc; if (obj_desc->common.reference_count > 1) { --- diff/drivers/acpi/dispatcher/dsobject.c 2004-02-09 10:36:09.000000000 +0000 +++ source/drivers/acpi/dispatcher/dsobject.c 2004-02-23 13:56:40.000000000 +0000 @@ -582,6 +582,11 @@ acpi_ds_init_object_from_op ( obj_desc->reference.opcode = AML_ARG_OP; obj_desc->reference.offset = opcode - AML_ARG_OP; + +#ifndef ACPI_NO_METHOD_EXECUTION + status = acpi_ds_method_data_get_node (AML_ARG_OP, obj_desc->reference.offset, + walk_state, (struct acpi_namespace_node **) &obj_desc->reference.object); +#endif break; default: /* Other literals, etc.. */ --- diff/drivers/acpi/dispatcher/dsopcode.c 2004-02-09 10:36:09.000000000 +0000 +++ source/drivers/acpi/dispatcher/dsopcode.c 2004-02-23 13:56:40.000000000 +0000 @@ -243,8 +243,8 @@ acpi_ds_get_buffer_arguments ( node = obj_desc->buffer.node; if (!node) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "No pointer back to NS node in buffer %p\n", obj_desc)); + ACPI_REPORT_ERROR (( + "No pointer back to NS node in buffer obj %p\n", obj_desc)); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -290,7 +290,7 @@ acpi_ds_get_package_arguments ( node = obj_desc->package.node; if (!node) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + ACPI_REPORT_ERROR (( "No pointer back to NS node in package %p\n", obj_desc)); return_ACPI_STATUS (AE_AML_INTERNAL); } --- diff/drivers/acpi/dispatcher/dsutils.c 2004-02-09 10:36:09.000000000 +0000 +++ source/drivers/acpi/dispatcher/dsutils.c 2004-02-23 13:56:40.000000000 +0000 @@ -280,7 +280,8 @@ acpi_ds_resolve_operands ( /* * Attempt to resolve each of the valid operands - * Method arguments are passed by value, not by reference + * Method arguments are passed by reference, not by value. This means + * that the actual objects are passed, not copies of the objects. */ for (i = 0; i < walk_state->num_operands; i++) { status = acpi_ex_resolve_to_value (&walk_state->operands[i], walk_state); --- diff/drivers/acpi/dispatcher/dswstate.c 2004-02-09 10:36:09.000000000 +0000 +++ source/drivers/acpi/dispatcher/dswstate.c 2004-02-23 13:56:40.000000000 +0000 @@ -328,7 +328,7 @@ acpi_ds_result_push ( state = walk_state->results; if (!state) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result stack frame\n")); + ACPI_REPORT_ERROR (("No result stack frame during push\n")); return (AE_AML_INTERNAL); } --- diff/drivers/acpi/executer/exconvrt.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/acpi/executer/exconvrt.c 2004-02-23 13:56:40.000000000 +0000 @@ -55,8 +55,9 @@ * * FUNCTION: acpi_ex_convert_to_integer * - * PARAMETERS: *obj_desc - Object to be converted. Must be an + * PARAMETERS: obj_desc - Object to be converted. Must be an * Integer, Buffer, or String + * result_desc - Where the new Integer object is returned * walk_state - Current method state * * RETURN: Status @@ -189,8 +190,9 @@ acpi_ex_convert_to_integer ( * * FUNCTION: acpi_ex_convert_to_buffer * - * PARAMETERS: *obj_desc - Object to be converted. Must be an + * PARAMETERS: obj_desc - Object to be converted. Must be an * Integer, Buffer, or String + * result_desc - Where the new buffer object is returned * walk_state - Current method state * * RETURN: Status @@ -319,6 +321,7 @@ acpi_ex_convert_to_ascii ( ACPI_FUNCTION_ENTRY (); + if (data_width < sizeof (acpi_integer)) { leading_zero = FALSE; length = data_width; @@ -328,22 +331,21 @@ acpi_ex_convert_to_ascii ( length = sizeof (acpi_integer); } - switch (base) { case 10: remainder = 0; - for (i = ACPI_MAX_DECIMAL_DIGITS; i > 0 ; i--) { + for (i = ACPI_MAX_DECIMAL_DIGITS; i > 0; i--) { /* Divide by nth factor of 10 */ digit = integer; - for (j = 1; j < i; j++) { + for (j = 0; j < i; j++) { (void) acpi_ut_short_divide (&digit, 10, &digit, &remainder); } /* Create the decimal digit */ - if (digit != 0) { + if (remainder != 0) { leading_zero = FALSE; } @@ -354,6 +356,7 @@ acpi_ex_convert_to_ascii ( } break; + case 16: /* Copy the integer to the buffer */ @@ -372,13 +375,14 @@ acpi_ex_convert_to_ascii ( } break; + default: break; } /* * Since leading zeros are supressed, we must check for the case where - * the integer equals 0. + * the integer equals 0 * * Finally, null terminate the string and return the length */ @@ -396,8 +400,11 @@ acpi_ex_convert_to_ascii ( * * FUNCTION: acpi_ex_convert_to_string * - * PARAMETERS: *obj_desc - Object to be converted. Must be an - * Integer, Buffer, or String + * PARAMETERS: obj_desc - Object to be converted. Must be an + * Integer, Buffer, or String + * result_desc - Where the string object is returned + * Base - 10 or 16 + * max_length - Max length of the returned string * walk_state - Current method state * * RETURN: Status @@ -415,10 +422,10 @@ acpi_ex_convert_to_string ( struct acpi_walk_state *walk_state) { union acpi_operand_object *ret_desc; - u32 i; - u32 string_length; u8 *new_buf; u8 *pointer; + u32 string_length; + u32 i; ACPI_FUNCTION_TRACE_PTR ("ex_convert_to_string", obj_desc); @@ -539,7 +546,6 @@ acpi_ex_convert_to_string ( return_ACPI_STATUS (AE_TYPE); } - /* * If we are about to overwrite the original object on the operand stack, * we must remove a reference on the original object because we are @@ -562,6 +568,7 @@ acpi_ex_convert_to_string ( * * PARAMETERS: destination_type - Current type of the destination * source_desc - Source object to be converted. + * result_desc - Where the converted object is returned * walk_state - Current method state * * RETURN: Status @@ -653,6 +660,8 @@ acpi_ex_convert_to_target_type ( default: + ACPI_REPORT_ERROR (("Bad destination type during conversion: %X\n", + destination_type)); status = AE_AML_INTERNAL; break; } @@ -672,6 +681,8 @@ acpi_ex_convert_to_target_type ( GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args), walk_state->op_info->name, acpi_ut_get_type_name (destination_type))); + ACPI_REPORT_ERROR (("Bad Target Type (ARGI): %X\n", + GET_CURRENT_ARG_TYPE (walk_state->op_info->runtime_args))) status = AE_AML_INTERNAL; } --- diff/drivers/acpi/executer/exfldio.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/acpi/executer/exfldio.c 2004-02-23 13:56:40.000000000 +0000 @@ -507,8 +507,8 @@ acpi_ex_field_datum_io ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p, Wrong object type - %s\n", - obj_desc, acpi_ut_get_object_type_name (obj_desc))); + ACPI_REPORT_ERROR (("Wrong object type in field I/O %X\n", + ACPI_GET_OBJECT_TYPE (obj_desc))); status = AE_AML_INTERNAL; break; } --- diff/drivers/acpi/executer/exmisc.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/acpi/executer/exmisc.c 2004-02-23 13:56:40.000000000 +0000 @@ -103,7 +103,7 @@ acpi_ex_get_object_reference ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference subtype %X\n", + ACPI_REPORT_ERROR (("Unknown Reference subtype in get ref %X\n", obj_desc->reference.opcode)); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -121,8 +121,8 @@ acpi_ex_get_object_reference ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p has invalid descriptor [%s]\n", - obj_desc, acpi_ut_get_descriptor_name (obj_desc))); + ACPI_REPORT_ERROR (("Invalid descriptor type in get ref: %X\n", + ACPI_GET_DESCRIPTOR_TYPE (obj_desc))); return_ACPI_STATUS (AE_TYPE); } @@ -349,6 +349,8 @@ acpi_ex_do_concatenate ( /* Invalid object type, should not happen here */ + ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n", + ACPI_GET_OBJECT_TYPE (obj_desc1))); status = AE_AML_INTERNAL; return_desc = NULL; } --- diff/drivers/acpi/executer/exoparg2.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/acpi/executer/exoparg2.c 2004-02-23 13:56:40.000000000 +0000 @@ -329,6 +329,8 @@ acpi_ex_opcode_2A_1T_1R ( break; default: + ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n", + ACPI_GET_OBJECT_TYPE (operand[0]))); status = AE_AML_INTERNAL; } @@ -433,7 +435,7 @@ acpi_ex_opcode_2A_1T_1R ( } return_desc->reference.target_type = ACPI_TYPE_PACKAGE; - return_desc->reference.object = operand[0]->package.elements [index]; + return_desc->reference.object = operand[0]; return_desc->reference.where = &operand[0]->package.elements [index]; } else { --- diff/drivers/acpi/executer/exprep.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/acpi/executer/exprep.c 2004-02-23 13:56:40.000000000 +0000 @@ -507,7 +507,7 @@ acpi_ex_prep_field_value ( (info->field_bit_position / ACPI_MUL_8 (obj_desc->field.access_byte_width)); if (!obj_desc->index_field.data_obj || !obj_desc->index_field.index_obj) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Index Object\n")); + ACPI_REPORT_ERROR (("Null Index Object during field prep\n")); return_ACPI_STATUS (AE_AML_INTERNAL); } --- diff/drivers/acpi/executer/exresolv.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/acpi/executer/exresolv.c 2004-02-23 13:56:40.000000000 +0000 @@ -238,8 +238,8 @@ acpi_ex_resolve_object_to_value ( /* Invalid reference object */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown target_type %X in Index/Reference obj %p\n", + ACPI_REPORT_ERROR (( + "During resolve, Unknown target_type %X in Index/Reference obj %p\n", stack_desc->reference.target_type, stack_desc)); status = AE_AML_INTERNAL; break; @@ -258,7 +258,7 @@ acpi_ex_resolve_object_to_value ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference opcode %X (%s) in %p\n", + ACPI_REPORT_ERROR (("During resolve, Unknown Reference opcode %X (%s) in %p\n", opcode, acpi_ps_get_opcode_name (opcode), stack_desc)); status = AE_AML_INTERNAL; break; --- diff/drivers/acpi/executer/exresop.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/acpi/executer/exresop.c 2004-02-23 13:56:40.000000000 +0000 @@ -154,7 +154,7 @@ acpi_ex_resolve_operands ( arg_types = op_info->runtime_args; if (arg_types == ARGI_INVALID_OPCODE) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - %X is not a valid AML opcode\n", + ACPI_REPORT_ERROR (("resolve_operands: %X is not a valid AML opcode\n", opcode)); return_ACPI_STATUS (AE_AML_INTERNAL); @@ -172,7 +172,7 @@ acpi_ex_resolve_operands ( */ while (GET_CURRENT_ARG_TYPE (arg_types)) { if (!stack_ptr || !*stack_ptr) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null stack entry at %p\n", + ACPI_REPORT_ERROR (("resolve_operands: Null stack entry at %p\n", stack_ptr)); return_ACPI_STATUS (AE_AML_INTERNAL); --- diff/drivers/acpi/executer/exstore.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/acpi/executer/exstore.c 2004-02-23 13:56:40.000000000 +0000 @@ -125,7 +125,7 @@ acpi_ex_store ( default: - /* Destination is not an Reference */ + /* Destination is not a Reference object */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Destination is not a Reference or Constant object [%p]\n", dest_desc)); @@ -189,35 +189,38 @@ acpi_ex_store ( switch (ACPI_GET_OBJECT_TYPE (source_desc)) { case ACPI_TYPE_INTEGER: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%8.8X%8.8X\n", + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n", ACPI_FORMAT_UINT64 (source_desc->integer.value))); break; case ACPI_TYPE_BUFFER: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length %.2X\n", + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X", (u32) source_desc->buffer.length)); + ACPI_DUMP_BUFFER (source_desc->buffer.pointer, + (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32); break; case ACPI_TYPE_STRING: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s\n", source_desc->string.pointer)); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X, \"%s\"\n", + source_desc->string.length, source_desc->string.pointer)); break; case ACPI_TYPE_PACKAGE: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements Ptr - %p\n", - source_desc->package.elements)); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Size 0x%.2X Elements Ptr - %p\n", + source_desc->package.count, source_desc->package.elements)); break; default: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Type %s %p\n", - acpi_ut_get_object_type_name (source_desc), source_desc)); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p\n", + source_desc)); break; } @@ -227,7 +230,7 @@ acpi_ex_store ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference opcode %X\n", + ACPI_REPORT_ERROR (("ex_store: Unknown Reference opcode %X\n", ref_desc->reference.opcode)); ACPI_DUMP_ENTRY (ref_desc, ACPI_LV_ERROR); @@ -263,6 +266,7 @@ acpi_ex_store_object_to_index ( union acpi_operand_object *obj_desc; union acpi_operand_object *new_desc; u8 value = 0; + u32 i; ACPI_FUNCTION_TRACE ("ex_store_object_to_index"); @@ -283,6 +287,7 @@ acpi_ex_store_object_to_index ( /* * The object at *(index_desc->Reference.Where) is the * element within the package that is to be modified. + * The parent package object is at index_desc->Reference.Object */ obj_desc = *(index_desc->reference.where); @@ -309,6 +314,12 @@ acpi_ex_store_object_to_index ( if (new_desc == source_desc) { acpi_ut_add_reference (new_desc); } + + /* Increment reference count by the ref count of the parent package -1 */ + + for (i = 1; i < ((union acpi_operand_object *) index_desc->reference.object)->common.reference_count; i++) { + acpi_ut_add_reference (new_desc); + } } break; --- diff/drivers/acpi/executer/exstoren.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/acpi/executer/exstoren.c 2004-02-23 13:56:40.000000000 +0000 @@ -112,6 +112,12 @@ acpi_ex_resolve_object ( } } + /* For copy_object, no further validation necessary */ + + if (walk_state->opcode == AML_COPY_OP) { + break; + } + /* * Must have a Integer, Buffer, or String */ @@ -136,7 +142,7 @@ acpi_ex_resolve_object ( /* * Aliases are resolved by acpi_ex_prep_operands */ - ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into Alias - should never happen\n")); + ACPI_REPORT_ERROR (("Store into Alias - should never happen\n")); status = AE_AML_INTERNAL; break; --- diff/drivers/acpi/namespace/nsaccess.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/acpi/namespace/nsaccess.c 2004-02-23 13:56:40.000000000 +0000 @@ -314,7 +314,7 @@ acpi_ns_lookup ( else { prefix_node = scope_info->scope.node; if (ACPI_GET_DESCRIPTOR_TYPE (prefix_node) != ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p Not a namespace node [%s]\n", + ACPI_REPORT_ERROR (("ns_lookup: %p is not a namespace node [%s]\n", prefix_node, acpi_ut_get_descriptor_name (prefix_node))); return_ACPI_STATUS (AE_AML_INTERNAL); } --- diff/drivers/acpi/parser/psargs.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/acpi/parser/psargs.c 2004-02-23 13:56:40.000000000 +0000 @@ -315,8 +315,8 @@ acpi_ps_get_next_namepath ( acpi_ps_append_arg (arg, name_op); if (!method_desc) { - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Control Method - %p has no attached object\n", + ACPI_REPORT_ERROR (( + "ps_get_next_namepath: Control Method %p has no attached object\n", node)); return_ACPI_STATUS (AE_AML_INTERNAL); } --- diff/drivers/acpi/sleep/proc.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/acpi/sleep/proc.c 2004-02-23 13:56:40.000000000 +0000 @@ -44,10 +44,10 @@ static int acpi_system_sleep_open_fs(str return single_open(file, acpi_system_sleep_seq_show, PDE(inode)->data); } -static int +static ssize_t acpi_system_write_sleep ( struct file *file, - const char *buffer, + const char __user *buffer, size_t count, loff_t *ppos) { @@ -189,10 +189,10 @@ get_date_field ( } -static int +static ssize_t acpi_system_write_alarm ( struct file *file, - const char *buffer, + const char __user *buffer, size_t count, loff_t *ppos) { --- diff/drivers/acpi/tables.c 2004-02-18 08:54:08.000000000 +0000 +++ source/drivers/acpi/tables.c 2004-02-23 13:56:40.000000000 +0000 @@ -58,6 +58,7 @@ static char *acpi_table_signatures[ACPI_ [ACPI_SSDT] = "SSDT", [ACPI_SPMI] = "SPMI", [ACPI_HPET] = "HPET", + [ACPI_MCFG] = "MCFG", }; static char *mps_inti_flags_polarity[] = { "dfl", "high", "res", "low" }; --- diff/drivers/acpi/utils.c 2003-02-26 16:00:53.000000000 +0000 +++ source/drivers/acpi/utils.c 2004-02-23 13:56:40.000000000 +0000 @@ -350,7 +350,7 @@ acpi_evaluate_reference ( if ((buffer.length == 0) || !package) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No return object (len %X ptr %p)\n", - buffer.length, package)); + (unsigned)buffer.length, package)); status = AE_BAD_DATA; acpi_util_eval_error(handle, pathname, status); goto end; --- diff/drivers/base/Makefile 2004-02-18 08:54:08.000000000 +0000 +++ source/drivers/base/Makefile 2004-02-23 13:56:40.000000000 +0000 @@ -2,7 +2,8 @@ obj-y := core.o sys.o interface.o bus.o \ driver.o class.o class_simple.o platform.o \ - cpu.o firmware.o init.o map.o dmapool.o + cpu.o firmware.o init.o map.o +obj-$(CONFIG_PCI) += dmapool.o obj-y += power/ obj-$(CONFIG_FW_LOADER) += firmware_class.o obj-$(CONFIG_NUMA) += node.o --- diff/drivers/base/cpu.c 2003-10-27 09:20:43.000000000 +0000 +++ source/drivers/base/cpu.c 2004-02-23 13:56:40.000000000 +0000 @@ -7,6 +7,7 @@ #include #include #include +#include struct sysdev_class cpu_sysdev_class = { @@ -14,6 +15,46 @@ struct sysdev_class cpu_sysdev_class = { }; EXPORT_SYMBOL(cpu_sysdev_class); +#ifdef CONFIG_HOTPLUG_CPU +static ssize_t show_online(struct sys_device *dev, char *buf) +{ + struct cpu *cpu = container_of(dev, struct cpu, sysdev); + + return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id)); +} + +static ssize_t store_online(struct sys_device *dev, const char *buf, + size_t count) +{ + struct cpu *cpu = container_of(dev, struct cpu, sysdev); + ssize_t ret; + + switch (buf[0]) { + case '0': + ret = cpu_down(cpu->sysdev.id); + break; + case '1': + ret = cpu_up(cpu->sysdev.id); + break; + default: + ret = -EINVAL; + } + + if (ret >= 0) + ret = count; + return ret; +} +static SYSDEV_ATTR(online, 0600, show_online, store_online); + +static void __init register_cpu_control(struct cpu *cpu) +{ + sysdev_create_file(&cpu->sysdev, &attr_online); +} +#else /* ... !CONFIG_HOTPLUG_CPU */ +static void __init register_cpu_control(struct cpu *cpu) +{ +} +#endif /* CONFIG_HOTPLUG_CPU */ /* * register_cpu - Setup a driverfs device for a CPU. @@ -29,11 +70,13 @@ int __init register_cpu(struct cpu *cpu, cpu->sysdev.id = num; cpu->sysdev.cls = &cpu_sysdev_class; - error = sys_device_register(&cpu->sysdev); + error = sysdev_register(&cpu->sysdev); if (!error && root) error = sysfs_create_link(&root->sysdev.kobj, &cpu->sysdev.kobj, kobject_name(&cpu->sysdev.kobj)); + if (!error) + register_cpu_control(cpu); return error; } --- diff/drivers/base/dmapool.c 2004-02-18 08:54:08.000000000 +0000 +++ source/drivers/base/dmapool.c 2004-02-23 13:56:40.000000000 +0000 @@ -52,7 +52,7 @@ show_pools (struct device *dev, char *bu next = buf; size = PAGE_SIZE; - temp = snprintf (next, size, "poolinfo - 0.1\n"); + temp = scnprintf(next, size, "poolinfo - 0.1\n"); size -= temp; next += temp; @@ -67,7 +67,7 @@ show_pools (struct device *dev, char *bu } /* per-pool info, no real statistics yet */ - temp = snprintf (next, size, "%-16s %4u %4Zu %4Zu %2u\n", + temp = scnprintf(next, size, "%-16s %4u %4Zu %4Zu %2u\n", pool->name, blocks, pages * pool->blocks_per_page, pool->size, pages); --- diff/drivers/base/node.c 2004-01-19 10:22:55.000000000 +0000 +++ source/drivers/base/node.c 2004-02-23 13:56:40.000000000 +0000 @@ -23,7 +23,7 @@ static ssize_t node_read_cpumap(struct s /* FIXME - someone should pass us a buffer size (count) or * use seq_file or something to avoid buffer overrun risk. */ - len = cpumask_snprintf(buf, 99 /* XXX FIXME */, mask); + len = cpumask_scnprintf(buf, 99 /* XXX FIXME */, mask); len += sprintf(buf + len, "\n"); return len; } @@ -69,7 +69,7 @@ int __init register_node(struct node *no node->cpumap = node_to_cpumask(num); node->sysdev.id = num; node->sysdev.cls = &node_class; - error = sys_device_register(&node->sysdev); + error = sysdev_register(&node->sysdev); if (!error){ sysdev_create_file(&node->sysdev, &attr_cpumap); --- diff/drivers/base/sys.c 2003-09-17 12:28:03.000000000 +0100 +++ source/drivers/base/sys.c 2004-02-23 13:56:40.000000000 +0000 @@ -8,7 +8,7 @@ * * This exports a 'system' bus type. * By default, a 'sys' bus gets added to the root of the system. There will - * always be core system devices. Devices can use sys_device_register() to + * always be core system devices. Devices can use sysdev_register() to * add themselves as children of the system bus. */ @@ -164,11 +164,11 @@ EXPORT_SYMBOL(sysdev_driver_unregister); /** - * sys_device_register - add a system device to the tree + * sysdev_register - add a system device to the tree * @sysdev: device in question * */ -int sys_device_register(struct sys_device * sysdev) +int sysdev_register(struct sys_device * sysdev) { int error; struct sysdev_class * cls = sysdev->cls; @@ -212,7 +212,7 @@ int sys_device_register(struct sys_devic return error; } -void sys_device_unregister(struct sys_device * sysdev) +void sysdev_unregister(struct sys_device * sysdev) { struct sysdev_driver * drv; @@ -390,5 +390,5 @@ int __init sys_bus_init(void) return subsystem_register(&system_subsys); } -EXPORT_SYMBOL(sys_device_register); -EXPORT_SYMBOL(sys_device_unregister); +EXPORT_SYMBOL(sysdev_register); +EXPORT_SYMBOL(sysdev_unregister); --- diff/drivers/block/Kconfig 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/block/Kconfig 2004-02-23 13:56:40.000000000 +0000 @@ -235,10 +235,13 @@ config BLK_DEV_LOOP bits of, say, a sound file). This is also safe if the file resides on a remote file server. - There are several ways of doing this. Some of these require kernel - patches. The vanilla kernel offers the cryptoloop option. If you - want to use that, say Y to both LOOP and CRYPTOLOOP, and make sure - you have a recent (version 2.12 or later) version of util-linux. + There are several ways of encrypting disks. Some of these require + kernel patches. The vanilla kernel offers the cryptoloop option + and a Device Mapper target (which is superior, as it supports all + file systems). If you want to use the cryptoloop, say Y to both + LOOP and CRYPTOLOOP, and make sure you have a recent (version 2.12 + or later) version of util-linux. Additionally, be aware that + the cryptoloop is not safe for storing journaled filesystems. Note that this loop device has nothing to do with the loopback device used for network connections from the machine to itself. @@ -257,6 +260,11 @@ config BLK_DEV_CRYPTOLOOP provided by the CryptoAPI as loop transformation. This might be used as hard disk encryption. + WARNING: This device is not safe for journaled file systems like + ext3 or Reiserfs. Please use the Device Mapper crypto module + instead, which can be configured to be on-disk compatible with the + cryptoloop device. + config BLK_DEV_NBD tristate "Network block device support" depends on NET --- diff/drivers/block/Kconfig.iosched 2003-10-09 09:47:16.000000000 +0100 +++ source/drivers/block/Kconfig.iosched 2004-02-23 13:56:40.000000000 +0000 @@ -27,3 +27,10 @@ config IOSCHED_DEADLINE a disk at any one time, its behaviour is almost identical to the anticipatory I/O scheduler and so is a good choice. +config IOSCHED_CFQ + bool "CFQ I/O scheduler" if EMBEDDED + default y + ---help--- + The CFQ I/O scheduler tries to distribute bandwidth equally + among all processes in the system. It should provide a fair + working environment, suitable for desktop systems. --- diff/drivers/block/Makefile 2003-10-27 09:20:37.000000000 +0000 +++ source/drivers/block/Makefile 2004-02-23 13:56:40.000000000 +0000 @@ -18,6 +18,7 @@ obj-y := elevator.o ll_rw_blk.o ioctl.o obj-$(CONFIG_IOSCHED_NOOP) += noop-iosched.o obj-$(CONFIG_IOSCHED_AS) += as-iosched.o obj-$(CONFIG_IOSCHED_DEADLINE) += deadline-iosched.o +obj-$(CONFIG_IOSCHED_CFQ) += cfq-iosched.o obj-$(CONFIG_MAC_FLOPPY) += swim3.o obj-$(CONFIG_BLK_DEV_FD) += floppy.o obj-$(CONFIG_BLK_DEV_FD98) += floppy98.o --- diff/drivers/block/cryptoloop.c 2003-08-26 10:00:52.000000000 +0100 +++ source/drivers/block/cryptoloop.c 2004-02-23 13:56:40.000000000 +0000 @@ -87,43 +87,49 @@ typedef int (*encdec_ecb_t)(struct crypt static int -cryptoloop_transfer_ecb(struct loop_device *lo, int cmd, char *raw_buf, - char *loop_buf, int size, sector_t IV) +cryptoloop_transfer_ecb(struct loop_device *lo, int cmd, + struct page *raw_page, unsigned raw_off, + struct page *loop_page, unsigned loop_off, + int size, sector_t IV) { struct crypto_tfm *tfm = (struct crypto_tfm *) lo->key_data; struct scatterlist sg_out = { 0, }; struct scatterlist sg_in = { 0, }; encdec_ecb_t encdecfunc; - char const *in; - char *out; + struct page *in_page, *out_page; + unsigned in_offs, out_offs; if (cmd == READ) { - in = raw_buf; - out = loop_buf; + in_page = raw_page; + in_offs = raw_off; + out_page = loop_page; + out_offs = loop_off; encdecfunc = tfm->crt_u.cipher.cit_decrypt; } else { - in = loop_buf; - out = raw_buf; + in_page = loop_page; + in_offs = loop_off; + out_page = raw_page; + out_offs = raw_off; encdecfunc = tfm->crt_u.cipher.cit_encrypt; } while (size > 0) { const int sz = min(size, LOOP_IV_SECTOR_SIZE); - sg_in.page = virt_to_page(in); - sg_in.offset = (unsigned long)in & ~PAGE_MASK; + sg_in.page = in_page; + sg_in.offset = in_offs; sg_in.length = sz; - sg_out.page = virt_to_page(out); - sg_out.offset = (unsigned long)out & ~PAGE_MASK; + sg_out.page = out_page; + sg_out.offset = out_offs; sg_out.length = sz; encdecfunc(tfm, &sg_out, &sg_in, sz); size -= sz; - in += sz; - out += sz; + in_offs += sz; + out_offs += sz; } return 0; @@ -135,24 +141,30 @@ typedef int (*encdec_cbc_t)(struct crypt unsigned int nsg, u8 *iv); static int -cryptoloop_transfer_cbc(struct loop_device *lo, int cmd, char *raw_buf, - char *loop_buf, int size, sector_t IV) +cryptoloop_transfer_cbc(struct loop_device *lo, int cmd, + struct page *raw_page, unsigned raw_off, + struct page *loop_page, unsigned loop_off, + int size, sector_t IV) { struct crypto_tfm *tfm = (struct crypto_tfm *) lo->key_data; struct scatterlist sg_out = { 0, }; struct scatterlist sg_in = { 0, }; encdec_cbc_t encdecfunc; - char const *in; - char *out; + struct page *in_page, *out_page; + unsigned in_offs, out_offs; if (cmd == READ) { - in = raw_buf; - out = loop_buf; + in_page = raw_page; + in_offs = raw_off; + out_page = loop_page; + out_offs = loop_off; encdecfunc = tfm->crt_u.cipher.cit_decrypt_iv; } else { - in = loop_buf; - out = raw_buf; + in_page = loop_page; + in_offs = loop_off; + out_page = raw_page; + out_offs = raw_off; encdecfunc = tfm->crt_u.cipher.cit_encrypt_iv; } @@ -161,39 +173,43 @@ cryptoloop_transfer_cbc(struct loop_devi u32 iv[4] = { 0, }; iv[0] = cpu_to_le32(IV & 0xffffffff); - sg_in.page = virt_to_page(in); - sg_in.offset = offset_in_page(in); + sg_in.page = in_page; + sg_in.offset = in_offs; sg_in.length = sz; - sg_out.page = virt_to_page(out); - sg_out.offset = offset_in_page(out); + sg_out.page = out_page; + sg_out.offset = out_offs; sg_out.length = sz; encdecfunc(tfm, &sg_out, &sg_in, sz, (u8 *)iv); IV++; size -= sz; - in += sz; - out += sz; + in_offs += sz; + out_offs += sz; } return 0; } static int -cryptoloop_transfer(struct loop_device *lo, int cmd, char *raw_buf, - char *loop_buf, int size, sector_t IV) +cryptoloop_transfer(struct loop_device *lo, int cmd, + struct page *raw_page, unsigned raw_off, + struct page *loop_page, unsigned loop_off, + int size, sector_t IV) { struct crypto_tfm *tfm = (struct crypto_tfm *) lo->key_data; if(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB) { lo->transfer = cryptoloop_transfer_ecb; - return cryptoloop_transfer_ecb(lo, cmd, raw_buf, loop_buf, size, IV); + return cryptoloop_transfer_ecb(lo, cmd, raw_page, raw_off, + loop_page, loop_off, size, IV); } if(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_CBC) { lo->transfer = cryptoloop_transfer_cbc; - return cryptoloop_transfer_cbc(lo, cmd, raw_buf, loop_buf, size, IV); + return cryptoloop_transfer_cbc(lo, cmd, raw_page, raw_off, + loop_page, loop_off, size, IV); } /* This is not supposed to happen */ --- diff/drivers/block/floppy.c 2004-02-18 08:54:08.000000000 +0000 +++ source/drivers/block/floppy.c 2004-02-23 13:56:40.000000000 +0000 @@ -4242,6 +4242,15 @@ int __init floppy_init(void) disks[i] = alloc_disk(1); if (!disks[i]) goto Enomem; + + disks[i]->major = FLOPPY_MAJOR; + disks[i]->first_minor = TOMINOR(i); + disks[i]->fops = &floppy_fops; + sprintf(disks[i]->disk_name, "fd%d", i); + + init_timer(&motor_off_timer[i]); + motor_off_timer[i].data = i; + motor_off_timer[i].function = motor_off_callback; } devfs_mk_dir ("floppy"); @@ -4255,13 +4264,6 @@ int __init floppy_init(void) goto fail_queue; } - for (i=0; imajor = FLOPPY_MAJOR; - disks[i]->first_minor = TOMINOR(i); - disks[i]->fops = &floppy_fops; - sprintf(disks[i]->disk_name, "fd%d", i); - } - blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE, floppy_find, NULL, NULL); @@ -4366,9 +4368,6 @@ int __init floppy_init(void) } for (drive = 0; drive < N_DRIVE; drive++) { - init_timer(&motor_off_timer[drive]); - motor_off_timer[drive].data = drive; - motor_off_timer[drive].function = motor_off_callback; if (!(allowed_drive_mask & (1 << drive))) continue; if (fdc_state[FDC(drive)].version == FDC_NONE) --- diff/drivers/block/genhd.c 2004-02-18 08:54:08.000000000 +0000 +++ source/drivers/block/genhd.c 2004-02-23 13:56:40.000000000 +0000 @@ -262,8 +262,9 @@ static int show_partition(struct seq_fil /* Don't show non-partitionable removeable devices or empty devices */ if (!get_capacity(sgp) || - (sgp->minors == 1 && (sgp->flags & GENHD_FL_REMOVABLE)) - ) + (sgp->minors == 1 && (sgp->flags & GENHD_FL_REMOVABLE))) + return 0; + if (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO) return 0; /* show the full disk and all non-0 size partitions of it */ --- diff/drivers/block/ll_rw_blk.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/block/ll_rw_blk.c 2004-02-23 13:56:40.000000000 +0000 @@ -27,6 +27,7 @@ #include #include #include +#include static void blk_unplug_work(void *data); static void blk_unplug_timeout(unsigned long data); @@ -521,10 +522,10 @@ init_tag_map(request_queue_t *q, struct { int bits, i; - if (depth > q->nr_requests * 2) { - depth = q->nr_requests * 2; - printk(KERN_ERR "%s: adjusted depth to %d\n", - __FUNCTION__, depth); + if (depth > q->nr_requests / 2) { + q->nr_requests = depth * 2; + printk(KERN_INFO "%s: large TCQ depth: adjusted nr_requests " + "to %lu\n", __FUNCTION__, q->nr_requests); } tags->tag_index = kmalloc(depth * sizeof(struct request *), GFP_ATOMIC); @@ -1334,6 +1335,8 @@ static elevator_t *chosen_elevator = &iosched_as; #elif defined(CONFIG_IOSCHED_DEADLINE) &iosched_deadline; +#elif defined(CONFIG_IOSCHED_CFQ) + &iosched_cfq; #elif defined(CONFIG_IOSCHED_NOOP) &elevator_noop; #else @@ -1352,6 +1355,10 @@ static int __init elevator_setup(char *s if (!strcmp(str, "as")) chosen_elevator = &iosched_as; #endif +#ifdef CONFIG_IOSCHED_CFQ + if (!strcmp(str, "cfq")) + chosen_elevator = &iosched_cfq; +#endif #ifdef CONFIG_IOSCHED_NOOP if (!strcmp(str, "noop")) chosen_elevator = &elevator_noop; @@ -1884,18 +1891,22 @@ EXPORT_SYMBOL(blk_put_request); * Waits for up to @timeout jiffies for a queue (any queue) to exit congestion. * If no queues are congested then just wait for the next request to be * returned. + * + * Returns the number of jiffies remaining, this is zero, unless we returned + * before @timeout expired. */ -void blk_congestion_wait(int rw, long timeout) +long blk_congestion_wait(int rw, long timeout) { + long ret; DEFINE_WAIT(wait); wait_queue_head_t *wqh = &congestion_wqh[rw]; blk_run_queues(); prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE); - io_schedule_timeout(timeout); + ret = io_schedule_timeout(timeout); finish_wait(wqh, &wait); + return ret; } - EXPORT_SYMBOL(blk_congestion_wait); /* @@ -2305,6 +2316,15 @@ int submit_bio(int rw, struct bio *bio) mod_page_state(pgpgout, count); else mod_page_state(pgpgin, count); + + if (unlikely(block_dump)) { + char b[BDEVNAME_SIZE]; + printk("%s(%d): %s block %Lu on %s\n", + current->comm, current->pid, + (rw & WRITE) ? "WRITE" : "READ", + (unsigned long long)bio->bi_sector, bdevname(bio->bi_bdev,b)); + } + generic_make_request(bio); return 1; } @@ -2592,10 +2612,22 @@ void end_that_request_last(struct reques unsigned long duration = jiffies - req->start_time; switch (rq_data_dir(req)) { case WRITE: + /* + * schedule the writeout of pending dirty data when the disk is idle. + * (Writeback is not postponed by writes, only by reads.) + */ + if (unlikely(laptop_mode)) + disk_is_spun_up(0); disk_stat_inc(disk, writes); disk_stat_add(disk, write_ticks, duration); break; case READ: + /* + * schedule the writeout of pending dirty data when the disk is idle. + * (postpone writeback until system is quiescent again.) + */ + if (unlikely(laptop_mode)) + disk_is_spun_up(1); disk_stat_inc(disk, reads); disk_stat_add(disk, read_ticks, duration); break; --- diff/drivers/block/loop.c 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/block/loop.c 2004-02-23 13:56:40.000000000 +0000 @@ -76,24 +76,34 @@ static struct gendisk **disks; /* * Transfer functions */ -static int transfer_none(struct loop_device *lo, int cmd, char *raw_buf, - char *loop_buf, int size, sector_t real_block) +static int transfer_none(struct loop_device *lo, int cmd, + struct page *raw_page, unsigned raw_off, + struct page *loop_page, unsigned loop_off, + int size, sector_t real_block) { - if (raw_buf != loop_buf) { - if (cmd == READ) - memcpy(loop_buf, raw_buf, size); - else - memcpy(raw_buf, loop_buf, size); - } + char *raw_buf = kmap_atomic(raw_page, KM_USER0) + raw_off; + char *loop_buf = kmap_atomic(loop_page, KM_USER1) + loop_off; + + if (cmd == READ) + memcpy(loop_buf, raw_buf, size); + else + memcpy(raw_buf, loop_buf, size); + kunmap_atomic(raw_buf, KM_USER0); + kunmap_atomic(loop_buf, KM_USER1); + cond_resched(); return 0; } -static int transfer_xor(struct loop_device *lo, int cmd, char *raw_buf, - char *loop_buf, int size, sector_t real_block) +static int transfer_xor(struct loop_device *lo, int cmd, + struct page *raw_page, unsigned raw_off, + struct page *loop_page, unsigned loop_off, + int size, sector_t real_block) { - char *in, *out, *key; - int i, keysize; + char *raw_buf = kmap_atomic(raw_page, KM_USER0) + raw_off; + char *loop_buf = kmap_atomic(loop_page, KM_USER1) + loop_off; + char *in, *out, *key; + int i, keysize; if (cmd == READ) { in = raw_buf; @@ -107,6 +117,10 @@ static int transfer_xor(struct loop_devi keysize = lo->lo_encrypt_key_size; for (i = 0; i < size; i++) *out++ = *in++ ^ key[(i & 511) % keysize]; + + kunmap_atomic(raw_buf, KM_USER0); + kunmap_atomic(loop_buf, KM_USER1); + cond_resched(); return 0; } @@ -162,13 +176,15 @@ figure_loop_size(struct loop_device *lo) } static inline int -lo_do_transfer(struct loop_device *lo, int cmd, char *rbuf, - char *lbuf, int size, sector_t rblock) +lo_do_transfer(struct loop_device *lo, int cmd, + struct page *rpage, unsigned roffs, + struct page *lpage, unsigned loffs, + int size, sector_t rblock) { if (!lo->transfer) return 0; - return lo->transfer(lo, cmd, rbuf, lbuf, size, rblock); + return lo->transfer(lo, cmd, rpage, roffs, lpage, loffs, size, rblock); } static int @@ -178,16 +194,15 @@ do_lo_send(struct loop_device *lo, struc struct address_space *mapping = file->f_mapping; struct address_space_operations *aops = mapping->a_ops; struct page *page; - char *kaddr, *data; pgoff_t index; - unsigned size, offset; + unsigned size, offset, bv_offs; int len; int ret = 0; down(&mapping->host->i_sem); index = pos >> PAGE_CACHE_SHIFT; offset = pos & ((pgoff_t)PAGE_CACHE_SIZE - 1); - data = kmap(bvec->bv_page) + bvec->bv_offset; + bv_offs = bvec->bv_offset; len = bvec->bv_len; while (len > 0) { sector_t IV; @@ -204,25 +219,28 @@ do_lo_send(struct loop_device *lo, struc goto fail; if (aops->prepare_write(file, page, offset, offset+size)) goto unlock; - kaddr = kmap(page); - transfer_result = lo_do_transfer(lo, WRITE, kaddr + offset, - data, size, IV); + transfer_result = lo_do_transfer(lo, WRITE, page, offset, + bvec->bv_page, bv_offs, + size, IV); if (transfer_result) { + char *kaddr; + /* * The transfer failed, but we still write the data to * keep prepare/commit calls balanced. */ printk(KERN_ERR "loop: transfer error block %llu\n", (unsigned long long)index); + kaddr = kmap_atomic(page, KM_USER0); memset(kaddr + offset, 0, size); + kunmap_atomic(kaddr, KM_USER0); } flush_dcache_page(page); - kunmap(page); if (aops->commit_write(file, page, offset, offset+size)) goto unlock; if (transfer_result) goto unlock; - data += size; + bv_offs += size; len -= size; offset = 0; index++; @@ -232,7 +250,6 @@ do_lo_send(struct loop_device *lo, struc } up(&mapping->host->i_sem); out: - kunmap(bvec->bv_page); return ret; unlock: @@ -247,12 +264,10 @@ fail: static int lo_send(struct loop_device *lo, struct bio *bio, int bsize, loff_t pos) { - unsigned vecnr; - int ret = 0; - - for (vecnr = 0; vecnr < bio->bi_vcnt; vecnr++) { - struct bio_vec *bvec = &bio->bi_io_vec[vecnr]; + struct bio_vec *bvec; + int i, ret = 0; + bio_for_each_segment(bvec, bio, i) { ret = do_lo_send(lo, bvec, bsize, pos); if (ret < 0) break; @@ -263,7 +278,8 @@ lo_send(struct loop_device *lo, struct b struct lo_read_data { struct loop_device *lo; - char *data; + struct page *page; + unsigned offset; int bsize; }; @@ -271,7 +287,6 @@ static int lo_read_actor(read_descriptor_t *desc, struct page *page, unsigned long offset, unsigned long size) { - char *kaddr; unsigned long count = desc->count; struct lo_read_data *p = (struct lo_read_data*)desc->buf; struct loop_device *lo = p->lo; @@ -282,18 +297,16 @@ lo_read_actor(read_descriptor_t *desc, s if (size > count) size = count; - kaddr = kmap(page); - if (lo_do_transfer(lo, READ, kaddr + offset, p->data, size, IV)) { + if (lo_do_transfer(lo, READ, page, offset, p->page, p->offset, size, IV)) { size = 0; printk(KERN_ERR "loop: transfer error block %ld\n", page->index); desc->error = -EINVAL; } - kunmap(page); desc->count = count - size; desc->written += size; - p->data += size; + p->offset += size; return size; } @@ -306,24 +319,22 @@ do_lo_receive(struct loop_device *lo, int retval; cookie.lo = lo; - cookie.data = kmap(bvec->bv_page) + bvec->bv_offset; + cookie.page = bvec->bv_page; + cookie.offset = bvec->bv_offset; cookie.bsize = bsize; file = lo->lo_backing_file; retval = file->f_op->sendfile(file, &pos, bvec->bv_len, lo_read_actor, &cookie); - kunmap(bvec->bv_page); return (retval < 0)? retval: 0; } static int lo_receive(struct loop_device *lo, struct bio *bio, int bsize, loff_t pos) { - unsigned vecnr; - int ret = 0; - - for (vecnr = 0; vecnr < bio->bi_vcnt; vecnr++) { - struct bio_vec *bvec = &bio->bi_io_vec[vecnr]; + struct bio_vec *bvec; + int i, ret = 0; + bio_for_each_segment(bvec, bio, i) { ret = do_lo_receive(lo, bvec, bsize, pos); if (ret < 0) break; @@ -345,23 +356,6 @@ static int do_bio_filebacked(struct loop return ret; } -static int loop_end_io_transfer(struct bio *, unsigned int, int); - -static void loop_put_buffer(struct bio *bio) -{ - /* - * check bi_end_io, may just be a remapped bio - */ - if (bio && bio->bi_end_io == loop_end_io_transfer) { - int i; - - for (i = 0; i < bio->bi_vcnt; i++) - __free_page(bio->bi_io_vec[i].bv_page); - - bio_put(bio); - } -} - /* * Add bio to back of pending list */ @@ -399,129 +393,8 @@ static struct bio *loop_get_bio(struct l return bio; } -/* - * if this was a WRITE lo->transfer stuff has already been done. for READs, - * queue it for the loop thread and let it do the transfer out of - * bi_end_io context (we don't want to do decrypt of a page with irqs - * disabled) - */ -static int loop_end_io_transfer(struct bio *bio, unsigned int bytes_done, int err) -{ - struct bio *rbh = bio->bi_private; - struct loop_device *lo = rbh->bi_bdev->bd_disk->private_data; - - if (bio->bi_size) - return 1; - - if (err || bio_rw(bio) == WRITE) { - bio_endio(rbh, rbh->bi_size, err); - if (atomic_dec_and_test(&lo->lo_pending)) - up(&lo->lo_bh_mutex); - loop_put_buffer(bio); - } else - loop_add_bio(lo, bio); - - return 0; -} - -static struct bio *loop_copy_bio(struct bio *rbh) -{ - struct bio *bio; - struct bio_vec *bv; - int i; - - bio = bio_alloc(__GFP_NOWARN, rbh->bi_vcnt); - if (!bio) - return NULL; - - /* - * iterate iovec list and alloc pages - */ - __bio_for_each_segment(bv, rbh, i, 0) { - struct bio_vec *bbv = &bio->bi_io_vec[i]; - - bbv->bv_page = alloc_page(__GFP_NOWARN|__GFP_HIGHMEM); - if (bbv->bv_page == NULL) - goto oom; - - bbv->bv_len = bv->bv_len; - bbv->bv_offset = bv->bv_offset; - } - - bio->bi_vcnt = rbh->bi_vcnt; - bio->bi_size = rbh->bi_size; - - return bio; - -oom: - while (--i >= 0) - __free_page(bio->bi_io_vec[i].bv_page); - - bio_put(bio); - return NULL; -} - -static struct bio *loop_get_buffer(struct loop_device *lo, struct bio *rbh) -{ - struct bio *bio; - - /* - * When called on the page reclaim -> writepage path, this code can - * trivially consume all memory. So we drop PF_MEMALLOC to avoid - * stealing all the page reserves and throttle to the writeout rate. - * pdflush will have been woken by page reclaim. Let it do its work. - */ - do { - int flags = current->flags; - - current->flags &= ~PF_MEMALLOC; - bio = loop_copy_bio(rbh); - if (flags & PF_MEMALLOC) - current->flags |= PF_MEMALLOC; - - if (bio == NULL) - blk_congestion_wait(WRITE, HZ/10); - } while (bio == NULL); - - bio->bi_end_io = loop_end_io_transfer; - bio->bi_private = rbh; - bio->bi_sector = rbh->bi_sector + (lo->lo_offset >> 9); - bio->bi_rw = rbh->bi_rw; - bio->bi_bdev = lo->lo_device; - - return bio; -} - -static int loop_transfer_bio(struct loop_device *lo, - struct bio *to_bio, struct bio *from_bio) -{ - sector_t IV; - struct bio_vec *from_bvec, *to_bvec; - char *vto, *vfrom; - int ret = 0, i; - - IV = from_bio->bi_sector + (lo->lo_offset >> 9); - - __bio_for_each_segment(from_bvec, from_bio, i, 0) { - to_bvec = &to_bio->bi_io_vec[i]; - - kmap(from_bvec->bv_page); - kmap(to_bvec->bv_page); - vfrom = page_address(from_bvec->bv_page) + from_bvec->bv_offset; - vto = page_address(to_bvec->bv_page) + to_bvec->bv_offset; - ret |= lo_do_transfer(lo, bio_data_dir(to_bio), vto, vfrom, - from_bvec->bv_len, IV); - kunmap(from_bvec->bv_page); - kunmap(to_bvec->bv_page); - IV += from_bvec->bv_len >> 9; - } - - return ret; -} - static int loop_make_request(request_queue_t *q, struct bio *old_bio) { - struct bio *new_bio = NULL; struct loop_device *lo = q->queuedata; int rw = bio_rw(old_bio); @@ -543,31 +416,11 @@ static int loop_make_request(request_que printk(KERN_ERR "loop: unknown command (%x)\n", rw); goto err; } - - /* - * file backed, queue for loop_thread to handle - */ - if (lo->lo_flags & LO_FLAGS_DO_BMAP) { - loop_add_bio(lo, old_bio); - return 0; - } - - /* - * piggy old buffer on original, and submit for I/O - */ - new_bio = loop_get_buffer(lo, old_bio); - if (rw == WRITE) { - if (loop_transfer_bio(lo, new_bio, old_bio)) - goto err; - } - - generic_make_request(new_bio); + loop_add_bio(lo, old_bio); return 0; - err: if (atomic_dec_and_test(&lo->lo_pending)) up(&lo->lo_bh_mutex); - loop_put_buffer(new_bio); out: bio_io_error(old_bio, old_bio->bi_size); return 0; @@ -580,20 +433,8 @@ static inline void loop_handle_bio(struc { int ret; - /* - * For block backed loop, we know this is a READ - */ - if (lo->lo_flags & LO_FLAGS_DO_BMAP) { - ret = do_bio_filebacked(lo, bio); - bio_endio(bio, bio->bi_size, ret); - } else { - struct bio *rbh = bio->bi_private; - - ret = loop_transfer_bio(lo, bio, rbh); - - bio_endio(rbh, rbh->bi_size, ret); - loop_put_buffer(bio); - } + ret = do_bio_filebacked(lo, bio); + bio_endio(bio, bio->bi_size, ret); } /* @@ -684,31 +525,23 @@ static int loop_set_fd(struct loop_devic lo_flags |= LO_FLAGS_READ_ONLY; error = -EINVAL; - if (S_ISBLK(inode->i_mode)) { - lo_device = I_BDEV(inode); - if (lo_device == bdev) { - error = -EBUSY; - goto out_putf; - } - lo_blocksize = block_size(lo_device); - if (bdev_read_only(lo_device)) - lo_flags |= LO_FLAGS_READ_ONLY; - } else if (S_ISREG(inode->i_mode)) { + if (S_ISREG(inode->i_mode) || S_ISBLK(inode->i_mode)) { struct address_space_operations *aops = mapping->a_ops; /* * If we can't read - sorry. If we only can't write - well, * it's going to be read-only. */ - if (!inode->i_fop->sendfile) + if (!lo_file->f_op->sendfile) goto out_putf; if (!aops->prepare_write || !aops->commit_write) lo_flags |= LO_FLAGS_READ_ONLY; lo_blocksize = inode->i_blksize; - lo_flags |= LO_FLAGS_DO_BMAP; - } else + error = 0; + } else { goto out_putf; + } if (!(lo_file->f_mode & FMODE_WRITE)) lo_flags |= LO_FLAGS_READ_ONLY; @@ -738,21 +571,6 @@ static int loop_set_fd(struct loop_devic blk_queue_make_request(lo->lo_queue, loop_make_request); lo->lo_queue->queuedata = lo; - /* - * we remap to a block device, make sure we correctly stack limits - */ - if (S_ISBLK(inode->i_mode)) { - request_queue_t *q = bdev_get_queue(lo_device); - - blk_queue_max_sectors(lo->lo_queue, q->max_sectors); - blk_queue_max_phys_segments(lo->lo_queue,q->max_phys_segments); - blk_queue_max_hw_segments(lo->lo_queue, q->max_hw_segments); - blk_queue_hardsect_size(lo->lo_queue, queue_hardsect_size(q)); - blk_queue_max_segment_size(lo->lo_queue, q->max_segment_size); - blk_queue_segment_boundary(lo->lo_queue, q->seg_boundary_mask); - blk_queue_merge_bvec(lo->lo_queue, q->merge_bvec_fn); - } - set_blocksize(bdev, lo_blocksize); kernel_thread(loop_thread, lo, CLONE_KERNEL); @@ -1196,7 +1014,6 @@ int __init loop_init(void) lo->lo_queue = blk_alloc_queue(GFP_KERNEL); if (!lo->lo_queue) goto out_mem4; - disks[i]->queue = lo->lo_queue; init_MUTEX(&lo->lo_ctl_mutex); init_MUTEX_LOCKED(&lo->lo_sem); init_MUTEX_LOCKED(&lo->lo_bh_mutex); @@ -1209,14 +1026,18 @@ int __init loop_init(void) sprintf(disk->devfs_name, "loop/%d", i); disk->private_data = lo; disk->queue = lo->lo_queue; - add_disk(disk); } + + /* We cannot fail after we call this, so another loop!*/ + for (i = 0; i < max_loop; i++) + add_disk(disks[i]); printk(KERN_INFO "loop: loaded (max %d devices)\n", max_loop); return 0; out_mem4: while (i--) blk_put_queue(loop_dev[i].lo_queue); + devfs_remove("loop"); i = max_loop; out_mem3: while (i--) --- diff/drivers/block/nbd.c 2003-08-26 10:00:52.000000000 +0100 +++ source/drivers/block/nbd.c 2004-02-23 13:56:40.000000000 +0000 @@ -36,7 +36,7 @@ * 03-06-24 Remove unneeded blksize_bits field from nbd_device struct. * * 03-06-24 Cleanup PARANOIA usage & code. - * + * 04-02-19 Remove PARANOIA, plus various cleanups (Paul Clements) * possible FIXME: make set_sock / set_blksize / set_size / do_it one syscall * why not: would need verify_area and friends, would share yet another * structure with userland @@ -61,12 +61,9 @@ #include #include -/* Define PARANOIA in linux/nbd.h to turn on extra sanity checking */ #include -#ifdef PARANOIA #define LO_MAGIC 0x68797548 -#endif #ifdef NDEBUG #define dprintk(flags, fmt...) @@ -97,11 +94,6 @@ static struct nbd_device nbd_dev[MAX_NBD */ static spinlock_t nbd_lock = SPIN_LOCK_UNLOCKED; -#ifdef PARANOIA -static int requests_in; -static int requests_out; -#endif - #ifndef NDEBUG static const char *ioctl_cmd_to_ascii(int cmd) { @@ -153,9 +145,6 @@ static void nbd_end_request(struct reque } spin_unlock(&lo->queue_lock); -#ifdef PARANOIA - requests_out++; -#endif spin_lock_irqsave(q->queue_lock, flags); if (!end_that_request_first(req, uptodate, req->nr_sectors)) { end_that_request_last(req); @@ -217,10 +206,8 @@ static int sock_xmit(struct socket *sock } if (result <= 0) { -#ifdef PARANOIA - printk(KERN_ERR "nbd: %s - sock=%p at buf=%p, size=%d returned %d.\n", - send? "send": "receive", sock, buf, size, result); -#endif + if (result == 0) + result = -EPIPE; /* short read */ break; } size -= result; @@ -309,7 +296,7 @@ void nbd_send_req(struct nbd_device *lo, up(&lo->tx_lock); return; - error_out: +error_out: up(&lo->tx_lock); req->errors++; } @@ -358,23 +345,22 @@ struct request *nbd_read_stat(struct nbd if (result <= 0) { printk(KERN_ERR "%s: Receive control failed (result %d)\n", lo->disk->disk_name, result); - lo->harderror = result; - return NULL; + goto harderror; } req = nbd_find_request(lo, reply.handle); if (req == NULL) { printk(KERN_ERR "%s: Unexpected reply (%p)\n", lo->disk->disk_name, reply.handle); - lo->harderror = result; - return NULL; + result = -EBADR; + goto harderror; } if (ntohl(reply.magic) != NBD_REPLY_MAGIC) { printk(KERN_ERR "%s: Wrong magic (0x%lx)\n", lo->disk->disk_name, (unsigned long)ntohl(reply.magic)); - lo->harderror = result; - return NULL; + result = -EPROTO; + goto harderror; } if (ntohl(reply.error)) { printk(KERN_ERR "%s: Other side returned error (%d)\n", @@ -396,8 +382,7 @@ struct request *nbd_read_stat(struct nbd printk(KERN_ERR "%s: Receive data failed (result %d)\n", lo->disk->disk_name, result); - lo->harderror = result; - return NULL; + goto harderror; } dprintk(DBG_RX, "%s: request %p: got %d bytes data\n", lo->disk->disk_name, req, bvec->bv_len); @@ -405,19 +390,19 @@ struct request *nbd_read_stat(struct nbd } } return req; +harderror: + lo->harderror = result; + return NULL; } void nbd_do_it(struct nbd_device *lo) { struct request *req; -#ifdef PARANOIA BUG_ON(lo->magic != LO_MAGIC); -#endif + while ((req = nbd_read_stat(lo)) != NULL) nbd_end_request(req); - printk(KERN_NOTICE "%s: req should never be null\n", - lo->disk->disk_name); return; } @@ -425,9 +410,7 @@ void nbd_clear_que(struct nbd_device *lo { struct request *req; -#ifdef PARANOIA BUG_ON(lo->magic != LO_MAGIC); -#endif do { req = NULL; @@ -466,9 +449,9 @@ static void do_nbd_request(request_queue goto error_out; lo = req->rq_disk->private_data; -#ifdef PARANOIA + BUG_ON(lo->magic != LO_MAGIC); -#endif + if (!lo->file) { printk(KERN_ERR "%s: Request when not-ready\n", lo->disk->disk_name); @@ -483,9 +466,6 @@ static void do_nbd_request(request_queue goto error_out; } } -#ifdef PARANOIA - requests_in++; -#endif req->errors = 0; spin_unlock_irq(q->queue_lock); @@ -526,7 +506,7 @@ static void do_nbd_request(request_queue spin_lock_irq(q->queue_lock); continue; - error_out: +error_out: req->errors++; spin_unlock(q->queue_lock); nbd_end_request(req); @@ -544,9 +524,9 @@ static int nbd_ioctl(struct inode *inode if (!capable(CAP_SYS_ADMIN)) return -EPERM; -#ifdef PARANOIA + BUG_ON(lo->magic != LO_MAGIC); -#endif + /* Anyone capable of this syscall can do *real bad* things */ dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n", lo->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg); @@ -662,15 +642,10 @@ static int nbd_ioctl(struct inode *inode nbd_clear_que(lo); return 0; case NBD_PRINT_DEBUG: -#ifdef PARANOIA - printk(KERN_INFO "%s: next = %p, prev = %p. Global: in %d, out %d\n", - inode->i_bdev->bd_disk->disk_name, lo->queue_head.next, - lo->queue_head.prev, requests_in, requests_out); -#else - printk(KERN_INFO "%s: next = %p, prev = %p\n", + printk(KERN_INFO "%s: next = %p, prev = %p, head = %p\n", inode->i_bdev->bd_disk->disk_name, - lo->queue_head.next, lo->queue_head.prev); -#endif + lo->queue_head.next, lo->queue_head.prev, + &lo->queue_head); return 0; } return -EINVAL; @@ -692,12 +667,10 @@ static int __init nbd_init(void) int err = -ENOMEM; int i; -#ifdef PARANOIA if (sizeof(struct nbd_request) != 28) { - printk(KERN_CRIT "nbd: Sizeof nbd_request needs to be 28 in order to work!\n" ); + printk(KERN_CRIT "nbd: sizeof nbd_request needs to be 28 in order to work!\n" ); return -EIO; } -#endif for (i = 0; i < MAX_NBD; i++) { struct gendisk *disk = alloc_disk(1); @@ -728,30 +701,28 @@ static int __init nbd_init(void) for (i = 0; i < MAX_NBD; i++) { struct gendisk *disk = nbd_dev[i].disk; nbd_dev[i].file = NULL; -#ifdef PARANOIA nbd_dev[i].magic = LO_MAGIC; -#endif nbd_dev[i].flags = 0; spin_lock_init(&nbd_dev[i].queue_lock); INIT_LIST_HEAD(&nbd_dev[i].queue_head); init_MUTEX(&nbd_dev[i].tx_lock); nbd_dev[i].blksize = 1024; - nbd_dev[i].bytesize = ((u64)0x7ffffc00) << 10; /* 2TB */ + nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */ disk->major = NBD_MAJOR; disk->first_minor = i; disk->fops = &nbd_fops; disk->private_data = &nbd_dev[i]; + disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; sprintf(disk->disk_name, "nbd%d", i); sprintf(disk->devfs_name, "nbd/%d", i); - set_capacity(disk, 0x3ffffe); + set_capacity(disk, 0x7ffffc00ULL << 1); /* 2 TB */ add_disk(disk); } return 0; out: while (i--) { - if (nbd_dev[i].disk->queue) - blk_cleanup_queue(nbd_dev[i].disk->queue); + blk_cleanup_queue(nbd_dev[i].disk->queue); put_disk(nbd_dev[i].disk); } return err; @@ -763,9 +734,8 @@ static void __exit nbd_cleanup(void) for (i = 0; i < MAX_NBD; i++) { struct gendisk *disk = nbd_dev[i].disk; if (disk) { - if (disk->queue) - blk_cleanup_queue(disk->queue); del_gendisk(disk); + blk_cleanup_queue(disk->queue); put_disk(disk); } } --- diff/drivers/block/rd.c 2003-10-09 09:47:16.000000000 +0100 +++ source/drivers/block/rd.c 2004-02-23 13:56:40.000000000 +0000 @@ -1,15 +1,15 @@ /* * ramdisk.c - Multiple RAM disk driver - gzip-loading version - v. 0.8 beta. - * - * (C) Chad Page, Theodore Ts'o, et. al, 1995. + * + * (C) Chad Page, Theodore Ts'o, et. al, 1995. * * This RAM disk is designed to have filesystems created on it and mounted - * just like a regular floppy disk. - * + * just like a regular floppy disk. + * * It also does something suggested by Linus: use the buffer cache as the * RAM disk data. This makes it possible to dynamically allocate the RAM disk - * buffer - with some consequences I have to deal with as I write this. - * + * buffer - with some consequences I have to deal with as I write this. + * * This code is based on the original ramdisk.c, written mostly by * Theodore Ts'o (TYT) in 1991. The code was largely rewritten by * Chad Page to use the buffer cache to store the RAM disk data in @@ -33,7 +33,7 @@ * * Added initrd: Werner Almesberger & Hans Lermen, Feb '96 * - * 4/25/96 : Made RAM disk size a parameter (default is now 4 MB) + * 4/25/96 : Made RAM disk size a parameter (default is now 4 MB) * - Chad Page * * Add support for fs images split across >1 disk, Paul Gortmaker, Mar '98 @@ -60,7 +60,7 @@ #include /* The RAM disk size is now a parameter */ -#define NUM_RAMDISKS 16 /* This cannot be overridden (yet) */ +#define NUM_RAMDISKS 16 /* This cannot be overridden (yet) */ /* Various static variables go here. Most are used only in the RAM disk code. */ @@ -73,7 +73,7 @@ static struct request_queue *rd_queue[NU * Parameters for the boot-loading of the RAM disk. These are set by * init/main.c (from arguments to the kernel command line) or from the * architecture-specific setup routine (from the stored boot sector - * information). + * information). */ int rd_size = CONFIG_BLK_DEV_RAM_SIZE; /* Size of the RAM disks */ /* @@ -94,7 +94,7 @@ int rd_blocksize = BLOCK_SIZE; /* bloc * 2000 Transmeta Corp. * aops copied from ramfs. */ -static int ramdisk_readpage(struct file *file, struct page * page) +static int ramdisk_readpage(struct file *file, struct page *page) { if (!PageUptodate(page)) { void *kaddr = kmap_atomic(page, KM_USER0); @@ -108,7 +108,8 @@ static int ramdisk_readpage(struct file return 0; } -static int ramdisk_prepare_write(struct file *file, struct page *page, unsigned offset, unsigned to) +static int ramdisk_prepare_write(struct file *file, struct page *page, + unsigned offset, unsigned to) { if (!PageUptodate(page)) { void *kaddr = kmap_atomic(page, KM_USER0); @@ -122,7 +123,8 @@ static int ramdisk_prepare_write(struct return 0; } -static int ramdisk_commit_write(struct file *file, struct page *page, unsigned offset, unsigned to) +static int ramdisk_commit_write(struct file *file, struct page *page, + unsigned offset, unsigned to) { return 0; } @@ -212,7 +214,7 @@ static int rd_blkdev_pagecache_IO(int rw * 19-JAN-1998 Richard Gooch Added devfs support * */ -static int rd_make_request(request_queue_t * q, struct bio *bio) +static int rd_make_request(request_queue_t *q, struct bio *bio) { struct block_device *bdev = bio->bi_bdev; struct address_space * mapping = bdev->bd_inode->i_mapping; @@ -242,7 +244,8 @@ fail: return 0; } -static int rd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +static int rd_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) { int error; struct block_device *bdev = inode->i_bdev; @@ -250,9 +253,11 @@ static int rd_ioctl(struct inode *inode, if (cmd != BLKFLSBUF) return -EINVAL; - /* special: we want to release the ramdisk memory, - it's not like with the other blockdevices where - this ioctl only flushes away the buffer cache. */ + /* + * special: we want to release the ramdisk memory, it's not like with + * the other blockdevices where this ioctl only flushes away the buffer + * cache + */ error = -EBUSY; down(&bdev->bd_sem); if (bdev->bd_openers <= 2) { @@ -268,7 +273,7 @@ static struct backing_dev_info rd_backin .memory_backed = 1, /* Does not contribute to dirty memory */ }; -static int rd_open(struct inode * inode, struct file * filp) +static int rd_open(struct inode *inode, struct file *filp) { unsigned unit = iminor(inode); @@ -295,33 +300,37 @@ static struct block_device_operations rd .ioctl = rd_ioctl, }; -/* Before freeing the module, invalidate all of the protected buffers! */ -static void __exit rd_cleanup (void) +/* + * Before freeing the module, invalidate all of the protected buffers! + */ +static void __exit rd_cleanup(void) { int i; - for (i = 0 ; i < NUM_RAMDISKS; i++) { + for (i = 0; i < NUM_RAMDISKS; i++) { struct block_device *bdev = rd_bdev[i]; rd_bdev[i] = NULL; if (bdev) { invalidate_bdev(bdev, 1); - blkdev_put(bdev, BDEV_FILE); + blkdev_put(bdev); } del_gendisk(rd_disks[i]); put_disk(rd_disks[i]); } devfs_remove("rd"); - unregister_blkdev(RAMDISK_MAJOR, "ramdisk" ); + unregister_blkdev(RAMDISK_MAJOR, "ramdisk"); } -/* This is the registration and initialization section of the RAM disk driver */ -static int __init rd_init (void) +/* + * This is the registration and initialization section of the RAM disk driver + */ +static int __init rd_init(void) { int i; int err = -ENOMEM; if (rd_blocksize > PAGE_SIZE || rd_blocksize < 512 || - (rd_blocksize & (rd_blocksize-1))) { + (rd_blocksize & (rd_blocksize-1))) { printk("RAMDISK: wrong blocksize %d, reverting to defaults\n", rd_blocksize); rd_blocksize = BLOCK_SIZE; @@ -354,6 +363,7 @@ static int __init rd_init (void) disk->first_minor = i; disk->fops = &rd_bd_op; disk->queue = rd_queue[i]; + disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; sprintf(disk->disk_name, "ram%d", i); sprintf(disk->devfs_name, "rd/%d", i); set_capacity(disk, rd_size * 2); @@ -362,8 +372,8 @@ static int __init rd_init (void) /* rd_size is given in kB */ printk("RAMDISK driver initialized: " - "%d RAM disks of %dK size %d blocksize\n", - NUM_RAMDISKS, rd_size, rd_blocksize); + "%d RAM disks of %dK size %d blocksize\n", + NUM_RAMDISKS, rd_size, rd_blocksize); return 0; out_queue: --- diff/drivers/block/scsi_ioctl.c 2004-02-18 08:54:08.000000000 +0000 +++ source/drivers/block/scsi_ioctl.c 2004-02-23 13:56:40.000000000 +0000 @@ -312,7 +312,7 @@ static int sg_scsi_ioctl(request_queue_t return -EFAULT; if (in_len > PAGE_SIZE || out_len > PAGE_SIZE) return -EINVAL; - if (get_user(opcode, sic->data)) + if (get_user(opcode, (int *)sic->data)) return -EFAULT; bytes = max(in_len, out_len); --- diff/drivers/block/swim3.c 2004-02-18 08:54:08.000000000 +0000 +++ source/drivers/block/swim3.c 2004-02-23 13:56:40.000000000 +0000 @@ -319,7 +319,7 @@ static void start_request(struct floppy_ #if 0 printk("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%ld buf=%p\n", req->rq_disk->disk_name, req->cmd, - req->sector, req->nr_sectors, req->buffer); + (long)req->sector, req->nr_sectors, req->buffer); printk(" rq_status=%d errors=%d current_nr_sectors=%ld\n", req->rq_status, req->errors, req->current_nr_sectors); #endif @@ -346,8 +346,13 @@ static void start_request(struct floppy_ } } - fs->req_cyl = req->sector / fs->secpercyl; - x = req->sector % fs->secpercyl; + /* Do not remove the cast. req->sector is now a sector_t and + * can be 64 bits, but it will never go past 32 bits for this + * driver anyway, so we can safely cast it down and not have + * to do a 64/32 division + */ + fs->req_cyl = ((long)req->sector) / fs->secpercyl; + x = ((long)req->sector) % fs->secpercyl; fs->head = x / fs->secpertrack; fs->req_sector = x % fs->secpertrack + 1; fd_req = req; @@ -614,7 +619,7 @@ static void xfer_timeout(unsigned long d fd_req->sector += s; fd_req->current_nr_sectors -= s; printk(KERN_ERR "swim3: timeout %sing sector %ld\n", - (rq_data_dir(fd_req)==WRITE? "writ": "read"), fd_req->sector); + (rq_data_dir(fd_req)==WRITE? "writ": "read"), (long)fd_req->sector); end_request(fd_req, 0); fs->state = idle; start_request(fs); @@ -730,7 +735,7 @@ static irqreturn_t swim3_interrupt(int i } else { printk("swim3: error %sing block %ld (err=%x)\n", rq_data_dir(fd_req) == WRITE? "writ": "read", - fd_req->sector, err); + (long)fd_req->sector, err); end_request(fd_req, 0); fs->state = idle; } --- diff/drivers/char/Kconfig 2004-02-18 08:54:09.000000000 +0000 +++ source/drivers/char/Kconfig 2004-02-23 13:56:41.000000000 +0000 @@ -445,7 +445,8 @@ config A2232 source "drivers/serial/Kconfig" config UNIX98_PTYS - bool "Unix98 PTY support" + bool "Unix98 PTY support" if EMBEDDED + default y ---help--- A pseudo terminal (PTY) is a software device consisting of two halves: a master and a slave. The slave device behaves identical to @@ -463,28 +464,38 @@ config UNIX98_PTYS terminal slave can be accessed as /dev/pts/. What was traditionally /dev/ttyp2 will then be /dev/pts/2, for example. - The entries in /dev/pts/ are created on the fly by a virtual - file system; therefore, if you say Y here you should say Y to - "/dev/pts file system for Unix98 PTYs" as well. - - If you want to say Y here, you need to have the C library glibc 2.1 - or later (equal to libc-6.1, check with "ls -l /lib/libc.so.*"). - Read the instructions in pertaining to - pseudo terminals. It's safe to say N. - -config UNIX98_PTY_COUNT - int "Maximum number of Unix98 PTYs in use (0-2048)" - depends on UNIX98_PTYS + All modern Linux systems use the Unix98 ptys. Say Y unless + you're on an embedded system and want to conserve memory. + +config LEGACY_PTYS + bool "Legacy (BSD) PTY support" + default y + ---help--- + A pseudo terminal (PTY) is a software device consisting of two + halves: a master and a slave. The slave device behaves identical to + a physical terminal; the master device is used by a process to + read data from and write data to the slave, thereby emulating a + terminal. Typical programs for the master side are telnet servers + and xterms. + + Linux has traditionally used the BSD-like names /dev/ptyxx + for masters and /dev/ttyxx for slaves of pseudo + terminals. This scheme has a number of problems, including + security. This option enables these legacy devices; on most + systems, it is safe to say N. + + +config LEGACY_PTY_COUNT + int "Maximum number of legacy PTY in use" + depends on LEGACY_PTYS default "256" - help - The maximum number of Unix98 PTYs that can be used at any one time. - The default is 256, and should be enough for desktop systems. Server - machines which support incoming telnet/rlogin/ssh connections and/or - serve several X terminals may want to increase this: every incoming - connection and every xterm uses up one PTY. + ---help--- + The maximum number of legacy PTYs that can be used at any one time. + The default is 256, and should be more than enough. Embedded + systems may want to reduce this to save memory. - When not in use, each additional set of 256 PTYs occupy - approximately 8 KB of kernel memory on 32-bit architectures. + When not in use, each legacy PTY occupies 12 bytes on 32-bit + architectures and 24 bytes on 64-bit architectures. config PRINTER tristate "Parallel printer support" @@ -588,30 +599,6 @@ config PC9800_OLDLP_CONSOLE bool "Support for console on line printer" depends on PC9800_OLDLP - -menu "Mice" - -config BUSMOUSE - tristate "Bus Mouse Support" - ---help--- - Say Y here if your machine has a bus mouse as opposed to a serial - mouse. Most people have a regular serial MouseSystem or - Microsoft mouse (made by Logitech) that plugs into a COM port - (rectangular with 9 or 25 pins). These people say N here. - - If you have a laptop, you either have to check the documentation or - experiment a bit to find out whether the trackball is a serial mouse - or not; it's best to say Y here for you. - - This is the generic bus mouse driver code. If you have a bus mouse, - you will have to say Y here and also to the specific driver for your - mouse below. - - To compile this driver as a module, choose M here: the - module will be called busmouse. - -endmenu - config QIC02_TAPE tristate "QIC-02 tape support" help @@ -754,7 +741,7 @@ config NVRAM config RTC tristate "Enhanced Real Time Clock Support" - depends on !PPC32 && !PARISC && !IA64 && !X86_PC9800 + depends on !PPC32 && !PARISC && !IA64 && !X86_PC9800 && !M68K ---help--- 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 @@ -794,8 +781,7 @@ config GEN_RTC precision in some cases. To compile this driver as a module, choose M here: the - module will be called genrtc. To load the module automatically - add 'alias char-major-10-135 genrtc' to your /etc/modules.conf + module will be called genrtc. config GEN_RTC_X bool "Extended RTC operation" --- diff/drivers/char/Makefile 2004-02-18 08:54:09.000000000 +0000 +++ source/drivers/char/Makefile 2004-02-23 13:56:41.000000000 +0000 @@ -49,7 +49,6 @@ obj-$(CONFIG_PRINTER) += lp.o obj-$(CONFIG_TIPAR) += tipar.o obj-$(CONFIG_PC9800_OLDLP) += lp_old98.o -obj-$(CONFIG_BUSMOUSE) += busmouse.o obj-$(CONFIG_DTLK) += dtlk.o obj-$(CONFIG_R3964) += n_r3964.o obj-$(CONFIG_APPLICOM) += applicom.o --- diff/drivers/char/agp/Kconfig 2004-02-18 08:54:09.000000000 +0000 +++ source/drivers/char/agp/Kconfig 2004-02-23 13:56:40.000000000 +0000 @@ -1,5 +1,5 @@ config AGP - tristate "/dev/agpgart (AGP Support)" if !GART_IOMMU + tristate "/dev/agpgart (AGP Support)" if !GART_IOMMU && !M68K default y if GART_IOMMU ---help--- AGP (Accelerated Graphics Port) is a bus system mainly used to @@ -77,7 +77,7 @@ config AGP_AMD64 config AGP_INTEL tristate "Intel 440LX/BX/GX, I8xx and E7x05 chipset support" - depends on AGP && X86 && !X86_64 + depends on AGP && X86 help This option gives you AGP support for the GLX component of XFree86 4.x on Intel 440LX/BX/GX, 815, 820, 830, 840, 845, 850, 860, 875, @@ -151,3 +151,13 @@ config AGP_UNINORTH This option gives you AGP support for Apple machines with a UniNorth bridge. +config AGP_EFFICEON + tristate "Transmeta Efficeon support" + depends on AGP && X86 && !X86_64 + help + This option fives you AGP support for the Transmeta Efficeon + series processors with integrated northbridges. + + You should say Y here if you use XFree86 3.3.6 or 4.x and want to + use GLX or DRI. If unsure, say Y. + --- diff/drivers/char/agp/Makefile 2003-09-17 12:28:04.000000000 +0100 +++ source/drivers/char/agp/Makefile 2004-02-23 13:56:40.000000000 +0000 @@ -6,6 +6,7 @@ obj-$(CONFIG_AGP_ATI) += ati-agp.o obj-$(CONFIG_AGP_AMD) += amd-k7-agp.o obj-$(CONFIG_AGP_AMD64) += amd64-agp.o obj-$(CONFIG_AGP_ALPHA_CORE) += alpha-agp.o +obj-$(CONFIG_AGP_EFFICEON) += efficeon-agp.o obj-$(CONFIG_AGP_HP_ZX1) += hp-agp.o obj-$(CONFIG_AGP_I460) += i460-agp.o obj-$(CONFIG_AGP_INTEL) += intel-agp.o --- diff/drivers/char/agp/intel-agp.c 2004-01-19 10:22:56.000000000 +0000 +++ source/drivers/char/agp/intel-agp.c 2004-02-23 13:56:40.000000000 +0000 @@ -1432,6 +1432,8 @@ static int agp_intel_resume(struct pci_d intel_configure(); else if (bridge->driver == &intel_845_driver) intel_845_configure(); + else if (bridge->driver == &intel_830mp_driver) + intel_830mp_configure(); return 0; } --- diff/drivers/char/amiserial.c 2003-10-09 09:47:33.000000000 +0100 +++ source/drivers/char/amiserial.c 2004-02-23 13:56:40.000000000 +0000 @@ -1248,57 +1248,48 @@ static int get_lsr_info(struct async_str } -static int get_modem_info(struct async_struct * info, unsigned int *value) +static int rs_tiocmget(struct tty_struct *tty, struct file *file) { + struct async_struct * info = (struct async_struct *)tty->driver_data; unsigned char control, status; - unsigned int result; unsigned long flags; + if (serial_paranoia_check(info, tty->name, "rs_ioctl")) + return -ENODEV; + if (tty->flags & (1 << TTY_IO_ERROR)) + return -EIO; + control = info->MCR; local_irq_save(flags); status = ciab.pra; local_irq_restore(flags); - result = ((control & SER_RTS) ? TIOCM_RTS : 0) + return ((control & SER_RTS) ? TIOCM_RTS : 0) | ((control & SER_DTR) ? TIOCM_DTR : 0) | (!(status & SER_DCD) ? TIOCM_CAR : 0) | (!(status & SER_DSR) ? TIOCM_DSR : 0) | (!(status & SER_CTS) ? TIOCM_CTS : 0); - if (copy_to_user(value, &result, sizeof(int))) - return -EFAULT; - return 0; } -static int set_modem_info(struct async_struct * info, unsigned int cmd, - unsigned int *value) +static int rs_tiocmset(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear) { - unsigned int arg; + struct async_struct * info = (struct async_struct *)tty->driver_data; unsigned long flags; - if (copy_from_user(&arg, value, sizeof(int))) - return -EFAULT; + if (serial_paranoia_check(info, tty->name, "rs_ioctl")) + return -ENODEV; + if (tty->flags & (1 << TTY_IO_ERROR)) + return -EIO; - switch (cmd) { - case TIOCMBIS: - if (arg & TIOCM_RTS) - info->MCR |= SER_RTS; - if (arg & TIOCM_DTR) - info->MCR |= SER_DTR; - break; - case TIOCMBIC: - if (arg & TIOCM_RTS) - info->MCR &= ~SER_RTS; - if (arg & TIOCM_DTR) - info->MCR &= ~SER_DTR; - break; - case TIOCMSET: - info->MCR = ((info->MCR & ~(SER_RTS | SER_DTR)) - | ((arg & TIOCM_RTS) ? SER_RTS : 0) - | ((arg & TIOCM_DTR) ? SER_DTR : 0)); - break; - default: - return -EINVAL; - } local_irq_save(flags); + if (set & TIOCM_RTS) + info->MCR |= SER_RTS; + if (set & TIOCM_DTR) + info->MCR |= SER_DTR; + if (clear & TIOCM_RTS) + info->MCR &= ~SER_RTS; + if (clear & TIOCM_DTR) + info->MCR &= ~SER_DTR; rtsdtr_ctrl(info->MCR); local_irq_restore(flags); return 0; @@ -1344,12 +1335,6 @@ static int rs_ioctl(struct tty_struct *t } switch (cmd) { - case TIOCMGET: - return get_modem_info(info, (unsigned int *) arg); - case TIOCMBIS: - case TIOCMBIC: - case TIOCMSET: - return set_modem_info(info, cmd, (unsigned int *) arg); case TIOCGSERIAL: return get_serial_info(info, (struct serial_struct *) arg); @@ -2045,6 +2030,8 @@ static struct tty_operations serial_ops .send_xchar = rs_send_xchar, .wait_until_sent = rs_wait_until_sent, .read_proc = rs_read_proc, + .tiocmget = rs_tiocmget, + .tiocmset = rs_tiocmset, }; /* --- diff/drivers/char/cyclades.c 2003-10-09 09:47:33.000000000 +0100 +++ source/drivers/char/cyclades.c 2004-02-23 13:56:40.000000000 +0000 @@ -3632,8 +3632,9 @@ static int get_lsr_info(struct cyclades_ } static int -get_modem_info(struct cyclades_port * info, unsigned int *value) +cy_tiocmget(struct tty_struct *tty, struct file *file) { + struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; int card,chip,channel,index; unsigned char *base_addr; unsigned long flags; @@ -3645,6 +3646,9 @@ get_modem_info(struct cyclades_port * in struct BOARD_CTRL *board_ctrl; struct CH_CTRL *ch_ctrl; + if (serial_paranoia_check(info, tty->name, __FUNCTION__)) + return -ENODEV; + card = info->card; channel = (info->line) - (cy_card[card].first_line); if (!IS_CYC_Z(cy_card[card])) { @@ -3700,24 +3704,27 @@ get_modem_info(struct cyclades_port * in } } - return cy_put_user(result, value); -} /* get_modem_info */ + return result; +} /* cy_tiomget */ static int -set_modem_info(struct cyclades_port * info, unsigned int cmd, - unsigned int *value) +cy_tiocmset(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear) { + struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; int card,chip,channel,index; unsigned char *base_addr; unsigned long flags; - unsigned int arg = cy_get_user((unsigned long *) value); struct FIRM_ID *firm_id; struct ZFW_CTRL *zfw_ctrl; struct BOARD_CTRL *board_ctrl; struct CH_CTRL *ch_ctrl; int retval; + if (serial_paranoia_check(info, tty->name, __FUNCTION__)) + return -ENODEV; + card = info->card; channel = (info->line) - (cy_card[card].first_line); if (!IS_CYC_Z(cy_card[card])) { @@ -3728,66 +3735,7 @@ set_modem_info(struct cyclades_port * in (cy_card[card].base_addr + (cy_chip_offset[chip]<rtsdtr_inv) { - cy_writeb((u_long)base_addr+(CyMSVR2<rtsdtr_inv) { - cy_writeb((u_long)base_addr+(CyMSVR1<rtsdtr_inv) { - cy_writeb((u_long)base_addr+(CyMSVR2<rtsdtr_inv) { - cy_writeb((u_long)base_addr+(CyMSVR1<rtsdtr_inv) { @@ -3796,7 +3744,8 @@ set_modem_info(struct cyclades_port * in cy_writeb((u_long)base_addr+(CyMSVR1<rtsdtr_inv) { @@ -3805,8 +3754,8 @@ set_modem_info(struct cyclades_port * in cy_writeb((u_long)base_addr+(CyMSVR1<rtsdtr_inv) { @@ -3821,7 +3770,8 @@ set_modem_info(struct cyclades_port * in cy_readb(base_addr+(CyMSVR2<rtsdtr_inv) { @@ -3837,10 +3787,6 @@ set_modem_info(struct cyclades_port * in cy_readb(base_addr+(CyMSVR2<board_ctrl; ch_ctrl = zfw_ctrl->ch_ctrl; - switch (cmd) { - case TIOCMBIS: - if (arg & TIOCM_RTS){ - CY_LOCK(info, flags); - cy_writel(&ch_ctrl[channel].rs_control, - cy_readl(&ch_ctrl[channel].rs_control) | C_RS_RTS); - CY_UNLOCK(info, flags); - } - if (arg & TIOCM_DTR){ - CY_LOCK(info, flags); - cy_writel(&ch_ctrl[channel].rs_control, - cy_readl(&ch_ctrl[channel].rs_control) | C_RS_DTR); -#ifdef CY_DEBUG_DTR - printk("cyc:set_modem_info raising Z DTR\n"); -#endif - CY_UNLOCK(info, flags); - } - break; - case TIOCMBIC: - if (arg & TIOCM_RTS){ - CY_LOCK(info, flags); - cy_writel(&ch_ctrl[channel].rs_control, - cy_readl(&ch_ctrl[channel].rs_control) & ~C_RS_RTS); - CY_UNLOCK(info, flags); - } - if (arg & TIOCM_DTR){ - CY_LOCK(info, flags); - cy_writel(&ch_ctrl[channel].rs_control, - cy_readl(&ch_ctrl[channel].rs_control) & ~C_RS_DTR); -#ifdef CY_DEBUG_DTR - printk("cyc:set_modem_info clearing Z DTR\n"); -#endif - CY_UNLOCK(info, flags); - } - break; - case TIOCMSET: - if (arg & TIOCM_RTS){ + if (set & TIOCM_RTS){ CY_LOCK(info, flags); cy_writel(&ch_ctrl[channel].rs_control, cy_readl(&ch_ctrl[channel].rs_control) | C_RS_RTS); CY_UNLOCK(info, flags); - }else{ + } + if (clear & TIOCM_RTS) { CY_LOCK(info, flags); cy_writel(&ch_ctrl[channel].rs_control, cy_readl(&ch_ctrl[channel].rs_control) & ~C_RS_RTS); CY_UNLOCK(info, flags); - } - if (arg & TIOCM_DTR){ + } + if (set & TIOCM_DTR){ CY_LOCK(info, flags); cy_writel(&ch_ctrl[channel].rs_control, cy_readl(&ch_ctrl[channel].rs_control) | C_RS_DTR); @@ -3909,7 +3820,8 @@ set_modem_info(struct cyclades_port * in printk("cyc:set_modem_info raising Z DTR\n"); #endif CY_UNLOCK(info, flags); - }else{ + } + if (clear & TIOCM_DTR) { CY_LOCK(info, flags); cy_writel(&ch_ctrl[channel].rs_control, cy_readl(&ch_ctrl[channel].rs_control) & ~C_RS_DTR); @@ -3917,10 +3829,6 @@ set_modem_info(struct cyclades_port * in printk("cyc:set_modem_info clearing Z DTR\n"); #endif CY_UNLOCK(info, flags); - } - break; - default: - return -EINVAL; } }else{ return -ENODEV; @@ -3935,7 +3843,7 @@ set_modem_info(struct cyclades_port * in CY_UNLOCK(info, flags); } return 0; -} /* set_modem_info */ +} /* cy_tiocmset */ /* * cy_break() --- routine which turns the break handling on or off @@ -4242,14 +4150,6 @@ cy_ioctl(struct tty_struct *tty, struct case CYGETWAIT: ret_val = info->closing_wait / (HZ/100); break; - case TIOCMGET: - ret_val = get_modem_info(info, (unsigned int *) arg); - break; - case TIOCMBIS: - case TIOCMBIC: - case TIOCMSET: - ret_val = set_modem_info(info, cmd, (unsigned int *) arg); - break; case TIOCGSERIAL: ret_val = get_serial_info(info, (struct serial_struct *) arg); break; @@ -5429,6 +5329,8 @@ static struct tty_operations cy_ops = { .break_ctl = cy_break, .wait_until_sent = cy_wait_until_sent, .read_proc = cyclades_get_proc_info, + .tiocmget = cy_tiocmget, + .tiocmset = cy_tiocmset, }; static int __init --- diff/drivers/char/drm/Kconfig 2004-02-09 10:36:10.000000000 +0000 +++ source/drivers/char/drm/Kconfig 2004-02-23 13:56:41.000000000 +0000 @@ -76,7 +76,7 @@ config DRM_SIS tristate "SiS video cards" depends on DRM && AGP help - Choose this option if you have a SiS 630 or compatibel video + Choose this option if you have a SiS 630 or compatible video chipset. If M is selected the module will be called sis. AGP support is required for this driver to work. --- diff/drivers/char/drm/drm.h 2003-07-22 18:54:27.000000000 +0100 +++ source/drivers/char/drm/drm.h 2004-02-23 13:56:40.000000000 +0000 @@ -580,6 +580,16 @@ typedef struct drm_scatter_gather { unsigned long handle; /**< Used for mapping / unmapping */ } drm_scatter_gather_t; +/** + * DRM_IOCTL_SET_VERSION ioctl argument type. + */ +typedef struct drm_set_version { + int drm_di_major; + int drm_di_minor; + int drm_dd_major; + int drm_dd_minor; +} drm_set_version_t; + #define DRM_IOCTL_BASE 'd' #define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr) @@ -594,6 +604,7 @@ typedef struct drm_scatter_gather { #define DRM_IOCTL_GET_MAP DRM_IOWR(0x04, drm_map_t) #define DRM_IOCTL_GET_CLIENT DRM_IOWR(0x05, drm_client_t) #define DRM_IOCTL_GET_STATS DRM_IOR( 0x06, drm_stats_t) +#define DRM_IOCTL_SET_VERSION DRM_IOWR(0x07, drm_set_version_t) #define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm_unique_t) #define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, drm_auth_t) --- diff/drivers/char/drm/drmP.h 2004-01-19 10:22:56.000000000 +0000 +++ source/drivers/char/drm/drmP.h 2004-02-23 13:56:40.000000000 +0000 @@ -92,8 +92,8 @@ #ifndef __HAVE_DMA #define __HAVE_DMA 0 #endif -#ifndef __HAVE_DMA_IRQ -#define __HAVE_DMA_IRQ 0 +#ifndef __HAVE_IRQ +#define __HAVE_IRQ 0 #endif #ifndef __HAVE_DMA_WAITLIST #define __HAVE_DMA_WAITLIST 0 @@ -324,6 +324,7 @@ do { \ #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x)) #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist) +#define DRM_IF_VERSION(maj, min) ((maj) << 16 | (min)) /** * Get the private SAREA mapping. * @@ -362,10 +363,13 @@ do { \ typedef int drm_ioctl_t( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -typedef struct drm_pci_list { - u16 vendor; - u16 device; -} drm_pci_list_t; +typedef struct drm_pci_id_list +{ + int vendor; + int device; + long driver_private; + char *name; +} drm_pci_id_list_t; typedef struct drm_ioctl_desc { drm_ioctl_t *func; @@ -488,6 +492,9 @@ typedef struct drm_file { struct drm_device *dev; int remove_auth_on_close; unsigned long lock_count; +#ifdef DRIVER_FILE_FIELDS + DRIVER_FILE_FIELDS; +#endif } drm_file_t; /** Wait queue */ @@ -622,6 +629,8 @@ typedef struct drm_device { int unique_len; /**< Length of unique field */ dev_t device; /**< Device number for mknod */ char *devname; /**< For /proc/interrupts */ + int minor; /**< Minor device number */ + int if_version; /**< Highest interface version set */ int blocked; /**< Blocked due to VC switch? */ struct proc_dir_entry *root; /**< Root for this device's entries */ @@ -679,6 +688,7 @@ typedef struct drm_device { /** \name Context support */ /*@{*/ int irq; /**< Interrupt used by board */ + int irq_enabled; /**< True if irq handler is enabled */ __volatile__ long context_flag; /**< Context swapping flag */ __volatile__ long interrupt_flag; /**< Interruption handler flag */ __volatile__ long dma_flag; /**< DMA dispatch flag */ @@ -714,7 +724,12 @@ typedef struct drm_device { #if __REALLY_HAVE_AGP drm_agp_head_t *agp; /**< AGP data */ #endif - struct pci_dev *pdev; /**< PCI device structure */ + + struct pci_dev *pdev; /**< PCI device structure */ + int pci_domain; /**< PCI bus domain number */ + int pci_bus; /**< PCI bus number */ + int pci_slot; /**< PCI slot number */ + int pci_func; /**< PCI function number */ #ifdef __alpha__ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3) struct pci_controler *hose; @@ -804,8 +819,8 @@ extern int DRM(unbind_agp)(DRM #endif /* Misc. IOCTL support (drm_ioctl.h) */ -extern int DRM(irq_busid)(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); +extern int DRM(irq_by_busid)(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); extern int DRM(getunique)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(setunique)(struct inode *inode, struct file *filp, @@ -816,6 +831,8 @@ extern int DRM(getclient)(struct in unsigned int cmd, unsigned long arg); extern int DRM(getstats)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); +extern int DRM(setversion)(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); /* Context IOCTL support (drm_context.h) */ extern int DRM(resctx)( struct inode *inode, struct file *filp, @@ -900,12 +917,17 @@ extern int DRM(dma_setup)(drm_devic extern void DRM(dma_takedown)(drm_device_t *dev); extern void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf); extern void DRM(reclaim_buffers)( struct file *filp ); -#if __HAVE_DMA_IRQ +#endif /* __HAVE_DMA */ + + /* IRQ support (drm_irq.h) */ +#if __HAVE_IRQ || __HAVE_DMA extern int DRM(control)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(irq_install)( drm_device_t *dev, int irq ); +#endif +#if __HAVE_IRQ +extern int DRM(irq_install)( drm_device_t *dev ); extern int DRM(irq_uninstall)( drm_device_t *dev ); -extern irqreturn_t DRM(dma_service)( DRM_IRQ_ARGS ); +extern irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS ); extern void DRM(driver_irq_preinstall)( drm_device_t *dev ); extern void DRM(driver_irq_postinstall)( drm_device_t *dev ); extern void DRM(driver_irq_uninstall)( drm_device_t *dev ); @@ -915,12 +937,11 @@ extern int DRM(wait_vblank)(st extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq); extern void DRM(vbl_send_signals)( drm_device_t *dev ); #endif -#if __HAVE_DMA_IRQ_BH -extern void DRM(dma_immediate_bh)( void *dev ); +#if __HAVE_IRQ_BH +extern void DRM(irq_immediate_bh)( void *dev ); #endif #endif -#endif /* __HAVE_DMA */ #if __REALLY_HAVE_AGP /* AGP/GART support (drm_agpsupport.h) */ --- diff/drivers/char/drm/drm_bufs.h 2003-07-22 18:54:27.000000000 +0100 +++ source/drivers/char/drm/drm_bufs.h 2004-02-23 13:56:40.000000000 +0000 @@ -147,7 +147,9 @@ int DRM(addmap)( struct inode *inode, st MTRR_TYPE_WRCOMB, 1 ); } #endif - map->handle = DRM(ioremap)( map->offset, map->size, dev ); + if (map->type == _DRM_REGISTERS) + map->handle = DRM(ioremap)( map->offset, map->size, + dev ); break; case _DRM_SHM: @@ -160,6 +162,12 @@ int DRM(addmap)( struct inode *inode, st } map->offset = (unsigned long)map->handle; if ( map->flags & _DRM_CONTAINS_LOCK ) { + /* Prevent a 2nd X Server from creating a 2nd lock */ + if (dev->lock.hw_lock != NULL) { + vfree( map->handle ); + DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + return -EBUSY; + } dev->sigdata.lock = dev->lock.hw_lock = map->handle; /* Pointer to lock */ } --- diff/drivers/char/drm/drm_dma.h 2003-07-22 18:54:27.000000000 +0100 +++ source/drivers/char/drm/drm_dma.h 2004-02-23 13:56:40.000000000 +0000 @@ -43,15 +43,6 @@ #ifndef __HAVE_DMA_RECLAIM #define __HAVE_DMA_RECLAIM 0 #endif -#ifndef __HAVE_SHARED_IRQ -#define __HAVE_SHARED_IRQ 0 -#endif - -#if __HAVE_SHARED_IRQ -#define DRM_IRQ_TYPE SA_SHIRQ -#else -#define DRM_IRQ_TYPE 0 -#endif #if __HAVE_DMA @@ -214,293 +205,11 @@ void DRM(reclaim_buffers)( struct file * } #endif - - - -#if __HAVE_DMA_IRQ - -/** - * Install IRQ handler. - * - * \param dev DRM device. - * \param irq IRQ number. - * - * Initializes the IRQ related data, and setups drm_device::vbl_queue. Installs the handler, calling the driver - * \c DRM(driver_irq_preinstall)() and \c DRM(driver_irq_postinstall)() functions - * before and after the installation. - */ -int DRM(irq_install)( drm_device_t *dev, int irq ) -{ - int ret; - - if ( !irq ) - return -EINVAL; - - down( &dev->struct_sem ); - - /* Driver must have been initialized */ - if ( !dev->dev_private ) { - up( &dev->struct_sem ); - return -EINVAL; - } - - if ( dev->irq ) { - up( &dev->struct_sem ); - return -EBUSY; - } - dev->irq = irq; - up( &dev->struct_sem ); - - DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, irq ); - - dev->context_flag = 0; - dev->interrupt_flag = 0; - dev->dma_flag = 0; - - dev->dma->next_buffer = NULL; - dev->dma->next_queue = NULL; - dev->dma->this_buffer = NULL; - -#if __HAVE_DMA_IRQ_BH - INIT_WORK(&dev->work, DRM(dma_immediate_bh), dev); -#endif - -#if __HAVE_VBL_IRQ - init_waitqueue_head(&dev->vbl_queue); - - spin_lock_init( &dev->vbl_lock ); - - INIT_LIST_HEAD( &dev->vbl_sigs.head ); - - dev->vbl_pending = 0; -#endif - - /* Before installing handler */ - DRM(driver_irq_preinstall)(dev); - - /* Install handler */ - ret = request_irq( dev->irq, DRM(dma_service), - DRM_IRQ_TYPE, dev->devname, dev ); - if ( ret < 0 ) { - down( &dev->struct_sem ); - dev->irq = 0; - up( &dev->struct_sem ); - return ret; - } - - /* After installing handler */ - DRM(driver_irq_postinstall)(dev); - - return 0; -} - -/** - * Uninstall the IRQ handler. - * - * \param dev DRM device. - * - * Calls the driver's \c DRM(driver_irq_uninstall)() function, and stops the irq. - */ -int DRM(irq_uninstall)( drm_device_t *dev ) -{ - int irq; - - down( &dev->struct_sem ); - irq = dev->irq; - dev->irq = 0; - up( &dev->struct_sem ); - - if ( !irq ) - return -EINVAL; - - DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, irq ); - - DRM(driver_irq_uninstall)( dev ); - - free_irq( irq, dev ); - - return 0; -} - -/** - * IRQ control ioctl. - * - * \param inode device inode. - * \param filp file pointer. - * \param cmd command. - * \param arg user argument, pointing to a drm_control structure. - * \return zero on success or a negative number on failure. - * - * Calls irq_install() or irq_uninstall() according to \p arg. - */ -int DRM(control)( struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg ) -{ - 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; - - switch ( ctl.func ) { - case DRM_INST_HANDLER: - return DRM(irq_install)( dev, ctl.irq ); - case DRM_UNINST_HANDLER: - return DRM(irq_uninstall)( dev ); - default: - return -EINVAL; - } -} - -#if __HAVE_VBL_IRQ - -/** - * Wait for VBLANK. - * - * \param inode device inode. - * \param filp file pointer. - * \param cmd command. - * \param data user argument, pointing to a drm_wait_vblank structure. - * \return zero on success or a negative number on failure. - * - * Verifies the IRQ is installed. - * - * If a signal is requested checks if this task has already scheduled the same signal - * for the same vblank sequence number - nothing to be done in - * that case. If the number of tasks waiting for the interrupt exceeds 100 the - * function fails. Otherwise adds a new entry to drm_device::vbl_sigs for this - * task. - * - * If a signal is not requested, then calls vblank_wait(). - */ -int DRM(wait_vblank)( DRM_IOCTL_ARGS ) -{ - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_wait_vblank_t vblwait; - struct timeval now; - int ret = 0; - unsigned int flags; - - if (!dev->irq) - return -EINVAL; - - DRM_COPY_FROM_USER_IOCTL( vblwait, (drm_wait_vblank_t *)data, - sizeof(vblwait) ); - - switch ( vblwait.request.type & ~_DRM_VBLANK_FLAGS_MASK ) { - case _DRM_VBLANK_RELATIVE: - vblwait.request.sequence += atomic_read( &dev->vbl_received ); - vblwait.request.type &= ~_DRM_VBLANK_RELATIVE; - case _DRM_VBLANK_ABSOLUTE: - break; - default: - return -EINVAL; - } - - flags = vblwait.request.type & _DRM_VBLANK_FLAGS_MASK; - - if ( flags & _DRM_VBLANK_SIGNAL ) { - unsigned long irqflags; - drm_vbl_sig_t *vbl_sig; - - vblwait.reply.sequence = atomic_read( &dev->vbl_received ); - - spin_lock_irqsave( &dev->vbl_lock, irqflags ); - - /* Check if this task has already scheduled the same signal - * for the same vblank sequence number; nothing to be done in - * that case - */ - list_for_each_entry( vbl_sig, &dev->vbl_sigs.head, head ) { - if (vbl_sig->sequence == vblwait.request.sequence - && vbl_sig->info.si_signo == vblwait.request.signal - && vbl_sig->task == current) - { - spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); - goto done; - } - } - - if ( dev->vbl_pending >= 100 ) { - spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); - return -EBUSY; - } - - dev->vbl_pending++; - - spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); - - if ( !( vbl_sig = DRM_MALLOC( sizeof( drm_vbl_sig_t ) ) ) ) { - return -ENOMEM; - } - - memset( (void *)vbl_sig, 0, sizeof(*vbl_sig) ); - - vbl_sig->sequence = vblwait.request.sequence; - vbl_sig->info.si_signo = vblwait.request.signal; - vbl_sig->task = current; - - spin_lock_irqsave( &dev->vbl_lock, irqflags ); - - list_add_tail( (struct list_head *) vbl_sig, &dev->vbl_sigs.head ); - - spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); - } else { - ret = DRM(vblank_wait)( dev, &vblwait.request.sequence ); - - do_gettimeofday( &now ); - vblwait.reply.tval_sec = now.tv_sec; - vblwait.reply.tval_usec = now.tv_usec; - } - -done: - DRM_COPY_TO_USER_IOCTL( (drm_wait_vblank_t *)data, vblwait, - sizeof(vblwait) ); - - return ret; -} - -/** - * Send the VBLANK signals. - * - * \param dev DRM device. - * - * Sends a signal for each task in drm_device::vbl_sigs and empties the list. - * - * If a signal is not requested, then calls vblank_wait(). +#if !__HAVE_IRQ +/* This stub DRM_IOCTL_CONTROL handler is for the drivers that used to require + * IRQs for DMA but no longer do. It maintains compatibility with the X Servers + * that try to use the control ioctl by simply returning success. */ -void DRM(vbl_send_signals)( drm_device_t *dev ) -{ - struct list_head *list, *tmp; - drm_vbl_sig_t *vbl_sig; - unsigned int vbl_seq = atomic_read( &dev->vbl_received ); - unsigned long flags; - - spin_lock_irqsave( &dev->vbl_lock, flags ); - - list_for_each_safe( list, tmp, &dev->vbl_sigs.head ) { - vbl_sig = list_entry( list, drm_vbl_sig_t, head ); - if ( ( vbl_seq - vbl_sig->sequence ) <= (1<<23) ) { - vbl_sig->info.si_code = vbl_seq; - send_sig_info( vbl_sig->info.si_signo, &vbl_sig->info, vbl_sig->task ); - - list_del( list ); - - DRM_FREE( vbl_sig, sizeof(*vbl_sig) ); - - dev->vbl_pending--; - } - } - - spin_unlock_irqrestore( &dev->vbl_lock, flags ); -} - -#endif /* __HAVE_VBL_IRQ */ - -#else - int DRM(control)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { @@ -517,7 +226,6 @@ int DRM(control)( struct inode *inode, s return -EINVAL; } } - -#endif /* __HAVE_DMA_IRQ */ +#endif #endif /* __HAVE_DMA */ --- diff/drivers/char/drm/drm_drv.h 2003-10-27 09:20:43.000000000 +0000 +++ source/drivers/char/drm/drm_drv.h 2004-02-23 13:56:40.000000000 +0000 @@ -58,8 +58,8 @@ #ifndef __HAVE_CTX_BITMAP #define __HAVE_CTX_BITMAP 0 #endif -#ifndef __HAVE_DMA_IRQ -#define __HAVE_DMA_IRQ 0 +#ifndef __HAVE_IRQ +#define __HAVE_IRQ 0 #endif #ifndef __HAVE_DMA_QUEUE #define __HAVE_DMA_QUEUE 0 @@ -126,6 +126,9 @@ #ifndef DRIVER_IOCTLS #define DRIVER_IOCTLS #endif +#ifndef DRIVER_OPEN_HELPER +#define DRIVER_OPEN_HELPER( priv, dev ) +#endif #ifndef DRIVER_FOPS #define DRIVER_FOPS \ static struct file_operations DRM(fops) = { \ @@ -159,15 +162,8 @@ __setup( DRIVER_NAME "=", DRM_OPTIONS_FU #undef DRM_OPTIONS_FUNC #endif -/** - * The default number of instances (minor numbers) to initialize. - */ -#ifndef DRIVER_NUM_CARDS -#define DRIVER_NUM_CARDS 1 -#endif - -static drm_device_t *DRM(device); -static int *DRM(minor); +#define MAX_DEVICES 4 +static drm_device_t DRM(device)[MAX_DEVICES]; static int DRM(numdevs) = 0; DRIVER_FOPS; @@ -177,10 +173,13 @@ static drm_ioctl_desc_t DRM(ioctls)[] [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { DRM(version), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { DRM(getunique), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { DRM(getmagic), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_busid), 0, 1 }, +#if __HAVE_IRQ + [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_by_busid), 0, 1 }, +#endif [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { DRM(getmap), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = { DRM(setversion), 0, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { DRM(setunique), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(noop), 1, 1 }, @@ -222,9 +221,9 @@ static drm_ioctl_desc_t DRM(ioctls)[] [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 }, - - /* The DRM_IOCTL_DMA ioctl should be defined by the driver. - */ + /* The DRM_IOCTL_DMA ioctl should be defined by the driver. */ +#endif +#if __HAVE_IRQ || __HAVE_DMA [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 }, #endif @@ -337,7 +336,7 @@ static int DRM(setup)( drm_device_t *dev dev->queue_reserved = 0; dev->queue_slots = 0; dev->queuelist = NULL; - dev->irq = 0; + dev->irq_enabled = 0; dev->context_flag = 0; dev->interrupt_flag = 0; dev->dma_flag = 0; @@ -345,6 +344,7 @@ static int DRM(setup)( drm_device_t *dev dev->last_switch = 0; dev->last_checked = 0; init_waitqueue_head( &dev->context_wait ); + dev->if_version = 0; dev->ctx_start = 0; dev->lck_start = 0; @@ -391,8 +391,8 @@ static int DRM(takedown)( drm_device_t * DRM_DEBUG( "\n" ); DRIVER_PRETAKEDOWN(); -#if __HAVE_DMA_IRQ - if ( dev->irq ) DRM(irq_uninstall)( dev ); +#if __HAVE_IRQ + if ( dev->irq_enabled ) DRM(irq_uninstall)( dev ); #endif down( &dev->struct_sem ); @@ -534,52 +534,111 @@ static int DRM(takedown)( drm_device_t * return 0; } -/** - * Figure out how many instances to initialize. - * - * \return number of cards found. - * - * Searches for every PCI card in \c DRIVER_CARD_LIST with matching vendor and device ids. - */ -static int drm_count_cards(void) +static drm_pci_id_list_t DRM(pciidlist)[] = { + DRIVER_PCI_IDS +}; + +static int DRM(probe)(struct pci_dev *pdev) { - int num = 0; -#if defined(DRIVER_CARD_LIST) - int i; - drm_pci_list_t *l; - u16 device, vendor; - struct pci_dev *pdev = NULL; + drm_device_t *dev; +#if __HAVE_CTX_BITMAP + int retcode; #endif + int i; + char *desc = NULL; DRM_DEBUG( "\n" ); -#if defined(DRIVER_COUNT_CARDS) - num = DRIVER_COUNT_CARDS(); -#elif defined(DRIVER_CARD_LIST) - for (i = 0, l = DRIVER_CARD_LIST; l[i].vendor != 0; i++) { - pdev = NULL; - vendor = l[i].vendor; - device = l[i].device; - if(device == 0xffff) device = PCI_ANY_ID; - if(vendor == 0xffff) vendor = PCI_ANY_ID; - while ((pdev = pci_find_device(vendor, device, pdev))) { - num++; + for (i = 0; DRM(pciidlist)[i].vendor != 0; i++) { + if ((DRM(pciidlist)[i].vendor == pdev->vendor) && + (DRM(pciidlist)[i].device == pdev->device)) { + desc = DRM(pciidlist)[i].name; } } + if (desc == NULL) + return -ENODEV; + + if (DRM(numdevs) >= MAX_DEVICES) + return -ENODEV; + + dev = &(DRM(device)[DRM(numdevs)]); + + memset( (void *)dev, 0, sizeof(*dev) ); + dev->count_lock = SPIN_LOCK_UNLOCKED; + init_timer( &dev->timer ); + sema_init( &dev->struct_sem, 1 ); + + if ((dev->minor = DRM(stub_register)(DRIVER_NAME, &DRM(fops),dev)) < 0) + return -EPERM; + dev->device = MKDEV(DRM_MAJOR, dev->minor ); + dev->name = DRIVER_NAME; + + dev->pdev = pdev; +#ifdef __alpha__ + dev->hose = pdev->sysdata; + dev->pci_domain = dev->hose->bus->number; #else - num = DRIVER_NUM_CARDS; + dev->pci_domain = 0; +#endif + dev->pci_bus = pdev->bus->number; + dev->pci_slot = PCI_SLOT(pdev->devfn); + dev->pci_func = PCI_FUNC(pdev->devfn); + dev->irq = pdev->irq; + + DRIVER_PREINIT(); + +#if __REALLY_HAVE_AGP + dev->agp = DRM(agp_init)(); +#if __MUST_HAVE_AGP + if ( dev->agp == NULL ) { + DRM_ERROR( "Cannot initialize the agpgart module.\n" ); + DRM(stub_unregister)(dev->minor); + DRM(takedown)( dev ); + return -ENOMEM; + } +#endif +#if __REALLY_HAVE_MTRR + if (dev->agp) + dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base, + dev->agp->agp_info.aper_size*1024*1024, + MTRR_TYPE_WRCOMB, + 1 ); +#endif +#endif + +#if __HAVE_CTX_BITMAP + retcode = DRM(ctxbitmap_init)( dev ); + if( retcode ) { + DRM_ERROR( "Cannot allocate memory for context bitmap.\n" ); + DRM(stub_unregister)(dev->minor); + DRM(takedown)( dev ); + return retcode; + } #endif - DRM_DEBUG("numdevs = %d\n", num); - return num; + DRM(numdevs)++; /* no errors, mark it reserved */ + + DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", + DRIVER_NAME, + DRIVER_MAJOR, + DRIVER_MINOR, + DRIVER_PATCHLEVEL, + DRIVER_DATE, + dev->minor, + desc ); + + DRIVER_POSTINIT(); + + return 0; } + /** * Module initialization. Called via init_module at module load time, or via * linux/init/main.c (this is not currently supported). * * \return zero on success or a negative number on failure. * - * Allocates and initialize an array of drm_device structures, and attempts to + * Initializes an array of drm_device structures, and attempts to * initialize all available devices, using consecutive minors, registering the * stubs and initializing the AGP device. * @@ -588,88 +647,19 @@ static int drm_count_cards(void) */ static int __init drm_init( void ) { + struct pci_dev *pdev = NULL; - drm_device_t *dev; - int i; -#if __HAVE_CTX_BITMAP - int retcode; -#endif DRM_DEBUG( "\n" ); #ifdef MODULE DRM(parse_options)( drm_opts ); #endif - DRM(numdevs) = drm_count_cards(); - /* Force at least one instance. */ - if (DRM(numdevs) <= 0) - DRM(numdevs) = 1; - - DRM(device) = kmalloc(sizeof(*DRM(device)) * DRM(numdevs), GFP_KERNEL); - if (!DRM(device)) { - return -ENOMEM; - } - DRM(minor) = kmalloc(sizeof(*DRM(minor)) * DRM(numdevs), GFP_KERNEL); - if (!DRM(minor)) { - kfree(DRM(device)); - return -ENOMEM; - } - - DRIVER_PREINIT(); - DRM(mem_init)(); - for (i = 0; i < DRM(numdevs); i++) { - dev = &(DRM(device)[i]); - memset( (void *)dev, 0, sizeof(*dev) ); - dev->count_lock = SPIN_LOCK_UNLOCKED; - init_timer( &dev->timer ); - sema_init( &dev->struct_sem, 1 ); - - if ((DRM(minor)[i] = DRM(stub_register)(DRIVER_NAME, &DRM(fops),dev)) < 0) - return -EPERM; - dev->device = MKDEV(DRM_MAJOR, DRM(minor)[i] ); - dev->name = DRIVER_NAME; - -#if __REALLY_HAVE_AGP - dev->agp = DRM(agp_init)(); -#if __MUST_HAVE_AGP - if ( dev->agp == NULL ) { - DRM_ERROR( "Cannot initialize the agpgart module.\n" ); - DRM(stub_unregister)(DRM(minor)[i]); - DRM(takedown)( dev ); - return -EINVAL; - } -#endif -#if __REALLY_HAVE_MTRR - if (dev->agp) - dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base, - dev->agp->agp_info.aper_size*1024*1024, - MTRR_TYPE_WRCOMB, - 1 ); -#endif -#endif - -#if __HAVE_CTX_BITMAP - retcode = DRM(ctxbitmap_init)( dev ); - if( retcode ) { - DRM_ERROR( "Cannot allocate memory for context bitmap.\n" ); - DRM(stub_unregister)(DRM(minor)[i]); - DRM(takedown)( dev ); - return retcode; - } -#endif - DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n", - DRIVER_NAME, - DRIVER_MAJOR, - DRIVER_MINOR, - DRIVER_PATCHLEVEL, - DRIVER_DATE, - DRM(minor)[i] ); + while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) { + DRM(probe)(pdev); } - - DRIVER_POSTINIT(); - return 0; } @@ -689,10 +679,10 @@ static void __exit drm_cleanup( void ) for (i = DRM(numdevs) - 1; i >= 0; i--) { dev = &(DRM(device)[i]); - if ( DRM(stub_unregister)(DRM(minor)[i]) ) { + if ( DRM(stub_unregister)(dev->minor) ) { DRM_ERROR( "Cannot unload module\n" ); } else { - DRM_DEBUG("minor %d unregistered\n", DRM(minor)[i]); + DRM_DEBUG("minor %d unregistered\n", dev->minor); if (i == 0) { DRM_INFO( "Module unloaded\n" ); } @@ -722,8 +712,6 @@ static void __exit drm_cleanup( void ) #endif } DRIVER_POSTCLEANUP(); - kfree(DRM(minor)); - kfree(DRM(device)); DRM(numdevs) = 0; } @@ -795,7 +783,7 @@ int DRM(open)( struct inode *inode, stru int i; for (i = 0; i < DRM(numdevs); i++) { - if (iminor(inode) == DRM(minor)[i]) { + if (iminor(inode) == DRM(device)[i].minor) { dev = &(DRM(device)[i]); break; } --- diff/drivers/char/drm/drm_fops.h 2003-10-09 09:47:16.000000000 +0100 +++ source/drivers/char/drm/drm_fops.h 2004-02-23 13:56:40.000000000 +0000 @@ -72,6 +72,8 @@ int DRM(open_helper)(struct inode *inode priv->authenticated = capable(CAP_SYS_ADMIN); priv->lock_count = 0; + DRIVER_OPEN_HELPER( priv, dev ); + down(&dev->struct_sem); if (!dev->file_last) { priv->next = NULL; --- diff/drivers/char/drm/drm_ioctl.h 2003-07-22 18:54:27.000000000 +0100 +++ source/drivers/char/drm/drm_ioctl.h 2004-02-23 13:56:40.000000000 +0000 @@ -35,69 +35,7 @@ #include "drmP.h" - -/** - * Get interrupt from bus id. - * - * \param inode device inode. - * \param filp file pointer. - * \param cmd command. - * \param arg user argument, pointing to a drm_irq_busid structure. - * \return zero on success or a negative number on failure. - * - * Finds the PCI device with the specified bus id and gets its IRQ number. - */ -int DRM(irq_busid)(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) -{ - drm_irq_busid_t p; - struct pci_dev *dev; - - if (copy_from_user(&p, (drm_irq_busid_t *)arg, sizeof(p))) - return -EFAULT; -#ifdef __alpha__ - { - int domain = p.busnum >> 8; - p.busnum &= 0xff; - - /* - * Find the hose the device is on (the domain number is the - * hose index) and offset the bus by the root bus of that - * hose. - */ - for(dev = pci_find_device(PCI_ANY_ID,PCI_ANY_ID,NULL); - dev; - dev = pci_find_device(PCI_ANY_ID,PCI_ANY_ID,dev)) { - struct pci_controller *hose = dev->sysdata; - - if (hose->index == domain) { - p.busnum += hose->bus->number; - break; - } - } - } -#endif - dev = pci_find_slot(p.busnum, PCI_DEVFN(p.devnum, p.funcnum)); - if (!dev) { - DRM_ERROR("pci_find_slot failed for %d:%d:%d\n", - p.busnum, p.devnum, p.funcnum); - p.irq = 0; - goto out; - } - if (pci_enable_device(dev) != 0) { - DRM_ERROR("pci_enable_device failed for %d:%d:%d\n", - p.busnum, p.devnum, p.funcnum); - p.irq = 0; - goto out; - } - p.irq = dev->irq; - out: - DRM_DEBUG("%d:%d:%d => IRQ %d\n", - p.busnum, p.devnum, p.funcnum, p.irq); - if (copy_to_user((drm_irq_busid_t *)arg, &p, sizeof(p))) - return -EFAULT; - return 0; -} +#include /** * Get the bus id. @@ -138,8 +76,10 @@ int DRM(getunique)(struct inode *inode, * \param arg user argument, pointing to a drm_unique structure. * \return zero on success or a negative number on failure. * - * Copies the bus id from userspace into drm_device::unique, and searches for - * the respective PCI device, updating drm_device::pdev. + * Copies the bus id from userspace into drm_device::unique, and verifies that + * it matches the device this DRM is attached to (EINVAL otherwise). Deprecated + * in interface version 1.1 and will return EBUSY when setversion has requested + * version 1.1 or greater. */ int DRM(setunique)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) @@ -147,6 +87,7 @@ int DRM(setunique)(struct inode *inode, drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; drm_unique_t u; + int domain, bus, slot, func, ret; if (dev->unique_len || dev->unique) return -EBUSY; @@ -164,55 +105,42 @@ int DRM(setunique)(struct inode *inode, dev->devname = DRM(alloc)(strlen(dev->name) + strlen(dev->unique) + 2, DRM_MEM_DRIVER); - if(!dev->devname) { - DRM(free)(dev->devname, sizeof(*dev->devname), DRM_MEM_DRIVER); + if (!dev->devname) return -ENOMEM; - } + sprintf(dev->devname, "%s@%s", dev->name, dev->unique); - do { - struct pci_dev *pci_dev; - int domain, b, d, f; - char *p; - - for(p = dev->unique; p && *p && *p != ':'; p++); - if (!p || !*p) break; - b = (int)simple_strtoul(p+1, &p, 10); - if (*p != ':') break; - d = (int)simple_strtoul(p+1, &p, 10); - if (*p != ':') break; - f = (int)simple_strtoul(p+1, &p, 10); - if (*p) break; - - domain = b >> 8; - b &= 0xff; - -#ifdef __alpha__ - /* - * Find the hose the device is on (the domain number is the - * hose index) and offset the bus by the root bus of that - * hose. - */ - for(pci_dev = pci_find_device(PCI_ANY_ID,PCI_ANY_ID,NULL); - pci_dev; - pci_dev = pci_find_device(PCI_ANY_ID,PCI_ANY_ID,pci_dev)) { - struct pci_controller *hose = pci_dev->sysdata; - - if (hose->index == domain) { - b += hose->bus->number; - break; - } - } -#endif + /* Return error if the busid submitted doesn't match the device's actual + * busid. + */ + ret = sscanf(dev->unique, "PCI:%d:%d:%d", &bus, &slot, &func); + if (ret != 3) + return DRM_ERR(EINVAL); + domain = bus >> 8; + bus &= 0xff; + + if ((domain != dev->pci_domain) || + (bus != dev->pci_bus) || + (slot != dev->pci_slot) || + (func != dev->pci_func)) + return -EINVAL; - pci_dev = pci_find_slot(b, PCI_DEVFN(d,f)); - if (pci_dev) { - dev->pdev = pci_dev; -#ifdef __alpha__ - dev->hose = pci_dev->sysdata; -#endif - } - } while(0); + return 0; +} + +static int +DRM(set_busid)(drm_device_t *dev) +{ + if (dev->unique != NULL) + return EBUSY; + + dev->unique_len = 20; + dev->unique = DRM(alloc)(dev->unique_len + 1, DRM_MEM_DRIVER); + if (dev->unique == NULL) + return ENOMEM; + + snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d", + dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func); return 0; } @@ -363,3 +291,48 @@ int DRM(getstats)( struct inode *inode, return -EFAULT; return 0; } + +#define DRM_IF_MAJOR 1 +#define DRM_IF_MINOR 2 + +int DRM(setversion)(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + drm_set_version_t sv; + drm_set_version_t retv; + int if_version; + + DRM_COPY_FROM_USER_IOCTL(sv, (drm_set_version_t *)data, sizeof(sv)); + + retv.drm_di_major = DRM_IF_MAJOR; + retv.drm_di_minor = DRM_IF_MINOR; + retv.drm_dd_major = DRIVER_MAJOR; + retv.drm_dd_minor = DRIVER_MINOR; + + DRM_COPY_TO_USER_IOCTL((drm_set_version_t *)data, retv, sizeof(sv)); + + if (sv.drm_di_major != -1) { + if (sv.drm_di_major != DRM_IF_MAJOR || + sv.drm_di_minor < 0 || sv.drm_di_minor > DRM_IF_MINOR) + return EINVAL; + if_version = DRM_IF_VERSION(sv.drm_di_major, sv.drm_dd_minor); + dev->if_version = DRM_MAX(if_version, dev->if_version); + if (sv.drm_di_minor >= 1) { + /* + * Version 1.1 includes tying of DRM to specific device + */ + DRM(set_busid)(dev); + } + } + + if (sv.drm_dd_major != -1) { + if (sv.drm_dd_major != DRIVER_MAJOR || + sv.drm_dd_minor < 0 || sv.drm_dd_minor > DRIVER_MINOR) + return EINVAL; +#ifdef DRIVER_SETVERSION + DRIVER_SETVERSION(dev, &sv); +#endif + } + return 0; +} + --- diff/drivers/char/drm/drm_os_linux.h 2003-09-30 15:46:12.000000000 +0100 +++ source/drivers/char/drm/drm_os_linux.h 2004-02-23 13:56:40.000000000 +0000 @@ -62,8 +62,12 @@ verify_area( VERIFY_READ, uaddr, size ) #define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \ __copy_from_user(arg1, arg2, arg3) +#define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \ + __copy_to_user(arg1, arg2, arg3) #define DRM_GET_USER_UNCHECKED(val, uaddr) \ __get_user(val, uaddr) +#define DRM_PUT_USER_UNCHECKED(uaddr, val) \ + __put_user(val, uaddr) /** 'malloc' without the overhead of DRM(alloc)() */ @@ -71,6 +75,8 @@ /** 'free' without the overhead of DRM(free)() */ #define DRM_FREE(x,size) kfree(x) +#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) _priv = _filp->private_data + /** * Get the pointer to the SAREA. * --- diff/drivers/char/drm/gamma.h 2003-05-21 11:50:14.000000000 +0100 +++ source/drivers/char/drm/gamma.h 2004-02-23 13:56:40.000000000 +0000 @@ -53,6 +53,10 @@ [DRM_IOCTL_NR(DRM_IOCTL_GAMMA_INIT)] = { gamma_dma_init, 1, 1 }, \ [DRM_IOCTL_NR(DRM_IOCTL_GAMMA_COPY)] = { gamma_dma_copy, 1, 1 } +#define DRIVER_PCI_IDS \ + {0x3d3d, 0x0008, 0, "3DLabs GLINT Gamma G1"}, \ + {0, 0, 0, NULL} + #define IOCTL_TABLE_NAME DRM(ioctls) #define IOCTL_FUNC_NAME DRM(ioctl) @@ -104,8 +108,8 @@ return 0; \ } while (0) -#define __HAVE_DMA_IRQ 1 -#define __HAVE_DMA_IRQ_BH 1 +#define __HAVE_IRQ 1 +#define __HAVE_IRQ_BH 1 #define DRIVER_AGP_BUFFERS_MAP( dev ) \ ((drm_gamma_private_t *)((dev)->dev_private))->buffers --- diff/drivers/char/drm/gamma_dma.c 2003-09-30 15:46:12.000000000 +0100 +++ source/drivers/char/drm/gamma_dma.c 2004-02-23 13:56:40.000000000 +0000 @@ -116,7 +116,7 @@ static inline int gamma_dma_is_ready(drm return (!GAMMA_READ(GAMMA_DMACOUNT)); } -irqreturn_t gamma_dma_service( DRM_IRQ_ARGS ) +irqreturn_t gamma_irq_handler( DRM_IRQ_ARGS ) { drm_device_t *dev = (drm_device_t *)arg; drm_device_dma_t *dma = dev->dma; @@ -262,7 +262,7 @@ static void gamma_dma_timer_bh(unsigned gamma_dma_schedule((drm_device_t *)dev, 0); } -void gamma_dma_immediate_bh(void *dev) +void gamma_irq_immediate_bh(void *dev) { gamma_dma_schedule(dev, 0); } @@ -656,12 +656,12 @@ int gamma_do_cleanup_dma( drm_device_t * { DRM_DEBUG( "%s\n", __FUNCTION__ ); -#if _HAVE_DMA_IRQ +#if __HAVE_IRQ /* Make sure interrupts are disabled here because the uninstall ioctl * may not have been called from userspace and after dev_private * is freed, it's too late. */ - if ( dev->irq ) DRM(irq_uninstall)(dev); + if ( dev->irq_enabled ) DRM(irq_uninstall)(dev); #endif if ( dev->dev_private ) { --- diff/drivers/char/drm/gamma_drv.c 2003-05-21 11:50:14.000000000 +0100 +++ source/drivers/char/drm/gamma_drv.c 2004-02-23 13:56:40.000000000 +0000 @@ -48,6 +48,7 @@ #include "drm_fops.h" #include "drm_init.h" #include "drm_ioctl.h" +#include "drm_irq.h" #include "gamma_lists.h" /* NOTE */ #include "drm_lock.h" #include "gamma_lock.h" /* NOTE */ --- diff/drivers/char/drm/i810.h 2003-08-26 10:00:52.000000000 +0100 +++ source/drivers/char/drm/i810.h 2004-02-23 13:56:40.000000000 +0000 @@ -77,7 +77,14 @@ [DRM_IOCTL_NR(DRM_IOCTL_I810_MC)] = { i810_dma_mc, 1, 1 }, \ [DRM_IOCTL_NR(DRM_IOCTL_I810_RSTATUS)] = { i810_rstatus, 1, 0 }, \ [DRM_IOCTL_NR(DRM_IOCTL_I810_FLIP)] = { i810_flip_bufs, 1, 0 } - + +#define DRIVER_PCI_IDS \ + {0x8086, 0x7121, 0, "Intel i810 GMCH"}, \ + {0x8086, 0x7123, 0, "Intel i810-DC100 GMCH"}, \ + {0x8086, 0x7125, 0, "Intel i810E GMCH"}, \ + {0x8086, 0x1132, 0, "Intel i815 GMCH"}, \ + {0, 0, 0, NULL} + #define __HAVE_COUNTERS 4 #define __HAVE_COUNTER6 _DRM_STAT_IRQ @@ -112,7 +119,7 @@ * a noop stub is generated for compatibility. */ /* XXX: Add vblank support? */ -#define __HAVE_DMA_IRQ 0 +#define __HAVE_IRQ 0 /* Buffer customization: */ --- diff/drivers/char/drm/i810_dma.c 2003-09-30 15:46:12.000000000 +0100 +++ source/drivers/char/drm/i810_dma.c 2004-02-23 13:56:40.000000000 +0000 @@ -53,41 +53,41 @@ static inline void i810_print_status_page(drm_device_t *dev) { - drm_device_dma_t *dma = dev->dma; - drm_i810_private_t *dev_priv = dev->dev_private; + drm_device_dma_t *dma = dev->dma; + drm_i810_private_t *dev_priv = dev->dev_private; u32 *temp = dev_priv->hw_status_page; - int i; + int i; - DRM_DEBUG( "hw_status: Interrupt Status : %x\n", temp[0]); - DRM_DEBUG( "hw_status: LpRing Head ptr : %x\n", temp[1]); - DRM_DEBUG( "hw_status: IRing Head ptr : %x\n", temp[2]); - DRM_DEBUG( "hw_status: Reserved : %x\n", temp[3]); + DRM_DEBUG( "hw_status: Interrupt Status : %x\n", temp[0]); + DRM_DEBUG( "hw_status: LpRing Head ptr : %x\n", temp[1]); + DRM_DEBUG( "hw_status: IRing Head ptr : %x\n", temp[2]); + DRM_DEBUG( "hw_status: Reserved : %x\n", temp[3]); DRM_DEBUG( "hw_status: Last Render: %x\n", temp[4]); - DRM_DEBUG( "hw_status: Driver Counter : %d\n", temp[5]); - for(i = 6; i < dma->buf_count + 6; i++) { - DRM_DEBUG( "buffer status idx : %d used: %d\n", i - 6, temp[i]); + DRM_DEBUG( "hw_status: Driver Counter : %d\n", temp[5]); + for(i = 6; i < dma->buf_count + 6; i++) { + DRM_DEBUG( "buffer status idx : %d used: %d\n", i - 6, temp[i]); } } static drm_buf_t *i810_freelist_get(drm_device_t *dev) { - drm_device_dma_t *dma = dev->dma; + drm_device_dma_t *dma = dev->dma; int i; - int used; + int used; /* Linear search might not be the best solution */ - for (i = 0; i < dma->buf_count; i++) { - drm_buf_t *buf = dma->buflist[ i ]; - drm_i810_buf_priv_t *buf_priv = buf->dev_private; + for (i = 0; i < dma->buf_count; i++) { + drm_buf_t *buf = dma->buflist[ i ]; + drm_i810_buf_priv_t *buf_priv = buf->dev_private; /* In use is already a pointer */ - used = cmpxchg(buf_priv->in_use, I810_BUF_FREE, + used = cmpxchg(buf_priv->in_use, I810_BUF_FREE, I810_BUF_CLIENT); if (used == I810_BUF_FREE) { return buf; } } - return NULL; + return NULL; } /* This should only be called if the buffer is not sent to the hardware @@ -96,17 +96,17 @@ static drm_buf_t *i810_freelist_get(drm_ static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf) { - drm_i810_buf_priv_t *buf_priv = buf->dev_private; - int used; + drm_i810_buf_priv_t *buf_priv = buf->dev_private; + int used; - /* In use is already a pointer */ - used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, I810_BUF_FREE); + /* In use is already a pointer */ + used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, I810_BUF_FREE); if (used != I810_BUF_CLIENT) { - DRM_ERROR("Freeing buffer thats not in use : %d\n", buf->idx); - return -EINVAL; + DRM_ERROR("Freeing buffer thats not in use : %d\n", buf->idx); + return -EINVAL; } - return 0; + return 0; } static struct file_operations i810_buffer_fops = { @@ -135,7 +135,7 @@ int i810_mmap_buffers(struct file *filp, vma->vm_flags |= (VM_IO | VM_DONTCOPY); vma->vm_file = filp; - buf_priv->currently_mapped = I810_BUF_MAPPED; + buf_priv->currently_mapped = I810_BUF_MAPPED; unlock_kernel(); if (remap_page_range(DRM_RPR_ARG(vma) vma->vm_start, @@ -150,8 +150,8 @@ static int i810_map_buffer(drm_buf_t *bu drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; drm_i810_buf_priv_t *buf_priv = buf->dev_private; - drm_i810_private_t *dev_priv = dev->dev_private; - struct file_operations *old_fops; + drm_i810_private_t *dev_priv = dev->dev_private; + struct file_operations *old_fops; int retcode = 0; if (buf_priv->currently_mapped == I810_BUF_MAPPED) @@ -192,8 +192,8 @@ static int i810_unmap_buffer(drm_buf_t * (size_t) buf->total); up_write(¤t->mm->mmap_sem); - buf_priv->currently_mapped = I810_BUF_UNMAPPED; - buf_priv->virtual = 0; + buf_priv->currently_mapped = I810_BUF_UNMAPPED; + buf_priv->virtual = 0; return retcode; } @@ -208,22 +208,22 @@ static int i810_dma_get_buffer(drm_devic buf = i810_freelist_get(dev); if (!buf) { retcode = -ENOMEM; - DRM_DEBUG("retcode=%d\n", retcode); + DRM_DEBUG("retcode=%d\n", retcode); return retcode; } retcode = i810_map_buffer(buf, filp); if (retcode) { i810_freelist_put(dev, buf); - DRM_ERROR("mapbuf failed, retcode %d\n", retcode); + DRM_ERROR("mapbuf failed, retcode %d\n", retcode); return retcode; } buf->filp = filp; buf_priv = buf->dev_private; d->granted = 1; - d->request_idx = buf->idx; - d->request_size = buf->total; - d->virtual = buf_priv->virtual; + d->request_idx = buf->idx; + d->request_size = buf->total; + d->virtual = buf_priv->virtual; return retcode; } @@ -232,33 +232,33 @@ int i810_dma_cleanup(drm_device_t *dev) { drm_device_dma_t *dma = dev->dma; -#if _HAVE_DMA_IRQ +#if __HAVE_IRQ /* Make sure interrupts are disabled here because the uninstall ioctl * may not have been called from userspace and after dev_private * is freed, it's too late. */ - if (dev->irq) DRM(irq_uninstall)(dev); + if (dev->irq_enabled) DRM(irq_uninstall)(dev); #endif if (dev->dev_private) { int i; - drm_i810_private_t *dev_priv = - (drm_i810_private_t *) dev->dev_private; + drm_i810_private_t *dev_priv = + (drm_i810_private_t *) dev->dev_private; if (dev_priv->ring.virtual_start) { - DRM(ioremapfree)((void *) dev_priv->ring.virtual_start, + DRM(ioremapfree)((void *) dev_priv->ring.virtual_start, dev_priv->ring.Size, dev); } - if (dev_priv->hw_status_page) { - pci_free_consistent(dev->pdev, PAGE_SIZE, + if (dev_priv->hw_status_page) { + pci_free_consistent(dev->pdev, PAGE_SIZE, dev_priv->hw_status_page, dev_priv->dma_status_page); - /* Need to rewrite hardware status page */ - I810_WRITE(0x02080, 0x1ffff000); + /* Need to rewrite hardware status page */ + I810_WRITE(0x02080, 0x1ffff000); } - DRM(free)(dev->dev_private, sizeof(drm_i810_private_t), + DRM(free)(dev->dev_private, sizeof(drm_i810_private_t), DRM_MEM_DRIVER); - dev->dev_private = NULL; + dev->dev_private = NULL; for (i = 0; i < dma->buf_count; i++) { drm_buf_t *buf = dma->buflist[ i ]; @@ -267,73 +267,73 @@ int i810_dma_cleanup(drm_device_t *dev) DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total, dev); } } - return 0; + return 0; } static int i810_wait_ring(drm_device_t *dev, int n) { - drm_i810_private_t *dev_priv = dev->dev_private; - drm_i810_ring_buffer_t *ring = &(dev_priv->ring); - int iters = 0; - unsigned long end; + drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_ring_buffer_t *ring = &(dev_priv->ring); + int iters = 0; + unsigned long end; unsigned int last_head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; end = jiffies + (HZ*3); - while (ring->space < n) { - ring->head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; - ring->space = ring->head - (ring->tail+8); + while (ring->space < n) { + ring->head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; + ring->space = ring->head - (ring->tail+8); if (ring->space < 0) ring->space += ring->Size; - + if (ring->head != last_head) { end = jiffies + (HZ*3); last_head = ring->head; } - iters++; + iters++; if (time_before(end, jiffies)) { - DRM_ERROR("space: %d wanted %d\n", ring->space, n); - DRM_ERROR("lockup\n"); - goto out_wait_ring; + DRM_ERROR("space: %d wanted %d\n", ring->space, n); + DRM_ERROR("lockup\n"); + goto out_wait_ring; } udelay(1); } out_wait_ring: - return iters; + return iters; } static void i810_kernel_lost_context(drm_device_t *dev) { - drm_i810_private_t *dev_priv = dev->dev_private; - drm_i810_ring_buffer_t *ring = &(dev_priv->ring); + drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_ring_buffer_t *ring = &(dev_priv->ring); - ring->head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; - ring->tail = I810_READ(LP_RING + RING_TAIL); - ring->space = ring->head - (ring->tail+8); - if (ring->space < 0) ring->space += ring->Size; + ring->head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; + ring->tail = I810_READ(LP_RING + RING_TAIL); + ring->space = ring->head - (ring->tail+8); + if (ring->space < 0) ring->space += ring->Size; } static int i810_freelist_init(drm_device_t *dev, drm_i810_private_t *dev_priv) { - drm_device_dma_t *dma = dev->dma; - int my_idx = 24; - u32 *hw_status = (u32 *)(dev_priv->hw_status_page + my_idx); - int i; + drm_device_dma_t *dma = dev->dma; + int my_idx = 24; + u32 *hw_status = (u32 *)(dev_priv->hw_status_page + my_idx); + int i; if (dma->buf_count > 1019) { - /* Not enough space in the status page for the freelist */ - return -EINVAL; + /* Not enough space in the status page for the freelist */ + return -EINVAL; } - for (i = 0; i < dma->buf_count; i++) { - drm_buf_t *buf = dma->buflist[ i ]; - drm_i810_buf_priv_t *buf_priv = buf->dev_private; + for (i = 0; i < dma->buf_count; i++) { + drm_buf_t *buf = dma->buflist[ i ]; + drm_i810_buf_priv_t *buf_priv = buf->dev_private; - buf_priv->in_use = hw_status++; - buf_priv->my_use_idx = my_idx; - my_idx += 4; + buf_priv->in_use = hw_status++; + buf_priv->my_use_idx = my_idx; + my_idx += 4; - *buf_priv->in_use = I810_BUF_FREE; + *buf_priv->in_use = I810_BUF_FREE; buf_priv->kernel_virtual = DRM(ioremap)(buf->bus_address, buf->total, dev); @@ -347,7 +347,7 @@ static int i810_dma_initialize(drm_devic { struct list_head *list; - memset(dev_priv, 0, sizeof(drm_i810_private_t)); + memset(dev_priv, 0, sizeof(drm_i810_private_t)); list_for_each(list, &dev->maplist->head) { drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head); @@ -355,51 +355,51 @@ static int i810_dma_initialize(drm_devic r_list->map->type == _DRM_SHM && r_list->map->flags & _DRM_CONTAINS_LOCK ) { dev_priv->sarea_map = r_list->map; - break; - } - } + break; + } + } if (!dev_priv->sarea_map) { dev->dev_private = (void *)dev_priv; - i810_dma_cleanup(dev); - DRM_ERROR("can not find sarea!\n"); - return -EINVAL; + i810_dma_cleanup(dev); + DRM_ERROR("can not find sarea!\n"); + return -EINVAL; } DRM_FIND_MAP( dev_priv->mmio_map, init->mmio_offset ); if (!dev_priv->mmio_map) { dev->dev_private = (void *)dev_priv; - i810_dma_cleanup(dev); - DRM_ERROR("can not find mmio map!\n"); - return -EINVAL; + i810_dma_cleanup(dev); + DRM_ERROR("can not find mmio map!\n"); + return -EINVAL; } DRM_FIND_MAP( dev_priv->buffer_map, init->buffers_offset ); if (!dev_priv->buffer_map) { dev->dev_private = (void *)dev_priv; - i810_dma_cleanup(dev); - DRM_ERROR("can not find dma buffer map!\n"); - return -EINVAL; + i810_dma_cleanup(dev); + DRM_ERROR("can not find dma buffer map!\n"); + return -EINVAL; } dev_priv->sarea_priv = (drm_i810_sarea_t *) ((u8 *)dev_priv->sarea_map->handle + init->sarea_priv_offset); - dev_priv->ring.Start = init->ring_start; - dev_priv->ring.End = init->ring_end; - dev_priv->ring.Size = init->ring_size; + dev_priv->ring.Start = init->ring_start; + dev_priv->ring.End = init->ring_end; + dev_priv->ring.Size = init->ring_size; - dev_priv->ring.virtual_start = DRM(ioremap)(dev->agp->base + + dev_priv->ring.virtual_start = DRM(ioremap)(dev->agp->base + init->ring_start, init->ring_size, dev); - if (dev_priv->ring.virtual_start == NULL) { + if (dev_priv->ring.virtual_start == NULL) { dev->dev_private = (void *) dev_priv; - i810_dma_cleanup(dev); - DRM_ERROR("can not ioremap virtual address for" + i810_dma_cleanup(dev); + DRM_ERROR("can not ioremap virtual address for" " ring buffer\n"); - return -ENOMEM; + return -ENOMEM; } - dev_priv->ring.tail_mask = dev_priv->ring.Size - 1; + dev_priv->ring.tail_mask = dev_priv->ring.Size - 1; dev_priv->w = init->w; dev_priv->h = init->h; @@ -415,33 +415,33 @@ static int i810_dma_initialize(drm_devic dev_priv->back_di1 = init->back_offset | init->pitch_bits; dev_priv->zi1 = init->depth_offset | init->pitch_bits; - /* Program Hardware Status Page */ - dev_priv->hw_status_page = + /* Program Hardware Status Page */ + dev_priv->hw_status_page = pci_alloc_consistent(dev->pdev, PAGE_SIZE, &dev_priv->dma_status_page); - if (!dev_priv->hw_status_page) { + if (!dev_priv->hw_status_page) { dev->dev_private = (void *)dev_priv; i810_dma_cleanup(dev); DRM_ERROR("Can not allocate hardware status page\n"); return -ENOMEM; } - memset(dev_priv->hw_status_page, 0, PAGE_SIZE); - DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page); + memset(dev_priv->hw_status_page, 0, PAGE_SIZE); + DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page); I810_WRITE(0x02080, dev_priv->dma_status_page); - DRM_DEBUG("Enabled hardware status page\n"); + DRM_DEBUG("Enabled hardware status page\n"); - /* Now we need to init our freelist */ + /* Now we need to init our freelist */ if (i810_freelist_init(dev, dev_priv) != 0) { dev->dev_private = (void *)dev_priv; - i810_dma_cleanup(dev); - DRM_ERROR("Not enough space in the status page for" + i810_dma_cleanup(dev); + DRM_ERROR("Not enough space in the status page for" " the freelist\n"); - return -ENOMEM; + return -ENOMEM; } dev->dev_private = (void *)dev_priv; - return 0; + return 0; } /* i810 DRM version 1.1 used a smaller init structure with different @@ -476,12 +476,12 @@ int i810_dma_init_compat(drm_i810_init_t /* This is a v1.1 client, fix the params */ DRM_INFO("Using PRE v1.2 init.\n"); - init->pitch_bits = init->h; - init->pitch = init->w; - init->h = init->overlay_physical; - init->w = init->overlay_offset; - init->overlay_physical = 0; - init->overlay_offset = 0; + init->pitch_bits = init->h; + init->pitch = init->w; + init->h = init->overlay_physical; + init->w = init->overlay_offset; + init->overlay_physical = 0; + init->overlay_offset = 0; } return 0; @@ -490,55 +490,55 @@ int i810_dma_init_compat(drm_i810_init_t int i810_dma_init(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_i810_private_t *dev_priv; - drm_i810_init_t init; - int retcode = 0; + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_i810_private_t *dev_priv; + drm_i810_init_t init; + int retcode = 0; /* Get only the init func */ if (copy_from_user(&init, (void *)arg, sizeof(drm_i810_init_func_t))) return -EFAULT; - switch(init.func) { - case I810_INIT_DMA: - /* This case is for backward compatibility. It + switch(init.func) { + case I810_INIT_DMA: + /* This case is for backward compatibility. It * handles XFree 4.1.0 and 4.2.0, and has to * do some parameter checking as described below. * It will someday go away. */ retcode = i810_dma_init_compat(&init, arg); - if (retcode) + if (retcode) return retcode; - dev_priv = DRM(alloc)(sizeof(drm_i810_private_t), + dev_priv = DRM(alloc)(sizeof(drm_i810_private_t), DRM_MEM_DRIVER); - if (dev_priv == NULL) - return -ENOMEM; - retcode = i810_dma_initialize(dev, dev_priv, &init); + if (dev_priv == NULL) + return -ENOMEM; + retcode = i810_dma_initialize(dev, dev_priv, &init); break; default: - case I810_INIT_DMA_1_4: + case I810_INIT_DMA_1_4: DRM_INFO("Using v1.4 init.\n"); - if (copy_from_user(&init, (drm_i810_init_t *)arg, + if (copy_from_user(&init, (drm_i810_init_t *)arg, sizeof(drm_i810_init_t))) { return -EFAULT; } - dev_priv = DRM(alloc)(sizeof(drm_i810_private_t), + dev_priv = DRM(alloc)(sizeof(drm_i810_private_t), DRM_MEM_DRIVER); if (dev_priv == NULL) return -ENOMEM; - retcode = i810_dma_initialize(dev, dev_priv, &init); + retcode = i810_dma_initialize(dev, dev_priv, &init); break; - case I810_CLEANUP_DMA: - DRM_INFO("DMA Cleanup\n"); - retcode = i810_dma_cleanup(dev); - break; + case I810_CLEANUP_DMA: + DRM_INFO("DMA Cleanup\n"); + retcode = i810_dma_cleanup(dev); + break; } - return retcode; + return retcode; } @@ -552,7 +552,7 @@ int i810_dma_init(struct inode *inode, s static void i810EmitContextVerified( drm_device_t *dev, volatile unsigned int *code ) { - drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_private_t *dev_priv = dev->dev_private; int i, j = 0; unsigned int tmp; RING_LOCALS; @@ -586,7 +586,7 @@ static void i810EmitContextVerified( drm static void i810EmitTexVerified( drm_device_t *dev, volatile unsigned int *code ) { - drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_private_t *dev_priv = dev->dev_private; int i, j = 0; unsigned int tmp; RING_LOCALS; @@ -622,7 +622,7 @@ static void i810EmitTexVerified( drm_dev static void i810EmitDestVerified( drm_device_t *dev, volatile unsigned int *code ) { - drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_private_t *dev_priv = dev->dev_private; unsigned int tmp; RING_LOCALS; @@ -658,8 +658,8 @@ static void i810EmitDestVerified( drm_de static void i810EmitState( drm_device_t *dev ) { - drm_i810_private_t *dev_priv = dev->dev_private; - drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int dirty = sarea_priv->dirty; DRM_DEBUG("%s %x\n", __FUNCTION__, dirty); @@ -693,8 +693,8 @@ static void i810_dma_dispatch_clear( drm unsigned int clear_color, unsigned int clear_zval ) { - drm_i810_private_t *dev_priv = dev->dev_private; - drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; int nbox = sarea_priv->nbox; drm_clip_rect_t *pbox = sarea_priv->boxes; int pitch = dev_priv->pitch; @@ -703,17 +703,17 @@ static void i810_dma_dispatch_clear( drm RING_LOCALS; if ( dev_priv->current_page == 1 ) { - unsigned int tmp = flags; - + unsigned int tmp = flags; + flags &= ~(I810_FRONT | I810_BACK); if (tmp & I810_FRONT) flags |= I810_BACK; if (tmp & I810_BACK) flags |= I810_FRONT; } - i810_kernel_lost_context(dev); + i810_kernel_lost_context(dev); - if (nbox > I810_NR_SAREA_CLIPRECTS) - nbox = I810_NR_SAREA_CLIPRECTS; + if (nbox > I810_NR_SAREA_CLIPRECTS) + nbox = I810_NR_SAREA_CLIPRECTS; for (i = 0 ; i < nbox ; i++, pbox++) { unsigned int x = pbox->x1; @@ -728,7 +728,7 @@ static void i810_dma_dispatch_clear( drm pbox->y2 > dev_priv->h) continue; - if ( flags & I810_FRONT ) { + if ( flags & I810_FRONT ) { BEGIN_LP_RING( 6 ); OUT_RING( BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3 ); @@ -768,8 +768,8 @@ static void i810_dma_dispatch_clear( drm static void i810_dma_dispatch_swap( drm_device_t *dev ) { - drm_i810_private_t *dev_priv = dev->dev_private; - drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; int nbox = sarea_priv->nbox; drm_clip_rect_t *pbox = sarea_priv->boxes; int pitch = dev_priv->pitch; @@ -779,10 +779,10 @@ static void i810_dma_dispatch_swap( drm_ DRM_DEBUG("swapbuffers\n"); - i810_kernel_lost_context(dev); + i810_kernel_lost_context(dev); - if (nbox > I810_NR_SAREA_CLIPRECTS) - nbox = I810_NR_SAREA_CLIPRECTS; + if (nbox > I810_NR_SAREA_CLIPRECTS) + nbox = I810_NR_SAREA_CLIPRECTS; for (i = 0 ; i < nbox; i++, pbox++) { @@ -820,19 +820,19 @@ static void i810_dma_dispatch_vertex(drm int discard, int used) { - drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_private_t *dev_priv = dev->dev_private; drm_i810_buf_priv_t *buf_priv = buf->dev_private; - drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; - drm_clip_rect_t *box = sarea_priv->boxes; - int nbox = sarea_priv->nbox; + drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_clip_rect_t *box = sarea_priv->boxes; + int nbox = sarea_priv->nbox; unsigned long address = (unsigned long)buf->bus_address; unsigned long start = address - dev->agp->base; int i = 0; - RING_LOCALS; + RING_LOCALS; - i810_kernel_lost_context(dev); + i810_kernel_lost_context(dev); - if (nbox > I810_NR_SAREA_CLIPRECTS) + if (nbox > I810_NR_SAREA_CLIPRECTS) nbox = I810_NR_SAREA_CLIPRECTS; if (used > 4*1024) @@ -898,7 +898,7 @@ static void i810_dma_dispatch_vertex(drm static void i810_dma_dispatch_flip( drm_device_t *dev ) { - drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_private_t *dev_priv = dev->dev_private; int pitch = dev_priv->pitch; RING_LOCALS; @@ -907,10 +907,10 @@ static void i810_dma_dispatch_flip( drm_ dev_priv->current_page, dev_priv->sarea_priv->pf_current_page); - i810_kernel_lost_context(dev); + i810_kernel_lost_context(dev); BEGIN_LP_RING( 2 ); - OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE ); + OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE ); OUT_RING( 0 ); ADVANCE_LP_RING(); @@ -945,44 +945,44 @@ static void i810_dma_dispatch_flip( drm_ void i810_dma_quiescent(drm_device_t *dev) { - drm_i810_private_t *dev_priv = dev->dev_private; - RING_LOCALS; + drm_i810_private_t *dev_priv = dev->dev_private; + RING_LOCALS; -/* printk("%s\n", __FUNCTION__); */ +/* printk("%s\n", __FUNCTION__); */ - i810_kernel_lost_context(dev); + i810_kernel_lost_context(dev); - BEGIN_LP_RING(4); - OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE ); - OUT_RING( CMD_REPORT_HEAD ); - OUT_RING( 0 ); - OUT_RING( 0 ); - ADVANCE_LP_RING(); + BEGIN_LP_RING(4); + OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE ); + OUT_RING( CMD_REPORT_HEAD ); + OUT_RING( 0 ); + OUT_RING( 0 ); + ADVANCE_LP_RING(); i810_wait_ring( dev, dev_priv->ring.Size - 8 ); } static int i810_flush_queue(drm_device_t *dev) { - drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_private_t *dev_priv = dev->dev_private; drm_device_dma_t *dma = dev->dma; - int i, ret = 0; - RING_LOCALS; + int i, ret = 0; + RING_LOCALS; -/* printk("%s\n", __FUNCTION__); */ +/* printk("%s\n", __FUNCTION__); */ - i810_kernel_lost_context(dev); + i810_kernel_lost_context(dev); - BEGIN_LP_RING(2); - OUT_RING( CMD_REPORT_HEAD ); - OUT_RING( 0 ); - ADVANCE_LP_RING(); + BEGIN_LP_RING(2); + OUT_RING( CMD_REPORT_HEAD ); + OUT_RING( 0 ); + ADVANCE_LP_RING(); i810_wait_ring( dev, dev_priv->ring.Size - 8 ); - for (i = 0; i < dma->buf_count; i++) { - drm_buf_t *buf = dma->buflist[ i ]; - drm_i810_buf_priv_t *buf_priv = buf->dev_private; + for (i = 0; i < dma->buf_count; i++) { + drm_buf_t *buf = dma->buflist[ i ]; + drm_i810_buf_priv_t *buf_priv = buf->dev_private; int used = cmpxchg(buf_priv->in_use, I810_BUF_HARDWARE, I810_BUF_FREE); @@ -993,7 +993,7 @@ static int i810_flush_queue(drm_device_t DRM_DEBUG("still on client\n"); } - return ret; + return ret; } /* Must be called with the lock held */ @@ -1005,14 +1005,14 @@ void i810_reclaim_buffers(struct file *f int i; if (!dma) return; - if (!dev->dev_private) return; + if (!dev->dev_private) return; if (!dma->buflist) return; - i810_flush_queue(dev); + i810_flush_queue(dev); for (i = 0; i < dma->buf_count; i++) { - drm_buf_t *buf = dma->buflist[ i ]; - drm_i810_buf_priv_t *buf_priv = buf->dev_private; + drm_buf_t *buf = dma->buflist[ i ]; + drm_i810_buf_priv_t *buf_priv = buf->dev_private; if (buf->filp == filp && buf_priv) { int used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, @@ -1021,7 +1021,7 @@ void i810_reclaim_buffers(struct file *f if (used == I810_BUF_CLIENT) DRM_DEBUG("reclaimed from client\n"); if (buf_priv->currently_mapped == I810_BUF_MAPPED) - buf_priv->currently_mapped = I810_BUF_UNMAPPED; + buf_priv->currently_mapped = I810_BUF_UNMAPPED; } } } @@ -1029,16 +1029,16 @@ void i810_reclaim_buffers(struct file *f int i810_flush_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("i810_flush_ioctl called without lock held\n"); return -EINVAL; } - i810_flush_queue(dev); - return 0; + i810_flush_queue(dev); + return 0; } @@ -1048,10 +1048,10 @@ int i810_dma_vertex(struct inode *inode, drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; drm_device_dma_t *dma = dev->dma; - drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; - u32 *hw_status = dev_priv->hw_status_page; - drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) - dev_priv->sarea_priv; + drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; + u32 *hw_status = dev_priv->hw_status_page; + drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) + dev_priv->sarea_priv; drm_i810_vertex_t vertex; if (copy_from_user(&vertex, (drm_i810_vertex_t *)arg, sizeof(vertex))) @@ -1072,10 +1072,10 @@ int i810_dma_vertex(struct inode *inode, dma->buflist[ vertex.idx ], vertex.discard, vertex.used ); - atomic_add(vertex.used, &dev->counts[_DRM_STAT_SECONDARY]); + atomic_add(vertex.used, &dev->counts[_DRM_STAT_SECONDARY]); atomic_inc(&dev->counts[_DRM_STAT_DMA]); sarea_priv->last_enqueue = dev_priv->counter-1; - sarea_priv->last_dispatch = (int) hw_status[5]; + sarea_priv->last_dispatch = (int) hw_status[5]; return 0; } @@ -1089,7 +1089,7 @@ int i810_clear_bufs(struct inode *inode, drm_device_t *dev = priv->dev; drm_i810_clear_t clear; - if (copy_from_user(&clear, (drm_i810_clear_t *)arg, sizeof(clear))) + if (copy_from_user(&clear, (drm_i810_clear_t *)arg, sizeof(clear))) return -EFAULT; if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { @@ -1097,15 +1097,15 @@ int i810_clear_bufs(struct inode *inode, return -EINVAL; } - /* GH: Someone's doing nasty things... */ - if (!dev->dev_private) { - return -EINVAL; - } + /* GH: Someone's doing nasty things... */ + if (!dev->dev_private) { + return -EINVAL; + } i810_dma_dispatch_clear( dev, clear.flags, clear.clear_color, clear.clear_depth ); - return 0; + return 0; } int i810_swap_bufs(struct inode *inode, struct file *filp, @@ -1122,20 +1122,20 @@ int i810_swap_bufs(struct inode *inode, } i810_dma_dispatch_swap( dev ); - return 0; + return 0; } int i810_getage(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { - drm_file_t *priv = filp->private_data; + drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; - drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; - u32 *hw_status = dev_priv->hw_status_page; - drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) - dev_priv->sarea_priv; + drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; + u32 *hw_status = dev_priv->hw_status_page; + drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) + dev_priv->sarea_priv; - sarea_priv->last_dispatch = (int) hw_status[5]; + sarea_priv->last_dispatch = (int) hw_status[5]; return 0; } @@ -1146,12 +1146,12 @@ int i810_getbuf(struct inode *inode, str drm_device_t *dev = priv->dev; int retcode = 0; drm_i810_dma_t d; - drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; - u32 *hw_status = dev_priv->hw_status_page; - drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) - dev_priv->sarea_priv; + drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; + u32 *hw_status = dev_priv->hw_status_page; + drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) + dev_priv->sarea_priv; - if (copy_from_user(&d, (drm_i810_dma_t *)arg, sizeof(d))) + if (copy_from_user(&d, (drm_i810_dma_t *)arg, sizeof(d))) return -EFAULT; if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { @@ -1168,7 +1168,7 @@ int i810_getbuf(struct inode *inode, str if (copy_to_user((drm_dma_t *)arg, &d, sizeof(d))) return -EFAULT; - sarea_priv->last_dispatch = (int) hw_status[5]; + sarea_priv->last_dispatch = (int) hw_status[5]; return retcode; } @@ -1384,5 +1384,5 @@ int i810_flip_bufs(struct inode *inode, i810_do_init_pageflip( dev ); i810_dma_dispatch_flip( dev ); - return 0; + return 0; } --- diff/drivers/char/drm/i830.h 2003-05-21 11:50:14.000000000 +0100 +++ source/drivers/char/drm/i830.h 2004-02-23 13:56:41.000000000 +0000 @@ -77,6 +77,13 @@ [DRM_IOCTL_NR(DRM_IOCTL_I830_GETPARAM)] = { i830_getparam, 1, 0 }, \ [DRM_IOCTL_NR(DRM_IOCTL_I830_SETPARAM)] = { i830_setparam, 1, 0 } +#define DRIVER_PCI_IDS \ + {0x8086, 0x3577, 0, "Intel i830M GMCH"}, \ + {0x8086, 0x2562, 0, "Intel i845G GMCH"}, \ + {0x8086, 0x3582, 0, "Intel i852GM/i855GM GMCH"}, \ + {0x8086, 0x2572, 0, "Intel i865G GMCH"}, \ + {0, 0, 0, NULL} + #define __HAVE_COUNTERS 4 #define __HAVE_COUNTER6 _DRM_STAT_IRQ #define __HAVE_COUNTER7 _DRM_STAT_PRIMARY @@ -115,10 +122,10 @@ #define USE_IRQS 0 #if USE_IRQS -#define __HAVE_DMA_IRQ 1 +#define __HAVE_IRQ 1 #define __HAVE_SHARED_IRQ 1 #else -#define __HAVE_DMA_IRQ 0 +#define __HAVE_IRQ 0 #endif --- diff/drivers/char/drm/i830_dma.c 2003-06-09 14:18:18.000000000 +0100 +++ source/drivers/char/drm/i830_dma.c 2004-02-23 13:56:41.000000000 +0000 @@ -231,12 +231,12 @@ int i830_dma_cleanup(drm_device_t *dev) { drm_device_dma_t *dma = dev->dma; -#if _HAVE_DMA_IRQ +#if __HAVE_IRQ /* Make sure interrupts are disabled here because the uninstall ioctl * may not have been called from userspace and after dev_private * is freed, it's too late. */ - if (dev->irq) DRM(irq_uninstall)(dev); + if (dev->irq_enabled) DRM(irq_uninstall)(dev); #endif if (dev->dev_private) { @@ -1539,7 +1539,7 @@ int i830_getparam( struct inode *inode, switch( param.param ) { case I830_PARAM_IRQ_ACTIVE: - value = dev->irq ? 1 : 0; + value = dev->irq_enabled; break; default: return -EINVAL; --- diff/drivers/char/drm/i830_drv.c 2003-05-21 11:50:14.000000000 +0100 +++ source/drivers/char/drm/i830_drv.c 2004-02-23 13:56:41.000000000 +0000 @@ -50,6 +50,7 @@ #include "drm_fops.h" #include "drm_init.h" #include "drm_ioctl.h" +#include "drm_irq.h" #include "drm_lock.h" #include "drm_memory.h" #include "drm_proc.h" --- diff/drivers/char/drm/i830_irq.c 2003-09-30 15:46:12.000000000 +0100 +++ source/drivers/char/drm/i830_irq.c 2004-02-23 13:56:41.000000000 +0000 @@ -35,7 +35,7 @@ #include -irqreturn_t DRM(dma_service)( DRM_IRQ_ARGS ) +irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS ) { drm_device_t *dev = (drm_device_t *)arg; drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private; --- diff/drivers/char/drm/mga.h 2003-05-21 11:50:14.000000000 +0100 +++ source/drivers/char/drm/mga.h 2004-02-23 13:56:41.000000000 +0000 @@ -64,6 +64,12 @@ [DRM_IOCTL_NR(DRM_IOCTL_MGA_BLIT)] = { mga_dma_blit, 1, 0 }, \ [DRM_IOCTL_NR(DRM_IOCTL_MGA_GETPARAM)]= { mga_getparam, 1, 0 }, +#define DRIVER_PCI_IDS \ + {0x102b, 0x0521, 0, "Matrox G200 (AGP)"}, \ + {0x102b, 0x0525, 0, "Matrox G400/G450 (AGP)"}, \ + {0x102b, 0x2527, 0, "Matrox G550 (AGP)"}, \ + {0, 0, 0, NULL} + #define __HAVE_COUNTERS 3 #define __HAVE_COUNTER6 _DRM_STAT_IRQ #define __HAVE_COUNTER7 _DRM_STAT_PRIMARY @@ -78,7 +84,7 @@ /* DMA customization: */ #define __HAVE_DMA 1 -#define __HAVE_DMA_IRQ 1 +#define __HAVE_IRQ 1 #define __HAVE_VBL_IRQ 1 #define __HAVE_SHARED_IRQ 1 --- diff/drivers/char/drm/mga_dma.c 2003-06-09 14:18:18.000000000 +0100 +++ source/drivers/char/drm/mga_dma.c 2004-02-23 13:56:41.000000000 +0000 @@ -500,14 +500,6 @@ static int mga_do_init_dma( drm_device_t return DRM_ERR(EINVAL); } - DRM_FIND_MAP( dev_priv->fb, init->fb_offset ); - if(!dev_priv->fb) { - DRM_ERROR( "failed to find framebuffer!\n" ); - /* Assign dev_private so we can do cleanup. */ - dev->dev_private = (void *)dev_priv; - mga_do_cleanup_dma( dev ); - return DRM_ERR(EINVAL); - } DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset ); if(!dev_priv->mmio) { DRM_ERROR( "failed to find mmio region!\n" ); @@ -639,12 +631,12 @@ int mga_do_cleanup_dma( drm_device_t *de { DRM_DEBUG( "\n" ); -#if _HAVE_DMA_IRQ +#if __HAVE_IRQ /* Make sure interrupts are disabled here because the uninstall ioctl * may not have been called from userspace and after dev_private * is freed, it's too late. */ - if ( dev->irq ) DRM(irq_uninstall)(dev); + if ( dev->irq_enabled ) DRM(irq_uninstall)(dev); #endif if ( dev->dev_private ) { --- diff/drivers/char/drm/mga_drv.c 2002-10-16 04:27:56.000000000 +0100 +++ source/drivers/char/drm/mga_drv.c 2004-02-23 13:56:41.000000000 +0000 @@ -45,6 +45,7 @@ #include "drm_fops.h" #include "drm_init.h" #include "drm_ioctl.h" +#include "drm_irq.h" #include "drm_lock.h" #include "drm_memory.h" #include "drm_proc.h" --- diff/drivers/char/drm/mga_drv.h 2003-06-09 14:18:18.000000000 +0100 +++ source/drivers/char/drm/mga_drv.h 2004-02-23 13:56:41.000000000 +0000 @@ -91,7 +91,6 @@ typedef struct drm_mga_private { unsigned int texture_size; drm_local_map_t *sarea; - drm_local_map_t *fb; drm_local_map_t *mmio; drm_local_map_t *status; drm_local_map_t *warp; --- diff/drivers/char/drm/mga_irq.c 2003-05-21 11:50:14.000000000 +0100 +++ source/drivers/char/drm/mga_irq.c 2004-02-23 13:56:41.000000000 +0000 @@ -36,7 +36,7 @@ #include "mga_drm.h" #include "mga_drv.h" -irqreturn_t mga_dma_service( DRM_IRQ_ARGS ) +irqreturn_t mga_irq_handler( DRM_IRQ_ARGS ) { drm_device_t *dev = (drm_device_t *) arg; drm_mga_private_t *dev_priv = --- diff/drivers/char/drm/r128.h 2003-08-26 10:00:52.000000000 +0100 +++ source/drivers/char/drm/r128.h 2004-02-23 13:56:41.000000000 +0000 @@ -79,6 +79,46 @@ [DRM_IOCTL_NR(DRM_IOCTL_R128_INDIRECT)] = { r128_cce_indirect, 1, 1 }, \ [DRM_IOCTL_NR(DRM_IOCTL_R128_GETPARAM)] = { r128_getparam, 1, 0 }, +#define DRIVER_PCI_IDS \ + {0x1002, 0x4c45, 0, "ATI Rage 128 Mobility LE (PCI)"}, \ + {0x1002, 0x4c46, 0, "ATI Rage 128 Mobility LF (AGP)"}, \ + {0x1002, 0x4d46, 0, "ATI Rage 128 Mobility MF (AGP)"}, \ + {0x1002, 0x4d4c, 0, "ATI Rage 128 Mobility ML (AGP)"}, \ + {0x1002, 0x5041, 0, "ATI Rage 128 Pro PA (PCI)"}, \ + {0x1002, 0x5042, 0, "ATI Rage 128 Pro PB (AGP)"}, \ + {0x1002, 0x5043, 0, "ATI Rage 128 Pro PC (AGP)"}, \ + {0x1002, 0x5044, 0, "ATI Rage 128 Pro PD (PCI)"}, \ + {0x1002, 0x5045, 0, "ATI Rage 128 Pro PE (AGP)"}, \ + {0x1002, 0x5046, 0, "ATI Rage 128 Pro PF (AGP)"}, \ + {0x1002, 0x5047, 0, "ATI Rage 128 Pro PG (PCI)"}, \ + {0x1002, 0x5048, 0, "ATI Rage 128 Pro PH (AGP)"}, \ + {0x1002, 0x5049, 0, "ATI Rage 128 Pro PI (AGP)"}, \ + {0x1002, 0x504A, 0, "ATI Rage 128 Pro PJ (PCI)"}, \ + {0x1002, 0x504B, 0, "ATI Rage 128 Pro PK (AGP)"}, \ + {0x1002, 0x504C, 0, "ATI Rage 128 Pro PL (AGP)"}, \ + {0x1002, 0x504D, 0, "ATI Rage 128 Pro PM (PCI)"}, \ + {0x1002, 0x504E, 0, "ATI Rage 128 Pro PN (AGP)"}, \ + {0x1002, 0x504F, 0, "ATI Rage 128 Pro PO (AGP)"}, \ + {0x1002, 0x5050, 0, "ATI Rage 128 Pro PP (PCI)"}, \ + {0x1002, 0x5051, 0, "ATI Rage 128 Pro PQ (AGP)"}, \ + {0x1002, 0x5052, 0, "ATI Rage 128 Pro PR (PCI)"}, \ + {0x1002, 0x5053, 0, "ATI Rage 128 Pro PS (PCI)"}, \ + {0x1002, 0x5054, 0, "ATI Rage 128 Pro PT (AGP)"}, \ + {0x1002, 0x5055, 0, "ATI Rage 128 Pro PU (AGP)"}, \ + {0x1002, 0x5056, 0, "ATI Rage 128 Pro PV (PCI)"}, \ + {0x1002, 0x5057, 0, "ATI Rage 128 Pro PW (AGP)"}, \ + {0x1002, 0x5058, 0, "ATI Rage 128 Pro PX (AGP)"}, \ + {0x1002, 0x5245, 0, "ATI Rage 128 RE (PCI)"}, \ + {0x1002, 0x5246, 0, "ATI Rage 128 RF (AGP)"}, \ + {0x1002, 0x5247, 0, "ATI Rage 128 RG (AGP)"}, \ + {0x1002, 0x524b, 0, "ATI Rage 128 RK (PCI)"}, \ + {0x1002, 0x524c, 0, "ATI Rage 128 RL (AGP)"}, \ + {0x1002, 0x534d, 0, "ATI Rage 128 SM (AGP)"}, \ + {0x1002, 0x5446, 0, "ATI Rage 128 Pro Ultra TF (AGP)"}, \ + {0x1002, 0x544C, 0, "ATI Rage 128 Pro Ultra TL (AGP)"}, \ + {0x1002, 0x5452, 0, "ATI Rage 128 Pro Ultra TR (AGP)"}, \ + {0, 0, 0, NULL} + /* Driver customization: */ #define DRIVER_PRERELEASE() do { \ @@ -97,7 +137,7 @@ /* DMA customization: */ #define __HAVE_DMA 1 -#define __HAVE_DMA_IRQ 1 +#define __HAVE_IRQ 1 #define __HAVE_VBL_IRQ 1 #define __HAVE_SHARED_IRQ 1 --- diff/drivers/char/drm/r128_cce.c 2003-09-30 15:46:12.000000000 +0100 +++ source/drivers/char/drm/r128_cce.c 2004-02-23 13:56:41.000000000 +0000 @@ -212,7 +212,7 @@ int r128_do_cce_idle( drm_r128_private_t int i; for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { - if ( GET_RING_HEAD( &dev_priv->ring ) == dev_priv->ring.tail ) { + if ( GET_RING_HEAD( dev_priv ) == dev_priv->ring.tail ) { int pm4stat = R128_READ( R128_PM4_STAT ); if ( ( (pm4stat & R128_PM4_FIFOCNT_MASK) >= dev_priv->cce_fifo_size ) && @@ -238,7 +238,8 @@ static void r128_do_cce_start( drm_r128_ r128_do_wait_for_idle( dev_priv ); R128_WRITE( R128_PM4_BUFFER_CNTL, - dev_priv->cce_mode | dev_priv->ring.size_l2qw ); + dev_priv->cce_mode | dev_priv->ring.size_l2qw + | R128_PM4_BUFFER_CNTL_NOUPDATE ); R128_READ( R128_PM4_BUFFER_ADDR ); /* as per the sample code */ R128_WRITE( R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN ); @@ -253,7 +254,6 @@ static void r128_do_cce_reset( drm_r128_ { R128_WRITE( R128_PM4_BUFFER_DL_WPTR, 0 ); R128_WRITE( R128_PM4_BUFFER_DL_RPTR, 0 ); - SET_RING_HEAD( &dev_priv->ring, 0 ); dev_priv->ring.tail = 0; } @@ -264,7 +264,8 @@ static void r128_do_cce_reset( drm_r128_ static void r128_do_cce_stop( drm_r128_private_t *dev_priv ) { R128_WRITE( R128_PM4_MICRO_CNTL, 0 ); - R128_WRITE( R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4 ); + R128_WRITE( R128_PM4_BUFFER_CNTL, + R128_PM4_NONPM4 | R128_PM4_BUFFER_CNTL_NOUPDATE ); dev_priv->cce_running = 0; } @@ -333,26 +334,6 @@ static void r128_cce_init_ring_buffer( d R128_WRITE( R128_PM4_BUFFER_DL_WPTR, 0 ); R128_WRITE( R128_PM4_BUFFER_DL_RPTR, 0 ); - /* DL_RPTR_ADDR is a physical address in AGP space. */ - SET_RING_HEAD( &dev_priv->ring, 0 ); - - if ( !dev_priv->is_pci ) { - R128_WRITE( R128_PM4_BUFFER_DL_RPTR_ADDR, - dev_priv->ring_rptr->offset ); - } else { - drm_sg_mem_t *entry = dev->sg; - unsigned long tmp_ofs, page_ofs; - - tmp_ofs = dev_priv->ring_rptr->offset - dev->sg->handle; - page_ofs = tmp_ofs >> PAGE_SHIFT; - - R128_WRITE( R128_PM4_BUFFER_DL_RPTR_ADDR, - entry->busaddr[page_ofs]); - DRM_DEBUG( "ring rptr: offset=0x%08lx handle=0x%08lx\n", - (unsigned long) entry->busaddr[page_ofs], - entry->handle + tmp_ofs ); - } - /* Set watermark control */ R128_WRITE( R128_PM4_BUFFER_WM_CNTL, ((R128_WATERMARK_L/4) << R128_WMA_SHIFT) @@ -486,13 +467,6 @@ static int r128_do_init_cce( drm_device_ return DRM_ERR(EINVAL); } - DRM_FIND_MAP( dev_priv->fb, init->fb_offset ); - if(!dev_priv->fb) { - DRM_ERROR("could not find framebuffer!\n"); - dev->dev_private = (void *)dev_priv; - r128_do_cleanup_cce( dev ); - return DRM_ERR(EINVAL); - } DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset ); if(!dev_priv->mmio) { DRM_ERROR("could not find mmio region!\n"); @@ -567,9 +541,6 @@ static int r128_do_init_cce( drm_device_ #endif dev_priv->cce_buffers_offset = dev->sg->handle; - dev_priv->ring.head = ((__volatile__ u32 *) - dev_priv->ring_rptr->handle); - dev_priv->ring.start = (u32 *)dev_priv->cce_ring->handle; dev_priv->ring.end = ((u32 *)dev_priv->cce_ring->handle + init->ring_size / sizeof(u32)); @@ -580,7 +551,6 @@ static int r128_do_init_cce( drm_device_ (dev_priv->ring.size / sizeof(u32)) - 1; dev_priv->ring.high_mark = 128; - dev_priv->ring.ring_rptr = dev_priv->ring_rptr; dev_priv->sarea_priv->last_frame = 0; R128_WRITE( R128_LAST_FRAME_REG, dev_priv->sarea_priv->last_frame ); @@ -589,8 +559,9 @@ static int r128_do_init_cce( drm_device_ R128_WRITE( R128_LAST_DISPATCH_REG, dev_priv->sarea_priv->last_dispatch ); -#if __REALLY_HAVE_SG +#if __REALLY_HAVE_AGP if ( dev_priv->is_pci ) { +#endif if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart, &dev_priv->bus_pci_gart) ) { DRM_ERROR( "failed to init PCI GART!\n" ); @@ -599,6 +570,7 @@ static int r128_do_init_cce( drm_device_ return DRM_ERR(ENOMEM); } R128_WRITE( R128_PCI_GART_PAGE, dev_priv->bus_pci_gart ); +#if __REALLY_HAVE_AGP } #endif @@ -615,12 +587,12 @@ static int r128_do_init_cce( drm_device_ int r128_do_cleanup_cce( drm_device_t *dev ) { -#if _HAVE_DMA_IRQ +#if __HAVE_IRQ /* Make sure interrupts are disabled here because the uninstall ioctl * may not have been called from userspace and after dev_private * is freed, it's too late. */ - if ( dev->irq ) DRM(irq_uninstall)(dev); + if ( dev->irq_enabled ) DRM(irq_uninstall)(dev); #endif if ( dev->dev_private ) { @@ -901,7 +873,7 @@ int r128_wait_ring( drm_r128_private_t * int i; for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { - r128_update_ring_snapshot( ring ); + r128_update_ring_snapshot( dev_priv ); if ( ring->space >= n ) return 0; DRM_UDELAY( 1 ); --- diff/drivers/char/drm/r128_drv.c 2002-10-16 04:27:48.000000000 +0100 +++ source/drivers/char/drm/r128_drv.c 2004-02-23 13:56:41.000000000 +0000 @@ -47,6 +47,7 @@ #include "drm_fops.h" #include "drm_init.h" #include "drm_ioctl.h" +#include "drm_irq.h" #include "drm_lock.h" #include "drm_memory.h" #include "drm_proc.h" --- diff/drivers/char/drm/r128_drv.h 2003-08-20 14:16:27.000000000 +0100 +++ source/drivers/char/drm/r128_drv.h 2004-02-23 13:56:41.000000000 +0000 @@ -34,8 +34,7 @@ #ifndef __R128_DRV_H__ #define __R128_DRV_H__ -#define GET_RING_HEAD(ring) DRM_READ32( (ring)->ring_rptr, 0 ) /* (ring)->head */ -#define SET_RING_HEAD(ring,val) DRM_WRITE32( (ring)->ring_rptr, 0, (val) ) /* (ring)->head */ +#define GET_RING_HEAD(dev_priv) R128_READ( R128_PM4_BUFFER_DL_RPTR ) typedef struct drm_r128_freelist { unsigned int age; @@ -50,13 +49,11 @@ typedef struct drm_r128_ring_buffer { int size; int size_l2qw; - volatile u32 *head; u32 tail; u32 tail_mask; int space; int high_mark; - drm_local_map_t *ring_rptr; } drm_r128_ring_buffer_t; typedef struct drm_r128_private { @@ -100,7 +97,6 @@ typedef struct drm_r128_private { u32 span_pitch_offset_c; drm_local_map_t *sarea; - drm_local_map_t *fb; drm_local_map_t *mmio; drm_local_map_t *cce_ring; drm_local_map_t *ring_rptr; @@ -132,14 +128,6 @@ extern drm_buf_t *r128_freelist_get( drm extern int r128_wait_ring( drm_r128_private_t *dev_priv, int n ); -static __inline__ void -r128_update_ring_snapshot( drm_r128_ring_buffer_t *ring ) -{ - ring->space = (GET_RING_HEAD( ring ) - ring->tail) * sizeof(u32); - if ( ring->space <= 0 ) - ring->space += ring->size; -} - extern int r128_do_cce_idle( drm_r128_private_t *dev_priv ); extern int r128_do_cleanup_cce( drm_device_t *dev ); extern int r128_do_cleanup_pageflip( drm_device_t *dev ); @@ -279,6 +267,7 @@ extern int r128_cce_indirect( DRM_IOCTL_ # define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28) # define R128_PM4_64BM_64VCBM_64INDBM (8 << 28) # define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28) +# define R128_PM4_BUFFER_CNTL_NOUPDATE (1 << 27) #define R128_PM4_BUFFER_WM_CNTL 0x0708 # define R128_WMA_SHIFT 0 @@ -403,6 +392,15 @@ extern int R128_READ_PLL(drm_device_t *d (pkt) | ((n) << 16)) +static __inline__ void +r128_update_ring_snapshot( drm_r128_private_t *dev_priv ) +{ + drm_r128_ring_buffer_t *ring = &dev_priv->ring; + ring->space = (GET_RING_HEAD( dev_priv ) - ring->tail) * sizeof(u32); + if ( ring->space <= 0 ) + ring->space += ring->size; +} + /* ================================================================ * Misc helper macros */ @@ -412,7 +410,7 @@ do { \ drm_r128_ring_buffer_t *ring = &dev_priv->ring; int i; \ if ( ring->space < ring->high_mark ) { \ for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { \ - r128_update_ring_snapshot( ring ); \ + r128_update_ring_snapshot( dev_priv ); \ if ( ring->space >= ring->high_mark ) \ goto __ring_space_done; \ DRM_UDELAY(1); \ @@ -445,17 +443,10 @@ do { \ * Ring control */ -#if defined(__powerpc__) -#define r128_flush_write_combine() (void) GET_RING_HEAD( &dev_priv->ring ) -#else -#define r128_flush_write_combine() DRM_WRITEMEMORYBARRIER() -#endif - - #define R128_VERBOSE 0 #define RING_LOCALS \ - int write; unsigned int tail_mask; volatile u32 *ring; + int write, _nr; unsigned int tail_mask; volatile u32 *ring; #define BEGIN_RING( n ) do { \ if ( R128_VERBOSE ) { \ @@ -463,9 +454,10 @@ do { \ (n), __FUNCTION__ ); \ } \ if ( dev_priv->ring.space <= (n) * sizeof(u32) ) { \ + COMMIT_RING(); \ r128_wait_ring( dev_priv, (n) * sizeof(u32) ); \ } \ - dev_priv->ring.space -= (n) * sizeof(u32); \ + _nr = n; dev_priv->ring.space -= (n) * sizeof(u32); \ ring = dev_priv->ring.start; \ write = dev_priv->ring.tail; \ tail_mask = dev_priv->ring.tail_mask; \ @@ -488,9 +480,23 @@ do { \ dev_priv->ring.start, \ write * sizeof(u32) ); \ } \ - r128_flush_write_combine(); \ - dev_priv->ring.tail = write; \ - R128_WRITE( R128_PM4_BUFFER_DL_WPTR, write ); \ + if (((dev_priv->ring.tail + _nr) & tail_mask) != write) { \ + DRM_ERROR( \ + "ADVANCE_RING(): mismatch: nr: %x write: %x line: %d\n", \ + ((dev_priv->ring.tail + _nr) & tail_mask), \ + write, __LINE__); \ + } else \ + dev_priv->ring.tail = write; \ +} while (0) + +#define COMMIT_RING() do { \ + if ( R128_VERBOSE ) { \ + DRM_INFO( "COMMIT_RING() tail=0x%06x\n", \ + dev_priv->ring.tail ); \ + } \ + DRM_MEMORYBARRIER(); \ + R128_WRITE( R128_PM4_BUFFER_DL_WPTR, dev_priv->ring.tail ); \ + R128_READ( R128_PM4_BUFFER_DL_WPTR ); \ } while (0) #define OUT_RING( x ) do { \ --- diff/drivers/char/drm/r128_irq.c 2003-05-21 11:50:14.000000000 +0100 +++ source/drivers/char/drm/r128_irq.c 2004-02-23 13:56:41.000000000 +0000 @@ -36,7 +36,7 @@ #include "r128_drm.h" #include "r128_drv.h" -irqreturn_t r128_dma_service( DRM_IRQ_ARGS ) +irqreturn_t r128_irq_handler( DRM_IRQ_ARGS ) { drm_device_t *dev = (drm_device_t *) arg; drm_r128_private_t *dev_priv = --- diff/drivers/char/drm/r128_state.c 2003-08-20 14:16:27.000000000 +0100 +++ source/drivers/char/drm/r128_state.c 2004-02-23 13:56:41.000000000 +0000 @@ -45,7 +45,7 @@ static void r128_emit_clip_rects( drm_r1 RING_LOCALS; DRM_DEBUG( " %s\n", __FUNCTION__ ); - BEGIN_RING( 17 ); + BEGIN_RING( (count < 3? count: 3) * 5 + 2 ); if ( count >= 1 ) { OUT_RING( CCE_PACKET0( R128_AUX1_SC_LEFT, 3 ) ); @@ -1269,6 +1269,7 @@ int r128_cce_clear( DRM_IOCTL_ARGS ) sarea_priv->nbox = R128_NR_SAREA_CLIPRECTS; r128_cce_dispatch_clear( dev, &clear ); + COMMIT_RING(); /* Make sure we restore the 3D state next time. */ @@ -1304,8 +1305,10 @@ int r128_do_cleanup_pageflip( drm_device R128_WRITE( R128_CRTC_OFFSET, dev_priv->crtc_offset ); R128_WRITE( R128_CRTC_OFFSET_CNTL, dev_priv->crtc_offset_cntl ); - if (dev_priv->current_page != 0) + if (dev_priv->current_page != 0) { r128_cce_dispatch_flip( dev ); + COMMIT_RING(); + } dev_priv->page_flipping = 0; return 0; @@ -1330,6 +1333,7 @@ int r128_cce_flip( DRM_IOCTL_ARGS ) r128_cce_dispatch_flip( dev ); + COMMIT_RING(); return 0; } @@ -1351,6 +1355,7 @@ int r128_cce_swap( DRM_IOCTL_ARGS ) dev_priv->sarea_priv->dirty |= (R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS); + COMMIT_RING(); return 0; } @@ -1410,6 +1415,7 @@ int r128_cce_vertex( DRM_IOCTL_ARGS ) r128_cce_dispatch_vertex( dev, buf ); + COMMIT_RING(); return 0; } @@ -1481,6 +1487,7 @@ int r128_cce_indices( DRM_IOCTL_ARGS ) r128_cce_dispatch_indices( dev, buf, elts.start, elts.end, count ); + COMMIT_RING(); return 0; } @@ -1490,6 +1497,7 @@ int r128_cce_blit( DRM_IOCTL_ARGS ) drm_device_dma_t *dma = dev->dma; drm_r128_private_t *dev_priv = dev->dev_private; drm_r128_blit_t blit; + int ret; LOCK_TEST_WITH_RETURN( dev, filp ); @@ -1507,7 +1515,10 @@ int r128_cce_blit( DRM_IOCTL_ARGS ) RING_SPACE_TEST_WITH_RETURN( dev_priv ); VB_AGE_TEST_WITH_RETURN( dev_priv ); - return r128_cce_dispatch_blit( filp, dev, &blit ); + ret = r128_cce_dispatch_blit( filp, dev, &blit ); + + COMMIT_RING(); + return ret; } int r128_cce_depth( DRM_IOCTL_ARGS ) @@ -1515,6 +1526,7 @@ int r128_cce_depth( DRM_IOCTL_ARGS ) DRM_DEVICE; drm_r128_private_t *dev_priv = dev->dev_private; drm_r128_depth_t depth; + int ret; LOCK_TEST_WITH_RETURN( dev, filp ); @@ -1523,18 +1535,20 @@ int r128_cce_depth( DRM_IOCTL_ARGS ) RING_SPACE_TEST_WITH_RETURN( dev_priv ); + ret = DRM_ERR(EINVAL); switch ( depth.func ) { case R128_WRITE_SPAN: - return r128_cce_dispatch_write_span( dev, &depth ); + ret = r128_cce_dispatch_write_span( dev, &depth ); case R128_WRITE_PIXELS: - return r128_cce_dispatch_write_pixels( dev, &depth ); + ret = r128_cce_dispatch_write_pixels( dev, &depth ); case R128_READ_SPAN: - return r128_cce_dispatch_read_span( dev, &depth ); + ret = r128_cce_dispatch_read_span( dev, &depth ); case R128_READ_PIXELS: - return r128_cce_dispatch_read_pixels( dev, &depth ); + ret = r128_cce_dispatch_read_pixels( dev, &depth ); } - return DRM_ERR(EINVAL); + COMMIT_RING(); + return ret; } int r128_cce_stipple( DRM_IOCTL_ARGS ) @@ -1557,6 +1571,7 @@ int r128_cce_stipple( DRM_IOCTL_ARGS ) r128_cce_dispatch_stipple( dev, mask ); + COMMIT_RING(); return 0; } @@ -1632,6 +1647,7 @@ int r128_cce_indirect( DRM_IOCTL_ARGS ) */ r128_cce_dispatch_indirect( dev, buf, indirect.start, indirect.end ); + COMMIT_RING(); return 0; } --- diff/drivers/char/drm/radeon.h 2003-09-30 15:46:12.000000000 +0100 +++ source/drivers/char/drm/radeon.h 2004-02-23 13:56:41.000000000 +0000 @@ -51,7 +51,7 @@ #define DRIVER_DATE "20020828" #define DRIVER_MAJOR 1 -#define DRIVER_MINOR 9 +#define DRIVER_MINOR 10 #define DRIVER_PATCHLEVEL 0 /* Interface history: @@ -81,6 +81,9 @@ * Add 'GET' queries for starting additional clients on different VT's. * 1.9 - Add DRM_IOCTL_RADEON_CP_RESUME ioctl. * Add texture rectangle support for r100. + * 1.10- Add SETPARAM ioctl; first parameter to set is FB_LOCATION, which + * clients use to tell the DRM where they think the framebuffer is + * located in the card's address space */ #define DRIVER_IOCTLS \ [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { radeon_cp_buffers, 1, 0 }, \ @@ -106,10 +109,82 @@ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_ALLOC)] = { radeon_mem_alloc, 1, 0 }, \ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_FREE)] = { radeon_mem_free, 1, 0 }, \ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_INIT_HEAP)] = { radeon_mem_init_heap, 1, 1 }, \ - [DRM_IOCTL_NR(DRM_IOCTL_RADEON_IRQ_EMIT)] = { radeon_irq_emit, 1, 0 }, \ - [DRM_IOCTL_NR(DRM_IOCTL_RADEON_IRQ_WAIT)] = { radeon_irq_wait, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_RADEON_IRQ_EMIT)] = { radeon_irq_emit, 1, 0 }, \ + [DRM_IOCTL_NR(DRM_IOCTL_RADEON_IRQ_WAIT)] = { radeon_irq_wait, 1, 0 }, \ + [DRM_IOCTL_NR(DRM_IOCTL_RADEON_SETPARAM)] = { radeon_cp_setparam, 1, 0 }, \ + +#define DRIVER_PCI_IDS \ + {0x1002, 0x4136, 0, "ATI Radeon RS100 IGP 320M"}, \ + {0x1002, 0x4137, 0, "ATI Radeon RS200 IGP"}, \ + {0x1002, 0x4237, 0, "ATI Radeon RS250 IGP"}, \ + {0x1002, 0x4242, 0, "ATI Radeon BB R200 AIW 8500DV"}, \ + {0x1002, 0x4242, 0, "ATI Radeon BC R200"}, \ + {0x1002, 0x4336, 0, "ATI Radeon RS100 Mobility U1"}, \ + {0x1002, 0x4337, 0, "ATI Radeon RS200 Mobility IGP 340M"}, \ + {0x1002, 0x4437, 0, "ATI Radeon RS250 Mobility IGP"}, \ + {0x1002, 0x4964, 0, "ATI Radeon Id R250 9000"}, \ + {0x1002, 0x4965, 0, "ATI Radeon Ie R250 9000"}, \ + {0x1002, 0x4966, 0, "ATI Radeon If R250 9000"}, \ + {0x1002, 0x4967, 0, "ATI Radeon Ig R250 9000"}, \ + {0x1002, 0x4C57, 0, "ATI Radeon LW Mobility 7500 M7"}, \ + {0x1002, 0x4C58, 0, "ATI Radeon LX RV200 Mobility FireGL 7800 M7"}, \ + {0x1002, 0x4C59, 0, "ATI Radeon LY Mobility M6"}, \ + {0x1002, 0x4C5A, 0, "ATI Radeon LZ Mobility M6"}, \ + {0x1002, 0x4C64, 0, "ATI Radeon Ld R250 Mobility 9000 M9"}, \ + {0x1002, 0x4C65, 0, "ATI Radeon Le R250 Mobility 9000 M9"}, \ + {0x1002, 0x4C66, 0, "ATI Radeon Lf R250 Mobility 9000 M9"}, \ + {0x1002, 0x4C67, 0, "ATI Radeon Lg R250 Mobility 9000 M9"}, \ + {0x1002, 0x5144, 0, "ATI Radeon QD R100"}, \ + {0x1002, 0x5145, 0, "ATI Radeon QE R100"}, \ + {0x1002, 0x5146, 0, "ATI Radeon QF R100"}, \ + {0x1002, 0x5147, 0, "ATI Radeon QG R100"}, \ + {0x1002, 0x5148, 0, "ATI Radeon QH R200 8500"}, \ + {0x1002, 0x5149, 0, "ATI Radeon QI R200"}, \ + {0x1002, 0x514A, 0, "ATI Radeon QJ R200"}, \ + {0x1002, 0x514B, 0, "ATI Radeon QK R200"}, \ + {0x1002, 0x514C, 0, "ATI Radeon QL R200 8500 LE"}, \ + {0x1002, 0x514D, 0, "ATI Radeon QM R200 9100"}, \ + {0x1002, 0x514E, 0, "ATI Radeon QN R200 8500 LE"}, \ + {0x1002, 0x514F, 0, "ATI Radeon QO R200 8500 LE"}, \ + {0x1002, 0x5157, 0, "ATI Radeon QW RV200 7500"}, \ + {0x1002, 0x5158, 0, "ATI Radeon QX RV200 7500"}, \ + {0x1002, 0x5159, 0, "ATI Radeon QY RV100 7000/VE"}, \ + {0x1002, 0x515A, 0, "ATI Radeon QZ RV100 7000/VE"}, \ + {0x1002, 0x5168, 0, "ATI Radeon Qh R200"}, \ + {0x1002, 0x5169, 0, "ATI Radeon Qi R200"}, \ + {0x1002, 0x516A, 0, "ATI Radeon Qj R200"}, \ + {0x1002, 0x516B, 0, "ATI Radeon Qk R200"}, \ + {0x1002, 0x516C, 0, "ATI Radeon Ql R200"}, \ + {0x1002, 0x5834, 0, "ATI Radeon RS300 IGP"}, \ + {0x1002, 0x5835, 0, "ATI Radeon RS300 Mobility IGP"}, \ + {0x1002, 0x5836, 0, "ATI Radeon RS300 IGP"}, \ + {0x1002, 0x5837, 0, "ATI Radeon RS300 IGP"}, \ + {0x1002, 0x5960, 0, "ATI Radeon RV280 9200"}, \ + {0x1002, 0x5961, 0, "ATI Radeon RV280 9200 SE"}, \ + {0x1002, 0x5962, 0, "ATI Radeon RV280 9200"}, \ + {0x1002, 0x5963, 0, "ATI Radeon RV280 9200"}, \ + {0x1002, 0x5964, 0, "ATI Radeon RV280 9200 SE"}, \ + {0x1002, 0x5968, 0, "ATI Radeon RV280 9200"}, \ + {0x1002, 0x5969, 0, "ATI Radeon RV280 9200"}, \ + {0x1002, 0x596A, 0, "ATI Radeon RV280 9200"}, \ + {0x1002, 0x596B, 0, "ATI Radeon RV280 9200"}, \ + {0x1002, 0x5c61, 0, "ATI Radeon RV280 Mobility"}, \ + {0x1002, 0x5c62, 0, "ATI Radeon RV280"}, \ + {0x1002, 0x5c63, 0, "ATI Radeon RV280 Mobility"}, \ + {0x1002, 0x5c64, 0, "ATI Radeon RV280"}, \ + {0, 0, 0, NULL} +#define DRIVER_FILE_FIELDS \ + int64_t radeon_fb_delta; \ +#define DRIVER_OPEN_HELPER( filp_priv, dev ) \ +do { \ + drm_radeon_private_t *dev_priv = dev->dev_private; \ + if ( dev_priv ) \ + filp_priv->radeon_fb_delta = dev_priv->fb_location; \ + else \ + filp_priv->radeon_fb_delta = 0; \ +} while( 0 ) /* When a client dies: * - Check for and clean up flipped page state @@ -125,7 +200,7 @@ do { \ radeon_do_cleanup_pageflip( dev ); \ } \ radeon_mem_release( filp, dev_priv->gart_heap ); \ - radeon_mem_release( filp, dev_priv->fb_heap ); \ + radeon_mem_release( filp, dev_priv->fb_heap ); \ } \ } while (0) @@ -142,7 +217,7 @@ do { \ /* DMA customization: */ #define __HAVE_DMA 1 -#define __HAVE_DMA_IRQ 1 +#define __HAVE_IRQ 1 #define __HAVE_VBL_IRQ 1 #define __HAVE_SHARED_IRQ 1 --- diff/drivers/char/drm/radeon_cp.c 2003-09-30 15:46:12.000000000 +0100 +++ source/drivers/char/drm/radeon_cp.c 2004-02-23 13:56:41.000000000 +0000 @@ -855,7 +855,8 @@ static void radeon_cp_init_ring_buffer( /* Initialize the memory controller */ RADEON_WRITE( RADEON_MC_FB_LOCATION, - (dev_priv->gart_vm_start - 1) & 0xffff0000 ); + ( ( dev_priv->gart_vm_start - 1 ) & 0xffff0000 ) + | ( dev_priv->fb_location >> 16 ) ); #if __REALLY_HAVE_AGP if ( !dev_priv->is_pci ) { @@ -1071,13 +1072,6 @@ static int radeon_do_init_cp( drm_device dev_priv->depth_offset = init->depth_offset; dev_priv->depth_pitch = init->depth_pitch; - dev_priv->front_pitch_offset = (((dev_priv->front_pitch/64) << 22) | - (dev_priv->front_offset >> 10)); - dev_priv->back_pitch_offset = (((dev_priv->back_pitch/64) << 22) | - (dev_priv->back_offset >> 10)); - dev_priv->depth_pitch_offset = (((dev_priv->depth_pitch/64) << 22) | - (dev_priv->depth_offset >> 10)); - /* Hardware state for depth clears. Remove this if/when we no * longer clear the depth buffer with a 3D rectangle. Hard-code * all values to prevent unwanted 3D state from slipping through @@ -1124,13 +1118,6 @@ static int radeon_do_init_cp( drm_device return DRM_ERR(EINVAL); } - DRM_FIND_MAP( dev_priv->fb, init->fb_offset ); - if(!dev_priv->fb) { - DRM_ERROR("could not find framebuffer!\n"); - dev->dev_private = (void *)dev_priv; - radeon_do_cleanup_cp(dev); - return DRM_ERR(EINVAL); - } DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset ); if(!dev_priv->mmio) { DRM_ERROR("could not find mmio region!\n"); @@ -1204,9 +1191,26 @@ static int radeon_do_init_cp( drm_device dev_priv->buffers->handle ); } + dev_priv->fb_location = ( RADEON_READ( RADEON_MC_FB_LOCATION ) + & 0xffff ) << 16; + + dev_priv->front_pitch_offset = (((dev_priv->front_pitch/64) << 22) | + ( ( dev_priv->front_offset + + dev_priv->fb_location ) >> 10 ) ); + + dev_priv->back_pitch_offset = (((dev_priv->back_pitch/64) << 22) | + ( ( dev_priv->back_offset + + dev_priv->fb_location ) >> 10 ) ); + + dev_priv->depth_pitch_offset = (((dev_priv->depth_pitch/64) << 22) | + ( ( dev_priv->depth_offset + + dev_priv->fb_location ) >> 10 ) ); + dev_priv->gart_size = init->gart_size; - dev_priv->gart_vm_start = RADEON_READ( RADEON_CONFIG_APER_SIZE ); + dev_priv->gart_vm_start = dev_priv->fb_location + + RADEON_READ( RADEON_CONFIG_APER_SIZE ); + #if __REALLY_HAVE_AGP if ( !dev_priv->is_pci ) dev_priv->gart_buffers_offset = (dev_priv->buffers->offset @@ -1271,12 +1275,12 @@ int radeon_do_cleanup_cp( drm_device_t * { DRM_DEBUG( "\n" ); -#if _HAVE_DMA_IRQ +#if __HAVE_IRQ /* Make sure interrupts are disabled here because the uninstall ioctl * may not have been called from userspace and after dev_private * is freed, it's too late. */ - if ( dev->irq ) DRM(irq_uninstall)(dev); + if ( dev->irq_enabled ) DRM(irq_uninstall)(dev); #endif if ( dev->dev_private ) { --- diff/drivers/char/drm/radeon_drm.h 2003-09-30 15:46:12.000000000 +0100 +++ source/drivers/char/drm/radeon_drm.h 2004-02-23 13:56:41.000000000 +0000 @@ -390,6 +390,7 @@ typedef struct { #define DRM_IOCTL_RADEON_IRQ_WAIT DRM_IOW( 0x57, drm_radeon_irq_wait_t) /* added by Charl P. Botha - see radeon_cp.c for details */ #define DRM_IOCTL_RADEON_CP_RESUME DRM_IO(0x58) +#define DRM_IOCTL_RADEON_SETPARAM DRM_IOW(0x59, drm_radeon_setparam_t) typedef struct drm_radeon_init { enum { @@ -502,7 +503,7 @@ typedef struct drm_radeon_tex_image { } drm_radeon_tex_image_t; typedef struct drm_radeon_texture { - int offset; + unsigned int offset; int pitch; int format; int width; /* Texture image coordinates */ @@ -537,6 +538,7 @@ typedef struct drm_radeon_indirect { #define RADEON_PARAM_STATUS_HANDLE 8 #define RADEON_PARAM_SAREA_HANDLE 9 #define RADEON_PARAM_GART_TEX_HANDLE 10 +#define RADEON_PARAM_SCRATCH_OFFSET 11 typedef struct drm_radeon_getparam { int param; @@ -578,4 +580,16 @@ typedef struct drm_radeon_irq_wait { } drm_radeon_irq_wait_t; +/* 1.10: Clients tell the DRM where they think the framebuffer is located in + * the card's address space, via a new generic ioctl to set parameters + */ + +typedef struct drm_radeon_setparam { + unsigned int param; + int64_t value; +} drm_radeon_setparam_t; + +#define RADEON_SETPARAM_FB_LOCATION 1 /* determined framebuffer location */ + + #endif --- diff/drivers/char/drm/radeon_drv.c 2003-07-22 18:54:27.000000000 +0100 +++ source/drivers/char/drm/radeon_drv.c 2004-02-23 13:56:41.000000000 +0000 @@ -48,6 +48,7 @@ #include "drm_fops.h" #include "drm_init.h" #include "drm_ioctl.h" +#include "drm_irq.h" #include "drm_lock.h" #include "drm_memory.h" #include "drm_proc.h" --- diff/drivers/char/drm/radeon_drv.h 2003-09-30 15:46:12.000000000 +0100 +++ source/drivers/char/drm/radeon_drv.h 2004-02-23 13:56:41.000000000 +0000 @@ -73,6 +73,8 @@ typedef struct drm_radeon_private { drm_radeon_ring_buffer_t ring; drm_radeon_sarea_t *sarea_priv; + u32 fb_location; + int gart_size; u32 gart_vm_start; unsigned long gart_buffers_offset; @@ -133,7 +135,6 @@ typedef struct drm_radeon_private { unsigned long gart_textures_offset; drm_local_map_t *sarea; - drm_local_map_t *fb; drm_local_map_t *mmio; drm_local_map_t *cp_ring; drm_local_map_t *ring_rptr; @@ -184,6 +185,7 @@ extern int radeon_cp_indirect( DRM_IOCTL extern int radeon_cp_vertex2( DRM_IOCTL_ARGS ); extern int radeon_cp_cmdbuf( DRM_IOCTL_ARGS ); extern int radeon_cp_getparam( DRM_IOCTL_ARGS ); +extern int radeon_cp_setparam( DRM_IOCTL_ARGS ); extern int radeon_cp_flip( DRM_IOCTL_ARGS ); extern int radeon_mem_alloc( DRM_IOCTL_ARGS ); @@ -239,6 +241,7 @@ extern void radeon_do_release(drm_device #define RADEON_CRTC2_OFFSET 0x0324 #define RADEON_CRTC2_OFFSET_CNTL 0x0328 +#define RADEON_RB3D_COLOROFFSET 0x1c40 #define RADEON_RB3D_COLORPITCH 0x1c48 #define RADEON_DP_GUI_MASTER_CNTL 0x146c @@ -332,6 +335,7 @@ extern void radeon_do_release(drm_device #define RADEON_PP_MISC 0x1c14 #define RADEON_PP_ROT_MATRIX_0 0x1d58 #define RADEON_PP_TXFILTER_0 0x1c54 +#define RADEON_PP_TXOFFSET_0 0x1c5c #define RADEON_PP_TXFILTER_1 0x1c6c #define RADEON_PP_TXFILTER_2 0x1c84 --- diff/drivers/char/drm/radeon_irq.c 2003-05-21 11:50:14.000000000 +0100 +++ source/drivers/char/drm/radeon_irq.c 2004-02-23 13:56:41.000000000 +0000 @@ -54,7 +54,7 @@ * tied to dma at all, this is just a hangover from dri prehistory. */ -irqreturn_t DRM(dma_service)( DRM_IRQ_ARGS ) +irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS ) { drm_device_t *dev = (drm_device_t *) arg; drm_radeon_private_t *dev_priv = --- diff/drivers/char/drm/radeon_state.c 2004-02-18 08:54:09.000000000 +0000 +++ source/drivers/char/drm/radeon_state.c 2004-02-23 13:56:41.000000000 +0000 @@ -36,6 +36,151 @@ /* ================================================================ + * Helper functions for client state checking and fixup + */ + +static __inline__ int radeon_check_and_fixup_offset( drm_radeon_private_t *dev_priv, + drm_file_t *filp_priv, + u32 *offset ) { + u32 off = *offset; + + if ( off >= dev_priv->fb_location && + off < ( dev_priv->gart_vm_start + dev_priv->gart_size ) ) + return 0; + + off += filp_priv->radeon_fb_delta; + + DRM_DEBUG( "offset fixed up to 0x%x\n", off ); + + if ( off < dev_priv->fb_location || + off >= ( dev_priv->gart_vm_start + dev_priv->gart_size ) ) + return DRM_ERR( EINVAL ); + + *offset = off; + + return 0; +} + +static __inline__ int radeon_check_and_fixup_offset_user( drm_radeon_private_t *dev_priv, + drm_file_t *filp_priv, + u32 *offset ) { + u32 off; + + DRM_GET_USER_UNCHECKED( off, offset ); + + if ( radeon_check_and_fixup_offset( dev_priv, filp_priv, &off ) ) + return DRM_ERR( EINVAL ); + + DRM_PUT_USER_UNCHECKED( offset, off ); + + return 0; +} + +static __inline__ int radeon_check_and_fixup_packets( drm_radeon_private_t *dev_priv, + drm_file_t *filp_priv, + int id, + u32 *data ) { + if ( id == RADEON_EMIT_PP_MISC && + radeon_check_and_fixup_offset_user( dev_priv, filp_priv, + &data[( RADEON_RB3D_DEPTHOFFSET + - RADEON_PP_MISC ) / 4] ) ) { + DRM_ERROR( "Invalid depth buffer offset\n" ); + return DRM_ERR( EINVAL ); + } else if ( id == RADEON_EMIT_PP_CNTL && + radeon_check_and_fixup_offset_user( dev_priv, filp_priv, + &data[( RADEON_RB3D_COLOROFFSET + - RADEON_PP_CNTL ) / 4] ) ) { + DRM_ERROR( "Invalid colour buffer offset\n" ); + return DRM_ERR( EINVAL ); + } else if ( id >= R200_EMIT_PP_TXOFFSET_0 && + id <= R200_EMIT_PP_TXOFFSET_5 && + radeon_check_and_fixup_offset_user( dev_priv, filp_priv, + &data[0] ) ) { + DRM_ERROR( "Invalid R200 texture offset\n" ); + return DRM_ERR( EINVAL ); + } else if ( ( id == RADEON_EMIT_PP_TXFILTER_0 || id == RADEON_EMIT_PP_TXFILTER_1 || + id == RADEON_EMIT_PP_TXFILTER_2 /*|| id == RADEON_EMIT_PP_TXFILTER_3 || + id == RADEON_EMIT_PP_TXFILTER_4 || id == RADEON_EMIT_PP_TXFILTER_5*/ ) && + radeon_check_and_fixup_offset_user( dev_priv, filp_priv, + &data[( RADEON_PP_TXOFFSET_0 + - RADEON_PP_TXFILTER_0 ) / 4] ) ) { + DRM_ERROR( "Invalid R100 texture offset\n" ); + return DRM_ERR( EINVAL ); + } else if ( id == R200_PP_CUBIC_OFFSET_F1_0 || id == R200_PP_CUBIC_OFFSET_F1_1 || + id == R200_PP_CUBIC_OFFSET_F1_2 || id == R200_PP_CUBIC_OFFSET_F1_3 || + id == R200_PP_CUBIC_OFFSET_F1_4 || id == R200_PP_CUBIC_OFFSET_F1_5 ) { + int i; + for ( i = 0; i < 6; i++ ) { + if ( radeon_check_and_fixup_offset_user( dev_priv, + filp_priv, + &data[i] ) ) { + DRM_ERROR( "Invalid R200 cubic texture offset\n" ); + return DRM_ERR( EINVAL ); + } + } + } + + return 0; +} + +static __inline__ int radeon_check_and_fixup_packet3( drm_radeon_private_t *dev_priv, + drm_file_t *filp_priv, + drm_radeon_cmd_buffer_t *cmdbuf, + unsigned int *cmdsz ) { + u32 tmp[4], *cmd = ( u32* )cmdbuf->buf; + + if ( DRM_COPY_FROM_USER_UNCHECKED( tmp, cmd, sizeof( tmp ) ) ) { + DRM_ERROR( "Failed to copy data from user space\n" ); + return DRM_ERR( EFAULT ); + } + + *cmdsz = 2 + ( ( tmp[0] & RADEON_CP_PACKET_COUNT_MASK ) >> 16 ); + + if ( ( tmp[0] & 0xc0000000 ) != RADEON_CP_PACKET3 ) { + DRM_ERROR( "Not a type 3 packet\n" ); + return DRM_ERR( EINVAL ); + } + + if ( 4 * *cmdsz > cmdbuf->bufsz ) { + DRM_ERROR( "Packet size larger than size of data provided\n" ); + return DRM_ERR( EINVAL ); + } + + /* Check client state and fix it up if necessary */ + if ( tmp[0] & 0x8000 ) { /* MSB of opcode: next DWORD GUI_CNTL */ + u32 offset; + + if ( tmp[1] & ( RADEON_GMC_SRC_PITCH_OFFSET_CNTL + | RADEON_GMC_DST_PITCH_OFFSET_CNTL ) ) { + offset = tmp[2] << 10; + if ( radeon_check_and_fixup_offset( dev_priv, filp_priv, &offset ) ) { + DRM_ERROR( "Invalid first packet offset\n" ); + return DRM_ERR( EINVAL ); + } + tmp[2] = ( tmp[2] & 0xffc00000 ) | offset >> 10; + } + + if ( ( tmp[1] & RADEON_GMC_SRC_PITCH_OFFSET_CNTL ) && + ( tmp[1] & RADEON_GMC_DST_PITCH_OFFSET_CNTL ) ) { + offset = tmp[3] << 10; + if ( radeon_check_and_fixup_offset( dev_priv, filp_priv, &offset ) ) { + DRM_ERROR( "Invalid second packet offset\n" ); + return DRM_ERR( EINVAL ); + } + tmp[3] = ( tmp[3] & 0xffc00000 ) | offset >> 10; + } + + if ( DRM_COPY_TO_USER_UNCHECKED( cmd, tmp, sizeof( tmp ) ) ) { + DRM_ERROR( "Failed to copy data to user space\n" ); + return DRM_ERR( EFAULT ); + } + } + + return 0; +} + + +/* ================================================================ * CP hardware state programming functions */ @@ -57,15 +202,28 @@ static __inline__ void radeon_emit_clip_ /* Emit 1.1 state */ -static void radeon_emit_state( drm_radeon_private_t *dev_priv, - drm_radeon_context_regs_t *ctx, - drm_radeon_texture_regs_t *tex, - unsigned int dirty ) +static int radeon_emit_state( drm_radeon_private_t *dev_priv, + drm_file_t *filp_priv, + drm_radeon_context_regs_t *ctx, + drm_radeon_texture_regs_t *tex, + unsigned int dirty ) { RING_LOCALS; DRM_DEBUG( "dirty=0x%08x\n", dirty ); if ( dirty & RADEON_UPLOAD_CONTEXT ) { + if ( radeon_check_and_fixup_offset( dev_priv, filp_priv, + &ctx->rb3d_depthoffset ) ) { + DRM_ERROR( "Invalid depth buffer offset\n" ); + return DRM_ERR( EINVAL ); + } + + if ( radeon_check_and_fixup_offset( dev_priv, filp_priv, + &ctx->rb3d_coloroffset ) ) { + DRM_ERROR( "Invalid depth buffer offset\n" ); + return DRM_ERR( EINVAL ); + } + BEGIN_RING( 14 ); OUT_RING( CP_PACKET0( RADEON_PP_MISC, 6 ) ); OUT_RING( ctx->pp_misc ); @@ -149,6 +307,12 @@ static void radeon_emit_state( drm_radeo } if ( dirty & RADEON_UPLOAD_TEX0 ) { + if ( radeon_check_and_fixup_offset( dev_priv, filp_priv, + &tex[0].pp_txoffset ) ) { + DRM_ERROR( "Invalid texture offset for unit 0\n" ); + return DRM_ERR( EINVAL ); + } + BEGIN_RING( 9 ); OUT_RING( CP_PACKET0( RADEON_PP_TXFILTER_0, 5 ) ); OUT_RING( tex[0].pp_txfilter ); @@ -163,6 +327,12 @@ static void radeon_emit_state( drm_radeo } if ( dirty & RADEON_UPLOAD_TEX1 ) { + if ( radeon_check_and_fixup_offset( dev_priv, filp_priv, + &tex[1].pp_txoffset ) ) { + DRM_ERROR( "Invalid texture offset for unit 1\n" ); + return DRM_ERR( EINVAL ); + } + BEGIN_RING( 9 ); OUT_RING( CP_PACKET0( RADEON_PP_TXFILTER_1, 5 ) ); OUT_RING( tex[1].pp_txfilter ); @@ -177,6 +347,12 @@ static void radeon_emit_state( drm_radeo } if ( dirty & RADEON_UPLOAD_TEX2 ) { + if ( radeon_check_and_fixup_offset( dev_priv, filp_priv, + &tex[2].pp_txoffset ) ) { + DRM_ERROR( "Invalid texture offset for unit 2\n" ); + return DRM_ERR( EINVAL ); + } + BEGIN_RING( 9 ); OUT_RING( CP_PACKET0( RADEON_PP_TXFILTER_2, 5 ) ); OUT_RING( tex[2].pp_txfilter ); @@ -189,12 +365,15 @@ static void radeon_emit_state( drm_radeo OUT_RING( tex[2].pp_border_color ); ADVANCE_RING(); } + + return 0; } /* Emit 1.2 state */ -static void radeon_emit_state2( drm_radeon_private_t *dev_priv, - drm_radeon_state_t *state ) +static int radeon_emit_state2( drm_radeon_private_t *dev_priv, + drm_file_t *filp_priv, + drm_radeon_state_t *state ) { RING_LOCALS; @@ -206,7 +385,7 @@ static void radeon_emit_state2( drm_rade ADVANCE_RING(); } - radeon_emit_state( dev_priv, &state->context, + return radeon_emit_state( dev_priv, filp_priv, &state->context, state->tex, state->dirty ); } @@ -1065,6 +1244,7 @@ static int radeon_cp_dispatch_texture( D drm_radeon_tex_image_t *image ) { drm_radeon_private_t *dev_priv = dev->dev_private; + drm_file_t *filp_priv; drm_buf_t *buf; u32 format; u32 *buffer; @@ -1074,6 +1254,13 @@ static int radeon_cp_dispatch_texture( D int i; RING_LOCALS; + DRM_GET_PRIV_WITH_RETURN( filp_priv, filp ); + + if ( radeon_check_and_fixup_offset( dev_priv, filp_priv, &tex->offset ) ) { + DRM_ERROR( "Invalid destination offset\n" ); + return DRM_ERR( EINVAL ); + } + dev_priv->stats.boxes |= RADEON_BOX_TEXTURE_LOAD; /* Flush the pixel cache. This ensures no pixel data gets mixed @@ -1377,6 +1564,7 @@ int radeon_cp_vertex( DRM_IOCTL_ARGS ) { DRM_DEVICE; drm_radeon_private_t *dev_priv = dev->dev_private; + drm_file_t *filp_priv; drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; drm_device_dma_t *dma = dev->dma; drm_buf_t *buf; @@ -1390,6 +1578,8 @@ int radeon_cp_vertex( DRM_IOCTL_ARGS ) return DRM_ERR(EINVAL); } + DRM_GET_PRIV_WITH_RETURN( filp_priv, filp ); + DRM_COPY_FROM_USER_IOCTL( vertex, (drm_radeon_vertex_t *)data, sizeof(vertex) ); @@ -1429,11 +1619,14 @@ int radeon_cp_vertex( DRM_IOCTL_ARGS ) buf->used = vertex.count; /* not used? */ if ( sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS ) { - radeon_emit_state( dev_priv, - &sarea_priv->context_state, - sarea_priv->tex_state, - sarea_priv->dirty ); - + if ( radeon_emit_state( dev_priv, filp_priv, + &sarea_priv->context_state, + sarea_priv->tex_state, + sarea_priv->dirty ) ) { + DRM_ERROR( "radeon_emit_state failed\n" ); + return DRM_ERR( EINVAL ); + } + sarea_priv->dirty &= ~(RADEON_UPLOAD_TEX0IMAGES | RADEON_UPLOAD_TEX1IMAGES | RADEON_UPLOAD_TEX2IMAGES | @@ -1461,6 +1654,7 @@ int radeon_cp_indices( DRM_IOCTL_ARGS ) { DRM_DEVICE; drm_radeon_private_t *dev_priv = dev->dev_private; + drm_file_t *filp_priv; drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; drm_device_dma_t *dma = dev->dma; drm_buf_t *buf; @@ -1475,6 +1669,8 @@ int radeon_cp_indices( DRM_IOCTL_ARGS ) return DRM_ERR(EINVAL); } + DRM_GET_PRIV_WITH_RETURN( filp_priv, filp ); + DRM_COPY_FROM_USER_IOCTL( elts, (drm_radeon_indices_t *)data, sizeof(elts) ); @@ -1523,10 +1719,13 @@ int radeon_cp_indices( DRM_IOCTL_ARGS ) buf->used = elts.end; if ( sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS ) { - radeon_emit_state( dev_priv, - &sarea_priv->context_state, - sarea_priv->tex_state, - sarea_priv->dirty ); + if ( radeon_emit_state( dev_priv, filp_priv, + &sarea_priv->context_state, + sarea_priv->tex_state, + sarea_priv->dirty ) ) { + DRM_ERROR( "radeon_emit_state failed\n" ); + return DRM_ERR( EINVAL ); + } sarea_priv->dirty &= ~(RADEON_UPLOAD_TEX0IMAGES | RADEON_UPLOAD_TEX1IMAGES | @@ -1686,6 +1885,7 @@ int radeon_cp_vertex2( DRM_IOCTL_ARGS ) { DRM_DEVICE; drm_radeon_private_t *dev_priv = dev->dev_private; + drm_file_t *filp_priv; drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; drm_device_dma_t *dma = dev->dma; drm_buf_t *buf; @@ -1700,6 +1900,8 @@ int radeon_cp_vertex2( DRM_IOCTL_ARGS ) return DRM_ERR(EINVAL); } + DRM_GET_PRIV_WITH_RETURN( filp_priv, filp ); + DRM_COPY_FROM_USER_IOCTL( vertex, (drm_radeon_vertex2_t *)data, sizeof(vertex) ); @@ -1747,7 +1949,10 @@ int radeon_cp_vertex2( DRM_IOCTL_ARGS ) sizeof(state) ) ) return DRM_ERR(EFAULT); - radeon_emit_state2( dev_priv, &state ); + if ( radeon_emit_state2( dev_priv, filp_priv, &state ) ) { + DRM_ERROR( "radeon_emit_state2 failed\n" ); + return DRM_ERR( EINVAL ); + } laststate = prim.stateidx; } @@ -1784,6 +1989,7 @@ int radeon_cp_vertex2( DRM_IOCTL_ARGS ) static int radeon_emit_packets( drm_radeon_private_t *dev_priv, + drm_file_t *filp_priv, drm_radeon_cmd_header_t header, drm_radeon_cmd_buffer_t *cmdbuf ) { @@ -1798,8 +2004,15 @@ static int radeon_emit_packets( sz = packet[id].len; reg = packet[id].start; - if (sz * sizeof(int) > cmdbuf->bufsz) + if (sz * sizeof(int) > cmdbuf->bufsz) { + DRM_ERROR( "Packet size provided larger than data provided\n" ); return DRM_ERR(EINVAL); + } + + if ( radeon_check_and_fixup_packets( dev_priv, filp_priv, id, data ) ) { + DRM_ERROR( "Packet verification failed\n" ); + return DRM_ERR( EINVAL ); + } BEGIN_RING(sz+1); OUT_RING( CP_PACKET0( reg, (sz-1) ) ); @@ -1882,24 +2095,21 @@ static __inline__ int radeon_emit_vector static int radeon_emit_packet3( drm_device_t *dev, + drm_file_t *filp_priv, drm_radeon_cmd_buffer_t *cmdbuf ) { drm_radeon_private_t *dev_priv = dev->dev_private; - int cmdsz, tmp; - int *cmd = (int *)cmdbuf->buf; + unsigned int cmdsz; + int *cmd = (int *)cmdbuf->buf, ret; RING_LOCALS; - DRM_DEBUG("\n"); - if (DRM_GET_USER_UNCHECKED( tmp, &cmd[0])) - return DRM_ERR(EFAULT); - - cmdsz = 2 + ((tmp & RADEON_CP_PACKET_COUNT_MASK) >> 16); - - if ((tmp & 0xc0000000) != RADEON_CP_PACKET3 || - cmdsz * 4 > cmdbuf->bufsz) - return DRM_ERR(EINVAL); + if ( ( ret = radeon_check_and_fixup_packet3( dev_priv, filp_priv, + cmdbuf, &cmdsz ) ) ) { + DRM_ERROR( "Packet verification failed\n" ); + return ret; + } BEGIN_RING( cmdsz ); OUT_RING_USER_TABLE( cmd, cmdsz ); @@ -1912,27 +2122,25 @@ static int radeon_emit_packet3( drm_devi static int radeon_emit_packet3_cliprect( drm_device_t *dev, + drm_file_t *filp_priv, drm_radeon_cmd_buffer_t *cmdbuf, int orig_nbox ) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_clip_rect_t box; - int cmdsz, tmp; - int *cmd = (int *)cmdbuf->buf; + unsigned int cmdsz; + int *cmd = (int *)cmdbuf->buf, ret; drm_clip_rect_t *boxes = cmdbuf->boxes; int i = 0; RING_LOCALS; DRM_DEBUG("\n"); - if (DRM_GET_USER_UNCHECKED( tmp, &cmd[0])) - return DRM_ERR(EFAULT); - - cmdsz = 2 + ((tmp & RADEON_CP_PACKET_COUNT_MASK) >> 16); - - if ((tmp & 0xc0000000) != RADEON_CP_PACKET3 || - cmdsz * 4 > cmdbuf->bufsz) - return DRM_ERR(EINVAL); + if ( ( ret = radeon_check_and_fixup_packet3( dev_priv, filp_priv, + cmdbuf, &cmdsz ) ) ) { + DRM_ERROR( "Packet verification failed\n" ); + return ret; + } if (!orig_nbox) goto out; @@ -2009,6 +2217,7 @@ int radeon_cp_cmdbuf( DRM_IOCTL_ARGS ) { DRM_DEVICE; drm_radeon_private_t *dev_priv = dev->dev_private; + drm_file_t *filp_priv; drm_device_dma_t *dma = dev->dma; drm_buf_t *buf = 0; int idx; @@ -2023,6 +2232,8 @@ int radeon_cp_cmdbuf( DRM_IOCTL_ARGS ) return DRM_ERR(EINVAL); } + DRM_GET_PRIV_WITH_RETURN( filp_priv, filp ); + DRM_COPY_FROM_USER_IOCTL( cmdbuf, (drm_radeon_cmd_buffer_t *)data, sizeof(cmdbuf) ); @@ -2053,7 +2264,7 @@ int radeon_cp_cmdbuf( DRM_IOCTL_ARGS ) switch (header.header.cmd_type) { case RADEON_CMD_PACKET: DRM_DEBUG("RADEON_CMD_PACKET\n"); - if (radeon_emit_packets( dev_priv, header, &cmdbuf )) { + if (radeon_emit_packets( dev_priv, filp_priv, header, &cmdbuf )) { DRM_ERROR("radeon_emit_packets failed\n"); return DRM_ERR(EINVAL); } @@ -2096,7 +2307,7 @@ int radeon_cp_cmdbuf( DRM_IOCTL_ARGS ) case RADEON_CMD_PACKET3: DRM_DEBUG("RADEON_CMD_PACKET3\n"); - if (radeon_emit_packet3( dev, &cmdbuf )) { + if (radeon_emit_packet3( dev, filp_priv, &cmdbuf )) { DRM_ERROR("radeon_emit_packet3 failed\n"); return DRM_ERR(EINVAL); } @@ -2104,7 +2315,7 @@ int radeon_cp_cmdbuf( DRM_IOCTL_ARGS ) case RADEON_CMD_PACKET3_CLIP: DRM_DEBUG("RADEON_CMD_PACKET3_CLIP\n"); - if (radeon_emit_packet3_cliprect( dev, &cmdbuf, orig_nbox )) { + if (radeon_emit_packet3_cliprect( dev, filp_priv, &cmdbuf, orig_nbox )) { DRM_ERROR("radeon_emit_packet3_clip failed\n"); return DRM_ERR(EINVAL); } @@ -2214,3 +2425,31 @@ int radeon_cp_getparam( DRM_IOCTL_ARGS ) return 0; } + +int radeon_cp_setparam( DRM_IOCTL_ARGS ) { + DRM_DEVICE; + drm_radeon_private_t *dev_priv = dev->dev_private; + drm_file_t *filp_priv; + drm_radeon_setparam_t sp; + + if ( !dev_priv ) { + DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ ); + return DRM_ERR( EINVAL ); + } + + DRM_GET_PRIV_WITH_RETURN( filp_priv, filp ); + + DRM_COPY_FROM_USER_IOCTL( sp, ( drm_radeon_setparam_t* )data, + sizeof( sp ) ); + + switch( sp.param ) { + case RADEON_SETPARAM_FB_LOCATION: + filp_priv->radeon_fb_delta = dev_priv->fb_location - sp.value; + break; + default: + DRM_DEBUG( "Invalid parameter %d\n", sp.param ); + return DRM_ERR( EINVAL ); + } + + return 0; +} --- diff/drivers/char/drm/sis.h 2003-09-30 15:46:12.000000000 +0100 +++ source/drivers/char/drm/sis.h 2004-02-23 13:56:41.000000000 +0000 @@ -62,6 +62,13 @@ [DRM_IOCTL_NR(DRM_IOCTL_SIS_AGP_FREE)] = { sis_ioctl_agp_free, 1, 0 }, \ [DRM_IOCTL_NR(DRM_IOCTL_SIS_FB_INIT)] = { sis_fb_init, 1, 1 } +#define DRIVER_PCI_IDS \ + {0x1039, 0x0300, 0, "SiS 300/305"}, \ + {0x1039, 0x5300, 0, "SiS 540"}, \ + {0x1039, 0x6300, 0, "SiS 630"}, \ + {0x1039, 0x7300, 0, "SiS 730"}, \ + {0, 0, 0, NULL} + #define __HAVE_COUNTERS 5 /* Buffer customization: --- diff/drivers/char/drm/sis_mm.c 2003-09-30 15:46:12.000000000 +0100 +++ source/drivers/char/drm/sis_mm.c 2004-02-23 13:56:41.000000000 +0000 @@ -34,7 +34,11 @@ #include "sis_drv.h" #include "sis_ds.h" #if defined(__linux__) && defined(CONFIG_FB_SIS) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) #include