diff -u --recursive --new-file v2.2.7/linux/Documentation/00-INDEX linux/Documentation/00-INDEX --- v2.2.7/linux/Documentation/00-INDEX Tue Feb 23 15:21:31 1999 +++ linux/Documentation/00-INDEX Thu Apr 29 11:53:41 1999 @@ -38,7 +38,7 @@ digiepca.txt - info on Digi Intl. {PC,PCI,EISA}Xx and Xem series cards. exception.txt - - how linux v2.1 handles exceptions without verify_area etc. + - how Linux v2.2 handles exceptions without verify_area etc. filesystems/ - directory with info on the various filesystems that Linux supports. ftape.txt @@ -52,11 +52,11 @@ ioctl-number.txt - how to implement and register device/driver ioctl calls. isdn/ - - directory with info on the linux ISDN support, and supported cards. + - directory with info on the Linux ISDN support, and supported cards. java.txt - info on the in-kernel binary support for Java(tm) joystick.txt - - info on using joystick devices (and driver) with linux. + - info on using joystick devices (and driver) with Linux. kbuild/ - directory with info about the kernel build process kmod.txt @@ -72,7 +72,7 @@ magic-number.txt - list of magic numbers used to mark/protect kernel data structures. mandatory.txt - - info on the linux implementation of Sys V mandatory file locking. + - info on the Linux implementation of Sys V mandatory file locking. mca.txt - info on supporting Micro Channel Architecture (e.g. PS/2) systems. md.txt @@ -100,7 +100,7 @@ pcwd-watchdog.txt - info and sample code for using with the PC Watchdog reset card. powerpc/ - - directory with info on using linux with the PowerPC. + - directory with info on using Linux with the PowerPC. ramdisk.txt - short guide on how to set up and use the RAM disk. riscom8.txt @@ -110,7 +110,7 @@ scsi.txt - short blurb on using SCSI support as a module. serial-console.txt - - how to set up linux with a serial line console as the default. + - how to set up Linux with a serial line console as the default. smart-config.txt - description of the Smart Config makefile feature. smp.tex diff -u --recursive --new-file v2.2.7/linux/Documentation/ARM-README linux/Documentation/ARM-README --- v2.2.7/linux/Documentation/ARM-README Sun Jun 7 11:16:25 1998 +++ linux/Documentation/ARM-README Thu Apr 29 11:53:41 1999 @@ -70,8 +70,8 @@ a 'make zImage' instead of 'make all'. -Bug reports etc ---------------- +Bug reports etc. +---------------- Please send patches, bug reports and code for the ARM Linux project to linux@arm.uk.linux.org. Patches will not be included into future @@ -116,7 +116,7 @@ at the top of the screen. The colours have the following significance when run in a 16 colour mode with the default palette: - Stripes of White,Red,Yellow,Green: + Stripes of white, red, yellow, and green: Kernel does not support the processor architecture detected. @@ -142,11 +142,11 @@ HDC base to the source. As of 31/3/96 it works with two drives (you should get the ADFS - *configure harddrive set to 2). I've got an internal 20MB and a great - big external 5.25" FH 64MB drive (who could ever want more :-) ). + *configure hard drive set to 2). I've got an internal 20 MB and a great + big external 5.25" FH 64 MB drive (who could ever want more :-) ). - I've just got 240K/s off it (a dd with bs=128k); thats about half of what - RiscOS gets; but it's a heck of a lot better than the 50K/s I was getting + I've just got 240 K/s off it (a dd with bs=128k); that's about half of what + RiscOS gets, but it's a heck of a lot better than the 50 K/s I was getting last week :-) Known bug: Drive data errors can cause a hang; including cases where diff -u --recursive --new-file v2.2.7/linux/Documentation/Changes linux/Documentation/Changes --- v2.2.7/linux/Documentation/Changes Fri Apr 16 14:47:30 1999 +++ linux/Documentation/Changes Fri May 7 09:31:25 1999 @@ -105,7 +105,7 @@ none /dev/pts devpts gid=5,mode=620 0 0 - (Note: gid=5 is applicable for RedHat systems for which group "tty" has + (Note: gid=5 is applicable for Red Hat systems for which group "tty" has gid 5. Adjust according to your distribution. Use mode=600 if you want "mesg n" to be default.) - Mount /dev/pts @@ -433,7 +433,7 @@ Xosview ======= - /proc interface changes require a recent xosview. + Changes to the /proc interface require a recent xosview. RealPlayer ========== @@ -444,8 +444,8 @@ software available shortly. In the mean time, you can always try backing up your copy of rvplayer, and then editing it by: - dd if=/dev/zero of=rvplayer bs=1 count=1 seek=657586 conv=notrunc dd -if=/dev/zero of=rvplayer bs=1 count=1 seek=665986 conv=notrunc + dd if=/dev/zero of=rvplayer bs=1 count=1 seek=657586 conv=notrunc + dd if=/dev/zero of=rvplayer bs=1 count=1 seek=665986 conv=notrunc If you're lucky, you'll then have sound.... diff -u --recursive --new-file v2.2.7/linux/Documentation/Configure.help linux/Documentation/Configure.help --- v2.2.7/linux/Documentation/Configure.help Wed Apr 28 11:37:29 1999 +++ linux/Documentation/Configure.help Thu May 6 14:02:34 1999 @@ -17,6 +17,8 @@ # ftp://ftp-pavia1.linux.it/pub/linux/Configure.help # - Polish, by Cezar Cichocki (cezar@cs.net.pl), at # http://www.cs.net.pl/~cezar/Kernel +# - German, by Jörg Strebel (jstrebel@suse.de) and Karl Eichwalder +# (ke@suse.de), at http://www.suse.de/~ke/kernel/Configure.de.help.gz # # Information about what a kernel is, what it does, how to patch and # compile it and much more is contained in the Kernel-HOWTO, available @@ -69,7 +71,7 @@ in some special cases. Detailed bug reports from people familiar with the kernel internals are usually welcomed by the developers (before submitting bug reports, please read the documents README, - MAINTAINERS, Documentation/BUG-HUNTING, and + MAINTAINERS, REPORTING_BUGS, Documentation/BUG-HUNTING, and Documentation/oops-tracing.txt in the kernel source). Unless you intend to help test and develop a feature or driver that @@ -127,12 +129,38 @@ available via FTP (user: anonymous) in ftp://metalab.unc.edu/pub/Linux/docs/HOWTO.) This means that it is a good idea to say Y here if you intend to use this kernel on - different machines. More information about the internals of Linux - math coprocessor emulation can be found in - arch/i386/math-emu/README. + different machines. + + More information about the internals of the Linux math coprocessor + emulation can be found in arch/i386/math-emu/README. If you are not sure, say Y; apart from resulting in a 45 KB bigger kernel, it won't hurt. + +Timer and CPU usage LEDs +CONFIG_LEDS + If you define this option, the LEDs on your machine will be used + to provide useful information about your current system status. + + If you are compiling a kernel for a NetWinder or EBSA-285, you + will be able to select which LEDs are active using the options + below. If you are compiling a kernel for the EBSA-110 however, + the red LED will simply flash regularly to indicate that the + system is still functional. It is still safe to say yes here if + you have a CATS system, but the driver will do nothing. + +Timer LED +CONFIG_LEDS_TIMER + If you say yes here, one of the system LEDs (the green one on the + NetWinder or the amber one on the EBSA285) will flash regularly to + indicate that the system is still operational. This is mainly + useful to kernel hackers who are debugging unstable kernels. + +CPU usage LED +CONFIG_LEDS_CPU + If you say yes here, the red LED will be used to give a good real + time indication of CPU usage, by lighting whenever the idle task + is not currently executing. Kernel FP software completion CONFIG_MATHEMU @@ -218,8 +246,8 @@ To use the loop device, you need the losetup utility and a recent version of the mount program, both contained in the util-linux - package (available via FTP (user: anonymous) from - ftp://ftp.win.tue.nl/pub/linux/util/). + package. The location and current version number of util-linux is + contained in the file Documentation/Changes. Note that this loop device has nothing to do with the loopback device used for network connections from the machine to itself. @@ -276,7 +304,7 @@ To fine-tune IDE drive/interface parameters for improved performance, look for the hdparm package at - ftp://metalab.unc.edu:/pub/Linux/kernel/patches/diskdrives/ + ftp://metalab.unc.edu/pub/Linux/kernel/patches/diskdrives/ If you want to compile this driver as a module ( = code which can be inserted in and removed from the running kernel whenever you want), @@ -475,7 +503,7 @@ Generic PCI IDE chipset support CONFIG_BLK_DEV_IDEPCI - Enable this for PCI systems which use IDE drive(s). + Say Y here for PCI systems which use IDE drive(s). This option helps the IDE driver to automatically detect and configure all PCI-based IDE interfaces in your system. @@ -560,15 +588,16 @@ This driver is enabled at runtime using the "ide0=dtc2278" kernel boot parameter. It enables support for the secondary IDE interface of the DTC-2278 card, and permits faster I/O speeds to be set as - well. See the Documentation/ide.txt and dtc2278.c files for more - info. + well. See the Documentation/ide.txt and drivers/block/dtc2278.c + files for more info. Holtek HT6560B support CONFIG_BLK_DEV_HT6560B This driver is enabled at runtime using the "ide0=ht6560b" kernel boot parameter. It enables support for the secondary IDE interface of the Holtek card, and permits faster I/O speeds to be set as well. - See the Documentation/ide.txt and ht6560b.c files for more info. + See the Documentation/ide.txt and drivers/block/ht6560b.c files for + more info. PROMISE DC4030 support (EXPERIMENTAL) CONFIG_BLK_DEV_PDC4030 @@ -618,36 +647,26 @@ If you say Y here, you also need to say Y to "Use DMA by default when available", above. - Please read the comments at the top of drivers/block/via82C586.c - If unsure, say N. CMD646 chipset support (EXPERIMENTAL) CONFIG_BLK_DEV_CMD646 Say Y here if you have an IDE controller like this. -HPT343 chipset support (EXPERIMENTAL) -CONFIG_BLK_DEV_HPT343 - This driver adds up to 4 more EIDE devices sharing a single - interrupt. The HPT343 chipset in its current form is a non-bootable - PCI UDMA controller. This driver requires dynamic tuning of the - chipset during the ide-probe at boot. It is reported to support DVD - II drives, by the manufacturer. - - Please read the comments at the top of drivers/block/hpt343.c - QDI QD6580 support CONFIG_BLK_DEV_QD6580 This driver is enabled at runtime using the "ide0=qd6580" kernel boot parameter. It permits faster I/O speeds to be set. See the - files Documentation/ide.txt and qd6580.c for more info. + files Documentation/ide.txt and drivers/block/qd6580.c for more + info. UMC 8672 support CONFIG_BLK_DEV_UMC8672 This driver is enabled at runtime using the "ide0=umc8672" kernel boot parameter. It enables support for the secondary IDE interface of the UMC-8672, and permits faster I/O speeds to be set as well. - See the files Documentation/ide.txt and umc8672.c for more info. + See the files Documentation/ide.txt and drivers/block/umc8672.c for + more info. ALI M14xx support CONFIG_BLK_DEV_ALI14XX @@ -655,7 +674,7 @@ boot parameter. It enables support for the secondary IDE interface of the ALI M1439/1443/1445/1487/1489 chipsets, and permits faster I/O speeds to be set as well. See the files Documentation/ide.txt - and ali14xx.c for more info. + and drivers/block/ali14xx.c for more info. XT hard disk support CONFIG_BLK_DEV_XD @@ -1034,6 +1053,24 @@ board uses the R4300 and a R5230 CPUs. For more information about this board see http://www.algor.co.uk. +IDE card support +CONFIG_BLK_DEV_IDE_CARDS + On Acorn systems, enable this if you wish to use an IDE interface + expansion card. If you do not or are unsure, say N to this. + +ICS IDE interface +CONFIG_BLK_DEV_IDE_ICS + On Acorn systems, enable this if you wish to use the ICS IDE + interface card. This is not required for ICS partition support. + If you are unsure, say N to this. + +ADFS partition support +CONFIG_BLK_DEV_PART + This allows Linux on Acorn systems to determine its partitions in + the 'non-ADFS' partition area of the hard disk - usually located + after the ADFS partition. You are probably using this system, so + you should enable it. + Support for Mips Magnum 4000 CONFIG_MIPS_MAGNUM_4000 This is a machine with a R4000 100 MHz CPU. To compile a Linux @@ -1870,7 +1907,7 @@ card. You do this by inserting several instances of the module matroxfb.o into the kernel with insmod, supplying the parameter "dev=N" where N is 0, 1, etc. for the different Matrox devices. - + MDA text console (dual-headed) CONFIG_MDA_CONSOLE Say Y here if you have an old MDA or monochrome Hercules graphics @@ -2030,7 +2067,7 @@ Parallel-port support CONFIG_PARPORT 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 + (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 @@ -2057,10 +2094,13 @@ CONFIG_PARPORT_PC 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. This code is also available as a module. If you want to it as - a module ( = code which can be inserted in and removed from the + ports. + + This code is also available as a module. If you want to compile it + as a module ( = code which can be inserted in and removed from the running kernel whenever you want), say M here and read Documentation/modules.txt. The module will be called parport_pc.o. + If unsure, say Y. Support foreign hardware @@ -2231,8 +2271,18 @@ the Linux router will also be able to take the packet's source address into account. Furthermore, if you also say Y to "IP: use TOS value as routing key" below, the TOS (Type-Of-Service) field of the - packet can be used for routing decisions as well. - + packet can be used for routing decisions as well. In addition, if + you say Y here and to "IP: fast network address translation" below, + the router will also be able to modify source and destination + addresses of forwarded packets. + + If you are interested in this, please see the preliminary + documentation at http://www.compendium.com.ar/policy-routing.txt and + ftp://post.tepkom.ru/pub/vol2/Linux/docs/advanced-routing.tex. You + will need supporting software from ftp://ftp.inr.ac.ru/ip-routing/ + + If unsure, say N. + IP: equal cost multipath CONFIG_IP_ROUTE_MULTIPATH Normally, the routing tables specify a single action to be taken in @@ -2275,9 +2325,9 @@ CONFIG_IP_ROUTE_NAT If you say Y here, your router will be able to modify source and destination addresses of packets that pass through it, in a manner - you specify. Please see - http://www.csn.tu-chemnitz.de/HyperNews/get/linux-ip-nat.html for - details. + you specify. General information about Network Address Translation + can be gotten from the document + http://www.csn.tu-chemnitz.de/~mha/linux-ip-nat/diplom/nat.html IP: optimize as router not host CONFIG_IP_ROUTER @@ -2601,12 +2651,12 @@ Sometimes it is useful to give several IP addresses to a single physical network interface (serial port or Ethernet card). The most common case is that you want to serve different WWW or ftp documents - to the outside according to which of your host names was used to + to the outside depending on which of your host names was used to connect to you. This is called "multihosting" or "virtual domains" or "virtual hosting services" and is explained in detail on the WWW at http://www.thesphere.com/~dlp/TwoServers/ (to browse the WWW, you need to have access to a machine on the Internet that has a program - like lynx or netscape) and also in the Virtual-Hosting-HOWTO, + like lynx or netscape) and also in the Virtual-Services-HOWTO, available via FTP (user: anonymous) from ftp://metalab.unc.edu/pub/Linux/docs/HOWTO. @@ -2920,36 +2970,45 @@ CONFIG_IPDDP This allows IP networking for users who only have AppleTalk networking available. This feature is experimental. With this - driver, you can either encapsulate IP inside AppleTalk (e.g. if your - Linux box is stuck on an AppleTalk only network) or decapsulate - (e.g. if you want your Linux box to act as an Internet gateway for a - zoo of AppleTalk connected Macs). You decide which one of the two - you want in the following two questions; you can say Y to only one - of them. Please see Documentation/networking/ipddp.txt for more - information. + driver, you can encapsulate IP inside AppleTalk (e.g. if your Linux + box is stuck on an AppleTalk only network) or decapsulate (e.g. if + you want your Linux box to act as an Internet gateway for a zoo of + AppleTalk connected Macs). Please see the file + Documentation/networking/ipddp.txt for more information. + + If you say Y here, the AppleTalk-IP support will be compiled into + the kernel. In this case, you can either use encapsulation or + decapsulation, but not both. With the following two questions, you + decide which one you want. - This driver is also available as a module ( = code which can be - inserted in and removed from the running kernel whenever you want). - The module is called ipddp.o. If you want to compile it as a module, - say M here and read Documentation/modules.txt. + If you say M here, the AppleTalk-IP support will be compiled as a + module ( = code which can be inserted in and removed from the + running kernel whenever you want, read Documentation/modules.txt). + The module is called ipddp.o. In this case, you will be able to use + both encapsulation and decapsulation simultaneously, by loading two + copies of the module and specifying different values for the module + option ipddp_mode. IP to AppleTalk-IP Encapsulation support CONFIG_IPDDP_ENCAP - If you say Y here, the kernel will be able to encapsulate IP packets - inside AppleTalk frames; this is useful if your Linux box is stuck - on an AppleTalk network (which hopefully contains a decapsulator - somewhere). Please see Documentation/networking/ipddp.txt for more - information. If you say Y here, you cannot say Y to "AppleTalk-IP to - IP Decapsulation support", below. + If you say Y here, the AppleTalk-IP code will be able to encapsulate + IP packets inside AppleTalk frames; this is useful if your Linux box + is stuck on an AppleTalk network (which hopefully contains a + decapsulator somewhere). Please see + Documentation/networking/ipddp.txt for more information. If you said + Y to "AppleTalk-IP driver support" above and you say Y here, then + you cannot say Y to "AppleTalk-IP to IP Decapsulation support", + below. AppleTalk-IP to IP Decapsulation support CONFIG_IPDDP_DECAP - If you say Y here, the kernel will be able to decapsulate + If you say Y here, the AppleTalk-IP code will be able to decapsulate AppleTalk-IP frames to IP packets; this is useful if you want your - Linux box to act as an Internet gateway for an AppleTalk - network. Please see Documentation/networking/ipddp.txt for more - information. If you say Y here, you cannot say Y to "IP to - AppleTalk-IP Encapsulation support", above. + Linux box to act as an Internet gateway for an AppleTalk network. + Please see Documentation/networking/ipddp.txt for more information. + If you said Y to "AppleTalk-IP driver support" above and you say Y + here, then you cannot say Y to "IP to AppleTalk-IP Encapsulation + support", above. Apple/Farallon LocalTalk PC card support CONFIG_LTPC @@ -3526,7 +3585,7 @@ CONFIG_BLK_DEV_SR If you want to use a SCSI CDROM under Linux, say Y and read the SCSI-HOWTO and the CDROM-HOWTO from - ftp://metalab.unc.edu:/pub/Linux/docs/HOWTO. Also make sure to say Y + ftp://metalab.unc.edu/pub/Linux/docs/HOWTO. Also make sure to say Y or M to "ISO 9660 CDROM filesystem support" later. This driver is also available as a module ( = code which can be @@ -3554,7 +3613,8 @@ other devices, it's possible that you'll have to write the driver software yourself, so have a look at the SCSI-HOWTO and at the SCSI-Programming-HOWTO, both available via FTP (user: anonymous) in - ftp://metalab.unc.edu:/pub/Linux/docs/HOWTO. + ftp://metalab.unc.edu/pub/Linux/docs/HOWTO. Please read the file + Documentation/scsi-generic.txt for more information. If you want to compile this as a module ( = code which can be inserted in and removed from the running kernel whenever you want), @@ -3956,33 +4016,33 @@ tagged command queuing and fast synchronous data transfers up to 80 MB/s with wide FAST-40 LVD devices and controllers. - An additionnal driver named SYM53C8XX (a.k.a 896 driver) can also be - configured. See the help on the SYM53C8XX driver for more information. + Recent versions of the 53C8XX chips are better supported by the + option "SYM53C8XX SCSI support", below. - Note: there is another driver for the 53c8xx family of controllers + Note: there is yet another driver for the 53c8xx family of controllers ("NCR53c7,8xx SCSI support" above). If you want to use them both, you need to say M to both and build them as modules, but only one - may be active at a time. If you have a 53c8xx board, it's best to - use this driver. + may be active at a time. If you have a 53c8xx board, you probably do + not want to use the "NCR53c7,8xx SCSI support". Please read drivers/scsi/README.ncr53c8xx for more information. SYM53C8XX SCSI support CONFIG_SCSI_SYM53C8XX - The 896 driver for Linux (a.k.a. sym53c8xx) is derivated from the - ncr53c8xx driver and has been heavily reworked and enhanced to - fully support all the features of recent 53C8XX chips, notably the - hardware phase mismatch feature of the SYM53C896. - - For that to be achieved without additionnal complexity, support of - old 8XX chips has been dropped. If your system uses either a - 810 rev. < 16, a 815, or a 825 rev. < 16 PCI SCSI processor, you must - use the generic NCR53C8XX driver or configure both the NCR53C8XX and - the SYM53C8XX drivers either as module or linked to the kernel image. + This driver supports all the features of recent 53C8XX chips (used + in PCI SCSI controllers), notably the hardware phase mismatch + feature of the SYM53C896. + + Older versions of the 53C8XX chips are not supported by this + driver. If your system uses either a 810 rev. < 16, a 815, or a 825 + rev. < 16 PCI SCSI processor, you must use the generic NCR53C8XX + driver ("NCR53C8XX SCSI support" above) or configure both the + NCR53C8XX and this SYM53C8XX drivers either as module or linked to + the kernel image. When both drivers are linked to the kernel, the SYM53C8XX driver is called first at initialization and you can use the 'excl=ioaddr' - driver boot option to exclude attachement of adapters by the SYM53C8XX + driver boot option to exclude attachment of adapters by the SYM53C8XX driver. For instance, entering 'sym53c8xx=excl:0xb400,excl=0xc000' at lilo prompt prevents adapters at io address 0xb400 and 0xc000 from being attached by the SYM53C8XX driver, thus allowing the NCR53C8XX @@ -4105,12 +4165,11 @@ include support for the NCR PQS/PDS SCSI card CONFIG_SCSI_NCR53C8XX_PQS_PDS - This allows the driver to detect a special adapter produced by NCR + Say Y here if you have a special SCSI adapter produced by NCR corporation called a PCI Quad SCSI or PCI Dual SCSI. You do not need - this if you do not have one of these adapters. However, since this - device is detected as a specific PCI device, this option is quite - safe. This option is only supported by the SYM53C8XX driver (not - by the NCR53C8XX driver). + this if you do not have one of these adapters. However, since this + device is detected as a specific PCI device, this option is quite + safe. The common answer here is N, but answering Y is safe. @@ -4215,17 +4274,6 @@ say M here and read Documentation/modules.txt. The module will be called initio.o -Initio 91XXU(W) SCSI support -CONFIG_SCSI_INITIO - This is support for the Initio 91XXU(W) SCSI host adapter. - Please read the SCSI-HOWTO, available via FTP (user: anonymous) at - ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO. - - If you want to compile this as a module ( = code which can be - inserted in and removed from the running kernel whenever you want), - say M here and read Documentation/modules.txt. The module will be - called initio.o - PAS16 SCSI support CONFIG_SCSI_PAS16 This is support for a SCSI host adapter. It is explained in section @@ -4243,7 +4291,7 @@ CONFIG_SCSI_INIA100 This is support for the Initio INI-A100U2W SCSI host adapter. Please read the SCSI-HOWTO, available via FTP (user: anonymous) at - ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO. + ftp://metalab.unc.edu/pub/Linux/docs/HOWTO. If you want to compile this as a module ( = code which can be inserted in and removed from the running kernel whenever you want), @@ -4309,8 +4357,8 @@ IQ-PCI-10, IQ_PCI-D) except for the PCI-basic card. (This latter card is supported by the "AM53/79C974 PCI SCSI" driver). - If you say Y here, make sure to say Y to choose "BIOS" at the - question "PCI access mode". + If you say Y here, make sure to choose "BIOS" at the question "PCI + access mode". Please read the file drivers/scsi/README.qlogicisp. You should also read the SCSI-HOWTO, available via FTP (user: anonymous) at @@ -4321,6 +4369,15 @@ The module will be called qlogicisp.o. If you want to compile it as a module, say M here and read Documentation/modules.txt. +Qlogic ISP FC SCSI support +CONFIG_SCSI_QLOGIC_FC + This is a driver for the QLogic ISP2100 SCSI-FCP host adapter. + + This driver is also available as a module ( = code which can be + inserted in and removed from the running kernel whenever you want). + The module will be called qlogicfc.o. If you want to compile it as + a module, say M here and read Documentation/modules.txt. + Seagate ST-02 and Future Domain TMC-8xx SCSI support CONFIG_SCSI_SEAGATE These are 8-bit SCSI controllers; the ST-01 is also supported by @@ -4444,20 +4501,22 @@ Symbios Logic sym53c416 support CONFIG_SCSI_SYM53C416 - This is support for the sym53c416 SCSI host adapter. This is the - SCSI adapter that comes with some hp scanners. This driver requires that - the sym53c416 is configured first using some sort of pnp configuration - program (e.g. isapnp) or by a PnP aware BIOS. If you are using isapnp then - you need to compile it as a module and then load it using insmod after - isapnp has run. The parameters of the configured card(s) should be passed - to the driver. The format is: + This is support for the sym53c416 SCSI host adapter, the SCSI + adapter that comes with some HP scanners. This driver requires that + the sym53c416 is configured first using some sort of pnp + configuration program (e.g. isapnp) or by a PnP aware BIOS. If you + are using isapnp then you need to compile this driver as a module + and then load it using insmod after isapnp has run. The parameters + of the configured card(s) should be passed to the driver. The format + is: insmod sym53c416 sym53c416=, [sym53c416_1=,] - There is support for up to four adapters. If you want to compile this - driver as a module ( = code which can be inserted in and removed from - the running kernel whenever you want), say M here and read - Documentation/modules.txt. + There is support for up to four adapters. If you want to compile + this driver as a module ( = code which can be inserted in and + removed from the running kernel whenever you want), say M here and + read Documentation/modules.txt. The module will be called + sym53c416.o. Tekram DC390(T) and Am53/79C974 (PCscsi) SCSI support CONFIG_SCSI_DC390T @@ -4518,6 +4577,12 @@ say M here and read Documentation/modules.txt. The module will be called megaraid.o. +### +### What is this? +### +#Concurrent IO commands on MegaRAID +#CONFIG_MEGARAID_MULTI_IO + GDT SCSI Disk Array Controller support CONFIG_SCSI_GDTH This is a driver for all SCSI Disk Array Controllers (EISA/ISA/PCI) @@ -4710,7 +4775,7 @@ you want to use under Linux (make sure you know its name because you will be asked for it and read the Ethernet-HOWTO (especially if you plan to use more than one network card under Linux), available from - ftp://metalab.unc.edu:/pub/Linux/docs/HOWTO/mini) or if you want to + ftp://metalab.unc.edu/pub/Linux/docs/HOWTO/mini) or if you want to use SLIP (Serial Line Internet Protocol is the protocol used to send Internet traffic over telephone lines or null modem cables) or CSLIP (compressed SLIP) or PPP (Point to Point Protocol, a better and @@ -4721,7 +4786,7 @@ Make sure to read the NET-3-HOWTO. Eventually, you will have to read Olaf Kirch's excellent and free book "Network Administrator's - Guide", to be found in ftp://metalab.unc.edu:/pub/Linux/docs/LDP. If + Guide", to be found in ftp://metalab.unc.edu/pub/Linux/docs/LDP. If unsure, say Y. Dummy net driver support @@ -4827,7 +4892,7 @@ To use PPP, you need an additional program called pppd as described in Documentation/networking/ppp.txt and in the PPP-HOWTO, available - from ftp://metalab.unc.edu:/pub/Linux/docs/HOWTO. If you upgrade + from ftp://metalab.unc.edu/pub/Linux/docs/HOWTO. If you upgrade from an older kernel, you might need to upgrade pppd as well. The PPP option enlarges your kernel by about 16 KB. @@ -5142,11 +5207,13 @@ *** This option is NOT COMPATIBLE with several important *** *** networking options: especially CONFIG*FIREWALL. *** + *** Say N here if you intend to use Linux as a firewall. *** However, it will work with all options in CONFIG_IP_ADVANCED_ROUTER - section (except for CONFIG_IP_ROUTE_TOS&FWMARK). At the moment, few devices - support fast switching (tulip is one of them, modified 8390 can be - found at ftp://ftp.inr.ac.ru/ip-routing/fastroute-8390.tar.gz). + section (except for CONFIG_IP_ROUTE_TOS and CONFIG_IP_ROUTE_FWMARK). + At the moment, few devices support fast switching (tulip is one of + them, modified 8390 can be found at + ftp://ftp.inr.ac.ru/ip-routing/fastroute-8390.tar.gz). If unsure, say N. @@ -5752,6 +5819,18 @@ module, say M here and read Documentation/modules.txt as well as Documentation/networking/net-modules.txt. +3c527 support +CONFIG_ELMC_II + If you have a network (Ethernet) card of this type, say Y and read + the Ethernet-HOWTO, available via FTP (user: anonymous) in + ftp://metalab.unc.edu/pub/Linux/docs/HOWTO. + + This driver is also available as a module ( = code which can be + inserted in and removed from the running kernel whenever you want). + The module will be called 3c527.o. If you want to compile it as a + module, say M here and read Documentation/modules.txt as well as + Documentation/networking/net-modules.txt. + 3c509/3c579 support CONFIG_EL3 If you have a network (Ethernet) card belonging to the 3Com @@ -6560,6 +6639,20 @@ The module will be called mcd.o. If you want to compile it as a module, say M here and read Documentation/modules.txt. +IRQ channel for Mitsumi CD-ROM +CONFIG_MCD_IRQ + This allows you to specify the default value of the IRQ used by the + driver. This setting can be overridden by passing the "mcd=" + parameter to the kernel at boot time (or at module load time if you + said M to "Standard Mitsumi CDROM support"). + +I/O base address for Mitsumi CD-ROM +CONFIG_MCD_BASE + This allows you to specify the default value of the I/O base address + used by the driver. This setting can be overridden by passing the + "mcd=" parameter to the kernel at boot time (or at module load time + if you said M to "Standard Mitsumi CDROM support"). + Mitsumi [XA/MultiSession] support CONFIG_MCDX Use this driver if you want to be able to read XA or MultiSession @@ -6750,6 +6843,13 @@ ftp://metalab.unc.edu/pub/Linux/docs/HOWTO/mini. Probably the quota support is only useful for multi user systems. If unsure, say N. +Acorn's ADFS filesystem support (read only) (EXPERIMENTAL) +CONFIG_ADFS_FS + The Advanced Disk File System is the filesystem used on floppy and + hard disks by Acorn Systems. Currently in development, as a read- + only driver for hard disks. These should be the first partition + (eg. /dev/[sh]d?1) on each of your drives. If unsure, say N. + Minix fs support CONFIG_MINIX_FS Minix is a simple operating system used in many classes about OS's. @@ -7032,10 +7132,13 @@ should say N here, or you can say Y and use this new experimental kernel based NFS server. The advantage of the kernel based solution is that it is faster; it might not be completely stable yet, though. - You will need the support software from the linux-nfs package - available at ftp://ftp.mathematik.th-darmstadt.de/pub/linux/okir/. + + In either case, you will need support software; the respective + locations are given in the file Documentation/Changes in the NFS + section. + Please read the NFS-HOWTO, available via FTP (user: anonymous) from - ftp://metalab.unc.edu:/pub/Linux/docs/HOWTO. + ftp://metalab.unc.edu/pub/Linux/docs/HOWTO. The NFS server is also available as a module ( = code which can be inserted in and removed from the running kernel whenever you want). @@ -7213,7 +7316,8 @@ Unixes can create and mount hard disk partitions and diskettes using this filesystem as well. Saying Y here will allow you to read from these partitions; if you also want to write to them, say Y to the - experimental "UFS filesystem write support", below. + experimental "UFS filesystem write support", below. Please read the + file Documentation/filesystems/ufs.txt for more information. If you only intend to mount files from some other Unix over the network using NFS, you don't need the UFS filesystem support (but @@ -7333,7 +7437,7 @@ SMB filesystem support (to mount Windows shares etc...) CONFIG_SMB_FS SMB (Server Message Block) is the protocol Windows for Workgroups - (WfW), Windows 95, Windows NT and OS/2 Lan Manager use to share + (WfW), Windows 95/98, Windows NT and OS/2 Lan Manager use to share files and printers over local networks. Saying Y here allows you to mount their filesystems (often called "shares" in this context) and access them just like any other Unix directory. Currently, this @@ -7397,7 +7501,7 @@ mount NetWare file server volumes and to access them just like any other Unix directory. For details, please read the file Documentation/filesystems/ncpfs.txt in the kernel source and the - IPX-HOWTO on ftp://metalab.unc.edu:/pub/Linux/docs/howto. + IPX-HOWTO on ftp://metalab.unc.edu/pub/Linux/docs/howto. You do not have to say Y here if you want your Linux box to act as a file *server* for Novell NetWare clients. @@ -7445,23 +7549,22 @@ Lowercase DOS filenames on LONG namespace volume CONFIG_NCPFS_SMALLDOS - Saying Y here will convert every filename with creator/owner DOS - namespace on NetWare servers to lowercase characters as silently - kernel does when you mount NetWare file server volumes with DOS - namespace without OS2/LONG namespace support. Saying N here will - give you these filenames with uppercase characters. - - This is only cosmetic option because of OS2/LONG namespace is - case insensitive. The only major reason for this option is - backward compatibility when you want to do step from DOS to - OS2/LONG namespace support. Long filenames (created by Win95) - will not be affected. - - This option does not solve a problem that filenames appear - differently in Linux box and in MS environment because of MS - does an additional conversions on client side. You can achieve - simillar effects enabling ncpfs option "Allow using of Native - Language Support" below. + If you say Y here, every filename on a NetWare server volume using + the OS2/LONG namespace will be converted to lowercase characters. + (For regular NetWare file server volumes with DOS namespace, this is + done automatically, even if you say N here.) Saying N here will give + you these filenames in uppercase. + + This is only a cosmetic option since the OS2/LONG namespace is case + insensitive. The only major reason for this option is backward + compatibility when moving from DOS to OS2/LONG namespace support. + Long filenames (created by Win95) will not be affected. + + This option does not solve the problem that filenames appear + differently under Linux and under Windows, since Windows does an + additional conversions on the client side. You can achieve similar + effects by saying Y to "Allow using of Native Language Support" + below. Allow mounting of volume subdirectories CONFIG_NCPFS_MOUNT_SUBDIR @@ -7483,10 +7586,10 @@ Allow using of Native Language Support CONFIG_NCPFS_NLS - Allows you to use codepages and I/O charsets for file name translation - between file system on server and input/output. This may be useful, - if you want to access to the server with other operating systems, - e.g. Windows 95. See also NLS for more Information. + Allows you to use codepages and I/O charsets for file name + translation between the server file system and input/output. This + may be useful, if you want to access the server with other operating + systems, e.g. Windows 95. See also NLS for more Information. To select codepages and I/O charsets use ncpfs-2.2.0.13 or newer. @@ -7494,12 +7597,11 @@ CONFIG_NCPFS_EXTRAS This enables the use of symbolic links and an execute permission bit on NCPFS. The file server need not have long name space or NFS - name space loaded for these to work, they are stored using rarely - found combinations of Hidden, System and Shared flags. + name space loaded for these to work. + + To use the new attributes, it is recommended to use the flags + '-f 600 -d 755' on the ncpmount command line. - To use the new attributes, you are recommended to use the flags - '-f 600 -d 755' on the ncpmount commandline. - nls codepage 437 CONFIG_NLS_CODEPAGE_437 The Microsoft fat filesystem family can deal with filenames in @@ -8035,14 +8137,24 @@ Provides support for the SyncLink ISA and PCI multiprotocol serial adapters. These adapters support asynchronous and HDLC bit synchronous - communication up to 10Mbps (PCI adapter) + communication up to 10Mbps (PCI adapter). + + This driver can only be built as a module ( = code which can be + inserted in and removed from the running kernel whenever you want). + The module will be called synclink.o. If you want to do that, say M + here. Synchronous HDLC line discipline support CONFIG_N_HDLC Allows synchronous HDLC communications with tty device drivers that support synchronous HDLC such as the Microgate SyncLink adapter. - + + This driver can only be built as a module ( = code which can be + inserted in and removed from the running kernel whenever you want). + The module will be called n_hdlc.o. If you want to do that, say M + here. + Hayes ESP serial port support CONFIG_ESPSERIAL This is a driver which supports Hayes ESP serial ports. Both single @@ -8087,7 +8199,7 @@ 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 Documentation/Changes pertaining to pseudo - terminals. It's save to say N. + terminals. It's safe to say N. Maximum number of Unix98 PTYs in use (0-2048) CONFIG_UNIX98_PTY_COUNT @@ -8183,7 +8295,7 @@ When using a PS/2 mouse, you can get problems if you want to use the mouse both on the Linux console and under X. Using the "-R" option of the Linux mouse managing program gpm (available from - ftp://metalab.unc.edu:/pub/Linux/system/Daemons) solves this + ftp://metalab.unc.edu/pub/Linux/system/Daemons) solves this problem, or you can get the "mconv" utility also from metalab. C&T 82C710 mouse port support (as on TI Travelmate) @@ -8893,6 +9005,17 @@ The module will be called nvram.o. If you want to compile it as a module, say M here and read Documentation/modules.txt. +Atomwide Serial Support +CONFIG_ATOMWIDE_SERIAL + If you have an Atomwide Serial card for an Acorn system, say Y to + this option. The driver can handle 1, 2, or 3 port cards. + If unsure, say N + +The Serial Port Dual Serial Port +CONFIG_DUALSP_SERIAL + If you have the Serial Port's dual serial card for an Acorn system, + say Y to this option. If unsure, say N + Joystick support CONFIG_JOYSTICK If you have a joystick, you can say Y here to enable generic @@ -8996,6 +9119,35 @@ If you have the Serial Port's dual serial card for an Acorn system, say Y to this option. If unsure, say N +NetWinder Button +CONFIG_NWBUTTON + If you enable this driver and create a character device node + /dev/nwbutton with major and minor numbers 10 and 158 ("man mknod"), + then every time the orange button is pressed a number of times, the + number of times the button was pressed will be written to that device. + This is most useful for applications, as yet unwritten, which perform + actions based on how many times the button is pressed in a row. + Do not hold the button down for too long, as the driver does not alter + the behaviour of the hardware reset circuitry attached to the button; + it will still execute a hard reset if the button is held down for + longer than approximately five seconds. + This driver is also available as a module ( = code which can be + inserted in and removed from the running kernel whenever you want). + If you want to compile it as a module, say M here and read + Documentation/modules.txt. The module will be called nwbutton.o. + Most people will answer Y to this question and "Reboot Using Button" + below to be able to initiate a system shutdown from the button. + +Reboot Using Button +CONFIG_NWBUTTON_REBOOT + If you enable this option, then you will be able to initiate a system + shutdown and reboot by pressing the orange button a number of times. + The number of presses to initiate the shutdown is two by default, but + this can be altered by modifying the value of NUM_PRESSES_REBOOT in + nwbutton.h and recompiling the driver or, if you compile the driver as + a module, you can specify the number of presses at load time with + "insmod button reboot_count=". + Sound card support CONFIG_SOUND If you have a sound card in your computer, i.e. if it can say more @@ -9037,18 +9189,19 @@ Persistent DMA buffers CONFIG_SOUND_DMAP - Linux can often have problems allocating DMA buffers for ISA cards on - machines with more than 16MB of RAM. This is because ISA DMA buffers - must exist below the 16MB boundry and it is quite possible that we - can't find a large enough free block in this region after the machine - has been running for any amount of time. If you say Y here the DMA - buffers (64Kb) will be allocated at boot time and kept until the - shutdown. This option is only usefull if you say Y to OSS sound - modules. If you say M to OSS sound modules then you can just pass to - the sound.o module a "dmabuf=1" command-line argument. + Linux can often have problems allocating DMA buffers for ISA sound + cards on machines with more than 16MB of RAM. This is because ISA + DMA buffers must exist below the 16MB boundary and it is quite + possible that a large enough free block in this region cannot be + found after the machine has been running for a while. If you say Y + here the DMA buffers (64Kb) will be allocated at boot time and kept + until the shutdown. This option is only useful if you said Y to + "OSS sound modules", above. If you said M to "OSS sound modules" + then you can get the persistent DMA buffer functionality by passing + the command-line argument "dmabuf=1" to the sound.o module. Say Y unless you have 16MB or less RAM or a PCI sound card. - + Support for Aztech Sound Galaxy (non-PnP) cards CONFIG_SOUND_SGALAXY This module initializes the older non Plug and Play sound galaxy @@ -9556,6 +9709,11 @@ differs slightly from OSS/Free, so PLEASE READ Documentation/sound/sonicvibes. +Rockwell WaveArtist +CONFIG_SOUND_WAVEARTIST + Say Y here to include support for the Rockwell WaveArtist sound + system. This driver is mainly for the NetWinder. + Are you using a crosscompiler CONFIG_CROSSCOMPILE Say Y here if you are compiling the kernel on a different @@ -10513,11 +10671,21 @@ motherboard will usually use a MACE (Medium Access Control for Ethernet) interface. Say Y to include support for the MACE chip. + This driver is also available as a module called mace.o ( = code + which can be inserted in and removed from the running kernel + whenever you want). If you want to compile it as a module, say M + here and read Documentation/modules.txt. + BMAC (G3 ethernet) support CONFIG_BMAC Say Y for support of BMAC Ethernet interfaces. These are used on G3 computers. + This driver is also available as a module called bmac.o ( = code + which can be inserted in and removed from the running kernel + whenever you want). If you want to compile it as a module, say M + here and read Documentation/modules.txt. + Video For Linux CONFIG_VIDEO_DEV Support for audio/video capture and overlay devices and FM radio @@ -10686,11 +10854,27 @@ CONFIG_RADIO_ZOLTRIX_PORT Enter the I/O port of your Zoltrix radio card. +ADS Cadet AM/FM Tuner +CONFIG_RADIO_CADET + Say Y here if this is your AM/FM radio card. + + In order to control your radio card, you will need to use programs + that are compatible with the Video for Linux API. Information on + this API and pointers to "v4l" programs may be found on the WWW at + http://roadrunner.swansea.uk.linux.org/v4l.shtml; to browse the WWW, + you need to have access to a machine on the Internet that has a + program like lynx or netscape. + + If you want to compile this driver as a module ( = code which can be + inserted in and removed from the running kernel whenever you want), + say M here and read Documentation/modules.txt. The module will be + called radio-cadet.o + Miro PCM20 Radio CONFIG_RADIO_MIROPCM20 - Choose Y here if you have this FM radio card. You also need the - PCM12/PCM20 ACI mixer in additional low level sound drivers for this - to work. + Choose Y here if you have this FM radio card. You also need to say Y + to "ACI mixer (miroPCM12/PCM20)" (in "additional low level sound + drivers") for this to work. In order to control your radio card, you will need to use programs that are compatible with the Video for Linux API. Information on @@ -10772,6 +10956,9 @@ from the running kernel whenever you want). If you want to compile it as a module, say M here and read Documentation/modules.txt. +# +# ARM options +# CPU Optimization CONFIG_CPU_ARM2 This selects the processor type of your CPU. This is only used to @@ -10788,40 +10975,154 @@ to set this option to, please consult any information supplied with your system. -Include support for CATS boards +Include support for Chalice CATS boards CONFIG_CATS - Say Y here if you wish to include support for the extra hardware - found in Chalice CATS machines. The resulting kernel will still run - on an EBSA-285 but will be slightly larger. If in doubt say N. + Say Y here if you intend to run this kernel on a CATS system. + +Include support for Intel EBSA285 +CONFIG_ARCH_EBSA285 + Say Y here if you intend to run this kernel on an EBSA-285 evaluation + board. + +Include support for the NetWinder +CONFIG_ARCH_NETWINDER + Say Y here if you intend to run this kernel on the NetWinder. + +Math emulation +CONFIG_NWFPE + Say Y to include the NWFPE floating point emulator in the kernel. This + is necessary to run most binaries. Linux does not currently support + floating point hardware so you need to say Y here even if your machine + has an FPA or floating point co-processor podule. + + It is also possible to say M to build the emulator as a module + (nwfpe.o) or indeed to leave it out altogether. However, unless you + know what you are doing this can easily render your machine unbootable. + Saying Y is the safe option. + + You may say N here if you are going to load the Acorn FPEmulator + early in the bootup. + +DS1620 Thermometer support +CONFIG_DS1620 + Say Y here to include support for the thermal management hardware + found in the NetWinder. This driver allows the user to control the + temperature set points and to read the current temperature. + + It is also possible to say M here to build it as a module (ds1620.o) + It is recommended to be used on a NetWinder, but it is not a + necessity. -Debug kernel errors +Verbose kernel error messages CONFIG_DEBUG_ERRORS This option controls verbose debugging information which can be - printed when the kernel detects an internal error. Verbose debugging - information is useful when tracking down kernel problems, but it - will be meaning less for non-kernel hackers. It's safe for everyone - to say Y. - -Build Tools Selection -CONFIG_BINUTILS_NEW - Say Y here if and only if you're using GCC 2.8.1/EGCS with a - binutils version >= 2.8.1 to compile the kernel (check with "gcc - --version" and "ld -v"). + printed when the kernel detects an internal error. This debugging + information is useful to kernel hackers when tracking down problems, + but mostly meaningless to other people. It's safe to say Y unless + you are concerned with the code size or don't want to see these + messages. Compile kernel with frame pointer CONFIG_FRAME_POINTER - If you say Y here, the resulting kernel will be slightly larger, but - it will give useful debugging/error results. If you don't debug the - kernel, you can say N. + If you say Y here, the resulting kernel will be slightly larger and + slower, but it will give useful debugging information. If you don't + debug the kernel, you can say N. + +User fault debugging +CONFIG_DEBUG_USER + When a user program crashes due to an exception, the kernel can print + a brief message explaining what the problem was. This is sometimes + helpful for debugging but serves no purpose on a production system. + Most people should say N here. + +Include gdb debugging information in kernel binary +CONFIG_DEBUG_INFO + Say Y here to include source-level debugging information in the + `vmlinux' binary image. This is handy if you want to use gdb or + addr2line to debug the kernel. It has no impact on the in-memory + footprint of the running kernel but it can increase the amount of + time and disk space needed for compilation. If in doubt say N. + +Split initialisation functions into discardable section +CONFIG_TEXT_SECTIONS + Normally code that is only used during initialisation is collected + into a special area of the kernel so that it can be discarded and + the memory reclaimed when initialisation is complete. In addition, + if the kernel you wish to build is able to run on multiple + architectures, it allows the unused code to be discarded. Some + versions of binutils, however, have a bug that causes the kernel + to crash during startup when this option is enabled. Say Y unless + you experience problems that you suspect may be caused by this. + +Disable pgtable cache +CONFIG_NO_PGT_CACHE + Normally the kernel maintains a `quicklist' of preallocated pagetable + structures in order to increase performance. On machines with very + few pages this may however be a loss. Say Y here to disable the pgtable + cache. + +RISC OS personality +CONFIG_ARTHUR + Say Y here to include the kernel code necessary if you want to run + Acorn RISC OS/Arthur binaries under Linux. This code is still very + experimental; if this sounds frightening, say N and sleep in peace. + You can also say M here to compile this support as a module (which + will be called arthur.o). Initial kernel command line CONFIG_CMDLINE - On some architectures (EBSA285, EBSA110 and Corel NetWinder), there - is currently no way for the boot loader to pass arguments to the - kernel. For these architectures, you should supply some command-line - options at build time by entering them here. As a minimum, you - should specify the memory size and the root device (e.g., mem=64M - root=/dev/nfs) + On some architectures (EBSA110 and CATS), there is currently no way + for the boot loader to pass arguments to the kernel. For these + architectures, you should supply some command-line options at build + time by entering them here. As a minimum, you should specify the + memory size and the root device (eg, mem=64M root=/dev/nfs) + +Hardware alignment trap +CONFIG_ALIGNMENT_TRAP + ARM processors can not fetch/store information which is not naturally + aligned on the bus, ie, a 4 byte fetch must start at an address divisable + by 4. On 32-bit ARM processors, these instructions can be emulated in + software with a severe performance impact. This is necessary for correct + operation of some network protocols. With an IP-only configuration + it is safe to say N, otherwise say Y. + +21285 serial port support +CONFIG_SERIAL_21285 + If you have a machine based on a 21285 (Footbridge) StrongARM/PCI + bridge you can enable its onboard serial port by enabling this + option. The device has major ID 4, minor 64. + +Console on 21285 serial port +CONFIG_SERIAL_21285_CONSOLE + If you have enabled the serial port on the 21285 footbridge you can + make it the console by answering 'Y' to this option. + +Footbridge Mode +CONFIG_HOST_FOOTBRIDGE + The 21285 Footbridge chip can operate in either `host mode' or + `add-in' mode. Say Y if your 21285 is in host mode, and therefore + is the configuration master, otherwise say N. + +MFM harddisk support +CONFIG_BLK_DEV_MFM + Support the MFM hard drives on the Acorn Archimedes both + on-board the A4x0 motherboards and via the Acorn MFM podules. + Drives upto 64MB are supported. If you haven't got one of these + machines or drives just say 'N'. + +Old Archimedes floppy (1772) support +CONFIG_BLK_DEV_FD1772 + Support the floppy drive on the Acorn Archimedes (A300, A4x0, A540, + R140 and R260) series of computers; it supports only 720K floppies + at the moment. If you don't have one of these machines just answer + 'N'. + +Autodetect hard drive geometry +CONFIG_BLK_DEV_MFM_AUTODETECT + If you answer 'Y' the MFM code will attempt to automatically detect + the cylinders/heads/sectors count on your hard drive. WARNING: This + sometimes doesn't work and it also does some dodgy stuff which + potentially might damage your drive. IrDA Protocols CONFIG_IRDA @@ -10834,7 +11135,7 @@ as well. For more information, see the file Documentation/networking/irda.txt. You also want to read the IR-HOWTO, available from - ftp://metalab.unc.edu:/pub/Linux/docs/HOWTO. + ftp://metalab.unc.edu/pub/Linux/docs/HOWTO. This support is also available as a module. If you want to compile it as a module, say M here and read Documentation/modules.txt. The @@ -10864,17 +11165,6 @@ If unsure, say N. -IrDA Recycle RR's -CONFIG_IRDA_RECYCLE_RR - In the normal life of the IrLAP protocol, it sends a lot of small RR - (Receive Ready) frames over the link (at least when it has nothing - else to do). Saying Y to this option will make IrLAP recycle these - frames thus avoiding many alloc_skb's and kfree_skb's. To do this it - will only buffer one of these frame which is enough for the normal - case. - - If unsure, say Y. - IrDA Debug CONFIG_IRDA_DEBUG Say Y here if you want the IrDA subsystem to write debug information @@ -10912,21 +11202,9 @@ The IrLAN protocol can be used to talk with infrared access points like the HP NetbeamIR, or the ESI JetEye NET. You can also connect - to another Linux machine running the IrLAN protocol for ac-hoc + to another Linux machine running the IrLAN protocol for ad-hoc networking! -IrOBEX Protocol -CONFIG_IROBEX - Say Y here if you want to build support for the IrOBEX protocol. If - you want to compile it as a module, say M here and read - Documentation/modules.txt. The module does not actually implement - the IrOBEX protocol since that protocol lives in user space, but it - contains the necessary functions to interface the user-space stuff - with the kernel. So you will need to have the user-space library and - programs that can use this library installed as well to be able to - use the IrOBEX protocol. This module will hopefully be replaced by - IrDA sockets in the future. - IrCOMM Protocol CONFIG_IRCOMM Say Y here if you want to build support for the IrCOMM protocol. If @@ -11331,7 +11609,7 @@ # LocalWords: COSA SRP muni cz kas cosa Alteon AceNIC acenic VTOC OSes GMT SAx # LocalWords: Inspiron localtime INTS Thinkpads Ralf Brown's Flightstick NNN # LocalWords: Xterminator Blackhawk NN mpu ioports DCA HPDCA HPLANCE DIO Corel -# LocalWords: GemTek gemtek CMDLINE IrDA PDA's irmanager irattach RR AVA DN +# LocalWords: GemTek gemtek CMDLINE IrDA PDA's irmanager irattach RR AVA DN rg # LocalWords: uit dagb irda LSAP IrLMP RR's IrLAP IR alloc skb's kfree skb's # LocalWords: GZIP IrLAN NetbeamIR ESI JetEye IrOBEX IrCOMM TTY's minicom dti # LocalWords: ircomm ircomm pluto thiguchi IrTTY Linux's bps NetWinder MIR NSC @@ -11340,3 +11618,4 @@ # LocalWords: alphalinux GOBIOS csn chemnitz nat ACARD AMI MegaRAID megaraid # LocalWords: QNXFS ISI isicom xterms Apollos VPN RCPCI rcpci sgi visws pcmcia # LocalWords: IrLPT UIRCC Tecra + diff -u --recursive --new-file v2.2.7/linux/Documentation/arm/Netwinder linux/Documentation/arm/Netwinder --- v2.2.7/linux/Documentation/arm/Netwinder Wed Dec 31 16:00:00 1969 +++ linux/Documentation/arm/Netwinder Sun May 2 09:51:16 1999 @@ -0,0 +1,78 @@ +NetWinder specific documentation +================================ + +The NetWinder is a small low-power computer, primarily designed +to run Linux. It is based around the StrongARM RISC processor, +DC21285 PCI bridge, with PC-type hardware glued around it. + +Port usage +========== + +Min - Max Description +--------------------------- +0x0000 - 0x000f DMA1 +0x0020 - 0x0021 PIC1 +0x0060 - 0x006f Keyboard +0x0070 - 0x007f RTC +0x0080 - 0x0087 DMA1 +0x0088 - 0x008f DMA2 +0x00a0 - 0x00a3 PIC2 +0x00c0 - 0x00df DMA2 +0x0180 - 0x0187 IRDA +0x01f0 - 0x01f6 ide0 +0x0201 Game port +0x0203 RWA010 configuration read +0x0220 - ? SoundBlaster +0x0250 - ? WaveArtist +0x0279 RWA010 configuration index +0x02f8 - 0x02ff Serial ttyS1 +0x0300 - 0x031f Ether10 +0x0338 GPIO1 +0x033a GPIO2 +0x0370 - 0x0371 W83977F configuration registers +0x0388 - ? AdLib +0x03c0 - 0x03df VGA +0x03f6 ide0 +0x03f8 - 0x03ff Serial ttyS0 +0x0400 - 0x0408 DC21143 +0x0480 - 0x0487 DMA1 +0x0488 - 0x048f DMA2 +0x0a79 RWA010 configuration write +0xe800 - 0xe80f ide0/ide1 BM DMA + + +Interrupt usage +=============== + +IRQ type Description +--------------------------- + 0 ISA 100Hz timer + 1 ISA Keyboard + 2 ISA cascade + 3 ISA Serial ttyS1 + 4 ISA Serial ttyS0 + 5 ISA PS/2 mouse + 6 ISA IRDA + 7 ISA Printer + 8 ISA RTC alarm + 9 ISA +10 ISA GP10 (Orange reset button) +11 ISA +12 ISA WaveArtist +13 ISA +14 ISA hda1 +15 ISA + +DMA usage +========= + +DMA type Description +--------------------------- + 0 ISA IRDA + 1 ISA + 2 ISA cascade + 3 ISA WaveArtist + 4 ISA + 5 ISA + 6 ISA + 7 ISA WaveArtist diff -u --recursive --new-file v2.2.7/linux/Documentation/arm/README linux/Documentation/arm/README --- v2.2.7/linux/Documentation/arm/README Wed Dec 31 16:00:00 1969 +++ linux/Documentation/arm/README Sun May 2 09:51:16 1999 @@ -0,0 +1,139 @@ + ARM Linux 2.2.3 + =============== + + * NOTE * The ARM support in the mainstream Linux kernel sources + is not up to date. Please check ftp.arm.uk.linux.org:/pub/armlinux + for latest updates. + +Compilation of kernel +--------------------- + + In order to compile ARM Linux, you will need a compiler capable of + generating ARM ELF code with GNU extensions. GCC-2.7.2.2 ELF, GCC 2.8.1 + and EGCS are good compilers. Note that GCC-2.7.2.2 ELF is rare, and + you probably don't have it. + + To build ARM Linux natively, you shouldn't have to alter the ARCH = line in + the top level Makefile. However, if you don't have the ARM Linux ELF tools + installed as default, then you should change the CROSS_COMPILE line as + detailed below. + + If you wish to cross-compile, then alter the following lines in the top + level make file: + + ARCH = + with + ARCH = arm + + and + + CROSS_COMPILE= + to + CROSS_COMPILE= + eg. + CROSS_COMPILE=arm-linux- + + Do a 'make config', followed by 'make dep', and finally 'make Image' to + build the kernel (arch/arm/boot/Image). A compressed image can be built + by doing a 'make zImage' instead of 'make Image'. + + +Bug reports etc +--------------- + + Please send patches, bug reports and code for the ARM Linux project + to linux@arm.linux.org.uk Patches will not be included into future + kernels unless they come to me (or the relevant person concerned). + + When sending bug reports, please ensure that they contain all relevant + information, eg. the kernel messages that were printed before/during + the problem, what you were doing, etc. + + For patches, please include some explanation as to what the patch does + and why (if relevant). + + +Modules +------- + + Although modularisation is supported (and required for the FP emulator), + each module on an arm2/arm250/arm3 machine when is loaded will take + memory up to the next 32k boundary due to the size of the pages. Hence is + modularisation on these machines really worth it? + + However, arm6 and up machines allow modules to take multiples of 4k, and + as such Acorn RiscPCs and other architectures using these processors can + make good use of modularisation. + + +ADFS Image files +---------------- + + You can access image files on your ADFS partitions by mounting the ADFS + partition, and then using the loopback device driver. You must have + losetup installed. + + Please note that the PCEmulator DOS partitions have a partition table at + the start, and as such, you will have to give '-o offset' to losetup. + + +Request to developers +--------------------- + + When writing device drivers which include a separate assembler file, please + include it in with the C file, and not the arch/arm/lib directory. This + allows the driver to be compiled as a loadable module without requiring + half the code to be compiled into the kernel image. + + In general, try to avoid using assembler unless it is really necessary. It + makes drivers far less easy to port to other hardware. + + +ST506 hard drives +----------------- + + The ST506 hard drive controllers seem to be working fine (if a little + slowly). At the moment they will only work off the controllers on an + A4x0's motherboard, but for it to work off a Podule just requires + someone with a podule to add the addresses for the IRQ mask and the + HDC base to the source. + + As of 31/3/96 it works with two drives (you should get the ADFS + *configure harddrive set to 2). I've got an internal 20MB and a great + big external 5.25" FH 64MB drive (who could ever want more :-) ). + + I've just got 240K/s off it (a dd with bs=128k); thats about half of what + RiscOS gets; but it's a heck of a lot better than the 50K/s I was getting + last week :-) + + Known bug: Drive data errors can cause a hang; including cases where + the controller has fixed the error using ECC. (Possibly ONLY + in that case...hmm). + + +1772 Floppy +----------- + This also seems to work OK, but hasn't been stressed much lately. It + hasn't got any code for disc change detection in there at the moment which + could be a bit of a problem! Suggestions on the correct way to do this + are welcome. + + +Kernel entry (head-armv.S) +-------------------------- + The initial entry into the kernel made via head-armv.S uses architecture + independent code. The architecture is selected by the value of 'r1' on + entry, which must be kept unique. You can register a new architecture + by mailing the following details to rmk@arm.uk.linux.org. Please give + the mail a subject of 'Register new architecture': + + Name: + ARCHDIR: + Description: + + + Please follow this format - it is an automated system. You should + receive a reply the next day. + +--- +Russell King (27/03/1999) diff -u --recursive --new-file v2.2.7/linux/Documentation/arm/nwfpe/NOTES linux/Documentation/arm/nwfpe/NOTES --- v2.2.7/linux/Documentation/arm/nwfpe/NOTES Wed Dec 31 16:00:00 1969 +++ linux/Documentation/arm/nwfpe/NOTES Sun May 2 09:51:16 1999 @@ -0,0 +1,29 @@ +There seems to be a problem with exp(double) and our emulator. I haven't +been able to track it down yet. This does not occur with the emulator +supplied by Russell King. + +I also found one oddity in the emulator. I don't think it is serious but +will point it out. The ARM calling conventions require floating point +registers f4-f7 to be preserved over a function call. The compiler quite +often uses an stfe instruction to save f4 on the stack upon entry to a +function, and an ldfe instruction to restore it before returning. + +I was looking at some code, that calculated a double result, stored it in f4 +then made a function call. Upon return from the function call the number in +f4 had been converted to an extended value in the emulator. + +This is a side effect of the stfe instruction. The double in f4 had to be +converted to extended, then stored. If an lfm/sfm combination had been used, +then no conversion would occur. This has performance considerations. The +result from the function call and f4 were used in a multiplication. If the +emulator sees a multiply of a double and extended, it promotes the double to +extended, then does the multiply in extended precision. + +This code will cause this problem: + +double x, y, z; +z = log(x)/log(y); + +The result of log(x) (a double) will be calculated, returned in f0, then +moved to f4 to preserve it over the log(y) call. The division will be done +in extended precision, due to the stfe instruction used to save f4 in log(y). diff -u --recursive --new-file v2.2.7/linux/Documentation/arm/nwfpe/README linux/Documentation/arm/nwfpe/README --- v2.2.7/linux/Documentation/arm/nwfpe/README Wed Dec 31 16:00:00 1969 +++ linux/Documentation/arm/nwfpe/README Sun May 2 09:51:16 1999 @@ -0,0 +1,70 @@ +This directory contains the version 0.92 test release of the NetWinder +Floating Point Emulator. + +The majority of the code was written by me, Scott Bambrough It is +written in C, with a small number of routines in inline assembler +where required. It was written quickly, with a goal of implementing a +working version of all the floating point instructions the compiler +emits as the first target. I have attempted to be as optimal as +possible, but there remains much room for improvement. + +I have attempted to make the emulator as portable as possible. One of +the problems is with leading underscores on kernel symbols. Elf +kernels have no leading underscores, a.out compiled kernels do. I +have attempted to use the C_SYMBOL_NAME macro wherever this may be +important. + +Another choice I made was in the file structure. I have attempted to +contain all operating system specfic code in one module (fpmodule.*). +All the other files contain emulator specific code. This should allow +others to port the emulator to NetBSD for instance relatively easily. + +The floating point operations are based on SoftFloat Release 2, by +John Hauser. SoftFloat is a software implementation of floating-point +that conforms to the IEC/IEEE Standard for Binary Floating-point +Arithmetic. As many as four formats are supported: single precision, +double precision, extended double precision, and quadruple precision. +All operations required by the standard are implemented, except for +conversions to and from decimal. We use only the single precision, +double precision and extended double precision formats. The port of +SoftFloat to the ARM was done by Phil Blundell, based on an earlier +port of SoftFloat version 1 by Neil Carson for NetBSD/arm32. + +The file README.FPE contains a description of what has been implemented +so far in the emulator. The file TODO contains a information on what +remains to be done, and other ideas for the emulator. + +Bug reports, comments, suggestions should be directed to me at +. General reports of "this program doesn't +work correctly when your emulator is installed" are useful for +determining that bugs still exist; but are virtually useless when +attempting to isolate the problem. Please report them, but don't +expect quick action. Bugs still exist. The problem remains in isolating +which instruction contains the bug. Small programs illustrating a specific +problem are a godsend. + +Legal Notices +------------- + +The NetWinder Floating Point Emulator is free software. Everything Corel +has written is provided under the GNU GPL. See the file COPYING for copying +conditions. Excluded from the above is the SoftFloat code. John Hauser's +legal notice for SoftFloat is included below. + +------------------------------------------------------------------------------- +SoftFloat Legal Notice + +SoftFloat was written by John R. Hauser. This work was made possible in +part by the International Computer Science Institute, located at Suite 600, +1947 Center Street, Berkeley, California 94704. Funding was partially +provided by the National Science Foundation under grant MIP-9311980. The +original version of this code was written as part of a project to build +a fixed-point vector processor in collaboration with the University of +California at Berkeley, overseen by Profs. Nelson Morgan and John Wawrzynek. + +THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort +has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT +TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO +PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY +AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. +------------------------------------------------------------------------------- diff -u --recursive --new-file v2.2.7/linux/Documentation/arm/nwfpe/README.FPE linux/Documentation/arm/nwfpe/README.FPE --- v2.2.7/linux/Documentation/arm/nwfpe/README.FPE Wed Dec 31 16:00:00 1969 +++ linux/Documentation/arm/nwfpe/README.FPE Sun May 2 09:51:16 1999 @@ -0,0 +1,156 @@ +The following describes the current state of the NetWinder's floating point +emulator. + +In the following nomenclature is used to describe the floating point +instructions. It follows the conventions in the ARM manual. + + = , no default +{P|M|Z} = {round to +infinity,round to -infinity,round to zero}, + default = round to nearest + +Note: items enclosed in {} are optional. + +Floating Point Coprocessor Data Transfer Instructions (CPDT) +------------------------------------------------------------ + +LDF/STF - load and store floating + +{cond} Fd, Rn +{cond} Fd, [Rn, #]{!} +{cond} Fd, [Rn], # + +These instructions are fully implemented. + +LFM/SFM - load and store multiple floating + +Form 1 syntax: +{cond} Fd, , [Rn] +{cond} Fd, , [Rn, #]{!} +{cond} Fd, , [Rn], # + +Form 2 syntax: +{cond} Fd, , [Rn]{!} + +These instructions are fully implemented. They store/load three words +for each floating point register into the memory location given in the +instruction. The format in memory is unlikely to be compatible with +other implementations, in particular the actual hardware. Specific +mention of this is made in the ARM manuals. + +Floating Point Coprocessor Register Transfer Instructions (CPRT) +---------------------------------------------------------------- + +Conversions, read/write status/control register instructions + +FLT{cond}{P,M,Z} Fn, Rd Convert integer to floating point +FIX{cond}{P,M,Z} Rd, Fn Convert floating point to integer +WFS{cond} Rd Write floating point status register +RFS{cond} Rd Read floating point status register +WFC{cond} Rd Write floating point control register +RFC{cond} Rd Read floating point control register + +FLT/FIX are fully implemented. + +RFS/WFS are fully implemented. + +RFC/WFC are fully implemented. RFC/WFC are supervisor only instructions, and +presently check the CPU mode, and do an invalid instruction trap if not called +from supervisor mode. + +Compare instructions + +CMF{cond} Fn, Fm Compare floating +CMFE{cond} Fn, Fm Compare floating with exception +CNF{cond} Fn, Fm Compare negated floating +CNFE{cond} Fn, Fm Compare negated floating with exception + +These are fully implemented. + +Floating Point Coprocessor Data Instructions (CPDT) +--------------------------------------------------- + +Dyadic operations: + +ADF{cond}{P,M,Z} Fd, Fn, - add +SUF{cond}{P,M,Z} Fd, Fn, - subtract +RSF{cond}{P,M,Z} Fd, Fn, - reverse subtract +MUF{cond}{P,M,Z} Fd, Fn, - multiply +DVF{cond}{P,M,Z} Fd, Fn, - divide +RDV{cond}{P,M,Z} Fd, Fn, - reverse divide + +These are fully implemented. + +FML{cond}{P,M,Z} Fd, Fn, - fast multiply +FDV{cond}{P,M,Z} Fd, Fn, - fast divide +FRD{cond}{P,M,Z} Fd, Fn, - fast reverse divide + +These are fully implemented as well. They use the same algorithm as the +non-fast versions. Hence, in this implementation their performance is +equivalent to the MUF/DVF/RDV instructions. This is acceptable according +to the ARM manual. The manual notes these are defined only for single +operands, on the actual FPA11 hardware they do not work for double or +extended precision operands. The emulator currently does not check +the requested permissions conditions, and performs the requested operation. + +RMF{cond}{P,M,Z} Fd, Fn, - IEEE remainder + +This is fully implemented. + +Monadic operations: + +MVF{cond}{P,M,Z} Fd, - move +MNF{cond}{P,M,Z} Fd, - move negated + +These are fully implemented. + +ABS{cond}{P,M,Z} Fd, - absolute value +SQT{cond}{P,M,Z} Fd, - square root +RND{cond}{P,M,Z} Fd, - round + +These are fully implemented. + +URD{cond}{P,M,Z} Fd, - unnormalized round +NRM{cond}{P,M,Z} Fd, - normalize + +These are implemented. URD is implemented using the same code as the RND +instruction. Since URD cannot return a unnormalized number, NRM becomes +a NOP. + +Library calls: + +POW{cond}{P,M,Z} Fd, Fn, - power +RPW{cond}{P,M,Z} Fd, Fn, - reverse power +POL{cond}{P,M,Z} Fd, Fn, - polar angle (arctan2) + +LOG{cond}{P,M,Z} Fd, - logarithm to base 10 +LGN{cond}{P,M,Z} Fd, - logarithm to base e +EXP{cond}{P,M,Z} Fd, - exponent +SIN{cond}{P,M,Z} Fd, - sine +COS{cond}{P,M,Z} Fd, - cosine +TAN{cond}{P,M,Z} Fd, - tangent +ASN{cond}{P,M,Z} Fd, - arcsine +ACS{cond}{P,M,Z} Fd, - arccosine +ATN{cond}{P,M,Z} Fd, - arctangent + +These are not implemented. They are not currently issued by the compiler, +and are handled by routines in libc. These are not implemented by the FPA11 +hardware, but are handled by the floating point support code. They should +be implemented in future versions. + +Signalling: + +Signals are implemented. However current ELF kernels produced by Corel +Computer have a bug in them that prevents the module from generating a +SIGFPE. This is caused by a failure to alias fp_current to the kernel +variable current_set[0] correctly. + +The kernel provided with this distribution (vmlinux-nwfpe-0.93) contains +a fix for this problem and also incorporates the current version of the +emulator directly. It is possible to run with no floating point module +loaded with this kernel. It is provided as a demonstration of the +technology and for those who want to do floating point work that depends +on signals. It is not strictly necessary to use the module. + +A module (either the one provided by Russell King, or the one in this +distribution) can be loaded to replace the functionality of the emulator +built into the kernel. diff -u --recursive --new-file v2.2.7/linux/Documentation/arm/nwfpe/TODO linux/Documentation/arm/nwfpe/TODO --- v2.2.7/linux/Documentation/arm/nwfpe/TODO Wed Dec 31 16:00:00 1969 +++ linux/Documentation/arm/nwfpe/TODO Sun May 2 09:51:16 1999 @@ -0,0 +1,67 @@ +TODO LIST +--------- + +POW{cond}{P,M,Z} Fd, Fn, - power +RPW{cond}{P,M,Z} Fd, Fn, - reverse power +POL{cond}{P,M,Z} Fd, Fn, - polar angle (arctan2) + +LOG{cond}{P,M,Z} Fd, - logarithm to base 10 +LGN{cond}{P,M,Z} Fd, - logarithm to base e +EXP{cond}{P,M,Z} Fd, - exponent +SIN{cond}{P,M,Z} Fd, - sine +COS{cond}{P,M,Z} Fd, - cosine +TAN{cond}{P,M,Z} Fd, - tangent +ASN{cond}{P,M,Z} Fd, - arcsine +ACS{cond}{P,M,Z} Fd, - arccosine +ATN{cond}{P,M,Z} Fd, - arctangent + +These are not implemented. They are not currently issued by the compiler, +and are handled by routines in libc. These are not implemented by the FPA11 +hardware, but are handled by the floating point support code. They should +be implemented in future versions. + +There are a couple of ways to approach the implementation of these. One +method would be to use accurate table methods for these routines. I have +a couple of papers by S. Gal from IBM's research labs in Haifa, Israel that +seem to promise extreme accuracy (in the order of 99.8%) and reasonable speed. +These methods are used in GLIBC for some of the transcendental functions. + +Another approach, which I know little about is CORDIC. This stands for +Coordinate Rotation Digital Computer, and is a method of computing +transcendental functions using mostly shifts and adds and a few +multiplications and divisions. The ARM excels at shifts and adds, +so such a method could be promising, but requires more research to +determine if it is feasible. + +Rounding Methods + +The IEEE standard defines 4 rounding modes. Round to nearest is the +default, but rounding to + or - infinity or round to zero are also allowed. +Many architectures allow the rounding mode to be specified by modifying bits +in a control register. Not so with the ARM FPA11 architecture. To change +the rounding mode one must specify it with each instruction. + +This has made porting some benchmarks difficult. It is possible to +introduce such a capability into the emulator. The FPCR contains +bits describing the rounding mode. The emulator could be altered to +examine a flag, which if set forced it to ignore the rounding mode in +the instruction, and use the mode specified in the bits in the FPCR. + +This would require a method of getting/setting the flag, and the bits +in the FPCR. This requires a kernel call in ArmLinux, as WFC/RFC are +supervisor only instructions. If anyone has any ideas or comments I +would like to hear them. + +[NOTE: pulled out from some docs on ARM floating point, specifically + for the Acorn FPE, but not limited to it: + + The floating point control register (FPCR) may only be present in some + implementations: it is there to control the hardware in an implementation- + specific manner, for example to disable the floating point system. The user + mode of the ARM is not permitted to use this register (since the right is + reserved to alter it between implementations) and the WFC and RFC + instructions will trap if tried in user mode. + + Hence, the answer is yes, you could do this, but then you will run a high + risk of becoming isolated if and when hardware FP emulation comes out + -- Russell]. diff -u --recursive --new-file v2.2.7/linux/Documentation/digiboard.txt linux/Documentation/digiboard.txt --- v2.2.7/linux/Documentation/digiboard.txt Fri Jan 8 22:35:58 1999 +++ linux/Documentation/digiboard.txt Thu Apr 29 11:53:41 1999 @@ -111,7 +111,7 @@ Boot-time configuration when linked into the kernel --------------------------------------------------- -Per Board to be configured, pass a digi= commandline parameter to the +Per board to be configured, pass a digi= command-line parameter to the kernel using lilo or loadlin. It consists of a string of comma separated identifiers or integers. The 6 values in order are: @@ -142,7 +142,7 @@ append="digi=1,0,0,16,512,851968" -If you don't give a digi= commandline, the compiled-in defaults of +If you don't give a digi= command line, the compiled-in defaults of board 1: io=0x200, membase=0xd0000, altpin=off and numports=16 are used. If you have the resources (io&mem) free for use, configure your board to @@ -153,9 +153,9 @@ Sources of Information ---------------------- -Webpage: http://private.fuller.edu/clameter/digi.html +Web page: http://private.fuller.edu/clameter/digi.html -Mailing List: digiboard@list.fuller.edu +Mailing list: digiboard@list.fuller.edu (Write e-mail to that address to subscribe. Common ListServ commands work. Archive of messages available) diff -u --recursive --new-file v2.2.7/linux/Documentation/digiepca.txt linux/Documentation/digiepca.txt --- v2.2.7/linux/Documentation/digiepca.txt Fri Jan 8 22:35:58 1999 +++ linux/Documentation/digiepca.txt Thu Apr 29 11:53:41 1999 @@ -11,7 +11,7 @@ The Linux MAKEDEV command does not support generating the Digiboard Devices. Users executing digiConfig to setup EISA and PC series cards -will have their device nodes automaticly constructed (cud?? for ~CLOCAL, +will have their device nodes automatically constructed (cud?? for ~CLOCAL, and ttyD?? for CLOCAL). Users wishing to boot their board from the LILO prompt, or those users booting PCI cards may use buildDIGI to construct the necessary nodes. @@ -19,7 +19,7 @@ Notes: ------ This driver may be configured via LILO. For users who have already configured -their driver using digiConfig, configuring from lilo will override previous +their driver using digiConfig, configuring from LILO will override previous settings. Multiple boards may be configured by issuing multiple LILO command lines. For examples see the bottom of this document. diff -u --recursive --new-file v2.2.7/linux/Documentation/fb/matroxfb.txt linux/Documentation/fb/matroxfb.txt --- v2.2.7/linux/Documentation/fb/matroxfb.txt Wed Apr 28 11:37:29 1999 +++ linux/Documentation/fb/matroxfb.txt Thu Apr 29 11:53:41 1999 @@ -95,11 +95,11 @@ ======= Driver contains SVGALib compatibility code. It is turned on by choosing textual -mode for console. You can do it at boottime by using videomode +mode for console. You can do it at boot time by using videomode 2,3,7,0x108-0x10C or 0x1C0. At runtime, `fbset -depth 0' does this work. Unfortunately, after SVGALib application exits, screen contents is corrupted. -Switching to another console and back fixes it. I hope that it is SVGALib and -not mine problem, but I'm not sure. +Switching to another console and back fixes it. I hope that it is SVGALib's +problem and not mine, but I'm not sure. Configuration @@ -113,7 +113,7 @@ mem:X - size of memory (X can be in megabytes, kilobytes or bytes) You can only decrease value determined by driver because of it always probe for memory. Default is to use whole detected - memory usable for on-screen display (i.e. max. 8MB). + memory usable for on-screen display (i.e. max. 8 MB). disabled - do not load driver; you can use also `off', but `disabled' is here too. enabled - load driver, if you have `video=matrox:disabled' in LILO @@ -159,7 +159,7 @@ inv24 - change timings parameters for 24bpp modes on Millenium and Millenium II. Specify this if you see strange color shadows around characters. -noinv24 - use standard timmings. It is default. +noinv24 - use standard timings. It is the default. inverse - invert colors on screen (for LCD displays) noinverse - show true colors on screen. It is default. dev:X - bind driver to device X. Driver numbers device from 0 up to N, @@ -252,25 +252,25 @@ access to /dev/fb* - everyone with access to this device can destroy your monitor, believe me...). + 24bpp does not support correctly XF-FBDev on big-endian architectures. - + interlaced text mode is not supported; it looks like hardware limitiation, + + interlaced text mode is not supported; it looks like hardware limitation, but I'm not sure. + G200 SGRAM/SDRAM is not autodetected. + maybe more... And following misfeatures: + SVGALib does not restore screen on exit. + pixclock for text modes is limited by hardware to - 83MHz on G200 - 66MHz on Millenium I - 60MHz on Millenium II - Because of I have not access to other devices, I do not know specific + 83 MHz on G200 + 66 MHz on Millennium I + 60 MHz on Millennium II + Because I have no access to other devices, I do not know specific frequencies for them. So driver does not check this and allows you to - set frequency higher that this. It cause sparks, black holes and other - pretty effects on screen. Device was not destroyed during tests :-) - + my Millenium G200 oscillator has frequency range from 35MHz to 380MHz - (and it works with 8bpp on about 320MHz dotclocks (and changed mclk)). - But Matrox says on product sheet that VCO limit is 50-250MHz, so I believe - them (maybe that chip overheates, but it has very big cooler (G100 has - not one), so it should work). + set frequency higher that this. It causes sparks, black holes and other + pretty effects on screen. Device was not destroyed during tests. :-) + + my Millennium G200 oscillator has frequency range from 35 MHz to 380 MHz + (and it works with 8bpp on about 320 MHz dotclocks (and changed mclk)). + But Matrox says on product sheet that VCO limit is 50-250 MHz, so I believe + them (maybe that chip overheats, but it has a very big cooler (G100 has + none), so it should work). + special mixed video/graphics videomodes of Mystique and Gx00 - 2G8V16 and G16V16 are not supported + color keying is not supported @@ -281,14 +281,14 @@ specify vslen=4000 and so on). + maybe more... And following features: - + 4bpp is available only on Millenium I and Millenium II. It is hardware - limitiation. + + 4bpp is available only on Millennium I and Millennium II. It is hardware + limitation. + current fbset is not able to set 15bpp videomode: you must specify depth==16 and green.length==5. fbset does not allow you to set green.length. + text mode uses 6 bit VGA palette instead of 8 bit (one of 262144 colors instead of one of 16M colors). It is due to hardware limitation of - MilleniumI/II and SVGALib compatibility. + Millennium I/II and SVGALib compatibility. Benchmarks @@ -296,14 +296,14 @@ It is time to redraw whole screen 1000 times in 1024x768, 60Hz. It is time for draw 6144000 characters on screen through /dev/vcsa (for 32bpp it is about 3GB of data (exactly 3000 MB); for 8x16 font in -16 seconds, i.e. 187MBps). +16 seconds, i.e. 187 MBps). Times were obtained from one older version of driver, now they are about 3% -faster, it is kernel-space only time on P-II/350MHz, Millenium I in 33MHz +faster, it is kernel-space only time on P-II/350 MHz, Millennium I in 33 MHz PCI slot, G200 in AGP 2x slot. I did not test vgacon. NOACCEL 8x16 12x22 - MilleniumI G200 MilleniumI G200 + Millennium I G200 Millennium I G200 8bpp 16.42 9.54 12.33 9.13 16bpp 21.00 15.70 19.11 15.02 24bpp 36.66 36.66 35.00 35.00 @@ -311,7 +311,7 @@ ACCEL, nofastfont 8x16 12x22 6x11 - MilleniumI G200 MilleniumI G200 MilleniumI G200 + Millennium I G200 Millennium I G200 Millennium I G200 8bpp 7.79 7.24 13.55 7.78 30.00 21.01 16bpp 9.13 7.78 16.16 7.78 30.00 21.01 24bpp 14.17 10.72 18.69 10.24 34.99 21.01 @@ -319,7 +319,7 @@ ACCEL, fastfont 8x16 12x22 6x11 - MilleniumI G200 MilleniumI G200 MilleniumI G200 + Millennium I G200 Millennium I G200 Millennium I G200 8bpp 8.41 6.01 6.54 4.37 16.00 10.51 16bpp 9.54 9.12 8.76 6.17 17.52 14.01 24bpp 15.00 12.36 11.67 10.00 22.01 18.32 @@ -327,10 +327,10 @@ TEXT 8x16 - MilleniumI G200 + Millennium I G200 TEXT 3.29 1.50 -* Yes, it is slower than Millenium I. +* Yes, it is slower than Millennium I. -- Petr Vandrovec diff -u --recursive --new-file v2.2.7/linux/Documentation/fb/vesafb.txt linux/Documentation/fb/vesafb.txt --- v2.2.7/linux/Documentation/fb/vesafb.txt Fri Apr 16 14:47:30 1999 +++ linux/Documentation/fb/vesafb.txt Thu Apr 29 11:53:41 1999 @@ -10,7 +10,7 @@ This means we decide at boot time whenever we want to run in text or graphics mode. Switching mode later on (in protected mode) is -impossible; BIOS calls work in real mode only. VESA BIOS Extentions +impossible; BIOS calls work in real mode only. VESA BIOS Extensions Version 2.0 are required, because we need a linear frame buffer. Advantages: @@ -66,10 +66,10 @@ mode at the "vga=ask" prompt. For example if you like to use 1024x768x256 colors you have to say "305" at this prompt. -If this does not work, this might be becauce your BIOS does not support -linear framebuffers or becauce it does not support this mode at all. +If this does not work, this might be because your BIOS does not support +linear framebuffers or because it does not support this mode at all. Even if your board does, it might be the BIOS which does not. VESA BIOS -Extentions v2.0 are required, 1.2 is NOT sufficient. You will get a +Extensions v2.0 are required, 1.2 is NOT sufficient. You will get a "bad mode number" message if something goes wrong. 1. Note: LILO cannot handle hex, for booting directly with @@ -99,8 +99,8 @@ available) and boot linux with loadlin. * use a native driver (matroxfb/atyfb) instead if vesafb. If none is available, write a new one! - * VBE 3.0 might work too. I havn't neither a gfx board with VBE 3.0 - support nor the specs, so I havn't checked this yet. But maybe... + * VBE 3.0 might work too. I have neither a gfx board with VBE 3.0 + support nor the specs, so I have not checked this yet. Configuration @@ -108,7 +108,7 @@ The VESA BIOS provides protected mode interface for changing some parameters. vesafb can use it for palette changes and -to pan the display. It is turned off by default becauce it +to pan the display. It is turned off by default because it seems not to work with some BIOS versions, but there are options to turn it on. @@ -124,7 +124,7 @@ interface. The visible screen is just a window of the video memory, console scrolling is done by changing the start of the window. - pro: * scrolling (fullscreen) is fast, becauce there is + pro: * scrolling (fullscreen) is fast, because there is no need to copy around data. * You'll get scrollback (the Shift-PgUp thing), the video memory can be used as scrollback buffer diff -u --recursive --new-file v2.2.7/linux/Documentation/filesystems/00-INDEX linux/Documentation/filesystems/00-INDEX --- v2.2.7/linux/Documentation/filesystems/00-INDEX Fri Apr 16 14:47:30 1999 +++ linux/Documentation/filesystems/00-INDEX Sun May 2 09:51:16 1999 @@ -1,5 +1,7 @@ 00-INDEX - this file (info on some of the filesystems supported by linux). +adfs.txt + - info and mount options for the Acorn Advanced Disc Filing System. affs.txt - info and mount options for the Amiga Fast File System. coda.txt diff -u --recursive --new-file v2.2.7/linux/Documentation/filesystems/adfs.txt linux/Documentation/filesystems/adfs.txt --- v2.2.7/linux/Documentation/filesystems/adfs.txt Wed Dec 31 16:00:00 1969 +++ linux/Documentation/filesystems/adfs.txt Sun May 2 09:51:16 1999 @@ -0,0 +1,57 @@ +Mount options for ADFS +---------------------- + + uid=nnn All files in the partition will be owned by + user id nnn. Default 0 (root). + gid=nnn All files in the partition willbe in group + nnn. Default 0 (root). + ownmask=nnn The permission mask for ADFS 'owner' permissions + will be nnn. Default 0700. + othmask=nnn The permission mask for ADFS 'other' permissions + will be nnn. Default 0077. + +Mapping of ADFS permissions to Linux permissions +------------------------------------------------ + + ADFS permissions consist of the following: + + Owner read + Owner write + Other read + Other write + + (In older versions, an 'execute' permission did exist, but this + does not hold the same meaning as the Linux 'execute' permission + and is now obsolete). + + The mapping is performed as follows: + + Owner read -> -r--r--r-- + Owner write -> --w--w---w + Owner read and filetype UnixExec -> ---x--x--x + These are then masked by ownmask, eg 700 -> -rwx------ + Possible owner mode permissions -> -rwx------ + + Other read -> -r--r--r-- + Other write -> --w--w--w- + Other read and filetype UnixExec -> ---x--x--x + These are then masked by othmask, eg 077 -> ----rwxrwx + Possible other mode permissions -> ----rwxrwx + + Hence, with the default masks, if a file is owner read/write, and + not a UnixExec filetype, then the permissions will be: + + -rw------- + + However, if the masks were ownmask=0770,othmask=0007, then this would + be modified to: + -rw-rw---- + + There is no restriction on what you can do with these masks. You may + wish that either read bits give read access to the file for all, but + keep the default write protection (ownmask=0755,othmask=0577): + + -rw-r--r-- + + You can therefore tailor the permission translation to whatever you + desire the permissions should be under Linux. diff -u --recursive --new-file v2.2.7/linux/Documentation/filesystems/coda.txt linux/Documentation/filesystems/coda.txt --- v2.2.7/linux/Documentation/filesystems/coda.txt Wed Jun 24 22:54:02 1998 +++ linux/Documentation/filesystems/coda.txt Thu Apr 29 11:53:41 1999 @@ -776,7 +776,7 @@ indicate confusion between the system call creat and the VFS operation create. The VFS operation create is only called to create new objects. This create call differs from the Unix one in that it is not invoked - to return a file descriptor. The trunctate and exclusive options, + to return a file descriptor. The truncate and exclusive options, together with the mode, could simply be part of the mode as it is under Unix. There should be no flags argument; this is used in open (2) to return a file descriptor for READ or WRITE mode. diff -u --recursive --new-file v2.2.7/linux/Documentation/filesystems/smbfs.txt linux/Documentation/filesystems/smbfs.txt --- v2.2.7/linux/Documentation/filesystems/smbfs.txt Fri Jan 23 18:10:31 1998 +++ linux/Documentation/filesystems/smbfs.txt Thu Apr 29 11:53:41 1999 @@ -1,7 +1,7 @@ Smbfs is a filesystem that implements the SMB protocol, which is the protocol used by Windows for Workgroups, Windows 95 and Windows NT. Smbfs was inspired by Samba, the program written by Andrew Tridgell -that turns any unix host into a file server for DOS or Windows clients. +that turns any Unix host into a file server for DOS or Windows clients. See ftp://nimbus.anu.edu.au/pub/tridge/samba/ for this interesting program suite and much more information on SMB, NetBIOS over TCP/IP, and explanations for concepts like netbios name or share. diff -u --recursive --new-file v2.2.7/linux/Documentation/filesystems/vfat.txt linux/Documentation/filesystems/vfat.txt --- v2.2.7/linux/Documentation/filesystems/vfat.txt Wed Jun 24 22:54:02 1998 +++ linux/Documentation/filesystems/vfat.txt Thu Apr 29 11:53:41 1999 @@ -177,7 +177,7 @@ Because the extended FAT system is backward compatible, it is possible for old software to modify directory entries. Measures must -be taken to insure the validity of slots. An extended FAT system can +be taken to ensure the validity of slots. An extended FAT system can verify that a slot does in fact belong to an 8.3 directory entry by the following: diff -u --recursive --new-file v2.2.7/linux/Documentation/networking/filter.txt linux/Documentation/networking/filter.txt --- v2.2.7/linux/Documentation/networking/filter.txt Sun Jun 7 11:16:26 1998 +++ linux/Documentation/networking/filter.txt Thu Apr 29 11:53:41 1999 @@ -12,7 +12,7 @@ attach a filter onto any socket and allow or disallow certain types of data to come through the socket. LSF follows exactly the same filter code structure as the BSD Berkeley Packet Filter -(BPF), so refering to the BSD bpf.4 manpage is very helpful in +(BPF), so referring to the BSD bpf.4 manpage is very helpful in creating filters. LSF is much simpler than BPF. One does not have to worry about diff -u --recursive --new-file v2.2.7/linux/Documentation/networking/ip-sysctl.txt linux/Documentation/networking/ip-sysctl.txt --- v2.2.7/linux/Documentation/networking/ip-sysctl.txt Thu Jan 7 15:11:35 1999 +++ linux/Documentation/networking/ip-sysctl.txt Thu Apr 29 11:53:41 1999 @@ -96,7 +96,7 @@ Enable timestamps as defined in RFC1323. tcp_sack - BOOLEAN - Enable select acknowledgements. + Enable select acknowledgments. tcp_retrans_collapse - BOOLEAN Bug-to-bug compatibility with some broken printers. @@ -119,7 +119,7 @@ icmp_paramprob_rate - INTEGER icmp_timeexceed_rate - INTEGER icmp_echoreply_rate - INTEGER (not enabled per default) - Limit the maximal rates for sending ICMP packets to specifc targets. + Limit the maximal rates for sending ICMP packets to specific targets. 0 to disable any limiting, otherwise the maximal rate in jiffies(1) See the source for more information. @@ -173,7 +173,7 @@ bootp_relay - BOOLEAN Accept packets with source address 0.b.c.d destined not to this host as local ones. It is supposed, that - BOOTP relay deamon will catch and forward such packets. + BOOTP relay daemon will catch and forward such packets. default FALSE Not Implemented Yet. diff -u --recursive --new-file v2.2.7/linux/Documentation/networking/ipddp.txt linux/Documentation/networking/ipddp.txt --- v2.2.7/linux/Documentation/networking/ipddp.txt Sat May 2 14:19:51 1998 +++ linux/Documentation/networking/ipddp.txt Thu Apr 29 11:53:41 1999 @@ -14,7 +14,7 @@ IP over an AppleTalk network or you can provide IP gatewaying functions for your AppleTalk users. -You can currently Encapsulate or Decapsulate AppleTalk-IP on LocalTalk, +You can currently encapsulate or decapsulate AppleTalk-IP on LocalTalk, EtherTalk and PPPTalk. The only limit on the protocol is that of what kernel AppleTalk layer and drivers are available. @@ -23,22 +23,22 @@ Compiling AppleTalk-IP Decapsulation/Encapsulation ================================================= -AppleTalk-IP Decapsulation needs to be compiled into your kernel. You -will need to turn on Appletalk-IP driver support. Then you will need to -select ONE of the two options; IP to AppleTalk-IP Encapsulation support or -AppleTalk-IP to IP Decapsulation support. If you compile the driver +AppleTalk-IP decapsulation needs to be compiled into your kernel. You +will need to turn on AppleTalk-IP driver support. Then you will need to +select ONE of the two options; IP to AppleTalk-IP encapsulation support or +AppleTalk-IP to IP decapsulation support. If you compile the driver statically you will only be able to use the driver for the function you have enabled in the kernel. If you compile the driver as a module you can select what mode you want it to run in via a module loading param. -ipddp_mode=1 for AppleTalk-IP Encapsulation and ipddp_mode=2 for -AppleTalk-IP to IP Decapsulation. +ipddp_mode=1 for AppleTalk-IP encapsulation and ipddp_mode=2 for +AppleTalk-IP to IP decapsulation. Basic instructions for user space tools ======================================= -To enable AppleTalk-IP Decapsulation/Encapsulation you will need the -proper tools. You can get the tools for Decapsulation from -http://spacs1.spacs.k12.wi.us/~jschlst/MacGate and for Encapsulation +To enable AppleTalk-IP decapsulation/encapsulation you will need the +proper tools. You can get the tools for decapsulation from +http://spacs1.spacs.k12.wi.us/~jschlst/MacGate and for encapsulation from http://www.maths.unm.edu/~bradford/ltpc.html I will briefly describe the operation of the tools, but you will @@ -61,8 +61,8 @@ Common Uses of ipddp.c ---------------------- -Of course AppleTalk-IP Decapsulation and Encapsulation, but specificly -Decapsulation is being used most for connecting LocalTalk networks to +Of course AppleTalk-IP decapsulation and encapsulation, but specifically +decapsulation is being used most for connecting LocalTalk networks to IP networks. Although it has been used on EtherTalk networks to allow Macs that are only able to tunnel IP over EtherTalk. @@ -73,6 +73,6 @@ Further Assistance ------------------- You can contact me (Jay Schulist ) with any -questions reguarding Decapsulation or Encapsulation. Bradford W. Johnson +questions regarding decapsulation or encapsulation. Bradford W. Johnson originally wrote the ipddp.c driver for IP encapsulation in AppleTalk. diff -u --recursive --new-file v2.2.7/linux/Documentation/powerpc/smp.txt linux/Documentation/powerpc/smp.txt --- v2.2.7/linux/Documentation/powerpc/smp.txt Fri Oct 23 22:01:18 1998 +++ linux/Documentation/powerpc/smp.txt Thu Apr 29 12:39:07 1999 @@ -5,11 +5,10 @@ (Cort Dougan, cort@cs.nmt.edu) please email me if you have questions, comments or corrections. -Last Change: 10.8.98 +Last Change: 3.31.99 -SMP support for Linux/PPC is still in its early stages and likely to -be buggy for a while. If you want to help by writing code or testing -different hardware please email me! +If you want to help by writing code or testing different hardware please +email me! 1. State of Supported Hardware @@ -29,3 +28,7 @@ BeBox BeBox support hasn't been added to the 2.1.X kernels from 2.0.X but work is being done and SMP support for BeBox is in the works. + + CHRP + CHRP SMP works and is fairly solid. It's been tested on the IBM F50 + with 4 processors for quite some time now. diff -u --recursive --new-file v2.2.7/linux/Documentation/sound/AD1816 linux/Documentation/sound/AD1816 --- v2.2.7/linux/Documentation/sound/AD1816 Tue Dec 22 14:16:53 1998 +++ linux/Documentation/sound/AD1816 Thu Apr 29 11:53:41 1999 @@ -105,7 +105,7 @@ As the driver is still experimental and under development, you should watch out for updates. Updates of the driver are available on the -internet from one of my home pages: +Internet from one of my home pages: http://www.student.informatik.tu-darmstadt.de/~tek/projects/linux.html or: http://www.tu-darmstadt.de/~tek01/projects/linux.html diff -u --recursive --new-file v2.2.7/linux/Documentation/sound/AWE32 linux/Documentation/sound/AWE32 --- v2.2.7/linux/Documentation/sound/AWE32 Thu Jan 7 15:11:35 1999 +++ linux/Documentation/sound/AWE32 Thu Apr 29 11:53:41 1999 @@ -53,7 +53,7 @@ (IO 2 (BASE 0x0E20)) (ACT Y) ))" Resources 0x0620, 0x0A20 and 0x0E20 should work. Other on-board devices: -Gameport and StereoEnhance are not required to be inited. +Gameport and StereoEnhance are not required to be initialized. Now you can execute "isapnp /etc/isapnp.conf". No errors should be reported. If you correctly installed isapnptools, then isapnp will run every boot time. diff -u --recursive --new-file v2.2.7/linux/Documentation/sound/AudioExcelDSP16 linux/Documentation/sound/AudioExcelDSP16 --- v2.2.7/linux/Documentation/sound/AudioExcelDSP16 Fri Jan 8 22:35:59 1999 +++ linux/Documentation/sound/AudioExcelDSP16 Thu Apr 29 11:53:41 1999 @@ -80,7 +80,7 @@ 2) Install your new kernel as the default boot kernel. 3) Boot MS-DOS and configure the audio card with the boot time device driver, for MSS irq10 dma3 in our example. -4) -- and boot Linux. This will mantain the DOS configuration +4) -- and boot Linux. This will maintain the DOS configuration and will boot the new kernel with sound driver. The sound driver will find the audio card and will recognize and attach it. diff -u --recursive --new-file v2.2.7/linux/Documentation/sound/ChangeLog.awe linux/Documentation/sound/ChangeLog.awe --- v2.2.7/linux/Documentation/sound/ChangeLog.awe Tue Dec 22 14:16:53 1998 +++ linux/Documentation/sound/ChangeLog.awe Thu Apr 29 11:53:41 1999 @@ -81,7 +81,7 @@ ver.0.3.3b - Fix version number in awe_version.h - - Fix a small bug in noteoff/relese all + - Fix a small bug in noteoff/release all ver.0.3.3a - Fix all notes/sounds off diff -u --recursive --new-file v2.2.7/linux/Documentation/sound/INSTALL.awe linux/Documentation/sound/INSTALL.awe --- v2.2.7/linux/Documentation/sound/INSTALL.awe Tue Dec 22 14:16:53 1998 +++ linux/Documentation/sound/INSTALL.awe Thu Apr 29 11:53:41 1999 @@ -17,7 +17,7 @@ http://www-jcr.lmh.ox.ac.uk/~pnp/ ---------------------------------------------------------------- -* Installation on RedHat 5.0 Sound Driver +* Installation on Red Hat 5.0 Sound Driver Please use install-rh.sh under RedHat5.0 directory. DO NOT USE install.sh below. @@ -31,7 +31,7 @@ % su 2. If you have never configured the kernel tree yet, run make config - once (to make depencies and symlinks). + once (to make dependencies and symlinks). # cd /usr/src/linux # make xconfig @@ -40,7 +40,7 @@ # sh ./install.sh - 4. Configure your kenrel + 4. Configure your kernel (for Linux 2.[01].x user) # cd /usr/src/linux @@ -77,7 +77,7 @@ do it by isapnp tools. Otherwise, skip to 8. This section described only a brief explanation. For more - detaills, please see AWE64-Mini-HOWTO or isapnp tools FAQ. + details, please see the AWE64-Mini-HOWTO or isapnp tools FAQ. 7a. If you have no isapnp.conf file, generate it by pnpdump. Otherwise, skip to 7d. diff -u --recursive --new-file v2.2.7/linux/Documentation/sound/Introduction linux/Documentation/sound/Introduction --- v2.2.7/linux/Documentation/sound/Introduction Tue Dec 22 14:16:53 1998 +++ linux/Documentation/sound/Introduction Thu Apr 29 11:53:41 1999 @@ -214,7 +214,7 @@ 3) In /etc/conf.modules when using modprobe. -4) Via RedHat's /usr/sbin/sndconfig program (text based). +4) Via Red Hat's /usr/sbin/sndconfig program (text based). 5) Via the OSS soundconf program (with the commercial version of the OSS driver. @@ -240,7 +240,7 @@ 6) The comments and code in linux/drivers/sound. -7) The sndconfig and rhsound documentation from RedHat. +7) The sndconfig and rhsound documentation from Red Hat. 8) The Linux-sound mailing list: sound-list@redhat.com diff -u --recursive --new-file v2.2.7/linux/Documentation/sound/MAD16 linux/Documentation/sound/MAD16 --- v2.2.7/linux/Documentation/sound/MAD16 Wed Apr 8 19:36:24 1998 +++ linux/Documentation/sound/MAD16 Thu Apr 29 11:53:41 1999 @@ -23,3 +23,12 @@ 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 + + +To get the built in mixer to work this needs to be: + +options adlib_card io=0x388 # FM synthesizer +options sb mad16=1 +options mad16 io=0x530 irq=7 dma=0 dma16=1 mpu_io=816 mpu_irq=5 && /usr/local/bin/aumix -w 15 -p 20 -m 0 -1 0 -2 0 -3 0 -i 0 + +The addition of the "mpu_io=816 mpu_irq=5" to the mad16 options line is diff -u --recursive --new-file v2.2.7/linux/Documentation/sound/OPL3-SA linux/Documentation/sound/OPL3-SA --- v2.2.7/linux/Documentation/sound/OPL3-SA Tue Feb 23 15:21:32 1999 +++ linux/Documentation/sound/OPL3-SA Thu Apr 29 11:53:41 1999 @@ -15,7 +15,7 @@ You'll need to know all of the relevant info (irq, dma, and io port) for the chip's WSS mode, since that is the mode the kernel sound driver uses, and of course you'll also need to know about where the MPU401 and OPL3 ports and -irq's are if you want to use those. +IRQs are if you want to use those. Here's the skinny on how to load it as a module: @@ -24,14 +24,14 @@ Module options in detail: io: This is the WSS's port base. - irq: This is the WSS's irq. - dma: This is the WSS's dma line. In my BIOS setup screen this was + irq: This is the WSS's IRQ. + dma: This is the WSS's DMA line. In my BIOS setup screen this was listed as "WSS Play DMA" - dma2: This is the WSS's secondary dma line. My BIOS calls it the + dma2: This is the WSS's secondary DMA line. My BIOS calls it the "WSS capture DMA" mpu_io: This is the MPU401's port base. - mpu_irq: This is the MPU401's irq. + mpu_irq: This is the MPU401's IRQ. If you'd like to use the OPL3 FM Synthesizer, make sure you enable CONFIG_YM3812 (in 'make config'). That'll build the opl3.o module. @@ -43,7 +43,7 @@ Say 'y' or 'm' to "SoftOSS software wave table engine" in make config. -If you said yes, the software synth is availible once you boot your new +If you said yes, the software synth is available once you boot your new kernel. If you chose to build it as a module, just insmod the resulting softoss2.o diff -u --recursive --new-file v2.2.7/linux/Documentation/sound/README.OSS linux/Documentation/sound/README.OSS --- v2.2.7/linux/Documentation/sound/README.OSS Tue Jan 19 11:32:50 1999 +++ linux/Documentation/sound/README.OSS Thu Apr 29 11:53:41 1999 @@ -58,7 +58,7 @@ Mika Liljeberg uLaw encoding and decoding routines Jeff Tranter Linux SOUND HOWTO document Greg Lee Volume computation algorithm for the GUS and - lot's of valuable suggestions. + lots of valuable suggestions. Andy Warner ISC port Jim Lowe, Amancio Hasty Jr FreeBSD/NetBSD port @@ -96,7 +96,7 @@ or before even starting to do any work. Tell me what you suggest to be changed or what you have planned to do. Also ensure you are using the very latest (development) version of OSS/Free since the change may already be -implemented there. In general it's major waste of time to try to improve +implemented there. In general it's a major waste of time to try to improve a several months old version. Information about the latest version can be found from http://www.opensound.com/ossfree. In general there is no point in sending me patches relative to production kernels. @@ -1314,8 +1314,8 @@ This ESS proprietary feature is supported only by OSS/Linux. There are ES1688 based cards which use different interrupt pin assignment than -recommended by ESS (5, 7, 9/2 and 10). In this case all IRQ's don't work. -At least a card called (Pearl?) Hypersound 16 supports IRQ15 but it doesn't +recommended by ESS (5, 7, 9/2 and 10). In this case all IRQs don't work. +At least a card called (Pearl?) Hypersound 16 supports IRQ 15 but it doesn't work. ES1868 is a PnP chip which is (supposed to be) compatible with ESS1688 diff -u --recursive --new-file v2.2.7/linux/Documentation/sound/README.awe linux/Documentation/sound/README.awe --- v2.2.7/linux/Documentation/sound/README.awe Tue Dec 22 14:16:53 1998 +++ linux/Documentation/sound/README.awe Thu Apr 29 11:53:41 1999 @@ -9,8 +9,8 @@ This is a sound driver extension for SoundBlaster AWE32 and other compatible cards (AWE32-PnP, SB32, SB32-PnP, AWE64 & etc) to enable -the wave synth operations. The driver is provided for both Linux -1.2.x and 2.[01].x kernels, and also FreeBSD, on Intel x86 and DEC +the wave synth operations. The driver is provided for Linux 1.2.x +and 2.[012].x kernels, as well as FreeBSD, on Intel x86 and DEC Alpha systems. This driver was written by Takashi Iwai , @@ -76,7 +76,7 @@ % sfxload synthgm % drvmidi -L 2mbgmgs foo.mid -This makes a big differece (believe me)! For more details, please +This makes a big difference (believe me)! For more details, please refer to the FAQ list which is available on the URL above. The current chorus, reverb and equalizer status can be changed by @@ -97,14 +97,14 @@ shell script. - AWE_MODULE_SUPPORT - indicates your linux kernel supports module for each soundcard - (in recent 2.1 kernels and unofficial patched 2.0 kernels as - distributed in the RH5.0 package). + indicates your Linux kernel supports module for each sound card + (in recent 2.1 or 2.2 kernels and unofficial patched 2.0 kernels + as distributed in the RH5.0 package). This flag is automatically set when you're using 2.1.x kernels. You can pass the base address and memory size via the following module options, io = base I/O port address (eg. 0x620) - memsize = DRAM size in Kbyes (eg. 512) + memsize = DRAM size in kilobytes (eg. 512) As default, AWE driver probes these values automatically. @@ -117,15 +117,15 @@ 0 means to autodetect the address. - AWE_DEFAULT_MEM_SIZE (default: not defined) - specifies the memory size of your AWE32 card in kilo bytes. + specifies the memory size of your AWE32 card in kilobytes. -1 means to autodetect its size. [Sample Table Size] From ver.0.4.0, sample tables are allocated dynamically (except Linux-1.2.x system), so you need NOT to touch these parameters. -Linux-1.2.x users may need to increase these values to apropriate size -if larger DRAM is equipped with the soundcard. +Linux-1.2.x users may need to increase these values to appropriate size +if the sound card is equipped with more DRAM. - AWE_MAX_SF_LISTS, AWE_MAX_SAMPLES, AWE_MAX_INFOS @@ -139,7 +139,7 @@ passthrough channels. - AWE_DEBUG_ON (default: defined) - turns on debuggin messages if defined. + turns on debugging messages if defined. - AWE_HAS_GUS_COMPATIBILITY (default: defined) Enables GUS compatibility mode if defined, reading GUS patches and @@ -170,7 +170,7 @@ - AWE_ALLOW_SAMPLE_SHARING (default: defined) Allow sample sharing for differently loaded patches. This function is available only together with awesfx-0.4.3p3. - Note that this is still an experimantal option. + Note that this is still an experimental option. - DEF_FM_CHORUS_DEPTH (default: 0x10) The default strength to be sent to the chorus effect engine. @@ -183,8 +183,8 @@ * ACKNOWLEDGMENTS -Thanks to Witold Jachimczyk (witek@xfactor.wpi.edu) for many advices -to programming of AWE32. Many codes are brought from his AWE32-native +Thanks to Witold Jachimczyk (witek@xfactor.wpi.edu) for much advice +on programming of AWE32. Much code is brought from his AWE32-native MOD player, ALMP. The port of awedrv to FreeBSD is done by Randall Hopper (rhh@ct.picker.com). diff -u --recursive --new-file v2.2.7/linux/Documentation/sound/Wavefront linux/Documentation/sound/Wavefront --- v2.2.7/linux/Documentation/sound/Wavefront Thu Sep 17 17:53:34 1998 +++ linux/Documentation/sound/Wavefront Thu Apr 29 11:53:41 1999 @@ -149,7 +149,7 @@ . . . - make modules_isntall + make modules_install Here's my autoconf.h SOUND section: diff -u --recursive --new-file v2.2.7/linux/Documentation/sysctl/vm.txt linux/Documentation/sysctl/vm.txt --- v2.2.7/linux/Documentation/sysctl/vm.txt Fri Apr 16 14:47:30 1999 +++ linux/Documentation/sysctl/vm.txt Thu Apr 29 11:53:41 1999 @@ -178,7 +178,7 @@ The Linux VM subsystem avoids excessive disk seeks by reading multiple pages on a page fault. The number of pages it reads -is dependant on the amount of memory in your machine. +is dependent on the amount of memory in your machine. The number of pages the kernel reads in at once is equal to 2 ^ page-cluster. Values above 2 ^ 5 don't make much sense diff -u --recursive --new-file v2.2.7/linux/Makefile linux/Makefile --- v2.2.7/linux/Makefile Wed Apr 28 11:37:29 1999 +++ linux/Makefile Wed Apr 28 11:38:52 1999 @@ -1,6 +1,6 @@ VERSION = 2 PATCHLEVEL = 2 -SUBLEVEL = 7 +SUBLEVEL = 8 EXTRAVERSION = ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/) diff -u --recursive --new-file v2.2.7/linux/REPORTING-BUGS linux/REPORTING-BUGS --- v2.2.7/linux/REPORTING-BUGS Tue Jan 19 11:32:50 1999 +++ linux/REPORTING-BUGS Thu Apr 29 11:53:41 1999 @@ -1,6 +1,6 @@ [Some of this is taken from Frohwalt Egerer's original linux-kernel FAQ] - What follows is a suggested proceedure for reporting Linux bugs. You + What follows is a suggested procedure for reporting Linux bugs. You aren't obliged to use the bug reporting format, it is provided as a guide to the kind of information that can be useful to developers - no more. @@ -23,11 +23,11 @@ This is a suggested format for a bug report sent to the Linux kernel mailing list. Having a standardized bug report form makes it easier for you not to overlook things, and easier for the developers to find the pieces of -information they're really interested in. +information they're really interested in. Don't feel you have to follow it. First run the ver_linux script included as scripts/ver_linux or at It checks out -the version of some important subsystems. Run it with the commnd +the version of some important subsystems. Run it with the command "sh scripts/ver_linux" Use that information to fill in all fields of the bug report form, and diff -u --recursive --new-file v2.2.7/linux/arch/alpha/kernel/osf_sys.c linux/arch/alpha/kernel/osf_sys.c --- v2.2.7/linux/arch/alpha/kernel/osf_sys.c Tue Mar 23 14:35:46 1999 +++ linux/arch/alpha/kernel/osf_sys.c Fri Apr 30 08:23:23 1999 @@ -1407,8 +1407,9 @@ copy_from_user(&txc.tick, &txc_p->tick, sizeof(struct timex32) - offsetof(struct timex32, time))) return -EFAULT; - - if ((ret = do_adjtimex(&txc))) + + ret = do_adjtimex(&txc); + if (ret < 0) return ret; /* copy back to timex32 */ @@ -1418,5 +1419,5 @@ (put_tv32(&txc_p->time, &txc.time))) return -EFAULT; - return 0; + return ret; } diff -u --recursive --new-file v2.2.7/linux/arch/alpha/lib/copy_user.S linux/arch/alpha/lib/copy_user.S --- v2.2.7/linux/arch/alpha/lib/copy_user.S Wed Apr 28 11:37:29 1999 +++ linux/arch/alpha/lib/copy_user.S Fri Apr 30 08:22:19 1999 @@ -109,7 +109,7 @@ $66: EXI( ldq $1,0($7) ) subq $4,8,$4 - stq $1,0($6) + EXO( stq $1,0($6) ) addq $7,8,$7 subq $0,8,$0 addq $6,8,$6 diff -u --recursive --new-file v2.2.7/linux/arch/i386/kernel/entry.S linux/arch/i386/kernel/entry.S --- v2.2.7/linux/arch/i386/kernel/entry.S Wed Jan 20 23:14:04 1999 +++ linux/arch/i386/kernel/entry.S Fri Apr 30 08:13:37 1999 @@ -154,7 +154,9 @@ .globl ret_from_fork ret_from_fork: #ifdef __SMP__ + pushl %ebx call SYMBOL_NAME(schedule_tail) + addl $4, %esp #endif /* __SMP__ */ GET_CURRENT(%ebx) jmp ret_from_sys_call diff -u --recursive --new-file v2.2.7/linux/arch/i386/kernel/i386_ksyms.c linux/arch/i386/kernel/i386_ksyms.c --- v2.2.7/linux/arch/i386/kernel/i386_ksyms.c Tue Mar 23 14:35:46 1999 +++ linux/arch/i386/kernel/i386_ksyms.c Thu May 6 15:13:05 1999 @@ -39,6 +39,7 @@ EXPORT_SYMBOL(local_irq_count); EXPORT_SYMBOL(enable_irq); EXPORT_SYMBOL(disable_irq); +EXPORT_SYMBOL(disable_irq_nosync); EXPORT_SYMBOL(kernel_thread); EXPORT_SYMBOL_NOVERS(__down_failed); diff -u --recursive --new-file v2.2.7/linux/arch/i386/kernel/io_apic.c linux/arch/i386/kernel/io_apic.c --- v2.2.7/linux/arch/i386/kernel/io_apic.c Fri Apr 16 14:47:30 1999 +++ linux/arch/i386/kernel/io_apic.c Thu May 6 16:07:03 1999 @@ -1049,7 +1049,7 @@ * and do not need to be masked. */ ack_APIC_irq(); - status = desc->status & ~IRQ_REPLAY; + status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING); status |= IRQ_PENDING; /* @@ -1060,8 +1060,9 @@ if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) { action = desc->action; status &= ~IRQ_PENDING; + status |= IRQ_INPROGRESS; } - desc->status = status | IRQ_INPROGRESS; + desc->status = status; spin_unlock(&irq_controller_lock); /* @@ -1103,7 +1104,7 @@ * So this all has to be within the spinlock. */ mask_IO_APIC_irq(irq); - status = desc->status & ~IRQ_REPLAY; + status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING); /* * If the IRQ is disabled for whatever reason, we must @@ -1112,8 +1113,9 @@ action = NULL; if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) { action = desc->action; + status |= IRQ_INPROGRESS; } - desc->status = status | IRQ_INPROGRESS; + desc->status = status; ack_APIC_irq(); spin_unlock(&irq_controller_lock); diff -u --recursive --new-file v2.2.7/linux/arch/i386/kernel/irq.c linux/arch/i386/kernel/irq.c --- v2.2.7/linux/arch/i386/kernel/irq.c Fri Apr 16 14:47:30 1999 +++ linux/arch/i386/kernel/irq.c Thu May 6 16:22:36 1999 @@ -203,7 +203,7 @@ void make_8259A_irq(unsigned int irq) { - disable_irq(irq); + disable_irq_nosync(irq); io_apic_irqs &= ~(1<status & ~IRQ_REPLAY; + status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING); action = NULL; - if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) + if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) { action = desc->action; - desc->status = status | IRQ_INPROGRESS; + status |= IRQ_INPROGRESS; + } + desc->status = status; } spin_unlock(&irq_controller_lock); @@ -747,7 +749,7 @@ * hardware disable after having gotten the irq * controller lock. */ -void disable_irq(unsigned int irq) +void disable_irq_nosync(unsigned int irq) { unsigned long flags; @@ -757,9 +759,21 @@ irq_desc[irq].handler->disable(irq); } spin_unlock_irqrestore(&irq_controller_lock, flags); +} + +/* + * Synchronous version of the above, making sure the IRQ is + * no longer running on any other IRQ.. + */ +void disable_irq(unsigned int irq) +{ + disable_irq_nosync(irq); - if (irq_desc[irq].status & IRQ_INPROGRESS) - synchronize_irq(); + if (!local_irq_count[smp_processor_id()]) { + do { + barrier(); + } while (irq_desc[irq].status & IRQ_INPROGRESS); + } } void enable_irq(unsigned int irq) @@ -769,7 +783,7 @@ spin_lock_irqsave(&irq_controller_lock, flags); switch (irq_desc[irq].depth) { case 1: - irq_desc[irq].status &= ~(IRQ_DISABLED | IRQ_INPROGRESS); + irq_desc[irq].status &= ~IRQ_DISABLED; irq_desc[irq].handler->enable(irq); /* fall throught */ default: @@ -864,7 +878,7 @@ if (!shared) { irq_desc[irq].depth = 0; - irq_desc[irq].status &= ~(IRQ_DISABLED | IRQ_INPROGRESS); + irq_desc[irq].status &= ~IRQ_DISABLED; irq_desc[irq].handler->startup(irq); } spin_unlock_irqrestore(&irq_controller_lock,flags); @@ -936,7 +950,7 @@ * * This depends on the fact that any interrupt that * comes in on to an unassigned handler will get stuck - * with "IRQ_INPROGRESS" asserted and the interrupt + * with "IRQ_WAITING" cleared and the interrupt * disabled. */ unsigned long probe_irq_on(void) @@ -950,8 +964,7 @@ spin_lock_irq(&irq_controller_lock); for (i = NR_IRQS-1; i > 0; i--) { if (!irq_desc[i].action) { - unsigned int status = irq_desc[i].status | IRQ_AUTODETECT; - irq_desc[i].status = status & ~IRQ_INPROGRESS; + irq_desc[i].status |= IRQ_AUTODETECT | IRQ_WAITING; irq_desc[i].handler->startup(i); } } @@ -974,7 +987,7 @@ continue; /* It triggered already - consider it spurious. */ - if (status & IRQ_INPROGRESS) { + if (!(status & IRQ_WAITING)) { irq_desc[i].status = status & ~IRQ_AUTODETECT; irq_desc[i].handler->shutdown(i); } @@ -1000,7 +1013,7 @@ if (!(status & IRQ_AUTODETECT)) continue; - if (status & IRQ_INPROGRESS) { + if (!(status & IRQ_WAITING)) { if (!nr_irqs) irq_found = i; nr_irqs++; diff -u --recursive --new-file v2.2.7/linux/arch/i386/kernel/irq.h linux/arch/i386/kernel/irq.h --- v2.2.7/linux/arch/i386/kernel/irq.h Fri Apr 16 14:47:30 1999 +++ linux/arch/i386/kernel/irq.h Fri May 7 15:10:17 1999 @@ -26,6 +26,7 @@ #define IRQ_PENDING 4 /* IRQ pending - replay on enable */ #define IRQ_REPLAY 8 /* IRQ has been replayed but not acked yet */ #define IRQ_AUTODETECT 16 /* IRQ is being autodetected */ +#define IRQ_WAITING 32 /* IRQ not yet seen - for autodetection */ /* * This is the "IRQ descriptor", which contains various information diff -u --recursive --new-file v2.2.7/linux/arch/i386/kernel/mtrr.c linux/arch/i386/kernel/mtrr.c --- v2.2.7/linux/arch/i386/kernel/mtrr.c Mon Dec 28 15:00:52 1998 +++ linux/arch/i386/kernel/mtrr.c Thu Apr 29 11:53:41 1999 @@ -132,6 +132,11 @@ Fixed harmless compiler warning in include/asm-i386/mtrr.h Fixed version numbering and history for v1.23 -> v1.24. v1.26 + + v1.26ac Alan Cox + Added some K6-II/III support. This needs back merging with + Richard's current code before it goes to Linus really. + */ #include #include @@ -163,6 +168,7 @@ #include #include #include +#include #include #include "irq.h" @@ -197,7 +203,7 @@ # define MTRR_CHANGE_MASK_DEFTYPE 0x04 #endif -/* In the processor's MTRR interface, the MTRR type is always held in +/* In the intel processor's MTRR interface, the MTRR type is always held in an 8 bit field: */ typedef u8 mtrr_type; @@ -225,6 +231,7 @@ #ifdef CONFIG_PROC_FS static void compute_ascii (void); #endif +static int k6_has_ranges(void); struct set_mtrr_context @@ -236,28 +243,13 @@ }; /* - * Access to machine-specific registers (available on 586 and better only) - * Note: the rd* operations modify the parameters directly (without using - * pointer indirection), this allows gcc to optimize better + * No point continually digging through complex CPU conditionals.. */ -#define rdmsr(msr,val1,val2) \ - __asm__ __volatile__("rdmsr" \ - : "=a" (val1), "=d" (val2) \ - : "c" (msr)) - -#define wrmsr(msr,val1,val2) \ - __asm__ __volatile__("wrmsr" \ - : /* no outputs */ \ - : "c" (msr), "a" (val1), "d" (val2)) - -#define rdtsc(low,high) \ - __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high)) - -#define rdpmc(counter,low,high) \ - __asm__ __volatile__("rdpmc" \ - : "=a" (low), "=d" (high) \ - : "c" (counter)) + +static int mtrr_flags; +#define MTRR_PRESENT 1 +#define MTRR_WRCOMB 2 /* Put the processor into a state where MTRRs can be safely set. */ static void set_mtrr_prepare(struct set_mtrr_context *ctxt) @@ -267,13 +259,15 @@ /* disable interrupts locally */ __save_flags (ctxt->flags); __cli (); + if(boot_cpu_data.x86_vendor == X86_VENDOR_AMD) + return; + /* save value of CR4 and clear Page Global Enable (bit 7) */ asm volatile ("movl %%cr4, %0\n\t" "movl %0, %1\n\t" "andb $0x7f, %b1\n\t" "movl %1, %%cr4\n\t" : "=r" (ctxt->cr4val), "=q" (tmp) : : "memory"); - /* disable and flush caches. Note that wbinvd flushes the TLBs as a side-effect. */ asm volatile ("movl %%cr0, %0\n\t" @@ -294,6 +288,9 @@ { unsigned long tmp; + if(boot_cpu_data.x86_vendor == X86_VENDOR_AMD) + return; + /* flush caches and TLBs */ asm volatile ("wbinvd" : : : "memory" ); @@ -319,6 +316,9 @@ static unsigned int get_num_var_ranges (void) { unsigned long config, dummy; + + if(boot_cpu_data.x86_vendor == X86_VENDOR_AMD) + return 2; rdmsr(MTRRcap_MSR, config, dummy); return (config & 0xff); @@ -340,6 +340,46 @@ { unsigned long dummy, mask_lo, base_lo; + if(boot_cpu_data.x86_vendor == X86_VENDOR_AMD) + { + unsigned long low, high; + rdmsr(0xC0000085, low, high); + /* Upper dword is region 1, lower is region 0 */ + if(reg==1) + low=high; + /* The base masks off on the right alignment */ + *base=low&0xFFFE0000; + *type=0; + if(low&1) + *type=MTRR_TYPE_UNCACHABLE; + if(low&2) + *type=MTRR_TYPE_WRCOMB; + if(!(low&3)) + { + *size=0; + return; + } + + /* + * This needs a little explaining. The size is stored as an + * inverted mask of bits of 128K granularity 15 bits long offset + * 2 bits + * + * So to get a size we do invert the mask and add 1 to the lowest + * mask bit (4 as its 2 bits in). This gives us a size we then shift + * to turn into 128K blocks + * + * eg 111 1111 1111 1100 is 512K + * + * invert 000 0000 0000 0011 + * +1 000 0000 0000 0100 + * *128K ... + */ + + low=(~low)&0x1FFFC; + *size = (low+4)<<15; + return; + } rdmsr(MTRRphysMask_MSR(reg), mask_lo, dummy); if ((mask_lo & 0x800) == 0) { /* Invalid (i.e. free) range. */ @@ -381,16 +421,56 @@ struct set_mtrr_context ctxt; if (do_safe) set_mtrr_prepare (&ctxt); - if (size == 0) + + if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) { - /* The invalid bit is kept in the mask, so we simply clear the - relevant mask register to disable a range. */ - wrmsr (MTRRphysMask_MSR (reg), 0, 0); + if (size == 0) + { + /* The invalid bit is kept in the mask, so we simply clear the + relevant mask register to disable a range. */ + wrmsr (MTRRphysMask_MSR (reg), 0, 0); + } + else + { + wrmsr (MTRRphysBase_MSR (reg), base | type, 0); + wrmsr (MTRRphysMask_MSR (reg), ~(size - 1) | 0x800, 0); + } } - else + if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) { - wrmsr (MTRRphysBase_MSR (reg), base | type, 0); - wrmsr (MTRRphysMask_MSR (reg), ~(size - 1) | 0x800, 0); + u32 low, high; + unsigned long flags; + /* + * Low is MTRR0 , High MTRR 1 + */ + rdmsr(0xC0000085, low, high); + /* + * Blank to disable + */ + if(size==0) + *(reg?&high:&low)=0; + else + /* Set the register to the base (already shifted for us), the + type (off by one) and an inverted bitmask of the size + + The size is the only odd bit. We are fed say 512K + We invert this and we get 111 1111 1111 1011 but + if you subtract one and invert you get the desired + 111 1111 1111 1100 mask + */ + + *(reg?&high:&low)=(((~(size-1))>>15)&0x0001FFFC)|base|(type+1); + + /* + * The writeback rule is quite specific. See the manual. Its + * disable local interrupts, write back the cache, set the mtrr + */ + + save_flags(flags); + __cli(); + __asm__ __volatile__("wbinvd" : : : "memory"); + wrmsr(0xC0000085, low, high); + restore_flags(flags); } if (do_safe) set_mtrr_done (&ctxt); } /* End Function set_mtrr_up */ @@ -518,11 +598,17 @@ for (i = 0; i < nvrs; i++) get_mtrr_var_range(i, &vrs[i]); - get_fixed_ranges(state->fixed_ranges); + if(boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) + { + get_fixed_ranges(state->fixed_ranges); - rdmsr(MTRRdefType_MSR, lo, dummy); - state->def_type = (lo & 0xff); - state->enabled = (lo & 0xc00) >> 10; + rdmsr(MTRRdefType_MSR, lo, dummy); + state->def_type = (lo & 0xff); + state->enabled = (lo & 0xc00) >> 10; + return; + } + state->def_type = 0; + state->enabled = 1; } /* End Function get_mtrr_state */ @@ -545,6 +631,9 @@ unsigned int i; unsigned long change_mask = 0; + if(boot_cpu_data.x86_vendor == X86_VENDOR_AMD) + return 0UL; + for (i = 0; i < state->num_var_ranges; i++) if (set_mtrr_var_range_testing(i, &state->var_ranges[i])) change_mask |= MTRR_CHANGE_MASK_VARIABLE; @@ -737,40 +826,58 @@ mtrr_type ltype; unsigned long lbase, lsize, last; - if ( !(boot_cpu_data.x86_capability & X86_FEATURE_MTRR) ) return -ENODEV; - if ( (base & 0xfff) || (size & 0xfff) ) - { - printk ("mtrr: size and base must be multiples of 4kB\n"); - printk ("mtrr: size: %lx base: %lx\n", size, base); - return -EINVAL; + if (!(mtrr_flags&MTRR_PRESENT)) + return -ENODEV; + + if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) + { + /* Apply the K6 block alignment and size rules + In order + o Uncached or gathering only + o 128K or bigger block + o Power of 2 block + o base suitably aligned to the power + */ + if(type > 1 || size < (1<<17) || (size & ~(size-1))-size || (base&(size-1))) + return -EINVAL; } - if (base + size < 0x100000) + + if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) { - printk ("mtrr: cannot set region below 1 MByte (0x%lx,0x%lx)\n", - base, size); - return -EINVAL; - } - /* Check upper bits of base and last are equal and lower bits are 0 for - base and 1 for last */ - last = base + size - 1; - for (lbase = base; !(lbase & 1) && (last & 1); - lbase = lbase >> 1, last = last >> 1); - if (lbase != last) - { - printk ("mtrr: base(0x%lx) is not aligned on a size(0x%lx) boundary\n", - base, size); - return -EINVAL; - } - if (type >= MTRR_NUM_TYPES) - { - printk ("mtrr: type: %u illegal\n", type); - return -EINVAL; - } - /* If the type is WC, check that this processor supports it */ - if ( (type == MTRR_TYPE_WRCOMB) && !have_wrcomb () ) - { - printk ("mtrr: your processor doesn't support write-combining\n"); - return -ENOSYS; + if ( (base & 0xfff) || (size & 0xfff) ) + { + printk ("mtrr: size and base must be multiples of 4kB\n"); + printk ("mtrr: size: %lx base: %lx\n", size, base); + return -EINVAL; + } + if (base + size < 0x100000) + { + printk ("mtrr: cannot set region below 1 MByte (0x%lx,0x%lx)\n", + base, size); + return -EINVAL; + } + /* Check upper bits of base and last are equal and lower bits are 0 for + base and 1 for last */ + last = base + size - 1; + for (lbase = base; !(lbase & 1) && (last & 1); + lbase = lbase >> 1, last = last >> 1); + if (lbase != last) + { + printk ("mtrr: base(0x%lx) is not aligned on a size(0x%lx) boundary\n", + base, size); + return -EINVAL; + } + if (type >= MTRR_NUM_TYPES) + { + printk ("mtrr: type: %u illegal\n", type); + return -EINVAL; + } + /* If the type is WC, check that this processor supports it */ + if ( (type == MTRR_TYPE_WRCOMB) && !have_wrcomb () ) + { + printk ("mtrr: your processor doesn't support write-combining\n"); + return -EINVAL; + } } increment = increment ? 1 : 0; max = get_num_var_ranges (); @@ -834,7 +941,7 @@ mtrr_type ltype; unsigned long lbase, lsize; - if ( !(boot_cpu_data.x86_capability & X86_FEATURE_MTRR) ) return -ENODEV; + if ( !(mtrr_flags&MTRR_PRESENT) ) return -ENODEV; max = get_num_var_ranges (); spin_lock (&main_lock); if (reg < 0) @@ -1153,10 +1260,15 @@ __initfunc(void mtrr_init_boot_cpu (void)) { - if ( !(boot_cpu_data.x86_capability & X86_FEATURE_MTRR) ) return; printk("mtrr: v%s Richard Gooch (rgooch@atnf.csiro.au)\n", MTRR_VERSION); - - get_mtrr_state (&smp_mtrr_state); + if (boot_cpu_data.x86_capability & X86_FEATURE_MTRR) + { + get_mtrr_state (&smp_mtrr_state); + } + if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD && k6_has_ranges()) + { + get_mtrr_state (&smp_mtrr_state); + } } /* End Function mtrr_init_boot_cpu */ __initfunc(void mtrr_init_secondary_cpu (void)) @@ -1181,9 +1293,35 @@ #endif /* __SMP__ */ +/* + * The extended memory handling is available on the K6-III and the + * K6-II stepping 8 and higher only. + */ + +static int k6_has_ranges(void) +{ + if(boot_cpu_data.x86 !=5) + return 0; + if(boot_cpu_data.x86_model == 9 || + (boot_cpu_data.x86_model == 8 && + boot_cpu_data.x86_mask >= 8)) + return 1; + return 0; +} + __initfunc(int mtrr_init(void)) { - if ( !(boot_cpu_data.x86_capability & X86_FEATURE_MTRR) ) return 0; + if ( boot_cpu_data.x86_vendor == X86_VENDOR_AMD && k6_has_ranges()) + { +# ifdef CONFIG_PROC_FS + proc_register (&proc_root, &proc_root_mtrr); +# endif + mtrr_flags|=MTRR_PRESENT|MTRR_WRCOMB; + init_table(); + return 0; + } + if ( !(boot_cpu_data.x86_capability & X86_FEATURE_MTRR) ) + return 0; # ifndef __SMP__ printk("mtrr: v%s Richard Gooch (rgooch@atnf.csiro.au)\n", MTRR_VERSION); # endif @@ -1197,6 +1335,7 @@ proc_register (&proc_root, &proc_root_mtrr); # endif + mtrr_flags|=MTRR_PRESENT; init_table (); return 0; } /* End Function mtrr_init */ diff -u --recursive --new-file v2.2.7/linux/arch/i386/kernel/process.c linux/arch/i386/kernel/process.c --- v2.2.7/linux/arch/i386/kernel/process.c Tue Mar 23 14:35:46 1999 +++ linux/arch/i386/kernel/process.c Fri Apr 30 08:13:37 1999 @@ -111,6 +111,8 @@ /* endless idle loop with no priority at all */ current->priority = 0; current->counter = -100; + init_idle(); + for (;;) { if (work) start_idle = jiffies; @@ -139,6 +141,8 @@ /* endless idle loop with no priority at all */ current->priority = 0; current->counter = -100; + init_idle(); + while(1) { if (current_cpu_data.hlt_works_ok && !hlt_counter && !current->need_resched) diff -u --recursive --new-file v2.2.7/linux/arch/i386/kernel/setup.c linux/arch/i386/kernel/setup.c --- v2.2.7/linux/arch/i386/kernel/setup.c Tue Mar 23 14:35:46 1999 +++ linux/arch/i386/kernel/setup.c Thu Apr 29 11:53:41 1999 @@ -39,6 +39,7 @@ #include #include #include +#include /* * Machine setup.. @@ -57,6 +58,7 @@ unsigned int machine_id = 0; unsigned int machine_submodel_id = 0; unsigned int BIOS_revision = 0; +unsigned int mca_pentium_flag = 0; /* * Setup options @@ -244,11 +246,6 @@ unsigned long memory_start, memory_end; char c = ' ', *to = command_line, *from = COMMAND_LINE; int len = 0; - static unsigned char smptrap=0; - - if (smptrap) - return; - smptrap=1; #ifdef CONFIG_VISWS visws_get_board_type_and_rev(); @@ -380,16 +377,6 @@ */ } - -#define rdmsr(msr,val1,val2) \ - __asm__ __volatile__("rdmsr" \ - : "=a" (val1), "=d" (val2) \ - : "c" (msr)) - -#define wrmsr(msr,val1,val2) \ - __asm__ __volatile__("wrmsr" \ - : /* no outputs */ \ - : "c" (msr), "a" (val1), "d" (val2)) __initfunc(static int get_model_name(struct cpuinfo_x86 *c)) { diff -u --recursive --new-file v2.2.7/linux/arch/i386/kernel/smp.c linux/arch/i386/kernel/smp.c --- v2.2.7/linux/arch/i386/kernel/smp.c Wed Apr 28 11:37:29 1999 +++ linux/arch/i386/kernel/smp.c Fri Apr 30 08:13:37 1999 @@ -40,10 +40,10 @@ #include #include #include +#include #include "irq.h" -extern unsigned long start_kernel; extern void update_one_process( struct task_struct *p, unsigned long ticks, unsigned long user, unsigned long system, int cpu); @@ -147,16 +147,7 @@ */ #define APIC_DEFAULT_PHYS_BASE 0xfee00000 -/* - * Reads and clears the Pentium Timestamp-Counter - */ -#define READ_TSC(x) __asm__ __volatile__ ( "rdtsc" \ - :"=a" (((unsigned long*)&(x))[0]), \ - "=d" (((unsigned long*)&(x))[1])) - -#define CLEAR_TSC \ - __asm__ __volatile__ ("\t.byte 0x0f, 0x30;\n"::\ - "a"(0x00001000), "d"(0x00001000), "c"(0x10):"memory") +#define CLEAR_TSC wrmsr(0x10, 0x00001000, 0x00001000) /* * Setup routine for controlling SMP activation @@ -899,6 +890,7 @@ * Everything has been set up for the secondary * CPUs - they just need to reload everything * from the task structure + * This function must not return. */ void __init initialize_secondary(void) { @@ -940,7 +932,6 @@ /* * We need an idle process for each processor. */ - kernel_thread(start_secondary, NULL, CLONE_PID); cpucount++; @@ -951,6 +942,8 @@ idle->processor = i; __cpu_logical_map[cpucount] = i; cpu_number_map[i] = cpucount; + idle->has_cpu = 1; /* we schedule the first task manually */ + idle->tss.eip = (unsigned long) start_secondary; /* start_eip had better be page-aligned! */ start_eip = setup_trampoline(); @@ -1183,6 +1176,7 @@ /* Must be done before other processors booted */ mtrr_init_boot_cpu (); #endif + init_idle(); /* * Initialize the logical to physical CPU number mapping * and the per-CPU profiling counter/multiplier @@ -1781,6 +1775,7 @@ local_flush_tlb(); ack_APIC_irq(); + } static void stop_this_cpu (void) @@ -1949,7 +1944,7 @@ /* * We wrapped around just now. Let's start: */ - READ_TSC(t1); + rdtscll(t1); tt1=apic_read(APIC_TMCCT); #define LOOPS (HZ/10) @@ -1960,7 +1955,7 @@ wait_8254_wraparound (); tt2=apic_read(APIC_TMCCT); - READ_TSC(t2); + rdtscll(t2); /* * The APIC bus clock counter is 32 bits only, it diff -u --recursive --new-file v2.2.7/linux/arch/i386/kernel/time.c linux/arch/i386/kernel/time.c --- v2.2.7/linux/arch/i386/kernel/time.c Tue Mar 23 14:35:46 1999 +++ linux/arch/i386/kernel/time.c Thu Apr 29 11:53:41 1999 @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -83,8 +84,8 @@ register unsigned long edx asm("dx"); /* Read the Time Stamp Counter */ - __asm__("rdtsc" - :"=a" (eax), "=d" (edx)); + + rdtsc(eax,edx); /* .. relative to previous jiffy (32 bits is enough) */ eax -= last_tsc_low; /* tsc_low delta */ @@ -443,7 +444,8 @@ */ /* read Pentium cycle counter */ - __asm__("rdtsc" : "=a" (last_tsc_low) : : "edx"); + + rdtscl(last_tsc_low); outb_p(0x00, 0x43); /* latch the count ASAP */ @@ -566,12 +568,12 @@ unsigned long endlow, endhigh; unsigned long count; - __asm__ __volatile__("rdtsc":"=a" (startlow),"=d" (starthigh)); + rdtsc(startlow,starthigh); count = 0; do { count++; } while ((inb(0x61) & 0x20) == 0); - __asm__ __volatile__("rdtsc":"=a" (endlow),"=d" (endhigh)); + rdtsc(endlow,endhigh); last_tsc_low = endlow; diff -u --recursive --new-file v2.2.7/linux/arch/i386/kernel/visws_apic.c linux/arch/i386/kernel/visws_apic.c --- v2.2.7/linux/arch/i386/kernel/visws_apic.c Wed Jan 20 23:14:04 1999 +++ linux/arch/i386/kernel/visws_apic.c Thu May 6 16:12:23 1999 @@ -201,11 +201,13 @@ { unsigned int status; /* XXX APIC EOI? */ - status = desc->status & ~IRQ_REPLAY; + status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING); action = NULL; - if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) + if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) { action = desc->action; - desc->status = status | IRQ_INPROGRESS; + status |= IRQ_INPROGRESS; + } + desc->status = status; } spin_unlock(&irq_controller_lock); diff -u --recursive --new-file v2.2.7/linux/arch/ppc/boot/Makefile linux/arch/ppc/boot/Makefile --- v2.2.7/linux/arch/ppc/boot/Makefile Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/boot/Makefile Thu Apr 29 12:39:01 1999 @@ -14,7 +14,7 @@ .s.o: $(AS) -o $*.o $< .c.o: - $(CC) $(CFLAGS) -DINITRD_OFFSET=$(IOFF) -DINITRD_SIZE=$(ISZ) -DZIMAGE_OFFSET=$(ZOFF) -DZIMAGE_SIZE=$(ZSZ) -DKERNELBASE=$(KERNELBASE) -c -o $*.o $< + $(CC) $(CFLAGS) -DINITRD_OFFSET=$(IOFF) -DINITRD_SIZE=$(ISZ) -DZIMAGE_OFFSET=$(ZOFF) -DZIMAGE_SIZE=$(ZSZ) -c -o $*.o $< .S.s: $(CC) -D__ASSEMBLY__ -traditional -E -o $*.o $< .S.o: @@ -57,7 +57,7 @@ -DINITRD_SIZE=`sh size $(OBJDUMP) zvmlinux.initrd initrd` \ -DZIMAGE_OFFSET=`sh offset $(OBJDUMP) zvmlinux.initrd image` \ -DZIMAGE_SIZE=`sh size $(OBJDUMP) zvmlinux.initrd image` \ - -DKERNELBASE=$(KERNELBASE) -c -o misc.o misc.c + -c -o misc.o misc.c $(LD) $(ZLINKFLAGS) -o zvmlinux.initrd.tmp $(OBJECTS) $(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \ --add-section=initrd=ramdisk.image.gz \ @@ -84,7 +84,7 @@ # $(CC) $(CFLAGS) -DINITRD_OFFSET=0 -DINITRD_SIZE=0 \ -DZIMAGE_OFFSET=`sh offset $(OBJDUMP) zvmlinux image` \ - -DZIMAGE_SIZE=`sh size $(OBJDUMP) zvmlinux image` -DKERNELBASE=$(KERNELBASE) \ + -DZIMAGE_SIZE=`sh size $(OBJDUMP) zvmlinux image` \ -c -o misc.o misc.c $(LD) $(ZLINKFLAGS) -o zvmlinux.tmp $(OBJECTS) $(OBJCOPY) $(OBJCOPY_ARGS) -R .comment --add-section=image=../coffboot/vmlinux.gz \ @@ -95,7 +95,7 @@ dd if=zImage of=/dev/fd0H1440 bs=64b mkprep : mkprep.c - $(HOSTCC) -DKERNELBASE=$(KERNELBASE) -o mkprep mkprep.c + $(HOSTCC) -o mkprep mkprep.c znetboot : zImage cp zImage $(TFTPIMAGE) diff -u --recursive --new-file v2.2.7/linux/arch/ppc/boot/head.S linux/arch/ppc/boot/head.S --- v2.2.7/linux/arch/ppc/boot/head.S Fri Apr 16 14:47:30 1999 +++ linux/arch/ppc/boot/head.S Thu Apr 29 12:39:01 1999 @@ -6,7 +6,7 @@ .text /* - * $Id: head.S,v 1.29 1999/03/08 23:41:17 cort Exp $ + * $Id: head.S,v 1.31 1999/04/22 06:32:00 davem Exp $ * * Boot loader philosophy: * ROM loads us to some arbitrary location @@ -23,11 +23,7 @@ start_: mr r11,r3 /* Save pointer to residual/board data */ mr r25,r5 /* Save OFW pointer */ - - mfmsr r3 /* Turn off interrupts */ - li r4,0 - ori r4,r4,MSR_EE - andc r3,r3,r4 + li r3,MSR_IP /* Establish default MSR value */ mtmsr r3 /* check if we need to relocate ourselves to the link addr or were we @@ -136,6 +132,20 @@ lis r10,0xdeadc0de@h ori r10,r10,0xdeadc0de@l stw r10,0(r9) +/* + * The Radstone firmware maps PCI memory at 0xc0000000 using BAT2 + * so disable BATs before setting this to avoid a clash + */ + li r8,0 + mtspr DBAT0U,r8 + mtspr DBAT1U,r8 + mtspr DBAT2U,r8 + mtspr DBAT3U,r8 + mtspr IBAT0U,r8 + mtspr IBAT1U,r8 + mtspr IBAT2U,r8 + mtspr IBAT3U,r8 + blr hang: b hang diff -u --recursive --new-file v2.2.7/linux/arch/ppc/boot/kbd.c linux/arch/ppc/boot/kbd.c --- v2.2.7/linux/arch/ppc/boot/kbd.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/boot/kbd.c Thu Apr 29 12:39:01 1999 @@ -127,6 +127,11 @@ unsigned char c; int i; + /* flush input queue */ + while ((inb(KBSTATP) & KBINRDY)) + { + (void)inb(KBDATAP); + } /* Send self-test */ while (inb(KBSTATP) & KBOUTRDY) ; outb(KBSTATP,0xAA); diff -u --recursive --new-file v2.2.7/linux/arch/ppc/boot/misc.c linux/arch/ppc/boot/misc.c --- v2.2.7/linux/arch/ppc/boot/misc.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/boot/misc.c Thu Apr 29 12:39:01 1999 @@ -1,7 +1,7 @@ /* * misc.c * - * $Id: misc.c,v 1.61 1999/03/08 23:51:02 cort Exp $ + * $Id: misc.c,v 1.63 1999/04/05 21:48:20 cort Exp $ * * Adapted for PowerPC by Gary Thomas * @@ -33,14 +33,16 @@ char *end_avail; extern char _end[]; -#if defined(CONFIG_SERIAL_CONSOLE) -char cmd_preset[] = "console=ttyS0,9600n8"; +#ifdef CONFIG_CMDLINE +#define CMDLINE CONFIG_CMDLINE #else -char cmd_preset[] = ""; +#define CMDLINE ""; #endif -char cmd_buf[256]; -char *cmd_line = cmd_buf; +char cmd_preset[] = CMDLINE; +char cmd_buf[256]; +char *cmd_line = cmd_buf; +int keyb_present = 1; /* keyboard controller is present by default */ RESIDUAL hold_resid_buf; RESIDUAL *hold_residual = &hold_resid_buf; unsigned long initrd_start = 0, initrd_end = 0; @@ -58,7 +60,8 @@ void * memcpy(void * __dest, __const void * __src, int __n); void gunzip(void *, int, unsigned char *, int *); -int _cvt(unsigned long val, char *buf, long radix, char *digits); +static int _cvt(unsigned long val, char *buf, long radix, char *digits); +unsigned char inb(int); void pause() { @@ -93,11 +96,14 @@ tstc(void) { - return ( #if defined(CONFIG_SERIAL_CONSOLE) - NS16550_tstc(com_port) || + if (keyb_present) + return (CRT_tstc() || NS16550_tstc(com_port)); + else + NS16550_tstc(com_port); +#else + return (CRT_tstc() ); #endif /* CONFIG_SERIAL_CONSOLE */ - CRT_tstc()); } getc(void) @@ -106,7 +112,8 @@ #if defined(CONFIG_SERIAL_CONSOLE) if (NS16550_tstc(com_port)) return (NS16550_getc(com_port)); #endif /* CONFIG_SERIAL_CONSOLE */ - if (CRT_tstc()) return (CRT_getc()); + if (keyb_present) + if (CRT_tstc()) return (CRT_getc()); } } @@ -188,6 +195,8 @@ } } + cursor(x, y); + orig_x = x; orig_y = y; } @@ -317,6 +326,8 @@ int dev_handle; int mem_info[2]; int res, size; + unsigned char board_type; + unsigned char base_mod; lines = 25; cols = 80; @@ -333,14 +344,30 @@ flush_instruction_cache(); _put_HID0(_get_HID0() & ~0x0000C000); _put_MSR((orig_MSR = _get_MSR()) & ~0x0030); - vga_init(0xC0000000); #if defined(CONFIG_SERIAL_CONSOLE) - com_port = (struct NS16550 *)NS16550_init(1); + com_port = (struct NS16550 *)NS16550_init(0); #endif /* CONFIG_SERIAL_CONSOLE */ + vga_init(0xC0000000); if (residual) { + /* Is this Motorola PPCBug? */ + if ((1 & residual->VitalProductData.FirmwareSupports) && + (1 == residual->VitalProductData.FirmwareSupplier)) { + board_type = inb(0x800) & 0xF0; + + /* If this is genesis 2 board then check for no + * keyboard controller and more than one processor. + */ + if (board_type == 0xe0) { + base_mod = inb(0x803); + /* if a MVME2300 or a MCME2400 then no keyboard */ + if((base_mod == 0x9) || (base_mod == 0xF9)) { + keyb_present = 0; /* no keyboard */ + } + } + } memcpy(hold_residual,residual,sizeof(RESIDUAL)); } else { /* Assume 32M in the absence of more info... */ @@ -429,7 +456,7 @@ avail_ram = (char *)PAGE_ALIGN((unsigned long)_end); puts("zimage at: "); puthex((unsigned long)zimage_start); puts(" "); puthex((unsigned long)(zimage_size+zimage_start)); puts("\n"); - if ( (unsigned long)zimage_start <= 0x008000000 ) + if ( (unsigned long)zimage_start <= 0x00800000 ) { memcpy( (void *)avail_ram, (void *)zimage_start, zimage_size ); zimage_start = (char *)avail_ram; @@ -458,9 +485,8 @@ puts("avail ram: "); puthex((unsigned long)avail_ram); puts(" "); puthex((unsigned long)end_avail); puts("\n"); -#if !defined(CONFIG_SERIAL_CONSOLE) - CRT_tstc(); /* Forces keyboard to be initialized */ -#endif + if (keyb_present) + CRT_tstc(); /* Forces keyboard to be initialized */ puts("\nLinux/PPC load: "); timer = 0; diff -u --recursive --new-file v2.2.7/linux/arch/ppc/boot/mkprep.c linux/arch/ppc/boot/mkprep.c --- v2.2.7/linux/arch/ppc/boot/mkprep.c Mon Oct 5 13:13:36 1998 +++ linux/arch/ppc/boot/mkprep.c Thu Apr 29 12:39:01 1999 @@ -14,15 +14,8 @@ * Modified for x86 hosted builds by Matt Porter */ -#ifdef linux -#include -/*#include */ -/*#include */ /* the byte swap funcs don't work here -- Cort */ -#else #include -#endif #include - #include #include @@ -168,10 +161,10 @@ /* set entry point and boot image size skipping over elf header */ #ifdef __i386__ *entry = 0x400/*+65536*/; - *length = info.st_size+0x400; + *length = info.st_size-elfhdr_size+0x400; #else *entry = cpu_to_le32(0x400/*+65536*/); - *length = cpu_to_le32(info.st_size+0x400); + *length = cpu_to_le32(info.st_size-elfhdr_size+0x400); #endif /* __i386__ */ /* sets magic number for msdos partition (used by linux) */ diff -u --recursive --new-file v2.2.7/linux/arch/ppc/common_defconfig linux/arch/ppc/common_defconfig --- v2.2.7/linux/arch/ppc/common_defconfig Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/common_defconfig Thu Apr 29 12:39:01 1999 @@ -1,5 +1,5 @@ # -# Automatically generated by make menuconfig: don't edit +# Automatically generated make config: don't edit # # @@ -14,7 +14,7 @@ CONFIG_ALL_PPC=y # CONFIG_APUS is not set # CONFIG_MBX is not set -# CONFIG_SMP is not set +CONFIG_SMP=y # # General setup @@ -43,12 +43,11 @@ CONFIG_MAC_FLOPPY=y CONFIG_MAC_SERIAL=y CONFIG_ADBMOUSE=y -CONFIG_BLK_DEV_IDE_PMAC=y CONFIG_PROC_DEVICETREE=y -# CONFIG_KGDB is not set -# CONFIG_XMON is not set # CONFIG_TOTALMP is not set CONFIG_BOOTX_TEXT=y +# CONFIG_MOTOROLA_HOTSWAP is not set +# CONFIG_CMDLINE_BOOL is not set # # Plug and Play support @@ -60,6 +59,10 @@ # # CONFIG_BLK_DEV_FD is not set CONFIG_BLK_DEV_IDE=y + +# +# Please see Documentation/ide.txt for help/info on IDE drives +# # CONFIG_BLK_DEV_HD_IDE is not set CONFIG_BLK_DEV_IDEDISK=y CONFIG_BLK_DEV_IDECD=y @@ -70,8 +73,14 @@ # CONFIG_BLK_DEV_RZ1000 is not set # CONFIG_BLK_DEV_IDEPCI is not set # CONFIG_BLK_DEV_SL82C105 is not set +CONFIG_BLK_DEV_IDE_PMAC=y +# CONFIG_BLK_DEV_IDEDMA_PMAC is not set # CONFIG_IDE_CHIPSETS is not set -# CONFIG_BLK_DEV_LOOP is not set + +# +# Additional Block Devices +# +CONFIG_BLK_DEV_LOOP=y # CONFIG_BLK_DEV_NBD is not set # CONFIG_BLK_DEV_MD is not set CONFIG_BLK_DEV_RAM=y @@ -101,10 +110,17 @@ # CONFIG_IP_MROUTE is not set CONFIG_IP_ALIAS=y # CONFIG_SYN_COOKIES is not set + +# +# (it is safe to leave these untouched) +# CONFIG_INET_RARP=y -CONFIG_IP_NOSR=y CONFIG_SKB_LARGE=y # CONFIG_IPV6 is not set + +# +# +# # CONFIG_IPX is not set CONFIG_ATALK=m # CONFIG_X25 is not set @@ -126,12 +142,20 @@ # SCSI support # CONFIG_SCSI=y + +# +# SCSI support type (disk, tape, CD-ROM) +# CONFIG_BLK_DEV_SD=y CONFIG_CHR_DEV_ST=y CONFIG_BLK_DEV_SR=y CONFIG_BLK_DEV_SR_VENDOR=y -# CONFIG_CHR_DEV_SG is not set -# CONFIG_SCSI_MULTI_LUN is not set +CONFIG_CHR_DEV_SG=y + +# +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs +# +CONFIG_SCSI_MULTI_LUN=y CONFIG_SCSI_CONSTANTS=y # CONFIG_SCSI_LOGGING is not set @@ -159,10 +183,15 @@ # CONFIG_SCSI_FUTURE_DOMAIN is not set # CONFIG_SCSI_GDTH is not set # CONFIG_SCSI_GENERIC_NCR5380 is not set +# CONFIG_SCSI_G_NCR5380_PORT is not set +# CONFIG_SCSI_G_NCR5380_MEM is not set # CONFIG_SCSI_INITIO is not set +# CONFIG_SCSI_INIA100 is not set # CONFIG_SCSI_NCR53C406A is not set +# CONFIG_SCSI_SYM53C416 is not set # CONFIG_SCSI_NCR53C7xx is not set CONFIG_SCSI_NCR53C8XX=y +# CONFIG_SCSI_SYM53C8XX is not set CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8 CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32 CONFIG_SCSI_NCR53C8XX_SYNC=20 @@ -175,6 +204,7 @@ # CONFIG_SCSI_PSI240I is not set # CONFIG_SCSI_QLOGIC_FAS is not set # CONFIG_SCSI_QLOGIC_ISP is not set +# CONFIG_SCSI_QLOGIC_FC is not set # CONFIG_SCSI_SEAGATE is not set # CONFIG_SCSI_DC390T is not set # CONFIG_SCSI_T128 is not set @@ -205,7 +235,7 @@ # CONFIG_ACENIC is not set # CONFIG_NET_ISA is not set CONFIG_NET_EISA=y -# CONFIG_PCNET32 is not set +CONFIG_PCNET32=y # CONFIG_AC3200 is not set # CONFIG_APRICOT is not set # CONFIG_CS89x0 is not set @@ -229,6 +259,10 @@ # CONFIG_COPS is not set # CONFIG_IPDDP is not set CONFIG_PPP=y + +# +# CCP compressors for PPP are only built as modules. +# # CONFIG_SLIP is not set # CONFIG_NET_RADIO is not set # CONFIG_TR is not set @@ -256,22 +290,37 @@ # Console drivers # CONFIG_DUMMY_CONSOLE=y +# CONFIG_FB_PM2 is not set CONFIG_FB_OF=y CONFIG_FB_CONTROL=y CONFIG_FB_PLATINUM=y CONFIG_FB_VALKYRIE=y -CONFIG_FB_ATY=y +# CONFIG_FB_ATY is not set CONFIG_FB_IMSTT=y CONFIG_FB_CT65550=y # CONFIG_FB_S3TRIO is not set -# CONFIG_FB_MATROX is not set -CONFIG_FB_ATY=y +CONFIG_FB_MATROX=y +CONFIG_FB_MATROX_MILLENIUM=y +CONFIG_FB_MATROX_MYSTIQUE=y +CONFIG_FB_MATROX_G100=y +# CONFIG_FB_MATROX_MULTIHEAD is not set +# CONFIG_FB_ATY is not set # CONFIG_FB_VIRTUAL is not set -# CONFIG_FBCON_ADVANCED is not set +CONFIG_FBCON_ADVANCED=y +# CONFIG_FBCON_MFB is not set +# CONFIG_FBCON_CFB2 is not set +# CONFIG_FBCON_CFB4 is not set CONFIG_FBCON_CFB8=y CONFIG_FBCON_CFB16=y CONFIG_FBCON_CFB24=y CONFIG_FBCON_CFB32=y +# CONFIG_FBCON_AFB is not set +# CONFIG_FBCON_ILBM is not set +# CONFIG_FBCON_IPLAN2P2 is not set +# CONFIG_FBCON_IPLAN2P4 is not set +# CONFIG_FBCON_IPLAN2P8 is not set +# CONFIG_FBCON_MAC is not set +# CONFIG_FBCON_VGA is not set # CONFIG_FBCON_FONTWIDTH8_ONLY is not set CONFIG_FBCON_FONTS=y # CONFIG_FONT_8x8 is not set @@ -292,7 +341,17 @@ # CONFIG_SERIAL_NONSTANDARD is not set CONFIG_UNIX98_PTYS=y CONFIG_UNIX98_PTY_COUNT=256 -# CONFIG_MOUSE is not set +CONFIG_MOUSE=y + +# +# Mice +# +# CONFIG_ATIXL_BUSMOUSE is not set +# CONFIG_BUSMOUSE is not set +# CONFIG_MS_BUSMOUSE is not set +CONFIG_PSMOUSE=y +# CONFIG_82C710_MOUSE is not set +# CONFIG_PC110_PAD is not set # CONFIG_QIC02_TAPE is not set # CONFIG_WATCHDOG is not set # CONFIG_NVRAM is not set @@ -307,11 +366,20 @@ # Joystick support # # CONFIG_JOYSTICK is not set +# CONFIG_DTLK is not set # # Ftape, the floppy tape device driver # # CONFIG_FTAPE is not set +# CONFIG_FT_NORMAL_DEBUG is not set +# CONFIG_FT_FULL_DEBUG is not set +# CONFIG_FT_NO_TRACE is not set +# CONFIG_FT_NO_TRACE_AT_ALL is not set +# CONFIG_FT_STD_FDC is not set +# CONFIG_FT_MACH2 is not set +# CONFIG_FT_PROBE_FC10 is not set +# CONFIG_FT_ALT_FDC is not set # # Filesystems @@ -402,3 +470,10 @@ # CONFIG_SOUND_MSNDCLAS is not set # CONFIG_SOUND_MSNDPIN is not set # CONFIG_SOUND_OSS is not set + +# +# Kernel hacking +# +# CONFIG_MAGIC_SYSRQ is not set +# CONFIG_KGDB is not set +# CONFIG_XMON is not set diff -u --recursive --new-file v2.2.7/linux/arch/ppc/config.in linux/arch/ppc/config.in --- v2.2.7/linux/arch/ppc/config.in Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/config.in Thu Apr 29 12:39:01 1999 @@ -1,4 +1,4 @@ -# $Id: config.in,v 1.84 1999/02/23 08:08:38 davem Exp $ +# $Id: config.in,v 1.91 1999/04/09 07:07:47 cort Exp $ # For a description of the syntax of this configuration file, # see the Configure script. # @@ -19,12 +19,10 @@ APUS CONFIG_APUS \ MBX CONFIG_MBX" PowerMac +bool 'Symmetric multi-processing support' CONFIG_SMP if [ "$CONFIG_ALL_PPC" != "y" ];then define_bool CONFIG_MACH_SPECIFIC y fi - -bool 'Symmetric multi-processing support' CONFIG_SMP - endmenu if [ "$CONFIG_MBX" = "y" ];then @@ -82,13 +80,20 @@ bool 'Support for PowerMac keyboard' CONFIG_MAC_KEYBOARD bool 'Support for PowerMac floppy' CONFIG_MAC_FLOPPY bool 'Support for PowerMac serial ports' CONFIG_MAC_SERIAL +if [ "$CONFIG_MAC_SERIAL" = "y" ]; then + bool ' Support for console on serial port' CONFIG_SERIAL_CONSOLE +fi bool 'Support for PowerMac ADB mouse' CONFIG_ADBMOUSE -bool 'Support for PowerMac IDE devices (must also enable IDE)' CONFIG_BLK_DEV_IDE_PMAC bool 'Support for Open Firmware device tree in /proc' CONFIG_PROC_DEVICETREE -bool 'Include kgdb kernel debugger' CONFIG_KGDB -bool 'Include xmon kernel debugger' CONFIG_XMON bool 'Support for TotalImpact TotalMP' CONFIG_TOTALMP bool 'Support for early boot text console (BootX only)' CONFIG_BOOTX_TEXT +bool 'Support for Motorola Hot Swap' CONFIG_MOTOROLA_HOTSWAP +if [ "$CONFIG_PREP" = "y" -o "$CONFIG_ALL_PPC" = "y" ]; then + bool 'PReP bootloader ernel arguments' CONFIG_CMDLINE_BOOL n + if [ "$CONFIG_CMDLINE_BOOL" = "y" ] ; then + string 'Initial kernel command string' CONFIG_CMDLINE "" + fi +fi if [ "$CONFIG_APUS" = "y" ]; then define_bool CONFIG_FB_CONSOLE y @@ -176,4 +181,12 @@ source drivers/sound/Config.in fi +endmenu + +mainmenu_option next_comment +comment 'Kernel hacking' + +bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ +bool 'Include kgdb kernel debugger' CONFIG_KGDB +bool 'Include xmon kernel debugger' CONFIG_XMON endmenu diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/Makefile linux/arch/ppc/kernel/Makefile --- v2.2.7/linux/arch/ppc/kernel/Makefile Mon Dec 28 15:00:52 1998 +++ linux/arch/ppc/kernel/Makefile Thu Apr 29 12:39:01 1999 @@ -27,7 +27,7 @@ endif ifeq ($(CONFIG_MBX),y) -O_OBJS += mbx_setup.o mbx_pci.o softemu8xx.o +O_OBJS += mbx_setup.o mbx_pci.o softemu8xx.o i8259.o ppc8xx_pic.o else ifeq ($(CONFIG_APUS),y) O_OBJS += apus_setup.o prom.o openpic.o @@ -36,7 +36,8 @@ O_OBJS += prep_time.o pmac_time.o chrp_time.o \ pmac_setup.o pmac_support.o \ prep_pci.o pmac_pci.o chrp_pci.o \ - residual.o prom.o openpic.o feature.o + residual.o prom.o openpic.o feature.o \ + prep_nvram.o open_pic.o i8259.o pmac_pic.o indirect_pci.o OX_OBJS += chrp_setup.o prep_setup.o endif endif diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/align.c linux/arch/ppc/kernel/align.c --- v2.2.7/linux/arch/ppc/kernel/align.c Mon Oct 5 13:13:36 1998 +++ linux/arch/ppc/kernel/align.c Thu Apr 29 12:39:01 1999 @@ -194,13 +194,8 @@ return -EFAULT; /* bad address */ } -#ifdef __SMP__ - if ((flags & F) && (regs->msr & MSR_FP) ) - smp_giveup_fpu(current); -#else - if ((flags & F) && last_task_used_math == current) - giveup_fpu(); -#endif + if ((flags & F) && (regs->msr & MSR_FP)) + giveup_fpu(current); if (flags & M) return 0; /* too hard for now */ @@ -254,27 +249,16 @@ data.d = current->tss.fpr[reg]; break; /* these require some floating point conversions... */ - /* note that giveup_fpu enables the FPU for the kernel */ /* we'd like to use the assignment, but we have to compile * the kernel with -msoft-float so it doesn't use the * fp regs for copying 8-byte objects. */ case LD+F+S: -#ifdef __SMP__ - if (regs->msr & MSR_FP ) - smp_giveup_fpu(current); -#else - giveup_fpu(); -#endif + enable_kernel_fp(); cvt_fd(&data.f, ¤t->tss.fpr[reg], ¤t->tss.fpscr); /* current->tss.fpr[reg] = data.f; */ break; case ST+F+S: -#ifdef __SMP__ - if (regs->msr & MSR_FP ) - smp_giveup_fpu(current); -#else - giveup_fpu(); -#endif + enable_kernel_fp(); cvt_df(¤t->tss.fpr[reg], &data.f, ¤t->tss.fpscr); /* data.f = current->tss.fpr[reg]; */ break; diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/apus_setup.c linux/arch/ppc/kernel/apus_setup.c --- v2.2.7/linux/arch/ppc/kernel/apus_setup.c Tue Dec 22 14:16:54 1998 +++ linux/arch/ppc/kernel/apus_setup.c Thu Apr 29 12:39:01 1999 @@ -14,12 +14,50 @@ #include #include #include +#include + +/* Get the IDE stuff from the 68k file */ +#define ide_init_hwif_ports m68k_ide_init_hwif_ports +#define ide_default_irq m68k_ide_default_irq +#define ide_default_io_base m68k_ide_default_io_base +#define ide_check_region m68k_ide_check_region +#define ide_request_region m68k_ide_request_region +#define ide_release_region m68k_ide_release_region +#define ide_fix_driveid m68k_ide_fix_driveid +#include +#undef ide_init_hwif_ports +#define ide_default_irq +#define ide_default_io_base +#define ide_check_region +#define ide_request_region +#define ide_release_region +#define ide_fix_driveid + #include #include #include #include #include +#include +#include + +#include "time.h" +#include "local_irq.h" + +unsigned long apus_get_rtc_time(void); +int apus_set_rtc_time(unsigned long nowtime); + +/* APUS defs */ +extern int parse_bootinfo(const struct bi_record *); +extern char _end[]; +#ifdef CONFIG_APUS +struct mem_info ramdisk; +unsigned long isa_io_base; +unsigned long isa_mem_base; +unsigned long pci_dram_offset; +#endif +/* END APUS defs */ unsigned long m68k_machtype; char debug_device[6] = ""; @@ -72,6 +110,8 @@ int i; char *p, *q; + m68k_machtype = MACH_AMIGA; + /* Parse the command line for arch-specific options. * For the m68k, this is currently only "debug=xxx" to enable printing * certain kernel messages to some machine-specific device. */ @@ -408,4 +448,195 @@ "icbi 0,%0 \n\t" "isync \n\t" : : "r" (addr)); +} + +void +apus_restart(char *cmd) +{ + cli(); + + APUS_WRITE(APUS_REG_LOCK, + REGLOCK_BLACKMAGICK1|REGLOCK_BLACKMAGICK2); + APUS_WRITE(APUS_REG_LOCK, + REGLOCK_BLACKMAGICK1|REGLOCK_BLACKMAGICK3); + APUS_WRITE(APUS_REG_LOCK, + REGLOCK_BLACKMAGICK2|REGLOCK_BLACKMAGICK3); + APUS_WRITE(APUS_REG_SHADOW, REGSHADOW_SELFRESET); + APUS_WRITE(APUS_REG_RESET, REGRESET_AMIGARESET); + for(;;); +} + +void +apus_power_off(void) +{ + for (;;); +} + +void +apus_halt(void) +{ + apus_restart(NULL); +} + +void +apus_do_IRQ(struct pt_regs *regs, + int cpu, + int isfake) +{ + int old_level, new_level; + + /* I don't think we need SMP code here - Corey */ + + old_level = ~(regs->mq) & IPLEMU_IPLMASK; + new_level = (~(regs->mq) >> 3) & IPLEMU_IPLMASK; + if (new_level != 0) + { + APUS_WRITE(APUS_IPL_EMU, IPLEMU_IPLMASK); + APUS_WRITE(APUS_IPL_EMU, (IPLEMU_SETRESET + | (~(new_level) & IPLEMU_IPLMASK))); + APUS_WRITE(APUS_IPL_EMU, IPLEMU_DISABLEINT); + + process_int (VEC_SPUR+new_level, regs); + APUS_WRITE(APUS_IPL_EMU, IPLEMU_SETRESET | IPLEMU_DISABLEINT); + APUS_WRITE(APUS_IPL_EMU, IPLEMU_IPLMASK); + APUS_WRITE(APUS_IPL_EMU, (IPLEMU_SETRESET + | (~(old_level) & IPLEMU_IPLMASK))); + } + APUS_WRITE(APUS_IPL_EMU, IPLEMU_DISABLEINT); +} + +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) +/* + * IDE stuff. + */ +void +apus_ide_insw(ide_ioreg_t port, void *buf, int ns) +{ + ide_insw(port, buf, ns); +} + +void +apus_ide_outsw(ide_ioreg_t port, void *buf, int ns) +{ + ide_outsw(port, buf, ns); +} + +int +apus_ide_default_irq(ide_ioreg_t base) +{ + m68k_ide_default_irq(base); +} + +ide_ioreg_t +apus_ide_default_io_base(int index) +{ + m68k_ide_default_io_base(index); +} + +int +apus_ide_check_region(ide_ioreg_t from, unsigned int extent) +{ + return m68k_ide_check_region(from, extent); +} + +void +apus_ide_request_region(ide_ioreg_t from, + unsigned int extent, + const char *name) +{ + m68k_ide_request_region(from, extent, name); +} + +void +apus_ide_release_region(ide_ioreg_t from, + unsigned int extent) +{ + m68k_ide_release_region(from, extent); +} + +void +apus_ide_fix_driveid(struct hd_driveid *id) +{ + m68k_ide_fix_driveid(id); +} + +__initfunc(void +apus_ide_init_hwif_ports (ide_ioreg_t *p, ide_ioreg_t base, int *irq)) +{ + m68k_ide_init_hwif_ports(p, base, irq); +} +#endif + +__initfunc(void +apus_local_init_IRQ(void)) +{ + ppc_md.mask_irq = amiga_disable_irq; + ppc_md.unmask_irq = amiga_enable_irq; + apus_init_IRQ(); +} + +__initfunc(void +apus_init(unsigned long r3, unsigned long r4, unsigned long r5, + unsigned long r6, unsigned long r7)) +{ + /* Parse bootinfo. The bootinfo is located right after + the kernel bss */ + parse_bootinfo((const struct bi_record *)&_end); +#ifdef CONFIG_BLK_DEV_INITRD + /* Take care of initrd if we have one. Use data from + bootinfo to avoid the need to initialize PPC + registers when kernel is booted via a PPC reset. */ + if ( ramdisk.addr ) { + initrd_start = (unsigned long) __va(ramdisk.addr); + initrd_end = (unsigned long) + __va(ramdisk.size + ramdisk.addr); + } + /* Make sure code below is not executed. */ + r4 = 0; + r6 = 0; +#endif /* CONFIG_BLK_DEV_INITRD */ + + ISA_DMA_THRESHOLD = 0x00ffffff; + + ppc_md.setup_arch = apus_setup_arch; + ppc_md.setup_residual = NULL; + ppc_md.get_cpuinfo = apus_get_cpuinfo; + ppc_md.irq_cannonicalize = NULL; + ppc_md.init_IRQ = apus_init_IRQ; + ppc_md.do_IRQ = apus_do_IRQ; + ppc_md.get_irq_source = NULL; + ppc_md.init = NULL; + + ppc_md.restart = apus_restart; + ppc_md.power_off = apus_power_off; + ppc_md.halt = apus_halt; + + ppc_md.time_init = NULL; + ppc_md.set_rtc_time = apus_set_rtc_time; + ppc_md.get_rtc_time = apus_get_rtc_time; + ppc_md.calibrate_decr = apus_calibrate_decr; + + /* These should not be used for the APUS yet, since it uses + the M68K keyboard now. */ + ppc_md.kbd_setkeycode = NULL; + ppc_md.kbd_getkeycode = NULL; + ppc_md.kbd_translate = NULL; + ppc_md.kbd_unexpected_up = NULL; + ppc_md.kbd_leds = NULL; + ppc_md.kbd_init_hw = NULL; + ppc_md.kbd_sysrq_xlate = NULL; + +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) + ppc_ide_md.insw = apus_ide_insw; + ppc_ide_md.outsw = apus_ide_outsw; + ppc_ide_md.default_irq = apus_ide_default_irq; + ppc_ide_md.default_io_base = apus_ide_default_io_base; + ppc_ide_md.check_region = apus_ide_check_region; + ppc_ide_md.request_region = apus_ide_request_region; + ppc_ide_md.release_region = apus_ide_release_region; + ppc_ide_md.fix_driveid = apus_ide_fix_driveid; + ppc_ide_md.ide_init_hwif = apus_ide_init_hwif_ports; + + ppc_ide_md.io_base = _IO_BASE; +#endif } diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/chrp_pci.c linux/arch/ppc/kernel/chrp_pci.c --- v2.2.7/linux/arch/ppc/kernel/chrp_pci.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/chrp_pci.c Thu Apr 29 12:39:01 1999 @@ -15,10 +15,14 @@ #include #include #include +#include +#include + +#include "pci.h" /* LongTrail */ #define pci_config_addr(bus, dev, offset) \ - (GG2_PCI_CONFIG_BASE | ((bus)<<16) | ((dev)<<8) | (offset)) +(GG2_PCI_CONFIG_BASE | ((bus)<<16) | ((dev)<<8) | (offset)) volatile struct Hydra *Hydra = NULL; @@ -30,149 +34,67 @@ int gg2_pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn, unsigned char offset, unsigned char *val) { - if (bus > 7) { - *val = 0xff; - return PCIBIOS_DEVICE_NOT_FOUND; - } - *val = in_8((unsigned char *)pci_config_addr(bus, dev_fn, offset)); - return PCIBIOS_SUCCESSFUL; + if (bus > 7) { + *val = 0xff; + return PCIBIOS_DEVICE_NOT_FOUND; + } + *val = in_8((unsigned char *)pci_config_addr(bus, dev_fn, offset)); + return PCIBIOS_SUCCESSFUL; } int gg2_pcibios_read_config_word(unsigned char bus, unsigned char dev_fn, unsigned char offset, unsigned short *val) { - if (bus > 7) { - *val = 0xffff; - return PCIBIOS_DEVICE_NOT_FOUND; - } - *val = in_le16((unsigned short *)pci_config_addr(bus, dev_fn, offset)); - return PCIBIOS_SUCCESSFUL; + if (bus > 7) { + *val = 0xffff; + return PCIBIOS_DEVICE_NOT_FOUND; + } + *val = in_le16((unsigned short *)pci_config_addr(bus, dev_fn, offset)); + return PCIBIOS_SUCCESSFUL; } int gg2_pcibios_read_config_dword(unsigned char bus, unsigned char dev_fn, unsigned char offset, unsigned int *val) { - if (bus > 7) { - *val = 0xffffffff; - return PCIBIOS_DEVICE_NOT_FOUND; - } - *val = in_le32((unsigned int *)pci_config_addr(bus, dev_fn, offset)); - return PCIBIOS_SUCCESSFUL; + if (bus > 7) { + *val = 0xffffffff; + return PCIBIOS_DEVICE_NOT_FOUND; + } + *val = in_le32((unsigned int *)pci_config_addr(bus, dev_fn, offset)); + return PCIBIOS_SUCCESSFUL; } int gg2_pcibios_write_config_byte(unsigned char bus, unsigned char dev_fn, unsigned char offset, unsigned char val) { - if (bus > 7) - return PCIBIOS_DEVICE_NOT_FOUND; - out_8((unsigned char *)pci_config_addr(bus, dev_fn, offset), val); - return PCIBIOS_SUCCESSFUL; + if (bus > 7) + return PCIBIOS_DEVICE_NOT_FOUND; + out_8((unsigned char *)pci_config_addr(bus, dev_fn, offset), val); + return PCIBIOS_SUCCESSFUL; } int gg2_pcibios_write_config_word(unsigned char bus, unsigned char dev_fn, unsigned char offset, unsigned short val) { - if (bus > 7) - return PCIBIOS_DEVICE_NOT_FOUND; - out_le16((unsigned short *)pci_config_addr(bus, dev_fn, offset), val); - return PCIBIOS_SUCCESSFUL; + if (bus > 7) + return PCIBIOS_DEVICE_NOT_FOUND; + out_le16((unsigned short *)pci_config_addr(bus, dev_fn, offset), val); + return PCIBIOS_SUCCESSFUL; } int gg2_pcibios_write_config_dword(unsigned char bus, unsigned char dev_fn, unsigned char offset, unsigned int val) { - if (bus > 7) - return PCIBIOS_DEVICE_NOT_FOUND; - out_le32((unsigned int *)pci_config_addr(bus, dev_fn, offset), val); - return PCIBIOS_SUCCESSFUL; -} - -extern volatile unsigned int *pci_config_address; -extern volatile unsigned char *pci_config_data; - -#define DEV_FN_MAX (31<<3) - -int raven_pcibios_read_config_byte(unsigned char bus, - unsigned char dev_fn, - unsigned char offset, - unsigned char *val) -{ - if (dev_fn >= DEV_FN_MAX) return PCIBIOS_DEVICE_NOT_FOUND; - out_be32(pci_config_address, - 0x80|(bus<<8)|(dev_fn<<16)|((offset&~3)<<24)); - *val = in_8(pci_config_data+(offset&3)); - return PCIBIOS_SUCCESSFUL; -} - -int raven_pcibios_read_config_word(unsigned char bus, - unsigned char dev_fn, - unsigned char offset, - unsigned short *val) -{ - if (dev_fn >= DEV_FN_MAX) return PCIBIOS_DEVICE_NOT_FOUND; - if (offset&1)return PCIBIOS_BAD_REGISTER_NUMBER; - out_be32(pci_config_address, - 0x80|(bus<<8)|(dev_fn<<16)|((offset&~3)<<24)); - *val = in_le16((volatile unsigned short *) - (pci_config_data+(offset&3))); - return PCIBIOS_SUCCESSFUL; -} - -int raven_pcibios_read_config_dword(unsigned char bus, - unsigned char dev_fn, - unsigned char offset, - unsigned int *val) -{ - if (dev_fn >= DEV_FN_MAX) return PCIBIOS_DEVICE_NOT_FOUND; - if (offset&3)return PCIBIOS_BAD_REGISTER_NUMBER; - out_be32(pci_config_address, - 0x80|(bus<<8)|(dev_fn<<16)|(offset<<24)); - *val = in_le32((volatile unsigned int *)(pci_config_data)); - return PCIBIOS_SUCCESSFUL; -} - -int raven_pcibios_write_config_byte(unsigned char bus, - unsigned char dev_fn, - unsigned char offset, - unsigned char val) -{ - if (dev_fn >= DEV_FN_MAX) return PCIBIOS_DEVICE_NOT_FOUND; - out_be32(pci_config_address, - 0x80|(bus<<8)|(dev_fn<<16)|((offset&~3)<<24)); - out_8(pci_config_data+(offset&3),val); - return PCIBIOS_SUCCESSFUL; -} - -int raven_pcibios_write_config_word(unsigned char bus, - unsigned char dev_fn, - unsigned char offset, - unsigned short val) -{ - if (dev_fn >= DEV_FN_MAX) return PCIBIOS_DEVICE_NOT_FOUND; - if (offset&1)return PCIBIOS_BAD_REGISTER_NUMBER; - out_be32(pci_config_address, - 0x80|(bus<<8)|(dev_fn<<16)|((offset&~3)<<24)); - out_le16((volatile unsigned short *)(pci_config_data+(offset&3)),val); - return PCIBIOS_SUCCESSFUL; -} - -int raven_pcibios_write_config_dword(unsigned char bus, - unsigned char dev_fn, - unsigned char offset, - unsigned int val) -{ - if (dev_fn >= DEV_FN_MAX) return PCIBIOS_DEVICE_NOT_FOUND; - if (offset&3)return PCIBIOS_BAD_REGISTER_NUMBER; - out_be32(pci_config_address, - 0x80|(bus<<8)|(dev_fn<<16)|(offset<<24)); - out_le32((volatile unsigned int *)pci_config_data,val); - return PCIBIOS_SUCCESSFUL; + if (bus > 7) + return PCIBIOS_DEVICE_NOT_FOUND; + out_le32((unsigned int *)pci_config_addr(bus, dev_fn, offset), val); + return PCIBIOS_SUCCESSFUL; } #define python_config_address(bus) (unsigned *)((0xfef00000+0xf8000)-(bus*0x100000)) #define python_config_data(bus) ((0xfef00000+0xf8010)-(bus*0x100000)) -#define PYTHON_CFA(b, d, o) (0x80 | ((b) << 8) | ((d) << 16) \ +#define PYTHON_CFA(b, d, o) (0x80 | ((b<<6) << 8) | ((d) << 16) \ | (((o) & ~3) << 24)) int python_pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn, @@ -182,7 +104,7 @@ *val = 0xff; return PCIBIOS_DEVICE_NOT_FOUND; } - out_be32( python_config_address( bus ), PYTHON_CFA(bus,dev_fn,offset) ); + out_be32( python_config_address( bus ), PYTHON_CFA(bus,dev_fn,offset)); *val = in_8((unsigned char *)python_config_data(bus) + (offset&3)); return PCIBIOS_SUCCESSFUL; } @@ -194,7 +116,7 @@ *val = 0xffff; return PCIBIOS_DEVICE_NOT_FOUND; } - out_be32( python_config_address( bus ), PYTHON_CFA(bus,dev_fn,offset) ); + out_be32( python_config_address( bus ), PYTHON_CFA(bus,dev_fn,offset)); *val = in_le16((unsigned short *)(python_config_data(bus) + (offset&3))); return PCIBIOS_SUCCESSFUL; } @@ -207,7 +129,7 @@ *val = 0xffffffff; return PCIBIOS_DEVICE_NOT_FOUND; } - out_be32( python_config_address( bus ), PYTHON_CFA(bus,dev_fn,offset) ); + out_be32( python_config_address( bus ), PYTHON_CFA(bus,dev_fn,offset)); *val = in_le32((unsigned *)python_config_data(bus)); return PCIBIOS_SUCCESSFUL; } @@ -217,7 +139,7 @@ { if (bus > 2) return PCIBIOS_DEVICE_NOT_FOUND; - out_be32( python_config_address( bus ), PYTHON_CFA(bus,dev_fn,offset) ); + out_be32( python_config_address( bus ), PYTHON_CFA(bus,dev_fn,offset)); out_8((volatile unsigned char *)python_config_data(bus) + (offset&3), val); return PCIBIOS_SUCCESSFUL; } @@ -227,7 +149,7 @@ { if (bus > 2) return PCIBIOS_DEVICE_NOT_FOUND; - out_be32( python_config_address( bus ), PYTHON_CFA(bus,dev_fn,offset) ); + out_be32( python_config_address( bus ), PYTHON_CFA(bus,dev_fn,offset)); out_le16((volatile unsigned short *)python_config_data(bus) + (offset&3), val); return PCIBIOS_SUCCESSFUL; @@ -238,7 +160,7 @@ { if (bus > 2) return PCIBIOS_DEVICE_NOT_FOUND; - out_be32( python_config_address( bus ), PYTHON_CFA(bus,dev_fn,offset) ); + out_be32( python_config_address( bus ), PYTHON_CFA(bus,dev_fn,offset)); out_le32((unsigned *)python_config_data(bus) + (offset&3), val); return PCIBIOS_SUCCESSFUL; } @@ -264,7 +186,8 @@ /* all others are 1 (= default) */ }; -__initfunc(int hydra_init(void)) +int __init +hydra_init(void) { struct device_node *np; @@ -287,4 +210,83 @@ OpenPIC_InitSenses = hydra_openpic_initsenses; OpenPIC_NumInitSenses = sizeof(hydra_openpic_initsenses); return 1; +} + +void __init +chrp_pcibios_fixup(void) +{ + struct pci_dev *dev; + + /* get the other 2 busses on the F50 */ + if ( !strncmp("F5", get_property(find_path_device("/"), + "ibm,model-class", NULL),2) ) + { + pci_scan_peer_bridge(1); + pci_scan_peer_bridge(2); + } + + /* PCI interrupts are controlled by the OpenPIC */ + for( dev=pci_devices ; dev; dev=dev->next ) + { + if ( dev->irq ) + dev->irq = openpic_to_irq( dev->irq ); + /* adjust the io_port for the NCR cards for busses other than 0 -- Cort */ + if ( (dev->bus->number > 0) && (dev->vendor == PCI_VENDOR_ID_NCR) ) + dev->base_address[0] += (dev->bus->number*0x08000000); + /* these need to be absolute addrs for OF and Matrox FB -- Cort */ + if ( dev->vendor == PCI_VENDOR_ID_MATROX ) + { + if ( dev->base_address[0] < isa_mem_base ) + dev->base_address[0] += isa_mem_base; + if ( dev->base_address[1] < isa_mem_base ) + dev->base_address[1] += isa_mem_base; + } + /* the F50 identifies the amd as a trident */ + if ( (dev->vendor == PCI_VENDOR_ID_TRIDENT) && + (dev->class == PCI_CLASS_NETWORK_ETHERNET) ) + { + dev->vendor = PCI_VENDOR_ID_AMD; + pcibios_write_config_word(dev->bus->number, dev->devfn, + PCI_VENDOR_ID, PCI_VENDOR_ID_AMD); + } + } +} + +decl_config_access_method(grackle); +decl_config_access_method(indirect); + +void __init +chrp_setup_pci_ptrs(void) +{ + if ( !strncmp("MOT", + get_property(find_path_device("/"), "model", NULL),3) ) + { + pci_dram_offset = 0; + isa_mem_base = 0xf7000000; + isa_io_base = 0xfe000000; + set_config_access_method(grackle); + } + else + { + if ( find_compatible_devices( "pci", "IBM,python" ) ) + { + /* + * We assume these values but should someday get them + * from the device tree or python itself instead -- Cort + */ + pci_dram_offset = 0x80000000; + isa_mem_base = 0xa0000000; + isa_io_base = 0x88000000; + set_config_access_method(python); + } + else + { + pci_dram_offset = 0; + isa_mem_base = 0xf7000000; + isa_io_base = 0xf8000000; + set_config_access_method(gg2); + } + } + + ppc_md.pcibios_fixup = chrp_pcibios_fixup; } diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/chrp_setup.c linux/arch/ppc/kernel/chrp_setup.c --- v2.2.7/linux/arch/ppc/kernel/chrp_setup.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/chrp_setup.c Thu Apr 29 12:39:01 1999 @@ -41,8 +41,50 @@ #include #include #include - -extern void hydra_init(void); +#include +#include +#include +#include +#include + +#include "time.h" +#include "local_irq.h" +#include "i8259.h" +#include "open_pic.h" + +/* Fixme - need to move these into their own .c and .h file */ +extern void i8259_mask_and_ack_irq(unsigned int irq_nr); +extern void i8259_set_irq_mask(unsigned int irq_nr); +extern void i8259_mask_irq(unsigned int irq_nr); +extern void i8259_unmask_irq(unsigned int irq_nr); +extern void i8259_init(void); + +/* Fixme - remove this when it is fixed. - Corey */ +extern volatile unsigned char *chrp_int_ack_special; + +unsigned long chrp_get_rtc_time(void); +int chrp_set_rtc_time(unsigned long nowtime); +void chrp_calibrate_decr(void); +void chrp_time_init(void); + +void chrp_setup_pci_ptrs(void); + +extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode); +extern int pckbd_getkeycode(unsigned int scancode); +extern int pckbd_translate(unsigned char scancode, unsigned char *keycode, + char raw_mode); +extern char pckbd_unexpected_up(unsigned char keycode); +extern void pckbd_leds(unsigned char leds); +extern void pckbd_init_hw(void); +extern unsigned char pckbd_sysrq_xlate[128]; +extern int mackbd_setkeycode(unsigned int scancode, unsigned int keycode); +extern int mackbd_getkeycode(unsigned int scancode); +extern int mackbd_translate(unsigned char scancode, unsigned char *keycode, + char raw_mode); +extern char mackbd_unexpected_up(unsigned char keycode); +extern void mackbd_leds(unsigned char leds); +extern void mackbd_init_hw(void); +extern unsigned char mackbd_sysrq_xlate[128]; /* for the mac fs */ kdev_t boot_dev; @@ -61,17 +103,17 @@ #endif static const char *gg2_memtypes[4] = { - "FPM", "SDRAM", "EDO", "BEDO" + "FPM", "SDRAM", "EDO", "BEDO" }; static const char *gg2_cachesizes[4] = { - "256 KB", "512 KB", "1 MB", "Reserved" + "256 KB", "512 KB", "1 MB", "Reserved" }; static const char *gg2_cachetypes[4] = { - "Asynchronous", "Reserved", "Flow-Through Synchronous", - "Pipelined Synchronous" + "Asynchronous", "Reserved", "Flow-Through Synchronous", + "Pipelined Synchronous" }; static const char *gg2_cachemodes[4] = { - "Disabled", "Write-Through", "Copy-Back", "Transparent Mode" + "Disabled", "Write-Through", "Copy-Back", "Transparent Mode" }; int @@ -84,7 +126,7 @@ root = find_path_device("/"); if (root) - model = get_property(root, "model", NULL); + model = get_property(root, "model", NULL); len = sprintf(buffer,"machine\t\t: CHRP %s\n", model); /* longtrail (goldengate) stuff */ @@ -137,7 +179,7 @@ return len; } - /* +/* * Fixes for the National Semiconductor PC78308VUL SuperI/O * * Some versions of Open Firmware incorrectly initialize the IRQ settings @@ -146,56 +188,56 @@ __initfunc(static inline void sio_write(u8 val, u8 index)) { - outb(index, 0x15c); - outb(val, 0x15d); + outb(index, 0x15c); + outb(val, 0x15d); } __initfunc(static inline u8 sio_read(u8 index)) { - outb(index, 0x15c); - return inb(0x15d); + outb(index, 0x15c); + return inb(0x15d); } __initfunc(static void sio_fixup_irq(const char *name, u8 device, u8 level, u8 type)) { - u8 level0, type0, active; + u8 level0, type0, active; - /* select logical device */ - sio_write(device, 0x07); - active = sio_read(0x30); - level0 = sio_read(0x70); - type0 = sio_read(0x71); - printk("sio: %s irq level %d, type %d, %sactive: ", name, level0, type0, - !active ? "in" : ""); - if (level0 == level && type0 == type && active) - printk("OK\n"); - else { - printk("remapping to level %d, type %d, active\n", level, type); - sio_write(0x01, 0x30); - sio_write(level, 0x70); - sio_write(type, 0x71); - } + /* select logical device */ + sio_write(device, 0x07); + active = sio_read(0x30); + level0 = sio_read(0x70); + type0 = sio_read(0x71); + printk("sio: %s irq level %d, type %d, %sactive: ", name, level0, type0, + !active ? "in" : ""); + if (level0 == level && type0 == type && active) + printk("OK\n"); + else { + printk("remapping to level %d, type %d, active\n", level, type); + sio_write(0x01, 0x30); + sio_write(level, 0x70); + sio_write(type, 0x71); + } } __initfunc(static void sio_init(void)) { - /* logical device 0 (KBC/Keyboard) */ - sio_fixup_irq("keyboard", 0, 1, 2); - /* select logical device 1 (KBC/Mouse) */ - sio_fixup_irq("mouse", 1, 12, 2); + /* logical device 0 (KBC/Keyboard) */ + sio_fixup_irq("keyboard", 0, 1, 2); + /* select logical device 1 (KBC/Mouse) */ + sio_fixup_irq("mouse", 1, 12, 2); } __initfunc(void -chrp_setup_arch(unsigned long * memory_start_p, unsigned long * memory_end_p)) + chrp_setup_arch(unsigned long * memory_start_p, unsigned long * memory_end_p)) { extern char cmd_line[]; /* init to some ~sane value until calibrate_delay() runs */ loops_per_sec = 50000000; - + #ifdef CONFIG_BLK_DEV_INITRD /* this is fine for chrp */ initrd_below_start_ok = 1; @@ -243,27 +285,207 @@ if ( !strncmp("MOT", get_property(find_path_device("/"), "model", NULL),3) ) *memory_start_p = pmac_find_bridges(*memory_start_p, *memory_end_p); + /* + * The f50 has a lot of IO space - we need to map some in that + * isn't covered by the BAT mappings in MMU_init() -- Cort + */ + if ( !strncmp("F5", get_property(find_path_device("/"), + "ibm,model-class", NULL),2) ) + { +#if 0 + /* + * This ugly hack allows us to force ioremap() to + * create a 1-to-1 mapping for us, even though + * the address is < ioremap_base. This is necessary + * since we want our PCI IO space to have contiguous + * virtual addresses and I think it's worse to have + * calls to map_page() here. + * -- Cort + */ + unsigned long hold = ioremap_base; + ioremap_base = 0; + __ioremap(0x90000000, 0x10000000, _PAGE_NO_CACHE); + ioremap_base = hold; +#endif + } } -#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) +void +chrp_restart(char *cmd) +{ +#if 0 + extern unsigned int rtas_entry, rtas_data, rtas_size; + printk("RTAS system-reboot returned %d\n", + call_rtas("system-reboot", 0, 1, NULL)); + printk("rtas_entry: %08lx rtas_data: %08lx rtas_size: %08lx\n", + rtas_entry,rtas_data,rtas_size); + for (;;); +#else + printk("System Halted\n"); + while(1); +#endif +} -unsigned int chrp_ide_irq = 0; -int chrp_ide_ports_known = 0; -ide_ioreg_t chrp_ide_regbase[MAX_HWIFS]; -ide_ioreg_t chrp_idedma_regbase; +void +chrp_power_off(void) +{ + /* RTAS doesn't seem to work on Longtrail. + For now, do it the same way as the PReP. */ +#if 0 + extern unsigned int rtas_entry, rtas_data, rtas_size; + printk("RTAS power-off returned %d\n", + call_rtas("power-off", 2, 1, NULL, 0, 0)); + printk("rtas_entry: %08lx rtas_data: %08lx rtas_size: %08lx\n", + rtas_entry,rtas_data,rtas_size); + for (;;); +#else + chrp_restart(NULL); +#endif +} -void chrp_ide_init_hwif_ports (ide_ioreg_t *p, ide_ioreg_t base, int *irq) +void +chrp_halt(void) { - ide_ioreg_t port = base; - int i = 8; + chrp_restart(NULL); +} - while (i--) - *p++ = port++; - *p++ = port; - if (irq != NULL) - *irq = chrp_ide_irq; +u_int +chrp_irq_cannonicalize(u_int irq) +{ + if (irq == 2) + { + return 9; + } + else + { + return irq; + } +} + +void +chrp_do_IRQ(struct pt_regs *regs, + int cpu, + int isfake) +{ + int irq; + unsigned long bits = 0; + int openpic_eoi_done = 0; + +#ifdef __SMP__ + { + unsigned int loops = 1000000; + while (test_bit(0, &global_irq_lock)) { + if (smp_processor_id() == global_irq_holder) { + printk("uh oh, interrupt while we hold global irq lock!\n"); +#ifdef CONFIG_XMON + xmon(0); +#endif + break; + } + if (loops-- == 0) { + printk("do_IRQ waiting for irq lock (holder=%d)\n", global_irq_holder); +#ifdef CONFIG_XMON + xmon(0); +#endif + } + } + } +#endif /* __SMP__ */ + + irq = openpic_irq(0); + if (irq == IRQ_8259_CASCADE) + { + /* + * This magic address generates a PCI IACK cycle. + * + * This should go in the above mask/ack code soon. -- Cort + */ + irq = *chrp_int_ack_special; + /* + * Acknowledge as soon as possible to allow i8259 + * interrupt nesting */ + openpic_eoi(0); + openpic_eoi_done = 1; + } + if (irq == OPENPIC_VEC_SPURIOUS) + { + /* + * Spurious interrupts should never be + * acknowledged + */ + ppc_spurious_interrupts++; + openpic_eoi_done = 1; + goto out; + } + bits = 1UL << irq; + + if (irq < 0) + { + printk(KERN_DEBUG "Bogus interrupt %d from PC = %lx\n", + irq, regs->nip); + ppc_spurious_interrupts++; + } + else + { + ppc_irq_dispatch_handler( regs, irq ); + } +out: + if (!openpic_eoi_done) + openpic_eoi(0); } +__initfunc(void + chrp_init_IRQ(void)) +{ + struct device_node *np; + int i; + + if ( !(np = find_devices("pci") ) ) + printk("Cannot find pci to get ack address\n"); + else + { + chrp_int_ack_special = (volatile unsigned char *) + (*(unsigned long *)get_property(np, + "8259-interrupt-acknowledge", NULL)); + } + for ( i = 16 ; i < NR_IRQS ; i++ ) + irq_desc[i].ctl = &open_pic; + /* openpic knows that it's at irq 16 offset + * so we don't need to set it in the pic structure + * -- Cort + */ + openpic_init(1); + for ( i = 0 ; i < 16 ; i++ ) + irq_desc[i].ctl = &i8259_pic; + i8259_init(); +#ifdef CONFIG_XMON + request_irq(openpic_to_irq(HYDRA_INT_ADB_NMI), + xmon_irq, 0, "NMI", 0); +#endif /* CONFIG_XMON */ +#ifdef __SMP__ + request_irq(openpic_to_irq(OPENPIC_VEC_IPI), + openpic_ipi_action, 0, "IPI0", 0); +#endif /* __SMP__ */ +} + +__initfunc(void + chrp_init2(void)) +{ + adb_init(); + + /* Should this be here? - Corey */ + pmac_nvram_init(); +} + +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) +/* + * IDE stuff. + */ +unsigned int chrp_ide_irq = 0; +int chrp_ide_ports_known = 0; +ide_ioreg_t chrp_ide_regbase[MAX_HWIFS]; +ide_ioreg_t chrp_idedma_regbase; + void chrp_ide_probe(void) { struct pci_dev *pdev = pci_find_device(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105, NULL); @@ -281,9 +503,167 @@ } } +void +chrp_ide_insw(ide_ioreg_t port, void *buf, int ns) +{ + ide_insw(port+_IO_BASE, buf, ns); +} + +void +chrp_ide_outsw(ide_ioreg_t port, void *buf, int ns) +{ + ide_outsw(port+_IO_BASE, buf, ns); +} + +int +chrp_ide_default_irq(ide_ioreg_t base) +{ + if (chrp_ide_ports_known == 0) + chrp_ide_probe(); + return chrp_ide_irq; +} + +ide_ioreg_t +chrp_ide_default_io_base(int index) +{ + if (chrp_ide_ports_known == 0) + chrp_ide_probe(); + return chrp_ide_regbase[index]; +} + +int +chrp_ide_check_region(ide_ioreg_t from, unsigned int extent) +{ + return check_region(from, extent); +} + +void +chrp_ide_request_region(ide_ioreg_t from, + unsigned int extent, + const char *name) +{ + request_region(from, extent, name); +} + +void +chrp_ide_release_region(ide_ioreg_t from, + unsigned int extent) +{ + release_region(from, extent); +} + +void +chrp_ide_fix_driveid(struct hd_driveid *id) +{ + ppc_generic_ide_fix_driveid(id); +} + +void chrp_ide_init_hwif_ports (ide_ioreg_t *p, ide_ioreg_t base, int *irq) +{ + ide_ioreg_t port = base; + int i = 8; + + while (i--) + *p++ = port++; + *p++ = port; + if (irq != NULL) + *irq = chrp_ide_irq; +} + EXPORT_SYMBOL(chrp_ide_irq); EXPORT_SYMBOL(chrp_ide_ports_known); EXPORT_SYMBOL(chrp_ide_regbase); EXPORT_SYMBOL(chrp_ide_probe); #endif + +__initfunc(void + chrp_init(unsigned long r3, unsigned long r4, unsigned long r5, + unsigned long r6, unsigned long r7)) +{ + chrp_setup_pci_ptrs(); +#ifdef CONFIG_BLK_DEV_INITRD + /* take care of initrd if we have one */ + if ( r3 ) + { + initrd_start = r3 + KERNELBASE; + initrd_end = r3 + r4 + KERNELBASE; + } +#endif /* CONFIG_BLK_DEV_INITRD */ + + /* pci_dram_offset/isa_io_base/isa_mem_base set by setup_pci_ptrs() */ + ISA_DMA_THRESHOLD = ~0L; + DMA_MODE_READ = 0x44; + DMA_MODE_WRITE = 0x48; + + ppc_md.setup_arch = chrp_setup_arch; + ppc_md.setup_residual = NULL; + ppc_md.get_cpuinfo = chrp_get_cpuinfo; + ppc_md.irq_cannonicalize = chrp_irq_cannonicalize; + ppc_md.init_IRQ = chrp_init_IRQ; + ppc_md.do_IRQ = chrp_do_IRQ; + + ppc_md.init = chrp_init2; + + ppc_md.restart = chrp_restart; + ppc_md.power_off = chrp_power_off; + ppc_md.halt = chrp_halt; + + ppc_md.time_init = chrp_time_init; + ppc_md.set_rtc_time = chrp_set_rtc_time; + ppc_md.get_rtc_time = chrp_get_rtc_time; + ppc_md.calibrate_decr = chrp_calibrate_decr; + +#ifdef CONFIG_VT +#ifdef CONFIG_MAC_KEYBOAD + if ( adb_hardware == ADB_NONE ) + { + ppc_md.kbd_setkeycode = pckbd_setkeycode; + ppc_md.kbd_getkeycode = pckbd_getkeycode; + ppc_md.kbd_translate = pckbd_translate; + ppc_md.kbd_unexpected_up = pckbd_unexpected_up; + ppc_md.kbd_leds = pckbd_leds; + ppc_md.kbd_init_hw = pckbd_init_hw; +#ifdef CONFIG_MAGIC_SYSRQ + ppc_md.kbd_sysrq_xlate = pckbd_sysrq_xlate; +#endif + } + else + { + ppc_md.kbd_setkeycode = mackbd_setkeycode; + ppc_md.kbd_getkeycode = mackbd_getkeycode; + ppc_md.kbd_translate = mackbd_translate; + ppc_md.kbd_unexpected_up = mackbd_unexpected_up; + ppc_md.kbd_leds = mackbd_leds; + ppc_md.kbd_init_hw = mackbd_init_hw; +#ifdef CONFIG_MAGIC_SYSRQ + ppc_md.kbd_sysrq_xlate = mackbd_sysrq_xlate; +#endif + } +#else + ppc_md.kbd_setkeycode = pckbd_setkeycode; + ppc_md.kbd_getkeycode = pckbd_getkeycode; + ppc_md.kbd_translate = pckbd_translate; + ppc_md.kbd_unexpected_up = pckbd_unexpected_up; + ppc_md.kbd_leds = pckbd_leds; + ppc_md.kbd_init_hw = pckbd_init_hw; +#ifdef CONFIG_MAGIC_SYSRQ + ppc_md.kbd_sysrq_xlate = pckbd_sysrq_xlate; +#endif +#endif +#endif + +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) + ppc_ide_md.insw = chrp_ide_insw; + ppc_ide_md.outsw = chrp_ide_outsw; + ppc_ide_md.default_irq = chrp_ide_default_irq; + ppc_ide_md.default_io_base = chrp_ide_default_io_base; + ppc_ide_md.check_region = chrp_ide_check_region; + ppc_ide_md.request_region = chrp_ide_request_region; + ppc_ide_md.release_region = chrp_ide_release_region; + ppc_ide_md.fix_driveid = chrp_ide_fix_driveid; + ppc_ide_md.ide_init_hwif = chrp_ide_init_hwif_ports; + + ppc_ide_md.io_base = _IO_BASE; +#endif +} diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/head.S linux/arch/ppc/kernel/head.S --- v2.2.7/linux/arch/ppc/kernel/head.S Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/head.S Thu Apr 29 12:39:01 1999 @@ -1,7 +1,7 @@ /* * arch/ppc/kernel/head.S * - * $Id: head.S,v 1.121 1999/03/16 10:40:29 cort Exp $ + * $Id: head.S,v 1.127 1999/04/07 07:26:55 paulus Exp $ * * PowerPC version * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) @@ -91,7 +91,7 @@ #define tlbia \ li r4,128; \ mtctr r4; \ - lis r4,0xC000; \ + lis r4,KERNELBASE@h; \ 0: tlbie r4; \ addi r4,r4,0x1000; \ bdnz 0b @@ -415,7 +415,7 @@ * this, we leave this much untouched space on the stack on exception * entry. */ -#define STACK_UNDERHEAD 64 +#define STACK_UNDERHEAD 0 /* * Exception entry code. This code runs with address translation @@ -1495,27 +1495,25 @@ * On SMP we know the fpu is free, since we give it up every * switch. -- Cort */ + mfmsr r5 + ori r5,r5,MSR_FP + SYNC + mtmsr r5 /* enable use of fpu now */ + SYNC +/* + * For SMP, we don't do lazy FPU switching because it just gets too + * horrendously complex, especially when a task switches from one CPU + * to another. Instead we call giveup_fpu in switch_to. + */ +#ifndef __SMP__ #ifndef CONFIG_APUS lis r6,-KERNELBASE@h #else lis r6,CYBERBASEp@h lwz r6,0(r6) #endif - addis r3,r6,last_task_used_math@ha lwz r4,last_task_used_math@l(r3) - mfmsr r5 - ori r5,r5,MSR_FP - SYNC - mtmsr r5 /* enable use of fpu now */ -/* - * All the saving of last_task_used_math is handled - * by a switch_to() call to smp_giveup_fpu() in SMP so - * last_task_used_math is not used. - * -- Cort - */ -#ifndef __SMP__ - SYNC cmpi 0,r4,0 beq 1f add r4,r4,r6 @@ -1529,15 +1527,17 @@ li r20,MSR_FP|MSR_FE0|MSR_FE1 andc r4,r4,r20 /* disable FP for previous task */ stw r4,_MSR-STACK_FRAME_OVERHEAD(r5) +1: #endif /* __SMP__ */ -1: ori r23,r23,MSR_FP|MSR_FE0|MSR_FE1 /* enable use of FP after return */ + /* enable use of FP after return */ + ori r23,r23,MSR_FP|MSR_FE0|MSR_FE1 mfspr r5,SPRG3 /* current task's TSS (phys) */ lfd fr0,TSS_FPSCR-4(r5) mtfsf 0xff,fr0 REST_32FPRS(0, r5) +#ifndef __SMP__ subi r4,r5,TSS sub r4,r4,r6 -#ifndef __SMP__ stw r4,last_task_used_math@l(r3) #endif /* __SMP__ */ /* restore registers and return */ @@ -1574,48 +1574,44 @@ .align 4 /* - * Disable FP for the task which had the FPU previously, - * and save its floating-point registers in its thread_struct. + * giveup_fpu(tsk) + * Disable FP for the task given as the argument, + * and save the floating-point registers in its thread_struct. * Enables the FPU for use in the kernel on return. */ -/* smp_giveup_fpu() takes an arg to tell it where to save the fpu - * regs since last_task_used_math can't be trusted (many many race - * conditions). -- Cort - */ - .globl smp_giveup_fpu -smp_giveup_fpu: - mr r4,r3 - b 12f .globl giveup_fpu giveup_fpu: - lis r3,last_task_used_math@ha - lwz r4,last_task_used_math@l(r3) -12: mfmsr r5 ori r5,r5,MSR_FP SYNC mtmsr r5 /* enable use of fpu now */ SYNC - cmpi 0,r4,0 + cmpi 0,r3,0 beqlr- /* if no previous owner, done */ - addi r4,r4,TSS /* want TSS of last_task_used_math */ + addi r3,r3,TSS /* want TSS of task */ + lwz r5,PT_REGS(r3) + cmpi 0,r5,0 + SAVE_32FPRS(0, r3) + mffs fr0 + stfd fr0,TSS_FPSCR-4(r3) + beq 1f + lwz r4,_MSR-STACK_FRAME_OVERHEAD(r5) + li r3,MSR_FP|MSR_FE0|MSR_FE1 + andc r4,r4,r3 /* disable FP for previous task */ + stw r4,_MSR-STACK_FRAME_OVERHEAD(r5) +1: #ifndef __SMP__ li r5,0 - stw r5,last_task_used_math@l(r3) + lis r4,last_task_used_math@ha + stw r5,last_task_used_math@l(r4) #endif /* __SMP__ */ - SAVE_32FPRS(0, r4) - mffs fr0 - stfd fr0,TSS_FPSCR-4(r4) - lwz r5,PT_REGS(r4) - lwz r3,_MSR-STACK_FRAME_OVERHEAD(r5) - li r4,MSR_FP|MSR_FE0|MSR_FE1 - andc r3,r3,r4 /* disable FP for previous task */ - stw r3,_MSR-STACK_FRAME_OVERHEAD(r5) + blr + #else /* CONFIG_8xx */ .globl giveup_fpu giveup_fpu: -#endif /* CONFIG_8xx */ blr +#endif /* CONFIG_8xx */ /* * This code is jumped to from the startup code to copy @@ -2127,8 +2123,8 @@ lwz r5,_MSR(r1) and. r5,r5,r4 beq 2f -3: lis r4,n_lost_interrupts@ha - lwz r4,n_lost_interrupts@l(r4) +3: lis r4,ppc_n_lost_interrupts@ha + lwz r4,ppc_n_lost_interrupts@l(r4) cmpi 0,r4,0 beq+ 1f addi r3,r1,STACK_FRAME_OVERHEAD diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/i8259.c linux/arch/ppc/kernel/i8259.c --- v2.2.7/linux/arch/ppc/kernel/i8259.c Wed Dec 31 16:00:00 1969 +++ linux/arch/ppc/kernel/i8259.c Thu Apr 29 12:39:01 1999 @@ -0,0 +1,96 @@ + +#include +#include +#include +#include +#include +#include "i8259.h" + +unsigned char cached_8259[2] = { 0xff, 0xff }; +#define cached_A1 (cached_8259[0]) +#define cached_21 (cached_8259[1]) + +static void i8259_mask_and_ack_irq(unsigned int irq_nr) +{ + if ( irq_nr >= i8259_pic.irq_offset ) + irq_nr -= i8259_pic.irq_offset; + + if (irq_nr > 7) { + cached_A1 |= 1 << (irq_nr-8); + inb(0xA1); /* DUMMY */ + outb(cached_A1,0xA1); + outb(0x20,0xA0); /* Non-specific EOI */ + outb(0x20,0x20); /* Non-specific EOI to cascade */ + } else { + cached_21 |= 1 << irq_nr; + inb(0x21); /* DUMMY */ + outb(cached_21,0x21); + outb(0x20,0x20); /* Non-specific EOI */ + } +} + +static void i8259_set_irq_mask(int irq_nr) +{ + outb(cached_A1,0xA1); + outb(cached_21,0x21); +} + +static void i8259_mask_irq(unsigned int irq_nr) +{ + if ( irq_nr >= i8259_pic.irq_offset ) + irq_nr -= i8259_pic.irq_offset; + if ( irq_nr < 8 ) + cached_21 |= 1 << irq_nr; + else + cached_A1 |= 1 << (irq_nr-8); + i8259_set_irq_mask(irq_nr); +} + +static void i8259_unmask_irq(unsigned int irq_nr) +{ + + if ( irq_nr >= i8259_pic.irq_offset ) + irq_nr -= i8259_pic.irq_offset; + if ( irq_nr < 8 ) + cached_21 &= ~(1 << irq_nr); + else + cached_A1 &= ~(1 << (irq_nr-8)); + i8259_set_irq_mask(irq_nr); +} + +struct hw_interrupt_type i8259_pic = { + " i8259 ", + NULL, + NULL, + NULL, + i8259_unmask_irq, + i8259_mask_irq, + i8259_mask_and_ack_irq, + 0 +}; + +static void +no_action(int cpl, void *dev_id, struct pt_regs *regs) +{ +} + +void __init i8259_init(void) +{ + /* init master interrupt controller */ + outb(0x11, 0x20); /* Start init sequence */ + outb(0x00, 0x21); /* Vector base */ + outb(0x04, 0x21); /* edge tiggered, Cascade (slave) on IRQ2 */ + outb(0x01, 0x21); /* Select 8086 mode */ + outb(0xFF, 0x21); /* Mask all */ + /* init slave interrupt controller */ + outb(0x11, 0xA0); /* Start init sequence */ + outb(0x08, 0xA1); /* Vector base */ + outb(0x02, 0xA1); /* edge triggered, Cascade (slave) on IRQ2 */ + outb(0x01, 0xA1); /* Select 8086 mode */ + outb(0xFF, 0xA1); /* Mask all */ + outb(cached_A1, 0xA1); + outb(cached_21, 0x21); + request_irq( i8259_pic.irq_offset + 2, no_action, SA_INTERRUPT, + "82c59 secondary cascade", NULL ); + enable_irq(i8259_pic.irq_offset + 2); /* Enable cascade interrupt */ +} diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/i8259.h linux/arch/ppc/kernel/i8259.h --- v2.2.7/linux/arch/ppc/kernel/i8259.h Wed Dec 31 16:00:00 1969 +++ linux/arch/ppc/kernel/i8259.h Thu Apr 29 12:39:01 1999 @@ -0,0 +1,11 @@ + +#ifndef _PPC_KERNEL_i8259_H +#define _PPC_KERNEL_i8259_H + +#include "local_irq.h" + +extern struct hw_interrupt_type i8259_pic; + +void i8259_init(void); + +#endif /* _PPC_KERNEL_i8259_H */ diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/idle.c linux/arch/ppc/kernel/idle.c --- v2.2.7/linux/arch/ppc/kernel/idle.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/idle.c Thu Apr 29 12:39:01 1999 @@ -1,5 +1,5 @@ /* - * $Id: idle.c,v 1.60 1999/02/12 07:06:26 cort Exp $ + * $Id: idle.c,v 1.61 1999/03/18 04:15:45 cort Exp $ * * Idle daemon for PowerPC. Idle daemon will handle any action * that needs to be taken when the system becomes idle. @@ -303,7 +303,14 @@ hid0 &= ~(HID0_NAP | HID0_SLEEP | HID0_DOZE); hid0 |= (powersave_nap? HID0_NAP: HID0_DOZE) | HID0_DPM; asm("mtspr 1008,%0" : : "r" (hid0)); - msr |= MSR_POW; + + /* set the POW bit in the MSR, and enable interrupts + * so we wake up sometime! */ + _nmask_and_or_msr(0, MSR_POW | MSR_EE); + + /* Disable interrupts again so restore_flags will + * work. */ + _nmask_and_or_msr(MSR_EE, 0); } restore_flags(msr); default: diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/indirect_pci.c linux/arch/ppc/kernel/indirect_pci.c --- v2.2.7/linux/arch/ppc/kernel/indirect_pci.c Wed Dec 31 16:00:00 1969 +++ linux/arch/ppc/kernel/indirect_pci.c Thu Apr 29 12:39:01 1999 @@ -0,0 +1,121 @@ +/* + * Support for indirect PCI bridges. + * + * Copyright (C) 1998 Gabriel Paubert. + * + * 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 +#include + +unsigned int * pci_config_address; +unsigned char * pci_config_data; + +int indirect_pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn, + unsigned char offset, unsigned char *val) +{ + unsigned flags; + + save_flags(flags); cli(); + + out_be32(pci_config_address, + ((offset&0xfc)<<24) | (dev_fn<<16) | (bus<<8) | 0x80); + + *val= in_8(pci_config_data + (offset&3)); + + restore_flags(flags); + return PCIBIOS_SUCCESSFUL; +} + +int indirect_pcibios_read_config_word(unsigned char bus, unsigned char dev_fn, + unsigned char offset, unsigned short *val) +{ + unsigned flags; + + if (offset&1) return PCIBIOS_BAD_REGISTER_NUMBER; + + save_flags(flags); cli(); + + out_be32(pci_config_address, + ((offset&0xfc)<<24) | (dev_fn<<16) | (bus<<8) | 0x80); + + *val= in_le16((unsigned short *)(pci_config_data + (offset&3))); + + restore_flags(flags); + return PCIBIOS_SUCCESSFUL; +} + +int indirect_pcibios_read_config_dword(unsigned char bus, unsigned char dev_fn, + unsigned char offset, unsigned int *val) +{ + unsigned flags; + + if (offset&3) return PCIBIOS_BAD_REGISTER_NUMBER; + + save_flags(flags); cli(); + + out_be32(pci_config_address, + ((offset&0xfc)<<24) | (dev_fn<<16) | (bus<<8) | 0x80); + + *val= in_le32((unsigned *)pci_config_data); + + restore_flags(flags); + return PCIBIOS_SUCCESSFUL; +} + +int indirect_pcibios_write_config_byte(unsigned char bus, unsigned char dev_fn, + unsigned char offset, unsigned char val) +{ + unsigned flags; + + save_flags(flags); cli(); + + out_be32(pci_config_address, + ((offset&0xfc)<<24) | (dev_fn<<16) | (bus<<8) | 0x80); + + out_8(pci_config_data + (offset&3), val); + + restore_flags(flags); + return PCIBIOS_SUCCESSFUL; +} + +int indirect_pcibios_write_config_word(unsigned char bus, unsigned char dev_fn, + unsigned char offset, unsigned short val) +{ + unsigned flags; + + if (offset&1) return PCIBIOS_BAD_REGISTER_NUMBER; + + save_flags(flags); cli(); + + out_be32(pci_config_address, + ((offset&0xfc)<<24) | (dev_fn<<16) | (bus<<8) | 0x80); + + out_le16((unsigned short *)(pci_config_data + (offset&3)), val); + + restore_flags(flags); + return PCIBIOS_SUCCESSFUL; +} + +int indirect_pcibios_write_config_dword(unsigned char bus, unsigned char dev_fn, + unsigned char offset, unsigned short val) +{ + unsigned flags; + + if (offset&3) return PCIBIOS_BAD_REGISTER_NUMBER; + + save_flags(flags); cli(); + + out_be32(pci_config_address, + ((offset&0xfc)<<24) | (dev_fn<<16) | (bus<<8) | 0x80); + + out_le32((unsigned *)pci_config_data, val); + + restore_flags(flags); + return PCIBIOS_SUCCESSFUL; +} diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/irq.c linux/arch/ppc/kernel/irq.c --- v2.2.7/linux/arch/ppc/kernel/irq.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/irq.c Thu Apr 29 12:39:01 1999 @@ -1,5 +1,5 @@ /* - * $Id: irq.c,v 1.102 1999/02/03 01:36:59 paulus Exp $ + * $Id: irq.c,v 1.105 1999/03/25 19:51:51 cort Exp $ * * arch/ppc/kernel/irq.c * @@ -58,44 +58,15 @@ #include #include #include -#ifdef CONFIG_8xx -#include -#include -#endif -static void no_action(int cpl, void *dev_id, struct pt_regs *regs) { } +#include "local_irq.h" + extern volatile unsigned long ipi_count; -static void dispatch_handler(struct pt_regs *regs, int irq); void enable_irq(unsigned int irq_nr); void disable_irq(unsigned int irq_nr); -static void i8259_mask_and_ack_irq(unsigned int irq_nr); -static void i8259_mask_irq(unsigned int irq_nr); -static void i8259_unmask_irq(unsigned int irq_nr); -#ifdef CONFIG_8xx -static void mbx_mask_and_ack(unsigned int irq_nr); -static void mbx_mask_irq(unsigned int irq_nr); -static void mbx_unmask_irq(unsigned int irq_nr); -static void mbx_i8259_action(int cpl, void *dev_id, struct pt_regs *regs); -#else /* CONFIG_8xx */ -static volatile unsigned char *chrp_int_ack_special; -extern void process_int(unsigned long vec, struct pt_regs *fp); -extern void apus_init_IRQ(void); -extern void amiga_disable_irq(unsigned int irq); -extern void amiga_enable_irq(unsigned int irq); -static void pmac_fix_gatwick_interrupts(struct device_node *gw, int irq_base); -static void gatwick_action(int cpl, void *dev_id, struct pt_regs *regs); -static void pmac_mask_irq(unsigned int irq_nr); -static void pmac_unmask_irq(unsigned int irq_nr); -static void pmac_mask_and_ack_irq(unsigned int irq_nr); -static void chrp_mask_and_ack_irq(unsigned int irq_nr); -static void chrp_unmask_irq(unsigned int irq_nr); -static void chrp_mask_irq(unsigned int irq_nr); -#ifdef __SMP__ -static void openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *regs); -extern void smp_message_recv(void); -#endif /* __SMP__ */ -#endif /* CONFIG_8xx */ +/* Fixme - Need to figure out a way to get rid of this - Corey */ +volatile unsigned char *chrp_int_ack_special; #ifdef CONFIG_APUS /* Rename a few functions. Requires the CONFIG_APUS protection. */ @@ -105,39 +76,19 @@ #define VEC_SPUR (24) #endif +#define MAXCOUNT 10000000 + #define NR_MASK_WORDS ((NR_IRQS + 31) / 32) -unsigned char cached_8259[2] = { 0xff, 0xff }; -#define cached_A1 (cached_8259[0]) -#define cached_21 (cached_8259[1]) - -unsigned int local_bh_count[NR_CPUS]; -unsigned int local_irq_count[NR_CPUS]; -int max_irqs; -int max_real_irqs; -static int spurious_interrupts = 0; -static unsigned int cached_irq_mask[NR_MASK_WORDS]; -unsigned int lost_interrupts[NR_MASK_WORDS]; -atomic_t n_lost_interrupts; - -#ifndef CONFIG_8xx -#define GATWICK_IRQ_POOL_SIZE 10 -static struct interrupt_info gatwick_int_pool[GATWICK_IRQ_POOL_SIZE]; -/* pmac */ -struct pmac_irq_hw { - unsigned int flag; - unsigned int enable; - unsigned int ack; - unsigned int level; -}; - -/* these addresses are obtained from the device tree now -- Cort */ -volatile struct pmac_irq_hw *pmac_irq_hw[4] __pmac = { - (struct pmac_irq_hw *) 0xf3000020, - (struct pmac_irq_hw *) 0xf3000010, - (struct pmac_irq_hw *) 0xf4000020, - (struct pmac_irq_hw *) 0xf4000010, -}; -#endif /* CONFIG_8xx */ + +int ppc_spurious_interrupts = 0; + +unsigned int ppc_local_bh_count[NR_CPUS]; +unsigned int ppc_local_irq_count[NR_CPUS]; +struct irqaction *ppc_irq_action[NR_IRQS]; +unsigned int ppc_cached_irq_mask[NR_MASK_WORDS]; +unsigned int ppc_lost_interrupts[NR_MASK_WORDS]; +atomic_t ppc_n_lost_interrupts; + /* nasty hack for shared irq's since we need to do kmalloc calls but * can't very early in the boot when we need to do a request irq. @@ -174,82 +125,7 @@ kfree(ptr); } -struct hw_interrupt_type { - const char * typename; - void (*startup)(unsigned int irq); - void (*shutdown)(unsigned int irq); - void (*handle)(unsigned int irq, struct pt_regs * regs); - void (*enable)(unsigned int irq); - void (*disable)(unsigned int irq); - void (*mask_and_ack)(unsigned int irq); - int irq_offset; -}; - -#define mask_irq(irq) ({if (irq_desc[irq].ctl && irq_desc[irq].ctl->disable) irq_desc[irq].ctl->disable(irq);}) -#define unmask_irq(irq) ({if (irq_desc[irq].ctl && irq_desc[irq].ctl->enable) irq_desc[irq].ctl->enable(irq);}) -#define mask_and_ack_irq(irq) ({if (irq_desc[irq].ctl && irq_desc[irq].ctl->mask_and_ack) irq_desc[irq].ctl->mask_and_ack(irq);}) - -struct irqdesc { - struct irqaction *action; - struct hw_interrupt_type *ctl; -}; -static struct irqdesc irq_desc[NR_IRQS] = {{0, 0}, }; - -static struct hw_interrupt_type i8259_pic = { - " i8259 ", - NULL, - NULL, - NULL, - i8259_unmask_irq, - i8259_mask_irq, - i8259_mask_and_ack_irq, - 0 -}; -#ifndef CONFIG_8xx -static struct hw_interrupt_type pmac_pic = { - " PMAC-PIC ", - NULL, - NULL, - NULL, - pmac_unmask_irq, - pmac_mask_irq, - pmac_mask_and_ack_irq, - 0 -}; - -static struct hw_interrupt_type gatwick_pic = { - " GATWICK ", - NULL, - NULL, - NULL, - pmac_unmask_irq, - pmac_mask_irq, - pmac_mask_and_ack_irq, - 0 -}; - -static struct hw_interrupt_type open_pic = { - " OpenPIC ", - NULL, - NULL, - NULL, - chrp_unmask_irq, - chrp_mask_irq, - chrp_mask_and_ack_irq, - 0 -}; -#else -static struct hw_interrupt_type ppc8xx_pic = { - " 8xx SIU ", - NULL, - NULL, - NULL, - mbx_unmask_irq, - mbx_mask_irq, - mbx_mask_and_ack, - 0 -}; -#endif /* CONFIG_8xx */ +struct irqdesc irq_desc[NR_IRQS] = {{0, 0}, }; int request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *), unsigned long irqflags, const char * devname, void *dev_id) @@ -357,19 +233,17 @@ } #ifdef __SMP__ /* should this be per processor send/receive? */ - len += sprintf(buf+len, "IPI: %10lu", ipi_count); - for ( i = 0 ; i <= smp_num_cpus-1; i++ ) - len += sprintf(buf+len," "); - len += sprintf(buf+len, " interprocessor messages received\n"); + len += sprintf(buf+len, "IPI: %10lu\n", ipi_count); #endif - len += sprintf(buf+len, "BAD: %10u",spurious_interrupts); - for ( i = 0 ; i <= smp_num_cpus-1; i++ ) - len += sprintf(buf+len," "); - len += sprintf(buf+len, " spurious or short\n"); + len += sprintf(buf+len, "BAD: %10u\n", ppc_spurious_interrupts); return len; } -static void dispatch_handler(struct pt_regs *regs, int irq) +/* + * Eventually, this should take an array of interrupts and an array size + * so it can dispatch multiple interrupts. + */ +void ppc_irq_dispatch_handler(struct pt_regs *regs, int irq) { int status; struct irqaction *action; @@ -390,209 +264,18 @@ __cli(); unmask_irq(irq); } else { - spurious_interrupts++; + ppc_spurious_interrupts++; disable_irq( irq ); } } -#define MAXCOUNT 100000000 asmlinkage void do_IRQ(struct pt_regs *regs, int isfake) { - int irq; - unsigned long bits = 0; int cpu = smp_processor_id(); - int openpic_eoi_done = 0; - - hardirq_enter(cpu); -#ifndef CONFIG_8xx -#ifdef __SMP__ - /* IPI's are a hack on the powersurge -- Cort */ - if ( (_machine == _MACH_Pmac) && (cpu != 0) ) - { - if (!isfake) - { -#ifdef CONFIG_XMON - static int xmon_2nd; - if (xmon_2nd) - xmon(regs); -#endif - smp_message_recv(); - goto out; - } - /* could be here due to a do_fake_interrupt call but we don't - mess with the controller from the second cpu -- Cort */ - goto out; - } - - { - unsigned int loops = MAXCOUNT; - while (test_bit(0, &global_irq_lock)) { - if (smp_processor_id() == global_irq_holder) { - printk("uh oh, interrupt while we hold global irq lock!\n"); -#ifdef CONFIG_XMON - xmon(0); -#endif - break; - } - if (loops-- == 0) { - printk("do_IRQ waiting for irq lock (holder=%d)\n", global_irq_holder); -#ifdef CONFIG_XMON - xmon(0); -#endif - } - } - } -#endif /* __SMP__ */ - - switch ( _machine ) - { - case _MACH_Pmac: - for (irq = max_real_irqs - 1; irq > 0; irq -= 32) { - int i = irq >> 5; - bits = ld_le32(&pmac_irq_hw[i]->flag) - | lost_interrupts[i]; - if (bits == 0) - continue; - irq -= cntlzw(bits); - break; - } - break; - case _MACH_chrp: - irq = openpic_irq(0); - if (irq == IRQ_8259_CASCADE) - { - /* - * This magic address generates a PCI IACK cycle. - * - * This should go in the above mask/ack code soon. -- Cort - */ - irq = *chrp_int_ack_special; - /* - * Acknowledge as soon as possible to allow i8259 - * interrupt nesting - */ - openpic_eoi(0); - openpic_eoi_done = 1; - } - if (irq == OPENPIC_VEC_SPURIOUS) - { - /* - * Spurious interrupts should never be - * acknowledged - */ - spurious_interrupts++; - openpic_eoi_done = 1; - } - bits = 1UL << irq; - break; - case _MACH_prep: - outb(0x0C, 0x20); - irq = inb(0x20) & 7; - if (irq == 2) - { - outb(0x0C, 0xA0); - irq = (inb(0xA0) & 7) + 8; - bits |= 1UL << irq; -#if 0 - /* It's possible to loose intrs here - * if we get 2 intrs in the upper 8 - * bits. We eoi irq 2 and handle one of - * the upper intrs but then ignore it - * since we've already eoi-d 2. So, - * we must keep track of lost intrs. - * -- Cort - */ - while (1) - { - int i; - outb(0x0C, 0xA0); - i = inb(0xA0); - if ( !(i & 128) ) - break; - irq &= 7; - irq += 8; - bits |= 1UL << irq; - } -#endif - } - else - bits = 1UL << irq; - - break; -#ifdef CONFIG_APUS - case _MACH_apus: - { - int old_level, new_level; - - old_level = ~(regs->mq) & IPLEMU_IPLMASK; - new_level = (~(regs->mq) >> 3) & IPLEMU_IPLMASK; - - if (new_level == 0) - { - goto apus_out; - } - - APUS_WRITE(APUS_IPL_EMU, IPLEMU_IPLMASK); - APUS_WRITE(APUS_IPL_EMU, (IPLEMU_SETRESET - | (~(new_level) & IPLEMU_IPLMASK))); - APUS_WRITE(APUS_IPL_EMU, IPLEMU_DISABLEINT); - - process_int (VEC_SPUR+new_level, regs); - - APUS_WRITE(APUS_IPL_EMU, IPLEMU_SETRESET | IPLEMU_DISABLEINT); - APUS_WRITE(APUS_IPL_EMU, IPLEMU_IPLMASK); - APUS_WRITE(APUS_IPL_EMU, (IPLEMU_SETRESET - | (~(old_level) & IPLEMU_IPLMASK))); -apus_out: - hardirq_exit(cpu); - APUS_WRITE(APUS_IPL_EMU, IPLEMU_DISABLEINT); - goto out2; - } -#endif - } - if (irq < 0) - { - printk(KERN_DEBUG "Bogus interrupt %d from PC = %lx\n", - irq, regs->nip); - spurious_interrupts++; - goto out; - } - -#else /* CONFIG_8xx */ - /* For MPC8xx, read the SIVEC register and shift the bits down - * to get the irq number. - */ - bits = ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_sivec; - irq = bits >> 26; - irq += ppc8xx_pic.irq_offset; - bits = 1UL << irq; -#endif /* CONFIG_8xx */ -#if 0 - /* - * this allows for > 1 interrupt at a time so we can - * clear out any 'double' interrupts on prep and - * finish up the lost interrupts. - * It doesn't currently work for irqs > 31 so I'm leaving - * it commented out for now. - * -- Cort - */ - for ( i = 0 ; i < sizeof(bits)*8 ; i++ ) - if ( bits & (1UL<= i8259_pic.irq_offset ) - irq_nr -= i8259_pic.irq_offset; - if (irq_nr > 7) { - cached_A1 |= 1 << (irq_nr-8); - inb(0xA1); /* DUMMY */ - outb(cached_A1,0xA1); - outb(0x62,0x20); /* Specific EOI to cascade */ - /*outb(0x20,0xA0);*/ - outb(0x60|(irq_nr-8), 0xA0); /* specific eoi */ - } else { - cached_21 |= 1 << irq_nr; - inb(0x21); /* DUMMY */ - outb(cached_21,0x21); - /*outb(0x20,0x20);*/ - outb(0x60|irq_nr,0x20); /* specific eoi */ - } -} - -static void i8259_set_irq_mask(int irq_nr) -{ - outb(cached_A1,0xA1); - outb(cached_21,0x21); -} - -static void i8259_mask_irq(unsigned int irq_nr) -{ - if ( irq_nr >= i8259_pic.irq_offset ) - irq_nr -= i8259_pic.irq_offset; - if ( irq_nr < 8 ) - cached_21 |= 1 << irq_nr; - else - cached_A1 |= 1 << (irq_nr-8); - i8259_set_irq_mask(irq_nr); -} - -static void i8259_unmask_irq(unsigned int irq_nr) -{ - - if ( irq_nr >= i8259_pic.irq_offset ) - irq_nr -= i8259_pic.irq_offset; - if ( irq_nr < 8 ) - cached_21 &= ~(1 << irq_nr); - else - cached_A1 &= ~(1 << (irq_nr-8)); - i8259_set_irq_mask(irq_nr); -} - -#ifndef CONFIG_8xx -static void gatwick_action(int cpl, void *dev_id, struct pt_regs *regs) -{ - int irq, bits; - - for (irq = max_irqs - 1; irq > max_real_irqs; irq -= 32) { - int i = irq >> 5; - bits = ld_le32(&pmac_irq_hw[i]->flag) - | lost_interrupts[i]; - if (bits == 0) - continue; - irq -= cntlzw(bits); - break; - } - /* The previous version of this code allowed for this case, we - * don't. Put this here to check for it. - * -- Cort - */ - if ( irq_desc[irq].ctl != &gatwick_pic ) - printk("gatwick irq not from gatwick pic\n"); - else - dispatch_handler( regs, irq ); -} - -void pmac_mask_and_ack_irq(unsigned int irq_nr) -{ - unsigned long bit = 1UL << (irq_nr & 0x1f); - int i = irq_nr >> 5; - - if ((unsigned)irq_nr >= max_irqs) - return; - - clear_bit(irq_nr, cached_irq_mask); - if (test_and_clear_bit(irq_nr, lost_interrupts)) - atomic_dec(&n_lost_interrupts); - out_le32(&pmac_irq_hw[i]->ack, bit); - out_le32(&pmac_irq_hw[i]->enable, cached_irq_mask[i]); - out_le32(&pmac_irq_hw[i]->ack, bit); - do { - /* make sure ack gets to controller before we enable interrupts */ - mb(); - } while(in_le32(&pmac_irq_hw[i]->flag) & bit); - -} - -void __openfirmware chrp_mask_and_ack_irq(unsigned int irq_nr) -{ - if (is_8259_irq(irq_nr)) - i8259_mask_and_ack_irq(irq_nr); -} - -static void pmac_set_irq_mask(int irq_nr) -{ - unsigned long bit = 1UL << (irq_nr & 0x1f); - int i = irq_nr >> 5; - - if ((unsigned)irq_nr >= max_irqs) - return; - - /* enable unmasked interrupts */ - out_le32(&pmac_irq_hw[i]->enable, cached_irq_mask[i]); - - do { - /* make sure mask gets to controller before we - return to user */ - mb(); - } while((in_le32(&pmac_irq_hw[i]->enable) & bit) - != (cached_irq_mask[i] & bit)); - - /* - * Unfortunately, setting the bit in the enable register - * when the device interrupt is already on *doesn't* set - * the bit in the flag register or request another interrupt. - */ - if ((bit & cached_irq_mask[i]) - && (ld_le32(&pmac_irq_hw[i]->level) & bit) - && !(ld_le32(&pmac_irq_hw[i]->flag) & bit)) { - if (!test_and_set_bit(irq_nr, lost_interrupts)) - atomic_inc(&n_lost_interrupts); - } -} - -static void pmac_mask_irq(unsigned int irq_nr) -{ - clear_bit(irq_nr, cached_irq_mask); - pmac_set_irq_mask(irq_nr); - mb(); -} - -static void pmac_unmask_irq(unsigned int irq_nr) -{ - set_bit(irq_nr, cached_irq_mask); - pmac_set_irq_mask(irq_nr); -} - -static void __openfirmware chrp_mask_irq(unsigned int irq_nr) -{ - if (is_8259_irq(irq_nr)) - i8259_mask_irq(irq_nr); - else - openpic_disable_irq(irq_to_openpic(irq_nr)); -} - -static void __openfirmware chrp_unmask_irq(unsigned int irq_nr) -{ - if (is_8259_irq(irq_nr)) - i8259_unmask_irq(irq_nr); - else - openpic_enable_irq(irq_to_openpic(irq_nr)); -} - -/* This routine will fix some missing interrupt values in the device tree - * on the gatwick mac-io controller used by some PowerBooks - */ -static void __init pmac_fix_gatwick_interrupts(struct device_node *gw, int irq_base) -{ - struct device_node *node; - int count; - - memset(gatwick_int_pool, 0, sizeof(gatwick_int_pool)); - node = gw->child; - count = 0; - while(node) - { - /* Fix SCC */ - if (strcasecmp(node->name, "escc") == 0) - if (node->child) { - if (node->child->n_intrs < 3) { - node->child->intrs = &gatwick_int_pool[count]; - count += 3; - } - node->child->n_intrs = 3; - node->child->intrs[0].line = 15+irq_base; - node->child->intrs[1].line = 4+irq_base; - node->child->intrs[2].line = 5+irq_base; - printk(KERN_INFO "irq: fixed SCC on second controller (%d,%d,%d)\n", - node->child->intrs[0].line, - node->child->intrs[1].line, - node->child->intrs[2].line); - } - /* Fix media-bay & left SWIM */ - if (strcasecmp(node->name, "media-bay") == 0) { - struct device_node* ya_node; - - if (node->n_intrs == 0) - node->intrs = &gatwick_int_pool[count++]; - node->n_intrs = 1; - node->intrs[0].line = 29+irq_base; - printk(KERN_INFO "irq: fixed media-bay on second controller (%d)\n", - node->intrs[0].line); - - ya_node = node->child; - while(ya_node) - { - if (strcasecmp(ya_node->name, "floppy") == 0) { - if (ya_node->n_intrs < 2) { - ya_node->intrs = &gatwick_int_pool[count]; - count += 2; - } - ya_node->n_intrs = 2; - ya_node->intrs[0].line = 19+irq_base; - ya_node->intrs[1].line = 1+irq_base; - printk(KERN_INFO "irq: fixed floppy on second controller (%d,%d)\n", - ya_node->intrs[0].line, ya_node->intrs[1].line); - } - if (strcasecmp(ya_node->name, "ata4") == 0) { - if (ya_node->n_intrs < 2) { - ya_node->intrs = &gatwick_int_pool[count]; - count += 2; - } - ya_node->n_intrs = 2; - ya_node->intrs[0].line = 14+irq_base; - ya_node->intrs[1].line = 3+irq_base; - printk(KERN_INFO "irq: fixed ide on second controller (%d,%d)\n", - ya_node->intrs[0].line, ya_node->intrs[1].line); - } - ya_node = ya_node->sibling; - } - } - node = node->sibling; - } - if (count > 10) { - printk("WARNING !! Gatwick interrupt pool overflow\n"); - printk(" GATWICK_IRQ_POOL_SIZE = %d\n", GATWICK_IRQ_POOL_SIZE); - printk(" requested = %d\n", count); - } -} - -#ifdef __SMP__ -static void openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *regs) -{ - smp_message_recv(); -} -#endif /* __SMP__ */ - - -#else /* CONFIG_8xx */ - -static void mbx_i8259_action(int cpl, void *dev_id, struct pt_regs *regs) -{ - int bits, irq; - - /* A bug in the QSpan chip causes it to give us 0xff always - * when doing a character read. So read 32 bits and shift. - * This doesn't seem to return useful values anyway, but - * read it to make sure things are acked. - * -- Cort - */ - irq = (inl(0x508) >> 24)&0xff; - if ( irq != 0xff ) printk("iack %d\n", irq); - - outb(0x0C, 0x20); - irq = inb(0x20) & 7; - if (irq == 2) - { - outb(0x0C, 0xA0); - irq = inb(0xA0); - irq = (irq&7) + 8; - } - bits = 1UL << irq; - irq += i8259_pic.irq_offset; - dispatch_handler( regs, irq ); -} - -static void mbx_mask_and_ack(unsigned int irq_nr) -{ - /* this shouldn't be masked, we mask the 8259 if we need to -- Cort */ - if ( irq_nr != ISA_BRIDGE_INT ) - mbx_mask_irq(irq_nr); - if ( irq_nr >= ppc8xx_pic.irq_offset ) - irq_nr -= ppc8xx_pic.irq_offset; - /* clear the pending bits */ - ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_sipend = 1 << (31-irq_nr); -} - -static void mbx_mask_irq(unsigned int irq_nr) -{ - if ( irq_nr == ISA_BRIDGE_INT ) return; - if ( irq_nr >= ppc8xx_pic.irq_offset ) - irq_nr -= ppc8xx_pic.irq_offset; - cached_irq_mask[0] &= ~(1 << (31-irq_nr)); - ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_simask = cached_irq_mask[0]; -} - -static void mbx_unmask_irq(unsigned int irq_nr) -{ - if ( irq_nr >= ppc8xx_pic.irq_offset ) - irq_nr -= ppc8xx_pic.irq_offset; - cached_irq_mask[0] |= (1 << (31-irq_nr)); - ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_simask = cached_irq_mask[0]; -} -#endif /* CONFIG_8xx */ - -static void __init i8259_init(void) -{ - /* init master interrupt controller */ - outb(0x11, 0x20); /* Start init sequence */ - outb(0x00, 0x21); /* Vector base */ - outb(0x04, 0x21); /* edge tiggered, Cascade (slave) on IRQ2 */ - outb(0x01, 0x21); /* Select 8086 mode */ - outb(0xFF, 0x21); /* Mask all */ - /* init slave interrupt controller */ - outb(0x11, 0xA0); /* Start init sequence */ - outb(0x08, 0xA1); /* Vector base */ - outb(0x02, 0xA1); /* edge triggered, Cascade (slave) on IRQ2 */ - outb(0x01, 0xA1); /* Select 8086 mode */ - outb(0xFF, 0xA1); /* Mask all */ - outb(cached_A1, 0xA1); - outb(cached_21, 0x21); - request_irq( i8259_pic.irq_offset + 2, no_action, SA_INTERRUPT, - "8259 secondary cascade", NULL ); - enable_irq(i8259_pic.irq_offset + 2); /* Enable cascade interrupt */ -} - void __init init_IRQ(void) { - extern void xmon_irq(int, void *, struct pt_regs *); - int i; static int once = 0; -#ifndef CONFIG_8xx - struct device_node *irqctrler; - unsigned long addr; - struct device_node *np; - int second_irq = -999; -#endif + if ( once ) return; else once++; -#ifndef CONFIG_8xx - switch (_machine) - { - case _MACH_Pmac: - /* G3 powermacs have 64 interrupts, G3 Series PowerBook have 128, - others have 32 */ - max_irqs = max_real_irqs = 32; - irqctrler = find_devices("mac-io"); - if (irqctrler) - { - max_real_irqs = 64; - if (irqctrler->next) - max_irqs = 128; - else - max_irqs = 64; - } - for ( i = 0; i < max_real_irqs ; i++ ) - irq_desc[i].ctl = &pmac_pic; - - /* get addresses of first controller */ - if (irqctrler) { - if (irqctrler->n_addrs > 0) { - addr = (unsigned long) - ioremap(irqctrler->addrs[0].address, 0x40); - for (i = 0; i < 2; ++i) - pmac_irq_hw[i] = (volatile struct pmac_irq_hw*) - (addr + (2 - i) * 0x10); - } - - /* get addresses of second controller */ - irqctrler = (irqctrler->next) ? irqctrler->next : NULL; - if (irqctrler && irqctrler->n_addrs > 0) { - addr = (unsigned long) - ioremap(irqctrler->addrs[0].address, 0x40); - for (i = 2; i < 4; ++i) - pmac_irq_hw[i] = (volatile struct pmac_irq_hw*) - (addr + (4 - i) * 0x10); - } - } - - /* disable all interrupts in all controllers */ - for (i = 0; i * 32 < max_irqs; ++i) - out_le32(&pmac_irq_hw[i]->enable, 0); - - /* get interrupt line of secondary interrupt controller */ - if (irqctrler) { - second_irq = irqctrler->intrs[0].line; - printk(KERN_INFO "irq: secondary controller on irq %d\n", - (int)second_irq); - if (device_is_compatible(irqctrler, "gatwick")) - pmac_fix_gatwick_interrupts(irqctrler, max_real_irqs); - for ( i = max_real_irqs ; i < max_irqs ; i++ ) - irq_desc[i].ctl = &gatwick_pic; - request_irq( second_irq, gatwick_action, SA_INTERRUPT, - "gatwick cascade", 0 ); - } - printk("System has %d possible interrupts\n", max_irqs); - if (max_irqs != max_real_irqs) - printk(KERN_DEBUG "%d interrupts on main controller\n", - max_real_irqs); - -#ifdef CONFIG_XMON - request_irq(20, xmon_irq, 0, "NMI - XMON", 0); -#endif /* CONFIG_XMON */ - break; - case _MACH_chrp: - if ( !(np = find_devices("pci") ) ) - printk("Cannot find pci to get ack address\n"); - else - { - chrp_int_ack_special = (volatile unsigned char *) - (*(unsigned long *)get_property(np, - "8259-interrupt-acknowledge", NULL)); - } - for ( i = 16 ; i < 36 ; i++ ) - irq_desc[i].ctl = &open_pic; - /* openpic knows that it's at irq 16 offset - * so we don't need to set it in the pic structure - * -- Cort - */ - openpic_init(1); - for ( i = 0 ; i < 16 ; i++ ) - irq_desc[i].ctl = &i8259_pic; - i8259_init(); -#ifdef CONFIG_XMON - request_irq(openpic_to_irq(HYDRA_INT_ADB_NMI), - xmon_irq, 0, "NMI", 0); -#endif /* CONFIG_XMON */ -#ifdef __SMP__ - request_irq(openpic_to_irq(OPENPIC_VEC_SPURIOUS), - openpic_ipi_action, 0, "IPI0", 0); -#endif /* __SMP__ */ - break; - case _MACH_prep: - for ( i = 0 ; i < 16 ; i++ ) - irq_desc[i].ctl = &i8259_pic; - i8259_init(); - break; -#ifdef CONFIG_APUS - case _MACH_apus: - apus_init_IRQ(); - break; -#endif - } -#else /* CONFIG_8xx */ - ppc8xx_pic.irq_offset = 16; - for ( i = 16 ; i < 32 ; i++ ) - irq_desc[i].ctl = &ppc8xx_pic; - unmask_irq(CPM_INTERRUPT); - - for ( i = 0 ; i < 16 ; i++ ) - irq_desc[i].ctl = &i8259_pic; - i8259_init(); - request_irq(ISA_BRIDGE_INT, mbx_i8259_action, 0, "8259 cascade", NULL); - enable_irq(ISA_BRIDGE_INT); -#endif /* CONFIG_8xx */ + ppc_md.init_IRQ(); } #ifdef __SMP__ @@ -1078,9 +316,13 @@ printk("\n%s, CPU %d:\n", str, cpu); printk("irq: %d [%d %d]\n", - atomic_read(&global_irq_count), local_irq_count[0], local_irq_count[1]); + atomic_read(&global_irq_count), + ppc_local_irq_count[0], + ppc_local_irq_count[1]); printk("bh: %d [%d %d]\n", - atomic_read(&global_bh_count), local_bh_count[0], local_bh_count[1]); + atomic_read(&global_bh_count), + ppc_local_bh_count[0], + ppc_local_bh_count[1]); stack = (unsigned long *) &str; for (i = 40; i ; i--) { unsigned long x = *++stack; @@ -1115,7 +357,8 @@ * already executing in one.. */ if (!atomic_read(&global_irq_count)) { - if (local_bh_count[cpu] || !atomic_read(&global_bh_count)) + if (ppc_local_bh_count[cpu] + || !atomic_read(&global_bh_count)) break; } @@ -1136,7 +379,8 @@ continue; if (global_irq_lock) continue; - if (!local_bh_count[cpu] && atomic_read(&global_bh_count)) + if (!ppc_local_bh_count[cpu] + && atomic_read(&global_bh_count)) continue; if (!test_and_set_bit(0,&global_irq_lock)) break; @@ -1226,7 +470,7 @@ if (flags & (1 << 15)) { int cpu = smp_processor_id(); __cli(); - if (!local_irq_count[cpu]) + if (!ppc_local_irq_count[cpu]) get_irqlock(cpu); } } @@ -1235,7 +479,7 @@ { int cpu = smp_processor_id(); - if (!local_irq_count[cpu]) + if (!ppc_local_irq_count[cpu]) release_irqlock(cpu); __sti(); } @@ -1259,7 +503,7 @@ retval = 2 + local_enabled; /* check for global flags if we're not in an interrupt */ - if (!local_irq_count[smp_processor_id()]) { + if (!ppc_local_irq_count[smp_processor_id()]) { if (local_enabled) retval = 1; if (global_irq_holder == (unsigned char) smp_processor_id()) @@ -1268,6 +512,31 @@ return retval; } +int +tb(long vals[], + int max_size) +{ + register unsigned long *orig_sp __asm__ ("r1"); + register unsigned long lr __asm__ ("r3"); + unsigned long *sp; + int i; + + asm volatile ("mflr 3"); + vals[0] = lr; + sp = (unsigned long *) *orig_sp; + sp = (unsigned long *) *sp; + for (i=1; i +#include + +void ppc_irq_dispatch_handler(struct pt_regs *regs, int irq); + +/* Structure describing interrupts */ +struct hw_interrupt_type { + const char * typename; + void (*startup)(unsigned int irq); + void (*shutdown)(unsigned int irq); + void (*handle)(unsigned int irq, struct pt_regs * regs); + void (*enable)(unsigned int irq); + void (*disable)(unsigned int irq); + void (*mask_and_ack)(unsigned int irq); + int irq_offset; +}; + +#define mask_irq(irq) ({if (irq_desc[irq].ctl && irq_desc[irq].ctl->disable) irq_desc[irq].ctl->disable(irq);}) +#define unmask_irq(irq) ({if (irq_desc[irq].ctl && irq_desc[irq].ctl->enable) irq_desc[irq].ctl->enable(irq);}) +#define mask_and_ack_irq(irq) ({if (irq_desc[irq].ctl && irq_desc[irq].ctl->mask_and_ack) irq_desc[irq].ctl->mask_and_ack(irq);}) + +struct irqdesc { + struct irqaction *action; + struct hw_interrupt_type *ctl; +}; + +extern struct irqdesc irq_desc[NR_IRQS]; + + +#define NR_MASK_WORDS ((NR_IRQS + 31) / 32) + +extern int ppc_spurious_interrupts; +extern int ppc_second_irq; +extern struct irqaction *ppc_irq_action[NR_IRQS]; +extern unsigned int ppc_local_bh_count[NR_CPUS]; +extern unsigned int ppc_local_irq_count[NR_CPUS]; +extern unsigned int ppc_cached_irq_mask[NR_MASK_WORDS]; +extern unsigned int ppc_lost_interrupts[NR_MASK_WORDS]; +extern atomic_t ppc_n_lost_interrupts; + +#endif /* _PPC_KERNEL_LOCAL_IRQ_H */ diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/mbx_pci.c linux/arch/ppc/kernel/mbx_pci.c --- v2.2.7/linux/arch/ppc/kernel/mbx_pci.c Thu Apr 23 20:21:29 1998 +++ linux/arch/ppc/kernel/mbx_pci.c Thu Apr 29 12:39:01 1999 @@ -252,3 +252,20 @@ } return PCIBIOS_DEVICE_NOT_FOUND; } + +__initfunc( +void +mbx_pcibios_fixup(void)) +{ + /* Nothing to do here? */ +} + +__initfunc( +void +mbx_setup_pci_ptrs(void)) +{ + set_config_access_method(mbx); + + ppc_md.pcibios_fixup = mbx_pcibios_fixup; +} + diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/mbx_setup.c linux/arch/ppc/kernel/mbx_setup.c --- v2.2.7/linux/arch/ppc/kernel/mbx_setup.c Fri Jan 8 22:36:02 1999 +++ linux/arch/ppc/kernel/mbx_setup.c Thu Apr 29 12:39:01 1999 @@ -1,5 +1,5 @@ /* - * $Id: mbx_setup.c,v 1.5 1998/12/29 18:55:07 cort Exp $ + * $Id: mbx_setup.c,v 1.9 1999/04/28 11:54:09 davem Exp $ * * linux/arch/ppc/kernel/setup.c * @@ -39,6 +39,22 @@ #include #include #include +#include + +#include "time.h" +#include "local_irq.h" + +static int mbx_set_rtc_time(unsigned long time); +unsigned long mbx_get_rtc_time(void); +void mbx_calibrate_decr(void); + +extern int mackbd_setkeycode(unsigned int scancode, unsigned int keycode); +extern int mackbd_getkeycode(unsigned int scancode); +extern int mackbd_translate(unsigned char scancode, unsigned char *keycode, + char raw_mode); +extern char mackbd_unexpected_up(unsigned char keycode); +extern void mackbd_leds(unsigned char leds); +extern void mackbd_init_hw(void); extern unsigned long loops_per_sec; @@ -55,35 +71,10 @@ extern unsigned long find_available_memory(void); extern void m8xx_cpm_reset(uint); -/* this really does make things cleaner -- Cort */ -void __init powermac_init(void) -{ -} - void __init adbdev_init(void) { } -void __init mbx_ide_init_hwif_ports(ide_ioreg_t *p, ide_ioreg_t base, int *irq) -{ - ide_ioreg_t port = base; - int i = 8; - - while (i--) - *p++ = port++; - *p++ = base + 0x206; - if (irq != NULL) - *irq = 0; -#ifdef ATA_FLASH - base = (unsigned long) ioremap(PCMCIA_MEM_ADDR, 0x200); - for (i = 0; i < 8; ++i) - *p++ = base++; - *p = ++base; /* Does not matter */ - if (irq) - *irq = 13; -#endif -} - __initfunc(void mbx_setup_arch(unsigned long * memory_start_p, unsigned long * memory_end_p)) { @@ -144,4 +135,338 @@ xmon(0); #endif machine_restart(NULL); +} + +/* The decrementer counts at the system (internal) clock frequency divided by + * sixteen, or external oscillator divided by four. Currently, we only + * support the MBX, which is system clock divided by sixteen. + */ +__initfunc(void mbx_calibrate_decr(void)) +{ + bd_t *binfo = (bd_t *)&res; + int freq, fp, divisor; + + if ((((immap_t *)MBX_IMAP_ADDR)->im_clkrst.car_sccr & 0x02000000) == 0) + printk("WARNING: Wrong decrementer source clock.\n"); + + /* The manual says the frequency is in Hz, but it is really + * as MHz. The value 'fp' is the number of decrementer ticks + * per second. + */ + fp = (binfo->bi_intfreq * 1000000) / 16; + freq = fp*60; /* try to make freq/1e6 an integer */ + divisor = 60; + printk("time_init: decrementer frequency = %d/%d\n", freq, divisor); + decrementer_count = freq / HZ / divisor; + count_period_num = divisor; + count_period_den = freq / 1000000; +} + +/* A place holder for time base interrupts, if they are ever enabled. +*/ +void timebase_interrupt(int irq, void * dev, struct pt_regs * regs) +{ + printk("timebase_interrupt()\n"); +} + +/* The RTC on the MPC8xx is an internal register. + * We want to protect this during power down, so we need to unlock, + * modify, and re-lock. + */ +static int +mbx_set_rtc_time(unsigned long time) +{ + ((immap_t *)MBX_IMAP_ADDR)->im_sitk.sitk_rtck = KAPWR_KEY; + ((immap_t *)MBX_IMAP_ADDR)->im_sit.sit_rtc = time; + ((immap_t *)MBX_IMAP_ADDR)->im_sitk.sitk_rtck = ~KAPWR_KEY; + return(0); +} + +initfunc(unsigned long +mbx_get_rtc_time(void) +{ + /* First, unlock all of the registers we are going to modify. + * To protect them from corruption during power down, registers + * that are maintained by keep alive power are "locked". To + * modify these registers we have to write the key value to + * the key location associated with the register. + */ + ((immap_t *)MBX_IMAP_ADDR)->im_sitk.sitk_tbscrk = KAPWR_KEY; + ((immap_t *)MBX_IMAP_ADDR)->im_sitk.sitk_rtcsck = KAPWR_KEY; + + + /* Disable the RTC one second and alarm interrupts. + */ + ((immap_t *)MBX_IMAP_ADDR)->im_sit.sit_rtcsc &= + ~(RTCSC_SIE | RTCSC_ALE); + + /* Enabling the decrementer also enables the timebase interrupts + * (or from the other point of view, to get decrementer interrupts + * we have to enable the timebase). The decrementer interrupt + * is wired into the vector table, nothing to do here for that. + */ + ((immap_t *)MBX_IMAP_ADDR)->im_sit.sit_tbscr = + ((mk_int_int_mask(DEC_INTERRUPT) << 8) | + (TBSCR_TBF | TBSCR_TBE)); + if (request_irq(DEC_INTERRUPT, timebase_interrupt, 0, "tbint", NULL) != 0) + panic("Could not allocate timer IRQ!"); + + /* Get time from the RTC. + */ + return ((immap_t *)MBX_IMAP_ADDR)->im_sit.sit_rtc; +} + +void +mbx_restart(char *cmd) +{ + extern void MBX_gorom(void); + + MBX_gorom(); +} + +void +mbx_power_off(void) +{ + mbx_restart(NULL); +} + +void +mbx_halt(void) +{ + mbx_restart(NULL) +} + + +int mbx_setup_residual(char *buffer) +{ + int len = 0; + bd_t *bp; + extern RESIDUAL *res; + + bp = (bd_t *)res; + + len += sprintf(len+buffer,"clock\t\t: %dMHz\n" + "bus clock\t: %dMHz\n", + bp->bi_intfreq /*/ 1000000*/, + bp->bi_busfreq /*/ 1000000*/); + + return len; +} + +void +mbx_do_IRQ(struct pt_regs *regs, + int cpu, + int isfake) +{ + int irq; + unsigned long bits = 0; + + /* For MPC8xx, read the SIVEC register and shift the bits down + * to get the irq number. */ + bits = ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_sivec; + irq = bits >> 26; + irq += ppc8xx_pic.irq_offset; + bits = 1UL << irq; + + if (irq < 0) { + printk(KERN_DEBUG "Bogus interrupt %d from PC = %lx\n", + irq, regs->nip); + spurious_interrupts++; + } + else { + ppc_irq_dispatch_handler( regs, irq ); + } + +} + +static void mbx_i8259_action(int cpl, void *dev_id, struct pt_regs *regs) +{ + int bits, irq; + + /* A bug in the QSpan chip causes it to give us 0xff always + * when doing a character read. So read 32 bits and shift. + * This doesn't seem to return useful values anyway, but + * read it to make sure things are acked. + * -- Cort + */ + irq = (inl(0x508) >> 24)&0xff; + if ( irq != 0xff ) printk("iack %d\n", irq); + + outb(0x0C, 0x20); + irq = inb(0x20) & 7; + if (irq == 2) + { + outb(0x0C, 0xA0); + irq = inb(0xA0); + irq = (irq&7) + 8; + } + bits = 1UL << irq; + irq += i8259_pic.irq_offset; + ppc_irq_dispatch_handler( regs, irq ); +} + + +/* On MBX8xx, the interrupt control (SIEL) was set by EPPC-bug. External + * interrupts can be either edge or level triggered, but there is no + * reason for us to change the EPPC-bug values (it would not work if we did). + */ +__initfunc(void +mbx_init_IRQ(void)) +{ + int i; + + ppc8xx_pic.irq_offset = 16; + for ( i = 16 ; i < 32 ; i++ ) + irq_desc[i].ctl = &ppc8xx_pic; + unmask_irq(CPM_INTERRUPT); + + for ( i = 0 ; i < 16 ; i++ ) + irq_desc[i].ctl = &i8259_pic; + i8259_init(); + request_irq(ISA_BRIDGE_INT, mbx_i8259_action, 0, "8259 cascade", NULL); + enable_irq(ISA_BRIDGE_INT); +} + +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) +/* + * IDE stuff. + */ +void +mbx_ide_insw(ide_ioreg_t port, void *buf, int ns) +{ + ide_insw(port+_IO_BASE), buf, ns); +} + +void +mbx_ide_outsw(ide_ioreg_t port, void *buf, int ns) +{ + ide_outsw(port+_IO_BASE, buf, ns); +} + +int +mbx_ide_default_irq(ide_ioreg_t base) +{ + return 14; +} + +ide_ioreg_t +mbx_ide_default_io_base(int index) +{ + return index; +} + +int +mbx_ide_check_region(ide_ioreg_t from, unsigned int extent) +{ + return 0 +} + +void +mbx_ide_request_region(ide_ioreg_t from, + unsigned int extent, + const char *name) +{ +} + +void +mbx_ide_release_region(ide_ioreg_t from, + unsigned int extent) +{ +} + +void +mbx_ide_fix_driveid(struct hd_driveid *id) +{ + ppc_generic_ide_fix_driveid(id); +} + +void __init mbx_ide_init_hwif_ports(ide_ioreg_t *p, ide_ioreg_t base, int *irq) +{ + ide_ioreg_t port = base; + int i = 8; + + while (i--) + *p++ = port++; + *p++ = base + 0x206; + if (irq != NULL) + *irq = 0; +#ifdef ATA_FLASH + base = (unsigned long) ioremap(PCMCIA_MEM_ADDR, 0x200); + for (i = 0; i < 8; ++i) + *p++ = base++; + *p = ++base; /* Does not matter */ + if (irq) + *irq = 13; +#endif +} +#endif + +__initfunc(void +mbx_init(unsigned long r3, unsigned long r4, unsigned long r5, + unsigned long r6, unsigned long r7)) +{ + + if ( r3 ) + memcpy( (void *)&res,(void *)(r3+KERNELBASE), sizeof(bd_t) ); + +#ifdef CONFIG_PCI + mbx_setup_pci_ptrs(); +#endif + +#ifdef CONFIG_BLK_DEV_INITRD + /* take care of initrd if we have one */ + if ( r4 ) + { + initrd_start = r4 + KERNELBASE; + initrd_end = r5 + KERNELBASE; + } +#endif /* CONFIG_BLK_DEV_INITRD */ + /* take care of cmd line */ + if ( r6 ) + { + + *(char *)(r7+KERNELBASE) = 0; + strcpy(cmd_line, (char *)(r6+KERNELBASE)); + } + + ppc_md.setup_arch = mbx_setup_arch; + ppc_md.setup_residual = mbx_setup_residual; + ppc_md.get_cpuinfo = NULL; + ppc_md.irq_cannonicalize = NULL; + ppc_md.init_IRQ = mbx_init_IRQ; + ppc_md.do_IRQ = mbx_do_IRQ; + ppc_md.init = NULL; + + ppc_md.restart = mbx_restart; + ppc_md.power_off = mbx_power_off; + ppc_md.halt = mbx_halt; + + ppc_md.time_init = NULL; + ppc_md.set_rtc_time = mbx_set_rtc_time; + ppc_md.get_rtc_time = mbx_get_rtc_time; + ppc_md.calibrate_decr = mbx_calibrate_decr; + + ppc_md.kbd_setkeycode = pckbd_setkeycode; + ppc_md.kbd_getkeycode = pckbd_getkeycode; + ppc_md.kbd_translate = pckbd_translate; + ppc_md.kbd_unexpected_up = pckbd_unexpected_up; + ppc_md.kbd_leds = pckbd_leds; + ppc_md.kbd_init_hw = pckbd_init_hw; +#ifdef CONFIG_MAGIC_SYSRQ + ppc_md.kbd_sysrq_xlate = pckbd_sysrq_xlate; +#endif + +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) + ppc_ide_md.insw = mbx_ide_insw; + ppc_ide_md.outsw = mbx_ide_outsw; + ppc_ide_md.default_irq = mbx_ide_default_irq; + ppc_ide_md.default_io_base = mbx_ide_default_io_base; + ppc_ide_md.check_region = mbx_ide_check_region; + ppc_ide_md.request_region = mbx_ide_request_region; + ppc_ide_md.release_region = mbx_ide_release_region; + ppc_ide_md.fix_driveid = mbx_ide_fix_driveid; + ppc_ide_md.ide_init_hwif = mbx_ide_init_hwif_ports; + + ppc_ide_md.io_base = _IO_BASE; +#endif } diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/misc.S linux/arch/ppc/kernel/misc.S --- v2.2.7/linux/arch/ppc/kernel/misc.S Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/misc.S Thu Apr 29 12:39:01 1999 @@ -36,6 +36,7 @@ * Returns (address we're running at) - (address we were linked at) * for use before the text and data are mapped to KERNELBASE. */ + _GLOBAL(reloc_offset) mflr r0 bl 1f @@ -72,8 +73,8 @@ beqlr /* nothing to do if state == 0 */ _GLOBAL(__sti) _GLOBAL(_hard_sti) - lis r4,n_lost_interrupts@ha - lwz r4,n_lost_interrupts@l(r4) + lis r4,ppc_n_lost_interrupts@ha + lwz r4,ppc_n_lost_interrupts@l(r4) mfmsr r3 /* Get current state */ ori r3,r3,MSR_EE /* Turn on 'EE' bit */ cmpi 0,r4,0 /* lost interrupts to process first? */ @@ -93,8 +94,8 @@ stw r0,20(r1) stw r3,8(r1) 1: bl fake_interrupt - lis r4,n_lost_interrupts@ha - lwz r4,n_lost_interrupts@l(r4) + lis r4,ppc_n_lost_interrupts@ha + lwz r4,ppc_n_lost_interrupts@l(r4) cmpi 0,r4,0 bne- 1b lwz r3,8(r1) @@ -105,6 +106,20 @@ addi r1,r1,16 blr + +/* + * complement mask on the msr then "or" some values on. + * _nmask_and_or_msr(nmask, value_to_or) + */ + _GLOBAL(_nmask_and_or_msr) + mfmsr r0 /* Get current msr */ + andc r0,r0,r3 /* And off the bits set in r3 (first parm) */ + or r0,r0,r4 /* Or on the bits in r4 (second parm) */ + sync /* Some chip revs have problems here... */ + mtmsr r0 /* Update machine state */ + blr /* Done */ + + /* * Flush MMU TLB */ @@ -613,16 +628,6 @@ stfd 0,-4(r5) blr - .globl __clear_msr_me -__clear_msr_me: - mfmsr r0 /* Get current interrupt state */ - lis r3,0 - ori r3,r3,MSR_ME - andc r0,r0,r3 /* Clears bit in (r4) */ - sync /* Some chip revs have problems here */ - mtmsr r0 /* Update machine state */ - blr - _GLOBAL(cvt_df) cvt_df: lfd 0,-4(r5) /* load up fpscr value */ @@ -633,6 +638,16 @@ stfd 0,-4(r5) blr + .globl __clear_msr_me +__clear_msr_me: + mfmsr r0 /* Get current interrupt state */ + lis r3,0 + ori r3,r3,MSR_ME + andc r0,r0,r3 /* Clears bit in (r4) */ + sync /* Some chip revs have problems here */ + mtmsr r0 /* Update machine state */ + blr + /* * Fetch the current SR register * get_SR(int index) @@ -651,6 +666,8 @@ sc cmpi 0,r3,0 /* parent or child? */ bnelr /* return if parent */ + li r0,0 /* clear out p->tss.regs */ + stw r0,TSS+PT_REGS(r2) /* since we don't have user ctx */ mtlr r4 /* fn addr in lr */ mr r3,r5 /* load arg and call fn */ blrl diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/mk_defs.c linux/arch/ppc/kernel/mk_defs.c --- v2.2.7/linux/arch/ppc/kernel/mk_defs.c Wed Sep 9 14:51:06 1998 +++ linux/arch/ppc/kernel/mk_defs.c Thu Apr 29 12:39:01 1999 @@ -29,7 +29,7 @@ int main(void) { - DEFINE(KERNELBASE, KERNELBASE); + /*DEFINE(KERNELBASE, KERNELBASE);*/ DEFINE(STATE, offsetof(struct task_struct, state)); DEFINE(NEXT_TASK, offsetof(struct task_struct, next_task)); DEFINE(COUNTER, offsetof(struct task_struct, counter)); diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/open_pic.c linux/arch/ppc/kernel/open_pic.c --- v2.2.7/linux/arch/ppc/kernel/open_pic.c Wed Dec 31 16:00:00 1969 +++ linux/arch/ppc/kernel/open_pic.c Thu Apr 29 12:39:01 1999 @@ -0,0 +1,48 @@ +#include +#include +#include +#include +#include +#include +#include "open_pic.h" +#include "i8259.h" + +#ifdef __SMP__ +void openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *regs) +{ + smp_message_recv(); +} +#endif /* __SMP__ */ + +void __openfirmware chrp_mask_and_ack_irq(unsigned int irq_nr) +{ + if (is_8259_irq(irq_nr)) + i8259_pic.mask_and_ack(irq_nr); +} + +static void __openfirmware chrp_mask_irq(unsigned int irq_nr) +{ + if (is_8259_irq(irq_nr)) + i8259_pic.disable(irq_nr); + else + openpic_disable_irq(irq_to_openpic(irq_nr)); +} + +static void __openfirmware chrp_unmask_irq(unsigned int irq_nr) +{ + if (is_8259_irq(irq_nr)) + i8259_pic.enable(irq_nr); + else + openpic_enable_irq(irq_to_openpic(irq_nr)); +} + +struct hw_interrupt_type open_pic = { + " OpenPIC ", + NULL, + NULL, + NULL, + chrp_unmask_irq, + chrp_mask_irq, + chrp_mask_and_ack_irq, + 0 +}; diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/open_pic.h linux/arch/ppc/kernel/open_pic.h --- v2.2.7/linux/arch/ppc/kernel/open_pic.h Wed Dec 31 16:00:00 1969 +++ linux/arch/ppc/kernel/open_pic.h Thu Apr 29 12:39:01 1999 @@ -0,0 +1,11 @@ + +#ifndef _PPC_KERNEL_OPEN_PIC_H +#define _PPC_KERNEL_OPEN_PIC_H + +#include "local_irq.h" + +extern struct hw_interrupt_type open_pic; + +void openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *regs); + +#endif /* _PPC_KERNEL_OPEN_PIC_H */ diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/openpic.c linux/arch/ppc/kernel/openpic.c --- v2.2.7/linux/arch/ppc/kernel/openpic.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/openpic.c Thu Apr 29 12:39:01 1999 @@ -190,6 +190,9 @@ case 2: version = "1.2"; break; + case 3: + version = "1.3"; + break; default: version = "?"; break; diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/pci.c linux/arch/ppc/kernel/pci.c --- v2.2.7/linux/arch/ppc/kernel/pci.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/pci.c Thu Apr 29 12:39:01 1999 @@ -1,5 +1,5 @@ /* - * $Id: pci.c,v 1.53 1999/03/12 23:38:02 cort Exp $ + * $Id: pci.c,v 1.54 1999/03/18 04:16:04 cort Exp $ * Common pmac/prep/chrp pci routines. -- Cort */ @@ -21,97 +21,41 @@ #include #include -unsigned long isa_io_base; -unsigned long isa_mem_base; -unsigned long pci_dram_offset; -unsigned int * pci_config_address; -unsigned char * pci_config_data; - -static void fix_intr(struct device_node *node, struct pci_dev *dev); - -/* - * It would be nice if we could create a include/asm/pci.h and have just - * function ptrs for all these in there, but that isn't the case. - * We have a function, pcibios_*() which calls the function ptr ptr_pcibios_*() - * which has been setup by pcibios_init(). This is all to avoid a check - * for pmac/prep every time we call one of these. It should also make the move - * to a include/asm/pcibios.h easier, we can drop the ptr_ on these functions - * and create pci.h - * -- Cort - */ -int (*ptr_pcibios_read_config_byte)(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned char *val); -int (*ptr_pcibios_read_config_word)(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned short *val); -int (*ptr_pcibios_read_config_dword)(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned int *val); -int (*ptr_pcibios_write_config_byte)(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned char val); -int (*ptr_pcibios_write_config_word)(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned short val); -int (*ptr_pcibios_write_config_dword)(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned int val); - -#define decl_config_access_method(name) \ -extern int name##_pcibios_read_config_byte(unsigned char bus, \ - unsigned char dev_fn, unsigned char offset, unsigned char *val); \ -extern int name##_pcibios_read_config_word(unsigned char bus, \ - unsigned char dev_fn, unsigned char offset, unsigned short *val); \ -extern int name##_pcibios_read_config_dword(unsigned char bus, \ - unsigned char dev_fn, unsigned char offset, unsigned int *val); \ -extern int name##_pcibios_write_config_byte(unsigned char bus, \ - unsigned char dev_fn, unsigned char offset, unsigned char val); \ -extern int name##_pcibios_write_config_word(unsigned char bus, \ - unsigned char dev_fn, unsigned char offset, unsigned short val); \ -extern int name##_pcibios_write_config_dword(unsigned char bus, \ - unsigned char dev_fn, unsigned char offset, unsigned int val) - -#define set_config_access_method(name) \ - ptr_pcibios_read_config_byte = name##_pcibios_read_config_byte; \ - ptr_pcibios_read_config_word = name##_pcibios_read_config_word; \ - ptr_pcibios_read_config_dword = name##_pcibios_read_config_dword; \ - ptr_pcibios_write_config_byte = name##_pcibios_write_config_byte; \ - ptr_pcibios_write_config_word = name##_pcibios_write_config_word; \ - ptr_pcibios_write_config_dword = name##_pcibios_write_config_dword - -decl_config_access_method(mech1); -decl_config_access_method(pmac); -decl_config_access_method(grackle); -decl_config_access_method(gg2); -decl_config_access_method(raven); -decl_config_access_method(prep); -decl_config_access_method(mbx); -decl_config_access_method(python); +#include "pci.h" + +unsigned long isa_io_base = 0; +unsigned long isa_mem_base = 0; +unsigned long pci_dram_offset = 0; int pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn, unsigned char offset, unsigned char *val) { - return ptr_pcibios_read_config_byte(bus,dev_fn,offset,val); + return ppc_md.pcibios_read_config_byte(bus,dev_fn,offset,val); } int pcibios_read_config_word(unsigned char bus, unsigned char dev_fn, unsigned char offset, unsigned short *val) { - return ptr_pcibios_read_config_word(bus,dev_fn,offset,val); + return ppc_md.pcibios_read_config_word(bus,dev_fn,offset,val); } int pcibios_read_config_dword(unsigned char bus, unsigned char dev_fn, unsigned char offset, unsigned int *val) { - return ptr_pcibios_read_config_dword(bus,dev_fn,offset,val); + return ppc_md.pcibios_read_config_dword(bus,dev_fn,offset,val); } int pcibios_write_config_byte(unsigned char bus, unsigned char dev_fn, unsigned char offset, unsigned char val) { - return ptr_pcibios_write_config_byte(bus,dev_fn,offset,val); + return ppc_md.pcibios_write_config_byte(bus,dev_fn,offset,val); } int pcibios_write_config_word(unsigned char bus, unsigned char dev_fn, unsigned char offset, unsigned short val) { - return ptr_pcibios_write_config_word(bus,dev_fn,offset,val); + return ppc_md.pcibios_write_config_word(bus,dev_fn,offset,val); } int pcibios_write_config_dword(unsigned char bus, unsigned char dev_fn, unsigned char offset, unsigned int val) { - return ptr_pcibios_write_config_dword(bus,dev_fn,offset,val); + return ppc_md.pcibios_write_config_dword(bus,dev_fn,offset,val); } int pcibios_present(void) @@ -123,175 +67,10 @@ { } -void __init setup_pci_ptrs(void) -{ -#ifndef CONFIG_MBX - PPC_DEVICE *hostbridge; - switch (_machine) { - case _MACH_prep: - printk("PReP architecture\n"); - if ( _prep_type == _PREP_Radstone ) - { - printk("Setting PCI access method to mech1\n"); - set_config_access_method(mech1); - break; - } - - hostbridge=residual_find_device(PROCESSORDEVICE, NULL, - BridgeController, PCIBridge, - -1, 0); - if (hostbridge && - hostbridge->DeviceId.Interface == PCIBridgeIndirect) { - PnP_TAG_PACKET * pkt; - set_config_access_method(raven); - pkt=PnP_find_large_vendor_packet( - res->DevicePnPHeap+hostbridge->AllocatedOffset, - 3, 0); - if(pkt) { -#define p pkt->L4_Pack.L4_Data.L4_PPCPack - pci_config_address= (unsigned *) - ld_le32((unsigned *) p.PPCData); - pci_config_data= (unsigned char *) - ld_le32((unsigned *) (p.PPCData+8)); - } else {/* default values */ - pci_config_address= (unsigned *) 0x80000cf8; - pci_config_data= (unsigned char *) 0x80000cfc; - } - } else { - set_config_access_method(prep); - } - break; - case _MACH_Pmac: - if (find_devices("pci") != 0) { - /* looks like a G3 powermac */ - set_config_access_method(grackle); - } else { - set_config_access_method(pmac); - } - break; - case _MACH_chrp: - if ( !strncmp("MOT", - get_property(find_path_device("/"), "model", NULL),3) ) - { - pci_dram_offset = 0; - isa_mem_base = 0xf7000000; - isa_io_base = 0xfe000000; - set_config_access_method(grackle); - } - else - { - if ( !strncmp("F5", - get_property(find_path_device("/"), - "ibm,model-class", NULL),2) ) - - { - pci_dram_offset = 0x80000000; - isa_mem_base = 0xa0000000; - isa_io_base = 0x88000000; - set_config_access_method(python); - } - else - { - pci_dram_offset = 0; - isa_mem_base = 0xf7000000; - isa_io_base = 0xf8000000; - set_config_access_method(gg2); - } - } - break; - default: - printk("setup_pci_ptrs(): unknown machine type!\n"); - } -#else /* CONFIG_MBX */ - set_config_access_method(mbx); -#endif /* CONFIG_MBX */ -#undef set_config_access_method -} void __init pcibios_fixup(void) { - extern unsigned long route_pci_interrupts(void); - struct pci_dev *dev; - extern struct bridge_data **bridges; - extern unsigned char *Motherboard_map; - extern unsigned char *Motherboard_routes; - unsigned char i; -#ifndef CONFIG_MBX - switch (_machine ) - { - case _MACH_prep: - if ( _prep_type == _PREP_Radstone ) - { - printk("Radstone boards require no PCI fixups\n"); - break; - } - - route_pci_interrupts(); - for(dev=pci_devices; dev; dev=dev->next) - { - /* - * Use our old hard-coded kludge to figure out what - * irq this device uses. This is necessary on things - * without residual data. -- Cort - */ - unsigned char d = PCI_SLOT(dev->devfn); - dev->irq = Motherboard_routes[Motherboard_map[d]]; - for ( i = 0 ; i <= 5 ; i++ ) - { - if ( dev->base_address[i] > 0x10000000 ) - { - printk("Relocating PCI address %lx -> %lx\n", - dev->base_address[i], - (dev->base_address[i] & 0x00FFFFFF) - | 0x01000000); - dev->base_address[i] = - (dev->base_address[i] & 0x00FFFFFF) | 0x01000000; - pci_write_config_dword(dev, - PCI_BASE_ADDRESS_0+(i*0x4), - dev->base_address[i] ); - } - } -#if 0 - /* - * If we have residual data and if it knows about this - * device ask it what the irq is. - * -- Cort - */ - ppcd = residual_find_device_id( ~0L, dev->device, - -1,-1,-1, 0); -#endif - } - break; - case _MACH_chrp: - /* PCI interrupts are controlled by the OpenPIC */ - for(dev=pci_devices; dev; dev=dev->next) - if (dev->irq) - dev->irq = openpic_to_irq(dev->irq); - break; - case _MACH_Pmac: - for(dev=pci_devices; dev; dev=dev->next) - { - /* - * Open Firmware often doesn't initialize the, - * PCI_INTERRUPT_LINE config register properly, so we - * should find the device node and se if it has an - * AAPL,interrupts property. - */ - struct bridge_data *bp = bridges[dev->bus->number]; - unsigned char pin; - - if (pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin) || - !pin) - continue; /* No interrupt generated -> no fixup */ - fix_intr(bp->node->child, dev); - } - break; - } -#else /* CONFIG_MBX */ - for(dev=pci_devices; dev; dev=dev->next) - { - } -#endif /* CONFIG_MBX */ + ppc_md.pcibios_fixup(); } void __init pcibios_fixup_bus(struct pci_bus *bus) @@ -309,7 +88,7 @@ * fix IRQ's for cards located behind P2P bridges. * - Ranjit Deshpande, 01/20/99 */ -static void __init fix_intr(struct device_node *node, struct pci_dev *dev) +void __init fix_intr(struct device_node *node, struct pci_dev *dev) { unsigned int *reg, *class_code; diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/pci.h linux/arch/ppc/kernel/pci.h --- v2.2.7/linux/arch/ppc/kernel/pci.h Wed Dec 31 16:00:00 1969 +++ linux/arch/ppc/kernel/pci.h Thu Apr 29 12:39:01 1999 @@ -0,0 +1,36 @@ + +#ifndef __PPC_KERNEL_PCI_H__ +#define __PPC_KERNEL_PCI_H__ + +extern unsigned long isa_io_base; +extern unsigned long isa_mem_base; +extern unsigned long pci_dram_offset; + +extern unsigned int *pci_config_address; +extern unsigned char *pci_config_data; + +void fix_intr(struct device_node *node, struct pci_dev *dev); + +#define decl_config_access_method(name) \ +extern int name##_pcibios_read_config_byte(unsigned char bus, \ + unsigned char dev_fn, unsigned char offset, unsigned char *val); \ +extern int name##_pcibios_read_config_word(unsigned char bus, \ + unsigned char dev_fn, unsigned char offset, unsigned short *val); \ +extern int name##_pcibios_read_config_dword(unsigned char bus, \ + unsigned char dev_fn, unsigned char offset, unsigned int *val); \ +extern int name##_pcibios_write_config_byte(unsigned char bus, \ + unsigned char dev_fn, unsigned char offset, unsigned char val); \ +extern int name##_pcibios_write_config_word(unsigned char bus, \ + unsigned char dev_fn, unsigned char offset, unsigned short val); \ +extern int name##_pcibios_write_config_dword(unsigned char bus, \ + unsigned char dev_fn, unsigned char offset, unsigned int val) + +#define set_config_access_method(name) \ + ppc_md.pcibios_read_config_byte = name##_pcibios_read_config_byte; \ + ppc_md.pcibios_read_config_word = name##_pcibios_read_config_word; \ + ppc_md.pcibios_read_config_dword = name##_pcibios_read_config_dword; \ + ppc_md.pcibios_write_config_byte = name##_pcibios_write_config_byte; \ + ppc_md.pcibios_write_config_word = name##_pcibios_write_config_word; \ + ppc_md.pcibios_write_config_dword = name##_pcibios_write_config_dword + +#endif /* __PPC_KERNEL_PCI_H__ */ diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/pmac_pci.c linux/arch/ppc/kernel/pmac_pci.c --- v2.2.7/linux/arch/ppc/kernel/pmac_pci.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/pmac_pci.c Thu Apr 29 12:39:01 1999 @@ -21,6 +21,9 @@ #include #include #include +#include + +#include "pci.h" struct bridge_data **bridges, *bridge_list; static int max_bus; @@ -437,5 +440,49 @@ if (strcmp(dev->name, "bandit") == 0) init_bandit(bp); } +} + +__initfunc( +void +pmac_pcibios_fixup(void)) +{ + struct pci_dev *dev; + + /* + * FIXME: This is broken: We should not assign IRQ's to IRQless + * devices (look at PCI_INTERRUPT_PIN) and we also should + * honor the existence of multi-function devices where + * different functions have different interrupt pins. [mj] + */ + for(dev=pci_devices; dev; dev=dev->next) + { + /* + * Open Firmware often doesn't initialize the, + * PCI_INTERRUPT_LINE config register properly, so we + * should find the device node and se if it has an + * AAPL,interrupts property. + */ + struct bridge_data *bp = bridges[dev->bus->number]; + unsigned char pin; + + if (pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin) || + !pin) + continue; /* No interrupt generated -> no fixup */ + fix_intr(bp->node->child, dev); + } +} + +__initfunc( +void +pmac_setup_pci_ptrs(void)) +{ + if (find_devices("pci") != 0) { + /* looks like a G3 powermac */ + set_config_access_method(grackle); + } else { + set_config_access_method(pmac); + } + + ppc_md.pcibios_fixup = pmac_pcibios_fixup; } diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/pmac_pic.c linux/arch/ppc/kernel/pmac_pic.c --- v2.2.7/linux/arch/ppc/kernel/pmac_pic.c Wed Dec 31 16:00:00 1969 +++ linux/arch/ppc/kernel/pmac_pic.c Thu May 6 23:14:36 1999 @@ -0,0 +1,362 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "pmac_pic.h" + +/* pmac */struct pmac_irq_hw { + unsigned int flag; + unsigned int enable; + unsigned int ack; + unsigned int level; +}; + +/* XXX these addresses should be obtained from the device tree */ +static volatile struct pmac_irq_hw *pmac_irq_hw[4] = { + (struct pmac_irq_hw *) 0xf3000020, + (struct pmac_irq_hw *) 0xf3000010, + (struct pmac_irq_hw *) 0xf4000020, + (struct pmac_irq_hw *) 0xf4000010, +}; + +static int max_irqs; +static int max_real_irqs; + +#define MAXCOUNT 10000000 + +#define GATWICK_IRQ_POOL_SIZE 10 +static struct interrupt_info gatwick_int_pool[GATWICK_IRQ_POOL_SIZE]; + +static void __pmac pmac_mask_and_ack_irq(unsigned int irq_nr) +{ + unsigned long bit = 1UL << (irq_nr & 0x1f); + int i = irq_nr >> 5; + + if ((unsigned)irq_nr >= max_irqs) + return; + + clear_bit(irq_nr, ppc_cached_irq_mask); + if (test_and_clear_bit(irq_nr, ppc_lost_interrupts)) + atomic_dec(&ppc_n_lost_interrupts); + out_le32(&pmac_irq_hw[i]->ack, bit); + out_le32(&pmac_irq_hw[i]->enable, ppc_cached_irq_mask[i]); + out_le32(&pmac_irq_hw[i]->ack, bit); + do { + /* make sure ack gets to controller before we enable + interrupts */ + mb(); + } while(in_le32(&pmac_irq_hw[i]->flag) & bit); +} + +static void __pmac pmac_set_irq_mask(unsigned int irq_nr) +{ + unsigned long bit = 1UL << (irq_nr & 0x1f); + int i = irq_nr >> 5; + + if ((unsigned)irq_nr >= max_irqs) + return; + + /* enable unmasked interrupts */ + out_le32(&pmac_irq_hw[i]->enable, ppc_cached_irq_mask[i]); + + do { + /* make sure mask gets to controller before we + return to user */ + mb(); + } while((in_le32(&pmac_irq_hw[i]->enable) & bit) + != (ppc_cached_irq_mask[i] & bit)); + + /* + * Unfortunately, setting the bit in the enable register + * when the device interrupt is already on *doesn't* set + * the bit in the flag register or request another interrupt. + */ + if ((bit & ppc_cached_irq_mask[i]) + && (ld_le32(&pmac_irq_hw[i]->level) & bit) + && !(ld_le32(&pmac_irq_hw[i]->flag) & bit)) { + if (!test_and_set_bit(irq_nr, ppc_lost_interrupts)) + atomic_inc(&ppc_n_lost_interrupts); + } +} + +static void __pmac pmac_mask_irq(unsigned int irq_nr) +{ + clear_bit(irq_nr, ppc_cached_irq_mask); + pmac_set_irq_mask(irq_nr); + mb(); +} + +static void __pmac pmac_unmask_irq(unsigned int irq_nr) +{ + set_bit(irq_nr, ppc_cached_irq_mask); + pmac_set_irq_mask(irq_nr); +} + +struct hw_interrupt_type pmac_pic = { + " PMAC-PIC ", + NULL, + NULL, + NULL, + pmac_unmask_irq, + pmac_mask_irq, + pmac_mask_and_ack_irq, + 0 +}; + +struct hw_interrupt_type gatwick_pic = { + " GATWICK ", + NULL, + NULL, + NULL, + pmac_unmask_irq, + pmac_mask_irq, + pmac_mask_and_ack_irq, + 0 +}; + +static void gatwick_action(int cpl, void *dev_id, struct pt_regs *regs) +{ + int irq, bits; + + for (irq = max_irqs - 1; irq > max_real_irqs; irq -= 32) { + int i = irq >> 5; + bits = ld_le32(&pmac_irq_hw[i]->flag) + | ppc_lost_interrupts[i]; + if (bits == 0) + continue; + irq -= cntlzw(bits); + break; + } + /* The previous version of this code allowed for this case, we + * don't. Put this here to check for it. + * -- Cort + */ + if ( irq_desc[irq].ctl != &gatwick_pic ) + printk("gatwick irq not from gatwick pic\n"); + else + ppc_irq_dispatch_handler( regs, irq ); +} + +void +pmac_do_IRQ(struct pt_regs *regs, + int cpu, + int isfake) +{ + int irq; + unsigned long bits = 0; + +#ifdef __SMP__ + /* IPI's are a hack on the powersurge -- Cort */ + if ( cpu != 0 ) + { + if (!isfake) + { +#ifdef CONFIG_XMON + static int xmon_2nd; + if (xmon_2nd) + xmon(regs); +#endif + smp_message_recv(); + goto out; + } + /* could be here due to a do_fake_interrupt call but we don't + mess with the controller from the second cpu -- Cort */ + goto out; + } + + { + unsigned int loops = MAXCOUNT; + while (test_bit(0, &global_irq_lock)) { + if (smp_processor_id() == global_irq_holder) { + printk("uh oh, interrupt while we hold global irq lock!\n"); +#ifdef CONFIG_XMON + xmon(0); +#endif + break; + } + if (loops-- == 0) { + printk("do_IRQ waiting for irq lock (holder=%d)\n", global_irq_holder); +#ifdef CONFIG_XMON + xmon(0); +#endif + } + } + } +#endif /* __SMP__ */ + + for (irq = max_real_irqs - 1; irq > 0; irq -= 32) { + int i = irq >> 5; + bits = ld_le32(&pmac_irq_hw[i]->flag) + | ppc_lost_interrupts[i]; + if (bits == 0) + continue; + irq -= cntlzw(bits); + break; + } + + if (irq < 0) + { + printk(KERN_DEBUG "Bogus interrupt %d from PC = %lx\n", + irq, regs->nip); + ppc_spurious_interrupts++; + } + else + { + ppc_irq_dispatch_handler( regs, irq ); + } +#ifdef CONFIG_SMP +out: +#endif /* CONFIG_SMP */ +} + +/* This routine will fix some missing interrupt values in the device tree + * on the gatwick mac-io controller used by some PowerBooks + */ +static void __init pmac_fix_gatwick_interrupts(struct device_node *gw, int irq_base) +{ + struct device_node *node; + int count; + + memset(gatwick_int_pool, 0, sizeof(gatwick_int_pool)); + node = gw->child; + count = 0; + while(node) + { + /* Fix SCC */ + if (strcasecmp(node->name, "escc") == 0) + if (node->child) { + if (node->child->n_intrs < 3) { + node->child->intrs = &gatwick_int_pool[count]; + count += 3; + } + node->child->n_intrs = 3; + node->child->intrs[0].line = 15+irq_base; + node->child->intrs[1].line = 4+irq_base; + node->child->intrs[2].line = 5+irq_base; + printk(KERN_INFO "irq: fixed SCC on second controller (%d,%d,%d)\n", + node->child->intrs[0].line, + node->child->intrs[1].line, + node->child->intrs[2].line); + } + /* Fix media-bay & left SWIM */ + if (strcasecmp(node->name, "media-bay") == 0) { + struct device_node* ya_node; + + if (node->n_intrs == 0) + node->intrs = &gatwick_int_pool[count++]; + node->n_intrs = 1; + node->intrs[0].line = 29+irq_base; + printk(KERN_INFO "irq: fixed media-bay on second controller (%d)\n", + node->intrs[0].line); + + ya_node = node->child; + while(ya_node) + { + if (strcasecmp(ya_node->name, "floppy") == 0) { + if (ya_node->n_intrs < 2) { + ya_node->intrs = &gatwick_int_pool[count]; + count += 2; + } + ya_node->n_intrs = 2; + ya_node->intrs[0].line = 19+irq_base; + ya_node->intrs[1].line = 1+irq_base; + printk(KERN_INFO "irq: fixed floppy on second controller (%d,%d)\n", + ya_node->intrs[0].line, ya_node->intrs[1].line); + } + if (strcasecmp(ya_node->name, "ata4") == 0) { + if (ya_node->n_intrs < 2) { + ya_node->intrs = &gatwick_int_pool[count]; + count += 2; + } + ya_node->n_intrs = 2; + ya_node->intrs[0].line = 14+irq_base; + ya_node->intrs[1].line = 3+irq_base; + printk(KERN_INFO "irq: fixed ide on second controller (%d,%d)\n", + ya_node->intrs[0].line, ya_node->intrs[1].line); + } + ya_node = ya_node->sibling; + } + } + node = node->sibling; + } + if (count > 10) { + printk("WARNING !! Gatwick interrupt pool overflow\n"); + printk(" GATWICK_IRQ_POOL_SIZE = %d\n", GATWICK_IRQ_POOL_SIZE); + printk(" requested = %d\n", count); + } +} + +__initfunc(void +pmac_pic_init(void)) +{ + int i; + struct device_node *irqctrler; + unsigned long addr; + int second_irq = -999; + + + /* G3 powermacs have 64 interrupts, G3 Series PowerBook have 128, + others have 32 */ + max_irqs = max_real_irqs = 32; + irqctrler = find_devices("mac-io"); + if (irqctrler) + { + max_real_irqs = 64; + if (irqctrler->next) + max_irqs = 128; + else + max_irqs = 64; + } + for ( i = 0; i < max_real_irqs ; i++ ) + irq_desc[i].ctl = &pmac_pic; + + /* get addresses of first controller */ + if (irqctrler) { + if (irqctrler->n_addrs > 0) { + addr = (unsigned long) + ioremap(irqctrler->addrs[0].address, 0x40); + for (i = 0; i < 2; ++i) + pmac_irq_hw[i] = (volatile struct pmac_irq_hw*) + (addr + (2 - i) * 0x10); + } + + /* get addresses of second controller */ + irqctrler = (irqctrler->next) ? irqctrler->next : NULL; + if (irqctrler && irqctrler->n_addrs > 0) { + addr = (unsigned long) + ioremap(irqctrler->addrs[0].address, 0x40); + for (i = 2; i < 4; ++i) + pmac_irq_hw[i] = (volatile struct pmac_irq_hw*) + (addr + (4 - i) * 0x10); + } + } + + /* disable all interrupts in all controllers */ + for (i = 0; i * 32 < max_irqs; ++i) + out_le32(&pmac_irq_hw[i]->enable, 0); + + /* get interrupt line of secondary interrupt controller */ + if (irqctrler) { + second_irq = irqctrler->intrs[0].line; + printk(KERN_INFO "irq: secondary controller on irq %d\n", + (int)second_irq); + if (device_is_compatible(irqctrler, "gatwick")) + pmac_fix_gatwick_interrupts(irqctrler, max_real_irqs); + for ( i = max_real_irqs ; i < max_irqs ; i++ ) + irq_desc[i].ctl = &gatwick_pic; + request_irq( second_irq, gatwick_action, SA_INTERRUPT, + "gatwick cascade", 0 ); + } + printk("System has %d possible interrupts\n", max_irqs); + if (max_irqs != max_real_irqs) + printk(KERN_DEBUG "%d interrupts on main controller\n", + max_real_irqs); + +#ifdef CONFIG_XMON + request_irq(20, xmon_irq, 0, "NMI - XMON", 0); +#endif /* CONFIG_XMON */ +} diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/pmac_pic.h linux/arch/ppc/kernel/pmac_pic.h --- v2.2.7/linux/arch/ppc/kernel/pmac_pic.h Wed Dec 31 16:00:00 1969 +++ linux/arch/ppc/kernel/pmac_pic.h Thu Apr 29 12:39:01 1999 @@ -0,0 +1,15 @@ +#ifndef _PPC_KERNEL_PMAC_PIC_H +#define _PPC_KERNEL_PMAC_PIC_H + +#include "local_irq.h" + +extern struct hw_interrupt_type pmac_pic; + +void pmac_pic_init(void); +void pmac_do_IRQ(struct pt_regs *regs, + int cpu, + int isfake); + + +#endif /* _PPC_KERNEL_PMAC_PIC_H */ + diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/pmac_setup.c linux/arch/ppc/kernel/pmac_setup.c --- v2.2.7/linux/arch/ppc/kernel/pmac_setup.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/pmac_setup.c Thu Apr 29 12:39:01 1999 @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -52,7 +53,36 @@ #include #include #include +#include +#include + #include "time.h" +#include "local_irq.h" +#include "pmac_pic.h" + +#undef SHOW_GATWICK_IRQS + +unsigned long pmac_get_rtc_time(void); +int pmac_set_rtc_time(unsigned long nowtime); +void pmac_read_rtc_time(void); +void pmac_calibrate_decr(void); +void pmac_setup_pci_ptrs(void); + +extern int mackbd_setkeycode(unsigned int scancode, unsigned int keycode); +extern int mackbd_getkeycode(unsigned int scancode); +extern int mackbd_translate(unsigned char scancode, unsigned char *keycode, + char raw_mode); +extern char mackbd_unexpected_up(unsigned char keycode); +extern void mackbd_leds(unsigned char leds); +extern void mackbd_init_hw(void); +extern unsigned char mackbd_sysrq_xlate[128]; +extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode); +extern int pckbd_getkeycode(unsigned int scancode); +extern int pckbd_translate(unsigned char scancode, unsigned char *keycode, + char raw_mode); +extern char pckbd_unexpected_up(unsigned char keycode); +extern void pckbd_leds(unsigned char leds); +extern void pckbd_init_hw(void); unsigned char drive_info; @@ -291,15 +321,12 @@ int boot_part; kdev_t boot_dev; -void __init powermac_init(void) +__initfunc(void +pmac_init2(void)) { - if ( (_machine != _MACH_chrp) && (_machine != _MACH_Pmac) ) - return; adb_init(); pmac_nvram_init(); - if (_machine == _MACH_Pmac) { - media_bay_init(); - } + media_bay_init(); } #ifdef CONFIG_SCSI @@ -402,5 +429,176 @@ boot_dev = NODEV; printk(" (root)"); } +} + +void +pmac_restart(char *cmd) +{ + struct adb_request req; + + switch (adb_hardware) { + case ADB_VIACUDA: + cuda_request(&req, NULL, 2, CUDA_PACKET, + CUDA_RESET_SYSTEM); + for (;;) + cuda_poll(); + break; + + case ADB_VIAPMU: + pmu_restart(); + break; + default: + } +} + +void +pmac_power_off(void) +{ + struct adb_request req; + + switch (adb_hardware) { + case ADB_VIACUDA: + cuda_request(&req, NULL, 2, CUDA_PACKET, + CUDA_POWERDOWN); + for (;;) + cuda_poll(); + break; + + case ADB_VIAPMU: + pmu_shutdown(); + break; + default: + } +} + +void +pmac_halt(void) +{ + pmac_power_off(); +} + + +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) +/* + * IDE stuff. + */ +void +pmac_ide_insw(ide_ioreg_t port, void *buf, int ns) +{ + ide_insw(port, buf, ns); +} + +void +pmac_ide_outsw(ide_ioreg_t port, void *buf, int ns) +{ + ide_outsw(port, buf, ns); +} + +int +pmac_ide_default_irq(ide_ioreg_t base) +{ + return 0; +} + +ide_ioreg_t +pmac_ide_default_io_base(int index) +{ +#if defined(CONFIG_BLK_DEV_IDE_PMAC) + return pmac_ide_regbase[index]; +#else + return 0; +#endif +} + +int +pmac_ide_check_region(ide_ioreg_t from, unsigned int extent) +{ + return 0; +} + +void +pmac_ide_request_region(ide_ioreg_t from, + unsigned int extent, + const char *name) +{ +} + +void +pmac_ide_release_region(ide_ioreg_t from, + unsigned int extent) +{ +} + +/* Convert the shorts/longs in hd_driveid from little to big endian; + * chars are endian independant, of course, but strings need to be flipped. + * (Despite what it says in drivers/block/ide.h, they come up as little + * endian...) + * + * Changes to linux/hdreg.h may require changes here. */ +void +pmac_ide_fix_driveid(struct hd_driveid *id) +{ + ppc_generic_ide_fix_driveid(id); +} + +/* This is declared in drivers/block/ide-pmac.c */ +void pmac_ide_init_hwif_ports (ide_ioreg_t *p, ide_ioreg_t base, int *irq); +#endif + +__initfunc(void +pmac_init(unsigned long r3, unsigned long r4, unsigned long r5, + unsigned long r6, unsigned long r7)) +{ + pmac_setup_pci_ptrs(); + + /* isa_io_base gets set in pmac_find_bridges */ + isa_mem_base = PMAC_ISA_MEM_BASE; + pci_dram_offset = PMAC_PCI_DRAM_OFFSET; + ISA_DMA_THRESHOLD = ~0L; + DMA_MODE_READ = 1; + DMA_MODE_WRITE = 2; + + ppc_md.setup_arch = pmac_setup_arch; + ppc_md.setup_residual = NULL; + ppc_md.get_cpuinfo = pmac_get_cpuinfo; + ppc_md.irq_cannonicalize = NULL; + ppc_md.init_IRQ = pmac_pic_init; + ppc_md.do_IRQ = pmac_do_IRQ; + ppc_md.init = pmac_init2; + + ppc_md.restart = pmac_restart; + ppc_md.power_off = pmac_power_off; + ppc_md.halt = pmac_halt; + + ppc_md.time_init = NULL; + ppc_md.set_rtc_time = pmac_set_rtc_time; + ppc_md.get_rtc_time = pmac_get_rtc_time; + ppc_md.calibrate_decr = pmac_calibrate_decr; + +#ifdef CONFIG_VT + ppc_md.kbd_setkeycode = mackbd_setkeycode; + ppc_md.kbd_getkeycode = mackbd_getkeycode; + ppc_md.kbd_translate = mackbd_translate; + ppc_md.kbd_unexpected_up = mackbd_unexpected_up; + ppc_md.kbd_leds = mackbd_leds; + ppc_md.kbd_init_hw = mackbd_init_hw; +#ifdef CONFIG_MAGIC_SYSRQ + ppc_md.kbd_sysrq_xlate = mackbd_sysrq_xlate; +#endif +#endif + +#if defined(CONFIG_BLK_DEV_IDE_PMAC) + ppc_ide_md.insw = pmac_ide_insw; + ppc_ide_md.outsw = pmac_ide_outsw; + ppc_ide_md.default_irq = pmac_ide_default_irq; + ppc_ide_md.default_io_base = pmac_ide_default_io_base; + ppc_ide_md.check_region = pmac_ide_check_region; + ppc_ide_md.request_region = pmac_ide_request_region; + ppc_ide_md.release_region = pmac_ide_release_region; + ppc_ide_md.fix_driveid = pmac_ide_fix_driveid; + ppc_ide_md.ide_init_hwif = pmac_ide_init_hwif_ports; + + ppc_ide_md.io_base = 0; +#endif } diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/ppc8xx_pic.c linux/arch/ppc/kernel/ppc8xx_pic.c --- v2.2.7/linux/arch/ppc/kernel/ppc8xx_pic.c Wed Dec 31 16:00:00 1969 +++ linux/arch/ppc/kernel/ppc8xx_pic.c Thu Apr 29 12:39:01 1999 @@ -0,0 +1,49 @@ + +#include +#include +#include +#include +#include +#include +#include +#include "ppc8xx_pic.h" + + +static void mbx_mask_irq(unsigned int irq_nr) +{ + if ( irq_nr == ISA_BRIDGE_INT ) return; + if ( irq_nr >= ppc8xx_pic.irq_offset ) + irq_nr -= ppc8xx_pic.irq_offset; + ppc_cached_irq_mask[0] &= ~(1 << (31-irq_nr)); + ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_simask = ppc_cached_irq_mask[0]; +} + +static void mbx_unmask_irq(unsigned int irq_nr) +{ + if ( irq_nr >= ppc8xx_pic.irq_offset ) + irq_nr -= ppc8xx_pic.irq_offset; + ppc_cached_irq_mask[0] |= (1 << (31-irq_nr)); + ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_simask = ppc_cached_irq_mask[0]; +} + +static void mbx_mask_and_ack(unsigned int irq_nr) +{ + /* this shouldn't be masked, we mask the 8259 if we need to -- Cort */ + if ( irq_nr != ISA_BRIDGE_INT ) + mbx_mask_irq(irq_nr); + if ( irq_nr >= ppc8xx_pic.irq_offset ) + irq_nr -= ppc8xx_pic.irq_offset; + /* clear the pending bits */ + ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_sipend = 1 << (31-irq_nr); +} + +struct hw_interrupt_type ppc8xx_pic = { + " 8xx SIU ", + NULL, + NULL, + NULL, + mbx_unmask_irq, + mbx_mask_irq, + mbx_mask_and_ack, + 0 +}; diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/ppc8xx_pic.h linux/arch/ppc/kernel/ppc8xx_pic.h --- v2.2.7/linux/arch/ppc/kernel/ppc8xx_pic.h Wed Dec 31 16:00:00 1969 +++ linux/arch/ppc/kernel/ppc8xx_pic.h Thu Apr 29 12:39:01 1999 @@ -0,0 +1,9 @@ + +#ifndef _PPC_KERNEL_PPC8xx_H +#define _PPC_KERNEL_PPC8xx_H + +#include "local_irq.h" + +extern struct hw_interrupt_type ppc8xx_pic; + +#endif /* _PPC_KERNEL_PPC8xx_H */ diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/ppc_ksyms.c linux/arch/ppc/kernel/ppc_ksyms.c --- v2.2.7/linux/arch/ppc/kernel/ppc_ksyms.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/ppc_ksyms.c Thu Apr 29 12:39:01 1999 @@ -27,6 +27,8 @@ #include #include #include +#include +#include #define __KERNEL_SYSCALLS__ #include @@ -40,7 +42,7 @@ extern void ProgramCheckException(struct pt_regs *regs); extern void SingleStepException(struct pt_regs *regs); extern int sys_sigreturn(struct pt_regs *regs); -extern atomic_t n_lost_interrupts; +extern atomic_t ppc_n_lost_interrupts; extern void do_lost_interrupts(unsigned long); extern int do_signal(sigset_t *, struct pt_regs *); @@ -59,16 +61,21 @@ EXPORT_SYMBOL(ProgramCheckException); EXPORT_SYMBOL(SingleStepException); EXPORT_SYMBOL(sys_sigreturn); -EXPORT_SYMBOL(n_lost_interrupts); +EXPORT_SYMBOL(ppc_n_lost_interrupts); EXPORT_SYMBOL(do_lost_interrupts); EXPORT_SYMBOL(enable_irq); EXPORT_SYMBOL(disable_irq); -EXPORT_SYMBOL(local_irq_count); -EXPORT_SYMBOL(local_bh_count); +EXPORT_SYMBOL(ppc_local_irq_count); +EXPORT_SYMBOL(ppc_local_bh_count); EXPORT_SYMBOL(isa_io_base); EXPORT_SYMBOL(isa_mem_base); EXPORT_SYMBOL(pci_dram_offset); +EXPORT_SYMBOL(ISA_DMA_THRESHOLD); +EXPORT_SYMBOL(DMA_MODE_READ); +EXPORT_SYMBOL(DMA_MODE_WRITE); +EXPORT_SYMBOL(_prep_type); +EXPORT_SYMBOL(ucSystemType); EXPORT_SYMBOL(atomic_add); EXPORT_SYMBOL(atomic_sub); @@ -157,6 +164,7 @@ EXPORT_SYMBOL(flush_instruction_cache); EXPORT_SYMBOL(_get_PVR); EXPORT_SYMBOL(giveup_fpu); +EXPORT_SYMBOL(enable_kernel_fp); EXPORT_SYMBOL(flush_icache_range); EXPORT_SYMBOL(xchg_u32); #ifdef __SMP__ @@ -173,18 +181,14 @@ EXPORT_SYMBOL(_write_unlock); #endif -#ifndef CONFIG_MACH_SPECIFIC EXPORT_SYMBOL(_machine); -#endif +EXPORT_SYMBOL(ppc_md); EXPORT_SYMBOL(adb_request); -EXPORT_SYMBOL(adb_autopoll); EXPORT_SYMBOL(adb_register); EXPORT_SYMBOL(cuda_request); -EXPORT_SYMBOL(cuda_send_request); EXPORT_SYMBOL(cuda_poll); EXPORT_SYMBOL(pmu_request); -EXPORT_SYMBOL(pmu_send_request); EXPORT_SYMBOL(pmu_poll); #ifdef CONFIG_PMAC_PBOOK EXPORT_SYMBOL(sleep_notifier_list); @@ -196,7 +200,6 @@ EXPORT_SYMBOL(find_path_device); EXPORT_SYMBOL(find_phandle); EXPORT_SYMBOL(get_property); -EXPORT_SYMBOL(device_is_compatible); EXPORT_SYMBOL(pci_io_base); EXPORT_SYMBOL(pci_device_loc); EXPORT_SYMBOL(feature_set); @@ -211,9 +214,8 @@ EXPORT_SYMBOL(nvram_write_byte); #endif /* CONFIG_PMAC */ -#ifdef CONFIG_SOUND_MODULE EXPORT_SYMBOL(abs); -#endif +EXPORT_SYMBOL(device_is_compatible); /* The following are special because they're not called explicitly (the C compiler generates them). Fortunately, diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/prep_nvram.c linux/arch/ppc/kernel/prep_nvram.c --- v2.2.7/linux/arch/ppc/kernel/prep_nvram.c Wed Dec 31 16:00:00 1969 +++ linux/arch/ppc/kernel/prep_nvram.c Thu Apr 29 12:39:01 1999 @@ -0,0 +1,173 @@ +/* + * linux/arch/ppc/kernel/prep_nvram.c + * + * Copyright (C) 1998 Corey Minyard + * + */ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +/* + * Allow for a maximum of 32K of PReP NvRAM data + */ +#define MAX_PREP_NVRAM 0x8000 +static char nvramData[MAX_PREP_NVRAM]; +static NVRAM_MAP *nvram=(NVRAM_MAP *)&nvramData[0]; + +#define PREP_NVRAM_AS0 0x74 +#define PREP_NVRAM_AS1 0x75 +#define PREP_NVRAM_DATA 0x77 + +unsigned char *rs_pcNvRAM; + +unsigned char prep_nvram_read_val(int addr) +{ + outb(addr, PREP_NVRAM_AS0); + outb(addr>>8, PREP_NVRAM_AS1); + return inb(PREP_NVRAM_DATA); +} + +void prep_nvram_write_val(int addr, + unsigned char val) +{ + outb(addr, PREP_NVRAM_AS0); + outb(addr>>8, PREP_NVRAM_AS1); + outb(val, PREP_NVRAM_DATA); +} + +/* + * Most Radstone boards have NvRAM memory mapped at offset 8M in ISA space + */ +unsigned char rs_nvram_read_val(int addr) +{ + return rs_pcNvRAM[addr]; +} + +void rs_nvram_write_val(int addr, + unsigned char val) +{ + rs_pcNvRAM[addr]=val; +} + +__initfunc(void init_prep_nvram(void)) +{ + unsigned char *nvp; + int i; + int nvramSize; + + /* + * I'm making the assumption that 32k will always cover the + * nvramsize. If this isn't the case please let me know and we can + * map the header, then get the size from the header, then map + * the whole size. -- Cort + */ + if ( _prep_type == _PREP_Radstone ) + rs_pcNvRAM = (unsigned char *)ioremap(_ISA_MEM_BASE+0x00800000, + 32<<10); + request_region(PREP_NVRAM_AS0, 0x8, "PReP NVRAM"); + /* + * The following could fail if the NvRAM were corrupt but + * we expect the boot firmware to have checked its checksum + * before boot + */ + nvp = (char *) &nvram->Header; + for (i=0; iHeader.GEAddress+nvram->Header.GELength; + if(nvramSize>MAX_PREP_NVRAM) + { + /* + * NvRAM is too large + */ + nvram->Header.GELength=0; + return; + } + + /* + * Read the remainder of the PReP NvRAM + */ + nvp = (char *) &nvram->GEArea[0]; + for (i=sizeof(HEADER); iGEArea)) < nvram->Header.GELength) + && (*cp == '\0')) + { + cp++; + } + + if ((cp - ((char *) nvram->GEArea)) < nvram->Header.GELength) { + return cp; + } else { + return NULL; + } +} + + + diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/prep_pci.c linux/arch/ppc/kernel/prep_pci.c --- v2.2.7/linux/arch/ppc/kernel/prep_pci.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/prep_pci.c Thu Apr 29 12:39:01 1999 @@ -1,5 +1,5 @@ /* - * $Id: prep_pci.c,v 1.25 1999/03/03 15:09:45 cort Exp $ + * $Id: prep_pci.c,v 1.31 1999/04/21 18:21:37 cort Exp $ * PReP pci functions. * Originally by Gary Thomas * rewritten and updated by Cort Dougan (cort@cs.nmt.edu) @@ -11,11 +11,19 @@ #include #include #include +#include #include #include #include +#include +#include +#include #include +#include +#include + +#include "pci.h" #define MAX_DEVNR 22 @@ -169,6 +177,46 @@ 15 /* Line 4 */ }; +/* Motorola Genesis2 MVME26XX, MVME 36XX */ +/* The final version for these boards should use the Raven PPC/PCI bridge +interrupt controller which is much sophisticated and allows more +devices on the PCI bus. */ +static char Genesis2_pci_IRQ_map[23] __prepdata = + { + 0, /* Slot 0 - ECC memory controller/PCI bridge */ + 0, /* Slot 1 - unused */ + 0, /* Slot 2 - unused */ + 0, /* Slot 3 - unused */ + 0, /* Slot 4 - unused */ + 0, /* Slot 5 - unused */ + 0, /* Slot 6 - unused */ + 0, /* Slot 7 - unused */ + 0, /* Slot 8 - unused */ + 0, /* Slot 9 - unused */ + 0, /* Slot 10 - unused */ + 0, /* Slot 11 - ISA bridge */ + 3, /* Slot 12 - SCSI */ + 2, /* Slot 13 - Universe PCI/VME bridge (and 22..24) */ + 1, /* Slot 14 - Ethernet */ + 0, /* Slot 15 - Unused (graphics on 3600, would be 20 ?) */ + 4, /* Slot 16 - PMC slot, assume uses INTA */ + 0, /* Slot 17 */ + 0, /* Slot 18 */ + 0, /* Slot 19 */ + 0, /* Slot 20 */ + 0, /* Slot 21 */ + 0, /* Slot 22 */ + }; + +static char Genesis2_pci_IRQ_routes[] __prepdata= + { + 0, /* Line 0 - Unused */ + 10, /* Line 1 - INTA */ + 11, /* Line 2 - INTB */ + 14, /* Line 3 - INTC */ + 15 /* Line 4 - INTD */ + }; + /* Motorola Series-E */ static char Comet_pci_IRQ_map[16] __prepdata = { @@ -328,106 +376,24 @@ #define ELCRM_INT7_LVL 0x80 #define ELCRM_INT5_LVL 0x20 -/* - * Mechanism 1 configuration space access as defined in the PCI spec. - */ -#define CFG_ADDR (volatile u_int *)0x80000cf8 -#define CFG_DATA 0x80000cfc - -#define CFG_DEV_ADDR(b, d, o) (0x80000000 | \ - ((b) << 16) | \ - ((d) << 8) | \ - ((o) & ~3)) - -unsigned char max_bus=255; - -int mech1_pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned char *val) -{ - *val = 0xff; - if (bus > max_bus) - return PCIBIOS_DEVICE_NOT_FOUND; - out_le32(CFG_ADDR, CFG_DEV_ADDR(bus, dev_fn, offset)); - *val = in_8((unsigned char *)CFG_DATA + (offset & 3)); - return PCIBIOS_SUCCESSFUL; -} - -int mech1_pcibios_read_config_word(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned short *val) -{ - *val = 0xffff; - if (bus > max_bus) - return PCIBIOS_DEVICE_NOT_FOUND; - if ((offset & 1) != 0) - return PCIBIOS_BAD_REGISTER_NUMBER; - out_le32(CFG_ADDR, CFG_DEV_ADDR(bus, dev_fn, offset)); - *val = in_le16((volatile unsigned short *)(CFG_DATA + (offset&3))); - return PCIBIOS_SUCCESSFUL; -} - -int mech1_pcibios_read_config_dword(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned int *val) -{ - *val = 0xffffffff; - if (bus > max_bus) - return PCIBIOS_DEVICE_NOT_FOUND; - if ((offset & 3) != 0) - return PCIBIOS_BAD_REGISTER_NUMBER; - out_le32(CFG_ADDR, CFG_DEV_ADDR(bus, dev_fn, offset)); - *val = in_le32((volatile unsigned int *)CFG_DATA); - return PCIBIOS_SUCCESSFUL; -} - -int mech1_pcibios_write_config_byte(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned char val) -{ - if (bus > max_bus) - return PCIBIOS_DEVICE_NOT_FOUND; - out_le32(CFG_ADDR, CFG_DEV_ADDR(bus, dev_fn, offset)); - out_8((unsigned char *)CFG_DATA + (offset & 3), val); - return PCIBIOS_SUCCESSFUL; -} - -int mech1_pcibios_write_config_word(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned short val) -{ - if (bus > max_bus) - return PCIBIOS_DEVICE_NOT_FOUND; - if ((offset & 1) != 0) - return PCIBIOS_BAD_REGISTER_NUMBER; - out_le32(CFG_ADDR, CFG_DEV_ADDR(bus, dev_fn, offset)); - out_le16((volatile unsigned short *)(CFG_DATA + (offset&3)), val); - return PCIBIOS_SUCCESSFUL; -} - -int mech1_pcibios_write_config_dword(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned int val) -{ - if (bus > max_bus) - return PCIBIOS_DEVICE_NOT_FOUND; - if ((offset & 1) != 0) - return PCIBIOS_BAD_REGISTER_NUMBER; - out_le32(CFG_ADDR, CFG_DEV_ADDR(bus, dev_fn, offset)); - out_le32((volatile unsigned int *)CFG_DATA, val); - return PCIBIOS_SUCCESSFUL; -} +#define CFGPTR(dev) (0x80800000 | (1<<(dev>>3)) | ((dev&7)<<8) | offset) +#define DEVNO(dev) (dev>>3) __prep int prep_pcibios_read_config_dword (unsigned char bus, unsigned char dev, unsigned char offset, unsigned int *val) { - unsigned long _val; + unsigned long _val; unsigned long *ptr; - dev >>= 3; - - if ((bus != 0) || (dev > MAX_DEVNR)) - { + + if ((bus != 0) || (DEVNO(dev) > MAX_DEVNR)) + { *val = 0xFFFFFFFF; - return PCIBIOS_DEVICE_NOT_FOUND; - } else + return PCIBIOS_DEVICE_NOT_FOUND; + } else { - ptr = (unsigned long *)(0x80800000 | (1<>= 3; - if ((bus != 0) || (dev > MAX_DEVNR)) - { - *val = (unsigned short)0xFFFFFFFF; - return PCIBIOS_DEVICE_NOT_FOUND; - } else + + if ((bus != 0) || (DEVNO(dev) > MAX_DEVNR)) + { + *val = 0xFFFF; + return PCIBIOS_DEVICE_NOT_FOUND; + } else { - ptr = (unsigned short *)(0x80800000 | (1<>= 3; - if ((bus != 0) || (dev > MAX_DEVNR)) - { - *(unsigned long *)val = (unsigned long) 0xFFFFFFFF; - return PCIBIOS_DEVICE_NOT_FOUND; - } else + unsigned char _val; + unsigned char *ptr; + + if ((bus != 0) || (DEVNO(dev) > MAX_DEVNR)) + { + *val = 0xFF; + return PCIBIOS_DEVICE_NOT_FOUND; + } else { - ptr = (unsigned char *)(0x80800000 | (1<>= 3; + _val = le32_to_cpu(val); - if ((bus != 0) || (dev > MAX_DEVNR)) + if ((bus != 0) || (DEVNO(dev) > MAX_DEVNR)) { return PCIBIOS_DEVICE_NOT_FOUND; } else { - ptr = (unsigned long *)(0x80800000 | (1<>= 3; + _val = le16_to_cpu(val); - if ((bus != 0) || (dev > MAX_DEVNR)) + if ((bus != 0) || (DEVNO(dev) > MAX_DEVNR)) { return PCIBIOS_DEVICE_NOT_FOUND; } else { - ptr = (unsigned short *)(0x80800000 | (1<>= 3; + _val = val; - if ((bus != 0) || (dev > MAX_DEVNR)) + if ((bus != 0) || (DEVNO(dev) > MAX_DEVNR)) { return PCIBIOS_DEVICE_NOT_FOUND; } else { - ptr = (unsigned char *)(0x80800000 | (1<L4_Pack.L4_Data.L4_PPCPack.PPCData + u_int bus = data[16]; + u_char *End, *p; + + End = data + ld_le16((u_short *)(&pkt->L4_Pack.Count0)) - 1; + printk("Interrupt mapping from %d to %d\n", 20, End-data); + for (p=data+20; pnext) { + unsigned code, irq; + u_char pin; + + if ( dev->bus->number != bus || + PCI_SLOT(dev->devfn) != PCI_SLOT(p[1])) + continue; + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); + if(!pin) continue; + code=ld_le16((unsigned short *) + (p+4+2*(pin-1))); + /* Set vector to 0 for unrouted PCI ints. This code + * is ugly but handles correctly the special case of + * interrupt 0 (8259 cascade) on OpenPIC + */ + + irq = (code == 0xffff) ? 0 : code&0x7fff; + if (p[2] == 2) { /* OpenPIC */ + if (irq) { + openpic_set_sense(irq, code<0x8000); + irq=openpic_to_irq(irq); + } else continue; + } else if (p[2] != 1){ /* Not 8259 */ + printk("Unknown or unsupported " + "interrupt controller" + "type %d.\n", p[2]); + continue; + } + dev->irq=irq; + } + + } +} + +__initfunc( +static inline void fixup_bases(struct pci_dev *dev)) { + int k; + for (k=0; k<6; k++) { + /* FIXME: get the base address physical offset from + the Raven instead of hard coding it. + -- Troy */ + if (dev->base_address[k] && + (dev->base_address[k]&PCI_BASE_ADDRESS_SPACE) + == PCI_BASE_ADDRESS_SPACE_MEMORY) + dev->base_address[k]+=0xC0000000; + if ((dev->base_address[k] & + (PCI_BASE_ADDRESS_SPACE | + PCI_BASE_ADDRESS_MEM_TYPE_MASK)) + == (PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_TYPE_64)) + k++; + } +} + + +__initfunc( +void +prep_pcibios_fixup(void)) +{ + struct pci_dev *dev; + extern unsigned char *Motherboard_map; + extern unsigned char *Motherboard_routes; + unsigned char i; + + if ( _prep_type == _PREP_Radstone ) + { + printk("Radstone boards require no PCI fixups\n"); + } + else + { + prep_route_pci_interrupts(); + for(dev=pci_devices; dev; dev=dev->next) + { + /* + * Use our old hard-coded kludge to figure out what + * irq this device uses. This is necessary on things + * without residual data. -- Cort + */ + unsigned char d = PCI_SLOT(dev->devfn); + dev->irq = Motherboard_routes[Motherboard_map[d]]; + for ( i = 0 ; i <= 5 ; i++ ) + { + if ( dev->base_address[i] > 0x10000000 ) + { + printk("Relocating PCI address %lx -> %lx\n", + dev->base_address[i], + (dev->base_address[i] & 0x00FFFFFF) + | 0x01000000); + dev->base_address[i] = + (dev->base_address[i] & 0x00FFFFFF) | 0x01000000; + pci_write_config_dword(dev, + PCI_BASE_ADDRESS_0+(i*0x4), + dev->base_address[i] ); + } + } +#if 0 + /* + * If we have residual data and if it knows about this + * device ask it what the irq is. + * -- Cort + */ + ppcd = residual_find_device_id( ~0L, dev->device, + -1,-1,-1, 0); +#endif + } + } +} + +decl_config_access_method(indirect); + +__initfunc( +void +prep_setup_pci_ptrs(void)) +{ + PPC_DEVICE *hostbridge; + + printk("PReP architecture\n"); + if ( _prep_type == _PREP_Radstone ) + { + pci_config_address = (unsigned *)0x80000cf8; + pci_config_data = (char *)0x80000cfc; + set_config_access_method(indirect); + } + else + { + hostbridge = residual_find_device(PROCESSORDEVICE, NULL, + BridgeController, PCIBridge, -1, 0); + if (hostbridge && + hostbridge->DeviceId.Interface == PCIBridgeIndirect) { + PnP_TAG_PACKET * pkt; + set_config_access_method(indirect); + pkt = PnP_find_large_vendor_packet( + res->DevicePnPHeap+hostbridge->AllocatedOffset, + 3, 0); + if(pkt) + { +#define p pkt->L4_Pack.L4_Data.L4_PPCPack + pci_config_address= (unsigned *)ld_le32((unsigned *) p.PPCData); + pci_config_data= (unsigned char *)ld_le32((unsigned *) (p.PPCData+8)); + } + else + { + pci_config_address= (unsigned *) 0x80000cf8; + pci_config_data= (unsigned char *) 0x80000cfc; + } + } + else + { + set_config_access_method(prep); + } + + } + + ppc_md.pcibios_fixup = prep_pcibios_fixup; } diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/prep_setup.c linux/arch/ppc/kernel/prep_setup.c --- v2.2.7/linux/arch/ppc/kernel/prep_setup.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/prep_setup.c Thu Apr 29 12:39:01 1999 @@ -30,6 +30,9 @@ #include #include #include +#include +#include +#include #include #include @@ -38,12 +41,63 @@ #include #include #include +#include +#include +#include +#include + +#include "time.h" +#include "local_irq.h" +#include "i8259.h" +#include "open_pic.h" #if defined(CONFIG_SOUND) || defined(CONFIG_SOUND_MODULE) #include <../drivers/sound/sound_config.h> #include <../drivers/sound/dev_table.h> #endif +unsigned char ucSystemType; +unsigned char ucBoardRev; +unsigned char ucBoardRevMaj, ucBoardRevMin; + +extern unsigned long mc146818_get_rtc_time(void); +extern int mc146818_set_rtc_time(unsigned long nowtime); +extern unsigned long mk48t59_get_rtc_time(void); +extern int mk48t59_set_rtc_time(unsigned long nowtime); + +extern unsigned char prep_nvram_read_val(int addr); +extern void prep_nvram_write_val(int addr, + unsigned char val); +extern unsigned char rs_nvram_read_val(int addr); +extern void rs_nvram_write_val(int addr, + unsigned char val); + +extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode); +extern int pckbd_getkeycode(unsigned int scancode); +extern int pckbd_translate(unsigned char scancode, unsigned char *keycode, + char raw_mode); +extern char pckbd_unexpected_up(unsigned char keycode); +extern void pckbd_leds(unsigned char leds); +extern void pckbd_init_hw(void); +extern unsigned char pckbd_sysrq_xlate[128]; + +extern void prep_setup_pci_ptrs(void); + +/* these need to be here since PReP uses them for OpenPIC support */ +/* Maybe move these to a 'openpic_irq.c' file instead? --Troy */ +extern void chrp_mask_and_ack_irq(unsigned int irq_nr); +extern void chrp_mask_irq(unsigned int irq_nr); +extern void chrp_unmask_irq(unsigned int irq_nr); +extern void chrp_do_IRQ(struct pt_regs *regs, int cpu, int isfake); +extern volatile unsigned char *chrp_int_ack_special; + +extern char saved_command_line[256]; + +int _prep_type; + +#define cached_21 (((char *)(ppc_cached_irq_mask))[3]) +#define cached_A1 (((char *)(ppc_cached_irq_mask))[2]) + /* for the mac fs */ kdev_t boot_dev; /* used in nasty hack for sound - see prep_setup_arch() -- Cort */ @@ -60,6 +114,9 @@ extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */ extern int rd_image_start; /* starting block # of image */ #endif +#ifdef CONFIG_VGA_CONSOLE +unsigned long vgacon_remap_base; +#endif __prep int @@ -177,6 +234,13 @@ outb(reg, SIO_CONFIG_RD); outb(reg, SIO_CONFIG_RD); /* Have to write twice to change! */ + /* + * We need to set up the NvRAM access routines early as prep_init + * has yet to be called + */ + ppc_md.nvram_read_val = prep_nvram_read_val; + ppc_md.nvram_write_val = prep_nvram_write_val; + /* we should determine this according to what we find! -- Cort */ switch ( _prep_type ) { @@ -210,9 +274,38 @@ ucBoardRev=inb(0x854); ucBoardRevMaj=ucBoardRev>>5; ucBoardRevMin=ucBoardRev&0x1f; + + /* + * Most Radstone boards have memory mapped NvRAM + */ + if((ucSystemType==RS_SYS_TYPE_PPC1) && (ucBoardRevMaj<5)) + { + ppc_md.nvram_read_val = prep_nvram_read_val; + ppc_md.nvram_write_val = prep_nvram_write_val; + } + else + { + ppc_md.nvram_read_val = rs_nvram_read_val; + ppc_md.nvram_write_val = rs_nvram_write_val; + } break; } + /* Read in NVRAM data */ + init_prep_nvram(); + + /* if no bootargs, look in NVRAM */ + if ( cmd_line[0] == '\0' ) { + char *bootargs; + bootargs = prep_nvram_get_var("bootargs"); + if (bootargs != NULL) { + strcpy(cmd_line, bootargs); + + /* again.. */ + strcpy(saved_command_line, cmd_line); + } + } + printk("Boot arguments: %s\n", cmd_line); #ifdef CONFIG_SOUND_CS4232 @@ -263,11 +356,362 @@ request_region(0xc0,0x20,"dma2"); #ifdef CONFIG_VGA_CONSOLE + /* remap the VGA memory */ + vgacon_remap_base = 0xf0000000; + /*vgacon_remap_base = ioremap(0xc0000000, 0xba000);*/ conswitchp = &vga_con; #endif } -__initfunc(void prep_ide_init_hwif_ports (ide_ioreg_t *p, ide_ioreg_t base, int *irq)) +/* + * Determine the decrementer frequency from the residual data + * This allows for a faster boot as we do not need to calibrate the + * decrementer against another clock. This is important for embedded systems. + */ +__initfunc(void prep_res_calibrate_decr(void)) +{ + int freq, divisor; + + freq = res->VitalProductData.ProcessorBusHz; + divisor = 4; + printk("time_init: decrementer frequency = %d/%d\n", freq, divisor); + decrementer_count = freq / HZ / divisor; + count_period_num = divisor; + count_period_den = freq / 1000000; +} + +/* + * Uses the on-board timer to calibrate the on-chip decrementer register + * for prep systems. On the pmac the OF tells us what the frequency is + * but on prep we have to figure it out. + * -- Cort + */ +int calibrate_done = 0; +volatile int *done_ptr = &calibrate_done; + +__initfunc(void +prep_calibrate_decr_handler(int irq, + void *dev, + struct pt_regs *regs)) +{ + unsigned long freq, divisor; + static unsigned long t1 = 0, t2 = 0; + + if ( !t1 ) + t1 = get_dec(); + else if (!t2) + { + t2 = get_dec(); + t2 = t1-t2; /* decr's in 1/HZ */ + t2 = t2*HZ; /* # decrs in 1s - thus in Hz */ + freq = t2 * 60; /* try to make freq/1e6 an integer */ + divisor = 60; + printk("time_init: decrementer frequency = %lu/%lu (%luMHz)\n", + freq, divisor,t2>>20); + decrementer_count = freq / HZ / divisor; + count_period_num = divisor; + count_period_den = freq / 1000000; + *done_ptr = 1; + } +} + +__initfunc(void prep_calibrate_decr(void)) +{ + unsigned long flags; + + + save_flags(flags); + +#define TIMER0_COUNT 0x40 +#define TIMER_CONTROL 0x43 + /* set timer to periodic mode */ + outb_p(0x34,TIMER_CONTROL);/* binary, mode 2, LSB/MSB, ch 0 */ + /* set the clock to ~100 Hz */ + outb_p(LATCH & 0xff , TIMER0_COUNT); /* LSB */ + outb(LATCH >> 8 , TIMER0_COUNT); /* MSB */ + + if (request_irq(0, prep_calibrate_decr_handler, 0, "timer", NULL) != 0) + panic("Could not allocate timer IRQ!"); + __sti(); + while ( ! *done_ptr ) /* nothing */; /* wait for calibrate */ + restore_flags(flags); + free_irq( 0, NULL); +} + + +/* We use the NVRAM RTC to time a second to calibrate the decrementer. */ +__initfunc(void mk48t59_calibrate_decr(void)) +{ + unsigned long freq, divisor; + unsigned long t1, t2; + unsigned char save_control; + long i; + unsigned char sec; + + + /* Make sure the time is not stopped. */ + save_control = ppc_md.nvram_read_val(MK48T59_RTC_CONTROLB); + + ppc_md.nvram_write_val(MK48T59_RTC_CONTROLA, + (save_control & (~MK48T59_RTC_CB_STOP))); + + /* Now make sure the read bit is off so the value will change. */ + save_control = ppc_md.nvram_read_val(MK48T59_RTC_CONTROLA); + save_control &= ~MK48T59_RTC_CA_READ; + ppc_md.nvram_write_val(MK48T59_RTC_CONTROLA, save_control); + + + /* Read the seconds value to see when it changes. */ + sec = ppc_md.nvram_read_val(MK48T59_RTC_SECONDS); + for (i = 0 ; i < 1000000 ; i++) { /* may take up to 1 second... */ + if (ppc_md.nvram_read_val(MK48T59_RTC_SECONDS) != sec) { + break; + } + } + t1 = get_dec(); + + sec = ppc_md.nvram_read_val(MK48T59_RTC_SECONDS); + for (i = 0 ; i < 1000000 ; i++) { /* Should take up 1 second... */ + if (ppc_md.nvram_read_val(MK48T59_RTC_SECONDS) != sec) { + break; + } + } + + t2 = t1 - get_dec(); + + freq = t2 * 60; /* try to make freq/1e6 an integer */ + divisor = 60; + printk("time_init: decrementer frequency = %lu/%lu (%luMHz)\n", + freq, divisor,t2>>20); + decrementer_count = freq / HZ / divisor; + count_period_num = divisor; + count_period_den = freq / 1000000; +} + +void +prep_restart(char *cmd) +{ + unsigned long i = 10000; + + + _disable_interrupts(); + + /* set exception prefix high - to the prom */ + _nmask_and_or_msr(0, MSR_IP); + + /* make sure bit 0 (reset) is a 0 */ + outb( inb(0x92) & ~1L , 0x92 ); + /* signal a reset to system control port A - soft reset */ + outb( inb(0x92) | 1 , 0x92 ); + + while ( i != 0 ) i++; + panic("restart failed\n"); +} + +/* + * This function will restart a board regardless of port 92 functionality + */ +void +prep_direct_restart(char *cmd) +{ + u32 jumpaddr=0xfff00100; + u32 defaultmsr=MSR_IP; + + /* + * This will ALWAYS work regardless of port 92 + * functionality + */ + _disable_interrupts(); + + __asm__ __volatile__("\n\ + mtspr 26, %1 /* SRR0 */ + mtspr 27, %0 /* SRR1 */ + rfi" + : + : "r" (defaultmsr), "r" (jumpaddr)); + /* + * Not reached + */ +} + +void +prep_halt(void) +{ + unsigned long flags; + _disable_interrupts(); + /* set exception prefix high - to the prom */ + save_flags( flags ); + restore_flags( flags|MSR_IP ); + + /* make sure bit 0 (reset) is a 0 */ + outb( inb(0x92) & ~1L , 0x92 ); + /* signal a reset to system control port A - soft reset */ + outb( inb(0x92) | 1 , 0x92 ); + + while ( 1 ) ; + /* + * Not reached + */ +} + +void +prep_power_off(void) +{ + prep_halt(); +} + +int prep_setup_residual(char *buffer) +{ + int len = 0; + + + /* PREP's without residual data will give incorrect values here */ + len += sprintf(len+buffer, "clock\t\t: "); + if ( res->ResidualLength ) + len += sprintf(len+buffer, "%ldMHz\n", + (res->VitalProductData.ProcessorHz > 1024) ? + res->VitalProductData.ProcessorHz>>20 : + res->VitalProductData.ProcessorHz); + else + len += sprintf(len+buffer, "???\n"); + + return len; +} + +u_int +prep_irq_cannonicalize(u_int irq) +{ + if (irq == 2) + { + return 9; + } + else + { + return irq; + } +} + +void +prep_do_IRQ(struct pt_regs *regs, int cpu, int isfake) +{ + int irq; + + /* + * Perform an interrupt acknowledge cycle on controller 1 + */ + outb(0x0C, 0x20); + irq = inb(0x20) & 7; + if (irq == 2) + { + /* + * Interrupt is cascaded so perform interrupt + * acknowledge on controller 2 + */ + outb(0x0C, 0xA0); + irq = (inb(0xA0) & 7) + 8; + } + else if (irq==7) + { + /* + * This may be a spurious interrupt + * + * Read the interrupt status register. If the most + * significant bit is not set then there is no valid + * interrupt + */ + outb(0x0b, 0x20); + + if(~inb(0x20)&0x80) + { + printk(KERN_DEBUG "Bogus interrupt from PC = %lx\n", + regs->nip); + ppc_spurious_interrupts++; + return; + } + } + ppc_irq_dispatch_handler( regs, irq ); +} + +__initfunc(void +prep_init_IRQ(void)) +{ + int i; + + for ( i = 0 ; i < 16 ; i++ ) + irq_desc[i].ctl = &i8259_pic; + i8259_init(); +} + +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) +/* + * IDE stuff. + */ +void +prep_ide_insw(ide_ioreg_t port, void *buf, int ns) +{ + _insw((unsigned short *)((port)+_IO_BASE), buf, ns); +} + +void +prep_ide_outsw(ide_ioreg_t port, void *buf, int ns) +{ + _outsw((unsigned short *)((port)+_IO_BASE), buf, ns); +} + +int +prep_ide_default_irq(ide_ioreg_t base) +{ + switch (base) { + case 0x1f0: return 13; + case 0x170: return 13; + case 0x1e8: return 11; + case 0x168: return 10; + default: + return 0; + } +} + +ide_ioreg_t +prep_ide_default_io_base(int index) +{ + switch (index) { + case 0: return 0x1f0; + case 1: return 0x170; + case 2: return 0x1e8; + case 3: return 0x168; + default: + return 0; + } +} + +int +prep_ide_check_region(ide_ioreg_t from, unsigned int extent) +{ + return check_region(from, extent); +} + +void +prep_ide_request_region(ide_ioreg_t from, + unsigned int extent, + const char *name) +{ + request_region(from, extent, name); +} + +void +prep_ide_release_region(ide_ioreg_t from, + unsigned int extent) +{ + release_region(from, extent); +} + +void +prep_ide_fix_driveid(struct hd_driveid *id) +{ +} + +__initfunc(void +prep_ide_init_hwif_ports (ide_ioreg_t *p, ide_ioreg_t base, int *irq)) { ide_ioreg_t port = base; int i = 8; @@ -277,6 +721,158 @@ *p++ = base + 0x206; if (irq != NULL) *irq = 0; +} +#endif + +__initfunc(void +prep_init(unsigned long r3, unsigned long r4, unsigned long r5, + unsigned long r6, unsigned long r7)) +{ + int tmp; + + /* make a copy of residual data */ + if ( r3 ) + { + memcpy((void *)res,(void *)(r3+KERNELBASE), + sizeof(RESIDUAL)); + } + + isa_io_base = PREP_ISA_IO_BASE; + isa_mem_base = PREP_ISA_MEM_BASE; + pci_dram_offset = PREP_PCI_DRAM_OFFSET; + ISA_DMA_THRESHOLD = 0x00ffffff; + DMA_MODE_READ = 0x44; + DMA_MODE_WRITE = 0x48; + + /* figure out what kind of prep workstation we are */ + if ( res->ResidualLength != 0 ) + { + if ( !strncmp(res->VitalProductData.PrintableModel,"IBM",3) ) + _prep_type = _PREP_IBM; + else if (!strncmp(res->VitalProductData.PrintableModel, + "Radstone",8)) + { + extern char *Motherboard_map_name; + + _prep_type = _PREP_Radstone; + Motherboard_map_name= + res->VitalProductData.PrintableModel; + } + else + _prep_type = _PREP_Motorola; + } + else /* assume motorola if no residual (netboot?) */ + { + _prep_type = _PREP_Motorola; + } + + prep_setup_pci_ptrs(); + +#ifdef CONFIG_BLK_DEV_INITRD + /* take care of initrd if we have one */ + if ( r4 ) + { + initrd_start = r4 + KERNELBASE; + initrd_end = r5 + KERNELBASE; + } +#endif /* CONFIG_BLK_DEV_INITRD */ + + /* take care of cmd line */ + if ( r6 && (((char *) r6) != '\0')) + { + *(char *)(r7+KERNELBASE) = 0; + strcpy(cmd_line, (char *)(r6+KERNELBASE)); + } + + if ( is_powerplus ) { /* look for a Raven OpenPIC */ + pcibios_read_config_dword(0, 0, 0, &tmp); + if (tmp == PCI_VENDOR_ID_MOTOROLA + (PCI_DEVICE_ID_MOTOROLA_RAVEN<<16)) { + pcibios_read_config_dword(0, 0, PCI_BASE_ADDRESS_1, &tmp); + if (tmp) { + OpenPIC=(volatile struct OpenPIC *) + (tmp + isa_mem_base); + /* printk("OpenPIC found at %p: \n", OpenPIC);*/ + } + } else { + printk ("prep_init: WARNING: can't find an OpenPIC on what looks like a PowerPlus board\n"); + } + } + + + ppc_md.setup_arch = prep_setup_arch; + ppc_md.setup_residual = prep_setup_residual; + ppc_md.get_cpuinfo = prep_get_cpuinfo; + ppc_md.irq_cannonicalize = prep_irq_cannonicalize; + ppc_md.init_IRQ = prep_init_IRQ; + ppc_md.do_IRQ = prep_do_IRQ; + ppc_md.init = NULL; + + ppc_md.restart = prep_restart; + ppc_md.power_off = prep_power_off; + ppc_md.halt = prep_halt; + + ppc_md.time_init = NULL; + if (_prep_type == _PREP_Radstone) { + /* + * We require a direct restart as port 92 does not work on + * all Radstone boards + */ + ppc_md.restart = prep_direct_restart; + /* + * The RTC device used varies according to board type + */ + if(((ucSystemType==RS_SYS_TYPE_PPC1) && (ucBoardRevMaj>=5)) || + (ucSystemType==RS_SYS_TYPE_PPC1a)) + { + ppc_md.set_rtc_time = mk48t59_set_rtc_time; + ppc_md.get_rtc_time = mk48t59_get_rtc_time; + } + else + { + ppc_md.set_rtc_time = mc146818_set_rtc_time; + ppc_md.get_rtc_time = mc146818_get_rtc_time; + } + /* + * Determine the decrementer rate from the residual data + */ + ppc_md.calibrate_decr = prep_res_calibrate_decr; + } + else if (_prep_type == _PREP_IBM) { + ppc_md.set_rtc_time = mc146818_set_rtc_time; + ppc_md.get_rtc_time = mc146818_get_rtc_time; + ppc_md.calibrate_decr = prep_calibrate_decr; + } + else { + ppc_md.set_rtc_time = mk48t59_set_rtc_time; + ppc_md.get_rtc_time = mk48t59_get_rtc_time; + ppc_md.calibrate_decr = mk48t59_calibrate_decr; + } + +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) + ppc_ide_md.insw = prep_ide_insw; + ppc_ide_md.outsw = prep_ide_outsw; + ppc_ide_md.default_irq = prep_ide_default_irq; + ppc_ide_md.default_io_base = prep_ide_default_io_base; + ppc_ide_md.check_region = prep_ide_check_region; + ppc_ide_md.request_region = prep_ide_request_region; + ppc_ide_md.release_region = prep_ide_release_region; + ppc_ide_md.fix_driveid = prep_ide_fix_driveid; + ppc_ide_md.ide_init_hwif = prep_ide_init_hwif_ports; + + ppc_ide_md.io_base = _IO_BASE; +#endif + +#ifdef CONFIG_VT + ppc_md.kbd_setkeycode = pckbd_setkeycode; + ppc_md.kbd_getkeycode = pckbd_getkeycode; + ppc_md.kbd_translate = pckbd_translate; + ppc_md.kbd_unexpected_up = pckbd_unexpected_up; + ppc_md.kbd_leds = pckbd_leds; + ppc_md.kbd_init_hw = pckbd_init_hw; +#ifdef CONFIG_MAGIC_SYSRQ + ppc_md.kbd_sysrq_xlate = pckbd_sysrq_xlate; +#endif +#endif } #ifdef CONFIG_SOUND_MODULE diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/prep_time.c linux/arch/ppc/kernel/prep_time.c --- v2.2.7/linux/arch/ppc/kernel/prep_time.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/prep_time.c Thu Apr 29 12:39:01 1999 @@ -22,7 +22,9 @@ #include #include #include -#include +#include +#include +#include #include "time.h" @@ -41,133 +43,44 @@ * is setup at boot time to use the correct addresses. * -- Cort */ -/* - * translate from mc146818 to m48t18 addresses - */ -unsigned int clock_transl[] __prepdata = { MOTO_RTC_SECONDS,0 /* alarm */, - MOTO_RTC_MINUTES,0 /* alarm */, - MOTO_RTC_HOURS,0 /* alarm */, /* 4,5 */ - MOTO_RTC_DAY_OF_WEEK, - MOTO_RTC_DAY_OF_MONTH, - MOTO_RTC_MONTH, - MOTO_RTC_YEAR, /* 9 */ - MOTO_RTC_CONTROLA, MOTO_RTC_CONTROLB /* 10,11 */ -}; - -/* - * The following struture is used to access the MK48T18 - */ -typedef volatile struct _MK48T18 { - unsigned char ucNvRAM[0x3ff8]; /* NvRAM locations */ - unsigned char ucControl; - unsigned char ucSecond; /* 0-59 */ - unsigned char ucMinute; /* 0-59 */ - unsigned char ucHour; /* 0-23 */ - unsigned char ucDay; /* 1-7 */ - unsigned char ucDate; /* 1-31 */ - unsigned char ucMonth; /* 1-12 */ - unsigned char ucYear; /* 0-99 */ -} MK48T18, *PMK48T18; - -/* - * The control register contains a 5 bit calibration value plus sign - * and read/write enable bits - */ -#define MK48T18_CTRL_CAL_MASK 0x1f -#define MK48T18_CTRL_CAL_SIGN 0x20 -#define MK48T18_CTRL_READ 0x40 -#define MK48T18_CTRL_WRITE 0x80 -/* - * The STOP bit is the most significant bit of the seconds location - */ -#define MK48T18_SEC_MASK 0x7f -#define MK48T18_SEC_STOP 0x80 -/* - * The day location also contains the frequency test bit which should - * be zero for normal operation - */ -#define MK48T18_DAY_MASK 0x07 -#define MK48T18_DAY_FT 0x40 - -__prep -int prep_cmos_clock_read(int addr) -{ - if ( _prep_type == _PREP_IBM ) - return CMOS_READ(addr); - else if ( _prep_type == _PREP_Motorola ) - { - outb(clock_transl[addr]>>8, NVRAM_AS1); - outb(clock_transl[addr], NVRAM_AS0); - return (inb(NVRAM_DATA)); - } - else if ( _prep_type == _PREP_Radstone ) - return CMOS_READ(addr); - - printk("Unknown machine in prep_cmos_clock_read()!\n"); - return -1; -} - -__prep -void prep_cmos_clock_write(unsigned long val, int addr) -{ - if ( _prep_type == _PREP_IBM ) - { - CMOS_WRITE(val,addr); - return; - } - else if ( _prep_type == _PREP_Motorola ) - { - outb(clock_transl[addr]>>8, NVRAM_AS1); - outb(clock_transl[addr], NVRAM_AS0); - outb(val,NVRAM_DATA); - return; - } - else if ( _prep_type == _PREP_Radstone ) - { - CMOS_WRITE(val,addr); - return; - } - - printk("Unknown machine in prep_cmos_clock_write()!\n"); -} /* * Set the hardware clock. -- Cort */ __prep -int prep_set_rtc_time(unsigned long nowtime) +int mc146818_set_rtc_time(unsigned long nowtime) { unsigned char save_control, save_freq_select; struct rtc_time tm; to_tm(nowtime, &tm); - save_control = prep_cmos_clock_read(RTC_CONTROL); /* tell the clock it's being set */ - - prep_cmos_clock_write((save_control|RTC_SET), RTC_CONTROL); - - save_freq_select = prep_cmos_clock_read(RTC_FREQ_SELECT); /* stop and reset prescaler */ + /* tell the clock it's being set */ + save_control = CMOS_READ(RTC_CONTROL); - prep_cmos_clock_write((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT); - - tm.tm_year -= 1900; + CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL); + + /* stop and reset prescaler */ + save_freq_select = CMOS_READ(RTC_FREQ_SELECT); + + CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT); + + tm.tm_year = (tm.tm_year - 1900) % 100; if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { BIN_TO_BCD(tm.tm_sec); BIN_TO_BCD(tm.tm_min); BIN_TO_BCD(tm.tm_hour); BIN_TO_BCD(tm.tm_mon); - BIN_TO_BCD(tm.tm_wday); BIN_TO_BCD(tm.tm_mday); BIN_TO_BCD(tm.tm_year); } - prep_cmos_clock_write(tm.tm_sec,RTC_SECONDS); - prep_cmos_clock_write(tm.tm_min,RTC_MINUTES); - prep_cmos_clock_write(tm.tm_hour,RTC_HOURS); - prep_cmos_clock_write(tm.tm_mon,RTC_MONTH); - prep_cmos_clock_write(tm.tm_wday+1,RTC_DAY_OF_WEEK); - prep_cmos_clock_write(tm.tm_mday,RTC_DAY_OF_MONTH); - prep_cmos_clock_write(tm.tm_year,RTC_YEAR); - + CMOS_WRITE(tm.tm_sec, RTC_SECONDS); + CMOS_WRITE(tm.tm_min, RTC_MINUTES); + CMOS_WRITE(tm.tm_hour, RTC_HOURS); + CMOS_WRITE(tm.tm_mon, RTC_MONTH); + CMOS_WRITE(tm.tm_mday, RTC_DAY_OF_MONTH); + CMOS_WRITE(tm.tm_year, RTC_YEAR); + /* 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 @@ -175,52 +88,14 @@ * the Dallas Semiconductor data sheets, but who believes data * sheets anyway ... -- Markus Kuhn */ - prep_cmos_clock_write(save_control, RTC_CONTROL); - prep_cmos_clock_write(save_freq_select, RTC_FREQ_SELECT); + CMOS_WRITE(save_control, RTC_CONTROL); + CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT); - /* - * Radstone Technology PPC1a boards use an MK48T18 device - * as the "master" RTC but also have a DS1287 equivalent incorporated - * into the PCI-ISA bridge device. The DS1287 is initialised by the boot - * firmware to reflect the value held in the MK48T18 and thus the - * time may be read from this device both here and in the rtc driver. - * Whenever we set the time, however, if it is to be preserved across - * boots we must also update the "master" RTC. - */ - if((_prep_type==_PREP_Radstone) && (ucSystemType==RS_SYS_TYPE_PPC1a)) - { - PMK48T18 pMk48t18=(PMK48T18)(_ISA_MEM_BASE+0x00800000); - - /* - * Set the write enable bit - */ - pMk48t18->ucControl|=MK48T18_CTRL_WRITE; - eieio(); - /* - * Update the clock - */ - pMk48t18->ucSecond=tm.tm_sec; - pMk48t18->ucMinute=tm.tm_min; - pMk48t18->ucHour=tm.tm_hour; - pMk48t18->ucMonth=tm.tm_mon; - pMk48t18->ucDay=tm.tm_wday+1; - pMk48t18->ucDate=tm.tm_mday; - pMk48t18->ucYear=tm.tm_year; - - eieio(); - /* - * Clear the write enable bit - */ - pMk48t18->ucControl&=~MK48T18_CTRL_WRITE; - } - - if ( (time_state == TIME_ERROR) || (time_state == TIME_BAD) ) - time_state = TIME_OK; return 0; } __prep -unsigned long prep_get_rtc_time(void) +unsigned long mc146818_get_rtc_time(void) { unsigned int year, mon, day, hour, min, sec; int i; @@ -232,29 +107,123 @@ */ /* read RTC exactly on falling edge of update flag */ for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */ - if (prep_cmos_clock_read(RTC_FREQ_SELECT) & RTC_UIP) + if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) break; for (i = 0 ; i < 1000000 ; i++) /* must try at least 2.228 ms */ - if (!(prep_cmos_clock_read(RTC_FREQ_SELECT) & RTC_UIP)) + if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)) break; do { /* Isn't this overkill ? UIP above should guarantee consistency */ - sec = prep_cmos_clock_read(RTC_SECONDS); - min = prep_cmos_clock_read(RTC_MINUTES); - hour = prep_cmos_clock_read(RTC_HOURS); - day = prep_cmos_clock_read(RTC_DAY_OF_MONTH); - mon = prep_cmos_clock_read(RTC_MONTH); - year = prep_cmos_clock_read(RTC_YEAR); - } while (sec != prep_cmos_clock_read(RTC_SECONDS)); - if (!(prep_cmos_clock_read(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) - { - BCD_TO_BIN(sec); - BCD_TO_BIN(min); - BCD_TO_BIN(hour); - BCD_TO_BIN(day); - BCD_TO_BIN(mon); - BCD_TO_BIN(year); - } + 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) + { + BCD_TO_BIN(sec); + BCD_TO_BIN(min); + BCD_TO_BIN(hour); + BCD_TO_BIN(day); + BCD_TO_BIN(mon); + BCD_TO_BIN(year); + } if ((year += 1900) < 1970) year += 100; + return mktime(year, mon, day, hour, min, sec); +} + +__prep +int mk48t59_set_rtc_time(unsigned long nowtime) +{ + unsigned char save_control; + struct rtc_time tm; + + + to_tm(nowtime, &tm); + + /* tell the clock it's being written */ + save_control = ppc_md.nvram_read_val(MK48T59_RTC_CONTROLA); + + ppc_md.nvram_write_val(MK48T59_RTC_CONTROLA, + (save_control | MK48T59_RTC_CA_WRITE)); + + tm.tm_year = (tm.tm_year - 1900) % 100; + BIN_TO_BCD(tm.tm_sec); + BIN_TO_BCD(tm.tm_min); + BIN_TO_BCD(tm.tm_hour); + BIN_TO_BCD(tm.tm_mon); + BIN_TO_BCD(tm.tm_mday); + BIN_TO_BCD(tm.tm_year); + + ppc_md.nvram_write_val(MK48T59_RTC_SECONDS, tm.tm_sec); + ppc_md.nvram_write_val(MK48T59_RTC_MINUTES, tm.tm_min); + ppc_md.nvram_write_val(MK48T59_RTC_HOURS, tm.tm_hour); + ppc_md.nvram_write_val(MK48T59_RTC_MONTH, tm.tm_mon); + ppc_md.nvram_write_val(MK48T59_RTC_DAY_OF_MONTH, tm.tm_mday); + ppc_md.nvram_write_val(MK48T59_RTC_YEAR, tm.tm_year); + + /* Turn off the write bit. */ + ppc_md.nvram_write_val(MK48T59_RTC_CONTROLA, save_control); + + return 0; +} + +__prep +unsigned long mk48t59_get_rtc_time(void) +{ + unsigned char save_control; + unsigned int year, mon, day, hour, min, sec; + int i; + + /* Make sure the time is not stopped. */ + save_control = ppc_md.nvram_read_val(MK48T59_RTC_CONTROLB); + + ppc_md.nvram_write_val(MK48T59_RTC_CONTROLA, + (save_control & (~MK48T59_RTC_CB_STOP))); + + /* Now make sure the read bit is off so the value will change. */ + save_control = ppc_md.nvram_read_val(MK48T59_RTC_CONTROLA); + save_control &= ~MK48T59_RTC_CA_READ; + ppc_md.nvram_write_val(MK48T59_RTC_CONTROLA, save_control); + + /* Read the seconds value to see when it changes. */ + sec = ppc_md.nvram_read_val(MK48T59_RTC_SECONDS); + + /* Wait until the seconds value changes, then read the value. */ + for (i = 0 ; i < 1000000 ; i++) { /* may take up to 1 second... */ + if (ppc_md.nvram_read_val(MK48T59_RTC_SECONDS) != sec) { + break; + } + } + + /* Set the register to read the value. */ + ppc_md.nvram_write_val(MK48T59_RTC_CONTROLA, + (save_control | MK48T59_RTC_CA_READ)); + + sec = ppc_md.nvram_read_val(MK48T59_RTC_SECONDS); + min = ppc_md.nvram_read_val(MK48T59_RTC_MINUTES); + hour = ppc_md.nvram_read_val(MK48T59_RTC_HOURS); + day = ppc_md.nvram_read_val(MK48T59_RTC_DAY_OF_MONTH); + mon = ppc_md.nvram_read_val(MK48T59_RTC_MONTH); + year = ppc_md.nvram_read_val(MK48T59_RTC_YEAR); + + /* Let the time values change again. */ + ppc_md.nvram_write_val(MK48T59_RTC_CONTROLA, save_control); + + BCD_TO_BIN(sec); + BCD_TO_BIN(min); + BCD_TO_BIN(hour); + BCD_TO_BIN(day); + BCD_TO_BIN(mon); + BCD_TO_BIN(year); + + year = year + 1900; + if (year < 1970) { + year += 100; + } + return mktime(year, mon, day, hour, min, sec); } diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/process.c linux/arch/ppc/kernel/process.c --- v2.2.7/linux/arch/ppc/kernel/process.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/process.c Thu Apr 29 12:39:01 1999 @@ -1,5 +1,5 @@ /* - * $Id: process.c,v 1.75 1999/02/12 07:06:29 cort Exp $ + * $Id: process.c,v 1.78 1999/04/07 07:27:00 paulus Exp $ * * linux/arch/ppc/kernel/process.c * @@ -77,17 +77,25 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs) { -#ifdef __SMP__ - if ( regs->msr & MSR_FP ) - smp_giveup_fpu(current); -#else - if (last_task_used_math == current) - giveup_fpu(); -#endif + if (regs->msr & MSR_FP) + giveup_fpu(current); memcpy(fpregs, ¤t->tss.fpr[0], sizeof(*fpregs)); return 1; } +void +enable_kernel_fp(void) +{ +#ifdef __SMP__ + if (current->tss.regs && (current->tss.regs->msr & MSR_FP)) + giveup_fpu(current); + else + giveup_fpu(NULL); /* just enables FP for kernel */ +#else + giveup_fpu(last_task_used_math); +#endif /* __SMP__ */ +} + /* check to make sure the kernel stack is healthy */ int check_stack(struct task_struct *tsk) { @@ -176,8 +184,8 @@ * reload its fp regs. * -- Cort */ - if ( prev->tss.regs->msr & MSR_FP ) - smp_giveup_fpu(prev); + if (prev->tss.regs && (prev->tss.regs->msr & MSR_FP)) + giveup_fpu(prev); prev->last_processor = prev->processor; current_set[smp_processor_id()] = new; @@ -237,7 +245,12 @@ printk("Instruction DUMP:"); for(i = -3; i < 6; i++) - printk("%c%08lx%c",i?' ':'<',pc[i],i?' ':'>'); + { + unsigned long p; + if (__get_user( p, &pc[i] )) + break; + printk("%c%08lx%c",i?' ':'<',p,i?' ':'>'); + } printk("\n"); } @@ -290,13 +303,8 @@ * copy fpu info - assume lazy fpu switch now always * -- Cort */ -#ifdef __SMP__ - if ( regs->msr & MSR_FP ) - smp_giveup_fpu(current); -#else - if ( last_task_used_math == current ) - giveup_fpu(); -#endif + if (regs->msr & MSR_FP) + giveup_fpu(current); memcpy(&p->tss.fpr, ¤t->tss.fpr, sizeof(p->tss.fpr)); p->tss.fpscr = current->tss.fpscr; @@ -424,13 +432,8 @@ error = PTR_ERR(filename); if (IS_ERR(filename)) goto out; -#ifdef __SMP__ - if ( regs->msr & MSR_FP ) - smp_giveup_fpu(current); -#else - if ( last_task_used_math == current ) - giveup_fpu(); -#endif + if (regs->msr & MSR_FP) + giveup_fpu(current); error = do_execve(filename, (char **) a1, (char **) a2, regs); putname(filename); out: diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/prom.c linux/arch/ppc/kernel/prom.c --- v2.2.7/linux/arch/ppc/kernel/prom.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/prom.c Thu Apr 29 12:39:01 1999 @@ -1,5 +1,5 @@ /* - * $Id: prom.c,v 1.50 1999/03/16 10:40:34 cort Exp $ + * $Id: prom.c,v 1.53 1999/04/22 22:45:42 cort Exp $ * * Procedures for interfacing to the Open Firmware PROM on * Power Macintosh computers. @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -263,9 +264,11 @@ void prom_init(int r3, int r4, prom_entry pp) { +#ifdef CONFIG_SMP int cpu = 0, i; phandle node; char type[16], *path; +#endif unsigned long mem; ihandle prom_rtas; unsigned long offset = reloc_offset(); @@ -1141,7 +1144,7 @@ if (cp == NULL) return 0; while (cplen > 0) { - if (strcasecmp(cp, compat) == 0) + if (strncasecmp(cp, compat, strlen(compat)) == 0) return 1; l = strlen(cp) + 1; cp += l; @@ -1277,6 +1280,8 @@ } #endif +spinlock_t rtas_lock = SPIN_LOCK_UNLOCKED; + /* this can be called after setup -- Cort */ __openfirmware int @@ -1307,7 +1312,9 @@ for (i = 0; i < nargs; ++i) u.words[i+3] = va_arg(list, unsigned long); va_end(list); + spin_lock(&rtas_lock); enter_rtas((void *)__pa(&u)); + spin_unlock(&rtas_lock); if (nret > 1 && outputs != NULL) for (i = 0; i < nret-1; ++i) outputs[i] = u.words[i+nargs+4]; diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/ptrace.c linux/arch/ppc/kernel/ptrace.c --- v2.2.7/linux/arch/ppc/kernel/ptrace.c Thu Dec 31 10:28:59 1998 +++ linux/arch/ppc/kernel/ptrace.c Thu Apr 29 12:39:01 1999 @@ -392,14 +392,8 @@ tmp = get_reg(child, addr); } else if (addr >= PT_FPR0 && addr <= PT_FPSCR) { -#ifdef __SMP__ - if (child->tss.regs->msr & MSR_FP ) - smp_giveup_fpu(child); -#else - /* only current can be last task to use math on SMP */ - if (last_task_used_math == child) - giveup_fpu(); -#endif + if (child->tss.regs->msr & MSR_FP) + giveup_fpu(child); tmp = ((long *)child->tss.fpr)[addr - PT_FPR0]; } else @@ -433,13 +427,8 @@ goto out; } if (addr >= PT_FPR0 && addr < PT_FPR0 + 64) { -#ifndef __SMP__ - if (last_task_used_math == child) - giveup_fpu(); -#else - if (child->tss.regs->msr & MSR_FP ) - smp_giveup_fpu(child); -#endif + if (child->tss.regs->msr & MSR_FP) + giveup_fpu(child); ((long *)child->tss.fpr)[addr - PT_FPR0] = data; ret = 0; goto out; diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/setup.c linux/arch/ppc/kernel/setup.c --- v2.2.7/linux/arch/ppc/kernel/setup.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/setup.c Thu Apr 29 12:39:01 1999 @@ -1,5 +1,5 @@ /* - * $Id: setup.c,v 1.130 1999/03/11 01:45:15 cort Exp $ + * $Id: setup.c,v 1.132 1999/03/24 00:32:19 cort Exp $ * Common prep/pmac/chrp boot and setup code. */ @@ -30,31 +30,62 @@ #include #endif #include +#include +#include -/* APUS defs */ -extern unsigned long m68k_machtype; -extern int parse_bootinfo(const struct bi_record *); -extern char _end[]; -#ifdef CONFIG_APUS -extern struct mem_info ramdisk; -unsigned long isa_io_base; -unsigned long isa_mem_base; -unsigned long pci_dram_offset; -#endif -/* END APUS defs */ +extern void pmac_init(unsigned long r3, + unsigned long r4, + unsigned long r5, + unsigned long r6, + unsigned long r7); + +extern void chrp_init(unsigned long r3, + unsigned long r4, + unsigned long r5, + unsigned long r6, + unsigned long r7); + +extern void prep_init(unsigned long r3, + unsigned long r4, + unsigned long r5, + unsigned long r6, + unsigned long r7); + +extern void mbx_init(unsigned long r3, + unsigned long r4, + unsigned long r5, + unsigned long r6, + unsigned long r7); + +extern void apus_init(unsigned long r3, + unsigned long r4, + unsigned long r5, + unsigned long r6, + unsigned long r7); extern boot_infos_t *boot_infos; extern char cmd_line[512]; char saved_command_line[256]; unsigned char aux_device_present; -#if !defined(CONFIG_MACH_SPECIFIC) +struct ide_machdep_calls ppc_ide_md; + unsigned long ISA_DMA_THRESHOLD; unsigned long DMA_MODE_READ, DMA_MODE_WRITE; -int _machine; -/* if we have openfirmware */ -unsigned long have_of; -#endif /* ! CONFIG_MACH_SPECIFIC */ + +/* Temporary hacks until machdep.h is fully done. */ +int _machine = 0; +/* do we have OF? */ +int have_of = 0; +int is_prep = 0; +int is_chrp = 0; +/* For MTX/MVME boards.. with Raven/Falcon Chipset + Real close to CHRP, but boot like PReP (via PPCbug) + There's probably a nicer way to do this.. --Troy */ +int is_powerplus = 0; + +struct machdep_calls ppc_md; + /* copy of the residual data */ #ifndef CONFIG_MBX @@ -65,15 +96,6 @@ RESIDUAL *res = (RESIDUAL *)&__res; -int _prep_type; -/* - * This is used to identify the board type from a given PReP board - * vendor. Board revision is also made available. - */ -unsigned char ucSystemType; -unsigned char ucBoardRev; -unsigned char ucBoardRevMaj, ucBoardRevMin; - /* * Perhaps we can put the pmac screen_info[] here * on pmac as well so we don't need the ifdef's. @@ -122,164 +144,28 @@ }; #endif /* CONFIG_MBX */ -/* cmd is ignored for now... */ void machine_restart(char *cmd) { -#ifndef CONFIG_MBX - unsigned long flags; - struct adb_request req; - - switch(_machine) - { - case _MACH_Pmac: - switch (adb_hardware) { - case ADB_VIACUDA: - cuda_request(&req, NULL, 2, CUDA_PACKET, - CUDA_RESET_SYSTEM); - for (;;) - cuda_poll(); - break; - case ADB_VIAPMU: - pmu_restart(); - break; - default: - } - break; - - case _MACH_chrp: -#if 0 /* RTAS doesn't seem to work on Longtrail. - For now, do it the same way as the PReP. */ - /*err = call_rtas("system-reboot", 0, 1, NULL); - printk("RTAS system-reboot returned %d\n", err); - for (;;);*/ - - { - extern unsigned int rtas_entry, rtas_data, rtas_size; - unsigned long status, value; - printk("rtas_ent`ry: %08x rtas_data: %08x rtas_size: %08x\n", - rtas_entry,rtas_data,rtas_size); - } -#endif - case _MACH_prep: - _disable_interrupts(); - /* set exception prefix high - to the prom */ - save_flags( flags ); - restore_flags( flags|MSR_IP ); - - /* make sure bit 0 (reset) is a 0 */ - outb( inb(0x92) & ~1L , 0x92 ); - /* signal a reset to system control port A - soft reset */ - outb( inb(0x92) | 1 , 0x92 ); - - while ( 1 ) ; - break; - /* - * Not reached - */ - case _MACH_apus: - cli(); - - APUS_WRITE(APUS_REG_LOCK, - REGLOCK_BLACKMAGICK1|REGLOCK_BLACKMAGICK2); - APUS_WRITE(APUS_REG_LOCK, - REGLOCK_BLACKMAGICK1|REGLOCK_BLACKMAGICK3); - APUS_WRITE(APUS_REG_LOCK, - REGLOCK_BLACKMAGICK2|REGLOCK_BLACKMAGICK3); - APUS_WRITE(APUS_REG_SHADOW, REGSHADOW_SELFRESET); - APUS_WRITE(APUS_REG_RESET, REGRESET_AMIGARESET); - for(;;); - break; - } -#else /* CONFIG_MBX */ - extern void __clear_msr_me(void); - __volatile__ unsigned char dummy; - - cli(); - ((immap_t *)IMAP_ADDR)->im_clkrst.car_plprcr |= 0x00000080; - __clear_msr_me(); - dummy = ((immap_t *)IMAP_ADDR)->im_clkrst.res[0]; - - printk("Restart failed\n"); - while(1); -#endif /* CONFIG_MBX */ + ppc_md.restart(cmd); } - + void machine_power_off(void) { -#ifndef CONFIG_MBX - struct adb_request req; -#if 0 - int err; -#endif - - switch (_machine) { - case _MACH_Pmac: - switch (adb_hardware) { - case ADB_VIACUDA: - cuda_request(&req, NULL, 2, CUDA_PACKET, - CUDA_POWERDOWN); - for (;;) - cuda_poll(); - break; - case ADB_VIAPMU: - pmu_shutdown(); - break; - default: - } - break; - - case _MACH_chrp: -#if 0 /* RTAS doesn't seem to work on Longtrail. - For now, do it the same way as the PReP. */ - err = call_rtas("power-off", 2, 1, NULL, 0, 0); - printk("RTAS system-reboot returned %d\n", err); - for (;;); -#endif - - case _MACH_prep: - machine_restart(NULL); - case _MACH_apus: - for (;;); - } - for (;;); -#else /* CONFIG_MBX */ - machine_halt(); -#endif /* CONFIG_MBX */ + ppc_md.power_off(); } - + void machine_halt(void) { - if ( _machine == _MACH_Pmac ) - { - machine_power_off(); - } - else /* prep, chrp or apus */ - machine_restart(NULL); + ppc_md.halt(); } - + #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) void ide_init_hwif_ports (ide_ioreg_t *p, ide_ioreg_t base, int *irq) { -#if !defined(CONFIG_MBX) && !defined(CONFIG_APUS) - switch (_machine) { -#if defined(CONFIG_BLK_DEV_IDE_PMAC) - case _MACH_Pmac: - pmac_ide_init_hwif_ports(p,base,irq); - break; -#endif - case _MACH_chrp: - chrp_ide_init_hwif_ports(p,base,irq); - break; - case _MACH_prep: - prep_ide_init_hwif_ports(p,base,irq); - break; + if (ppc_ide_md.ide_init_hwif != NULL) { + ppc_ide_md.ide_init_hwif(p, base, irq); } -#endif -#if defined(CONFIG_MBX) - mbx_ide_init_hwif_ports(p,base,irq); -#endif } -EXPORT_SYMBOL(ide_init_hwif_ports); #endif unsigned long cpu_temp(void) @@ -313,10 +199,6 @@ int get_cpuinfo(char *buffer) { - extern int pmac_get_cpuinfo(char *); - extern int chrp_get_cpuinfo(char *); - extern int prep_get_cpuinfo(char *); - extern int apus_get_cpuinfo(char *); unsigned long len = 0; unsigned long bogosum = 0; unsigned long i; @@ -380,7 +262,6 @@ break; } -#ifndef CONFIG_MBX /* * Assume here that all clock rates are the same in a * smp system. -- Cort @@ -397,33 +278,11 @@ len += sprintf(len+buffer, "clock\t\t: %dMHz\n", *fp / 1000000); } - - /* PREP's without residual data for some reason will give - incorrect values here */ - if ( is_prep ) - { - len += sprintf(len+buffer, "clock\t\t: "); - if ( res->ResidualLength ) - len += sprintf(len+buffer, "%ldMHz\n", - (res->VitalProductData.ProcessorHz > 1024) ? - res->VitalProductData.ProcessorHz>>20 : - res->VitalProductData.ProcessorHz); - else - len += sprintf(len+buffer, "???\n"); - } -#else /* CONFIG_MBX */ + + if (ppc_md.setup_residual != NULL) { - bd_t *bp; - extern RESIDUAL *res; - - bp = (bd_t *)res; - - len += sprintf(len+buffer,"clock\t\t: %dMHz\n" - "bus clock\t: %dMHz\n", - bp->bi_intfreq /*/ 1000000*/, - bp->bi_busfreq /*/ 1000000*/); + len += ppc_md.setup_residual(buffer + len); } -#endif /* CONFIG_MBX */ len += sprintf(len+buffer, "revision\t: %ld.%ld\n", (GET_PVR & 0xff00) >> 8, GET_PVR & 0xff); @@ -438,8 +297,8 @@ if ( i ) len += sprintf(buffer+len, "\n"); len += sprintf(buffer+len,"total bogomips\t: %lu.%02lu\n", - (bogosum+2500)/500000, - (bogosum+2500)/5000 % 100); + (bogosum+2500)/500000, + (bogosum+2500)/5000 % 100); #endif /* __SMP__ */ /* @@ -455,27 +314,14 @@ zero_cache_hits,zero_cache_calls, /* : 1 below is so we don't div by zero */ (zero_cache_hits*100) / - ((zero_cache_calls)?zero_cache_calls:1)); + ((zero_cache_calls)?zero_cache_calls:1)); } -#ifndef CONFIG_MBX - switch (_machine) + if (ppc_md.get_cpuinfo != NULL) { - case _MACH_Pmac: - len += pmac_get_cpuinfo(buffer+len); - break; - case _MACH_prep: - len += prep_get_cpuinfo(buffer+len); - break; - case _MACH_chrp: - len += chrp_get_cpuinfo(buffer+len); - break; - case _MACH_apus: - /* Not much point in printing m68k info when it is not - used. */ - break; + len += ppc_md.get_cpuinfo(buffer+len); } -#endif /* ndef CONFIG_MBX */ + return len; } @@ -487,25 +333,22 @@ identify_machine(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7) { - extern void setup_pci_ptrs(void); #ifdef __SMP__ if ( first_cpu_booted ) return 0; #endif /* __SMP__ */ -#ifndef CONFIG_MBX #ifndef CONFIG_MACH_SPECIFIC /* boot loader will tell us if we're APUS */ if ( r3 == 0x61707573 ) { _machine = _MACH_apus; - have_of = 0; r3 = 0; } /* prep boot loader tells us if we're prep or not */ else if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) ) { _machine = _MACH_prep; - have_of = 0; + is_prep = 1; } else { char *model; @@ -516,19 +359,49 @@ /* ask the OF info if we're a chrp or pmac */ model = get_property(find_path_device("/"), "device_type", NULL); if ( model && !strncmp("chrp",model,4) ) + { _machine = _MACH_chrp; + is_chrp = 1; + } else { model = get_property(find_path_device("/"), "model", NULL); if ( model && !strncmp(model, "IBM", 3)) + { _machine = _MACH_chrp; + is_chrp = 1; + } else + { _machine = _MACH_Pmac; + is_prep = 1; + } } } -#endif /* CONFIG_MACH_SPECIFIC */ +#else /* CONFIG_MACH_SPECIFIC */ + +#ifdef CONFIG_PREP + _machine = _MACH_prep; + is_prep = 1; +#elif defined(CONFIG_CHRP) + _machine = _MACH_chrp; + is_chrp = 1; + have_of = 1; +#elif defined(CONFIG_PMAC) + _machine = _MACH_Pmac; + have_of = 1; +#elif defined(CONFIG_MBX) + _machine = _MACH_mbx; +#elif defined(CONFIG_FADS) + _machine = _MACH_fads; +#elif defined(CONFIG_APUS) + _machine = _MACH_apus; +#else +#error "Machine not defined correctly" +#endif /* CONFIG_APUS */ +#endif /* CONFIG_MACH_SPECIFIC */ if ( have_of ) { @@ -587,138 +460,31 @@ cmd_line[sizeof(cmd_line) - 1] = 0; } - switch (_machine) { case _MACH_Pmac: - setup_pci_ptrs(); - /* isa_io_base gets set in pmac_find_bridges */ - isa_mem_base = PMAC_ISA_MEM_BASE; - pci_dram_offset = PMAC_PCI_DRAM_OFFSET; -#if !defined(CONFIG_MACH_SPECIFIC) - ISA_DMA_THRESHOLD = ~0L; - DMA_MODE_READ = 1; - DMA_MODE_WRITE = 2; -#endif /* ! CONFIG_MACH_SPECIFIC */ + pmac_init(r3, r4, r5, r6, r7); break; case _MACH_prep: - /* make a copy of residual data */ - if ( r3 ) - memcpy((void *)res,(void *)(r3+KERNELBASE), - sizeof(RESIDUAL)); - isa_io_base = PREP_ISA_IO_BASE; - isa_mem_base = PREP_ISA_MEM_BASE; - pci_dram_offset = PREP_PCI_DRAM_OFFSET; -#if !defined(CONFIG_MACH_SPECIFIC) - ISA_DMA_THRESHOLD = 0x00ffffff; - DMA_MODE_READ = 0x44; - DMA_MODE_WRITE = 0x48; -#endif /* ! CONFIG_MACH_SPECIFIC */ - /* figure out what kind of prep workstation we are */ - if ( res->ResidualLength != 0 ) - { - if ( !strncmp(res->VitalProductData.PrintableModel,"IBM",3) ) - _prep_type = _PREP_IBM; - else if (!strncmp(res->VitalProductData.PrintableModel, - "Radstone",8)) - { - extern char *Motherboard_map_name; - - _prep_type = _PREP_Radstone; - Motherboard_map_name= - res->VitalProductData.PrintableModel; - } - else - _prep_type = _PREP_Motorola; - } - else /* assume motorola if no residual (netboot?) */ - _prep_type = _PREP_Motorola; - setup_pci_ptrs(); -#ifdef CONFIG_BLK_DEV_INITRD - /* take care of initrd if we have one */ - if ( r4 ) - { - initrd_start = r4 + KERNELBASE; - initrd_end = r5 + KERNELBASE; - } -#endif /* CONFIG_BLK_DEV_INITRD */ - /* take care of cmd line */ - if ( r6 ) - { - *(char *)(r7+KERNELBASE) = 0; - strcpy(cmd_line, (char *)(r6+KERNELBASE)); - } + prep_init(r3, r4, r5, r6, r7); break; case _MACH_chrp: - setup_pci_ptrs(); -#ifdef CONFIG_BLK_DEV_INITRD - /* take care of initrd if we have one */ - if ( r3 ) - { - initrd_start = r3 + KERNELBASE; - initrd_end = r3 + r4 + KERNELBASE; - } -#endif /* CONFIG_BLK_DEV_INITRD */ - /* pci_dram_offset/isa_io_base/isa_mem_base set by setup_pci_ptrs() */ -#if !defined(CONFIG_MACH_SPECIFIC) - ISA_DMA_THRESHOLD = ~0L; - DMA_MODE_READ = 0x44; - DMA_MODE_WRITE = 0x48; -#endif /* ! CONFIG_MACH_SPECIFIC */ + chrp_init(r3, r4, r5, r6, r7); break; -#ifdef CONFIG_APUS +#ifdef CONFIG_APUS case _MACH_apus: - /* Parse bootinfo. The bootinfo is located right after - the kernel bss */ - parse_bootinfo((const struct bi_record *)&_end); -#ifdef CONFIG_BLK_DEV_INITRD - /* Take care of initrd if we have one. Use data from - bootinfo to avoid the need to initialize PPC - registers when kernel is booted via a PPC reset. */ - if ( ramdisk.addr ) { - initrd_start = (unsigned long) __va(ramdisk.addr); - initrd_end = (unsigned long) - __va(ramdisk.size + ramdisk.addr); - } - /* Make sure code below is not executed. */ - r4 = 0; - r6 = 0; -#endif /* CONFIG_BLK_DEV_INITRD */ -#if !defined(CONFIG_MACH_SPECIFIC) - ISA_DMA_THRESHOLD = 0x00ffffff; -#endif /* ! CONFIG_MACH_SPECIFIC */ + apus_init(r3, r4, r5, r6, r7); break; #endif +#ifdef CONFIG_MBX + case _MACH_mbx: + mbx_init(r3, r4, r5, r6, r7); + break; +#endif default: printk("Unknown machine type in identify_machine!\n"); } -#else /* CONFIG_MBX */ - - if ( r3 ) - memcpy( (void *)res,(void *)(r3+KERNELBASE), sizeof(bd_t) ); - -#ifdef CONFIG_PCI - setup_pci_ptrs(); -#endif - -#ifdef CONFIG_BLK_DEV_INITRD - /* take care of initrd if we have one */ - if ( r4 ) - { - initrd_start = r4 + KERNELBASE; - initrd_end = r5 + KERNELBASE; - } -#endif /* CONFIG_BLK_DEV_INITRD */ - /* take care of cmd line */ - if ( r6 ) - { - - *(char *)(r7+KERNELBASE) = 0; - strcpy(cmd_line, (char *)(r6+KERNELBASE)); - } -#endif /* CONFIG_MBX */ - /* Check for nobats option (used in mapin_ram). */ if (strstr(cmd_line, "nobats")) { extern int __map_without_bats; @@ -740,14 +506,17 @@ } } +__initfunc(void + ppc_init(void)) +{ + if (ppc_md.init != NULL) { + ppc_md.init(); + } +} + __initfunc(void setup_arch(char **cmdline_p, - unsigned long * memory_start_p, unsigned long * memory_end_p)) + unsigned long * memory_start_p, unsigned long * memory_end_p)) { - extern void pmac_setup_arch(unsigned long *, unsigned long *); - extern void chrp_setup_arch(unsigned long *, unsigned long *); - extern void prep_setup_arch(unsigned long *, unsigned long *); - extern void mbx_setup_arch(unsigned long *, unsigned long *); - extern void apus_setup_arch(unsigned long *, unsigned long *); extern int panic_timeout; extern char _etext[], _edata[]; extern char *klimit; @@ -776,27 +545,113 @@ *memory_start_p = find_available_memory(); *memory_end_p = (unsigned long) end_of_DRAM; -#ifdef CONFIG_MBX - mbx_setup_arch(memory_start_p,memory_end_p); -#else /* CONFIG_MBX */ - switch (_machine) { - case _MACH_Pmac: - pmac_setup_arch(memory_start_p, memory_end_p); - break; - case _MACH_prep: - prep_setup_arch(memory_start_p, memory_end_p); - break; - case _MACH_chrp: - chrp_setup_arch(memory_start_p, memory_end_p); - break; -#ifdef CONFIG_APUS - case _MACH_apus: - m68k_machtype = MACH_AMIGA; - apus_setup_arch(memory_start_p,memory_end_p); - break; -#endif - default: - printk("Unknown machine %d in setup_arch()\n", _machine); - } -#endif /* CONFIG_MBX */ + ppc_md.setup_arch(memory_start_p, memory_end_p); +} + +void ppc_generic_ide_fix_driveid(struct hd_driveid *id) +{ + int i; + unsigned short *stringcast; + + + id->config = __le16_to_cpu(id->config); + id->cyls = __le16_to_cpu(id->cyls); + id->reserved2 = __le16_to_cpu(id->reserved2); + id->heads = __le16_to_cpu(id->heads); + id->track_bytes = __le16_to_cpu(id->track_bytes); + id->sector_bytes = __le16_to_cpu(id->sector_bytes); + id->sectors = __le16_to_cpu(id->sectors); + id->vendor0 = __le16_to_cpu(id->vendor0); + id->vendor1 = __le16_to_cpu(id->vendor1); + id->vendor2 = __le16_to_cpu(id->vendor2); + stringcast = (unsigned short *)&id->serial_no[0]; + for (i=0; i<(20/2); i++) + stringcast[i] = __le16_to_cpu(stringcast[i]); + id->buf_type = __le16_to_cpu(id->buf_type); + id->buf_size = __le16_to_cpu(id->buf_size); + id->ecc_bytes = __le16_to_cpu(id->ecc_bytes); + stringcast = (unsigned short *)&id->fw_rev[0]; + for (i=0; i<(8/2); i++) + stringcast[i] = __le16_to_cpu(stringcast[i]); + stringcast = (unsigned short *)&id->model[0]; + for (i=0; i<(40/2); i++) + stringcast[i] = __le16_to_cpu(stringcast[i]); + id->dword_io = __le16_to_cpu(id->dword_io); + id->reserved50 = __le16_to_cpu(id->reserved50); + id->field_valid = __le16_to_cpu(id->field_valid); + id->cur_cyls = __le16_to_cpu(id->cur_cyls); + id->cur_heads = __le16_to_cpu(id->cur_heads); + id->cur_sectors = __le16_to_cpu(id->cur_sectors); + id->cur_capacity0 = __le16_to_cpu(id->cur_capacity0); + id->cur_capacity1 = __le16_to_cpu(id->cur_capacity1); + id->lba_capacity = __le32_to_cpu(id->lba_capacity); + id->dma_1word = __le16_to_cpu(id->dma_1word); + id->dma_mword = __le16_to_cpu(id->dma_mword); + id->eide_pio_modes = __le16_to_cpu(id->eide_pio_modes); + id->eide_dma_min = __le16_to_cpu(id->eide_dma_min); + id->eide_dma_time = __le16_to_cpu(id->eide_dma_time); + id->eide_pio = __le16_to_cpu(id->eide_pio); + id->eide_pio_iordy = __le16_to_cpu(id->eide_pio_iordy); + id->word69 = __le16_to_cpu(id->word69); + id->word70 = __le16_to_cpu(id->word70); + id->word71 = __le16_to_cpu(id->word71); + id->word72 = __le16_to_cpu(id->word72); + id->word73 = __le16_to_cpu(id->word73); + id->word74 = __le16_to_cpu(id->word74); + id->word75 = __le16_to_cpu(id->word75); + id->word76 = __le16_to_cpu(id->word76); + id->word77 = __le16_to_cpu(id->word77); + id->word78 = __le16_to_cpu(id->word78); + id->word79 = __le16_to_cpu(id->word79); + id->word80 = __le16_to_cpu(id->word80); + id->word81 = __le16_to_cpu(id->word81); + id->command_sets = __le16_to_cpu(id->command_sets); + id->word83 = __le16_to_cpu(id->word83); + id->word84 = __le16_to_cpu(id->word84); + id->word85 = __le16_to_cpu(id->word85); + id->word86 = __le16_to_cpu(id->word86); + id->word87 = __le16_to_cpu(id->word87); + id->dma_ultra = __le16_to_cpu(id->dma_ultra); + id->word89 = __le16_to_cpu(id->word89); + id->word90 = __le16_to_cpu(id->word90); + id->word91 = __le16_to_cpu(id->word91); + id->word92 = __le16_to_cpu(id->word92); + id->word93 = __le16_to_cpu(id->word93); + id->word94 = __le16_to_cpu(id->word94); + id->word95 = __le16_to_cpu(id->word95); + id->word96 = __le16_to_cpu(id->word96); + id->word97 = __le16_to_cpu(id->word97); + id->word98 = __le16_to_cpu(id->word98); + id->word99 = __le16_to_cpu(id->word99); + id->word100 = __le16_to_cpu(id->word100); + id->word101 = __le16_to_cpu(id->word101); + id->word102 = __le16_to_cpu(id->word102); + id->word103 = __le16_to_cpu(id->word103); + id->word104 = __le16_to_cpu(id->word104); + id->word105 = __le16_to_cpu(id->word105); + id->word106 = __le16_to_cpu(id->word106); + id->word107 = __le16_to_cpu(id->word107); + id->word108 = __le16_to_cpu(id->word108); + id->word109 = __le16_to_cpu(id->word109); + id->word110 = __le16_to_cpu(id->word110); + id->word111 = __le16_to_cpu(id->word111); + id->word112 = __le16_to_cpu(id->word112); + id->word113 = __le16_to_cpu(id->word113); + id->word114 = __le16_to_cpu(id->word114); + id->word115 = __le16_to_cpu(id->word115); + id->word116 = __le16_to_cpu(id->word116); + id->word117 = __le16_to_cpu(id->word117); + id->word118 = __le16_to_cpu(id->word118); + id->word119 = __le16_to_cpu(id->word119); + id->word120 = __le16_to_cpu(id->word120); + id->word121 = __le16_to_cpu(id->word121); + id->word122 = __le16_to_cpu(id->word122); + id->word123 = __le16_to_cpu(id->word123); + id->word124 = __le16_to_cpu(id->word124); + id->word125 = __le16_to_cpu(id->word125); + id->word126 = __le16_to_cpu(id->word126); + id->word127 = __le16_to_cpu(id->word127); + id->security = __le16_to_cpu(id->security); + for (i=0; i<127; i++) + id->reserved[i] = __le16_to_cpu(id->reserved[i]); } diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/signal.c linux/arch/ppc/kernel/signal.c --- v2.2.7/linux/arch/ppc/kernel/signal.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/signal.c Thu Apr 29 12:39:01 1999 @@ -1,7 +1,7 @@ /* * linux/arch/ppc/kernel/signal.c * - * $Id: signal.c,v 1.23 1999/03/01 16:51:53 cort Exp $ + * $Id: signal.c,v 1.24 1999/04/03 11:25:16 paulus Exp $ * * PowerPC version * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) @@ -218,13 +218,8 @@ if (sc == (struct sigcontext_struct *)(sigctx.regs)) { /* Last stacked signal - restore registers */ sr = (struct sigregs *) sigctx.regs; -#ifdef __SMP__ - if ( regs->msr & MSR_FP ) - smp_giveup_fpu(current); -#else - if (last_task_used_math == current) - giveup_fpu(); -#endif + if (regs->msr & MSR_FP ) + giveup_fpu(current); if (copy_from_user(saved_regs, &sr->gp_regs, sizeof(sr->gp_regs))) goto badframe; @@ -271,13 +266,8 @@ if (verify_area(VERIFY_WRITE, frame, sizeof(*frame))) goto badframe; -#ifdef __SMP__ - if ( regs->msr & MSR_FP ) - smp_giveup_fpu(current); -#else - if (last_task_used_math == current) - giveup_fpu(); -#endif + if (regs->msr & MSR_FP) + giveup_fpu(current); if (__copy_to_user(&frame->gp_regs, regs, GP_REGS_SIZE) || __copy_to_user(&frame->fp_regs, current->tss.fpr, ELF_NFPREG * sizeof(double)) diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/smp.c linux/arch/ppc/kernel/smp.c --- v2.2.7/linux/arch/ppc/kernel/smp.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/smp.c Thu Apr 29 12:39:01 1999 @@ -1,10 +1,13 @@ /* - * $Id: smp.c,v 1.48 1999/03/16 10:40:32 cort Exp $ + * $Id: smp.c,v 1.49 1999/03/18 04:16:31 cort Exp $ * * Smp support for ppc. * * Written by Cort Dougan (cort@cs.nmt.edu) borrowing a great * deal of code from the sparc and intel versions. + * + * Support for PReP (Motorola MTX/MVME) SMP by Troy Benjegerdes + * (troy@microux.com, hozer@drgw.net) */ #include @@ -253,6 +256,7 @@ * cpu 0, the master -- Cort */ cpu_callin_map[0] = 1; + cpu_callin_map[1] = 0; smp_store_cpu_info(0); active_kernel_processor = 0; current->processor = 0; diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/time.c linux/arch/ppc/kernel/time.c --- v2.2.7/linux/arch/ppc/kernel/time.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/kernel/time.c Thu Apr 29 12:39:01 1999 @@ -1,5 +1,5 @@ /* - * $Id: time.c,v 1.45 1999/03/03 15:09:59 cort Exp $ + * $Id: time.c,v 1.47 1999/03/18 05:11:11 cort Exp $ * Common time routines among all ppc machines. * * Written by Cort Dougan (cort@cs.nmt.edu) to merge @@ -41,18 +41,14 @@ #include #include #include -#ifdef CONFIG_MBX -#include -#endif +/* Fixme - Why is this here? - Corey */ #ifdef CONFIG_8xx #include #endif +#include #include "time.h" -/* this is set to the appropriate pmac/prep/chrp func in init_IRQ() */ -int (*set_rtc_time)(unsigned long); - void smp_local_timer_interrupt(struct pt_regs *); /* keep track of when we need to update the rtc */ @@ -116,16 +112,21 @@ */ if ( xtime.tv_sec > last_rtc_update + 660 ) { - if (set_rtc_time(xtime.tv_sec) == 0) + if (ppc_md.set_rtc_time(xtime.tv_sec) == 0) { last_rtc_update = xtime.tv_sec; - else - last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */ + } + else { + /* do it again in 60 s */ + last_rtc_update = xtime.tv_sec - 60; + } } } } #ifdef __SMP__ smp_local_timer_interrupt(regs); #endif + + /* Fixme - make this more generic - Corey */ #ifdef CONFIG_APUS { extern void apus_heartbeat (void); @@ -135,28 +136,6 @@ hardirq_exit(cpu); } -#ifdef CONFIG_MBX -/* A place holder for time base interrupts, if they are ever enabled. -*/ -void timebase_interrupt(int irq, void * dev, struct pt_regs * regs) -{ - printk("timebase_interrupt()\n"); -} - -/* The RTC on the MPC8xx is an internal register. - * We want to protect this during power down, so we need to unlock, - * modify, and re-lock. - */ -static int -mbx_set_rtc_time(unsigned long time) -{ - ((immap_t *)IMAP_ADDR)->im_sitk.sitk_rtck = KAPWR_KEY; - ((immap_t *)IMAP_ADDR)->im_sit.sit_rtc = time; - ((immap_t *)IMAP_ADDR)->im_sitk.sitk_rtck = ~KAPWR_KEY; - return(0); -} -#endif /* CONFIG_MBX */ - /* * This version of gettimeofday has microsecond resolution. */ @@ -203,199 +182,29 @@ __initfunc(void time_init(void)) { -#ifndef CONFIG_MBX + if (ppc_md.time_init != NULL) + { + ppc_md.time_init(); + } + if ((_get_PVR() >> 16) == 1) { /* 601 processor: dec counts down by 128 every 128ns */ decrementer_count = DECREMENTER_COUNT_601; count_period_num = COUNT_PERIOD_NUM_601; count_period_den = COUNT_PERIOD_DEN_601; + } else if (!smp_processor_id()) { + ppc_md.calibrate_decr(); } - switch (_machine) { - case _MACH_Pmac: - xtime.tv_sec = pmac_get_rtc_time(); - if ( (_get_PVR() >> 16) != 1 && (!smp_processor_id()) ) - pmac_calibrate_decr(); - if ( !smp_processor_id() ) - set_rtc_time = pmac_set_rtc_time; - break; - case _MACH_chrp: - chrp_time_init(); - xtime.tv_sec = chrp_get_rtc_time(); - if ((_get_PVR() >> 16) != 1) - chrp_calibrate_decr(); - set_rtc_time = chrp_set_rtc_time; - break; - case _MACH_prep: - xtime.tv_sec = prep_get_rtc_time(); - prep_calibrate_decr(); - set_rtc_time = prep_set_rtc_time; - break; -#ifdef CONFIG_APUS - case _MACH_apus: - { - xtime.tv_sec = apus_get_rtc_time(); - apus_calibrate_decr(); - set_rtc_time = apus_set_rtc_time; - break; - } -#endif - } - xtime.tv_usec = 0; -#else /* CONFIG_MBX */ - mbx_calibrate_decr(); - set_rtc_time = mbx_set_rtc_time; - - /* First, unlock all of the registers we are going to modify. - * To protect them from corruption during power down, registers - * that are maintained by keep alive power are "locked". To - * modify these registers we have to write the key value to - * the key location associated with the register. - */ - ((immap_t *)IMAP_ADDR)->im_sitk.sitk_tbscrk = KAPWR_KEY; - ((immap_t *)IMAP_ADDR)->im_sitk.sitk_rtcsck = KAPWR_KEY; - - - /* Disable the RTC one second and alarm interrupts. - */ - ((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc &= - ~(RTCSC_SIE | RTCSC_ALE); - - /* Enabling the decrementer also enables the timebase interrupts - * (or from the other point of view, to get decrementer interrupts - * we have to enable the timebase). The decrementer interrupt - * is wired into the vector table, nothing to do here for that. - */ - ((immap_t *)IMAP_ADDR)->im_sit.sit_tbscr = - ((mk_int_int_mask(DEC_INTERRUPT) << 8) | - (TBSCR_TBF | TBSCR_TBE)); - if (request_irq(DEC_INTERRUPT, timebase_interrupt, 0, "tbint", NULL) != 0) - panic("Could not allocate timer IRQ!"); - - /* Get time from the RTC. - */ - xtime.tv_sec = ((immap_t *)IMAP_ADDR)->im_sit.sit_rtc; - xtime.tv_usec = 0; + xtime.tv_sec = ppc_md.get_rtc_time(); + xtime.tv_usec = 0; -#endif /* CONFIG_MBX */ set_dec(decrementer_count); /* mark the rtc/on-chip timer as in sync * so we don't update right away */ last_rtc_update = xtime.tv_sec; } - -#ifndef CONFIG_MBX -/* - * Uses the on-board timer to calibrate the on-chip decrementer register - * for prep systems. On the pmac the OF tells us what the frequency is - * but on prep we have to figure it out. - * -- Cort - */ -int calibrate_done = 0; -volatile int *done_ptr = &calibrate_done; -__initfunc(void prep_calibrate_decr(void)) -{ - unsigned long flags; - unsigned long freq, divisor; - - /* the Powerstack II's have trouble with the timer so - * we use a default value -- Cort - */ - if ( (_prep_type == _PREP_Motorola) && - ((inb(0x800) & 0xF0) & 0x40) ) - { - static unsigned long t2 = 0; - - t2 = 998700000/60; - freq = t2 * 60; /* try to make freq/1e6 an integer */ - divisor = 60; - printk("time_init: decrementer frequency = %lu/%lu (%luMHz)\n", - freq, divisor,t2>>20); - decrementer_count = freq / HZ / divisor; - count_period_num = divisor; - count_period_den = freq / 1000000; - return; - } - if ( _prep_type == _PREP_Radstone ) - { - freq = res->VitalProductData.ProcessorBusHz; - divisor = 4; - printk("time_init: decrementer frequency = %d/%d\n", freq, divisor); - decrementer_count = freq / HZ / divisor; - count_period_num = divisor; - count_period_den = freq / 1000000; - return; - } - - save_flags(flags); - -#define TIMER0_COUNT 0x40 -#define TIMER_CONTROL 0x43 - /* set timer to periodic mode */ - outb_p(0x34,TIMER_CONTROL);/* binary, mode 2, LSB/MSB, ch 0 */ - /* set the clock to ~100 Hz */ - outb_p(LATCH & 0xff , TIMER0_COUNT); /* LSB */ - outb(LATCH >> 8 , TIMER0_COUNT); /* MSB */ - - if (request_irq(0, prep_calibrate_decr_handler, 0, "timer", NULL) != 0) - panic("Could not allocate timer IRQ!"); - __sti(); - while ( ! *done_ptr ) /* nothing */; /* wait for calibrate */ - restore_flags(flags); - free_irq( 0, NULL); -} - -__initfunc(void prep_calibrate_decr_handler(int irq, void *dev, struct pt_regs * regs)) -{ - unsigned long freq, divisor; - static unsigned long t1 = 0, t2 = 0; - - if ( !t1 ) - t1 = get_dec(); - else if (!t2) - { - t2 = get_dec(); - t2 = t1-t2; /* decr's in 1/HZ */ - t2 = t2*HZ; /* # decrs in 1s - thus in Hz */ - freq = t2 * 60; /* try to make freq/1e6 an integer */ - divisor = 60; - printk("time_init: decrementer frequency = %lu/%lu (%luMHz)\n", - freq, divisor,t2>>20); - decrementer_count = freq / HZ / divisor; - count_period_num = divisor; - count_period_den = freq / 1000000; - *done_ptr = 1; - } -} - -#else /* CONFIG_MBX */ - -/* The decrementer counts at the system (internal) clock frequency divided by - * sixteen, or external oscillator divided by four. Currently, we only - * support the MBX, which is system clock divided by sixteen. - */ -__initfunc(void mbx_calibrate_decr(void)) -{ - bd_t *binfo = (bd_t *)res; - int freq, fp, divisor; - - if ((((immap_t *)IMAP_ADDR)->im_clkrst.car_sccr & 0x02000000) == 0) - printk("WARNING: Wrong decrementer source clock.\n"); - - /* The manual says the frequency is in Hz, but it is really - * as MHz. The value 'fp' is the number of decrementer ticks - * per second. - */ - fp = (binfo->bi_intfreq * 1000000) / 16; - freq = fp*60; /* try to make freq/1e6 an integer */ - divisor = 60; - printk("time_init: decrementer frequency = %d/%d\n", freq, divisor); - decrementer_count = freq / HZ / divisor; - count_period_num = divisor; - count_period_den = freq / 1000000; -} -#endif /* CONFIG_MBX */ /* Converts Gregorian date to seconds since 1970-01-01 00:00:00. * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/time.h linux/arch/ppc/kernel/time.h --- v2.2.7/linux/arch/ppc/kernel/time.h Thu Apr 23 20:21:29 1998 +++ linux/arch/ppc/kernel/time.h Thu Apr 29 12:39:01 1999 @@ -1,5 +1,5 @@ /* - * $Id: time.h,v 1.10 1998/04/01 07:46:03 geert Exp $ + * $Id: time.h,v 1.11 1999/03/18 04:16:34 cort Exp $ * Common time prototypes and such for all ppc machines. * * Written by Cort Dougan (cort@cs.nmt.edu) to merge @@ -9,32 +9,15 @@ #include /* time.c */ -void prep_calibrate_decr_handler(int, void *,struct pt_regs *); -void prep_calibrate_decr(void); -void pmac_calibrate_decr(void); -extern void apus_calibrate_decr(void); extern unsigned decrementer_count; extern unsigned count_period_num; extern unsigned count_period_den; -extern unsigned long mktime(unsigned int, unsigned int,unsigned int, +extern unsigned long mktime(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); extern void to_tm(int tim, struct rtc_time * tm); extern unsigned long last_rtc_update; -/* pmac/prep/chrp_time.c */ -unsigned long prep_get_rtc_time(void); -unsigned long pmac_get_rtc_time(void); -unsigned long chrp_get_rtc_time(void); -unsigned long apus_get_rtc_time(void); -int prep_set_rtc_time(unsigned long nowtime); -int pmac_set_rtc_time(unsigned long nowtime); -int chrp_set_rtc_time(unsigned long nowtime); -int apus_set_rtc_time(unsigned long nowtime); -void pmac_read_rtc_time(void); -void chrp_calibrate_decr(void); -void chrp_time_init(void); int via_calibrate_decr(void); -void mbx_calibrate_decr(void); /* Accessor functions for the decrementer register. */ static __inline__ unsigned int get_dec(void) diff -u --recursive --new-file v2.2.7/linux/arch/ppc/kernel/traps.c linux/arch/ppc/kernel/traps.c --- v2.2.7/linux/arch/ppc/kernel/traps.c Thu Jan 7 15:11:36 1999 +++ linux/arch/ppc/kernel/traps.c Thu Apr 29 12:39:01 1999 @@ -191,13 +191,8 @@ { int fixed; -#ifdef __SMP__ - if (regs->msr & MSR_FP ) - smp_giveup_fpu(current); -#else - if (last_task_used_math == current) - giveup_fpu(); -#endif + if (regs->msr & MSR_FP) + giveup_fpu(current); fixed = fix_alignment(regs); if (fixed == 1) { regs->nip += 4; /* skip over emulated instruction */ diff -u --recursive --new-file v2.2.7/linux/arch/ppc/lib/strcase.c linux/arch/ppc/lib/strcase.c --- v2.2.7/linux/arch/ppc/lib/strcase.c Sat Aug 16 09:51:08 1997 +++ linux/arch/ppc/lib/strcase.c Thu Apr 29 12:39:01 1999 @@ -10,3 +10,14 @@ } while (c1 == c2 && c1 != 0); return c1 - c2; } + +int strncasecmp(const char *s1, const char *s2, int n) +{ + int c1, c2; + + do { + c1 = tolower(*s1++); + c2 = tolower(*s2++); + } while ((--n > 0) && c1 == c2 && c1 != 0); + return c1 - c2; +} diff -u --recursive --new-file v2.2.7/linux/arch/ppc/mbxboot/head.S linux/arch/ppc/mbxboot/head.S --- v2.2.7/linux/arch/ppc/mbxboot/head.S Fri Apr 16 14:47:30 1999 +++ linux/arch/ppc/mbxboot/head.S Thu Apr 29 12:39:01 1999 @@ -6,7 +6,7 @@ .text /* - * $Id: head.S,v 1.2 1999/02/17 06:29:41 cort Exp $ + * $Id: head.S,v 1.4 1999/04/22 06:32:09 davem Exp $ * * This code is loaded by the ROM loader at some arbitrary location. * Move it to high memory so that it can load the kernel at 0x0000. @@ -67,7 +67,7 @@ mr r11, r21 lis r8,start@h ori r8,r8,start@l - li r9,end@h + lis r9,end@h ori r9,r9,end@l sub r7,r8,r9 srwi r7,r7,2 diff -u --recursive --new-file v2.2.7/linux/arch/ppc/mm/init.c linux/arch/ppc/mm/init.c --- v2.2.7/linux/arch/ppc/mm/init.c Tue Mar 23 14:35:46 1999 +++ linux/arch/ppc/mm/init.c Thu Apr 29 12:39:01 1999 @@ -1,5 +1,5 @@ - /* - * $Id: init.c,v 1.150 1999/03/10 08:16:33 cort Exp $ +/* + * $Id: init.c,v 1.163 1999/04/09 06:37:13 cort Exp $ * * PowerPC version * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) @@ -132,6 +132,8 @@ unsigned long limit; unsigned long phys; } bat_addrs[4]; +unsigned long inline v_mapped_by_bats(unsigned long); +unsigned long inline p_mapped_by_bats(unsigned long); #endif /* CONFIG_8xx */ /* @@ -144,6 +146,7 @@ /* optimization for 603 to load the tlb directly from the linux table -- Cort */ #define NO_RELOAD_HTAB 1 /* change in kernel/head.S too! */ + void __bad_pte(pmd_t *pmd) { printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd)); @@ -332,15 +335,42 @@ * virt == phys; for addresses below this we use * space going down from ioremap_base (ioremap_bot * records where we're up to). - * - * We should also look out for a frame buffer and - * map it with a free BAT register, if there is one. */ p = addr & PAGE_MASK; size = PAGE_ALIGN(addr + size) - p; + + /* + * Don't allow anybody to remap normal RAM that we're using. + * mem_init() sets high_memory so only do the check after that. + */ + if ( mem_init_done && (p < virt_to_phys(high_memory)) ) + { + printk("__ioremap(): phys addr %0lx is RAM lr %p\n", p, + __builtin_return_address(0)); + return NULL; + } + if (size == 0) return NULL; +#ifndef CONFIG_8xx +#if 0 + /* + * Is it already mapped? Perhaps overlapped by a previous + * BAT mapping. If the whole area is mapped then we're done, + * otherwise remap it since we want to keep the virt addrs for + * each request contiguous. + * + * We make the assumption here that if the bottom and top + * of the range we want are mapped then it's mapped to the + * same virt address (and this is contiguous). + * -- Cort + */ + if ( (v = p_mapped_by_bats(addr)) /*&& p_mapped_by_bats(addr+(size-1))*/ ) + goto out; +#endif +#endif /* CONFIG_8xx */ + if (mem_init_done) { struct vm_struct *area; area = get_vm_area(size); @@ -358,9 +388,15 @@ flags |= pgprot_val(PAGE_KERNEL); if (flags & (_PAGE_NO_CACHE | _PAGE_WRITETHRU)) flags |= _PAGE_GUARDED; + +#ifndef CONFIG_8xx + /* + * Is it a candidate for a BAT mapping? + */ +#endif /* CONFIG_8xx */ + for (i = 0; i < size; i += PAGE_SIZE) map_page(&init_task, v+i, p+i, flags); - return (void *) (v + (addr & ~PAGE_MASK)); } @@ -412,9 +448,7 @@ { pmd_t *pd; pte_t *pg; -#ifndef CONFIG_8xx - int b; -#endif + if (tsk->mm->pgd == NULL) { /* Allocate upper level page map */ tsk->mm->pgd = (pgd_t *) MMU_get_page(); @@ -422,20 +456,8 @@ /* Use upper 10 bits of VA to index the first level map */ pd = (pmd_t *) (tsk->mm->pgd + (va >> PGDIR_SHIFT)); if (pmd_none(*pd)) { -#ifndef CONFIG_8xx - /* - * Need to allocate second-level table, but first - * check whether this address is already mapped by - * the BATs; if so, don't bother allocating the page. - */ - for (b = 0; b < 4; ++b) { - if (va >= bat_addrs[b].start - && va <= bat_addrs[b].limit) { - /* XXX should check the phys address matches */ - return; - } - } -#endif /* CONFIG_8xx */ + if ( v_mapped_by_bats(va) ) + return; pg = (pte_t *) MMU_get_page(); pmd_val(*pd) = (unsigned long) pg; } @@ -680,6 +702,33 @@ static void sort_mem_pieces(struct mem_pieces *); static void coalesce_mem_pieces(struct mem_pieces *); +/* + * Return 1 if this VA is mapped by BATs + */ +unsigned long inline v_mapped_by_bats(unsigned long va) +{ + int b; + for (b = 0; b < 4; ++b) + if (va >= bat_addrs[b].start + && va < bat_addrs[b].limit) + return 1; + return 0; +} + +/* + * Return VA for a given PA or 0 if not mapped + */ +unsigned long inline p_mapped_by_bats(unsigned long pa) +{ + int b; + for (b = 0; b < 4; ++b) + if (pa >= bat_addrs[b].phys + && pa < (bat_addrs[b].limit-bat_addrs[b].start) + +bat_addrs[b].phys) + return bat_addrs[b].start+(pa-bat_addrs[b].phys); + return 0; +} + __initfunc(static void sort_mem_pieces(struct mem_pieces *mp)) { unsigned long a, s; @@ -836,7 +885,7 @@ setbat(2, KERNELBASE, mem_base, bl, RAM_PAGE); done = (unsigned long)bat_addrs[2].limit - KERNELBASE + 1; - if (done < tot) { + if ((done < tot) && !bat_addrs[3].limit) { /* use BAT3 to cover a bit more */ tot -= done; for (bl = 128<<10; bl < max_size; bl <<= 1) @@ -990,11 +1039,13 @@ switch (_machine) { case _MACH_prep: setbat(0, 0x80000000, 0x80000000, 0x10000000, IO_PAGE); - setbat(1, 0xd0000000, 0xc0000000, 0x10000000, IO_PAGE); + setbat(1, 0xf0000000, 0xc0000000, 0x08000000, IO_PAGE); + ioremap_base = 0xf0000000; break; case _MACH_chrp: setbat(0, 0xf8000000, 0xf8000000, 0x08000000, IO_PAGE); setbat(1, 0x80000000, 0x80000000, 0x10000000, IO_PAGE); + setbat(3, 0x90000000, 0x90000000, 0x10000000, IO_PAGE); break; case _MACH_Pmac: { @@ -1245,7 +1296,7 @@ int i; /* max amount of RAM we allow -- Cort */ -#define RAM_LIMIT (768<<20) +#define RAM_LIMIT (768<<20) memory_node = find_devices("memory"); if (memory_node == NULL) { @@ -1530,4 +1581,3 @@ } } #endif /* ndef CONFIG_8xx */ - diff -u --recursive --new-file v2.2.7/linux/arch/sparc64/kernel/ioctl32.c linux/arch/sparc64/kernel/ioctl32.c --- v2.2.7/linux/arch/sparc64/kernel/ioctl32.c Mon Mar 29 11:09:11 1999 +++ linux/arch/sparc64/kernel/ioctl32.c Wed Apr 28 14:40:07 1999 @@ -1,4 +1,4 @@ -/* $Id: ioctl32.c,v 1.60 1999/03/22 10:40:54 jj Exp $ +/* $Id: ioctl32.c,v 1.61 1999/04/28 19:44:31 davem Exp $ * ioctl32.c: Conversion between 32bit and 64bit native ioctls. * * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff -u --recursive --new-file v2.2.7/linux/drivers/block/Config.in linux/drivers/block/Config.in --- v2.2.7/linux/drivers/block/Config.in Thu Dec 31 10:28:59 1998 +++ linux/drivers/block/Config.in Thu Apr 29 12:53:48 1999 @@ -51,13 +51,15 @@ bool ' Winbond SL82c105 support' CONFIG_BLK_DEV_SL82C105 fi fi - if [ "$CONFIG_PMAC" = "y" ]; then - define_bool CONFIG_BLK_DEV_IDE_PMAC y - bool ' PowerMac IDE DMA support' CONFIG_BLK_DEV_IDEDMA_PMAC - if [ "$CONFIG_BLK_DEV_IDEDMA_PMAC" = "y" ]; then - define_bool CONFIG_BLK_DEV_IDEDMA y - bool ' Use DMA by default' CONFIG_PMAC_IDEDMA_AUTO - fi + if [ "$CONFIG_PMAC" = "y" -o "$CONFIG_ALL_PPC" = "y" ]; then + bool ' Builtin PowerMac IDE support' CONFIG_BLK_DEV_IDE_PMAC + if [ "$CONFIG_BLK_DEV_IDE_PMAC" != "n" ]; then + bool ' PowerMac IDE DMA support' CONFIG_BLK_DEV_IDEDMA_PMAC + if [ "$CONFIG_BLK_DEV_IDEDMA_PMAC" = "y" ]; then + define_bool CONFIG_BLK_DEV_IDEDMA y + bool ' Use DMA by default' CONFIG_PMAC_IDEDMA_AUTO + fi + fi fi bool ' Other IDE chipset support' CONFIG_IDE_CHIPSETS if [ "$CONFIG_IDE_CHIPSETS" = "y" ]; then diff -u --recursive --new-file v2.2.7/linux/drivers/block/ide.c linux/drivers/block/ide.c --- v2.2.7/linux/drivers/block/ide.c Tue Mar 23 14:35:47 1999 +++ linux/drivers/block/ide.c Mon May 3 09:34:51 1999 @@ -813,7 +813,7 @@ ide_end_drive_cmd(drive, stat, err); return; } - if (stat & BUSY_STAT) { /* other bits are useless when BUSY */ + if (stat & BUSY_STAT || ((stat & WRERR_STAT) && !drive->nowerr)) { /* other bits are useless when BUSY */ rq->errors |= ERROR_RESET; } else { if (drive->media == ide_disk && (stat & ERR_STAT)) { diff -u --recursive --new-file v2.2.7/linux/drivers/block/rd.c linux/drivers/block/rd.c --- v2.2.7/linux/drivers/block/rd.c Wed Apr 28 11:37:30 1999 +++ linux/drivers/block/rd.c Thu Apr 29 11:53:41 1999 @@ -33,11 +33,13 @@ * * 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 * + * Make block size and block size shift for RAM disks a global macro + * and set blk_size for -ENOSPC, Werner Fink , Apr '99 */ #include @@ -47,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -70,6 +73,15 @@ #define MAJOR_NR RAMDISK_MAJOR #include +/* + * We use a block size of 512 bytes in comparision to BLOCK_SIZE + * defined in include/linux/blk.h. This because of the finer + * granularity for filling up a RAM disk. + */ +#define RDBLK_SIZE_BITS 9 +#define RDBLK_SIZE (1<rq_dev); @@ -132,14 +149,20 @@ goto repeat; } - offset = CURRENT->sector << 9; - len = CURRENT->current_nr_sectors << 9; + offset = CURRENT->sector << RDBLK_SIZE_BITS; + len = CURRENT->current_nr_sectors << RDBLK_SIZE_BITS; if ((offset + len) > rd_length[minor]) { end_request(0); goto repeat; } + if ((CURRENT->cmd != READ) && (CURRENT->cmd != WRITE)) { + printk(KERN_INFO "RAMDISK: bad command: %d\n", CURRENT->cmd); + end_request(0); + goto repeat; + } + /* * If we're reading, fill the buffer with 0's. This is okay since * we're using protected buffers which should never get freed... @@ -158,24 +181,31 @@ static int rd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { + unsigned int minor; + if (!inode || !inode->i_rdev) return -EINVAL; + minor = MINOR(inode->i_rdev); + switch (cmd) { case BLKFLSBUF: if (!capable(CAP_SYS_ADMIN)) return -EACCES; invalidate_buffers(inode->i_rdev); break; + case BLKGETSIZE: /* Return device size */ if (!arg) return -EINVAL; - return put_user(rd_length[MINOR(inode->i_rdev)] / 512, - (long *) arg); - case BLKSSZGET: - /* Block size of media */ - return put_user(rd_blocksizes[MINOR(inode->i_rdev)], - (int *)arg); + return put_user(rd_length[minor] >> RDBLK_SIZE_BITS, (long *) arg); + + case BLKSSZGET: /* Block size of media */ + if (!arg) return -EINVAL; + return put_user(rd_blocksizes[minor], (int *)arg); + + RO_IOCTLS(inode->i_rdev, arg); + default: - break; + return -EINVAL; }; return 0; @@ -263,7 +293,7 @@ rd_open, /* open */ NULL, /* flush */ rd_release, /* module needs to decrement use count */ - block_fsync /* fsync */ + block_fsync /* fsync */ }; /* This is the registration and initialization section of the RAM disk driver */ @@ -279,11 +309,16 @@ blk_dev[MAJOR_NR].request_fn = &rd_request; for (i = 0; i < NUM_RAMDISKS; i++) { - rd_length[i] = (rd_size * 1024); - rd_blocksizes[i] = 1024; + /* rd_size is given in kB */ + rd_length[i] = (rd_size << BLOCK_SIZE_BITS); + rd_hardsec[i] = RDBLK_SIZE; + rd_blocksizes[i] = BLOCK_SIZE; + rd_kbsize[i] = (rd_length[i] >> BLOCK_SIZE_BITS); } - blksize_size[MAJOR_NR] = rd_blocksizes; + hardsect_size[MAJOR_NR] = rd_hardsec; /* Size of the RAM disk blocks */ + blksize_size[MAJOR_NR] = rd_blocksizes; /* Avoid set_blocksize() check */ + blk_size[MAJOR_NR] = rd_kbsize; /* Size of the RAM disk in kB */ printk("RAM disk driver initialized: %d RAM disks of %dK size\n", NUM_RAMDISKS, rd_size); @@ -295,7 +330,8 @@ #ifdef MODULE -MODULE_PARM (rd_size, "1i"); +MODULE_PARM (rd_size, "1i"); +MODULE_PARM_DESC(rd_size, "Size of each RAM disk."); int init_module(void) { @@ -427,7 +463,7 @@ /* * This routine loads in the RAM disk image. */ -__initfunc(static void rd_load_image(kdev_t device,int offset)) +__initfunc(static void rd_load_image(kdev_t device, int offset, int unit)) { struct inode inode, out_inode; struct file infile, outfile; @@ -440,7 +476,7 @@ unsigned short devblocks = 0; char rotator[4] = { '|' , '/' , '-' , '\\' }; - ram_device = MKDEV(MAJOR_NR, 0); + ram_device = MKDEV(MAJOR_NR, unit); memset(&infile, 0, sizeof(infile)); memset(&inode, 0, sizeof(inode)); @@ -480,9 +516,9 @@ goto done; } - if (nblocks > (rd_length[0] >> BLOCK_SIZE_BITS)) { + if (nblocks > (rd_length[unit] >> RDBLK_SIZE_BITS)) { printk("RAMDISK: image too big! (%d/%d blocks)\n", - nblocks, rd_length[0] >> BLOCK_SIZE_BITS); + nblocks, rd_length[unit] >> RDBLK_SIZE_BITS); goto done; } @@ -538,7 +574,7 @@ successful_load: invalidate_buffers(device); - ROOT_DEV = MKDEV(MAJOR_NR,0); + ROOT_DEV = MKDEV(MAJOR_NR, unit); done: if (infile.f_op->release) @@ -547,12 +583,21 @@ } -__initfunc(void rd_load(void)) +__initfunc(static void rd_load_disk(int n)) { +#ifdef CONFIG_BLK_DEV_INITRD + extern kdev_t real_root_dev; +#endif + if (rd_doload == 0) return; - - if (MAJOR(ROOT_DEV) != FLOPPY_MAJOR) return; + + if (MAJOR(ROOT_DEV) != FLOPPY_MAJOR +#ifdef CONFIG_BLK_DEV_INITRD + && MAJOR(real_root_dev) != FLOPPY_MAJOR +#endif + ) + return; if (rd_prompt) { #ifdef CONFIG_BLK_DEV_FD @@ -563,15 +608,24 @@ wait_for_keypress(); } - rd_load_image(ROOT_DEV,rd_image_start); + rd_load_image(ROOT_DEV,rd_image_start, n); } +__initfunc(void rd_load(void)) +{ + rd_load_disk(0); +} + +__initfunc(void rd_load_secondary(void)) +{ + rd_load_disk(1); +} #ifdef CONFIG_BLK_DEV_INITRD __initfunc(void initrd_load(void)) { - rd_load_image(MKDEV(MAJOR_NR, INITRD_MINOR),0); + rd_load_image(MKDEV(MAJOR_NR, INITRD_MINOR),0,0); } #endif @@ -695,7 +749,14 @@ crd_load(struct file * fp, struct file *outfp)) { int result; - + + insize = 0; /* valid bytes in inbuf */ + inptr = 0; /* index of next byte to be processed in inbuf */ + outcnt = 0; /* bytes in output buffer */ + exit_code = 0; + bytes_out = 0; + crc = (ulg)0xffffffffL; /* shift register contents */ + crd_infp = fp; crd_outfp = outfp; inbuf = kmalloc(INBUFSIZ, GFP_KERNEL); diff -u --recursive --new-file v2.2.7/linux/drivers/cdrom/cdrom.c linux/drivers/cdrom/cdrom.c --- v2.2.7/linux/drivers/cdrom/cdrom.c Tue Mar 23 14:35:47 1999 +++ linux/drivers/cdrom/cdrom.c Thu Apr 29 11:53:41 1999 @@ -120,11 +120,16 @@ 2.54 Mar 15, 1999 - Jens Axboe -- Check capability mask from low level driver when counting tracks as per suggestion from Corey J. Scotts . + + 2.55 Apr 25, 1999 - Jens Axboe + -- autoclose was mistakenly checked against CDC_OPEN_TRAY instead of + CDC_CLOSE_TRAY. + -- proc info didn't mask against capabilities mask. -------------------------------------------------------------------------*/ -#define REVISION "Revision: 2.54" -#define VERSION "Id: cdrom.c 2.54 1999/03/15" +#define REVISION "Revision: 2.55" +#define VERSION "Id: cdrom.c 2.55 1999/04/25" /* I use an error-log mask to give fine grain control over the type of messages dumped to the system logs. The available masks include: */ @@ -268,7 +273,7 @@ cdo->n_minors = 0; cdi->options = CDO_USE_FFLAGS; - if (autoclose==1 && cdo->capability & ~cdi->mask & CDC_OPEN_TRAY) + if (autoclose==1 && cdo->capability & ~cdi->mask & CDC_CLOSE_TRAY) cdi->options |= (int) CDO_AUTO_CLOSE; if (autoeject==1 && cdo->capability & ~cdi->mask & CDC_OPEN_TRAY) cdi->options |= (int) CDO_AUTO_EJECT; @@ -1097,27 +1102,27 @@ pos += sprintf(cdrom_drive_info+pos, "\nCan close tray:\t"); for (cdi=topCdromPtr;cdi!=NULL;cdi=cdi->next) pos += sprintf(cdrom_drive_info+pos, "\t%d", - ((cdi->ops->capability & CDC_CLOSE_TRAY)!=0)); + ((cdi->ops->capability & ~cdi->mask & CDC_CLOSE_TRAY)!=0)); pos += sprintf(cdrom_drive_info+pos, "\nCan open tray:\t"); for (cdi=topCdromPtr;cdi!=NULL;cdi=cdi->next) pos += sprintf(cdrom_drive_info+pos, "\t%d", - ((cdi->ops->capability & CDC_OPEN_TRAY)!=0)); + ((cdi->ops->capability & ~cdi->mask & CDC_OPEN_TRAY)!=0)); pos += sprintf(cdrom_drive_info+pos, "\nCan lock tray:\t"); for (cdi=topCdromPtr;cdi!=NULL;cdi=cdi->next) pos += sprintf(cdrom_drive_info+pos, "\t%d", - ((cdi->ops->capability & CDC_LOCK)!=0)); + ((cdi->ops->capability & ~cdi->mask & CDC_LOCK)!=0)); pos += sprintf(cdrom_drive_info+pos, "\nCan change speed:"); for (cdi=topCdromPtr;cdi!=NULL;cdi=cdi->next) pos += sprintf(cdrom_drive_info+pos, "\t%d", - ((cdi->ops->capability & CDC_SELECT_SPEED)!=0)); + ((cdi->ops->capability & ~cdi->mask & CDC_SELECT_SPEED)!=0)); pos += sprintf(cdrom_drive_info+pos, "\nCan select disk:"); for (cdi=topCdromPtr;cdi!=NULL;cdi=cdi->next) pos += sprintf(cdrom_drive_info+pos, "\t%d", - ((cdi->ops->capability & CDC_SELECT_DISC)!=0)); + ((cdi->ops->capability & ~cdi->mask & CDC_SELECT_DISC)!=0)); pos += sprintf(cdrom_drive_info+pos, "\nCan read multisession:"); for (cdi=topCdromPtr;cdi!=NULL;cdi=cdi->next) @@ -1137,7 +1142,7 @@ pos += sprintf(cdrom_drive_info+pos, "\nCan play audio:\t"); for (cdi=topCdromPtr;cdi!=NULL;cdi=cdi->next) pos += sprintf(cdrom_drive_info+pos, "\t%d", - ((cdi->ops->capability & CDC_PLAY_AUDIO)!=0)); + ((cdi->ops->capability & ~cdi->mask & CDC_PLAY_AUDIO)!=0)); strcpy(cdrom_drive_info+pos,"\n\n"); *lenp=pos+3; diff -u --recursive --new-file v2.2.7/linux/drivers/cdrom/mcdx.h linux/drivers/cdrom/mcdx.h --- v2.2.7/linux/drivers/cdrom/mcdx.h Wed Jan 20 23:14:05 1999 +++ linux/drivers/cdrom/mcdx.h Thu Apr 29 11:53:41 1999 @@ -176,8 +176,10 @@ #define MCDX_ST_DRV 0x00ff /* mask to query the drive status */ #ifndef I_WAS_HERE +#ifndef MODULE #warning You have not edited mcdx.h #warning Perhaps irq and i/o settings are wrong. +#endif #endif /* ex:set ts=4 sw=4: */ diff -u --recursive --new-file v2.2.7/linux/drivers/char/Config.in linux/drivers/char/Config.in --- v2.2.7/linux/drivers/char/Config.in Fri Apr 16 14:47:30 1999 +++ linux/drivers/char/Config.in Fri May 7 11:05:30 1999 @@ -137,6 +137,9 @@ dep_tristate 'Colour QuickCam Video For Linux (EXPERIMENTAL)' CONFIG_VIDEO_CQCAM $CONFIG_VIDEO_DEV $CONFIG_PARPORT fi dep_tristate 'Mediavision Pro Movie Studio Video For Linux' CONFIG_VIDEO_PMS $CONFIG_VIDEO_DEV + if [ "$CONFIG_PMAC" = "y" ]; then + dep_tristate 'PlanB Video-In on PowerMac' CONFIG_VIDEO_PLANB $CONFIG_VIDEO_DEV + fi dep_tristate 'SAA5249 Teletext processor' CONFIG_VIDEO_SAA5249 $CONFIG_VIDEO_DEV dep_tristate 'SF16FMI Radio' CONFIG_RADIO_SF16FMI $CONFIG_VIDEO_DEV if [ "$CONFIG_RADIO_SF16FMI" = "y" ]; then diff -u --recursive --new-file v2.2.7/linux/drivers/char/Makefile linux/drivers/char/Makefile --- v2.2.7/linux/drivers/char/Makefile Wed Apr 28 11:37:30 1999 +++ linux/drivers/char/Makefile Fri May 7 11:05:30 1999 @@ -283,12 +283,12 @@ endif ifeq ($(CONFIG_NVRAM),y) - ifeq ($(CONFIG_PMAC)$(CONFIG_CHRP),) + ifeq ($(CONFIG_PPC),) L_OBJS += nvram.o endif else ifeq ($(CONFIG_NVRAM),m) - ifeq ($(CONFIG_PMAC)$(CONFIG_CHRP),) + ifeq ($(CONFIG_PPC),) M_OBJS += nvram.o endif endif @@ -351,6 +351,14 @@ else ifeq ($(CONFIG_VIDEO_PMS),m) M_OBJS += pms.o + endif +endif + +ifeq ($(CONFIG_VIDEO_PLANB),y) +L_OBJS += planb.o +else + ifeq ($(CONFIG_VIDEO_PLANB),m) + M_OBJS += planb.o endif endif diff -u --recursive --new-file v2.2.7/linux/drivers/char/adbmouse.c linux/drivers/char/adbmouse.c --- v2.2.7/linux/drivers/char/adbmouse.c Thu Nov 19 09:56:28 1998 +++ linux/drivers/char/adbmouse.c Thu Apr 29 12:53:48 1999 @@ -113,7 +113,7 @@ * on a logitech mouseman, the right and mid buttons sometimes behave * strangely until they both have been pressed after booting. */ /* data valid only if extended mouse format ! */ - if (nb == 4) + if (nb >= 4) buttons = (buttons&6) | (buf[3] & 0x80 ? 1 : 0); /* 1+3 unchanged */ add_mouse_randomness(((~buttons&7) << 16) + ((buf[2]&0x7f) << 8) + (buf[1]&0x7f)); diff -u --recursive --new-file v2.2.7/linux/drivers/char/isicom.c linux/drivers/char/isicom.c --- v2.2.7/linux/drivers/char/isicom.c Fri Apr 16 14:47:30 1999 +++ linux/drivers/char/isicom.c Fri May 7 11:05:30 1999 @@ -13,6 +13,23 @@ * (fixed range check bug as a side effect) * Printk clean up * 9/12/98 alan@redhat.com Rough port to 2.1.x + * + * + * *********************************************************** + * + * To use this driver you also need the support package. You + * can find this in RPM format on + * ftp://ftp.linux.org.uk/pub/linux/alan + * + * You can find the original tools for this direct from Multitech + * ftp://ftp.multitech.com/ISI-Cards/ + * + * Having installed the cards the module options (/etc/conf.modules) + * + * options isicom io=card1,card2,card3,card4 irq=card1,card2,card3,card4 + * + * Omit those entries for boards you don't have installed. + * */ #include diff -u --recursive --new-file v2.2.7/linux/drivers/char/mem.c linux/drivers/char/mem.c --- v2.2.7/linux/drivers/char/mem.c Wed Apr 28 11:37:30 1999 +++ linux/drivers/char/mem.c Thu Apr 29 18:10:00 1999 @@ -605,11 +605,13 @@ if (register_chrdev(MEM_MAJOR,"mem",&memory_fops)) printk("unable to get major %d for memory devs\n", MEM_MAJOR); rand_initialize(); +#ifdef CONFIG_USB #ifdef CONFIG_USB_UHCI uhci_init(); #endif #ifdef CONFIG_USB_OHCI ohci_init(); +#endif #endif #if defined (CONFIG_FB) fbmem_init(); diff -u --recursive --new-file v2.2.7/linux/drivers/char/planb.c linux/drivers/char/planb.c --- v2.2.7/linux/drivers/char/planb.c Wed Dec 31 16:00:00 1969 +++ linux/drivers/char/planb.c Fri May 7 11:05:30 1999 @@ -0,0 +1,2390 @@ +/* + planb - PlanB frame grabber driver + + PlanB is used in the 7x00/8x00 series of PowerMacintosh + Computers as video input DMA controller. + + Copyright (C) 1998 Michel Lanners (mlan@cpu.lu) + + Based largely on the bttv driver by Ralph Metzler (rjkm@thp.uni-koeln.de) + + Additional debugging and coding by Takashi Oe (toe@unlinfo.unl.edu) + (Some codes are stolen from proposed v4l2 videodev.c + of Bill Dirks ) + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* $Id: planb.c,v 1.18 1999/05/02 17:36:34 mlan Exp $ */ + +#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 "planb.h" +#include "saa7196.h" + + +/* Would you mind for some ugly debugging? */ +//#define DEBUG(x...) printk(KERN_DEBUG ## x) /* Debug driver */ +#define DEBUG(x...) /* Don't debug driver */ +//#define IDEBUG(x...) printk(KERN_DEBUG ## x) /* Debug interrupt part */ +#define IDEBUG(x...) /* Don't debug interrupt part */ + +/* Ever seen a Mac with more than 1 of these? */ +#define PLANB_MAX 1 + +static int planb_num; +static struct planb planbs[PLANB_MAX]; +static volatile struct planb_registers *planb_regs; + +static int def_norm = PLANB_DEF_NORM; /* default norm */ + +MODULE_PARM(def_norm, "i"); +MODULE_PARM_DESC(def_norm, "Default startup norm (0=PAL, 1=NTSC, 2=SECAM)"); + +/* ------------------ PlanB Exported Functions ------------------ */ +static long planb_write(struct video_device *, const char *, unsigned long, int); +static long planb_read(struct video_device *, char *, unsigned long, int); +static int planb_open(struct video_device *, int); +static void planb_close(struct video_device *); +static int planb_ioctl(struct video_device *, unsigned int, void *); +static int planb_init_done(struct video_device *); +static int planb_mmap(struct video_device *, const char *, unsigned long); +static void planb_irq(int, void *, struct pt_regs *); +static void release_planb(void); +int init_planbs(struct video_init *); + +/* ------------------ PlanB Internal Functions ------------------ */ +static int planb_prepare_open(struct planb *); +static void planb_prepare_close(struct planb *); +static void saa_write_reg(unsigned char, unsigned char); +static unsigned char saa_status(int, struct planb *); +static void saa_set(unsigned char, unsigned char, struct planb *); +static void saa_init_regs(struct planb *); +static void * rvmalloc(unsigned long); +static void rvfree(void *, unsigned long); +static unsigned long vmalloc_to_bus(void *); +static unsigned long vmalloc_to_phys(void *); +static int fbuffer_alloc(struct planb *); +static int vgrab(struct planb *, struct video_mmap *); +static void add_clip(struct planb *, struct video_clip *); +static void fill_cmd_buff(struct planb *); +static void cmd_buff(struct planb *); +static volatile struct dbdma_cmd *setup_grab_cmd(int, struct planb *); +static void overlay_start(struct planb *); +static void overlay_stop(struct planb *); +static inline void tab_cmd_dbdma(volatile struct dbdma_cmd *, unsigned short, + unsigned int); +static inline void tab_cmd_store(volatile struct dbdma_cmd *, unsigned int, + unsigned int); +static inline void tab_cmd_gen(volatile struct dbdma_cmd *, unsigned short, + unsigned short, unsigned int, unsigned int); +static int init_planb(struct planb *); +static int find_planb(void); +static void planb_pre_capture(int, int, struct planb *); +static volatile struct dbdma_cmd *cmd_geo_setup(volatile struct dbdma_cmd *, + int, int, int, int, int, struct planb *); +static inline void planb_dbdma_stop(volatile struct dbdma_regs *); +static unsigned int saa_geo_setup(int, int, int, int, struct planb *); +static inline int overlay_is_active(struct planb *); + +/*******************************/ +/* Memory management functions */ +/*******************************/ + +static void * rvmalloc(unsigned long size) +{ + void *mem, *memptr; + unsigned long page; + + mem=vmalloc(size); + if (mem) + { + memset(mem, 0, size); /* Clear the ram out, leave no junk */ + memptr = mem; + while (size > 0) + { + page = vmalloc_to_phys(memptr); + mem_map_reserve(MAP_NR(phys_to_virt(page))); + memptr+=PAGE_SIZE; + size-=PAGE_SIZE; + } + } + return mem; +} + +static void rvfree(void * mem, unsigned long size) +{ + void *memptr; + unsigned long page; + + if (mem) + { + memptr = mem; + while (size > 0) + { + page = vmalloc_to_phys(memptr); + mem_map_unreserve(MAP_NR(phys_to_virt(page))); + memptr += PAGE_SIZE; + size-=PAGE_SIZE; + } + vfree(mem); + } +} + +/* Useful for using vmalloc()ed memory as DMA target */ +static unsigned long vmalloc_to_bus(void *virt) +{ + pgd_t *pgd; + pmd_t *pmd; + pte_t *pte; + unsigned long a = (unsigned long)virt; + + if (pgd_none(*(pgd = pgd_offset(current->mm, a))) || + pmd_none(*(pmd = pmd_offset(pgd, a))) || + pte_none(*(pte = pte_offset(pmd, a)))) + return 0; + return virt_to_bus((void *)pte_page(*pte)) + + (a & (PAGE_SIZE - 1)); +} + +static unsigned long vmalloc_to_phys(void *virt) { + return virt_to_phys(bus_to_virt(vmalloc_to_bus(virt))); +} + +/* + * Create the giant waste of buffer space we need for now + * until we get DMA to user space sorted out (probably 2.3.x) + * + * We only create this as and when someone uses mmap + */ + +static int fbuffer_alloc(struct planb *pb) +{ + if(!pb->fbuffer) + pb->fbuffer=(unsigned char *) rvmalloc(MAX_GBUFFERS + * PLANB_MAX_FBUF); + else + printk(KERN_ERR "PlanB: Double alloc of fbuffer!\n"); + if(!pb->fbuffer) + return -ENOBUFS; + return 0; +} + +/*****************************/ +/* Hardware access functions */ +/*****************************/ + +static void saa_write_reg(unsigned char addr, unsigned char val) +{ + planb_regs->saa_addr = addr; eieio(); + planb_regs->saa_regval = val; eieio(); + return; +} + +/* return status byte 0 or 1: */ +static unsigned char saa_status(int byte, struct planb *pb) +{ + saa_regs[pb->win.norm][SAA7196_STDC] = + (saa_regs[pb->win.norm][SAA7196_STDC] & ~2) | ((byte & 1) << 1); + saa_write_reg (SAA7196_STDC, saa_regs[pb->win.norm][SAA7196_STDC]); + + /* Let's wait 30msec for this one */ + current->state = TASK_INTERRUPTIBLE; +#if LINUX_VERSION_CODE >= 0x02017F + schedule_timeout(30 * HZ / 1000); +#else + current->timeout = jiffies + 30 * HZ / 1000; /* 30 ms */; + schedule(); +#endif + + return (unsigned char)in_8 (&planb_regs->saa_status); +} + +static void saa_set(unsigned char addr, unsigned char val, struct planb *pb) +{ + if(saa_regs[pb->win.norm][addr] != val) { + saa_regs[pb->win.norm][addr] = val; + saa_write_reg (addr, val); + } + return; +} + +static void saa_init_regs(struct planb *pb) +{ + int i; + + for (i = 0; i < SAA7196_NUMREGS; i++) + saa_write_reg (i, saa_regs[pb->win.norm][i]); +} + +static unsigned int saa_geo_setup(int width, int height, int interlace, int bpp, + struct planb *pb) +{ + int ht, norm = pb->win.norm; + + switch(bpp) { + case 2: + /* RGB555+a 1x16-bit + 16-bit transparent */ + saa_regs[norm][SAA7196_FMTS] &= ~0x3; + break; + case 1: + case 4: + /* RGB888 1x24-bit + 8-bit transparent */ + saa_regs[norm][SAA7196_FMTS] &= ~0x1; + saa_regs[norm][SAA7196_FMTS] |= 0x2; + break; + default: + return -EINVAL; + } + ht = (interlace ? height / 2 : height); + saa_regs[norm][SAA7196_OUTPIX] = (unsigned char) (width & 0x00ff); + saa_regs[norm][SAA7196_HFILT] = (saa_regs[norm][SAA7196_HFILT] & ~0x3) + | (width >> 8 & 0x3); + saa_regs[norm][SAA7196_OUTLINE] = (unsigned char) (ht & 0xff); + saa_regs[norm][SAA7196_VYP] = (saa_regs[norm][SAA7196_VYP] & ~0x3) + | (ht >> 8 & 0x3); + /* feed both fields if interlaced, or else feed only even fields */ + saa_regs[norm][SAA7196_FMTS] = (interlace) ? + (saa_regs[norm][SAA7196_FMTS] & ~0x60) + : (saa_regs[norm][SAA7196_FMTS] | 0x60); + /* transparent mode; extended format enabled */ + saa_regs[norm][SAA7196_DPATH] |= 0x3; + + return 0; +} + +/***************************/ +/* DBDMA support functions */ +/***************************/ + +static inline void planb_dbdma_restart(volatile struct dbdma_regs *ch) +{ + out_le32(&ch->control, PLANB_CLR(RUN)); + out_le32(&ch->control, PLANB_SET(RUN|WAKE) | PLANB_CLR(PAUSE)); +} + +static inline void planb_dbdma_stop(volatile struct dbdma_regs *ch) +{ + int i = 0; + + out_le32(&ch->control, PLANB_CLR(RUN) | PLANB_SET(FLUSH)); + while((in_le32(&ch->status) == (ACTIVE | FLUSH)) && (i < 999)) { + IDEBUG("PlanB: waiting for DMA to stop\n"); + i++; + } +} + +static inline void tab_cmd_dbdma(volatile struct dbdma_cmd *ch, + unsigned short command, unsigned int cmd_dep) +{ + st_le16(&ch->command, command); + st_le32(&ch->cmd_dep, cmd_dep); +} + +static inline void tab_cmd_store(volatile struct dbdma_cmd *ch, + unsigned int phy_addr, unsigned int cmd_dep) +{ + st_le16(&ch->command, STORE_WORD | KEY_SYSTEM); + st_le16(&ch->req_count, 4); + st_le32(&ch->phy_addr, phy_addr); + st_le32(&ch->cmd_dep, cmd_dep); +} + +static inline void tab_cmd_gen(volatile struct dbdma_cmd *ch, + unsigned short command, unsigned short req_count, + unsigned int phy_addr, unsigned int cmd_dep) +{ + st_le16(&ch->command, command); + st_le16(&ch->req_count, req_count); + st_le32(&ch->phy_addr, phy_addr); + st_le32(&ch->cmd_dep, cmd_dep); +} + +static volatile struct dbdma_cmd *cmd_geo_setup( + volatile struct dbdma_cmd *c1, int width, int height, int interlace, + int bpp, int clip, struct planb *pb) +{ + int norm = pb->win.norm; + + if((saa_geo_setup(width, height, interlace, bpp, pb)) != 0) + return (volatile struct dbdma_cmd *)NULL; + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_addr), + SAA7196_FMTS); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_regval), + saa_regs[norm][SAA7196_FMTS]); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_addr), + SAA7196_DPATH); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_regval), + saa_regs[norm][SAA7196_DPATH]); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->even), + bpp | ((clip)? PLANB_CLIPMASK: 0)); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->odd), + bpp | ((clip)? PLANB_CLIPMASK: 0)); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_addr), + SAA7196_OUTPIX); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_regval), + saa_regs[norm][SAA7196_OUTPIX]); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_addr), + SAA7196_HFILT); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_regval), + saa_regs[norm][SAA7196_HFILT]); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_addr), + SAA7196_OUTLINE); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_regval), + saa_regs[norm][SAA7196_OUTLINE]); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_addr), + SAA7196_VYP); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_regval), + saa_regs[norm][SAA7196_VYP]); + return c1; +} + +/******************************/ +/* misc. supporting functions */ +/******************************/ + +static void __planb_wait(struct planb *pb) +{ + struct wait_queue wait = { current, NULL }; + + add_wait_queue(&pb->lockq, &wait); +repeat: + current->state = TASK_UNINTERRUPTIBLE; + if (pb->lock) { + schedule(); + goto repeat; + } + remove_wait_queue(&pb->lockq, &wait); + current->state = TASK_RUNNING; +} + +static inline void planb_wait(struct planb *pb) +{ + DEBUG("PlanB: planb_wait\n"); + if(pb->lock) + __planb_wait(pb); +} + +static inline void planb_lock(struct planb *pb) +{ + DEBUG("PlanB: planb_lock\n"); + if(pb->lock) + __planb_wait(pb); + pb->lock = 1; +} + +static inline void planb_unlock(struct planb *pb) +{ + DEBUG("PlanB: planb_unlock\n"); + pb->lock = 0; + wake_up(&pb->lockq); +} + +/***************/ +/* Driver Core */ +/***************/ + +static int planb_prepare_open(struct planb *pb) +{ + int i, size; + + /* allocate memory for two plus alpha command buffers (size: max lines, + plus 40 commands handling, plus 1 alignment), plus dummy command buf, + plus clipmask buffer, plus frame grabbing status */ + size = (pb->tab_size*(2+MAX_GBUFFERS*TAB_FACTOR)+1+MAX_GBUFFERS + * PLANB_DUMMY)*sizeof(struct dbdma_cmd) + +(PLANB_MAXLINES*((PLANB_MAXPIXELS+7)& ~7))/8 + +MAX_GBUFFERS*sizeof(unsigned int); + if ((pb->priv_space = kmalloc (size, GFP_KERNEL)) == 0) + return -ENOMEM; + memset ((void *) pb->priv_space, 0, size); + pb->overlay_last1 = pb->ch1_cmd = (volatile struct dbdma_cmd *) + DBDMA_ALIGN (pb->priv_space); + pb->overlay_last2 = pb->ch2_cmd = pb->ch1_cmd + pb->tab_size; + pb->ch1_cmd_phys = virt_to_bus(pb->ch1_cmd); + pb->cap_cmd[0] = pb->ch2_cmd + pb->tab_size; + pb->pre_cmd[0] = pb->cap_cmd[0] + pb->tab_size * TAB_FACTOR; + for (i = 1; i < MAX_GBUFFERS; i++) { + pb->cap_cmd[i] = pb->pre_cmd[i-1] + PLANB_DUMMY; + pb->pre_cmd[i] = pb->cap_cmd[i] + pb->tab_size * TAB_FACTOR; + } + pb->frame_stat=(volatile unsigned int *)(pb->pre_cmd[MAX_GBUFFERS-1] + + PLANB_DUMMY); + pb->mask = (unsigned char *)(pb->frame_stat+MAX_GBUFFERS); + + pb->fbuffer = (unsigned char *)rvmalloc(MAX_GBUFFERS * PLANB_MAX_FBUF); + if (!pb->fbuffer) { + kfree(pb->priv_space); + return -ENOMEM; + } + pb->grabbing = 0; + for (i = 0; i < MAX_GBUFFERS; i++) { + pb->frame_stat[i] = GBUFFER_UNUSED; + pb->gwidth[i] = 0; + pb->gheight[i] = 0; + pb->gfmt[i] = 0; + pb->gnorm_switch[i] = 0; +#ifndef PLANB_GSCANLINE + pb->lsize[i] = 0; + pb->lnum[i] = 0; + pb->l_fr_addr[i]=(unsigned char *)rvmalloc(PAGE_SIZE*MAX_LNUM); + if (!pb->l_fr_addr[i]) { + int j; + kfree(pb->priv_space); + rvfree((void *)pb->fbuffer, MAX_GBUFFERS + * PLANB_MAX_FBUF); + for(j = 0; j < i; j++) + rvfree((void *)pb->l_fr_addr[j], PAGE_SIZE + * MAX_LNUM); + return -ENOMEM; + } +#endif /* PLANB_GSCANLINE */ + } + pb->gcount = 0; + pb->suspend = 0; + pb->last_fr = -999; + pb->prev_last_fr = -999; + return 0; +} + +static void planb_prepare_close(struct planb *pb) +{ +#ifndef PLANB_GSCANLINE + int i; +#endif + + /* make sure the dma's are idle */ + planb_dbdma_stop(&pb->planb_base->ch2); + planb_dbdma_stop(&pb->planb_base->ch1); + /* free kernel memory of command buffers */ + if(pb->priv_space != 0) { + kfree (pb->priv_space); + pb->priv_space = 0; + pb->cmd_buff_inited = 0; + } + if(pb->fbuffer) + rvfree((void *)pb->fbuffer, MAX_GBUFFERS*PLANB_MAX_FBUF); + pb->fbuffer = NULL; +#ifndef PLANB_GSCANLINE + for(i = 0; i < MAX_GBUFFERS; i++) { + if(pb->l_fr_addr[i]) + rvfree((void *)pb->l_fr_addr[i], PAGE_SIZE * MAX_LNUM); + pb->l_fr_addr[i] = NULL; + } +#endif /* PLANB_GSCANLINE */ +} + +/*****************************/ +/* overlay support functions */ +/*****************************/ + +static void overlay_start(struct planb *pb) +{ + + DEBUG("PlanB: overlay_start()\n"); + + if(ACTIVE & in_le32(&pb->planb_base->ch1.status)) { + + DEBUG("PlanB: presumably, grabbing is in progress...\n"); + + planb_dbdma_stop(&pb->planb_base->ch2); + out_le32 (&pb->planb_base->ch2.cmdptr, + virt_to_bus(pb->ch2_cmd)); + planb_dbdma_restart(&pb->planb_base->ch2); + st_le16 (&pb->ch1_cmd->command, DBDMA_NOP); + tab_cmd_dbdma(pb->last_cmd[pb->last_fr], + DBDMA_NOP | BR_ALWAYS, + virt_to_bus(pb->ch1_cmd)); + eieio(); + pb->prev_last_fr = pb->last_fr; + pb->last_fr = -2; + if(!(ACTIVE & in_le32(&pb->planb_base->ch1.status))) { + IDEBUG("PlanB: became inactive " + "in the mean time... reactivating\n"); + planb_dbdma_stop(&pb->planb_base->ch1); + out_le32 (&pb->planb_base->ch1.cmdptr, + virt_to_bus(pb->ch1_cmd)); + planb_dbdma_restart(&pb->planb_base->ch1); + } + } else { + + DEBUG("PlanB: currently idle, so can do whatever\n"); + + planb_dbdma_stop(&pb->planb_base->ch2); + planb_dbdma_stop(&pb->planb_base->ch1); + st_le32 (&pb->planb_base->ch2.cmdptr, + virt_to_bus(pb->ch2_cmd)); + st_le32 (&pb->planb_base->ch1.cmdptr, + virt_to_bus(pb->ch1_cmd)); + out_le16 (&pb->ch1_cmd->command, DBDMA_NOP); + planb_dbdma_restart(&pb->planb_base->ch2); + planb_dbdma_restart(&pb->planb_base->ch1); + pb->last_fr = -1; + } + return; +} + +static void overlay_stop(struct planb *pb) +{ + DEBUG("PlanB: overlay_stop()\n"); + + if(pb->last_fr == -1) { + + DEBUG("PlanB: no grabbing, it seems...\n"); + + planb_dbdma_stop(&pb->planb_base->ch2); + planb_dbdma_stop(&pb->planb_base->ch1); + pb->last_fr = -999; + } else if(pb->last_fr == -2) { + unsigned int cmd_dep; + tab_cmd_dbdma(pb->cap_cmd[pb->prev_last_fr], DBDMA_STOP, 0); + eieio(); + cmd_dep = (unsigned int)in_le32(&pb->overlay_last1->cmd_dep); + if(overlay_is_active(pb)) { + + DEBUG("PlanB: overlay is currently active\n"); + + planb_dbdma_stop(&pb->planb_base->ch2); + planb_dbdma_stop(&pb->planb_base->ch1); + if(cmd_dep != pb->ch1_cmd_phys) { + out_le32(&pb->planb_base->ch1.cmdptr, + virt_to_bus(pb->overlay_last1)); + planb_dbdma_restart(&pb->planb_base->ch1); + } + } + pb->last_fr = pb->prev_last_fr; + pb->prev_last_fr = -999; + } + return; +} + +static void suspend_overlay(struct planb *pb) +{ + int fr = -1; + struct dbdma_cmd last; + + DEBUG("PlanB: suspend_overlay: %d\n", pb->suspend); + + if(pb->suspend++) + return; + if(ACTIVE & in_le32(&pb->planb_base->ch1.status)) { + if(pb->last_fr == -2) { + fr = pb->prev_last_fr; + memcpy(&last, (void*)pb->last_cmd[fr], sizeof(last)); + tab_cmd_dbdma(pb->last_cmd[fr], DBDMA_STOP, 0); + } + if(overlay_is_active(pb)) { + planb_dbdma_stop(&pb->planb_base->ch2); + planb_dbdma_stop(&pb->planb_base->ch1); + pb->suspended.overlay = 1; + pb->suspended.frame = fr; + memcpy(&pb->suspended.cmd, &last, sizeof(last)); + return; + } + } + pb->suspended.overlay = 0; + pb->suspended.frame = fr; + memcpy(&pb->suspended.cmd, &last, sizeof(last)); + return; +} + +static void resume_overlay(struct planb *pb) +{ + + DEBUG("PlanB: resume_overlay: %d\n", pb->suspend); + + if(pb->suspend > 1) + return; + if(pb->suspended.frame != -1) { + memcpy((void*)pb->last_cmd[pb->suspended.frame], + &pb->suspended.cmd, sizeof(pb->suspended.cmd)); + } + if(ACTIVE & in_le32(&pb->planb_base->ch1.status)) { + goto finish; + } + if(pb->suspended.overlay) { + + DEBUG("PlanB: overlay being resumed\n"); + + st_le16 (&pb->ch1_cmd->command, DBDMA_NOP); + st_le16 (&pb->ch2_cmd->command, DBDMA_NOP); + /* Set command buffer addresses */ + st_le32(&pb->planb_base->ch1.cmdptr, + virt_to_bus(pb->overlay_last1)); + out_le32(&pb->planb_base->ch2.cmdptr, + virt_to_bus(pb->overlay_last2)); + /* Start the DMA controller */ + out_le32 (&pb->planb_base->ch2.control, + PLANB_CLR(PAUSE) | PLANB_SET(RUN|WAKE)); + out_le32 (&pb->planb_base->ch1.control, + PLANB_CLR(PAUSE) | PLANB_SET(RUN|WAKE)); + } else if(pb->suspended.frame != -1) { + out_le32(&pb->planb_base->ch1.cmdptr, + virt_to_bus(pb->last_cmd[pb->suspended.frame])); + out_le32 (&pb->planb_base->ch1.control, + PLANB_CLR(PAUSE) | PLANB_SET(RUN|WAKE)); + } + +finish: + pb->suspend--; + wake_up_interruptible(&pb->suspendq); +} + +static void add_clip(struct planb *pb, struct video_clip *clip) +{ + volatile unsigned char *base; + int xc = clip->x, yc = clip->y; + int wc = clip->width, hc = clip->height; + int ww = pb->win.width, hw = pb->win.height; + int x, y, xtmp1, xtmp2; + + DEBUG("PlanB: clip %dx%d+%d+%d\n", wc, hc, xc, yc); + + if(xc < 0) { + wc += xc; + xc = 0; + } + if(yc < 0) { + hc += yc; + yc = 0; + } + if(xc + wc > ww) + wc = ww - xc; + if(wc <= 0) /* Nothing to do */ + return; + if(yc + hc > hw) + hc = hw - yc; + + for (y = yc; y < yc+hc; y++) { + xtmp1=xc>>3; + xtmp2=(xc+wc)>>3; + base = pb->mask + y*96; + if(xc != 0 || wc >= 8) + *(base + xtmp1) &= (unsigned char)(0x00ff & + (0xff00 >> (xc&7))); + for (x = xtmp1 + 1; x < xtmp2; x++) { + *(base + x) = 0; + } + if(xc < (ww & ~0x7)) + *(base + xtmp2) &= (unsigned char)(0x00ff >> + ((xc+wc) & 7)); + } + + return; +} + +static void fill_cmd_buff(struct planb *pb) +{ + int restore = 0; + volatile struct dbdma_cmd last; + + DEBUG("PlanB: fill_cmd_buff()\n"); + + if(pb->overlay_last1 != pb->ch1_cmd) { + restore = 1; + last = *(pb->overlay_last1); + } + memset ((void *) pb->ch1_cmd, 0, 2 * pb->tab_size + * sizeof(struct dbdma_cmd)); + cmd_buff (pb); + if(restore) + *(pb->overlay_last1) = last; + if(pb->suspended.overlay) { + unsigned long jump_addr = in_le32(&pb->overlay_last1->cmd_dep); + if(jump_addr != pb->ch1_cmd_phys) { + int i; + + DEBUG("PlanB: adjusting ch1's jump address\n"); + + for(i = 0; i < MAX_GBUFFERS; i++) { + if(pb->need_pre_capture[i]) { + if(jump_addr == virt_to_bus(pb->pre_cmd[i])) + goto found; + } else { + if(jump_addr == virt_to_bus(pb->cap_cmd[i])) + goto found; + } + } + + DEBUG("PlanB: not found...\n"); + + goto out; +found: + if(pb->need_pre_capture[i]) + out_le32(&pb->pre_cmd[i]->phy_addr, + virt_to_bus(pb->overlay_last1)); + else + out_le32(&pb->cap_cmd[i]->phy_addr, + virt_to_bus(pb->overlay_last1)); + } + } +out: + pb->cmd_buff_inited = 1; + + return; +} + +static void cmd_buff(struct planb *pb) +{ + int i, bpp, count, nlines, stepsize, interlace; + unsigned long base, jump, addr_com, addr_dep; + volatile struct dbdma_cmd *c1 = pb->ch1_cmd; + volatile struct dbdma_cmd *c2 = pb->ch2_cmd; + + interlace = pb->win.interlace; + bpp = pb->win.bpp; + count = (bpp * ((pb->win.x + pb->win.width > pb->win.swidth) ? + (pb->win.swidth - pb->win.x) : pb->win.width)); + nlines = ((pb->win.y + pb->win.height > pb->win.sheight) ? + (pb->win.sheight - pb->win.y) : pb->win.height); + + /* Do video in: */ + + /* Preamble commands: */ + addr_com = virt_to_bus(c1); + addr_dep = virt_to_bus(&c1->cmd_dep); + tab_cmd_dbdma(c1++, DBDMA_NOP, 0); + jump = virt_to_bus(c1+16); /* 14 by cmd_geo_setup() and 2 for padding */ + if((c1 = cmd_geo_setup(c1, pb->win.width, pb->win.height, interlace, + bpp, 1, pb)) == NULL) { + printk(KERN_WARNING "PlanB: encountered serious problems\n"); + tab_cmd_dbdma(pb->ch1_cmd + 1, DBDMA_STOP, 0); + tab_cmd_dbdma(pb->ch2_cmd + 1, DBDMA_STOP, 0); + return; + } + tab_cmd_store(c1++, addr_com, (unsigned)(DBDMA_NOP | BR_ALWAYS) << 16); + tab_cmd_store(c1++, addr_dep, jump); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.wait_sel), + PLANB_SET(FIELD_SYNC)); + /* (1) wait for field sync to be set */ + tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFCLR, 0); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), + PLANB_SET(ODD_FIELD)); + /* wait for field sync to be cleared */ + tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFSET, 0); + /* if not odd field, wait until field sync is set again */ + tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFSET, virt_to_bus(c1-3)); c1++; + /* assert ch_sync to ch2 */ + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch2.control), + PLANB_SET(CH_SYNC)); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), + PLANB_SET(DMA_ABORT)); + + base = (pb->frame_buffer_phys + pb->offset + pb->win.y * (pb->win.bpl + + pb->win.pad) + pb->win.x * bpp); + + if (interlace) { + stepsize = 2; + jump = virt_to_bus(c1 + (nlines + 1) / 2); + } else { + stepsize = 1; + jump = virt_to_bus(c1 + nlines); + } + + /* even field data: */ + for (i=0; i < nlines; i += stepsize, c1++) + tab_cmd_gen(c1, INPUT_MORE | KEY_STREAM0 | BR_IFSET, + count, base + i * (pb->win.bpl + pb->win.pad), jump); + + /* For non-interlaced, we use even fields only */ + if (!interlace) + goto cmd_tab_data_end; + + /* Resync to odd field */ + /* (2) wait for field sync to be set */ + tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFCLR, 0); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), + PLANB_SET(ODD_FIELD)); + /* wait for field sync to be cleared */ + tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFSET, 0); + /* if not odd field, wait until field sync is set again */ + tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFCLR, virt_to_bus(c1-3)); c1++; + /* assert ch_sync to ch2 */ + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch2.control), + PLANB_SET(CH_SYNC)); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), + PLANB_SET(DMA_ABORT)); + + /* odd field data: */ + jump = virt_to_bus(c1 + nlines / 2); + for (i=1; i < nlines; i += stepsize, c1++) + tab_cmd_gen(c1, INPUT_MORE | KEY_STREAM0 | BR_IFSET, count, + base + i * (pb->win.bpl + pb->win.pad), jump); + + /* And jump back to the start */ +cmd_tab_data_end: + pb->overlay_last1 = c1; /* keep a pointer to the last command */ + tab_cmd_dbdma(c1, DBDMA_NOP | BR_ALWAYS, virt_to_bus(pb->ch1_cmd)); + + /* Clipmask command buffer */ + + /* Preamble commands: */ + tab_cmd_dbdma(c2++, DBDMA_NOP, 0); + tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch2.wait_sel), + PLANB_SET(CH_SYNC)); + /* wait until ch1 asserts ch_sync */ + tab_cmd_dbdma(c2++, DBDMA_NOP | WAIT_IFCLR, 0); + /* clear ch_sync asserted by ch1 */ + tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch2.control), + PLANB_CLR(CH_SYNC)); + tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch2.wait_sel), + PLANB_SET(FIELD_SYNC)); + tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch2.br_sel), + PLANB_SET(ODD_FIELD)); + + /* jump to end of even field if appropriate */ + /* this points to (interlace)? pos. C: pos. B */ + jump = (interlace) ? virt_to_bus(c2 + (nlines + 1) / 2 + 2): + virt_to_bus(c2 + nlines + 2); + /* if odd field, skip over to odd field clipmasking */ + tab_cmd_dbdma(c2++, DBDMA_NOP | BR_IFSET, jump); + + /* even field mask: */ + tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch2.br_sel), + PLANB_SET(DMA_ABORT)); + /* this points to pos. B */ + jump = (interlace) ? virt_to_bus(c2 + nlines + 1): + virt_to_bus(c2 + nlines); + base = virt_to_bus(pb->mask); + for (i=0; i < nlines; i += stepsize, c2++) + tab_cmd_gen(c2, OUTPUT_MORE | KEY_STREAM0 | BR_IFSET, 96, + base + i * 96, jump); + + /* For non-interlaced, we use only even fields */ + if(!interlace) + goto cmd_tab_mask_end; + + /* odd field mask: */ +/* C */ tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch2.br_sel), + PLANB_SET(DMA_ABORT)); + /* this points to pos. B */ + jump = virt_to_bus(c2 + nlines / 2); + base = virt_to_bus(pb->mask); + for (i=1; i < nlines; i += 2, c2++) /* abort if set */ + tab_cmd_gen(c2, OUTPUT_MORE | KEY_STREAM0 | BR_IFSET, 96, + base + i * 96, jump); + + /* Inform channel 1 and jump back to start */ +cmd_tab_mask_end: + /* ok, I just realized this is kind of flawed. */ + /* this part is reached only after odd field clipmasking. */ + /* wanna clean up? */ + /* wait for field sync to be set */ + /* corresponds to fsync (1) of ch1 */ +/* B */ tab_cmd_dbdma(c2++, DBDMA_NOP | WAIT_IFCLR, 0); + /* restart ch1, meant to clear any dead bit or something */ + tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch1.control), + PLANB_CLR(RUN)); + tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch1.control), + PLANB_SET(RUN)); + pb->overlay_last2 = c2; /* keep a pointer to the last command */ + /* start over even field clipmasking */ + tab_cmd_dbdma(c2, DBDMA_NOP | BR_ALWAYS, virt_to_bus(pb->ch2_cmd)); + + eieio(); + return; +} + +/*********************************/ +/* grabdisplay support functions */ +/*********************************/ + +static int palette2fmt[] = { + 0, + PLANB_GRAY, + 0, + 0, + 0, + PLANB_COLOUR32, + PLANB_COLOUR15, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +}; +#define PLANB_PALETTE_MAX 15 + +#define SWAP4(x) (((x>>24) & 0x000000ff) |\ + ((x>>8) & 0x0000ff00) |\ + ((x<<8) & 0x00ff0000) |\ + ((x<<24) & 0xff000000)) + +static inline int overlay_is_active(struct planb *pb) +{ + unsigned int size = pb->tab_size * sizeof(struct dbdma_cmd); + unsigned int caddr = (unsigned)in_le32(&pb->planb_base->ch1.cmdptr); + + return (in_le32(&pb->overlay_last1->cmd_dep) == pb->ch1_cmd_phys) + && (caddr < (pb->ch1_cmd_phys + size)) + && (caddr >= (unsigned)pb->ch1_cmd_phys); +} + +static int vgrab(struct planb *pb, struct video_mmap *mp) +{ + unsigned int fr = mp->frame; + unsigned int format; + + if(pb->fbuffer==NULL) { + if(fbuffer_alloc(pb)) + return -ENOBUFS; + } + + IDEBUG("PlanB: grab %d: %dx%d(%u)\n", pb->grabbing, + mp->width, mp->height, fr); + + if(pb->grabbing >= MAX_GBUFFERS) + return -ENOBUFS; + if(fr > (MAX_GBUFFERS - 1) || fr < 0) + return -EINVAL; + if(mp->height <= 0 || mp->width <= 0) + return -EINVAL; + if(mp->format < 0 || mp->format >= PLANB_PALETTE_MAX) + return -EINVAL; + if((format = palette2fmt[mp->format]) == 0) + return -EINVAL; + if (mp->height * mp->width * format > PLANB_MAX_FBUF) /* format = bpp */ + return -EINVAL; + + planb_lock(pb); + pb->gbuffer[fr] = (unsigned char *)(pb->fbuffer + PLANB_MAX_FBUF * fr); + if(mp->width != pb->gwidth[fr] || mp->height != pb->gheight[fr] || + format != pb->gfmt[fr] || (pb->gnorm_switch[fr])) { +#ifdef PLANB_GSCANLINE + int i; +#else + unsigned int osize = pb->gwidth[fr] * pb->gheight[fr] + * pb->gfmt[fr]; + unsigned int nsize = mp->width * mp->height * format; +#endif + + IDEBUG("PlanB: gwidth = %d, gheight = %d, mp->format = %u\n", + mp->width, mp->height, mp->format); + +#ifndef PLANB_GSCANLINE + if(pb->gnorm_switch[fr]) + nsize = 0; + if(nsize < osize) + memset((void *)(pb->gbuffer[fr] + nsize), 0, + osize - nsize); + memset((void *)pb->l_fr_addr[fr], 0, PAGE_SIZE * pb->lnum[fr]); +#else +/* XXX TODO */ +/* + if(pb->gnorm_switch[fr]) + memset((void *)pb->gbuffer[fr], 0, + pb->gbytes_per_line * pb->gheight[fr]); + else { + if(mp-> + for(i = 0; i < pb->gheight[fr]; i++) { + memset((void *)(pb->gbuffer[fr] + + pb->gbytes_per_line * i + } + } +*/ +#endif + pb->gwidth[fr] = mp->width; + pb->gheight[fr] = mp->height; + pb->gfmt[fr] = format; + pb->last_cmd[fr] = setup_grab_cmd(fr, pb); + planb_pre_capture(fr, pb->gfmt[fr], pb); /* gfmt = bpp */ + pb->need_pre_capture[fr] = 1; + pb->gnorm_switch[fr] = 0; + } else + pb->need_pre_capture[fr] = 0; + pb->frame_stat[fr] = GBUFFER_GRABBING; + if(!(ACTIVE & in_le32(&pb->planb_base->ch1.status))) { + + IDEBUG("PlanB: ch1 inactive, initiating grabbing\n"); + + planb_dbdma_stop(&pb->planb_base->ch1); + if(pb->need_pre_capture[fr]) { + + IDEBUG("PlanB: padding pre-capture sequence\n"); + + out_le32 (&pb->planb_base->ch1.cmdptr, + virt_to_bus(pb->pre_cmd[fr])); + } else { + tab_cmd_dbdma(pb->last_cmd[fr], DBDMA_STOP, 0); + tab_cmd_dbdma(pb->cap_cmd[fr], DBDMA_NOP, 0); + /* let's be on the safe side. here is not timing critical. */ + tab_cmd_dbdma((pb->cap_cmd[fr] + 1), DBDMA_NOP, 0); + out_le32 (&pb->planb_base->ch1.cmdptr, + virt_to_bus(pb->cap_cmd[fr])); + } + planb_dbdma_restart(&pb->planb_base->ch1); + pb->last_fr = fr; + } else { + int i; + + IDEBUG("PlanB: ch1 active, grabbing being queued\n"); + + if((pb->last_fr == -1) || ((pb->last_fr == -2) && + overlay_is_active(pb))) { + + IDEBUG("PlanB: overlay is active, grabbing defered\n"); + + tab_cmd_dbdma(pb->last_cmd[fr], + DBDMA_NOP | BR_ALWAYS, + virt_to_bus(pb->ch1_cmd)); + if(pb->need_pre_capture[fr]) { + + IDEBUG("PlanB: padding pre-capture sequence\n"); + + tab_cmd_store(pb->pre_cmd[fr], + virt_to_bus(&pb->overlay_last1->cmd_dep), + virt_to_bus(pb->ch1_cmd)); + eieio(); + out_le32 (&pb->overlay_last1->cmd_dep, + virt_to_bus(pb->pre_cmd[fr])); + } else { + tab_cmd_store(pb->cap_cmd[fr], + virt_to_bus(&pb->overlay_last1->cmd_dep), + virt_to_bus(pb->ch1_cmd)); + tab_cmd_dbdma((pb->cap_cmd[fr] + 1), + DBDMA_NOP, 0); + eieio(); + out_le32 (&pb->overlay_last1->cmd_dep, + virt_to_bus(pb->cap_cmd[fr])); + } + for(i = 0; overlay_is_active(pb) && i < 999; i++) + IDEBUG("PlanB: waiting for overlay done\n"); + tab_cmd_dbdma(pb->ch1_cmd, DBDMA_NOP, 0); + pb->prev_last_fr = fr; + pb->last_fr = -2; + } else if(pb->last_fr == -2) { + + IDEBUG("PlanB: mixed mode detected, grabbing" + " will be done before activating overlay\n"); + + tab_cmd_dbdma(pb->ch1_cmd, DBDMA_NOP, 0); + if(pb->need_pre_capture[fr]) { + + IDEBUG("PlanB: padding pre-capture sequence\n"); + + tab_cmd_dbdma(pb->last_cmd[pb->prev_last_fr], + DBDMA_NOP | BR_ALWAYS, + virt_to_bus(pb->pre_cmd[fr])); + eieio(); + } else { + tab_cmd_dbdma(pb->cap_cmd[fr], DBDMA_NOP, 0); + if(pb->gwidth[pb->prev_last_fr] != + pb->gwidth[fr] + || pb->gheight[pb->prev_last_fr] != + pb->gheight[fr] + || pb->gfmt[pb->prev_last_fr] != + pb->gfmt[fr]) + tab_cmd_dbdma((pb->cap_cmd[fr] + 1), + DBDMA_NOP, 0); + else + tab_cmd_dbdma((pb->cap_cmd[fr] + 1), + DBDMA_NOP | BR_ALWAYS, + virt_to_bus(pb->cap_cmd[fr] + 16)); + tab_cmd_dbdma(pb->last_cmd[pb->prev_last_fr], + DBDMA_NOP | BR_ALWAYS, + virt_to_bus(pb->cap_cmd[fr])); + eieio(); + } + tab_cmd_dbdma(pb->last_cmd[fr], + DBDMA_NOP | BR_ALWAYS, + virt_to_bus(pb->ch1_cmd)); + eieio(); + pb->prev_last_fr = fr; + pb->last_fr = -2; + } else { + + IDEBUG("PlanB: active grabbing session detected\n"); + + if(pb->need_pre_capture[fr]) { + + IDEBUG("PlanB: padding pre-capture sequence\n"); + + tab_cmd_dbdma(pb->last_cmd[pb->last_fr], + DBDMA_NOP | BR_ALWAYS, + virt_to_bus(pb->pre_cmd[fr])); + eieio(); + } else { + tab_cmd_dbdma(pb->last_cmd[fr], DBDMA_STOP, 0); + tab_cmd_dbdma(pb->cap_cmd[fr], DBDMA_NOP, 0); + if(pb->gwidth[pb->last_fr] != pb->gwidth[fr] + || pb->gheight[pb->last_fr] != + pb->gheight[fr] + || pb->gfmt[pb->last_fr] != + pb->gfmt[fr]) + tab_cmd_dbdma((pb->cap_cmd[fr] + 1), + DBDMA_NOP, 0); + else + tab_cmd_dbdma((pb->cap_cmd[fr] + 1), + DBDMA_NOP | BR_ALWAYS, + virt_to_bus(pb->cap_cmd[fr] + 16)); + tab_cmd_dbdma(pb->last_cmd[pb->last_fr], + DBDMA_NOP | BR_ALWAYS, + virt_to_bus(pb->cap_cmd[fr])); + eieio(); + } + pb->last_fr = fr; + } + if(!(ACTIVE & in_le32(&pb->planb_base->ch1.status))) { + + IDEBUG("PlanB: became inactive in the mean time..." + "reactivating\n"); + + planb_dbdma_stop(&pb->planb_base->ch1); + out_le32 (&pb->planb_base->ch1.cmdptr, + virt_to_bus(pb->cap_cmd[fr])); + planb_dbdma_restart(&pb->planb_base->ch1); + } + } + pb->grabbing++; + planb_unlock(pb); + + return 0; +} + +static void planb_pre_capture(int fr, int bpp, struct planb *pb) +{ + volatile struct dbdma_cmd *c1 = pb->pre_cmd[fr]; + int interlace = (pb->gheight[fr] > pb->maxlines/2)? 1: 0; + + tab_cmd_dbdma(c1++, DBDMA_NOP, 0); + if((c1 = cmd_geo_setup(c1, pb->gwidth[fr], pb->gheight[fr], interlace, + bpp, 0, pb)) == NULL) { + printk(KERN_WARNING "PlanB: encountered some problems\n"); + tab_cmd_dbdma(pb->pre_cmd[fr] + 1, DBDMA_STOP, 0); + return; + } + /* Sync to even field */ + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.wait_sel), + PLANB_SET(FIELD_SYNC)); + tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFCLR, 0); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), + PLANB_SET(ODD_FIELD)); + tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFSET, 0); + tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFSET, virt_to_bus(c1-3)); c1++; + tab_cmd_dbdma(c1++, DBDMA_NOP | INTR_ALWAYS, 0); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), + PLANB_SET(DMA_ABORT)); + /* For non-interlaced, we use even fields only */ + if (pb->gheight[fr] <= pb->maxlines/2) + goto cmd_tab_data_end; + /* Sync to odd field */ + tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFCLR, 0); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), + PLANB_SET(ODD_FIELD)); + tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFSET, 0); + tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFCLR, virt_to_bus(c1-3)); c1++; + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), + PLANB_SET(DMA_ABORT)); +cmd_tab_data_end: + tab_cmd_dbdma(c1, DBDMA_NOP | BR_ALWAYS, virt_to_bus(pb->cap_cmd[fr])); + + eieio(); +} + +static volatile struct dbdma_cmd *setup_grab_cmd(int fr, struct planb *pb) +{ + int i, bpp, count, nlines, stepsize, interlace; +#ifdef PLANB_GSCANLINE + int scanline; +#else + int nlpp, leftover1; + unsigned long base; +#endif + unsigned long jump; + unsigned char *vaddr; + volatile struct dbdma_cmd *c1; + volatile struct dbdma_cmd *jump_addr; + + c1 = pb->cap_cmd[fr]; + interlace = (pb->gheight[fr] > pb->maxlines/2)? 1: 0; + bpp = pb->gfmt[fr]; /* gfmt = bpp */ + count = bpp * pb->gwidth[fr]; + nlines = pb->gheight[fr]; +#ifdef PLANB_GSCANLINE + scanline = pb->gbytes_per_line; +#else + pb->lsize[fr] = count; + pb->lnum[fr] = 0; +#endif + + /* Do video in: */ + + /* Preamble commands: */ + tab_cmd_dbdma(c1++, DBDMA_NOP, 0); + tab_cmd_dbdma(c1, DBDMA_NOP | BR_ALWAYS, virt_to_bus(c1 + 16)); c1++; + if((c1 = cmd_geo_setup(c1, pb->gwidth[fr], pb->gheight[fr], interlace, + bpp, 0, pb)) == NULL) { + printk(KERN_WARNING "PlanB: encountered serious problems\n"); + tab_cmd_dbdma(pb->cap_cmd[fr] + 1, DBDMA_STOP, 0); + return (pb->cap_cmd[fr] + 2); + } + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.wait_sel), + PLANB_SET(FIELD_SYNC)); + tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFCLR, 0); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), + PLANB_SET(ODD_FIELD)); + tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFSET, 0); + tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFSET, virt_to_bus(c1-3)); c1++; + tab_cmd_dbdma(c1++, DBDMA_NOP | INTR_ALWAYS, 0); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), + PLANB_SET(DMA_ABORT)); + + if (interlace) { + stepsize = 2; + jump_addr = c1 + TAB_FACTOR * (nlines + 1) / 2; + } else { + stepsize = 1; + jump_addr = c1 + TAB_FACTOR * nlines; + } + jump = virt_to_bus(jump_addr); + + /* even field data: */ + + vaddr = pb->gbuffer[fr]; +#ifdef PLANB_GSCANLINE + for (i = 0; i < nlines; i += stepsize) { + tab_cmd_gen(c1++, INPUT_MORE | BR_IFSET, count, + vmalloc_to_bus(vaddr + i * scanline), jump); + } +#else + i = 0; + leftover1 = 0; + do { + int j; + + base = vmalloc_to_bus((void*)vaddr); + nlpp = (PAGE_SIZE - leftover1) / count / stepsize; + for(j = 0; j < nlpp && i < nlines; j++, i += stepsize, c1++) + tab_cmd_gen(c1, INPUT_MORE | KEY_STREAM0 | BR_IFSET, + count, base + count * j * stepsize + leftover1, jump); + if(i < nlines) { + int lov0 = PAGE_SIZE - count * nlpp * stepsize - leftover1; + + if(lov0 == 0) + leftover1 = 0; + else { + if(lov0 >= count) { + tab_cmd_gen(c1++, INPUT_MORE | BR_IFSET, count, base + + count * nlpp * stepsize + leftover1, jump); + } else { + pb->l_to_addr[fr][pb->lnum[fr]] = vaddr + count * nlpp + * stepsize + leftover1; + tab_cmd_gen(c1++, INPUT_MORE | BR_IFSET, count, + vmalloc_to_bus(pb->l_fr_addr[fr] + PAGE_SIZE + * pb->lnum[fr]), jump); + if(++pb->lnum[fr] > MAX_LNUM) + pb->lnum[fr]--; + } + leftover1 = count * stepsize - lov0; + i += stepsize; + } + } + vaddr += PAGE_SIZE; + } while(i < nlines); + tab_cmd_dbdma(c1, DBDMA_NOP | BR_ALWAYS, jump); + c1 = jump_addr; +#endif /* PLANB_GSCANLINE */ + + /* For non-interlaced, we use even fields only */ + if (!interlace) + goto cmd_tab_data_end; + + /* Sync to odd field */ + tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFCLR, 0); + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), + PLANB_SET(ODD_FIELD)); + tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFSET, 0); + tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFCLR, virt_to_bus(c1-3)); c1++; + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel), + PLANB_SET(DMA_ABORT)); + + /* odd field data: */ + jump_addr = c1 + TAB_FACTOR * nlines / 2; + jump = virt_to_bus(jump_addr); +#ifdef PLANB_GSCANLINE + for (i = 1; i < nlines; i += stepsize) { + tab_cmd_gen(c1++, INPUT_MORE | BR_IFSET, count, + vmalloc_to_bus(vaddr + i * scanline), jump); + } +#else + i = 1; + leftover1 = 0; + vaddr = pb->gbuffer[fr]; + if(nlines <= 1) + goto skip; + do { + int j; + + base = vmalloc_to_bus((void*)vaddr); + nlpp = (PAGE_SIZE - leftover1) / count / stepsize; + if(leftover1 >= count) { + tab_cmd_gen(c1++, INPUT_MORE | KEY_STREAM0 | BR_IFSET, count, + base + leftover1 - count, jump); + i += stepsize; + } + for(j = 0; j < nlpp && i < nlines; j++, i += stepsize, c1++) + tab_cmd_gen(c1, INPUT_MORE | KEY_STREAM0 | BR_IFSET, count, + base + count * (j * stepsize + 1) + leftover1, jump); + if(i < nlines) { + int lov0 = PAGE_SIZE - count * nlpp * stepsize - leftover1; + + if(lov0 == 0) + leftover1 = 0; + else { + if(lov0 > count) { + pb->l_to_addr[fr][pb->lnum[fr]] = vaddr + count + * (nlpp * stepsize + 1) + leftover1; + tab_cmd_gen(c1++, INPUT_MORE | BR_IFSET, count, + vmalloc_to_bus(pb->l_fr_addr[fr] + PAGE_SIZE + * pb->lnum[fr]), jump); + if(++pb->lnum[fr] > MAX_LNUM) + pb->lnum[fr]--; + i += stepsize; + } + leftover1 = count * stepsize - lov0; + } + } + vaddr += PAGE_SIZE; + } while(i < nlines); +skip: + tab_cmd_dbdma(c1, DBDMA_NOP | BR_ALWAYS, jump); + c1 = jump_addr; +#endif /* PLANB_GSCANLINE */ + +cmd_tab_data_end: + tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->intr_stat), + (fr << 2) | PLANB_FRM_IRQ | PLANB_GEN_IRQ); + /* stop it */ + tab_cmd_dbdma(c1, DBDMA_STOP, 0); + + eieio(); + return c1; +} + +static void planb_irq(int irq, void *dev_id, struct pt_regs * regs) +{ + unsigned int stat, astat; + struct planb *pb = (struct planb *)dev_id; + + IDEBUG("PlanB: planb_irq()\n"); + + /* get/clear interrupt status bits */ + stat = in_le32(&pb->planb_base->intr_stat); + astat = stat & pb->intr_mask; + out_le32(&pb->planb_base->intr_stat, PLANB_IRQ_CMD_MASK + & ~astat & stat & ~PLANB_GEN_IRQ); + + if(astat & PLANB_FRM_IRQ) { + unsigned int fr = stat >> 2; +#ifndef PLANB_GSCANLINE + int i; +#endif + IDEBUG("PlanB: PLANB_FRM_IRQ\n"); + + pb->gcount++; + + IDEBUG("PlanB: grab %d: fr = %d, gcount = %d\n", + pb->grabbing, fr, pb->gcount); +#ifndef PLANB_GSCANLINE + IDEBUG("PlanB: %d * %d bytes are being copied over\n", + pb->lnum[fr], pb->lsize[fr]); + for(i = 0; i < pb->lnum[fr]; i++) + memcpy(pb->l_to_addr[fr][i], pb->l_fr_addr[fr] + + PAGE_SIZE * i, pb->lsize[fr]); +#endif + pb->frame_stat[fr] = GBUFFER_DONE; + pb->grabbing--; + wake_up_interruptible(&pb->capq); + return; + } + /* incorrect interrupts? */ + pb->intr_mask = PLANB_CLR_IRQ; + out_le32(&pb->planb_base->intr_stat, PLANB_CLR_IRQ); + printk(KERN_ERR "PlanB: IRQ lockup, cleared intrrupts" + " unconditionally\n"); +} + +/******************************* + * Device Operations functions * + *******************************/ + +static int planb_open(struct video_device *dev, int mode) +{ + struct planb *pb = (struct planb *)dev; + + if (pb->user == 0) { + int err; + if((err = planb_prepare_open(pb)) != 0) + return err; + } + pb->user++; + + DEBUG("PlanB: device opened\n"); + + MOD_INC_USE_COUNT; + return 0; +} + +static void planb_close(struct video_device *dev) +{ + struct planb *pb = (struct planb *)dev; + + if(pb->user < 1) /* ??? */ + return; + planb_lock(pb); + if (pb->user == 1) { + if (pb->overlay) { + planb_dbdma_stop(&pb->planb_base->ch2); + planb_dbdma_stop(&pb->planb_base->ch1); + pb->overlay = 0; + } + planb_prepare_close(pb); + } + pb->user--; + planb_unlock(pb); + + DEBUG("PlanB: device closed\n"); + + MOD_DEC_USE_COUNT; +} + +static long planb_read(struct video_device *v, char *buf, unsigned long count, + int nonblock) +{ + DEBUG("planb: read request\n"); + return -EINVAL; +} + +static long planb_write(struct video_device *v, const char *buf, + unsigned long count, int nonblock) +{ + DEBUG("planb: write request\n"); + return -EINVAL; +} + +static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg) +{ + struct planb *pb=(struct planb *)dev; + + switch (cmd) + { + case VIDIOCGCAP: + { + struct video_capability b; + + DEBUG("PlanB: IOCTL VIDIOCGCAP\n"); + + strcpy (b.name, pb->video_dev.name); + b.type = VID_TYPE_OVERLAY | VID_TYPE_CLIPPING | + VID_TYPE_FRAMERAM | VID_TYPE_SCALES | + VID_TYPE_CAPTURE; + b.channels = 2; /* composite & svhs */ + b.audios = 0; + b.maxwidth = PLANB_MAXPIXELS; + b.maxheight = PLANB_MAXLINES; + b.minwidth = 32; /* wild guess */ + b.minheight = 32; + if (copy_to_user(arg,&b,sizeof(b))) + return -EFAULT; + return 0; + } + case VIDIOCSFBUF: + { + struct video_buffer v; + unsigned short bpp; + unsigned int fmt; + + DEBUG("PlanB: IOCTL VIDIOCSFBUF\n"); + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + if (copy_from_user(&v, arg,sizeof(v))) + return -EFAULT; + planb_lock(pb); + switch(v.depth) { + case 8: + bpp = 1; + fmt = PLANB_GRAY; + break; + case 15: + case 16: + bpp = 2; + fmt = PLANB_COLOUR15; + break; + case 24: + case 32: + bpp = 4; + fmt = PLANB_COLOUR32; + break; + default: + planb_unlock(pb); + return -EINVAL; + } + if (bpp * v.width > v.bytesperline) { + planb_unlock(pb); + return -EINVAL; + } + pb->win.bpp = bpp; + pb->win.color_fmt = fmt; + pb->frame_buffer_phys = (unsigned long) v.base; + pb->win.sheight = v.height; + pb->win.swidth = v.width; + pb->picture.depth = pb->win.depth = v.depth; + pb->win.bpl = pb->win.bpp * pb->win.swidth; + pb->win.pad = v.bytesperline - pb->win.bpl; + + DEBUG("PlanB: Display at %p is %d by %d, bytedepth %d," + " bpl %d (+ %d)\n", v.base, v.width,v.height, + pb->win.bpp, pb->win.bpl, pb->win.pad); + + pb->cmd_buff_inited = 0; + if(pb->overlay) { + suspend_overlay(pb); + fill_cmd_buff(pb); + resume_overlay(pb); + } + planb_unlock(pb); + return 0; + } + case VIDIOCGFBUF: + { + struct video_buffer v; + + DEBUG("PlanB: IOCTL VIDIOCGFBUF\n"); + + v.base = (void *)pb->frame_buffer_phys; + v.height = pb->win.sheight; + v.width = pb->win.swidth; + v.depth = pb->win.depth; + v.bytesperline = pb->win.bpl + pb->win.pad; + if (copy_to_user(arg, &v, sizeof(v))) + return -EFAULT; + return 0; + } + case VIDIOCCAPTURE: + { + int i; + + if(copy_from_user(&i, arg, sizeof(i))) + return -EFAULT; + if(i==0) { + DEBUG("PlanB: IOCTL VIDIOCCAPTURE Stop\n"); + + if (!(pb->overlay)) + return 0; + planb_lock(pb); + pb->overlay = 0; + overlay_stop(pb); + planb_unlock(pb); + } else { + DEBUG("PlanB: IOCTL VIDIOCCAPTURE Start\n"); + + if (pb->frame_buffer_phys == 0 || + pb->win.width == 0 || + pb->win.height == 0) + return -EINVAL; + if (pb->overlay) + return 0; + planb_lock(pb); + pb->overlay = 1; + if(!(pb->cmd_buff_inited)) + fill_cmd_buff(pb); + overlay_start(pb); + planb_unlock(pb); + } + return 0; + } + case VIDIOCGCHAN: + { + struct video_channel v; + + DEBUG("PlanB: IOCTL VIDIOCGCHAN\n"); + + if(copy_from_user(&v, arg,sizeof(v))) + return -EFAULT; + v.flags = 0; + v.tuners = 0; + v.type = VIDEO_TYPE_CAMERA; + v.norm = pb->win.norm; + switch(v.channel) + { + case 0: + strcpy(v.name,"Composite"); + break; + case 1: + strcpy(v.name,"SVHS"); + break; + default: + return -EINVAL; + break; + } + if(copy_to_user(arg,&v,sizeof(v))) + return -EFAULT; + + return 0; + } + case VIDIOCSCHAN: + { + struct video_channel v; + + DEBUG("PlanB: IOCTL VIDIOCSCHAN\n"); + + if(copy_from_user(&v, arg, sizeof(v))) + return -EFAULT; + + if (v.norm != pb->win.norm) { + int i, maxlines; + + switch (v.norm) + { + case VIDEO_MODE_PAL: + case VIDEO_MODE_SECAM: + maxlines = PLANB_MAXLINES; + break; + case VIDEO_MODE_NTSC: + maxlines = PLANB_NTSC_MAXLINES; + break; + default: + return -EINVAL; + break; + } + planb_lock(pb); + /* empty the grabbing queue */ + while(pb->grabbing) + interruptible_sleep_on(&pb->capq); + pb->maxlines = maxlines; + pb->win.norm = v.norm; + /* Stop overlay if running */ + suspend_overlay(pb); + for(i = 0; i < MAX_GBUFFERS; i++) + pb->gnorm_switch[i] = 1; + /* I know it's an overkill, but.... */ + fill_cmd_buff(pb); + /* ok, now init it accordingly */ + saa_init_regs (pb); + /* restart overlay if it was running */ + resume_overlay(pb); + planb_unlock(pb); + } + + switch(v.channel) + { + case 0: /* Composite */ + saa_set (SAA7196_IOCC, + ((saa_regs[pb->win.norm][SAA7196_IOCC] & + ~7) | 3), pb); + break; + case 1: /* SVHS */ + saa_set (SAA7196_IOCC, + ((saa_regs[pb->win.norm][SAA7196_IOCC] & + ~7) | 4), pb); + break; + default: + return -EINVAL; + break; + } + + return 0; + } + case VIDIOCGPICT: + { + struct video_picture vp = pb->picture; + + DEBUG("PlanB: IOCTL VIDIOCGPICT\n"); + + switch(pb->win.color_fmt) { + case PLANB_GRAY: + vp.palette = VIDEO_PALETTE_GREY; + case PLANB_COLOUR15: + vp.palette = VIDEO_PALETTE_RGB555; + break; + case PLANB_COLOUR32: + vp.palette = VIDEO_PALETTE_RGB32; + break; + default: + vp.palette = 0; + break; + } + + if(copy_to_user(arg,&vp,sizeof(vp))) + return -EFAULT; + return 0; + } + case VIDIOCSPICT: + { + struct video_picture vp; + + DEBUG("PlanB: IOCTL VIDIOCSPICT\n"); + + if(copy_from_user(&vp,arg,sizeof(vp))) + return -EFAULT; + pb->picture = vp; + /* Should we do sanity checks here? */ + saa_set (SAA7196_BRIG, (unsigned char) + ((pb->picture.brightness) >> 8), pb); + saa_set (SAA7196_HUEC, (unsigned char) + ((pb->picture.hue) >> 8) ^ 0x80, pb); + saa_set (SAA7196_CSAT, (unsigned char) + ((pb->picture.colour) >> 9), pb); + saa_set (SAA7196_CONT, (unsigned char) + ((pb->picture.contrast) >> 9), pb); + + return 0; + } + case VIDIOCSWIN: + { + struct video_window vw; + struct video_clip clip; + int i; + + DEBUG("PlanB: IOCTL VIDIOCSWIN\n"); + + if(copy_from_user(&vw,arg,sizeof(vw))) + return -EFAULT; + + planb_lock(pb); + /* Stop overlay if running */ + suspend_overlay(pb); + pb->win.interlace = (vw.height > pb->maxlines/2)? 1: 0; + if (pb->win.x != vw.x || + pb->win.y != vw.y || + pb->win.width != vw.width || + pb->win.height != vw.height || + !pb->cmd_buff_inited) { + pb->win.x = vw.x; + pb->win.y = vw.y; + pb->win.width = vw.width; + pb->win.height = vw.height; + fill_cmd_buff(pb); + } + /* Reset clip mask */ + memset ((void *) pb->mask, 0xff, (pb->maxlines + * ((PLANB_MAXPIXELS + 7) & ~7)) / 8); + /* Add any clip rects */ + for (i = 0; i < vw.clipcount; i++) { + if (copy_from_user(&clip, vw.clips + i, + sizeof(struct video_clip))) + return -EFAULT; + add_clip(pb, &clip); + } + /* restart overlay if it was running */ + resume_overlay(pb); + planb_unlock(pb); + return 0; + } + case VIDIOCGWIN: + { + struct video_window vw; + + DEBUG("PlanB: IOCTL VIDIOCGWIN\n"); + + vw.x=pb->win.x; + vw.y=pb->win.y; + vw.width=pb->win.width; + vw.height=pb->win.height; + vw.chromakey=0; + vw.flags=0; + if(pb->win.interlace) + vw.flags|=VIDEO_WINDOW_INTERLACE; + if(copy_to_user(arg,&vw,sizeof(vw))) + return -EFAULT; + return 0; + } + case VIDIOCSYNC: { + int i; + + IDEBUG("PlanB: IOCTL VIDIOCSYNC\n"); + + if(copy_from_user((void *)&i,arg,sizeof(int))) + return -EFAULT; + + IDEBUG("PlanB: sync to frame %d\n", i); + + if(i > (MAX_GBUFFERS - 1) || i < 0) + return -EINVAL; +chk_grab: + switch (pb->frame_stat[i]) { + case GBUFFER_UNUSED: + return -EINVAL; + case GBUFFER_GRABBING: + IDEBUG("PlanB: waiting for grab" + " done (%d)\n", i); + interruptible_sleep_on(&pb->capq); + goto chk_grab; + case GBUFFER_DONE: + pb->frame_stat[i] = GBUFFER_UNUSED; + break; + } + return 0; + } + + case VIDIOCMCAPTURE: + { + struct video_mmap vm; + volatile unsigned int status; + + IDEBUG("PlanB: IOCTL VIDIOCMCAPTURE\n"); + + if(copy_from_user((void *) &vm,(void *)arg,sizeof(vm))) + return -EFAULT; + status = pb->frame_stat[vm.frame]; + if (status != GBUFFER_UNUSED) + return -EBUSY; + + return vgrab(pb, &vm); + } + + case VIDIOCGMBUF: + { + int i; + struct video_mbuf vm; + + DEBUG("PlanB: IOCTL VIDIOCGMBUF\n"); + + memset(&vm, 0 , sizeof(vm)); + vm.size = PLANB_MAX_FBUF * MAX_GBUFFERS; + vm.frames = MAX_GBUFFERS; + for(i = 0; i= SAA7196_NUMREGS) + return -EINVAL; + preg.val = saa_regs[pb->win.norm][preg.addr]; + if(copy_to_user((void *)arg, (void *)&preg, + sizeof(preg))) + return -EFAULT; + return 0; + } + + case PLANBIOCSSAAREGS: + { + struct planb_saa_regs preg; + + DEBUG("PlanB: IOCTL PLANBIOCSSAAREGS\n"); + + if(copy_from_user(&preg, arg, sizeof(preg))) + return -EFAULT; + if(preg.addr >= SAA7196_NUMREGS) + return -EINVAL; + saa_set (preg.addr, preg.val, pb); + return 0; + } + + case PLANBIOCGSTAT: + { + struct planb_stat_regs pstat; + + DEBUG("PlanB: IOCTL PLANBIOCGSTAT\n"); + + pstat.ch1_stat = in_le32(&pb->planb_base->ch1.status); + pstat.ch2_stat = in_le32(&pb->planb_base->ch2.status); + pstat.saa_stat0 = saa_status(0, pb); + pstat.saa_stat1 = saa_status(1, pb); + + if(copy_to_user((void *)arg, (void *)&pstat, + sizeof(pstat))) + return -EFAULT; + return 0; + } + + case PLANBIOCSMODE: { + int v; + + DEBUG("PlanB: IOCTL PLANBIOCSMODE\n"); + + if(copy_from_user(&v, arg, sizeof(v))) + return -EFAULT; + + switch(v) + { + case PLANB_TV_MODE: + saa_set (SAA7196_STDC, + (saa_regs[pb->win.norm][SAA7196_STDC] & + 0x7f), pb); + break; + case PLANB_VTR_MODE: + saa_set (SAA7196_STDC, + (saa_regs[pb->win.norm][SAA7196_STDC] | + 0x80), pb); + break; + default: + return -EINVAL; + break; + } + pb->win.mode = v; + return 0; + } + case PLANBIOCGMODE: { + int v=pb->win.mode; + + DEBUG("PlanB: IOCTL PLANBIOCGMODE\n"); + + if(copy_to_user(arg,&v,sizeof(v))) + return -EFAULT; + return 0; + } +#ifdef PLANB_GSCANLINE + case PLANBG_GRAB_BPL: { + int v=pb->gbytes_per_line; + + DEBUG("PlanB: IOCTL PLANBG_GRAB_BPL\n"); + + if(copy_to_user(arg,&v,sizeof(v))) + return -EFAULT; + return 0; + } +#endif /* PLANB_GSCANLINE */ + case PLANB_INTR_DEBUG: { + int i; + + DEBUG("PlanB: IOCTL PLANB_INTR_DEBUG\n"); + + if(copy_from_user(&i, arg, sizeof(i))) + return -EFAULT; + + /* avoid hang ups all together */ + for (i = 0; i < MAX_GBUFFERS; i++) { + if(pb->frame_stat[i] == GBUFFER_GRABBING) { + pb->frame_stat[i] = GBUFFER_DONE; + } + } + if(pb->grabbing) + pb->grabbing--; + wake_up_interruptible(&pb->capq); + return 0; + } + case PLANB_INV_REGS: { + int i; + struct planb_any_regs any; + + DEBUG("PlanB: IOCTL PLANB_INV_REGS\n"); + + if(copy_from_user(&any, arg, sizeof(any))) + return -EFAULT; + if(any.offset < 0 || any.offset + any.bytes > 0x400) + return -EINVAL; + if(any.bytes > 128) + return -EINVAL; + for (i = 0; i < any.bytes; i++) { + any.data[i] = + in_8((unsigned char *)pb->planb_base + + any.offset + i); + } + if(copy_to_user(arg,&any,sizeof(any))) + return -EFAULT; + return 0; + } + default: + { + DEBUG("PlanB: Unimplemented IOCTL\n"); + return -ENOIOCTLCMD; + } + /* Some IOCTLs are currently unsupported on PlanB */ + case VIDIOCGTUNER: { + DEBUG("PlanB: IOCTL VIDIOCGTUNER\n"); + goto unimplemented; } + case VIDIOCSTUNER: { + DEBUG("PlanB: IOCTL VIDIOCSTUNER\n"); + goto unimplemented; } + case VIDIOCSFREQ: { + DEBUG("PlanB: IOCTL VIDIOCSFREQ\n"); + goto unimplemented; } + case VIDIOCGFREQ: { + DEBUG("PlanB: IOCTL VIDIOCGFREQ\n"); + goto unimplemented; } + case VIDIOCKEY: { + DEBUG("PlanB: IOCTL VIDIOCKEY\n"); + goto unimplemented; } + case VIDIOCSAUDIO: { + DEBUG("PlanB: IOCTL VIDIOCSAUDIO\n"); + goto unimplemented; } + case VIDIOCGAUDIO: { + DEBUG("PlanB: IOCTL VIDIOCGAUDIO\n"); + goto unimplemented; } +unimplemented: + DEBUG(" Unimplemented\n"); + return -ENOIOCTLCMD; + } + return 0; +} + +/* + * This maps the vmalloced and reserved fbuffer to user space. + * + * FIXME: + * - PAGE_READONLY should suffice!? + * - remap_page_range is kind of inefficient for page by page remapping. + * But e.g. pte_alloc() does not work in modules ... :-( + */ + +static int planb_mmap(struct video_device *dev, const char *adr, unsigned long size) +{ + struct planb *pb=(struct planb *)dev; + unsigned long start=(unsigned long) adr; + unsigned long page; + void *pos; + + if (size>MAX_GBUFFERS*PLANB_MAX_FBUF) + return -EINVAL; + if (!pb->fbuffer) + { + if(fbuffer_alloc(pb)) + return -EINVAL; + } + pos = (void *)pb->fbuffer; + while (size > 0) + { + page = vmalloc_to_phys(pos); + if (remap_page_range(start, page, PAGE_SIZE, PAGE_SHARED)) + return -EAGAIN; + start+=PAGE_SIZE; + pos+=PAGE_SIZE; + size-=PAGE_SIZE; + } + return 0; +} + +/* This gets called upon device registration */ +/* we could do some init here */ +static int planb_init_done(struct video_device *dev) +{ + return 0; +} + +static struct video_device planb_template= +{ + PLANB_DEVICE_NAME, + VID_TYPE_OVERLAY, + VID_HARDWARE_PLANB, + planb_open, + planb_close, + planb_read, + planb_write, +#if LINUX_VERSION_CODE >= 0x020100 + NULL, /* poll */ +#endif + planb_ioctl, + planb_mmap, /* mmap? */ + planb_init_done, + NULL, /* pointer to private data */ + 0, + 0 +}; + +static int init_planb(struct planb *pb) +{ + unsigned char saa_rev; + int i, result; + + memset ((void *) &pb->win, 0, sizeof (struct planb_window)); + /* Simple sanity check */ + if(def_norm >= NUM_SUPPORTED_NORM || def_norm < 0) { + printk(KERN_ERR "PlanB: Option(s) invalid\n"); + return -2; + } + pb->win.norm = def_norm; + pb->win.mode = PLANB_TV_MODE; /* TV mode */ + pb->win.interlace=1; + pb->win.x=0; + pb->win.y=0; + pb->win.width=768; /* 640 */ + pb->win.height=576; /* 480 */ + pb->maxlines=576; +#if 0 + btv->win.cropwidth=768; /* 640 */ + btv->win.cropheight=576; /* 480 */ + btv->win.cropx=0; + btv->win.cropy=0; +#endif + pb->win.pad=0; + pb->win.bpp=4; + pb->win.depth=32; + pb->win.color_fmt=PLANB_COLOUR32; + pb->win.bpl=1024*pb->win.bpp; + pb->win.swidth=1024; + pb->win.sheight=768; +#ifdef PLANB_GSCANLINE + if((pb->gbytes_per_line = PLANB_MAXPIXELS * 4) > PAGE_SIZE + || (pb->gbytes_per_line <= 0)) + return -3; + else { + /* page align pb->gbytes_per_line for DMA purpose */ + for(i = PAGE_SIZE; pb->gbytes_per_line < (i>>1);) + i>>=1; + pb->gbytes_per_line = i; + } +#endif + pb->tab_size = PLANB_MAXLINES + 40; + pb->suspend = 0; + pb->lock = 0; + pb->lockq = NULL; + pb->ch1_cmd = 0; + pb->ch2_cmd = 0; + pb->mask = 0; + pb->priv_space = 0; + pb->offset = 0; + pb->user = 0; + pb->overlay = 0; + pb->suspendq = NULL; + pb->cmd_buff_inited = 0; + pb->frame_buffer_phys = 0; + + /* Reset DMA controllers */ + planb_dbdma_stop(&pb->planb_base->ch2); + planb_dbdma_stop(&pb->planb_base->ch1); + + saa_rev = (saa_status(0, pb) & 0xf0) >> 4; + printk(KERN_INFO "PlanB: SAA7196 video processor rev. %d\n", saa_rev); + /* Initialize the SAA registers in memory and on chip */ + saa_init_regs (pb); + + /* clear interrupt mask */ + pb->intr_mask = PLANB_CLR_IRQ; + + result = request_irq(pb->irq, planb_irq, 0, "PlanB", (void *)pb); + if (result==-EINVAL) { + printk(KERN_ERR "PlanB: Bad irq number (%d) or handler\n", + (int)pb->irq); + return result; + } + if (result==-EBUSY) { + printk(KERN_ERR "PlanB: I don't know why, but IRQ %d busy\n", + (int)pb->irq); + return result; + } + if (result < 0) + return result; + + /* Now add the template and register the device unit. */ + memcpy(&pb->video_dev,&planb_template,sizeof(planb_template)); + + pb->picture.brightness=0x90<<8; + pb->picture.contrast = 0x70 << 8; + pb->picture.colour = 0x70<<8; + pb->picture.hue = 0x8000; + pb->picture.whiteness = 0; + pb->picture.depth = pb->win.depth; + + pb->frame_stat=NULL; + pb->capq=NULL; + for(i=0; igbuffer[i]=NULL; + pb->gwidth[i]=0; + pb->gheight[i]=0; + pb->gfmt[i]=0; + pb->cap_cmd[i]=NULL; +#ifndef PLANB_GSCANLINE + pb->l_fr_addr[i]=NULL; + pb->lsize[i] = 0; + pb->lnum[i] = 0; +#endif + } + pb->fbuffer=NULL; + pb->grabbing=0; + + /* clear interrupts */ + out_le32(&pb->planb_base->intr_stat, PLANB_CLR_IRQ); + /* set interrupt mask */ + pb->intr_mask = PLANB_FRM_IRQ; + + if(video_register_device(&pb->video_dev, VFL_TYPE_GRABBER)<0) + return -1; + + return 0; +} + +/* + * Scan for a PlanB controller, request the irq and map the io memory + */ + +static int find_planb(void) +{ + struct planb *pb; + struct device_node *planb_devices; + unsigned char dev_fn, confreg, bus; + unsigned int old_base, new_base; + unsigned int irq; + + if (_machine != _MACH_Pmac) + return 0; + + planb_devices = find_devices("planb"); + if (planb_devices == 0) { + planb_num=0; + printk(KERN_WARNING "PlanB: no device found!\n"); + return planb_num; + } + + if (planb_devices->next != NULL) + printk(KERN_ERR "Warning: only using first PlanB device!\n"); + pb = &planbs[0]; + planb_num = 1; + + if (planb_devices->n_addrs != 1) { + printk (KERN_WARNING "PlanB: expecting 1 address for planb " + "(got %d)", planb_devices->n_addrs); + return 0; + } + + if (planb_devices->n_intrs == 0) { + printk(KERN_WARNING "PlanB: no intrs for device %s\n", + planb_devices->full_name); + return 0; + } else { + irq = planb_devices->intrs[0].line; + } + + /* Initialize PlanB's PCI registers */ + + /* There is a bug with the way OF assigns addresses + to the devices behind the chaos bridge. + control needs only 0x1000 of space, but decodes only + the upper 16 bits. It therefore occupies a full 64K. + OF assigns the planb controller memory within this space; + so we need to change that here in order to access planb. */ + + /* We remap to 0xf1000000 in hope that nobody uses it ! */ + + bus = (planb_devices->addrs[0].space >> 16) & 0xff; + dev_fn = (planb_devices->addrs[0].space >> 8) & 0xff; + confreg = planb_devices->addrs[0].space & 0xff; + old_base = planb_devices->addrs[0].address; + new_base = 0xf1000000; + + DEBUG("PlanB: Found on bus %d, dev %d, func %d, " + "membase 0x%x (base reg. 0x%x)\n", + bus, PCI_SLOT(dev_fn), PCI_FUNC(dev_fn), old_base, confreg); + + /* Enable response in memory space, bus mastering, + use memory write and invalidate */ + pcibios_write_config_word (bus, dev_fn, PCI_COMMAND, + PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | + PCI_COMMAND_INVALIDATE); + /* Set PCI Cache line size & latency timer */ + pcibios_write_config_byte (bus, dev_fn, PCI_CACHE_LINE_SIZE, 0x8); + pcibios_write_config_byte (bus, dev_fn, PCI_LATENCY_TIMER, 0x40); + + /* Set the new base address */ + pcibios_write_config_dword (bus, dev_fn, confreg, new_base); + + planb_regs = (volatile struct planb_registers *) + ioremap (new_base, 0x400); + pb->planb_base = planb_regs; + pb->planb_base_phys = (struct planb_registers *)new_base; + pb->irq = irq; + + return planb_num; +} + +static void release_planb(void) +{ + int i; + struct planb *pb; + + for (i=0;iplanb_base->ch2); + planb_dbdma_stop(&pb->planb_base->ch1); + + /* clear and free interrupts */ + pb->intr_mask = PLANB_CLR_IRQ; + out_le32 (&pb->planb_base->intr_stat, PLANB_CLR_IRQ); + free_irq(pb->irq, pb); + + /* make sure all allocated memory are freed */ + planb_prepare_close(pb); + + printk(KERN_INFO "PlanB: unregistering with v4l\n"); + video_unregister_device(&pb->video_dev); + + /* note that iounmap() does nothing on the PPC right now */ + iounmap ((void *)pb->planb_base); + } +} + +#ifdef MODULE + +int init_module(void) +{ +#else +__initfunc(int init_planbs(struct video_init *unused)) +{ +#endif + int i; + + if (find_planb()<=0) + return -EIO; + + for (i=0; i +#include "saa7196.h" +#endif /* __KERNEL__ */ + +#define PLANB_DEVICE_NAME "Apple PlanB Video-In" +#define PLANB_REV "1.0" + +#ifdef __KERNEL__ +//#define PLANB_GSCANLINE /* use this if apps have the notion of */ + /* grab buffer scanline */ +/* This should be safe for both PAL and NTSC */ +#define PLANB_MAXPIXELS 768 +#define PLANB_MAXLINES 576 +#define PLANB_NTSC_MAXLINES 480 + +/* Uncomment your preferred norm ;-) */ +#define PLANB_DEF_NORM VIDEO_MODE_PAL +//#define PLANB_DEF_NORM VIDEO_MODE_NTSC +//#define PLANB_DEF_NORM VIDEO_MODE_SECAM + +/* fields settings */ +#define PLANB_GRAY 0x1 /* 8-bit mono? */ +#define PLANB_COLOUR15 0x2 /* 16-bit mode */ +#define PLANB_COLOUR32 0x4 /* 32-bit mode */ +#define PLANB_CLIPMASK 0x8 /* hardware clipmasking */ + +/* misc. flags for PlanB DMA operation */ +#define CH_SYNC 0x1 /* synchronize channels (set by ch1; + cleared by ch2) */ +#define FIELD_SYNC 0x2 /* used for the start of each field + (0 -> 1 -> 0 for ch1; 0 -> 1 for ch2) */ +#define EVEN_FIELD 0x0 /* even field is detected if unset */ +#define DMA_ABORT 0x2 /* error or just out of sync if set */ +#define ODD_FIELD 0x4 /* odd field is detected if set */ + +/* for capture operations */ +#define MAX_GBUFFERS 2 +#ifdef PLANB_GSCANLINE +#define PLANB_MAX_FBUF 0x240000 /* 576 * 1024 * 4 */ +#define TAB_FACTOR (1) +#else +#define PLANB_MAX_FBUF 0x1b0000 /* 576 * 768 * 4 */ +#define TAB_FACTOR (2) +#endif +#endif /* __KERNEL__ */ + +struct planb_saa_regs { + unsigned char addr; + unsigned char val; +}; + +struct planb_stat_regs { + unsigned int ch1_stat; + unsigned int ch2_stat; + unsigned char saa_stat0; + unsigned char saa_stat1; +}; + +struct planb_any_regs { + unsigned int offset; + unsigned int bytes; + unsigned char data[128]; +}; + +/* planb private ioctls */ +#define PLANBIOCGSAAREGS _IOWR('v', BASE_VIDIOCPRIVATE, struct planb_saa_regs) /* Read a saa7196 reg value */ +#define PLANBIOCSSAAREGS _IOW('v', BASE_VIDIOCPRIVATE + 1, struct planb_saa_regs) /* Set a saa7196 reg value */ +#define PLANBIOCGSTAT _IOR('v', BASE_VIDIOCPRIVATE + 2, struct planb_stat_regs) /* Read planb status */ +#define PLANB_TV_MODE 1 +#define PLANB_VTR_MODE 2 +#define PLANBIOCGMODE _IOR('v', BASE_VIDIOCPRIVATE + 3, int) /* Get TV/VTR mode */ +#define PLANBIOCSMODE _IOW('v', BASE_VIDIOCPRIVATE + 4, int) /* Set TV/VTR mode */ + +#ifdef PLANB_GSCANLINE +#define PLANBG_GRAB_BPL _IOR('v', BASE_VIDIOCPRIVATE + 5, int) /* # of bytes per scanline in grab buffer */ +#endif + +/* call wake_up_interruptible() with appropriate actions */ +#define PLANB_INTR_DEBUG _IOW('v', BASE_VIDIOCPRIVATE + 20, int) +/* investigate which reg does what */ +#define PLANB_INV_REGS _IOWR('v', BASE_VIDIOCPRIVATE + 21, struct planb_any_regs) + +#ifdef __KERNEL__ + +/* Potentially useful macros */ +#define PLANB_SET(x) ((x) << 16 | (x)) +#define PLANB_CLR(x) ((x) << 16) + +/* This represents the physical register layout */ +struct planb_registers { + volatile struct dbdma_regs ch1; /* 0x00: video in */ + volatile unsigned int even; /* 0x40: even field setting */ + volatile unsigned int odd; /* 0x44; odd field setting */ + unsigned int pad1[14]; /* empty? */ + volatile struct dbdma_regs ch2; /* 0x80: clipmask out */ + unsigned int pad2[16]; /* 0xc0: empty? */ + volatile unsigned int reg3; /* 0x100: ???? */ + volatile unsigned int intr_stat; /* 0x104: irq status */ +#define PLANB_CLR_IRQ 0x00 /* clear Plan B interrupt */ +#define PLANB_GEN_IRQ 0x01 /* assert Plan B interrupt */ +#define PLANB_FRM_IRQ 0x02 /* end of frame */ +#define PLANB_IRQ_CMD_MASK 0x00000003U /* reserve 2 lsbs for command */ + unsigned int pad3[1]; /* empty? */ + volatile unsigned int reg5; /* 0x10c: ??? */ + unsigned int pad4[60]; /* empty? */ + volatile unsigned char saa_addr; /* 0x200: SAA subadr */ + char pad5[3]; + volatile unsigned char saa_regval; /* SAA7196 write reg. val */ + char pad6[3]; + volatile unsigned char saa_status; /* SAA7196 status byte */ + /* There is more unused stuff here */ +}; + +struct planb_window { + int x, y; + ushort width, height; + ushort bpp, bpl, depth, pad; + ushort swidth, sheight; + int norm; + int interlace; + u32 color_fmt; + int chromakey; + int mode; /* used to switch between TV/VTR modes */ +}; + +struct planb_suspend { + int overlay; + int frame; + struct dbdma_cmd cmd; +}; + +struct planb { + struct video_device video_dev; + struct video_picture picture; /* Current picture params */ + struct video_audio audio_dev; /* Current audio params */ + + volatile struct planb_registers *planb_base; /* virt base of planb */ + struct planb_registers *planb_base_phys; /* phys base of planb */ + void *priv_space; /* Org. alloc. mem for kfree */ + int user; + unsigned int tab_size; + int maxlines; + int lock; + struct wait_queue *lockq; + unsigned int irq; /* interrupt number */ + volatile unsigned int intr_mask; + + int overlay; /* overlay running? */ + struct planb_window win; + unsigned long frame_buffer_phys; /* We need phys for DMA */ + int offset; /* offset of pixel 1 */ + volatile struct dbdma_cmd *ch1_cmd; /* Video In DMA cmd buffer */ + volatile struct dbdma_cmd *ch2_cmd; /* Clip Out DMA cmd buffer */ + volatile struct dbdma_cmd *overlay_last1; + volatile struct dbdma_cmd *overlay_last2; + unsigned long ch1_cmd_phys; + volatile unsigned char *mask; /* Clipmask buffer */ + int suspend; + struct wait_queue *suspendq; + struct planb_suspend suspended; + int cmd_buff_inited; /* cmd buffer inited? */ + + int grabbing; + unsigned int gcount; + struct wait_queue *capq; + int last_fr; + int prev_last_fr; + unsigned char *fbuffer; + unsigned char *gbuffer[MAX_GBUFFERS]; + volatile struct dbdma_cmd *cap_cmd[MAX_GBUFFERS]; + volatile struct dbdma_cmd *last_cmd[MAX_GBUFFERS]; + volatile struct dbdma_cmd *pre_cmd[MAX_GBUFFERS]; + int need_pre_capture[MAX_GBUFFERS]; +#define PLANB_DUMMY 40 /* # of command buf's allocated for pre-capture seq. */ + int gwidth[MAX_GBUFFERS], gheight[MAX_GBUFFERS]; + unsigned int gfmt[MAX_GBUFFERS]; + int gnorm_switch[MAX_GBUFFERS]; + volatile unsigned int *frame_stat; +#define GBUFFER_UNUSED 0x00U +#define GBUFFER_GRABBING 0x01U +#define GBUFFER_DONE 0x02U +#ifdef PLANB_GSCANLINE + int gbytes_per_line; +#else +#define MAX_LNUM 431 /* change this if PLANB_MAXLINES or */ + /* PLANB_MAXPIXELS changes */ + unsigned char *l_fr_addr[MAX_GBUFFERS]; + unsigned char *l_to_addr[MAX_GBUFFERS][MAX_LNUM]; + int lsize[MAX_GBUFFERS], lnum[MAX_GBUFFERS]; +#endif +}; + +#endif /* __KERNEL__ */ + +#endif /* _PLANB_H_ */ diff -u --recursive --new-file v2.2.7/linux/drivers/char/saa7196.h linux/drivers/char/saa7196.h --- v2.2.7/linux/drivers/char/saa7196.h Wed Dec 31 16:00:00 1969 +++ linux/drivers/char/saa7196.h Fri May 7 11:05:30 1999 @@ -0,0 +1,117 @@ +/* + Definitions for the Philips SAA7196 digital video decoder, + scaler, and clock generator circuit (DESCpro), as used in + the PlanB video input of the Powermac 7x00/8x00 series. + + Copyright (C) 1998 Michel Lanners (mlan@cpu.lu) + + The register defines are shamelessly copied from the meteor + driver out of NetBSD (with permission), + and are copyrighted (c) 1995 Mark Tinguely and Jim Lowe + (Thanks !) + + Additional debugging and coding by Takashi Oe (toe@unlinfo.unl.edu) + + The default values used for PlanB are my mistakes. +*/ + +/* $Id: saa7196.h,v 1.5 1999/03/26 23:28:47 mlan Exp $ */ + +#ifndef _SAA7196_H_ +#define _SAA7196_H_ + +#define SAA7196_NUMREGS 0x31 /* Number of registers (used)*/ +#define NUM_SUPPORTED_NORM 3 /* Number of supported norms by PlanB */ + +/* Decoder part: */ +#define SAA7196_IDEL 0x00 /* Increment delay */ +#define SAA7196_HSB5 0x01 /* H-sync begin; 50 hz */ +#define SAA7196_HSS5 0x02 /* H-sync stop; 50 hz */ +#define SAA7196_HCB5 0x03 /* H-clamp begin; 50 hz */ +#define SAA7196_HCS5 0x04 /* H-clamp stop; 50 hz */ +#define SAA7196_HSP5 0x05 /* H-sync after PHI1; 50 hz */ +#define SAA7196_LUMC 0x06 /* Luminance control */ +#define SAA7196_HUEC 0x07 /* Hue control */ +#define SAA7196_CKTQ 0x08 /* Colour Killer Threshold QAM (PAL, NTSC) */ +#define SAA7196_CKTS 0x09 /* Colour Killer Threshold SECAM */ +#define SAA7196_PALS 0x0a /* PAL switch sensitivity */ +#define SAA7196_SECAMS 0x0b /* SECAM switch sensitivity */ +#define SAA7196_CGAINC 0x0c /* Chroma gain control */ +#define SAA7196_STDC 0x0d /* Standard/Mode control */ +#define SAA7196_IOCC 0x0e /* I/O and Clock Control */ +#define SAA7196_CTRL1 0x0f /* Control #1 */ +#define SAA7196_CTRL2 0x10 /* Control #2 */ +#define SAA7196_CGAINR 0x11 /* Chroma Gain Reference */ +#define SAA7196_CSAT 0x12 /* Chroma Saturation */ +#define SAA7196_CONT 0x13 /* Luminance Contrast */ +#define SAA7196_HSB6 0x14 /* H-sync begin; 60 hz */ +#define SAA7196_HSS6 0x15 /* H-sync stop; 60 hz */ +#define SAA7196_HCB6 0x16 /* H-clamp begin; 60 hz */ +#define SAA7196_HCS6 0x17 /* H-clamp stop; 60 hz */ +#define SAA7196_HSP6 0x18 /* H-sync after PHI1; 60 hz */ +#define SAA7196_BRIG 0x19 /* Luminance Brightness */ + +/* Scaler part: */ +#define SAA7196_FMTS 0x20 /* Formats and sequence */ +#define SAA7196_OUTPIX 0x21 /* Output data pixel/line */ +#define SAA7196_INPIX 0x22 /* Input data pixel/line */ +#define SAA7196_HWS 0x23 /* Horiz. window start */ +#define SAA7196_HFILT 0x24 /* Horiz. filter */ +#define SAA7196_OUTLINE 0x25 /* Output data lines/field */ +#define SAA7196_INLINE 0x26 /* Input data lines/field */ +#define SAA7196_VWS 0x27 /* Vertical window start */ +#define SAA7196_VYP 0x28 /* AFS/vertical Y processing */ +#define SAA7196_VBS 0x29 /* Vertical Bypass start */ +#define SAA7196_VBCNT 0x2a /* Vertical Bypass count */ +#define SAA7196_VBP 0x2b /* veritcal Bypass Polarity */ +#define SAA7196_VLOW 0x2c /* Colour-keying lower V limit */ +#define SAA7196_VHIGH 0x2d /* Colour-keying upper V limit */ +#define SAA7196_ULOW 0x2e /* Colour-keying lower U limit */ +#define SAA7196_UHIGH 0x2f /* Colour-keying upper U limit */ +#define SAA7196_DPATH 0x30 /* Data path setting */ + +/* Initialization default values: */ + +unsigned char saa_regs[NUM_SUPPORTED_NORM][SAA7196_NUMREGS] = { + +/* PAL, 768x576 (no scaling), composite video-in */ +/* Decoder: */ + { 0x50, 0x30, 0x00, 0xe8, 0xb6, 0xe5, 0x63, 0xff, + 0xfe, 0xf0, 0xfe, 0xe0, 0x20, 0x06, 0x3b, 0x98, + 0x00, 0x59, 0x41, 0x45, 0x34, 0x0a, 0xf4, 0xd2, + 0xe9, 0xa2, +/* Padding */ + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, +/* Scaler: */ + 0x72, 0x80, 0x00, 0x03, 0x8d, 0x20, 0x20, 0x12, + 0xa5, 0x12, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, + 0x87 }, + +/* NTSC, 640x480? (no scaling), composite video-in */ +/* Decoder: */ + { 0x50, 0x30, 0x00, 0xe8, 0xb6, 0xe5, 0x50, 0x00, + 0xf8, 0xf0, 0xfe, 0xe0, 0x00, 0x06, 0x3b, 0x98, + 0x00, 0x2c, 0x3d, 0x40, 0x34, 0x0a, 0xf4, 0xd2, + 0xe9, 0x98, +/* Padding */ + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, +/* Scaler: */ + 0x72, 0x80, 0x80, 0x03, 0x89, 0xf0, 0xf0, 0x0d, + 0xa0, 0x0d, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, + 0x87 }, + +/* SECAM, 768x576 (no scaling), composite video-in */ +/* Decoder: */ + { 0x50, 0x30, 0x00, 0xe8, 0xb6, 0xe5, 0x63, 0xff, + 0xfe, 0xf0, 0xfe, 0xe0, 0x20, 0x07, 0x3b, 0x98, + 0x00, 0x59, 0x41, 0x45, 0x34, 0x0a, 0xf4, 0xd2, + 0xe9, 0xa2, +/* Padding */ + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, +/* Scaler: */ + 0x72, 0x80, 0x00, 0x03, 0x8d, 0x20, 0x20, 0x12, + 0xa5, 0x12, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, + 0x87 } + }; + +#endif /* _SAA7196_H_ */ diff -u --recursive --new-file v2.2.7/linux/drivers/char/specialix.c linux/drivers/char/specialix.c --- v2.2.7/linux/drivers/char/specialix.c Thu Dec 31 10:29:00 1998 +++ linux/drivers/char/specialix.c Sun May 2 09:51:09 1999 @@ -2355,6 +2355,9 @@ int irq [SX_NBOARD] = {0,}; +MODULE_PARM(iobase,"1-" __MODULE_STRING(SX_NBOARD) "i"); +MODULE_PARM(irq,"1-" __MODULE_STRING(SX_NBOARD) "i"); + /* * You can setup up to 4 boards. * by specifying "iobase=0xXXX,0xXXX ..." as insmod parameter. diff -u --recursive --new-file v2.2.7/linux/drivers/macintosh/Makefile linux/drivers/macintosh/Makefile --- v2.2.7/linux/drivers/macintosh/Makefile Thu Nov 19 09:56:28 1998 +++ linux/drivers/macintosh/Makefile Thu Apr 29 12:53:48 1999 @@ -16,7 +16,7 @@ M_OBJS := ifndef CONFIG_MBX -L_OBJS := via-cuda.o nvram.o macio-adb.o via-pmu.o mediabay.o +L_OBJS := via-cuda.o macio-adb.o via-pmu.o mediabay.o LX_OBJS := adb.o endif @@ -25,6 +25,14 @@ else ifeq ($(CONFIG_MAC_SERIAL),m) M_OBJS += macserial.o + endif +endif + +ifeq ($(CONFIG_NVRAM),y) + L_OBJS += nvram.o +else + ifeq ($(CONFIG_NVRAM),m) + M_OBJS += nvram.o endif endif diff -u --recursive --new-file v2.2.7/linux/drivers/macintosh/adb.c linux/drivers/macintosh/adb.c --- v2.2.7/linux/drivers/macintosh/adb.c Fri Apr 16 14:47:30 1999 +++ linux/drivers/macintosh/adb.c Thu Apr 29 12:53:48 1999 @@ -3,8 +3,19 @@ * and the /dev/adb device on macintoshes. * * Copyright (C) 1996 Paul Mackerras. + * + * Modified to declare controllers as structures, added + * client notification of bus reset and handles PowerBook + * sleep, by Benjamin Herrenschmidt. + * + * To do: + * + * - /proc/adb to list the devices and infos + * - more /dev/adb to allow userland to receive the + * flow of auto-polling datas from a given device. */ +#include #include #include #include @@ -21,12 +32,23 @@ #include #include +EXPORT_SYMBOL(adb_controller); +EXPORT_SYMBOL(adb_client_list); EXPORT_SYMBOL(adb_hardware); +struct adb_controller *adb_controller = NULL; +struct notifier_block *adb_client_list = NULL; enum adb_hw adb_hardware = ADB_NONE; -int (*adb_send_request)(struct adb_request *req, int sync); -int (*adb_autopoll)(int devs); -int (*adb_reset_bus)(void); + +#ifdef CONFIG_PMAC_PBOOK +static int adb_notify_sleep(struct notifier_block *, unsigned long, void *); +static struct notifier_block adb_sleep_notifier = { + adb_notify_sleep, + NULL, + 0 +}; +#endif + static int adb_scan_bus(void); static struct adb_handler { @@ -35,13 +57,6 @@ int handler_id; } adb_handler[16]; -__openfirmware - -static int adb_nodev(void) -{ - return -1; -} - #if 0 static void printADBreply(struct adb_request *req) { @@ -61,8 +76,6 @@ int devmask = 0; struct adb_request req; - adb_reset_bus(); /* reset ADB bus */ - /* assumes adb_handler[] is all zeroes at this point */ for (i = 1; i < 16; i++) { /* see if there is anything at address i */ @@ -147,22 +160,96 @@ void adb_init(void) { - adb_send_request = (void *) adb_nodev; - adb_autopoll = (void *) adb_nodev; - adb_reset_bus = adb_nodev; if ( (_machine != _MACH_chrp) && (_machine != _MACH_Pmac) ) return; + via_cuda_init(); via_pmu_init(); macio_adb_init(); - if (adb_hardware == ADB_NONE) + + if (adb_controller == NULL) printk(KERN_WARNING "Warning: no ADB interface detected\n"); - else { - int devs = adb_scan_bus(); - adb_autopoll(devs); + else + { + adb_hardware = adb_controller->kind; +#ifdef CONFIG_PMAC_PBOOK + notifier_chain_register(&sleep_notifier_list, + &adb_sleep_notifier); +#endif /* CONFIG_PMAC_PBOOK */ + + adb_reset_bus(); + } +} + + +#ifdef CONFIG_PMAC_PBOOK +/* + * notify clients before sleep and reset bus afterwards + */ +int +adb_notify_sleep(struct notifier_block *this, unsigned long code, void *x) +{ + int ret; + + switch (code) { + case PBOOK_SLEEP: + ret = notifier_call_chain(&adb_client_list, ADB_MSG_POWERDOWN, NULL); + if (ret & NOTIFY_STOP_MASK) + return -EBUSY; + case PBOOK_WAKE: + adb_reset_bus(); + break; + } + return NOTIFY_DONE; +} +#endif /* CONFIG_PMAC_PBOOK */ + +int +adb_reset_bus(void) +{ + int ret, devs; + unsigned long flags; + + if (adb_controller == NULL) + return -ENXIO; + + ret = notifier_call_chain(&adb_client_list, ADB_MSG_PRE_RESET, NULL); + if (ret & NOTIFY_STOP_MASK) + return -EBUSY; + + save_flags(flags); + cli(); + memset(adb_handler, 0, sizeof(adb_handler)); + restore_flags(flags); + + if (adb_controller->reset_bus) + ret = adb_controller->reset_bus(); + else + ret = 0; + + if (!ret) + { + devs = adb_scan_bus(); + if (adb_controller->autopoll) + adb_controller->autopoll(devs); } + + ret = notifier_call_chain(&adb_client_list, ADB_MSG_POST_RESET, NULL); + if (ret & NOTIFY_STOP_MASK) + return -EBUSY; + + return 1; +} + +void +adb_poll(void) +{ + if ((adb_controller == NULL)||(adb_controller->poll == NULL)) + return; + adb_controller->poll(); } + int adb_request(struct adb_request *req, void (*done)(struct adb_request *), int flags, int nbytes, ...) @@ -171,18 +258,25 @@ int i; struct adb_request sreq; + if ((adb_controller == NULL) || (adb_controller->send_request == NULL)) + return -ENXIO; + if (nbytes < 1) + return -EINVAL; + if (req == NULL) { req = &sreq; flags |= ADBREQ_SYNC; } - req->nbytes = nbytes; + req->nbytes = nbytes+1; req->done = done; req->reply_expected = flags & ADBREQ_REPLY; + req->data[0] = ADB_PACKET; va_start(list, nbytes); for (i = 0; i < nbytes; ++i) - req->data[i] = va_arg(list, int); + req->data[i+1] = va_arg(list, int); va_end(list); - return adb_send_request(req, flags & ADBREQ_SYNC); + + return adb_controller->send_request(req, flags & ADBREQ_SYNC); } /* Ultimately this should return the number of devices with @@ -247,7 +341,7 @@ if (req.reply_len < 2) return 0; adb_request(&req, NULL, ADBREQ_SYNC, 3, - ADB_WRITEREG(address, 3), req.reply[1], new_id); + ADB_WRITEREG(address, 3), req.reply[1] & 0xF0, new_id); adb_request(&req, NULL, ADBREQ_SYNC | ADBREQ_REPLY, 1, ADB_READREG(address, 3)); if (req.reply_len < 2) @@ -318,7 +412,7 @@ { struct adbdev_state *state; - if (MINOR(inode->i_rdev) > 0 || adb_hardware == ADB_NONE) + if (MINOR(inode->i_rdev) > 0 || (adb_controller == NULL)/*adb_hardware == ADB_NONE*/) return -ENXIO; state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL); if (state == 0) @@ -420,7 +514,7 @@ static ssize_t adb_write(struct file *file, const char *buf, size_t count, loff_t *ppos) { - int ret, i; + int ret/*, i*/; struct adbdev_state *state = file->private_data; struct adb_request *req; @@ -439,36 +533,26 @@ req->done = adb_write_done; req->arg = (void *) state; req->complete = 0; - + ret = -EFAULT; if (copy_from_user(req->data, buf, count)) goto out; atomic_inc(&state->n_pending); - switch (adb_hardware) { - case ADB_NONE: - ret = -ENXIO; - break; - case ADB_VIACUDA: - req->reply_expected = 1; - ret = cuda_send_request(req); - break; - case ADB_VIAPMU: - if (req->data[0] != ADB_PACKET) { - ret = pmu_send_request(req); - break; - } - /* else fall through */ - default: - ret = -EINVAL; - if (req->data[0] != ADB_PACKET) - break; - for (i = 0; i < req->nbytes-1; ++i) - req->data[i] = req->data[i+1]; - req->nbytes--; - req->reply_expected = ((req->data[0] & 0xc) == 0xc); - ret = adb_send_request(req, 0); - break; + + /* Special case for ADB_BUSRESET request, all others are sent to + the controller */ + if ((req->data[0] == ADB_PACKET)&&(count > 1) + &&(req->data[1] == ADB_BUSRESET)) + ret = adb_reset_bus(); + else + { + req->reply_expected = ((req->data[1] & 0xc) == 0xc); + + if (adb_controller && adb_controller->send_request) + ret = adb_controller->send_request(req, 0); + else + ret = -ENXIO; } if (ret != 0) { diff -u --recursive --new-file v2.2.7/linux/drivers/macintosh/mac_keyb.c linux/drivers/macintosh/mac_keyb.c --- v2.2.7/linux/drivers/macintosh/mac_keyb.c Wed Apr 28 11:37:30 1999 +++ linux/drivers/macintosh/mac_keyb.c Thu Apr 29 12:53:48 1999 @@ -7,6 +7,27 @@ * (see that file for its authors and contributors). * * Copyright (C) 1996 Paul Mackerras. + * + * Adapted to ADB changes and support for more devices by + * Benjamin Herrenschmidt. Adapted from code in MkLinux + * and reworked. + * + * Supported devices: + * + * - Standard 1 button mouse + * - All standard Apple Extended protocol (handler ID 4) + * mice & trackballs + * - PowerBook Trackpad (default setup: enable tapping) + * - MicroSpeed mouse & trackball (needs testing) + * - CH Products Trackball Pro (needs testing) + * - Contour Design (Contour Mouse) + * - Hunter digital (NoHandsMouse) + * - Kensignton TurboMouse 5 (needs testing) + * + * To do: + * + * Improve Kensignton support, add MacX support as a dynamic + * option (not a compile-time option). */ #include @@ -32,6 +53,41 @@ #define KEYB_LEDREG 2 /* register # for leds on ADB keyboard */ #define MOUSE_DATAREG 0 /* reg# for movement/button codes from mouse */ +static int adb_message_handler(struct notifier_block *, unsigned long, void *); +static struct notifier_block mackeyb_adb_notifier = { + adb_message_handler, + NULL, + 0 +}; + +/* this map indicates which keys shouldn't autorepeat. */ +static unsigned char dont_repeat[128] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* esc...option */ + 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, /* fn, num lock */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, /* scroll lock */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +/* Simple translation table for the SysRq keys */ + +#ifdef CONFIG_MAGIC_SYSRQ +unsigned char mackbd_sysrq_xlate[128] = + "asdfhgzxcv\000bqwer" /* 0x00 - 0x0f */ + "yt123465=97-80o]" /* 0x10 - 0x1f */ + "u[ip\rlj'k;\\,/nm." /* 0x20 - 0x2f */ + "\t `\177\000\033\000\000\000\000\000\000\000\000\000\000" + /* 0x30 - 0x3f */ + "\000\000\000*\000+\000\000\000\000\000/\r\000-\000" + /* 0x40 - 0x4f */ + "\000\0000123456789\000\000\000" /* 0x50 - 0x5f */ + "\205\206\207\203\210\211\000\213\000\215\000\000\000\000\000\212\000\214"; + /* 0x60 - 0x6f */ +#endif + static u_short macplain_map[NR_KEYS] __initdata = { 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb68, 0xfb67, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xf200, 0xfb62, 0xfb71, 0xfb77, 0xfb65, 0xfb72, @@ -170,6 +226,8 @@ static struct timer_list repeat_timer = { NULL, NULL, 0, 0, kbd_repeat }; static int last_keycode; +static void mackeyb_probe(void); + static void keyboard_input(unsigned char *, int, struct pt_regs *, int); static void input_keycode(int, int); static void leds_done(struct adb_request *); @@ -180,6 +238,7 @@ static void init_trackpad(int id); static void init_trackball(int id); static void init_turbomouse(int id); +static void init_microspeed(int id); #ifdef CONFIG_ADBMOUSE /* XXX: Hook for mouse driver */ @@ -207,21 +266,11 @@ #define ADBMOUSE_TRACKBALL 3 /* TrackBall (handler 4) */ #define ADBMOUSE_TRACKPAD 4 /* Apple's PowerBook trackpad (handler 4) */ #define ADBMOUSE_TURBOMOUSE5 5 /* Turbomouse 5 (previously req. mousehack) */ +#define ADBMOUSE_MICROSPEED 6 /* Microspeed mouse (&trackball ?), MacPoint */ +#define ADBMOUSE_TRACKBALLPRO 7 /* Trackball Pro (special buttons) */ static int adb_mouse_kinds[16]; -/* this map indicates which keys shouldn't autorepeat. */ -static unsigned char dont_repeat[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* esc...option */ - 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, /* fn, num lock */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, /* scroll lock */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - __openfirmware int mackbd_setkeycode(unsigned int scancode, unsigned int keycode) @@ -281,6 +330,10 @@ /* on the powerbook 3400, the power key gives code 0x7e */ if (keycode == 0x7e) keycode = 0x7f; + /* remap the "Fn" key of the PowerBook G3 Series to 0x48 + to avoid conflict with button emulation */ + if (keycode == 0x3f) + keycode = 0x48; if (!repeat) del_timer(&repeat_timer); @@ -441,9 +494,24 @@ the first (the real) button is released. We could do this here using async flush requests. */ - if (adb_mouse_kinds[(data[0]>>4) & 0xf] == ADBMOUSE_TRACKPAD) { + switch (adb_mouse_kinds[(data[0]>>4) & 0xf]) + { + case ADBMOUSE_TRACKPAD: data[1] = (data[1] & 0x7f) | ((data[1] & data[2]) & 0x80); - data[2] = (data[2] & 0x7f) | 0x80; + data[2] = data[2] | 0x80; + break; + case ADBMOUSE_MICROSPEED: + data[1] = (data[1] & 0x7f) | ((data[3] & 0x01) << 7); + data[2] = (data[2] & 0x7f) | ((data[3] & 0x02) << 6); + data[3] = (data[3] & 0x77) | ((data[3] & 0x04) << 5) + | (data[3] & 0x08); + break; + case ADBMOUSE_TRACKBALLPRO: + data[1] = (data[1] & 0x7f) | (((data[3] & 0x04) << 5) + & ((data[3] & 0x08) << 4)); + data[2] = (data[2] & 0x7f) | ((data[3] & 0x01) << 7); + data[3] = (data[3] & 0x77) | ((data[3] & 0x02) << 6); + break; } if (adb_mouse_interrupt_hook) @@ -473,7 +541,7 @@ } /* Macintosh 3-button mouse (handler 4). */ - if (nb == 4) { + if (nb >= 4) { static unsigned char uch_ButtonStateThird = 0x80; unsigned char uchButtonThird; @@ -608,9 +676,6 @@ __initfunc(void mackbd_init_hw(void)) { - struct adb_request req; - int i; - if ( (_machine != _MACH_chrp) && (_machine != _MACH_Pmac) ) return; @@ -626,71 +691,127 @@ #ifdef CONFIG_ADBMOUSE /* initialize mouse interrupt hook */ adb_mouse_interrupt_hook = NULL; +#endif + + led_request.complete = 1; + + mackeyb_probe(); + + notifier_chain_register(&adb_client_list, &mackeyb_adb_notifier); +} + +static int +adb_message_handler(struct notifier_block *this, unsigned long code, void *x) +{ + switch (code) { + case ADB_MSG_PRE_RESET: + case ADB_MSG_POWERDOWN: + /* Add unregister_keyboard when merging with Paul Mackerras */ + while(!led_request.complete) + adb_poll(); + break; + + case ADB_MSG_POST_RESET: + mackeyb_probe(); + break; + } + return NOTIFY_DONE; +} +static void +mackeyb_probe(void) +{ + struct adb_request req; + int i; + +#ifdef CONFIG_ADBMOUSE adb_register(ADB_MOUSE, 0, &mouse_ids, mouse_input); #endif /* CONFIG_ADBMOUSE */ adb_register(ADB_KEYBOARD, 0, &keyboard_ids, keyboard_input); adb_register(0x07, 0x1F, &buttons_ids, buttons_input); - for(i = 0; i < keyboard_ids.nids; i++) { - /* turn off all leds */ - adb_request(&req, NULL, ADBREQ_SYNC, 3, - ADB_WRITEREG(keyboard_ids.id[i], KEYB_LEDREG), 0xff, 0xff); - } + for (i = 0; i < keyboard_ids.nids; i++) { + int id = keyboard_ids.id[i]; - /* Enable full feature set of the keyboard - ->get it to send separate codes for left and right shift, - control, option keys */ - for(i = 0;i < keyboard_ids.nids; i++) { - if (adb_try_handler_change(keyboard_ids.id[i], 5)) - printk("ADB keyboard at %d, handler set to 5\n", keyboard_ids.id[i]); - else if (adb_try_handler_change(keyboard_ids.id[i], 3)) - printk("ADB keyboard at %d, handler set to 3\n", keyboard_ids.id[i]); - else - printk("ADB keyboard at %d, handler 1\n", keyboard_ids.id[i]); + /* turn off all leds */ + adb_request(&req, NULL, ADBREQ_SYNC, 3, + ADB_WRITEREG(id, KEYB_LEDREG), 0xff, 0xff); + + /* Enable full feature set of the keyboard + ->get it to send separate codes for left and right shift, + control, option keys */ + if (adb_try_handler_change(id, 5)) + printk("ADB keyboard at %d, handler set to 5\n", id); + else if (adb_try_handler_change(id, 3)) + printk("ADB keyboard at %d, handler set to 3\n", id); + else + printk("ADB keyboard at %d, handler 1\n", id); } - led_request.complete = 1; - /* Try to switch all mice to handler 4, or 2 for three-button mode and full resolution. */ - for(i = 0; i < mouse_ids.nids; i++) { - if (adb_try_handler_change(mouse_ids.id[i], 4)) { - printk("ADB mouse at %d, handler set to 4", mouse_ids.id[i]); - adb_mouse_kinds[mouse_ids.id[i]] = ADBMOUSE_EXTENDED; - } - else if (adb_try_handler_change(mouse_ids.id[i], 2)) { - printk("ADB mouse at %d, handler set to 2", mouse_ids.id[i]); - adb_mouse_kinds[mouse_ids.id[i]] = ADBMOUSE_STANDARD_200; - } - else { - printk("ADB mouse at %d, handler 1", mouse_ids.id[i]); - adb_mouse_kinds[mouse_ids.id[i]] = ADBMOUSE_STANDARD_100; - } - - /* Register 1 is usually used for device identification. - Here, we try to identify a known device and call the - appropriate init function */ - adb_request(&req, NULL, ADBREQ_SYNC | ADBREQ_REPLY, 1, - ADB_READREG(mouse_ids.id[i], 1)); - - if ((req.reply_len) && - (req.reply[1] == 0x9a) && (req.reply[2] == 0x21)) - init_trackball(mouse_ids.id[i]); - else if ((req.reply_len >= 4) && - (req.reply[1] == 0x74) && (req.reply[2] == 0x70) && - (req.reply[3] == 0x61) && (req.reply[4] == 0x64)) - init_trackpad(mouse_ids.id[i]); - else if ((req.reply_len >= 4) && - (req.reply[1] == 0x4b) && (req.reply[2] == 0x4d) && - (req.reply[3] == 0x4c) && (req.reply[4] == 0x31)) - init_turbomouse(mouse_ids.id[i]); - printk("\n"); + for (i = 0; i < mouse_ids.nids; i++) { + int id = mouse_ids.id[i]; + if (adb_try_handler_change(id, 4)) { + printk("ADB mouse at %d, handler set to 4", id); + adb_mouse_kinds[id] = ADBMOUSE_EXTENDED; + } + else if (adb_try_handler_change(id, 2)) { + printk("ADB mouse at %d, handler set to 2", id); + adb_mouse_kinds[id] = ADBMOUSE_STANDARD_200; + } + else if (adb_try_handler_change(id, 0x2F)) { + printk("ADB mouse at %d, handler set to 0x2F", id); + adb_mouse_kinds[id] = ADBMOUSE_MICROSPEED; + } + else if (adb_try_handler_change(id, 0x42)) { + printk("ADB mouse at %d, handler set to 0x42", id); + adb_mouse_kinds[id] = ADBMOUSE_TRACKBALLPRO; + } + else if (adb_try_handler_change(id, 0x66)) { + printk("ADB mouse at %d, handler set to 0x66", id); + adb_mouse_kinds[id] = ADBMOUSE_MICROSPEED; + } + else if (adb_try_handler_change(id, 0x5F)) { + printk("ADB mouse at %d, handler set to 0x5F", id); + adb_mouse_kinds[id] = ADBMOUSE_MICROSPEED; + } + else { + printk("ADB mouse at %d, handler 1", id); + adb_mouse_kinds[id] = ADBMOUSE_STANDARD_100; + } + + if ((adb_mouse_kinds[id] == ADBMOUSE_TRACKBALLPRO) + || (adb_mouse_kinds[id] == ADBMOUSE_MICROSPEED)) { + init_microspeed(id); + } else if (adb_mouse_kinds[id] == ADBMOUSE_EXTENDED) { + /* + * Register 1 is usually used for device + * identification. Here, we try to identify + * a known device and call the appropriate + * init function. + */ + adb_request(&req, NULL, ADBREQ_SYNC | ADBREQ_REPLY, 1, + ADB_READREG(id, 1)); + + if ((req.reply_len) && + (req.reply[1] == 0x9a) && (req.reply[2] == 0x21)) + init_trackball(id); + else if ((req.reply_len >= 4) && + (req.reply[1] == 0x74) && (req.reply[2] == 0x70) && + (req.reply[3] == 0x61) && (req.reply[4] == 0x64)) + init_trackpad(id); + else if ((req.reply_len >= 4) && + (req.reply[1] == 0x4b) && (req.reply[2] == 0x4d) && + (req.reply[3] == 0x4c) && (req.reply[4] == 0x31)) + init_turbomouse(id); + } + printk("\n"); } } -__init static void +static void init_trackpad(int id) { struct adb_request req; @@ -716,7 +837,7 @@ r1_buffer[4], r1_buffer[5], 0x0d, /*r1_buffer[6],*/ - r1_buffer[7]); + r1_buffer[7]); adb_request(&req, NULL, ADBREQ_SYNC, 9, ADB_WRITEREG(id,2), @@ -742,7 +863,7 @@ } } -__init static void +static void init_trackball(int id) { struct adb_request req; @@ -776,7 +897,7 @@ ADB_WRITEREG(id,1), 03,0x38); } -__init static void +static void init_turbomouse(int id) { struct adb_request req; @@ -785,6 +906,13 @@ adb_mouse_kinds[id] = ADBMOUSE_TURBOMOUSE5; + adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id)); + + adb_request(&req, NULL, ADBREQ_SYNC, 3, + ADB_WRITEREG(id,3), 0x20 | id, 4); + + adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id)); + adb_request(&req, NULL, ADBREQ_SYNC, 9, ADB_WRITEREG(id,2), 0xe7, @@ -809,3 +937,44 @@ 0xff, 0x27); } + +static void +init_microspeed(int id) +{ + struct adb_request req; + + printk(" (Microspeed/MacPoint or compatible)"); + + adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id)); + + /* This will initialize mice using the Microspeed, MacPoint and + other compatible firmware. Bit 12 enables extended protocol. + + Register 1 Listen (4 Bytes) + 0 - 3 Button is mouse (set also for double clicking!!!) + 4 - 7 Button is locking (affects change speed also) + 8 - 11 Button changes speed + 12 1 = Extended mouse mode, 0 = normal mouse mode + 13 - 15 unused 0 + 16 - 23 normal speed + 24 - 31 changed speed + + Register 1 talk holds version and product identification information. + Register 1 Talk (4 Bytes): + 0 - 7 Product code + 8 - 23 undefined, reserved + 24 - 31 Version number + + Speed 0 is max. 1 to 255 set speed in increments of 1/256 of max. + */ + adb_request(&req, NULL, ADBREQ_SYNC, 5, + ADB_WRITEREG(id,1), + 0x20, /* alt speed = 0x20 (rather slow) */ + 0x00, /* norm speed = 0x00 (fastest) */ + 0x10, /* extended protocol, no speed change */ + 0x07); /* all buttons enabled as mouse buttons, no locking */ + + + adb_request(&req, NULL, ADBREQ_SYNC, 1, ADB_FLUSH(id)); +} + diff -u --recursive --new-file v2.2.7/linux/drivers/macintosh/macio-adb.c linux/drivers/macintosh/macio-adb.c --- v2.2.7/linux/drivers/macintosh/macio-adb.c Thu Nov 19 09:56:28 1998 +++ linux/drivers/macintosh/macio-adb.c Thu Apr 29 12:53:48 1999 @@ -63,9 +63,17 @@ static int macio_adb_send_request(struct adb_request *req, int sync); static int macio_adb_autopoll(int devs); static void macio_adb_poll(void); -static int macio_reset_bus(void); +static int macio_adb_reset_bus(void); static void completed(void); +static struct adb_controller macio_controller = { + ADB_MACIO, + macio_adb_send_request, + macio_adb_autopoll, + macio_adb_reset_bus, + macio_adb_poll +}; + __openfirmware void macio_adb_init(void) @@ -106,10 +114,12 @@ out_8(&adb->autopoll.r, APE); out_8(&adb->intr_enb.r, DFB | TAG); - adb_hardware = ADB_MACIO; - adb_send_request = macio_adb_send_request; - adb_autopoll = macio_adb_autopoll; - adb_reset_bus = macio_reset_bus; + adb_controller = &macio_controller; +// adb_hardware = ADB_MACIO; + +// adb_send_request = macio_adb_send_request; +// adb_autopoll = macio_adb_autopoll; +// adb_reset_bus = macio_reset_bus; } static int macio_adb_autopoll(int devs) @@ -120,7 +130,7 @@ return 0; } -static int macio_reset_bus(void) +static int macio_adb_reset_bus(void) { int timeout = 1000000; @@ -138,7 +148,15 @@ static int macio_adb_send_request(struct adb_request *req, int sync) { unsigned long mflags; - + int i; + + if (req->data[0] != ADB_PACKET) + return -EINVAL; + + for (i = 0; i < req->nbytes - 1; ++i) + req->data[i] = req->data[i+1]; + --req->nbytes; + req->next = 0; req->sent = 0; req->complete = 0; diff -u --recursive --new-file v2.2.7/linux/drivers/macintosh/macserial.c linux/drivers/macintosh/macserial.c --- v2.2.7/linux/drivers/macintosh/macserial.c Tue Mar 23 14:35:47 1999 +++ linux/drivers/macintosh/macserial.c Thu Apr 29 12:53:48 1999 @@ -1986,6 +1986,7 @@ info->line = i; info->tty = 0; info->custom_divisor = 16; + info->timeout = 0; info->close_delay = 50; info->closing_wait = 3000; info->x_char = 0; @@ -2058,6 +2059,32 @@ static void serial_console_write(struct console *co, const char *s, unsigned count) { + struct mac_serial *info = zs_soft + co->index; + int i; + + /* Turn of interrupts and enable the transmitter. */ + write_zsreg(info->zs_channel, R1, info->curregs[1] & ~TxINT_ENAB); + write_zsreg(info->zs_channel, R5, info->curregs[5] | TxENAB | RTS | DTR); + + for (i=0; izs_channel, 0) & Tx_BUF_EMP) == 0) { + eieio(); + } + + write_zsdata(info->zs_channel, s[i]); + if (s[i] == 10) { + while ((read_zsreg(info->zs_channel, 0) & Tx_BUF_EMP) + == 0) + eieio(); + + write_zsdata(info->zs_channel, 13); + } + } + + /* Restore the values in the registers. */ + write_zsreg(info->zs_channel, R1, info->curregs[1]); + /* Don't disable the transmitter. */ } /* @@ -2065,7 +2092,23 @@ */ static int serial_console_wait_key(struct console *co) { - return 0; + struct mac_serial *info = zs_soft + co->index; + int val; + + /* Turn of interrupts and enable the transmitter. */ + write_zsreg(info->zs_channel, R1, info->curregs[1] & ~INT_ALL_Rx); + write_zsreg(info->zs_channel, R3, info->curregs[3] | RxENABLE); + + /* Wait for something in the receive buffer. */ + while((read_zsreg(info->zs_channel, 0) & Rx_CH_AV) == 0) + eieio(); + val = read_zsdata(info->zs_channel); + + /* Restore the values in the registers. */ + write_zsreg(info->zs_channel, R1, info->curregs[1]); + write_zsreg(info->zs_channel, R3, info->curregs[3]); + + return val; } static kdev_t serial_console_device(struct console *c) @@ -2081,14 +2124,24 @@ */ __initfunc(static int serial_console_setup(struct console *co, char *options)) { - struct serial_state *ser; - unsigned cval; - int baud = 9600; + struct mac_serial *info = zs_soft + co->index; + int baud = 38400; int bits = 8; int parity = 'n'; int cflag = CREAD | HUPCL | CLOCAL; - int quot = 0; + int brg; char *s; + long flags; + + /* Find out how many Z8530 SCCs we have */ + if (zs_chain == 0) + probe_sccs(); + + if (zs_chain == 0) + return -1; + + /* Reset the channel */ + write_zsreg(info->zs_channel, R9, CHRA); if (options) { baud = simple_strtoul(options, NULL, 10); @@ -2114,21 +2167,21 @@ case 4800: cflag |= B4800; break; + case 9600: + cflag |= B9600; + break; case 19200: cflag |= B19200; break; - case 38400: - cflag |= B38400; - break; case 57600: cflag |= B57600; break; case 115200: cflag |= B115200; break; - case 9600: + case 38400: default: - cflag |= B9600; + cflag |= B38400; break; } switch(bits) { @@ -2142,7 +2195,7 @@ } switch(parity) { case 'o': case 'O': - cflag |= PARODD; + cflag |= PARENB | PARODD; break; case 'e': case 'E': cflag |= PARENB; @@ -2150,6 +2203,90 @@ } co->cflag = cflag; + save_flags(flags); cli(); + memset(info->curregs, 0, sizeof(info->curregs)); + + info->zs_baud = baud; + info->clk_divisor = 16; + switch (info->zs_baud) { + case ZS_CLOCK/16: /* 230400 */ + info->curregs[4] = X16CLK; + info->curregs[11] = 0; + break; + case ZS_CLOCK/32: /* 115200 */ + info->curregs[4] = X32CLK; + info->curregs[11] = 0; + break; + default: + info->curregs[4] = X16CLK; + info->curregs[11] = TCBR | RCBR; + brg = BPS_TO_BRG(info->zs_baud, ZS_CLOCK/info->clk_divisor); + info->curregs[12] = (brg & 255); + info->curregs[13] = ((brg >> 8) & 255); + info->curregs[14] = BRENABL; + } + + /* byte size and parity */ + info->curregs[3] &= ~RxNBITS_MASK; + info->curregs[5] &= ~TxNBITS_MASK; + switch (cflag & CSIZE) { + case CS5: + info->curregs[3] |= Rx5; + info->curregs[5] |= Tx5; + break; + case CS6: + info->curregs[3] |= Rx6; + info->curregs[5] |= Tx6; + break; + case CS7: + info->curregs[3] |= Rx7; + info->curregs[5] |= Tx7; + break; + case CS8: + default: /* defaults to 8 bits */ + info->curregs[3] |= Rx8; + info->curregs[5] |= Tx8; + break; + } + info->curregs[5] |= TxENAB | RTS | DTR; + info->pendregs[3] = info->curregs[3]; + info->pendregs[5] = info->curregs[5]; + + info->curregs[4] &= ~(SB_MASK | PAR_ENA | PAR_EVEN); + if (cflag & CSTOPB) { + info->curregs[4] |= SB2; + } else { + info->curregs[4] |= SB1; + } + if (cflag & PARENB) { + info->curregs[4] |= PAR_ENA; + if (!(cflag & PARODD)) { + info->curregs[4] |= PAR_EVEN; + } + } + info->pendregs[4] = info->curregs[4]; + + if (!(cflag & CLOCAL)) { + if (!(info->curregs[15] & DCDIE)) + info->read_reg_zero = read_zsreg(info->zs_channel, 0); + info->curregs[15] |= DCDIE; + } else + info->curregs[15] &= ~DCDIE; + if (cflag & CRTSCTS) { + info->curregs[15] |= CTSIE; + if ((read_zsreg(info->zs_channel, 0) & CTS) != 0) + info->tx_stopped = 1; + } else { + info->curregs[15] &= ~CTSIE; + info->tx_stopped = 0; + } + info->pendregs[15] = info->curregs[15]; + + /* Load up the new values */ + load_zsregs(info->zs_channel, info->curregs); + + restore_flags(flags); + return 0; } @@ -2170,9 +2307,10 @@ /* * Register console. */ -__initfunc (void serial_console_init(void)) +__initfunc (long serial_console_init(long kmem_start, long kmem_end)) { register_console(&sercons); + return kmem_start; } #endif /* ifdef CONFIG_SERIAL_CONSOLE */ diff -u --recursive --new-file v2.2.7/linux/drivers/macintosh/nvram.c linux/drivers/macintosh/nvram.c --- v2.2.7/linux/drivers/macintosh/nvram.c Wed Aug 26 11:37:38 1998 +++ linux/drivers/macintosh/nvram.c Thu Apr 29 12:53:48 1999 @@ -1,6 +1,11 @@ /* * /dev/nvram driver for Power Macintosh. */ + +#define NVRAM_VERSION "1.0" + +#include + #include #include #include @@ -9,11 +14,14 @@ #include #include #include -#include #define NVRAM_SIZE 8192 +/* when building as a module, __openfirmware is both unavailable + * and unnecessary. */ +#ifndef MODULE __openfirmware +#endif static long long nvram_llseek(struct file *file, loff_t offset, int origin) { @@ -70,6 +78,13 @@ static int nvram_open(struct inode *inode, struct file *file) { + MOD_INC_USE_COUNT; + return 0; +} + +static int nvram_release(struct inode *inode, struct file *file) +{ + MOD_DEC_USE_COUNT; return 0; } @@ -83,7 +98,7 @@ NULL, /* nvram_mmap */ nvram_open, NULL, /* flush */ - NULL, /* no special release code */ + nvram_release, NULL /* fsync */ }; @@ -95,6 +110,19 @@ __initfunc(int nvram_init(void)) { + printk(KERN_INFO "Macintosh non-volatile memory driver v%s\n", + NVRAM_VERSION); misc_register(&nvram_dev); return 0; } +#ifdef MODULE +int init_module (void) +{ + return( nvram_init() ); +} + +void cleanup_module (void) +{ + misc_deregister( &nvram_dev ); +} +#endif diff -u --recursive --new-file v2.2.7/linux/drivers/macintosh/via-cuda.c linux/drivers/macintosh/via-cuda.c --- v2.2.7/linux/drivers/macintosh/via-cuda.c Thu Nov 19 09:56:28 1998 +++ linux/drivers/macintosh/via-cuda.c Thu Apr 29 12:53:48 1999 @@ -74,6 +74,7 @@ static int reading_reply; static int data_index; static struct device_node *vias; +static int cuda_fully_inited = 0; static int init_via(void); static void cuda_start(void); @@ -81,7 +82,17 @@ static void cuda_input(unsigned char *buf, int nb, struct pt_regs *regs); static int cuda_adb_send_request(struct adb_request *req, int sync); static int cuda_adb_autopoll(int devs); -static int cuda_reset_bus(void); +static int cuda_adb_reset_bus(void); +static int cuda_send_request(struct adb_request *req); + + +static struct adb_controller cuda_controller = { + ADB_VIACUDA, + cuda_adb_send_request, + cuda_adb_autopoll, + cuda_adb_reset_bus, + cuda_poll +}; __openfirmware @@ -121,7 +132,7 @@ via = NULL; } - adb_hardware = ADB_VIACUDA; + adb_controller = &cuda_controller; } void @@ -139,10 +150,7 @@ via[IFR] = 0x7f; eieio(); /* clear interrupts by writing 1s */ via[IER] = IER_SET|SR_INT; eieio(); /* enable interrupt from SR */ - /* Set function pointers */ - adb_send_request = cuda_adb_send_request; - adb_autopoll = cuda_adb_autopoll; - adb_reset_bus = cuda_reset_bus; + cuda_fully_inited = 1; } #define WAIT_FOR(cond, what) \ @@ -201,14 +209,17 @@ { int i; - for (i = req->nbytes; i > 0; --i) - req->data[i] = req->data[i-1]; - req->data[0] = ADB_PACKET; - ++req->nbytes; + if ((via == NULL) || !cuda_fully_inited) { + req->complete = 1; + return -ENXIO; + } + req->reply_expected = 1; + i = cuda_send_request(req); if (i) return i; + if (sync) { while (!req->complete) cuda_poll(); @@ -216,12 +227,16 @@ return 0; } + /* Enable/disable autopolling */ static int cuda_adb_autopoll(int devs) { struct adb_request req; + if ((via == NULL) || !cuda_fully_inited) + return -ENXIO; + cuda_request(&req, NULL, 3, CUDA_PACKET, CUDA_AUTOPOLL, (devs? 1: 0)); while (!req.complete) cuda_poll(); @@ -230,10 +245,13 @@ /* Reset adb bus - how do we do this?? */ static int -cuda_reset_bus(void) +cuda_adb_reset_bus(void) { struct adb_request req; + if ((via == NULL) || !cuda_fully_inited) + return -ENXIO; + cuda_request(&req, NULL, 2, ADB_PACKET, 0); /* maybe? */ while (!req.complete) cuda_poll(); @@ -248,6 +266,11 @@ va_list list; int i; + if (via == NULL) { + req->complete = 1; + return -ENXIO; + } + req->nbytes = nbytes; req->done = done; va_start(list, nbytes); @@ -258,15 +281,11 @@ return cuda_send_request(req); } -int +static int cuda_send_request(struct adb_request *req) { unsigned long flags; - if (via == NULL) { - req->complete = 1; - return -ENXIO; - } if (req->nbytes < 2 || req->data[0] > CUDA_PACKET) { req->complete = 1; return -EINVAL; @@ -472,3 +491,9 @@ printk("\n"); } } + +int +cuda_present(void) +{ + return (adb_controller && (adb_controller->kind == ADB_VIACUDA) && via); +} \ No newline at end of file diff -u --recursive --new-file v2.2.7/linux/drivers/macintosh/via-pmu.c linux/drivers/macintosh/via-pmu.c --- v2.2.7/linux/drivers/macintosh/via-pmu.c Tue Mar 23 14:35:47 1999 +++ linux/drivers/macintosh/via-pmu.c Thu Apr 29 12:53:48 1999 @@ -93,6 +93,7 @@ static struct adb_request bright_req_1, bright_req_2, bright_req_3; static struct device_node *vias; static int pmu_kind = PMU_UNKNOWN; +static int pmu_fully_inited = 0; int asleep; struct notifier_block *sleep_notifier_list; @@ -103,7 +104,7 @@ static void via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs); static int pmu_adb_send_request(struct adb_request *req, int sync); static int pmu_adb_autopoll(int devs); -static int pmu_reset_bus(void); +static int pmu_adb_reset_bus(void); static void send_byte(int x); static void recv_byte(void); static void pmu_sr_intr(struct pt_regs *regs); @@ -112,6 +113,14 @@ struct pt_regs *regs); static void set_volume(int level); +static struct adb_controller pmu_controller = { + ADB_VIAPMU, + pmu_adb_send_request, + pmu_adb_autopoll, + pmu_adb_reset_bus, + pmu_poll +}; + /* * This table indicates for each PMU opcode: * - the number of data bytes to be sent with the command, or -1 @@ -126,17 +135,17 @@ /*10*/ { 1, 0},{ 1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0}, /*18*/ { 0, 1},{ 0, 1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{ 0, 0}, /*20*/ {-1, 0},{ 0, 0},{ 2, 0},{ 1, 0},{ 1, 0},{-1, 0},{-1, 0},{-1, 0}, -/*28*/ { 0,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, -/*30*/ { 4, 0},{20, 0},{ 2, 0},{ 3, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0}, -/*38*/ { 0, 4},{ 0,20},{ 1, 1},{ 2, 1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, +/*28*/ { 0,-1},{ 0,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{ 0,-1}, +/*30*/ { 4, 0},{20, 0},{-1, 0},{ 3, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0}, +/*38*/ { 0, 4},{ 0,20},{ 2,-1},{ 2, 1},{ 3,-1},{-1,-1},{-1,-1},{ 4, 0}, /*40*/ { 1, 0},{ 1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0}, -/*48*/ { 0, 1},{ 0, 1},{-1,-1},{-1,-1},{ 1, 0},{-1,-1},{-1,-1},{-1,-1}, +/*48*/ { 0, 1},{ 0, 1},{-1,-1},{ 1, 0},{ 1, 0},{-1,-1},{-1,-1},{-1,-1}, /*50*/ { 1, 0},{ 0, 0},{ 2, 0},{ 2, 0},{-1, 0},{ 1, 0},{ 3, 0},{ 1, 0}, /*58*/ { 0, 1},{ 1, 0},{ 0, 2},{ 0, 2},{ 0,-1},{-1,-1},{-1,-1},{-1,-1}, -/*60*/ { 2, 0},{-1, 0},{ 2, 0},{ 0, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0}, +/*60*/ { 2, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0}, /*68*/ { 0, 3},{ 0, 3},{ 0, 2},{ 0, 8},{ 0,-1},{ 0,-1},{-1,-1},{-1,-1}, /*70*/ { 1, 0},{ 1, 0},{ 1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0}, -/*78*/ { 0,-1},{ 0,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{ 4, 1},{ 4, 1}, +/*78*/ { 0,-1},{ 0,-1},{-1,-1},{-1,-1},{-1,-1},{ 5, 1},{ 4, 1},{ 4, 1}, /*80*/ { 4, 0},{-1, 0},{ 0, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0}, /*88*/ { 0, 5},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, /*90*/ { 1, 0},{ 2, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0}, @@ -149,7 +158,7 @@ /*c8*/ {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, /*d0*/ { 0, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0}, /*d8*/ { 1, 1},{ 1, 1},{-1,-1},{-1,-1},{ 0, 1},{ 0,-1},{-1,-1},{-1,-1}, -/*e0*/ {-1, 0},{ 4, 0},{ 0, 1},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0}, +/*e0*/ {-1, 0},{ 4, 0},{ 0, 1},{-1, 0},{-1, 0},{ 4, 0},{-1, 0},{-1, 0}, /*e8*/ { 3,-1},{-1,-1},{ 0, 1},{-1,-1},{ 0,-1},{-1,-1},{-1,-1},{ 0, 0}, /*f0*/ {-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0}, /*f8*/ {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, @@ -186,8 +195,8 @@ return; } - if (vias->parent->name && strcmp(vias->parent->name, "ohare") == 0 - || device_is_compatible(vias->parent, "ohare")) + if (vias->parent->name && ((strcmp(vias->parent->name, "ohare") == 0) + || device_is_compatible(vias->parent, "ohare"))) pmu_kind = PMU_OHARE_BASED; else if (device_is_compatible(vias->parent, "heathrow")) pmu_kind = PMU_HEATHROW_BASED; @@ -203,13 +212,13 @@ if (!init_pmu()) via = NULL; - adb_hardware = ADB_VIAPMU; - + adb_controller = &pmu_controller; + if (via) printk(KERN_INFO "PMU driver initialized for %s\n", - (pmu_kind == PMU_OHARE_BASED) ? "PowerBook 2400/3400/3500(G3)" : - ((pmu_kind == PMU_HEATHROW_BASED) ? "PowerBook G3 Series" : - "Unknown PowerBook")); + (pmu_kind == PMU_OHARE_BASED) ? "PowerBook 2400/3400/3500(G3)" : + ((pmu_kind == PMU_HEATHROW_BASED) ? "PowerBook G3 Series" : + "Unknown PowerBook")); } void __openfirmware @@ -232,11 +241,8 @@ /* Enable interrupts */ out_8(&via[IER], IER_SET | SR_INT | CB1_INT); - /* Set function pointers */ - adb_send_request = pmu_adb_send_request; - adb_autopoll = pmu_adb_autopoll; - adb_reset_bus = pmu_reset_bus; - + pmu_fully_inited = 1; + /* Enable backlight */ pmu_enable_backlight(1); } @@ -288,25 +294,81 @@ static int __openfirmware pmu_adb_send_request(struct adb_request *req, int sync) { - int i; + int i, ret; - for (i = req->nbytes - 1; i > 0; --i) - req->data[i+3] = req->data[i]; - req->data[3] = req->nbytes - 1; - req->data[2] = pmu_adb_flags; - req->data[1] = req->data[0]; - req->data[0] = PMU_ADB_CMD; - req->nbytes += 3; - req->reply_expected = 1; - req->reply_len = 0; - i = pmu_queue_request(req); - if (i) - return i; - if (sync) { - while (!req->complete) - pmu_poll(); - } - return 0; + if ((vias == NULL) || (!pmu_fully_inited)) + { + req->complete = 1; + return -ENXIO; + } + + ret = -EINVAL; + + switch (req->data[0]) { + case PMU_PACKET: + for (i = 0; i < req->nbytes - 1; ++i) + req->data[i] = req->data[i+1]; + --req->nbytes; + if (pmu_data_len[req->data[0]][1] != 0) { + req->reply[0] = ADB_RET_OK; + req->reply_len = 1; + } else + req->reply_len = 0; + ret = pmu_queue_request(req); + break; + case CUDA_PACKET: + switch (req->data[1]) { + case CUDA_GET_TIME: + if (req->nbytes != 2) + break; + req->data[0] = PMU_READ_RTC; + req->nbytes = 1; + req->reply_len = 3; + req->reply[0] = CUDA_PACKET; + req->reply[1] = 0; + req->reply[2] = CUDA_GET_TIME; + ret = pmu_queue_request(req); + break; + case CUDA_SET_TIME: + if (req->nbytes != 6) + break; + req->data[0] = PMU_SET_RTC; + req->nbytes = 5; + for (i = 1; i <= 4; ++i) + req->data[i] = req->data[i+1]; + req->reply_len = 3; + req->reply[0] = CUDA_PACKET; + req->reply[1] = 0; + req->reply[2] = CUDA_SET_TIME; + ret = pmu_queue_request(req); + break; + } + break; + case ADB_PACKET: + for (i = req->nbytes - 1; i > 1; --i) + req->data[i+2] = req->data[i]; + req->data[3] = req->nbytes - 2; + req->data[2] = pmu_adb_flags; + /*req->data[1] = req->data[1];*/ + req->data[0] = PMU_ADB_CMD; + req->nbytes += 2; + req->reply_expected = 1; + req->reply_len = 0; + ret = pmu_queue_request(req); + break; + } + if (ret) + { + req->complete = 1; + return ret; + } + + if (sync) { + while (!req->complete) + pmu_poll(); + } + + return 0; } /* Enable/disable autopolling */ @@ -315,6 +377,9 @@ { struct adb_request req; + if ((vias == NULL) || (!pmu_fully_inited)) + return -ENXIO; + if (devs) { adb_dev_map = devs; pmu_request(&req, NULL, 5, PMU_ADB_CMD, 0, 0x86, @@ -331,12 +396,15 @@ /* Reset the ADB bus */ static int __openfirmware -pmu_reset_bus(void) +pmu_adb_reset_bus(void) { struct adb_request req; long timeout; int save_autopoll = adb_dev_map; + if ((vias == NULL) || (!pmu_fully_inited)) + return -ENXIO; + /* anyone got a better idea?? */ pmu_adb_autopoll(0); @@ -344,23 +412,23 @@ req.done = NULL; req.data[0] = PMU_ADB_CMD; req.data[1] = 0; - req.data[2] = 3; + req.data[2] = 3; /* ADB_BUSRESET ??? */ req.data[3] = 0; req.data[4] = 0; req.reply_len = 0; req.reply_expected = 1; if (pmu_queue_request(&req) != 0) { - printk(KERN_ERR "pmu_reset_bus: pmu_queue_request failed\n"); - return 0; + printk(KERN_ERR "pmu_adb_reset_bus: pmu_queue_request failed\n"); + return -EIO; } while (!req.complete) pmu_poll(); timeout = 100000; while (!req.complete) { if (--timeout < 0) { - printk(KERN_ERR "pmu_reset_bus (reset): no response from PMU\n"); - return 0; + printk(KERN_ERR "pmu_adb_reset_bus (reset): no response from PMU\n"); + return -EIO; } udelay(10); pmu_poll(); @@ -369,7 +437,7 @@ if (save_autopoll != 0) pmu_adb_autopoll(save_autopoll); - return 1; + return 0; } /* Construct and send a pmu request */ @@ -380,6 +448,9 @@ va_list list; int i; + if (vias == NULL) + return -ENXIO; + if (nbytes < 0 || nbytes > 32) { printk(KERN_ERR "pmu_request: bad nbytes (%d)\n", nbytes); req->complete = 1; @@ -400,57 +471,6 @@ return pmu_queue_request(req); } -/* - * This procedure handles requests written to /dev/adb where the - * first byte is CUDA_PACKET or PMU_PACKET. For CUDA_PACKET, we - * emulate a few CUDA requests. - */ -int __openfirmware -pmu_send_request(struct adb_request *req) -{ - int i; - - switch (req->data[0]) { - case PMU_PACKET: - for (i = 0; i < req->nbytes - 1; ++i) - req->data[i] = req->data[i+1]; - --req->nbytes; - if (pmu_data_len[req->data[0]][1] != 0) { - req->reply[0] = ADB_RET_OK; - req->reply_len = 1; - } else - req->reply_len = 0; - return pmu_queue_request(req); - case CUDA_PACKET: - switch (req->data[1]) { - case CUDA_GET_TIME: - if (req->nbytes != 2) - break; - req->data[0] = PMU_READ_RTC; - req->nbytes = 1; - req->reply_len = 3; - req->reply[0] = CUDA_PACKET; - req->reply[1] = 0; - req->reply[2] = CUDA_GET_TIME; - return pmu_queue_request(req); - case CUDA_SET_TIME: - if (req->nbytes != 6) - break; - req->data[0] = PMU_SET_RTC; - req->nbytes = 5; - for (i = 1; i <= 4; ++i) - req->data[i] = req->data[i+1]; - req->reply_len = 3; - req->reply[0] = CUDA_PACKET; - req->reply[1] = 0; - req->reply[2] = CUDA_SET_TIME; - return pmu_queue_request(req); - } - break; - } - return -EINVAL; -} - int __openfirmware pmu_queue_request(struct adb_request *req) { @@ -737,7 +757,7 @@ { struct adb_request req; - if (adb_hardware != ADB_VIAPMU) + if (vias == NULL) return ; if (on) { @@ -780,7 +800,7 @@ { int bright; - if (adb_hardware != ADB_VIAPMU) + if (vias == NULL) return ; backlight_level = level; @@ -807,7 +827,7 @@ { struct adb_request req; - if (adb_hardware != ADB_VIAPMU) + if (vias == NULL) return ; pmu_request(&req, NULL, 2, PMU_POWER_CTRL, PMU_POW_IRLED | @@ -860,6 +880,11 @@ ; } +int +pmu_present(void) +{ + return (adb_controller && (adb_controller->kind == ADB_VIAPMU) && vias); +} #ifdef CONFIG_PMAC_PBOOK @@ -1104,3 +1129,4 @@ misc_register(&pmu_device); } #endif /* CONFIG_PMAC_PBOOK */ + diff -u --recursive --new-file v2.2.7/linux/drivers/net/3c507.c linux/drivers/net/3c507.c --- v2.2.7/linux/drivers/net/3c507.c Thu Feb 12 20:56:07 1998 +++ linux/drivers/net/3c507.c Thu May 6 23:14:36 1999 @@ -40,6 +40,7 @@ info that the casual reader might think that it documents the i82586 :-<. */ +#include #include #include #include @@ -53,6 +54,7 @@ #include #include #include +#include #include #include @@ -123,6 +125,7 @@ ushort tx_head; ushort tx_cmd_link; ushort tx_reap; + spinlock_t lock; }; /* @@ -448,6 +451,7 @@ struct net_local *lp = (struct net_local *)dev->priv; int ioaddr = dev->base_addr; unsigned long shmem = dev->mem_start; + unsigned long flags; if (dev->tbusy) { @@ -487,7 +491,13 @@ lp->stats.tx_bytes+=length; /* Disable the 82586's input to the interrupt line. */ outb(0x80, ioaddr + MISC_CTRL); +#ifdef CONFIG_SMP + spin_lock_irqsave(&lp->lock, flags); hardware_send_packet(dev, buf, length); + spin_unlock_irqrestore(&lp->lock, flags); +#else + hardware_send_packet(dev, buf, length); +#endif dev->trans_start = jiffies; /* Enable the 82586 interrupt input. */ outb(0x84, ioaddr + MISC_CTRL); @@ -515,11 +525,14 @@ return; } dev->interrupt = 1; + ioaddr = dev->base_addr; lp = (struct net_local *)dev->priv; shmem = dev->mem_start; + spin_lock(&lp->lock); + status = readw(shmem+iSCB_STATUS); if (net_debug > 4) { @@ -598,6 +611,7 @@ /* Enable the 82586's interrupt input. */ outb(0x84, ioaddr + MISC_CTRL); + spin_unlock(&lp->lock); return; } diff -u --recursive --new-file v2.2.7/linux/drivers/net/3c509.c linux/drivers/net/3c509.c --- v2.2.7/linux/drivers/net/3c509.c Tue Mar 23 14:35:47 1999 +++ linux/drivers/net/3c509.c Thu May 6 14:02:34 1999 @@ -568,7 +568,7 @@ */ #ifdef __SMP__ - disable_irq(dev->irq); + disable_irq_nosync(dev->irq); spin_lock(&lp->lock); #endif diff -u --recursive --new-file v2.2.7/linux/drivers/net/8390.c linux/drivers/net/8390.c --- v2.2.7/linux/drivers/net/8390.c Wed Mar 10 15:29:46 1999 +++ linux/drivers/net/8390.c Thu May 6 14:02:34 1999 @@ -257,8 +257,7 @@ /* Ugly but a reset can be slow, yet must be protected */ - disable_irq(dev->irq); - synchronize_irq(); + disable_irq_nosync(dev->irq); spin_lock(&ei_local->page_lock); /* Try to restart the card. Perhaps the user has fixed something. */ @@ -286,8 +285,7 @@ * Slow phase with lock held. */ - disable_irq(dev->irq); - synchronize_irq(); + disable_irq_nosync(dev->irq); spin_lock(&ei_local->page_lock); diff -u --recursive --new-file v2.2.7/linux/drivers/net/eexpress.c linux/drivers/net/eexpress.c --- v2.2.7/linux/drivers/net/eexpress.c Tue Jan 19 11:32:51 1999 +++ linux/drivers/net/eexpress.c Thu May 6 23:14:36 1999 @@ -83,6 +83,7 @@ * practice. */ +#include #include #include @@ -107,6 +108,8 @@ #include #include +#include + #ifndef NET_DEBUG #define NET_DEBUG 4 #endif @@ -141,6 +144,7 @@ unsigned char width; /* 0 for 16bit, 1 for 8bit */ unsigned char was_promisc; unsigned char old_mc_count; + spinlock_t lock; }; /* This is the code and data that is downloaded to the EtherExpress card's @@ -502,6 +506,7 @@ static int eexp_xmit(struct sk_buff *buf, struct device *dev) { struct net_local *lp = (struct net_local *)dev->priv; + unsigned long flags; #if NET_DEBUG > 6 printk(KERN_DEBUG "%s: eexp_xmit()\n", dev->name); @@ -509,6 +514,15 @@ disable_irq(dev->irq); + /* + * Best would be to use synchronize_irq(); spin_lock() here + * lets make it work first.. + */ + +#ifdef CONFIG_SMP + spin_lock_irqsave(&lp->lock, flags); +#endif + /* If dev->tbusy is set, all our tx buffers are full but the kernel * is calling us anyway. Check that nothing bad is happening. */ @@ -516,7 +530,13 @@ int status = scb_status(dev); unstick_cu(dev); if ((jiffies - lp->last_tx) < HZ) + { +#ifdef CONFIG_SMP + spin_unlock_irqrestore(&lp->lock, flags); +#endif + return 1; + } printk(KERN_INFO "%s: transmit timed out, %s?", dev->name, (SCB_complete(status)?"lost interrupt": "board on fire")); @@ -544,6 +564,9 @@ eexp_hw_tx_pio(dev,data,length); } dev_kfree_skb(buf); +#ifdef CONFIG_SMP + spin_unlock_irqrestore(&lp->lock, flags); +#endif enable_irq(dev->irq); return 0; } @@ -646,11 +669,14 @@ lp = (struct net_local *)dev->priv; ioaddr = dev->base_addr; + spin_lock(&lp->lock); + old_read_ptr = inw(ioaddr+READ_PTR); old_write_ptr = inw(ioaddr+WRITE_PTR); outb(SIRQ_dis|irqrmap[irq],ioaddr+SET_IRQ); + dev->interrupt = 1; status = scb_status(dev); @@ -726,6 +752,8 @@ #endif outw(old_read_ptr, ioaddr+READ_PTR); outw(old_write_ptr, ioaddr+WRITE_PTR); + + spin_unlock(&lp->lock); return; } diff -u --recursive --new-file v2.2.7/linux/drivers/net/epic100.c linux/drivers/net/epic100.c --- v2.2.7/linux/drivers/net/epic100.c Wed Jan 13 15:00:42 1999 +++ linux/drivers/net/epic100.c Thu Apr 29 11:53:41 1999 @@ -1106,6 +1106,7 @@ memcpy(skb_put(skb, pkt_len), bus_to_virt(ep->rx_ring[entry].bufaddr), pkt_len); #endif + ep->rx_ring[entry].status = 0x8000; } else { skb_put(skb = ep->rx_skbuff[entry], pkt_len); ep->rx_skbuff[entry] = NULL; diff -u --recursive --new-file v2.2.7/linux/drivers/net/ibmtr.c linux/drivers/net/ibmtr.c --- v2.2.7/linux/drivers/net/ibmtr.c Wed Apr 28 11:37:30 1999 +++ linux/drivers/net/ibmtr.c Fri May 7 10:57:42 1999 @@ -513,6 +513,7 @@ /* How much shared RAM is on adapter ? */ #ifdef PCMCIA ti->avail_shared_ram = pcmcia_reality_check(get_sram_size(ti)); + ibmtr_mem_base = ti->sram_base ; #else ti->avail_shared_ram = get_sram_size(ti); #endif @@ -1498,6 +1499,7 @@ ti->asb + offsetof(struct asb_rec, rec_buf_addr)); lan_hdr_len=readb(ti->arb + offsetof(struct arb_rec_req, lan_hdr_len)); + hdr_len = lan_hdr_len + sizeof(struct trllc) + sizeof(struct iphdr); llc=(rbuffer + offsetof(struct rec_buf, data) + lan_hdr_len); @@ -1524,8 +1526,10 @@ return; } + length = ntohs(readw(ti->arb+offsetof(struct arb_rec_req, frame_len))); if ((readb(llc + offsetof(struct trllc, dsap))==EXTENDED_SAP) && - (readb(llc + offsetof(struct trllc, ssap))==EXTENDED_SAP)) { + (readb(llc + offsetof(struct trllc, ssap))==EXTENDED_SAP) && + (length>=hdr_len)) { IPv4_p = 1; } @@ -1556,7 +1560,6 @@ } #endif - length = ntohs(readw(ti->arb+offsetof(struct arb_rec_req, frame_len))); skb_size = length-lan_hdr_len+sizeof(struct trh_hdr)+sizeof(struct trllc); if (!(skb=dev_alloc_skb(skb_size))) { @@ -1576,7 +1579,6 @@ if (IPv4_p) { /* Copy the headers without checksumming */ - hdr_len = lan_hdr_len + sizeof(struct trllc) + sizeof(struct iphdr); memcpy_fromio(data, rbufdata, hdr_len); /* Watch for padded packets and bogons */ diff -u --recursive --new-file v2.2.7/linux/drivers/net/ppp.c linux/drivers/net/ppp.c --- v2.2.7/linux/drivers/net/ppp.c Wed Apr 28 11:37:30 1999 +++ linux/drivers/net/ppp.c Thu May 6 23:14:37 1999 @@ -241,6 +241,7 @@ 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 }; +EXPORT_SYMBOL(ppp_crc16_table); #ifdef CHECK_CHARACTERS static __u32 paritytab[8] = diff -u --recursive --new-file v2.2.7/linux/drivers/net/via-rhine.c linux/drivers/net/via-rhine.c --- v2.2.7/linux/drivers/net/via-rhine.c Mon Dec 28 15:00:52 1998 +++ linux/drivers/net/via-rhine.c Thu Apr 29 13:13:17 1999 @@ -1053,6 +1053,7 @@ skb->protocol = eth_type_trans(skb, dev); netif_rx(skb); dev->last_rx = jiffies; + np->stats.rx_bytes += pkt_len; np->stats.rx_packets++; } entry = (++np->cur_rx) % RX_RING_SIZE; diff -u --recursive --new-file v2.2.7/linux/drivers/net/wavelan.c linux/drivers/net/wavelan.c --- v2.2.7/linux/drivers/net/wavelan.c Tue Mar 23 14:35:48 1999 +++ linux/drivers/net/wavelan.c Thu Apr 29 11:53:41 1999 @@ -324,6 +324,7 @@ return crc_bytes; } /* psa_crc */ +#endif /* SET_PSA_CRC */ /*------------------------------------------------------------------*/ /* @@ -334,6 +335,7 @@ u_long ioaddr, u_short hacr) { +#ifdef SET_PSA_CRC psa_t psa; u_short crc; @@ -363,8 +365,8 @@ if(crc != 0) printk(KERN_WARNING "%s: update_psa_checksum(): CRC does not agree with PSA data (even after recalculating)\n", dev->name); #endif /* DEBUG_IOCTL_INFO */ -} /* update_psa_checksum */ #endif /* SET_PSA_CRC */ +} /* update_psa_checksum */ /*------------------------------------------------------------------*/ /* @@ -748,23 +750,23 @@ unsigned short ias_addr; /* Check mc_config command */ - if((status & AC_SFLD_OK) != 0) - printk(KERN_INFO "wv_config_complete(): set_multicast_address failed; status = 0x%x\n", - dev->name, str, status); + if((status & AC_SFLD_OK) != AC_SFLD_OK) + printk(KERN_INFO "%s: wv_config_complete(): set_multicast_address failed; status = 0x%x\n", + dev->name, status); /* check ia-config command */ ias_addr = mcs_addr - sizeof(ac_ias_t); obram_read(ioaddr, acoff(ias_addr, ac_status), (unsigned char *)&status, sizeof(status)); - if((status & AC_SFLD_OK) != 0) - printk(KERN_INFO "wv_config_complete(): set_MAC_address; status = 0x%x\n", - dev->name, str, status); + if((status & AC_SFLD_OK) != AC_SFLD_OK) + printk(KERN_INFO "%s: wv_config_complete(): set_MAC_address failed; status = 0x%x\n", + dev->name, status); /* Check config command. */ cfg_addr = ias_addr - sizeof(ac_cfg_t); obram_read(ioaddr, acoff(cfg_addr, ac_status), (unsigned char *)&status, sizeof(status)); - if((status & AC_SFLD_OK) != 0) - printk(KERN_INFO "wv_config_complete(): configure; status = 0x%x\n", - dev->name, str, status); + if((status & AC_SFLD_OK) != AC_SFLD_OK) + printk(KERN_INFO "%s: wv_config_complete(): configure failed; status = 0x%x\n", + dev->name, status); #endif /* DEBUG_CONFIG_ERROR */ ret = 1; /* Ready to be scrapped */ @@ -800,15 +802,15 @@ /* Read the first transmit buffer */ obram_read(ioaddr, acoff(lp->tx_first_in_use, ac_status), (unsigned char *)&tx_status, sizeof(tx_status)); + /* If not completed -> exit */ + if((tx_status & AC_SFLD_C) == 0) + break; + /* Hack for reconfiguration */ if(tx_status == 0xFFFF) if(!wv_config_complete(dev, ioaddr, lp)) break; /* Not completed */ - /* If not completed -> exit */ - if((tx_status & AC_SFLD_C) == 0) - break; - /* We now remove this buffer */ nreaped++; --lp->tx_n_in_use; @@ -841,7 +843,7 @@ lp->stats.tx_packets++; ncollisions = tx_status & AC_SFLD_MAXCOL; lp->stats.collisions += ncollisions; -#ifdef DEBUG_INTERRUPT_INFO +#ifdef DEBUG_TX_INFO if(ncollisions > 0) printk(KERN_DEBUG "%s: wv_complete(): tx completed after %d collisions.\n", dev->name, ncollisions); @@ -850,53 +852,49 @@ else { lp->stats.tx_errors++; -#ifndef IGNORE_NORMAL_XMIT_ERRS if(tx_status & AC_SFLD_S10) { lp->stats.tx_carrier_errors++; -#ifdef DEBUG_INTERRUPT_ERROR - printk(KERN_INFO "%s: wv_complete(): tx error: no CS.\n", +#ifdef DEBUG_TX_FAIL + printk(KERN_DEBUG "%s: wv_complete(): tx error: no CS.\n", dev->name); #endif } -#endif /* IGNORE_NORMAL_XMIT_ERRS */ if(tx_status & AC_SFLD_S9) { lp->stats.tx_carrier_errors++; -#ifdef DEBUG_INTERRUPT_ERROR - printk(KERN_INFO "%s: wv_complete(): tx error: lost CTS.\n", +#ifdef DEBUG_TX_FAIL + printk(KERN_DEBUG "%s: wv_complete(): tx error: lost CTS.\n", dev->name); #endif } if(tx_status & AC_SFLD_S8) { lp->stats.tx_fifo_errors++; -#ifdef DEBUG_INTERRUPT_ERROR - printk(KERN_INFO "%s: wv_complete(): tx error: slow DMA.\n", +#ifdef DEBUG_TX_FAIL + printk(KERN_DEBUG "%s: wv_complete(): tx error: slow DMA.\n", dev->name); #endif } -#ifndef IGNORE_NORMAL_XMIT_ERRS if(tx_status & AC_SFLD_S6) { lp->stats.tx_heartbeat_errors++; -#ifdef DEBUG_INTERRUPT_ERROR - printk(KERN_INFO "%s: wv_complete(): tx error: heart beat.\n", +#ifdef DEBUG_TX_FAIL + printk(KERN_DEBUG "%s: wv_complete(): tx error: heart beat.\n", dev->name); #endif } if(tx_status & AC_SFLD_S5) { lp->stats.tx_aborted_errors++; -#ifdef DEBUG_INTERRUPT_ERROR - printk(KERN_INFO "%s: wv_complete(): tx error: too many collisions.\n", +#ifdef DEBUG_TX_FAIL + printk(KERN_DEBUG "%s: wv_complete(): tx error: too many collisions.\n", dev->name); #endif } -#endif /* IGNORE_NORMAL_XMIT_ERRS */ } -#ifdef DEBUG_INTERRUPT_INFO +#ifdef DEBUG_TX_INFO printk(KERN_DEBUG "%s: wv_complete(): tx completed, tx_status 0x%04x\n", dev->name, tx_status); #endif @@ -1323,21 +1321,21 @@ char * msg1, /* Name of the device */ char * msg2) /* Name of the function */ { -#ifndef DEBUG_PACKET_DUMP + int i; + int maxi; + printk(KERN_DEBUG "%s: %s(): dest %02X:%02X:%02X:%02X:%02X:%02X, length %d\n", msg1, msg2, p[0], p[1], p[2], p[3], p[4], p[5], length); printk(KERN_DEBUG "%s: %s(): src %02X:%02X:%02X:%02X:%02X:%02X, type 0x%02X%02X\n", msg1, msg2, p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13]); -#else /* DEBUG_PACKET_DUMP */ - int i; - int maxi; +#ifdef DEBUG_PACKET_DUMP - printk(KERN_DEBUG "%s: %s(): len=%d, data=\"", msg1, msg2, length); + printk(KERN_DEBUG "data=\""); if((maxi = length) > DEBUG_PACKET_DUMP) maxi = DEBUG_PACKET_DUMP; - for(i = 0; i < maxi; i++) + for(i = 14; i < maxi; i++) if(p[i] >= ' ' && p[i] <= '~') printk(" %c", p[i]); else @@ -1564,7 +1562,9 @@ /*------------------------------------------------------------------*/ /* * This function doesn't exist. + * (Note : it was a nice way to test the reconfigure stuff...) */ +#ifdef SET_MAC_ADDRESS static int wavelan_set_mac_address(device * dev, void * addr) @@ -1579,6 +1579,7 @@ return 0; } +#endif /* SET_MAC_ADDRESS */ #ifdef WIRELESS_EXT /* if wireless extensions exist in the kernel */ @@ -1932,10 +1933,8 @@ /* Disable NWID in the mmc (no filtering). */ mmc_out(ioaddr, mmwoff(0, mmw_loopt_sel), MMW_LOOPT_SEL_DIS_NWID); } -#ifdef SET_PSA_CRC /* update the Wavelan checksum */ update_psa_checksum(dev, ioaddr, lp->hacr); -#endif break; case SIOCGIWNWID: @@ -1992,10 +1991,8 @@ psa.psa_thr_pre_set = wrq->u.sensitivity & 0x3F; psa_write(ioaddr, lp->hacr, (char *)&psa.psa_thr_pre_set - (char *)&psa, (unsigned char *) &psa.psa_thr_pre_set, 1); -#ifdef SET_PSA_CRC /* update the Wavelan checksum */ update_psa_checksum(dev, ioaddr, lp->hacr); -#endif mmc_out(ioaddr, mmwoff(0, mmw_thr_pre_set), psa.psa_thr_pre_set); break; @@ -2043,10 +2040,8 @@ mmc_out(ioaddr, mmwoff(0, mmw_encr_enable), 0); } -#ifdef SET_PSA_CRC /* update the Wavelan checksum */ update_psa_checksum(dev, ioaddr, lp->hacr); -#endif break; case SIOCGIWENCODE: @@ -2260,10 +2255,8 @@ psa.psa_quality_thr = *(wrq->u.name) & 0x0F; psa_write(ioaddr, lp->hacr, (char *)&psa.psa_quality_thr - (char *)&psa, (unsigned char *)&psa.psa_quality_thr, 1); -#ifdef SET_PSA_CRC /* update the Wavelan checksum */ update_psa_checksum(dev, ioaddr, lp->hacr); -#endif mmc_out(ioaddr, mmwoff(0, mmw_quality_thr), psa.psa_quality_thr); break; @@ -2426,7 +2419,7 @@ #ifdef DEBUG_RX_TRACE printk(KERN_DEBUG "%s: ->wv_packet_read(0x%X, %d)\n", - dev->name, fd_p, sksize); + dev->name, buf_off, sksize); #endif /* Allocate buffer for the data */ @@ -2514,6 +2507,8 @@ { u_long ioaddr = dev->base_addr; net_local * lp = (net_local *)dev->priv; + fd_t fd; + rbd_t rbd; int nreaped = 0; #ifdef DEBUG_RX_TRACE @@ -2523,12 +2518,17 @@ /* Loop on each received packet. */ for(;;) { - fd_t fd; - rbd_t rbd; - ushort pkt_len; - obram_read(ioaddr, lp->rx_head, (unsigned char *) &fd, sizeof(fd)); + /* Note about the status : + * It start up to be 0 (the value we set). Then, when the RU + * grab the buffer to prepare for reception, it sets the + * FD_STATUS_B flag. When the RU has finished receiving the + * frame, it clears FD_STATUS_B, set FD_STATUS_C to indicate + * completion and set the other flags to indicate the eventual + * errors. FD_STATUS_OK indicates that the reception was OK. + */ + /* If the current frame is not complete, we have reached the end. */ if((fd.fd_status & FD_STATUS_C) != FD_STATUS_C) break; /* This is how we exit the loop. */ @@ -2536,35 +2536,44 @@ nreaped++; /* Check whether frame was correctly received. */ - if((fd.fd_status & (FD_STATUS_B | FD_STATUS_OK)) != - (FD_STATUS_B | FD_STATUS_OK)) + if((fd.fd_status & FD_STATUS_OK) == FD_STATUS_OK) { - /* - * Not sure about this one -- it does not seem - * to be an error so we will keep quiet about it. - */ -#ifndef IGNORE_NORMAL_XMIT_ERRS -#ifdef DEBUG_RX_ERROR - if((fd.fd_status & FD_STATUS_B) != FD_STATUS_B) - printk(KERN_INFO "%s: wv_receive(): frame not consumed by RU.\n", - dev->name); -#endif -#endif /* IGNORE_NORMAL_XMIT_ERRS */ + /* Does the frame contain a pointer to the data? Let's check. */ + if(fd.fd_rbd_offset != I82586NULL) + { + /* Read the receive buffer descriptor */ + obram_read(ioaddr, fd.fd_rbd_offset, + (unsigned char *) &rbd, sizeof(rbd)); #ifdef DEBUG_RX_ERROR - if((fd.fd_status & FD_STATUS_OK) != FD_STATUS_OK) - printk(KERN_INFO "%s: wv_receive(): frame not received successfully.\n", + if((rbd.rbd_status & RBD_STATUS_EOF) != RBD_STATUS_EOF) + printk(KERN_INFO "%s: wv_receive(): missing EOF flag.\n", + dev->name); + + if((rbd.rbd_status & RBD_STATUS_F) != RBD_STATUS_F) + printk(KERN_INFO "%s: wv_receive(): missing F flag.\n", + dev->name); +#endif /* DEBUG_RX_ERROR */ + + /* Read the packet and transmit to Linux */ + wv_packet_read(dev, rbd.rbd_bufl, + rbd.rbd_status & RBD_STATUS_ACNT); + } +#ifdef DEBUG_RX_ERROR + else /* if frame has no data */ + printk(KERN_INFO "%s: wv_receive(): frame has no data.\n", dev->name); #endif } - - /* Were there problems in processing the frame? Let's check. */ - if((fd.fd_status & (FD_STATUS_S6 | FD_STATUS_S7 | FD_STATUS_S8 | - FD_STATUS_S9 | FD_STATUS_S10 | FD_STATUS_S11)) - != 0) + else /* If reception was no successful */ { lp->stats.rx_errors++; +#ifdef DEBUG_RX_INFO + printk(KERN_DEBUG "%s: wv_receive(): frame not received successfully (%X).\n", + dev->name, fd.fd_status); +#endif + #ifdef DEBUG_RX_ERROR if((fd.fd_status & FD_STATUS_S6) != 0) printk(KERN_INFO "%s: wv_receive(): no EOF flag.\n", dev->name); @@ -2573,8 +2582,8 @@ if((fd.fd_status & FD_STATUS_S7) != 0) { lp->stats.rx_length_errors++; -#ifdef DEBUG_RX_ERROR - printk(KERN_INFO "%s: wv_receive(): frame too short.\n", +#ifdef DEBUG_RX_FAIL + printk(KERN_DEBUG "%s: wv_receive(): frame too short.\n", dev->name); #endif } @@ -2582,8 +2591,8 @@ if((fd.fd_status & FD_STATUS_S8) != 0) { lp->stats.rx_over_errors++; -#ifdef DEBUG_RX_ERROR - printk(KERN_INFO "%s: wv_receive(): rx DMA overrun.\n", +#ifdef DEBUG_RX_FAIL + printk(KERN_DEBUG "%s: wv_receive(): rx DMA overrun.\n", dev->name); #endif } @@ -2591,8 +2600,8 @@ if((fd.fd_status & FD_STATUS_S9) != 0) { lp->stats.rx_fifo_errors++; -#ifdef DEBUG_RX_ERROR - printk(KERN_INFO "%s: wv_receive(): ran out of resources.\n", +#ifdef DEBUG_RX_FAIL + printk(KERN_DEBUG "%s: wv_receive(): ran out of resources.\n", dev->name); #endif } @@ -2600,8 +2609,8 @@ if((fd.fd_status & FD_STATUS_S10) != 0) { lp->stats.rx_frame_errors++; -#ifdef DEBUG_RX_ERROR - printk(KERN_INFO "%s: wv_receive(): alignment error.\n", +#ifdef DEBUG_RX_FAIL + printk(KERN_DEBUG "%s: wv_receive(): alignment error.\n", dev->name); #endif } @@ -2609,38 +2618,12 @@ if((fd.fd_status & FD_STATUS_S11) != 0) { lp->stats.rx_crc_errors++; -#ifdef DEBUG_RX_ERROR - printk(KERN_INFO "%s: wv_receive(): CRC error.\n", dev->name); +#ifdef DEBUG_RX_FAIL + printk(KERN_DEBUG "%s: wv_receive(): CRC error.\n", dev->name); #endif } } - /* Does the frame contain a pointer to the data? Let's check. */ - if(fd.fd_rbd_offset == I82586NULL) -#ifdef DEBUG_RX_ERROR - printk(KERN_INFO "%s: wv_receive(): frame has no data.\n", dev->name); -#endif - else - { - obram_read(ioaddr, fd.fd_rbd_offset, - (unsigned char *) &rbd, sizeof(rbd)); - -#ifdef DEBUG_RX_ERROR - if((rbd.rbd_status & RBD_STATUS_EOF) != RBD_STATUS_EOF) - printk(KERN_INFO "%s: wv_receive(): missing EOF flag.\n", - dev->name); - - if((rbd.rbd_status & RBD_STATUS_F) != RBD_STATUS_F) - printk(KERN_INFO "%s: wv_receive(): missing F flag.\n", - dev->name); -#endif - - pkt_len = rbd.rbd_status & RBD_STATUS_ACNT; - - /* Read the packet and transmit to Linux */ - wv_packet_read(dev, rbd.rbd_bufl, pkt_len); - } /* if frame has data */ - fd.fd_status = 0; obram_write(ioaddr, fdoff(lp->rx_head, fd_status), (unsigned char *) &fd.fd_status, sizeof(fd.fd_status)); @@ -2775,7 +2758,7 @@ /* * Data */ - obram_write(ioaddr, buf_addr, buf, clen); + obram_write(ioaddr, buf_addr, buf, length); /* * Overwrite the predecessor NOP link @@ -2950,11 +2933,9 @@ (unsigned char *)&psa.psa_quality_thr, 1); psa_write(ioaddr, lp->hacr, (char *)&psa.psa_conf_status - (char *)&psa, (unsigned char *)&psa.psa_conf_status, 1); -#ifdef SET_PSA_CRC /* update the Wavelan checksum */ update_psa_checksum(dev, ioaddr, lp->hacr); #endif -#endif } /* Zero the mmc structure. */ @@ -3125,7 +3106,7 @@ if(i <= 0) { -#ifdef DEBUG_CONFIG_ERRORS +#ifdef DEBUG_CONFIG_ERROR printk(KERN_INFO "%s: wavelan_ru_start(): board not accepting command.\n", dev->name); #endif @@ -3229,7 +3210,7 @@ if(i <= 0) { -#ifdef DEBUG_CONFIG_ERRORS +#ifdef DEBUG_CONFIG_ERROR printk(KERN_INFO "%s: wavelan_cu_start(): board not accepting command.\n", dev->name); #endif @@ -3316,7 +3297,7 @@ if(i <= 0) { -#ifdef DEBUG_CONFIG_ERRORS +#ifdef DEBUG_CONFIG_ERROR printk(KERN_INFO "%s: wv_82586_start(): iscp_busy timeout.\n", dev->name); #endif @@ -3336,7 +3317,7 @@ if (i <= 0) { -#ifdef DEBUG_CONFIG_ERRORS +#ifdef DEBUG_CONFIG_ERROR printk(KERN_INFO "%s: wv_82586_start(): status: expected 0x%02x, got 0x%02x.\n", dev->name, SCB_ST_CX | SCB_ST_CNA, scb.scb_status); #endif @@ -3357,7 +3338,7 @@ obram_read(ioaddr, OFFSET_CU, (unsigned char *)&cb, sizeof(cb)); if(cb.ac_status & AC_SFLD_FAIL) { -#ifdef DEBUG_CONFIG_ERRORS +#ifdef DEBUG_CONFIG_ERROR printk(KERN_INFO "%s: wv_82586_start(): i82586 Self Test failed.\n", dev->name); #endif @@ -3638,13 +3619,16 @@ wv_ints_on(dev); /* Start card functions */ - if((wv_ru_start(dev) < 0) || - (wv_cu_start(dev) < 0)) + if(wv_cu_start(dev) < 0) return -1; - /* Finish configuration. */ + /* Setup the controller and parameters */ wv_82586_config(dev); + /* Finish configuration with the receive unit */ + if(wv_ru_start(dev) < 0) + return -1; + #ifdef DEBUG_CONFIG_TRACE printk(KERN_DEBUG "%s: <-wv_hw_reset()\n", dev->name); #endif @@ -3945,7 +3929,7 @@ /* Check irq */ if(dev->irq == 0) { -#ifdef DEBUG_CONFIG_ERRORS +#ifdef DEBUG_CONFIG_ERROR printk(KERN_WARNING "%s: wavelan_open(): no IRQ\n", dev->name); #endif return -ENXIO; @@ -3953,7 +3937,7 @@ if(request_irq(dev->irq, &wavelan_interrupt, 0, "WaveLAN", dev) != 0) { -#ifdef DEBUG_CONFIG_ERRORS +#ifdef DEBUG_CONFIG_ERROR printk(KERN_WARNING "%s: wavelan_open(): invalid IRQ\n", dev->name); #endif return -EAGAIN; @@ -3968,7 +3952,7 @@ else { free_irq(dev->irq, dev); -#ifdef DEBUG_CONFIG_ERRORS +#ifdef DEBUG_CONFIG_ERROR printk(KERN_INFO "%s: wavelan_open(): impossible to start the card\n", dev->name); #endif @@ -4065,10 +4049,8 @@ #endif psa_write(ioaddr, HACR_DEFAULT, psaoff(0, psa_int_req_no), &irq_mask, 1); -#ifdef SET_PSA_CRC /* update the Wavelan checksum */ update_psa_checksum(dev, ioaddr, HACR_DEFAULT); -#endif wv_hacr_reset(ioaddr); } } @@ -4122,7 +4104,9 @@ dev->hard_start_xmit = wavelan_packet_xmit; dev->get_stats = wavelan_get_stats; dev->set_multicast_list = &wavelan_set_multicast_list; +#ifdef SET_MAC_ADDRESS dev->set_mac_address = &wavelan_set_mac_address; +#endif /* SET_MAC_ADDRESS */ #ifdef WIRELESS_EXT /* if wireless extension exists in the kernel */ dev->do_ioctl = wavelan_ioctl; @@ -4176,7 +4160,7 @@ /* Don't probe at all. */ if(base_addr < 0) { -#ifdef DEBUG_CONFIG_ERRORS +#ifdef DEBUG_CONFIG_ERROR printk(KERN_WARNING "%s: wavelan_probe(): invalid base address\n", dev->name); #endif @@ -4259,7 +4243,7 @@ /* If probing is asked */ if(io[0] == 0) { -#ifdef DEBUG_CONFIG_ERRORS +#ifdef DEBUG_CONFIG_ERROR printk(KERN_WARNING "WaveLAN init_module(): doing device probing (bad !)\n"); printk(KERN_WARNING "Specify base addresses while loading module to correct the problem\n"); #endif @@ -4303,7 +4287,7 @@ } /* if there is something at the address */ } /* Loop on all addresses. */ -#ifdef DEBUG_CONFIG_ERRORS +#ifdef DEBUG_CONFIG_ERROR if(wavelan_list == (net_local *) NULL) printk(KERN_WARNING "WaveLAN init_module(): no device found\n"); #endif diff -u --recursive --new-file v2.2.7/linux/drivers/net/wavelan.p.h linux/drivers/net/wavelan.p.h --- v2.2.7/linux/drivers/net/wavelan.p.h Tue Mar 23 14:35:48 1999 +++ linux/drivers/net/wavelan.p.h Thu Apr 29 11:53:41 1999 @@ -34,16 +34,22 @@ * I try to maintain a web page with the Wireless LAN Howto at : * http://www-uk.hpl.hp.com/people/jt/Linux/Wavelan.html * + * Debugging and options + * --------------------- + * You will find below a set of '#define" allowing a very fine control + * on the driver behaviour and the debug messages printed. + * The main options are : + * o SET_PSA_CRC, to have your card correctly recognised by + * an access point and the Point-to-Point diagnostic tool. + * o USE_PSA_CONFIG, to read configuration from the PSA (EEprom) + * (otherwise we always start afresh with some defaults) + * * wavelan.o is too darned big * --------------------------- * That's true! There is a very simple way to reduce the driver * object by 33%! Comment out the following line: * #include - * - * Debugging and options - * --------------------- - * You will find below a set of '#define" allowing a very fine control - * on the driver behaviour and the debug messages printed. + * Other compile options can also reduce the size of it... * * MAC address and hardware detection: * ----------------------------------- @@ -274,7 +280,17 @@ * - Correct i82586 configuration parameters * - Encryption initialisation bug (Robert McCormack) * - New mac addresses detected in the probe - * - Increase watchdog for busy envirnoments + * - Increase watchdog for busy environments + * + * Changes made for release in 2.0.38 & 2.2.7 : + * ------------------------------------------ + * - Correct the reception logic to better report errors and avoid + * sending bogus packet up the stack + * - Delay RU config to avoid corrupting first received packet + * - Change config completion code (to actually check something) + * - Avoid reading out of bound in skbuf to transmit + * - Rectify a lot of (useless) debugging code + * - Change the way to `#ifdef SET_PSA_CRC' * * Wishes & dreams: * ---------------- @@ -315,6 +331,24 @@ #include "i82586.h" #include "wavelan.h" +/************************** DRIVER OPTIONS **************************/ +/* + * `#define' or `#undef' the following constant to change the behaviour + * of the driver... + */ +#undef SET_PSA_CRC /* Calculate and set the CRC on PSA (slower) */ +#define USE_PSA_CONFIG /* Use info from the PSA. */ +#undef STRUCT_CHECK /* Verify padding of structures. */ +#undef EEPROM_IS_PROTECTED /* doesn't seem to be necessary */ +#define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical). */ +#undef SET_MAC_ADDRESS /* Experimental */ + +#ifdef WIRELESS_EXT /* If wireless extensions exist in the kernel */ +/* Warning: this stuff will slow down the driver. */ +#define WIRELESS_SPY /* Enable spying addresses. */ +#undef HISTOGRAM /* Enable histogram of signal level. */ +#endif + /****************************** DEBUG ******************************/ #undef DEBUG_MODULE_TRACE /* module insertion/removal */ @@ -324,14 +358,16 @@ #define DEBUG_INTERRUPT_ERROR /* problems */ #undef DEBUG_CONFIG_TRACE /* Trace the config functions. */ #undef DEBUG_CONFIG_INFO /* what's going on */ -#define DEBUG_CONFIG_ERRORS /* errors on configuration */ +#define DEBUG_CONFIG_ERROR /* errors on configuration */ #undef DEBUG_TX_TRACE /* transmission calls */ #undef DEBUG_TX_INFO /* header of the transmitted packet */ -#define DEBUG_TX_ERROR /* unexpected conditions */ +#undef DEBUG_TX_FAIL /* Normal failure conditions */ +#define DEBUG_TX_ERROR /* Unexpected conditions */ #undef DEBUG_RX_TRACE /* transmission calls */ -#undef DEBUG_RX_INFO /* header of the transmitted packet */ -#define DEBUG_RX_ERROR /* unexpected conditions */ -#undef DEBUG_PACKET_DUMP 16 /* Dump packet on the screen. */ +#undef DEBUG_RX_INFO /* header of the received packet */ +#undef DEBUG_RX_FAIL /* Normal failure conditions */ +#define DEBUG_RX_ERROR /* Unexpected conditions */ +#undef DEBUG_PACKET_DUMP 32 /* Dump packet on the screen. */ #undef DEBUG_IOCTL_TRACE /* misc. call by Linux */ #undef DEBUG_IOCTL_INFO /* various debugging info */ #define DEBUG_IOCTL_ERROR /* what's going wrong */ @@ -343,26 +379,10 @@ #undef DEBUG_I82586_SHOW /* Show i82586 status. */ #undef DEBUG_DEVICE_SHOW /* Show device parameters. */ -/* Options */ -#define USE_PSA_CONFIG /* Use info from the PSA. */ -#define SET_PSA_CRC /* Calculate and set the CRC on PSA */ -#define IGNORE_NORMAL_XMIT_ERRS /* Don't bother with normal conditions. */ -#undef STRUCT_CHECK /* Verify padding of structures. */ -#undef OLDIES /* old code (to redo) */ -#undef RECORD_SNR /* to redo */ -#undef EEPROM_IS_PROTECTED /* doesn't seem to be necessary */ -#define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical). */ - -#ifdef WIRELESS_EXT /* If wireless extensions exist in the kernel */ -/* Warning: this stuff will slow down the driver. */ -#define WIRELESS_SPY /* Enable spying addresses. */ -#undef HISTOGRAM /* Enable histogram of signal level. */ -#endif - /************************ CONSTANTS & MACROS ************************/ #ifdef DEBUG_VERSION_SHOW -static const char *version = "wavelan.c : v18 (wireless extensions) 18/2/99\n"; +static const char *version = "wavelan.c : v19 (wireless extensions) 20/4/99\n"; #endif /* Watchdog temporisation */ diff -u --recursive --new-file v2.2.7/linux/drivers/scsi/Config.in linux/drivers/scsi/Config.in --- v2.2.7/linux/drivers/scsi/Config.in Fri Apr 16 14:47:30 1999 +++ linux/drivers/scsi/Config.in Thu Apr 29 11:53:41 1999 @@ -55,9 +55,7 @@ dep_tristate 'EATA-PIO (old DPT PM2001, PM2012A) support' CONFIG_SCSI_EATA_PIO $CONFIG_SCSI dep_tristate 'Future Domain 16xx SCSI/AHA-2920A support' CONFIG_SCSI_FUTURE_DOMAIN $CONFIG_SCSI if [ "$CONFIG_MCA" = "y" ]; then - if [ "$CONFIG_SCSI" = "y" ]; then - bool 'Future Domain MCS-600/700 SCSI support' CONFIG_SCSI_FD_MCS - fi + dep_tristate 'Future Domain MCS-600/700 SCSI support' CONFIG_SCSI_FD_MCS $CONFIG_SCSI fi dep_tristate 'GDT SCSI Disk Array Controller support' CONFIG_SCSI_GDTH $CONFIG_SCSI dep_tristate 'Generic NCR5380/53c400 SCSI support' CONFIG_SCSI_GENERIC_NCR5380 $CONFIG_SCSI diff -u --recursive --new-file v2.2.7/linux/drivers/scsi/Makefile linux/drivers/scsi/Makefile --- v2.2.7/linux/drivers/scsi/Makefile Fri Apr 16 14:47:30 1999 +++ linux/drivers/scsi/Makefile Thu Apr 29 11:53:41 1999 @@ -533,8 +533,11 @@ ifeq ($(CONFIG_SCSI_FD_MCS),y) L_OBJS += fd_mcs.o +else + ifeq ($(CONFIG_SCSI_FD_MCS),m) + M_OBJS += fd_mcs.o + endif endif - ifeq ($(CONFIG_SCSI_T128),y) L_OBJS += t128.o diff -u --recursive --new-file v2.2.7/linux/drivers/scsi/imm.c linux/drivers/scsi/imm.c --- v2.2.7/linux/drivers/scsi/imm.c Tue Feb 23 15:21:33 1999 +++ linux/drivers/scsi/imm.c Fri May 7 10:57:42 1999 @@ -881,6 +881,7 @@ { imm_struct *tmp = (imm_struct *) data; Scsi_Cmnd *cmd = tmp->cur_cmd; + unsigned long flags; if (!cmd) { printk("IMM: bug in imm_interrupt\n"); @@ -931,8 +932,10 @@ if (cmd->SCp.phase > 0) imm_pb_release(cmd->host->unique_id); + spin_lock_irqsave(&io_request_lock, flags); tmp->cur_cmd = 0; cmd->scsi_done(cmd); + spin_unlock_irqrestore(&io_request_lock, flags); return; } diff -u --recursive --new-file v2.2.7/linux/drivers/scsi/megaraid.c linux/drivers/scsi/megaraid.c --- v2.2.7/linux/drivers/scsi/megaraid.c Fri Apr 16 14:47:31 1999 +++ linux/drivers/scsi/megaraid.c Thu May 6 23:14:37 1999 @@ -9,7 +9,7 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * - * Version : 0.96 + * Version : 1.00 * * Description: Linux device driver for AMI MegaRAID controller * @@ -73,19 +73,37 @@ * * Version 0.96: * 762 fully supported. + * Version 0.97: + * Changed megaraid_command to use wait_queue. + * Fixed bug of undesirably detecting HP onboard controllers which + * are disabled. + * + * Version 1.00: + * Checks to see if an irq ocurred while in isr, and runs through + * routine again. + * Copies mailbox to temp area before processing in isr + * Added barrier() in busy wait to fix volatility bug + * Uses separate list for freed Scbs, keeps track of cmd state + * Put spinlocks around entire queue function for now... + * Full multi-io commands working stablely without previous problems + * Added skipXX LILO option for Madrona motherboard support + * * * BUGS: * Some older 2.1 kernels (eg. 2.1.90) have a bug in pci.c that * fails to detect the controller as a pci device on the system. * + * Timeout period for mid scsi layer is too short for + * this controller. Must be increased or Aborts will occur. + * *===================================================================*/ #define CRLFSTR "\n" -#include #include #ifdef MODULE +#include #include #if LINUX_VERSION_CODE >= 0x20100 @@ -213,14 +231,15 @@ * *================================================================ */ -static int MegaIssueCmd (mega_host_config * megaCfg, +static int megaIssueCmd (mega_host_config * megaCfg, u_char * mboxData, mega_scb * scb, int intr); static int build_sglist (mega_host_config * megaCfg, mega_scb * scb, u_long * buffer, u_long * length); -static void mega_runque (void *); +static int mega_busyWaitMbox(mega_host_config *); +static void mega_runpendq (mega_host_config *); static void mega_rundoneq (void); static void mega_cmd_done (mega_host_config *, mega_scb *, int); static mega_scb *mega_ioctl (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt); @@ -241,15 +260,34 @@ * *================================================================ */ + +/* Use "megaraid=skipXX" to prohibit driver from scanning XX scsi id + on each channel. Used for Madrona motherboard, where SAF_TE + processor id cannot be scanned */ +static char *megaraid; +#if LINUX_VERSION_CODE > 0x20100 +#ifdef MODULE +MODULE_PARM(megaraid, "s"); +#endif +#endif +static int skip_id; + static int numCtlrs = 0; static mega_host_config *megaCtlrs[12] = {0}; +#if DEBUG +static u_long maxCmdTime = 0; +#endif + +static mega_scb *pLastScb = NULL; + /* Queue of pending/completed SCBs */ -static mega_scb *qPending = NULL; static Scsi_Cmnd *qCompleted = NULL; +#if SERDEBUG +volatile static spinlock_t serial_lock; +#endif volatile static spinlock_t mega_lock; -static struct tq_struct runq = {0, 0, mega_runque, NULL}; struct proc_dir_entry proc_scsi_megaraid = { @@ -299,10 +337,12 @@ int i; long flags; + spin_lock_irqsave(&serial_lock,flags); va_start (args, fmt); i = vsprintf (strbuf, fmt, args); ser_puts (strbuf); va_end (args); + spin_unlock_irqrestore(&serial_lock,flags); return i; } @@ -329,27 +369,28 @@ * *-------------------------------------------------------------------------*/ -/*================================================ - * Initialize SCB structures - *================================================ +/*======================= + * Free a SCB structure + *======================= */ -static int initSCB (mega_host_config * megaCfg) +static void freeSCB (mega_host_config *megaCfg, mega_scb * pScb) { - int idx; + mega_scb **ppScb; - for (idx = 0; idx < megaCfg->max_cmds; idx++) { - megaCfg->scbList[idx].idx = -1; - megaCfg->scbList[idx].flag = 0; - megaCfg->scbList[idx].sgList = kmalloc(sizeof(mega_sglist) * MAX_SGLIST, - GFP_ATOMIC | GFP_DMA); - if (megaCfg->scbList[idx].sgList == NULL) { - printk(KERN_WARNING "Can't allocate sglist for id %d\n",idx); - freeSgList(megaCfg); - return -1; + /* Unlink from pending queue */ + for(ppScb=&megaCfg->qPending; *ppScb; ppScb=&(*ppScb)->next) { + if (*ppScb == pScb) { + *ppScb = pScb->next; + break; } - megaCfg->scbList[idx].SCpnt = NULL; } - return 0; + + /* Link back into list */ + pScb->state = SCB_FREE; + pScb->SCpnt = NULL; + + pScb->next = megaCfg->qFree; + megaCfg->qFree = pScb; } /*=========================== @@ -358,138 +399,134 @@ */ static mega_scb * allocateSCB (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt) { - int idx; - long flags; - - spin_lock_irqsave (&mega_lock, flags); - for (idx = 0; idx < megaCfg->max_cmds; idx++) { - if (megaCfg->scbList[idx].idx < 0) { + mega_scb *pScb; - /* Set Index and SCB pointer */ - megaCfg->scbList[idx].idx = idx; - spin_unlock_irqrestore (&mega_lock, flags); - megaCfg->scbList[idx].flag = 0; - megaCfg->scbList[idx].SCpnt = SCpnt; - megaCfg->scbList[idx].next = NULL; + /* Unlink command from Free List */ + if ((pScb = megaCfg->qFree) != NULL) { + megaCfg->qFree = pScb->next; + + pScb->isrcount = jiffies; + pScb->next = NULL; + pScb->state = SCB_ACTIVE; + pScb->SCpnt = SCpnt; - return &megaCfg->scbList[idx]; - } + return pScb; } - spin_unlock_irqrestore (&mega_lock, flags); printk (KERN_WARNING "Megaraid: Could not allocate free SCB!!!\n"); return NULL; } -/*======================= - * Free a SCB structure - *======================= +/*================================================ + * Initialize SCB structures + *================================================ */ -static void freeSCB (mega_scb * scb) +static int initSCB (mega_host_config * megaCfg) { - scb->flag = 0; - scb->next = NULL; - scb->SCpnt = NULL; - scb->idx = -1; + int idx; + + megaCfg->qFree = NULL; + for (idx = megaCfg->max_cmds-1; idx >= 0; idx--) { + megaCfg->scbList[idx].idx = idx; + megaCfg->scbList[idx].sgList = kmalloc(sizeof(mega_sglist) * MAX_SGLIST, + GFP_ATOMIC | GFP_DMA); + if (megaCfg->scbList[idx].sgList == NULL) { + printk(KERN_WARNING "Can't allocate sglist for id %d\n",idx); + freeSgList(megaCfg); + return -1; + } + + if (idx < MAX_COMMANDS) { + /* Link to free list */ + freeSCB(megaCfg, &megaCfg->scbList[idx]); + } + } + return 0; } /* Run through the list of completed requests */ static void mega_rundoneq () { - mega_host_config *megaCfg; Scsi_Cmnd *SCpnt; - char islogical; while (1) { DEQUEUE (SCpnt, Scsi_Cmnd, qCompleted, host_scribble); if (SCpnt == NULL) return; - megaCfg = (mega_host_config *) SCpnt->host->hostdata; - - islogical = (SCpnt->channel == megaCfg->host->max_channel && - SCpnt->target == 0); - if (SCpnt->cmnd[0] == INQUIRY && - ((((u_char *) SCpnt->request_buffer)[0] & 0x1F) == TYPE_DISK) && - !islogical) { - SCpnt->result = 0xF0; - } - - /* Convert result to error */ - switch (SCpnt->result) { - case 0x00: - case 0x02: - SCpnt->result |= (DID_OK << 16); - break; - case 0x8: - SCpnt->result |= (DID_BUS_BUSY << 16); - break; - default: - SCpnt->result |= (DID_BAD_TARGET << 16); - break; - } - /* Callback */ callDone (SCpnt); } } -/* Add command to the list of completed requests */ -static void mega_cmd_done (mega_host_config * megaCfg, mega_scb * pScb, int status) -{ - pScb->SCpnt->result = status; - ENQUEUE (pScb->SCpnt, Scsi_Cmnd, qCompleted, host_scribble); - freeSCB (pScb); -} - -/*---------------------------------------------------- - * Process pending queue list - * - * Run as a scheduled task - *----------------------------------------------------*/ -static void mega_runque (void *dummy) +/* + Runs through the list of pending requests + Assumes that mega_lock spin_lock has been acquired. +*/ +static void mega_runpendq(mega_host_config *megaCfg) { - mega_host_config *megaCfg; mega_scb *pScb; - long flags; - /* Take care of any completed requests */ - mega_rundoneq (); + /* Issue any pending commands to the card */ + for(pScb=megaCfg->qPending; pScb; pScb=pScb->next) { + if (pScb->state == SCB_ACTIVE) { + megaIssueCmd(megaCfg, pScb->mboxData, pScb, 1); + } + } +} - DEQUEUE (pScb, mega_scb, qPending, next); +/* Add command to the list of completed requests */ +static void mega_cmd_done (mega_host_config * megaCfg, mega_scb * pScb, + int status) +{ + int islogical; + Scsi_Cmnd *SCpnt; - if (pScb) { - if (pScb->SCpnt) { - TRACE(("NULL SCpnt for idx %d!\n",pScb->idx)); - } - megaCfg = (mega_host_config *) pScb->SCpnt->host->hostdata; - - if (megaCfg->mbox->busy || megaCfg->flag & (IN_ISR | PENDING)) { - TRACE (("%.08lx %.02x <%d.%d.%d> busy%d isr%d pending%d\n", - pScb->SCpnt->serial_number, - pScb->SCpnt->cmnd[0], - pScb->SCpnt->channel, - pScb->SCpnt->target, - pScb->SCpnt->lun, - megaCfg->mbox->busy, - (megaCfg->flag & IN_ISR) ? 1 : 0, - (megaCfg->flag & PENDING) ? 1 : 0)); - } - - if (MegaIssueCmd (megaCfg, pScb->mboxData, pScb, 1)) { - /* We're BUSY... come back later */ - spin_lock_irqsave (&mega_lock, flags); - pScb->next = qPending; - qPending = pScb; - spin_unlock_irqrestore (&mega_lock, flags); - - if (!(megaCfg->flag & PENDING)) { - /* If PENDING, irq will schedule task */ - queue_task (&runq, &tq_scheduler); - } - } + if (pScb == NULL) { + TRACE(("NULL pScb in mega_cmd_done!")); + printk("NULL pScb in mega_cmd_done!"); + } + + SCpnt = pScb->SCpnt; + freeSCB(megaCfg, pScb); + + if (SCpnt == NULL) { + TRACE(("NULL SCpnt in mega_cmd_done!")); + TRACE(("pScb->idx = ",pScb->idx)); + TRACE(("pScb->state = ",pScb->state)); + TRACE(("pScb->state = ",pScb->state)); + printk("Problem...!\n"); + while(1); + } + + islogical = (SCpnt->channel == megaCfg->host->max_channel && + SCpnt->target == 0); + if (SCpnt->cmnd[0] == INQUIRY && + ((((u_char *) SCpnt->request_buffer)[0] & 0x1F) == TYPE_DISK) && + !islogical) { + status = 0xF0; + } + + SCpnt->result = 0; /* clear result; otherwise, success returns corrupt + value */ + + /* Convert MegaRAID status to Linux error code */ + switch (status) { + case 0x00: /* SUCCESS */ + case 0x02: /* ERROR_ABORTED */ + SCpnt->result |= (DID_OK << 16); + break; + case 0x8: /* ERR_DEST_DRIVE_FAILED */ + SCpnt->result |= (DID_BUS_BUSY << 16); + break; + default: + SCpnt->result |= (DID_BAD_TARGET << 16); + break; } + + /* Add Scsi_Command to end of completed queue */ + ENQUEUE_NL(SCpnt, Scsi_Cmnd, qCompleted, host_scribble); } /*------------------------------------------------------------------- @@ -500,7 +537,8 @@ * If NULL is returned, the scsi_done function MUST have been called * *-------------------------------------------------------------------*/ -static mega_scb * mega_build_cmd (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt) +static mega_scb * mega_build_cmd (mega_host_config * megaCfg, + Scsi_Cmnd * SCpnt) { mega_scb *pScb; mega_mailbox *mbox; @@ -508,6 +546,11 @@ long seg; char islogical; + if (SCpnt == NULL) { + printk("NULL SCpnt in mega_build_cmd!\n"); + while(1); + } + if (SCpnt->cmnd[0] & 0x80) /* ioctl from megamgr */ return mega_ioctl (megaCfg, SCpnt); @@ -519,6 +562,12 @@ return NULL; } + if (!islogical && SCpnt->target == skip_id) { + SCpnt->result = (DID_BAD_TARGET << 16); + callDone (SCpnt); + return NULL; + } + /*----------------------------------------------------- * * Logical drive commands @@ -738,6 +787,21 @@ return (pScb); } +#if DEBUG +static void showMbox(mega_scb *pScb) +{ + mega_mailbox *mbox; + + if (pScb == NULL) return; + + mbox = (mega_mailbox *)pScb->mboxData; + printk("%u cmd:%x id:%x #scts:%x lba:%x addr:%x logdrv:%x #sg:%x\n", + pScb->SCpnt->pid, + mbox->cmd, mbox->cmdid, mbox->numsectors, + mbox->lba, mbox->xferaddr, mbox->logdrv, + mbox->numsgelements); +} +#endif /*-------------------------------------------------------------------- * Interrupt service routine @@ -745,7 +809,7 @@ static void megaraid_isr (int irq, void *devp, struct pt_regs *regs) { mega_host_config *megaCfg; - u_char byte, idx, sIdx; + u_char byte, idx, sIdx, tmpBox[MAILBOX_SIZE]; u_long dword; mega_mailbox *mbox; mega_scb *pScb; @@ -753,14 +817,14 @@ int qCnt, qStatus; megaCfg = (mega_host_config *) devp; - mbox = (mega_mailbox *) megaCfg->mbox; - - if (megaCfg->host->irq == irq) { + mbox = (mega_mailbox *)tmpBox; #if LINUX_VERSION_CODE >= 0x20100 - spin_lock_irqsave (&io_request_lock, flags); + spin_lock_irqsave (&io_request_lock, flags); #endif + while (megaCfg->host->irq == irq) { + spin_lock_irqsave (&mega_lock, flags); if (megaCfg->flag & IN_ISR) { @@ -769,6 +833,11 @@ megaCfg->flag |= IN_ISR; + if (mega_busyWaitMbox(megaCfg)) { + printk(KERN_WARNING "Error: mailbox busy in isr!\n"); + } + + /* Check if a valid interrupt is pending */ if (megaCfg->flag & BOARD_QUARTZ) { dword = RDOUTDOOR (megaCfg); @@ -776,12 +845,16 @@ /* Spurious interrupt */ megaCfg->flag &= ~IN_ISR; spin_unlock_irqrestore (&mega_lock, flags); -#if LINUX_VERSION_CODE >= 0x20100 - spin_unlock_irqrestore (&io_request_lock, flags); -#endif - return; + break; } WROUTDOOR (megaCfg, dword); + + /* Copy to temp location */ + memcpy(tmpBox, (mega_mailbox *)megaCfg->mbox, MAILBOX_SIZE); + + /* Acknowledge interrupt */ + WRINDOOR (megaCfg, virt_to_bus (megaCfg->mbox) | 0x2); + while (RDINDOOR (megaCfg) & 0x02); } else { byte = READ_PORT (megaCfg->host->io_port, INTR_PORT); @@ -789,71 +862,74 @@ /* Spurious interrupt */ megaCfg->flag &= ~IN_ISR; spin_unlock_irqrestore (&mega_lock, flags); -#if LINUX_VERSION_CODE >= 0x20100 - spin_unlock_irqrestore (&io_request_lock, flags); -#endif - return; + break; } WRITE_PORT (megaCfg->host->io_port, INTR_PORT, byte); + + /* Copy to temp location */ + memcpy(tmpBox, (mega_mailbox *)megaCfg->mbox, MAILBOX_SIZE); + + /* Acknowledge interrupt */ + CLEAR_INTR (megaCfg->host->io_port); } qCnt = mbox->numstatus; qStatus = mbox->status; - if (qCnt > 1) { - TRACE (("ISR: Received %d status\n", qCnt)) - printk (KERN_DEBUG "Got numstatus = %d\n", qCnt); - } - for (idx = 0; idx < qCnt; idx++) { sIdx = mbox->completed[idx]; if (sIdx > 0) { pScb = &megaCfg->scbList[sIdx - 1]; - /* FVF: let's try to avoid un/locking for no good reason */ - pScb->SCpnt->result = qStatus; - ENQUEUE_NL (pScb->SCpnt, Scsi_Cmnd, qCompleted, host_scribble); - freeSCB (pScb); + + /* ASSERT(pScb->state == SCB_ISSUED); */ + +#if DEBUG + if (((jiffies) - pScb->isrcount) > maxCmdTime) { + maxCmdTime = (jiffies) - pScb->isrcount; + printk("cmd time = %u\n", maxCmdTime); + } +#endif + + if (pScb->state == SCB_ABORTED) { + printk("Received aborted SCB! %u\n", (int)((jiffies)-pScb->isrcount)); + } + + /* Mark command as completed */ + mega_cmd_done(megaCfg, pScb, qStatus); } + } - if (megaCfg->flag & BOARD_QUARTZ) { - WRINDOOR (megaCfg, virt_to_bus (megaCfg->mbox) | 0x2); - while (RDINDOOR (megaCfg) & 0x02); - } - else { - CLEAR_INTR (megaCfg->host->io_port); - } + spin_unlock_irqrestore (&mega_lock, flags); megaCfg->flag &= ~IN_ISR; - megaCfg->flag &= ~PENDING; - spin_unlock_irqrestore (&mega_lock, flags); - mega_runque (NULL); + mega_rundoneq(); -#if LINUX_VERSION_CODE >= 0x20100 - spin_unlock_irqrestore (&io_request_lock, flags); -#endif + /* Loop through any pending requests */ + spin_lock_irqsave(&mega_lock, flags); + mega_runpendq(megaCfg); + spin_unlock_irqrestore(&mega_lock,flags); + } -#if 0 - /* Queue as a delayed ISR routine */ - queue_task_irq_off (&runq, &tq_immediate); - mark_bh (IMMEDIATE_BH); +#if LINUX_VERSION_CODE >= 0x20100 + spin_unlock_irqrestore (&io_request_lock, flags); #endif - - } } /*==================================================*/ /* Wait until the controller's mailbox is available */ /*==================================================*/ -static int busyWaitMbox (mega_host_config * megaCfg) +static int mega_busyWaitMbox (mega_host_config * megaCfg) { mega_mailbox *mbox = (mega_mailbox *) megaCfg->mbox; long counter; for (counter = 0; counter < 10000; counter++) { - udelay (100); - if (!mbox->busy) + if (!mbox->busy) { return 0; + } + udelay (100); + barrier(); } return -1; /* give up after 1 second */ } @@ -868,47 +944,55 @@ * int intr - if 1, interrupt, 0 is blocking *===================================================== */ -static int MegaIssueCmd (mega_host_config * megaCfg, +static int megaIssueCmd (mega_host_config * megaCfg, u_char * mboxData, mega_scb * pScb, int intr) { mega_mailbox *mbox = (mega_mailbox *) megaCfg->mbox; - long flags; u_char byte; u_long cmdDone; - - mboxData[0x1] = (pScb ? pScb->idx + 1 : 0x00); /* Set cmdid */ + Scsi_Cmnd *SCpnt; + + mboxData[0x1] = (pScb ? pScb->idx + 1: 0x0); /* Set cmdid */ mboxData[0xF] = 1; /* Set busy */ - spin_lock_irqsave(&mega_lock,flags); - -#ifndef CONFIG_MEGARAID_MULTI_IO - if (megaCfg->flag & PENDING) { - spin_unlock_irqrestore(&mega_lock,flags); - return -1; +#if 0 + if (intr && mbox->busy) { + return 0; } #endif /* Wait until mailbox is free */ - if (busyWaitMbox (megaCfg)) { - if (pScb) { - TRACE (("Mailbox busy %.08lx <%d.%d.%d>\n", pScb->SCpnt->serial_number, - pScb->SCpnt->channel, pScb->SCpnt->target, pScb->SCpnt->lun)); - } else { - TRACE(("pScb NULL in MegaIssueCmd!\n")); + while (mega_busyWaitMbox (megaCfg)) { + printk("Blocked mailbox!!\n"); + udelay(1000); + +#if DEBUG + showMbox(pLastScb); +#endif + + /* Abort command */ + if (pScb == NULL) { + printk("NULL pScb in megaIssue\n"); + TRACE(("NULL pScb in megaIssue\n")); } - spin_unlock_irqrestore(&mega_lock,flags); - return -1; + SCpnt = pScb->SCpnt; + freeSCB(megaCfg, pScb); + + SCpnt->result = (DID_ABORT << 16); + callDone(SCpnt); + return 0; } + pLastScb = pScb; + /* Copy mailbox data into host structure */ - memset (mbox, 0, 16); memcpy (mbox, mboxData, 16); /* Kick IO */ - megaCfg->flag |= PENDING; if (intr) { + /* Issue interrupt (non-blocking) command */ if (megaCfg->flag & BOARD_QUARTZ) { mbox->mraid_poll = 0; @@ -919,12 +1003,11 @@ ENABLE_INTR (megaCfg->host->io_port); ISSUE_COMMAND (megaCfg->host->io_port); } - spin_unlock_irqrestore(&mega_lock,flags); + pScb->state = SCB_ISSUED; } else { /* Issue non-ISR (blocking) command */ - + disable_irq(megaCfg->host->irq); if (megaCfg->flag & BOARD_QUARTZ) { - mbox->mraid_poll = 0; mbox->mraid_ack = 0; WRINDOOR (megaCfg, virt_to_bus (megaCfg->mbox) | 0x1); @@ -932,7 +1015,6 @@ while ((cmdDone = RDOUTDOOR (megaCfg)) != 0x10001234); WROUTDOOR (megaCfg, cmdDone); - spin_unlock_irqrestore(&mega_lock,flags); if (pScb) { mega_cmd_done (megaCfg, pScb, mbox->status); mega_rundoneq (); @@ -941,8 +1023,6 @@ WRINDOOR (megaCfg, virt_to_bus (megaCfg->mbox) | 0x2); while (RDINDOOR (megaCfg) & 0x2); - megaCfg->flag &= ~PENDING; - } else { DISABLE_INTR (megaCfg->host->io_port); @@ -954,8 +1034,6 @@ ENABLE_INTR (megaCfg->host->io_port); CLEAR_INTR (megaCfg->host->io_port); - megaCfg->flag &= ~PENDING; - spin_unlock_irqrestore(&mega_lock,flags); if (pScb) { mega_cmd_done (megaCfg, pScb, mbox->status); @@ -966,6 +1044,11 @@ } } + enable_irq(megaCfg->host->irq); + } + while (mega_busyWaitMbox (megaCfg)) { + printk("Blocked mailbox on exit!\n"); + udelay(1000); } return 0; @@ -1058,6 +1141,7 @@ u_long paddr; spin_lock_init (&mega_lock); + /* Initialize adapter inquiry */ paddr = virt_to_bus (megaCfg->mega_buffer); mbox = (mega_mailbox *) mboxData; @@ -1070,7 +1154,7 @@ mbox->xferaddr = paddr; /* Issue a blocking command to the card */ - MegaIssueCmd (megaCfg, mboxData, NULL, 0); + megaIssueCmd (megaCfg, mboxData, NULL, 0); /* Initialize host/local structures with Adapter info */ adapterInfo = (mega_RAIDINQ *) megaCfg->mega_buffer; @@ -1136,7 +1220,7 @@ * Returns data to be displayed in /proc/scsi/megaraid/X *----------------------------------------------------------*/ int megaraid_proc_info (char *buffer, char **start, off_t offset, - int length, int inode, int inout) + int length, int host_no, int inout) { *start = buffer; return 0; @@ -1150,35 +1234,33 @@ struct Scsi_Host *host; u_char pciBus, pciDevFun, megaIrq; u_long megaBase; - u_short pciIdx = 0; + u_short jdx,pciIdx = 0; u_short numFound = 0; #if LINUX_VERSION_CODE < 0x20100 while (!pcibios_find_device (pciVendor, pciDev, pciIdx, &pciBus, &pciDevFun)) { -#if 0 - if (flag & BOARD_QUARTZ) { - u_int magic; - pcibios_read_config_dword (pciBus, pciDevFun, - PCI_CONF_AMISIG, - &magic); - if (magic != AMI_SIGNATURE) { - pciIdx++; - continue; /* not an AMI board */ - } - } -#endif #if 0 - } /* keep auto-indenters happy */ + } /* keep auto-indenters happy */ #endif - #else + struct pci_dev *pdev = pci_devices; - + while ((pdev = pci_find_device (pciVendor, pciDev, pdev))) { pciBus = pdev->bus->number; pciDevFun = pdev->devfn; #endif + if (flag & BOARD_QUARTZ) { + u_short magic; + pcibios_read_config_word (pciBus, pciDevFun, + PCI_CONF_AMISIG, + &magic); + if (magic != AMI_SIGNATURE) { + pciIdx++; + continue; /* not an AMI board */ + } + } printk (KERN_INFO "megaraid: found 0x%4.04x:0x%4.04x:idx %d:bus %d:slot %d:fun %d\n", pciVendor, pciDev, @@ -1196,7 +1278,7 @@ &megaIrq); #else megaBase = pdev->base_address[0]; - megaIrq = pdev->irq; + megaIrq = pdev->irq; #endif pciIdx++; @@ -1214,10 +1296,12 @@ megaCfg = (mega_host_config *) host->hostdata; memset (megaCfg, 0, sizeof (mega_host_config)); - printk (KERN_INFO " scsi%d: Found a MegaRAID controller at 0x%x, IRQ: %d" CRLFSTR, + printk (" scsi%d: Found a MegaRAID controller at 0x%x, IRQ: %d" CRLFSTR, host->host_no, (u_int) megaBase, megaIrq); /* Copy resource info into structure */ + megaCfg->qPending = NULL; + megaCfg->qFree = NULL; megaCfg->flag = flag; megaCfg->host = host; megaCfg->base = megaBase; @@ -1248,11 +1332,16 @@ mega_register_mailbox (megaCfg, virt_to_bus ((void *) &megaCfg->mailbox)); mega_i_query_adapter (megaCfg); + + for(jdx=0; jdxnReads[jdx] = 0; + megaCfg->nWrites[jdx] = 0; + } /* Initialize SCBs */ if (initSCB (megaCfg)) { - scsi_unregister (host); - continue; + scsi_unregister (host); + continue; } numFound++; @@ -1275,6 +1364,16 @@ return 0; } #endif + skip_id = -1; + if (megaraid && !strncmp(megaraid,"skip",strlen("skip"))) { + if (megaraid[4] != '\0') { + skip_id = megaraid[4] - '0'; + if (megaraid[5] != '\0') { + skip_id = (skip_id * 10) + (megaraid[5] - '0'); + } + } + skip_id = (skip_id > 15) ? -1 : skip_id; + } count += findCard (pHostTmpl, 0x101E, 0x9010, 0); count += findCard (pHostTmpl, 0x101E, 0x9060, 0); @@ -1299,10 +1398,11 @@ memset (mbox, 0, 16); mboxData[0] = 0xA; - /* Issue a blocking (interrupts disabled) command to the card */ - MegaIssueCmd (megaCfg, mboxData, NULL, 0); + free_irq (megaCfg->host->irq, megaCfg);/* Must be freed first, otherwise + extra interrupt is generated */ - schedule (); + /* Issue a blocking (interrupts disabled) command to the card */ + megaIssueCmd (megaCfg, mboxData, NULL, 0); /* Free our resources */ if (megaCfg->flag & BOARD_QUARTZ) { @@ -1311,9 +1411,7 @@ else { release_region (megaCfg->host->io_port, 16); } - free_irq (megaCfg->host->irq, megaCfg); /* Must be freed first, otherwise - extra interrupt is generated */ freeSgList(megaCfg); scsi_unregister (pSHost); @@ -1369,6 +1467,9 @@ { mega_host_config *megaCfg; mega_scb *pScb; + long flags; + + spin_lock_irqsave(&mega_lock,flags); megaCfg = (mega_host_config *) SCpnt->host->hostdata; @@ -1381,15 +1482,38 @@ SCpnt->scsi_done = pktComp; + /* If driver in abort or reset.. cancel this command */ + if (megaCfg->flag & IN_ABORT) { + SCpnt->result = (DID_ABORT << 16); + ENQUEUE_NL(SCpnt, Scsi_Cmnd, qCompleted, host_scribble); + + spin_unlock_irqrestore(&mega_lock,flags); + return 0; + } + else if (megaCfg->flag & IN_RESET) { + SCpnt->result = (DID_RESET << 16); + ENQUEUE_NL(SCpnt, Scsi_Cmnd, qCompleted, host_scribble); + + spin_unlock_irqrestore(&mega_lock,flags); + return 0; + } + /* Allocate and build a SCB request */ if ((pScb = mega_build_cmd (megaCfg, SCpnt)) != NULL) { /* Add SCB to the head of the pending queue */ - ENQUEUE (pScb, mega_scb, qPending, next); + ENQUEUE_NL (pScb, mega_scb, megaCfg->qPending, next); - /* Issue the command to the card */ - mega_runque (NULL); + /* Issue any pending command to the card if not in ISR */ + if (!(megaCfg->flag & IN_ISR)) { + mega_runpendq(megaCfg); + } + else { + printk("IRQ pend...\n"); + } } + spin_unlock_irqrestore(&mega_lock,flags); + return 0; } @@ -1398,31 +1522,16 @@ *----------------------------------------------------------------------*/ volatile static int internal_done_flag = 0; volatile static int internal_done_errcode = 0; +static struct wait_queue *internal_wait = NULL; static void internal_done (Scsi_Cmnd * SCpnt) { internal_done_errcode = SCpnt->result; internal_done_flag++; + wake_up(&internal_wait); } -/* - * This seems dangerous in an SMP environment because - * while spinning on internal_done_flag in 2.0.x SMP - * no IRQ's will be taken, including those that might - * be needed to clear this. - * - * I think this should be using a wait queue ? - * -- AC - */ - -/* - * I'll probably fix this in the next version, but - * megaraid_command() will never get called since can_queue is set, - * except maybe in a *really* old kernel in which case it's very - * unlikely they'd be using SMP anyway. Really this function is - * just here for completeness. - * - JLJ - */ +/* shouldn't be used, but included for completeness */ int megaraid_command (Scsi_Cmnd * SCpnt) { @@ -1431,8 +1540,9 @@ /* Queue command, and wait until it has completed */ megaraid_queue (SCpnt, internal_done); - while (!internal_done_flag) - barrier (); + while (!internal_done_flag) { + interruptible_sleep_on(&internal_wait); + } return internal_done_errcode; } @@ -1443,31 +1553,77 @@ int megaraid_abort (Scsi_Cmnd * SCpnt) { mega_host_config *megaCfg; - int idx; - long flags; + int rc, idx; + long flags; + mega_scb *pScb; + + rc = SCSI_ABORT_SUCCESS; spin_lock_irqsave (&mega_lock, flags); megaCfg = (mega_host_config *) SCpnt->host->hostdata; + megaCfg->flag |= IN_ABORT; + + for(pScb=megaCfg->qPending; pScb; pScb=pScb->next) { + if (pScb->SCpnt == SCpnt) { + /* Found an aborting command */ +#if DEBUG + showMbox(pScb); +#endif + + printk("Abort: %d %u\n", + SCpnt->timeout_per_command, + (uint)((jiffies) - pScb->isrcount)); + + switch(pScb->state) { + case SCB_ABORTED: /* Already aborted */ + rc = SCSI_ABORT_SNOOZE; + break; + case SCB_ISSUED: /* Waiting on ISR result */ + rc = SCSI_ABORT_PENDING; + pScb->state = SCB_ABORTED; + break; + } + } + } + +#if 0 TRACE (("ABORT!!! %.08lx %.02x <%d.%d.%d>\n", - SCpnt->serial_number, SCpnt->cmnd[0], SCpnt->channel, SCpnt->target, + SCpnt->serial_number, SCpnt->cmnd[0], SCpnt->channel, SCpnt->target, SCpnt->lun)); + for(pScb=megaCfg->qPending; pScb; pScb=pScb->next) { + if (pScb->SCpnt == SCpnt) { + ser_printk("** %d<%x> %c\n", pScb->SCpnt->pid, pScb->idx+1, + pScb->state == SCB_ACTIVE ? 'A' : 'I'); +#if DEBUG + showMbox(pScb); +#endif + } + } +#endif + /* * Walk list of SCBs for any that are still outstanding */ for (idx = 0; idx < megaCfg->max_cmds; idx++) { - if (megaCfg->scbList[idx].idx >= 0) { + if (megaCfg->scbList[idx].state != SCB_FREE) { if (megaCfg->scbList[idx].SCpnt == SCpnt) { - freeSCB (&megaCfg->scbList[idx]); + freeSCB (megaCfg, &megaCfg->scbList[idx]); - SCpnt->result = (DID_RESET << 16) | (SUGGEST_RETRY << 24); - callDone (SCpnt); + SCpnt->result = (DID_ABORT << 16) | (SUGGEST_RETRY << 24); + ENQUEUE_NL(SCpnt, Scsi_Cmnd, qCompleted, host_scribble); } } } + + megaCfg->flag &= ~IN_ABORT; + spin_unlock_irqrestore (&mega_lock, flags); - return SCSI_ABORT_SNOOZE; + + mega_rundoneq(); + + return rc; } /*--------------------------------------------------------------------- @@ -1483,6 +1639,8 @@ megaCfg = (mega_host_config *) SCpnt->host->hostdata; + megaCfg->flag |= IN_RESET; + TRACE (("RESET: %.08lx %.02x <%d.%d.%d>\n", SCpnt->serial_number, SCpnt->cmnd[0], SCpnt->channel, SCpnt->target, SCpnt->lun)); @@ -1491,14 +1649,21 @@ * Walk list of SCBs for any that are still outstanding */ for (idx = 0; idx < megaCfg->max_cmds; idx++) { - if (megaCfg->scbList[idx].idx >= 0) { + if (megaCfg->scbList[idx].state != SCB_FREE) { SCpnt = megaCfg->scbList[idx].SCpnt; - freeSCB (&megaCfg->scbList[idx]); - SCpnt->result = (DID_RESET << 16) | (SUGGEST_RETRY << 24); - callDone (SCpnt); + if (SCpnt != NULL) { + freeSCB (megaCfg, &megaCfg->scbList[idx]); + SCpnt->result = (DID_RESET << 16) | (SUGGEST_RETRY << 24); + ENQUEUE_NL(SCpnt, Scsi_Cmnd, qCompleted, host_scribble); + } } } + + megaCfg->flag &= ~IN_RESET; + spin_unlock_irqrestore (&mega_lock, flags); + + mega_rundoneq(); return SCSI_RESET_PUNT; } diff -u --recursive --new-file v2.2.7/linux/drivers/scsi/megaraid.h linux/drivers/scsi/megaraid.h --- v2.2.7/linux/drivers/scsi/megaraid.h Fri Apr 16 14:47:31 1999 +++ linux/drivers/scsi/megaraid.h Fri May 7 15:09:45 1999 @@ -6,24 +6,23 @@ #endif #define IN_ISR 0x80000000L -#define NO_INTR 0x40000000L -#define IN_TIMEOUT 0x20000000L -#define PENDING 0x10000000L +#define IN_ABORT 0x40000000L +#define IN_RESET 0x20000000L #define BOARD_QUARTZ 0x08000000L -#define SCB_ACTIVE 0x1 -#define SCB_WAITQ 0x2 -#define SCB_ISSUED 0x4 - -#define SCB_FREE -1 -#define SCB_RESET -2 -#define SCB_ABORT -3 -#define SCB_LOCKED -4 +#define SCB_FREE 0x0 +#define SCB_ACTIVE 0x1 +#define SCB_WAITQ 0x2 +#define SCB_ISSUED 0x3 +#define SCB_COMPLETE 0x4 +#define SCB_ABORTED 0x5 +#define SCB_RESET 0x6 #define MEGA_CMD_TIMEOUT 10 #define MAX_SGLIST 17 -#define MAX_COMMANDS 254 +#define MAX_COMMANDS 250 +#define MAX_CMD_PER_LUN 63 #define MAX_LOGICAL_DRIVES 8 #define MAX_CHANNEL 5 @@ -99,7 +98,7 @@ #define PCI_CONF_BASE_ADDR_OFFSET 0x10 #define PCI_CONF_IRQ_OFFSET 0x3c #define PCI_CONF_AMISIG 0xa0 -#define AMI_SIGNATURE 0x11223344 +#define AMI_SIGNATURE 0x3344 #if LINUX_VERSION_CODE < 0x20100 #define MEGARAID \ @@ -117,11 +116,11 @@ megaraid_reset, /* Reset Command Function */\ NULL, /* Slave Attach Function */\ megaraid_biosparam, /* Disk BIOS Parameters */\ - 254, /* # of cmds that can be\ + MAX_COMMANDS, /* # of cmds that can be\ outstanding at any time */\ 7, /* HBA Target ID */\ MAX_SGLIST, /* Scatter/Gather Table Size */\ - 64, /* SCSI Commands per LUN */\ + MAX_CMD_PER_LUN, /* SCSI Commands per LUN */\ 0, /* Present */\ 0, /* Default Unchecked ISA DMA */\ ENABLE_CLUSTERING } /* Enable Clustering */ @@ -138,10 +137,10 @@ abort: megaraid_abort, /* Abort Command Function */\ reset: megaraid_reset, /* Reset Command Function */\ bios_param: megaraid_biosparam, /* Disk BIOS Parameters */\ - can_queue: 1 /* MAX_COMMANDS */, /* Can Queue */\ + can_queue: MAX_COMMANDS, /* Can Queue */\ this_id: 7, /* HBA Target ID */\ sg_tablesize: MAX_SGLIST, /* Scatter/Gather Table Size */\ - cmd_per_lun: 64, /* SCSI Commands per LUN */\ + cmd_per_lun: MAX_CMD_PER_LUN, /* SCSI Commands per LUN */\ present: 0, /* Present */\ unchecked_isa_dma:0, /* Default Unchecked ISA DMA */\ use_clustering: ENABLE_CLUSTERING /* Enable Clustering */\ @@ -250,13 +249,14 @@ typedef struct _mega_scb mega_scb; struct _mega_scb { - int idx; - u_long flag; - Scsi_Cmnd *SCpnt; - u_char mboxData[16]; - mega_passthru pthru; - mega_sglist *sgList; - mega_scb *next; + int idx; + u_long state; + u_long isrcount; + u_char mboxData[16]; + mega_passthru pthru; + Scsi_Cmnd *SCpnt; + mega_sglist *sgList; + mega_scb *next; }; /* Per-controller data */ @@ -264,8 +264,12 @@ u_char numldrv; u_long flag; u_long base; + + mega_scb *qFree; + mega_scb *qPending; - struct tq_struct megaTq; + u_long nReads[MAX_LOGICAL_DRIVES]; + u_long nWrites[MAX_LOGICAL_DRIVES]; /* Host adapter parameters */ u_char fwVer[7]; diff -u --recursive --new-file v2.2.7/linux/drivers/scsi/ppa.c linux/drivers/scsi/ppa.c --- v2.2.7/linux/drivers/scsi/ppa.c Mon Mar 29 11:09:11 1999 +++ linux/drivers/scsi/ppa.c Fri May 7 10:57:42 1999 @@ -741,6 +741,7 @@ { ppa_struct *tmp = (ppa_struct *) data; Scsi_Cmnd *cmd = tmp->cur_cmd; + unsigned long flags; if (!cmd) { printk("PPA: bug in ppa_interrupt\n"); @@ -792,7 +793,10 @@ ppa_pb_release(cmd->host->unique_id); tmp->cur_cmd = 0; + + spin_lock_irqsave(&io_request_lock, flags); cmd->scsi_done(cmd); + spin_unlock_irqrestore(&io_request_lock, flags); return; } diff -u --recursive --new-file v2.2.7/linux/drivers/scsi/scsi.c linux/drivers/scsi/scsi.c --- v2.2.7/linux/drivers/scsi/scsi.c Tue Mar 23 14:35:48 1999 +++ linux/drivers/scsi/scsi.c Thu Apr 29 11:53:41 1999 @@ -1926,10 +1926,12 @@ SDpnt->device_queue = NULL; for(j=0;jqueue_depth;j++){ - SCpnt = (Scsi_Cmnd *) + SCpnt = (Scsi_Cmnd *) scsi_init_malloc(sizeof(Scsi_Cmnd), GFP_ATOMIC | (host->unchecked_isa_dma ? GFP_DMA : 0)); + if (NULL == SCpnt) + break; /* If not, the next line will oops ... */ memset(&SCpnt->eh_timeout, 0, sizeof(SCpnt->eh_timeout)); SCpnt->host = host; SCpnt->device = SDpnt; @@ -1951,6 +1953,12 @@ SDpnt->device_queue = SCpnt; SCpnt->state = SCSI_STATE_UNUSED; SCpnt->owner = SCSI_OWNER_NOBODY; + } + if (j < SDpnt->queue_depth) { /* low on space (D.Gilbert 990424) */ + printk("scsi_build_commandblocks: want=%d, space for=%d blocks\n", + SDpnt->queue_depth, j); + SDpnt->queue_depth = j; + /* Still problem if 0==j , continue anyway ... */ } SDpnt->has_cmdblocks = 1; } diff -u --recursive --new-file v2.2.7/linux/drivers/scsi/scsi_ioctl.c linux/drivers/scsi/scsi_ioctl.c --- v2.2.7/linux/drivers/scsi/scsi_ioctl.c Wed Sep 9 14:51:09 1998 +++ linux/drivers/scsi/scsi_ioctl.c Thu Apr 29 11:53:41 1999 @@ -131,15 +131,16 @@ else printk("SCSI device (ioctl) reports ILLEGAL REQUEST.\n"); break; case NOT_READY: /* This happens if there is no disc in drive */ - if(dev->removable){ + if(dev->removable && (cmd[0] != TEST_UNIT_READY)){ printk(KERN_INFO "Device not ready. Make sure there is a disc in the drive.\n"); break; - }; + } case UNIT_ATTENTION: if (dev->removable){ dev->changed = 1; SCpnt->result = 0; /* This is no longer considered an error */ - printk(KERN_INFO "Disc change detected.\n"); + /* gag this error, VFS will log it anyway /axboe */ + /* printk(KERN_INFO "Disc change detected.\n"); */ break; }; default: /* Fall through for non-removable media */ diff -u --recursive --new-file v2.2.7/linux/drivers/scsi/sd.c linux/drivers/scsi/sd.c --- v2.2.7/linux/drivers/scsi/sd.c Tue Feb 23 15:21:34 1999 +++ linux/drivers/scsi/sd.c Thu Apr 29 11:53:41 1999 @@ -719,6 +719,12 @@ SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors); goto repeat; } + if (rscsi_disks[dev].sector_size == 4096) + if((block & 7) || (SCpnt->request.nr_sectors & 7)) { + printk("sd.cBad block number/count requested"); + SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors); + goto repeat; + } switch (SCpnt->request.cmd) { @@ -984,6 +990,13 @@ cmd[1] = (SCpnt->lun << 5) & 0xe0; + if (rscsi_disks[dev].sector_size == 4096){ + if(block & 7) panic("sd.c:Bad block number requested"); + if(this_count & 7) panic("sd.c:Bad block number requested"); + block = block >> 3; + this_count = block >> 3; + } + if (rscsi_disks[dev].sector_size == 2048){ if(block & 3) panic("sd.c:Bad block number requested"); if(this_count & 3) panic("sd.c:Bad block number requested"); @@ -1335,6 +1348,7 @@ if (rscsi_disks[i].sector_size != 512 && rscsi_disks[i].sector_size != 1024 && rscsi_disks[i].sector_size != 2048 && + rscsi_disks[i].sector_size != 4096 && rscsi_disks[i].sector_size != 256) { printk ("%s : unsupported sector size %d.\n", @@ -1394,6 +1408,8 @@ nbuff, hard_sector, rscsi_disks[i].capacity, mb, sz_quot, sz_rem); } + if(rscsi_disks[i].sector_size == 4096) + rscsi_disks[i].capacity <<= 3; if(rscsi_disks[i].sector_size == 2048) rscsi_disks[i].capacity <<= 2; /* Change into 512 byte sectors */ if(rscsi_disks[i].sector_size == 1024) diff -u --recursive --new-file v2.2.7/linux/drivers/scsi/sg.c linux/drivers/scsi/sg.c --- v2.2.7/linux/drivers/scsi/sg.c Fri Apr 16 14:47:31 1999 +++ linux/drivers/scsi/sg.c Fri May 7 11:05:30 1999 @@ -16,7 +16,7 @@ * * Borrows code from st driver. Thanks to Alessandro Rubini's "dd" book. */ - static char * sg_version_str = "Version: 2.1.31 (990327)"; + static char * sg_version_str = "Version: 2.1.32 (990501)"; /* * D. P. Gilbert (dgilbert@interlog.com, dougg@triode.net.au) * - scatter list logic replaces previous large atomic SG_BIG_BUFF @@ -69,8 +69,9 @@ int sg_big_buff = SG_SCATTER_SZ; /* sg_big_buff is ro through sysctl */ /* N.B. This global is here to keep existing software happy. It now holds - the size of the "first buffer" of the most recent sucessful sg_open(). */ -/* Only available when 'sg' compiled into kernel (rather than a module). */ + the size of the "first buffer" of the most recent sucessful sg_open(). + Only available when 'sg' compiled into kernel (rather than a module). + This should probably be deprecated (use SG_GET_RESERVED_SIZE instead). */ #define SG_SECTOR_SZ 512 #define SG_SECTOR_MSK (SG_SECTOR_SZ - 1) @@ -146,6 +147,7 @@ char closed; /* 1 -> fd closed but request(s) outstanding */ char my_mem_src; /* heap whereabouts of this sg_fb object */ char cmd_q; /* 1 -> allow command queuing, 0 -> don't */ + char underrun_flag; /* 1 -> flag underruns, 0 -> don't, 2 -> test */ } Sg_fd; /* around 1192 bytes long on i386 */ typedef struct sg_device /* holds the state of each scsi generic device */ @@ -173,7 +175,7 @@ static char * sg_low_malloc(int rqSz, int lowDma, int mem_src, int * retSzp); static void sg_low_free(char * buff, int size, int mem_src); -static Sg_fd * sg_add_sfp(Sg_device * sdp, int dev); +static Sg_fd * sg_add_sfp(Sg_device * sdp, int dev, int get_reserved); static int sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp); static Sg_request * sg_get_request(const Sg_fd * sfp, int pack_id); static Sg_request * sg_add_request(Sg_fd * sfp); @@ -240,11 +242,14 @@ if (! sdp->headfp) { /* no existing opens on this device */ sdp->sgdebug = 0; sdp->sg_tablesize = sdp->device->host->sg_tablesize; - sdp->merge_fd = SG_DEF_MERGE_FD; + sdp->merge_fd = 0; /* A little tricky if SG_DEF_MERGE_FD set */ } - if ((sfp = sg_add_sfp(sdp, dev))) { + if ((sfp = sg_add_sfp(sdp, dev, O_RDWR == (flags & O_ACCMODE)))) { + filp->private_data = sfp; +#if SG_DEF_MERGE_FD if (0 == sdp->merge_fd) - filp->private_data = sfp; + sdp->merge_fd = 1; +#endif } else { if (flags & O_EXCL) sdp->exclude = 0; /* undo if error */ @@ -322,11 +327,12 @@ return -ERESTARTSYS; srp = sg_get_request(sfp, req_pack_id); } - srp->header.pack_len = srp->header.reply_len; /* Why ????? */ + if (2 != sfp->underrun_flag) + srp->header.pack_len = srp->header.reply_len; /* Why ????? */ /* Now copy the result back to the user buffer. */ if (count >= size_sg_header) { - copy_to_user(buf, &srp->header, size_sg_header); + __copy_to_user(buf, &srp->header, size_sg_header); buf += size_sg_header; if (count > srp->header.reply_len) count = srp->header.reply_len; @@ -371,7 +377,7 @@ ; /* FIXME: Hmm. Seek to the right place, or fail? */ if ((k = verify_area(VERIFY_READ, buf, count))) - return k; + return k; /* protects following copy_from_user()s + get_user()s */ /* The minimum scsi command length is 6 bytes. If we get anything * less than this, it is clearly bogus. */ if (count < (size_sg_header + 6)) @@ -382,10 +388,10 @@ SCSI_LOG_TIMEOUT(1, printk("sg_write: queue full, domain error\n")); return -EDOM; } - copy_from_user(&srp->header, buf, size_sg_header); + __copy_from_user(&srp->header, buf, size_sg_header); buf += size_sg_header; srp->header.pack_len = count; - get_user(opcode, buf); + __get_user(opcode, buf); cmd_size = COMMAND_SIZE(opcode); if ((opcode >= 0xc0) && srp->header.twelve_byte) cmd_size = 12; @@ -427,7 +433,7 @@ SCpnt->sense_buffer[0] = 0; SCpnt->cmd_len = cmd_size; /* Now copy the SCSI command from the user's address space. */ - copy_from_user(cmnd, buf, cmd_size); + __copy_from_user(cmnd, buf, cmd_size); /* Set the LUN field in the command structure. */ cmnd[1]= (cmnd[1] & 0x1f) | (sdp->device->lun << 5); @@ -439,11 +445,10 @@ SCpnt->use_sg = srp->data.use_sg; SCpnt->sglist_len = srp->data.sglist_len; SCpnt->bufflen = srp->data.bufflen; - SCpnt->underflow = srp->data.bufflen; -/* Not many drivers look at this: - aic7xxx driver gives DID_RETRY_COMMAND on underrun - seagate comments out its underrun checking code, and the rest ... -*/ + if (1 == sfp->underrun_flag) + SCpnt->underflow = srp->data.bufflen; + else + SCpnt->underflow = 0; SCpnt->buffer = srp->data.buffer; srp->data.use_sg = 0; srp->data.sglist_len = 0; @@ -479,14 +484,10 @@ switch(cmd_in) { case SG_SET_TIMEOUT: - result = verify_area(VERIFY_READ, (const void *)arg, sizeof(int)); - if (result) return result; return get_user(sfp->timeout, (int *)arg); case SG_GET_TIMEOUT: return sfp->timeout; /* strange ..., for backward compatibility */ case SG_SET_FORCE_LOW_DMA: - result = verify_area(VERIFY_READ, (const void *)arg, sizeof(int)); - if (result) return result; result = get_user(val, (int *)arg); if (result) return result; if (val) { @@ -503,28 +504,23 @@ sfp->low_dma = sdp->device->host->unchecked_isa_dma; return 0; case SG_GET_LOW_DMA: - result = verify_area(VERIFY_WRITE, (void *) arg, sizeof(int)); - if (result) return result; - put_user((int)sfp->low_dma, (int *)arg); - return 0; + return put_user((int)sfp->low_dma, (int *)arg); case SG_GET_SCSI_ID: result = verify_area(VERIFY_WRITE, (void *)arg, sizeof(Sg_scsi_id)); if (result) return result; else { Sg_scsi_id * sg_idp = (Sg_scsi_id *)arg; - put_user((int)sdp->device->host->host_no, &sg_idp->host_no); - put_user((int)sdp->device->channel, &sg_idp->channel); - put_user((int)sdp->device->id, &sg_idp->scsi_id); - put_user((int)sdp->device->lun, &sg_idp->lun); - put_user((int)sdp->device->type, &sg_idp->scsi_type); - put_user(0, &sg_idp->unused1); - put_user(0, &sg_idp->unused2); - put_user(0, &sg_idp->unused3); + __put_user((int)sdp->device->host->host_no, &sg_idp->host_no); + __put_user((int)sdp->device->channel, &sg_idp->channel); + __put_user((int)sdp->device->id, &sg_idp->scsi_id); + __put_user((int)sdp->device->lun, &sg_idp->lun); + __put_user((int)sdp->device->type, &sg_idp->scsi_type); + __put_user(0, &sg_idp->unused1); + __put_user(0, &sg_idp->unused2); + __put_user(0, &sg_idp->unused3); return 0; } case SG_SET_FORCE_PACK_ID: - result = verify_area(VERIFY_READ, (const void *)arg, sizeof(int)); - if (result) return result; result = get_user(val, (int *)arg); if (result) return result; sfp->force_packid = val ? 1 : 0; @@ -535,16 +531,14 @@ srp = sfp->headrp; while (srp) { if (! srp->my_cmdp) { - put_user(srp->header.pack_id, (int *)arg); + __put_user(srp->header.pack_id, (int *)arg); return 0; } srp = srp->nextrp; } - put_user(-1, (int *)arg); + __put_user(-1, (int *)arg); return 0; case SG_GET_NUM_WAITING: - result = verify_area(VERIFY_WRITE, (void *) arg, sizeof(int)); - if (result) return result; srp = sfp->headrp; val = 0; while (srp) { @@ -552,36 +546,25 @@ ++val; srp = srp->nextrp; } - put_user(val, (int *)arg); - return 0; + return put_user(val, (int *)arg); case SG_GET_SG_TABLESIZE: - result = verify_area(VERIFY_WRITE, (void *) arg, sizeof(int)); - if (result) return result; - put_user(sdp->sg_tablesize, (int *)arg); - return 0; + return put_user(sdp->sg_tablesize, (int *)arg); case SG_SET_RESERVED_SIZE: /* currently ignored, future extension */ if (O_RDWR != (filp->f_flags & O_ACCMODE)) return -EACCES; - result = verify_area(VERIFY_READ, (const void *)arg, sizeof(int)); + result = get_user(val, (int *)arg); if (result) return result; + /* logic should go here */ return 0; case SG_GET_RESERVED_SIZE: - result = verify_area(VERIFY_WRITE, (void *) arg, sizeof(int)); - if (result) return result; - put_user(sfp->fb_size, (int *)arg); - return 0; + return put_user(sfp->fb_size, (int *)arg); case SG_GET_MERGE_FD: - result = verify_area(VERIFY_WRITE, (void *) arg, sizeof(int)); - if (result) return result; - put_user((int)sdp->merge_fd, (int *)arg); - return 0; + return put_user((int)sdp->merge_fd, (int *)arg); case SG_SET_MERGE_FD: if (O_RDWR != (filp->f_flags & O_ACCMODE)) return -EACCES; /* require write access since effect wider then just this fd */ - result = verify_area(VERIFY_READ, (const void *)arg, sizeof(int)); - if (result) return result; result = get_user(val, (int *)arg); if (result) return result; val = val ? 1 : 0; @@ -591,17 +574,19 @@ sdp->merge_fd = val; return 0; case SG_SET_COMMAND_Q: - result = verify_area(VERIFY_READ, (const void *)arg, sizeof(int)); - if (result) return result; result = get_user(val, (int *)arg); if (result) return result; sfp->cmd_q = val ? 1 : 0; return 0; case SG_GET_COMMAND_Q: - result = verify_area(VERIFY_WRITE, (void *) arg, sizeof(int)); + return put_user((int)sfp->cmd_q, (int *)arg); + case SG_SET_UNDERRUN_FLAG: + result = get_user(val, (int *)arg); if (result) return result; - put_user((int)sfp->cmd_q, (int *)arg); + sfp->underrun_flag = val; return 0; + case SG_GET_UNDERRUN_FLAG: + return put_user((int)sfp->underrun_flag, (int *)arg); case SG_EMULATED_HOST: return put_user(sdp->device->host->hostt->emulated, (int *)arg); case SCSI_IOCTL_SEND_COMMAND: @@ -613,8 +598,6 @@ dangerous */ return scsi_ioctl_send_command(sdp->device, (void *)arg); case SG_SET_DEBUG: - result = verify_area(VERIFY_READ, (const void *)arg, sizeof(int)); - if (result) return result; result = get_user(val, (int *)arg); if (result) return result; sdp->sgdebug = (char)val; @@ -625,6 +608,8 @@ return 0; case SCSI_IOCTL_GET_IDLUN: case SCSI_IOCTL_GET_BUS_NUMBER: + case SCSI_IOCTL_PROBE_HOST: + case SG_GET_TRANSFORM: return scsi_ioctl(sdp->device, cmd_in, (void *)arg); default: if (O_RDWR != (filp->f_flags & O_ACCMODE)) @@ -698,6 +683,7 @@ sdp = &sg_dev_arr[dev]; if (NULL == sdp->device) return; /* Get out of here quick ... */ + sfp = sdp->headfp; while (sfp) { srp = sfp->headrp; @@ -721,6 +707,8 @@ srp->data.sglist_len = SCpnt->sglist_len; srp->data.bufflen = SCpnt->bufflen; srp->data.buffer = SCpnt->buffer; + if (2 == sfp->underrun_flag) + srp->header.pack_len = SCpnt->underflow; sg_clr_scpnt(SCpnt); srp->my_cmdp = NULL; @@ -755,7 +743,7 @@ * underrun or overrun should signal an error. Until that can be * implemented, this kludge allows for returning useful error values * except in cases that return DID_ERROR that might be due to an - * underrun. [Underrun on advansys adapter yields DID_ABORT -dpg] */ + * underrun. */ if (SCpnt->sense_buffer[0] == 0 && status_byte(SCpnt->result) == GOOD) srp->header.result = 0; @@ -887,8 +875,9 @@ printk(">> Following FD has NULL parent pointer ???\n"); printk(" FD(%d): timeout=%d, fb_size=%d, cmd_q=%d\n", k, fp->timeout, fp->fb_size, (int)fp->cmd_q); - printk(" low_dma=%d, force_packid=%d, closed=%d\n", - (int)fp->low_dma, (int)fp->force_packid, (int)fp->closed); + printk(" low_dma=%d, force_packid=%d, urun_flag=%d, closed=%d\n", + (int)fp->low_dma, (int)fp->force_packid, + (int)fp->underrun_flag, (int)fp->closed); srp = fp->headrp; if (NULL == srp) printk(" No requests active\n"); @@ -1002,7 +991,7 @@ sdp->generic_wait = NULL; sdp->headfp= NULL; sdp->exclude = 0; - sdp->merge_fd = 0; + sdp->merge_fd = 0; /* Cope with SG_DEF_MERGE_FD on open */ sdp->sgdebug = 0; sdp->sg_tablesize = scsidp->host ? scsidp->host->sg_tablesize : 0; sdp->i_rdev = MKDEV(SCSI_GENERIC_MAJOR, k); @@ -1120,7 +1109,7 @@ if ((blk_size < 0) || (! srp)) return -EFAULT; - SCSI_LOG_TIMEOUT(4, printk("sg build: m_b_s=%d, num_write_xfer=%d\n", + SCSI_LOG_TIMEOUT(4, printk("sg_sc_build: m_b_s=%d, num_write_xfer=%d\n", max_buff_size, num_write_xfer)); if (0 == blk_size) ++blk_size; /* don't know why */ @@ -1139,7 +1128,7 @@ srp->data.mem_src = mem_src; srp->data.b_malloc_len = blk_size; if (inp && (num_write_xfer > 0)) - copy_from_user(srp->data.buffer, inp, num_write_xfer); + __copy_from_user(srp->data.buffer, inp, num_write_xfer); return 0; } } @@ -1185,17 +1174,17 @@ } sclp->address = p; sclp->length = ret_sz; - sclp->alt_address = (char *)mem_src; + sclp->alt_address = (char *)(long)mem_src; if(inp && (num_write_xfer > 0)) { num = (ret_sz > num_write_xfer) ? num_write_xfer : ret_sz; - copy_from_user(sclp->address, inp, num); + __copy_from_user(sclp->address, inp, num); num_write_xfer -= num; inp += num; } SCSI_LOG_TIMEOUT(5, - printk("sg_sc_build: k=%d, a=0x%x, len=%d, ms=%d\n", - k, (int)sclp->address, ret_sz, (int)sclp->alt_address)); + printk("sg_sc_build: k=%d, a=0x%p, len=%d, ms=%d\n", + k, sclp->address, ret_sz, mem_src)); } /* end of for loop */ srp->data.use_sg = k; SCSI_LOG_TIMEOUT(5, @@ -1224,20 +1213,20 @@ if (num_read_xfer > 0) { num = (int)sclp->length; if (num > num_read_xfer) { - copy_to_user(outp, sclp->address, num_read_xfer); + __copy_to_user(outp, sclp->address, num_read_xfer); outp += num_read_xfer; num_read_xfer = 0; } else { - copy_to_user(outp, sclp->address, num); + __copy_to_user(outp, sclp->address, num); outp += num; num_read_xfer -= num; } } - mem_src = (int)sclp->alt_address; + mem_src = (int)(long)sclp->alt_address; SCSI_LOG_TIMEOUT(5, - printk("sg_sc_undo_rem: k=%d, a=0x%x, len=%d, ms=%d\n", - k, (int)sclp->address, sclp->length, mem_src)); + printk("sg_sc_undo_rem: k=%d, a=0x%p, len=%d, ms=%d\n", + k, sclp->address, sclp->length, mem_src)); sg_free(srp, sclp->address, sclp->length, mem_src); } sg_free(srp, srp->data.buffer, srp->data.sglist_len, @@ -1245,13 +1234,13 @@ } else { if (num_read_xfer > 0) - copy_to_user(outp, srp->data.buffer, num_read_xfer); + __copy_to_user(outp, srp->data.buffer, num_read_xfer); sg_free(srp, srp->data.buffer, srp->data.b_malloc_len, srp->data.mem_src); } if (0 == sg_remove_request(srp->parentfp, srp)) { - SCSI_LOG_TIMEOUT(1, printk("sg_sc_undo_rem: srp=%d not found\n", - (int)srp)); + SCSI_LOG_TIMEOUT(1, printk("sg_sc_undo_rem: srp=0x%p not found\n", + srp)); } return 0; } @@ -1336,7 +1325,7 @@ return 0; } -static Sg_fd * sg_add_sfp(Sg_device * sdp, int dev) +static Sg_fd * sg_add_sfp(Sg_device * sdp, int dev, int get_reserved) { Sg_fd * sfp; @@ -1357,8 +1346,12 @@ sfp->low_dma = (SG_DEF_FORCE_LOW_DMA == 0) ? sdp->device->host->unchecked_isa_dma : 1; sfp->cmd_q = SG_DEF_COMMAND_Q; - sfp->fst_buf = sg_low_malloc(SG_SCATTER_SZ, sfp->low_dma, - SG_HEAP_PAGE, &sfp->fb_size); + sfp->underrun_flag = SG_DEF_UNDERRUN_FLAG; + if (get_reserved) + sfp->fst_buf = sg_low_malloc(SG_SCATTER_SZ, sfp->low_dma, + SG_HEAP_PAGE, &sfp->fb_size); + else + sfp->fst_buf = NULL; if (! sfp->fst_buf) sfp->fb_size = 0; sfp->parentdp = sdp; @@ -1371,10 +1364,10 @@ pfp->nextfp = sfp; } sg_big_buff = sfp->fb_size; /* show sysctl most recent "fb" size */ - SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: sfp=0x%x, m_s=%d\n", - (int)sfp, (int)sfp->my_mem_src)); - SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: fb_sz=%d, fst_buf=0x%x\n", - sfp->fb_size, (int)sfp->fst_buf)); + SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: sfp=0x%p, m_s=%d\n", + sfp, (int)sfp->my_mem_src)); + SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: fb_sz=%d, fst_buf=0x%p\n", + sfp->fb_size, sfp->fst_buf)); return sfp; } @@ -1416,13 +1409,13 @@ prev_fp = fp; } } -SCSI_LOG_TIMEOUT(6, printk("sg_remove_sfp: fb_sz=%d, fst_buf=0x%x\n", - sfp->fb_size, (int)sfp->fst_buf)); +SCSI_LOG_TIMEOUT(6, printk("sg_remove_sfp: fb_sz=%d, fst_buf=0x%p\n", + sfp->fb_size, sfp->fst_buf)); sg_low_free(sfp->fst_buf, sfp->fb_size, SG_HEAP_PAGE); sfp->parentdp = NULL; sfp->fst_buf = NULL; sfp->fb_size = 0; - SCSI_LOG_TIMEOUT(6, printk("sg_remove_sfp: sfp=0x%x\n", (int)sfp)); + SCSI_LOG_TIMEOUT(6, printk("sg_remove_sfp: sfp=0x%p\n", sfp)); sg_low_free((char *)sfp, sizeof(Sg_fd), sfp->my_mem_src); res = 1; } @@ -1573,8 +1566,8 @@ } if (resp) *mem_srcp = l_ms; } - SCSI_LOG_TIMEOUT(6, printk("sg_malloc: size=%d, ms=%d, ret=0x%x\n", - size, *mem_srcp, (int)resp)); + SCSI_LOG_TIMEOUT(6, printk("sg_malloc: size=%d, ms=%d, ret=0x%p\n", + size, *mem_srcp, resp)); return resp; } @@ -1598,8 +1591,8 @@ free_pages((unsigned long)buff, order); } else - printk("sg_low_free: bad mem_src=%d, buff=0x%x, rqSz=%df\n", - mem_src, (int)buff, size); + printk("sg_low_free: bad mem_src=%d, buff=0x%p, rqSz=%df\n", + mem_src, buff, size); } static void sg_free(Sg_request * srp, char * buff, int size, int mem_src) @@ -1607,7 +1600,7 @@ Sg_fd * sfp = srp->parentfp; SCSI_LOG_TIMEOUT(6, - printk("sg_free: buff=0x%x, size=%d\n", (int)buff, size)); + printk("sg_free: buff=0x%p, size=%d\n", buff, size)); if ((! sfp) || (! buff) || (size <= 0)) ; else if (sfp->fst_buf == buff) { @@ -1624,5 +1617,7 @@ SCpnt->sglist_len = 0; SCpnt->bufflen = 0; SCpnt->buffer = NULL; + SCpnt->underflow = 0; + SCpnt->request.rq_dev = MKDEV(0, 0); /* "sg" _disowns_ command blk */ } diff -u --recursive --new-file v2.2.7/linux/drivers/usb/hub.c linux/drivers/usb/hub.c --- v2.2.7/linux/drivers/usb/hub.c Wed Apr 28 11:37:30 1999 +++ linux/drivers/usb/hub.c Fri Apr 30 08:20:01 1999 @@ -30,6 +30,9 @@ /* List of hubs needing servicing */ static struct list_head hub_event_list; +/* PID of khubd */ +static int khubd_pid = 0; + /* * A irq handler returns non-zero to indicate to * the low-level driver that it wants to be re-activated, @@ -166,7 +169,8 @@ /* Is it a hub? */ if (interface->bInterfaceClass != 9) return -1; - if (interface->bInterfaceSubClass != 0) + if ((interface->bInterfaceSubClass != 0) && + (interface->bInterfaceSubClass != 1)) return -1; /* Multiple endpoints? What kind of mutant ninja-hub is this? */ @@ -398,8 +402,10 @@ usb_register(&hub_driver); pid = kernel_thread(usb_hub_thread, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND); - if (pid >= 0) + if (pid >= 0) { + khubd_pid = pid; return 0; + } /* Fall through if kernel_thread failed */ usb_deregister(&hub_driver); @@ -407,3 +413,10 @@ return 0; } +void hub_cleanup(void) +{ + if (khubd_pid >= 0) + kill_proc(khubd_pid, SIGINT, 1); + + usb_deregister(&hub_driver); +} diff -u --recursive --new-file v2.2.7/linux/drivers/usb/inits.h linux/drivers/usb/inits.h --- v2.2.7/linux/drivers/usb/inits.h Wed Apr 28 11:37:30 1999 +++ linux/drivers/usb/inits.h Fri Apr 30 08:20:30 1999 @@ -2,3 +2,5 @@ int usb_kbd_init(void); int usb_audio_init(void); int hub_init(void); +void hub_cleanup(void); +void usb_mouse_cleanup(void); diff -u --recursive --new-file v2.2.7/linux/drivers/usb/mouse.c linux/drivers/usb/mouse.c --- v2.2.7/linux/drivers/usb/mouse.c Wed Apr 28 11:37:30 1999 +++ linux/drivers/usb/mouse.c Fri Apr 30 08:20:49 1999 @@ -1,9 +1,12 @@ /* * USB HID boot protocol mouse support based on MS BusMouse driver, psaux - * driver, and Linus's skeleton USB mouse driver + * driver, and Linus's skeleton USB mouse driver. Fixed up a lot by Linus. * * Brad Keryan 4/3/1999 * + * version 0.20: Linus rewrote read_mouse() to do PS/2 and do it + * correctly. Events are added together, not queued, to keep the rodent sober. + * * version 0.02: Hmm, the mouse seems drunk because I'm queueing the events. * This is wrong: when an application (like X or gpm) reads the mouse device, * it wants to find out the mouse's current position, not its recent history. @@ -282,18 +285,9 @@ return 0; } -#if 0 - -int init_module(void) -{ - return usb_mouse_init(); -} - -void cleanup_module(void) +void usb_mouse_cleanup(void) { /* this, too, probably needs work */ usb_deregister(&mouse_driver); misc_deregister(&usb_mouse); } - -#endif diff -u --recursive --new-file v2.2.7/linux/drivers/usb/uhci.c linux/drivers/usb/uhci.c --- v2.2.7/linux/drivers/usb/uhci.c Wed Apr 28 11:37:30 1999 +++ linux/drivers/usb/uhci.c Fri Apr 30 08:20:53 1999 @@ -47,9 +47,6 @@ #define compile_assert(x) do { switch (0) { case 1: case !(x): } } while (0) -int usb_mouse_init(void); -int hub_init(void); - static struct wait_queue *uhci_configure = NULL; /* @@ -515,6 +512,7 @@ dev = kmalloc(sizeof(*dev), GFP_KERNEL); if (!dev) { + usb_destroy_configuration(usb_dev); kfree(usb_dev); return NULL; } @@ -573,6 +571,7 @@ } kfree(dev); + usb_destroy_configuration(usb_dev); kfree(usb_dev); return 0; @@ -995,6 +994,8 @@ kfree(uhci); } +void cleanup_drivers(void); + static int uhci_control_thread(void * __uhci) { struct uhci *uhci = (struct uhci *)__uhci; @@ -1052,6 +1053,8 @@ usb_disconnect(uhci->root_hub->usb->children + i); #endif + cleanup_drivers(); + reset_hc(uhci); release_region(uhci->io_addr, 32); @@ -1199,4 +1202,12 @@ return 0; } return retval; +} + +void cleanup_drivers(void) +{ + hub_cleanup(); +#ifdef CONFIG_USB_MOUSE + usb_mouse_cleanup(); +#endif } diff -u --recursive --new-file v2.2.7/linux/drivers/usb/usb.c linux/drivers/usb/usb.c --- v2.2.7/linux/drivers/usb/usb.c Wed Apr 28 11:37:30 1999 +++ linux/drivers/usb/usb.c Fri May 7 15:16:04 1999 @@ -213,6 +213,15 @@ return -1; } + interface->endpoint = (struct usb_endpoint_descriptor *) + kmalloc(interface->bNumEndpoints * sizeof(struct usb_endpoint_descriptor), GFP_KERNEL); + if(interface->endpoint==NULL) + { + printk(KERN_WARNING "usb: out of memory.\n"); + return -1; + } + memset(interface->endpoint, 0, interface->bNumEndpoints*sizeof(struct usb_endpoint_descriptor)); + for (i = 0; i < interface->bNumEndpoints; i++) { // if(((USB_DT_HID << 8) | 9) == *(unsigned short*)(ptr + parsed)) { // parsed += 9; /* skip over the HID descriptor for now */ @@ -242,8 +251,18 @@ { printk(KERN_WARNING "usb: too many interfaces.\n"); return -1; + } + config->interface = (struct usb_interface_descriptor *) + kmalloc(config->bNumInterfaces * sizeof(struct usb_interface_descriptor), GFP_KERNEL); + if(config->interface==NULL) + { + printk(KERN_WARNING "usb: out of memory.\n"); + return -1; + } + memset(config->interface, 0, config->bNumInterfaces*sizeof(struct usb_interface_descriptor)); + for (i = 0; i < config->bNumInterfaces; i++) { int retval = usb_parse_interface(dev, config->interface + i, ptr + parsed, len); if (retval < 0) @@ -266,6 +285,14 @@ return -1; } + dev->config = (struct usb_config_descriptor *) + kmalloc(dev->descriptor.bNumConfigurations * sizeof(struct usb_config_descriptor), GFP_KERNEL); + if(dev->config==NULL) + { + printk(KERN_WARNING "usb: out of memory.\n"); + return -1; + } + memset(dev->config, 0, dev->descriptor.bNumConfigurations*sizeof(struct usb_config_descriptor)); for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { int retval = usb_parse_config(dev, dev->config + i, ptr, bytes); if (retval < 0) @@ -276,6 +303,31 @@ return 0; } +void usb_destroy_configuration(struct usb_device *dev) +{ + int c, i; + struct usb_config_descriptor *cf; + struct usb_interface_descriptor *ifp; + + if(dev->config==NULL) + return; + for(c=0;cdescriptor.bNumConfigurations;c++) + { + cf=&dev->config[c]; + if(cf->interface==NULL) + break; + for(i=0;ibNumInterfaces;i++) + { + ifp=&cf->interface[i]; + if(ifp->endpoint==NULL) + break; + kfree(ifp->endpoint); + } + kfree(cf->interface); + } + kfree(dev->config); +} + void usb_init_root_hub(struct usb_device *dev) { dev->devnum = -1; @@ -517,24 +569,29 @@ int usb_get_configuration(struct usb_device *dev) { - unsigned int size; + unsigned int cfgno,size; unsigned char buffer[400]; - - /* Get the first 8 bytes - guaranteed */ - if (usb_get_descriptor(dev, USB_DT_CONFIG, 0, buffer, 8)) - return -1; - - /* Get the full buffer */ - size = *(unsigned short *)(buffer+2); - if (size > sizeof(buffer)) - { - printk(KERN_INFO "usb: truncated DT_CONFIG (want %d).\n", size); - size = sizeof(buffer); + unsigned char * bufptr; + + bufptr=buffer; + for (cfgno=0;cfgnodescriptor.bNumConfigurations;cfgno++) { + /* Get the first 8 bytes - guaranteed */ + if (usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, bufptr, 8)) + return -1; + + /* Get the full buffer */ + size = *(unsigned short *)(bufptr+2); + if (bufptr+size > buffer+sizeof(buffer)) + { + printk(KERN_INFO "usb: truncated DT_CONFIG (want %d).\n", size); + size = buffer+sizeof(buffer)-bufptr; + } + if (usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, bufptr, size)) + return -1; + + /* Prepare for next configuration */ + bufptr+=size; } - - if (usb_get_descriptor(dev, USB_DT_CONFIG, 0, buffer, size)) - return -1; - return usb_parse_configuration(dev, buffer, size); } diff -u --recursive --new-file v2.2.7/linux/drivers/usb/usb.h linux/drivers/usb/usb.h --- v2.2.7/linux/drivers/usb/usb.h Wed Apr 28 11:37:30 1999 +++ linux/drivers/usb/usb.h Thu Apr 29 13:21:13 1999 @@ -1,6 +1,7 @@ #ifndef __LINUX_USB_H #define __LINUX_USB_H +#include #include #include #include @@ -99,17 +100,11 @@ * * USB device information * - * Make this MUCH dynamic, right now - * it contains enough information for - * a USB floppy controller, and nothing - * else. - * - * I'm not proud. I just want this dang - * thing to start working. */ -#define USB_MAXCONFIG 2 -#define USB_MAXINTERFACES 8 -#define USB_MAXENDPOINTS 4 + +#define USB_MAXCONFIG 8 +#define USB_MAXINTERFACES 32 +#define USB_MAXENDPOINTS 32 struct usb_device_descriptor { __u8 bLength; @@ -136,6 +131,7 @@ __u8 bmAttributes; __u16 wMaxPacketSize; __u8 bInterval; + void *audio; }; /* Interface descriptor */ @@ -150,7 +146,8 @@ __u8 bInterfaceProtocol; __u8 iInterface; - struct usb_endpoint_descriptor endpoint[USB_MAXENDPOINTS]; + struct usb_endpoint_descriptor *endpoint; + void *audio; }; /* Configuration descriptor information.. */ @@ -164,7 +161,7 @@ __u8 bmAttributes; __u8 MaxPower; - struct usb_interface_descriptor interface[USB_MAXINTERFACES]; + struct usb_interface_descriptor *interface; }; /* String descriptor */ @@ -228,7 +225,7 @@ struct usb_bus *bus; /* Bus we're apart of */ struct usb_driver *driver; /* Driver */ struct usb_device_descriptor descriptor; /* Descriptor */ - struct usb_config_descriptor config[USB_MAXCONFIG]; /* All of the configs */ + struct usb_config_descriptor *config; /* All of the configs */ struct usb_device *parent; /* @@ -363,8 +360,8 @@ void usb_audio_interface(struct usb_interface_descriptor *, u8 *); void usb_audio_endpoint(struct usb_endpoint_descriptor *, u8 *); #else -extern inline void usb_audio_interface(struct usb_interface_descriptor *, u8 *) {} -extern inline void usb_audio_endpoint(struct usb_endpoint_descriptor *, u8 *) {} +extern inline void usb_audio_interface(struct usb_interface_descriptor *interface, u8 *data) {} +extern inline void usb_audio_endpoint(struct usb_endpoint_descriptor *interface, u8 *data) {} #endif #endif diff -u --recursive --new-file v2.2.7/linux/drivers/video/matroxfb.c linux/drivers/video/matroxfb.c --- v2.2.7/linux/drivers/video/matroxfb.c Wed Apr 28 11:37:30 1999 +++ linux/drivers/video/matroxfb.c Thu Apr 29 12:53:48 1999 @@ -57,6 +57,9 @@ * "H. Peter Arvin" * Ideas * + * "Cort Dougan" + * CHRP fixes and PReP cleanup + * * (following author is not in any relation with this code, but his code * is included in this driver) * @@ -187,14 +190,8 @@ #if defined(__m68k__) #define MAP_BUSTOVIRT #else -#if defined(CONFIG_PPC) && defined(CONFIG_PREP) && defined(_ISA_MEM_BASE) -/* do not tell me that PPC is not broken... if ioremap() oops with - invalid value written to msr... */ -#define MAP_ISAMEMBASE -#else #define MAP_IOREMAP #endif -#endif #ifdef DEBUG #define dprintk(X...) printk(X) @@ -354,11 +351,7 @@ #ifdef MAP_BUSTOVIRT virt->vaddr = bus_to_virt(phys); #else -#ifdef MAP_ISAMEMBASE - virt->vaddr = (void*)(phys + _ISA_MEM_BASE); -#else #error "Your architecture does not have neither ioremap nor bus_to_virt... Giving up" -#endif #endif #endif return (virt->vaddr == 0); /* 0, !0... 0, error_code in future */ diff -u --recursive --new-file v2.2.7/linux/drivers/video/offb.c linux/drivers/video/offb.c --- v2.2.7/linux/drivers/video/offb.c Tue Mar 23 14:35:48 1999 +++ linux/drivers/video/offb.c Thu Apr 29 12:53:48 1999 @@ -476,9 +476,7 @@ printk("no framebuffer address found for %s\n", dp->full_name); return; } - /* needed for the gxt on the f50 -- Cort */ - if ( dp->addrs[i].address < isa_mem_base ) - (u_long)dp->addrs[i].address += isa_mem_base; + address = (u_long)dp->addrs[i].address; /* kludge for valkyrie */ @@ -487,6 +485,7 @@ } offb_init_fb(dp->name, dp->full_name, width, height, depth, pitch, address); + } __initfunc(static void offb_init_fb(const char *name, const char *full_name, diff -u --recursive --new-file v2.2.7/linux/fs/dquot.c linux/fs/dquot.c --- v2.2.7/linux/fs/dquot.c Wed Mar 10 15:29:49 1999 +++ linux/fs/dquot.c Mon May 3 11:33:23 1999 @@ -1268,11 +1268,11 @@ int quota_on(kdev_t dev, short type, char *path) { - struct file *filp = NULL; - struct dentry *dentry; + struct file *f; struct vfsmount *vfsmnt; struct inode *inode; struct dquot *dquot; + struct quota_mount_options *mnt_dquot; char *tmp; int error; @@ -1281,69 +1281,48 @@ return -ENODEV; if (is_enabled(vfsmnt, type)) - return(-EBUSY); + return -EBUSY; + mnt_dquot = &vfsmnt->mnt_dquot; tmp = getname(path); error = PTR_ERR(tmp); if (IS_ERR(tmp)) return error; - dentry = open_namei(tmp, O_RDWR, 0600); + f = filp_open(tmp, O_RDWR, 0600); putname(tmp); + if (IS_ERR(f)) + return PTR_ERR(f); - error = PTR_ERR(dentry); - if (IS_ERR(dentry)) - return error; - inode = dentry->d_inode; - - if (!S_ISREG(inode->i_mode)) { - dput(dentry); - return -EACCES; - } - - if (inode->i_size == 0 || (inode->i_size % sizeof(struct dqblk)) != 0) { - dput(dentry); - return(-EINVAL); - } - - filp = get_empty_filp(); - if (filp != (struct file *)NULL) { - filp->f_mode = (O_RDWR + 1) & O_ACCMODE; - filp->f_flags = O_RDWR; - filp->f_dentry = dentry; - filp->f_pos = 0; - filp->f_reada = 0; - filp->f_op = inode->i_op->default_file_ops; - if (filp->f_op->read || filp->f_op->write) { - error = get_write_access(inode); - if (!error) { - if (filp->f_op && filp->f_op->open) - error = filp->f_op->open(inode, filp); - if (!error) { - set_enable_flags(vfsmnt, type); - vfsmnt->mnt_dquot.files[type] = filp; - - dquot = dqget(dev, 0, type); - vfsmnt->mnt_dquot.inode_expire[type] = (dquot) ? dquot->dq_itime : MAX_IQ_TIME; - vfsmnt->mnt_dquot.block_expire[type] = (dquot) ? dquot->dq_btime : MAX_DQ_TIME; - dqput(dquot); - - vfsmnt->mnt_sb->dq_op = &dquot_operations; - add_dquot_ref(dev, type); - - return(0); - } - put_write_access(inode); - } - } else - error = -EIO; - put_filp(filp); - } else - error = -EMFILE; - - dput(dentry); - - return(error); + /* sanity checks */ + error = -EIO; + if (!f->f_op->read && !f->f_op->write) + goto cleanup; + inode = f->f_dentry->d_inode; + error = -EACCES; + if (!S_ISREG(inode->i_mode)) + goto cleanup; + error = -EINVAL; + if (inode->i_size == 0 || (inode->i_size % sizeof(struct dqblk)) != 0) + goto cleanup; + + /* OK, there we go */ + set_enable_flags(vfsmnt, type); + mnt_dquot->files[type] = f; + + dquot = dqget(dev, 0, type); + mnt_dquot->inode_expire[type] = (dquot) ? dquot->dq_itime : MAX_IQ_TIME; + mnt_dquot->block_expire[type] = (dquot) ? dquot->dq_btime : MAX_DQ_TIME; + dqput(dquot); + + vfsmnt->mnt_sb->dq_op = &dquot_operations; + add_dquot_ref(dev, type); + + return(0); + +cleanup: + fput(f); + return error; } /* diff -u --recursive --new-file v2.2.7/linux/fs/exec.c linux/fs/exec.c --- v2.2.7/linux/fs/exec.c Tue Jan 19 11:32:52 1999 +++ linux/fs/exec.c Thu Apr 29 22:10:12 1999 @@ -29,7 +29,6 @@ #include #include #include -#include #include #include diff -u --recursive --new-file v2.2.7/linux/fs/ext2/inode.c linux/fs/ext2/inode.c --- v2.2.7/linux/fs/ext2/inode.c Tue Mar 23 14:35:48 1999 +++ linux/fs/ext2/inode.c Tue May 4 16:27:07 1999 @@ -286,7 +286,8 @@ u32 * p; struct buffer_head * result; int blocks = inode->i_sb->s_blocksize / 512; - + unsigned long limit; + if (!bh) return NULL; if (!buffer_uptodate(bh)) { @@ -309,13 +310,22 @@ brelse (result); goto repeat; } - if (!create || new_block >= - (current->rlim[RLIMIT_FSIZE].rlim_cur >> - EXT2_BLOCK_SIZE_BITS(inode->i_sb))) { + *err = -EFBIG; + if (!create) { brelse (bh); - *err = -EFBIG; return NULL; } + + limit = current->rlim[RLIMIT_FSIZE].rlim_cur; + if (limit < RLIM_INFINITY) { + limit >>= EXT2_BLOCK_SIZE_BITS(inode->i_sb); + if (new_block >= limit) { + brelse (bh); + send_sig(SIGXFSZ, current, 0); + return NULL; + } + } + if (inode->u.ext2_i.i_next_alloc_block == new_block) goal = inode->u.ext2_i.i_next_alloc_goal; if (!goal) { diff -u --recursive --new-file v2.2.7/linux/fs/inode.c linux/fs/inode.c --- v2.2.7/linux/fs/inode.c Wed Apr 28 11:37:31 1999 +++ linux/fs/inode.c Tue May 4 10:57:12 1999 @@ -522,6 +522,7 @@ inode->i_nlink = 1; inode->i_writecount = 0; inode->i_size = 0; + inode->i_generation = 0; memset(&inode->i_dquot, 0, sizeof(inode->i_dquot)); sema_init(&inode->i_sem, 1); } diff -u --recursive --new-file v2.2.7/linux/fs/nfs/dir.c linux/fs/nfs/dir.c --- v2.2.7/linux/fs/nfs/dir.c Wed Apr 28 11:37:31 1999 +++ linux/fs/nfs/dir.c Fri May 7 14:38:54 1999 @@ -72,7 +72,7 @@ NULL, /* select - default */ NULL, /* ioctl - default */ NULL, /* mmap */ - NULL, /* no special open is needed */ + nfs_open, /* open - revalidate the inode */ NULL, /* flush */ NULL, /* no special release code */ NULL /* fsync */ @@ -389,8 +389,11 @@ * If we don't have an inode, let's just assume * a 5-second "live" time for negative dentries. */ - if (!inode) - goto do_lookup; + if (!inode) { + if (time_after(jiffies, dentry->d_time + NFS_REVALIDATE_INTERVAL)) + goto out_bad; + goto out_valid; + } if (is_bad_inode(inode)) { dfprintk(VFS, "nfs_lookup_validate: %s/%s has dud inode\n", @@ -398,27 +401,17 @@ goto out_bad; } - if (_nfs_revalidate_inode(NFS_DSERVER(dentry), dentry)) - goto out_bad; - if (time_before(jiffies,dentry->d_time+NFS_ATTRTIMEO(inode))) goto out_valid; if (IS_ROOT(dentry)) goto out_valid; -do_lookup: /* * Do a new lookup and check the dentry attributes. */ error = nfs_proc_lookup(NFS_DSERVER(parent), NFS_FH(parent), dentry->d_name.name, &fhandle, &fattr); - if (dentry->d_inode == NULL) { - if (error == -ENOENT && - time_before(jiffies,dentry->d_time+NFS_REVALIDATE_INTERVAL)) - goto out_valid; - goto out_bad; - } if (error) goto out_bad; diff -u --recursive --new-file v2.2.7/linux/fs/nfs/file.c linux/fs/nfs/file.c --- v2.2.7/linux/fs/nfs/file.c Tue Mar 23 14:35:48 1999 +++ linux/fs/nfs/file.c Fri May 7 11:07:22 1999 @@ -46,7 +46,7 @@ NULL, /* select - default */ NULL, /* ioctl - default */ nfs_file_mmap, /* mmap */ - NULL, /* no special open is needed */ + nfs_open, /* open - revalidate the inode */ nfs_file_flush, /* flush */ NULL, /* release */ nfs_fsync, /* fsync */ diff -u --recursive --new-file v2.2.7/linux/fs/nfs/inode.c linux/fs/nfs/inode.c --- v2.2.7/linux/fs/nfs/inode.c Wed Apr 28 11:37:31 1999 +++ linux/fs/nfs/inode.c Fri May 7 15:07:37 1999 @@ -696,6 +696,28 @@ } /* + * Revalidate the file on open (this + * is separate from the path-revalidation + * that we do on any lookup). + * + * When we actually open a file, we want + * fairly strict consistency: make sure that + * we've updated the attributes within the + * last second or so.. + */ +int nfs_open(struct inode *inode, struct file *filp) +{ + int retval = 0; + + if (time_after(jiffies, NFS_READTIME(inode) + HZ/2)) { + struct dentry *dentry = filp->f_dentry; + struct nfs_server *server = NFS_DSERVER(dentry); + retval = _nfs_revalidate_inode(server, dentry); + } + return retval; +} + +/* * This function is called whenever some part of NFS notices that * the cached attributes have to be refreshed. */ diff -u --recursive --new-file v2.2.7/linux/fs/super.c linux/fs/super.c --- v2.2.7/linux/fs/super.c Fri Apr 16 14:47:31 1999 +++ linux/fs/super.c Thu Apr 29 11:53:41 1999 @@ -1156,12 +1156,22 @@ #ifdef CONFIG_BLK_DEV_FD if (MAJOR(ROOT_DEV) == FLOPPY_MAJOR) { +#ifdef CONFIG_BLK_DEV_RAM + extern int rd_doload; +#endif floppy_eject(); #ifndef CONFIG_BLK_DEV_RAM printk(KERN_NOTICE "(Warning, this kernel has no ramdisk support)\n"); +#else + /* rd_doload is 2 for a dual initrd/ramload setup */ + if(rd_doload==2) + rd_load_secondary(); + else #endif - printk(KERN_NOTICE "VFS: Insert root floppy and press ENTER\n"); - wait_for_keypress(); + { + printk(KERN_NOTICE "VFS: Insert root floppy and press ENTER\n"); + wait_for_keypress(); + } } #endif diff -u --recursive --new-file v2.2.7/linux/include/asm-alpha/semaphore.h linux/include/asm-alpha/semaphore.h --- v2.2.7/linux/include/asm-alpha/semaphore.h Wed Apr 28 11:37:31 1999 +++ linux/include/asm-alpha/semaphore.h Fri May 7 10:55:26 1999 @@ -190,7 +190,7 @@ " stl_c $28,%1\n" " beq $28,2f\n" " mb\n" - " ble $27,3f\n" + " ble $24,3f\n" "4:\n" ".section .text2,\"ax\"\n" "2: br 1b\n" diff -u --recursive --new-file v2.2.7/linux/include/asm-i386/bugs.h linux/include/asm-i386/bugs.h --- v2.2.7/linux/include/asm-i386/bugs.h Fri Jan 1 12:58:21 1999 +++ linux/include/asm-i386/bugs.h Fri May 7 15:17:59 1999 @@ -19,6 +19,7 @@ #include #include +#include #define CONFIG_BUGi386 @@ -27,6 +28,11 @@ boot_cpu_data.hlt_works_ok = 0; } +__initfunc(static void mca_pentium(char *s, int *ints)) +{ + mca_pentium_flag = 1; +} + __initfunc(static void no_387(char *s, int *ints)) { boot_cpu_data.hard_math = 0; @@ -61,6 +67,31 @@ #endif return; } + if (mca_pentium_flag) { + /* The IBM Model 95 machines with pentiums lock up on + * fpu test, so we avoid it. All pentiums have inbuilt + * FPU and thus should use exception 16. We still do + * the FDIV test, although I doubt there where ever any + * MCA boxes built with non-FDIV-bug cpus. + */ + __asm__("fninit\n\t" + "fldl %1\n\t" + "fdivl %2\n\t" + "fmull %2\n\t" + "fldl %1\n\t" + "fsubp %%st,%%st(1)\n\t" + "fistpl %0\n\t" + "fwait\n\t" + "fninit" + : "=m" (*&boot_cpu_data.fdiv_bug) + : "m" (*&x), "m" (*&y)); + printk("mca-pentium specified, avoiding FPU coupling test... "); + if (!boot_cpu_data.fdiv_bug) + printk("??? No FDIV bug? Lucky you...\n"); + else + printk("detected FDIV bug though.\n"); + return; + } /* * check if exception 16 works correctly.. This is truly evil * code: it disables the high 8 interrupts to make sure that @@ -173,10 +204,10 @@ n = K6_BUG_LOOP; f_vide = vide; - __asm__ ("rdtsc" : "=a" (d)); + rdtscl(d); while (n--) f_vide(); - __asm__ ("rdtsc" : "=a" (d2)); + rdtscl(d2); d = d2-d; /* Knock these two lines out if it debugs out ok */ diff -u --recursive --new-file v2.2.7/linux/include/asm-i386/irq.h linux/include/asm-i386/irq.h --- v2.2.7/linux/include/asm-i386/irq.h Tue Feb 23 15:21:34 1999 +++ linux/include/asm-i386/irq.h Thu May 6 14:02:34 1999 @@ -29,6 +29,7 @@ } extern void disable_irq(unsigned int); +extern void disable_irq_nosync(unsigned int); extern void enable_irq(unsigned int); #endif /* _ASM_IRQ_H */ diff -u --recursive --new-file v2.2.7/linux/include/asm-i386/msr.h linux/include/asm-i386/msr.h --- v2.2.7/linux/include/asm-i386/msr.h Wed Dec 31 16:00:00 1969 +++ linux/include/asm-i386/msr.h Thu Apr 29 11:53:41 1999 @@ -0,0 +1,30 @@ +/* + * Access to machine-specific registers (available on 586 and better only) + * Note: the rd* operations modify the parameters directly (without using + * pointer indirection), this allows gcc to optimize better + */ + +#define rdmsr(msr,val1,val2) \ + __asm__ __volatile__("rdmsr" \ + : "=a" (val1), "=d" (val2) \ + : "c" (msr)) + +#define wrmsr(msr,val1,val2) \ + __asm__ __volatile__("wrmsr" \ + : /* no outputs */ \ + : "c" (msr), "a" (val1), "d" (val2)) + +#define rdtsc(low,high) \ + __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high)) + +#define rdtscl(low) \ + __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") + +#define rdtscll(val) \ + __asm__ __volatile__ ("rdtsc" : "=A" (val)) + +#define rdpmc(counter,low,high) \ + __asm__ __volatile__("rdpmc" \ + : "=a" (low), "=d" (high) \ + : "c" (counter)) + diff -u --recursive --new-file v2.2.7/linux/include/asm-i386/processor.h linux/include/asm-i386/processor.h --- v2.2.7/linux/include/asm-i386/processor.h Tue Jan 19 11:32:53 1999 +++ linux/include/asm-i386/processor.h Fri May 7 15:08:57 1999 @@ -148,6 +148,7 @@ extern unsigned int machine_id; extern unsigned int machine_submodel_id; extern unsigned int BIOS_revision; +extern unsigned int mca_pentium_flag; /* * User space process size: 3GB (default). diff -u --recursive --new-file v2.2.7/linux/include/asm-i386/system.h linux/include/asm-i386/system.h --- v2.2.7/linux/include/asm-i386/system.h Mon Dec 28 15:00:53 1998 +++ linux/include/asm-i386/system.h Fri May 7 15:08:56 1999 @@ -9,30 +9,24 @@ struct task_struct; /* one of the stranger aspects of C forward declarations.. */ extern void FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next)); -/* - * We do most of the task switching in C, but we need - * to do the EIP/ESP switch in assembly.. - */ -#define switch_to(prev,next) do { \ - unsigned long eax, edx, ecx; \ - asm volatile("pushl %%ebx\n\t" \ - "pushl %%esi\n\t" \ +#define switch_to(prev,next,last) do { \ + asm volatile("pushl %%esi\n\t" \ "pushl %%edi\n\t" \ "pushl %%ebp\n\t" \ "movl %%esp,%0\n\t" /* save ESP */ \ - "movl %5,%%esp\n\t" /* restore ESP */ \ + "movl %3,%%esp\n\t" /* restore ESP */ \ "movl $1f,%1\n\t" /* save EIP */ \ - "pushl %6\n\t" /* restore EIP */ \ + "pushl %4\n\t" /* restore EIP */ \ "jmp __switch_to\n" \ "1:\t" \ "popl %%ebp\n\t" \ "popl %%edi\n\t" \ "popl %%esi\n\t" \ - "popl %%ebx" \ :"=m" (prev->tss.esp),"=m" (prev->tss.eip), \ - "=a" (eax), "=d" (edx), "=c" (ecx) \ + "=b" (last) \ :"m" (next->tss.esp),"m" (next->tss.eip), \ - "a" (prev), "d" (next)); \ + "a" (prev), "d" (next), \ + "b" (prev)); \ } while (0) #define _set_base(addr,base) do { unsigned long __pr; \ diff -u --recursive --new-file v2.2.7/linux/include/asm-i386/timex.h linux/include/asm-i386/timex.h --- v2.2.7/linux/include/asm-i386/timex.h Mon Mar 29 11:09:12 1999 +++ linux/include/asm-i386/timex.h Fri May 7 15:08:57 1999 @@ -7,6 +7,7 @@ #define _ASMi386_TIMEX_H #include +#include #define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ #define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */ @@ -39,7 +40,7 @@ #else unsigned long eax, edx; - __asm__ __volatile__("rdtsc":"=a" (eax), "=d" (edx)); + rdtsc(eax,edx); return eax; #endif } diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/adb.h linux/include/asm-ppc/adb.h --- v2.2.7/linux/include/asm-ppc/adb.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/adb.h Thu Apr 29 12:39:01 1999 @@ -21,6 +21,16 @@ #define ADB_RET_OK 0 #define ADB_RET_TIMEOUT 3 +/* The kind of ADB request. The controller may emulate some + of all of those CUDA/PMU packet kinds */ +#define ADB_PACKET 0 +#define CUDA_PACKET 1 +#define ERROR_PACKET 2 +#define TIMER_PACKET 3 +#define POWER_PACKET 4 +#define MACIIC_PACKET 5 +#define PMU_PACKET 6 + #ifdef __KERNEL__ struct adb_request { @@ -41,19 +51,37 @@ unsigned char id[16]; }; -extern enum adb_hw { - ADB_NONE, ADB_VIACUDA, ADB_VIAPMU, ADB_MACIO -} adb_hardware; - -extern int (*adb_send_request)(struct adb_request *req, int sync); -extern int (*adb_autopoll)(int devs); -extern int (*adb_reset_bus)(void); +/* Messages sent thru the client_list notifier. You should NOT stop + the operation, at least not with this version */ +enum adb_message { + ADB_MSG_POWERDOWN, /* Currently called before sleep only */ + ADB_MSG_PRE_RESET, /* Called before resetting the bus */ + ADB_MSG_POST_RESET /* Called after resetting the bus (re-do init & register) */ +}; +extern struct notifier_block *adb_client_list; + +/* Kind of ADB controller */ +enum adb_hw { + ADB_NONE, ADB_VIACUDA, ADB_VIAPMU, ADB_MACIO, ADB_UNKNOWN +}; + +/* Definition of a controller */ +extern struct adb_controller { + enum adb_hw kind; + + int (*send_request)(struct adb_request *req, int sync); + int (*autopoll)(int devs); + int (*reset_bus)(void); + void (*poll)(void); +} *adb_controller; +extern enum adb_hw adb_hardware; /* Values for adb_request flags */ #define ADBREQ_REPLY 1 /* expect reply */ #define ADBREQ_SYNC 2 /* poll until done */ void adb_init(void); + int adb_request(struct adb_request *req, void (*done)(struct adb_request *), int flags, int nbytes, ...); int adb_register(int default_id,int handler_id,struct adb_ids *ids, @@ -62,6 +90,10 @@ int adb_try_handler_change(int address, int new_id); int adb_get_infos(int address, int *original_address, int *handler_id); + +int adb_reset_bus(void); + +void adb_poll(void); #endif /* __KERNEL__ */ diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/cuda.h linux/include/asm-ppc/cuda.h --- v2.2.7/linux/include/asm-ppc/cuda.h Fri May 8 23:14:56 1998 +++ linux/include/asm-ppc/cuda.h Thu Apr 29 12:39:01 1999 @@ -5,15 +5,6 @@ * Copyright (C) 1996 Paul Mackerras. */ -/* First byte sent to or received from CUDA */ -#define ADB_PACKET 0 -#define CUDA_PACKET 1 -#define ERROR_PACKET 2 -#define TIMER_PACKET 3 -#define POWER_PACKET 4 -#define MACIIC_PACKET 5 -#define PMU_PACKET 6 - /* CUDA commands (2nd byte) */ #define CUDA_WARM_START 0 #define CUDA_AUTOPOLL 1 @@ -41,7 +32,7 @@ void via_cuda_init(void); int cuda_request(struct adb_request *req, void (*done)(struct adb_request *), int nbytes, ...); -int cuda_send_request(struct adb_request *req); void cuda_poll(void); +int cuda_present(void); #endif /* __KERNEL */ diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/dma.h linux/include/asm-ppc/dma.h --- v2.2.7/linux/include/asm-ppc/dma.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/dma.h Thu Apr 29 12:39:01 1999 @@ -35,36 +35,9 @@ /* Doesn't really apply... */ #define MAX_DMA_ADDRESS 0xFFFFFFFF -#if defined(CONFIG_MACH_SPECIFIC) - -#if defined(CONFIG_PREP) -#define DMA_MODE_READ 0x44 -#define DMA_MODE_WRITE 0x48 -#define ISA_DMA_THRESHOLD 0x00ffffff -#endif /* CONFIG_PREP */ - -#if defined(CONFIG_CHRP) -#define DMA_MODE_READ 0x44 -#define DMA_MODE_WRITE 0x48 -#define ISA_DMA_THRESHOLD ~0L -#endif /* CONFIG_CHRP */ - -#ifdef CONFIG_PMAC -#define DMA_MODE_READ 1 -#define DMA_MODE_WRITE 2 -#define ISA_DMA_THRESHOLD ~0L -#endif /* CONFIG_PMAC */ - -#ifdef CONFIG_APUS -/* This is bogus and should go away. */ -#define ISA_DMA_THRESHOLD (0x00ffffff) -#endif - -#else /* in arch/ppc/kernel/setup.c -- Cort */ extern unsigned long DMA_MODE_WRITE, DMA_MODE_READ; extern unsigned long ISA_DMA_THRESHOLD; -#endif #ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER @@ -204,7 +177,7 @@ #define DMA2_EXT_REG 0x4D6 #define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */ -#define DMA_AUTOINIT 0x10 +#define DMA_AUTOINIT 0x10 extern spinlock_t dma_spin_lock; @@ -427,9 +400,8 @@ extern void free_dma(unsigned int dmanr); /* release it again */ #ifdef CONFIG_PCI_QUIRKS -extern int isa_dma_bridge_buggy; -#else -#define isa_dma_bridge_buggy (0) +extern int isa_dma_bridge_buggy; +#else +#define isa_dma_bridge_buggy (0) #endif - #endif /* _ASM_DMA_H */ diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/hardirq.h linux/include/asm-ppc/hardirq.h --- v2.2.7/linux/include/asm-ppc/hardirq.h Mon Oct 5 13:13:43 1998 +++ linux/include/asm-ppc/hardirq.h Thu Apr 29 12:39:01 1999 @@ -1,22 +1,22 @@ #ifndef __ASM_HARDIRQ_H #define __ASM_HARDIRQ_H -extern unsigned int local_irq_count[NR_CPUS]; +extern unsigned int ppc_local_irq_count[NR_CPUS]; /* * Are we in an interrupt context? Either doing bottom half * or hardware interrupt processing? */ #define in_interrupt() ({ int __cpu = smp_processor_id(); \ - (local_irq_count[__cpu] + local_bh_count[__cpu] != 0); }) + (ppc_local_irq_count[__cpu] + ppc_local_bh_count[__cpu] != 0); }) #ifndef __SMP__ -#define hardirq_trylock(cpu) (local_irq_count[cpu] == 0) +#define hardirq_trylock(cpu) (ppc_local_irq_count[cpu] == 0) #define hardirq_endlock(cpu) do { } while (0) -#define hardirq_enter(cpu) (local_irq_count[cpu]++) -#define hardirq_exit(cpu) (local_irq_count[cpu]--) +#define hardirq_enter(cpu) (ppc_local_irq_count[cpu]++) +#define hardirq_exit(cpu) (ppc_local_irq_count[cpu]--) #define synchronize_irq() do { } while (0) @@ -39,14 +39,14 @@ static inline void hardirq_enter(int cpu) { - ++local_irq_count[cpu]; + ++ppc_local_irq_count[cpu]; atomic_inc(&global_irq_count); } static inline void hardirq_exit(int cpu) { atomic_dec(&global_irq_count); - --local_irq_count[cpu]; + --ppc_local_irq_count[cpu]; } static inline int hardirq_trylock(int cpu) diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/ide.h linux/include/asm-ppc/ide.h --- v2.2.7/linux/include/asm-ppc/ide.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/ide.h Thu May 6 23:14:37 1999 @@ -11,17 +11,8 @@ #ifndef __ASMPPC_IDE_H #define __ASMPPC_IDE_H -#include -/* - * On APUS, nearly everything comes from the m68k file - * -- Cort - */ -#ifdef CONFIG_APUS -#include -#define ide_init_hwif_ports m68k_ide_init_hwif_ports -#include -#undef ide_init_hwif_ports -#endif /* CONFIG_APUS */ +#include +#include #ifndef MAX_HWIFS #define MAX_HWIFS 4 @@ -29,6 +20,12 @@ typedef unsigned int ide_ioreg_t; +#ifdef __KERNEL__ + +#include +#include +#include + extern int pmac_ide_ports_known; extern ide_ioreg_t pmac_ide_regbase[MAX_HWIFS]; extern int pmac_ide_irq[MAX_HWIFS]; @@ -40,43 +37,42 @@ extern unsigned int chrp_ide_irq; extern void chrp_ide_probe(void); +struct ide_machdep_calls { + void (*insw)(ide_ioreg_t port, void *buf, int ns); + void (*outsw)(ide_ioreg_t port, void *buf, int ns); + int (*default_irq)(ide_ioreg_t base); + ide_ioreg_t (*default_io_base)(int index); + int (*check_region)(ide_ioreg_t from, unsigned int extent); + void (*request_region)(ide_ioreg_t from, + unsigned int extent, + const char *name); + void (*release_region)(ide_ioreg_t from, + unsigned int extent); + void (*fix_driveid)(struct hd_driveid *id); + void (*ide_init_hwif)(ide_ioreg_t *p, + ide_ioreg_t base, + int *irq); + + int io_base; +}; + +extern struct ide_machdep_calls ppc_ide_md; + void ide_init_hwif_ports(ide_ioreg_t *p, ide_ioreg_t base, int *irq); -void prep_ide_init_hwif_ports(ide_ioreg_t *p, ide_ioreg_t base, int *irq); -void mbx_ide_init_hwif_ports(ide_ioreg_t *p, ide_ioreg_t base, int *irq); -void pmac_ide_init_hwif_ports(ide_ioreg_t *p, ide_ioreg_t base, int *irq); -void chrp_ide_init_hwif_ports(ide_ioreg_t *p, ide_ioreg_t base, int *irq); void ide_insw(ide_ioreg_t port, void *buf, int ns); void ide_outsw(ide_ioreg_t port, void *buf, int ns); +void ppc_generic_ide_fix_driveid(struct hd_driveid *id); #undef insw #define insw(port, buf, ns) do { \ - if ( _machine & (_MACH_chrp|_MACH_mbx) ) \ - ide_insw((port)+_IO_BASE, (buf), (ns)); \ - else if ( _machine & (_MACH_Pmac|_MACH_apus) ) \ - ide_insw((port), (buf), (ns)); \ - else \ - /* this must be the same as insw in io.h!! */ \ - _insw((unsigned short *)((port)+_IO_BASE), (buf), (ns)); \ + ppc_ide_md.insw((port), (buf), (ns)); \ } while (0) #undef outsw #define outsw(port, buf, ns) do { \ - if ( _machine & (_MACH_chrp|_MACH_mbx) ) \ - ide_outsw((port)+_IO_BASE, (buf), (ns)); \ - else if ( _machine & (_MACH_Pmac|_MACH_apus) ) \ - ide_outsw((port), (buf), (ns)); \ - else \ - /* this must be the same as outsw in io.h!! */ \ - _outsw((unsigned short *)((port)+_IO_BASE), (buf), (ns)); \ + ppc_ide_md.outsw((port), (buf), (ns)); \ } while (0) -#ifndef CONFIG_APUS -#ifdef __KERNEL__ - -#include -#include -#include - #undef SUPPORT_SLOW_DATA_PORTS #define SUPPORT_SLOW_DATA_PORTS 0 #undef SUPPORT_VLB_SYNC @@ -86,192 +82,41 @@ static __inline__ int ide_default_irq(ide_ioreg_t base) { - if ( _machine == _MACH_Pmac ) - return 0; - else if ( _machine == _MACH_mbx ) - /* IRQ 14 when in legacy mode on MBX */ - return 14; - else if ( _machine == _MACH_chrp) { - if (chrp_ide_ports_known == 0) - chrp_ide_probe(); - return chrp_ide_irq; - } - switch (base) { - case 0x1f0: return 13; - case 0x170: return 13; - case 0x1e8: return 11; - case 0x168: return 10; - default: - return 0; - } + return ppc_ide_md.default_irq(base); } static __inline__ ide_ioreg_t ide_default_io_base(int index) { -#if defined(CONFIG_BLK_DEV_IDE_PMAC) - if (_machine == _MACH_Pmac) { - return pmac_ide_regbase[index]; - } -#endif - if (_machine == _MACH_mbx) return index; - if ( _machine == _MACH_chrp ) { - if (chrp_ide_ports_known == 0) - chrp_ide_probe(); - return chrp_ide_regbase[index]; - } - switch (index) { - case 0: return 0x1f0; - case 1: return 0x170; - case 2: return 0x1e8; - case 3: return 0x168; - default: - return 0; - } + return ppc_ide_md.default_io_base(index); } static __inline__ int ide_check_region (ide_ioreg_t from, unsigned int extent) { - if ( (_machine == _MACH_Pmac) || (_machine == _MACH_mbx)) - return 0; - return check_region(from, extent); + return ppc_ide_md.check_region(from, extent); } static __inline__ void ide_request_region (ide_ioreg_t from, unsigned int extent, const char *name) { - if ( (_machine == _MACH_Pmac) || (_machine == _MACH_mbx) ) - return; - request_region(from, extent, name); + ppc_ide_md.request_region(from, extent, name); } static __inline__ void ide_release_region (ide_ioreg_t from, unsigned int extent) { - if ( (_machine == _MACH_Pmac) || (_machine == _MACH_mbx) ) - return; - release_region(from, extent); + ppc_ide_md.release_region(from, extent); } -/* Convert the shorts/longs in hd_driveid from little to big endian; - chars are endian independent, of course, but strings need to be flipped. - (Despite what it says in drivers/block/ide.h, they come up as little endian...) - Changes to linux/hdreg.h may require changes here. */ static __inline__ void ide_fix_driveid (struct hd_driveid *id) { - if ( _machine & (_MACH_chrp|_MACH_mbx|_MACH_Pmac) ) { \ - int i; - unsigned short *stringcast; - id->config = __le16_to_cpu(id->config); - id->cyls = __le16_to_cpu(id->cyls); - id->reserved2 = __le16_to_cpu(id->reserved2); - id->heads = __le16_to_cpu(id->heads); - id->track_bytes = __le16_to_cpu(id->track_bytes); - id->sector_bytes = __le16_to_cpu(id->sector_bytes); - id->sectors = __le16_to_cpu(id->sectors); - id->vendor0 = __le16_to_cpu(id->vendor0); - id->vendor1 = __le16_to_cpu(id->vendor1); - id->vendor2 = __le16_to_cpu(id->vendor2); - stringcast = (unsigned short *)&id->serial_no[0]; - for (i=0; i<(20/2); i++) - stringcast[i] = __le16_to_cpu(stringcast[i]); - id->buf_type = __le16_to_cpu(id->buf_type); - id->buf_size = __le16_to_cpu(id->buf_size); - id->ecc_bytes = __le16_to_cpu(id->ecc_bytes); - stringcast = (unsigned short *)&id->fw_rev[0]; - for (i=0; i<(8/2); i++) - stringcast[i] = __le16_to_cpu(stringcast[i]); - stringcast = (unsigned short *)&id->model[0]; - for (i=0; i<(40/2); i++) - stringcast[i] = __le16_to_cpu(stringcast[i]); - id->dword_io = __le16_to_cpu(id->dword_io); - id->reserved50 = __le16_to_cpu(id->reserved50); - id->field_valid = __le16_to_cpu(id->field_valid); - id->cur_cyls = __le16_to_cpu(id->cur_cyls); - id->cur_heads = __le16_to_cpu(id->cur_heads); - id->cur_sectors = __le16_to_cpu(id->cur_sectors); - id->cur_capacity0 = __le16_to_cpu(id->cur_capacity0); - id->cur_capacity1 = __le16_to_cpu(id->cur_capacity1); - id->lba_capacity = __le32_to_cpu(id->lba_capacity); - id->dma_1word = __le16_to_cpu(id->dma_1word); - id->dma_mword = __le16_to_cpu(id->dma_mword); - id->eide_pio_modes = __le16_to_cpu(id->eide_pio_modes); - id->eide_dma_min = __le16_to_cpu(id->eide_dma_min); - id->eide_dma_time = __le16_to_cpu(id->eide_dma_time); - id->eide_pio = __le16_to_cpu(id->eide_pio); - id->eide_pio_iordy = __le16_to_cpu(id->eide_pio_iordy); - id->word69 = __le16_to_cpu(id->word69); - id->word70 = __le16_to_cpu(id->word70); - id->word71 = __le16_to_cpu(id->word71); - id->word72 = __le16_to_cpu(id->word72); - id->word73 = __le16_to_cpu(id->word73); - id->word74 = __le16_to_cpu(id->word74); - id->word75 = __le16_to_cpu(id->word75); - id->word76 = __le16_to_cpu(id->word76); - id->word77 = __le16_to_cpu(id->word77); - id->word78 = __le16_to_cpu(id->word78); - id->word79 = __le16_to_cpu(id->word79); - id->word80 = __le16_to_cpu(id->word80); - id->word81 = __le16_to_cpu(id->word81); - id->command_sets = __le16_to_cpu(id->command_sets); - id->word83 = __le16_to_cpu(id->word83); - id->word84 = __le16_to_cpu(id->word84); - id->word85 = __le16_to_cpu(id->word85); - id->word86 = __le16_to_cpu(id->word86); - id->word87 = __le16_to_cpu(id->word87); - id->dma_ultra = __le16_to_cpu(id->dma_ultra); - id->word89 = __le16_to_cpu(id->word89); - id->word90 = __le16_to_cpu(id->word90); - id->word91 = __le16_to_cpu(id->word91); - id->word92 = __le16_to_cpu(id->word92); - id->word93 = __le16_to_cpu(id->word93); - id->word94 = __le16_to_cpu(id->word94); - id->word95 = __le16_to_cpu(id->word95); - id->word96 = __le16_to_cpu(id->word96); - id->word97 = __le16_to_cpu(id->word97); - id->word98 = __le16_to_cpu(id->word98); - id->word99 = __le16_to_cpu(id->word99); - id->word100 = __le16_to_cpu(id->word100); - id->word101 = __le16_to_cpu(id->word101); - id->word102 = __le16_to_cpu(id->word102); - id->word103 = __le16_to_cpu(id->word103); - id->word104 = __le16_to_cpu(id->word104); - id->word105 = __le16_to_cpu(id->word105); - id->word106 = __le16_to_cpu(id->word106); - id->word107 = __le16_to_cpu(id->word107); - id->word108 = __le16_to_cpu(id->word108); - id->word109 = __le16_to_cpu(id->word109); - id->word110 = __le16_to_cpu(id->word110); - id->word111 = __le16_to_cpu(id->word111); - id->word112 = __le16_to_cpu(id->word112); - id->word113 = __le16_to_cpu(id->word113); - id->word114 = __le16_to_cpu(id->word114); - id->word115 = __le16_to_cpu(id->word115); - id->word116 = __le16_to_cpu(id->word116); - id->word117 = __le16_to_cpu(id->word117); - id->word118 = __le16_to_cpu(id->word118); - id->word119 = __le16_to_cpu(id->word119); - id->word120 = __le16_to_cpu(id->word120); - id->word121 = __le16_to_cpu(id->word121); - id->word122 = __le16_to_cpu(id->word122); - id->word123 = __le16_to_cpu(id->word123); - id->word124 = __le16_to_cpu(id->word124); - id->word125 = __le16_to_cpu(id->word125); - id->word126 = __le16_to_cpu(id->word126); - id->word127 = __le16_to_cpu(id->word127); - id->security = __le16_to_cpu(id->security); - for (i=0; i<127; i++) - id->reserved[i] = __le16_to_cpu(id->reserved[i]); - } + ppc_ide_md.fix_driveid(id); } #undef inb -#define inb(port) \ - in_8((unsigned char *)((port) + \ - ((_machine==_MACH_Pmac)? 0: _IO_BASE) ) ) +#define inb(port) in_8((unsigned char *)((port) + ppc_ide_md.io_base)) #undef inb_p #define inb_p(port) inb(port) #undef outb #define outb(val, port) \ - out_8((unsigned char *)((port) + \ - ((_machine==_MACH_Pmac)? 0: _IO_BASE) ), (val) ) + out_8((unsigned char *)((port) + ppc_ide_md.io_base), (val) ) #undef outb_p #define outb_p(val, port) outb(val, port) @@ -305,6 +150,5 @@ #define ide_get_lock(lock, hdlr, data) do {} while (0) #endif /* __KERNEL__ */ -#endif /* CONFIG_APUS */ #endif /* __ASMPPC_IDE_H */ diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/io.h linux/include/asm-ppc/io.h --- v2.2.7/linux/include/asm-ppc/io.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/io.h Thu Apr 29 12:39:01 1999 @@ -5,8 +5,6 @@ #include #include -#define KERNELBASE 0xc0000000 - #define SIO_CONFIG_RA 0x398 #define SIO_CONFIG_RD 0x399 @@ -18,7 +16,7 @@ #define CHRP_ISA_MEM_BASE 0xf7000000 #define CHRP_PCI_DRAM_OFFSET 0 #define PREP_ISA_IO_BASE 0x80000000 -#define PREP_ISA_MEM_BASE 0xd0000000 +#define PREP_ISA_MEM_BASE 0xc0000000 #define PREP_PCI_DRAM_OFFSET 0x80000000 #ifdef CONFIG_MBX @@ -49,7 +47,7 @@ #define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b)) #else #define readw(addr) in_le16((volatile unsigned short *)(addr)) -#define readl(addr) in_le32((volatile unsigned *)addr) +#define readl(addr) in_le32((volatile unsigned *)(addr)) #define writew(b,addr) out_le16((volatile unsigned short *)(addr),(b)) #define writel(b,addr) out_le32((volatile unsigned *)(addr),(b)) #endif diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/irq.h linux/include/asm-ppc/irq.h --- v2.2.7/linux/include/asm-ppc/irq.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/irq.h Thu Apr 29 12:39:01 1999 @@ -3,7 +3,7 @@ #ifndef _ASM_IRQ_H #define _ASM_IRQ_H -#include /* for is_prep() */ +#include /* ppc_md */ extern void disable_irq(unsigned int); extern void enable_irq(unsigned int); @@ -42,7 +42,14 @@ */ static __inline__ int irq_cannonicalize(int irq) { - return (((is_prep || is_chrp) && irq == 2) ? 9 : irq); + if (ppc_md.irq_cannonicalize) + { + return ppc_md.irq_cannonicalize(irq); + } + else + { + return irq; + } } #endif diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/keyboard.h linux/include/asm-ppc/keyboard.h --- v2.2.7/linux/include/asm-ppc/keyboard.h Wed Apr 28 11:37:31 1999 +++ linux/include/asm-ppc/keyboard.h Thu Apr 29 12:39:01 1999 @@ -17,7 +17,7 @@ #include #include - +#include #ifdef CONFIG_APUS #include #else @@ -26,132 +26,44 @@ #define DISABLE_KBD_DURING_INTERRUPTS 0 #define INIT_KBD -extern int mackbd_setkeycode(unsigned int scancode, unsigned int keycode); -extern int mackbd_getkeycode(unsigned int scancode); -extern int mackbd_translate(unsigned char scancode, unsigned char *keycode, - char raw_mode); -extern int mackbd_unexpected_up(unsigned char keycode); -extern void mackbd_leds(unsigned char leds); -extern void mackbd_init_hw(void); - -extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode); -extern int pckbd_getkeycode(unsigned int scancode); -extern int pckbd_translate(unsigned char scancode, unsigned char *keycode, - char raw_mode); -extern char pckbd_unexpected_up(unsigned char keycode); -extern void pckbd_leds(unsigned char leds); -extern void pckbd_init_hw(void); - static inline int kbd_setkeycode(unsigned int scancode, unsigned int keycode) { - if ( is_prep || (_machine == _MACH_mbx) ) - return pckbd_setkeycode(scancode,keycode); - else if ( is_chrp ) -#ifndef CONFIG_MAC_KEYBOARD - return pckbd_setkeycode(scancode,keycode); -#else - /* I'm not actually sure if it's legal to have a CHRP machine - * without an ADB controller. In any case, this should really - * be changed to be a test to see if an ADB _keyboard_ exists - * (not just a controller), but that's another story for - * another night. - */ - if ( adb_hardware == ADB_NONE ) - return pckbd_setkeycode(scancode,keycode); - else - return mackbd_setkeycode(scancode,keycode); -#endif - else - return mackbd_setkeycode(scancode,keycode); + return ppc_md.kbd_setkeycode(scancode, keycode); } - -static inline int kbd_getkeycode(unsigned int x) + +static inline int kbd_getkeycode(unsigned int scancode) { - if ( is_prep || (_machine == _MACH_mbx) ) - return pckbd_getkeycode(x); - else if ( is_chrp ) -#ifndef CONFIG_MAC_KEYBOARD - return pckbd_getkeycode(x); -#else - if ( adb_hardware == ADB_NONE ) - return pckbd_getkeycode(x); - else - return mackbd_getkeycode(x); -#endif - else - return mackbd_getkeycode(x); + return ppc_md.kbd_getkeycode(scancode); } - + static inline int kbd_translate(unsigned char keycode, unsigned char *keycodep, - char raw_mode) + char raw_mode) { - if ( is_prep || (_machine == _MACH_mbx) ) - return pckbd_translate(keycode,keycodep,raw_mode); - else if ( is_chrp ) -#ifndef CONFIG_MAC_KEYBOARD - return pckbd_translate(keycode,keycodep,raw_mode); -#else - if ( adb_hardware == ADB_NONE ) - return pckbd_translate(keycode,keycodep,raw_mode); - else - return mackbd_translate(keycode,keycodep,raw_mode); -#endif - else - return mackbd_translate(keycode,keycodep,raw_mode); - + return ppc_md.kbd_translate(keycode, keycodep, raw_mode); } - + static inline int kbd_unexpected_up(unsigned char keycode) { - if ( is_prep || (_machine == _MACH_mbx) ) - return pckbd_unexpected_up(keycode); - else if ( is_chrp ) -#ifndef CONFIG_MAC_KEYBOARD - return pckbd_unexpected_up(keycode); -#else - if ( adb_hardware == ADB_NONE ) - return pckbd_unexpected_up(keycode); - else - return mackbd_unexpected_up(keycode); -#endif - else - return mackbd_unexpected_up(keycode); - + return ppc_md.kbd_unexpected_up(keycode); } - + static inline void kbd_leds(unsigned char leds) { - if ( is_prep || (_machine == _MACH_mbx) ) - pckbd_leds(leds); - else if ( is_chrp ) -#ifndef CONFIG_MAC_KEYBOARD - pckbd_leds(leds); -#else - if ( adb_hardware == ADB_NONE ) - pckbd_leds(leds); - else - mackbd_leds(leds); -#endif - else - mackbd_leds(leds); + ppc_md.kbd_leds(leds); } - + static inline void kbd_init_hw(void) { - if ( is_prep || (_machine == _MACH_mbx) ) - pckbd_init_hw(); - else if ( is_chrp ) -#ifndef CONFIG_MAC_KEYBOARD - pckbd_init_hw(); + ppc_md.kbd_init_hw(); +} + +#define kbd_sysrq_xlate (ppc_md.kbd_sysrq_xlate) + +#ifdef CONFIG_MAC_KEYBOARD +# define SYSRQ_KEY 0x69 #else - if ( adb_hardware == ADB_NONE ) - pckbd_init_hw(); - else - mackbd_init_hw(); +# define SYSRQ_KEY 0x54 #endif - else - mackbd_init_hw(); -} #endif /* CONFIG_APUS */ diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/machdep.h linux/include/asm-ppc/machdep.h --- v2.2.7/linux/include/asm-ppc/machdep.h Thu Aug 6 14:06:33 1998 +++ linux/include/asm-ppc/machdep.h Thu Apr 29 12:39:01 1999 @@ -1,3 +1,4 @@ + #ifndef _PPC_MACHDEP_H #define _PPC_MACHDEP_H @@ -7,6 +8,69 @@ #include #endif -#endif /* _PPC_MACHDEP_H */ +struct pt_regs; + +struct machdep_calls { + void (*setup_arch)(unsigned long * memory_start_p, + unsigned long * memory_end_p); + /* Optional, may be NULL. */ + int (*setup_residual)(char *buffer); + /* Optional, may be NULL. */ + int (*get_cpuinfo)(char *buffer); + /* Optional, may be NULL. */ + unsigned int (*irq_cannonicalize)(unsigned int irq); + void (*init_IRQ)(void); + void (*do_IRQ)(struct pt_regs *regs, int cpu, int isfake); + + /* A general init function, called by ppc_init in init/main.c. + May be NULL. */ + void (*init)(void); + + void (*restart)(char *cmd); + void (*power_off)(void); + void (*halt)(void); + + void (*time_init)(void); /* Optional, may be NULL */ + int (*set_rtc_time)(unsigned long nowtime); + unsigned long (*get_rtc_time)(void); + void (*calibrate_decr)(void); + unsigned char (*nvram_read_val)(int addr); + void (*nvram_write_val)(int addr, unsigned char val); +/* Tons of keyboard stuff. */ + int (*kbd_setkeycode)(unsigned int scancode, + unsigned int keycode); + int (*kbd_getkeycode)(unsigned int scancode); + int (*kbd_translate)(unsigned char scancode, + unsigned char *keycode, + char raw_mode); + char (*kbd_unexpected_up)(unsigned char keycode); + void (*kbd_leds)(unsigned char leds); + void (*kbd_init_hw)(void); +#ifdef CONFIG_MAGIC_SYSRQ + unsigned char *kbd_sysrq_xlate; +#endif + + /* PCI interfaces */ + int (*pcibios_read_config_byte)(unsigned char bus, + unsigned char dev_fn, unsigned char offset, unsigned char *val); + int (*pcibios_read_config_word)(unsigned char bus, + unsigned char dev_fn, unsigned char offset, unsigned short *val); + int (*pcibios_read_config_dword)(unsigned char bus, + unsigned char dev_fn, unsigned char offset, unsigned int *val); + int (*pcibios_write_config_byte)(unsigned char bus, + unsigned char dev_fn, unsigned char offset, unsigned char val); + int (*pcibios_write_config_word)(unsigned char bus, + unsigned char dev_fn, unsigned char offset, unsigned short val); + int (*pcibios_write_config_dword)(unsigned char bus, + unsigned char dev_fn, unsigned char offset, unsigned int val); + void (*pcibios_fixup)(void); +}; + +extern struct machdep_calls ppc_md; +extern char cmd_line[512]; + +extern void setup_pci_ptrs(void); + +#endif /* _PPC_MACHDEP_H */ diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/mk48t59.h linux/include/asm-ppc/mk48t59.h --- v2.2.7/linux/include/asm-ppc/mk48t59.h Wed Dec 31 16:00:00 1969 +++ linux/include/asm-ppc/mk48t59.h Thu Apr 29 12:39:01 1999 @@ -0,0 +1,35 @@ +/* + * Registers for the mk48t59 real-time-clock + */ + +#ifndef _PPC_MK48T59_H +#define _PPC_MK48T59_H + +/* RTC Offsets */ + +#define MK48T59_RTC_SECONDS 0x1FF9 +#define MK48T59_RTC_MINUTES 0x1FFA +#define MK48T59_RTC_HOURS 0x1FFB +#define MK48T59_RTC_DAY_OF_WEEK 0x1FFC +#define MK48T59_RTC_DAY_OF_MONTH 0x1FFD +#define MK48T59_RTC_MONTH 0x1FFE +#define MK48T59_RTC_YEAR 0x1FFF + +#define MK48T59_RTC_CONTROLA 0x1FF8 +#define MK48T59_RTC_CA_WRITE 0x80 +#define MK48T59_RTC_CA_READ 0x40 +#define MK48T59_RTC_CA_CALIB_SIGN 0x20 +#define MK48T59_RTC_CA_CALIB_MASK 0x1f + +#define MK48T59_RTC_CONTROLB 0x1FF9 +#define MK48T59_RTC_CB_STOP 0x80 + +#ifndef BCD_TO_BIN +#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) +#endif + +#ifndef BIN_TO_BCD +#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) +#endif + +#endif /* _PPC_MK48T59_H */ diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/page.h linux/include/asm-ppc/page.h --- v2.2.7/linux/include/asm-ppc/page.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/page.h Thu Apr 29 12:39:01 1999 @@ -9,7 +9,7 @@ #define PAGE_MASK (~(PAGE_SIZE-1)) #define PAGE_OFFSET 0xc0000000 - +#define KERNELBASE PAGE_OFFSET #ifndef __ASSEMBLY__ #ifdef __KERNEL__ diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/pgtable.h linux/include/asm-ppc/pgtable.h --- v2.2.7/linux/include/asm-ppc/pgtable.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/pgtable.h Thu Apr 29 12:39:01 1999 @@ -37,6 +37,7 @@ extern unsigned long va_to_phys(unsigned long address); extern pte_t *va_to_pte(struct task_struct *tsk, unsigned long address); +extern unsigned long ioremap_bot, ioremap_base; #endif /* __ASSEMBLY__ */ /* * The PowerPC MMU uses a hash table containing PTEs, together with @@ -95,16 +96,19 @@ * The vmalloc() routines leaves a hole of 4kB between each vmalloced * area for the same reason. ;) * - * The vmalloc_offset MUST be larger than the gap between the bat2 mapping - * and the size of physical ram. Since the bat2 mapping can be larger than - * the amount of ram we have vmalloc_offset must ensure that we don't try - * to allocate areas that don't exist! This value of 64M will only cause - * problems when we have >128M -- Cort + * We no longer map larger than phys RAM with the BATs so we don't have + * to worry about the VMALLOC_OFFSET causing problems. We do have to worry + * about clashes between our early calls to ioremap() that start growing down + * from ioremap_base being run into the VM area allocations (growing upwards + * from VMALLOC_START). For this reason we have ioremap_bot to check when + * we actually run into our mappings setup in the early boot with the VM + * system. This really does become a problem for machines with good amounts + * of RAM. -- Cort */ -#define VMALLOC_OFFSET (0x4000000) /* 64M */ +#define VMALLOC_OFFSET (0x4000000) /* 64M */ #define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))) #define VMALLOC_VMADDR(x) ((unsigned long)(x)) -#define VMALLOC_END 0xf0000000 +#define VMALLOC_END ioremap_bot /* * Bits in a linux-style PTE. These match the bits in the diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/pmu.h linux/include/asm-ppc/pmu.h --- v2.2.7/linux/include/asm-ppc/pmu.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/pmu.h Thu Apr 29 12:39:01 1999 @@ -64,11 +64,12 @@ #define PMU_IOC_GET_MODEL _IOR('B', 3, sizeof(__u32*)) #ifdef __KERNEL__ + void find_via_pmu(void); void via_pmu_init(void); + int pmu_request(struct adb_request *req, void (*done)(struct adb_request *), int nbytes, ...); -int pmu_send_request(struct adb_request *req); void pmu_poll(void); void pmu_enable_backlight(int on); @@ -79,6 +80,7 @@ void pmu_restart(void); void pmu_shutdown(void); +int pmu_present(void); int pmu_get_model(void); /* diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/posix_types.h linux/include/asm-ppc/posix_types.h --- v2.2.7/linux/include/asm-ppc/posix_types.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/posix_types.h Thu Apr 29 12:39:01 1999 @@ -43,7 +43,8 @@ #else /* __GNUC__ */ -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ <= 2) +#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) \ + || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0) /* With GNU C, use inline functions instead so args are evaluated only once: */ #undef __FD_SET diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/prep_nvram.h linux/include/asm-ppc/prep_nvram.h --- v2.2.7/linux/include/asm-ppc/prep_nvram.h Wed Dec 31 16:00:00 1969 +++ linux/include/asm-ppc/prep_nvram.h Thu Apr 29 12:39:01 1999 @@ -0,0 +1,146 @@ +/* + * PreP compliant NVRAM access + */ + +/* Corey Minyard (minyard@acm.org) - Stolen from PReP book. Per the + license I must say: + (C) Copyright (Corey Minyard), (1998). All rights reserved + */ + +/* Structure map for NVRAM on PowerPC Reference Platform */ +/* All fields are either character/byte strings which are valid either + endian or they are big-endian numbers. + + There are a number of Date and Time fields which are in RTC format, + big-endian. These are stored in UT (GMT). + + For enum's: if given in hex then they are bit significant, i.e. only + one bit is on for each enum. +*/ +#ifndef _PPC_PREP_NVRAM_H +#define _PPC_PREP_NVRAM_H + +#define NVSIZE 4096 /* size of NVRAM */ +#define OSAREASIZE 512 /* size of OSArea space */ +#define CONFSIZE 1024 /* guess at size of Configuration space */ + +typedef struct _SECURITY { + unsigned long BootErrCnt; /* Count of boot password errors */ + unsigned long ConfigErrCnt; /* Count of config password errors */ + unsigned long BootErrorDT[2]; /* Date&Time from RTC of last error in pw */ + unsigned long ConfigErrorDT[2]; /* Date&Time from RTC of last error in pw */ + unsigned long BootCorrectDT[2]; /* Date&Time from RTC of last correct pw */ + unsigned long ConfigCorrectDT[2]; /* Date&Time from RTC of last correct pw */ + unsigned long BootSetDT[2]; /* Date&Time from RTC of last set of pw */ + unsigned long ConfigSetDT[2]; /* Date&Time from RTC of last set of pw */ + unsigned char Serial[16]; /* Box serial number */ +} SECURITY; + +typedef enum _OS_ID { + Unknown = 0, + Firmware = 1, + AIX = 2, + NT = 3, + MKOS2 = 4, + MKAIX = 5, + Taligent = 6, + Solaris = 7, + MK = 12 +} OS_ID; + +typedef struct _ERROR_LOG { + unsigned char ErrorLogEntry[40]; /* To be architected */ +} ERROR_LOG; + +typedef enum _BOOT_STATUS { + BootStarted = 0x01, + BootFinished = 0x02, + RestartStarted = 0x04, + RestartFinished = 0x08, + PowerFailStarted = 0x10, + PowerFailFinished = 0x20, + ProcessorReady = 0x40, + ProcessorRunning = 0x80, + ProcessorStart = 0x0100 +} BOOT_STATUS; + +typedef struct _RESTART_BLOCK { + unsigned short Version; + unsigned short Revision; + unsigned long ResumeReserve1[2]; + volatile unsigned long BootStatus; + unsigned long CheckSum; /* Checksum of RESTART_BLOCK */ + void * RestartAddress; + void * SaveAreaAddr; + unsigned long SaveAreaLength; +} RESTART_BLOCK; + +typedef enum _OSAREA_USAGE { + Empty = 0, + Used = 1 +} OSAREA_USAGE; + +typedef enum _PM_MODE { + Suspend = 0x80, /* Part of state is in memory */ + Normal = 0x00 /* No power management in effect */ +} PMMode; + +typedef struct _HEADER { + unsigned short Size; /* NVRAM size in K(1024) */ + unsigned char Version; /* Structure map different */ + unsigned char Revision; /* Structure map the same -may + be new values in old fields + in other words old code still works */ + unsigned short Crc1; /* check sum from beginning of nvram to OSArea */ + unsigned short Crc2; /* check sum of config */ + unsigned char LastOS; /* OS_ID */ + unsigned char Endian; /* B if big endian, L if little endian */ + unsigned char OSAreaUsage; /* OSAREA_USAGE */ + unsigned char PMMode; /* Shutdown mode */ + RESTART_BLOCK RestartBlock; + SECURITY Security; + ERROR_LOG ErrorLog[2]; + + /* Global Environment information */ + void * GEAddress; + unsigned long GELength; + + /* Date&Time from RTC of last change to Global Environment */ + unsigned long GELastWriteDT[2]; + + /* Configuration information */ + void * ConfigAddress; + unsigned long ConfigLength; + + /* Date&Time from RTC of last change to Configuration */ + unsigned long ConfigLastWriteDT[2]; + unsigned long ConfigCount; /* Count of entries in Configuration */ + + /* OS dependent temp area */ + void * OSAreaAddress; + unsigned long OSAreaLength; + + /* Date&Time from RTC of last change to OSAreaArea */ + unsigned long OSAreaLastWriteDT[2]; +} HEADER; + +/* Here is the whole map of the NVRAM */ +typedef struct _NVRAM_MAP { + HEADER Header; + unsigned char GEArea[NVSIZE-CONFSIZE-OSAREASIZE-sizeof(HEADER)]; + unsigned char OSArea[OSAREASIZE]; + unsigned char ConfigArea[CONFSIZE]; +} NVRAM_MAP; + +/* Routines to manipulate the NVRAM */ +void init_prep_nvram(void); +char *prep_nvram_get_var(const char *name); +char *prep_nvram_first_var(void); +char *prep_nvram_next_var(char *name); + +/* Routines to read and write directly to the NVRAM */ +unsigned char prep_nvram_read_val(int addr); +void prep_nvram_write_val(int addr, + unsigned char val); + +#endif /* _PPC_PREP_NVRAM_H */ diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/processor.h linux/include/asm-ppc/processor.h --- v2.2.7/linux/include/asm-ppc/processor.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/processor.h Thu Apr 29 12:39:01 1999 @@ -175,67 +175,13 @@ #define SR15 15 #ifndef __ASSEMBLY__ -/* - * If we've configured for a specific machine set things - * up so the compiler can optimize away the other parts. - * -- Cort - */ -#ifdef CONFIG_MACH_SPECIFIC -#ifdef CONFIG_PREP -#define _machine (_MACH_prep) -#define is_prep (1) -#define is_chrp (0) -#define have_of (0) -#endif /* CONFIG_PREP */ - -#ifdef CONFIG_CHRP -#define _machine (_MACH_chrp) -#define is_prep (0) -#define is_chrp (1) -#define have_of (1) -#endif /* CONFIG_CHRP */ - -#ifdef CONFIG_PMAC -#define _machine (_MACH_Pmac) -#define is_prep (0) -#define is_chrp (0) -#define have_of (1) -#endif /* CONFIG_PMAC */ - -#ifdef CONFIG_MBX -#define _machine (_MACH_mbx) -#define is_prep (0) -#define is_chrp (0) -#define have_of (0) -#endif /* CONFIG_MBX */ - -#ifdef CONFIG_FADS -#define _machine (_MACH_fads) -#define is_prep (0) -#define is_chrp (0) -#define have_of (0) -#endif /* CONFIG_FADS */ - -#ifdef CONFIG_APUS -#define _machine (_MACH_apus) -#define is_prep (0) -#define is_chrp (0) -#define have_of (0) -#endif /* CONFIG_APUS */ - -#else /* CONFIG_MACH_SPECIFIC */ - extern int _machine; -/* if we're a prep machine */ -#define is_prep (_machine == _MACH_prep) - -/* if we're a chrp machine */ -#define is_chrp (_machine == _MACH_chrp) - -/* if we have openfirmware */ -extern unsigned long have_of; -#endif /* CONFIG_MACH_SPECIFIC */ +/* Temporary hacks until we can clean things up better - Corey */ +extern int have_of; +extern int is_prep; +extern int is_chrp; +extern int is_powerplus; /* what kind of prep workstation we are */ extern int _prep_type; @@ -338,14 +284,10 @@ #define init_task (init_task_union.task) #define init_stack (init_task_union.stack) +/* In misc.c */ +void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val); + #endif /* ndef ASSEMBLY*/ #endif /* __ASM_PPC_PROCESSOR_H */ - - - - - - - diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/smp.h linux/include/asm-ppc/smp.h --- v2.2.7/linux/include/asm-ppc/smp.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/smp.h Thu Apr 29 12:39:07 1999 @@ -27,6 +27,7 @@ extern void smp_message_pass(int target, int msg, unsigned long data, int wait); extern void smp_store_cpu_info(int id); +extern void smp_message_recv(void); #define NO_PROC_ID 0xFF /* No processor magic marker */ #define PROC_CHANGE_PENALTY 20 diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/softirq.h linux/include/asm-ppc/softirq.h --- v2.2.7/linux/include/asm-ppc/softirq.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/softirq.h Thu Apr 29 12:39:07 1999 @@ -4,7 +4,7 @@ #include #include -extern unsigned int local_bh_count[NR_CPUS]; +extern unsigned int ppc_local_bh_count[NR_CPUS]; #define get_active_bhs() (bh_mask & bh_active) #define clear_active_bhs(x) atomic_clear_mask((x),&bh_active) @@ -29,6 +29,7 @@ } #ifdef __SMP__ + /* * The locking mechanism for base handlers, to prevent re-entrancy, * is entirely private to an implementation, it should not be @@ -55,7 +56,7 @@ { if (!test_and_set_bit(0,&global_bh_count)) { if (atomic_read(&global_bh_lock) == 0) { - ++local_bh_count[cpu]; + ++ppc_local_bh_count[cpu]; return 1; } clear_bit(0,&global_bh_count); @@ -65,30 +66,30 @@ static inline void softirq_endlock(int cpu) { - local_bh_count[cpu]--; + ppc_local_bh_count[cpu]--; clear_bit(0,&global_bh_count); } -#else /* __SMP__ */ +#else extern inline void start_bh_atomic(void) { - local_bh_count[smp_processor_id()]++; + ppc_local_bh_count[smp_processor_id()]++; barrier(); } extern inline void end_bh_atomic(void) { barrier(); - local_bh_count[smp_processor_id()]--; + ppc_local_bh_count[smp_processor_id()]--; } /* These are for the irq's testing the lock */ -#define softirq_trylock(cpu) (local_bh_count[cpu] ? 0 : (local_bh_count[cpu]=1)) -#define softirq_endlock(cpu) (local_bh_count[cpu] = 0) -#define synchronize_bh() do { } while (0) +#define softirq_trylock(cpu) (ppc_local_bh_count[cpu] ? 0 : (ppc_local_bh_count[cpu]=1)) +#define softirq_endlock(cpu) (ppc_local_bh_count[cpu] = 0) +#define synchronize_bh() barrier() -#endif /* __SMP__ */ +#endif /* SMP */ /* * These use a mask count to correctly handle @@ -107,4 +108,4 @@ bh_mask |= 1 << nr; } -#endif +#endif /* __ASM_SOFTIRQ_H */ diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/string.h linux/include/asm-ppc/string.h --- v2.2.7/linux/include/asm-ppc/string.h Sat Aug 16 09:51:09 1997 +++ linux/include/asm-ppc/string.h Thu Apr 29 12:39:07 1999 @@ -14,5 +14,6 @@ #define __HAVE_ARCH_MEMCHR extern int strcasecmp(const char *, const char *); +extern int strncasecmp(const char *, const char *, int); #endif diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/system.h linux/include/asm-ppc/system.h --- v2.2.7/linux/include/asm-ppc/system.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/system.h Thu Apr 29 12:39:07 1999 @@ -25,6 +25,9 @@ #define rmb() __asm__ __volatile__ ("sync" : : : "memory") #define wmb() __asm__ __volatile__ ("eieio" : : : "memory") +extern void xmon_irq(int, void *, struct pt_regs *); +extern void xmon(struct pt_regs *excp); + #define __save_flags(flags) ({\ __asm__ __volatile__ ("mfmsr %0" : "=r" ((flags)) : : "memory"); }) #define __save_and_cli(flags) ({__save_flags(flags);__cli();}) @@ -38,10 +41,10 @@ extern __inline__ void __restore_flags(unsigned long flags) { - extern atomic_t n_lost_interrupts; + extern atomic_t ppc_n_lost_interrupts; extern void do_lost_interrupts(unsigned long); - if ((flags & MSR_EE) && atomic_read(&n_lost_interrupts) != 0) { + if ((flags & MSR_EE) && atomic_read(&ppc_n_lost_interrupts) != 0) { do_lost_interrupts(flags); } else { __asm__ __volatile__ ("sync; mtmsr %0; isync" @@ -68,8 +71,8 @@ extern void pmac_nvram_init(void); extern void read_rtc_time(void); extern void pmac_find_display(void); -extern void giveup_fpu(void); -extern void smp_giveup_fpu(struct task_struct *); +extern void giveup_fpu(struct task_struct *); +extern void enable_kernel_fp(void); extern void cvt_fd(float *from, double *to, unsigned long *fpscr); extern void cvt_df(double *from, float *to, unsigned long *fpscr); diff -u --recursive --new-file v2.2.7/linux/include/asm-ppc/vga.h linux/include/asm-ppc/vga.h --- v2.2.7/linux/include/asm-ppc/vga.h Tue Mar 23 14:35:48 1999 +++ linux/include/asm-ppc/vga.h Thu Apr 29 12:39:07 1999 @@ -46,7 +46,8 @@ #define scr_memcpyw_from memcpy #define scr_memcpyw_to memcpy -#define VGA_MAP_MEM(x) (x + _ISA_MEM_BASE) +extern unsigned long vgacon_remap_base; +#define VGA_MAP_MEM(x) (x + vgacon_remap_base) #define vga_readb(x) (*(x)) #define vga_writeb(x,y) (*(y) = (x)) diff -u --recursive --new-file v2.2.7/linux/include/asm-sparc/siginfo.h linux/include/asm-sparc/siginfo.h --- v2.2.7/linux/include/asm-sparc/siginfo.h Wed Apr 28 11:37:31 1999 +++ linux/include/asm-sparc/siginfo.h Wed Apr 28 14:40:07 1999 @@ -1,4 +1,4 @@ -/* $Id: siginfo.h,v 1.3 1998/08/26 10:33:29 davem Exp $ +/* $Id: siginfo.h,v 1.4 1999/04/28 19:45:20 davem Exp $ * siginfo.c: */ diff -u --recursive --new-file v2.2.7/linux/include/linux/capability.h linux/include/linux/capability.h --- v2.2.7/linux/include/linux/capability.h Fri Oct 23 22:01:26 1998 +++ linux/include/linux/capability.h Fri May 7 15:08:59 1999 @@ -193,7 +193,6 @@ /* Allow device administration (mknod)*/ /* Allow examination and configuration of disk quotas */ /* Allow configuring the kernel's syslog (printk behaviour) */ -/* Allow sending a signal to any process */ /* Allow setting the domainname */ /* Allow setting the hostname */ /* Allow calling bdflush() */ diff -u --recursive --new-file v2.2.7/linux/include/linux/nfs_fs.h linux/include/linux/nfs_fs.h --- v2.2.7/linux/include/linux/nfs_fs.h Wed Mar 10 15:29:50 1999 +++ linux/include/linux/nfs_fs.h Fri May 7 15:09:26 1999 @@ -181,6 +181,7 @@ struct nfs_fattr *); extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *); extern int nfs_revalidate(struct dentry *); +extern int nfs_open(struct inode *, struct file *); extern int _nfs_revalidate_inode(struct nfs_server *, struct dentry *); /* diff -u --recursive --new-file v2.2.7/linux/include/linux/pagemap.h linux/include/linux/pagemap.h --- v2.2.7/linux/include/linux/pagemap.h Wed Apr 28 11:37:31 1999 +++ linux/include/linux/pagemap.h Fri May 7 15:09:32 1999 @@ -17,6 +17,27 @@ return PAGE_OFFSET + PAGE_SIZE * (page - mem_map); } +/* + * The page cache can done in larger chunks than + * one page, because it allows for more efficient + * throughput (it can then be mapped into user + * space in smaller chunks for same flexibility). + * + * Or rather, it _will_ be done in larger chunks. + */ +#define PAGE_CACHE_SHIFT PAGE_SHIFT +#define PAGE_CACHE_SIZE PAGE_SIZE +#define PAGE_CACHE_MASK PAGE_MASK + +#define page_cache_alloc() __get_free_page(GFP_USER) +#define page_cache_free(x) free_page(x) +#define page_cache_release(x) __free_page(x) + +/* + * From a kernel address, get the "struct page *" + */ +#define page_cache_entry(x) (mem_map + MAP_NR(x)) + #define PAGE_HASH_BITS 12 #define PAGE_HASH_SIZE (1 << PAGE_HASH_BITS) diff -u --recursive --new-file v2.2.7/linux/include/linux/sched.h linux/include/linux/sched.h --- v2.2.7/linux/include/linux/sched.h Mon Mar 29 11:09:12 1999 +++ linux/include/linux/sched.h Fri May 7 15:09:03 1999 @@ -112,10 +112,10 @@ * a separate lock). */ extern rwlock_t tasklist_lock; -extern spinlock_t scheduler_lock; extern spinlock_t runqueue_lock; extern void sched_init(void); +extern void init_idle(void); extern void show_state(void); extern void trap_init(void); diff -u --recursive --new-file v2.2.7/linux/include/linux/videodev.h linux/include/linux/videodev.h --- v2.2.7/linux/include/linux/videodev.h Tue Feb 23 15:21:35 1999 +++ linux/include/linux/videodev.h Fri May 7 11:05:30 1999 @@ -95,6 +95,8 @@ #define VIDEO_TUNER_LOW 8 /* Uses KHz not MHz */ #define VIDEO_TUNER_NORM 16 /* Tuner can set norm */ #define VIDEO_TUNER_STEREO_ON 128 /* Tuner is seeing stereo */ +#define VIDEO_TUNER_RDS_ON 256 /* Tuner is seeing an RDS datastream */ +#define VIDEO_TUNER_MBS_ON 512 /* Tuner is seeing an MBS datastream */ __u16 mode; /* PAL/NTSC/SECAM/OTHER */ #define VIDEO_MODE_PAL 0 #define VIDEO_MODE_NTSC 1 @@ -275,6 +277,7 @@ #define VID_HARDWARE_GEMTEK 18 #define VID_HARDWARE_TYPHOON 19 #define VID_HARDWARE_VINO 20 /* Reserved for SGI Indy Vino */ +#define VID_HARDWARE_CADET 21 /* Cadet radio */ /* * Initialiser list diff -u --recursive --new-file v2.2.7/linux/include/scsi/sg.h linux/include/scsi/sg.h --- v2.2.7/linux/include/scsi/sg.h Fri Apr 16 14:47:31 1999 +++ linux/include/scsi/sg.h Fri May 7 11:05:30 1999 @@ -12,10 +12,16 @@ * Copyright (C) 1998, 1999 Douglas Gilbert - Version: 2.1.31 (990327) + Version: 2.1.32 (990501) This version for later 2.1.x series and 2.2.x kernels D. P. Gilbert (dgilbert@interlog.com, dougg@triode.net.au) + Changes since 2.1.31 (990327) + - add ioctls SG_GET_UNDERRUN_FLAG and _SET_. Change the default + to _not_ flag underruns (affects aic7xxx driver) + - clean up logging of pointers to use %p (for 64 bit architectures) + - rework usage of get_user/copy_to_user family of kernel calls + - "disown" scsi_command blocks before releasing them Changes since 2.1.30 (990320) - memory tweaks: change flags on kmalloc (GFP_KERNEL to GFP_ATOMIC) - increase max allowable mid-level pool usage @@ -113,7 +119,7 @@ requesting 512KB) and scale them back in the face of ENOMEM errors. N.B. Queuing up commands also ties up kernel memory. - More documentation can be found at www.netwinder.org/~dougg + More documentation can be found at www.torque.net/sg */ #define SG_MAX_SENSE 16 /* too little, unlikely to change in 2.2.x */ @@ -197,6 +203,11 @@ #define SG_GET_COMMAND_Q 0x2270 /* Yields 0 (queuing off) or 1 (on) */ #define SG_SET_COMMAND_Q 0x2271 /* Change queuing state with 0 or 1 */ +/* Get/set whether DMA underrun will cause an error (DID_ERROR) [this only + currently applies to the [much-used] aic7xxx driver) */ +#define SG_GET_UNDERRUN_FLAG 0x2280 /* Yields 0 (don't flag) or 1 (flag) */ +#define SG_SET_UNDERRUN_FLAG 0x2281 /* Change flag underrun state */ + #define SG_DEFAULT_TIMEOUT (60*HZ) /* HZ == 'jiffies in 1 second' */ #define SG_DEFAULT_RETRIES 1 @@ -206,6 +217,7 @@ #define SG_DEF_MERGE_FD 0 /* was 1 -> per device sequencing */ #define SG_DEF_FORCE_LOW_DMA 0 /* was 1 -> memory below 16MB on i386 */ #define SG_DEF_FORCE_PACK_ID 0 +#define SG_DEF_UNDERRUN_FLAG 0 /* maximum outstanding requests, write() yields EDOM if exceeded */ #define SG_MAX_QUEUE 16 diff -u --recursive --new-file v2.2.7/linux/init/main.c linux/init/main.c --- v2.2.7/linux/init/main.c Wed Apr 28 11:37:32 1999 +++ linux/init/main.c Fri May 7 11:05:30 1999 @@ -74,7 +74,7 @@ extern void uidcache_init(void); extern void mca_init(void); extern void sbus_init(void); -extern void powermac_init(void); +extern void ppc_init(void); extern void sysctl_init(void); extern void filescache_init(void); extern void signals_init(void); @@ -354,7 +354,7 @@ int rows, cols; #ifdef CONFIG_BLK_DEV_RAM -extern int rd_doload; /* 1 = load ramdisk, 0 = don't load */ +extern int rd_doload; /* 1 = load ramdisk, 0 = don't load 2 = dual disk */ extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */ extern int rd_size; /* Size of the ramdisk(s) */ extern int rd_image_start; /* starting block # of image */ @@ -578,6 +578,7 @@ { "no-hlt", no_halt }, { "no387", no_387 }, { "reboot=", reboot_setup }, + { "mca-pentium", mca_pentium }, #endif #ifdef CONFIG_INET { "ether=", eth_setup }, @@ -901,7 +902,7 @@ static void __init load_ramdisk(char *str, int *ints) { if (ints[0] > 0 && ints[1] >= 0) - rd_doload = ints[1] & 1; + rd_doload = ints[1] & 3; } static void __init prompt_ramdisk(char *str, int *ints) @@ -1262,7 +1263,7 @@ sbus_init(); #endif #if defined(CONFIG_PPC) - powermac_init(); + ppc_init(); #endif #ifdef CONFIG_MCA mca_init(); diff -u --recursive --new-file v2.2.7/linux/ipc/shm.c linux/ipc/shm.c --- v2.2.7/linux/ipc/shm.c Wed Apr 28 11:37:32 1999 +++ linux/ipc/shm.c Tue May 4 16:58:15 1999 @@ -634,7 +634,7 @@ pte = __pte(shp->shm_pages[idx]); if (!pte_present(pte)) { - unsigned long page = get_free_page(GFP_KERNEL); + unsigned long page = get_free_page(GFP_USER); if (!page) { oom(current); return 0; diff -u --recursive --new-file v2.2.7/linux/kernel/exit.c linux/kernel/exit.c --- v2.2.7/linux/kernel/exit.c Tue Mar 23 14:35:48 1999 +++ linux/kernel/exit.c Fri Apr 30 08:13:37 1999 @@ -32,9 +32,9 @@ */ for (;;) { int has_cpu; - spin_lock(&scheduler_lock); + spin_lock_irq(&runqueue_lock); has_cpu = p->has_cpu; - spin_unlock(&scheduler_lock); + spin_unlock_irq(&runqueue_lock); if (!has_cpu) break; do { diff -u --recursive --new-file v2.2.7/linux/kernel/sched.c linux/kernel/sched.c --- v2.2.7/linux/kernel/sched.c Tue Mar 23 14:35:48 1999 +++ linux/kernel/sched.c Fri Apr 30 08:13:37 1999 @@ -96,13 +96,156 @@ struct task_struct * task[NR_TASKS] = {&init_task, }; +/* + * We align per-CPU scheduling data on cacheline boundaries, + * to prevent cacheline ping-pong. + */ +static union { + struct schedule_data { + struct task_struct * curr; + cycles_t last_schedule; + } schedule_data; + char __pad [SMP_CACHE_BYTES]; +} aligned_data [NR_CPUS] __cacheline_aligned = { {{&init_task,0}}}; + +#define cpu_curr(cpu) aligned_data[(cpu)].schedule_data.curr + struct kernel_stat kstat = { 0 }; +#ifdef __SMP__ + +#define idle_task(cpu) (task[cpu_number_map[(cpu)]]) +#define can_schedule(p) (!(p)->has_cpu) + +#else + +#define idle_task(cpu) (&init_task) +#define can_schedule(p) (1) + +#endif + void scheduling_functions_start_here(void) { } +/* + * This is the function that decides how desirable a process is.. + * You can weigh different processes against each other depending + * on what CPU they've run on lately etc to try to handle cache + * and TLB miss penalties. + * + * Return values: + * -1000: never select this + * 0: out of time, recalculate counters (but it might still be + * selected) + * +ve: "goodness" value (the larger, the better) + * +1000: realtime process, select this. + */ + +static inline int goodness (struct task_struct * prev, + struct task_struct * p, int this_cpu) +{ + int weight; + + /* + * Realtime process, select the first one on the + * runqueue (taking priorities within processes + * into account). + */ + if (p->policy != SCHED_OTHER) { + weight = 1000 + p->rt_priority; + goto out; + } + + /* + * Give the process a first-approximation goodness value + * according to the number of clock-ticks it has left. + * + * Don't do any other calculations if the time slice is + * over.. + */ + weight = p->counter; + if (!weight) + goto out; + #ifdef __SMP__ -static void reschedule_idle_slow(struct task_struct * p) + /* Give a largish advantage to the same processor... */ + /* (this is equivalent to penalizing other processors) */ + if (p->processor == this_cpu) + weight += PROC_CHANGE_PENALTY; +#endif + + /* .. and a slight advantage to the current MM */ + if (p->mm == prev->mm) + weight += 1; + weight += p->priority; + +out: + return weight; +} + +/* + * subtle. We want to discard a yielded process only if it's being + * considered for a reschedule. Wakeup-time 'queries' of the scheduling + * state do not count. Another optimization we do: sched_yield()-ed + * processes are runnable (and thus will be considered for scheduling) + * right when they are calling schedule(). So the only place we need + * to care about SCHED_YIELD is when we calculate the previous process' + * goodness ... + */ +static inline int prev_goodness (struct task_struct * prev, + struct task_struct * p, int this_cpu) +{ + if (p->policy & SCHED_YIELD) { + p->policy &= ~SCHED_YIELD; + return 0; + } + return goodness(prev, p, this_cpu); +} + +/* + * the 'goodness value' of replacing a process on a given CPU. + * positive value means 'replace', zero or negative means 'dont'. + */ +static inline int preemption_goodness (struct task_struct * prev, + struct task_struct * p, int cpu) { + return goodness(prev, p, cpu) - goodness(prev, prev, cpu); +} + +/* + * If there is a dependency between p1 and p2, + * don't be too eager to go into the slow schedule. + * In particular, if p1 and p2 both want the kernel + * lock, there is no point in trying to make them + * extremely parallel.. + * + * (No lock - lock_depth < 0) + * + * There are two additional metrics here: + * + * first, a 'cutoff' interval, currently 0-200 usecs on + * x86 CPUs, depending on the size of the 'SMP-local cache'. + * If the current process has longer average timeslices than + * this, then we utilize the idle CPU. + * + * second, if the wakeup comes from a process context, + * then the two processes are 'related'. (they form a + * 'gang') + * + * An idle CPU is almost always a bad thing, thus we skip + * the idle-CPU utilization only if both these conditions + * are true. (ie. a 'process-gang' rescheduling with rather + * high frequency should stay on the same CPU). + * + * [We can switch to something more finegrained in 2.3.] + * + * do not 'guess' if the to-be-scheduled task is RT. + */ +#define related(p1,p2) (((p1)->lock_depth >= 0) && (p2)->lock_depth >= 0) && \ + (((p2)->policy == SCHED_OTHER) && ((p1)->avg_slice < cacheflush_time)) + +static inline void reschedule_idle_slow(struct task_struct * p) +{ +#ifdef __SMP__ /* * (see reschedule_idle() for an explanation first ...) * @@ -124,60 +267,71 @@ * 2.3. Also we can try to use the avg_slice value to predict * 'likely reschedule' events even on other CPUs.] */ - int best_cpu = p->processor, this_cpu = smp_processor_id(); - struct task_struct **idle = task, *tsk, *target_tsk; - int i = smp_num_cpus; + int this_cpu = smp_processor_id(), target_cpu; + struct task_struct *tsk, *target_tsk; + int cpu, best_cpu, weight, best_weight, i; + unsigned long flags; + + best_weight = 0; /* prevents negative weight */ + + spin_lock_irqsave(&runqueue_lock, flags); + + /* + * shortcut if the woken up task's last CPU is + * idle now. + */ + best_cpu = p->processor; + target_tsk = idle_task(best_cpu); + if (cpu_curr(best_cpu) == target_tsk) + goto send_now; target_tsk = NULL; - do { - tsk = *idle; - idle++; - if (tsk->has_cpu) { - if (tsk->processor == this_cpu) - continue; + for (i = 0; i < smp_num_cpus; i++) { + cpu = cpu_logical_map(i); + tsk = cpu_curr(cpu); + if (related(tsk, p)) + goto out_no_target; + weight = preemption_goodness(tsk, p, cpu); + if (weight > best_weight) { + best_weight = weight; target_tsk = tsk; - if (tsk->processor == best_cpu) { - /* - * bingo, we couldnt get a better - * CPU, activate it. - */ - goto send; /* this one helps GCC ... */ - } } - } while (--i > 0); + } /* - * found any idle CPU? + * found any suitable CPU? */ - if (target_tsk) { -send: - target_tsk->need_resched = 1; - smp_send_reschedule(target_tsk->processor); - return; - } + if (!target_tsk) + goto out_no_target; + +send_now: + target_cpu = target_tsk->processor; + target_tsk->need_resched = 1; + spin_unlock_irqrestore(&runqueue_lock, flags); + /* + * the APIC stuff can go outside of the lock because + * it uses no task information, only CPU#. + */ + if (target_cpu != this_cpu) + smp_send_reschedule(target_cpu); + return; +out_no_target: + spin_unlock_irqrestore(&runqueue_lock, flags); + return; +#else /* UP */ + int this_cpu = smp_processor_id(); + struct task_struct *tsk; + + tsk = cpu_curr(this_cpu); + if (preemption_goodness(tsk, p, this_cpu) > 0) + tsk->need_resched = 1; +#endif } -#endif /* __SMP__ */ -/* - * If there is a dependency between p1 and p2, - * don't be too eager to go into the slow schedule. - * In particular, if p1 and p2 both want the kernel - * lock, there is no point in trying to make them - * extremely parallel.. - * - * (No lock - lock_depth < 0) - */ -#define related(p1,p2) ((p1)->lock_depth >= 0 && (p2)->lock_depth >= 0) - -static inline void reschedule_idle(struct task_struct * p) +static void reschedule_idle(struct task_struct * p) { - - if (p->policy != SCHED_OTHER || p->counter > current->counter + 3) { - current->need_resched = 1; - return; - } - #ifdef __SMP__ + int cpu = smp_processor_id(); /* * ("wakeup()" should not be called before we've initialized * SMP completely. @@ -187,35 +341,20 @@ * * SMP rescheduling is done in 2 passes: * - pass #1: faster: 'quick decisions' - * - pass #2: slower: 'lets try and find another CPU' + * - pass #2: slower: 'lets try and find a suitable CPU' */ /* - * Pass #1 - * - * There are two metrics here: - * - * first, a 'cutoff' interval, currently 0-200 usecs on - * x86 CPUs, depending on the size of the 'SMP-local cache'. - * If the current process has longer average timeslices than - * this, then we utilize the idle CPU. - * - * second, if the wakeup comes from a process context, - * then the two processes are 'related'. (they form a - * 'gang') - * - * An idle CPU is almost always a bad thing, thus we skip - * the idle-CPU utilization only if both these conditions - * are true. (ie. a 'process-gang' rescheduling with rather - * high frequency should stay on the same CPU). - * - * [We can switch to something more finegrained in 2.3.] + * Pass #1. (subtle. We might be in the middle of __switch_to, so + * to preserve scheduling atomicity we have to use cpu_curr) */ - if ((current->avg_slice < cacheflush_time) && related(current, p)) + if ((p->processor == cpu) && related(cpu_curr(cpu), p)) return; - - reschedule_idle_slow(p); #endif /* __SMP__ */ + /* + * Pass #2 + */ + reschedule_idle_slow(p); } /* @@ -291,7 +430,6 @@ * The run-queue lock locks the parts that actually access * and change the run-queues, and have to be interrupt-safe. */ -spinlock_t scheduler_lock = SPIN_LOCK_UNLOCKED; /* should be acquired first */ spinlock_t runqueue_lock = SPIN_LOCK_UNLOCKED; /* second */ rwlock_t tasklist_lock = RW_LOCK_UNLOCKED; /* third */ @@ -307,12 +445,19 @@ { unsigned long flags; + /* + * We want the common case fall through straight, thus the goto. + */ spin_lock_irqsave(&runqueue_lock, flags); p->state = TASK_RUNNING; - if (!p->next_run) { - add_to_runqueue(p); - reschedule_idle(p); - } + if (p->next_run) + goto out; + add_to_runqueue(p); + spin_unlock_irqrestore(&runqueue_lock, flags); + + reschedule_idle(p); + return; +out: spin_unlock_irqrestore(&runqueue_lock, flags); } @@ -324,63 +469,6 @@ } /* - * This is the function that decides how desirable a process is.. - * You can weigh different processes against each other depending - * on what CPU they've run on lately etc to try to handle cache - * and TLB miss penalties. - * - * Return values: - * -1000: never select this - * 0: out of time, recalculate counters (but it might still be - * selected) - * +ve: "goodness" value (the larger, the better) - * +1000: realtime process, select this. - */ -static inline int goodness(struct task_struct * p, struct task_struct * prev, int this_cpu) -{ - int policy = p->policy; - int weight; - - if (policy & SCHED_YIELD) { - p->policy = policy & ~SCHED_YIELD; - return 0; - } - - /* - * Realtime process, select the first one on the - * runqueue (taking priorities within processes - * into account). - */ - if (policy != SCHED_OTHER) - return 1000 + p->rt_priority; - - /* - * Give the process a first-approximation goodness value - * according to the number of clock-ticks it has left. - * - * Don't do any other calculations if the time slice is - * over.. - */ - weight = p->counter; - if (weight) { - -#ifdef __SMP__ - /* Give a largish advantage to the same processor... */ - /* (this is equivalent to penalizing other processors) */ - if (p->processor == this_cpu) - weight += PROC_CHANGE_PENALTY; -#endif - - /* .. and a slight advantage to the current thread */ - if (p->mm == prev->mm) - weight += 1; - weight += p->priority; - } - - return weight; -} - -/* * Event timer code */ #define TVN_BITS 6 @@ -513,18 +601,6 @@ return ret; } -#ifdef __SMP__ - -#define idle_task (task[cpu_number_map[this_cpu]]) -#define can_schedule(p) (!(p)->has_cpu) - -#else - -#define idle_task (&init_task) -#define can_schedule(p) (1) - -#endif - signed long schedule_timeout(signed long timeout) { struct timer_list timer; @@ -577,62 +653,25 @@ } /* - * This one aligns per-CPU data on cacheline boundaries. + * schedule_tail() is getting called from the fork return path. This + * cleans up all remaining scheduler things, without impacting the + * common case. */ -static union { - struct schedule_data { - struct task_struct * prev; - long prevstate; - cycles_t last_schedule; - } schedule_data; - char __pad [SMP_CACHE_BYTES]; -} aligned_data [NR_CPUS] __cacheline_aligned = { {{&init_task,0}}}; - - -static inline void __schedule_tail (void) +static inline void __schedule_tail (struct task_struct *prev) { #ifdef __SMP__ - struct schedule_data * sched_data; - - /* - * We might have switched CPUs: - */ - sched_data = & aligned_data[smp_processor_id()].schedule_data; - - /* - * Subtle. In the rare event that we got a wakeup to 'prev' just - * during the reschedule (this is possible, the scheduler is pretty - * parallel), we should do another reschedule in the next task's - * context. schedule() will do the right thing next time around. - * this is equivalent to 'delaying' the wakeup until the reschedule - * has finished. - */ - if (sched_data->prev->state != sched_data->prevstate) - current->need_resched = 1; - - /* - * Release the previous process ... - * - * We have dropped all locks, and we must make sure that we - * only mark the previous process as no longer having a CPU - * after all other state has been seen by other CPU's. Thus - * the write memory barrier! - */ + if ((prev->state == TASK_RUNNING) && + (prev != idle_task(smp_processor_id()))) + reschedule_idle(prev); wmb(); - sched_data->prev->has_cpu = 0; + prev->has_cpu = 0; #endif /* __SMP__ */ } -/* - * schedule_tail() is getting called from the fork return path. This - * cleans up all remaining scheduler things, without impacting the - * common case. - */ -void schedule_tail (void) +void schedule_tail (struct task_struct *prev) { - __schedule_tail(); + __schedule_tail(prev); } - /* * 'schedule()' is the scheduler function. It's a very simple and nice * scheduler: it's not perfect, but certainly works for most things. @@ -646,37 +685,38 @@ asmlinkage void schedule(void) { struct schedule_data * sched_data; - struct task_struct * prev, * next; - int this_cpu; + struct task_struct *prev, *next, *p; + int this_cpu, c; - run_task_queue(&tq_scheduler); + if (tq_scheduler) + goto handle_tq_scheduler; +tq_scheduler_back: prev = current; this_cpu = prev->processor; - /* - * 'sched_data' is protected by the fact that we can run - * only one process per CPU. - */ - sched_data = & aligned_data[this_cpu].schedule_data; if (in_interrupt()) goto scheduling_in_interrupt; + release_kernel_lock(prev, this_cpu); /* Do "administrative" work here while we don't hold any locks */ - if (bh_active & bh_mask) - do_bottom_half(); + if (bh_mask & bh_active) + goto handle_bh; +handle_bh_back: + + /* + * 'sched_data' is protected by the fact that we can run + * only one process per CPU. + */ + sched_data = & aligned_data[this_cpu].schedule_data; - spin_lock(&scheduler_lock); spin_lock_irq(&runqueue_lock); /* move an exhausted RR process to be last.. */ - prev->need_resched = 0; - - if (!prev->counter && prev->policy == SCHED_RR) { - prev->counter = prev->priority; - move_last_runqueue(prev); - } + if (prev->policy == SCHED_RR) + goto move_rr_last; +move_rr_back: switch (prev->state) { case TASK_INTERRUPTIBLE: @@ -688,62 +728,72 @@ del_from_runqueue(prev); case TASK_RUNNING: } + prev->need_resched = 0; - sched_data->prevstate = prev->state; +repeat_schedule: -/* this is the scheduler proper: */ - { - struct task_struct * p = init_task.next_run; - int c = -1000; + /* + * this is the scheduler proper: + */ - /* Default process to select.. */ - next = idle_task; - if (prev->state == TASK_RUNNING) { - c = goodness(prev, prev, this_cpu); - next = prev; - } + p = init_task.next_run; + /* Default process to select.. */ + next = idle_task(this_cpu); + c = -1000; + if (prev->state == TASK_RUNNING) + goto still_running; +still_running_back: - /* - * This is subtle. - * Note how we can enable interrupts here, even - * though interrupts can add processes to the run- - * queue. This is because any new processes will - * be added to the front of the queue, so "p" above - * is a safe starting point. - * run-queue deletion and re-ordering is protected by - * the scheduler lock - */ - spin_unlock_irq(&runqueue_lock); + /* + * This is subtle. + * Note how we can enable interrupts here, even + * though interrupts can add processes to the run- + * queue. This is because any new processes will + * be added to the front of the queue, so "p" above + * is a safe starting point. + * run-queue deletion and re-ordering is protected by + * the scheduler lock + */ /* * Note! there may appear new tasks on the run-queue during this, as * interrupts are enabled. However, they will be put on front of the * list, so our list starting at "p" is essentially fixed. */ - while (p != &init_task) { - if (can_schedule(p)) { - int weight = goodness(p, prev, this_cpu); - if (weight > c) - c = weight, next = p; - } - p = p->next_run; - } - - /* Do we need to re-calculate counters? */ - if (!c) { - struct task_struct *p; - read_lock(&tasklist_lock); - for_each_task(p) - p->counter = (p->counter >> 1) + p->priority; - read_unlock(&tasklist_lock); + while (p != &init_task) { + if (can_schedule(p)) { + int weight = goodness(prev, p, this_cpu); + if (weight > c) + c = weight, next = p; } + p = p->next_run; } + /* Do we need to re-calculate counters? */ + if (!c) + goto recalculate; + /* + * from this point on nothing can prevent us from + * switching to the next task, save this fact in + * sched_data. + */ + sched_data->curr = next; +#ifdef __SMP__ + next->has_cpu = 1; + next->processor = this_cpu; +#endif + spin_unlock_irq(&runqueue_lock); + + if (prev == next) + goto same_process; + +#ifdef __SMP__ /* * maintain the per-process 'average timeslice' value. * (this has to be recalculated even if we reschedule to - * the same process) Currently this is only used on SMP: + * the same process) Currently this is only used on SMP, + * and it's approximate, so we do not have to maintain + * it while holding the runqueue spinlock. */ -#ifdef __SMP__ { cycles_t t, this_slice; @@ -752,10 +802,11 @@ sched_data->last_schedule = t; /* - * Simple, exponentially fading average calculation: + * Exponentially fading average calculation, with + * some weight so it doesnt get fooled easily by + * smaller irregularities. */ - prev->avg_slice = this_slice + prev->avg_slice; - prev->avg_slice >>= 1; + prev->avg_slice = (this_slice*1 + prev->avg_slice*1)/2; } /* @@ -763,27 +814,55 @@ * thus we have to lock the previous process from getting * rescheduled during switch_to(). */ - next->processor = this_cpu; - next->has_cpu = 1; - spin_unlock(&scheduler_lock); + #endif /* __SMP__ */ - if (prev != next) { -#ifdef __SMP__ - sched_data->prev = prev; -#endif - kstat.context_swtch++; - get_mmu_context(next); - switch_to(prev,next); - __schedule_tail(); - } + kstat.context_swtch++; + get_mmu_context(next); + switch_to(prev, next, prev); + schedule_tail(prev); + +same_process: reacquire_kernel_lock(current); return; +recalculate: + { + struct task_struct *p; + spin_unlock_irq(&runqueue_lock); + read_lock(&tasklist_lock); + for_each_task(p) + p->counter = (p->counter >> 1) + p->priority; + read_unlock(&tasklist_lock); + spin_lock_irq(&runqueue_lock); + goto repeat_schedule; + } + +still_running: + c = prev_goodness(prev, prev, this_cpu); + next = prev; + goto still_running_back; + +handle_bh: + do_bottom_half(); + goto handle_bh_back; + +handle_tq_scheduler: + run_task_queue(&tq_scheduler); + goto tq_scheduler_back; + +move_rr_last: + if (!prev->counter) { + prev->counter = prev->priority; + move_last_runqueue(prev); + } + goto move_rr_back; + scheduling_in_interrupt: printk("Scheduling in interrupt\n"); *(int *)0 = 0; + return; } rwlock_t waitqueue_lock = RW_LOCK_UNLOCKED; @@ -798,21 +877,42 @@ */ void __wake_up(struct wait_queue **q, unsigned int mode) { - struct wait_queue *next; + struct task_struct *p; + struct wait_queue *head, *next; + + if (!q) + goto out; + /* + * this is safe to be done before the check because it + * means no deference, just pointer operations. + */ + head = WAIT_QUEUE_HEAD(q); read_lock(&waitqueue_lock); - if (q && (next = *q)) { - struct wait_queue *head; + next = *q; + if (!next) + goto out_unlock; - head = WAIT_QUEUE_HEAD(q); - while (next != head) { - struct task_struct *p = next->task; - next = next->next; - if (p->state & mode) + while (next != head) { + p = next->task; + next = next->next; + if (p->state & mode) { + /* + * We can drop the read-lock early if this + * is the only/last process. + */ + if (next == head) { + read_unlock(&waitqueue_lock); wake_up_process(p); + goto out; + } + wake_up_process(p); } } +out_unlock: read_unlock(&waitqueue_lock); +out: + return; } /* @@ -942,14 +1042,14 @@ #define SLEEP_ON_HEAD \ wait.task = current; \ - write_lock_irqsave(&waitqueue_lock, flags); \ + write_lock_irqsave(&waitqueue_lock,flags); \ __add_wait_queue(p, &wait); \ write_unlock(&waitqueue_lock); #define SLEEP_ON_TAIL \ write_lock_irq(&waitqueue_lock); \ __remove_wait_queue(p, &wait); \ - write_unlock_irqrestore(&waitqueue_lock, flags); + write_unlock_irqrestore(&waitqueue_lock,flags); void interruptible_sleep_on(struct wait_queue **p) { @@ -1623,7 +1723,6 @@ /* * We play safe to avoid deadlocks. */ - spin_lock(&scheduler_lock); spin_lock_irq(&runqueue_lock); read_lock(&tasklist_lock); @@ -1671,7 +1770,6 @@ out_unlock: read_unlock(&tasklist_lock); spin_unlock_irq(&runqueue_lock); - spin_unlock(&scheduler_lock); out_nounlock: return retval; @@ -1746,14 +1844,12 @@ asmlinkage int sys_sched_yield(void) { - spin_lock(&scheduler_lock); spin_lock_irq(&runqueue_lock); if (current->policy == SCHED_OTHER) current->policy |= SCHED_YIELD; current->need_resched = 1; move_last_runqueue(current); spin_unlock_irq(&runqueue_lock); - spin_unlock(&scheduler_lock); return 0; } @@ -1930,11 +2026,22 @@ read_unlock(&tasklist_lock); } +void __init init_idle(void) +{ + cycles_t t; + struct schedule_data * sched_data; + sched_data = &aligned_data[smp_processor_id()].schedule_data; + + t = get_cycles(); + sched_data->curr = current; + sched_data->last_schedule = t; +} + void __init sched_init(void) { /* - * We have to do a little magic to get the first - * process right in SMP mode. + * We have to do a little magic to get the first + * process right in SMP mode. */ int cpu=hard_smp_processor_id(); int nr = NR_TASKS; diff -u --recursive --new-file v2.2.7/linux/kernel/signal.c linux/kernel/signal.c --- v2.2.7/linux/kernel/signal.c Mon Mar 29 11:09:12 1999 +++ linux/kernel/signal.c Sun May 2 12:23:54 1999 @@ -265,7 +265,7 @@ && ((sig != SIGCONT) || (current->session != t->session)) && (current->euid ^ t->suid) && (current->euid ^ t->uid) && (current->uid ^ t->suid) && (current->uid ^ t->uid) - && !capable(CAP_SYS_ADMIN)) + && !capable(CAP_KILL)) goto out_nolock; /* The null signal is a permissions and process existance probe. diff -u --recursive --new-file v2.2.7/linux/mm/filemap.c linux/mm/filemap.c --- v2.2.7/linux/mm/filemap.c Tue Mar 23 14:35:48 1999 +++ linux/mm/filemap.c Thu Apr 29 15:07:58 1999 @@ -34,12 +34,6 @@ unsigned long page_cache_size = 0; struct page * page_hash_table[PAGE_HASH_SIZE]; -/* - * Simple routines for both non-shared and shared mappings. - */ - -#define release_page(page) __free_page((page)) - /* * Define a request structure for outstanding page write requests * to the background page io daemon @@ -83,7 +77,7 @@ page->prev = NULL; remove_page_from_hash_queue(page); page->inode = NULL; - __free_page(page); + page_cache_release(page); continue; } } @@ -115,15 +109,15 @@ page->prev = NULL; remove_page_from_hash_queue(page); page->inode = NULL; - __free_page(page); + page_cache_release(page); continue; } p = &page->next; offset = start - offset; /* partial truncate, clear end of page */ - if (offset < PAGE_SIZE) { + if (offset < PAGE_CACHE_SIZE) { unsigned long address = page_address(page); - memset((void *) (offset + address), 0, PAGE_SIZE - offset); + memset((void *) (offset + address), 0, PAGE_CACHE_SIZE - offset); flush_page_to_ram(address); } } @@ -136,7 +130,7 @@ { remove_page_from_hash_queue(page); remove_page_from_inode_queue(page); - __free_page(page); + page_cache_release(page); } int shrink_mmap(int priority, int gfp_mask) @@ -226,9 +220,9 @@ { unsigned long offset, len; - offset = (pos & ~PAGE_MASK); - pos = pos & PAGE_MASK; - len = PAGE_SIZE - offset; + offset = (pos & ~PAGE_CACHE_MASK); + pos = pos & PAGE_CACHE_MASK; + len = PAGE_CACHE_SIZE - offset; do { struct page * page; @@ -238,13 +232,13 @@ if (page) { wait_on_page(page); memcpy((void *) (offset + page_address(page)), buf, len); - release_page(page); + page_cache_release(page); } count -= len; buf += len; - len = PAGE_SIZE; + len = PAGE_CACHE_SIZE; offset = 0; - pos += PAGE_SIZE; + pos += PAGE_CACHE_SIZE; } while (count); } @@ -271,10 +265,10 @@ struct page * page; struct page ** hash; - offset &= PAGE_MASK; + offset &= PAGE_CACHE_MASK; switch (page_cache) { case 0: - page_cache = __get_free_page(GFP_USER); + page_cache = page_cache_alloc(); if (!page_cache) break; default: @@ -286,12 +280,12 @@ /* * Ok, add the new page to the hash-queues... */ - page = mem_map + MAP_NR(page_cache); + page = page_cache_entry(page_cache); add_to_page_cache(page, inode, offset, hash); inode->i_op->readpage(file, page); page_cache = 0; } - release_page(page); + page_cache_release(page); } return page_cache; } @@ -413,7 +407,7 @@ * performances. * Reasonable means, in this context, not too large but not too small. * The actual maximum value is: - * MAX_READAHEAD + PAGE_SIZE = 76k is CONFIG_READA_SMALL is undefined + * MAX_READAHEAD + PAGE_CACHE_SIZE = 76k is CONFIG_READA_SMALL is undefined * and 32K if defined (4K page size assumed). * * Asynchronous read-ahead benefits: @@ -440,7 +434,7 @@ * ONE seems to be the only reasonable value. * - The total memory pool usage for the file access stream. * This maximum memory usage is implicitly 2 IO read chunks: - * 2*(MAX_READAHEAD + PAGE_SIZE) = 156K if CONFIG_READA_SMALL is undefined, + * 2*(MAX_READAHEAD + PAGE_CACHE_SIZE) = 156K if CONFIG_READA_SMALL is undefined, * 64k if defined (4K page size assumed). */ @@ -459,7 +453,7 @@ unsigned long raend; int max_readahead = get_max_readahead(inode); - raend = filp->f_raend & PAGE_MASK; + raend = filp->f_raend & PAGE_CACHE_MASK; max_ahead = 0; /* @@ -476,7 +470,7 @@ if (raend < inode->i_size) max_ahead = filp->f_ramax; filp->f_rawin = 0; - filp->f_ralen = PAGE_SIZE; + filp->f_ralen = PAGE_CACHE_SIZE; if (!max_ahead) { filp->f_raend = ppos + filp->f_ralen; filp->f_rawin += filp->f_ralen; @@ -491,17 +485,17 @@ * it is the moment to try to read ahead asynchronously. * We will later force unplug device in order to force asynchronous read IO. */ - else if (reada_ok && filp->f_ramax && raend >= PAGE_SIZE && + else if (reada_ok && filp->f_ramax && raend >= PAGE_CACHE_SIZE && ppos <= raend && ppos + filp->f_ralen >= raend) { /* * Add ONE page to max_ahead in order to try to have about the same IO max size - * as synchronous read-ahead (MAX_READAHEAD + 1)*PAGE_SIZE. + * as synchronous read-ahead (MAX_READAHEAD + 1)*PAGE_CACHE_SIZE. * Compute the position of the last page we have tried to read in order to * begin to read ahead just at the next page. */ - raend -= PAGE_SIZE; + raend -= PAGE_CACHE_SIZE; if (raend < inode->i_size) - max_ahead = filp->f_ramax + PAGE_SIZE; + max_ahead = filp->f_ramax + PAGE_CACHE_SIZE; if (max_ahead) { filp->f_rawin = filp->f_ralen; @@ -516,7 +510,7 @@ */ ahead = 0; while (ahead < max_ahead) { - ahead += PAGE_SIZE; + ahead += PAGE_CACHE_SIZE; page_cache = try_to_read_ahead(filp, raend + ahead, page_cache); } @@ -538,7 +532,7 @@ filp->f_ralen += ahead; filp->f_rawin += filp->f_ralen; - filp->f_raend = raend + ahead + PAGE_SIZE; + filp->f_raend = raend + ahead + PAGE_CACHE_SIZE; filp->f_ramax += filp->f_ramax; @@ -590,7 +584,7 @@ page_cache = 0; pos = *ppos; - pgpos = pos & PAGE_MASK; + pgpos = pos & PAGE_CACHE_MASK; /* * If the current position is outside the previous read-ahead window, * we reset the current read-ahead context and set read ahead max to zero @@ -614,12 +608,12 @@ * Then, at least MIN_READAHEAD if read ahead is ok, * and at most MAX_READAHEAD in all cases. */ - if (pos + desc->count <= (PAGE_SIZE >> 1)) { + if (pos + desc->count <= (PAGE_CACHE_SIZE >> 1)) { filp->f_ramax = 0; } else { unsigned long needed; - needed = ((pos + desc->count) & PAGE_MASK) - pgpos; + needed = ((pos + desc->count) & PAGE_CACHE_MASK) - pgpos; if (filp->f_ramax < needed) filp->f_ramax = needed; @@ -639,8 +633,8 @@ /* * Try to find the data in the page cache.. */ - hash = page_hash(inode, pos & PAGE_MASK); - page = __find_page(inode, pos & PAGE_MASK, *hash); + hash = page_hash(inode, pos & PAGE_CACHE_MASK); + page = __find_page(inode, pos & PAGE_CACHE_MASK, *hash); if (!page) goto no_cached_page; @@ -653,7 +647,7 @@ * the page has been rewritten. */ if (PageUptodate(page) || PageLocked(page)) - page_cache = generic_file_readahead(reada_ok, filp, inode, pos & PAGE_MASK, page, page_cache); + page_cache = generic_file_readahead(reada_ok, filp, inode, pos & PAGE_CACHE_MASK, page, page_cache); else if (reada_ok && filp->f_ramax > MIN_READAHEAD) filp->f_ramax = MIN_READAHEAD; @@ -670,8 +664,8 @@ { unsigned long offset, nr; - offset = pos & ~PAGE_MASK; - nr = PAGE_SIZE - offset; + offset = pos & ~PAGE_CACHE_MASK; + nr = PAGE_CACHE_SIZE - offset; if (nr > inode->i_size - pos) nr = inode->i_size - pos; @@ -684,7 +678,7 @@ */ nr = actor(desc, (const char *) (page_address(page) + offset), nr); pos += nr; - release_page(page); + page_cache_release(page); if (nr && desc->count) continue; break; @@ -696,7 +690,7 @@ * page.. */ if (!page_cache) { - page_cache = __get_free_page(GFP_USER); + page_cache = page_cache_alloc(); /* * That could have slept, so go around to the * very beginning.. @@ -710,9 +704,9 @@ /* * Ok, add the new page to the hash-queues... */ - page = mem_map + MAP_NR(page_cache); + page = page_cache_entry(page_cache); page_cache = 0; - add_to_page_cache(page, inode, pos & PAGE_MASK, hash); + add_to_page_cache(page, inode, pos & PAGE_CACHE_MASK, hash); /* * Error handling is tricky. If we get a read error, @@ -737,7 +731,7 @@ if (!error) goto found_page; desc->error = error; - release_page(page); + page_cache_release(page); break; } @@ -756,7 +750,7 @@ error = -EIO; /* Some unspecified error occurred.. */ } desc->error = error; - release_page(page); + page_cache_release(page); break; } } @@ -764,7 +758,7 @@ *ppos = pos; filp->f_reada = 1; if (page_cache) - free_page(page_cache); + page_cache_free(page_cache); UPDATE_ATIME(inode); } @@ -943,7 +937,7 @@ unsigned long old_page, new_page; new_page = 0; - offset = (address & PAGE_MASK) - area->vm_start + area->vm_offset; + offset = (address - area->vm_start + area->vm_offset) & PAGE_MASK; if (offset >= inode->i_size && (area->vm_flags & VM_SHARED) && area->vm_mm == current->mm) goto no_page; @@ -962,7 +956,7 @@ * extra page -- better to overlap the allocation with the I/O. */ if (no_share && !new_page) { - new_page = __get_free_page(GFP_USER); + new_page = page_cache_alloc(); if (!new_page) goto failure; } @@ -984,7 +978,7 @@ * of any potential extra pages. */ if (new_page) - free_page(new_page); + page_cache_free(new_page); flush_page_to_ram(old_page); return old_page; @@ -995,7 +989,7 @@ */ copy_page(new_page, old_page); flush_page_to_ram(new_page); - release_page(page); + page_cache_release(page); return new_page; no_cached_page: @@ -1003,14 +997,14 @@ * Try to read in an entire cluster at once. */ reada = offset; - reada >>= PAGE_SHIFT + page_cluster; - reada <<= PAGE_SHIFT + page_cluster; + reada >>= PAGE_CACHE_SHIFT + page_cluster; + reada <<= PAGE_CACHE_SHIFT + page_cluster; - for (i = 1 << page_cluster; i > 0; --i, reada += PAGE_SIZE) + for (i = 1 << page_cluster; i > 0; --i, reada += PAGE_CACHE_SIZE) new_page = try_to_read_ahead(file, reada, new_page); if (!new_page) - new_page = __get_free_page(GFP_USER); + new_page = page_cache_alloc(); if (!new_page) goto no_page; @@ -1027,7 +1021,7 @@ /* * Now, create a new page-cache page from the page we got */ - page = mem_map + MAP_NR(new_page); + page = page_cache_entry(new_page); new_page = 0; add_to_page_cache(page, inode, offset, hash); @@ -1061,9 +1055,9 @@ * mm layer so, possibly freeing the page cache page first. */ failure: - release_page(page); + page_cache_release(page); if (new_page) - free_page(new_page); + page_cache_free(new_page); no_page: return 0; } @@ -1166,7 +1160,7 @@ set_pte(ptep, pte_mkclean(pte)); flush_tlb_page(vma, address); page = pte_page(pte); - atomic_inc(&mem_map[MAP_NR(page)].count); + atomic_inc(&page_cache_entry(page)->count); } else { if (pte_none(pte)) return 0; @@ -1179,12 +1173,12 @@ } page = pte_page(pte); if (!pte_dirty(pte) || flags == MS_INVALIDATE) { - free_page(page); + page_cache_free(page); return 0; } } error = filemap_write_page(vma, address - vma->vm_start + vma->vm_offset, page, 1); - free_page(page); + page_cache_free(page); return error; } @@ -1492,9 +1486,9 @@ * Try to find the page in the cache. If it isn't there, * allocate a free page. */ - offset = (pos & ~PAGE_MASK); - pgpos = pos & PAGE_MASK; - bytes = PAGE_SIZE - offset; + offset = (pos & ~PAGE_CACHE_MASK); + pgpos = pos & PAGE_CACHE_MASK; + bytes = PAGE_CACHE_SIZE - offset; if (bytes > count) bytes = count; @@ -1502,13 +1496,13 @@ page = __find_page(inode, pgpos, *hash); if (!page) { if (!page_cache) { - page_cache = __get_free_page(GFP_USER); + page_cache = page_cache_alloc(); if (page_cache) continue; status = -ENOMEM; break; } - page = mem_map + MAP_NR(page_cache); + page = page_cache_entry(page_cache); add_to_page_cache(page, inode, pgpos, hash); page_cache = 0; } @@ -1530,7 +1524,7 @@ /* Mark it unlocked again and drop the page.. */ clear_bit(PG_locked, &page->flags); wake_up(&page->wait); - __free_page(page); + page_cache_release(page); if (status < 0) break; @@ -1545,7 +1539,7 @@ inode->i_size = pos; if (page_cache) - free_page(page_cache); + page_cache_free(page_cache); out: return written ? written : status; } @@ -1573,10 +1567,11 @@ if (!page) { if (!new) goto out; - page_cache = get_free_page(GFP_USER); + page_cache = page_cache_alloc(); if (!page_cache) goto out; - page = mem_map + MAP_NR(page_cache); + clear_page(page_cache); + page = page_cache_entry(page_cache); add_to_page_cache(page, inode, offset, hash); } if (atomic_read(&page->count) != 2) @@ -1596,7 +1591,7 @@ */ void put_cached_page(unsigned long addr) { - struct page * page = mem_map + MAP_NR(addr); + struct page * page = page_cache_entry(addr); if (!test_bit(PG_locked, &page->flags)) printk("put_cached_page: page not locked!\n"); @@ -1605,7 +1600,7 @@ atomic_read(&page->count)); clear_bit(PG_locked, &page->flags); wake_up(&page->wait); - __free_page(page); + page_cache_release(page); } @@ -1637,7 +1632,7 @@ { struct pio_request *p; - atomic_inc(&mem_map[MAP_NR(page)].count); + atomic_inc(&page_cache_entry(page)->count); /* * We need to allocate without causing any recursive IO in the @@ -1726,7 +1721,7 @@ (const char *) p->page, p->offset); up(&inode->i_sem); fput(p->file); - free_page(p->page); + page_cache_free(p->page); kmem_cache_free(pio_request_cache, p); } } diff -u --recursive --new-file v2.2.7/linux/mm/mmap.c linux/mm/mmap.c --- v2.2.7/linux/mm/mmap.c Fri Apr 16 14:47:31 1999 +++ linux/mm/mmap.c Tue May 4 15:44:38 1999 @@ -176,6 +176,9 @@ struct vm_area_struct * vma; int error; + if (file && (!file->f_op || !file->f_op->mmap)) + return -ENODEV; + if ((len = PAGE_ALIGN(len)) == 0) return addr; @@ -244,9 +247,6 @@ * specific mapper. the address has already been validated, but * not unmapped, but the maps are removed from the list. */ - if (file && (!file->f_op || !file->f_op->mmap)) - return -ENODEV; - vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); if (!vma) return -ENOMEM; diff -u --recursive --new-file v2.2.7/linux/mm/page_alloc.c linux/mm/page_alloc.c --- v2.2.7/linux/mm/page_alloc.c Wed Apr 28 11:37:32 1999 +++ linux/mm/page_alloc.c Thu May 6 14:32:06 1999 @@ -419,12 +419,12 @@ return; } - /* The page is unshared, and we want write access. In this - case, it is safe to tear down the swap cache and give the - page over entirely to this process. */ - - if (PageSwapCache(page_map)) - delete_from_swap_cache(page_map); + /* + * The page is unshared and we're going to dirty it - so tear + * down the swap cache and give exclusive access to the page to + * this process. + */ + delete_from_swap_cache(page_map); set_pte(page_table, pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)))); return; } diff -u --recursive --new-file v2.2.7/linux/net/core/sock.c linux/net/core/sock.c --- v2.2.7/linux/net/core/sock.c Mon Mar 29 11:09:12 1999 +++ linux/net/core/sock.c Sun May 2 12:23:54 1999 @@ -944,7 +944,7 @@ */ if (current->pgrp != -arg && current->pid != arg && - !capable(CAP_NET_ADMIN)) return(-EPERM); + !capable(CAP_KILL)) return(-EPERM); sk->proc = arg; return(0); case F_GETOWN: diff -u --recursive --new-file v2.2.7/linux/net/irda/ircomm/ircomm_common.c linux/net/irda/ircomm/ircomm_common.c --- v2.2.7/linux/net/irda/ircomm/ircomm_common.c Wed Apr 28 11:37:32 1999 +++ linux/net/irda/ircomm/ircomm_common.c Thu May 6 16:40:53 1999 @@ -147,13 +147,7 @@ }; #ifdef CONFIG_PROC_FS -extern struct proc_dir_entry proc_irda; -struct proc_dir_entry proc_ircomm = { - 0, 6, "ircomm", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, NULL, - &ircomm_proc_read, -}; +extern struct proc_dir_entry *proc_irda; #endif static void (*state[])( struct ircomm_cb *self, IRCOMM_EVENT event, @@ -229,7 +223,7 @@ */ #ifdef CONFIG_PROC_FS - proc_register( &proc_irda, &proc_ircomm); + create_proc_entry("ircomm", 0, proc_irda)->get_info = ircomm_proc_read; #endif /* CONFIG_PROC_FS */ @@ -267,7 +261,7 @@ } #ifdef CONFIG_PROC_FS - proc_unregister( &proc_irda, proc_ircomm.low_ino); + remove_proc_entry("ircomm", proc_irda); #endif /* CONFIG_PROC_FS */ } #endif /* MODULE */ diff -u --recursive --new-file v2.2.7/linux/net/irda/irlan/irlan_common.c linux/net/irda/irlan/irlan_common.c --- v2.2.7/linux/net/irda/irlan/irlan_common.c Wed Apr 28 11:37:32 1999 +++ linux/net/irda/irlan/irlan_common.c Thu May 6 16:40:53 1999 @@ -99,15 +99,8 @@ static int irlan_proc_read(char *buf, char **start, off_t offset, int len, int unused); -extern struct proc_dir_entry proc_irda; - -struct proc_dir_entry proc_irlan = { - 0, 5, "irlan", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, NULL, - &irlan_proc_read, -}; -#endif /* CONFIG_PROC_FS */ +extern struct proc_dir_entry *proc_irda; +#endif void irlan_watchdog_timer_expired(unsigned long data) { @@ -188,7 +181,7 @@ return -ENOMEM; } #ifdef CONFIG_PROC_FS - proc_register(&proc_irda, &proc_irlan); + create_proc_entry("irlan", 0, proc_irda)->get_info = irlan_proc_read; #endif /* CONFIG_PROC_FS */ DEBUG(4, __FUNCTION__ "()\n"); @@ -224,7 +217,7 @@ irlmp_unregister_service(skey); #ifdef CONFIG_PROC_FS - proc_unregister(&proc_irda, proc_irlan.low_ino); + remove_proc_entry("irlan", proc_irda); #endif /* CONFIG_PROC_FS */ /* * Delete hashbin and close all irlan client instances in it diff -u --recursive --new-file v2.2.7/linux/net/irda/irlpt/irlpt_cli.c linux/net/irda/irlpt/irlpt_cli.c --- v2.2.7/linux/net/irda/irlpt/irlpt_cli.c Wed Apr 28 11:37:32 1999 +++ linux/net/irda/irlpt/irlpt_cli.c Thu May 6 16:40:53 1999 @@ -157,14 +157,7 @@ return len; } -struct proc_dir_entry proc_irlpt_client = { - 0, 12, "irlpt_client", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, NULL /* ops -- default to array */, - &irlpt_client_proc_read /* get_info */, -}; - -extern struct proc_dir_entry proc_irda; +extern struct proc_dir_entry *proc_irda; #endif /* CONFIG_PROC_FS */ @@ -193,7 +186,8 @@ NULL); #ifdef CONFIG_PROC_FS - proc_register( &proc_irda, &proc_irlpt_client); + create_proc_entry("irlpt_client", 0, proc_irda)->get_info + = irlpt_client_proc_read; #endif /* CONFIG_PROC_FS */ DEBUG( irlpt_client_debug, __FUNCTION__ " -->\n"); @@ -219,7 +213,7 @@ hashbin_delete( irlpt_clients, (FREE_FUNC) irlpt_client_close); #ifdef CONFIG_PROC_FS - proc_unregister( &proc_irda, proc_irlpt_client.low_ino); + remove_proc_entry("irlpt_client", proc_irda); #endif DEBUG( irlpt_client_debug, __FUNCTION__ " -->\n"); diff -u --recursive --new-file v2.2.7/linux/net/irda/irlpt/irlpt_srvr.c linux/net/irda/irlpt/irlpt_srvr.c --- v2.2.7/linux/net/irda/irlpt/irlpt_srvr.c Fri Apr 16 14:47:31 1999 +++ linux/net/irda/irlpt/irlpt_srvr.c Thu May 6 16:40:53 1999 @@ -160,14 +160,7 @@ return len; } -extern struct proc_dir_entry proc_irda; - -struct proc_dir_entry proc_irlpt_server = { - 0, 12, "irlpt_server", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, NULL /* ops -- default to array */, - &irlpt_server_proc_read /* get_info */, -}; +extern struct proc_dir_entry *proc_irda; #endif /* CONFIG_PROC_FS */ @@ -215,7 +208,8 @@ register_irlpt_server(); #ifdef CONFIG_PROC_FS - proc_register( &proc_irda, &proc_irlpt_server); + create_proc_entry("irlpt_server", 0, proc_irda)->get_info + = irlpt_server_proc_read; #endif /* CONFIG_PROC_FS */ DEBUG( irlpt_server_debug, __FUNCTION__ " -->\n"); @@ -248,7 +242,7 @@ kfree(irlpt_server); #ifdef CONFIG_PROC_FS - proc_unregister( &proc_irda, proc_irlpt_server.low_ino); + remove_proc_entry("irlpt_server", proc_irda); #endif DEBUG( irlpt_server_debug, __FUNCTION__ " -->\n"); diff -u --recursive --new-file v2.2.7/linux/net/irda/irproc.c linux/net/irda/irproc.c --- v2.2.7/linux/net/irda/irproc.c Fri Apr 16 14:47:31 1999 +++ linux/net/irda/irproc.c Thu May 6 16:40:53 1999 @@ -32,11 +32,6 @@ #include #include -static int proc_irda_lookup(struct inode * dir, struct dentry *dentry); - -static int proc_irda_readdir(struct file *filp, void *dirent, - filldir_t filldir); - extern int irda_device_proc_read(char *buf, char **start, off_t offset, int len, int unused); extern int irlap_proc_read(char *buf, char **start, off_t offset, int len, @@ -50,9 +45,6 @@ extern int discovery_proc_read(char *buf, char **start, off_t offset, int len, int unused); -static int proc_discovery_read(char *buf, char **start, off_t offset, int len, - int unused); - enum irda_directory_inos { PROC_IRDA_LAP = 1, PROC_IRDA_LMP, @@ -63,121 +55,26 @@ PROC_IRDA_IRIAS }; -static struct file_operations proc_irda_dir_operations = { - NULL, /* lseek - default */ - NULL, /* read - bad */ - NULL, /* write - bad */ - proc_irda_readdir, /* readdir */ - NULL, /* select - default */ - NULL, /* ioctl - default */ - NULL, /* mmap */ - NULL, /* no special open code */ - NULL, /* no special release code */ - NULL /* can't fsync */ -}; - -/* - * proc directories can do almost nothing.. - */ -struct inode_operations proc_irda_dir_inode_operations = { - &proc_irda_dir_operations, /* default net directory file-ops */ - NULL, /* create */ - proc_irda_lookup, - NULL, /* link */ - NULL, /* unlink */ - NULL, /* symlink */ - NULL, /* mkdir */ - NULL, /* rmdir */ - NULL, /* mknod */ - NULL, /* rename */ - NULL, /* readlink */ - NULL, /* follow_link */ - NULL, /* readpage */ - NULL, /* writepage */ - NULL, /* bmap */ - NULL, /* truncate */ - NULL /* permission */ +struct irda_entry { + char *name; + int (*fn)(char*,char**,off_t,int,int); }; -struct proc_dir_entry proc_irda = { - 0, 4, "irda", - S_IFDIR | S_IRUGO | S_IXUGO, 2, 0, 0, - 0, &proc_irda_dir_inode_operations, - NULL, NULL, - NULL, - NULL, NULL -}; +struct proc_dir_entry *proc_irda; +static irda_entry dir[] = { #if 0 -struct proc_dir_entry proc_lpt = { - 0, 3, "lpt", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, NULL /* ops -- default to array */, - &irlpt_proc_read /* get_info */, -}; + {"lpt", irlpt_proc_read}, #endif - -struct proc_dir_entry proc_discovery = { - 0, 9, "discovery", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, NULL /* ops -- default to array */, - &discovery_proc_read /* get_info */, + {"discovery", discovery_proc_read}, + {"irda_device", irda_device_proc_read}, + {"irttp", irttp_proc_read}, + {"irlmp", irlmp_proc_read}, + {"irlap", irlap_proc_read}, + {"irias", irias_proc_read}, }; -struct proc_dir_entry proc_irda_device = { - 0, 11, "irda_device", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, NULL, - &irda_device_proc_read, -}; - -struct proc_dir_entry proc_ttp = { - 0, 5, "irttp", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, NULL /* ops -- default to array */, - &irttp_proc_read /* get_info */, -}; - -struct proc_dir_entry proc_lmp = { - 0, 5, "irlmp", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, NULL /* ops -- default to array */, - &irlmp_proc_read /* get_info */, -}; - -struct proc_dir_entry proc_lap = { - 0, 5, "irlap", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, NULL /* ops -- default to array */, - &irlap_proc_read /* get_info */, -}; - -struct proc_dir_entry proc_ias = { - 0, 5, "irias", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, NULL /* ops -- default to array */, - &irias_proc_read /* get_info */, -}; - -/* - * Function proc_delete_dentry (dentry) - * - * Copy of proc/root.c because this function is invisible to the irda - * module - * - */ -static void proc_delete_dentry(struct dentry * dentry) -{ - d_drop(dentry); -} - -static struct dentry_operations proc_dentry_operations = -{ - NULL, /* revalidate */ - NULL, /* d_hash */ - NULL, /* d_compare */ - proc_delete_dentry /* d_delete(struct dentry *) */ -}; +#define IRDA_ENTRIES_NUM (sizeof(dir)/sizeof(dir[0])) /* * Function irda_proc_register (void) @@ -186,16 +83,13 @@ * */ void irda_proc_register(void) { - proc_net_register(&proc_irda); + int i; + proc_irda = create_proc_entry("net/irda", S_IFDIR, NULL); #ifdef MODULE - proc_irda.fill_inode = &irda_proc_modcount; + proc_irda->fill_inode = &irda_proc_modcount; #endif /* MODULE */ - proc_register(&proc_irda, &proc_lap); - proc_register(&proc_irda, &proc_lmp); - proc_register(&proc_irda, &proc_ttp); - proc_register(&proc_irda, &proc_ias); - proc_register(&proc_irda, &proc_irda_device); - proc_register(&proc_irda, &proc_discovery); + for (i=0;iget_info=dir[i].fn; } /* @@ -205,116 +99,8 @@ * */ void irda_proc_unregister(void) { - proc_unregister(&proc_irda, proc_discovery.low_ino); - proc_unregister(&proc_irda, proc_irda_device.low_ino); - proc_unregister(&proc_irda, proc_ias.low_ino); - proc_unregister(&proc_irda, proc_ttp.low_ino); - proc_unregister(&proc_irda, proc_lmp.low_ino); - proc_unregister(&proc_irda, proc_lap.low_ino); - proc_unregister(proc_net, proc_irda.low_ino); -} - -/* - * Function proc_irda_lookup (dir, dentry) - * - * This is a copy of proc_lookup from the linux-2.2.x kernel - * - */ -int proc_irda_lookup(struct inode * dir, struct dentry *dentry) -{ - struct inode *inode; - struct proc_dir_entry * de; - int error; - - error = -ENOTDIR; - if (!dir || !S_ISDIR(dir->i_mode)) - goto out; - - error = -ENOENT; - inode = NULL; - de = (struct proc_dir_entry *) dir->u.generic_ip; - if (de) { - for (de = de->subdir; de ; de = de->next) { - if (!de || !de->low_ino) - continue; - if (de->namelen != dentry->d_name.len) - continue; - if (!memcmp(dentry->d_name.name, de->name, de->namelen)) { - int ino = de->low_ino | (dir->i_ino & ~(0xffff)); - error = -EINVAL; - inode = proc_get_inode(dir->i_sb, ino, de); - break; - } - } - } - - if (inode) { - dentry->d_op = &proc_dentry_operations; - d_add(dentry, inode); - error = 0; - } -out: - return error; -} - -/* - * Function proc_irda_readdir (filp, dirent, filldir) - * - * This is a copy from linux/fs/proc because the function is invisible - * to the irda module - * - */ -static int proc_irda_readdir(struct file *filp, void *dirent, - filldir_t filldir) -{ - struct proc_dir_entry * de; - unsigned int ino; int i; - - struct inode *inode = filp->f_dentry->d_inode; - if (!inode || !S_ISDIR(inode->i_mode)) - return -ENOTDIR; - ino = inode->i_ino; - de = (struct proc_dir_entry *) inode->u.generic_ip; - if (!de) - return -EINVAL; - i = filp->f_pos; - switch (i) { - case 0: - if (filldir(dirent, ".", 1, i, ino) < 0) - return 0; - i++; - filp->f_pos++; - /* fall through */ - case 1: - if (filldir(dirent, "..", 2, i, de->parent->low_ino) < 0) - return 0; - i++; - filp->f_pos++; - /* fall through */ - default: - ino &= ~0xffff; - de = de->subdir; - i -= 2; - for (;;) { - if (!de) - return 1; - if (!i) - break; - de = de->next; - i--; - } - - do { - if (filldir(dirent, de->name, de->namelen, filp->f_pos, - ino | de->low_ino) < 0) - return 0; - filp->f_pos++; - de = de->next; - } while (de); - } - return 1; + for (i=0;itk_flags |= RPC_TASK_RUNNING; if (RPC_IS_ASYNC(task)) { int status; status = rpc_add_wait_queue(&schedq, task); @@ -186,7 +187,6 @@ } else { wake_up(&task->tk_wait); } - task->tk_flags |= RPC_TASK_RUNNING; } @@ -447,7 +447,10 @@ task->tk_pid); if (current->pid == rpciod_pid) printk(KERN_ERR "RPC: rpciod waiting on sync task!\n"); - sleep_on(&task->tk_wait); + + sti(); + __wait_event(task->tk_wait, RPC_IS_RUNNING(task)); + cli(); /* * When the task received a signal, remove from diff -u --recursive --new-file v2.2.7/linux/net/sunrpc/svcsock.c linux/net/sunrpc/svcsock.c --- v2.2.7/linux/net/sunrpc/svcsock.c Tue Mar 23 14:35:48 1999 +++ linux/net/sunrpc/svcsock.c Tue May 4 10:29:07 1999 @@ -249,7 +249,8 @@ msg.msg_namelen = sizeof(rqstp->rq_addr); msg.msg_iov = iov; msg.msg_iovlen = nr; - msg.msg_control = 0; + msg.msg_control = NULL; + msg.msg_controllen = 0; #if LINUX_VERSION_CODE >= 0x020100 msg.msg_flags = MSG_DONTWAIT; @@ -308,7 +309,8 @@ msg.msg_namelen = sizeof(rqstp->rq_addr); msg.msg_iov = iov; msg.msg_iovlen = nr; - msg.msg_control = 0; + msg.msg_control = NULL; + msg.msg_controllen = 0; #if LINUX_VERSION_CODE >= 0x020100 msg.msg_flags = MSG_DONTWAIT; diff -u --recursive --new-file v2.2.7/linux/net/sunrpc/xprt.c linux/net/sunrpc/xprt.c --- v2.2.7/linux/net/sunrpc/xprt.c Tue Mar 23 14:35:48 1999 +++ linux/net/sunrpc/xprt.c Tue May 4 10:29:07 1999 @@ -200,6 +200,7 @@ msg.msg_name = (struct sockaddr *) &xprt->addr; msg.msg_namelen = sizeof(xprt->addr); msg.msg_control = NULL; + msg.msg_controllen = 0; /* Dont repeat bytes */ @@ -256,6 +257,7 @@ msg.msg_name = &sin; msg.msg_namelen = sizeof(sin); msg.msg_control = NULL; + msg.msg_controllen = 0; oldfs = get_fs(); set_fs(get_ds()); result = sock_recvmsg(sock, &msg, len, MSG_DONTWAIT); @@ -268,6 +270,7 @@ msg.msg_name = &sin; msg.msg_namelen = sizeof(sin); msg.msg_control = NULL; + msg.msg_controllen = 0; oldfs = get_fs(); set_fs(get_ds()); result = sock->ops->recvmsg(sock, &msg, len, 1, 0, &alen); diff -u --recursive --new-file v2.2.7/linux/scripts/Menuconfig linux/scripts/Menuconfig --- v2.2.7/linux/scripts/Menuconfig Tue Feb 23 15:21:36 1999 +++ linux/scripts/Menuconfig Sun May 2 09:51:16 1999 @@ -193,7 +193,7 @@ else if [ "$3" = "m" ]; then mod_bool "$1" "$2" else - define_bool "$2" "$n" + define_bool "$2" n fi; fi } diff -u --recursive --new-file v2.2.7/linux/scripts/tkgen.c linux/scripts/tkgen.c --- v2.2.7/linux/scripts/tkgen.c Tue Feb 23 15:21:36 1999 +++ linux/scripts/tkgen.c Sun May 2 09:51:16 1999 @@ -930,8 +930,11 @@ case token_hex: case token_int: + printf( "set %s %s\n", cfg->optionname, cfg->value ? cfg->value : "0"); + break; + case token_string: - printf( "set %s %s\n", cfg->optionname, cfg->value ); + printf( "set %s \"%s\"\n", cfg->optionname, cfg->value ? cfg->value : ""); break; } } diff -u --recursive --new-file v2.2.7/linux/scripts/tkparse.c linux/scripts/tkparse.c --- v2.2.7/linux/scripts/tkparse.c Tue Feb 23 15:21:36 1999 +++ linux/scripts/tkparse.c Sun May 2 09:51:16 1999 @@ -496,10 +496,15 @@ case token_hex: case token_int: - case token_string: pnt = get_qstring ( pnt, &cfg->label ); pnt = get_string ( pnt, &cfg->optionname ); pnt = get_string ( pnt, &cfg->value ); + break; + + case token_string: + pnt = get_qstring ( pnt, &cfg->label ); + pnt = get_string ( pnt, &cfg->optionname ); + pnt = get_qstring ( pnt, &cfg->value ); break; case token_if: